-
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
feat(ko): Enable templating of labels
and env
#6944
feat(ko): Enable templating of labels
and env
#6944
Conversation
d586ccd
to
067e5f7
Compare
Codecov Report
@@ Coverage Diff @@
## main #6944 +/- ##
==========================================
- Coverage 70.48% 68.83% -1.66%
==========================================
Files 515 551 +36
Lines 23150 25324 +2174
==========================================
+ Hits 16317 17431 +1114
- Misses 5776 6716 +940
- Partials 1057 1177 +120
Continue to review full report at Codecov.
|
bo, err := buildOptions(&test.artifact, test.runMode) | ||
os.Setenv(testKoBuildOptionsEnvVar, test.envVarValue) | ||
gotBo, err := buildOptions(&test.artifact, test.runMode) | ||
os.Unsetenv(testKoBuildOptionsEnvVar) |
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.
lets call this in defer.
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.
Good point, done!
ArtifactType: latestV1.ArtifactType{ | ||
KoArtifact: &latestV1.KoArtifact{ | ||
Dir: "my-go-mod-is-here", | ||
envVarValue: "baz", |
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.
shd we add a test case for {{.Env.baz}}
here?
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.
Added.
This change enables `ko` builder users to substitute environment variable values in the `labels` and `env` config fields. These fields are used for image labels and build-time environment variables, respectively. Envvar templating of image labels can be used to add information such as the Git commit SHA to the image, see GoogleContainerTools#6916. Also, environment variable expansion of `flags` and `ldflags` in the `ko` builder configuration now supports Skaffold's templating syntax, for consistency. For backwards compatibility, `ko`'s templating syntax still works with `flags` and `ldflags`: Skaffold: `{{.FOO}}` `ko`: `{{.Env.FOO}}` Tracking: GoogleContainerTools#6041 Fixes: GoogleContainerTools#6916
067e5f7
to
fd5150f
Compare
This change enables
ko
builder users to substitute environment variable values in thelabels
andenv
config fields.These fields are used for image labels and build-time environment variables, respectively.
Envvar templating of image labels can be used to add information such as the Git commit SHA to the image, see #6916.
Also, environment variable expansion of
flags
andldflags
in theko
builder configuration now supports Skaffold's templating syntax, for consistency.For backwards compatibility,
ko
's templating syntax still works withflags
andldflags
:Skaffold:
{{.FOO}}
ko
:{{.Env.FOO}}
Tracking: #6041
Fixes: #6916