Skip to content

Commit

Permalink
Make webhook cover ApisixRoute v2beta2 (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgksgf committed Oct 9, 2021
1 parent 9dd4f40 commit 6f46ac2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/api/validation/apisix_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
v1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v1"
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2alpha1"
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1"
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2"
"github.com/apache/apisix-ingress-controller/pkg/log"
)

Expand All @@ -53,7 +54,7 @@ var ApisixRouteValidator = kwhvalidating.ValidatorFunc(
var spec interface{}

switch ar := object.(type) {
case *v2beta1.ApisixRoute:
case *v2beta2.ApisixRoute:
spec = ar.Spec

// validate plugins
Expand All @@ -67,6 +68,18 @@ var ApisixRouteValidator = kwhvalidating.ValidatorFunc(
}
}
}
case *v2beta1.ApisixRoute:
spec = ar.Spec

for _, h := range ar.Spec.HTTP {
for _, p := range h.Plugins {
if p.Enable {
plugins = append(plugins, apisixRoutePlugin{
p.Name, p.Config,
})
}
}
}
case *v2alpha1.ApisixRoute:
spec = ar.Spec

Expand Down

0 comments on commit 6f46ac2

Please sign in to comment.