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

ARG Command #162

Merged
merged 6 commits into from
May 11, 2018
Merged

ARG Command #162

merged 6 commits into from
May 11, 2018

Conversation

priyawadhwa
Copy link
Collaborator

Begins to fix #14

To implement ARG, I modified the code here. I also created a BuildArgs type and passed it in to every command along with the config. Then, in each command, we get a list of ARG variables that aren't already defined in config.Env, and add them as values that can be used for environment replacement.

I didn't add functionality for specifying ARGs before FROM and replacing environment variables in FROM since this PR was getting big, so I was thinking I'd add that after this one goes in.

@dlorenc
Copy link
Collaborator

dlorenc commented May 2, 2018

To implement ARG, I modified the code here. I also created a BuildArgs type and passed it in to every command along with the config. Then, in each command, we get a list of ARG variables that aren't already defined in config.Env, and add them as values that can be used for environment replacement.

Can you explain why you had to modify that code? It will be difficult to carry a modification to it long term, and the diff is a bit hard to read.

@priyawadhwa
Copy link
Collaborator Author

None of the buildargs methods are exported, so I pretty much just copied over the parts I needed. Not great but I couldn't think of a better way to do it...

@dlorenc
Copy link
Collaborator

dlorenc commented May 7, 2018

None of the buildargs methods are exported, so I pretty much just copied over the parts I needed. Not great but I couldn't think of a better way to do it...

View changes

Could you try sending a PR to that repo to get them exported publicly? If that doesn't work, we'll need to checkin a patch file here to automate the change.

@priyawadhwa
Copy link
Collaborator Author

For sure, it's exported now so I switched to vendoring it in.

The changes are still kind of hard to read, but basically I changed
ExecuteCommand(config *v1.Config)
to
ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs)
for all the commands, and then wrote ReplacementEnvs to get the combined ENV/ARG keys for substitution.

It should be RFAL now

logrus.Error(err)
os.Exit(1)
}
},
}

type buildArg []string
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: could you move this to another file in the same package?

@@ -33,15 +35,16 @@ type CopyCommand struct {
snapshotFiles []string
}

func (c *CopyCommand) ExecuteCommand(config *v1.Config) error {
func (c *CopyCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: it's generally a best practice to not expose types like dockerfile.BuildArgs that come from a package dependency. Could we wrap this type with one of our own, and pass that around everywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@priyawadhwa priyawadhwa merged commit ef191be into GoogleContainerTools:master May 11, 2018
@priyawadhwa priyawadhwa deleted the arg branch May 11, 2018 18:15
@priyawadhwa priyawadhwa added the area/dockerfile-command For all bugs related to dockerfile file commands label Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dockerfile-command For all bugs related to dockerfile file commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ARG command
3 participants