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

Allow build args in target image config #491

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pmengelbert
Copy link
Contributor

@pmengelbert pmengelbert commented Jan 6, 2025

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #490
Fixes #487

Special notes for your reviewer:

@pmengelbert pmengelbert requested a review from a team as a code owner January 6, 2025 17:45
Also fix implementation

Signed-off-by: Peter Engelbert <[email protected]>
img.Labels[k] = updated
}

if img.Post != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see why this would be necessary and would prefer to not support it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understandable. Not strictly necessary, just a little more convenient for certain things. If you don't agree with the rationale feel free to close

*p = updated
}

for i, s := range img.Env {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little hesitant support this here but not against it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍


func (img *ImageConfig) processBuildArgs(lex *shell.Lex, args map[string]string, allowArg func(string) bool) error {
var errs error
for _, p := range []*string{&img.Base, &img.Cmd, &img.User, &img.Entrypoint, &img.StopSignal, &img.WorkingDir} {
Copy link
Member

Choose a reason for hiding this comment

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

Likewise, I don't see why image base would need build args.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the very least I think it would be useful for the tag. Some repos do not have a latest tag, and not allowing a build arg here forces a hard-coded tag. I'm not married to the idea of introducing this, but it does seem useful.

Other uses could be not hard-coding a registry.

Copy link
Member

Choose a reason for hiding this comment

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

Not hard-coding a registry could be taken care of by source policies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think about tags?

Copy link
Member

Choose a reason for hiding this comment

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

I think I'd opt for explicitness in the spec in this case until someone actually asks for this.

@cpuguy83 cpuguy83 requested a review from MorrisLaw January 6, 2025 19:02
@@ -447,3 +453,57 @@ func (b *ArtifactBuild) processBuildArgs(lex *shell.Lex, args map[string]string,

return goerrors.Join(errs...)
}

func (img *ImageConfig) processBuildArgs(lex *shell.Lex, args map[string]string, allowArg func(string) bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Labels seems like a good candidate for build args. But why the other fields? Why not just limit support to Labels for now until there's a compelling use case/need for additional build arg support?

Note: I could be missing context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above, I think it could be useful for setting base image tags or registry host, particularly when the base image provider doesn't have a latest tag.

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.

[BUG] Build args are not substituted into image.base [REQ] image.labels should support arg substitution
3 participants