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

Docs to accommodate the deprecation of envTemplate's use of {{.IMAGE_NAME}} #4532

Merged
merged 4 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/content/en/docs/pipeline-stages/taggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,15 @@ process.

The following `build` section, for example, instructs Skaffold to build a
Docker image `gcr.io/k8s-skaffold/example` with the `envTemplate`
tag policy. The tag template is `{{.IMAGE_NAME}}:{{.FOO}}`; when Skaffold
tag policy. The tag template is `{{.FOO}}`; when Skaffold
finishes building the image, it will check the list of available environment
variables in the system for the variable `FOO`, and use its value to tag the
image.

{{< alert >}}
<b>Note</b><br>
<b>Deprecated</b><br>

`IMAGE_NAME` is a built-in variable whose value is the `imageName` field in
the `artifacts` part of the `build` section.
The use of `IMAGE_NAME` as a built-in variable whose value is the `imageName` field in the `artifacts` part of the `build` section has been deprecated. Please use the envTemplate to express solely the tag value for the image.
felixtran39 marked this conversation as resolved.
Show resolved Hide resolved
{{< /alert >}}

### Example
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/samples/taggers/envTemplate.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build:
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:{{.FOO}}"
template: "{{.FOO}}"
artifacts:
- image: gcr.io/k8s-skaffold/example
2 changes: 1 addition & 1 deletion docs/content/en/samples/templating/env.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build:
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:{{.FOO}}"
template: "{{.FOO}}"
artifacts:
- image: gcr.io/k8s-skaffold/example
6 changes: 3 additions & 3 deletions docs/content/en/schemas/v2beta6.json
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,10 @@
"properties": {
"template": {
"type": "string",
"description": "used to produce the image name and tag. See golang [text/template](https://golang.org/pkg/text/template/). The template is executed against the current environment, with those variables injected: IMAGE_NAME | Name of the image being built, as supplied in the artifacts section.",
"x-intellij-html-description": "used to produce the image name and tag. See golang <a href=\"https://golang.org/pkg/text/template/\">text/template</a>. The template is executed against the current environment, with those variables injected: IMAGE_NAME | Name of the image being built, as supplied in the artifacts section.",
"description": "used to produce the image name and tag. See golang [text/template](https://golang.org/pkg/text/template/). The template is executed against the current environment, with those variables injected.",
"x-intellij-html-description": "used to produce the image name and tag. See golang <a href=\"https://golang.org/pkg/text/template/\">text/template</a>. The template is executed against the current environment, with those variables injected.",
"examples": [
"{{.RELEASE}}-{{.IMAGE_NAME}}"
"{{.RELEASE}}"
]
}
},
Expand Down
7 changes: 3 additions & 4 deletions examples/tagging-with-environment-variables/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Example: using the envTemplate tag policy

This example reuses the image name and uses an environment variable `FOO` to tag the image.
This example uses an environment variable `FOO` to tag the image.
The way you configure it in `skaffold.yaml` is the following build stanza:

```yaml
Expand All @@ -9,9 +9,8 @@ build:
- image: skaffold-example
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:{{.FOO}}"
template: "{{.FOO}}"
```

1. define `tagPolicy` to be `envTemplate`
2. use [go templates](https://golang.org/pkg/text/template) syntax
3. The `IMAGE_NAME` variable is built-in and reuses the value defined in the artifacts' `image`.
2. use [go templates](https://golang.org/pkg/text/template) syntax
2 changes: 1 addition & 1 deletion examples/tagging-with-environment-variables/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
- image: skaffold-example
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:{{.FOO}}"
template: "{{.FOO}}"
deploy:
kubectl:
manifests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Example: using the envTemplate tag policy

This example reuses the image name and uses an environment variable `FOO` to tag the image.
This example uses an environment variable `FOO` to tag the image.
The way you configure it in `skaffold.yaml` is the following build stanza:

```yaml
Expand All @@ -9,9 +9,8 @@ build:
- image: skaffold-example
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:{{.FOO}}"
template: "{{.FOO}}"
```

1. define `tagPolicy` to be `envTemplate`
2. use [go templates](https://golang.org/pkg/text/template) syntax
3. The `IMAGE_NAME` variable is built-in and reuses the value defined in the artifacts' `image`.
2. use [go templates](https://golang.org/pkg/text/template) syntax
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
- image: skaffold-example
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:{{.FOO}}"
template: "{{.FOO}}"
deploy:
kubectl:
manifests:
Expand Down
2 changes: 0 additions & 2 deletions pkg/skaffold/build/tag/git_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@ func TestGitCommit_GenerateFullyQualifiedImageName(t *testing.T) {
for _, test := range tests {
test := test
testutil.Run(t, test.description, func(t *testutil.T) {
t.Parallel()

tmpDir := t.NewTempDir()
test.createGitRepo(tmpDir.Root())
workspace := tmpDir.Path(test.subDir)
Expand Down
5 changes: 2 additions & 3 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ type EnvTemplateTagger struct {
// Template used to produce the image name and tag.
// See golang [text/template](https://golang.org/pkg/text/template/).
// The template is executed against the current environment,
// with those variables injected:
// IMAGE_NAME | Name of the image being built, as supplied in the artifacts section.
// For example: `{{.RELEASE}}-{{.IMAGE_NAME}}`.
// with those variables injected.
// For example: `{{.RELEASE}}`.
Template string `yaml:"template,omitempty" yamltags:"required"`
}

Expand Down