mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
754 removing redundant code
This commit is contained in:
parent
2e8cb1e482
commit
a369675e08
1 changed files with 1 additions and 7 deletions
|
@ -79,6 +79,7 @@ func ValidateResource(patchedResource unstructured.Unstructured, kind string) er
|
||||||
kind = openApiGlobalState.kindToDefinitionName[kind]
|
kind = openApiGlobalState.kindToDefinitionName[kind]
|
||||||
schema := openApiGlobalState.models.LookupModel(kind)
|
schema := openApiGlobalState.models.LookupModel(kind)
|
||||||
if schema == nil {
|
if schema == nil {
|
||||||
|
// Check if kind is a CRD
|
||||||
schema, err = getSchemaFromDefinitions(kind)
|
schema, err = getSchemaFromDefinitions(kind)
|
||||||
if err != nil || schema == nil {
|
if err != nil || schema == nil {
|
||||||
return fmt.Errorf("pre-validation: couldn't find model %s", kind)
|
return fmt.Errorf("pre-validation: couldn't find model %s", kind)
|
||||||
|
@ -108,13 +109,6 @@ func validatePolicyMutation(policy v1.ClusterPolicy) error {
|
||||||
var kindToRules = make(map[string][]v1.Rule)
|
var kindToRules = make(map[string][]v1.Rule)
|
||||||
for _, rule := range policy.Spec.Rules {
|
for _, rule := range policy.Spec.Rules {
|
||||||
if rule.HasMutate() {
|
if rule.HasMutate() {
|
||||||
rule.MatchResources = v1.MatchResources{
|
|
||||||
UserInfo: v1.UserInfo{},
|
|
||||||
ResourceDescription: v1.ResourceDescription{
|
|
||||||
Kinds: rule.MatchResources.Kinds,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
rule.ExcludeResources = v1.ExcludeResources{}
|
|
||||||
for _, kind := range rule.MatchResources.Kinds {
|
for _, kind := range rule.MatchResources.Kinds {
|
||||||
kindToRules[kind] = append(kindToRules[kind], rule)
|
kindToRules[kind] = append(kindToRules[kind], rule)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue