fix: centralize environment variable expansion at config boundary#2710
Open
yunus25jmi1 wants to merge 2 commits intodocker:mainfrom
Open
fix: centralize environment variable expansion at config boundary#2710yunus25jmi1 wants to merge 2 commits intodocker:mainfrom
yunus25jmi1 wants to merge 2 commits intodocker:mainfrom
Conversation
Implement Layered Expansion: Layer 1 (Universal POSIX/JS syntax normalization) and Layer 2 (JS expressions). Add reflection-based Config walker to expand all fields during loading. Normalize ${env.VAR} to ${VAR} across all configuration fields. Improve error reporting for missing environment variables. Fixes docker#2615
a09ecd7 to
3b35cf0
Compare
Member
|
/review |
Member
|
/review |
Contributor
Author
|
@dgageot I am currently working on this PR. I am facing some GO environment system-level configuration problems. I will make a comment when my PR is in good shape. |
|
❌ PR Review Failed — The review agent encountered an error and could not complete the review. View logs. |
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.
Root Cause
Fragmented expansion logic across the codebase caused incompatibility between syntaxes (
$VARvs${env.VAR}) and silent failures. Path fields only supported POSIX style, while command fields used a JS-based expander that often ignored standard environment variables or failed silently.Solution: Layered Expansion Architecture
Implemented a robust two-layer expansion pipeline at the configuration boundary:
Layer 1: Universal Expansion (Config Loading Phase)
$VAR,${VAR},${env.VAR}) into a standard form.pkg/config/expand.go) to visit and expand every exported string field, slice, and map in the configuration immediately after unmarshaling.ErrMissingVarsinstead of silent partial expansion.Layer 2: Dynamic JS Expressions (Runtime Phase)
pkg/js/expand.go) by removing redundant environment handling.${tool(...)}), as environment variables are guaranteed to be resolved by Layer 1.Key Changes
os.Expand.Loadpipeline.Sourceinterface to carryEnvProvidercontext.Impact
$VAR,${VAR}, and${env.VAR}in all string-based config fields (working_dir, commands, instruction, etc).Fixes #2615