fix: update ARG variable handling#665
Merged
patrickhoefler merged 2 commits intomainfrom May 23, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Enhance ARG variable substitution in Dockerfile conversion, streamline constant usage, and add tests to cover nested and unresolved ARG scenarios.
- Introduce
ArgReplacementslices with resolution helpers (appendAndResolveArgReplacement,stripRemainingArgPatterns) - Define constants for Dockerfile instructions and precompile regex patterns
- Add tests for nested ARG substitution and ARG referencing before definition
- Update linter config to enable
ineffassignandstaticcheck
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/dockerfile2dot/convert.go | Switch to slice-based ARG resolution, add constants, regex, helpers |
| internal/dockerfile2dot/convert_test.go | Add test cases for nested and unresolved ARG variable substitution |
| .golangci.yaml | Enable additional linters (ineffassign, staticcheck) |
Comments suppressed due to low confidence (3)
internal/dockerfile2dot/convert.go:75
- The comment has a typo/grammar issue: 'set is at the name' should be 'set it as the name'.
// If there is an "AS" alias, set is at the name
internal/dockerfile2dot/convert_test.go:315
- Consider adding a test case for a stage-specific ARG (defined after the first FROM) to verify that the implementation correctly ignores or handles stage-scoped ARG variables.
args: args{
internal/dockerfile2dot/convert.go:217
- [nitpick] The function name 'appendAndResolveArgReplacement' is quite long; consider renaming to something more concise like 'resolveAndAppendArg' for readability.
func appendAndResolveArgReplacement(
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.
This pull request introduces enhancements focusing on improving ARG variable substitution, simplifying code, and adding new tests to ensure correctness. The changes include replacing the ARG substitution mechanism with a more robust approach, introducing constants for Dockerfile instructions, and adding test cases to validate nested and unresolved ARG scenarios.
Closes #664.