Skip to content

Commit

Permalink
fix(giterminism): --add-custom-tag option is not allowed
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Sep 9, 2022
1 parent bc691f2 commit 8b72dfe
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
11 changes: 4 additions & 7 deletions cmd/werf/common/conveyor_options.go
Expand Up @@ -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{}{
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions docs/_data/werf_giterminism_yaml.yml
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions docs/pages_en/advanced/giterminism.md
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/pages_ru/advanced/giterminism.md
Expand Up @@ -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-шаблонизатора

Expand Down
2 changes: 1 addition & 1 deletion pkg/giterminism_manager/inspector/cli.go
Expand Up @@ -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.`)
}

0 comments on commit 8b72dfe

Please sign in to comment.