Repository navigation
fix: edit the compose YAML in place when adding or removing the tunnel - #37
Merged
Merged
Conversation
Injecting the tunnel parsed the file into a typed model and wrote that back, which rewrote './secrets:/run/secrets:ro' as 'secrets:/run/secrets:ro' (a named volume), dropped volume options such as ':z', top-level secrets, configs and volume definitions, comments and flow-style lists. This also ran on every save of a tunneled app's compose file. Tunnel injection and removal now edit the YAML tree and touch only the tunnel service and the networks it needs. The lossy write path (MarshalComposeFile, InjectTunnelContainer, RemoveTunnelService, ExtractNetworks) is removed. Apps with no networks keep Compose's implicit default network. The old path wrote a top-level 'default' network named '_default'. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
Adding or removing the tunnel rewrote the user's whole compose file, and the rewrite changed what it meant.
./secrets:/run/secrets:robecamesecrets:/run/secrets:ro, which Compose reads as a named volume, so the container lost its bind mount. It ran on tunnel changes and on every save of a tunneled app's compose file.The tunnel code now edits the YAML in place and touches only its own service and the networks it needs.
Also fixed by this:
:zand other volume options, top-levelsecrets:/configs:, volume definitions (external,name), list-formcommand:, comments and flow-style lists are no longer dropped.networks: default: name: _default, so every such app shared one network called_default.Evidence
./secrets:/run/secrets:rocame out assecrets:/run/secrets:ro,./cfg:/cfg:zascfg:/cfg(reproduced with a throwaway test, since removed).After:
TestInjectTunnelKeepsEverythingElseInTheFileasserts the bind mounts, options, comments, secrets and volume specs survive injection unchanged, and compares every originalwebkey.network_modeservices left alone, quick-tunnel config, replacing an existing tunnel in place, removal, a nil container config, and invalid input.go build,go vetandgo test ./...pass on top of the latestmain.docker compose updeploy.Merge Danger
Door: two-way
Blast Radius: Moderate
./mounts by hand. This PR only stops new damage._default. Existing apps with an explicitdefaultnetwork keep using it.networks(those services are left alone, not attached to the tunnel's network).