From 6e6d2f7a5989778c542afd479cee8ac4a9f9d44f Mon Sep 17 00:00:00 2001 From: Lubron Date: Wed, 14 Feb 2024 06:48:17 -0800 Subject: [PATCH] Replace ref package with k8s.io/utils/ptr (#6189) Closes #6163. Signed-off-by: lubronzhan --- .../v1alpha1/contourconfig_helpers_test.go | 6 +- cmd/contour/serve.go | 21 +- cmd/contour/serve_test.go | 6 +- cmd/contour/servecontext.go | 26 +- cmd/contour/servecontext_test.go | 72 +-- .../contourconfig/contourconfiguration.go | 20 +- .../contourconfiguration_test.go | 70 +-- internal/dag/accessors_test.go | 8 +- internal/dag/builder_test.go | 425 +++++++++--------- internal/dag/cache.go | 4 +- internal/dag/cache_test.go | 9 +- internal/dag/gatewayapi_processor.go | 27 +- internal/dag/gatewayapi_processor_test.go | 60 +-- internal/dag/httpproxy_processor_test.go | 22 +- internal/dag/ingress_processor.go | 4 +- internal/dag/policy.go | 6 +- internal/dag/status_test.go | 405 +++++++++-------- internal/envoy/v3/cluster_test.go | 8 +- internal/envoy/v3/listener_test.go | 10 +- .../v3/backendcavalidation_test.go | 4 +- .../featuretests/v3/backendclientauth_test.go | 6 +- internal/featuretests/v3/cluster_test.go | 4 +- .../featuretests/v3/extensionservice_test.go | 6 +- internal/featuretests/v3/externalname_test.go | 8 +- internal/featuretests/v3/httproute_test.go | 8 +- internal/featuretests/v3/ingressclass_test.go | 10 +- internal/featuretests/v3/listeners_test.go | 14 +- .../v3/redirectroutepolicy_test.go | 34 +- internal/featuretests/v3/routeweight_test.go | 14 +- internal/featuretests/v3/tcproute_test.go | 22 +- internal/featuretests/v3/tlsroute_test.go | 16 +- internal/featuretests/v3/tracing_test.go | 4 +- internal/featuretests/v3/upstreamtls_test.go | 6 +- internal/gatewayapi/helpers.go | 53 ++- internal/gatewayapi/listeners.go | 7 +- internal/gatewayapi/listeners_test.go | 67 ++- internal/ingressclass/ingressclass.go | 4 +- internal/ingressclass/ingressclass_test.go | 20 +- internal/k8s/statusaddress.go | 8 +- internal/k8s/statusaddress_test.go | 10 +- internal/metrics/metrics_test.go | 7 +- .../provisioner/controller/gateway_test.go | 48 +- .../controller/gatewayclass_test.go | 24 +- .../provisioner/equality/equality_test.go | 8 +- internal/provisioner/model/model.go | 10 +- .../objects/dataplane/dataplane.go | 20 +- .../objects/deployment/deployment.go | 12 +- .../provisioner/objects/service/service.go | 4 +- internal/ref/ref.go | 25 -- internal/status/gatewaystatus.go | 5 +- internal/status/gatewaystatus_test.go | 16 +- .../v3/endpointslicetranslator_test.go | 188 ++++---- internal/xdscache/v3/listener_test.go | 28 +- internal/xdscache/v3/route_test.go | 14 +- internal/xdscache/v3/runtime_test.go | 12 +- internal/xdscache/v3/server_test.go | 6 +- pkg/config/parameters_test.go | 79 ++-- test/e2e/deployment.go | 10 +- test/e2e/fixtures.go | 20 +- test/e2e/gateway/gateway_test.go | 22 +- test/e2e/gateway/host_rewrite_test.go | 6 +- test/e2e/gateway/request_redirect_test.go | 10 +- test/e2e/gateway/tcproute_test.go | 6 +- test/e2e/gateway/tls_gateway_test.go | 10 +- test/e2e/gateway/tls_wildcard_host_test.go | 6 +- test/e2e/httpproxy/cookie_rewrite_test.go | 24 +- test/e2e/httpproxy/external_name_test.go | 4 +- test/e2e/httpproxy/fqdn_test.go | 4 +- test/e2e/httpproxy/grpc_test.go | 6 +- test/e2e/httpproxy/httpproxy_test.go | 26 +- test/e2e/httpproxy/internal_redirect_test.go | 8 +- test/e2e/httpproxy/request_redirect_test.go | 22 +- test/e2e/incluster/leaderelection_test.go | 5 +- test/e2e/incluster/rbac_test.go | 4 +- test/e2e/ingress/backend_tls_test.go | 4 +- test/e2e/ingress/headers_policy_test.go | 4 +- test/e2e/ingress/ingress_class_test.go | 6 +- test/e2e/ingress/ingress_test.go | 6 +- test/e2e/ingress/long_path_match_test.go | 8 +- test/e2e/ingress/tls_wildcard_host_test.go | 4 +- test/e2e/provisioner/provisioner_test.go | 39 +- test/e2e/upgrade/upgrade_test.go | 6 +- 82 files changed, 1137 insertions(+), 1173 deletions(-) delete mode 100644 internal/ref/ref.go diff --git a/apis/projectcontour/v1alpha1/contourconfig_helpers_test.go b/apis/projectcontour/v1alpha1/contourconfig_helpers_test.go index c9b7279c2f6..1b6fdbcb116 100644 --- a/apis/projectcontour/v1alpha1/contourconfig_helpers_test.go +++ b/apis/projectcontour/v1alpha1/contourconfig_helpers_test.go @@ -19,9 +19,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "k8s.io/utils/ptr" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" ) func TestContourConfigurationSpecValidate(t *testing.T) { @@ -193,10 +193,10 @@ func TestContourConfigurationSpecValidate(t *testing.T) { } require.NoError(t, c.Validate()) - c.Tracing.OverallSampling = ref.To("number") + c.Tracing.OverallSampling = ptr.To("number") require.Error(t, c.Validate()) - c.Tracing.OverallSampling = ref.To("10") + c.Tracing.OverallSampling = ptr.To("10") require.NoError(t, c.Validate()) customTags := []*contour_v1alpha1.CustomTag{ diff --git a/cmd/contour/serve.go b/cmd/contour/serve.go index 4d5bb85ea66..06101fd3b15 100644 --- a/cmd/contour/serve.go +++ b/cmd/contour/serve.go @@ -36,6 +36,7 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" + "k8s.io/utils/ptr" ctrl_cache "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" @@ -59,7 +60,6 @@ import ( "github.com/projectcontour/contour/internal/k8s" "github.com/projectcontour/contour/internal/leadership" "github.com/projectcontour/contour/internal/metrics" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" "github.com/projectcontour/contour/internal/xds" contour_xds_v3 "github.com/projectcontour/contour/internal/xds/v3" @@ -804,7 +804,7 @@ func (s *Server) setupTracingService(tracingConfig *contour_v1alpha1.TracingConf var customTags []*xdscache_v3.CustomTag - if ref.Val(tracingConfig.IncludePodDetail, true) { + if ptr.Deref(tracingConfig.IncludePodDetail, true) { customTags = append(customTags, &xdscache_v3.CustomTag{ TagName: "podName", EnvironmentName: "HOSTNAME", @@ -822,16 +822,16 @@ func (s *Server) setupTracingService(tracingConfig *contour_v1alpha1.TracingConf }) } - overallSampling, err := strconv.ParseFloat(ref.Val(tracingConfig.OverallSampling, "100"), 64) + overallSampling, err := strconv.ParseFloat(ptr.Deref(tracingConfig.OverallSampling, "100"), 64) if err != nil || overallSampling == 0 { overallSampling = 100.0 } return &xdscache_v3.TracingConfig{ - ServiceName: ref.Val(tracingConfig.ServiceName, "contour"), + ServiceName: ptr.Deref(tracingConfig.ServiceName, "contour"), ExtensionServiceConfig: extensionSvcConfig, OverallSampling: overallSampling, - MaxPathTagLength: ref.Val(tracingConfig.MaxPathTagLength, 256), + MaxPathTagLength: ptr.Deref(tracingConfig.MaxPathTagLength, 256), CustomTags: customTags, }, nil } @@ -848,11 +848,12 @@ func (s *Server) setupRateLimitService(contourConfiguration contour_v1alpha1.Con } return &xdscache_v3.RateLimitConfig{ - ExtensionServiceConfig: extensionSvcConfig, - Domain: contourConfiguration.RateLimitService.Domain, - FailOpen: ref.Val(contourConfiguration.RateLimitService.FailOpen, false), - EnableXRateLimitHeaders: ref.Val(contourConfiguration.RateLimitService.EnableXRateLimitHeaders, false), - EnableResourceExhaustedCode: ref.Val(contourConfiguration.RateLimitService.EnableResourceExhaustedCode, false), + ExtensionServiceConfig: extensionSvcConfig, + Domain: contourConfiguration.RateLimitService.Domain, + + FailOpen: ptr.Deref(contourConfiguration.RateLimitService.FailOpen, false), + EnableXRateLimitHeaders: ptr.Deref(contourConfiguration.RateLimitService.EnableXRateLimitHeaders, false), + EnableResourceExhaustedCode: ptr.Deref(contourConfiguration.RateLimitService.EnableResourceExhaustedCode, false), }, nil } diff --git a/cmd/contour/serve_test.go b/cmd/contour/serve_test.go index 53113608ece..248e9bc17c4 100644 --- a/cmd/contour/serve_test.go +++ b/cmd/contour/serve_test.go @@ -20,10 +20,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/dag" - "github.com/projectcontour/contour/internal/ref" ) func TestGetDAGBuilder(t *testing.T) { @@ -102,7 +102,7 @@ func TestGetDAGBuilder(t *testing.T) { }, Remove: []string{"res-remove-key-1", "res-remove-key-2"}, }, - ApplyToIngress: ref.To(false), + ApplyToIngress: ptr.To(false), } serve := &Server{ @@ -165,7 +165,7 @@ func TestGetDAGBuilder(t *testing.T) { }, Remove: []string{"res-remove-key-1", "res-remove-key-2"}, }, - ApplyToIngress: ref.To(true), + ApplyToIngress: ptr.To(true), } serve := &Server{ diff --git a/cmd/contour/servecontext.go b/cmd/contour/servecontext.go index 3fccce59512..3a1057b6479 100644 --- a/cmd/contour/servecontext.go +++ b/cmd/contour/servecontext.go @@ -27,12 +27,12 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" xdscache_v3 "github.com/projectcontour/contour/internal/xdscache/v3" "github.com/projectcontour/contour/pkg/config" ) @@ -167,7 +167,7 @@ func grpcOptions(log logrus.FieldLogger, contourXDSConfig *contour_v1alpha1.TLS) }), } - if !ref.Val(contourXDSConfig.Insecure, false) { + if !ptr.Deref(contourXDSConfig.Insecure, false) { tlsconfig := tlsconfig(log, contourXDSConfig) creds := credentials.NewTLS(tlsconfig) opts = append(opts, grpc.Creds(creds)) @@ -345,25 +345,25 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_v1alpha1.Co timeoutParams := &contour_v1alpha1.TimeoutParameters{} if len(ctx.Config.Timeouts.RequestTimeout) > 0 { - timeoutParams.RequestTimeout = ref.To(ctx.Config.Timeouts.RequestTimeout) + timeoutParams.RequestTimeout = ptr.To(ctx.Config.Timeouts.RequestTimeout) } if len(ctx.Config.Timeouts.ConnectionIdleTimeout) > 0 { - timeoutParams.ConnectionIdleTimeout = ref.To(ctx.Config.Timeouts.ConnectionIdleTimeout) + timeoutParams.ConnectionIdleTimeout = ptr.To(ctx.Config.Timeouts.ConnectionIdleTimeout) } if len(ctx.Config.Timeouts.StreamIdleTimeout) > 0 { - timeoutParams.StreamIdleTimeout = ref.To(ctx.Config.Timeouts.StreamIdleTimeout) + timeoutParams.StreamIdleTimeout = ptr.To(ctx.Config.Timeouts.StreamIdleTimeout) } if len(ctx.Config.Timeouts.MaxConnectionDuration) > 0 { - timeoutParams.MaxConnectionDuration = ref.To(ctx.Config.Timeouts.MaxConnectionDuration) + timeoutParams.MaxConnectionDuration = ptr.To(ctx.Config.Timeouts.MaxConnectionDuration) } if len(ctx.Config.Timeouts.DelayedCloseTimeout) > 0 { - timeoutParams.DelayedCloseTimeout = ref.To(ctx.Config.Timeouts.DelayedCloseTimeout) + timeoutParams.DelayedCloseTimeout = ptr.To(ctx.Config.Timeouts.DelayedCloseTimeout) } if len(ctx.Config.Timeouts.ConnectionShutdownGracePeriod) > 0 { - timeoutParams.ConnectionShutdownGracePeriod = ref.To(ctx.Config.Timeouts.ConnectionShutdownGracePeriod) + timeoutParams.ConnectionShutdownGracePeriod = ptr.To(ctx.Config.Timeouts.ConnectionShutdownGracePeriod) } if len(ctx.Config.Timeouts.ConnectTimeout) > 0 { - timeoutParams.ConnectTimeout = ref.To(ctx.Config.Timeouts.ConnectTimeout) + timeoutParams.ConnectTimeout = ptr.To(ctx.Config.Timeouts.ConnectTimeout) } var dnsLookupFamily contour_v1alpha1.ClusterDNSFamilyType @@ -412,9 +412,9 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_v1alpha1.Co Namespace: nsedName.Namespace, }, Domain: ctx.Config.RateLimitService.Domain, - FailOpen: ref.To(ctx.Config.RateLimitService.FailOpen), - EnableXRateLimitHeaders: ref.To(ctx.Config.RateLimitService.EnableXRateLimitHeaders), - EnableResourceExhaustedCode: ref.To(ctx.Config.RateLimitService.EnableResourceExhaustedCode), + FailOpen: ptr.To(ctx.Config.RateLimitService.FailOpen), + EnableXRateLimitHeaders: ptr.To(ctx.Config.RateLimitService.EnableXRateLimitHeaders), + EnableResourceExhaustedCode: ptr.To(ctx.Config.RateLimitService.EnableResourceExhaustedCode), DefaultGlobalRateLimitPolicy: ctx.Config.RateLimitService.DefaultGlobalRateLimitPolicy, } } @@ -466,7 +466,7 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_v1alpha1.Co Set: ctx.Config.Policy.ResponseHeadersPolicy.Set, Remove: ctx.Config.Policy.ResponseHeadersPolicy.Remove, }, - ApplyToIngress: ref.To(ctx.Config.Policy.ApplyToIngress), + ApplyToIngress: ptr.To(ctx.Config.Policy.ApplyToIngress), } var clientCertificate *contour_v1alpha1.NamespacedName diff --git a/cmd/contour/servecontext_test.go b/cmd/contour/servecontext_test.go index 67c1da51d94..641a3c0ff44 100644 --- a/cmd/contour/servecontext_test.go +++ b/cmd/contour/servecontext_test.go @@ -27,12 +27,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/tsaarni/certyaml" "google.golang.org/grpc" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/pkg/config" ) @@ -93,7 +93,7 @@ func TestServeContextTLSParams(t *testing.T) { CAFile: "cacert.pem", CertFile: "contourcert.pem", KeyFile: "contourkey.pem", - Insecure: ref.To(false), + Insecure: ptr.To(false), }, expectError: false, }, @@ -101,7 +101,7 @@ func TestServeContextTLSParams(t *testing.T) { tls: &contour_v1alpha1.TLS{ CertFile: "contourcert.pem", KeyFile: "contourkey.pem", - Insecure: ref.To(false), + Insecure: ptr.To(false), }, expectError: true, }, @@ -191,7 +191,7 @@ func TestServeContextCertificateHandling(t *testing.T) { CAFile: filepath.Join(configDir, "CAcert.pem"), CertFile: filepath.Join(configDir, "contourcert.pem"), KeyFile: filepath.Join(configDir, "contourkey.pem"), - Insecure: ref.To(false), + Insecure: ptr.To(false), } // Initial set of credentials must be written into temp directory before @@ -257,7 +257,7 @@ func TestTlsVersionDeprecation(t *testing.T) { CAFile: filepath.Join(configDir, "CAcert.pem"), CertFile: filepath.Join(configDir, "contourcert.pem"), KeyFile: filepath.Join(configDir, "contourkey.pem"), - Insecure: ref.To(false), + Insecure: ptr.To(false), } err = caCert.WritePEM(contourTLS.CAFile, filepath.Join(configDir, "CAkey.pem")) @@ -386,7 +386,7 @@ func TestConvertServeContext(t *testing.T) { CAFile: "/certs/ca.crt", CertFile: "/certs/cert.crt", KeyFile: "/certs/cert.key", - Insecure: ref.To(false), + Insecure: ptr.To(false), }, }, Ingress: &contour_v1alpha1.IngressConfig{ @@ -407,9 +407,9 @@ func TestConvertServeContext(t *testing.T) { Namespace: "projectcontour", }, Listener: &contour_v1alpha1.EnvoyListenerConfig{ - UseProxyProto: ref.To(false), - DisableAllowChunkedLength: ref.To(false), - DisableMergeSlashes: ref.To(false), + UseProxyProto: ptr.To(false), + DisableAllowChunkedLength: ptr.To(false), + DisableMergeSlashes: ptr.To(false), ServerHeaderTransformation: contour_v1alpha1.OverwriteServerHeader, TLS: &contour_v1alpha1.EnvoyTLS{ MinimumProtocolVersion: "", @@ -471,8 +471,8 @@ func TestConvertServeContext(t *testing.T) { }, DefaultHTTPVersions: nil, Timeouts: &contour_v1alpha1.TimeoutParameters{ - ConnectionIdleTimeout: ref.To("60s"), - ConnectTimeout: ref.To("2s"), + ConnectionIdleTimeout: ptr.To("60s"), + ConnectTimeout: ptr.To("2s"), }, Cluster: &contour_v1alpha1.ClusterParameters{ DNSLookupFamily: contour_v1alpha1.AutoClusterDNSFamily, @@ -483,22 +483,22 @@ func TestConvertServeContext(t *testing.T) { }, }, Network: &contour_v1alpha1.NetworkParameters{ - EnvoyAdminPort: ref.To(9001), - XffNumTrustedHops: ref.To(uint32(0)), + EnvoyAdminPort: ptr.To(9001), + XffNumTrustedHops: ptr.To(uint32(0)), }, }, Gateway: nil, HTTPProxy: &contour_v1alpha1.HTTPProxyConfig{ - DisablePermitInsecure: ref.To(false), + DisablePermitInsecure: ptr.To(false), FallbackCertificate: nil, }, - EnableExternalNameService: ref.To(false), + EnableExternalNameService: ptr.To(false), RateLimitService: nil, GlobalExternalAuthorization: nil, Policy: &contour_v1alpha1.PolicyConfig{ RequestHeadersPolicy: &contour_v1alpha1.HeadersPolicy{}, ResponseHeadersPolicy: &contour_v1alpha1.HeadersPolicy{}, - ApplyToIngress: ref.To(false), + ApplyToIngress: ptr.To(false), }, Metrics: &contour_v1alpha1.MetricsConfig{ Address: "0.0.0.0", @@ -544,7 +544,7 @@ func TestConvertServeContext(t *testing.T) { Set: map[string]string{"custom-response-header-set": "foo-bar", "Host": "response-bar.com"}, Remove: []string{"custom-response-header-remove"}, }, - ApplyToIngress: ref.To(true), + ApplyToIngress: ptr.To(true), } return cfg }, @@ -610,7 +610,7 @@ func TestConvertServeContext(t *testing.T) { }, getContourConfiguration: func(cfg contour_v1alpha1.ContourConfigurationSpec) contour_v1alpha1.ContourConfigurationSpec { cfg.HTTPProxy = &contour_v1alpha1.HTTPProxyConfig{ - DisablePermitInsecure: ref.To(true), + DisablePermitInsecure: ptr.To(true), FallbackCertificate: &contour_v1alpha1.NamespacedName{ Name: "fallbackname", Namespace: "fallbacknamespace", @@ -651,9 +651,9 @@ func TestConvertServeContext(t *testing.T) { Namespace: "ratens", }, Domain: "contour", - FailOpen: ref.To(true), - EnableXRateLimitHeaders: ref.To(true), - EnableResourceExhaustedCode: ref.To(true), + FailOpen: ptr.To(true), + EnableXRateLimitHeaders: ptr.To(true), + EnableResourceExhaustedCode: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -751,7 +751,7 @@ func TestConvertServeContext(t *testing.T) { return ctx }, getContourConfiguration: func(cfg contour_v1alpha1.ContourConfigurationSpec) contour_v1alpha1.ContourConfigurationSpec { - cfg.Envoy.Listener.DisableMergeSlashes = ref.To(true) + cfg.Envoy.Listener.DisableMergeSlashes = ptr.To(true) return cfg }, }, @@ -828,10 +828,10 @@ func TestConvertServeContext(t *testing.T) { "tracing config normal": { getServeContext: func(ctx *serveContext) *serveContext { ctx.Config.Tracing = &config.Tracing{ - IncludePodDetail: ref.To(false), - ServiceName: ref.To("contour"), - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + IncludePodDetail: ptr.To(false), + ServiceName: ptr.To("contour"), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: []config.CustomTag{ { TagName: "literal", @@ -848,10 +848,10 @@ func TestConvertServeContext(t *testing.T) { }, getContourConfiguration: func(cfg contour_v1alpha1.ContourConfigurationSpec) contour_v1alpha1.ContourConfigurationSpec { cfg.Tracing = &contour_v1alpha1.TracingConfig{ - IncludePodDetail: ref.To(false), - ServiceName: ref.To("contour"), - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + IncludePodDetail: ptr.To(false), + ServiceName: ptr.To("contour"), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: []*contour_v1alpha1.CustomTag{ { TagName: "literal", @@ -889,15 +889,15 @@ func TestConvertServeContext(t *testing.T) { }, "envoy listener settings": { getServeContext: func(ctx *serveContext) *serveContext { - ctx.Config.Listener.MaxRequestsPerIOCycle = ref.To(uint32(10)) - ctx.Config.Listener.HTTP2MaxConcurrentStreams = ref.To(uint32(30)) - ctx.Config.Listener.MaxConnectionsPerListener = ref.To(uint32(50)) + ctx.Config.Listener.MaxRequestsPerIOCycle = ptr.To(uint32(10)) + ctx.Config.Listener.HTTP2MaxConcurrentStreams = ptr.To(uint32(30)) + ctx.Config.Listener.MaxConnectionsPerListener = ptr.To(uint32(50)) return ctx }, getContourConfiguration: func(cfg contour_v1alpha1.ContourConfigurationSpec) contour_v1alpha1.ContourConfigurationSpec { - cfg.Envoy.Listener.MaxRequestsPerIOCycle = ref.To(uint32(10)) - cfg.Envoy.Listener.HTTP2MaxConcurrentStreams = ref.To(uint32(30)) - cfg.Envoy.Listener.MaxConnectionsPerListener = ref.To(uint32(50)) + cfg.Envoy.Listener.MaxRequestsPerIOCycle = ptr.To(uint32(10)) + cfg.Envoy.Listener.HTTP2MaxConcurrentStreams = ptr.To(uint32(30)) + cfg.Envoy.Listener.MaxConnectionsPerListener = ptr.To(uint32(50)) return cfg }, }, diff --git a/internal/contourconfig/contourconfiguration.go b/internal/contourconfig/contourconfiguration.go index 7b89ce8c8fb..2cd3ada80a5 100644 --- a/internal/contourconfig/contourconfiguration.go +++ b/internal/contourconfig/contourconfiguration.go @@ -18,9 +18,9 @@ import ( "time" "dario.cat/mergo" + "k8s.io/utils/ptr" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" ) @@ -48,7 +48,7 @@ func Defaults() contour_v1alpha1.ContourConfigurationSpec { CAFile: "/certs/ca.crt", CertFile: "/certs/tls.crt", KeyFile: "/certs/tls.key", - Insecure: ref.To(false), + Insecure: ptr.To(false), }, }, Ingress: &contour_v1alpha1.IngressConfig{ @@ -65,9 +65,9 @@ func Defaults() contour_v1alpha1.ContourConfigurationSpec { }, Envoy: &contour_v1alpha1.EnvoyConfig{ Listener: &contour_v1alpha1.EnvoyListenerConfig{ - UseProxyProto: ref.To(false), - DisableAllowChunkedLength: ref.To(false), - DisableMergeSlashes: ref.To(false), + UseProxyProto: ptr.To(false), + DisableAllowChunkedLength: ptr.To(false), + DisableMergeSlashes: ptr.To(false), ServerHeaderTransformation: contour_v1alpha1.OverwriteServerHeader, ConnectionBalancer: "", TLS: &contour_v1alpha1.EnvoyTLS{ @@ -128,22 +128,22 @@ func Defaults() contour_v1alpha1.ContourConfigurationSpec { }, }, Network: &contour_v1alpha1.NetworkParameters{ - XffNumTrustedHops: ref.To(uint32(0)), - EnvoyAdminPort: ref.To(9001), + XffNumTrustedHops: ptr.To(uint32(0)), + EnvoyAdminPort: ptr.To(9001), }, }, Gateway: nil, HTTPProxy: &contour_v1alpha1.HTTPProxyConfig{ - DisablePermitInsecure: ref.To(false), + DisablePermitInsecure: ptr.To(false), RootNamespaces: nil, FallbackCertificate: nil, }, - EnableExternalNameService: ref.To(false), + EnableExternalNameService: ptr.To(false), RateLimitService: nil, Policy: &contour_v1alpha1.PolicyConfig{ RequestHeadersPolicy: &contour_v1alpha1.HeadersPolicy{}, ResponseHeadersPolicy: &contour_v1alpha1.HeadersPolicy{}, - ApplyToIngress: ref.To(false), + ApplyToIngress: ptr.To(false), }, Metrics: &contour_v1alpha1.MetricsConfig{ Address: "0.0.0.0", diff --git a/internal/contourconfig/contourconfiguration_test.go b/internal/contourconfig/contourconfiguration_test.go index f78e21ab0a7..caaac35e8a2 100644 --- a/internal/contourconfig/contourconfiguration_test.go +++ b/internal/contourconfig/contourconfiguration_test.go @@ -19,11 +19,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/contourconfig" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" ) @@ -37,7 +37,7 @@ func TestOverlayOnDefaults(t *testing.T) { CAFile: "/foo/ca.crt", CertFile: "/foo/tls.crt", KeyFile: "/foo/tls.key", - Insecure: ref.To(true), + Insecure: ptr.To(true), }, }, Ingress: &contour_v1alpha1.IngressConfig{ @@ -54,11 +54,11 @@ func TestOverlayOnDefaults(t *testing.T) { }, Envoy: &contour_v1alpha1.EnvoyConfig{ Listener: &contour_v1alpha1.EnvoyListenerConfig{ - UseProxyProto: ref.To(true), - DisableAllowChunkedLength: ref.To(true), - DisableMergeSlashes: ref.To(true), - MaxRequestsPerConnection: ref.To(uint32(1)), - HTTP2MaxConcurrentStreams: ref.To(uint32(10)), + UseProxyProto: ptr.To(true), + DisableAllowChunkedLength: ptr.To(true), + DisableMergeSlashes: ptr.To(true), + MaxRequestsPerConnection: ptr.To(uint32(1)), + HTTP2MaxConcurrentStreams: ptr.To(uint32(10)), ServerHeaderTransformation: contour_v1alpha1.PassThroughServerHeader, ConnectionBalancer: "yesplease", TLS: &contour_v1alpha1.EnvoyTLS{ @@ -112,13 +112,13 @@ func TestOverlayOnDefaults(t *testing.T) { "HTTP/3", }, Timeouts: &contour_v1alpha1.TimeoutParameters{ - RequestTimeout: ref.To("1s"), - ConnectionIdleTimeout: ref.To("2s"), - StreamIdleTimeout: ref.To("3s"), - MaxConnectionDuration: ref.To("4s"), - DelayedCloseTimeout: ref.To("5s"), - ConnectionShutdownGracePeriod: ref.To("6s"), - ConnectTimeout: ref.To("7s"), + RequestTimeout: ptr.To("1s"), + ConnectionIdleTimeout: ptr.To("2s"), + StreamIdleTimeout: ptr.To("3s"), + MaxConnectionDuration: ptr.To("4s"), + DelayedCloseTimeout: ptr.To("5s"), + ConnectionShutdownGracePeriod: ptr.To("6s"), + ConnectTimeout: ptr.To("7s"), }, Cluster: &contour_v1alpha1.ClusterParameters{ DNSLookupFamily: contour_v1alpha1.IPv4ClusterDNSFamily, @@ -131,8 +131,8 @@ func TestOverlayOnDefaults(t *testing.T) { }, }, Network: &contour_v1alpha1.NetworkParameters{ - XffNumTrustedHops: ref.To(uint32(77)), - EnvoyAdminPort: ref.To(9997), + XffNumTrustedHops: ptr.To(uint32(77)), + EnvoyAdminPort: ptr.To(9997), }, }, Gateway: &contour_v1alpha1.GatewayConfig{ @@ -142,22 +142,22 @@ func TestOverlayOnDefaults(t *testing.T) { }, }, HTTPProxy: &contour_v1alpha1.HTTPProxyConfig{ - DisablePermitInsecure: ref.To(true), + DisablePermitInsecure: ptr.To(true), RootNamespaces: []string{"rootnamespace"}, FallbackCertificate: &contour_v1alpha1.NamespacedName{ Namespace: "fallbackcertificatenamespace", Name: "fallbackcertificatename", }, }, - EnableExternalNameService: ref.To(true), + EnableExternalNameService: ptr.To(true), RateLimitService: &contour_v1alpha1.RateLimitServiceConfig{ ExtensionService: contour_v1alpha1.NamespacedName{ Namespace: "ratelimitservicenamespace", Name: "ratelimitservicename", }, Domain: "ratelimitservicedomain", - FailOpen: ref.To(true), - EnableXRateLimitHeaders: ref.To(true), + FailOpen: ptr.To(true), + EnableXRateLimitHeaders: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -182,7 +182,7 @@ func TestOverlayOnDefaults(t *testing.T) { Set: map[string]string{"set": "val"}, Remove: []string{"remove"}, }, - ApplyToIngress: ref.To(true), + ApplyToIngress: ptr.To(true), }, Metrics: &contour_v1alpha1.MetricsConfig{ Address: "9.8.7.6", @@ -264,13 +264,13 @@ func TestParseTimeoutPolicy(t *testing.T) { }, "timeouts all set": { config: &contour_v1alpha1.TimeoutParameters{ - RequestTimeout: ref.To("1s"), - ConnectionIdleTimeout: ref.To("2s"), - StreamIdleTimeout: ref.To("3s"), - MaxConnectionDuration: ref.To("infinity"), - DelayedCloseTimeout: ref.To("5s"), - ConnectionShutdownGracePeriod: ref.To("6s"), - ConnectTimeout: ref.To("8s"), + RequestTimeout: ptr.To("1s"), + ConnectionIdleTimeout: ptr.To("2s"), + StreamIdleTimeout: ptr.To("3s"), + MaxConnectionDuration: ptr.To("infinity"), + DelayedCloseTimeout: ptr.To("5s"), + ConnectionShutdownGracePeriod: ptr.To("6s"), + ConnectTimeout: ptr.To("8s"), }, expected: contourconfig.Timeouts{ Request: timeout.DurationSetting(time.Second), @@ -284,43 +284,43 @@ func TestParseTimeoutPolicy(t *testing.T) { }, "request timeout invalid": { config: &contour_v1alpha1.TimeoutParameters{ - RequestTimeout: ref.To("xxx"), + RequestTimeout: ptr.To("xxx"), }, errorMsg: "failed to parse request timeout", }, "connection idle timeout invalid": { config: &contour_v1alpha1.TimeoutParameters{ - ConnectionIdleTimeout: ref.To("a"), + ConnectionIdleTimeout: ptr.To("a"), }, errorMsg: "failed to parse connection idle timeout", }, "stream idle timeout invalid": { config: &contour_v1alpha1.TimeoutParameters{ - StreamIdleTimeout: ref.To("invalid"), + StreamIdleTimeout: ptr.To("invalid"), }, errorMsg: "failed to parse stream idle timeout", }, "max connection duration invalid": { config: &contour_v1alpha1.TimeoutParameters{ - MaxConnectionDuration: ref.To("xxx"), + MaxConnectionDuration: ptr.To("xxx"), }, errorMsg: "failed to parse max connection duration", }, "delayed close timeout invalid": { config: &contour_v1alpha1.TimeoutParameters{ - DelayedCloseTimeout: ref.To("xxx"), + DelayedCloseTimeout: ptr.To("xxx"), }, errorMsg: "failed to parse delayed close timeout", }, "connection shutdown grace period invalid": { config: &contour_v1alpha1.TimeoutParameters{ - ConnectionShutdownGracePeriod: ref.To("xxx"), + ConnectionShutdownGracePeriod: ptr.To("xxx"), }, errorMsg: "failed to parse connection shutdown grace period", }, "connect timeout invalid": { config: &contour_v1alpha1.TimeoutParameters{ - ConnectTimeout: ref.To("infinite"), + ConnectTimeout: ptr.To("infinite"), }, errorMsg: "failed to parse connect timeout", }, diff --git a/internal/dag/accessors_test.go b/internal/dag/accessors_test.go index 6e6b64bbedc..bc3e2b8692e 100644 --- a/internal/dag/accessors_test.go +++ b/internal/dag/accessors_test.go @@ -23,9 +23,9 @@ import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" ) func makeServicePort(name string, protocol core_v1.Protocol, port int32, extras ...any) core_v1.ServicePort { @@ -40,7 +40,7 @@ func makeServicePort(name string, protocol core_v1.Protocol, port int32, extras } if len(extras) > 1 { - p.AppProtocol = ref.To(extras[1].(string)) + p.AppProtocol = ptr.To(extras[1].(string)) } return p @@ -118,13 +118,13 @@ func TestBuilderLookupService(t *testing.T) { { Name: "k8s-h2c", Protocol: "TCP", - AppProtocol: ref.To("kubernetes.io/h2c"), + AppProtocol: ptr.To("kubernetes.io/h2c"), Port: 8443, }, { Name: "k8s-wss", Protocol: "TCP", - AppProtocol: ref.To("kubernetes.io/wss"), + AppProtocol: ptr.To("kubernetes.io/wss"), Port: 8444, }, }, diff --git a/internal/dag/builder_test.go b/internal/dag/builder_test.go index 8715b6e9694..ffeced315ff 100644 --- a/internal/dag/builder_test.go +++ b/internal/dag/builder_test.go @@ -33,7 +33,6 @@ import ( contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/status" "github.com/projectcontour/contour/internal/timeout" ) @@ -143,7 +142,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -163,7 +162,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }}, @@ -182,7 +181,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "app": "contour", @@ -215,7 +214,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -235,7 +234,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -251,7 +250,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { GatewayClassName: gatewayapi_v1.ObjectName(validClass.Name), Addresses: []gatewayapi_v1.GatewayAddress{ { - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: "1.2.3.4", }, }, @@ -261,7 +260,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -279,11 +278,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -301,11 +300,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }}, @@ -323,11 +322,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{"matching-label-key": "matching-label-value"}, }, @@ -398,14 +397,14 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef(sec2.Name, sec2.Namespace), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -429,7 +428,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -450,7 +449,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -465,7 +464,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -532,12 +531,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1.HTTPBackendRef{{ BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }}, }) @@ -899,14 +898,14 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 80, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef(sec1.Name, sec1.Namespace), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -931,11 +930,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 80, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -961,7 +960,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.TLSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -985,11 +984,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Port: 80, Protocol: gatewayapi_v1.HTTPProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -1042,11 +1041,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, Kinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: gatewayapi_v1.Kind("INVALID-KIND"), }, }, @@ -1073,11 +1072,11 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, Kinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group("invalid-group-name")), + Group: ptr.To(gatewayapi_v1.Group("invalid-group-name")), Kind: gatewayapi_v1.Kind("HTTPRoute"), }, }, @@ -1270,7 +1269,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: "kuard", }, }, @@ -1348,7 +1347,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Service", - Name: ref.To(gatewayapi_v1.ObjectName(kuardService.Name)), + Name: ptr.To(gatewayapi_v1.ObjectName(kuardService.Name)), }}, }, }, @@ -1467,7 +1466,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Service", - Name: ref.To(gatewayapi_v1.ObjectName("some-other-service")), // would need to be "kuard" to be valid. + Name: ptr.To(gatewayapi_v1.ObjectName("some-other-service")), // would need to be "kuard" to be valid. }}, }, }, @@ -1523,18 +1522,18 @@ func TestDAGInsertGatewayAPI(t *testing.T) { gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, { Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/blog"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/blog"), }, }, { Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/tech"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/tech"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -1570,7 +1569,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -1608,7 +1607,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.HTTPSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -1713,15 +1712,15 @@ func TestDAGInsertGatewayAPI(t *testing.T) { TLS: &gatewayapi_v1.GatewayTLSConfig{ CertificateRefs: []gatewayapi_v1.SecretObjectReference{ { - Group: ref.To(gatewayapi_v1.Group("custom")), - Kind: ref.To(gatewayapi_v1.Kind("shhhh")), + Group: ptr.To(gatewayapi_v1.Group("custom")), + Kind: ptr.To(gatewayapi_v1.Kind("shhhh")), Name: gatewayapi_v1.ObjectName(sec1.Name), }, }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -1748,7 +1747,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { TLS: &gatewayapi_v1.GatewayTLSConfig{}, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -1830,7 +1829,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Secret", - Name: ref.To(gatewayapi_v1.ObjectName(sec2.Name)), + Name: ptr.To(gatewayapi_v1.ObjectName(sec2.Name)), }}, }, }, @@ -1974,7 +1973,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Secret", - Name: ref.To(gatewayapi_v1.ObjectName("wrong-name")), + Name: ptr.To(gatewayapi_v1.ObjectName("wrong-name")), }}, }, }, @@ -2007,7 +2006,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.TCPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -2029,7 +2028,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: gatewayapi_v1.UDPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -2051,7 +2050,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Protocol: "projectcontour.io/HTTPUDP", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -2137,8 +2136,8 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, Headers: gatewayapi.HTTPHeaderMatch(gatewayapi_v1.HeaderMatchExact, "foo", "bar"), }}, @@ -2169,13 +2168,13 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Matches: []gatewayapi_v1.HTTPRouteMatch{ { Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/blog"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/blog"), }, }, { Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/tech"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/tech"), }, Headers: gatewayapi.HTTPHeaderMatch(gatewayapi_v1.HeaderMatchExact, "foo", "bar"), }, @@ -2270,10 +2269,10 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, - Method: ref.To(gatewayapi_v1.HTTPMethodGet), + Method: ptr.To(gatewayapi_v1.HTTPMethodGet), }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), }), @@ -2301,8 +2300,8 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { @@ -2337,12 +2336,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-1", Value: "value-1", }, @@ -2374,27 +2373,27 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-1", Value: "value-1", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-2", Value: "value-2", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-1", Value: "value-3", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "Param-1", Value: "value-4", }, @@ -2428,27 +2427,27 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-1", Value: "value-1", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-2", Value: "value-2", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-1", Value: "value-3", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.QueryParamMatchRegularExpression), Name: "Param-1", Value: "value-4", }, @@ -2484,17 +2483,17 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: "param-1", Value: "value-1", }, { - Type: ref.To(gatewayapi_v1.QueryParamMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.QueryParamMatchRegularExpression), Name: "param-1", Value: "value-2", }, @@ -2528,12 +2527,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { makeHTTPRoute("basic", "projectcontour", "test.projectcontour.io", gatewayapi_v1.HTTPRouteRule{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.QueryParamMatchRegularExpression), Name: "query-param-regex", Value: "value-%d-[a-zA-Z0-9]", }, @@ -2691,7 +2690,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi.ServiceBackendObjectRef("kuard", 8080), - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, Filters: []gatewayapi_v1.HTTPRouteFilter{ { @@ -2749,7 +2748,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi.ServiceBackendObjectRef("kuard", 8080), - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, Filters: []gatewayapi_v1.HTTPRouteFilter{ { @@ -2846,7 +2845,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi.ServiceBackendObjectRef("kuard", 8080), - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, Filters: []gatewayapi_v1.HTTPRouteFilter{{ Type: gatewayapi_v1.HTTPRouteFilterRequestHeaderModifier, @@ -2887,7 +2886,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi.ServiceBackendObjectRef("kuard", 8080), - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, Filters: []gatewayapi_v1.HTTPRouteFilter{{ Type: gatewayapi_v1.HTTPRouteFilterResponseHeaderModifier, @@ -2927,10 +2926,10 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Filters: []gatewayapi_v1.HTTPRouteFilter{{ Type: gatewayapi_v1.HTTPRouteFilterRequestRedirect, RequestRedirect: &gatewayapi_v1.HTTPRequestRedirectFilter{ - Scheme: ref.To("https"), - Hostname: ref.To(gatewayapi_v1.PreciseHostname("envoyproxy.io")), - Port: ref.To(gatewayapi_v1.PortNumber(443)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To(gatewayapi_v1.PreciseHostname("envoyproxy.io")), + Port: ptr.To(gatewayapi_v1.PortNumber(443)), + StatusCode: ptr.To(301), }, }}, }), @@ -2965,10 +2964,10 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Filters: []gatewayapi_v1.HTTPRouteFilter{{ Type: gatewayapi_v1.HTTPRouteFilterRequestRedirect, RequestRedirect: &gatewayapi_v1.HTTPRequestRedirectFilter{ - Scheme: ref.To("https"), - Hostname: ref.To(gatewayapi_v1.PreciseHostname("envoyproxy.io")), - Port: ref.To(gatewayapi_v1.PortNumber(443)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To(gatewayapi_v1.PreciseHostname("envoyproxy.io")), + Port: ptr.To(gatewayapi_v1.PortNumber(443)), + StatusCode: ptr.To(301), }, }}, }), @@ -3011,7 +3010,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { RequestRedirect: &gatewayapi_v1.HTTPRequestRedirectFilter{ Path: &gatewayapi_v1.HTTPPathModifier{ Type: gatewayapi_v1.PrefixMatchHTTPPathModifier, - ReplacePrefixMatch: ref.To("/replacement"), + ReplacePrefixMatch: ptr.To("/replacement"), }, }, }}, @@ -3046,7 +3045,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { RequestRedirect: &gatewayapi_v1.HTTPRequestRedirectFilter{ Path: &gatewayapi_v1.HTTPPathModifier{ Type: gatewayapi_v1.PrefixMatchHTTPPathModifier, - ReplacePrefixMatch: ref.To("/"), + ReplacePrefixMatch: ptr.To("/"), }, }, }}, @@ -3081,7 +3080,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { RequestRedirect: &gatewayapi_v1.HTTPRequestRedirectFilter{ Path: &gatewayapi_v1.HTTPPathModifier{ Type: gatewayapi_v1.FullPathHTTPPathModifier, - ReplaceFullPath: ref.To("/replacement"), + ReplaceFullPath: ptr.To("/replacement"), }, }, }}, @@ -3205,7 +3204,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { URLRewrite: &gatewayapi_v1.HTTPURLRewriteFilter{ Path: &gatewayapi_v1.HTTPPathModifier{ Type: gatewayapi_v1.PrefixMatchHTTPPathModifier, - ReplacePrefixMatch: ref.To("/replacement"), + ReplacePrefixMatch: ptr.To("/replacement"), }, }, }}, @@ -3239,7 +3238,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { URLRewrite: &gatewayapi_v1.HTTPURLRewriteFilter{ Path: &gatewayapi_v1.HTTPPathModifier{ Type: gatewayapi_v1.PrefixMatchHTTPPathModifier, - ReplacePrefixMatch: ref.To("/"), + ReplacePrefixMatch: ptr.To("/"), }, }, }}, @@ -3273,7 +3272,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { URLRewrite: &gatewayapi_v1.HTTPURLRewriteFilter{ Path: &gatewayapi_v1.HTTPPathModifier{ Type: gatewayapi_v1.FullPathHTTPPathModifier, - ReplaceFullPath: ref.To("/replacement"), + ReplaceFullPath: ptr.To("/replacement"), }, }, }}, @@ -3305,7 +3304,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Filters: []gatewayapi_v1.HTTPRouteFilter{{ Type: gatewayapi_v1.HTTPRouteFilterURLRewrite, URLRewrite: &gatewayapi_v1.HTTPURLRewriteFilter{ - Hostname: ref.To(gatewayapi_v1.PreciseHostname("rewritten.com")), + Hostname: ptr.To(gatewayapi_v1.PreciseHostname("rewritten.com")), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -3346,7 +3345,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { Type: gatewayapi_v1.HTTPRouteFilterURLRewrite, URLRewrite: &gatewayapi_v1.HTTPURLRewriteFilter{ - Hostname: ref.To(gatewayapi_v1.PreciseHostname("url.rewritten.com")), + Hostname: ptr.To(gatewayapi_v1.PreciseHostname("url.rewritten.com")), }, }, }, @@ -4115,12 +4114,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }}, @@ -4178,12 +4177,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }}, @@ -4202,7 +4201,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Service", - Name: ref.To(gatewayapi_v1.ObjectName(kuardService.Name)), + Name: ptr.To(gatewayapi_v1.ObjectName(kuardService.Name)), }}, }, }, @@ -4242,12 +4241,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }}, @@ -4291,12 +4290,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }}, @@ -4340,12 +4339,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }}, @@ -4389,12 +4388,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }}, @@ -4413,7 +4412,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Service", - Name: ref.To(gatewayapi_v1.ObjectName("some-other-service")), // would have to be "kuard" to be valid + Name: ptr.To(gatewayapi_v1.ObjectName("some-other-service")), // would have to be "kuard" to be valid }}, }, }, @@ -4630,9 +4629,9 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Hostnames: []gatewayapi_v1alpha2.Hostname{"tcp.projectcontour.io"}, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ BackendRefs: gatewayapi.TLSRouteBackendRefs( - gatewayapi.TLSRouteBackendRef("kuard", 8080, ref.To(int32(1))), - gatewayapi.TLSRouteBackendRef("kuard2", 8080, ref.To(int32(2))), - gatewayapi.TLSRouteBackendRef("kuard3", 8080, ref.To(int32(3))), + gatewayapi.TLSRouteBackendRef("kuard", 8080, ptr.To(int32(1))), + gatewayapi.TLSRouteBackendRef("kuard2", 8080, ptr.To(int32(2))), + gatewayapi.TLSRouteBackendRef("kuard3", 8080, ptr.To(int32(3))), ), }}, }, @@ -4677,9 +4676,9 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Hostnames: []gatewayapi_v1alpha2.Hostname{"tcp.projectcontour.io"}, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ BackendRefs: gatewayapi.TLSRouteBackendRefs( - gatewayapi.TLSRouteBackendRef("kuard", 8080, ref.To(int32(1))), - gatewayapi.TLSRouteBackendRef("kuard2", 8080, ref.To(int32(0))), - gatewayapi.TLSRouteBackendRef("kuard3", 8080, ref.To(int32(3))), + gatewayapi.TLSRouteBackendRef("kuard", 8080, ptr.To(int32(1))), + gatewayapi.TLSRouteBackendRef("kuard2", 8080, ptr.To(int32(0))), + gatewayapi.TLSRouteBackendRef("kuard3", 8080, ptr.To(int32(3))), ), }}, }, @@ -5331,7 +5330,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { { BackendRef: gatewayapi_v1alpha2.BackendRef{ BackendObjectReference: gatewayapi.ServiceBackendObjectRef("kuard", 8080), - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, Filters: []gatewayapi_v1alpha2.GRPCRouteFilter{{ Type: gatewayapi_v1alpha2.GRPCRouteFilterResponseHeaderModifier, @@ -5477,12 +5476,12 @@ func TestDAGInsertGatewayAPI(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.GRPCBackendRef{{ BackendRef: gatewayapi_v1alpha2.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1alpha2.Kind("Service")), - Namespace: ref.To(gatewayapi_v1alpha2.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1alpha2.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1alpha2.Namespace(kuardService.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1alpha2.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1alpha2.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }}, }}, @@ -6329,37 +6328,37 @@ func TestDAGInsert(t *testing.T) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: (*networking_v1.PathType)(ref.To("Exact")), + PathType: (*networking_v1.PathType)(ptr.To("Exact")), Path: "/exact", Backend: *backendv1("kuard", intstr.FromString("http")), }, { - PathType: (*networking_v1.PathType)(ref.To("Exact")), + PathType: (*networking_v1.PathType)(ptr.To("Exact")), Path: "/exact_with_regex/.*", Backend: *backendv1("kuard", intstr.FromString("http")), }, { - PathType: (*networking_v1.PathType)(ref.To("Prefix")), + PathType: (*networking_v1.PathType)(ptr.To("Prefix")), Path: "/prefix", Backend: *backendv1("kuard", intstr.FromString("http")), }, { - PathType: (*networking_v1.PathType)(ref.To("Prefix")), + PathType: (*networking_v1.PathType)(ptr.To("Prefix")), Path: "/prefix_trailing_slash/", Backend: *backendv1("kuard", intstr.FromString("http")), }, { - PathType: (*networking_v1.PathType)(ref.To("Prefix")), + PathType: (*networking_v1.PathType)(ptr.To("Prefix")), Path: "/prefix_with_regex/.*", Backend: *backendv1("kuard", intstr.FromString("http")), }, { - PathType: (*networking_v1.PathType)(ref.To("ImplementationSpecific")), + PathType: (*networking_v1.PathType)(ptr.To("ImplementationSpecific")), Path: "/implementation_specific", Backend: *backendv1("kuard", intstr.FromString("http")), }, { - PathType: (*networking_v1.PathType)(ref.To("ImplementationSpecific")), + PathType: (*networking_v1.PathType)(ptr.To("ImplementationSpecific")), Path: "/implementation_specific_with_regex/.*", Backend: *backendv1("kuard", intstr.FromString("http")), }, @@ -9009,13 +9008,13 @@ func TestDAGInsert(t *testing.T) { DomainRewrite: &contour_v1.CookieDomainRewrite{ Value: "example.com", }, - Secure: ref.To(true), - SameSite: ref.To("Strict"), + Secure: ptr.To(true), + SameSite: ptr.To("Strict"), }, { Name: "some-other-cookie", - SameSite: ref.To("Lax"), - Secure: ref.To(false), + SameSite: ptr.To("Lax"), + Secure: ptr.To(false), }, }, Services: []contour_v1.Service{{ @@ -9051,12 +9050,12 @@ func TestDAGInsert(t *testing.T) { DomainRewrite: &contour_v1.CookieDomainRewrite{ Value: "example.com", }, - Secure: ref.To(true), - SameSite: ref.To("Strict"), + Secure: ptr.To(true), + SameSite: ptr.To("Strict"), }, { Name: "some-other-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), }, }, }}, @@ -9080,11 +9079,11 @@ func TestDAGInsert(t *testing.T) { CookieRewritePolicies: []contour_v1.CookieRewritePolicy{ { Name: "some-cookie", - Secure: ref.To(true), + Secure: ptr.To(true), }, { Name: "some-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), }, }, Services: []contour_v1.Service{{ @@ -9114,11 +9113,11 @@ func TestDAGInsert(t *testing.T) { CookieRewritePolicies: []contour_v1.CookieRewritePolicy{ { Name: "some-cookie", - Secure: ref.To(true), + Secure: ptr.To(true), }, { Name: "some-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), }, }, }}, @@ -9257,7 +9256,7 @@ func TestDAGInsert(t *testing.T) { Services: []contour_v1.Service{{ Name: s14.GetName(), Port: 80, - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), }}, }, }, @@ -12279,10 +12278,10 @@ func TestDAGInsert(t *testing.T) { Prefix: "/", }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), }, }}, }, @@ -12322,10 +12321,10 @@ func TestDAGInsert(t *testing.T) { Prefix: "/", }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), }, }}, }, @@ -12374,10 +12373,10 @@ func TestDAGInsert(t *testing.T) { Prefix: "/blog", }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), }, }}, }, @@ -12527,10 +12526,10 @@ func TestDAGInsert(t *testing.T) { Prefix: "/redirect", }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), }, }, }, @@ -12984,14 +12983,14 @@ func TestDAGInsert(t *testing.T) { CookieRewritePolicies: []CookieRewritePolicy{ { Name: "some-cookie", - Path: ref.To("/foo"), - Domain: ref.To("example.com"), + Path: ptr.To("/foo"), + Domain: ptr.To("example.com"), Secure: 2, - SameSite: ref.To("Strict"), + SameSite: ptr.To("Strict"), }, { Name: "some-other-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), Secure: 1, }, }, @@ -13018,14 +13017,14 @@ func TestDAGInsert(t *testing.T) { CookieRewritePolicies: []CookieRewritePolicy{ { Name: "some-cookie", - Path: ref.To("/foo"), - Domain: ref.To("example.com"), + Path: ptr.To("/foo"), + Domain: ptr.To("example.com"), Secure: 2, - SameSite: ref.To("Strict"), + SameSite: ptr.To("Strict"), }, { Name: "some-other-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), }, }, }, @@ -13938,7 +13937,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -13998,7 +13997,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14008,7 +14007,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 81, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14061,7 +14060,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14071,11 +14070,11 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, }, }, @@ -14134,7 +14133,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14144,11 +14143,11 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, }, }, @@ -14217,7 +14216,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14227,7 +14226,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14297,7 +14296,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14355,7 +14354,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14411,7 +14410,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14421,7 +14420,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 81, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14470,7 +14469,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14480,11 +14479,11 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, }, }, @@ -14539,7 +14538,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14549,11 +14548,11 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, }, }, @@ -14621,7 +14620,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14631,7 +14630,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -14700,7 +14699,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -15994,10 +15993,10 @@ func makeHTTPRouteTimeouts(request, backendRequest string) *gatewayapi_v1.HTTPRo httpRouteTimeouts := &gatewayapi_v1.HTTPRouteTimeouts{} if request != "" { - httpRouteTimeouts.Request = ref.To(gatewayapi_v1.Duration(request)) + httpRouteTimeouts.Request = ptr.To(gatewayapi_v1.Duration(request)) } if backendRequest != "" { - httpRouteTimeouts.BackendRequest = ref.To(gatewayapi_v1.Duration(backendRequest)) + httpRouteTimeouts.BackendRequest = ptr.To(gatewayapi_v1.Duration(backendRequest)) } return httpRouteTimeouts diff --git a/internal/dag/cache.go b/internal/dag/cache.go index 59d4b4c2ec4..ac04f69ca9e 100644 --- a/internal/dag/cache.go +++ b/internal/dag/cache.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/tools/cache" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -38,7 +39,6 @@ import ( "github.com/projectcontour/contour/internal/ingressclass" "github.com/projectcontour/contour/internal/k8s" "github.com/projectcontour/contour/internal/metrics" - "github.com/projectcontour/contour/internal/ref" ) // A KubernetesCache holds Kubernetes objects and associated configuration and produces @@ -154,7 +154,7 @@ func (kc *KubernetesCache) Insert(obj any) bool { WithField("namespace", obj.GetNamespace()). WithField("kind", k8s.KindOf(obj)). WithField("ingress-class-annotation", annotation.IngressClass(obj)). - WithField("ingress-class-name", ref.Val(obj.Spec.IngressClassName, "")). + WithField("ingress-class-name", ptr.Deref(obj.Spec.IngressClassName, "")). WithField("target-ingress-classes", kc.IngressClassNames). Debug("ignoring Ingress with unmatched ingress class") return false, len(kc.ingresses) diff --git a/internal/dag/cache_test.go b/internal/dag/cache_test.go index 0a7556fd070..449ad672be6 100644 --- a/internal/dag/cache_test.go +++ b/internal/dag/cache_test.go @@ -36,7 +36,6 @@ import ( "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" "github.com/projectcontour/contour/internal/ingressclass" - "github.com/projectcontour/contour/internal/ref" ) func TestKubernetesCacheInsert(t *testing.T) { @@ -465,7 +464,7 @@ func TestKubernetesCacheInsert(t *testing.T) { Namespace: "default", }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("nginx"), + IngressClassName: ptr.To("nginx"), }, }, want: false, @@ -477,7 +476,7 @@ func TestKubernetesCacheInsert(t *testing.T) { Namespace: "default", }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("contour"), + IngressClassName: ptr.To("contour"), }, }, want: true, @@ -566,7 +565,7 @@ func TestKubernetesCacheInsert(t *testing.T) { }, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("contour"), + IngressClassName: ptr.To("contour"), }, }, want: false, @@ -581,7 +580,7 @@ func TestKubernetesCacheInsert(t *testing.T) { }, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("nginx"), + IngressClassName: ptr.To("nginx"), }, }, want: true, diff --git a/internal/dag/gatewayapi_processor.go b/internal/dag/gatewayapi_processor.go index e37880dba27..58c4479b589 100644 --- a/internal/dag/gatewayapi_processor.go +++ b/internal/dag/gatewayapi_processor.go @@ -35,7 +35,6 @@ import ( contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/gatewayapi" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/status" "github.com/projectcontour/contour/internal/timeout" ) @@ -243,7 +242,7 @@ func (p *GatewayAPIProcessor) processRoute( routeHostnames = route.Spec.Hostnames } - hosts, errs = p.computeHosts(routeHostnames, string(ref.Val(listener.listener.Hostname, ""))) + hosts, errs = p.computeHosts(routeHostnames, string(ptr.Deref(listener.listener.Hostname, ""))) for _, err := range errs { // The Gateway API spec does not indicate what to do if syntactically // invalid hostnames make it through, we're using our best judgment here. @@ -411,7 +410,7 @@ func isAddressAssigned(specAddresses []gatewayapi_v1.GatewayAddress, statusAddre for _, specAddress := range specAddresses { for _, statusAddress := range statusAddresses { // Types must match - if ref.Val(specAddress.Type, gatewayapi_v1.IPAddressType) != ref.Val(statusAddress.Type, gatewayapi_v1.IPAddressType) { + if ptr.Deref(specAddress.Type, gatewayapi_v1.IPAddressType) != ptr.Deref(statusAddress.Type, gatewayapi_v1.IPAddressType) { continue } @@ -1623,7 +1622,7 @@ func gatewayGRPCHeaderMatchConditions(matches []gatewayapi_v1alpha2.GRPCHeaderMa for _, match := range matches { // "Exact" and "RegularExpression" are the only supported match types. If match type is not specified, use "Exact" as default. var matchType string - switch ref.Val(match.Type, gatewayapi_v1.HeaderMatchExact) { + switch ptr.Deref(match.Type, gatewayapi_v1.HeaderMatchExact) { case gatewayapi_v1.HeaderMatchExact: matchType = HeaderMatchTypeExact case gatewayapi_v1.HeaderMatchRegularExpression: @@ -1769,19 +1768,19 @@ func (p *GatewayAPIProcessor) validateBackendObjectRef( routeNamespace string, ) (*Service, *meta_v1.Condition) { if !(backendObjectRef.Group == nil || *backendObjectRef.Group == "") { - return nil, ref.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonInvalidKind, fmt.Sprintf("%s.Group must be \"\"", field))) + return nil, ptr.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonInvalidKind, fmt.Sprintf("%s.Group must be \"\"", field))) } if !(backendObjectRef.Kind != nil && *backendObjectRef.Kind == "Service") { - return nil, ref.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonInvalidKind, fmt.Sprintf("%s.Kind must be 'Service'", field))) + return nil, ptr.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonInvalidKind, fmt.Sprintf("%s.Kind must be 'Service'", field))) } if backendObjectRef.Name == "" { - return nil, ref.To(resolvedRefsFalse(status.ReasonDegraded, fmt.Sprintf("%s.Name must be specified", field))) + return nil, ptr.To(resolvedRefsFalse(status.ReasonDegraded, fmt.Sprintf("%s.Name must be specified", field))) } if backendObjectRef.Port == nil { - return nil, ref.To(resolvedRefsFalse(status.ReasonDegraded, fmt.Sprintf("%s.Port must be specified", field))) + return nil, ptr.To(resolvedRefsFalse(status.ReasonDegraded, fmt.Sprintf("%s.Port must be specified", field))) } // If the backend is in a different namespace than the route, then we need to @@ -1800,7 +1799,7 @@ func (p *GatewayAPIProcessor) validateBackendObjectRef( name: string(backendObjectRef.Name), }, ) { - return nil, ref.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonRefNotPermitted, fmt.Sprintf("%s.Namespace must match the route's namespace or be covered by a ReferenceGrant", field))) + return nil, ptr.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonRefNotPermitted, fmt.Sprintf("%s.Namespace must match the route's namespace or be covered by a ReferenceGrant", field))) } } @@ -1813,12 +1812,12 @@ func (p *GatewayAPIProcessor) validateBackendObjectRef( service, err := p.dag.EnsureService(meta, int(*backendObjectRef.Port), int(*backendObjectRef.Port), p.source, p.EnableExternalNameService) if err != nil { - return nil, ref.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonBackendNotFound, fmt.Sprintf("service %q is invalid: %s", meta.Name, err))) + return nil, ptr.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonBackendNotFound, fmt.Sprintf("service %q is invalid: %s", meta.Name, err))) } service = serviceCircuitBreakerPolicy(service, p.GlobalCircuitBreakerDefaults) if err = validateAppProtocol(&service.Weighted.ServicePort); err != nil { - return nil, ref.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonUnsupportedProtocol, err.Error())) + return nil, ptr.To(resolvedRefsFalse(gatewayapi_v1.RouteReasonUnsupportedProtocol, err.Error())) } return service, nil @@ -1839,7 +1838,7 @@ func gatewayPathMatchCondition(match *gatewayapi_v1.HTTPPathMatch, routeAccessor return &PrefixMatchCondition{Prefix: "/"} } - path := ref.Val(match.Value, "/") + path := ptr.Deref(match.Value, "/") // If path match type is not defined, default to 'PathPrefix'. if match.Type == nil || *match.Type == gatewayapi_v1.PathMatchPathPrefix { @@ -1897,7 +1896,7 @@ func gatewayHeaderMatchConditions(matches []gatewayapi_v1.HTTPHeaderMatch) ([]He for _, match := range matches { // "Exact" and "RegularExpression" are the only supported match types. If match type is not specified, use "Exact" as default. var matchType string - switch ref.Val(match.Type, gatewayapi_v1.HeaderMatchExact) { + switch ptr.Deref(match.Type, gatewayapi_v1.HeaderMatchExact) { case gatewayapi_v1.HeaderMatchExact: matchType = HeaderMatchTypeExact case gatewayapi_v1.HeaderMatchRegularExpression: @@ -1933,7 +1932,7 @@ func gatewayQueryParamMatchConditions(matches []gatewayapi_v1.HTTPQueryParamMatc for _, match := range matches { var matchType string - switch ref.Val(match.Type, gatewayapi_v1.QueryParamMatchExact) { + switch ptr.Deref(match.Type, gatewayapi_v1.QueryParamMatchExact) { case gatewayapi_v1.QueryParamMatchExact: matchType = HeaderMatchTypeExact case gatewayapi_v1.QueryParamMatchRegularExpression: diff --git a/internal/dag/gatewayapi_processor_test.go b/internal/dag/gatewayapi_processor_test.go index ccf5ed0adc2..bf7e5cf71f3 100644 --- a/internal/dag/gatewayapi_processor_test.go +++ b/internal/dag/gatewayapi_processor_test.go @@ -23,11 +23,11 @@ import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/status" ) @@ -263,28 +263,28 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromAll matches all": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, namespace: "projectcontour", valid: true, }, "From.NamespacesFromSame matches": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, namespace: "projectcontour", valid: true, }, "From.NamespacesFromSame doesn't match": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, namespace: "custom", valid: false, }, "From.NamespacesFromSelector matches labels, same ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "app": "production", @@ -296,7 +296,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector matches labels, different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "something": "special", @@ -308,7 +308,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector doesn't matches labels, different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "something": "special", @@ -320,7 +320,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector matches expression 'In', different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchExpressions: []meta_v1.LabelSelectorRequirement{{ Key: "something", @@ -334,7 +334,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector matches expression 'DoesNotExist', different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchExpressions: []meta_v1.LabelSelectorRequirement{{ Key: "notthere", @@ -347,7 +347,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector doesn't match expression 'DoesNotExist', different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchExpressions: []meta_v1.LabelSelectorRequirement{{ Key: "something", @@ -360,7 +360,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector matches expression 'Exists', different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchExpressions: []meta_v1.LabelSelectorRequirement{{ Key: "notthere", @@ -373,7 +373,7 @@ func TestNamespaceMatches(t *testing.T) { }, "From.NamespacesFromSelector doesn't match expression 'Exists', different ns as gateway": { namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchExpressions: []meta_v1.LabelSelectorRequirement{{ Key: "something", @@ -459,7 +459,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -471,7 +471,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -491,7 +491,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -502,7 +502,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -521,7 +521,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -533,7 +533,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -553,7 +553,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -564,7 +564,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -584,7 +584,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -596,7 +596,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -616,7 +616,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -628,7 +628,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -648,7 +648,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -659,7 +659,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -678,7 +678,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -690,7 +690,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -710,7 +710,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-1", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -722,7 +722,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) { Name: "http-2", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, diff --git a/internal/dag/httpproxy_processor_test.go b/internal/dag/httpproxy_processor_test.go index a3a4c6c6d37..bda49fef6fb 100644 --- a/internal/dag/httpproxy_processor_test.go +++ b/internal/dag/httpproxy_processor_test.go @@ -21,10 +21,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" ) @@ -846,7 +846,7 @@ func TestDetermineExternalAuthTimeout(t *testing.T) { ResponseTimeout: timeout.DurationSetting(time.Second * 10), }, }, - want: ref.To(timeout.DurationSetting(time.Second * 10)), + want: ptr.To(timeout.DurationSetting(time.Second * 10)), wantBool: true, }, "success": { @@ -858,7 +858,7 @@ func TestDetermineExternalAuthTimeout(t *testing.T) { ResponseTimeout: timeout.DurationSetting(time.Second * 10), }, }, - want: ref.To(timeout.DurationSetting(time.Second * 20)), + want: ptr.To(timeout.DurationSetting(time.Second * 20)), wantBool: true, }, } @@ -1003,7 +1003,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "no rate limit policy is set anywhere": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), }, wantValidCond: &contour_v1.DetailedCondition{}, httpproxy: &contour_v1.HTTPProxy{ @@ -1020,7 +1020,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "default global rate limit Policy is not set": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), }, wantValidCond: &contour_v1.DetailedCondition{}, httpproxy: &contour_v1.HTTPProxy{ @@ -1069,7 +1069,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "default global rate limit policy is set but HTTPProxy is opted out": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -1106,7 +1106,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "default global rate limit policy is set but HTTPProxy defines its own global RateLimit policy": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -1169,7 +1169,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "default rate limit policy is set": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -1215,7 +1215,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "default rate limit policy is set and HTTPProxy's local rate limit should not change": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -1273,7 +1273,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "default rate limit policy is set but it is invalid": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -1320,7 +1320,7 @@ func TestValidateVirtualHostRateLimitPolicy(t *testing.T) { "global rate limit policy on HTTPProxy is invalid": { rateLimitServiceConfig: &contour_v1alpha1.RateLimitServiceConfig{ Domain: "test-domain", - FailOpen: ref.To(true), + FailOpen: ptr.To(true), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { diff --git a/internal/dag/ingress_processor.go b/internal/dag/ingress_processor.go index e207c1f56a7..d5dd05e5bed 100644 --- a/internal/dag/ingress_processor.go +++ b/internal/dag/ingress_processor.go @@ -22,11 +22,11 @@ import ( networking_v1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/annotation" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" ) // IngressProcessor translates Ingresses into DAG @@ -194,7 +194,7 @@ func (p *IngressProcessor) computeIngressRule(ing *networking_v1.Ingress, rule n for _, httppath := range httppaths(rule) { path := stringOrDefault(httppath.Path, "/") // Default to implementation specific path matching if not set. - pathType := ref.Val(httppath.PathType, networking_v1.PathTypeImplementationSpecific) + pathType := ptr.Deref(httppath.PathType, networking_v1.PathTypeImplementationSpecific) be := httppath.Backend m := types.NamespacedName{Name: be.Service.Name, Namespace: ing.Namespace} diff --git a/internal/dag/policy.go b/internal/dag/policy.go index 9550a646416..1c1ea5ea6f2 100644 --- a/internal/dag/policy.go +++ b/internal/dag/policy.go @@ -26,13 +26,13 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/annotation" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" ) @@ -356,12 +356,12 @@ func cookieRewritePolicies(policies []contour_v1.CookieRewritePolicy) ([]CookieR var path *string if p.PathRewrite != nil { policiesSet++ - path = ref.To(p.PathRewrite.Value) + path = ptr.To(p.PathRewrite.Value) } var domain *string if p.DomainRewrite != nil { policiesSet++ - domain = ref.To(p.DomainRewrite.Value) + domain = ptr.To(p.DomainRewrite.Value) } // We use a uint here since a pointer to bool cannot be // distingiuished when unset or false in golang text templates. diff --git a/internal/dag/status_test.go b/internal/dag/status_test.go index 79b9a066b12..4272f49b29e 100644 --- a/internal/dag/status_test.go +++ b/internal/dag/status_test.go @@ -34,7 +34,6 @@ import ( "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/status" ) @@ -3044,11 +3043,11 @@ func TestDAGStatus(t *testing.T) { CookieRewritePolicies: []contour_v1.CookieRewritePolicy{ { Name: "a-cookie", - Secure: ref.To(true), + Secure: ptr.To(true), }, { Name: "a-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), }, }, }}, @@ -3080,11 +3079,11 @@ func TestDAGStatus(t *testing.T) { CookieRewritePolicies: []contour_v1.CookieRewritePolicy{ { Name: "a-cookie", - Secure: ref.To(true), + Secure: ptr.To(true), }, { Name: "a-cookie", - SameSite: ref.To("Lax"), + SameSite: ptr.To("Lax"), }, }, }, @@ -4769,7 +4768,7 @@ func TestDAGStatus(t *testing.T) { Port: 80, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -4779,7 +4778,7 @@ func TestDAGStatus(t *testing.T) { Port: 81, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -4848,11 +4847,11 @@ func TestDAGStatus(t *testing.T) { Port: 443, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, }, }, @@ -5174,29 +5173,29 @@ func validGatewayStatusUpdate(listenerName string, listenerProtocol gatewayapi_v case gatewayapi_v1.HTTPProtocolType, gatewayapi_v1.HTTPSProtocolType: supportedKinds = append(supportedKinds, gatewayapi_v1.RouteGroupKind{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: KindHTTPRoute, }, gatewayapi_v1.RouteGroupKind{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: KindGRPCRoute, }, ) case gatewayapi_v1.TLSProtocolType: supportedKinds = append(supportedKinds, gatewayapi_v1.RouteGroupKind{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: KindTLSRoute, }, gatewayapi_v1.RouteGroupKind{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: KindTCPRoute, }, ) case gatewayapi_v1.TCPProtocolType: supportedKinds = append(supportedKinds, gatewayapi_v1.RouteGroupKind{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: KindTCPRoute, }, ) @@ -5287,7 +5286,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -5451,12 +5450,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace(kuardService.Namespace)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace(kuardService.Namespace)), Name: gatewayapi_v1.ObjectName(kuardService.Name), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, - Weight: ref.To(int32(1)), + Weight: ptr.To(int32(1)), }, }, }, @@ -5564,8 +5563,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("doesnt-start-with-slash"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("doesnt-start-with-slash"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -5611,8 +5610,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchExact), - Value: ref.To("doesnt-start-with-slash"), + Type: ptr.To(gatewayapi_v1.PathMatchExact), + Value: ptr.To("doesnt-start-with-slash"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -5702,8 +5701,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/foo///bar"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/foo///bar"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -5750,8 +5749,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchExact), - Value: ref.To("//foo/bar"), + Type: ptr.To(gatewayapi_v1.PathMatchExact), + Value: ptr.To("//foo/bar"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -5798,8 +5797,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchType("UNKNOWN")), // <---- unknown type to break the test - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchType("UNKNOWN")), // <---- unknown type to break the test + Value: ptr.To("/"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -5840,12 +5839,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, Headers: []gatewayapi_v1.HTTPHeaderMatch{ { - Type: ref.To(gatewayapi_v1.HeaderMatchType("UNKNOWN")), // <---- unknown type to break the test + Type: ptr.To(gatewayapi_v1.HeaderMatchType("UNKNOWN")), // <---- unknown type to break the test Name: gatewayapi_v1.HTTPHeaderName("foo"), Value: "bar", }, @@ -5889,12 +5888,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, Headers: []gatewayapi_v1.HTTPHeaderMatch{ { - Type: ref.To(gatewayapi_v1.HeaderMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.HeaderMatchRegularExpression), Name: gatewayapi_v1.HTTPHeaderName("foo"), Value: "invalid-regrex\\", }, @@ -5938,12 +5937,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.QueryParamMatchRegularExpression), Name: "param-1", Value: "valid-[a-z]?-[A-Za-z]+-[0=9]+-\\d+", }, @@ -5992,12 +5991,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.QueryParamMatchRegularExpression), Name: "param-1", Value: "invalid-regex????", }, @@ -6041,12 +6040,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, QueryParams: []gatewayapi_v1.HTTPQueryParamMatch{ { - Type: ref.To(gatewayapi_v1.QueryParamMatchType("Invalid")), + Type: ptr.To(gatewayapi_v1.QueryParamMatchType("Invalid")), Name: "param-1", Value: "invalid query param type", }, @@ -6093,8 +6092,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }, @@ -6136,16 +6135,16 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("invalid-one", 8080, 1), }, { Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/blog"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/blog"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("invalid-two", 8080, 1), @@ -6190,7 +6189,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: "kuard", }, }, @@ -6273,10 +6272,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace("some-other-namespace")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace("some-other-namespace")), Name: "service", - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }, @@ -6317,14 +6316,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6372,14 +6371,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6411,11 +6410,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -6452,14 +6451,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6487,7 +6486,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Secret", - Name: ref.To(gatewayapi_v1.ObjectName("secret")), + Name: ptr.To(gatewayapi_v1.ObjectName("secret")), }}, }, }, @@ -6508,14 +6507,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6563,11 +6562,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -6604,14 +6603,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6659,11 +6658,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -6700,14 +6699,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6755,11 +6754,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -6796,14 +6795,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6851,11 +6850,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -6892,14 +6891,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("secret", "tls-cert-namespace"), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -6927,7 +6926,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { }}, To: []gatewayapi_v1beta1.ReferenceGrantTo{{ Kind: "Secret", - Name: ref.To(gatewayapi_v1.ObjectName("wrong-name")), + Name: ptr.To(gatewayapi_v1.ObjectName("wrong-name")), }}, }, }, @@ -6948,11 +6947,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7138,10 +7137,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, { Name: "listener-2", @@ -7149,10 +7148,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("specific.hostname.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("specific.hostname.io")), }, }, }, @@ -7187,11 +7186,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(1), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7202,11 +7201,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(1), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7250,10 +7249,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, { Name: "listener-2", @@ -7261,10 +7260,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("specific.hostname.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("specific.hostname.io")), }, }, }, @@ -7304,11 +7303,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(1), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7319,11 +7318,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(1), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7367,10 +7366,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, }, }, @@ -7410,11 +7409,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(0), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7458,10 +7457,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, }, }, @@ -7501,11 +7500,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(0), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7581,10 +7580,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, }, }, @@ -7655,11 +7654,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AttachedRoutes: int32(1), SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -7703,10 +7702,10 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, }, }, @@ -7813,9 +7812,9 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Type: gatewayapi_v1.HTTPRouteFilterRequestMirror, RequestMirror: &gatewayapi_v1.HTTPRequestMirrorFilter{ BackendRef: gatewayapi_v1.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }}, @@ -7862,8 +7861,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Type: gatewayapi_v1.HTTPRouteFilterRequestMirror, RequestMirror: &gatewayapi_v1.HTTPRequestMirrorFilter{ BackendRef: gatewayapi_v1.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: gatewayapi_v1.ObjectName("kuard2"), }, }, @@ -7907,8 +7906,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }}, BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), @@ -7922,8 +7921,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { BackendRefs: gatewayapi.HTTPBackendRef("kuard2", 8080, 1), Matches: []gatewayapi_v1.HTTPRouteMatch{{ Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/blog"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/blog"), }, }}, Filters: []gatewayapi_v1.HTTPRouteFilter{{ @@ -7977,11 +7976,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Type: gatewayapi_v1.HTTPRouteFilterRequestMirror, RequestMirror: &gatewayapi_v1.HTTPRequestMirrorFilter{ BackendRef: gatewayapi_v1.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Namespace: ref.To(gatewayapi_v1.Namespace("some-other-namespace")), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Namespace: ptr.To(gatewayapi_v1.Namespace("some-other-namespace")), Name: gatewayapi_v1.ObjectName("kuard2"), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }}, @@ -8360,7 +8359,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8382,11 +8381,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "http", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -8411,12 +8410,12 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Kinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group("invalid-group")), + Group: ptr.To(gatewayapi_v1.Group("invalid-group")), Kind: "HTTPRoute", }, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8474,7 +8473,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { {Kind: "FooRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8532,7 +8531,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { {Kind: "TLSRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8587,14 +8586,14 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ CertificateRefs: []gatewayapi_v1.SecretObjectReference{ { - Group: ref.To(gatewayapi_v1.Group("invalid-group")), - Kind: ref.To(gatewayapi_v1.Kind("NotASecret")), + Group: ptr.To(gatewayapi_v1.Group("invalid-group")), + Kind: ptr.To(gatewayapi_v1.Kind("NotASecret")), Name: "foo", }, }, @@ -8618,11 +8617,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -8660,7 +8659,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ @@ -8687,11 +8686,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -8729,7 +8728,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: "invalid", AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8784,7 +8783,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8806,11 +8805,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -8843,7 +8842,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.TLSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -8865,11 +8864,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "tls", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TLSRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TCPRoute", }, }, @@ -8902,11 +8901,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.TLSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert", "projectcontour"), }, @@ -8930,11 +8929,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "tls", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TLSRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TCPRoute", }, }, @@ -8967,11 +8966,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.TLSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), }, }}, }, @@ -8992,11 +8991,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "tls", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TLSRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TCPRoute", }, }, @@ -9029,11 +9028,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, }}, }, @@ -9054,11 +9053,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "https", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -9092,7 +9091,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: nil, }, }, @@ -9116,11 +9115,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "http", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -9154,7 +9153,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{ MatchExpressions: []meta_v1.LabelSelectorRequirement{{ Key: "something", @@ -9184,11 +9183,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "http", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -9222,7 +9221,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSelector), + From: ptr.To(gatewayapi_v1.NamespacesFromSelector), Selector: &meta_v1.LabelSelector{}, }, }, @@ -9246,11 +9245,11 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Name: "http", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "GRPCRoute", }, }, @@ -9383,7 +9382,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { {Kind: "FooRoute"}, }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, }, }, @@ -9462,8 +9461,8 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Matches: gatewayapi.HTTPRouteMatch(gatewayapi_v1.PathMatchPathPrefix, "/"), BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), Timeouts: &gatewayapi_v1.HTTPRouteTimeouts{ - Request: ref.To(gatewayapi_v1.Duration("30s")), - BackendRequest: ref.To(gatewayapi_v1.Duration("30s")), + Request: ptr.To(gatewayapi_v1.Duration("30s")), + BackendRequest: ptr.To(gatewayapi_v1.Duration("30s")), }, }, }, @@ -9507,7 +9506,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Matches: gatewayapi.HTTPRouteMatch(gatewayapi_v1.PathMatchPathPrefix, "/"), BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), Timeouts: &gatewayapi_v1.HTTPRouteTimeouts{ - BackendRequest: ref.To(gatewayapi_v1.Duration("30s")), + BackendRequest: ptr.To(gatewayapi_v1.Duration("30s")), }, }, }, @@ -9547,7 +9546,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1.HTTPRouteRule{{ BackendRefs: gatewayapi.HTTPBackendRef("kuard", 8080, 1), Timeouts: &gatewayapi_v1.HTTPRouteTimeouts{ - Request: ref.To(gatewayapi_v1.Duration("invalid")), + Request: ptr.To(gatewayapi_v1.Duration("invalid")), }, }}, }, @@ -9672,11 +9671,11 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -9713,8 +9712,8 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }, @@ -9806,7 +9805,7 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { BackendRefs: []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: "kuard", }, }, @@ -10024,7 +10023,7 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { }, Hostnames: []gatewayapi_v1alpha2.Hostname{"test.projectcontour.io"}, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ - BackendRefs: gatewayapi.TLSRouteBackendRef(kuardService.Name, 8080, ref.To(int32(0))), + BackendRefs: gatewayapi.TLSRouteBackendRef(kuardService.Name, 8080, ptr.To(int32(0))), }}, }, }, @@ -10115,11 +10114,11 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeType("invalid-mode")), + Mode: ptr.To(gatewayapi_v1.TLSModeType("invalid-mode")), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -10178,11 +10177,11 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { Name: "tls", SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TLSRoute", }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TCPRoute", }, }, @@ -10264,7 +10263,7 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -10537,13 +10536,13 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1alpha2.GRPCRouteRule{{ Matches: []gatewayapi_v1alpha2.GRPCRouteMatch{{ Method: &gatewayapi_v1alpha2.GRPCMethodMatch{ - Type: ref.To(gatewayapi_v1alpha2.GRPCMethodMatchExact), - Service: ref.To("come.example.service"), - Method: ref.To("Login"), + Type: ptr.To(gatewayapi_v1alpha2.GRPCMethodMatchExact), + Service: ptr.To("come.example.service"), + Method: ptr.To("Login"), }, Headers: []gatewayapi_v1alpha2.GRPCHeaderMatch{ { - Type: ref.To(gatewayapi_v1.HeaderMatchType("UNKNOWN")), // <---- unknown type to break the test + Type: ptr.To(gatewayapi_v1.HeaderMatchType("UNKNOWN")), // <---- unknown type to break the test Name: gatewayapi_v1alpha2.GRPCHeaderName("foo"), Value: "bar", }, @@ -10592,13 +10591,13 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Rules: []gatewayapi_v1alpha2.GRPCRouteRule{{ Matches: []gatewayapi_v1alpha2.GRPCRouteMatch{{ Method: &gatewayapi_v1alpha2.GRPCMethodMatch{ - Type: ref.To(gatewayapi_v1alpha2.GRPCMethodMatchExact), - Service: ref.To("come.example.service"), - Method: ref.To("Login"), + Type: ptr.To(gatewayapi_v1alpha2.GRPCMethodMatchExact), + Service: ptr.To("come.example.service"), + Method: ptr.To("Login"), }, Headers: []gatewayapi_v1alpha2.GRPCHeaderMatch{ { - Type: ref.To(gatewayapi_v1.HeaderMatchRegularExpression), + Type: ptr.To(gatewayapi_v1.HeaderMatchRegularExpression), Name: gatewayapi_v1alpha2.GRPCHeaderName("foo"), Value: "invalid(-)regex)", }, @@ -10807,9 +10806,9 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Type: gatewayapi_v1alpha2.GRPCRouteFilterRequestMirror, RequestMirror: &gatewayapi_v1.HTTPRequestMirrorFilter{ BackendRef: gatewayapi_v1.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }}, @@ -11149,7 +11148,7 @@ func TestGatewayAPITCPRouteDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.TCPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -11239,7 +11238,7 @@ func TestGatewayAPITCPRouteDAGStatus(t *testing.T) { {Kind: "TCPRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -11295,10 +11294,10 @@ func TestGatewayAPITCPRouteDAGStatus(t *testing.T) { }, Rules: []gatewayapi_v1alpha2.TCPRouteRule{ { - BackendRefs: gatewayapi.TLSRouteBackendRef("kuard", 8080, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("kuard", 8080, ptr.To(int32(1))), }, { - BackendRefs: gatewayapi.TLSRouteBackendRef("kuard2", 8080, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("kuard2", 8080, ptr.To(int32(1))), }, }, }, @@ -11369,7 +11368,7 @@ func TestGatewayAPITCPRouteDAGStatus(t *testing.T) { }, Rules: []gatewayapi_v1alpha2.TCPRouteRule{ { - BackendRefs: gatewayapi.TLSRouteBackendRef("nonexistent", 8080, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("nonexistent", 8080, ptr.To(int32(1))), }, }, }, @@ -11451,7 +11450,7 @@ func TestGatewayAPIBackendTLSPolicyDAGStatus(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, diff --git a/internal/envoy/v3/cluster_test.go b/internal/envoy/v3/cluster_test.go index db421b658cf..d8b4670a7fe 100644 --- a/internal/envoy/v3/cluster_test.go +++ b/internal/envoy/v3/cluster_test.go @@ -31,11 +31,11 @@ import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "github.com/projectcontour/contour/internal/dag" "github.com/projectcontour/contour/internal/envoy" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" "github.com/projectcontour/contour/internal/xds" ) @@ -726,7 +726,7 @@ func TestCluster(t *testing.T) { "cluster with per connection buffer limit bytes set": { cluster: &dag.Cluster{ Upstream: service(s1), - PerConnectionBufferLimitBytes: ref.To(uint32(32768)), + PerConnectionBufferLimitBytes: ptr.To(uint32(32768)), }, want: &envoy_config_cluster_v3.Cluster{ Name: "default/kuard/443/da39a3ee5e", @@ -742,7 +742,7 @@ func TestCluster(t *testing.T) { "cluster with max requests per connection set": { cluster: &dag.Cluster{ Upstream: service(s1), - MaxRequestsPerConnection: ref.To(uint32(1)), + MaxRequestsPerConnection: ptr.To(uint32(1)), }, want: &envoy_config_cluster_v3.Cluster{ Name: "default/kuard/443/da39a3ee5e", @@ -771,7 +771,7 @@ func TestCluster(t *testing.T) { "cluster with max requests per connection and idle timeout set": { cluster: &dag.Cluster{ Upstream: service(s1), - MaxRequestsPerConnection: ref.To(uint32(1)), + MaxRequestsPerConnection: ptr.To(uint32(1)), TimeoutPolicy: dag.ClusterTimeoutPolicy{ IdleConnectionTimeout: timeout.DurationSetting(time.Second * 60), }, diff --git a/internal/envoy/v3/listener_test.go b/internal/envoy/v3/listener_test.go index 598c4e02e32..e2aa3a64fee 100644 --- a/internal/envoy/v3/listener_test.go +++ b/internal/envoy/v3/listener_test.go @@ -41,12 +41,12 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/dag" "github.com/projectcontour/contour/internal/envoy" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" ) @@ -162,7 +162,7 @@ func TestListener(t *testing.T) { name: "http", address: "0.0.0.0", port: 9000, - perConnectionBufferLimitBytes: ref.To(uint32(32768)), + perConnectionBufferLimitBytes: ptr.To(uint32(32768)), f: []*envoy_config_listener_v3.Filter{ HTTPConnectionManager("http", FileAccessLogEnvoy("/dev/null", "", nil, contour_v1alpha1.LogLevelInfo), 0), }, @@ -180,7 +180,7 @@ func TestListener(t *testing.T) { name: "https", address: "0.0.0.0", port: 9000, - perConnectionBufferLimitBytes: ref.To(uint32(32768)), + perConnectionBufferLimitBytes: ptr.To(uint32(32768)), lf: ListenerFilters( TLSInspector(), ), @@ -1362,7 +1362,7 @@ func TestHTTPConnectionManager(t *testing.T) { "maxRequestsPerConnection set to 1": { routename: "default/kuard", accesslogger: FileAccessLogEnvoy("/dev/stdout", "", nil, contour_v1alpha1.LogLevelInfo), - maxRequestsPerConnection: ref.To(uint32(1)), + maxRequestsPerConnection: ptr.To(uint32(1)), want: &envoy_config_listener_v3.Filter{ Name: wellknown.HTTPConnectionManager, ConfigType: &envoy_config_listener_v3.Filter_TypedConfig{ @@ -1411,7 +1411,7 @@ func TestHTTPConnectionManager(t *testing.T) { "http2MaxConcurrentStreams set": { routename: "default/kuard", accesslogger: FileAccessLogEnvoy("/dev/stdout", "", nil, contour_v1alpha1.LogLevelInfo), - http2MaxConcurrentStreams: ref.To(uint32(50)), + http2MaxConcurrentStreams: ptr.To(uint32(50)), want: &envoy_config_listener_v3.Filter{ Name: wellknown.HTTPConnectionManager, ConfigType: &envoy_config_listener_v3.Filter_TypedConfig{ diff --git a/internal/featuretests/v3/backendcavalidation_test.go b/internal/featuretests/v3/backendcavalidation_test.go index 2e5c7720e44..0a3a1fbe73d 100644 --- a/internal/featuretests/v3/backendcavalidation_test.go +++ b/internal/featuretests/v3/backendcavalidation_test.go @@ -19,11 +19,11 @@ import ( envoy_service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" core_v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" ) func TestClusterServiceTLSBackendCAValidation(t *testing.T) { @@ -185,7 +185,7 @@ func TestClusterServiceTLSBackendCAValidation(t *testing.T) { Services: []contour_v1.Service{{ Name: svc.Name, Port: 443, - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), UpstreamValidation: &contour_v1.UpstreamValidation{ CACertificate: caSecret.Name, SubjectName: "subjname", diff --git a/internal/featuretests/v3/backendclientauth_test.go b/internal/featuretests/v3/backendclientauth_test.go index 9326f76ad0f..0ee16ea7173 100644 --- a/internal/featuretests/v3/backendclientauth_test.go +++ b/internal/featuretests/v3/backendclientauth_test.go @@ -22,6 +22,7 @@ import ( core_v1 "k8s.io/api/core/v1" networking_v1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" @@ -29,7 +30,6 @@ import ( envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" ) func proxyClientCertificateOpt(t *testing.T) func(*dag.Builder) { @@ -87,7 +87,7 @@ func TestBackendClientAuthenticationWithHTTPProxy(t *testing.T) { Services: []contour_v1.Service{{ Name: svc.Name, Port: 443, - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), UpstreamValidation: &contour_v1.UpstreamValidation{ CACertificate: caSecret.Name, SubjectName: "subjname", @@ -120,7 +120,7 @@ func TestBackendClientAuthenticationWithHTTPProxy(t *testing.T) { Services: []contour_v1.Service{{ Name: svc.Name, Port: 443, - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), UpstreamValidation: &contour_v1.UpstreamValidation{ CACertificate: caSecret.Name, SubjectName: "subjname", diff --git a/internal/featuretests/v3/cluster_test.go b/internal/featuretests/v3/cluster_test.go index 40a22336ed7..aedeb82c842 100644 --- a/internal/featuretests/v3/cluster_test.go +++ b/internal/featuretests/v3/cluster_test.go @@ -25,6 +25,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" @@ -34,7 +35,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" ) // projectcontour/contour#186 @@ -721,7 +721,7 @@ func TestClusterCircuitbreakerAnnotationsGateway(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, diff --git a/internal/featuretests/v3/extensionservice_test.go b/internal/featuretests/v3/extensionservice_test.go index 2d02676f5a1..93314db9505 100644 --- a/internal/featuretests/v3/extensionservice_test.go +++ b/internal/featuretests/v3/extensionservice_test.go @@ -24,13 +24,13 @@ import ( envoy_service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" envoy_matcher_v3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" core_v1 "k8s.io/api/core/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" ) func extBasic(t *testing.T, rh ResourceEventHandlerWrapper, c *Contour) { @@ -79,7 +79,7 @@ func extCleartext(t *testing.T, rh ResourceEventHandlerWrapper, c *Contour) { rh.OnAdd(&contour_v1alpha1.ExtensionService{ ObjectMeta: fixture.ObjectMeta("ns/ext"), Spec: contour_v1alpha1.ExtensionServiceSpec{ - Protocol: ref.To("h2c"), + Protocol: ptr.To("h2c"), Services: []contour_v1alpha1.ExtensionServiceTarget{ {Name: "svc1", Port: 8081}, {Name: "svc2", Port: 8082}, @@ -317,7 +317,7 @@ func extInconsistentProto(_ *testing.T, rh ResourceEventHandlerWrapper, c *Conto Services: []contour_v1alpha1.ExtensionServiceTarget{ {Name: "svc1", Port: 8081}, }, - Protocol: ref.To("h2c"), + Protocol: ptr.To("h2c"), UpstreamValidation: &contour_v1.UpstreamValidation{ CACertificate: "cacert", SubjectName: "ext.projectcontour.io", diff --git a/internal/featuretests/v3/externalname_test.go b/internal/featuretests/v3/externalname_test.go index 23e0678304f..2d3bbe43922 100644 --- a/internal/featuretests/v3/externalname_test.go +++ b/internal/featuretests/v3/externalname_test.go @@ -26,6 +26,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/dag" @@ -33,7 +34,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" ) // Assert that services of type core_v1.ServiceTypeExternalName can be @@ -172,7 +172,7 @@ func TestExternalNameService(t *testing.T) { WithSpec(contour_v1.HTTPProxySpec{ Routes: []contour_v1.Route{{ Services: []contour_v1.Service{{ - Protocol: ref.To("h2"), + Protocol: ptr.To("h2"), Name: s1.Name, Port: 80, }}, @@ -236,7 +236,7 @@ func TestExternalNameService(t *testing.T) { WithSpec(contour_v1.HTTPProxySpec{ Routes: []contour_v1.Route{{ Services: []contour_v1.Service{{ - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), Name: s1.Name, Port: 80, }}, @@ -290,7 +290,7 @@ func TestExternalNameService(t *testing.T) { WithSpec(contour_v1.HTTPProxySpec{ TCPProxy: &contour_v1.TCPProxy{ Services: []contour_v1.Service{{ - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), Name: s1.Name, Port: 80, }}, diff --git a/internal/featuretests/v3/httproute_test.go b/internal/featuretests/v3/httproute_test.go index 949ee33346a..e87c4771588 100644 --- a/internal/featuretests/v3/httproute_test.go +++ b/internal/featuretests/v3/httproute_test.go @@ -22,13 +22,13 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" ) var ( @@ -63,7 +63,7 @@ var ( Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -72,14 +72,14 @@ var ( Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert", ""), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, diff --git a/internal/featuretests/v3/ingressclass_test.go b/internal/featuretests/v3/ingressclass_test.go index c05a2d480cc..f056ca88d1c 100644 --- a/internal/featuretests/v3/ingressclass_test.go +++ b/internal/featuretests/v3/ingressclass_test.go @@ -21,6 +21,7 @@ import ( core_v1 "k8s.io/api/core/v1" networking_v1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/contour" @@ -28,7 +29,6 @@ import ( envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" ) const ( @@ -568,7 +568,7 @@ func TestIngressClassResource_Configured(t *testing.T) { ingressValid := &networking_v1.Ingress{ ObjectMeta: fixture.ObjectMeta(IngressName), Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("testingressclass"), + IngressClassName: ptr.To("testingressclass"), DefaultBackend: featuretests.IngressBackend(svc), }, } @@ -593,7 +593,7 @@ func TestIngressClassResource_Configured(t *testing.T) { ingressWrongClass := &networking_v1.Ingress{ ObjectMeta: fixture.ObjectMeta(IngressName), Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("wrongingressclass"), + IngressClassName: ptr.To("wrongingressclass"), DefaultBackend: featuretests.IngressBackend(svc), }, } @@ -812,7 +812,7 @@ func TestIngressClassResource_NotConfigured(t *testing.T) { ingressMatchingClass := &networking_v1.Ingress{ ObjectMeta: fixture.ObjectMeta(IngressName), Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("contour"), + IngressClassName: ptr.To("contour"), DefaultBackend: featuretests.IngressBackend(svc), }, } @@ -837,7 +837,7 @@ func TestIngressClassResource_NotConfigured(t *testing.T) { ingressNonMatchingClass := &networking_v1.Ingress{ ObjectMeta: fixture.ObjectMeta(IngressName), Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("notcontour"), + IngressClassName: ptr.To("notcontour"), DefaultBackend: featuretests.IngressBackend(svc), }, } diff --git a/internal/featuretests/v3/listeners_test.go b/internal/featuretests/v3/listeners_test.go index 6b60ce72860..55ed7208cab 100644 --- a/internal/featuretests/v3/listeners_test.go +++ b/internal/featuretests/v3/listeners_test.go @@ -24,6 +24,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -35,7 +36,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" "github.com/projectcontour/contour/internal/xdscache" xdscache_v3 "github.com/projectcontour/contour/internal/xdscache/v3" @@ -1298,7 +1298,7 @@ func TestGatewayListenersSetAddress(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -1307,14 +1307,14 @@ func TestGatewayListenersSetAddress(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.HTTPSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert", ""), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -1323,11 +1323,11 @@ func TestGatewayListenersSetAddress(t *testing.T) { Port: 8443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -1337,7 +1337,7 @@ func TestGatewayListenersSetAddress(t *testing.T) { Protocol: gatewayapi_v1.TCPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, diff --git a/internal/featuretests/v3/redirectroutepolicy_test.go b/internal/featuretests/v3/redirectroutepolicy_test.go index 3d8b66eae16..5a7bc7645e1 100644 --- a/internal/featuretests/v3/redirectroutepolicy_test.go +++ b/internal/featuretests/v3/redirectroutepolicy_test.go @@ -20,11 +20,11 @@ import ( envoy_service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" core_v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" ) func TestRedirectResponsePolicy_HTTProxy(t *testing.T) { @@ -40,11 +40,11 @@ func TestRedirectResponsePolicy_HTTProxy(t *testing.T) { VirtualHost: &contour_v1.VirtualHost{Fqdn: "hello.world"}, Routes: []contour_v1.Route{{ RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), - Path: ref.To("/blog"), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), + Path: ptr.To("/blog"), }, }}, }) @@ -84,11 +84,11 @@ func TestRedirectResponsePolicy_HTTProxy(t *testing.T) { VirtualHost: &contour_v1.VirtualHost{Fqdn: "hello.world"}, Routes: []contour_v1.Route{{ RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), - Prefix: ref.To("/blogprefix"), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), + Prefix: ptr.To("/blogprefix"), }, }}, }) @@ -132,12 +132,12 @@ func TestRedirectResponsePolicy_HTTProxy(t *testing.T) { Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(443)), - StatusCode: ref.To(301), - Prefix: ref.To("/blogprefix"), - Path: ref.To("/blogprefix"), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(443)), + StatusCode: ptr.To(301), + Prefix: ptr.To("/blogprefix"), + Path: ptr.To("/blogprefix"), }, }}, }) diff --git a/internal/featuretests/v3/routeweight_test.go b/internal/featuretests/v3/routeweight_test.go index c062a42a311..1e056950693 100644 --- a/internal/featuretests/v3/routeweight_test.go +++ b/internal/featuretests/v3/routeweight_test.go @@ -24,6 +24,7 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -31,7 +32,6 @@ import ( envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" ) func TestHTTPProxy_RouteWithAServiceWeight(t *testing.T) { @@ -368,7 +368,7 @@ func TestHTTPRoute_RouteWithAServiceWeight(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -484,11 +484,11 @@ func TestTLSRoute_RouteWithAServiceWeight(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -509,7 +509,7 @@ func TestTLSRoute_RouteWithAServiceWeight(t *testing.T) { }, Hostnames: []gatewayapi_v1alpha2.Hostname{"test.projectcontour.io"}, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ - BackendRefs: gatewayapi.TLSRouteBackendRef("svc1", 443, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("svc1", 443, ptr.To(int32(1))), }}, }, } @@ -557,8 +557,8 @@ func TestTLSRoute_RouteWithAServiceWeight(t *testing.T) { Hostnames: []gatewayapi_v1alpha2.Hostname{"test.projectcontour.io"}, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ BackendRefs: gatewayapi.TLSRouteBackendRefs( - gatewayapi.TLSRouteBackendRef("svc1", 443, ref.To(int32(1))), - gatewayapi.TLSRouteBackendRef("svc2", 443, ref.To(int32(7))), + gatewayapi.TLSRouteBackendRef("svc1", 443, ptr.To(int32(1))), + gatewayapi.TLSRouteBackendRef("svc2", 443, ptr.To(int32(7))), ), }}, }, diff --git a/internal/featuretests/v3/tcproute_test.go b/internal/featuretests/v3/tcproute_test.go index fce4cddd5f5..0682b5f4a5b 100644 --- a/internal/featuretests/v3/tcproute_test.go +++ b/internal/featuretests/v3/tcproute_test.go @@ -22,6 +22,7 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -29,7 +30,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" ) func TestTCPRoute(t *testing.T) { @@ -70,7 +70,7 @@ func TestTCPRoute(t *testing.T) { Protocol: gatewayapi_v1.TCPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -84,9 +84,9 @@ func TestTCPRoute(t *testing.T) { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), Name: gatewayapi_v1.ObjectName("contour"), - SectionName: ref.To(gatewayapi_v1.SectionName("tcp-1")), + SectionName: ptr.To(gatewayapi_v1.SectionName("tcp-1")), }, }, }, @@ -123,7 +123,7 @@ func TestTCPRoute(t *testing.T) { Protocol: gatewayapi_v1.TCPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }) @@ -135,9 +135,9 @@ func TestTCPRoute(t *testing.T) { CommonRouteSpec: gatewayapi_v1alpha2.CommonRouteSpec{ ParentRefs: []gatewayapi_v1alpha2.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), Name: gatewayapi_v1.ObjectName("contour"), - SectionName: ref.To(gatewayapi_v1.SectionName("tcp-2")), + SectionName: ptr.To(gatewayapi_v1.SectionName("tcp-2")), }, }, }, @@ -216,14 +216,14 @@ func TestTCPRoute_TLSTermination(t *testing.T) { Port: 5000, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert", ""), }, }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -238,9 +238,9 @@ func TestTCPRoute_TLSTermination(t *testing.T) { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), Name: gatewayapi_v1.ObjectName("contour"), - SectionName: ref.To(gatewayapi_v1.SectionName("tls")), + SectionName: ptr.To(gatewayapi_v1.SectionName("tls")), }, }, }, diff --git a/internal/featuretests/v3/tlsroute_test.go b/internal/featuretests/v3/tlsroute_test.go index 26a80bd0e85..ed59422e5f8 100644 --- a/internal/featuretests/v3/tlsroute_test.go +++ b/internal/featuretests/v3/tlsroute_test.go @@ -22,6 +22,7 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -29,7 +30,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" ) func TestTLSRoute_TLSPassthrough(t *testing.T) { @@ -68,11 +68,11 @@ func TestTLSRoute_TLSPassthrough(t *testing.T) { Port: 443, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModePassthrough), + Mode: ptr.To(gatewayapi_v1.TLSModePassthrough), }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, @@ -270,15 +270,15 @@ func TestTLSRoute_TLSTermination(t *testing.T) { Port: 5000, Protocol: gatewayapi_v1.TLSProtocolType, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert", ""), }, }, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -303,7 +303,7 @@ func TestTLSRoute_TLSTermination(t *testing.T) { "test1.projectcontour.io", }, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ - BackendRefs: gatewayapi.TLSRouteBackendRef("svc1", 80, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("svc1", 80, ptr.To(int32(1))), }}, }, }) @@ -340,7 +340,7 @@ func TestTLSRoute_TLSTermination(t *testing.T) { "test2.projectcontour.io", }, Rules: []gatewayapi_v1alpha2.TLSRouteRule{{ - BackendRefs: gatewayapi.TLSRouteBackendRef("svc2", 80, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("svc2", 80, ptr.To(int32(1))), }}, }, }) diff --git a/internal/featuretests/v3/tracing_test.go b/internal/featuretests/v3/tracing_test.go index 47565ab9047..68b148e2b5c 100644 --- a/internal/featuretests/v3/tracing_test.go +++ b/internal/featuretests/v3/tracing_test.go @@ -19,6 +19,7 @@ import ( envoy_service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" @@ -26,7 +27,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" xdscache_v3 "github.com/projectcontour/contour/internal/xdscache/v3" ) @@ -75,7 +75,7 @@ func TestTracing(t *testing.T) { Services: []contour_v1alpha1.ExtensionServiceTarget{ {Name: "otel-collector", Port: 4317}, }, - Protocol: ref.To("h2c"), + Protocol: ptr.To("h2c"), TimeoutPolicy: &contour_v1.TimeoutPolicy{ Response: defaultResponseTimeout.String(), }, diff --git a/internal/featuretests/v3/upstreamtls_test.go b/internal/featuretests/v3/upstreamtls_test.go index c965fc72826..c1f3c468446 100644 --- a/internal/featuretests/v3/upstreamtls_test.go +++ b/internal/featuretests/v3/upstreamtls_test.go @@ -25,6 +25,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -35,7 +36,6 @@ import ( "github.com/projectcontour/contour/internal/featuretests" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" ) func TestUpstreamTLSWithHTTPProxy(t *testing.T) { @@ -69,7 +69,7 @@ func TestUpstreamTLSWithHTTPProxy(t *testing.T) { Services: []contour_v1.Service{{ Name: svc.Name, Port: 443, - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), UpstreamValidation: &contour_v1.UpstreamValidation{ CACertificate: caSecret.Name, SubjectName: "subjname", @@ -269,7 +269,7 @@ func TestUpstreamTLSWithHTTPRoute(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }}, diff --git a/internal/gatewayapi/helpers.go b/internal/gatewayapi/helpers.go index ac73077b849..3e374429fdb 100644 --- a/internal/gatewayapi/helpers.go +++ b/internal/gatewayapi/helpers.go @@ -15,21 +15,20 @@ package gatewayapi import ( "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - - "github.com/projectcontour/contour/internal/ref" ) func CertificateRef(name, namespace string) gatewayapi_v1.SecretObjectReference { secretRef := gatewayapi_v1.SecretObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Secret")), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Secret")), Name: gatewayapi_v1.ObjectName(name), } if namespace != "" { - secretRef.Namespace = ref.To(gatewayapi_v1.Namespace(namespace)) + secretRef.Namespace = ptr.To(gatewayapi_v1.Namespace(namespace)) } return secretRef @@ -37,13 +36,13 @@ func CertificateRef(name, namespace string) gatewayapi_v1.SecretObjectReference func GatewayParentRef(namespace, name string) gatewayapi_v1.ParentReference { parentRef := gatewayapi_v1.ParentReference{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), - Kind: ref.To(gatewayapi_v1.Kind("Gateway")), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Kind: ptr.To(gatewayapi_v1.Kind("Gateway")), Name: gatewayapi_v1.ObjectName(name), } if namespace != "" { - parentRef.Namespace = ref.To(gatewayapi_v1.Namespace(namespace)) + parentRef.Namespace = ptr.To(gatewayapi_v1.Namespace(namespace)) } return parentRef @@ -53,11 +52,11 @@ func GatewayListenerParentRef(namespace, name, listener string, port int) gatewa parentRef := GatewayParentRef(namespace, name) if listener != "" { - parentRef.SectionName = ref.To(gatewayapi_v1.SectionName(listener)) + parentRef.SectionName = ptr.To(gatewayapi_v1.SectionName(listener)) } if port != 0 { - parentRef.Port = ref.To(gatewayapi_v1.PortNumber(port)) + parentRef.Port = ptr.To(gatewayapi_v1.PortNumber(port)) } return parentRef @@ -65,10 +64,10 @@ func GatewayListenerParentRef(namespace, name, listener string, port int) gatewa func ServiceBackendObjectRef(name string, port int) gatewayapi_v1.BackendObjectReference { return gatewayapi_v1.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: gatewayapi_v1.ObjectName(name), - Port: ref.To(gatewayapi_v1.PortNumber(port)), + Port: ptr.To(gatewayapi_v1.PortNumber(port)), } } @@ -76,8 +75,8 @@ func HTTPRouteMatch(pathType gatewayapi_v1.PathMatchType, value string) []gatewa return []gatewayapi_v1.HTTPRouteMatch{ { Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(pathType), - Value: ref.To(value), + Type: ptr.To(pathType), + Value: ptr.To(value), }, }, } @@ -86,7 +85,7 @@ func HTTPRouteMatch(pathType gatewayapi_v1.PathMatchType, value string) []gatewa func HTTPHeaderMatch(matchType gatewayapi_v1.HeaderMatchType, name, value string) []gatewayapi_v1.HTTPHeaderMatch { return []gatewayapi_v1.HTTPHeaderMatch{ { - Type: ref.To(matchType), + Type: ptr.To(matchType), Name: gatewayapi_v1.HTTPHeaderName(name), Value: value, }, @@ -98,7 +97,7 @@ func HTTPQueryParamMatches(namesAndValues map[string]string) []gatewayapi_v1.HTT for name, val := range namesAndValues { matches = append(matches, gatewayapi_v1.HTTPQueryParamMatch{ - Type: ref.To(gatewayapi_v1.QueryParamMatchExact), + Type: ptr.To(gatewayapi_v1.QueryParamMatchExact), Name: gatewayapi_v1.HTTPHeaderName(name), Value: val, }) @@ -140,10 +139,10 @@ func TLSRouteBackendRef(serviceName string, port int, weight *int32) []gatewayap return []gatewayapi_v1alpha2.BackendRef{ { BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: gatewayapi_v1alpha2.ObjectName(serviceName), - Port: ref.To(gatewayapi_v1.PortNumber(port)), + Port: ptr.To(gatewayapi_v1.PortNumber(port)), }, Weight: weight, }, @@ -155,10 +154,10 @@ func GRPCRouteBackendRef(serviceName string, port int, weight int32) []gatewayap { BackendRef: gatewayapi_v1alpha2.BackendRef{ BackendObjectReference: gatewayapi_v1alpha2.BackendObjectReference{ - Group: ref.To(gatewayapi_v1.Group("")), - Kind: ref.To(gatewayapi_v1.Kind("Service")), + Group: ptr.To(gatewayapi_v1.Group("")), + Kind: ptr.To(gatewayapi_v1.Kind("Service")), Name: gatewayapi_v1alpha2.ObjectName(serviceName), - Port: ref.To(gatewayapi_v1.PortNumber(port)), + Port: ptr.To(gatewayapi_v1.PortNumber(port)), }, Weight: &weight, }, @@ -169,16 +168,16 @@ func GRPCRouteBackendRef(serviceName string, port int, weight int32) []gatewayap func GRPCMethodMatch(matchType gatewayapi_v1alpha2.GRPCMethodMatchType, service, method string) *gatewayapi_v1alpha2.GRPCMethodMatch { return &gatewayapi_v1alpha2.GRPCMethodMatch{ - Type: ref.To(matchType), - Service: ref.To(service), - Method: ref.To(method), + Type: ptr.To(matchType), + Service: ptr.To(service), + Method: ptr.To(method), } } func GRPCHeaderMatch(matchType gatewayapi_v1.HeaderMatchType, name, value string) []gatewayapi_v1alpha2.GRPCHeaderMatch { return []gatewayapi_v1alpha2.GRPCHeaderMatch{ { - Type: ref.To(matchType), + Type: ptr.To(matchType), Name: gatewayapi_v1alpha2.GRPCHeaderName(name), Value: value, }, diff --git a/internal/gatewayapi/listeners.go b/internal/gatewayapi/listeners.go index 1e5d34d0b07..0a3f6a186ec 100644 --- a/internal/gatewayapi/listeners.go +++ b/internal/gatewayapi/listeners.go @@ -21,9 +21,8 @@ import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" - - "github.com/projectcontour/contour/internal/ref" ) // ContourHTTPSProtocolType is the protocol for an HTTPS Listener @@ -88,7 +87,7 @@ func ValidateListeners(listeners []gatewayapi_v1.Listener) ValidateListenersResu for i, listener := range listeners { // Check for a valid hostname. - if hostname := ref.Val(listener.Hostname, ""); len(hostname) > 0 { + if hostname := ptr.Deref(listener.Hostname, ""); len(hostname) > 0 { if err := IsValidHostname(string(hostname)); err != nil { result.InvalidListenerConditions[listener.Name] = meta_v1.Condition{ Type: string(gatewayapi_v1.ListenerConditionProgrammed), @@ -159,7 +158,7 @@ func ValidateListeners(listeners []gatewayapi_v1.Listener) ValidateListenersResu } // Hostname conflict - if ref.Val(listener.Hostname, "") == ref.Val(otherListener.Hostname, "") { + if ptr.Deref(listener.Hostname, "") == ptr.Deref(otherListener.Hostname, "") { result.InvalidListenerConditions[listener.Name] = conflictedCondition(gatewayapi_v1.ListenerReasonHostnameConflict, "All Listener hostnames for a given port must be unique") return true } diff --git a/internal/gatewayapi/listeners_test.go b/internal/gatewayapi/listeners_test.go index 422e0b37d2a..16d41973d12 100644 --- a/internal/gatewayapi/listeners_test.go +++ b/internal/gatewayapi/listeners_test.go @@ -18,9 +18,8 @@ import ( "github.com/stretchr/testify/assert" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" - - "github.com/projectcontour/contour/internal/ref" ) func TestValidateListeners(t *testing.T) { @@ -35,25 +34,25 @@ func TestValidateListeners(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, { Name: "listener-4", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), }, { Name: "non-http-listener-1", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, } @@ -76,25 +75,25 @@ func TestValidateListeners(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, { Name: "listener-4", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 8080, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "non-http-listener-1", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, } @@ -118,31 +117,31 @@ func TestValidateListeners(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), // duplicate hostname + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), // duplicate hostname }, { Name: "listener-4", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), }, { Name: "listener-5", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 8080, - Hostname: ref.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), }, { Name: "non-http-listener-1", Protocol: gatewayapi_v1.TLSProtocolType, // non-HTTP Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, } @@ -173,25 +172,25 @@ func TestValidateListeners(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, { Name: "listener-4", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), }, { Name: "non-http-listener-1", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, } @@ -214,25 +213,25 @@ func TestValidateListeners(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.projectcontour.io")), }, { Name: "listener-4", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 8443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "http-listener-1", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, } @@ -256,31 +255,31 @@ func TestValidateListeners(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), // duplicate hostname + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), // duplicate hostname }, { Name: "listener-4", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), }, { Name: "listener-5", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 8443, - Hostname: ref.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.envoyproxy.io")), }, { Name: "http-listener-1", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("local.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("local.projectcontour.io")), }, } @@ -306,19 +305,19 @@ func TestValidateListeners(t *testing.T) { Name: "listener-1", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("192.168.1.1")), + Hostname: ptr.To(gatewayapi_v1.Hostname("192.168.1.1")), }, { Name: "listener-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("*.*.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("*.*.projectcontour.io")), }, { Name: "listener-3", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname(".invalid.$.")), + Hostname: ptr.To(gatewayapi_v1.Hostname(".invalid.$.")), }, } @@ -351,19 +350,19 @@ func TestValidateListeners(t *testing.T) { { Name: "https-1", Protocol: gatewayapi_v1.HTTPSProtocolType, - Hostname: ref.To(gatewayapi_v1.Hostname("https-1.gateway.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-1.gateway.projectcontour.io")), Port: 443, }, { Name: "https-2", Protocol: gatewayapi_v1.HTTPSProtocolType, - Hostname: ref.To(gatewayapi_v1.Hostname("https-2.gateway.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-2.gateway.projectcontour.io")), Port: 443, }, { Name: "https-3", Protocol: gatewayapi_v1.HTTPSProtocolType, - Hostname: ref.To(gatewayapi_v1.Hostname("https-3.gateway.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-3.gateway.projectcontour.io")), Port: 443, }, } diff --git a/internal/ingressclass/ingressclass.go b/internal/ingressclass/ingressclass.go index 4bf4d8f96e0..5ca3d448a85 100644 --- a/internal/ingressclass/ingressclass.go +++ b/internal/ingressclass/ingressclass.go @@ -15,10 +15,10 @@ package ingressclass import ( networking_v1 "k8s.io/api/networking/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/annotation" - "github.com/projectcontour/contour/internal/ref" ) // DefaultClassName is the default IngressClass name that Contour will match @@ -34,7 +34,7 @@ func MatchesIngress(obj *networking_v1.Ingress, ingressClassNames []string) bool return matches(annotationClass, ingressClassNames) } - return matches(ref.Val(obj.Spec.IngressClassName, ""), ingressClassNames) + return matches(ptr.Deref(obj.Spec.IngressClassName, ""), ingressClassNames) } // MatchesHTTPProxy returns true if the passed in HTTPProxy annotations diff --git a/internal/ingressclass/ingressclass_test.go b/internal/ingressclass/ingressclass_test.go index ab6ccf0edfe..08a9cbee9e4 100644 --- a/internal/ingressclass/ingressclass_test.go +++ b/internal/ingressclass/ingressclass_test.go @@ -19,9 +19,9 @@ import ( "github.com/stretchr/testify/assert" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" ) func TestMatchesIngress(t *testing.T) { @@ -38,7 +38,7 @@ func TestMatchesIngress(t *testing.T) { // No annotation set, spec field set to default, class not configured assert.True(t, MatchesIngress(&networking_v1.Ingress{ Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("contour"), + IngressClassName: ptr.To("contour"), }, }, nil)) // Annotation set, no spec field set, class not configured @@ -52,7 +52,7 @@ func TestMatchesIngress(t *testing.T) { // No annotation set, spec field set, class not configured assert.False(t, MatchesIngress(&networking_v1.Ingress{ Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("aclass"), + IngressClassName: ptr.To("aclass"), }, }, nil)) // No annotation, no spec field set, class configured @@ -68,7 +68,7 @@ func TestMatchesIngress(t *testing.T) { // No annotation set, spec field set, class configured assert.True(t, MatchesIngress(&networking_v1.Ingress{ Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("something"), + IngressClassName: ptr.To("something"), }, }, []string{"something"})) // Annotation set, no spec field set, class configured @@ -82,7 +82,7 @@ func TestMatchesIngress(t *testing.T) { // No annotation set, spec field set, class configured assert.False(t, MatchesIngress(&networking_v1.Ingress{ Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("aclass"), + IngressClassName: ptr.To("aclass"), }, }, []string{"something"})) // Annotation set, spec field set, class configured @@ -93,7 +93,7 @@ func TestMatchesIngress(t *testing.T) { }, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("aclass"), + IngressClassName: ptr.To("aclass"), }, }, []string{"something"})) // Annotation set, spec field set, class configured @@ -104,7 +104,7 @@ func TestMatchesIngress(t *testing.T) { }, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("something"), + IngressClassName: ptr.To("something"), }, }, []string{"something"})) // Multiple classes: Annotation set, no spec field set, class configured @@ -118,7 +118,7 @@ func TestMatchesIngress(t *testing.T) { // Multiple classes: No annotation set, spec field set, class configured assert.False(t, MatchesIngress(&networking_v1.Ingress{ Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("aclass"), + IngressClassName: ptr.To("aclass"), }, }, []string{"something", "somethingelse"})) // Multiple classes: Annotation set, spec field set, class configured @@ -129,7 +129,7 @@ func TestMatchesIngress(t *testing.T) { }, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("aclass"), + IngressClassName: ptr.To("aclass"), }, }, []string{"somethingelse", "something"})) // Multiple classes: Annotation set, spec field set, class configured @@ -140,7 +140,7 @@ func TestMatchesIngress(t *testing.T) { }, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To("something"), + IngressClassName: ptr.To("something"), }, }, []string{"something", "somethingelse"})) } diff --git a/internal/k8s/statusaddress.go b/internal/k8s/statusaddress.go index 7c30d1913d3..0cb5cc1daa2 100644 --- a/internal/k8s/statusaddress.go +++ b/internal/k8s/statusaddress.go @@ -22,6 +22,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" @@ -29,7 +30,6 @@ import ( contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/annotation" "github.com/projectcontour/contour/internal/ingressclass" - "github.com/projectcontour/contour/internal/ref" ) // StatusAddressUpdater observes informer OnAdd and OnUpdate events and @@ -84,7 +84,7 @@ func (s *StatusAddressUpdater) OnAdd(obj any, _ bool) { switch o := obj.(type) { case *networking_v1.Ingress: if !ingressclass.MatchesIngress(o, s.IngressClassNames) { - logNoMatch(s.Logger.WithField("ingress-class-name", ref.Val(o.Spec.IngressClassName, "")), o) + logNoMatch(s.Logger.WithField("ingress-class-name", ptr.Deref(o.Spec.IngressClassName, "")), o) return } @@ -266,13 +266,13 @@ func lbStatusToGatewayAddresses(lbs core_v1.LoadBalancerStatus) []gatewayapi_v1. for _, lbi := range lbs.Ingress { if len(lbi.IP) > 0 { addrs = append(addrs, gatewayapi_v1.GatewayStatusAddress{ - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: lbi.IP, }) } if len(lbi.Hostname) > 0 { addrs = append(addrs, gatewayapi_v1.GatewayStatusAddress{ - Type: ref.To(gatewayapi_v1.HostnameAddressType), + Type: ptr.To(gatewayapi_v1.HostnameAddressType), Value: lbi.Hostname, }) } diff --git a/internal/k8s/statusaddress_test.go b/internal/k8s/statusaddress_test.go index 7988c20b4cb..db2553407cb 100644 --- a/internal/k8s/statusaddress_test.go +++ b/internal/k8s/statusaddress_test.go @@ -23,6 +23,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" @@ -30,7 +31,6 @@ import ( "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/ingressclass" "github.com/projectcontour/contour/internal/k8s/mocks" - "github.com/projectcontour/contour/internal/ref" ) func TestServiceStatusLoadBalancerWatcherOnAdd(t *testing.T) { @@ -416,11 +416,11 @@ func TestStatusAddressUpdater_Gateway(t *testing.T) { }, Addresses: []gatewayapi_v1.GatewayStatusAddress{ { - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: ipLBStatus.Ingress[0].IP, }, { - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: ipLBStatus.Ingress[1].IP, }, }, @@ -464,7 +464,7 @@ func TestStatusAddressUpdater_Gateway(t *testing.T) { }, Addresses: []gatewayapi_v1.GatewayStatusAddress{ { - Type: ref.To(gatewayapi_v1.HostnameAddressType), + Type: ptr.To(gatewayapi_v1.HostnameAddressType), Value: hostnameLBStatus.Ingress[0].Hostname, }, }, @@ -567,7 +567,7 @@ func simpleIngressGenerator(name, ingressClassAnnotation, ingressClassSpec strin } var ingressClassName *string if ingressClassSpec != "" { - ingressClassName = ref.To(ingressClassSpec) + ingressClassName = ptr.To(ingressClassSpec) } return &networking_v1.Ingress{ TypeMeta: meta_v1.TypeMeta{ diff --git a/internal/metrics/metrics_test.go b/internal/metrics/metrics_test.go index f0d158dd4a4..eb7db51e8cd 100644 --- a/internal/metrics/metrics_test.go +++ b/internal/metrics/metrics_test.go @@ -20,8 +20,7 @@ import ( "github.com/prometheus/client_golang/prometheus" io_prometheus_client "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" - - "github.com/projectcontour/contour/internal/ref" + "k8s.io/utils/ptr" ) type testMetric struct { @@ -708,8 +707,8 @@ func TestSetDAGCacheObjectMetric(t *testing.T) { { Label: []*io_prometheus_client.LabelPair{ { - Name: ref.To("kind"), - Value: ref.To("test"), + Name: ptr.To("kind"), + Value: ptr.To("test"), }, }, Gauge: &io_prometheus_client.Gauge{ diff --git a/internal/provisioner/controller/gateway_test.go b/internal/provisioner/controller/gateway_test.go index c95f9a59238..ca516d95772 100644 --- a/internal/provisioner/controller/gateway_test.go +++ b/internal/provisioner/controller/gateway_test.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -34,7 +35,6 @@ import ( contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/provisioner" "github.com/projectcontour/contour/internal/provisioner/model" - "github.com/projectcontour/contour/internal/ref" ) func TestGatewayReconcile(t *testing.T) { @@ -66,7 +66,7 @@ func TestGatewayReconcile(t *testing.T) { gc.Spec.ParametersRef = &gatewayapi_v1.ParametersReference{ Group: gatewayapi_v1.Group(contour_v1alpha1.GroupVersion.Group), Kind: "ContourDeployment", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), Name: name + "-params", } return gc @@ -77,7 +77,7 @@ func TestGatewayReconcile(t *testing.T) { gc.Spec.ParametersRef = &gatewayapi_v1.ParametersReference{ Group: gatewayapi_v1.Group(contour_v1alpha1.GroupVersion.Group), Kind: "InvalidKind", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), Name: name + "-params", } return gc @@ -222,7 +222,7 @@ func TestGatewayReconcile(t *testing.T) { gatewayClass: reconcilableGatewayClass("gatewayclass-1", controller), gateway: makeGatewayWithAddrs([]gatewayapi_v1.GatewayAddress{ { - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: "172.18.255.207", }, }), @@ -236,11 +236,11 @@ func TestGatewayReconcile(t *testing.T) { gatewayClass: reconcilableGatewayClass("gatewayclass-1", controller), gateway: makeGatewayWithAddrs([]gatewayapi_v1.GatewayAddress{ { - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: "172.18.255.207", }, { - Type: ref.To(gatewayapi_v1.IPAddressType), + Type: ptr.To(gatewayapi_v1.IPAddressType), Value: "172.18.255.999", }, }), @@ -253,7 +253,7 @@ func TestGatewayReconcile(t *testing.T) { gatewayClass: reconcilableGatewayClass("gatewayclass-1", controller), gateway: makeGatewayWithAddrs([]gatewayapi_v1.GatewayAddress{ { - Type: ref.To(gatewayapi_v1.HostnameAddressType), + Type: ptr.To(gatewayapi_v1.HostnameAddressType), Value: "projectcontour.io", }, }), @@ -266,11 +266,11 @@ func TestGatewayReconcile(t *testing.T) { gatewayClass: reconcilableGatewayClass("gatewayclass-1", controller), gateway: makeGatewayWithAddrs([]gatewayapi_v1.GatewayAddress{ { - Type: ref.To(gatewayapi_v1.HostnameAddressType), + Type: ptr.To(gatewayapi_v1.HostnameAddressType), Value: "projectcontour.io", }, { - Type: ref.To(gatewayapi_v1.HostnameAddressType), + Type: ptr.To(gatewayapi_v1.HostnameAddressType), Value: "anotherhost.io", }, }), @@ -283,7 +283,7 @@ func TestGatewayReconcile(t *testing.T) { gatewayClass: reconcilableGatewayClass("gatewayclass-1", controller), gateway: makeGatewayWithAddrs([]gatewayapi_v1.GatewayAddress{ { - Type: ref.To(gatewayapi_v1.AddressType("acme.io/CustomAddressType")), + Type: ptr.To(gatewayapi_v1.AddressType("acme.io/CustomAddressType")), Value: "custom-address-types-are-not-supported", }, }), @@ -301,10 +301,10 @@ func TestGatewayReconcile(t *testing.T) { }, Spec: contour_v1alpha1.ContourDeploymentSpec{ RuntimeSettings: &contour_v1alpha1.ContourConfigurationSpec{ - EnableExternalNameService: ref.To(true), + EnableExternalNameService: ptr.To(true), Envoy: &contour_v1alpha1.EnvoyConfig{ Listener: &contour_v1alpha1.EnvoyListenerConfig{ - DisableMergeSlashes: ref.To(true), + DisableMergeSlashes: ptr.To(true), }, Metrics: &contour_v1alpha1.MetricsConfig{ Port: 8003, @@ -333,7 +333,7 @@ func TestGatewayReconcile(t *testing.T) { require.NoError(t, r.client.Get(context.Background(), keyFor(contourConfig), contourConfig)) want := contour_v1alpha1.ContourConfigurationSpec{ - EnableExternalNameService: ref.To(true), + EnableExternalNameService: ptr.To(true), Gateway: &contour_v1alpha1.GatewayConfig{ GatewayRef: contour_v1alpha1.NamespacedName{ Namespace: gw.Name, @@ -342,7 +342,7 @@ func TestGatewayReconcile(t *testing.T) { }, Envoy: &contour_v1alpha1.EnvoyConfig{ Listener: &contour_v1alpha1.EnvoyListenerConfig{ - DisableMergeSlashes: ref.To(true), + DisableMergeSlashes: ptr.To(true), }, Service: &contour_v1alpha1.NamespacedName{ Namespace: gw.Namespace, @@ -427,10 +427,10 @@ func TestGatewayReconcile(t *testing.T) { }, Spec: contour_v1alpha1.ContourDeploymentSpec{ RuntimeSettings: &contour_v1alpha1.ContourConfigurationSpec{ - EnableExternalNameService: ref.To(true), + EnableExternalNameService: ptr.To(true), Envoy: &contour_v1alpha1.EnvoyConfig{ Listener: &contour_v1alpha1.EnvoyListenerConfig{ - DisableMergeSlashes: ref.To(true), + DisableMergeSlashes: ptr.To(true), }, }, }, @@ -485,7 +485,7 @@ func TestGatewayReconcile(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("foo.bar")), + Hostname: ptr.To(gatewayapi_v1.Hostname("foo.bar")), }, { Name: "listener-3", @@ -507,13 +507,13 @@ func TestGatewayReconcile(t *testing.T) { Name: "listener-6", Protocol: gatewayapi_v1.TLSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("foo.bar")), + Hostname: ptr.To(gatewayapi_v1.Hostname("foo.bar")), }, { Name: "listener-7", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 8443, - Hostname: ref.To(gatewayapi_v1.Hostname("foo.baz")), + Hostname: ptr.To(gatewayapi_v1.Hostname("foo.baz")), }, }), @@ -567,7 +567,7 @@ func TestGatewayReconcile(t *testing.T) { Name: "listener-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("foo.bar")), + Hostname: ptr.To(gatewayapi_v1.Hostname("foo.bar")), }, { Name: "listener-3", @@ -911,7 +911,7 @@ func TestGatewayReconcile(t *testing.T) { Protocol: gatewayapi_v1.HTTPProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, Name: gatewayapi_v1.SectionName("http"), @@ -923,11 +923,11 @@ func TestGatewayReconcile(t *testing.T) { Protocol: gatewayapi_v1.HTTPSProtocolType, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), }, }, }), @@ -949,7 +949,7 @@ func TestGatewayReconcile(t *testing.T) { } require.NoError(t, r.client.Get(context.Background(), keyFor(svc), svc)) assert.Equal(t, core_v1.ServiceExternalTrafficPolicyTypeCluster, svc.Spec.ExternalTrafficPolicy) - assert.Equal(t, ref.To(core_v1.IPFamilyPolicyPreferDualStack), svc.Spec.IPFamilyPolicy) + assert.Equal(t, ptr.To(core_v1.IPFamilyPolicyPreferDualStack), svc.Spec.IPFamilyPolicy) assert.Equal(t, core_v1.ServiceTypeNodePort, svc.Spec.Type) require.Len(t, svc.Annotations, 2) assert.Equal(t, "val-1", svc.Annotations["key-1"]) diff --git a/internal/provisioner/controller/gatewayclass_test.go b/internal/provisioner/controller/gatewayclass_test.go index 419fe06cb43..484ed0b8576 100644 --- a/internal/provisioner/controller/gatewayclass_test.go +++ b/internal/provisioner/controller/gatewayclass_test.go @@ -25,6 +25,7 @@ import ( apiextensions_v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -35,7 +36,6 @@ import ( contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/provisioner" - "github.com/projectcontour/contour/internal/ref" ) func TestGatewayClassReconcile(t *testing.T) { @@ -110,7 +110,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -138,7 +138,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "invalidgroup.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -172,7 +172,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "InvalidKind", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -206,7 +206,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "invalid-name", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -240,7 +240,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("invalid-namespace")), + Namespace: ptr.To(gatewayapi_v1.Namespace("invalid-namespace")), }, }, }, @@ -274,7 +274,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -308,7 +308,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -350,7 +350,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -398,7 +398,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -437,7 +437,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, @@ -478,7 +478,7 @@ func TestGatewayClassReconcile(t *testing.T) { Group: "projectcontour.io", Kind: "ContourDeployment", Name: "gatewayclass-params", - Namespace: ref.To(gatewayapi_v1.Namespace("projectcontour")), + Namespace: ptr.To(gatewayapi_v1.Namespace("projectcontour")), }, }, }, diff --git a/internal/provisioner/equality/equality_test.go b/internal/provisioner/equality/equality_test.go index 131b9228f8c..856121b3a8c 100644 --- a/internal/provisioner/equality/equality_test.go +++ b/internal/provisioner/equality/equality_test.go @@ -20,13 +20,13 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "github.com/projectcontour/contour/internal/provisioner/equality" "github.com/projectcontour/contour/internal/provisioner/model" "github.com/projectcontour/contour/internal/provisioner/objects/dataplane" "github.com/projectcontour/contour/internal/provisioner/objects/deployment" "github.com/projectcontour/contour/internal/provisioner/objects/service" - "github.com/projectcontour/contour/internal/ref" ) var ( @@ -308,7 +308,7 @@ func TestClusterIpServiceChanged(t *testing.T) { { description: "if ip family policy changed", mutate: func(svc *core_v1.Service) { - svc.Spec.IPFamilyPolicy = ref.To(core_v1.IPFamilyPolicyRequireDualStack) + svc.Spec.IPFamilyPolicy = ptr.To(core_v1.IPFamilyPolicyRequireDualStack) }, expect: true, }, @@ -441,7 +441,7 @@ func TestLoadBalancerServiceChanged(t *testing.T) { { description: "if ip family policy changed", mutate: func(svc *core_v1.Service) { - svc.Spec.IPFamilyPolicy = ref.To(core_v1.IPFamilyPolicyRequireDualStack) + svc.Spec.IPFamilyPolicy = ptr.To(core_v1.IPFamilyPolicyRequireDualStack) }, expect: true, }, @@ -539,7 +539,7 @@ func TestNodePortServiceChanged(t *testing.T) { { description: "if ip family policy changed", mutate: func(svc *core_v1.Service) { - svc.Spec.IPFamilyPolicy = ref.To(core_v1.IPFamilyPolicyRequireDualStack) + svc.Spec.IPFamilyPolicy = ptr.To(core_v1.IPFamilyPolicyRequireDualStack) }, expect: true, }, diff --git a/internal/provisioner/model/model.go b/internal/provisioner/model/model.go index a141182f92a..74105f8c5c0 100644 --- a/internal/provisioner/model/model.go +++ b/internal/provisioner/model/model.go @@ -18,10 +18,10 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" ) const ( @@ -59,20 +59,20 @@ func Default(namespace, name string) *Contour { EnvoyDaemonSetUpdateStrategy: apps_v1.DaemonSetUpdateStrategy{ Type: apps_v1.RollingUpdateDaemonSetStrategyType, RollingUpdate: &apps_v1.RollingUpdateDaemonSet{ - MaxUnavailable: ref.To(intstr.FromString("10%")), + MaxUnavailable: ptr.To(intstr.FromString("10%")), }, }, EnvoyDeploymentStrategy: apps_v1.DeploymentStrategy{ Type: apps_v1.RollingUpdateDeploymentStrategyType, RollingUpdate: &apps_v1.RollingUpdateDeployment{ - MaxSurge: ref.To(intstr.FromString("10%")), + MaxSurge: ptr.To(intstr.FromString("10%")), }, }, ContourDeploymentStrategy: apps_v1.DeploymentStrategy{ Type: apps_v1.RollingUpdateDeploymentStrategyType, RollingUpdate: &apps_v1.RollingUpdateDeployment{ - MaxSurge: ref.To(intstr.FromString("50%")), - MaxUnavailable: ref.To(intstr.FromString("25%")), + MaxSurge: ptr.To(intstr.FromString("50%")), + MaxUnavailable: ptr.To(intstr.FromString("25%")), }, }, ResourceLabels: map[string]string{}, diff --git a/internal/provisioner/objects/dataplane/dataplane.go b/internal/provisioner/objects/dataplane/dataplane.go index b4892f65128..19d9d1d184e 100644 --- a/internal/provisioner/objects/dataplane/dataplane.go +++ b/internal/provisioner/objects/dataplane/dataplane.go @@ -23,13 +23,13 @@ import ( "k8s.io/apimachinery/pkg/api/resource" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/projectcontour/contour/internal/provisioner/equality" "github.com/projectcontour/contour/internal/provisioner/labels" "github.com/projectcontour/contour/internal/provisioner/model" "github.com/projectcontour/contour/internal/provisioner/objects" - "github.com/projectcontour/contour/internal/ref" ) const ( @@ -345,7 +345,7 @@ func DesiredDaemonSet(contour *model.Contour, contourImage, envoyImage string) * Annotations: contour.CommonAnnotations(), }, Spec: apps_v1.DaemonSetSpec{ - RevisionHistoryLimit: ref.To(int32(10)), + RevisionHistoryLimit: ptr.To(int32(10)), // Ensure the deamonset adopts only its own pods. Selector: EnvoyPodSelector(contour), UpdateStrategy: contour.Spec.EnvoyDaemonSetUpdateStrategy, @@ -364,7 +364,7 @@ func DesiredDaemonSet(contour *model.Contour, contourImage, envoyImage string) * Name: envoyCertsVolName, VolumeSource: core_v1.VolumeSource{ Secret: &core_v1.SecretVolumeSource{ - DefaultMode: ref.To(int32(420)), + DefaultMode: ptr.To(int32(420)), SecretName: contour.EnvoyCertsSecretName(), }, }, @@ -383,8 +383,8 @@ func DesiredDaemonSet(contour *model.Contour, contourImage, envoyImage string) * }, }, ServiceAccountName: contour.EnvoyRBACNames().ServiceAccount, - AutomountServiceAccountToken: ref.To(false), - TerminationGracePeriodSeconds: ref.To(int64(300)), + AutomountServiceAccountToken: ptr.To(false), + TerminationGracePeriodSeconds: ptr.To(int64(300)), SecurityContext: objects.NewUnprivilegedPodSecurity(), DNSPolicy: core_v1.DNSClusterFirst, RestartPolicy: core_v1.RestartPolicyAlways, @@ -418,8 +418,8 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) Annotations: contour.CommonAnnotations(), }, Spec: apps_v1.DeploymentSpec{ - Replicas: ref.To(contour.Spec.EnvoyReplicas), - RevisionHistoryLimit: ref.To(int32(10)), + Replicas: ptr.To(contour.Spec.EnvoyReplicas), + RevisionHistoryLimit: ptr.To(int32(10)), // Ensure the deamonset adopts only its own pods. Selector: EnvoyPodSelector(contour), Strategy: contour.Spec.EnvoyDeploymentStrategy, @@ -451,7 +451,7 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) Name: envoyCertsVolName, VolumeSource: core_v1.VolumeSource{ Secret: &core_v1.SecretVolumeSource{ - DefaultMode: ref.To(int32(420)), + DefaultMode: ptr.To(int32(420)), SecretName: contour.EnvoyCertsSecretName(), }, }, @@ -470,8 +470,8 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) }, }, ServiceAccountName: contour.EnvoyRBACNames().ServiceAccount, - AutomountServiceAccountToken: ref.To(false), - TerminationGracePeriodSeconds: ref.To(int64(300)), + AutomountServiceAccountToken: ptr.To(false), + TerminationGracePeriodSeconds: ptr.To(int64(300)), SecurityContext: objects.NewUnprivilegedPodSecurity(), DNSPolicy: core_v1.DNSClusterFirst, RestartPolicy: core_v1.RestartPolicyAlways, diff --git a/internal/provisioner/objects/deployment/deployment.go b/internal/provisioner/objects/deployment/deployment.go index 523c35e6580..237e91867c6 100644 --- a/internal/provisioner/objects/deployment/deployment.go +++ b/internal/provisioner/objects/deployment/deployment.go @@ -24,6 +24,7 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" @@ -31,7 +32,6 @@ import ( "github.com/projectcontour/contour/internal/provisioner/labels" "github.com/projectcontour/contour/internal/provisioner/model" "github.com/projectcontour/contour/internal/provisioner/objects" - "github.com/projectcontour/contour/internal/ref" ) const ( @@ -214,9 +214,9 @@ func DesiredDeployment(contour *model.Contour, image string) *apps_v1.Deployment Annotations: contour.CommonAnnotations(), }, Spec: apps_v1.DeploymentSpec{ - ProgressDeadlineSeconds: ref.To(int32(600)), - Replicas: ref.To(contour.Spec.ContourReplicas), - RevisionHistoryLimit: ref.To(int32(10)), + ProgressDeadlineSeconds: ptr.To(int32(600)), + Replicas: ptr.To(contour.Spec.ContourReplicas), + RevisionHistoryLimit: ptr.To(int32(10)), // Ensure the deployment adopts only its own pods. Selector: ContourDeploymentPodSelector(contour), Strategy: contour.Spec.ContourDeploymentStrategy, @@ -251,7 +251,7 @@ func DesiredDeployment(contour *model.Contour, image string) *apps_v1.Deployment Name: contourCertsVolName, VolumeSource: core_v1.VolumeSource{ Secret: &core_v1.SecretVolumeSource{ - DefaultMode: ref.To(int32(420)), + DefaultMode: ptr.To(int32(420)), SecretName: contour.ContourCertsSecretName(), }, }, @@ -262,7 +262,7 @@ func DesiredDeployment(contour *model.Contour, image string) *apps_v1.Deployment RestartPolicy: core_v1.RestartPolicyAlways, SchedulerName: "default-scheduler", SecurityContext: objects.NewUnprivilegedPodSecurity(), - TerminationGracePeriodSeconds: ref.To(int64(30)), + TerminationGracePeriodSeconds: ptr.To(int64(30)), }, }, }, diff --git a/internal/provisioner/objects/service/service.go b/internal/provisioner/objects/service/service.go index 439ab00f338..bd4ed821dc3 100644 --- a/internal/provisioner/objects/service/service.go +++ b/internal/provisioner/objects/service/service.go @@ -21,6 +21,7 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/projectcontour/contour/internal/provisioner/equality" @@ -29,7 +30,6 @@ import ( "github.com/projectcontour/contour/internal/provisioner/objects" "github.com/projectcontour/contour/internal/provisioner/objects/dataplane" "github.com/projectcontour/contour/internal/provisioner/objects/deployment" - "github.com/projectcontour/contour/internal/ref" ) const ( @@ -251,7 +251,7 @@ func DesiredEnvoyService(contour *model.Contour) *core_v1.Service { } if contour.Spec.NetworkPublishing.Envoy.IPFamilyPolicy != "" { - svc.Spec.IPFamilyPolicy = ref.To(contour.Spec.NetworkPublishing.Envoy.IPFamilyPolicy) + svc.Spec.IPFamilyPolicy = ptr.To(contour.Spec.NetworkPublishing.Envoy.IPFamilyPolicy) } epType := contour.Spec.NetworkPublishing.Envoy.Type diff --git a/internal/ref/ref.go b/internal/ref/ref.go deleted file mode 100644 index d2f4798c18b..00000000000 --- a/internal/ref/ref.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Project Contour Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ref - -func To[T any](v T) *T { - return &v -} - -func Val[T any](v *T, def T) T { - if v != nil { - return *v - } - return def -} diff --git a/internal/status/gatewaystatus.go b/internal/status/gatewaystatus.go index a97bda782eb..8b261e9ea1d 100644 --- a/internal/status/gatewaystatus.go +++ b/internal/status/gatewaystatus.go @@ -19,10 +19,9 @@ import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" - - "github.com/projectcontour/contour/internal/ref" ) const MessageValidGateway = "Valid Gateway" @@ -73,7 +72,7 @@ func (gatewayUpdate *GatewayStatusUpdate) SetListenerSupportedKinds(listenerName for _, kind := range kinds { groupKind := gatewayapi_v1.RouteGroupKind{ - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: kind, } diff --git a/internal/status/gatewaystatus_test.go b/internal/status/gatewaystatus_test.go index 70e6196d17c..3de0ff7c836 100644 --- a/internal/status/gatewaystatus_test.go +++ b/internal/status/gatewaystatus_test.go @@ -19,10 +19,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" ) func TestGatewayAddCondition(t *testing.T) { @@ -71,15 +71,15 @@ func TestGatewaySetListenerSupportedKinds(t *testing.T) { assert.ElementsMatch(t, []gatewayapi_v1.RouteGroupKind{ - {Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute"}, + {Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute"}, }, gsu.ListenerStatus["http"].SupportedKinds, ) assert.ElementsMatch(t, []gatewayapi_v1.RouteGroupKind{ - {Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute"}, - {Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TLSRoute"}, + {Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "HTTPRoute"}, + {Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: "TLSRoute"}, }, gsu.ListenerStatus["https"].SupportedKinds, ) @@ -109,11 +109,11 @@ func TestGatewayMutate(t *testing.T) { AttachedRoutes: 7, SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: gatewayapi_v1.Kind("FooRoute"), }, { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: gatewayapi_v1.Kind("BarRoute"), }, }, @@ -124,7 +124,7 @@ func TestGatewayMutate(t *testing.T) { AttachedRoutes: 77, SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: gatewayapi_v1.Kind("TLSRoute"), }, }, @@ -140,7 +140,7 @@ func TestGatewayMutate(t *testing.T) { AttachedRoutes: 3, SupportedKinds: []gatewayapi_v1.RouteGroupKind{ { - Group: ref.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), + Group: ptr.To(gatewayapi_v1.Group(gatewayapi_v1.GroupName)), Kind: gatewayapi_v1.Kind("HTTPRoute"), }, }, diff --git a/internal/xdscache/v3/endpointslicetranslator_test.go b/internal/xdscache/v3/endpointslicetranslator_test.go index 56aa36a4cb2..70250a02f6a 100644 --- a/internal/xdscache/v3/endpointslicetranslator_test.go +++ b/internal/xdscache/v3/endpointslicetranslator_test.go @@ -21,12 +21,12 @@ import ( "google.golang.org/protobuf/proto" core_v1 "k8s.io/api/core/v1" discovery_v1 "k8s.io/api/discovery/v1" + "k8s.io/utils/ptr" "github.com/projectcontour/contour/internal/dag" envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" ) func TestEndpointSliceTranslatorContents(t *testing.T) { @@ -179,8 +179,8 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -202,8 +202,8 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -219,8 +219,8 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](80), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](80), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -261,8 +261,8 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](80), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](80), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -291,14 +291,14 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Name: ref.To[string]("a"), - Port: ref.To[int32](8675), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("a"), + Port: ptr.To[int32](8675), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, { - Name: ref.To[string]("b"), - Port: ref.To[int32](309), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("b"), + Port: ptr.To[int32](309), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -331,14 +331,14 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Name: ref.To[string]("a"), - Port: ref.To[int32](8675), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("a"), + Port: ptr.To[int32](8675), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, { - Name: ref.To[string]("b"), - Port: ref.To[int32](309), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("b"), + Port: ptr.To[int32](309), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -369,7 +369,7 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { "10.10.1.1", }, Conditions: discovery_v1.EndpointConditions{ - Ready: ref.To[bool](false), + Ready: ptr.To[bool](false), }, }, { @@ -377,19 +377,19 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { "10.10.2.2", }, Conditions: discovery_v1.EndpointConditions{ - Ready: ref.To[bool](true), + Ready: ptr.To[bool](true), }, }, }, []discovery_v1.EndpointPort{ { - Name: ref.To[string]("a"), - Port: ref.To[int32](8675), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("a"), + Port: ptr.To[int32](8675), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, { - Name: ref.To[string]("b"), - Port: ref.To[int32](309), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("b"), + Port: ptr.To[int32](309), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -420,14 +420,14 @@ func TestEndpointSliceTranslatorAddEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Name: ref.To[string]("health"), - Port: ref.To[int32](8998), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("health"), + Port: ptr.To[int32](8998), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, { - Name: ref.To[string]("a"), - Port: ref.To[int32](309), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("a"), + Port: ptr.To[int32](309), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -512,8 +512,8 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), false) @@ -524,8 +524,8 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -544,8 +544,8 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), false) @@ -556,8 +556,8 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -579,8 +579,8 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -606,14 +606,14 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Name: ref.To[string]("http"), - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("http"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, { - Name: ref.To[string]("https"), - Port: ref.To[int32](8443), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("https"), + Port: ptr.To[int32](8443), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ) @@ -632,14 +632,14 @@ func TestEndpointSliceTranslatorRemoveEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Name: ref.To[string]("http"), - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("http"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, { - Name: ref.To[string]("https"), - Port: ref.To[int32](8443), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("https"), + Port: ptr.To[int32](8443), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -701,8 +701,8 @@ func TestEndpointSliceTranslatorUpdateEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), false) @@ -713,8 +713,8 @@ func TestEndpointSliceTranslatorUpdateEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -724,8 +724,8 @@ func TestEndpointSliceTranslatorUpdateEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8081), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8081), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -745,8 +745,8 @@ func TestEndpointSliceTranslatorUpdateEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), false) @@ -757,8 +757,8 @@ func TestEndpointSliceTranslatorUpdateEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -768,8 +768,8 @@ func TestEndpointSliceTranslatorUpdateEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8081), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8081), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -824,8 +824,8 @@ func TestEndpointSliceTranslatorRecomputeClusterLoadAssignment(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -861,8 +861,8 @@ func TestEndpointSliceTranslatorRecomputeClusterLoadAssignment(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](80), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](80), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ), @@ -894,9 +894,9 @@ func TestEndpointSliceTranslatorRecomputeClusterLoadAssignment(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8443), - Protocol: ref.To[core_v1.Protocol]("TCP"), - Name: ref.To[string]("https"), + Port: ptr.To[int32](8443), + Protocol: ptr.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("https"), }, }, ), @@ -934,14 +934,14 @@ func TestEndpointSliceTranslatorRecomputeClusterLoadAssignment(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](80), - Protocol: ref.To[core_v1.Protocol]("TCP"), - Name: ref.To[string]("a"), + Port: ptr.To[int32](80), + Protocol: ptr.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("a"), }, { - Port: ref.To[int32](8998), - Protocol: ref.To[core_v1.Protocol]("TCP"), - Name: ref.To[string]("health"), + Port: ptr.To[int32](8998), + Protocol: ptr.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("health"), }, }, ), @@ -983,14 +983,14 @@ func TestEndpointSliceTranslatorRecomputeClusterLoadAssignment(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](80), - Protocol: ref.To[core_v1.Protocol]("TCP"), - Name: ref.To[string]("a"), + Port: ptr.To[int32](80), + Protocol: ptr.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("a"), }, { - Port: ref.To[int32](8998), - Protocol: ref.To[core_v1.Protocol]("TCP"), - Name: ref.To[string]("health"), + Port: ptr.To[int32](8998), + Protocol: ptr.To[core_v1.Protocol]("TCP"), + Name: ptr.To[string]("health"), }, }, ), @@ -1041,8 +1041,8 @@ func TestEndpointSliceTranslatorScaleToZeroEndpoints(t *testing.T) { }, }, []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, }, ) @@ -1108,8 +1108,8 @@ func TestEndpointSliceTranslatorWeightedService(t *testing.T) { ports := []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, } @@ -1171,8 +1171,8 @@ func TestEndpointSliceTranslatorDefaultWeightedService(t *testing.T) { ports := []discovery_v1.EndpointPort{ { - Port: ref.To[int32](8080), - Protocol: ref.To[core_v1.Protocol]("TCP"), + Port: ptr.To[int32](8080), + Protocol: ptr.To[core_v1.Protocol]("TCP"), }, } diff --git a/internal/xdscache/v3/listener_test.go b/internal/xdscache/v3/listener_test.go index d5d0cdc5ee8..095f248210a 100644 --- a/internal/xdscache/v3/listener_test.go +++ b/internal/xdscache/v3/listener_test.go @@ -33,6 +33,7 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" @@ -41,7 +42,6 @@ import ( envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/k8s" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/timeout" ) @@ -2824,7 +2824,7 @@ func TestListenerVisit(t *testing.T) { }, "httpproxy with MaxRequestsPerConnection set in listener config": { ListenerConfig: ListenerConfig{ - MaxRequestsPerConnection: ref.To(uint32(1)), + MaxRequestsPerConnection: ptr.To(uint32(1)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -2858,7 +2858,7 @@ func TestListenerVisit(t *testing.T) { MetricsPrefix(ENVOY_HTTP_LISTENER). AccessLoggers(envoy_v3.FileAccessLogEnvoy(DEFAULT_HTTP_ACCESS_LOG, "", nil, contour_v1alpha1.LogLevelInfo)). DefaultFilters(). - MaxRequestsPerConnection(ref.To(uint32(1))). + MaxRequestsPerConnection(ptr.To(uint32(1))). Get(), ), SocketOptions: envoy_v3.NewSocketOptions().TCPKeepalive().Build(), @@ -2866,7 +2866,7 @@ func TestListenerVisit(t *testing.T) { }, "httpsproxy with MaxRequestsPerConnection set in listener config": { ListenerConfig: ListenerConfig{ - MaxRequestsPerConnection: ref.To(uint32(1)), + MaxRequestsPerConnection: ptr.To(uint32(1)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -2900,7 +2900,7 @@ func TestListenerVisit(t *testing.T) { MetricsPrefix(ENVOY_HTTP_LISTENER). AccessLoggers(envoy_v3.FileAccessLogEnvoy(DEFAULT_HTTP_ACCESS_LOG, "", nil, contour_v1alpha1.LogLevelInfo)). DefaultFilters(). - MaxRequestsPerConnection(ref.To(uint32(1))). + MaxRequestsPerConnection(ptr.To(uint32(1))). Get(), ), SocketOptions: envoy_v3.NewSocketOptions().TCPKeepalive().Build(), @@ -2918,7 +2918,7 @@ func TestListenerVisit(t *testing.T) { MetricsPrefix(ENVOY_HTTPS_LISTENER). RouteConfigName(path.Join("https", "www.example.com")). AccessLoggers(envoy_v3.FileAccessLogEnvoy(DEFAULT_HTTP_ACCESS_LOG, "", nil, contour_v1alpha1.LogLevelInfo)). - MaxRequestsPerConnection(ref.To(uint32(1))). + MaxRequestsPerConnection(ptr.To(uint32(1))). Get()), }}, ListenerFilters: envoy_v3.ListenerFilters( @@ -2929,7 +2929,7 @@ func TestListenerVisit(t *testing.T) { }, "httpproxy with HTTP2MaxConcurrentStreams set in listener config": { ListenerConfig: ListenerConfig{ - HTTP2MaxConcurrentStreams: ref.To(uint32(100)), + HTTP2MaxConcurrentStreams: ptr.To(uint32(100)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -2963,7 +2963,7 @@ func TestListenerVisit(t *testing.T) { MetricsPrefix(ENVOY_HTTP_LISTENER). AccessLoggers(envoy_v3.FileAccessLogEnvoy(DEFAULT_HTTP_ACCESS_LOG, "", nil, contour_v1alpha1.LogLevelInfo)). DefaultFilters(). - HTTP2MaxConcurrentStreams(ref.To(uint32(100))). + HTTP2MaxConcurrentStreams(ptr.To(uint32(100))). Get(), ), SocketOptions: envoy_v3.NewSocketOptions().TCPKeepalive().Build(), @@ -2971,7 +2971,7 @@ func TestListenerVisit(t *testing.T) { }, "httpsproxy with HTTP2MaxConcurrentStreams set in listener config": { ListenerConfig: ListenerConfig{ - HTTP2MaxConcurrentStreams: ref.To(uint32(101)), + HTTP2MaxConcurrentStreams: ptr.To(uint32(101)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -3005,7 +3005,7 @@ func TestListenerVisit(t *testing.T) { MetricsPrefix(ENVOY_HTTP_LISTENER). AccessLoggers(envoy_v3.FileAccessLogEnvoy(DEFAULT_HTTP_ACCESS_LOG, "", nil, contour_v1alpha1.LogLevelInfo)). DefaultFilters(). - HTTP2MaxConcurrentStreams(ref.To(uint32(101))). + HTTP2MaxConcurrentStreams(ptr.To(uint32(101))). Get(), ), SocketOptions: envoy_v3.NewSocketOptions().TCPKeepalive().Build(), @@ -3023,7 +3023,7 @@ func TestListenerVisit(t *testing.T) { MetricsPrefix(ENVOY_HTTPS_LISTENER). RouteConfigName(path.Join("https", "www.example.com")). AccessLoggers(envoy_v3.FileAccessLogEnvoy(DEFAULT_HTTP_ACCESS_LOG, "", nil, contour_v1alpha1.LogLevelInfo)). - HTTP2MaxConcurrentStreams(ref.To(uint32(101))). + HTTP2MaxConcurrentStreams(ptr.To(uint32(101))). Get()), }}, ListenerFilters: envoy_v3.ListenerFilters( @@ -3034,7 +3034,7 @@ func TestListenerVisit(t *testing.T) { }, "httpproxy with PerConnectionBufferLimitBytes set in listener config": { ListenerConfig: ListenerConfig{ - PerConnectionBufferLimitBytes: ref.To(uint32(32768)), + PerConnectionBufferLimitBytes: ptr.To(uint32(32768)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -3076,7 +3076,7 @@ func TestListenerVisit(t *testing.T) { }, "httpsproxy with PerConnectionBufferLimitBytes set in listener config": { ListenerConfig: ListenerConfig{ - PerConnectionBufferLimitBytes: ref.To(uint32(32768)), + PerConnectionBufferLimitBytes: ptr.To(uint32(32768)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -3140,7 +3140,7 @@ func TestListenerVisit(t *testing.T) { "httpproxy with authZ the authN": { ListenerConfig: ListenerConfig{ - PerConnectionBufferLimitBytes: ref.To(uint32(32768)), + PerConnectionBufferLimitBytes: ptr.To(uint32(32768)), }, objs: []any{ &contour_v1alpha1.ExtensionService{ diff --git a/internal/xdscache/v3/route_test.go b/internal/xdscache/v3/route_test.go index 6a1d1ec0a24..b043c4a5a98 100644 --- a/internal/xdscache/v3/route_test.go +++ b/internal/xdscache/v3/route_test.go @@ -34,6 +34,7 @@ import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" @@ -41,7 +42,6 @@ import ( envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3" "github.com/projectcontour/contour/internal/fixture" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" ) func TestRouteCacheContents(t *testing.T) { @@ -817,32 +817,32 @@ func TestRouteVisit(t *testing.T) { Paths: []networking_v1.HTTPIngressPath{ { Path: "/", - PathType: (*networking_v1.PathType)(ref.To("Prefix")), + PathType: (*networking_v1.PathType)(ptr.To("Prefix")), Backend: *backend("kuard", 8080), }, { Path: "/foo", - PathType: (*networking_v1.PathType)(ref.To("Prefix")), + PathType: (*networking_v1.PathType)(ptr.To("Prefix")), Backend: *backend("kuard", 8080), }, { Path: "/foo", - PathType: (*networking_v1.PathType)(ref.To("ImplementationSpecific")), + PathType: (*networking_v1.PathType)(ptr.To("ImplementationSpecific")), Backend: *backend("kuard", 8080), }, { Path: "/foo2", - PathType: (*networking_v1.PathType)(ref.To("ImplementationSpecific")), + PathType: (*networking_v1.PathType)(ptr.To("ImplementationSpecific")), Backend: *backend("kuard", 8080), }, { Path: "/foo3[a|b]?", - PathType: (*networking_v1.PathType)(ref.To("ImplementationSpecific")), + PathType: (*networking_v1.PathType)(ptr.To("ImplementationSpecific")), Backend: *backend("kuard", 8080), }, { Path: "/foo4", - PathType: (*networking_v1.PathType)(ref.To("Exact")), + PathType: (*networking_v1.PathType)(ptr.To("Exact")), Backend: *backend("kuard", 8080), }, }, diff --git a/internal/xdscache/v3/runtime_test.go b/internal/xdscache/v3/runtime_test.go index 70c1185af3b..da68821341f 100644 --- a/internal/xdscache/v3/runtime_test.go +++ b/internal/xdscache/v3/runtime_test.go @@ -22,10 +22,10 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/protobuf" - "github.com/projectcontour/contour/internal/ref" ) func TestRuntimeCacheContents(t *testing.T) { @@ -38,7 +38,7 @@ func TestRuntimeCacheContents(t *testing.T) { }, "http max requests per io cycle set": { runtimeSettings: ConfigurableRuntimeSettings{ - MaxRequestsPerIOCycle: ref.To(uint32(1)), + MaxRequestsPerIOCycle: ptr.To(uint32(1)), }, additionalFields: map[string]*structpb.Value{ "http.max_requests_per_io_cycle": structpb.NewNumberValue(1), @@ -46,7 +46,7 @@ func TestRuntimeCacheContents(t *testing.T) { }, "http max requests per io cycle set invalid": { runtimeSettings: ConfigurableRuntimeSettings{ - MaxRequestsPerIOCycle: ref.To(uint32(0)), + MaxRequestsPerIOCycle: ptr.To(uint32(0)), }, }, "http max requests per io cycle set nil": { @@ -158,7 +158,7 @@ func TestRuntimeVisit(t *testing.T) { }, "configure max connection per listener for one listener": { ConfigurableRuntimeSettings: ConfigurableRuntimeSettings{ - MaxConnectionsPerListener: ref.To(uint32(100)), + MaxConnectionsPerListener: ptr.To(uint32(100)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -198,7 +198,7 @@ func TestRuntimeVisit(t *testing.T) { }, "configure max connection per listener for two listeners": { ConfigurableRuntimeSettings: ConfigurableRuntimeSettings{ - MaxConnectionsPerListener: ref.To(uint32(100)), + MaxConnectionsPerListener: ptr.To(uint32(100)), }, objs: []any{ &contour_v1.HTTPProxy{ @@ -254,7 +254,7 @@ func TestRuntimeVisit(t *testing.T) { func TestRuntimeCacheOnChangeDelete(t *testing.T) { configurableRuntimeSettings := ConfigurableRuntimeSettings{ - MaxConnectionsPerListener: ref.To(uint32(100)), + MaxConnectionsPerListener: ptr.To(uint32(100)), } objs := []any{ &contour_v1.HTTPProxy{ diff --git a/internal/xdscache/v3/server_test.go b/internal/xdscache/v3/server_test.go index 7472e17bfb3..a98490723e2 100644 --- a/internal/xdscache/v3/server_test.go +++ b/internal/xdscache/v3/server_test.go @@ -37,11 +37,11 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "github.com/projectcontour/contour/internal/contour" "github.com/projectcontour/contour/internal/dag" "github.com/projectcontour/contour/internal/fixture" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/internal/xds" contour_xds_v3 "github.com/projectcontour/contour/internal/xds/v3" "github.com/projectcontour/contour/internal/xdscache" @@ -124,10 +124,10 @@ func TestGRPC(t *testing.T) { }, Ports: []discovery_v1.EndpointPort{ { - Port: ref.To[int32](80), + Port: ptr.To[int32](80), }, { - Port: ref.To[int32](80), + Port: ptr.To[int32](80), }, }, }, false) diff --git a/pkg/config/parameters_test.go b/pkg/config/parameters_test.go index 8341906daff..a6f8526081a 100644 --- a/pkg/config/parameters_test.go +++ b/pkg/config/parameters_test.go @@ -21,8 +21,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" - - "github.com/projectcontour/contour/internal/ref" + "k8s.io/utils/ptr" ) func TestGetenvOr(t *testing.T) { @@ -462,42 +461,42 @@ network: `) check(func(t *testing.T, conf *Parameters) { - assert.Equal(t, ref.To(uint32(1)), conf.Listener.MaxRequestsPerConnection) + assert.Equal(t, ptr.To(uint32(1)), conf.Listener.MaxRequestsPerConnection) }, ` listener: max-requests-per-connection: 1 `) check(func(t *testing.T, conf *Parameters) { - assert.Equal(t, ref.To(uint32(10)), conf.Listener.HTTP2MaxConcurrentStreams) + assert.Equal(t, ptr.To(uint32(10)), conf.Listener.HTTP2MaxConcurrentStreams) }, ` listener: http2-max-concurrent-streams: 10 `) check(func(t *testing.T, conf *Parameters) { - assert.Equal(t, ref.To(uint32(1)), conf.Listener.PerConnectionBufferLimitBytes) + assert.Equal(t, ptr.To(uint32(1)), conf.Listener.PerConnectionBufferLimitBytes) }, ` listener: per-connection-buffer-limit-bytes: 1 `) check(func(t *testing.T, conf *Parameters) { - assert.Equal(t, ref.To(uint32(1)), conf.Listener.MaxRequestsPerIOCycle) + assert.Equal(t, ptr.To(uint32(1)), conf.Listener.MaxRequestsPerIOCycle) }, ` listener: max-requests-per-io-cycle: 1 `) check(func(t *testing.T, conf *Parameters) { - assert.Equal(t, ref.To(uint32(1)), conf.Listener.MaxConnectionsPerListener) + assert.Equal(t, ptr.To(uint32(1)), conf.Listener.MaxConnectionsPerListener) }, ` listener: max-connections-per-listener: 1 `) check(func(t *testing.T, conf *Parameters) { - assert.Equal(t, ref.To(uint32(1)), conf.Cluster.MaxRequestsPerConnection) + assert.Equal(t, ptr.To(uint32(1)), conf.Cluster.MaxRequestsPerConnection) }, ` cluster: max-requests-per-connection: 1 @@ -589,35 +588,35 @@ func TestListenerValidation(t *testing.T) { } require.Error(t, l.Validate()) l = &ListenerParameters{ - MaxRequestsPerConnection: ref.To(uint32(1)), + MaxRequestsPerConnection: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) l = &ListenerParameters{ - MaxRequestsPerConnection: ref.To(uint32(0)), + MaxRequestsPerConnection: ptr.To(uint32(0)), } require.Error(t, l.Validate()) l = &ListenerParameters{ - PerConnectionBufferLimitBytes: ref.To(uint32(1)), + PerConnectionBufferLimitBytes: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) l = &ListenerParameters{ - PerConnectionBufferLimitBytes: ref.To(uint32(0)), + PerConnectionBufferLimitBytes: ptr.To(uint32(0)), } require.Error(t, l.Validate()) l = &ListenerParameters{ - MaxRequestsPerIOCycle: ref.To(uint32(1)), + MaxRequestsPerIOCycle: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) l = &ListenerParameters{ - MaxRequestsPerIOCycle: ref.To(uint32(0)), + MaxRequestsPerIOCycle: ptr.To(uint32(0)), } require.Error(t, l.Validate()) l = &ListenerParameters{ - HTTP2MaxConcurrentStreams: ref.To(uint32(1)), + HTTP2MaxConcurrentStreams: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) l = &ListenerParameters{ - HTTP2MaxConcurrentStreams: ref.To(uint32(0)), + HTTP2MaxConcurrentStreams: ptr.To(uint32(0)), } require.Error(t, l.Validate()) l = &ListenerParameters{ @@ -637,11 +636,11 @@ func TestListenerValidation(t *testing.T) { require.Error(t, l.Validate()) l = &ListenerParameters{ - MaxConnectionsPerListener: ref.To(uint32(1)), + MaxConnectionsPerListener: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) l = &ListenerParameters{ - MaxConnectionsPerListener: ref.To(uint32(0)), + MaxConnectionsPerListener: ptr.To(uint32(0)), } require.Error(t, l.Validate()) } @@ -649,15 +648,15 @@ func TestListenerValidation(t *testing.T) { func TestClusterParametersValidation(t *testing.T) { var l *ClusterParameters l = &ClusterParameters{ - MaxRequestsPerConnection: ref.To(uint32(0)), + MaxRequestsPerConnection: ptr.To(uint32(0)), } require.Error(t, l.Validate()) l = &ClusterParameters{ - MaxRequestsPerConnection: ref.To(uint32(1)), + MaxRequestsPerConnection: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) l = &ClusterParameters{ - PerConnectionBufferLimitBytes: ref.To(uint32(0)), + PerConnectionBufferLimitBytes: ptr.To(uint32(0)), } require.Error(t, l.Validate()) l = &ClusterParameters{ @@ -667,7 +666,7 @@ func TestClusterParametersValidation(t *testing.T) { } require.Error(t, l.Validate()) l = &ClusterParameters{ - PerConnectionBufferLimitBytes: ref.To(uint32(1)), + PerConnectionBufferLimitBytes: ptr.To(uint32(1)), } require.NoError(t, l.Validate()) } @@ -677,36 +676,36 @@ func TestTracingConfigValidation(t *testing.T) { require.NoError(t, trace.Validate()) trace = &Tracing{ - IncludePodDetail: ref.To(false), - ServiceName: ref.To("contour"), - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + IncludePodDetail: ptr.To(false), + ServiceName: ptr.To("contour"), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: nil, ExtensionService: "projectcontour/otel-collector", } require.NoError(t, trace.Validate()) trace = &Tracing{ - IncludePodDetail: ref.To(false), - ServiceName: ref.To("contour"), - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + IncludePodDetail: ptr.To(false), + ServiceName: ptr.To("contour"), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: nil, } require.Error(t, trace.Validate()) trace = &Tracing{ - IncludePodDetail: ref.To(false), - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + IncludePodDetail: ptr.To(false), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: nil, ExtensionService: "projectcontour/otel-collector", } require.NoError(t, trace.Validate()) trace = &Tracing{ - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: []CustomTag{ { TagName: "first", @@ -719,8 +718,8 @@ func TestTracingConfigValidation(t *testing.T) { require.Error(t, trace.Validate()) trace = &Tracing{ - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: []CustomTag{ { Literal: "literal", @@ -731,9 +730,9 @@ func TestTracingConfigValidation(t *testing.T) { require.Error(t, trace.Validate()) trace = &Tracing{ - IncludePodDetail: ref.To(true), - OverallSampling: ref.To("100"), - MaxPathTagLength: ref.To(uint32(256)), + IncludePodDetail: ptr.To(true), + OverallSampling: ptr.To("100"), + MaxPathTagLength: ptr.To(uint32(256)), CustomTags: []CustomTag{ { TagName: "first", diff --git a/test/e2e/deployment.go b/test/e2e/deployment.go index fd73f1f69d7..beb56df0170 100644 --- a/test/e2e/deployment.go +++ b/test/e2e/deployment.go @@ -45,10 +45,10 @@ import ( apimachinery_util_yaml "k8s.io/apimachinery/pkg/util/yaml" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/pkg/config" ) @@ -523,7 +523,7 @@ func (d *Deployment) EnsureResourcesForLocalContour() error { // The envoy deployment uses host ports, so can have at most // one replica per node, and our cluster only has one worker // node, so scale the deployment to 1. - d.EnvoyDeployment.Spec.Replicas = ref.To(int32(1)) + d.EnvoyDeployment.Spec.Replicas = ptr.To(int32(1)) return d.EnsureEnvoyDeployment() } @@ -623,7 +623,7 @@ func (d *Deployment) StartLocalContour(config *config.Parameters, contourConfigu contourConfiguration.Spec.XDSServer.Port = port contourConfiguration.Spec.XDSServer.Address = listenAllAddress() contourConfiguration.Spec.XDSServer.TLS = &contour_v1alpha1.TLS{ - Insecure: ref.To(true), + Insecure: ptr.To(true), } if err := d.client.Create(context.TODO(), contourConfiguration); err != nil { @@ -832,7 +832,7 @@ func (d *Deployment) EnsureResourcesForInclusterContour(startContourDeployment b // The envoy deployment uses host ports, so can have at most // one replica per node, and our cluster only has one worker // node, so scale the deployment to 1. - d.EnvoyDeployment.Spec.Replicas = ref.To(int32(1)) + d.EnvoyDeployment.Spec.Replicas = ptr.To(int32(1)) if err := d.EnsureEnvoyDeployment(); err != nil { return err @@ -949,7 +949,7 @@ func (d *Deployment) DumpContourLogs() error { func (d *Deployment) EnsureDeleted(obj client.Object) error { // Delete the object; if it already doesn't exist, // then we're done. - err := d.client.Delete(context.Background(), obj, &client.DeleteOptions{PropagationPolicy: ref.To(meta_v1.DeletePropagationBackground)}) + err := d.client.Delete(context.Background(), obj, &client.DeleteOptions{PropagationPolicy: ptr.To(meta_v1.DeletePropagationBackground)}) if api_errors.IsNotFound(err) { return nil } diff --git a/test/e2e/fixtures.go b/test/e2e/fixtures.go index 3f1d1273927..07ef45d6baf 100644 --- a/test/e2e/fixtures.go +++ b/test/e2e/fixtures.go @@ -30,10 +30,10 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/pkg/config" ) @@ -88,7 +88,7 @@ func (e *Echo) DeployN(ns, name string, replicas int32) (func(), *apps_v1.Deploy Name: name, }, Spec: apps_v1.DeploymentSpec{ - Replicas: ref.To(replicas), + Replicas: ptr.To(replicas), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{"app.kubernetes.io/name": name}, }, @@ -194,7 +194,7 @@ func (e *Echo) ScaleAndWaitDeployment(name, ns string, replicas int32) { updateAndWaitFor(e.t, e.client, deployment, func(d *apps_v1.Deployment) { - d.Spec.Replicas = ref.To(replicas) + d.Spec.Replicas = ptr.To(replicas) }, func(d *apps_v1.Deployment) bool { if d.Status.Replicas == replicas && d.Status.ReadyReplicas == replicas { @@ -443,7 +443,7 @@ func (g *GRPC) Deploy(ns, name string) func() { Name: name, }, Spec: apps_v1.DeploymentSpec{ - Replicas: ref.To(int32(1)), + Replicas: ptr.To(int32(1)), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{"app.kubernetes.io/name": name}, }, @@ -565,7 +565,7 @@ func DefaultContourConfiguration() *contour_v1alpha1.ContourConfiguration { CAFile: "/certs/ca.crt", CertFile: "/certs/tls.crt", KeyFile: "/certs/tls.key", - Insecure: ref.To(false), + Insecure: ptr.To(false), }, }, Debug: &contour_v1alpha1.DebugConfig{ @@ -582,8 +582,8 @@ func DefaultContourConfiguration() *contour_v1alpha1.ContourConfiguration { "HTTP/1.1", "HTTP/2", }, Listener: &contour_v1alpha1.EnvoyListenerConfig{ - UseProxyProto: ref.To(false), - DisableAllowChunkedLength: ref.To(false), + UseProxyProto: ptr.To(false), + DisableAllowChunkedLength: ptr.To(false), ConnectionBalancer: "", TLS: &contour_v1alpha1.EnvoyTLS{ MinimumProtocolVersion: "1.2", @@ -624,13 +624,13 @@ func DefaultContourConfiguration() *contour_v1alpha1.ContourConfiguration { DNSLookupFamily: contour_v1alpha1.AutoClusterDNSFamily, }, Network: &contour_v1alpha1.NetworkParameters{ - EnvoyAdminPort: ref.To(9001), + EnvoyAdminPort: ptr.To(9001), }, }, HTTPProxy: &contour_v1alpha1.HTTPProxyConfig{ - DisablePermitInsecure: ref.To(false), + DisablePermitInsecure: ptr.To(false), }, - EnableExternalNameService: ref.To(false), + EnableExternalNameService: ptr.To(false), Metrics: &contour_v1alpha1.MetricsConfig{ Address: listenAllAddress(), Port: 8000, diff --git a/test/e2e/gateway/gateway_test.go b/test/e2e/gateway/gateway_test.go index dfdadbb55e6..9ffa6d4de59 100644 --- a/test/e2e/gateway/gateway_test.go +++ b/test/e2e/gateway/gateway_test.go @@ -27,11 +27,11 @@ import ( "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/pkg/config" "github.com/projectcontour/contour/test/e2e" ) @@ -159,7 +159,7 @@ var _ = Describe("Gateway API", func() { Port: gatewayapi_v1.PortNumber(80), AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -203,7 +203,7 @@ var _ = Describe("Gateway API", func() { {Kind: "HTTPRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -221,7 +221,7 @@ var _ = Describe("Gateway API", func() { {Kind: "HTTPRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -258,7 +258,7 @@ var _ = Describe("Gateway API", func() { Name: "https-1", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: gatewayapi_v1.PortNumber(443), - Hostname: ref.To(gatewayapi_v1.Hostname("https-1.gateway.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-1.gateway.projectcontour.io")), TLS: &gatewayapi_v1.GatewayTLSConfig{ CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert-1", ""), @@ -269,7 +269,7 @@ var _ = Describe("Gateway API", func() { {Kind: "HTTPRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -277,7 +277,7 @@ var _ = Describe("Gateway API", func() { Name: "https-2", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: gatewayapi_v1.PortNumber(443), - Hostname: ref.To(gatewayapi_v1.Hostname("https-2.gateway.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-2.gateway.projectcontour.io")), TLS: &gatewayapi_v1.GatewayTLSConfig{ CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert-2", ""), @@ -288,7 +288,7 @@ var _ = Describe("Gateway API", func() { {Kind: "HTTPRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -296,7 +296,7 @@ var _ = Describe("Gateway API", func() { Name: "https-3", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: gatewayapi_v1.PortNumber(443), - Hostname: ref.To(gatewayapi_v1.Hostname("https-3.gateway.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-3.gateway.projectcontour.io")), TLS: &gatewayapi_v1.GatewayTLSConfig{ CertificateRefs: []gatewayapi_v1.SecretObjectReference{ gatewayapi.CertificateRef("tlscert-3", ""), @@ -307,7 +307,7 @@ var _ = Describe("Gateway API", func() { {Kind: "HTTPRoute"}, }, Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -345,7 +345,7 @@ var _ = Describe("Gateway API", func() { Port: gatewayapi_v1.PortNumber(80), AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, diff --git a/test/e2e/gateway/host_rewrite_test.go b/test/e2e/gateway/host_rewrite_test.go index 721b381403d..545c9e5c6a2 100644 --- a/test/e2e/gateway/host_rewrite_test.go +++ b/test/e2e/gateway/host_rewrite_test.go @@ -21,10 +21,10 @@ import ( "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -51,8 +51,8 @@ func testHostRewrite(namespace string, gateway types.NamespacedName) { Matches: []gatewayapi_v1.HTTPRouteMatch{ { Path: &gatewayapi_v1.HTTPPathMatch{ - Type: ref.To(gatewayapi_v1.PathMatchPathPrefix), - Value: ref.To("/"), + Type: ptr.To(gatewayapi_v1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, }, diff --git a/test/e2e/gateway/request_redirect_test.go b/test/e2e/gateway/request_redirect_test.go index 1e111251eae..803d2577c02 100644 --- a/test/e2e/gateway/request_redirect_test.go +++ b/test/e2e/gateway/request_redirect_test.go @@ -23,10 +23,10 @@ import ( "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -55,10 +55,10 @@ func testRequestRedirectRule(namespace string, gateway types.NamespacedName) { { Type: gatewayapi_v1.HTTPRouteFilterRequestRedirect, RequestRedirect: &gatewayapi_v1.HTTPRequestRedirectFilter{ - Hostname: ref.To(gatewayapi_v1.PreciseHostname("envoyproxy.io")), - StatusCode: ref.To(301), - Scheme: ref.To("https"), - Port: ref.To(gatewayapi_v1.PortNumber(8080)), + Hostname: ptr.To(gatewayapi_v1.PreciseHostname("envoyproxy.io")), + StatusCode: ptr.To(301), + Scheme: ptr.To("https"), + Port: ptr.To(gatewayapi_v1.PortNumber(8080)), }, }, }, diff --git a/test/e2e/gateway/tcproute_test.go b/test/e2e/gateway/tcproute_test.go index 7eb8429bc17..4e3d4ea05f9 100644 --- a/test/e2e/gateway/tcproute_test.go +++ b/test/e2e/gateway/tcproute_test.go @@ -21,11 +21,11 @@ import ( "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -44,14 +44,14 @@ func testTCPRoute(namespace string, gateway types.NamespacedName) { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1alpha2.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace(gateway.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(gateway.Namespace)), Name: gatewayapi_v1.ObjectName(gateway.Name), }, }, }, Rules: []gatewayapi_v1alpha2.TCPRouteRule{ { - BackendRefs: gatewayapi.TLSRouteBackendRef("echo", 80, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("echo", 80, ptr.To(int32(1))), }, }, }, diff --git a/test/e2e/gateway/tls_gateway_test.go b/test/e2e/gateway/tls_gateway_test.go index f2d2aff9f91..34883d0902e 100644 --- a/test/e2e/gateway/tls_gateway_test.go +++ b/test/e2e/gateway/tls_gateway_test.go @@ -21,10 +21,10 @@ import ( "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -45,9 +45,9 @@ func testTLSGateway(namespace string, gateway types.NamespacedName) { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace(gateway.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(gateway.Namespace)), Name: gatewayapi_v1.ObjectName(gateway.Name), - SectionName: ref.To(gatewayapi_v1.SectionName("insecure")), + SectionName: ptr.To(gatewayapi_v1.SectionName("insecure")), }, }, }, @@ -71,9 +71,9 @@ func testTLSGateway(namespace string, gateway types.NamespacedName) { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace(gateway.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(gateway.Namespace)), Name: gatewayapi_v1.ObjectName(gateway.Name), - SectionName: ref.To(gatewayapi_v1.SectionName("secure")), + SectionName: ptr.To(gatewayapi_v1.SectionName("secure")), }, }, }, diff --git a/test/e2e/gateway/tls_wildcard_host_test.go b/test/e2e/gateway/tls_wildcard_host_test.go index ccb765a4913..54137abe33f 100644 --- a/test/e2e/gateway/tls_wildcard_host_test.go +++ b/test/e2e/gateway/tls_wildcard_host_test.go @@ -22,10 +22,10 @@ import ( "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/projectcontour/contour/internal/gatewayapi" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -46,9 +46,9 @@ func testTLSWildcardHost(namespace string, gateway types.NamespacedName) { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace(gateway.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(gateway.Namespace)), Name: gatewayapi_v1.ObjectName(gateway.Name), - SectionName: ref.To(gatewayapi_v1.SectionName("secure")), + SectionName: ptr.To(gatewayapi_v1.SectionName("secure")), }, }, }, diff --git a/test/e2e/httpproxy/cookie_rewrite_test.go b/test/e2e/httpproxy/cookie_rewrite_test.go index 9d3bfccc2c0..daa0f33436d 100644 --- a/test/e2e/httpproxy/cookie_rewrite_test.go +++ b/test/e2e/httpproxy/cookie_rewrite_test.go @@ -29,10 +29,10 @@ import ( core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -162,7 +162,7 @@ func testInvalidCookieRewriteFields(namespace string) { CookieRewritePolicies: []contour_v1.CookieRewritePolicy{ { Name: "invalid-samesite", - SameSite: ref.To("Invalid"), + SameSite: ptr.To("Invalid"), }, }, Services: []contour_v1.Service{ @@ -214,8 +214,8 @@ func testAppCookieRewrite(namespace string) { Name: "no-attributes", PathRewrite: &contour_v1.CookiePathRewrite{Value: "/foo"}, DomainRewrite: &contour_v1.CookieDomainRewrite{Value: "foo.com"}, - Secure: ref.To(true), - SameSite: ref.To("Strict"), + Secure: ptr.To(true), + SameSite: ptr.To("Strict"), }, }, Services: []contour_v1.Service{ @@ -234,8 +234,8 @@ func testAppCookieRewrite(namespace string) { Name: "rewrite-all", PathRewrite: &contour_v1.CookiePathRewrite{Value: "/ra"}, DomainRewrite: &contour_v1.CookieDomainRewrite{Value: "ra.com"}, - Secure: ref.To(false), - SameSite: ref.To("Lax"), + Secure: ptr.To(false), + SameSite: ptr.To("Lax"), }, }, Services: []contour_v1.Service{ @@ -333,8 +333,8 @@ func testAppCookieRewrite(namespace string) { { Name: "route-service", PathRewrite: &contour_v1.CookiePathRewrite{Value: "/service"}, - Secure: ref.To(true), - SameSite: ref.To("Lax"), + Secure: ptr.To(true), + SameSite: ptr.To("Lax"), }, { Name: "service", @@ -506,8 +506,8 @@ func testHeaderRewriteCookieRewrite(namespace string) { CookieRewritePolicies: []contour_v1.CookieRewritePolicy{ { Name: "X-Contour-Session-Affinity", - Secure: ref.To(true), - SameSite: ref.To("Strict"), + Secure: ptr.To(true), + SameSite: ptr.To("Strict"), }, }, Services: []contour_v1.Service{ @@ -681,8 +681,8 @@ func testCookieRewriteTLS(namespace string) { Name: "a-cookie", PathRewrite: &contour_v1.CookiePathRewrite{Value: "/"}, DomainRewrite: &contour_v1.CookieDomainRewrite{Value: "cookie-rewrite-tls.projectcontour.io"}, - Secure: ref.To(true), - SameSite: ref.To("Strict"), + Secure: ptr.To(true), + SameSite: ptr.To("Strict"), }, }, Services: []contour_v1.Service{ diff --git a/test/e2e/httpproxy/external_name_test.go b/test/e2e/httpproxy/external_name_test.go index 3f322e08052..20baf86a355 100644 --- a/test/e2e/httpproxy/external_name_test.go +++ b/test/e2e/httpproxy/external_name_test.go @@ -23,9 +23,9 @@ import ( "github.com/stretchr/testify/require" core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -138,7 +138,7 @@ func testExternalNameServiceTLS(namespace string) { { Name: externalNameService.Name, Port: 443, - Protocol: ref.To("tls"), + Protocol: ptr.To("tls"), }, }, RequestHeadersPolicy: &contour_v1.HeadersPolicy{ diff --git a/test/e2e/httpproxy/fqdn_test.go b/test/e2e/httpproxy/fqdn_test.go index b113a48921e..4057928f3b2 100644 --- a/test/e2e/httpproxy/fqdn_test.go +++ b/test/e2e/httpproxy/fqdn_test.go @@ -23,9 +23,9 @@ import ( "github.com/stretchr/testify/require" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -201,7 +201,7 @@ func testIngressWildcardSubdomainFQDN(namespace string) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: "/", Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/httpproxy/grpc_test.go b/test/e2e/httpproxy/grpc_test.go index 28088948158..a0f5264390d 100644 --- a/test/e2e/httpproxy/grpc_test.go +++ b/test/e2e/httpproxy/grpc_test.go @@ -34,9 +34,9 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -67,7 +67,7 @@ func testGRPCServicePlaintext(namespace string) { { Name: "grpc-echo", Port: 9000, - Protocol: ref.To("h2c"), + Protocol: ptr.To("h2c"), }, }, Conditions: []contour_v1.MatchCondition{ @@ -151,7 +151,7 @@ func testGRPCWeb(namespace string) { { Name: "grpc-echo", Port: 9000, - Protocol: ref.To("h2c"), + Protocol: ptr.To("h2c"), }, }, }, diff --git a/test/e2e/httpproxy/httpproxy_test.go b/test/e2e/httpproxy/httpproxy_test.go index e5e9a87c6f9..ff01a0af897 100644 --- a/test/e2e/httpproxy/httpproxy_test.go +++ b/test/e2e/httpproxy/httpproxy_test.go @@ -28,10 +28,10 @@ import ( "github.com/onsi/gomega/gexec" "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/pkg/config" "github.com/projectcontour/contour/test/e2e" ) @@ -117,7 +117,7 @@ var _ = Describe("HTTPProxy", func() { Context("with ExternalName Services enabled", func() { BeforeEach(func() { contourConfig.EnableExternalNameService = true - contourConfiguration.Spec.EnableExternalNameService = ref.To(true) + contourConfiguration.Spec.EnableExternalNameService = ptr.To(true) }) testInternalRedirectPolicy(namespace) }) @@ -145,7 +145,7 @@ var _ = Describe("HTTPProxy", func() { Context("set to true", func() { BeforeEach(func() { contourConfig.DisableMergeSlashes = true - contourConfiguration.Spec.Envoy.Listener.DisableMergeSlashes = ref.To(true) + contourConfiguration.Spec.Envoy.Listener.DisableMergeSlashes = ptr.To(true) }) f.NamespacedTest("httpproxy-disable-merge-slashes", testDisableMergeSlashes(true)) @@ -404,7 +404,7 @@ var _ = Describe("HTTPProxy", func() { Context("with ExternalName Services enabled", func() { BeforeEach(func() { contourConfig.EnableExternalNameService = true - contourConfiguration.Spec.EnableExternalNameService = ref.To(true) + contourConfiguration.Spec.EnableExternalNameService = ptr.To(true) }) testHostRewriteHeaderExternalNameService(namespace) }) @@ -415,7 +415,7 @@ var _ = Describe("HTTPProxy", func() { Context("with trusted xff hops", func() { BeforeEach(func() { contourConfig.Network.XffNumTrustedHops = 1 - contourConfiguration.Spec.Envoy.Network.XffNumTrustedHops = ref.To(uint32(1)) + contourConfiguration.Spec.Envoy.Network.XffNumTrustedHops = ptr.To(uint32(1)) }) testIPFilterPolicy(namespace) @@ -453,7 +453,7 @@ var _ = Describe("HTTPProxy", func() { Context("with ExternalName Services enabled", func() { BeforeEach(func() { contourConfig.EnableExternalNameService = true - contourConfiguration.Spec.EnableExternalNameService = ref.To(true) + contourConfiguration.Spec.EnableExternalNameService = ptr.To(true) }) testExternalNameServiceInsecure(namespace) }) @@ -463,7 +463,7 @@ var _ = Describe("HTTPProxy", func() { Context("with ExternalName Services enabled", func() { BeforeEach(func() { contourConfig.EnableExternalNameService = true - contourConfiguration.Spec.EnableExternalNameService = ref.To(true) + contourConfiguration.Spec.EnableExternalNameService = ptr.To(true) }) testExternalNameServiceTLS(namespace) }) @@ -473,7 +473,7 @@ var _ = Describe("HTTPProxy", func() { Context("with ExternalName Services enabled", func() { BeforeEach(func() { contourConfig.EnableExternalNameService = true - contourConfiguration.Spec.EnableExternalNameService = ref.To(true) + contourConfiguration.Spec.EnableExternalNameService = ptr.To(true) }) testExternalNameServiceLocalhostInvalid(namespace) }) @@ -498,8 +498,8 @@ var _ = Describe("HTTPProxy", func() { Namespace: namespace, }, Domain: "contour", - FailOpen: ref.To(false), - EnableXRateLimitHeaders: ref.To(false), + FailOpen: ptr.To(false), + EnableXRateLimitHeaders: ptr.To(false), } require.NoError(f.T(), f.Deployment.EnsureRateLimitResources( @@ -590,8 +590,8 @@ descriptors: Namespace: namespace, }, Domain: "contour-default-global-rate-limit", - FailOpen: ref.To(false), - EnableXRateLimitHeaders: ref.To(false), + FailOpen: ptr.To(false), + EnableXRateLimitHeaders: ptr.To(false), DefaultGlobalRateLimitPolicy: &contour_v1.GlobalRateLimitPolicy{ Descriptors: []contour_v1.RateLimitDescriptor{ { @@ -635,7 +635,7 @@ descriptors: - key: customHeader rate_limit: unit: hour - requests_per_unit: 1 + requests_per_unit: 1 - key: anotherHeader rate_limit: unit: hour diff --git a/test/e2e/httpproxy/internal_redirect_test.go b/test/e2e/httpproxy/internal_redirect_test.go index 68d29259589..d16920e8617 100644 --- a/test/e2e/httpproxy/internal_redirect_test.go +++ b/test/e2e/httpproxy/internal_redirect_test.go @@ -25,9 +25,9 @@ import ( "github.com/stretchr/testify/require" core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -192,9 +192,9 @@ func getInternalRedirectHTTPProxy(namespace string) *contour_v1.HTTPProxy { }}, Services: []contour_v1.Service{}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Hostname: ref.To(fqdn), - StatusCode: ref.To(302), - Path: ref.To("/echo"), + Hostname: ptr.To(fqdn), + StatusCode: ptr.To(302), + Path: ptr.To("/echo"), }, }, { diff --git a/test/e2e/httpproxy/request_redirect_test.go b/test/e2e/httpproxy/request_redirect_test.go index df8569f33de..972f9eacd21 100644 --- a/test/e2e/httpproxy/request_redirect_test.go +++ b/test/e2e/httpproxy/request_redirect_test.go @@ -22,9 +22,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -110,7 +110,7 @@ func getRedirectHTTPProxy(namespace string, removeServices bool) *contour_v1.HTT Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Hostname: ref.To("projectcontour.io"), + Hostname: ptr.To("projectcontour.io"), }, }, { Conditions: []contour_v1.MatchCondition{{ @@ -121,10 +121,10 @@ func getRedirectHTTPProxy(namespace string, removeServices bool) *contour_v1.HTT Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Scheme: ref.To("https"), - Hostname: ref.To("envoyproxy.io"), - Port: ref.To(int32(8080)), - StatusCode: ref.To(301), + Scheme: ptr.To("https"), + Hostname: ptr.To("envoyproxy.io"), + Port: ptr.To(int32(8080)), + StatusCode: ptr.To(301), }, }, { Conditions: []contour_v1.MatchCondition{{ @@ -135,7 +135,7 @@ func getRedirectHTTPProxy(namespace string, removeServices bool) *contour_v1.HTT Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Path: ref.To("/path"), + Path: ptr.To("/path"), }, }, { Conditions: []contour_v1.MatchCondition{{ @@ -146,7 +146,7 @@ func getRedirectHTTPProxy(namespace string, removeServices bool) *contour_v1.HTT Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Prefix: ref.To("/v2"), + Prefix: ptr.To("/v2"), }, }, { Conditions: []contour_v1.MatchCondition{{ @@ -157,7 +157,7 @@ func getRedirectHTTPProxy(namespace string, removeServices bool) *contour_v1.HTT Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Prefix: ref.To("/v2"), + Prefix: ptr.To("/v2"), }, }}, }, @@ -192,8 +192,8 @@ func getRedirectHTTPProxyInvalid(namespace string) *contour_v1.HTTPProxy { Port: 80, }}, RequestRedirectPolicy: &contour_v1.HTTPRequestRedirectPolicy{ - Path: ref.To("/path"), - Prefix: ref.To("/path"), + Path: ptr.To("/path"), + Prefix: ptr.To("/path"), }, }}, }, diff --git a/test/e2e/incluster/leaderelection_test.go b/test/e2e/incluster/leaderelection_test.go index 70b8d060bb5..a45c976d5e2 100644 --- a/test/e2e/incluster/leaderelection_test.go +++ b/test/e2e/incluster/leaderelection_test.go @@ -26,9 +26,8 @@ import ( coordination_v1 "k8s.io/api/coordination/v1" core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/projectcontour/contour/internal/ref" ) func testLeaderElection() { @@ -50,7 +49,7 @@ func testLeaderElection() { return "", err } - leaseHolder := ref.Val(leaderElectionLease.Spec.HolderIdentity, "") + leaseHolder := ptr.Deref(leaderElectionLease.Spec.HolderIdentity, "") if !strings.HasPrefix(leaseHolder, "contour-") { return "", fmt.Errorf("invalid leader name: %q", leaseHolder) } diff --git a/test/e2e/incluster/rbac_test.go b/test/e2e/incluster/rbac_test.go index d3e0d68a738..cc4f0cc24f4 100644 --- a/test/e2e/incluster/rbac_test.go +++ b/test/e2e/incluster/rbac_test.go @@ -25,11 +25,11 @@ import ( networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/retry" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -146,7 +146,7 @@ func testIngressResourceRBAC(namespace string) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: "/", Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/ingress/backend_tls_test.go b/test/e2e/ingress/backend_tls_test.go index be0517e92ea..b37b45769fe 100644 --- a/test/e2e/ingress/backend_tls_test.go +++ b/test/e2e/ingress/backend_tls_test.go @@ -27,9 +27,9 @@ import ( core_v1 "k8s.io/api/core/v1" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -69,7 +69,7 @@ func testBackendTLS(namespace string) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: "/", Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/ingress/headers_policy_test.go b/test/e2e/ingress/headers_policy_test.go index 8126c3ac5e3..6820ce8ca8f 100644 --- a/test/e2e/ingress/headers_policy_test.go +++ b/test/e2e/ingress/headers_policy_test.go @@ -23,8 +23,8 @@ import ( "github.com/stretchr/testify/require" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -62,7 +62,7 @@ func testGlobalHeadersPolicy(applyToIngress bool) e2e.NamespacedTestBody { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: "/", Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/ingress/ingress_class_test.go b/test/e2e/ingress/ingress_class_test.go index df16f298be9..faf65116fd3 100644 --- a/test/e2e/ingress/ingress_class_test.go +++ b/test/e2e/ingress/ingress_class_test.go @@ -22,8 +22,8 @@ import ( "github.com/stretchr/testify/require" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -40,7 +40,7 @@ func testIngressClass(namespace, class string) { Name: name, }, Spec: networking_v1.IngressSpec{ - IngressClassName: ref.To(class), + IngressClassName: ptr.To(class), Rules: []networking_v1.IngressRule{ { Host: name + ".projectcontour.io", @@ -48,7 +48,7 @@ func testIngressClass(namespace, class string) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: "/", Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/ingress/ingress_test.go b/test/e2e/ingress/ingress_test.go index a27db459b3d..0e48a3cf481 100644 --- a/test/e2e/ingress/ingress_test.go +++ b/test/e2e/ingress/ingress_test.go @@ -26,9 +26,9 @@ import ( "github.com/onsi/gomega/gexec" "github.com/stretchr/testify/require" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/pkg/config" "github.com/projectcontour/contour/test/e2e" ) @@ -237,7 +237,7 @@ var _ = Describe("Ingress", func() { Context("when ApplyToIngress is false", func() { BeforeEach(func() { contourConfig.Policy.ApplyToIngress = false - contourConfiguration.Spec.Policy.ApplyToIngress = ref.To(false) + contourConfiguration.Spec.Policy.ApplyToIngress = ptr.To(false) }) f.NamespacedTest("global-headers-policy-apply-to-ingress-false", testGlobalHeadersPolicy(false)) @@ -246,7 +246,7 @@ var _ = Describe("Ingress", func() { Context("when ApplyToIngress is true", func() { BeforeEach(func() { contourConfig.Policy.ApplyToIngress = true - contourConfiguration.Spec.Policy.ApplyToIngress = ref.To(true) + contourConfiguration.Spec.Policy.ApplyToIngress = ptr.To(true) }) f.NamespacedTest("global-headers-policy-apply-to-ingress-true", testGlobalHeadersPolicy(true)) diff --git a/test/e2e/ingress/long_path_match_test.go b/test/e2e/ingress/long_path_match_test.go index d945d69b371..9c9687e1d27 100644 --- a/test/e2e/ingress/long_path_match_test.go +++ b/test/e2e/ingress/long_path_match_test.go @@ -24,8 +24,8 @@ import ( "github.com/stretchr/testify/require" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -51,7 +51,7 @@ func testLongPathMatch(namespace string) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: longPrefixMatch, Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ @@ -63,7 +63,7 @@ func testLongPathMatch(namespace string) { }, }, { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: reallyLongPrefixMatch, Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ @@ -75,7 +75,7 @@ func testLongPathMatch(namespace string) { }, }, { - PathType: ref.To(networking_v1.PathTypeImplementationSpecific), + PathType: ptr.To(networking_v1.PathTypeImplementationSpecific), Path: longRegexMatch, Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/ingress/tls_wildcard_host_test.go b/test/e2e/ingress/tls_wildcard_host_test.go index f0c7223582a..12d1cedf365 100644 --- a/test/e2e/ingress/tls_wildcard_host_test.go +++ b/test/e2e/ingress/tls_wildcard_host_test.go @@ -23,8 +23,8 @@ import ( "github.com/stretchr/testify/require" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -55,7 +55,7 @@ func testTLSWildcardHost(namespace string) { HTTP: &networking_v1.HTTPIngressRuleValue{ Paths: []networking_v1.HTTPIngressPath{ { - PathType: ref.To(networking_v1.PathTypePrefix), + PathType: ptr.To(networking_v1.PathTypePrefix), Path: "/", Backend: networking_v1.IngressBackend{ Service: &networking_v1.IngressServiceBackend{ diff --git a/test/e2e/provisioner/provisioner_test.go b/test/e2e/provisioner/provisioner_test.go index c553b0745b1..0847189c68c 100644 --- a/test/e2e/provisioner/provisioner_test.go +++ b/test/e2e/provisioner/provisioner_test.go @@ -37,7 +37,6 @@ import ( contour_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/gatewayapi" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -81,7 +80,7 @@ var _ = BeforeSuite(func() { gc.Spec.ParametersRef = &gatewayapi_v1.ParametersReference{ Group: "projectcontour.io", Kind: "ContourDeployment", - Namespace: ref.To(gatewayapi_v1.Namespace(params.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(params.Namespace)), Name: params.Name, } } @@ -112,7 +111,7 @@ var _ = BeforeSuite(func() { ParametersRef: &gatewayapi_v1.ParametersReference{ Group: "projectcontour.io", Kind: "ContourDeployment", - Namespace: ref.To(gatewayapi_v1.Namespace(paramsEnvoyDeployment.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(paramsEnvoyDeployment.Namespace)), Name: paramsEnvoyDeployment.Name, }, }, @@ -176,7 +175,7 @@ var _ = Describe("Gateway provisioner", func() { ParametersRef: &gatewayapi_v1.ParametersReference{ Group: "projectcontour.io", Kind: "ContourDeployment", - Namespace: ref.To(gatewayapi_v1.Namespace(namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(namespace)), Name: "contour-params", }, }, @@ -200,7 +199,7 @@ var _ = Describe("Gateway provisioner", func() { Port: gatewayapi_v1.PortNumber(80), AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -270,7 +269,7 @@ var _ = Describe("Gateway provisioner", func() { Port: gatewayapi_v1.PortNumber(80), AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -340,21 +339,21 @@ var _ = Describe("Gateway provisioner", func() { Name: "http-1", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 80, - Hostname: ref.To(gatewayapi_v1.Hostname("http-1.provisioner.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("http-1.provisioner.projectcontour.io")), }, { Name: "http-2", Protocol: gatewayapi_v1.HTTPProtocolType, Port: 81, - Hostname: ref.To(gatewayapi_v1.Hostname("http-2.provisioner.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("http-2.provisioner.projectcontour.io")), }, { Name: "https-1", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 443, - Hostname: ref.To(gatewayapi_v1.Hostname("https-1.provisioner.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-1.provisioner.projectcontour.io")), TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ {Name: "https-1-cert"}, }, @@ -364,9 +363,9 @@ var _ = Describe("Gateway provisioner", func() { Name: "https-2", Protocol: gatewayapi_v1.HTTPSProtocolType, Port: 444, - Hostname: ref.To(gatewayapi_v1.Hostname("https-2.provisioner.projectcontour.io")), + Hostname: ptr.To(gatewayapi_v1.Hostname("https-2.provisioner.projectcontour.io")), TLS: &gatewayapi_v1.GatewayTLSConfig{ - Mode: ref.To(gatewayapi_v1.TLSModeTerminate), + Mode: ptr.To(gatewayapi_v1.TLSModeTerminate), CertificateRefs: []gatewayapi_v1.SecretObjectReference{ {Name: "https-2-cert"}, }, @@ -474,14 +473,14 @@ var _ = Describe("Gateway provisioner", func() { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1alpha2.ParentReference{ { - Namespace: ref.To(gatewayapi_v1.Namespace(gateway.Namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(gateway.Namespace)), Name: gatewayapi_v1.ObjectName(gateway.Name), }, }, }, Rules: []gatewayapi_v1alpha2.TCPRouteRule{ { - BackendRefs: gatewayapi.TLSRouteBackendRef("echo", 80, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("echo", 80, ptr.To(int32(1))), }, }, }, @@ -529,7 +528,7 @@ var _ = Describe("Gateway provisioner", func() { ParametersRef: &gatewayapi_v1.ParametersReference{ Group: "projectcontour.io", Kind: "ContourDeployment", - Namespace: ref.To(gatewayapi_v1.Namespace(namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(namespace)), Name: objectTestName, }, }, @@ -588,7 +587,7 @@ var _ = Describe("Gateway provisioner", func() { Namespaces: &gatewayapi_v1.RouteNamespaces{ // TODO: set to from all for now // The correct way would be label the testns-1, testns-2, testns-3, then select by label - From: ref.To(gatewayapi_v1.NamespacesFromAll), + From: ptr.To(gatewayapi_v1.NamespacesFromAll), }, }, }, @@ -697,7 +696,7 @@ var _ = Describe("Gateway provisioner", func() { ParametersRef: &gatewayapi_v1.ParametersReference{ Group: "projectcontour.io", Kind: "ContourDeployment", - Namespace: ref.To(gatewayapi_v1.Namespace(namespace)), + Namespace: ptr.To(gatewayapi_v1.Namespace(namespace)), Name: objectTestName, }, }, @@ -756,7 +755,7 @@ var _ = Describe("Gateway provisioner", func() { }, AllowedRoutes: &gatewayapi_v1.AllowedRoutes{ Namespaces: &gatewayapi_v1.RouteNamespaces{ - From: ref.To(gatewayapi_v1.NamespacesFromSame), + From: ptr.To(gatewayapi_v1.NamespacesFromSame), }, }, }, @@ -781,14 +780,14 @@ var _ = Describe("Gateway provisioner", func() { CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ ParentRefs: []gatewayapi_v1alpha2.ParentReference{ { - Namespace: ref.To(gatewayapi_v1alpha2.Namespace(gateway.Namespace)), + Namespace: ptr.To(gatewayapi_v1alpha2.Namespace(gateway.Namespace)), Name: gatewayapi_v1alpha2.ObjectName(gateway.Name), }, }, }, Rules: []gatewayapi_v1alpha2.TLSRouteRule{ { - BackendRefs: gatewayapi.TLSRouteBackendRef("echo-secure", 443, ref.To(int32(1))), + BackendRefs: gatewayapi.TLSRouteBackendRef("echo-secure", 443, ptr.To(int32(1))), }, }, }, diff --git a/test/e2e/upgrade/upgrade_test.go b/test/e2e/upgrade/upgrade_test.go index 7088743c5df..f9c86d03e9b 100644 --- a/test/e2e/upgrade/upgrade_test.go +++ b/test/e2e/upgrade/upgrade_test.go @@ -29,12 +29,12 @@ import ( "github.com/stretchr/testify/require" apps_v1 "k8s.io/api/apps/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1" "github.com/projectcontour/contour/internal/k8s" - "github.com/projectcontour/contour/internal/ref" "github.com/projectcontour/contour/test/e2e" ) @@ -190,7 +190,7 @@ var _ = Describe("When upgrading", func() { Name: "http", Port: gatewayapi_v1.PortNumber(80), Protocol: gatewayapi_v1.HTTPProtocolType, - Hostname: ref.To(gatewayapi_v1.Hostname(appHost)), + Hostname: ptr.To(gatewayapi_v1.Hostname(appHost)), }, }, }, @@ -222,7 +222,7 @@ var _ = Describe("When upgrading", func() { BackendRef: gatewayapi_v1.BackendRef{ BackendObjectReference: gatewayapi_v1.BackendObjectReference{ Name: gatewayapi_v1.ObjectName("echo"), - Port: ref.To(gatewayapi_v1.PortNumber(80)), + Port: ptr.To(gatewayapi_v1.PortNumber(80)), }, }, },