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

Commit

Permalink
pkg/k8sutil: utility function to set labels and annotations in one txn
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Callendrello committed Jan 18, 2018
1 parent 60bd412 commit dedf1a2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/k8sutil/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ func SetNodeAnnotations(nc v1core.NodeInterface, node string, m map[string]strin
})
}

// SetNodeAnnotationsLabels sets all keys in a and l to their respective values in
// node's annotations and labels, likewise
func SetNodeAnnotationsLabels(nc v1core.NodeInterface, node string, a, l map[string]string) error {
return UpdateNodeRetry(nc, node, func(n *v1api.Node) {
for k, v := range a {
n.Annotations[k] = v
}

for k, v := range l {
n.Labels[k] = v
}
})
}

// DeleteNodeLabels deletes all keys in ks
func DeleteNodeLabels(nc v1core.NodeInterface, node string, ks []string) error {
return UpdateNodeRetry(nc, node, func(n *v1api.Node) {
Expand Down

0 comments on commit dedf1a2

Please sign in to comment.