Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit dedf1a2

Browse files
author
Casey Callendrello
committed
pkg/k8sutil: utility function to set labels and annotations in one txn
1 parent 60bd412 commit dedf1a2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/k8sutil/metadata.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ func SetNodeAnnotations(nc v1core.NodeInterface, node string, m map[string]strin
8080
})
8181
}
8282

83+
// SetNodeAnnotationsLabels sets all keys in a and l to their respective values in
84+
// node's annotations and labels, likewise
85+
func SetNodeAnnotationsLabels(nc v1core.NodeInterface, node string, a, l map[string]string) error {
86+
return UpdateNodeRetry(nc, node, func(n *v1api.Node) {
87+
for k, v := range a {
88+
n.Annotations[k] = v
89+
}
90+
91+
for k, v := range l {
92+
n.Labels[k] = v
93+
}
94+
})
95+
}
96+
8397
// DeleteNodeLabels deletes all keys in ks
8498
func DeleteNodeLabels(nc v1core.NodeInterface, node string, ks []string) error {
8599
return UpdateNodeRetry(nc, node, func(n *v1api.Node) {

0 commit comments

Comments
 (0)