Skip to content
Permalink
Browse files
fix(helm): empty resource annos/labels result in no service annos/labels
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Sep 16, 2022
1 parent da78086 commit 902c5a16169a1884ee959a7ac71b974ef5b1f5e4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
@@ -227,6 +227,11 @@ func appendExtraData(node *yaml_v3.Node, key string, data interface{}) error {
} else {
appendToNode(targetNode, data)
}

if targetNode.Kind != yaml_v3.AliasNode && targetNode.Kind != yaml_v3.MappingNode {
targetNode.Kind = yaml_v3.MappingNode
}
targetNode.Tag = "!!map"
} else {
appendToNode(node, map[string]interface{}{key: data})
}
@@ -232,6 +232,34 @@ spec:
`, werf.Version, werf.Version),
}),

Entry("should add builtin and extra annotations and labels into resources manifest with empty annotations and labels",
ExtraAnnotationsAndLabelsPostRendererTestData{
PostRenderer: NewExtraAnnotationsAndLabelsPostRenderer(
map[string]string{"test-annotation-1": "value-1", "test-annotation-2": "value-2"},
map[string]string{"test-label-1": "value-1", "test-label-2": "value-2"},
false,
),
Manifest: `apiVersion: v1
kind: ConfigMap
metadata:
labels:
annotations:
name: test
`,
ExpectedManifest: fmt.Sprintf(`apiVersion: v1
kind: ConfigMap
metadata:
labels:
test-label-1: value-1
test-label-2: value-2
annotations:
test-annotation-1: value-1
test-annotation-2: value-2
werf.io/version: %s
name: test
`, werf.Version),
}),

Entry("should add extra annotations into yaml alias node defined by yaml anchor",
ExtraAnnotationsAndLabelsPostRendererTestData{
PostRenderer: NewExtraAnnotationsAndLabelsPostRenderer(

0 comments on commit 902c5a1

Please sign in to comment.