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

FR: ko builder to support envvars in labels config field #6916

Closed
halvards opened this issue Nov 29, 2021 · 0 comments · Fixed by #6944
Closed

FR: ko builder to support envvars in labels config field #6916

halvards opened this issue Nov 29, 2021 · 0 comments · Fixed by #6944

Comments

@halvards
Copy link
Contributor

Desired behavior

When using Skaffold to publish a "releaseable" container image in a CI build, users often want to add image labels with information such as release tag, git SHA, and more.

Example: https://github.com/google/k8s-digester/blob/main/.github/workflows/release.yml#L136

Current behavior

The ko builder labels config field doesn't support expansion of environment variables.

Design considerations

The flags and ldflags ko builder config fields support expansion of environment variables. However, this expansion is currently handled by the upstream ko implementation, which uses a slightly different syntax to other Skaffold config fields that support envvar expansion.

Skaffold: {{.FOO}}

ko: {{.Env.FOO}}

Would we accept different envvar handling and syntax for different fields within the same builder config?

Or should we consider moving envvar expansion of the flags and ldflags fields to Skaffold?

Tracking: #6041

@halvards halvards self-assigned this Nov 29, 2021
@aaron-prindle aaron-prindle added kind/todo implementation task/epic for the skaffold team kind/question User question kind/design discussion triage/discuss Items for discussion and removed kind/question User question kind/todo implementation task/epic for the skaffold team labels Nov 29, 2021
halvards added a commit to halvards/skaffold that referenced this issue Dec 7, 2021
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
halvards added a commit to halvards/skaffold that referenced this issue Dec 8, 2021
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
halvards added a commit to halvards/skaffold that referenced this issue Dec 9, 2021
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
tejal29 pushed a commit that referenced this issue Dec 13, 2021
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 #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: #6041
Fixes: #6916
@MarlonGamez MarlonGamez removed the triage/discuss Items for discussion label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants