From 69f65c713df0440ba2724cec9f828b57adaac3d4 Mon Sep 17 00:00:00 2001 From: shivkumar dudhani Date: Tue, 4 Feb 2020 14:35:10 -0800 Subject: [PATCH] temp --- pkg/generate/generate.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/generate/generate.go b/pkg/generate/generate.go index 47214a5220..dac8632f89 100644 --- a/pkg/generate/generate.go +++ b/pkg/generate/generate.go @@ -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 + } + +}