Skip to content

feat: materialize secrets as files with file sinks - #9

Merged
bfirestone merged 34 commits into
mainfrom
feat/file-sink
Sep 4, 2026
Merged

bfirestone merged 34 commits into
mainfrom
feat/file-sink

Conversation

@bfirestone

Copy link
Copy Markdown
Contributor

Some secrets are consumed as files, not environment variables: SAML keypairs and IdP metadata, TLS certs, kubeconfigs. Developers had been hand-copying them from Secrets Manager into a gitignored directory inside the repo, where coding agents and indexers still read them.

A source can now declare a file: block. envctl run writes it into a fresh 0700 directory under $TMPDIR with mode 0600, exports the path through path_as, and removes the directory on every exit path, including a non-zero child exit and SIGINT. file.path opts into a persistent location, refused when it sits unignored inside a git worktree. envctl clean removes persistent sinks. Content never reaches stdout in any command.

Also moves the toolchain to Go 1.27.0 with a mise.toml.

Verify: mise exec -- go test ./..., then envctl validate against a config with a file: source and envctl run -- ls -l "$KEY_FILE".

golangci-lint 2.12.2 was built with Go 1.26 and refuses to lint a 1.27 module, so mise.toml pins 2.13.2 next to the toolchain. CI already reads the Go version from go.mod.
mockery's snakecase filename for RawReader would collide with the
hand-written raw_reader_mock.go and overwrite MockRawClient on the next run.
A SIGINT during secret fetch or file materialization used to kill envctl
before the deferred cleanup ran, leaking the 0700 run directory. runRun now
traps signals for the whole command, and materializeFiles zeros every
content buffer on exit instead of only on the success path.
@bfirestone

Copy link
Copy Markdown
Contributor Author

Added end-to-end tests in internal/cmd/e2e_test.go. TestMain re-execs the test binary as envctl with a JSON-fixture client installed through the existing newSecretsClient hook, so no test code ships in the release binary. Seven tests cover exit code propagation to the shell, a SIGINT delivered from outside the process with the run directory removed afterward, stdout isolation for env and validate, the persistent write then clean round trip, and refusal of an unignored path inside a git repo.

One test-only race surfaced on the way: sh defers a SIGINT that arrives while it waits on a foreground command, so both SIGINT tests now wait for a marker written after all setup commands finish.

The repo has no CI job running go test, filed as envctl-04qa.00yomn.

@bfirestone

Copy link
Copy Markdown
Contributor Author

CI is wired up and green: https://github.com/SentioLabs/envctl/actions/runs/33816135539

.github/workflows/ci.yml builds, vets and tests on ubuntu and macos with the toolchain from mise.toml (via jdx/mise-action@v4), and runs the full golangci-lint on pull requests. The first run exposed that the 1Password routing test needs the op CLI, which runners lack, so it now skips without it.

The lint job runs the whole module because the 96 pre-existing findings are fixed in this branch too, twelve behavior-neutral commits reviewed for output and state-transition parity in the TUI refactors. golangci-lint 2.13.2 is the current upstream release, so the pin stays.

@bfirestone
bfirestone merged commit c22a015 into main Sep 4, 2026
3 checks passed
@bfirestone
bfirestone deleted the feat/file-sink branch September 4, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant