Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile ARG parsing #103

Merged
merged 1 commit into from
Mar 11, 2024
Merged

Fix Dockerfile ARG parsing #103

merged 1 commit into from
Mar 11, 2024

Conversation

aaronlehmann
Copy link
Collaborator

Double quotes weren't handled while evaluating ARG statements in the Dockerfile.

Fixes #78

Double quotes weren't handled while evaluating ARG statements in the
Dockerfile.
@aaronlehmann aaronlehmann requested a review from kylecarbs March 8, 2024 04:43
imageRef = strings.TrimPrefix(line, "FROM ")
if imageRef == "" {
if fromArgs, ok := strings.CutPrefix(line, "FROM "); ok {
imageRef = fromArgs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we strings.TrimSpace(fromArgs), I saw another issue with FROM image<space> being mis-parsed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, n/m I see it in your tests, looks good

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's trimmed on this line below:

	image, err := name.ParseReference(strings.TrimSpace(imageRef))

I also added a unit test case for this.

@aaronlehmann aaronlehmann merged commit 8d3cfdf into main Mar 11, 2024
1 check passed
@aaronlehmann aaronlehmann deleted the arg-parsing branch March 11, 2024 21:34
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.

Dockerfile ARG replacement doesnt remove quotes from strings
3 participants