returnfmt.Errorf("admission annotations are not allowd to be overwritten, key:%q, old value: %q, new value:%q",key,record.annotations[key],value)
}
record.annotations[key]=value
returnnil
}
funccheckKeyFormat(keystring)error{
parts:=strings.Split(key,"/")
iflen(parts)!=2{
returnfmt.Errorf("annotation key has invalid format, the right format is a DNS subdomain prefix and '/' and key name. (e.g. 'podsecuritypolicy.admission.k8s.io/admit-policy')")
returnfmt.Errorf("annotation key has invalid format %s. A qualified name like 'podsecuritypolicy.admission.k8s.io/admit-policy' is required.",strings.Join(msgs,","))
// GetUserInfo is information about the requesting user
GetUserInfo()user.Info
// AddAnnotation sets annotation according to key-value pair. The key should be qualified, e.g., podsecuritypolicy.admission.k8s.io/admit-policy, where
// "podsecuritypolicy" is the name of the plugin, "admission.k8s.io" is the name of the organization, "admit-policy" is the key name.
// An error is returned if the format of key is invalid. When trying to overwrite annotation with a new value, an error is returned.
// Both ValidationInterface and MutationInterface are allowed to add Annotations.
AddAnnotation(key,valuestring)error
}
// privateAnnotationsGetter is a private interface which allows users to get annotations from Attributes.
typeprivateAnnotationsGetterinterface{
getAnnotations()map[string]string
}
// AnnotationsGetter allows users to get annotations from Attributes. An alternate Attribute should implement
// this interface.
typeAnnotationsGetterinterface{
GetAnnotations()map[string]string
}
// Interface is an abstract, pluggable interface for Admission Control decisions.