Skip to content

Commit

Permalink
refactor: remove redundant validation code from auth policy
Browse files Browse the repository at this point in the history
  • Loading branch information
KevFan committed Dec 8, 2023
1 parent 789e5b2 commit ff72840
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions api/v1beta2/authpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,6 @@ func (ap *AuthPolicy) TargetKey() client.ObjectKey {
}

func (ap *AuthPolicy) Validate() error {
if ap.Spec.TargetRef.Group != ("gateway.networking.k8s.io") {
return fmt.Errorf("invalid targetRef.Group %s. The only supported group is gateway.networking.k8s.io", ap.Spec.TargetRef.Group)
}

switch kind := ap.Spec.TargetRef.Kind; kind {
case
"HTTPRoute",
"Gateway":
default:
return fmt.Errorf("invalid targetRef.Kind %s. The only supported kinds are HTTPRoute and Gateway", kind)
}

if ap.Spec.TargetRef.Namespace != nil && string(*ap.Spec.TargetRef.Namespace) != ap.Namespace {
return fmt.Errorf("invalid targetRef.Namespace %s. Currently only supporting references to the same namespace", *ap.Spec.TargetRef.Namespace)
}
Expand Down

0 comments on commit ff72840

Please sign in to comment.