Merge pull request #3385 from monopole/elimateExtraneousEmtpyMaps

Eliminate extraneous label and anno maps.
This commit is contained in:
Kubernetes Prow Robot
2020-12-22 08:54:26 -08:00
committed by GitHub
5 changed files with 10 additions and 26 deletions

View File

@@ -130,8 +130,6 @@ data:
testValue: "2" testValue: "2"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: comp-my-configmap-kc6k2kmkh9 name: comp-my-configmap-kc6k2kmkh9
--- ---
apiVersion: v1 apiVersion: v1
@@ -184,8 +182,6 @@ data:
testValue: "2" testValue: "2"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: comp-my-configmap-55249mf5kb name: comp-my-configmap-55249mf5kb
--- ---
apiVersion: v1 apiVersion: v1
@@ -239,8 +235,6 @@ data:
testValue: "2" testValue: "2"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: comp-my-configmap-55249mf5kb name: comp-my-configmap-55249mf5kb
--- ---
apiVersion: v1 apiVersion: v1
@@ -299,8 +293,6 @@ data:
testValue: "2" testValue: "2"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: comp-my-configmap-kc6k2kmkh9 name: comp-my-configmap-kc6k2kmkh9
--- ---
apiVersion: v1 apiVersion: v1
@@ -347,8 +339,6 @@ data:
testValue: "2" testValue: "2"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: my-configmap-kc6k2kmkh9 name: my-configmap-kc6k2kmkh9
`, `,
}, },
@@ -378,8 +368,6 @@ data:
testValue: "1" testValue: "1"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: my-configmap-5g7gh5mgt5 name: my-configmap-5g7gh5mgt5
--- ---
apiVersion: v1 apiVersion: v1

View File

@@ -197,8 +197,6 @@ data:
veggie: broccoli veggie: broccoli
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: p-cm-877mt5hc89 name: p-cm-877mt5hc89
`) `)
} }
@@ -259,8 +257,6 @@ data:
from: overlay from: overlay
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: p1-com1-8tc62428t2 name: p1-com1-8tc62428t2
--- ---
apiVersion: v1 apiVersion: v1
@@ -268,8 +264,6 @@ data:
from: overlay from: overlay
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: p2-com2-87mcggf7d7 name: p2-com2-87mcggf7d7
`) `)
} }
@@ -316,8 +310,6 @@ data:
foo: bar foo: bar
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: o1-cm-ft9mmdc8c6 name: o1-cm-ft9mmdc8c6
--- ---
apiVersion: v1 apiVersion: v1
@@ -326,8 +318,6 @@ data:
foo: bar foo: bar
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: cm-o2-5k95kd76ft name: cm-o2-5k95kd76ft
`) `)
} }

View File

@@ -88,8 +88,6 @@ data:
PORT: "3306" PORT: "3306"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: mysql-9792mdchtg name: mysql-9792mdchtg
--- ---
apiVersion: apps/v1 apiVersion: apps/v1

View File

@@ -102,8 +102,6 @@ data:
overlay: "true" overlay: "true"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: {}
labels: {}
name: testCase-bcbmmg48hd name: testCase-bcbmmg48hd
namespace: overlay namespace: overlay
`) `)

View File

@@ -95,6 +95,11 @@ func (r *Resource) MatchesAnnotationSelector(selector string) (bool, error) {
} }
func (r *Resource) SetAnnotations(m map[string]string) { func (r *Resource) SetAnnotations(m map[string]string) {
if len(m) == 0 {
// Force field erasure.
r.kunStr.SetAnnotations(nil)
return
}
r.kunStr.SetAnnotations(m) r.kunStr.SetAnnotations(m)
} }
@@ -107,6 +112,11 @@ func (r *Resource) SetGvk(gvk resid.Gvk) {
} }
func (r *Resource) SetLabels(m map[string]string) { func (r *Resource) SetLabels(m map[string]string) {
if len(m) == 0 {
// Force field erasure.
r.kunStr.SetLabels(nil)
return
}
r.kunStr.SetLabels(m) r.kunStr.SetLabels(m)
} }