2019-10-09 20:49:40 +03:00
|
|
|
package labelsync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/Azure/node-label-operator/labelsync/options"
|
|
|
|
)
|
|
|
|
|
|
|
|
func LabelPatch(labels map[string]string) ([]byte, error) {
|
|
|
|
return json.Marshal(map[string]interface{}{
|
|
|
|
"metadata": map[string]interface{}{
|
|
|
|
"labels": labels,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func LabelPatchWithDelete(labels map[string]*string) ([]byte, error) {
|
|
|
|
return json.Marshal(map[string]interface{}{
|
|
|
|
"metadata": map[string]interface{}{
|
|
|
|
"labels": labels,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-09 21:35:53 +03:00
|
|
|
func labelDeletionAllowed(configOptions *options.ConfigOptions) bool {
|
2019-10-09 20:49:40 +03:00
|
|
|
return configOptions.LabelPrefix != "" && (configOptions.ConflictPolicy == options.ARMPrecedence || configOptions.ConflictPolicy == options.Ignore)
|
|
|
|
}
|