Skip to content

Commit c9e2eff

Browse files
fix(deploy): label/annotation separator options have no effect
Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
1 parent e339a6a commit c9e2eff

File tree

13 files changed

+78
-89
lines changed

13 files changed

+78
-89
lines changed

cmd/werf/common/common.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,40 +414,40 @@ func SetupNamespace(cmdData *CmdData, cmd *cobra.Command, projectConfigParsed bo
414414

415415
func SetupAddAnnotations(cmdData *CmdData, cmd *cobra.Command) {
416416
cmdData.AddAnnotations = new([]string)
417-
cmd.Flags().StringArrayVarP(cmdData.AddAnnotations, "add-annotation", "", []string{}, `Add annotation to deploying resources (can specify multiple).
418-
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
419-
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g. $WERF_ADD_ANNOTATION_1=annoName1=annoValue1, $WERF_ADD_ANNOTATION_2=annoName2=annoValue2)`)
417+
cmd.Flags().StringArrayVarP(cmdData.AddAnnotations, "add-annotation", "", []string{}, fmt.Sprintf(`Add annotation to deploying resources (can specify multiple).
418+
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is %q, but it can be customized using the --add-annotation-separator flag.
419+
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g. $WERF_ADD_ANNOTATION_1=annoName1=annoValue1, $WERF_ADD_ANNOTATION_2=annoName2=annoValue2)`, DefaultPairSeparator))
420420
}
421421

422422
const DefaultAnnoAndLabelPairSeparator = "\n"
423423

424424
func SetupAddAnnotationSeparator(cmdData *CmdData, cmd *cobra.Command) {
425425
cmdData.AddAnnotationSeparator = new(string)
426426

427-
defaultValue := DefaultAnnoAndLabelPairSeparator
427+
defaultValue := DefaultPairSeparator
428428
if os.Getenv("WERF_ADD_ANNOTATION_SEPARATOR") != "" {
429429
defaultValue = os.Getenv("WERF_ADD_ANNOTATION_SEPARATOR")
430430
}
431431

432-
cmd.Flags().StringVarP(cmdData.AddAnnotationSeparator, "add-annotation-separator", "", defaultValue, `Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")`)
432+
cmd.Flags().StringVarP(cmdData.AddAnnotationSeparator, "add-annotation-separator", "", defaultValue, fmt.Sprintf(`Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or %q)`, DefaultPairSeparator))
433433
}
434434

435435
func SetupAddLabels(cmdData *CmdData, cmd *cobra.Command) {
436436
cmdData.AddLabels = new([]string)
437-
cmd.Flags().StringArrayVarP(cmdData.AddLabels, "add-label", "", []string{}, `Add label to deploying resources (can specify multiple).
438-
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default separator is a newline ("\n"), but it can be customized using the --add-label-separator flag.
439-
Also, can be specified with $WERF_ADD_LABEL_* (e.g. $WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)`)
437+
cmd.Flags().StringArrayVarP(cmdData.AddLabels, "add-label", "", []string{}, fmt.Sprintf(`Add label to deploying resources (can specify multiple).
438+
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default separator is %q, but it can be customized using the --add-label-separator flag.
439+
Also, can be specified with $WERF_ADD_LABEL_* (e.g. $WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)`, DefaultPairSeparator))
440440
}
441441

442442
func SetupAddLabelSeparator(cmdData *CmdData, cmd *cobra.Command) {
443443
cmdData.AddLabelSeparator = new(string)
444444

445-
defaultValue := DefaultAnnoAndLabelPairSeparator
445+
defaultValue := DefaultPairSeparator
446446
if os.Getenv("WERF_ADD_LABEL_SEPARATOR") != "" {
447447
defaultValue = os.Getenv("WERF_ADD_LABEL_SEPARATOR")
448448
}
449449

450-
cmd.Flags().StringVarP(cmdData.AddLabelSeparator, "add-label-separator", "", defaultValue, `Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")`)
450+
cmd.Flags().StringVarP(cmdData.AddLabelSeparator, "add-label-separator", "", defaultValue, fmt.Sprintf(`Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or %q)`, DefaultPairSeparator))
451451
}
452452

453453
func SetupKubeContext(cmdData *CmdData, cmd *cobra.Command) {

cmd/werf/common/deploy_params.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
)
1414

1515
func GetUserExtraAnnotations(cmdData *CmdData) (map[string]string, error) {
16-
result, err := InputArrayToKeyValueMap(GetAddAnnotations(cmdData), ",", DefaultKeyValueSeparator)
16+
result, err := InputArrayToKeyValueMap(GetAddAnnotations(cmdData), *cmdData.AddAnnotationSeparator, DefaultKeyValueSeparator)
1717
if err != nil {
1818
return nil, fmt.Errorf("unsupported --add-annotation value: %w", err)
1919
}
@@ -22,7 +22,7 @@ func GetUserExtraAnnotations(cmdData *CmdData) (map[string]string, error) {
2222
}
2323

2424
func GetUserExtraLabels(cmdData *CmdData) (map[string]string, error) {
25-
result, err := InputArrayToKeyValueMap(GetAddLabels(cmdData), ",", DefaultKeyValueSeparator)
25+
result, err := InputArrayToKeyValueMap(GetAddLabels(cmdData), *cmdData.AddLabelSeparator, DefaultKeyValueSeparator)
2626
if err != nil {
2727
return nil, fmt.Errorf("unsupported --add-label value: %w", err)
2828
}

docs/_includes/reference/cli/werf_bundle_apply.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,20 @@ werf bundle apply [options]
1818
--add-annotation=[]
1919
Add annotation to deploying resources (can specify multiple).
2020
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
21-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
21+
",", but it can be customized using the --add-annotation-separator flag.
2222
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
2323
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
2424
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
25-
--add-annotation-separator="\n"
26-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
25+
--add-annotation-separator=","
26+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
2727
--add-label=[]
2828
Add label to deploying resources (can specify multiple).
2929
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
30-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
31-
flag.
30+
separator is ",", but it can be customized using the --add-label-separator flag.
3231
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
3332
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
34-
--add-label-separator="\n"
35-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
33+
--add-label-separator=","
34+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
3635
--atomic=false
3736
Enable auto rollback of the failed release to the previous deployed release version
3837
when current deploy process have failed ($WERF_ATOMIC by default)

docs/_includes/reference/cli/werf_bundle_publish.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ werf bundle publish [IMAGE_NAME...] [options]
1919
--add-annotation=[]
2020
Add annotation to deploying resources (can specify multiple).
2121
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
22-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
22+
",", but it can be customized using the --add-annotation-separator flag.
2323
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
2424
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
2525
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
26-
--add-annotation-separator="\n"
27-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
26+
--add-annotation-separator=","
27+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
2828
--add-custom-tag=[]
2929
Set tag alias for the content-based tag.
3030
The alias may contain the following shortcuts:
@@ -37,12 +37,11 @@ werf bundle publish [IMAGE_NAME...] [options]
3737
--add-label=[]
3838
Add label to deploying resources (can specify multiple).
3939
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
40-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
41-
flag.
40+
separator is ",", but it can be customized using the --add-label-separator flag.
4241
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
4342
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
44-
--add-label-separator="\n"
45-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
43+
--add-label-separator=","
44+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
4645
--allowed-backend-storage-volume-usage=70
4746
Set allowed percentage of backend (Docker or Buildah) storage volume usage which will
4847
cause cleanup of least recently used local backend images (default 70% or

docs/_includes/reference/cli/werf_bundle_render.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@ werf bundle render [options]
2929
--add-annotation=[]
3030
Add annotation to deploying resources (can specify multiple).
3131
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
32-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
32+
",", but it can be customized using the --add-annotation-separator flag.
3333
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
3434
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
3535
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
36-
--add-annotation-separator="\n"
37-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
36+
--add-annotation-separator=","
37+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
3838
--add-label=[]
3939
Add label to deploying resources (can specify multiple).
4040
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
41-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
42-
flag.
41+
separator is ",", but it can be customized using the --add-label-separator flag.
4342
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
4443
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
45-
--add-label-separator="\n"
46-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
44+
--add-label-separator=","
45+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
4746
-b, --bundle-dir=""
4847
Get extracted bundle from directory instead of registry (default $WERF_BUNDLE_DIR)
4948
--container-registry-mirror=[]

docs/_includes/reference/cli/werf_converge.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ werf converge --repo registry.mydomain.com/web --env production
4242
--add-annotation=[]
4343
Add annotation to deploying resources (can specify multiple).
4444
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
45-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
45+
",", but it can be customized using the --add-annotation-separator flag.
4646
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
4747
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
4848
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
49-
--add-annotation-separator="\n"
50-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
49+
--add-annotation-separator=","
50+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
5151
--add-custom-tag=[]
5252
Set tag alias for the content-based tag.
5353
The alias may contain the following shortcuts:
@@ -60,12 +60,11 @@ werf converge --repo registry.mydomain.com/web --env production
6060
--add-label=[]
6161
Add label to deploying resources (can specify multiple).
6262
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
63-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
64-
flag.
63+
separator is ",", but it can be customized using the --add-label-separator flag.
6564
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
6665
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
67-
--add-label-separator="\n"
68-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
66+
--add-label-separator=","
67+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
6968
--allowed-backend-storage-volume-usage=70
7069
Set allowed percentage of backend (Docker or Buildah) storage volume usage which will
7170
cause cleanup of least recently used local backend images (default 70% or

docs/_includes/reference/cli/werf_helm_install.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,20 @@ werf helm install [NAME] [CHART] [flags] [options]
6161
--add-annotation=[]
6262
Add annotation to deploying resources (can specify multiple).
6363
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
64-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
64+
",", but it can be customized using the --add-annotation-separator flag.
6565
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
6666
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
6767
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
68-
--add-annotation-separator="\n"
69-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
68+
--add-annotation-separator=","
69+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
7070
--add-label=[]
7171
Add label to deploying resources (can specify multiple).
7272
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
73-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
74-
flag.
73+
separator is ",", but it can be customized using the --add-label-separator flag.
7574
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
7675
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
77-
--add-label-separator="\n"
78-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
76+
--add-label-separator=","
77+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
7978
--atomic=false
8079
if set, the installation process deletes the installation on failure. The --wait flag
8180
will be set automatically if --atomic is used

docs/_includes/reference/cli/werf_helm_lint.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@ werf helm lint PATH [flags] [options]
1919
--add-annotation=[]
2020
Add annotation to deploying resources (can specify multiple).
2121
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
22-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
22+
",", but it can be customized using the --add-annotation-separator flag.
2323
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
2424
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
2525
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
26-
--add-annotation-separator="\n"
27-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
26+
--add-annotation-separator=","
27+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
2828
--add-label=[]
2929
Add label to deploying resources (can specify multiple).
3030
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
31-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
32-
flag.
31+
separator is ",", but it can be customized using the --add-label-separator flag.
3332
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
3433
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
35-
--add-label-separator="\n"
36-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
34+
--add-label-separator=","
35+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
3736
--env=""
3837
Use specified environment (default $WERF_ENV)
3938
--ignore-secret-key=false

docs/_includes/reference/cli/werf_helm_template.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,20 @@ werf helm template [NAME] [CHART] [flags] [options]
2323
--add-annotation=[]
2424
Add annotation to deploying resources (can specify multiple).
2525
Format: annoName=annoValue[<separator>annoName=annoValue ...]. The default separator is
26-
a newline ("\n"), but it can be customized using the --add-annotation-separator flag.
26+
",", but it can be customized using the --add-annotation-separator flag.
2727
Also, can be specified with $WERF_ADD_ANNOTATION_* (e.g.
2828
$WERF_ADD_ANNOTATION_1=annoName1=annoValue1,
2929
$WERF_ADD_ANNOTATION_2=annoName2=annoValue2)
30-
--add-annotation-separator="\n"
31-
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or "\n")
30+
--add-annotation-separator=","
31+
Separator for --add-annotation values (default $WERF_ADD_ANNOTATION_SEPARATOR or ",")
3232
--add-label=[]
3333
Add label to deploying resources (can specify multiple).
3434
Format: labelName=labelValue[<separator>labelName=labelValue ...]. The default
35-
separator is a newline ("\n"), but it can be customized using the --add-label-separator
36-
flag.
35+
separator is ",", but it can be customized using the --add-label-separator flag.
3736
Also, can be specified with $WERF_ADD_LABEL_* (e.g.
3837
$WERF_ADD_LABEL_1=labelName1=labelValue1, $WERF_ADD_LABEL_2=labelName2=labelValue2)
39-
--add-label-separator="\n"
40-
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or "\n")
38+
--add-label-separator=","
39+
Separator for --add-label values (default $WERF_ADD_LABEL_SEPARATOR or ",")
4140
-a, --api-versions=[]
4241
Kubernetes api versions used for Capabilities.APIVersions
4342
--atomic=false

0 commit comments

Comments
 (0)