From 889826b4d9f2a84870dd40533d11a6c759886b00 Mon Sep 17 00:00:00 2001 From: shubham Date: Wed, 29 Jan 2020 20:02:46 +0530 Subject: [PATCH] added break in for loop and comments Signed-off-by: shubham --- pkg/webhook/configuration.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/webhook/configuration.go b/pkg/webhook/configuration.go index 522ee426fa..714958cfec 100644 --- a/pkg/webhook/configuration.go +++ b/pkg/webhook/configuration.go @@ -436,16 +436,24 @@ func GetAdmissionReference() (*metav1.OwnerReference, error) { return nil, fmt.Errorf("failed to create deployment ownerReference") } +// addCSPCDeleteRule adds the DELETE operation to for CSPC if coming from 1.6.0 +// or older version func addCSPCDeleteRule(config *v1beta1.ValidatingWebhookConfiguration) { if config.Labels[string(apis.OpenEBSVersionKey)] < "1.7.0" { index := -1 + // find the index of the RuleWithOperations having CSPC for i, rule := range config.Webhooks[0].Rules { if util.ContainsString(rule.Rule.Resources, "cstorpoolclusters") { index = i + break } } + // if CSPC RuleWithOperations is found append DELETE operation if index != -1 { - config.Webhooks[0].Rules[index].Operations = append(config.Webhooks[0].Rules[index].Operations, v1beta1.Delete) + config.Webhooks[0].Rules[index].Operations = append( + config.Webhooks[0].Rules[index].Operations, + v1beta1.Delete, + ) } } }