MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / compareMaps

Function compareMaps

pkg/specs/podspec_diff.go:118–137  ·  view source on GitHub ↗

compareMaps returns true iff the maps are equivalent, otherwise returns false, and the first difference found

(current, target map[string]V)

Source from the content-addressed store, hash-verified

116// compareMaps returns true iff the maps are equivalent, otherwise returns
117// false, and the first difference found
118func compareMaps[V comparable](current, target map[string]V) (bool, string) {
119 for name, currentValue := range current {
120 targetValue, found := target[name]
121 if !found {
122 return false, fmt.Sprintf("element %s has been removed", name)
123 }
124 deepEqual := reflect.DeepEqual(currentValue, targetValue)
125 if !deepEqual {
126 return false, fmt.Sprintf("element %s has differing value", name)
127 }
128 }
129 for name := range target {
130 _, found := current[name]
131 if !found {
132 return false, fmt.Sprintf("element %s has been added", name)
133 }
134 // if the key is in both maps, the values have been compared in the previous loop
135 }
136 return true, ""
137}
138
139// normalizeVolumeName maps old unprefixed volume names to the new prefixed
140// scheme (ext- for extensions, tbs- for tablespaces) to avoid spurious

Callers 2

compareVolumesFunction · 0.85
compareVolumeMountsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected