feat: add --env-file / -e flag for secret injection (Issue #23)#45
Merged
seanseannery merged 10 commits intomainfrom Mar 9, 2026
Merged
feat: add --env-file / -e flag for secret injection (Issue #23)#45seanseannery merged 10 commits intomainfrom
seanseannery merged 10 commits intomainfrom
Conversation
added 10 commits
March 9, 2026 15:52
…, default .ops_secrets.env
…ins priority, single-use flag, default .ops_secrets.env)
Add -e/--env-file flag to load variables from .env files with 6-level shell-wins priority chain. Default loads .ops_secrets.env if present.
…dir, error format, P3vsP5 priority, wrong-env scoped key, help text validation)
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.
Key Changes
-e/--env-file <path>flag loads secrets from a.env-format file at invocation time without committing them to the Opsfile or pre-exporting them in the shell.ops_secrets.envfrom the Opsfile directory when no-eflag is given (silent no-op if absent); explicit-ereplaces the default, not stacks with it--helpdocuments that-emust appear before positional arguments, and that--dry-runwill expose injected secret valuesWhy do we need this?
Opsfile variables are committed to the repo for non-sensitive config, but many operational commands require secrets (AWS tokens, DB passwords, API keys) that cannot be committed. Previously operators had to pre-export these manually in their shell session. This flag lets them point
opsat a.envfile at invocation time. Closes #23.New modules or other dependencies introduced
None.
internal/envfile_parser.goreuses the existingextractVariableValuehelper fromopsfile_parser.go. No external dependencies added.How was this tested?
ParseEnvFileunit tests: quoting (single/double), comments, blank lines, env-scoped keys, empty-name error, file-not-found, directory path, Windows\r\nline endings, exact error format-eshort/long/=syntax, duplicate flag error, missing arg error, combined with other flags,--helpoutput assertionsTestResolveVar_PriorityChain(p1–p6) plus boundary tests (env-file-scoped beats opsfile-unscoped, env-scoped key wrong-env).ops_secrets.envauto-load, silent-skip, and bypass-when-explicit tested incmd/opsintegration path