-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
implement env variable expansion for kaniko builds #4557
implement env variable expansion for kaniko builds #4557
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4557 +/- ##
==========================================
- Coverage 72.36% 72.36% -0.01%
==========================================
Files 360 360
Lines 12474 12527 +53
==========================================
+ Hits 9027 9065 +38
- Misses 2789 2800 +11
- Partials 658 662 +4
Continue to review full report at Codecov.
|
e1271b7
to
9296c71
Compare
@tejal29 @gsquared94 it seems like some of the unit tests are flaky in the CI, but run flawless locally. Took me a few attempts to get the build to pass: https://github.com/GoogleContainerTools/skaffold/runs/907521989 Now I removed the dummy commit via force-push and the build status went from passing to failing without a rebuild. Do you have any ideas what I should do? |
1f537f4
to
9296c71
Compare
The Travis CI build is back to green. Thanks, in case anyone manually triggered the rebuild! |
@DanielSel sorry about the long time to reply; was traveling. I'd restarted the failed job manually, travis can be flaky that way sometimes. |
9296c71
to
1d54f66
Compare
I fixed the oversight in parsing image names (forgot the possibility of IP:PORT as registry url) and added a test. Thanks! |
1d54f66
to
0f9f51c
Compare
@gsquared94 one last kokoro run please :) |
pkg/skaffold/build/cluster/kaniko.go
Outdated
return generatedEnvs, nil | ||
} | ||
|
||
func parseImageParts(imageStr string) (string, string, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to use docker.ParseReference
here instead. we do this a few other places in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how I started out until I realized that docker.ParseReference
can't split out the image name from the repo path, which we need for our CI setup.
I could replace part of the function code with a call to docker.ParseReference
and only leave the code to split IMAGE_NAME from IMAGE_REPO if you prefer.
What do you think @nkubala ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I totally missed this one. I was actually wrong on my original comment, we're using docker's (reference.Parse
)[https://godoc.org/github.com/docker/distribution/reference#Parse] in skaffold. we finesse that into a ImageReference
struct which should be able to split image name and repo path (we call it Domain
) right?
if it isn't doing everything you need, I think that code should live somewhere near here so we can embed those pieces into the ImageReference
struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nkubala no worries. I'm not sure that it would make sense to refactor the ImageReference to change the way it splits image FQDN's since I assume there was a reason for this specific split.
However, I refactored my code to use docker.ParseReference (which returns the ImageReference you pointed out) instead of implementing it from scratch. Was that what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @DanielSel, I dug in a little more into ParseReference
and how it creates the ImageReference
. take the image gcr.io/k8s-skaffold/skaffold:foo
as an example:
BaseName -> gcr.io/k8s-skaffold/skaffold
Domain -> gcr.io
Path -> k8s-skaffold/skaffold
the part you're interested in here is the "Repo", which would be gcr.io/k8s-skaffold
. I think part of the confusion is that our terminology is not quite right here: BaseName
is really "Unqualified Image Name" (to me at least), which is also "Repo" + "Image Name" (both of which are missing from this struct).
I propose that you take your logic here to split the image parts (which seems mostly fine to me as is) and move it into docker.ParseReference
, and then embed "Repo" and "Image Name" into the ImageReference
struct we already have. this won't change the existing usage of the struct around the codebase, but could be used later on if we wanted to, and is easier to find if we ever want to make changes to it. this isn't kaniko-specific logic, so it doesn't really belong in the kaniko package. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I think) I got you now :)
Code updated.
d08e704
to
bc5dbc2
Compare
@tejal29 I took the freedom to rebase, I hope that's ok. Could somebody trigger another kokoro run and make a decision about the requested changes please? This pull request is starting to gather dust :) |
bc5dbc2
to
640f41f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielSel thank you so much for sticking with us here, this is very close but I just want to make sure we put the code in the right place the first time so we don't have to move it later :)
pkg/skaffold/build/cluster/kaniko.go
Outdated
return generatedEnvs, nil | ||
} | ||
|
||
func parseImageParts(imageStr string) (string, string, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @DanielSel, I dug in a little more into ParseReference
and how it creates the ImageReference
. take the image gcr.io/k8s-skaffold/skaffold:foo
as an example:
BaseName -> gcr.io/k8s-skaffold/skaffold
Domain -> gcr.io
Path -> k8s-skaffold/skaffold
the part you're interested in here is the "Repo", which would be gcr.io/k8s-skaffold
. I think part of the confusion is that our terminology is not quite right here: BaseName
is really "Unqualified Image Name" (to me at least), which is also "Repo" + "Image Name" (both of which are missing from this struct).
I propose that you take your logic here to split the image parts (which seems mostly fine to me as is) and move it into docker.ParseReference
, and then embed "Repo" and "Image Name" into the ImageReference
struct we already have. this won't change the existing usage of the struct around the codebase, but could be used later on if we wanted to, and is easier to find if we ever want to make changes to it. this isn't kaniko-specific logic, so it doesn't really belong in the kaniko package. WDYT?
@DanielSel yep this is more what I was thinking! looks like the error you introduced in |
0393706
to
acdcf5f
Compare
@nkubala Sorry, my mistake. Fixed now. |
Hey @DanielSel, Thanks for continuously working on this! If you get the chance, would you be able to rebase and fix file conflicts? We should be able to merge this in after that :) |
…not set explicitly). resolves GoogleContainerTools#3229
7bc0be7
to
2d0bdb7
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Done! @MarlonGamez |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielSel thanks for all your hard work on this PR, and sticking with us to see it through!
Adds environment variable expansion for kaniko builds (to address currently inconsistent behaviour between buildArgs and envs).
See #3974