GoogleContainerTools / GoogleContainerTools/skaffold
Support templating in build.artifacts.*.image
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
### Expected behavior
I'm trying to create a `skaffold.yaml` config to be reused among multiple projects. Right now, the only blocker is inability to set `build.artifacts.image` via a template variable, like so:
```yaml
apiVersion: skaffold/v2beta28
kind: Config
build:
artifacts:
- image: &name "{{.PROJECT}}"
jib:
project: *name
deploy:
helm:
releases:
- name: *name
chartPath: helm
artifactOverrides:
image: *name
```
which _could_ work from a project directory using something like
```bash
PROJECT=$(basename $PWD) skaffold dev -f ../skaffold.yaml
```
### Actual behavior
Instead, since template variables are not understood in `build.artifacts.*.image`, we have to either
1) hard-code the image name and thus have a separate copy of `skaffold.yaml` for each individual project, or
2) use an external template substitution tool, for example `envsubst` or `gomplate` to pre-process `skaffold.yaml`, like so:
```bash
PROJECT=$(basename $PWD) envsubst <../skaffold.yaml | skaffold dev -f -
```
Otherwise, Skaffold complains with a message like `invalid image "{{.PROJECT}}": invalid reference format`.
We _cannot_ use `--default-repo` with a generic `image` for this use case either, since other values in the template depend on the image name and must be unique per-project (and they don't support `{{.IMAGE_NAME}}` either).
### Information
- Skaffold version: `v1.38.0`
- Operating system: `MacOS 12.4`
- Installed via: Homebrew Google Cloud SDK
- Contents of skaffold.yaml: please see above
### Steps to reproduce the behavior
1. Create a Skaffold config similar to the above, with template variables in `build.artifacts.*.image`
2. Use any Skaffold command with it
3. Observe that template variables are not understood in `build.artifacts.*.image`
Contributor guide
Assessment
This issue has not been assessed yet.