Skip to content

Commit ee82b5a

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 2b0c2fa commit ee82b5a

File tree

5 files changed

+295
-78
lines changed

5 files changed

+295
-78
lines changed

internal/provider/init/init.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
package init
1919

2020
import (
21-
"github.com/go-logr/logr"
22-
2321
"github.com/apache/apisix-ingress-controller/internal/controller/status"
2422
"github.com/apache/apisix-ingress-controller/internal/manager/readiness"
2523
"github.com/apache/apisix-ingress-controller/internal/provider"

internal/provider/register.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"fmt"
2222
"net/http"
2323

24-
"github.com/go-logr/logr"
25-
2624
"github.com/apache/apisix-ingress-controller/internal/controller/status"
2725
"github.com/apache/apisix-ingress-controller/internal/manager/readiness"
2826
)

internal/webhook/v1/gatewayproxy_webhook.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ func (v *GatewayProxyCustomValidator) ValidateCreate(ctx context.Context, obj ru
6666
gatewayProxyLog.Info("Validation for GatewayProxy upon creation", "name", gp.GetName(), "namespace", gp.GetNamespace())
6767

6868
warnings := v.collectWarnings(ctx, gp)
69-
if err := v.validateGatewayGroupConflict(ctx, gp); err != nil {
70-
return warnings, err
69+
if err := v.validateGatewayProxyConflict(ctx, gp); err != nil {
70+
return nil, err
7171
}
7272

7373
return warnings, nil
@@ -81,8 +81,8 @@ func (v *GatewayProxyCustomValidator) ValidateUpdate(ctx context.Context, oldObj
8181
gatewayProxyLog.Info("Validation for GatewayProxy upon update", "name", gp.GetName(), "namespace", gp.GetNamespace())
8282

8383
warnings := v.collectWarnings(ctx, gp)
84-
if err := v.validateGatewayGroupConflict(ctx, gp); err != nil {
85-
return warnings, err
84+
if err := v.validateGatewayProxyConflict(ctx, gp); err != nil {
85+
return nil, err
8686
}
8787

8888
return warnings, nil
@@ -124,8 +124,8 @@ func (v *GatewayProxyCustomValidator) collectWarnings(ctx context.Context, gp *v
124124
return warnings
125125
}
126126

127-
func (v *GatewayProxyCustomValidator) validateGatewayGroupConflict(ctx context.Context, gp *v1alpha1.GatewayProxy) error {
128-
current := buildGatewayGroupConfig(gp)
127+
func (v *GatewayProxyCustomValidator) validateGatewayProxyConflict(ctx context.Context, gp *v1alpha1.GatewayProxy) error {
128+
current := buildGatewayProxyConfig(gp)
129129
if !current.readyForConflict() {
130130
return nil
131131
}
@@ -141,7 +141,7 @@ func (v *GatewayProxyCustomValidator) validateGatewayGroupConflict(ctx context.C
141141
// skip self
142142
continue
143143
}
144-
otherConfig := buildGatewayGroupConfig(&other)
144+
otherConfig := buildGatewayProxyConfig(&other)
145145
if !otherConfig.readyForConflict() {
146146
continue
147147
}
@@ -171,7 +171,7 @@ func (v *GatewayProxyCustomValidator) validateGatewayGroupConflict(ctx context.C
171171
return nil
172172
}
173173

174-
type gatewayGroupConfig struct {
174+
type gatewayProxyConfig struct {
175175
adminKeyKey string
176176
adminKeyDescription string
177177
serviceKey string
@@ -180,8 +180,8 @@ type gatewayGroupConfig struct {
180180
sortedEndpoints []string
181181
}
182182

183-
func buildGatewayGroupConfig(gp *v1alpha1.GatewayProxy) gatewayGroupConfig {
184-
var cfg gatewayGroupConfig
183+
func buildGatewayProxyConfig(gp *v1alpha1.GatewayProxy) gatewayProxyConfig {
184+
var cfg gatewayProxyConfig
185185

186186
if gp == nil || gp.Spec.Provider == nil || gp.Spec.Provider.Type != v1alpha1.ProviderTypeControlPlane || gp.Spec.Provider.ControlPlane == nil {
187187
return cfg
@@ -217,14 +217,14 @@ func buildGatewayGroupConfig(gp *v1alpha1.GatewayProxy) gatewayGroupConfig {
217217
return cfg
218218
}
219219

220-
func (c gatewayGroupConfig) readyForConflict() bool {
220+
func (c gatewayProxyConfig) readyForConflict() bool {
221221
if c.adminKeyKey == "" {
222222
return false
223223
}
224224
return c.serviceKey != "" || len(c.endpoints) > 0
225225
}
226226

227-
func (c gatewayGroupConfig) endpointOverlap(other gatewayGroupConfig) []string {
227+
func (c gatewayProxyConfig) endpointOverlap(other gatewayProxyConfig) []string {
228228
var overlap []string
229229
for endpoint := range c.endpoints {
230230
if _, ok := other.endpoints[endpoint]; ok {

test/e2e/framework/manifests/webhook.yaml

Lines changed: 121 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@ kind: ValidatingWebhookConfiguration
2020
metadata:
2121
name: test-webhook-{{ .Namespace }}
2222
webhooks:
23-
- name: vingress-v1.kb.io
23+
- name: vapisixconsumer-v2.kb.io
2424
clientConfig:
2525
service:
2626
name: webhook-service
2727
namespace: {{ .Namespace }}
28-
path: /validate-networking-k8s-io-v1-ingress
28+
path: /validate-apisix-apache-org-v2-apisixconsumer
2929
caBundle: {{ .CABundle }}
3030
admissionReviewVersions:
3131
- v1
3232
rules:
33-
- operations:
34-
- CREATE
35-
- UPDATE
36-
apiGroups:
37-
- networking.k8s.io
38-
apiVersions:
39-
- v1
40-
resources:
41-
- ingresses
33+
- operations:
34+
- CREATE
35+
- UPDATE
36+
apiGroups:
37+
- apisix.apache.org
38+
apiVersions:
39+
- v2
40+
resources:
41+
- apisixconsumers
4242
failurePolicy: Fail
4343
sideEffects: None
44-
- name: vingressclass-v1.kb.io
44+
- name: vapisixroute-v2.kb.io
4545
clientConfig:
4646
service:
4747
name: webhook-service
4848
namespace: {{ .Namespace }}
49-
path: /validate-networking-k8s-io-v1-ingressclass
49+
path: /validate-apisix-apache-org-v2-apisixroute
5050
caBundle: {{ .CABundle }}
5151
admissionReviewVersions:
5252
- v1
@@ -55,11 +55,53 @@ webhooks:
5555
- CREATE
5656
- UPDATE
5757
apiGroups:
58-
- networking.k8s.io
58+
- apisix.apache.org
5959
apiVersions:
60-
- v1
60+
- v2
6161
resources:
62-
- ingressclasses
62+
- apisixroutes
63+
failurePolicy: Fail
64+
sideEffects: None
65+
- name: vapisixtls-v2.kb.io
66+
clientConfig:
67+
service:
68+
name: webhook-service
69+
namespace: {{ .Namespace }}
70+
path: /validate-apisix-apache-org-v2-apisixtls
71+
caBundle: {{ .CABundle }}
72+
admissionReviewVersions:
73+
- v1
74+
rules:
75+
- operations:
76+
- CREATE
77+
- UPDATE
78+
apiGroups:
79+
- apisix.apache.org
80+
apiVersions:
81+
- v2
82+
resources:
83+
- apisixtlses
84+
failurePolicy: Fail
85+
sideEffects: None
86+
- name: vconsumer-v1alpha1.kb.io
87+
clientConfig:
88+
service:
89+
name: webhook-service
90+
namespace: {{ .Namespace }}
91+
path: /validate-apisix-apache-org-v1alpha1-consumer
92+
caBundle: {{ .CABundle }}
93+
admissionReviewVersions:
94+
- v1
95+
rules:
96+
- operations:
97+
- CREATE
98+
- UPDATE
99+
apiGroups:
100+
- apisix.apache.org
101+
apiVersions:
102+
- v1alpha1
103+
resources:
104+
- consumers
63105
failurePolicy: Fail
64106
sideEffects: None
65107
- name: vgateway-v1.kb.io
@@ -83,3 +125,66 @@ webhooks:
83125
- gateways
84126
failurePolicy: Fail
85127
sideEffects: None
128+
- name: vgatewayproxy-v1alpha1.kb.io
129+
clientConfig:
130+
service:
131+
name: webhook-service
132+
namespace: {{ .Namespace }}
133+
path: /validate-apisix-apache-org-v1alpha1-gatewayproxy
134+
caBundle: {{ .CABundle }}
135+
admissionReviewVersions:
136+
- v1
137+
rules:
138+
- operations:
139+
- CREATE
140+
- UPDATE
141+
apiGroups:
142+
- apisix.apache.org
143+
apiVersions:
144+
- v1alpha1
145+
resources:
146+
- gatewayproxies
147+
failurePolicy: Fail
148+
sideEffects: None
149+
- name: vingress-v1.kb.io
150+
clientConfig:
151+
service:
152+
name: webhook-service
153+
namespace: {{ .Namespace }}
154+
path: /validate-networking-k8s-io-v1-ingress
155+
caBundle: {{ .CABundle }}
156+
admissionReviewVersions:
157+
- v1
158+
rules:
159+
- operations:
160+
- CREATE
161+
- UPDATE
162+
apiGroups:
163+
- networking.k8s.io
164+
apiVersions:
165+
- v1
166+
resources:
167+
- ingresses
168+
failurePolicy: Fail
169+
sideEffects: None
170+
- name: vingressclass-v1.kb.io
171+
clientConfig:
172+
service:
173+
name: webhook-service
174+
namespace: {{ .Namespace }}
175+
path: /validate-networking-k8s-io-v1-ingressclass
176+
caBundle: {{ .CABundle }}
177+
admissionReviewVersions:
178+
- v1
179+
rules:
180+
- operations:
181+
- CREATE
182+
- UPDATE
183+
apiGroups:
184+
- networking.k8s.io
185+
apiVersions:
186+
- v1
187+
resources:
188+
- ingressclasses
189+
failurePolicy: Fail
190+
sideEffects: None

0 commit comments

Comments
 (0)