Skip to content

Commit

Permalink
code improvement
Browse files Browse the repository at this point in the history
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
  • Loading branch information
NoSkillGirl committed Mar 11, 2021
1 parent 247c876 commit 9caa926
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/kyverno/common/common.go
Expand Up @@ -10,7 +10,6 @@ import (
"net/http"
"os"
"path/filepath"
"reflect"
"strings"

jsonpatch "github.com/evanphx/json-patch/v5"
Expand All @@ -26,7 +25,6 @@ import (
"github.com/kyverno/kyverno/pkg/utils"
ut "github.com/kyverno/kyverno/pkg/utils"
yamlv2 "gopkg.in/yaml.v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/yaml"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -384,16 +382,15 @@ func MutatePolices(policies []*v1.ClusterPolicy) ([]*v1.ClusterPolicy, error) {
func ApplyPolicyOnResource(policy *v1.ClusterPolicy, resource *unstructured.Unstructured,
mutateLogPath string, mutateLogPathIsDir bool, variables map[string]string, policyReport bool, namespaceSelectorMap map[string]map[string]string) ([]*response.EngineResponse, *response.EngineResponse, bool, bool, error) {

var emptyNamespaceSelector *metav1.LabelSelector
responseError := false
rcError := false
engineResponses := make([]*response.EngineResponse, 0)
namespaceLabels := make(map[string]string)

policyWithNamespaceSelector := false
for _, p := range policy.Spec.Rules {
if !reflect.DeepEqual(p.MatchResources.ResourceDescription.NamespaceSelector, emptyNamespaceSelector) ||
!reflect.DeepEqual(p.ExcludeResources.ResourceDescription.NamespaceSelector, emptyNamespaceSelector) {
if p.MatchResources.ResourceDescription.NamespaceSelector != nil ||
p.ExcludeResources.ResourceDescription.NamespaceSelector != nil {
policyWithNamespaceSelector = true
break
}
Expand Down

0 comments on commit 9caa926

Please sign in to comment.