Skip to content

Commit

Permalink
feat(v2): remove deprecated "werf_image" Helm templates function
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Apr 24, 2024
1 parent 4782dc2 commit 8721568
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 60 deletions.
4 changes: 2 additions & 2 deletions cmd/werf/bundle/publish/publish_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
func GetBundlePublishDocs() structs.DocsStruct {
var docs structs.DocsStruct

docs.Long = `Publish bundle into the container registry. werf bundle contains built images defined in the werf.yaml, Helm chart, Service values which contain built images tags, any custom values and set values params provided during publish invocation, werf addon templates (like werf_image).
docs.Long = `Publish bundle into the container registry. werf bundle contains built images defined in the werf.yaml, Helm chart, Service values which contain built images tags, any custom values and set values params provided during publish invocation, werf addon templates.
Published into container registry bundle can be rolled out by the "werf bundle" command.`

docs.LongMD = "Publish bundle into the container registry. `werf bundle` contains built images defined " +
"in the `werf.yaml`, Helm chart, Service values which contain built images tags, any custom values " +
"and set values params provided during publish invocation, werf addon templates (like `werf_image`).\n\n" +
"and set values params provided during publish invocation, werf addon templates.\n\n" +
"Published into container registry bundle can be rolled out by the `werf bundle` command."

return docs
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/reference/cli/werf_bundle_publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% else %}
{% assign header = "###" %}
{% endif %}
Publish bundle into the container registry. `werf bundle` contains built images defined in the `werf.yaml`, Helm chart, Service values which contain built images tags, any custom values and set values params provided during publish invocation, werf addon templates (like `werf_image`).
Publish bundle into the container registry. `werf bundle` contains built images defined in the `werf.yaml`, Helm chart, Service values which contain built images tags, any custom values and set values params provided during publish invocation, werf addon templates.

Published into container registry bundle can be rolled out by the `werf bundle` command.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
- name: backend
workingDir: /app
command: [ "python3", "-m", "http.server", "8080" ]
image: {{ werf_image . }}
image: {{ $.Values.werf.image }}
livenessProbe:
httpGet:
path: /
Expand Down
1 change: 0 additions & 1 deletion pkg/deploy/helm/chart_extender/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func (bundle *Bundle) MakeValues(inputVals map[string]interface{}) (map[string]i
// SetupTemplateFuncs method for the chart.Extender interface
func (bundle *Bundle) SetupTemplateFuncs(t *template.Template, funcMap template.FuncMap) {
helpers.SetupIncludeWrapperFuncs(funcMap)
helpers.SetupWerfImageDeprecationFunc(bundle.ChartExtenderContext, funcMap)
}

func convertBufferedFilesForChartExtender(files []*loader.BufferedFile) []*chart.ChartExtenderBufferedFile {
Expand Down
41 changes: 0 additions & 41 deletions pkg/deploy/helm/chart_extender/helpers/chart_template_helpers.go

This file was deleted.

11 changes: 1 addition & 10 deletions pkg/deploy/helm/chart_extender/helpers/common_template_funcs.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package helpers

import (
"context"
"fmt"
"path"
"strings"
"text/template"

"github.com/werf/logboek"
"github.com/werf/werf/v2/pkg/deploy/helm/chart_extender/helpers/secrets"
)

Expand All @@ -19,18 +17,11 @@ func SetupIncludeWrapperFuncs(funcMap template.FuncMap) {
}
}

for _, name := range []string{"werf_image"} {
for _, name := range []string{} {
setupIncludeWrapperFunc(name)
}
}

func SetupWerfImageDeprecationFunc(ctx context.Context, funcMap template.FuncMap) {
funcMap["_print_werf_image_deprecation"] = func() (string, error) {
logboek.Context(ctx).Warn().LogF("DEPRECATION WARNING: Usage of werf_image is deprecated, use .Values.werf.image.IMAGE_NAME directly instead, werf_image template function will be removed in v1.3.\n")
return "", nil
}
}

func SetupWerfSecretFile(secretsRuntimeData *secrets.SecretsRuntimeData, funcMap template.FuncMap) {
funcMap["werf_secret_file"] = func(secretRelativePath string) (string, error) {
if path.IsAbs(secretRelativePath) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/deploy/helm/chart_extender/werf_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func (wc *WerfChart) ChartLoaded(files []*chart.ChartExtenderBufferedFile) error

wc.HelmChart.Templates = append(wc.HelmChart.Templates, &chart.File{
Name: "templates/_werf_helpers.tpl",
Data: []byte(helpers.ChartTemplateHelpers),
})

if wc.DisableDefaultValues {
Expand Down Expand Up @@ -187,7 +186,6 @@ func (wc *WerfChart) MakeBundleSecretValues(ctx context.Context, secretsRuntimeD
func (wc *WerfChart) SetupTemplateFuncs(t *template.Template, funcMap template.FuncMap) {
helpers.SetupWerfSecretFile(wc.SecretsRuntimeData, funcMap)
helpers.SetupIncludeWrapperFuncs(funcMap)
helpers.SetupWerfImageDeprecationFunc(wc.ChartExtenderContext, funcMap)
}

// LoadDir method for the chart.Extender interface
Expand Down
2 changes: 0 additions & 2 deletions pkg/deploy/helm/chart_extender/werf_chart_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func (wc *WerfChartStub) ChartLoaded(files []*chart.ChartExtenderBufferedFile) e

wc.HelmChart.Templates = append(wc.HelmChart.Templates, &chart.File{
Name: "templates/_werf_helpers.tpl",
Data: []byte(helpers.ChartTemplateHelpers),
})

return nil
Expand All @@ -118,7 +117,6 @@ func (wc *WerfChartStub) MakeValues(inputVals map[string]interface{}) (map[strin
func (wc *WerfChartStub) SetupTemplateFuncs(t *template.Template, funcMap template.FuncMap) {
helpers.SetupWerfSecretFile(wc.SecretsRuntimeData, funcMap)
helpers.SetupIncludeWrapperFuncs(funcMap)
helpers.SetupWerfImageDeprecationFunc(wc.ChartExtenderContext, funcMap)
}

// LoadDir method for the chart.Extender interface
Expand Down

0 comments on commit 8721568

Please sign in to comment.