mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
temp
This commit is contained in:
parent
f608d4db18
commit
69f65c713d
1 changed files with 23 additions and 0 deletions
|
@ -414,3 +414,26 @@ func generatePV(gr kyverno.GenerateRequest, resource unstructured.Unstructured,
|
|||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func addLabels(unstr *unstructured.Unstructured) {
|
||||
// add managedBY label if not defined
|
||||
labels := unstr.GetLabels()
|
||||
if labels == nil {
|
||||
labels = map[string]string{}
|
||||
}
|
||||
// ManagedBy label
|
||||
key := "app.kubernetes.io/managed-by"
|
||||
value := "kyverno"
|
||||
val, ok := labels[key]
|
||||
if ok {
|
||||
if val != value {
|
||||
glog.Infof("resource managed by %s, kyverno wont over-ride the label", val)
|
||||
}
|
||||
}
|
||||
// we dont over-ride the key managed by
|
||||
if !ok {
|
||||
// add lable
|
||||
labels[key] = value
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue