@@ -22,34 +22,25 @@ import (
22
22
"sort"
23
23
24
24
goyaml "gopkg.in/yaml.v2"
25
+ "helm.sh/helm/v3/pkg/chartutil"
25
26
"helm.sh/helm/v3/pkg/release"
26
27
"sigs.k8s.io/yaml"
27
28
)
28
29
29
30
// ValuesChecksum calculates and returns the SHA1 checksum for the
30
31
// given chartutil.Values.
31
- func ValuesChecksum (values map [string ]interface {}) string {
32
- newValues := copyValues (values )
33
- var (
34
- s []byte
35
- err error
36
- )
37
-
38
- if len (newValues ) != 0 {
39
- // cleanUpInterfaceMap
40
- for i , value := range newValues {
41
- newValues [i ] = cleanUpMapValue (value )
42
- }
32
+ func ValuesChecksum (values chartutil.Values ) string {
33
+ var s []byte
34
+ if len (values ) != 0 {
35
+ // Check sum on the formatted values
36
+ newValues := copyValues (values )
43
37
msValues := yaml .JSONObjectToYAMLObject (newValues )
44
38
// Sort
45
39
SortMapSlice (msValues )
46
40
// Marshal
47
- s , err = goyaml .Marshal (msValues )
48
- if err != nil {
49
- panic (err )
50
- }
41
+ s , _ = goyaml .Marshal (msValues )
51
42
}
52
- // Gethash
43
+ // Get hash
53
44
return fmt .Sprintf ("%x" , sha1 .Sum (s ))
54
45
}
55
46
@@ -76,17 +67,15 @@ func cleanUpMapValue(v interface{}) interface{} {
76
67
return cleanUpInterfaceArray (v )
77
68
case map [interface {}]interface {}:
78
69
return cleanUpInterfaceMap (v )
79
- case string :
80
- return v
81
70
default :
82
- return fmt . Sprintf ( "%v" , v )
71
+ return v
83
72
}
84
73
}
85
74
86
75
func cleanUpInterfaceMap (in map [interface {}]interface {}) map [string ]interface {} {
87
76
result := make (map [string ]interface {})
88
77
for k , v := range in {
89
- result [fmt .Sprintf ("%v" , k )] = cleanUpMapValue (v )
78
+ result [fmt .Sprintf ("%T.%v" , k , k )] = cleanUpMapValue (v )
90
79
}
91
80
return result
92
81
}
@@ -101,14 +90,16 @@ func cleanUpInterfaceArray(in []interface{}) []interface{} {
101
90
102
91
func copyValues (in map [string ]interface {}) map [string ]interface {} {
103
92
// Marshal
104
- coppiedValues , err := goyaml .Marshal (in )
105
- if err != nil {
106
- panic (err )
107
- }
93
+ coppiedValues , _ := goyaml .Marshal (in )
108
94
// Unmarshal
109
- newValues := make (map [string ]interface {})
95
+ newValues := make (map [interface {} ]interface {})
110
96
goyaml .Unmarshal (coppiedValues , newValues )
111
- return newValues
97
+ formattedValues := make (map [string ]interface {})
98
+ // cleanUpInterfaceMap
99
+ for i , value := range newValues {
100
+ formattedValues [fmt .Sprintf ("%T.%v" , i , i )] = cleanUpMapValue (value )
101
+ }
102
+ return formattedValues
112
103
}
113
104
114
105
// ReleaseRevision returns the revision of the given release.Release.
0 commit comments