From 8b72dfef1076a8374d89ba9def584095150e6f29 Mon Sep 17 00:00:00 2001 From: Alexey Igrychev Date: Fri, 9 Sep 2022 00:08:49 +0100 Subject: [PATCH] fix(giterminism): --add-custom-tag option is not allowed Signed-off-by: Alexey Igrychev --- cmd/werf/common/conveyor_options.go | 11 ++++------- docs/_data/werf_giterminism_yaml.yml | 4 ++-- docs/pages_en/advanced/giterminism.md | 4 ++-- docs/pages_ru/advanced/giterminism.md | 4 ++-- pkg/giterminism_manager/inspector/cli.go | 2 +- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/cmd/werf/common/conveyor_options.go b/cmd/werf/common/conveyor_options.go index dd231a2ea3..b0ac7070a0 100644 --- a/cmd/werf/common/conveyor_options.go +++ b/cmd/werf/common/conveyor_options.go @@ -88,10 +88,6 @@ func getCustomTagFuncList(tagOptionValues []string, commonCmdData *CmdData, gite return nil, fmt.Errorf("custom tags can only be used with remote storage: --repo=ADDRESS param required") } - if err := giterminismManager.Inspector().InspectCustomTags(); err != nil { - return nil, err - } - templateName := "--add/use-custom-tag" tmpl := template.New(templateName).Delims("%", "%") tmpl = tmpl.Funcs(map[string]interface{}{ @@ -150,9 +146,6 @@ func GetUseCustomTagFunc(commonCmdData *CmdData, giterminismManager giterminism_ if *commonCmdData.UseCustomTag != "" { tagOptionValues = []string{*commonCmdData.UseCustomTag} } - if len(tagOptionValues) == 0 { - return nil, nil - } customTagFuncList, err := getCustomTagFuncList(tagOptionValues, commonCmdData, giterminismManager, werfConfig) if err != nil { @@ -163,6 +156,10 @@ func GetUseCustomTagFunc(commonCmdData *CmdData, giterminismManager giterminism_ return nil, nil } + if err := giterminismManager.Inspector().InspectCustomTags(); err != nil { + return nil, err + } + if len(customTagFuncList) != 1 { panic("unexpected condition") } diff --git a/docs/_data/werf_giterminism_yaml.yml b/docs/_data/werf_giterminism_yaml.yml index 08437f0534..6517c59e16 100644 --- a/docs/_data/werf_giterminism_yaml.yml +++ b/docs/_data/werf_giterminism_yaml.yml @@ -13,8 +13,8 @@ directives: - name: allowCustomTags value: "bool" description: - en: Allow the use of --add-custom-tag and --use-custom-tag options - ru: Разрешить опции --add-custom-tag и --use-custom-tag + en: Allow the use of --use-custom-tag option + ru: Разрешить опцию --use-custom-tag - name: config description: en: The rules of loosening giterminism for the werf configuration file (werf.yaml) diff --git a/docs/pages_en/advanced/giterminism.md b/docs/pages_en/advanced/giterminism.md index 79a33b459a..0902e302f7 100644 --- a/docs/pages_en/advanced/giterminism.md +++ b/docs/pages_en/advanced/giterminism.md @@ -32,11 +32,11 @@ By default, werf prohibits using a particular set of directives and Go-template #### CLI -##### --add-custom-tag and --use-custom-tag options +##### \-\-use-custom-tag option The use of tag aliases with immutable values (e.g., `%image%-master`) makes previous deployments unreproducible and requires specifying the policy `imagePullPolicy: Always` for each image when configuring application containers in the helm chart. -To activate `--add-custom-tag` and `--use-custom-tag` options it is necessary to use [werf-giterminism.yaml]({{ "reference/werf_giterminism_yaml.html" | true_relative_url }}), but we recommend thinking again about the possible consequences. +To activate `--use-custom-tag` option it is necessary to use [werf-giterminism.yaml]({{ "reference/werf_giterminism_yaml.html" | true_relative_url }}), but we recommend thinking again about the possible consequences. #### Go-template functions diff --git a/docs/pages_ru/advanced/giterminism.md b/docs/pages_ru/advanced/giterminism.md index d0055dfadb..90ac3d5229 100644 --- a/docs/pages_ru/advanced/giterminism.md +++ b/docs/pages_ru/advanced/giterminism.md @@ -32,11 +32,11 @@ werf не позволяет работать с незакоммиченным #### CLI -##### Опции --add-custom-tag и --use-custom-tag +##### Опция --use-custom-tag Использование алиасов тегов с неизменяемыми значениями (например, `%image%-master`) делает предыдущие выкаты невоспроизводимыми и требует указания политики `imagePullPolicy: Always` для каждого образа при конфигурации контейнеров приложения в helm-чарте. -Для активации опций `--add-custom-tag` и `--use-custom-tag` необходимо использовать [werf-giterminism.yaml]({{ "reference/werf_giterminism_yaml.html" | true_relative_url }}), но мы рекомендуем еще раз подумать о возможных последствиях. +Для активации опции `--use-custom-tag` необходимо использовать [werf-giterminism.yaml]({{ "reference/werf_giterminism_yaml.html" | true_relative_url }}), но мы рекомендуем еще раз подумать о возможных последствиях. #### Функции Go-шаблонизатора diff --git a/pkg/giterminism_manager/inspector/cli.go b/pkg/giterminism_manager/inspector/cli.go index 0652192879..f95b6e674c 100644 --- a/pkg/giterminism_manager/inspector/cli.go +++ b/pkg/giterminism_manager/inspector/cli.go @@ -13,5 +13,5 @@ func (i Inspector) InspectCustomTags() error { return errors.NewError(`custom tags not allowed by giterminism -The use of --add-custom-tag and --use-custom-tag options might make previous deployments unreproducible and require extra configuration in the helm chart.`) +The use of --use-custom-tag option might make previous deployments unreproducible and require extra configuration in the helm chart.`) }