mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 14:14:39 +00:00
Fix NetworkPolicy PolicyTypes validation
The validation had an excess nested loop and also caused wrong error feedback that all policyTypes input will be reported as unsupported if any of them is wrong.
This commit is contained in:
@@ -123,10 +123,8 @@ func ValidateNetworkPolicySpec(spec *networking.NetworkPolicySpec, fldPath *fiel
|
|||||||
}
|
}
|
||||||
for i, pType := range spec.PolicyTypes {
|
for i, pType := range spec.PolicyTypes {
|
||||||
policyPath := fldPath.Child("policyTypes").Index(i)
|
policyPath := fldPath.Child("policyTypes").Index(i)
|
||||||
for _, p := range spec.PolicyTypes {
|
if !allowed.Has(string(pType)) {
|
||||||
if !allowed.Has(string(p)) {
|
allErrs = append(allErrs, field.NotSupported(policyPath, pType, []string{string(networking.PolicyTypeIngress), string(networking.PolicyTypeEgress)}))
|
||||||
allErrs = append(allErrs, field.NotSupported(policyPath, pType, []string{string(networking.PolicyTypeIngress), string(networking.PolicyTypeEgress)}))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allErrs
|
return allErrs
|
||||||
|
Reference in New Issue
Block a user