diff --git a/ingress/kube/annotations/retry_test.go b/ingress/kube/annotations/retry_test.go index 0552a0768..d33c99c1f 100644 --- a/ingress/kube/annotations/retry_test.go +++ b/ingress/kube/annotations/retry_test.go @@ -19,6 +19,7 @@ import ( "testing" "github.com/gogo/protobuf/types" + "github.com/stretchr/testify/assert" networking "istio.io/api/networking/v1alpha3" ) @@ -100,9 +101,7 @@ func TestRetryParse(t *testing.T) { t.Run("", func(t *testing.T) { config := &Ingress{} _ = retry.Parse(inputCase.input, config, nil) - if !reflect.DeepEqual(inputCase.expect, config.Retry) { - t.Fatalf("Should be equal") - } + assert.Equal(t, inputCase.expect, config.Retry) }) } } diff --git a/ingress/kube/ingress/controller.go b/ingress/kube/ingress/controller.go index 76fb015c3..1fc1c71cf 100644 --- a/ingress/kube/ingress/controller.go +++ b/ingress/kube/ingress/controller.go @@ -379,15 +379,15 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp preDomainBuilder, _ := convertOptions.IngressDomainCache.Valid[rule.Host] if !exist { wrapperGateway = &common.WrapperGateway{ - Gateway: &networking.Gateway{ - Selector: map[string]string{ - c.options.GatewaySelectorKey: c.options.GatewaySelectorValue, - }, - }, + Gateway: &networking.Gateway{}, WrapperConfig: wrapper, ClusterId: c.options.ClusterId, Host: rule.Host, } + if c.options.GatewaySelectorKey != "" { + wrapperGateway.Gateway.Selector = map[string]string{c.options.GatewaySelectorKey: c.options.GatewaySelectorValue} + + } wrapperGateway.Gateway.Servers = append(wrapperGateway.Gateway.Servers, &networking.Server{ Port: &networking.Port{ Number: 80, diff --git a/ingress/kube/ingressv1/controller.go b/ingress/kube/ingressv1/controller.go index b43872e5e..0c2c48d3a 100644 --- a/ingress/kube/ingressv1/controller.go +++ b/ingress/kube/ingressv1/controller.go @@ -373,15 +373,15 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp preDomainBuilder, _ := convertOptions.IngressDomainCache.Valid[rule.Host] if !exist { wrapperGateway = &common.WrapperGateway{ - Gateway: &networking.Gateway{ - Selector: map[string]string{ - c.options.GatewaySelectorKey: c.options.GatewaySelectorValue, - }, - }, + Gateway: &networking.Gateway{}, WrapperConfig: wrapper, ClusterId: c.options.ClusterId, Host: rule.Host, } + if c.options.GatewaySelectorKey != "" { + wrapperGateway.Gateway.Selector = map[string]string{c.options.GatewaySelectorKey: c.options.GatewaySelectorValue} + + } wrapperGateway.Gateway.Servers = append(wrapperGateway.Gateway.Servers, &networking.Server{ Port: &networking.Port{ Number: 80,