This is an automated email from the ASF dual-hosted git repository.

ronething pushed a commit to branch feat/gatewayproxy_webhook
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git

commit 02dffe4f11f3f5b51761308df1224f301ec44cec
Author: Ashing Zheng <[email protected]>
AuthorDate: Fri Oct 10 17:19:15 2025 +0800

    fix: r
    
    Signed-off-by: Ashing Zheng <[email protected]>
---
 internal/provider/init/init.go                   |  3 ++-
 internal/provider/register.go                    |  3 ++-
 internal/webhook/v1/gatewayproxy_webhook.go      |  4 ++--
 internal/webhook/v1/gatewayproxy_webhook_test.go | 22 +++++++++++++---------
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/internal/provider/init/init.go b/internal/provider/init/init.go
index b6ed9e99..be21c07d 100644
--- a/internal/provider/init/init.go
+++ b/internal/provider/init/init.go
@@ -18,11 +18,12 @@
 package init
 
 import (
+       "github.com/go-logr/logr"
+
        "github.com/apache/apisix-ingress-controller/internal/controller/status"
        "github.com/apache/apisix-ingress-controller/internal/manager/readiness"
        "github.com/apache/apisix-ingress-controller/internal/provider"
        "github.com/apache/apisix-ingress-controller/internal/provider/apisix"
-       "github.com/go-logr/logr"
 )
 
 func init() {
diff --git a/internal/provider/register.go b/internal/provider/register.go
index fddb1af5..a9feb032 100644
--- a/internal/provider/register.go
+++ b/internal/provider/register.go
@@ -21,9 +21,10 @@ import (
        "fmt"
        "net/http"
 
+       "github.com/go-logr/logr"
+
        "github.com/apache/apisix-ingress-controller/internal/controller/status"
        "github.com/apache/apisix-ingress-controller/internal/manager/readiness"
-       "github.com/go-logr/logr"
 )
 
 type RegisterHandler interface {
diff --git a/internal/webhook/v1/gatewayproxy_webhook.go 
b/internal/webhook/v1/gatewayproxy_webhook.go
index 764e655b..2738da87 100644
--- a/internal/webhook/v1/gatewayproxy_webhook.go
+++ b/internal/webhook/v1/gatewayproxy_webhook.go
@@ -149,7 +149,7 @@ func (v *GatewayProxyCustomValidator) 
validateGatewayGroupConflict(ctx context.C
                        continue
                }
                if current.serviceKey != "" && current.serviceKey == 
otherConfig.serviceKey {
-                       return fmt.Errorf("gateway group conflict: GatewayProxy 
%s/%s and %s/%s both target %s while sharing %s",
+                       return fmt.Errorf("gateway proxy configuration 
conflict: GatewayProxy %s/%s and %s/%s both target %s while sharing %s",
                                gp.GetNamespace(), gp.GetName(),
                                other.GetNamespace(), other.GetName(),
                                current.serviceDescription,
@@ -158,7 +158,7 @@ func (v *GatewayProxyCustomValidator) 
validateGatewayGroupConflict(ctx context.C
                }
                if len(current.endpoints) > 0 && len(otherConfig.endpoints) > 0 
{
                        if overlap := current.endpointOverlap(otherConfig); 
len(overlap) > 0 {
-                               return fmt.Errorf("gateway group conflict: 
GatewayProxy %s/%s and %s/%s both target control plane endpoints [%s] while 
sharing %s",
+                               return fmt.Errorf("gateway proxy configuration 
conflict: GatewayProxy %s/%s and %s/%s both target control plane endpoints [%s] 
while sharing %s",
                                        gp.GetNamespace(), gp.GetName(),
                                        other.GetNamespace(), other.GetName(),
                                        strings.Join(overlap, ", "),
diff --git a/internal/webhook/v1/gatewayproxy_webhook_test.go 
b/internal/webhook/v1/gatewayproxy_webhook_test.go
index 82ab018b..f10fe4c2 100644
--- a/internal/webhook/v1/gatewayproxy_webhook_test.go
+++ b/internal/webhook/v1/gatewayproxy_webhook_test.go
@@ -29,6 +29,10 @@ import (
        v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1"
 )
 
+const (
+       candidateName = "candidate"
+)
+
 func buildGatewayProxyValidator(t *testing.T, objects ...runtime.Object) 
*GatewayProxyCustomValidator {
        t.Helper()
 
@@ -209,12 +213,12 @@ func TestGatewayProxyValidator_DetectsServiceConflict(t 
*testing.T) {
        validator := buildGatewayProxyValidator(t, existing, service, secret)
 
        candidate := newGatewayProxy()
-       candidate.Name = "candidate"
+       candidate.Name = candidateName
 
        warnings, err := validator.ValidateCreate(context.Background(), 
candidate)
        require.Error(t, err)
        require.Len(t, warnings, 0)
-       require.Contains(t, err.Error(), "gateway group conflict")
+       require.Contains(t, err.Error(), "gateway proxy configuration conflict")
        require.Contains(t, err.Error(), "Service default/control-plane port 
9180")
        require.Contains(t, err.Error(), "AdminKey secret default/admin-key key 
token")
 }
@@ -232,12 +236,12 @@ func TestGatewayProxyValidator_DetectsEndpointConflict(t 
*testing.T) {
        }
        validator := buildGatewayProxyValidator(t, existing, secret)
 
-       candidate := newGatewayProxyWithEndpoints("candidate", 
[]string{"https://10.0.0.1:9443";, "https://127.0.0.1:9443"})
+       candidate := newGatewayProxyWithEndpoints(candidateName, 
[]string{"https://10.0.0.1:9443";, "https://127.0.0.1:9443"})
 
        warnings, err := validator.ValidateCreate(context.Background(), 
candidate)
        require.Error(t, err)
        require.Len(t, warnings, 0)
-       require.Contains(t, err.Error(), "gateway group conflict")
+       require.Contains(t, err.Error(), "gateway proxy configuration conflict")
        require.Contains(t, err.Error(), "endpoints [https://10.0.0.1:9443, 
https://127.0.0.1:9443]";)
        require.Contains(t, err.Error(), "AdminKey secret default/admin-key key 
token")
 }
@@ -262,7 +266,7 @@ func 
TestGatewayProxyValidator_AllowsDistinctGatewayGroups(t *testing.T) {
        validator := buildGatewayProxyValidator(t, existing, secret, service)
 
        candidate := newGatewayProxy()
-       candidate.Name = "candidate"
+       candidate.Name = candidateName
        candidate.Spec.Provider.ControlPlane.Service = 
&v1alpha1.ProviderService{
                Name: "control-plane",
                Port: 9180,
@@ -278,7 +282,7 @@ func 
TestGatewayProxyValidator_AllowsServiceConflictWithDifferentAdminSecret(t *
        existing.Name = "existing"
 
        candidate := newGatewayProxy()
-       candidate.Name = "candidate"
+       candidate.Name = candidateName
        setSecretAdminKey(candidate, "admin-key-alt", "token")
 
        service := &corev1.Service{
@@ -317,7 +321,7 @@ func 
TestGatewayProxyValidator_DetectsInlineAdminKeyConflict(t *testing.T) {
        existing := newGatewayProxyWithEndpoints("existing", 
[]string{"https://127.0.0.1:9443";, "https://10.0.0.1:9443"})
        setInlineAdminKey(existing, "inline-cred")
 
-       candidate := newGatewayProxyWithEndpoints("candidate", 
[]string{"https://10.0.0.1:9443"})
+       candidate := newGatewayProxyWithEndpoints(candidateName, 
[]string{"https://10.0.0.1:9443"})
        setInlineAdminKey(candidate, "inline-cred")
 
        validator := buildGatewayProxyValidator(t, existing)
@@ -325,7 +329,7 @@ func 
TestGatewayProxyValidator_DetectsInlineAdminKeyConflict(t *testing.T) {
        warnings, err := validator.ValidateCreate(context.Background(), 
candidate)
        require.Error(t, err)
        require.Len(t, warnings, 0)
-       require.Contains(t, err.Error(), "gateway group conflict")
+       require.Contains(t, err.Error(), "gateway proxy configuration conflict")
        require.Contains(t, err.Error(), "control plane endpoints 
[https://10.0.0.1:9443]";)
        require.Contains(t, err.Error(), "inline AdminKey value")
 }
@@ -333,7 +337,7 @@ func 
TestGatewayProxyValidator_DetectsInlineAdminKeyConflict(t *testing.T) {
 func TestGatewayProxyValidator_AllowsEndpointOverlapWithDifferentAdminKey(t 
*testing.T) {
        existing := newGatewayProxyWithEndpoints("existing", 
[]string{"https://127.0.0.1:9443";, "https://10.0.0.1:9443"})
 
-       candidate := newGatewayProxyWithEndpoints("candidate", 
[]string{"https://10.0.0.1:9443";, "https://192.168.0.1:9443"})
+       candidate := newGatewayProxyWithEndpoints(candidateName, 
[]string{"https://10.0.0.1:9443";, "https://192.168.0.1:9443"})
        setSecretAdminKey(candidate, "admin-key-alt", "token")
 
        existingSecret := &corev1.Secret{

Reply via email to