refactor(mounts): extract host bind-mount logic into sandbox/mounts package - #44
Merged
Conversation
…ackage Refactors the mount subsystem introduced in #42 out of internal/sandbox/options into its own package, mirroring the internal/sandbox/network precedent. Decode now delegates shape parsing to mapstructure with a string->BindMount hook (fully lenient, no unknown-field rejection), leaving ResolveBindMounts as the validation layer. The managed mount-point constants (VMHomeDir, WorkspaceMountPath, TmpMountPath) move with the subsystem so the dependency direction stays options -> mounts. Also documents in AGENTS.md how to finalize a sandbox session.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
==========================================
- Coverage 88.80% 88.73% -0.07%
==========================================
Files 87 87
Lines 5314 5299 -15
==========================================
- Hits 4719 4702 -17
- Misses 413 414 +1
- Partials 182 183 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactors the mount subsystem introduced in #42 out of
internal/sandbox/optionsinto its owninternal/sandbox/mountspackage, mirroring the existinginternal/sandbox/networkprecedent for self-contained, domain-specific config types.Triggered by discussion on #42, the hand-rolled mount shape parser (
decodeMountswitch) is replaced with mapstructure decoding: astring -> BindMountdecode hook handles the short form (target: ~/.m2), andResolveBindMountsremains the validation layer (path existence,~expansion, target conflicts, duplicates). Decoding is fully lenient — unknown fields are ignored.The managed mount-point constants (
VMHomeDir,WorkspaceMountPath,TmpMountPath) move with the subsystem so the dependency direction staysoptions -> mounts, andoptionsno longer importsmapstructure.Why not decode via viper's
UnmarshalA note for reviewers: the
mountsmap is decoded fromv.Get("mounts")rather than throughviper.Unmarshalbecause viper flattens dotted guest paths (e.g./home/dev/.m2into nested keys), which would corrupt the map keys. This is documented on theConfig.Mountsfield.Checklist
make checkpasses (fmt, lint, test)