Skip to content

Commit

Permalink
Merge branch 'main' into issue_100
Browse files Browse the repository at this point in the history
Signed-off-by: Ved Ratan <[email protected]>
  • Loading branch information
VedRatan authored Sep 23, 2024
2 parents b09f413 + 56bd5c3 commit 2e525fa
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/adapter/nimbus-kyverno/processor/kpbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func BuildKpsFrom(logger logr.Logger, np *v1alpha1.NimbusPolicy) []kyvernov1.Pol
// Build KPs based on given IDs
var allkps []kyvernov1.Policy
background := true
skipBackgroundAdmissionReq := true
for _, nimbusRule := range np.Spec.NimbusRules {
id := nimbusRule.ID
if idpool.IsIdSupportedBy(id, "kyverno") {
Expand All @@ -53,8 +52,7 @@ func BuildKpsFrom(logger logr.Logger, np *v1alpha1.NimbusPolicy) []kyvernov1.Pol
kp.Annotations = make(map[string]string)
kp.Annotations["policies.kyverno.io/description"] = nimbusRule.Description
kp.Spec.Background = &background
kp.Spec.Rules[0].SkipBackgroundRequests = skipBackgroundAdmissionReq


if nimbusRule.Rule.RuleAction == "Block" {
kp.Spec.ValidationFailureAction = kyvernov1.ValidationFailureAction("Enforce")
} else {
Expand Down Expand Up @@ -231,17 +229,17 @@ func cocoRuntimeAddition(np *v1alpha1.NimbusPolicy) ([]kyvernov1.Policy, error)
if err != nil {
errs = append(errs, err)
}
var markLabels = make(map[string]string)
var markLabels = make(map[string][]string)
for _, d := range deployments.Items {
for k, v := range d.GetLabels() {
key := k + ":" + v
markLabels[key] = d.GetName() // we need to add all the names of the deployments having this label
markLabels[key] = append(markLabels[key], d.GetName())
}
}
for k, v := range labels {
key := k + ":" + v
if markLabels[key] != "" {
deployNames = append(deployNames, markLabels[key])
if len(markLabels[key]) != 0 {
deployNames = append(deployNames, markLabels[key]...)
}
}

Expand Down

0 comments on commit 2e525fa

Please sign in to comment.