compareMaps returns true iff the maps are equivalent, otherwise returns false, and the first difference found
(current, target map[string]V)
| 116 | // compareMaps returns true iff the maps are equivalent, otherwise returns |
| 117 | // false, and the first difference found |
| 118 | func 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 |
no outgoing calls
no test coverage detected