refactor: consolidate guard policy env var names into constants, replace os.Getenv with envutil#5546
Merged
Merged
Conversation
5 tasks
Copilot
AI
changed the title
[WIP] Fix duplicate environment variable reads in guard policy
refactor: consolidate guard policy env var names into constants, replace os.Getenv with envutil
May 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Consolidates guard-policy environment variable handling by introducing shared constants and standardizing lookups through envutil, reducing duplication and improving consistency across config parsing and CLI flag defaults.
Changes:
- Added
internal/configconstants for guard-policy env var names. - Updated guard policy override resolution to use
envutil.GetEnvString/Booland the new constants. - Updated DIFC flag defaults to reference the shared env var constants.
Show a summary per file
| File | Description |
|---|---|
| internal/config/guard_policy_parse.go | Uses shared env var constants and envutil helpers when resolving guard policy overrides from the environment. |
| internal/config/guard_policy_env.go | Introduces exported constants for guard-policy env var names as a single source of truth. |
| internal/cmd/flags_difc.go | Switches guard policy-related flag defaults to use config.Env* constants. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
This was referenced May 12, 2026
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.
✨ Enhancement
The five guard-policy env var names were duplicated as string literals across
flags_difc.goandguard_policy_parse.go, andguard_policy_parse.gomixed rawos.Getenvcalls withenvutil.GetEnvBool— inconsistent with the rest of the codebase.What does this improve?
envutil.GetEnvString/Boolusage throughout guard policy codeImplementation approach:
internal/config/guard_policy_env.go— five exported constants:guard_policy_parse.go— replacedos.Getenv(...)withenvutil.GetEnvString(Env..., ""), replaced string literals with constants, removed theosimportflags_difc.go— replaced string literals withconfig.EnvXxxconstants