Skip to content

fix: consume dockerfile arguments when parsing the image #45

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

Merged
merged 3 commits into from
Jul 26, 2023
Merged

Conversation

kylecarbs
Copy link
Member

@kylecarbs kylecarbs commented Jul 26, 2023

Fixes #35.

@kylecarbs kylecarbs requested a review from coadler July 26, 2023 18:38
@kylecarbs kylecarbs self-assigned this Jul 26, 2023
@kylecarbs kylecarbs merged commit 82204fd into main Jul 26, 2023
@kylecarbs kylecarbs deleted the imagearg branch July 26, 2023 18:40
lines := strings.Split(dockerfileContent, "\n")
// Iterate over lines in reverse
for i := len(lines) - 1; i >= 0; i-- {
line := lines[i]
if !strings.HasPrefix(line, "FROM ") {
if strings.HasPrefix(line, "ARG ") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like technically leading whitespace is allowed. See "Note on whitespace" on https://docs.docker.com/engine/reference/builder/.

I'm not sure if multiple spaces (or tabs?) after ARG or FROM are permitted... but in case they are, tokenizing on whitespace might be a better way to do this.

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 when using ARG in FROM doesn't work
3 participants