Repository navigation
Fix config push when the gateway has no config directory - #51
Merged
Merged
Conversation
A gateway configured entirely by environment variables has no gateway.toml and no config directory — which is exactly how the punchd-gateway container instances run, with every setting passed as an env var and no volumes. The first push resolved a path under a directory that did not exist and the write failed with ENOENT. Creates the parent directory before writing.
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.
Second bug found while updating the live gateways, same area as #50.
The bug
A gateway configured purely by environment variables has no
gateway.tomland no config directory. The path resolves under$HOME/.keylessh/, which doesn't exist, so the first config push failed withNo such file or directory.Not a corner case — it's how all three
punchd-gatewaycontainer instances run.az container showreportsvolumes: null, with every setting (GATEWAY_ID,BACKENDS,API_SECRET,TIDECLOAK_CONFIG_B64, …) passed as an env var.The fix
Create the parent directory before writing.
Testing
47 gateway tests pass, one new: writing to a path whose parent doesn't exist creates it, and the config reads back.
Related caveat, not fixed here
Because those containers mount no volumes, a pushed
gateway.tomllives in the container's writable layer and is lost on restart, reverting to the env-var values. TOML takes precedence over env while the file exists, so pushes do work — they just aren't durable across a container recreate.Making them durable means mounting a volume for the config directory, which is a deployment change rather than a code one. Worth deciding before relying on push for those gateways.