mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 10:04:25 +00:00
remove pkg/engine/mutation/checkRules.go since the logic is moved to /pkg/engine/mutation/utils.go
This commit is contained in:
parent
b08357a170
commit
35f829e4b6
1 changed files with 0 additions and 44 deletions
|
@ -1,44 +0,0 @@
|
|||
package mutation
|
||||
|
||||
import (
|
||||
"github.com/minio/minio/pkg/wildcard"
|
||||
types "github.com/nirmata/kube-policy/pkg/apis/policy/v1alpha1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// kind is the type of object being manipulated
|
||||
// Checks requests kind, name and labels to fit the policy
|
||||
func IsRuleApplicableToResource(resourceRaw []byte, description types.ResourceDescription) (bool, error) {
|
||||
kind := ParseKindFromObject(resourceRaw)
|
||||
if description.Kind != kind {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if resourceRaw != nil {
|
||||
meta := ParseMetadataFromObject(resourceRaw)
|
||||
name := ParseNameFromObject(resourceRaw)
|
||||
|
||||
if description.Name != nil {
|
||||
|
||||
if !wildcard.Match(*description.Name, name) {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
if description.Selector != nil {
|
||||
selector, err := metav1.LabelSelectorAsSelector(description.Selector)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
labelMap := ParseLabelsFromMetadata(meta)
|
||||
|
||||
if !selector.Matches(labelMap) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
Loading…
Add table
Reference in a new issue