Skip to content

Commit 79e0104

Browse files
wkingopenshift-cherrypick-robot
authored andcommitted
lib/resourcemerge/core: Reconcile ConfigMap binaryData too
Since 4.20, some Cluster-API ConfigMap manifests have wanted to set this: $ oc adm release extract --to manifests quay.io/openshift-release-dev/ocp-release:4.20.10-x86_64 $ grep -r binaryData manifests manifests/0000_30_cluster-api_04_cm.infrastructure-aws.yaml:binaryData: so we need to compare the in-cluster ConfigMap with this property as well, when deciding if the resource needs updating.
1 parent 73583cd commit 79e0104

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

lib/resourcemerge/core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
func EnsureConfigMap(modified *bool, existing *corev1.ConfigMap, required corev1.ConfigMap) {
1616
EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta)
1717

18+
mergeByteSliceMap(modified, &existing.BinaryData, required.BinaryData)
1819
mergeMap(modified, &existing.Data, required.Data)
1920
}
2021

lib/resourcemerge/meta.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ func mergeMap(modified *bool, existing *map[string]string, required map[string]s
4040
}
4141
}
4242

43+
func mergeByteSliceMap(modified *bool, existing *map[string][]byte, required map[string][]byte) {
44+
if *existing == nil {
45+
if required == nil {
46+
return
47+
}
48+
*existing = map[string][]byte{}
49+
}
50+
for k, v := range required {
51+
if existingV, ok := (*existing)[k]; !ok || string(v) != string(existingV) {
52+
*modified = true
53+
(*existing)[k] = v
54+
}
55+
}
56+
}
57+
4358
func mergeOwnerRefs(modified *bool, existing *[]metav1.OwnerReference, required []metav1.OwnerReference) {
4459
for ridx := range required {
4560
found := false

0 commit comments

Comments
 (0)