Skip to content

Commit 4549047

Browse files
committed
Annotation to override object name for diff purposes
This is useful for immutable secrets which are typically named as secret-base-name-<.data hash>. Previously old and new secrets were considere completely independent ConfigMap/Secret. With this annotation user can add "helm.sh/base-name: secret-base-name" annotation and compare old and new objects similar to git rename.
1 parent e41445a commit 4549047

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

manifest/parse.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"log"
88
"strings"
99

10-
yaml "gopkg.in/yaml.v2"
10+
"gopkg.in/yaml.v2"
1111
"k8s.io/helm/pkg/proto/hapi/release"
1212
)
1313

@@ -40,8 +40,13 @@ func (m metadata) String() string {
4040
if len(sp) > 1 {
4141
apiBase = strings.Join(sp[:len(sp)-1], "/")
4242
}
43-
44-
return fmt.Sprintf("%s, %s, %s (%s)", m.Metadata.Namespace, m.Metadata.Name, m.Kind, apiBase)
43+
name := m.Metadata.Name
44+
if a := m.Metadata.Annotations; a != nil {
45+
if baseName, ok := a["helm.sh/base-name"]; ok {
46+
name = baseName
47+
}
48+
}
49+
return fmt.Sprintf("%s, %s, %s (%s)", m.Metadata.Namespace, name, m.Kind, apiBase)
4550
}
4651

4752
func scanYamlSpecs(data []byte, atEOF bool) (advance int, token []byte, err error) {

0 commit comments

Comments
 (0)