From 28e1a485fad395291dd633e3d472f130455de0e8 Mon Sep 17 00:00:00 2001 From: sh2 Date: Sat, 15 Jun 2024 01:16:03 +0800 Subject: [PATCH] chore: enable importas for lint (#3603) * enable lint-importas check for gateway and k8s api Signed-off-by: shawnh2 * fix lint Signed-off-by: shawnh2 --------- Signed-off-by: shawnh2 --- api/v1alpha1/envoygateway_metrics_types.go | 6 +- api/v1alpha1/envoyproxy_helpers.go | 14 +- api/v1alpha1/kubernetes_helpers.go | 26 +- api/v1alpha1/shared_types.go | 6 +- .../validation/envoygateway_validate.go | 30 +- .../validation/envoygateway_validate_test.go | 638 +++++++++--------- .../validation/envoyproxy_validate_test.go | 10 +- internal/admin/server.go | 4 +- internal/admin/server_test.go | 6 +- internal/cmd/egctl/config.go | 4 +- internal/cmd/egctl/config_ratelimit.go | 10 +- internal/cmd/egctl/status.go | 22 +- internal/cmd/egctl/status_test.go | 158 ++--- internal/cmd/egctl/translate.go | 32 +- internal/cmd/envoy/shutdown_manager.go | 6 +- internal/cmd/version/version.go | 4 +- internal/crypto/certgen.go | 4 +- internal/envoygateway/config/config.go | 8 +- internal/envoygateway/config/config_test.go | 18 +- internal/envoygateway/config/decoder.go | 12 +- internal/envoygateway/config/decoder_test.go | 214 +++--- internal/envoygateway/scheme.go | 4 +- .../extension/registry/extension_manager.go | 24 +- .../registry/extension_manager_test.go | 24 +- internal/extension/types/manager.go | 10 +- internal/gatewayapi/address.go | 4 +- internal/gatewayapi/backendtrafficpolicy.go | 14 +- internal/gatewayapi/clienttrafficpolicy.go | 14 +- internal/gatewayapi/contexts.go | 26 +- internal/gatewayapi/envoyextensionpolicy.go | 14 +- internal/gatewayapi/envoypatchpolicy.go | 20 +- internal/gatewayapi/extensionserverpolicy.go | 26 +- .../gatewayapi/extensionserverpolicy_test.go | 24 +- internal/gatewayapi/helpers.go | 20 +- internal/gatewayapi/resource.go | 34 +- internal/gatewayapi/route.go | 12 +- internal/gatewayapi/runner/runner.go | 16 +- internal/gatewayapi/securitypolicy.go | 20 +- .../gatewayapi/status/envoypatchpolicy.go | 10 +- internal/gatewayapi/status/policy.go | 34 +- internal/gatewayapi/tls.go | 6 +- internal/gatewayapi/tls_test.go | 4 +- internal/gatewayapi/translator_test.go | 14 +- internal/gatewayapi/validate.go | 34 +- internal/globalratelimit/runner/runner.go | 10 +- internal/infrastructure/kubernetes/infra.go | 8 +- .../kubernetes/infra_resource.go | 6 +- .../proxy/resource_provider_test.go | 18 +- .../kubernetes/ratelimit/resource_provider.go | 4 +- .../ratelimit/resource_provider_test.go | 4 +- internal/infrastructure/manager.go | 4 +- internal/infrastructure/runner/runner.go | 6 +- internal/ir/infra.go | 8 +- internal/ir/xds.go | 4 +- internal/logging/log.go | 20 +- internal/logging/log_test.go | 18 +- internal/message/watchutil.go | 4 +- internal/metrics/metadata.go | 4 +- internal/metrics/register.go | 8 +- internal/provider/kubernetes/controller.go | 16 +- internal/provider/kubernetes/helpers.go | 6 +- internal/provider/kubernetes/indexers.go | 50 +- internal/provider/kubernetes/predicates.go | 6 +- .../provider/kubernetes/predicates_test.go | 190 +++--- internal/provider/kubernetes/status.go | 48 +- internal/provider/kubernetes/store_test.go | 12 +- internal/provider/runner/runner.go | 10 +- internal/provider/runner/runner_test.go | 16 +- internal/xds/server/runner/runner.go | 6 +- internal/xds/server/runner/runner_test.go | 4 +- internal/xds/translator/extension.go | 10 +- internal/xds/translator/jwt.go | 4 +- internal/xds/translator/runner/runner.go | 6 +- internal/xds/translator/runner/runner_test.go | 6 +- internal/xds/translator/translator.go | 4 +- internal/xds/translator/translator_test.go | 22 +- test/e2e/tests/authorization-client-ip.go | 10 +- .../e2e/tests/authorization-default-action.go | 10 +- test/e2e/tests/backend_tls_settings.go | 32 +- test/e2e/tests/basic_auth.go | 34 +- test/e2e/tests/connection_limit.go | 10 +- test/e2e/tests/envoy_shutdown.go | 10 +- test/e2e/tests/ext_auth_grpc_service.go | 28 +- test/e2e/tests/ext_auth_http_service.go | 28 +- test/e2e/tests/ext_proc.go | 22 +- test/e2e/tests/local_ratelimit.go | 16 +- test/e2e/tests/oidc.go | 16 +- test/e2e/tests/tcp_route.go | 38 +- test/e2e/tests/udproute.go | 38 +- test/e2e/tests/utils.go | 14 +- test/e2e/tests/wasm.go | 16 +- tools/linter/golangci-lint/.golangci.yml | 27 + 92 files changed, 1279 insertions(+), 1252 deletions(-) diff --git a/api/v1alpha1/envoygateway_metrics_types.go b/api/v1alpha1/envoygateway_metrics_types.go index 7d796e848f6..62aeec39519 100644 --- a/api/v1alpha1/envoygateway_metrics_types.go +++ b/api/v1alpha1/envoygateway_metrics_types.go @@ -5,7 +5,7 @@ package v1alpha1 -import gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" +import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" // EnvoyGatewayMetrics defines control plane push/pull metrics configurations. type EnvoyGatewayMetrics struct { @@ -45,13 +45,13 @@ type EnvoyGatewayOpenTelemetrySink struct { // OTEL_METRIC_EXPORT_INTERVAL environment variable. // If ExportInterval is less than or equal to zero, 60 seconds // is used as the default. - ExportInterval *gatewayv1.Duration `json:"exportInterval,omitempty"` + ExportInterval *gwapiv1.Duration `json:"exportInterval,omitempty"` // ExportTimeout configures the time a Sink waits for an export to // complete before canceling it. This option overrides any value set for the // OTEL_METRIC_EXPORT_TIMEOUT environment variable. // If ExportTimeout is less than or equal to zero, 30 seconds // is used as the default. - ExportTimeout *gatewayv1.Duration `json:"exportTimeout,omitempty"` + ExportTimeout *gwapiv1.Duration `json:"exportTimeout,omitempty"` } // EnvoyGatewayPrometheusProvider will expose prometheus endpoint in pull mode. diff --git a/api/v1alpha1/envoyproxy_helpers.go b/api/v1alpha1/envoyproxy_helpers.go index 03f50d9c9e3..3d5016bae9f 100644 --- a/api/v1alpha1/envoyproxy_helpers.go +++ b/api/v1alpha1/envoyproxy_helpers.go @@ -11,7 +11,7 @@ import ( "strings" autoscalingv2 "k8s.io/api/autoscaling/v2" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/utils/ptr" ) @@ -46,7 +46,7 @@ func DefaultEnvoyProxyHpaMetrics() []autoscalingv2.MetricSpec { return []autoscalingv2.MetricSpec{ { Resource: &autoscalingv2.ResourceMetricSource{ - Name: v1.ResourceCPU, + Name: corev1.ResourceCPU, Target: autoscalingv2.MetricTarget{ Type: autoscalingv2.UtilizationMetricType, AverageUtilization: ptr.To[int32](80), @@ -149,11 +149,11 @@ func (logging *ProxyLogging) GetEnvoyProxyComponentLevel() string { } // DefaultShutdownManagerContainerResourceRequirements returns a new ResourceRequirements with default settings. -func DefaultShutdownManagerContainerResourceRequirements() *v1.ResourceRequirements { - return &v1.ResourceRequirements{ - Requests: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse(DefaultShutdownManagerCPUResourceRequests), - v1.ResourceMemory: resource.MustParse(DefaultShutdownManagerMemoryResourceRequests), +func DefaultShutdownManagerContainerResourceRequirements() *corev1.ResourceRequirements { + return &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse(DefaultShutdownManagerCPUResourceRequests), + corev1.ResourceMemory: resource.MustParse(DefaultShutdownManagerMemoryResourceRequests), }, } } diff --git a/api/v1alpha1/kubernetes_helpers.go b/api/v1alpha1/kubernetes_helpers.go index f22f51822f4..1ac790b9c13 100644 --- a/api/v1alpha1/kubernetes_helpers.go +++ b/api/v1alpha1/kubernetes_helpers.go @@ -10,7 +10,7 @@ import ( "fmt" jsonpatch "github.com/evanphx/json-patch" - appv1 "k8s.io/api/apps/v1" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/strategicpatch" @@ -18,16 +18,16 @@ import ( ) // DefaultKubernetesDeploymentStrategy returns the default deployment strategy settings. -func DefaultKubernetesDeploymentStrategy() *appv1.DeploymentStrategy { - return &appv1.DeploymentStrategy{ - Type: appv1.RollingUpdateDeploymentStrategyType, +func DefaultKubernetesDeploymentStrategy() *appsv1.DeploymentStrategy { + return &appsv1.DeploymentStrategy{ + Type: appsv1.RollingUpdateDeploymentStrategyType, } } // DefaultKubernetesDaemonSetStrategy returns the default daemonset strategy settings. -func DefaultKubernetesDaemonSetStrategy() *appv1.DaemonSetUpdateStrategy { - return &appv1.DaemonSetUpdateStrategy{ - Type: appv1.RollingUpdateDaemonSetStrategyType, +func DefaultKubernetesDaemonSetStrategy() *appsv1.DaemonSetUpdateStrategy { + return &appsv1.DaemonSetUpdateStrategy{ + Type: appsv1.RollingUpdateDaemonSetStrategyType, } } @@ -157,7 +157,7 @@ func (hpa *KubernetesHorizontalPodAutoscalerSpec) setDefault() { } // ApplyMergePatch applies a merge patch to a deployment based on the merge type -func (deployment *KubernetesDeploymentSpec) ApplyMergePatch(old *appv1.Deployment) (*appv1.Deployment, error) { +func (deployment *KubernetesDeploymentSpec) ApplyMergePatch(old *appsv1.Deployment) (*appsv1.Deployment, error) { if deployment.Patch == nil { return old, nil } @@ -173,7 +173,7 @@ func (deployment *KubernetesDeploymentSpec) ApplyMergePatch(old *appv1.Deploymen switch { case deployment.Patch.Type == nil || *deployment.Patch.Type == StrategicMerge: - patchedJSON, err = strategicpatch.StrategicMergePatch(originalJSON, deployment.Patch.Value.Raw, appv1.Deployment{}) + patchedJSON, err = strategicpatch.StrategicMergePatch(originalJSON, deployment.Patch.Value.Raw, appsv1.Deployment{}) case *deployment.Patch.Type == JSONMerge: patchedJSON, err = jsonpatch.MergePatch(originalJSON, deployment.Patch.Value.Raw) default: @@ -184,7 +184,7 @@ func (deployment *KubernetesDeploymentSpec) ApplyMergePatch(old *appv1.Deploymen } // Deserialize the patched JSON into a new deployment object - var patchedDeployment appv1.Deployment + var patchedDeployment appsv1.Deployment if err := json.Unmarshal(patchedJSON, &patchedDeployment); err != nil { return nil, fmt.Errorf("error unmarshaling patched deployment: %w", err) } @@ -193,7 +193,7 @@ func (deployment *KubernetesDeploymentSpec) ApplyMergePatch(old *appv1.Deploymen } // ApplyMergePatch applies a merge patch to a daemonset based on the merge type -func (daemonset *KubernetesDaemonSetSpec) ApplyMergePatch(old *appv1.DaemonSet) (*appv1.DaemonSet, error) { +func (daemonset *KubernetesDaemonSetSpec) ApplyMergePatch(old *appsv1.DaemonSet) (*appsv1.DaemonSet, error) { if daemonset.Patch == nil { return old, nil } @@ -209,7 +209,7 @@ func (daemonset *KubernetesDaemonSetSpec) ApplyMergePatch(old *appv1.DaemonSet) switch { case daemonset.Patch.Type == nil || *daemonset.Patch.Type == StrategicMerge: - patchedJSON, err = strategicpatch.StrategicMergePatch(originalJSON, daemonset.Patch.Value.Raw, appv1.DaemonSet{}) + patchedJSON, err = strategicpatch.StrategicMergePatch(originalJSON, daemonset.Patch.Value.Raw, appsv1.DaemonSet{}) case *daemonset.Patch.Type == JSONMerge: patchedJSON, err = jsonpatch.MergePatch(originalJSON, daemonset.Patch.Value.Raw) default: @@ -220,7 +220,7 @@ func (daemonset *KubernetesDaemonSetSpec) ApplyMergePatch(old *appv1.DaemonSet) } // Deserialize the patched JSON into a new daemonset object - var patchedDaemonSet appv1.DaemonSet + var patchedDaemonSet appsv1.DaemonSet if err := json.Unmarshal(patchedJSON, &patchedDaemonSet); err != nil { return nil, fmt.Errorf("error unmarshaling patched daemonset: %w", err) } diff --git a/api/v1alpha1/shared_types.go b/api/v1alpha1/shared_types.go index 71b9299bda0..6ad310859bc 100644 --- a/api/v1alpha1/shared_types.go +++ b/api/v1alpha1/shared_types.go @@ -6,7 +6,7 @@ package v1alpha1 import ( - appv1 "k8s.io/api/apps/v1" + appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -72,7 +72,7 @@ type KubernetesDeploymentSpec struct { // The deployment strategy to use to replace existing pods with new ones. // +optional - Strategy *appv1.DeploymentStrategy `json:"strategy,omitempty"` + Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` // Pod defines the desired specification of pod. // @@ -107,7 +107,7 @@ type KubernetesDaemonSetSpec struct { // The daemonset strategy to use to replace existing pods with new ones. // +optional - Strategy *appv1.DaemonSetUpdateStrategy `json:"strategy,omitempty"` + Strategy *appsv1.DaemonSetUpdateStrategy `json:"strategy,omitempty"` // Pod defines the desired specification of pod. // diff --git a/api/v1alpha1/validation/envoygateway_validate.go b/api/v1alpha1/validation/envoygateway_validate.go index 7851dab4fbe..91d61bcc80d 100644 --- a/api/v1alpha1/validation/envoygateway_validate.go +++ b/api/v1alpha1/validation/envoygateway_validate.go @@ -12,11 +12,11 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) // ValidateEnvoyGateway validates the provided EnvoyGateway. -func ValidateEnvoyGateway(eg *v1alpha1.EnvoyGateway) error { +func ValidateEnvoyGateway(eg *egv1a1.EnvoyGateway) error { switch { case eg == nil: return errors.New("envoy gateway config is unspecified") @@ -26,16 +26,16 @@ func ValidateEnvoyGateway(eg *v1alpha1.EnvoyGateway) error { return errors.New("gateway controllerName is unspecified") case eg.Provider == nil: return errors.New("provider is unspecified") - case eg.Provider.Type != v1alpha1.ProviderTypeKubernetes: + case eg.Provider.Type != egv1a1.ProviderTypeKubernetes: return fmt.Errorf("unsupported provider %v", eg.Provider.Type) case eg.Provider.Kubernetes != nil && eg.Provider.Kubernetes.Watch != nil: watch := eg.Provider.Kubernetes.Watch switch watch.Type { - case v1alpha1.KubernetesWatchModeTypeNamespaces: + case egv1a1.KubernetesWatchModeTypeNamespaces: if len(watch.Namespaces) == 0 { return errors.New("namespaces should be specified when envoy gateway watch mode is 'Namespaces'") } - case v1alpha1.KubernetesWatchModeTypeNamespaceSelector: + case egv1a1.KubernetesWatchModeTypeNamespaceSelector: if watch.NamespaceSelector == nil { return errors.New("namespaceSelector should be specified when envoy gateway watch mode is 'NamespaceSelector'") } @@ -46,15 +46,15 @@ func ValidateEnvoyGateway(eg *v1alpha1.EnvoyGateway) error { level := eg.Logging.Level for component, logLevel := range level { switch component { - case v1alpha1.LogComponentGatewayDefault, - v1alpha1.LogComponentProviderRunner, - v1alpha1.LogComponentGatewayAPIRunner, - v1alpha1.LogComponentXdsTranslatorRunner, - v1alpha1.LogComponentXdsServerRunner, - v1alpha1.LogComponentInfrastructureRunner, - v1alpha1.LogComponentGlobalRateLimitRunner: + case egv1a1.LogComponentGatewayDefault, + egv1a1.LogComponentProviderRunner, + egv1a1.LogComponentGatewayAPIRunner, + egv1a1.LogComponentXdsTranslatorRunner, + egv1a1.LogComponentXdsServerRunner, + egv1a1.LogComponentInfrastructureRunner, + egv1a1.LogComponentGlobalRateLimitRunner: switch logLevel { - case v1alpha1.LogLevelDebug, v1alpha1.LogLevelError, v1alpha1.LogLevelWarn, v1alpha1.LogLevelInfo: + case egv1a1.LogLevelDebug, egv1a1.LogLevelError, egv1a1.LogLevelWarn, egv1a1.LogLevelInfo: default: return errors.New("envoy gateway logging level invalid. valid options: info/debug/warn/error") } @@ -63,7 +63,7 @@ func ValidateEnvoyGateway(eg *v1alpha1.EnvoyGateway) error { } } case eg.RateLimit != nil: - if eg.RateLimit.Backend.Type != v1alpha1.RedisBackendType { + if eg.RateLimit.Backend.Type != egv1a1.RedisBackendType { return fmt.Errorf("unsupported ratelimit backend %v", eg.RateLimit.Backend.Type) } if eg.RateLimit.Backend.Redis == nil || eg.RateLimit.Backend.Redis.URL == "" { @@ -111,7 +111,7 @@ func ValidateEnvoyGateway(eg *v1alpha1.EnvoyGateway) error { case eg.Telemetry != nil: if eg.Telemetry.Metrics != nil { for _, sink := range eg.Telemetry.Metrics.Sinks { - if sink.Type == v1alpha1.MetricSinkTypeOpenTelemetry { + if sink.Type == egv1a1.MetricSinkTypeOpenTelemetry { if sink.OpenTelemetry == nil { return fmt.Errorf("OpenTelemetry is required when sink Type is OpenTelemetry") } diff --git a/api/v1alpha1/validation/envoygateway_validate_test.go b/api/v1alpha1/validation/envoygateway_validate_test.go index 4163ff80f80..004a5ac8298 100644 --- a/api/v1alpha1/validation/envoygateway_validate_test.go +++ b/api/v1alpha1/validation/envoygateway_validate_test.go @@ -11,22 +11,22 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) var ( - TLSSecretKind = v1.Kind("Secret") - TLSUnrecognizedKind = v1.Kind("Unrecognized") + TLSSecretKind = gwapiv1.Kind("Secret") + TLSUnrecognizedKind = gwapiv1.Kind("Unrecognized") ) func TestValidateEnvoyGateway(t *testing.T) { - eg := v1alpha1.DefaultEnvoyGateway() + eg := egv1a1.DefaultEnvoyGateway() testCases := []struct { name string - eg *v1alpha1.EnvoyGateway + eg *egv1a1.EnvoyGateway expect bool }{ { @@ -41,63 +41,63 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "unspecified gateway", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: egv1a1.DefaultEnvoyGatewayProvider(), }, }, expect: false, }, { name: "unspecified provider", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), }, }, expect: false, }, { name: "empty gateway controllerName", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: &v1alpha1.Gateway{ControllerName: ""}, - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: &egv1a1.Gateway{ControllerName: ""}, + Provider: egv1a1.DefaultEnvoyGatewayProvider(), }, }, expect: false, }, { name: "unsupported provider", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{Type: v1alpha1.ProviderTypeFile}, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{Type: egv1a1.ProviderTypeFile}, }, }, expect: false, }, { name: "empty ratelimit", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - RateLimit: &v1alpha1.RateLimit{}, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + RateLimit: &egv1a1.RateLimit{}, }, }, expect: false, }, { name: "empty ratelimit redis setting", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - RateLimit: &v1alpha1.RateLimit{ - Backend: v1alpha1.RateLimitDatabaseBackend{ - Type: v1alpha1.RedisBackendType, - Redis: &v1alpha1.RateLimitRedisSettings{}, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + RateLimit: &egv1a1.RateLimit{ + Backend: egv1a1.RateLimitDatabaseBackend{ + Type: egv1a1.RedisBackendType, + Redis: &egv1a1.RateLimitRedisSettings{}, }, }, }, @@ -106,14 +106,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "unknown ratelimit redis url format", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - RateLimit: &v1alpha1.RateLimit{ - Backend: v1alpha1.RateLimitDatabaseBackend{ - Type: v1alpha1.RedisBackendType, - Redis: &v1alpha1.RateLimitRedisSettings{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + RateLimit: &egv1a1.RateLimit{ + Backend: egv1a1.RateLimitDatabaseBackend{ + Type: egv1a1.RedisBackendType, + Redis: &egv1a1.RateLimitRedisSettings{ URL: ":foo", }, }, @@ -124,14 +124,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "happy ratelimit redis settings", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - RateLimit: &v1alpha1.RateLimit{ - Backend: v1alpha1.RateLimitDatabaseBackend{ - Type: v1alpha1.RedisBackendType, - Redis: &v1alpha1.RateLimitRedisSettings{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + RateLimit: &egv1a1.RateLimit{ + Backend: egv1a1.RateLimitDatabaseBackend{ + Type: egv1a1.RedisBackendType, + Redis: &egv1a1.RateLimitRedisSettings{ URL: "localhost:6376", }, }, @@ -142,30 +142,30 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "happy extension settings", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Hooks: &v1alpha1.ExtensionHooks{ - XDSTranslator: &v1alpha1.XDSTranslatorHooks{ - Pre: []v1alpha1.XDSTranslatorHook{}, - Post: []v1alpha1.XDSTranslatorHook{ - v1alpha1.XDSHTTPListener, - v1alpha1.XDSTranslation, - v1alpha1.XDSRoute, - v1alpha1.XDSVirtualHost, + Hooks: &egv1a1.ExtensionHooks{ + XDSTranslator: &egv1a1.XDSTranslatorHooks{ + Pre: []egv1a1.XDSTranslatorHook{}, + Post: []egv1a1.XDSTranslatorHook{ + egv1a1.XDSHTTPListener, + egv1a1.XDSTranslation, + egv1a1.XDSRoute, + egv1a1.XDSVirtualHost, }, }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.extension", Port: 80, }, @@ -176,36 +176,36 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "happy extension settings tls", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Hooks: &v1alpha1.ExtensionHooks{ - XDSTranslator: &v1alpha1.XDSTranslatorHooks{ - Pre: []v1alpha1.XDSTranslatorHook{}, - Post: []v1alpha1.XDSTranslatorHook{ - v1alpha1.XDSHTTPListener, - v1alpha1.XDSTranslation, - v1alpha1.XDSRoute, - v1alpha1.XDSVirtualHost, + Hooks: &egv1a1.ExtensionHooks{ + XDSTranslator: &egv1a1.XDSTranslatorHooks{ + Pre: []egv1a1.XDSTranslatorHook{}, + Post: []egv1a1.XDSTranslatorHook{ + egv1a1.XDSHTTPListener, + egv1a1.XDSTranslation, + egv1a1.XDSRoute, + egv1a1.XDSVirtualHost, }, }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.extension", Port: 443, - TLS: &v1alpha1.ExtensionTLS{ - CertificateRef: v1.SecretObjectReference{ + TLS: &egv1a1.ExtensionTLS{ + CertificateRef: gwapiv1.SecretObjectReference{ Kind: &TLSSecretKind, - Name: v1.ObjectName("certificate"), + Name: gwapiv1.ObjectName("certificate"), }, }, }, @@ -216,29 +216,29 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "happy extension settings no resources", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Hooks: &v1alpha1.ExtensionHooks{ - XDSTranslator: &v1alpha1.XDSTranslatorHooks{ - Pre: []v1alpha1.XDSTranslatorHook{}, - Post: []v1alpha1.XDSTranslatorHook{ - v1alpha1.XDSHTTPListener, - v1alpha1.XDSTranslation, - v1alpha1.XDSRoute, - v1alpha1.XDSVirtualHost, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Hooks: &egv1a1.ExtensionHooks{ + XDSTranslator: &egv1a1.XDSTranslatorHooks{ + Pre: []egv1a1.XDSTranslatorHook{}, + Post: []egv1a1.XDSTranslatorHook{ + egv1a1.XDSHTTPListener, + egv1a1.XDSTranslation, + egv1a1.XDSRoute, + egv1a1.XDSVirtualHost, }, }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.extension", Port: 443, - TLS: &v1alpha1.ExtensionTLS{ - CertificateRef: v1.SecretObjectReference{ + TLS: &egv1a1.ExtensionTLS{ + CertificateRef: gwapiv1.SecretObjectReference{ Kind: &TLSSecretKind, - Name: v1.ObjectName("certificate"), + Name: gwapiv1.ObjectName("certificate"), }, }, }, @@ -249,36 +249,36 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "unknown TLS certificateRef in extension settings", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Hooks: &v1alpha1.ExtensionHooks{ - XDSTranslator: &v1alpha1.XDSTranslatorHooks{ - Pre: []v1alpha1.XDSTranslatorHook{}, - Post: []v1alpha1.XDSTranslatorHook{ - v1alpha1.XDSHTTPListener, - v1alpha1.XDSTranslation, - v1alpha1.XDSRoute, - v1alpha1.XDSVirtualHost, + Hooks: &egv1a1.ExtensionHooks{ + XDSTranslator: &egv1a1.XDSTranslatorHooks{ + Pre: []egv1a1.XDSTranslatorHook{}, + Post: []egv1a1.XDSTranslatorHook{ + egv1a1.XDSHTTPListener, + egv1a1.XDSTranslation, + egv1a1.XDSRoute, + egv1a1.XDSVirtualHost, }, }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.extension", Port: 8080, - TLS: &v1alpha1.ExtensionTLS{ - CertificateRef: v1.SecretObjectReference{ + TLS: &egv1a1.ExtensionTLS{ + CertificateRef: gwapiv1.SecretObjectReference{ Kind: &TLSUnrecognizedKind, - Name: v1.ObjectName("certificate"), + Name: gwapiv1.ObjectName("certificate"), }, }, }, @@ -289,26 +289,26 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "empty service in extension settings", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Hooks: &v1alpha1.ExtensionHooks{ - XDSTranslator: &v1alpha1.XDSTranslatorHooks{ - Pre: []v1alpha1.XDSTranslatorHook{}, - Post: []v1alpha1.XDSTranslatorHook{ - v1alpha1.XDSHTTPListener, - v1alpha1.XDSTranslation, - v1alpha1.XDSRoute, - v1alpha1.XDSVirtualHost, + Hooks: &egv1a1.ExtensionHooks{ + XDSTranslator: &egv1a1.XDSTranslatorHooks{ + Pre: []egv1a1.XDSTranslatorHook{}, + Post: []egv1a1.XDSTranslatorHook{ + egv1a1.XDSHTTPListener, + egv1a1.XDSTranslation, + egv1a1.XDSRoute, + egv1a1.XDSVirtualHost, }, }, }, @@ -319,19 +319,19 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "empty hooks in extension settings", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.extension", Port: 8080, }, @@ -342,13 +342,13 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "valid gateway logging level info", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Logging: &v1alpha1.EnvoyGatewayLogging{ - Level: map[v1alpha1.EnvoyGatewayLogComponent]v1alpha1.LogLevel{ - v1alpha1.LogComponentGatewayDefault: v1alpha1.LogLevelInfo, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Logging: &egv1a1.EnvoyGatewayLogging{ + Level: map[egv1a1.EnvoyGatewayLogComponent]egv1a1.LogLevel{ + egv1a1.LogComponentGatewayDefault: egv1a1.LogLevelInfo, }, }, }, @@ -357,13 +357,13 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "valid gateway logging level warn", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Logging: &v1alpha1.EnvoyGatewayLogging{ - Level: map[v1alpha1.EnvoyGatewayLogComponent]v1alpha1.LogLevel{ - v1alpha1.LogComponentGatewayDefault: v1alpha1.LogLevelWarn, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Logging: &egv1a1.EnvoyGatewayLogging{ + Level: map[egv1a1.EnvoyGatewayLogComponent]egv1a1.LogLevel{ + egv1a1.LogComponentGatewayDefault: egv1a1.LogLevelWarn, }, }, }, @@ -372,13 +372,13 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "valid gateway logging level error", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Logging: &v1alpha1.EnvoyGatewayLogging{ - Level: map[v1alpha1.EnvoyGatewayLogComponent]v1alpha1.LogLevel{ - v1alpha1.LogComponentGatewayDefault: v1alpha1.LogLevelError, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Logging: &egv1a1.EnvoyGatewayLogging{ + Level: map[egv1a1.EnvoyGatewayLogComponent]egv1a1.LogLevel{ + egv1a1.LogComponentGatewayDefault: egv1a1.LogLevelError, }, }, }, @@ -387,14 +387,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "valid gateway logging level debug", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Logging: &v1alpha1.EnvoyGatewayLogging{ - Level: map[v1alpha1.EnvoyGatewayLogComponent]v1alpha1.LogLevel{ - v1alpha1.LogComponentGatewayDefault: v1alpha1.LogLevelDebug, - v1alpha1.LogComponentProviderRunner: v1alpha1.LogLevelDebug, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Logging: &egv1a1.EnvoyGatewayLogging{ + Level: map[egv1a1.EnvoyGatewayLogComponent]egv1a1.LogLevel{ + egv1a1.LogComponentGatewayDefault: egv1a1.LogLevelDebug, + egv1a1.LogComponentProviderRunner: egv1a1.LogLevelDebug, }, }, }, @@ -403,13 +403,13 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "invalid gateway logging level", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Logging: &v1alpha1.EnvoyGatewayLogging{ - Level: map[v1alpha1.EnvoyGatewayLogComponent]v1alpha1.LogLevel{ - v1alpha1.LogComponentGatewayDefault: "inffo", + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Logging: &egv1a1.EnvoyGatewayLogging{ + Level: map[egv1a1.EnvoyGatewayLogComponent]egv1a1.LogLevel{ + egv1a1.LogComponentGatewayDefault: "inffo", }, }, }, @@ -418,16 +418,16 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "valid gateway metrics sink", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Telemetry: &v1alpha1.EnvoyGatewayTelemetry{ - Metrics: &v1alpha1.EnvoyGatewayMetrics{ - Sinks: []v1alpha1.EnvoyGatewayMetricSink{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Telemetry: &egv1a1.EnvoyGatewayTelemetry{ + Metrics: &egv1a1.EnvoyGatewayMetrics{ + Sinks: []egv1a1.EnvoyGatewayMetricSink{ { - Type: v1alpha1.MetricSinkTypeOpenTelemetry, - OpenTelemetry: &v1alpha1.EnvoyGatewayOpenTelemetrySink{ + Type: egv1a1.MetricSinkTypeOpenTelemetry, + OpenTelemetry: &egv1a1.EnvoyGatewayOpenTelemetrySink{ Host: "x.x.x.x", Port: 4317, Protocol: "grpc", @@ -442,15 +442,15 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "invalid gateway metrics sink", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Telemetry: &v1alpha1.EnvoyGatewayTelemetry{ - Metrics: &v1alpha1.EnvoyGatewayMetrics{ - Sinks: []v1alpha1.EnvoyGatewayMetricSink{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Telemetry: &egv1a1.EnvoyGatewayTelemetry{ + Metrics: &egv1a1.EnvoyGatewayMetrics{ + Sinks: []egv1a1.EnvoyGatewayMetricSink{ { - Type: v1alpha1.MetricSinkTypeOpenTelemetry, + Type: egv1a1.MetricSinkTypeOpenTelemetry, }, }, }, @@ -461,13 +461,13 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "invalid gateway watch mode", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ Type: "foobar", }, }, @@ -478,14 +478,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "happy namespaces must be set when watch mode is Namespaces", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ - Type: v1alpha1.KubernetesWatchModeTypeNamespaces, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ + Type: egv1a1.KubernetesWatchModeTypeNamespaces, Namespaces: []string{"foo"}, }, }, @@ -496,14 +496,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "fail namespaces is not be set when watch mode is Namespaces", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ - Type: v1alpha1.KubernetesWatchModeTypeNamespaces, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ + Type: egv1a1.KubernetesWatchModeTypeNamespaces, NamespaceSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": ""}}, }, }, @@ -514,14 +514,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "happy namespaceSelector must be set when watch mode is NamespaceSelector", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ - Type: v1alpha1.KubernetesWatchModeTypeNamespaceSelector, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ + Type: egv1a1.KubernetesWatchModeTypeNamespaceSelector, NamespaceSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": ""}}, }, }, @@ -532,14 +532,14 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "fail namespaceSelector is not be set when watch mode is NamespaceSelector", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ - Type: v1alpha1.KubernetesWatchModeTypeNamespaceSelector, + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ + Type: egv1a1.KubernetesWatchModeTypeNamespaceSelector, }, }, }, @@ -549,19 +549,19 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "no extension server target set", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Port: 8080, }, }, @@ -571,25 +571,25 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "both host and path targets are set for extension server", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Service: &v1alpha1.ExtensionService{ - BackendEndpoint: v1alpha1.BackendEndpoint{ - FQDN: &v1alpha1.FQDNEndpoint{ + Service: &egv1a1.ExtensionService{ + BackendEndpoint: egv1a1.BackendEndpoint{ + FQDN: &egv1a1.FQDNEndpoint{ Hostname: "foo.example.com", Port: 8080, }, - Unix: &v1alpha1.UnixSocket{ + Unix: &egv1a1.UnixSocket{ Path: "/some/path", }, }, @@ -601,25 +601,25 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "multiple backend targets are set for extension server", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Service: &v1alpha1.ExtensionService{ - BackendEndpoint: v1alpha1.BackendEndpoint{ - FQDN: &v1alpha1.FQDNEndpoint{ + Service: &egv1a1.ExtensionService{ + BackendEndpoint: egv1a1.BackendEndpoint{ + FQDN: &egv1a1.FQDNEndpoint{ Hostname: "foo.example.com", Port: 8080, }, - IP: &v1alpha1.IPEndpoint{ + IP: &egv1a1.IPEndpoint{ Address: "10.9.8.7", Port: 8080, }, @@ -632,23 +632,23 @@ func TestValidateEnvoyGateway(t *testing.T) { }, { name: "both host and path targets are set for extension server", - eg: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - ExtensionManager: &v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + eg: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + ExtensionManager: &egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "Foo", }, }, - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.example.com", Port: 8080, - BackendEndpoint: v1alpha1.BackendEndpoint{ - FQDN: &v1alpha1.FQDNEndpoint{ + BackendEndpoint: egv1a1.BackendEndpoint{ + FQDN: &egv1a1.FQDNEndpoint{ Hostname: "foo.example.com", Port: 8080, }, @@ -675,74 +675,74 @@ func TestValidateEnvoyGateway(t *testing.T) { } func TestEnvoyGateway(t *testing.T) { - envoyGateway := v1alpha1.DefaultEnvoyGateway() + envoyGateway := egv1a1.DefaultEnvoyGateway() assert.NotNil(t, envoyGateway.Provider) assert.NotNil(t, envoyGateway.Gateway) assert.NotNil(t, envoyGateway.Logging) envoyGateway.SetEnvoyGatewayDefaults() - assert.Equal(t, envoyGateway.Logging, v1alpha1.DefaultEnvoyGatewayLogging()) + assert.Equal(t, envoyGateway.Logging, egv1a1.DefaultEnvoyGatewayLogging()) - logging := v1alpha1.DefaultEnvoyGatewayLogging() + logging := egv1a1.DefaultEnvoyGatewayLogging() assert.NotNil(t, logging) - assert.Equal(t, v1alpha1.LogLevelInfo, logging.Level[v1alpha1.LogComponentGatewayDefault]) + assert.Equal(t, egv1a1.LogLevelInfo, logging.Level[egv1a1.LogComponentGatewayDefault]) - gatewayLogging := &v1alpha1.EnvoyGatewayLogging{ + gatewayLogging := &egv1a1.EnvoyGatewayLogging{ Level: logging.Level, } gatewayLogging.SetEnvoyGatewayLoggingDefaults() assert.NotNil(t, gatewayLogging) - assert.Equal(t, v1alpha1.LogLevelInfo, gatewayLogging.Level[v1alpha1.LogComponentGatewayDefault]) + assert.Equal(t, egv1a1.LogLevelInfo, gatewayLogging.Level[egv1a1.LogComponentGatewayDefault]) } func TestDefaultEnvoyGatewayLoggingLevel(t *testing.T) { type args struct { component string - level v1alpha1.LogLevel + level egv1a1.LogLevel } tests := []struct { name string args args - want v1alpha1.LogLevel + want egv1a1.LogLevel }{ { name: "test default info level for empty level", args: args{component: "", level: ""}, - want: v1alpha1.LogLevelInfo, + want: egv1a1.LogLevelInfo, }, { name: "test default info level for empty level", - args: args{component: string(v1alpha1.LogComponentGatewayDefault), level: ""}, - want: v1alpha1.LogLevelInfo, + args: args{component: string(egv1a1.LogComponentGatewayDefault), level: ""}, + want: egv1a1.LogLevelInfo, }, { name: "test default info level for info level", - args: args{component: string(v1alpha1.LogComponentGatewayDefault), level: v1alpha1.LogLevelInfo}, - want: v1alpha1.LogLevelInfo, + args: args{component: string(egv1a1.LogComponentGatewayDefault), level: egv1a1.LogLevelInfo}, + want: egv1a1.LogLevelInfo, }, { name: "test default error level for error level", - args: args{component: string(v1alpha1.LogComponentGatewayDefault), level: v1alpha1.LogLevelError}, - want: v1alpha1.LogLevelError, + args: args{component: string(egv1a1.LogComponentGatewayDefault), level: egv1a1.LogLevelError}, + want: egv1a1.LogLevelError, }, { name: "test gateway-api error level for error level", - args: args{component: string(v1alpha1.LogComponentGatewayAPIRunner), level: v1alpha1.LogLevelError}, - want: v1alpha1.LogLevelError, + args: args{component: string(egv1a1.LogComponentGatewayAPIRunner), level: egv1a1.LogLevelError}, + want: egv1a1.LogLevelError, }, { name: "test gateway-api info level for info level", - args: args{component: string(v1alpha1.LogComponentGatewayAPIRunner), level: v1alpha1.LogLevelInfo}, - want: v1alpha1.LogLevelInfo, + args: args{component: string(egv1a1.LogComponentGatewayAPIRunner), level: egv1a1.LogLevelInfo}, + want: egv1a1.LogLevelInfo, }, { name: "test default gateway-api warn level for info level", - args: args{component: string(v1alpha1.LogComponentGatewayAPIRunner), level: ""}, - want: v1alpha1.LogLevelInfo, + args: args{component: string(egv1a1.LogComponentGatewayAPIRunner), level: ""}, + want: egv1a1.LogLevelInfo, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - logging := &v1alpha1.EnvoyGatewayLogging{} + logging := &egv1a1.EnvoyGatewayLogging{} if got := logging.DefaultEnvoyGatewayLoggingLevel(tt.args.level); got != tt.want { t.Errorf("defaultLevel() = %v, want %v", got, tt.want) } @@ -751,9 +751,9 @@ func TestDefaultEnvoyGatewayLoggingLevel(t *testing.T) { } func TestEnvoyGatewayProvider(t *testing.T) { - envoyGateway := &v1alpha1.EnvoyGateway{ + envoyGateway := &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{}, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{Provider: v1alpha1.DefaultEnvoyGatewayProvider()}, + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{Provider: egv1a1.DefaultEnvoyGatewayProvider()}, } assert.NotNil(t, envoyGateway.Provider) @@ -761,14 +761,14 @@ func TestEnvoyGatewayProvider(t *testing.T) { assert.NotNil(t, envoyGatewayProvider.Kubernetes) assert.Equal(t, envoyGateway.Provider, envoyGatewayProvider) - envoyGatewayProvider.Kubernetes = v1alpha1.DefaultEnvoyGatewayKubeProvider() - assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment, v1alpha1.DefaultKubernetesDeployment(v1alpha1.DefaultRateLimitImage)) + envoyGatewayProvider.Kubernetes = egv1a1.DefaultEnvoyGatewayKubeProvider() + assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment, egv1a1.DefaultKubernetesDeployment(egv1a1.DefaultRateLimitImage)) - envoyGatewayProvider.Kubernetes = &v1alpha1.EnvoyGatewayKubernetesProvider{} + envoyGatewayProvider.Kubernetes = &egv1a1.EnvoyGatewayKubernetesProvider{} assert.Nil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment) - envoyGatewayProvider.Kubernetes = &v1alpha1.EnvoyGatewayKubernetesProvider{ - RateLimitDeployment: &v1alpha1.KubernetesDeploymentSpec{ + envoyGatewayProvider.Kubernetes = &egv1a1.EnvoyGatewayKubernetesProvider{ + RateLimitDeployment: &egv1a1.KubernetesDeploymentSpec{ Replicas: nil, Pod: nil, Container: nil, @@ -779,10 +779,10 @@ func TestEnvoyGatewayProvider(t *testing.T) { assert.Nil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container) envoyGatewayKubeProvider := envoyGatewayProvider.GetEnvoyGatewayKubeProvider() - envoyGatewayProvider.Kubernetes = &v1alpha1.EnvoyGatewayKubernetesProvider{ - RateLimitDeployment: &v1alpha1.KubernetesDeploymentSpec{ + envoyGatewayProvider.Kubernetes = &egv1a1.EnvoyGatewayKubernetesProvider{ + RateLimitDeployment: &egv1a1.KubernetesDeploymentSpec{ Pod: nil, - Container: &v1alpha1.KubernetesContainerSpec{ + Container: &egv1a1.KubernetesContainerSpec{ Resources: nil, SecurityContext: nil, Image: nil, @@ -796,35 +796,35 @@ func TestEnvoyGatewayProvider(t *testing.T) { assert.Equal(t, envoyGatewayProvider.Kubernetes, envoyGatewayKubeProvider) assert.NotNil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment) - assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment, v1alpha1.DefaultKubernetesDeployment(v1alpha1.DefaultRateLimitImage)) + assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment, egv1a1.DefaultKubernetesDeployment(egv1a1.DefaultRateLimitImage)) assert.NotNil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Pod) - assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Pod, v1alpha1.DefaultKubernetesPod()) + assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Pod, egv1a1.DefaultKubernetesPod()) assert.NotNil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container) - assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container, v1alpha1.DefaultKubernetesContainer(v1alpha1.DefaultRateLimitImage)) + assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container, egv1a1.DefaultKubernetesContainer(egv1a1.DefaultRateLimitImage)) assert.NotNil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container.Resources) - assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container.Resources, v1alpha1.DefaultResourceRequirements()) + assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container.Resources, egv1a1.DefaultResourceRequirements()) assert.NotNil(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container.Image) - assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container.Image, v1alpha1.DefaultKubernetesContainerImage(v1alpha1.DefaultRateLimitImage)) + assert.Equal(t, envoyGatewayProvider.Kubernetes.RateLimitDeployment.Container.Image, egv1a1.DefaultKubernetesContainerImage(egv1a1.DefaultRateLimitImage)) } func TestEnvoyGatewayAdmin(t *testing.T) { // default envoygateway config admin should not be nil - eg := v1alpha1.DefaultEnvoyGateway() + eg := egv1a1.DefaultEnvoyGateway() assert.NotNil(t, eg.Admin) // get default admin config from envoygateway // values should be set in default egAdmin := eg.GetEnvoyGatewayAdmin() assert.NotNil(t, egAdmin) - assert.Equal(t, v1alpha1.GatewayAdminPort, egAdmin.Address.Port) - assert.Equal(t, v1alpha1.GatewayAdminHost, egAdmin.Address.Host) + assert.Equal(t, egv1a1.GatewayAdminPort, egAdmin.Address.Port) + assert.Equal(t, egv1a1.GatewayAdminHost, egAdmin.Address.Host) assert.False(t, egAdmin.EnableDumpConfig) assert.False(t, egAdmin.EnablePprof) // override the admin config // values should be updated - eg.Admin = &v1alpha1.EnvoyGatewayAdmin{ - Address: &v1alpha1.EnvoyGatewayAdminAddress{ + eg.Admin = &egv1a1.EnvoyGatewayAdmin{ + Address: &egv1a1.EnvoyGatewayAdminAddress{ Host: "0.0.0.0", Port: 19010, }, @@ -842,15 +842,15 @@ func TestEnvoyGatewayAdmin(t *testing.T) { eg.Admin = nil eg.SetEnvoyGatewayDefaults() assert.NotNil(t, eg.Admin) - assert.Equal(t, v1alpha1.GatewayAdminPort, eg.Admin.Address.Port) - assert.Equal(t, v1alpha1.GatewayAdminHost, eg.Admin.Address.Host) + assert.Equal(t, egv1a1.GatewayAdminPort, eg.Admin.Address.Port) + assert.Equal(t, egv1a1.GatewayAdminHost, eg.Admin.Address.Host) assert.False(t, eg.Admin.EnableDumpConfig) assert.False(t, eg.Admin.EnablePprof) } func TestEnvoyGatewayTelemetry(t *testing.T) { // default envoygateway config telemetry should not be nil - eg := v1alpha1.DefaultEnvoyGateway() + eg := egv1a1.DefaultEnvoyGateway() assert.NotNil(t, eg.Telemetry) // get default telemetry config from envoygateway @@ -863,21 +863,21 @@ func TestEnvoyGatewayTelemetry(t *testing.T) { // override the telemetry config // values should be updated - eg.Telemetry.Metrics = &v1alpha1.EnvoyGatewayMetrics{ - Prometheus: &v1alpha1.EnvoyGatewayPrometheusProvider{ + eg.Telemetry.Metrics = &egv1a1.EnvoyGatewayMetrics{ + Prometheus: &egv1a1.EnvoyGatewayPrometheusProvider{ Disable: true, }, - Sinks: []v1alpha1.EnvoyGatewayMetricSink{ + Sinks: []egv1a1.EnvoyGatewayMetricSink{ { - Type: v1alpha1.MetricSinkTypeOpenTelemetry, - OpenTelemetry: &v1alpha1.EnvoyGatewayOpenTelemetrySink{ + Type: egv1a1.MetricSinkTypeOpenTelemetry, + OpenTelemetry: &egv1a1.EnvoyGatewayOpenTelemetrySink{ Host: "otel-collector.monitoring.svc.cluster.local", Protocol: "grpc", Port: 4317, }, }, { - Type: v1alpha1.MetricSinkTypeOpenTelemetry, - OpenTelemetry: &v1alpha1.EnvoyGatewayOpenTelemetrySink{ + Type: egv1a1.MetricSinkTypeOpenTelemetry, + OpenTelemetry: &egv1a1.EnvoyGatewayOpenTelemetrySink{ Host: "otel-collector.monitoring.svc.cluster.local", Protocol: "http", Port: 4318, @@ -888,7 +888,7 @@ func TestEnvoyGatewayTelemetry(t *testing.T) { assert.True(t, eg.GetEnvoyGatewayTelemetry().Metrics.Prometheus.Disable) assert.Len(t, eg.GetEnvoyGatewayTelemetry().Metrics.Sinks, 2) - assert.Equal(t, v1alpha1.MetricSinkTypeOpenTelemetry, eg.GetEnvoyGatewayTelemetry().Metrics.Sinks[0].Type) + assert.Equal(t, egv1a1.MetricSinkTypeOpenTelemetry, eg.GetEnvoyGatewayTelemetry().Metrics.Sinks[0].Type) // set eg defaults when telemetry is nil // the telemetry should not be nil diff --git a/api/v1alpha1/validation/envoyproxy_validate_test.go b/api/v1alpha1/validation/envoyproxy_validate_test.go index 6e1321eeee7..b4bb760e066 100644 --- a/api/v1alpha1/validation/envoyproxy_validate_test.go +++ b/api/v1alpha1/validation/envoyproxy_validate_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" @@ -507,7 +507,7 @@ func TestValidateEnvoyProxy(t *testing.T) { Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ EnvoyService: &egv1a1.KubernetesServiceSpec{ Patch: &egv1a1.KubernetesPatchSpec{ - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte{}, }, }, @@ -531,7 +531,7 @@ func TestValidateEnvoyProxy(t *testing.T) { Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{ Patch: &egv1a1.KubernetesPatchSpec{ - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte{}, }, }, @@ -578,7 +578,7 @@ func TestValidateEnvoyProxy(t *testing.T) { EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte("{}"), }, }, @@ -602,7 +602,7 @@ func TestValidateEnvoyProxy(t *testing.T) { Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ EnvoyDeployment: &egv1a1.KubernetesDeploymentSpec{ Patch: &egv1a1.KubernetesPatchSpec{ - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte("{}"), }, }, diff --git a/internal/admin/server.go b/internal/admin/server.go index 29901814381..0569513033e 100644 --- a/internal/admin/server.go +++ b/internal/admin/server.go @@ -12,12 +12,12 @@ import ( "github.com/davecgh/go-spew/spew" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/logging" ) -var adminLogger = logging.DefaultLogger(v1alpha1.LogLevelInfo).WithName("admin") +var adminLogger = logging.DefaultLogger(egv1a1.LogLevelInfo).WithName("admin") func Init(cfg *config.Server) error { if cfg.EnvoyGateway.GetEnvoyGatewayAdmin().EnableDumpConfig { diff --git a/internal/admin/server_test.go b/internal/admin/server_test.go index f5227080d4c..2280738c235 100644 --- a/internal/admin/server_test.go +++ b/internal/admin/server_test.go @@ -10,14 +10,14 @@ import ( "github.com/stretchr/testify/require" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" ) func TestInitAdminServer(t *testing.T) { svrConfig := &config.Server{ - EnvoyGateway: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{}, + EnvoyGateway: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{}, }, } err := Init(svrConfig) diff --git a/internal/cmd/egctl/config.go b/internal/cmd/egctl/config.go index 67ca0526443..13a0f6bed21 100644 --- a/internal/cmd/egctl/config.go +++ b/internal/cmd/egctl/config.go @@ -18,7 +18,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/reflect/protoreflect" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/yaml" @@ -120,7 +120,7 @@ func fetchRunningEnvoyPods(c kube.CLIClient, nn types.NamespacedName, labelSelec switch { case allNamespaces: - namespaces, err := c.Kube().CoreV1().Namespaces().List(context.Background(), v1.ListOptions{}) + namespaces, err := c.Kube().CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{}) if err != nil { return nil, err } diff --git a/internal/cmd/egctl/config_ratelimit.go b/internal/cmd/egctl/config_ratelimit.go index 089a52f1f69..1b779f9b7d4 100644 --- a/internal/cmd/egctl/config_ratelimit.go +++ b/internal/cmd/egctl/config_ratelimit.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/types" cmdutil "k8s.io/kubectl/pkg/cmd/util" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/ratelimit" "github.com/envoyproxy/gateway/internal/kubernetes" @@ -179,13 +179,13 @@ func checkEnableGlobalRateLimit(cli kubernetes.CLIClient) (bool, error) { return false, err } - if gvk.Group != v1alpha1.GroupVersion.Group || - gvk.Version != v1alpha1.GroupVersion.Version || - gvk.Kind != v1alpha1.KindEnvoyGateway { + if gvk.Group != egv1a1.GroupVersion.Group || + gvk.Version != egv1a1.GroupVersion.Version || + gvk.Kind != egv1a1.KindEnvoyGateway { return false, errors.New("failed to decode unmatched resource type") } - eg, ok := obj.(*v1alpha1.EnvoyGateway) + eg, ok := obj.(*egv1a1.EnvoyGateway) if !ok { return false, errors.New("failed to convert object to EnvoyGateway type") } diff --git a/internal/cmd/egctl/status.go b/internal/cmd/egctl/status.go index e82b6557ee9..a19fdd978d4 100644 --- a/internal/cmd/egctl/status.go +++ b/internal/cmd/egctl/status.go @@ -18,9 +18,9 @@ import ( "github.com/spf13/cobra" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - gwv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -151,7 +151,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp switch strings.ToLower(inputResourceType) { case "gc", "gatewayclass": - gc := gwv1.GatewayClassList{} + gc := gwapiv1.GatewayClassList{} if err := cli.List(ctx, &gc, client.InNamespace(namespace)); err != nil { return err } @@ -159,7 +159,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindGatewayClass case "gtw", "gateway": - gtw := gwv1.GatewayList{} + gtw := gwapiv1.GatewayList{} if err := cli.List(ctx, >w, client.InNamespace(namespace)); err != nil { return err } @@ -167,7 +167,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindGateway case "httproute": - httproute := gwv1.HTTPRouteList{} + httproute := gwapiv1.HTTPRouteList{} if err := cli.List(ctx, &httproute, client.InNamespace(namespace)); err != nil { return err } @@ -175,7 +175,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindHTTPRoute case "grpcroute": - grpcroute := gwv1.GRPCRouteList{} + grpcroute := gwapiv1.GRPCRouteList{} if err := cli.List(ctx, &grpcroute, client.InNamespace(namespace)); err != nil { return err } @@ -183,7 +183,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindGRPCRoute case "tcproute": - tcproute := gwv1a2.TCPRouteList{} + tcproute := gwapiv1a2.TCPRouteList{} if err := cli.List(ctx, &tcproute, client.InNamespace(namespace)); err != nil { return err } @@ -191,7 +191,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindTCPRoute case "udproute": - udproute := gwv1a2.UDPRouteList{} + udproute := gwapiv1a2.UDPRouteList{} if err := cli.List(ctx, &udproute, client.InNamespace(namespace)); err != nil { return err } @@ -199,7 +199,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindUDPRoute case "tlsroute": - tlsroute := gwv1a2.TLSRouteList{} + tlsroute := gwapiv1a2.TLSRouteList{} if err := cli.List(ctx, &tlsroute, client.InNamespace(namespace)); err != nil { return err } @@ -207,7 +207,7 @@ func runStatus(ctx context.Context, cli client.Client, inputResourceType, namesp resourceKind = gatewayapi.KindTLSRoute case "btlspolicy", "backendtlspolicy": - btlspolicy := gwv1a3.BackendTLSPolicyList{} + btlspolicy := gwapiv1a3.BackendTLSPolicyList{} if err := cli.List(ctx, &btlspolicy, client.InNamespace(namespace)); err != nil { return err } diff --git a/internal/cmd/egctl/status_test.go b/internal/cmd/egctl/status_test.go index 2dd1455eb83..68123a6962b 100644 --- a/internal/cmd/egctl/status_test.go +++ b/internal/cmd/egctl/status_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - gwv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -38,7 +38,7 @@ func TestWriteStatus(t *testing.T) { }{ { name: "egctl x status gc -v, but no resources", - resourceList: &gwv1.GatewayClassList{}, + resourceList: &gwapiv1.GatewayClassList{}, resourceNamespaced: false, resourceKind: gatewayapi.KindGatewayClass, quiet: false, @@ -50,13 +50,13 @@ func TestWriteStatus(t *testing.T) { }, { name: "egctl x status gc", - resourceList: &gwv1.GatewayClassList{ - Items: []gwv1.GatewayClass{ + resourceList: &gwapiv1.GatewayClassList{ + Items: []gwapiv1.GatewayClass{ { ObjectMeta: metav1.ObjectMeta{ Name: "gc", }, - Status: gwv1.GatewayClassStatus{ + Status: gwapiv1.GatewayClassStatus{ Conditions: []metav1.Condition{ { Type: "foobar1", @@ -92,13 +92,13 @@ gc foobar2 test-status-2 test reason 2 }, { name: "egctl x status gc -v", - resourceList: &gwv1.GatewayClassList{ - Items: []gwv1.GatewayClass{ + resourceList: &gwapiv1.GatewayClassList{ + Items: []gwapiv1.GatewayClass{ { ObjectMeta: metav1.ObjectMeta{ Name: "gc", }, - Status: gwv1.GatewayClassStatus{ + Status: gwapiv1.GatewayClassStatus{ Conditions: []metav1.Condition{ { Type: "foobar1", @@ -134,13 +134,13 @@ gc foobar2 test-status-2 test reason 2 test message 2 123457 }, { name: "egctl x status gc -v -q", - resourceList: &gwv1.GatewayClassList{ - Items: []gwv1.GatewayClass{ + resourceList: &gwapiv1.GatewayClassList{ + Items: []gwapiv1.GatewayClass{ { ObjectMeta: metav1.ObjectMeta{ Name: "gc", }, - Status: gwv1.GatewayClassStatus{ + Status: gwapiv1.GatewayClassStatus{ Conditions: []metav1.Condition{ { Type: "foobar1", @@ -175,7 +175,7 @@ gc foobar2 test-status-2 test reason 2 test message 2 123457 }, { name: "egctl x status gtw -v -A, no resources", - resourceList: &gwv1.GatewayList{}, + resourceList: &gwapiv1.GatewayList{}, resourceNamespaced: true, resourceKind: gatewayapi.KindGateway, quiet: false, @@ -187,14 +187,14 @@ gc foobar2 test-status-2 test reason 2 test message 2 123457 }, { name: "egctl x status gtw -v -A", - resourceList: &gwv1.GatewayList{ - Items: []gwv1.Gateway{ + resourceList: &gwapiv1.GatewayList{ + Items: []gwapiv1.Gateway{ { ObjectMeta: metav1.ObjectMeta{ Name: "gtw", Namespace: "default", }, - Status: gwv1.GatewayStatus{ + Status: gwapiv1.GatewayStatus{ Conditions: []metav1.Condition{ { Type: "foobar1", @@ -230,14 +230,14 @@ default gtw foobar2 test-status-2 test reason 2 test message 2 }, { name: "egctl x status gtw -v -q -A", - resourceList: &gwv1.GatewayList{ - Items: []gwv1.Gateway{ + resourceList: &gwapiv1.GatewayList{ + Items: []gwapiv1.Gateway{ { ObjectMeta: metav1.ObjectMeta{ Name: "gtw1", Namespace: "default1", }, - Status: gwv1.GatewayStatus{ + Status: gwapiv1.GatewayStatus{ Conditions: []metav1.Condition{ { Type: "foobar1", @@ -263,7 +263,7 @@ default gtw foobar2 test-status-2 test reason 2 test message 2 Name: "gtw2", Namespace: "default2", }, - Status: gwv1.GatewayStatus{ + Status: gwapiv1.GatewayStatus{ Conditions: []metav1.Condition{ { Type: "foobar3", @@ -299,20 +299,20 @@ default2 gtw2 foobar4 test-status-4 test reason 4 test message 4 }, { name: "egctl x status httproute -A", - resourceList: &gwv1.HTTPRouteList{ - Items: []gwv1.HTTPRoute{ + resourceList: &gwapiv1.HTTPRouteList{ + Items: []gwapiv1.HTTPRoute{ { ObjectMeta: metav1.ObjectMeta{ Name: "http1", Namespace: "default1", }, - Status: gwv1.HTTPRouteStatus{ - RouteStatus: gwv1.RouteStatus{ - Parents: []gwv1.RouteParentStatus{ + Status: gwapiv1.HTTPRouteStatus{ + RouteStatus: gwapiv1.RouteStatus{ + Parents: []gwapiv1.RouteParentStatus{ { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-1"), + Name: gwapiv1.ObjectName("test-1"), }, Conditions: []metav1.Condition{ { @@ -342,13 +342,13 @@ default2 gtw2 foobar4 test-status-4 test reason 4 test message 4 Name: "http2", Namespace: "default2", }, - Status: gwv1.HTTPRouteStatus{ - RouteStatus: gwv1.RouteStatus{ - Parents: []gwv1.RouteParentStatus{ + Status: gwapiv1.HTTPRouteStatus{ + RouteStatus: gwapiv1.RouteStatus{ + Parents: []gwapiv1.RouteParentStatus{ { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-2"), + Name: gwapiv1.ObjectName("test-2"), }, Conditions: []metav1.Condition{ { @@ -390,20 +390,20 @@ default2 http2 gateway/test-2 foobar4 test-status-4 test reason 4 }, { name: "egctl x status httproute -q -n default1", - resourceList: &gwv1.HTTPRouteList{ - Items: []gwv1.HTTPRoute{ + resourceList: &gwapiv1.HTTPRouteList{ + Items: []gwapiv1.HTTPRoute{ { ObjectMeta: metav1.ObjectMeta{ Name: "http1", Namespace: "default1", }, - Status: gwv1.HTTPRouteStatus{ - RouteStatus: gwv1.RouteStatus{ - Parents: []gwv1.RouteParentStatus{ + Status: gwapiv1.HTTPRouteStatus{ + RouteStatus: gwapiv1.RouteStatus{ + Parents: []gwapiv1.RouteParentStatus{ { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-1"), + Name: gwapiv1.ObjectName("test-1"), }, Conditions: []metav1.Condition{ { @@ -433,13 +433,13 @@ default2 http2 gateway/test-2 foobar4 test-status-4 test reason 4 Name: "http2", Namespace: "default2", }, - Status: gwv1.HTTPRouteStatus{ - RouteStatus: gwv1.RouteStatus{ - Parents: []gwv1.RouteParentStatus{ + Status: gwapiv1.HTTPRouteStatus{ + RouteStatus: gwapiv1.RouteStatus{ + Parents: []gwapiv1.RouteParentStatus{ { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-2"), + Name: gwapiv1.ObjectName("test-2"), }, Conditions: []metav1.Condition{ { @@ -480,19 +480,19 @@ http2 gateway/test-2 foobar4 test-status-4 test reason 4 }, { name: "egctl x status btlspolicy", - resourceList: &gwv1a3.BackendTLSPolicyList{ - Items: []gwv1a3.BackendTLSPolicy{ + resourceList: &gwapiv1a3.BackendTLSPolicyList{ + Items: []gwapiv1a3.BackendTLSPolicy{ { ObjectMeta: metav1.ObjectMeta{ Name: "btls", Namespace: "default", }, - Status: gwv1a2.PolicyStatus{ - Ancestors: []gwv1a2.PolicyAncestorStatus{ + Status: gwapiv1a2.PolicyStatus{ + Ancestors: []gwapiv1a2.PolicyAncestorStatus{ { - AncestorRef: gwv1.ParentReference{ + AncestorRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test"), + Name: gwapiv1.ObjectName("test"), }, Conditions: []metav1.Condition{ { @@ -531,20 +531,20 @@ btls gateway/test foobar2 test-status-2 test reason 2 }, { name: "multiple httproutes with multiple parents", - resourceList: &gwv1.HTTPRouteList{ - Items: []gwv1.HTTPRoute{ + resourceList: &gwapiv1.HTTPRouteList{ + Items: []gwapiv1.HTTPRoute{ { ObjectMeta: metav1.ObjectMeta{ Name: "http1", Namespace: "default1", }, - Status: gwv1.HTTPRouteStatus{ - RouteStatus: gwv1.RouteStatus{ - Parents: []gwv1.RouteParentStatus{ + Status: gwapiv1.HTTPRouteStatus{ + RouteStatus: gwapiv1.RouteStatus{ + Parents: []gwapiv1.RouteParentStatus{ { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-1"), + Name: gwapiv1.ObjectName("test-1"), }, Conditions: []metav1.Condition{ { @@ -566,9 +566,9 @@ btls gateway/test foobar2 test-status-2 test reason 2 }, }, { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-2"), + Name: gwapiv1.ObjectName("test-2"), }, Conditions: []metav1.Condition{ { @@ -598,13 +598,13 @@ btls gateway/test foobar2 test-status-2 test reason 2 Name: "http2", Namespace: "default2", }, - Status: gwv1.HTTPRouteStatus{ - RouteStatus: gwv1.RouteStatus{ - Parents: []gwv1.RouteParentStatus{ + Status: gwapiv1.HTTPRouteStatus{ + RouteStatus: gwapiv1.RouteStatus{ + Parents: []gwapiv1.RouteParentStatus{ { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-3"), + Name: gwapiv1.ObjectName("test-3"), }, Conditions: []metav1.Condition{ { @@ -626,9 +626,9 @@ btls gateway/test foobar2 test-status-2 test reason 2 }, }, { - ParentRef: gwv1.ParentReference{ + ParentRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-4"), + Name: gwapiv1.ObjectName("test-4"), }, Conditions: []metav1.Condition{ { @@ -681,12 +681,12 @@ default2 http2 gateway/test-3 foobar6 test-status-6 test reason 6 Name: "btp-1", Namespace: "default", }, - Status: gwv1a2.PolicyStatus{ - Ancestors: []gwv1a2.PolicyAncestorStatus{ + Status: gwapiv1a2.PolicyStatus{ + Ancestors: []gwapiv1a2.PolicyAncestorStatus{ { - AncestorRef: gwv1.ParentReference{ + AncestorRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-1"), + Name: gwapiv1.ObjectName("test-1"), }, Conditions: []metav1.Condition{ { @@ -708,9 +708,9 @@ default2 http2 gateway/test-3 foobar6 test-status-6 test reason 6 }, }, { - AncestorRef: gwv1.ParentReference{ + AncestorRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindHTTPRoute), - Name: gwv1.ObjectName("test-2"), + Name: gwapiv1.ObjectName("test-2"), }, Conditions: []metav1.Condition{ { @@ -739,12 +739,12 @@ default2 http2 gateway/test-3 foobar6 test-status-6 test reason 6 Name: "btp-2", Namespace: "default", }, - Status: gwv1a2.PolicyStatus{ - Ancestors: []gwv1a2.PolicyAncestorStatus{ + Status: gwapiv1a2.PolicyStatus{ + Ancestors: []gwapiv1a2.PolicyAncestorStatus{ { - AncestorRef: gwv1.ParentReference{ + AncestorRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), - Name: gwv1.ObjectName("test-3"), + Name: gwapiv1.ObjectName("test-3"), }, Conditions: []metav1.Condition{ { @@ -766,9 +766,9 @@ default2 http2 gateway/test-3 foobar6 test-status-6 test reason 6 }, }, { - AncestorRef: gwv1.ParentReference{ + AncestorRef: gwapiv1.ParentReference{ Kind: gatewayapi.KindPtr(gatewayapi.KindGRPCRoute), - Name: gwv1.ObjectName("test-4"), + Name: gwapiv1.ObjectName("test-4"), }, Conditions: []metav1.Condition{ { diff --git a/internal/cmd/egctl/translate.go b/internal/cmd/egctl/translate.go index 6afb724bc5f..2cf06396078 100644 --- a/internal/cmd/egctl/translate.go +++ b/internal/cmd/egctl/translate.go @@ -22,7 +22,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/anypb" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/util/sets" @@ -545,9 +545,9 @@ func constructConfigDump(resources *gatewayapi.Resources, tCtx *xds_types.Resour return globalConfigs, nil } -func addMissingServices(requiredServices map[string]*v1.Service, obj interface{}) { +func addMissingServices(requiredServices map[string]*corev1.Service, obj interface{}) { var objNamespace string - protocol := v1.Protocol(gatewayapi.TCPProtocol) + protocol := corev1.Protocol(gatewayapi.TCPProtocol) refs := []gwapiv1.BackendRef{} switch route := obj.(type) { @@ -576,7 +576,7 @@ func addMissingServices(requiredServices map[string]*v1.Service, obj interface{} refs = append(refs, rule.BackendRefs...) } case *gwapiv1a2.UDPRoute: - protocol = v1.Protocol(gatewayapi.UDPProtocol) + protocol = corev1.Protocol(gatewayapi.UDPProtocol) objNamespace = route.Namespace for _, rule := range route.Spec.Rules { refs = append(refs, rule.BackendRefs...) @@ -596,21 +596,21 @@ func addMissingServices(requiredServices map[string]*v1.Service, obj interface{} key := ns + "/" + name port := int32(*ref.Port) - servicePort := v1.ServicePort{ + servicePort := corev1.ServicePort{ Name: fmt.Sprintf("%s-%d", protocol, port), Protocol: protocol, Port: port, } if service, found := requiredServices[key]; !found { - service := &v1.Service{ + service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: ns, }, - Spec: v1.ServiceSpec{ + Spec: corev1.ServiceSpec{ // Just a dummy IP ClusterIP: "127.0.0.1", - Ports: []v1.ServicePort{servicePort}, + Ports: []corev1.ServicePort{servicePort}, }, } requiredServices[key] = service @@ -776,7 +776,7 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap } resources.GRPCRoutes = append(resources.GRPCRoutes, grpcRoute) case gatewayapi.KindNamespace: - namespace := &v1.Namespace{ + namespace := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -785,12 +785,12 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap providedNamespaceMap.Insert(name) case gatewayapi.KindService: typedSpec := spec.Interface() - service := &v1.Service{ + service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: typedSpec.(v1.ServiceSpec), + Spec: typedSpec.(corev1.ServiceSpec), } resources.Services = append(resources.Services, service) case egv1a1.KindEnvoyPatchPolicy: @@ -854,7 +854,7 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap if useDefaultNamespace { if !providedNamespaceMap.Has(config.DefaultNamespace) { - namespace := &v1.Namespace{ + namespace := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: config.DefaultNamespace, }, @@ -867,7 +867,7 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap if addMissingResources { for ns := range requiredNamespaceMap { if !providedNamespaceMap.Has(ns) { - namespace := &v1.Namespace{ + namespace := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: ns, }, @@ -876,7 +876,7 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap } } - requiredServiceMap := map[string]*v1.Service{} + requiredServiceMap := map[string]*corev1.Service{} for _, route := range resources.TCPRoutes { addMissingServices(requiredServiceMap, route) } @@ -893,7 +893,7 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap addMissingServices(requiredServiceMap, route) } - providedServiceMap := map[string]*v1.Service{} + providedServiceMap := map[string]*corev1.Service{} for _, service := range resources.Services { providedServiceMap[service.Namespace+"/"+service.Name] = service } @@ -911,7 +911,7 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap for _, port := range service.Spec.Ports { name := fmt.Sprintf("%s-%d", port.Protocol, port.Port) if !providedPorts.Has(name) { - servicePort := v1.ServicePort{ + servicePort := corev1.ServicePort{ Name: name, Protocol: port.Protocol, Port: port.Port, diff --git a/internal/cmd/envoy/shutdown_manager.go b/internal/cmd/envoy/shutdown_manager.go index 257a3d323bc..9f2702cff33 100644 --- a/internal/cmd/envoy/shutdown_manager.go +++ b/internal/cmd/envoy/shutdown_manager.go @@ -18,12 +18,12 @@ import ( "golang.org/x/sys/unix" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/logging" "github.com/envoyproxy/gateway/internal/xds/bootstrap" ) -var logger = logging.DefaultLogger(v1alpha1.LogLevelInfo).WithName("shutdown-manager") +var logger = logging.DefaultLogger(egv1a1.LogLevelInfo).WithName("shutdown-manager") const ( // ShutdownManagerPort is the port Envoy shutdown manager will listen on. @@ -122,7 +122,7 @@ func Shutdown(drainTimeout time.Duration, minDrainDuration time.Duration, exitAt // Reconfigure logger to write to stdout of main process if running in Kubernetes if _, k8s := os.LookupEnv("KUBERNETES_SERVICE_HOST"); k8s && os.Getpid() != 1 { - logger = logging.FileLogger("/proc/1/fd/1", "shutdown-manager", v1alpha1.LogLevelInfo) + logger = logging.FileLogger("/proc/1/fd/1", "shutdown-manager", egv1a1.LogLevelInfo) } logger.Info(fmt.Sprintf("initiating graceful drain with %.0f second minimum drain period and %.0f second timeout", diff --git a/internal/cmd/version/version.go b/internal/cmd/version/version.go index f1294fcfb45..37d3bb1748c 100644 --- a/internal/cmd/version/version.go +++ b/internal/cmd/version/version.go @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/yaml" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) type Info struct { @@ -36,7 +36,7 @@ func Get() Info { var ( envoyGatewayVersion string gatewayAPIVersion string - envoyProxyVersion = strings.Split(v1alpha1.DefaultEnvoyProxyImage, ":")[1] + envoyProxyVersion = strings.Split(egv1a1.DefaultEnvoyProxyImage, ":")[1] gitCommitID string ) diff --git a/internal/crypto/certgen.go b/internal/crypto/certgen.go index de5a6584843..0b63994fb4b 100644 --- a/internal/crypto/certgen.go +++ b/internal/crypto/certgen.go @@ -17,7 +17,7 @@ import ( "math/big" "time" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" ) @@ -107,7 +107,7 @@ func GenerateCerts(cfg *config.Server) (*Certificates, error) { var egDNSNames, envoyDNSNames []string egProvider := cfg.EnvoyGateway.GetEnvoyGatewayProvider().Type switch egProvider { - case v1alpha1.ProviderTypeKubernetes: + case egv1a1.ProviderTypeKubernetes: egDNSNames = kubeServiceNames(DefaultEnvoyGatewayDNSPrefix, cfg.Namespace, cfg.DNSDomain) envoyDNSNames = append(envoyDNSNames, fmt.Sprintf("*.%s", cfg.Namespace)) default: diff --git a/internal/envoygateway/config/config.go b/internal/envoygateway/config/config.go index 3afe0425f6c..c842c184e4c 100644 --- a/internal/envoygateway/config/config.go +++ b/internal/envoygateway/config/config.go @@ -8,7 +8,7 @@ package config import ( "errors" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/api/v1alpha1/validation" "github.com/envoyproxy/gateway/internal/logging" "github.com/envoyproxy/gateway/internal/utils/env" @@ -29,7 +29,7 @@ const ( // used by Envoy Gateway server. type Server struct { // EnvoyGateway is the configuration used to startup Envoy Gateway. - EnvoyGateway *v1alpha1.EnvoyGateway + EnvoyGateway *egv1a1.EnvoyGateway // Namespace is the namespace that Envoy Gateway runs in. Namespace string // DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local". @@ -43,11 +43,11 @@ type Server struct { // New returns a Server with default parameters. func New() (*Server, error) { return &Server{ - EnvoyGateway: v1alpha1.DefaultEnvoyGateway(), + EnvoyGateway: egv1a1.DefaultEnvoyGateway(), Namespace: env.Lookup("ENVOY_GATEWAY_NAMESPACE", DefaultNamespace), DNSDomain: env.Lookup("KUBERNETES_CLUSTER_DOMAIN", DefaultDNSDomain), // the default logger - Logger: logging.DefaultLogger(v1alpha1.LogLevelInfo), + Logger: logging.DefaultLogger(egv1a1.LogLevelInfo), Elected: make(chan struct{}), }, nil } diff --git a/internal/envoygateway/config/config_test.go b/internal/envoygateway/config/config_test.go index 09f3ddfdcb2..2b3f461f762 100644 --- a/internal/envoygateway/config/config_test.go +++ b/internal/envoygateway/config/config_test.go @@ -9,15 +9,15 @@ import ( "testing" "github.com/stretchr/testify/require" - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/logging" ) var ( - TLSSecretKind = v1.Kind("Secret") - TLSUnrecognizedKind = v1.Kind("Unrecognized") + TLSSecretKind = gwapiv1.Kind("Secret") + TLSUnrecognizedKind = gwapiv1.Kind("Unrecognized") ) func TestValidate(t *testing.T) { @@ -42,10 +42,10 @@ func TestValidate(t *testing.T) { { name: "empty namespace", cfg: &Server{ - EnvoyGateway: &v1alpha1.EnvoyGateway{ - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), + EnvoyGateway: &egv1a1.EnvoyGateway{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), }, }, Namespace: "", @@ -56,7 +56,7 @@ func TestValidate(t *testing.T) { name: "unspecified envoy gateway", cfg: &Server{ Namespace: "test-ns", - Logger: logging.DefaultLogger(v1alpha1.LogLevelInfo), + Logger: logging.DefaultLogger(egv1a1.LogLevelInfo), }, expect: false, }, diff --git a/internal/envoygateway/config/decoder.go b/internal/envoygateway/config/decoder.go index dea52b68321..68ca23b6485 100644 --- a/internal/envoygateway/config/decoder.go +++ b/internal/envoygateway/config/decoder.go @@ -11,11 +11,11 @@ import ( "k8s.io/apimachinery/pkg/runtime/serializer" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway" ) -func Decode(cfgPath string) (*v1alpha1.EnvoyGateway, error) { +func Decode(cfgPath string) (*egv1a1.EnvoyGateway, error) { data, err := os.ReadFile(cfgPath) if err != nil { return nil, err @@ -29,14 +29,14 @@ func Decode(cfgPath string) (*v1alpha1.EnvoyGateway, error) { } // Figure out the resource type from the Group|Version|Kind. - if gvk.Group != v1alpha1.GroupVersion.Group || - gvk.Version != v1alpha1.GroupVersion.Version || - gvk.Kind != v1alpha1.KindEnvoyGateway { + if gvk.Group != egv1a1.GroupVersion.Group || + gvk.Version != egv1a1.GroupVersion.Version || + gvk.Kind != egv1a1.KindEnvoyGateway { return nil, errors.New("failed to decode unmatched resource type") } // Attempt to cast the object. - eg, ok := obj.(*v1alpha1.EnvoyGateway) + eg, ok := obj.(*egv1a1.EnvoyGateway) if !ok { return nil, errors.New("failed to convert object to EnvoyGateway type") } diff --git a/internal/envoygateway/config/decoder_test.go b/internal/envoygateway/config/decoder_test.go index 28ce394cb7c..67520f2e5dd 100644 --- a/internal/envoygateway/config/decoder_test.go +++ b/internal/envoygateway/config/decoder_test.go @@ -15,7 +15,7 @@ import ( "k8s.io/utils/ptr" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) var inPath = "./testdata/decoder/in/" @@ -23,118 +23,118 @@ var inPath = "./testdata/decoder/in/" func TestDecode(t *testing.T) { testCases := []struct { in string - out *v1alpha1.EnvoyGateway + out *egv1a1.EnvoyGateway expect bool }{ { in: inPath + "kube-provider.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: egv1a1.DefaultEnvoyGatewayProvider(), }, }, expect: true, }, { in: inPath + "gateway-controller-name.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), }, }, expect: true, }, { in: inPath + "provider-with-gateway.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: egv1a1.DefaultEnvoyGatewayProvider(), }, }, expect: true, }, { in: inPath + "provider-mixing-gateway.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: egv1a1.DefaultEnvoyGatewayProvider(), }, }, expect: true, }, { in: inPath + "gateway-mixing-provider.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), }, }, expect: true, }, { in: inPath + "provider-mixing-gateway.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Gateway: v1alpha1.DefaultGateway(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Gateway: egv1a1.DefaultGateway(), }, }, expect: false, }, { in: inPath + "gateway-mixing-provider.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Gateway: v1alpha1.DefaultGateway(), + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Gateway: egv1a1.DefaultGateway(), }, }, expect: false, }, { in: inPath + "gateway-ratelimit.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - RateLimitDeployment: &v1alpha1.KubernetesDeploymentSpec{ - Strategy: v1alpha1.DefaultKubernetesDeploymentStrategy(), - Container: &v1alpha1.KubernetesContainerSpec{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + RateLimitDeployment: &egv1a1.KubernetesDeploymentSpec{ + Strategy: egv1a1.DefaultKubernetesDeploymentStrategy(), + Container: &egv1a1.KubernetesContainerSpec{ Env: []corev1.EnvVar{ { Name: "env_a", @@ -146,13 +146,13 @@ func TestDecode(t *testing.T) { }, }, Image: ptr.To("envoyproxy/ratelimit:latest"), - Resources: v1alpha1.DefaultResourceRequirements(), + Resources: egv1a1.DefaultResourceRequirements(), SecurityContext: &corev1.SecurityContext{ RunAsUser: ptr.To[int64](2000), AllowPrivilegeEscalation: ptr.To(false), }, }, - Pod: &v1alpha1.KubernetesPodSpec{ + Pod: &egv1a1.KubernetesPodSpec{ Annotations: map[string]string{ "key1": "val1", "key2": "val2", @@ -167,12 +167,12 @@ func TestDecode(t *testing.T) { }, }, }, - RateLimit: &v1alpha1.RateLimit{ - Backend: v1alpha1.RateLimitDatabaseBackend{ - Type: v1alpha1.RedisBackendType, - Redis: &v1alpha1.RateLimitRedisSettings{ + RateLimit: &egv1a1.RateLimit{ + Backend: egv1a1.RateLimitDatabaseBackend{ + Type: egv1a1.RedisBackendType, + Redis: &egv1a1.RateLimitRedisSettings{ URL: "localhost:6379", - TLS: &v1alpha1.RedisTLSSettings{ + TLS: &egv1a1.RedisTLSSettings{ CertificateRef: &gwapiv1.SecretObjectReference{ Name: "ratelimit-cert", }, @@ -186,22 +186,22 @@ func TestDecode(t *testing.T) { }, { in: inPath + "gateway-global-ratelimit.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: v1alpha1.DefaultEnvoyGatewayProvider(), - Gateway: v1alpha1.DefaultGateway(), - RateLimit: &v1alpha1.RateLimit{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: egv1a1.DefaultEnvoyGatewayProvider(), + Gateway: egv1a1.DefaultGateway(), + RateLimit: &egv1a1.RateLimit{ Timeout: &metav1.Duration{ Duration: 10000000, }, FailClosed: true, - Backend: v1alpha1.RateLimitDatabaseBackend{ - Type: v1alpha1.RedisBackendType, - Redis: &v1alpha1.RateLimitRedisSettings{ + Backend: egv1a1.RateLimitDatabaseBackend{ + Type: egv1a1.RedisBackendType, + Redis: &egv1a1.RateLimitRedisSettings{ URL: "localhost:6379", }, }, @@ -212,19 +212,19 @@ func TestDecode(t *testing.T) { }, { in: inPath + "gateway-logging.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, }, - Gateway: v1alpha1.DefaultGateway(), - Logging: &v1alpha1.EnvoyGatewayLogging{ - Level: map[v1alpha1.EnvoyGatewayLogComponent]v1alpha1.LogLevel{ - v1alpha1.LogComponentGatewayDefault: v1alpha1.LogLevelInfo, + Gateway: egv1a1.DefaultGateway(), + Logging: &egv1a1.EnvoyGatewayLogging{ + Level: map[egv1a1.EnvoyGatewayLogComponent]egv1a1.LogLevel{ + egv1a1.LogComponentGatewayDefault: egv1a1.LogLevelInfo, }, }, }, @@ -233,17 +233,17 @@ func TestDecode(t *testing.T) { }, { in: inPath + "gateway-ns-watch.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ - Type: v1alpha1.KubernetesWatchModeTypeNamespaces, + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ + Type: egv1a1.KubernetesWatchModeTypeNamespaces, Namespaces: []string{ "ns-a", "ns-b", @@ -251,24 +251,24 @@ func TestDecode(t *testing.T) { }, }, }, - Gateway: v1alpha1.DefaultGateway(), + Gateway: egv1a1.DefaultGateway(), }, }, expect: true, }, { in: inPath + "gateway-nsselector-watch.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - Watch: &v1alpha1.KubernetesWatchMode{ - Type: v1alpha1.KubernetesWatchModeTypeNamespaceSelector, + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + Watch: &egv1a1.KubernetesWatchMode{ + Type: egv1a1.KubernetesWatchModeTypeNamespaceSelector, NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"label-a": "foo"}, MatchExpressions: []metav1.LabelSelectorRequirement{ @@ -287,7 +287,7 @@ func TestDecode(t *testing.T) { }, }, }, - Gateway: v1alpha1.DefaultGateway(), + Gateway: egv1a1.DefaultGateway(), }, }, expect: true, @@ -322,17 +322,17 @@ func TestDecode(t *testing.T) { }, { in: inPath + "gateway-leaderelection.yaml", - out: &v1alpha1.EnvoyGateway{ + out: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - Kind: v1alpha1.KindEnvoyGateway, - APIVersion: v1alpha1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Gateway: v1alpha1.DefaultGateway(), - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeKubernetes, - Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ - LeaderElection: &v1alpha1.LeaderElection{ + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyGatewayKubernetesProvider{ + LeaderElection: &egv1a1.LeaderElection{ Disable: ptr.To(true), LeaseDuration: ptr.To(gwapiv1.Duration("1s")), RenewDeadline: ptr.To(gwapiv1.Duration("2s")), diff --git a/internal/envoygateway/scheme.go b/internal/envoygateway/scheme.go index 94eefbf0d44..da28699d6a4 100644 --- a/internal/envoygateway/scheme.go +++ b/internal/envoygateway/scheme.go @@ -11,7 +11,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" gwapischeme "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/scheme" - mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + mcsapiv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) @@ -31,7 +31,7 @@ func init() { // Add Gateway API types. utilruntime.Must(gwapischeme.AddToScheme(scheme)) // Add mcs api types. - utilruntime.Must(mcsapi.AddToScheme(scheme)) + utilruntime.Must(mcsapiv1a1.AddToScheme(scheme)) // Add CRD kind to known types, experimental conformance test requires this. utilruntime.Must(apiextensionsv1.AddToScheme(scheme)) } diff --git a/internal/extension/registry/extension_manager.go b/internal/extension/registry/extension_manager.go index f3312923400..918c9a7c018 100644 --- a/internal/extension/registry/extension_manager.go +++ b/internal/extension/registry/extension_manager.go @@ -19,9 +19,9 @@ import ( corev1 "k8s.io/api/core/v1" k8scli "sigs.k8s.io/controller-runtime/pkg/client" k8sclicfg "sigs.k8s.io/controller-runtime/pkg/client/config" - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway" "github.com/envoyproxy/gateway/internal/envoygateway/config" extTypes "github.com/envoyproxy/gateway/internal/extension/types" @@ -47,7 +47,7 @@ var _ extTypes.Manager = (*Manager)(nil) type Manager struct { k8sClient k8scli.Client namespace string - extension v1alpha1.ExtensionManager + extension egv1a1.ExtensionManager extensionConnCache *grpc.ClientConn } @@ -58,14 +58,14 @@ func NewManager(cfg *config.Server) (extTypes.Manager, error) { return nil, err } - var extension *v1alpha1.ExtensionManager + var extension *egv1a1.ExtensionManager if cfg.EnvoyGateway != nil { extension = cfg.EnvoyGateway.ExtensionManager } // Setup an empty default in the case that no config was provided if extension == nil { - extension = &v1alpha1.ExtensionManager{} + extension = &egv1a1.ExtensionManager{} } return &Manager{ @@ -75,7 +75,7 @@ func NewManager(cfg *config.Server) (extTypes.Manager, error) { }, nil } -func NewInMemoryManager(cfg v1alpha1.ExtensionManager, server extension.EnvoyGatewayExtensionServer) (extTypes.Manager, func(), error) { +func NewInMemoryManager(cfg egv1a1.ExtensionManager, server extension.EnvoyGatewayExtensionServer) (extTypes.Manager, func(), error) { if server == nil { return nil, nil, fmt.Errorf("in-memory manager must be passed a server") } @@ -108,18 +108,18 @@ func NewInMemoryManager(cfg v1alpha1.ExtensionManager, server extension.EnvoyGat // HasExtension checks to see whether a given Group and Kind has an // associated extension registered for it. -func (m *Manager) HasExtension(g v1.Group, k v1.Kind) bool { +func (m *Manager) HasExtension(g gwapiv1.Group, k gwapiv1.Kind) bool { extension := m.extension // TODO: not currently checking the version since extensionRef only supports group and kind. for _, gvk := range extension.Resources { - if g == v1.Group(gvk.Group) && k == v1.Kind(gvk.Kind) { + if g == gwapiv1.Group(gvk.Group) && k == gwapiv1.Kind(gvk.Kind) { return true } } return false } -func getExtensionServerAddress(service *v1alpha1.ExtensionService) string { +func getExtensionServerAddress(service *egv1a1.ExtensionService) string { var serverAddr string switch { case service.FQDN != nil: @@ -138,7 +138,7 @@ func getExtensionServerAddress(service *v1alpha1.ExtensionService) string { // that are used to generate an xDS resource. // If the extension makes use of the hook then the XDS Hook Client is returned. If it does not support // the hook type then nil is returned -func (m *Manager) GetPreXDSHookClient(xdsHookType v1alpha1.XDSTranslatorHook) extTypes.XDSHookClient { +func (m *Manager) GetPreXDSHookClient(xdsHookType egv1a1.XDSTranslatorHook) extTypes.XDSHookClient { ctx := context.Background() ext := m.extension @@ -187,7 +187,7 @@ func (m *Manager) GetPreXDSHookClient(xdsHookType v1alpha1.XDSTranslatorHook) ex // xDS resources after they are generated by Envoy Gateway. // If the extension makes use of the hook then the XDS Hook Client is returned. If it does not support // the hook type then nil is returned -func (m *Manager) GetPostXDSHookClient(xdsHookType v1alpha1.XDSTranslatorHook) extTypes.XDSHookClient { +func (m *Manager) GetPostXDSHookClient(xdsHookType egv1a1.XDSTranslatorHook) extTypes.XDSHookClient { ctx := context.Background() ext := m.extension @@ -250,7 +250,7 @@ func parseCA(caSecret *corev1.Secret) (*x509.CertPool, error) { return cp, nil } -func setupGRPCOpts(ctx context.Context, client k8scli.Client, ext *v1alpha1.ExtensionManager, namespace string) ([]grpc.DialOption, error) { +func setupGRPCOpts(ctx context.Context, client k8scli.Client, ext *egv1a1.ExtensionManager, namespace string) ([]grpc.DialOption, error) { // These two errors shouldn't happen since we check these conditions when loading the extension if ext == nil { return nil, errors.New("the registered extension's config is nil") diff --git a/internal/extension/registry/extension_manager_test.go b/internal/extension/registry/extension_manager_test.go index 38386add268..f64160ed5ca 100644 --- a/internal/extension/registry/extension_manager_test.go +++ b/internal/extension/registry/extension_manager_test.go @@ -10,20 +10,20 @@ import ( "github.com/stretchr/testify/require" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) func TestGetExtensionServerAddress(t *testing.T) { tests := []struct { Name string - Service *v1alpha1.ExtensionService + Service *egv1a1.ExtensionService Expected string }{ { Name: "has an FQDN", - Service: &v1alpha1.ExtensionService{ - BackendEndpoint: v1alpha1.BackendEndpoint{ - FQDN: &v1alpha1.FQDNEndpoint{ + Service: &egv1a1.ExtensionService{ + BackendEndpoint: egv1a1.BackendEndpoint{ + FQDN: &egv1a1.FQDNEndpoint{ Hostname: "extserver.svc.cluster.local", Port: 5050, }, @@ -33,9 +33,9 @@ func TestGetExtensionServerAddress(t *testing.T) { }, { Name: "has an IP", - Service: &v1alpha1.ExtensionService{ - BackendEndpoint: v1alpha1.BackendEndpoint{ - IP: &v1alpha1.IPEndpoint{ + Service: &egv1a1.ExtensionService{ + BackendEndpoint: egv1a1.BackendEndpoint{ + IP: &egv1a1.IPEndpoint{ Address: "10.10.10.10", Port: 5050, }, @@ -45,9 +45,9 @@ func TestGetExtensionServerAddress(t *testing.T) { }, { Name: "has a Unix path", - Service: &v1alpha1.ExtensionService{ - BackendEndpoint: v1alpha1.BackendEndpoint{ - Unix: &v1alpha1.UnixSocket{ + Service: &egv1a1.ExtensionService{ + BackendEndpoint: egv1a1.BackendEndpoint{ + Unix: &egv1a1.UnixSocket{ Path: "/some/path", }, }, @@ -56,7 +56,7 @@ func TestGetExtensionServerAddress(t *testing.T) { }, { Name: "has a Unix path", - Service: &v1alpha1.ExtensionService{ + Service: &egv1a1.ExtensionService{ Host: "foo.bar", Port: 5050, }, diff --git a/internal/extension/types/manager.go b/internal/extension/types/manager.go index 766bd4fda3c..f761cbe8f66 100644 --- a/internal/extension/types/manager.go +++ b/internal/extension/types/manager.go @@ -6,9 +6,9 @@ package types import ( - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) // Manager handles and maintains registered extensions and returns clients for @@ -19,17 +19,17 @@ type Manager interface { // // If a Group and Kind is registered with an extension, then it should // return true, otherwise return false. - HasExtension(g v1.Group, k v1.Kind) bool + HasExtension(g gwapiv1.Group, k gwapiv1.Kind) bool // GetPreXDSHookClient checks if the registered extension makes use of a particular hook type that modifies inputs // that are used to generate an xDS resource. // If the extension makes use of the hook then the XDS Hook Client is returned. If it does not support // the hook type then nil is returned - GetPreXDSHookClient(xdsHookType v1alpha1.XDSTranslatorHook) XDSHookClient + GetPreXDSHookClient(xdsHookType egv1a1.XDSTranslatorHook) XDSHookClient // GetPostXDSHookClient checks if the registered extension makes use of a particular hook type that modifies // xDS resources after they are generated by Envoy Gateway. // If the extension makes use of the hook then the XDS Hook Client is returned. If it does not support // the hook type then nil is returned - GetPostXDSHookClient(xdsHookType v1alpha1.XDSTranslatorHook) XDSHookClient + GetPostXDSHookClient(xdsHookType egv1a1.XDSTranslatorHook) XDSHookClient } diff --git a/internal/gatewayapi/address.go b/internal/gatewayapi/address.go index 54907df0b12..fea4aeae7db 100644 --- a/internal/gatewayapi/address.go +++ b/internal/gatewayapi/address.go @@ -6,7 +6,7 @@ package gatewayapi import ( - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) var _ AddressesTranslator = (*Translator)(nil) @@ -23,7 +23,7 @@ func (t *Translator) ProcessAddresses(gateways []*GatewayContext, xdsIR XdsIRMap var ipAddr []string for _, addr := range gateway.Spec.Addresses { - if *addr.Type == v1.IPAddressType { + if *addr.Type == gwapiv1.IPAddressType { ipAddr = append(ipAddr, addr.Value) } } diff --git a/internal/gatewayapi/backendtrafficpolicy.go b/internal/gatewayapi/backendtrafficpolicy.go index 3c8e27a9788..d72a1bbad5e 100644 --- a/internal/gatewayapi/backendtrafficpolicy.go +++ b/internal/gatewayapi/backendtrafficpolicy.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/utils/ptr" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" @@ -84,7 +84,7 @@ func (t *Translator) ProcessBackendTrafficPolicies(backendTrafficPolicies []*egv // gatewayRouteMap and ancestor list, which will be used to check // policy overrides and populate its ancestor status. parentRefs := GetParentReferences(route) - ancestorRefs := make([]gwv1a2.ParentReference, 0, len(parentRefs)) + ancestorRefs := make([]gwapiv1a2.ParentReference, 0, len(parentRefs)) for _, p := range parentRefs { if p.Kind == nil || *p.Kind == KindGateway { namespace := route.GetNamespace() @@ -148,7 +148,7 @@ func (t *Translator) ProcessBackendTrafficPolicies(backendTrafficPolicies []*egv // Find its ancestor reference by resolved gateway, even with resolve error gatewayNN := utils.NamespacedName(gateway) - ancestorRefs := []gwv1a2.ParentReference{ + ancestorRefs := []gwapiv1a2.ParentReference{ // Don't need a section name since the policy is targeting to a gateway getAncestorRefForPolicy(gatewayNN, nil), } @@ -222,7 +222,7 @@ func resolveBTPolicyGatewayTargetRef(policy *egv1a1.BackendTrafficPolicy, gatewa policy.Namespace, targetNs) return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -232,7 +232,7 @@ func resolveBTPolicyGatewayTargetRef(policy *egv1a1.BackendTrafficPolicy, gatewa message := "Unable to target Gateway, another BackendTrafficPolicy has already attached to it" return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } } @@ -266,7 +266,7 @@ func resolveBTPolicyRouteTargetRef(policy *egv1a1.BackendTrafficPolicy, routes m policy.Namespace, targetNs) return route.RouteContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -277,7 +277,7 @@ func resolveBTPolicyRouteTargetRef(policy *egv1a1.BackendTrafficPolicy, routes m string(policy.Spec.TargetRef.Kind)) return route.RouteContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } } diff --git a/internal/gatewayapi/clienttrafficpolicy.go b/internal/gatewayapi/clienttrafficpolicy.go index 95e3c3fa2f6..b50e655668b 100644 --- a/internal/gatewayapi/clienttrafficpolicy.go +++ b/internal/gatewayapi/clienttrafficpolicy.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/utils/ptr" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" @@ -79,7 +79,7 @@ func (t *Translator) ProcessClientTrafficPolicies(resources *Resources, } key := utils.NamespacedName(gateway) - ancestorRefs := []gwv1a2.ParentReference{ + ancestorRefs := []gwapiv1a2.ParentReference{ getAncestorRefForPolicy(key, policy.Spec.TargetRef.SectionName), } @@ -102,7 +102,7 @@ func (t *Translator) ProcessClientTrafficPolicies(resources *Resources, message := "Unable to target section, another ClientTrafficPolicy has already attached to it" resolveErr = &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } @@ -168,7 +168,7 @@ func (t *Translator) ProcessClientTrafficPolicies(resources *Resources, } key := utils.NamespacedName(gateway) - ancestorRefs := []gwv1a2.ParentReference{ + ancestorRefs := []gwapiv1a2.ParentReference{ getAncestorRefForPolicy(key, nil), } @@ -190,7 +190,7 @@ func (t *Translator) ProcessClientTrafficPolicies(resources *Resources, message := "Unable to target Gateway, another ClientTrafficPolicy has already attached to it" resolveErr = &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } @@ -286,7 +286,7 @@ func resolveCTPolicyTargetRef(policy *egv1a1.ClientTrafficPolicy, gateways map[t policy.Namespace, targetNs) return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -305,7 +305,7 @@ func resolveCTPolicyTargetRef(policy *egv1a1.ClientTrafficPolicy, gateways map[t message := fmt.Sprintf("No section name %s found for %s", *sectionName, key.String()) return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } diff --git a/internal/gatewayapi/contexts.go b/internal/gatewayapi/contexts.go index 4ab2048876f..9d3e90fbe8c 100644 --- a/internal/gatewayapi/contexts.go +++ b/internal/gatewayapi/contexts.go @@ -8,12 +8,12 @@ package gatewayapi import ( "reflect" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) // GatewayContext wraps a Gateway and provides helper methods for @@ -50,7 +50,7 @@ type ListenerContext struct { gateway *gwapiv1.Gateway listenerStatusIdx int namespaceSelector labels.Selector - tlsSecrets []*v1.Secret + tlsSecrets []*corev1.Secret } func (l *ListenerContext) SetSupportedKinds(kinds ...gwapiv1.RouteGroupKind) { @@ -76,7 +76,7 @@ func (l *ListenerContext) AllowsKind(kind gwapiv1.RouteGroupKind) bool { return false } -func (l *ListenerContext) AllowsNamespace(namespace *v1.Namespace) bool { +func (l *ListenerContext) AllowsNamespace(namespace *corev1.Namespace) bool { if namespace == nil { return false } @@ -113,7 +113,7 @@ func (l *ListenerContext) GetConditions() []metav1.Condition { return l.gateway.Status.Listeners[l.listenerStatusIdx].Conditions } -func (l *ListenerContext) SetTLSSecrets(tlsSecrets []*v1.Secret) { +func (l *ListenerContext) SetTLSSecrets(tlsSecrets []*corev1.Secret) { l.tlsSecrets = tlsSecrets } @@ -151,7 +151,7 @@ type TLSRouteContext struct { // GatewayControllerName is the name of the Gateway API controller. GatewayControllerName string - *v1alpha2.TLSRoute + *gwapiv1a2.TLSRoute ParentRefs map[gwapiv1.ParentReference]*RouteParentContext } @@ -162,7 +162,7 @@ type UDPRouteContext struct { // GatewayControllerName is the name of the Gateway API controller. GatewayControllerName string - *v1alpha2.UDPRoute + *gwapiv1a2.UDPRoute ParentRefs map[gwapiv1.ParentReference]*RouteParentContext } @@ -173,7 +173,7 @@ type TCPRouteContext struct { // GatewayControllerName is the name of the Gateway API controller. GatewayControllerName string - *v1alpha2.TCPRoute + *gwapiv1a2.TCPRoute ParentRefs map[gwapiv1.ParentReference]*RouteParentContext } @@ -296,8 +296,8 @@ func GetRouteParentContext(route RouteContext, forParentRef gwapiv1.ParentRefere if !isHTTPRoute { tmpPR = DowngradeParentReference(tmpPR) } - rParentStatus := v1alpha2.RouteParentStatus{ - ControllerName: v1alpha2.GatewayController(rv.FieldByName("GatewayControllerName").String()), + rParentStatus := gwapiv1a2.RouteParentStatus{ + ControllerName: gwapiv1a2.GatewayController(rv.FieldByName("GatewayControllerName").String()), ParentRef: tmpPR, } statusParents.Set(reflect.Append(statusParents, reflect.ValueOf(rParentStatus))) @@ -324,9 +324,9 @@ type RouteParentContext struct { // a single field pointing to *gwapiv1.RouteStatus. HTTPRoute *gwapiv1.HTTPRoute GRPCRoute *gwapiv1.GRPCRoute - TLSRoute *v1alpha2.TLSRoute - TCPRoute *v1alpha2.TCPRoute - UDPRoute *v1alpha2.UDPRoute + TLSRoute *gwapiv1a2.TLSRoute + TCPRoute *gwapiv1a2.TCPRoute + UDPRoute *gwapiv1a2.UDPRoute routeParentStatusIdx int listeners []*ListenerContext diff --git a/internal/gatewayapi/envoyextensionpolicy.go b/internal/gatewayapi/envoyextensionpolicy.go index fc0f67ba2e0..8831cb1989c 100644 --- a/internal/gatewayapi/envoyextensionpolicy.go +++ b/internal/gatewayapi/envoyextensionpolicy.go @@ -17,7 +17,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/utils/ptr" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" @@ -78,7 +78,7 @@ func (t *Translator) ProcessEnvoyExtensionPolicies(envoyExtensionPolicies []*egv // gatewayRouteMap and ancestor list, which will be used to check // policy overrides and populate its ancestor status. parentRefs := GetParentReferences(route) - ancestorRefs := make([]gwv1a2.ParentReference, 0, len(parentRefs)) + ancestorRefs := make([]gwapiv1a2.ParentReference, 0, len(parentRefs)) for _, p := range parentRefs { if p.Kind == nil || *p.Kind == KindGateway { namespace := route.GetNamespace() @@ -142,7 +142,7 @@ func (t *Translator) ProcessEnvoyExtensionPolicies(envoyExtensionPolicies []*egv // Find its ancestor reference by resolved gateway, even with resolve error gatewayNN := utils.NamespacedName(gateway) - ancestorRefs := []gwv1a2.ParentReference{ + ancestorRefs := []gwapiv1a2.ParentReference{ // Don't need a section name since the policy is targeting to a gateway getAncestorRefForPolicy(gatewayNN, nil), } @@ -217,7 +217,7 @@ func resolveEEPolicyGatewayTargetRef(policy *egv1a1.EnvoyExtensionPolicy, gatewa policy.Namespace, targetNs) return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -227,7 +227,7 @@ func resolveEEPolicyGatewayTargetRef(policy *egv1a1.EnvoyExtensionPolicy, gatewa message := "Unable to target Gateway, another EnvoyExtensionPolicy has already attached to it" return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } } @@ -261,7 +261,7 @@ func resolveEEPolicyRouteTargetRef(policy *egv1a1.EnvoyExtensionPolicy, routes m policy.Namespace, targetNs) return route.RouteContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -272,7 +272,7 @@ func resolveEEPolicyRouteTargetRef(policy *egv1a1.EnvoyExtensionPolicy, routes m string(policy.Spec.TargetRef.Kind)) return route.RouteContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } } diff --git a/internal/gatewayapi/envoypatchpolicy.go b/internal/gatewayapi/envoypatchpolicy.go index c2533b18a76..d8558e2e579 100644 --- a/internal/gatewayapi/envoypatchpolicy.go +++ b/internal/gatewayapi/envoypatchpolicy.go @@ -10,8 +10,8 @@ import ( "sort" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" @@ -27,7 +27,7 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo for _, policy := range envoyPatchPolicies { var ( policy = policy.DeepCopy() - ancestorRefs []gwv1a2.ParentReference + ancestorRefs []gwapiv1a2.ParentReference resolveErr *status.PolicyResolveError targetKind string irKey string @@ -39,9 +39,9 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo targetKind = KindGatewayClass irKey = string(t.GatewayClassName) - ancestorRefs = []gwv1a2.ParentReference{ + ancestorRefs = []gwapiv1a2.ParentReference{ { - Group: GroupPtr(gwv1.GroupName), + Group: GroupPtr(gwapiv1.GroupName), Kind: KindPtr(targetKind), Name: policy.Spec.TargetRef.Name, }, @@ -55,7 +55,7 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo // It must exist since the gateways have already been processed irKey = irStringKey(gatewayNN.Namespace, gatewayNN.Name) - ancestorRefs = []gwv1a2.ParentReference{ + ancestorRefs = []gwapiv1a2.ParentReference{ getAncestorRefForPolicy(gatewayNN, nil), } } @@ -91,12 +91,12 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo } // Ensure EnvoyPatchPolicy is targeting to a support type - if policy.Spec.TargetRef.Group != gwv1.GroupName || string(policy.Spec.TargetRef.Kind) != targetKind { + if policy.Spec.TargetRef.Group != gwapiv1.GroupName || string(policy.Spec.TargetRef.Kind) != targetKind { message := fmt.Sprintf("TargetRef.Group:%s TargetRef.Kind:%s, only TargetRef.Group:%s and TargetRef.Kind:%s is supported.", - policy.Spec.TargetRef.Group, policy.Spec.TargetRef.Kind, gwv1.GroupName, targetKind) + policy.Spec.TargetRef.Group, policy.Spec.TargetRef.Kind, gwapiv1.GroupName, targetKind) resolveErr = &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } status.SetResolveErrorForPolicyAncestors(&policy.Status, @@ -115,7 +115,7 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo policy.Namespace, targetNs, targetKind) resolveErr = &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } status.SetResolveErrorForPolicyAncestors(&policy.Status, diff --git a/internal/gatewayapi/extensionserverpolicy.go b/internal/gatewayapi/extensionserverpolicy.go index 705f69830e8..b2e7e29149f 100644 --- a/internal/gatewayapi/extensionserverpolicy.go +++ b/internal/gatewayapi/extensionserverpolicy.go @@ -15,8 +15,8 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - gwv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" "github.com/envoyproxy/gateway/internal/ir" @@ -48,7 +48,7 @@ func (t *Translator) ProcessExtensionServerPolicies(policies []unstructured.Unst // A policy is considered accepted if at least one targetRef contained inside matched a listener. for _, policy := range policies { policy := policy.DeepCopy() - var policyStatus gwv1a2.PolicyStatus + var policyStatus gwapiv1a2.PolicyStatus accepted := false targetRefs, err := extractTargetRefs(policy) if err != nil { @@ -80,7 +80,7 @@ func (t *Translator) ProcessExtensionServerPolicies(policies []unstructured.Unst // Only add a status condition if the policy was added into the IR // Find its ancestor reference by resolved gateway, even with resolve error gatewayNN := utils.NamespacedName(gateway) - ancestorRefs := []gwv1a2.ParentReference{ + ancestorRefs := []gwapiv1a2.ParentReference{ getAncestorRefForPolicy(gatewayNN, currTarget.SectionName), } status.SetAcceptedForPolicyAncestors(&policyStatus, ancestorRefs, t.GatewayControllerName) @@ -96,8 +96,8 @@ func (t *Translator) ProcessExtensionServerPolicies(policies []unstructured.Unst return res, errs } -func extractTargetRefs(policy *unstructured.Unstructured) ([]gwv1a2.LocalPolicyTargetReferenceWithSectionName, error) { - ret := []gwv1a2.LocalPolicyTargetReferenceWithSectionName{} +func extractTargetRefs(policy *unstructured.Unstructured) ([]gwapiv1a2.LocalPolicyTargetReferenceWithSectionName, error) { + ret := []gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{} spec, found := policy.Object["spec"].(map[string]any) if !found { return nil, fmt.Errorf("no targets found for the policy") @@ -130,8 +130,8 @@ func extractTargetRefs(policy *unstructured.Unstructured) ([]gwv1a2.LocalPolicyT return ret, nil } -func extractSingleTargetRef(data any) (gwv1a2.LocalPolicyTargetReferenceWithSectionName, error) { - var currRef gwv1a2.LocalPolicyTargetReferenceWithSectionName +func extractSingleTargetRef(data any) (gwapiv1a2.LocalPolicyTargetReferenceWithSectionName, error) { + var currRef gwapiv1a2.LocalPolicyTargetReferenceWithSectionName d, err := json.Marshal(data) if err != nil { return currRef, err @@ -145,7 +145,7 @@ func extractSingleTargetRef(data any) (gwv1a2.LocalPolicyTargetReferenceWithSect return currRef, nil } -func policyStatusToUnstructured(policyStatus gwv1a2.PolicyStatus) map[string]any { +func policyStatusToUnstructured(policyStatus gwapiv1a2.PolicyStatus) map[string]any { ret := map[string]any{} // No need to check the marshal/unmarshal error here d, _ := json.Marshal(policyStatus) @@ -153,8 +153,8 @@ func policyStatusToUnstructured(policyStatus gwv1a2.PolicyStatus) map[string]any return ret } -func resolveExtServerPolicyGatewayTargetRef(policy *unstructured.Unstructured, target gwv1a2.LocalPolicyTargetReferenceWithSectionName, gateways map[types.NamespacedName]*policyGatewayTargetContext) (*GatewayContext, *status.PolicyResolveError) { - targetNs := ptr.To(gwv1b1.Namespace(policy.GetNamespace())) +func resolveExtServerPolicyGatewayTargetRef(policy *unstructured.Unstructured, target gwapiv1a2.LocalPolicyTargetReferenceWithSectionName, gateways map[types.NamespacedName]*policyGatewayTargetContext) (*GatewayContext, *status.PolicyResolveError) { + targetNs := ptr.To(gwapiv1b1.Namespace(policy.GetNamespace())) // Check if the gateway exists key := types.NamespacedName{ @@ -174,7 +174,7 @@ func resolveExtServerPolicyGatewayTargetRef(policy *unstructured.Unstructured, t policy.GetNamespace(), *targetNs) return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -185,7 +185,7 @@ func resolveExtServerPolicyGatewayTargetRef(policy *unstructured.Unstructured, t func (t *Translator) translateExtServerPolicyForGateway( policy *unstructured.Unstructured, gateway *GatewayContext, - target gwv1a2.LocalPolicyTargetReferenceWithSectionName, + target gwapiv1a2.LocalPolicyTargetReferenceWithSectionName, xdsIR XdsIRMap, ) bool { irKey := t.getIRKey(gateway.Gateway) diff --git a/internal/gatewayapi/extensionserverpolicy_test.go b/internal/gatewayapi/extensionserverpolicy_test.go index 907e244c971..6837f7e5ce8 100644 --- a/internal/gatewayapi/extensionserverpolicy_test.go +++ b/internal/gatewayapi/extensionserverpolicy_test.go @@ -11,14 +11,14 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/utils/ptr" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) func TestExtractTargetRefs(t *testing.T) { tests := []struct { desc string specInput map[string]any - output []gwv1a2.LocalPolicyTargetReferenceWithSectionName + output []gwapiv1a2.LocalPolicyTargetReferenceWithSectionName expectedError string }{ { @@ -62,9 +62,9 @@ func TestExtractTargetRefs(t *testing.T) { "name": "name", }, }, - output: []gwv1a2.LocalPolicyTargetReferenceWithSectionName{ + output: []gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ { - LocalPolicyTargetReference: gwv1a2.LocalPolicyTargetReference{ + LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Group: "some.group", Kind: "SomeKind", Name: "name", @@ -88,16 +88,16 @@ func TestExtractTargetRefs(t *testing.T) { }, }, }, - output: []gwv1a2.LocalPolicyTargetReferenceWithSectionName{ + output: []gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ { - LocalPolicyTargetReference: gwv1a2.LocalPolicyTargetReference{ + LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Group: "some.group", Kind: "SomeKind2", Name: "othername", }, }, { - LocalPolicyTargetReference: gwv1a2.LocalPolicyTargetReference{ + LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Group: "some.group", Kind: "SomeKind", Name: "name", @@ -127,28 +127,28 @@ func TestExtractTargetRefs(t *testing.T) { "sectionName": "one", }, }, - output: []gwv1a2.LocalPolicyTargetReferenceWithSectionName{ + output: []gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ { - LocalPolicyTargetReference: gwv1a2.LocalPolicyTargetReference{ + LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Group: "some.group", Kind: "SomeKind2", Name: "othername", }, }, { - LocalPolicyTargetReference: gwv1a2.LocalPolicyTargetReference{ + LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Group: "some.group", Kind: "SomeKind", Name: "name", }, }, { - LocalPolicyTargetReference: gwv1a2.LocalPolicyTargetReference{ + LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Group: "some.group", Kind: "SomeKind", Name: "three", }, - SectionName: ptr.To(gwv1a2.SectionName("one")), + SectionName: ptr.To(gwapiv1a2.SectionName("one")), }, }, }, diff --git a/internal/gatewayapi/helpers.go b/internal/gatewayapi/helpers.go index e2fba715378..05865225505 100644 --- a/internal/gatewayapi/helpers.go +++ b/internal/gatewayapi/helpers.go @@ -11,12 +11,12 @@ import ( "net" "strings" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/ir" @@ -67,8 +67,8 @@ func PortNumPtr(val int32) *gwapiv1.PortNumber { return &portNum } -func ObjectNamePtr(val string) *v1alpha2.ObjectName { - objectName := v1alpha2.ObjectName(val) +func ObjectNamePtr(val string) *gwapiv1a2.ObjectName { + objectName := gwapiv1a2.ObjectName(val) return &objectName } @@ -390,7 +390,7 @@ func irRouteDestinationName(route RouteContext, ruleIdx int) string { return fmt.Sprintf("%srule/%d", irRoutePrefix(route), ruleIdx) } -func irTLSConfigs(tlsSecrets ...*v1.Secret) *ir.TLSConfig { +func irTLSConfigs(tlsSecrets ...*corev1.Secret) *ir.TLSConfig { if len(tlsSecrets) == 0 { return nil } @@ -401,14 +401,14 @@ func irTLSConfigs(tlsSecrets ...*v1.Secret) *ir.TLSConfig { for i, tlsSecret := range tlsSecrets { tlsListenerConfigs.Certificates[i] = ir.TLSCertificate{ Name: irTLSListenerConfigName(tlsSecret), - Certificate: tlsSecret.Data[v1.TLSCertKey], - PrivateKey: tlsSecret.Data[v1.TLSPrivateKeyKey], + Certificate: tlsSecret.Data[corev1.TLSCertKey], + PrivateKey: tlsSecret.Data[corev1.TLSPrivateKeyKey], } } return tlsListenerConfigs } -func irTLSListenerConfigName(secret *v1.Secret) string { +func irTLSListenerConfigName(secret *corev1.Secret) string { return fmt.Sprintf("%s/%s", secret.Namespace, secret.Name) } @@ -429,8 +429,8 @@ func protocolSliceToStringSlice(protocols []gwapiv1.ProtocolType) []string { } // getAncestorRefForPolicy returns Gateway as an ancestor reference for policy. -func getAncestorRefForPolicy(gatewayNN types.NamespacedName, sectionName *v1alpha2.SectionName) v1alpha2.ParentReference { - return v1alpha2.ParentReference{ +func getAncestorRefForPolicy(gatewayNN types.NamespacedName, sectionName *gwapiv1a2.SectionName) gwapiv1a2.ParentReference { + return gwapiv1a2.ParentReference{ Group: GroupPtr(gwapiv1.GroupName), Kind: KindPtr(KindGateway), Namespace: NamespacePtr(gatewayNN.Namespace), diff --git a/internal/gatewayapi/resource.go b/internal/gatewayapi/resource.go index 6f03b6267a6..da7c49441f6 100644 --- a/internal/gatewayapi/resource.go +++ b/internal/gatewayapi/resource.go @@ -10,14 +10,14 @@ import ( "reflect" "golang.org/x/exp/slices" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" discoveryv1 "k8s.io/api/discovery/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + mcsapiv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/ir" @@ -42,12 +42,12 @@ type Resources struct { TCPRoutes []*gwapiv1a2.TCPRoute `json:"tcpRoutes,omitempty" yaml:"tcpRoutes,omitempty"` UDPRoutes []*gwapiv1a2.UDPRoute `json:"udpRoutes,omitempty" yaml:"udpRoutes,omitempty"` ReferenceGrants []*gwapiv1b1.ReferenceGrant `json:"referenceGrants,omitempty" yaml:"referenceGrants,omitempty"` - Namespaces []*v1.Namespace `json:"namespaces,omitempty" yaml:"namespaces,omitempty"` - Services []*v1.Service `json:"services,omitempty" yaml:"services,omitempty"` - ServiceImports []*mcsapi.ServiceImport `json:"serviceImports,omitempty" yaml:"serviceImports,omitempty"` + Namespaces []*corev1.Namespace `json:"namespaces,omitempty" yaml:"namespaces,omitempty"` + Services []*corev1.Service `json:"services,omitempty" yaml:"services,omitempty"` + ServiceImports []*mcsapiv1a1.ServiceImport `json:"serviceImports,omitempty" yaml:"serviceImports,omitempty"` EndpointSlices []*discoveryv1.EndpointSlice `json:"endpointSlices,omitempty" yaml:"endpointSlices,omitempty"` - Secrets []*v1.Secret `json:"secrets,omitempty" yaml:"secrets,omitempty"` - ConfigMaps []*v1.ConfigMap `json:"configMaps,omitempty" yaml:"configMaps,omitempty"` + Secrets []*corev1.Secret `json:"secrets,omitempty" yaml:"secrets,omitempty"` + ConfigMaps []*corev1.ConfigMap `json:"configMaps,omitempty" yaml:"configMaps,omitempty"` EnvoyProxy *egv1a1.EnvoyProxy `json:"envoyProxy,omitempty" yaml:"envoyProxy,omitempty"` ExtensionRefFilters []unstructured.Unstructured `json:"extensionRefFilters,omitempty" yaml:"extensionRefFilters,omitempty"` EnvoyPatchPolicies []*egv1a1.EnvoyPatchPolicy `json:"envoyPatchPolicies,omitempty" yaml:"envoyPatchPolicies,omitempty"` @@ -66,12 +66,12 @@ func NewResources() *Resources { HTTPRoutes: []*gwapiv1.HTTPRoute{}, GRPCRoutes: []*gwapiv1.GRPCRoute{}, TLSRoutes: []*gwapiv1a2.TLSRoute{}, - Services: []*v1.Service{}, + Services: []*corev1.Service{}, EndpointSlices: []*discoveryv1.EndpointSlice{}, - Secrets: []*v1.Secret{}, - ConfigMaps: []*v1.ConfigMap{}, + Secrets: []*corev1.Secret{}, + ConfigMaps: []*corev1.ConfigMap{}, ReferenceGrants: []*gwapiv1b1.ReferenceGrant{}, - Namespaces: []*v1.Namespace{}, + Namespaces: []*corev1.Namespace{}, ExtensionRefFilters: []unstructured.Unstructured{}, EnvoyPatchPolicies: []*egv1a1.EnvoyPatchPolicy{}, ClientTrafficPolicies: []*egv1a1.ClientTrafficPolicy{}, @@ -84,7 +84,7 @@ func NewResources() *Resources { } } -func (r *Resources) GetNamespace(name string) *v1.Namespace { +func (r *Resources) GetNamespace(name string) *corev1.Namespace { for _, ns := range r.Namespaces { if ns.Name == name { return ns @@ -94,7 +94,7 @@ func (r *Resources) GetNamespace(name string) *v1.Namespace { return nil } -func (r *Resources) GetService(namespace, name string) *v1.Service { +func (r *Resources) GetService(namespace, name string) *corev1.Service { for _, svc := range r.Services { if svc.Namespace == namespace && svc.Name == name { return svc @@ -104,7 +104,7 @@ func (r *Resources) GetService(namespace, name string) *v1.Service { return nil } -func (r *Resources) GetServiceImport(namespace, name string) *mcsapi.ServiceImport { +func (r *Resources) GetServiceImport(namespace, name string) *mcsapiv1a1.ServiceImport { for _, svcImp := range r.ServiceImports { if svcImp.Namespace == namespace && svcImp.Name == name { return svcImp @@ -124,7 +124,7 @@ func (r *Resources) GetBackend(namespace, name string) *egv1a1.Backend { return nil } -func (r *Resources) GetSecret(namespace, name string) *v1.Secret { +func (r *Resources) GetSecret(namespace, name string) *corev1.Secret { for _, secret := range r.Secrets { if secret.Namespace == namespace && secret.Name == name { return secret @@ -134,7 +134,7 @@ func (r *Resources) GetSecret(namespace, name string) *v1.Secret { return nil } -func (r *Resources) GetConfigMap(namespace, name string) *v1.ConfigMap { +func (r *Resources) GetConfigMap(namespace, name string) *corev1.ConfigMap { for _, configMap := range r.ConfigMaps { if configMap.Namespace == namespace && configMap.Name == name { return configMap @@ -152,7 +152,7 @@ func (r *Resources) GetEndpointSlicesForBackend(svcNamespace, svcName string, ba case KindService: backendSelectorLabel = discoveryv1.LabelServiceName case KindServiceImport: - backendSelectorLabel = mcsapi.LabelServiceName + backendSelectorLabel = mcsapiv1a1.LabelServiceName } if svcNamespace == endpointSlice.Namespace && endpointSlice.GetLabels()[backendSelectorLabel] == svcName { diff --git a/internal/gatewayapi/route.go b/internal/gatewayapi/route.go index f367c389340..6d4ac03b663 100644 --- a/internal/gatewayapi/route.go +++ b/internal/gatewayapi/route.go @@ -18,9 +18,9 @@ import ( "k8s.io/utils/ptr" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + mcsapiv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" "github.com/envoyproxy/gateway/internal/ir" "github.com/envoyproxy/gateway/internal/utils/regex" @@ -1151,7 +1151,7 @@ func (t *Translator) processDestination(backendRefContext BackendRefContext, switch KindDerefOr(backendRef.Kind, KindService) { case KindServiceImport: serviceImport := resources.GetServiceImport(backendNamespace, string(backendRef.Name)) - var servicePort mcsapi.ServicePort + var servicePort mcsapiv1a1.ServicePort for _, port := range serviceImport.Spec.Ports { if port.Port == int32(*backendRef.Port) { servicePort = port @@ -1193,7 +1193,7 @@ func (t *Translator) processDestination(backendRefContext BackendRefContext, }, resources) ds.Filters = t.processDestinationFilters(routeType, backendRefContext, parentRef, route, resources) - case v1alpha1.KindBackend: + case egv1a1.KindBackend: ds = t.processBackendDestinationSetting(backendRef.BackendObjectReference, backendNamespace, resources) ds.TLS = t.applyBackendTLSSetting( backendRef.BackendObjectReference, @@ -1228,7 +1228,7 @@ func (t *Translator) processDestination(backendRefContext BackendRefContext, func validateDestinationSettings(destinationSettings *ir.DestinationSetting, endpointRoutingDisabled bool, kind *gwapiv1.Kind) error { // TODO: support mixed endpointslice address type for the same backendRef switch KindDerefOr(kind, KindService) { - case v1alpha1.KindBackend: + case egv1a1.KindBackend: if destinationSettings.AddressType != nil && *destinationSettings.AddressType == ir.MIXED { return fmt.Errorf("mixed FQDN and IP or Unix address type for the same backendRef is not supported") } @@ -1574,7 +1574,7 @@ func (t *Translator) processBackendDestinationSetting(backendRef gwapiv1.Backend } for _, ap := range backend.Spec.AppProtocols { - if ap == v1alpha1.AppProtocolTypeH2C { + if ap == egv1a1.AppProtocolTypeH2C { dstProtocol = ir.HTTP2 break } diff --git a/internal/gatewayapi/runner/runner.go b/internal/gatewayapi/runner/runner.go index fa5d3dc11f1..b4419aff63b 100644 --- a/internal/gatewayapi/runner/runner.go +++ b/internal/gatewayapi/runner/runner.go @@ -13,10 +13,10 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" - v1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" extension "github.com/envoyproxy/gateway/internal/extension/types" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -41,7 +41,7 @@ func New(cfg *Config) *Runner { } func (r *Runner) Name() string { - return string(v1alpha1.LogComponentGatewayAPIRunner) + return string(egv1a1.LogComponentGatewayAPIRunner) } // Start starts the gateway-api translator runner @@ -53,7 +53,7 @@ func (r *Runner) Start(ctx context.Context) (err error) { } func (r *Runner) subscribeAndTranslate(ctx context.Context) { - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentGatewayAPIRunner), Message: "provider-resources"}, r.ProviderResources.GatewayAPIResources.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentGatewayAPIRunner), Message: "provider-resources"}, r.ProviderResources.GatewayAPIResources.Subscribe(ctx), func(update message.Update[string, *gatewayapi.ControllerResources], errChan chan error) { r.Logger.Info("received an update") val := update.Value @@ -82,7 +82,7 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) { // Translate and publish IRs. t := &gatewayapi.Translator{ GatewayControllerName: r.Server.EnvoyGateway.Gateway.ControllerName, - GatewayClassName: v1.ObjectName(resources.GatewayClass.Name), + GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name), GlobalRateLimitEnabled: r.EnvoyGateway.RateLimit != nil, EnvoyPatchPolicyEnabled: r.EnvoyGateway.ExtensionAPIs != nil && r.EnvoyGateway.ExtensionAPIs.EnableEnvoyPatchPolicy, BackendEnabled: r.EnvoyGateway.ExtensionAPIs != nil && r.EnvoyGateway.ExtensionAPIs.EnableBackend, @@ -231,8 +231,8 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) { r.Logger.Info("shutting down") } -func unstructuredToPolicyStatus(policyStatus map[string]any) gwv1a2.PolicyStatus { - var ret gwv1a2.PolicyStatus +func unstructuredToPolicyStatus(policyStatus map[string]any) gwapiv1a2.PolicyStatus { + var ret gwapiv1a2.PolicyStatus // No need to check the json marshal/unmarshal error, the policyStatus was // created via a typed object so the marshalling/unmarshalling will always // work diff --git a/internal/gatewayapi/securitypolicy.go b/internal/gatewayapi/securitypolicy.go index 0734f7a73cf..ebb7d45061b 100644 --- a/internal/gatewayapi/securitypolicy.go +++ b/internal/gatewayapi/securitypolicy.go @@ -17,13 +17,13 @@ import ( "strings" perr "github.com/pkg/errors" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/utils/ptr" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" @@ -86,7 +86,7 @@ func (t *Translator) ProcessSecurityPolicies(securityPolicies []*egv1a1.Security var ( policy = policy.DeepCopy() targetedRoute RouteContext - parentGateways []gwv1a2.ParentReference + parentGateways []gwapiv1a2.ParentReference resolveErr *status.PolicyResolveError ) @@ -173,7 +173,7 @@ func (t *Translator) ProcessSecurityPolicies(securityPolicies []*egv1a1.Security // Find its ancestor reference by resolved gateway, even with resolve error gatewayNN := utils.NamespacedName(targetedGateway) - parentGateways := []gwv1a2.ParentReference{ + parentGateways := []gwapiv1a2.ParentReference{ getAncestorRefForPolicy(gatewayNN, nil), } @@ -254,7 +254,7 @@ func resolveSecurityPolicyGatewayTargetRef( policy.Namespace, targetNs) return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -264,7 +264,7 @@ func resolveSecurityPolicyGatewayTargetRef( message := "Unable to target Gateway, another SecurityPolicy has already attached to it" return gateway.GatewayContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } } @@ -305,7 +305,7 @@ func resolveSecurityPolicyRouteTargetRef( policy.Namespace, targetNs) return route.RouteContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonInvalid, + Reason: gwapiv1a2.PolicyReasonInvalid, Message: message, } } @@ -316,7 +316,7 @@ func resolveSecurityPolicyRouteTargetRef( string(policy.Spec.TargetRef.Kind)) return route.RouteContext, &status.PolicyResolveError{ - Reason: gwv1a2.PolicyReasonConflicted, + Reason: gwapiv1a2.PolicyReasonConflicted, Message: message, } } @@ -555,7 +555,7 @@ func (t *Translator) buildOIDC( ) (*ir.OIDC, error) { var ( oidc = policy.Spec.OIDC - clientSecret *v1.Secret + clientSecret *corev1.Secret provider *ir.OIDCProvider err error ) @@ -763,7 +763,7 @@ func (t *Translator) buildBasicAuth( ) (*ir.BasicAuth, error) { var ( basicAuth = policy.Spec.BasicAuth - usersSecret *v1.Secret + usersSecret *corev1.Secret err error ) diff --git a/internal/gatewayapi/status/envoypatchpolicy.go b/internal/gatewayapi/status/envoypatchpolicy.go index 8a8d1b601e4..86a239da7fd 100644 --- a/internal/gatewayapi/status/envoypatchpolicy.go +++ b/internal/gatewayapi/status/envoypatchpolicy.go @@ -10,20 +10,20 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) // SetProgrammedForEnvoyPatchPolicy sets programmed conditions for each ancestor reference in policy status if it is unset. -func SetProgrammedForEnvoyPatchPolicy(s *gwv1a2.PolicyStatus) { +func SetProgrammedForEnvoyPatchPolicy(s *gwapiv1a2.PolicyStatus) { // Return early if Programmed condition is already set for _, ancestor := range s.Ancestors { for _, c := range ancestor.Conditions { if c.Type == string(egv1a1.PolicyConditionProgrammed) { return } - if c.Type == string(gwv1a2.PolicyConditionAccepted) && c.Status == metav1.ConditionFalse { + if c.Type == string(gwapiv1a2.PolicyConditionAccepted) && c.Status == metav1.ConditionFalse { return } } @@ -36,14 +36,14 @@ func SetProgrammedForEnvoyPatchPolicy(s *gwv1a2.PolicyStatus) { } } -func SetTranslationErrorForEnvoyPatchPolicy(s *gwv1a2.PolicyStatus, errMsg string) { +func SetTranslationErrorForEnvoyPatchPolicy(s *gwapiv1a2.PolicyStatus, errMsg string) { cond := newCondition(string(egv1a1.PolicyConditionProgrammed), metav1.ConditionFalse, string(egv1a1.PolicyReasonInvalid), errMsg, time.Now(), 0) for i := range s.Ancestors { s.Ancestors[i].Conditions = MergeConditions(s.Ancestors[i].Conditions, cond) } } -func SetResourceNotFoundErrorForEnvoyPatchPolicy(s *gwv1a2.PolicyStatus, notFoundResources []string) { +func SetResourceNotFoundErrorForEnvoyPatchPolicy(s *gwapiv1a2.PolicyStatus, notFoundResources []string) { message := "Unable to find xds resources: " + strings.Join(notFoundResources, ",") cond := newCondition(string(egv1a1.PolicyConditionProgrammed), metav1.ConditionFalse, string(egv1a1.PolicyReasonResourceNotFound), message, time.Now(), 0) for i := range s.Ancestors { diff --git a/internal/gatewayapi/status/policy.go b/internal/gatewayapi/status/policy.go index a5c7a21a92f..23c6b5ad715 100644 --- a/internal/gatewayapi/status/policy.go +++ b/internal/gatewayapi/status/policy.go @@ -10,43 +10,43 @@ import ( "github.com/google/go-cmp/cmp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) type PolicyResolveError struct { - Reason gwv1a2.PolicyConditionReason + Reason gwapiv1a2.PolicyConditionReason Message string error } -func SetResolveErrorForPolicyAncestors(policyStatus *gwv1a2.PolicyStatus, ancestorRefs []gwv1a2.ParentReference, controllerName string, generation int64, resolveErr *PolicyResolveError) { +func SetResolveErrorForPolicyAncestors(policyStatus *gwapiv1a2.PolicyStatus, ancestorRefs []gwapiv1a2.ParentReference, controllerName string, generation int64, resolveErr *PolicyResolveError) { for _, ancestorRef := range ancestorRefs { SetConditionForPolicyAncestor(policyStatus, ancestorRef, controllerName, - gwv1a2.PolicyConditionAccepted, metav1.ConditionFalse, resolveErr.Reason, resolveErr.Message, generation) + gwapiv1a2.PolicyConditionAccepted, metav1.ConditionFalse, resolveErr.Reason, resolveErr.Message, generation) } } -func SetTranslationErrorForPolicyAncestors(policyStatus *gwv1a2.PolicyStatus, ancestorRefs []gwv1a2.ParentReference, controllerName string, generation int64, errMsg string) { +func SetTranslationErrorForPolicyAncestors(policyStatus *gwapiv1a2.PolicyStatus, ancestorRefs []gwapiv1a2.ParentReference, controllerName string, generation int64, errMsg string) { for _, ancestorRef := range ancestorRefs { SetConditionForPolicyAncestor(policyStatus, ancestorRef, controllerName, - gwv1a2.PolicyConditionAccepted, metav1.ConditionFalse, gwv1a2.PolicyReasonInvalid, errMsg, generation) + gwapiv1a2.PolicyConditionAccepted, metav1.ConditionFalse, gwapiv1a2.PolicyReasonInvalid, errMsg, generation) } } // SetAcceptedForPolicyAncestors sets accepted conditions for each ancestor reference if it is unset. -func SetAcceptedForPolicyAncestors(policyStatus *gwv1a2.PolicyStatus, ancestorRefs []gwv1a2.ParentReference, controllerName string) { +func SetAcceptedForPolicyAncestors(policyStatus *gwapiv1a2.PolicyStatus, ancestorRefs []gwapiv1a2.ParentReference, controllerName string) { for _, ancestorRef := range ancestorRefs { setAcceptedForPolicyAncestor(policyStatus, ancestorRef, controllerName) } } -func setAcceptedForPolicyAncestor(policyStatus *gwv1a2.PolicyStatus, ancestorRef gwv1a2.ParentReference, controllerName string) { +func setAcceptedForPolicyAncestor(policyStatus *gwapiv1a2.PolicyStatus, ancestorRef gwapiv1a2.ParentReference, controllerName string) { // Return early if Accepted condition is already set for specific ancestor. for _, ancestor := range policyStatus.Ancestors { if string(ancestor.ControllerName) == controllerName && cmp.Equal(ancestor.AncestorRef, ancestorRef) { for _, c := range ancestor.Conditions { - if c.Type == string(gwv1a2.PolicyConditionAccepted) { + if c.Type == string(gwapiv1a2.PolicyConditionAccepted) { return } } @@ -55,22 +55,22 @@ func setAcceptedForPolicyAncestor(policyStatus *gwv1a2.PolicyStatus, ancestorRef message := "Policy has been accepted." SetConditionForPolicyAncestor(policyStatus, ancestorRef, controllerName, - gwv1a2.PolicyConditionAccepted, metav1.ConditionTrue, gwv1a2.PolicyReasonAccepted, message, 0) + gwapiv1a2.PolicyConditionAccepted, metav1.ConditionTrue, gwapiv1a2.PolicyReasonAccepted, message, 0) } -func SetConditionForPolicyAncestors(policyStatus *gwv1a2.PolicyStatus, ancestorRefs []gwv1a2.ParentReference, controllerName string, - conditionType gwv1a2.PolicyConditionType, status metav1.ConditionStatus, reason gwv1a2.PolicyConditionReason, message string, generation int64, +func SetConditionForPolicyAncestors(policyStatus *gwapiv1a2.PolicyStatus, ancestorRefs []gwapiv1a2.ParentReference, controllerName string, + conditionType gwapiv1a2.PolicyConditionType, status metav1.ConditionStatus, reason gwapiv1a2.PolicyConditionReason, message string, generation int64, ) { for _, ancestorRef := range ancestorRefs { SetConditionForPolicyAncestor(policyStatus, ancestorRef, controllerName, conditionType, status, reason, message, generation) } } -func SetConditionForPolicyAncestor(policyStatus *gwv1a2.PolicyStatus, ancestorRef gwv1a2.ParentReference, controllerName string, - conditionType gwv1a2.PolicyConditionType, status metav1.ConditionStatus, reason gwv1a2.PolicyConditionReason, message string, generation int64, +func SetConditionForPolicyAncestor(policyStatus *gwapiv1a2.PolicyStatus, ancestorRef gwapiv1a2.ParentReference, controllerName string, + conditionType gwapiv1a2.PolicyConditionType, status metav1.ConditionStatus, reason gwapiv1a2.PolicyConditionReason, message string, generation int64, ) { if policyStatus.Ancestors == nil { - policyStatus.Ancestors = []gwv1a2.PolicyAncestorStatus{} + policyStatus.Ancestors = []gwapiv1a2.PolicyAncestorStatus{} } cond := newCondition(string(conditionType), status, string(reason), message, time.Now(), generation) @@ -84,9 +84,9 @@ func SetConditionForPolicyAncestor(policyStatus *gwv1a2.PolicyStatus, ancestorRe } // Add condition for new PolicyAncestorStatus. - policyStatus.Ancestors = append(policyStatus.Ancestors, gwv1a2.PolicyAncestorStatus{ + policyStatus.Ancestors = append(policyStatus.Ancestors, gwapiv1a2.PolicyAncestorStatus{ AncestorRef: ancestorRef, - ControllerName: gwv1a2.GatewayController(controllerName), + ControllerName: gwapiv1a2.GatewayController(controllerName), Conditions: []metav1.Condition{cond}, }) } diff --git a/internal/gatewayapi/tls.go b/internal/gatewayapi/tls.go index cc01c4c56c1..1d38897ed26 100644 --- a/internal/gatewayapi/tls.go +++ b/internal/gatewayapi/tls.go @@ -12,12 +12,12 @@ import ( "time" corev1 "k8s.io/api/core/v1" - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) // validateTLSSecretData ensures the cert and key provided in a secret // is not malformed and can be properly parsed -func validateTLSSecretsData(secrets []*corev1.Secret, host *v1.Hostname) error { +func validateTLSSecretsData(secrets []*corev1.Secret, host *gwapiv1.Hostname) error { var publicKeyAlgorithm string var parseErr error @@ -85,7 +85,7 @@ func validateTLSSecretsData(secrets []*corev1.Secret, host *v1.Hostname) error { } // verifyHostname checks if the listener Hostname matches any domain in the certificate, returns a list of matched hosts. -func verifyHostname(cert *x509.Certificate, host *v1.Hostname) ([]string, error) { +func verifyHostname(cert *x509.Certificate, host *gwapiv1.Hostname) ([]string, error) { var matchedHosts []string if len(cert.DNSNames) > 0 { diff --git a/internal/gatewayapi/tls_test.go b/internal/gatewayapi/tls_test.go index a53e53948b2..d97824382ce 100644 --- a/internal/gatewayapi/tls_test.go +++ b/internal/gatewayapi/tls_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) const ( @@ -53,7 +53,7 @@ func TestValidateTLSSecretsData(t *testing.T) { Name string CertFile string KeyFile string - Domain v1.Hostname + Domain gwapiv1.Hostname ExpectedErr error } diff --git a/internal/gatewayapi/translator_test.go b/internal/gatewayapi/translator_test.go index 617998713e9..89191103ed9 100644 --- a/internal/gatewayapi/translator_test.go +++ b/internal/gatewayapi/translator_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/yaml" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -625,7 +625,7 @@ func TestIsValidCrossNamespaceRef(t *testing.T) { name string from crossNamespaceFrom to crossNamespaceTo - referenceGrant *v1beta1.ReferenceGrant + referenceGrant *gwapiv1b1.ReferenceGrant want bool } @@ -647,20 +647,20 @@ func TestIsValidCrossNamespaceRef(t *testing.T) { namespace: "default", name: "tls-secret-1", }, - referenceGrant: &v1beta1.ReferenceGrant{ + referenceGrant: &gwapiv1b1.ReferenceGrant{ ObjectMeta: metav1.ObjectMeta{ Name: "referencegrant-1", Namespace: "default", }, - Spec: v1beta1.ReferenceGrantSpec{ - From: []v1beta1.ReferenceGrantFrom{ + Spec: gwapiv1b1.ReferenceGrantSpec{ + From: []gwapiv1b1.ReferenceGrantFrom{ { Group: "gateway.networking.k8s.io", Kind: "Gateway", Namespace: "envoy-gateway-system", }, }, - To: []v1beta1.ReferenceGrantTo{ + To: []gwapiv1b1.ReferenceGrantTo{ { Group: "", Kind: "Secret", @@ -730,7 +730,7 @@ func TestIsValidCrossNamespaceRef(t *testing.T) { for _, tc := range testcases { tc := tc t.Run(tc.name, func(t *testing.T) { - var referenceGrants []*v1beta1.ReferenceGrant + var referenceGrants []*gwapiv1b1.ReferenceGrant if tc.referenceGrant != nil { referenceGrants = append(referenceGrants, tc.referenceGrant) } diff --git a/internal/gatewayapi/validate.go b/internal/gatewayapi/validate.go index 46847d02ac2..1817f6e06fc 100644 --- a/internal/gatewayapi/validate.go +++ b/internal/gatewayapi/validate.go @@ -11,7 +11,7 @@ import ( "net/netip" "strings" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation" @@ -43,9 +43,9 @@ func (t *Translator) validateBackendRef(backendRefContext BackendRefContext, par if !t.validateBackendPort(backendRef, parentRef, route) { return false } - protocol := v1.ProtocolTCP + protocol := corev1.ProtocolTCP if routeKind == KindUDPRoute { - protocol = v1.ProtocolUDP + protocol = corev1.ProtocolUDP } backendRefKind := KindDerefOr(backendRef.Kind, KindService) switch backendRefKind { @@ -197,7 +197,7 @@ func (t *Translator) validateBackendPort(backendRef *gwapiv1a2.BackendRef, paren } func validateBackendService(backendRef gwapiv1a2.BackendObjectReference, resources *Resources, - serviceNamespace string, protocol v1.Protocol, + serviceNamespace string, protocol corev1.Protocol, ) error { service := resources.GetService(serviceNamespace, string(backendRef.Name)) if service == nil { @@ -209,7 +209,7 @@ func validateBackendService(backendRef gwapiv1a2.BackendObjectReference, resourc for _, port := range service.Spec.Ports { portProtocol := port.Protocol if port.Protocol == "" { // Default protocol is TCP - portProtocol = v1.ProtocolTCP + portProtocol = corev1.ProtocolTCP } if port.Port == int32(*backendRef.Port) && portProtocol == protocol { portFound = true @@ -224,7 +224,7 @@ func validateBackendService(backendRef gwapiv1a2.BackendObjectReference, resourc } func (t *Translator) validateBackendServiceImport(backendRef *gwapiv1a2.BackendRef, parentRef *RouteParentContext, resources *Resources, - serviceImportNamespace string, route RouteContext, protocol v1.Protocol, + serviceImportNamespace string, route RouteContext, protocol corev1.Protocol, ) bool { serviceImport := resources.GetServiceImport(serviceImportNamespace, string(backendRef.Name)) if serviceImport == nil { @@ -244,7 +244,7 @@ func (t *Translator) validateBackendServiceImport(backendRef *gwapiv1a2.BackendR for _, port := range serviceImport.Spec.Ports { portProtocol := port.Protocol if port.Protocol == "" { // Default protocol is TCP - portProtocol = v1.ProtocolTCP + portProtocol = corev1.ProtocolTCP } if port.Port == int32(*backendRef.Port) && portProtocol == protocol { portFound = true @@ -415,7 +415,7 @@ func (t *Translator) validateAllowedNamespaces(listener *ListenerContext) { } } -func (t *Translator) validateTerminateModeAndGetTLSSecrets(listener *ListenerContext, resources *Resources) []*v1.Secret { +func (t *Translator) validateTerminateModeAndGetTLSSecrets(listener *ListenerContext, resources *Resources) []*corev1.Secret { if len(listener.TLS.CertificateRefs) == 0 { status.SetGatewayListenerStatusCondition(listener.gateway, listener.listenerStatusIdx, @@ -427,7 +427,7 @@ func (t *Translator) validateTerminateModeAndGetTLSSecrets(listener *ListenerCon return nil } - secrets := make([]*v1.Secret, 0) + secrets := make([]*corev1.Secret, 0) for _, certificateRef := range listener.TLS.CertificateRefs { // TODO zhaohuabing: reuse validateSecretRef if certificateRef.Group != nil && string(*certificateRef.Group) != "" { @@ -495,24 +495,24 @@ func (t *Translator) validateTerminateModeAndGetTLSSecrets(listener *ListenerCon break } - if secret.Type != v1.SecretTypeTLS { + if secret.Type != corev1.SecretTypeTLS { status.SetGatewayListenerStatusCondition(listener.gateway, listener.listenerStatusIdx, gwapiv1.ListenerConditionResolvedRefs, metav1.ConditionFalse, gwapiv1.ListenerReasonInvalidCertificateRef, - fmt.Sprintf("Secret %s/%s must be of type %s.", listener.gateway.Namespace, certificateRef.Name, v1.SecretTypeTLS), + fmt.Sprintf("Secret %s/%s must be of type %s.", listener.gateway.Namespace, certificateRef.Name, corev1.SecretTypeTLS), ) break } - if len(secret.Data[v1.TLSCertKey]) == 0 || len(secret.Data[v1.TLSPrivateKeyKey]) == 0 { + if len(secret.Data[corev1.TLSCertKey]) == 0 || len(secret.Data[corev1.TLSPrivateKeyKey]) == 0 { status.SetGatewayListenerStatusCondition(listener.gateway, listener.listenerStatusIdx, gwapiv1.ListenerConditionResolvedRefs, metav1.ConditionFalse, gwapiv1.ListenerReasonInvalidCertificateRef, - fmt.Sprintf("Secret %s/%s must contain %s and %s.", listener.gateway.Namespace, certificateRef.Name, v1.TLSCertKey, v1.TLSPrivateKeyKey), + fmt.Sprintf("Secret %s/%s must contain %s and %s.", listener.gateway.Namespace, certificateRef.Name, corev1.TLSCertKey, corev1.TLSPrivateKeyKey), ) break } @@ -900,7 +900,7 @@ func (t *Translator) validateSecretRef( from crossNamespaceFrom, secretObjRef gwapiv1b1.SecretObjectReference, resources *Resources, -) (*v1.Secret, error) { +) (*corev1.Secret, error) { if err := t.validateSecretObjectRef(allowCrossNamespace, from, secretObjRef, resources); err != nil { return nil, err } @@ -924,7 +924,7 @@ func (t *Translator) validateConfigMapRef( from crossNamespaceFrom, secretObjRef gwapiv1b1.SecretObjectReference, resources *Resources, -) (*v1.ConfigMap, error) { +) (*corev1.ConfigMap, error) { if err := t.validateSecretObjectRef(allowCrossNamespace, from, secretObjRef, resources); err != nil { return nil, err } @@ -1040,10 +1040,10 @@ func (t *Translator) validateExtServiceBackendReference( for _, port := range service.Spec.Ports { portProtocol := port.Protocol if port.Protocol == "" { // Default protocol is TCP - portProtocol = v1.ProtocolTCP + portProtocol = corev1.ProtocolTCP } // currently only HTTP and GRPC are supported, both of which are TCP - if port.Port == int32(*backendRef.Port) && portProtocol == v1.ProtocolTCP { + if port.Port == int32(*backendRef.Port) && portProtocol == corev1.ProtocolTCP { portFound = true break } diff --git a/internal/globalratelimit/runner/runner.go b/internal/globalratelimit/runner/runner.go index a5ff5fed73a..f5590983441 100644 --- a/internal/globalratelimit/runner/runner.go +++ b/internal/globalratelimit/runner/runner.go @@ -20,11 +20,11 @@ import ( cachev3 "github.com/envoyproxy/go-control-plane/pkg/cache/v3" resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3" serverv3 "github.com/envoyproxy/go-control-plane/pkg/server/v3" - "github.com/envoyproxy/go-control-plane/pkg/test/v3" + testv3 "github.com/envoyproxy/go-control-plane/pkg/test/v3" "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/ratelimit" "github.com/envoyproxy/gateway/internal/ir" @@ -57,7 +57,7 @@ type Runner struct { } func (r *Runner) Name() string { - return string(v1alpha1.LogComponentGlobalRateLimitRunner) + return string(egv1a1.LogComponentGlobalRateLimitRunner) } func New(cfg *Config) *Runner { @@ -77,7 +77,7 @@ func (r *Runner) Start(ctx context.Context) (err error) { r.cache = cachev3.NewSnapshotCache(false, cachev3.IDHash{}, r.Logger.Sugar()) // Register xDS Config server. - cb := &test.Callbacks{} + cb := &testv3.Callbacks{} discoveryv3.RegisterAggregatedDiscoveryServiceServer(r.grpc, serverv3.NewServer(ctx, r.cache, cb)) // Start and listen xDS gRPC config Server. @@ -111,7 +111,7 @@ func (r *Runner) serveXdsConfigServer(ctx context.Context) { func (r *Runner) subscribeAndTranslate(ctx context.Context) { // Subscribe to resources. - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentGlobalRateLimitRunner), Message: "xds-ir"}, r.XdsIR.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentGlobalRateLimitRunner), Message: "xds-ir"}, r.XdsIR.Subscribe(ctx), func(update message.Update[string, *ir.Xds], errChan chan error) { r.Logger.Info("received a notification") diff --git a/internal/infrastructure/kubernetes/infra.go b/internal/infrastructure/kubernetes/infra.go index efc2fbb9d02..6d90b3ac342 100644 --- a/internal/infrastructure/kubernetes/infra.go +++ b/internal/infrastructure/kubernetes/infra.go @@ -12,10 +12,10 @@ import ( appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/policy/v1" + policyv1 "k8s.io/api/policy/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" ) @@ -29,7 +29,7 @@ type ResourceRender interface { Deployment() (*appsv1.Deployment, error) DaemonSet() (*appsv1.DaemonSet, error) HorizontalPodAutoscaler() (*autoscalingv2.HorizontalPodAutoscaler, error) - PodDisruptionBudget() (*v1.PodDisruptionBudget, error) + PodDisruptionBudget() (*policyv1.PodDisruptionBudget, error) } // Infra manages the creation and deletion of Kubernetes infrastructure @@ -39,7 +39,7 @@ type Infra struct { Namespace string // EnvoyGateway is the configuration used to startup Envoy Gateway. - EnvoyGateway *v1alpha1.EnvoyGateway + EnvoyGateway *egv1a1.EnvoyGateway // Client wrap k8s client. Client *InfraClient diff --git a/internal/infrastructure/kubernetes/infra_resource.go b/internal/infrastructure/kubernetes/infra_resource.go index 73d94a02414..01bf35c75a4 100644 --- a/internal/infrastructure/kubernetes/infra_resource.go +++ b/internal/infrastructure/kubernetes/infra_resource.go @@ -12,7 +12,7 @@ import ( appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/policy/v1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/envoyproxy/gateway/internal/metrics" @@ -170,7 +170,7 @@ func (i *Infra) createOrUpdateDaemonSet(ctx context.Context, r ResourceRender) ( func (i *Infra) createOrUpdatePodDisruptionBudget(ctx context.Context, r ResourceRender) (err error) { var ( - pdb *v1.PodDisruptionBudget + pdb *policyv1.PodDisruptionBudget startTime = time.Now() labels = []metrics.LabelValue{ kindLabel.Value("PDB"), @@ -473,7 +473,7 @@ func (i *Infra) deleteHPA(ctx context.Context, r ResourceRender) (err error) { func (i *Infra) deletePDB(ctx context.Context, r ResourceRender) (err error) { var ( name, ns = r.Name(), i.Namespace - pdb = &v1.PodDisruptionBudget{ + pdb = &policyv1.PodDisruptionBudget{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns, Name: name, diff --git a/internal/infrastructure/kubernetes/proxy/resource_provider_test.go b/internal/infrastructure/kubernetes/proxy/resource_provider_test.go index 3642e031cf4..16c94d037a4 100644 --- a/internal/infrastructure/kubernetes/proxy/resource_provider_test.go +++ b/internal/infrastructure/kubernetes/proxy/resource_provider_test.go @@ -18,8 +18,8 @@ import ( appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" - v12 "k8s.io/api/policy/v1" - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + policyv1 "k8s.io/api/policy/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" @@ -146,7 +146,7 @@ func TestDeployment(t *testing.T) { deploy: &egv1a1.KubernetesDeploymentSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte("{\"spec\":{\"template\":{\"spec\":{\"hostNetwork\":true,\"dnsPolicy\":\"ClusterFirstWithHostNet\"}}}}"), }, }, @@ -158,7 +158,7 @@ func TestDeployment(t *testing.T) { deploy: &egv1a1.KubernetesDeploymentSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte(`{ "spec":{ "template":{ @@ -662,7 +662,7 @@ func TestDaemonSet(t *testing.T) { daemonset: &egv1a1.KubernetesDaemonSetSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte("{\"spec\":{\"template\":{\"spec\":{\"hostNetwork\":true,\"dnsPolicy\":\"ClusterFirstWithHostNet\"}}}}"), }, }, @@ -674,7 +674,7 @@ func TestDaemonSet(t *testing.T) { daemonset: &egv1a1.KubernetesDaemonSetSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte(`{ "spec":{ "template":{ @@ -1092,7 +1092,7 @@ func TestService(t *testing.T) { service: &egv1a1.KubernetesServiceSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte("{\"metadata\":{\"name\":\"foo\"}}"), }, }, @@ -1364,13 +1364,13 @@ func loadHPA(caseName string) (*autoscalingv2.HorizontalPodAutoscaler, error) { return hpa, nil } -func loadPDB(caseName string) (*v12.PodDisruptionBudget, error) { +func loadPDB(caseName string) (*policyv1.PodDisruptionBudget, error) { pdbYAML, err := os.ReadFile(fmt.Sprintf("testdata/pdb/%s.yaml", caseName)) if err != nil { return nil, err } - pdb := &v12.PodDisruptionBudget{} + pdb := &policyv1.PodDisruptionBudget{} _ = yaml.Unmarshal(pdbYAML, pdb) return pdb, nil } diff --git a/internal/infrastructure/kubernetes/ratelimit/resource_provider.go b/internal/infrastructure/kubernetes/ratelimit/resource_provider.go index 16718e082a9..14d2a3d830b 100644 --- a/internal/infrastructure/kubernetes/ratelimit/resource_provider.go +++ b/internal/infrastructure/kubernetes/ratelimit/resource_provider.go @@ -12,7 +12,7 @@ import ( appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/policy/v1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" @@ -273,6 +273,6 @@ func (r *ResourceRender) HorizontalPodAutoscaler() (*autoscalingv2.HorizontalPod return nil, nil } -func (r *ResourceRender) PodDisruptionBudget() (*v1.PodDisruptionBudget, error) { +func (r *ResourceRender) PodDisruptionBudget() (*policyv1.PodDisruptionBudget, error) { return nil, nil } diff --git a/internal/infrastructure/kubernetes/ratelimit/resource_provider_test.go b/internal/infrastructure/kubernetes/ratelimit/resource_provider_test.go index 6345aebdc55..4ee3a144bd9 100644 --- a/internal/infrastructure/kubernetes/ratelimit/resource_provider_test.go +++ b/internal/infrastructure/kubernetes/ratelimit/resource_provider_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -271,7 +271,7 @@ func TestDeployment(t *testing.T) { deploy: &egv1a1.KubernetesDeploymentSpec{ Patch: &egv1a1.KubernetesPatchSpec{ Type: ptr.To(egv1a1.StrategicMerge), - Value: v1.JSON{ + Value: apiextensionsv1.JSON{ Raw: []byte("{\"spec\":{\"template\":{\"spec\":{\"hostNetwork\":true,\"dnsPolicy\":\"ClusterFirstWithHostNet\"}}}}"), }, }, diff --git a/internal/infrastructure/manager.go b/internal/infrastructure/manager.go index 2a5cae1062a..34fc1b24b12 100644 --- a/internal/infrastructure/manager.go +++ b/internal/infrastructure/manager.go @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" clicfg "sigs.k8s.io/controller-runtime/pkg/client/config" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes" @@ -36,7 +36,7 @@ type Manager interface { // NewManager returns a new infrastructure Manager. func NewManager(cfg *config.Server) (Manager, error) { var mgr Manager - if cfg.EnvoyGateway.Provider.Type == v1alpha1.ProviderTypeKubernetes { + if cfg.EnvoyGateway.Provider.Type == egv1a1.ProviderTypeKubernetes { cli, err := client.New(clicfg.GetConfigOrDie(), client.Options{Scheme: envoygateway.GetScheme()}) if err != nil { return nil, err diff --git a/internal/infrastructure/runner/runner.go b/internal/infrastructure/runner/runner.go index d9376eb8499..7574c493090 100644 --- a/internal/infrastructure/runner/runner.go +++ b/internal/infrastructure/runner/runner.go @@ -10,7 +10,7 @@ import ( "k8s.io/utils/ptr" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/infrastructure" "github.com/envoyproxy/gateway/internal/ir" @@ -28,7 +28,7 @@ type Runner struct { } func (r *Runner) Name() string { - return string(v1alpha1.LogComponentInfrastructureRunner) + return string(egv1a1.LogComponentInfrastructureRunner) } func New(cfg *Config) *Runner { @@ -73,7 +73,7 @@ func (r *Runner) Start(ctx context.Context) (err error) { func (r *Runner) subscribeToProxyInfraIR(ctx context.Context) { // Subscribe to resources - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentInfrastructureRunner), Message: "infra-ir"}, r.InfraIR.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentInfrastructureRunner), Message: "infra-ir"}, r.InfraIR.Subscribe(ctx), func(update message.Update[string, *ir.Infra], errChan chan error) { r.Logger.Info("received an update") val := update.Value diff --git a/internal/ir/infra.go b/internal/ir/infra.go index 52672be64b1..532c7b079e8 100644 --- a/internal/ir/infra.go +++ b/internal/ir/infra.go @@ -15,7 +15,7 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "sigs.k8s.io/yaml" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) const ( @@ -42,7 +42,7 @@ type ProxyInfra struct { // Name is the name used for managed proxy infrastructure. Name string `json:"name" yaml:"name"` // Config defines user-facing configuration of the managed proxy infrastructure. - Config *v1alpha1.EnvoyProxy `json:"config,omitempty" yaml:"config,omitempty"` + Config *egv1a1.EnvoyProxy `json:"config,omitempty" yaml:"config,omitempty"` // Listeners define the listeners exposed by the proxy infrastructure. Listeners []*ProxyListener `json:"listeners,omitempty" yaml:"listeners,omitempty"` // Addresses contain the external addresses this gateway has been @@ -176,9 +176,9 @@ func (p *ProxyInfra) GetProxyMetadata() *InfraMetadata { } // GetProxyConfig returns the ProxyInfra config. -func (p *ProxyInfra) GetProxyConfig() *v1alpha1.EnvoyProxy { +func (p *ProxyInfra) GetProxyConfig() *egv1a1.EnvoyProxy { if p.Config == nil { - p.Config = new(v1alpha1.EnvoyProxy) + p.Config = new(egv1a1.EnvoyProxy) } return p.Config diff --git a/internal/ir/xds.go b/internal/ir/xds.go index 6fec4597268..2c58ab98783 100644 --- a/internal/ir/xds.go +++ b/internal/ir/xds.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/yaml" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -1619,7 +1619,7 @@ type EnvoyPatchPolicyStatus struct { Name string `json:"name,omitempty" yaml:"name"` Namespace string `json:"namespace,omitempty" yaml:"namespace"` // Status of the EnvoyPatchPolicy - Status *gwv1a2.PolicyStatus `json:"status,omitempty" yaml:"status,omitempty"` + Status *gwapiv1a2.PolicyStatus `json:"status,omitempty" yaml:"status,omitempty"` } // JSONPatchConfig defines the configuration for patching a Envoy xDS Resource diff --git a/internal/logging/log.go b/internal/logging/log.go index 8f90a9c8e0a..a4fb787f9c2 100644 --- a/internal/logging/log.go +++ b/internal/logging/log.go @@ -14,17 +14,17 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) type Logger struct { logr.Logger - logging *v1alpha1.EnvoyGatewayLogging + logging *egv1a1.EnvoyGatewayLogging sugaredLogger *zap.SugaredLogger } -func NewLogger(logging *v1alpha1.EnvoyGatewayLogging) Logger { - logger := initZapLogger(os.Stdout, logging, logging.Level[v1alpha1.LogComponentGatewayDefault]) +func NewLogger(logging *egv1a1.EnvoyGatewayLogging) Logger { + logger := initZapLogger(os.Stdout, logging, logging.Level[egv1a1.LogComponentGatewayDefault]) return Logger{ Logger: zapr.NewLogger(logger), @@ -33,13 +33,13 @@ func NewLogger(logging *v1alpha1.EnvoyGatewayLogging) Logger { } } -func FileLogger(file string, name string, level v1alpha1.LogLevel) Logger { +func FileLogger(file string, name string, level egv1a1.LogLevel) Logger { writer, err := os.OpenFile(file, os.O_WRONLY, 0o666) if err != nil { panic(err) } - logging := v1alpha1.DefaultEnvoyGatewayLogging() + logging := egv1a1.DefaultEnvoyGatewayLogging() logger := initZapLogger(writer, logging, level) return Logger{ @@ -49,8 +49,8 @@ func FileLogger(file string, name string, level v1alpha1.LogLevel) Logger { } } -func DefaultLogger(level v1alpha1.LogLevel) Logger { - logging := v1alpha1.DefaultEnvoyGatewayLogging() +func DefaultLogger(level egv1a1.LogLevel) Logger { + logging := egv1a1.DefaultEnvoyGatewayLogging() logger := initZapLogger(os.Stdout, logging, level) return Logger{ @@ -66,7 +66,7 @@ func DefaultLogger(level v1alpha1.LogLevel) Logger { // contain only letters, digits, and hyphens (see the package documentation for // more information). func (l Logger) WithName(name string) Logger { - logLevel := l.logging.Level[v1alpha1.EnvoyGatewayLogComponent(name)] + logLevel := l.logging.Level[egv1a1.EnvoyGatewayLogComponent(name)] logger := initZapLogger(os.Stdout, l.logging, logLevel) return Logger{ @@ -105,7 +105,7 @@ func (l Logger) Sugar() *zap.SugaredLogger { return l.sugaredLogger } -func initZapLogger(w io.Writer, logging *v1alpha1.EnvoyGatewayLogging, level v1alpha1.LogLevel) *zap.Logger { +func initZapLogger(w io.Writer, logging *egv1a1.EnvoyGatewayLogging, level egv1a1.LogLevel) *zap.Logger { parseLevel, _ := zapcore.ParseLevel(string(logging.DefaultEnvoyGatewayLoggingLevel(level))) core := zapcore.NewCore(zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig()), zapcore.AddSync(w), zap.NewAtomicLevelAt(parseLevel)) diff --git a/internal/logging/log_test.go b/internal/logging/log_test.go index 756e4e39318..999f922759c 100644 --- a/internal/logging/log_test.go +++ b/internal/logging/log_test.go @@ -15,7 +15,7 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" ) func TestZapLogLevel(t *testing.T) { @@ -32,17 +32,17 @@ func TestZapLogLevel(t *testing.T) { } func TestLogger(t *testing.T) { - logger := NewLogger(v1alpha1.DefaultEnvoyGatewayLogging()) + logger := NewLogger(egv1a1.DefaultEnvoyGatewayLogging()) logger.Info("kv msg", "key", "value") logger.Sugar().Infof("template %s %d", "string", 123) - logger.WithName(string(v1alpha1.LogComponentGlobalRateLimitRunner)).WithValues("runner", v1alpha1.LogComponentGlobalRateLimitRunner).Info("msg", "k", "v") + logger.WithName(string(egv1a1.LogComponentGlobalRateLimitRunner)).WithValues("runner", egv1a1.LogComponentGlobalRateLimitRunner).Info("msg", "k", "v") - defaultLogger := DefaultLogger(v1alpha1.LogLevelInfo) + defaultLogger := DefaultLogger(egv1a1.LogLevelInfo) assert.NotNil(t, defaultLogger.logging) assert.NotNil(t, defaultLogger.sugaredLogger) - fileLogger := FileLogger("/dev/stderr", "fl-test", v1alpha1.LogLevelInfo) + fileLogger := FileLogger("/dev/stderr", "fl-test", egv1a1.LogLevelInfo) assert.NotNil(t, fileLogger.logging) assert.NotNil(t, fileLogger.sugaredLogger) } @@ -59,10 +59,10 @@ func TestLoggerWithName(t *testing.T) { require.NoError(t, err) }() - config := v1alpha1.DefaultEnvoyGatewayLogging() - config.Level[v1alpha1.LogComponentInfrastructureRunner] = v1alpha1.LogLevelDebug + config := egv1a1.DefaultEnvoyGatewayLogging() + config.Level[egv1a1.LogComponentInfrastructureRunner] = egv1a1.LogLevelDebug - logger := NewLogger(config).WithName(string(v1alpha1.LogComponentInfrastructureRunner)) + logger := NewLogger(config).WithName(string(egv1a1.LogComponentInfrastructureRunner)) logger.Info("info message") logger.Sugar().Debugf("debug message") @@ -71,7 +71,7 @@ func TestLoggerWithName(t *testing.T) { _, err := r.Read(outputBytes) require.NoError(t, err) capturedOutput := string(outputBytes) - assert.Contains(t, capturedOutput, string(v1alpha1.LogComponentInfrastructureRunner)) + assert.Contains(t, capturedOutput, string(egv1a1.LogComponentInfrastructureRunner)) assert.Contains(t, capturedOutput, "info message") assert.Contains(t, capturedOutput, "debug message") } diff --git a/internal/message/watchutil.go b/internal/message/watchutil.go index bd7829f3cbd..2eb95725bee 100644 --- a/internal/message/watchutil.go +++ b/internal/message/watchutil.go @@ -10,14 +10,14 @@ import ( "github.com/telepresenceio/watchable" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/logging" "github.com/envoyproxy/gateway/internal/metrics" ) type Update[K comparable, V any] watchable.Update[K, V] -var logger = logging.DefaultLogger(v1alpha1.LogLevelInfo).WithName("watchable") +var logger = logging.DefaultLogger(egv1a1.LogLevelInfo).WithName("watchable") type Metadata struct { Runner string diff --git a/internal/metrics/metadata.go b/internal/metrics/metadata.go index 255619bbd11..c6daf9e94da 100644 --- a/internal/metrics/metadata.go +++ b/internal/metrics/metadata.go @@ -13,7 +13,7 @@ import ( api "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/sdk/metric" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" log "github.com/envoyproxy/gateway/internal/logging" ) @@ -22,7 +22,7 @@ var ( return otel.GetMeterProvider().Meter("envoy-gateway") } - metricsLogger = log.DefaultLogger(v1alpha1.LogLevelInfo).WithName("metrics") + metricsLogger = log.DefaultLogger(egv1a1.LogLevelInfo).WithName("metrics") ) func init() { diff --git a/internal/metrics/register.go b/internal/metrics/register.go index a73d433718b..f4e9e7a34cc 100644 --- a/internal/metrics/register.go +++ b/internal/metrics/register.go @@ -21,7 +21,7 @@ import ( "go.opentelemetry.io/otel/sdk/metric" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" ) @@ -77,7 +77,7 @@ func start(address string, handler http.Handler) error { func newOptions(svr *config.Server) (registerOptions, error) { newOpts := registerOptions{} - newOpts.address = net.JoinHostPort(v1alpha1.GatewayMetricsHost, fmt.Sprint(v1alpha1.GatewayMetricsPort)) + newOpts.address = net.JoinHostPort(egv1a1.GatewayMetricsHost, fmt.Sprint(egv1a1.GatewayMetricsPort)) if svr.EnvoyGateway.DisablePrometheus() { newOpts.pullOptions.disable = true @@ -171,7 +171,7 @@ func registerOTELPromExporter(otelOpts *[]metric.Option, opts registerOptions) e // registerOTELHTTPexporter registers OTEL HTTP metrics exporter (PUSH mode). func registerOTELHTTPexporter(otelOpts *[]metric.Option, opts registerOptions) error { for _, sink := range opts.pushOptions.sinks { - if sink.protocol == v1alpha1.HTTPProtocol { + if sink.protocol == egv1a1.HTTPProtocol { address := net.JoinHostPort(sink.host, fmt.Sprint(sink.port)) httpexporter, err := otlpmetrichttp.New( context.Background(), @@ -204,7 +204,7 @@ func registerOTELHTTPexporter(otelOpts *[]metric.Option, opts registerOptions) e // registerOTELgRPCexporter registers OTEL gRPC metrics exporter (PUSH mode). func registerOTELgRPCexporter(otelOpts *[]metric.Option, opts registerOptions) error { for _, sink := range opts.pushOptions.sinks { - if sink.protocol == v1alpha1.GRPCProtocol { + if sink.protocol == egv1a1.GRPCProtocol { address := net.JoinHostPort(sink.host, fmt.Sprint(sink.port)) httpexporter, err := otlpmetricgrpc.New( context.Background(), diff --git a/internal/provider/kubernetes/controller.go b/internal/provider/kubernetes/controller.go index ec51d0018d0..55bd54c915f 100644 --- a/internal/provider/kubernetes/controller.go +++ b/internal/provider/kubernetes/controller.go @@ -31,7 +31,7 @@ import ( gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + mcsapiv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/api/v1alpha1/validation" @@ -391,7 +391,7 @@ func (r *gatewayAPIReconciler) processBackendRefs(ctx context.Context, gwcResour endpointSliceLabelKey = discoveryv1.LabelServiceName case gatewayapi.KindServiceImport: - serviceImport := new(mcsapi.ServiceImport) + serviceImport := new(mcsapiv1a1.ServiceImport) err := r.client.Get(ctx, types.NamespacedName{Namespace: string(*backendRef.Namespace), Name: string(backendRef.Name)}, serviceImport) if err != nil { r.log.Error(err, "failed to get ServiceImport", "namespace", string(*backendRef.Namespace), @@ -402,7 +402,7 @@ func (r *gatewayAPIReconciler) processBackendRefs(ctx context.Context, gwcResour r.log.Info("added ServiceImport to resource tree", "namespace", string(*backendRef.Namespace), "name", string(backendRef.Name)) } - endpointSliceLabelKey = mcsapi.LabelServiceName + endpointSliceLabelKey = mcsapiv1a1.LabelServiceName case egv1a1.KindBackend: backend := new(egv1a1.Backend) @@ -1206,12 +1206,12 @@ func (r *gatewayAPIReconciler) watchResources(ctx context.Context, mgr manager.M // Watch ServiceImport CRUDs and process affected *Route objects. if serviceImportCRDExists { if err := c.Watch( - source.Kind(mgr.GetCache(), &mcsapi.ServiceImport{}, - handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, si *mcsapi.ServiceImport) []reconcile.Request { + source.Kind(mgr.GetCache(), &mcsapiv1a1.ServiceImport{}, + handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, si *mcsapiv1a1.ServiceImport) []reconcile.Request { return r.enqueueClass(ctx, si) }), - predicate.TypedGenerationChangedPredicate[*mcsapi.ServiceImport]{}, - predicate.NewTypedPredicateFuncs[*mcsapi.ServiceImport](func(si *mcsapi.ServiceImport) bool { + predicate.TypedGenerationChangedPredicate[*mcsapiv1a1.ServiceImport]{}, + predicate.NewTypedPredicateFuncs[*mcsapiv1a1.ServiceImport](func(si *mcsapiv1a1.ServiceImport) bool { return r.validateServiceImportForReconcile(si) }))); err != nil { // ServiceImport is not available in the cluster, skip the watch and not throw error. @@ -1685,7 +1685,7 @@ func (r *gatewayAPIReconciler) serviceImportCRDExists(mgr manager.Manager) bool serviceImportFound := false for _, list := range apiResourceList { for _, resource := range list.APIResources { - if list.GroupVersion == mcsapi.GroupVersion.String() && resource.Kind == gatewayapi.KindServiceImport { + if list.GroupVersion == mcsapiv1a1.GroupVersion.String() && resource.Kind == gatewayapi.KindServiceImport { serviceImportFound = true break } diff --git a/internal/provider/kubernetes/helpers.go b/internal/provider/kubernetes/helpers.go index bc765b2260f..847bdc35261 100644 --- a/internal/provider/kubernetes/helpers.go +++ b/internal/provider/kubernetes/helpers.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + mcsapiv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -153,8 +153,8 @@ func validateBackendRef(ref *gwapiv1.BackendRef) error { switch { case ref == nil: return nil - case gatewayapi.GroupDerefOr(ref.Group, corev1.GroupName) != corev1.GroupName && gatewayapi.GroupDerefOr(ref.Group, corev1.GroupName) != mcsapi.GroupName && gatewayapi.GroupDerefOr(ref.Group, corev1.GroupName) != egv1a1.GroupName: - return fmt.Errorf("invalid group; must be nil, empty string %q or %q", mcsapi.GroupName, egv1a1.GroupName) + case gatewayapi.GroupDerefOr(ref.Group, corev1.GroupName) != corev1.GroupName && gatewayapi.GroupDerefOr(ref.Group, corev1.GroupName) != mcsapiv1a1.GroupName && gatewayapi.GroupDerefOr(ref.Group, corev1.GroupName) != egv1a1.GroupName: + return fmt.Errorf("invalid group; must be nil, empty string %q or %q", mcsapiv1a1.GroupName, egv1a1.GroupName) case gatewayapi.KindDerefOr(ref.Kind, gatewayapi.KindService) != gatewayapi.KindService && gatewayapi.KindDerefOr(ref.Kind, gatewayapi.KindService) != gatewayapi.KindServiceImport && gatewayapi.KindDerefOr(ref.Kind, gatewayapi.KindService) != egv1a1.KindBackend: return fmt.Errorf("invalid kind %q; must be %q, %q or %q", *ref.BackendObjectReference.Kind, gatewayapi.KindService, gatewayapi.KindServiceImport, egv1a1.KindBackend) diff --git a/internal/provider/kubernetes/indexers.go b/internal/provider/kubernetes/indexers.go index b99929196f4..9b4a3f17a1f 100644 --- a/internal/provider/kubernetes/indexers.go +++ b/internal/provider/kubernetes/indexers.go @@ -17,7 +17,7 @@ import ( gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" ) @@ -97,7 +97,7 @@ func backendHTTPRouteIndexFunc(rawObj client.Object) []string { var backendRefs []string for _, rule := range httproute.Spec.Rules { for _, backend := range rule.BackendRefs { - if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == v1alpha1.KindBackend { + if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == egv1a1.KindBackend { // If an explicit Backend namespace is not provided, use the HTTPRoute namespace to // lookup the provided Gateway Name. backendRefs = append(backendRefs, @@ -113,7 +113,7 @@ func backendHTTPRouteIndexFunc(rawObj client.Object) []string { } func secretEnvoyProxyIndexFunc(rawObj client.Object) []string { - ep := rawObj.(*v1alpha1.EnvoyProxy) + ep := rawObj.(*egv1a1.EnvoyProxy) var secretReferences []string if ep.Spec.BackendTLS != nil { if ep.Spec.BackendTLS.ClientCertificateRef != nil { @@ -130,11 +130,11 @@ func secretEnvoyProxyIndexFunc(rawObj client.Object) []string { } func addEnvoyProxyIndexers(ctx context.Context, mgr manager.Manager) error { - if err := mgr.GetFieldIndexer().IndexField(ctx, &v1alpha1.EnvoyProxy{}, backendEnvoyProxyTelemetryIndex, backendEnvoyProxyTelemetryIndexFunc); err != nil { + if err := mgr.GetFieldIndexer().IndexField(ctx, &egv1a1.EnvoyProxy{}, backendEnvoyProxyTelemetryIndex, backendEnvoyProxyTelemetryIndexFunc); err != nil { return err } - if err := mgr.GetFieldIndexer().IndexField(ctx, &v1alpha1.EnvoyProxy{}, secretEnvoyProxyIndex, secretEnvoyProxyIndexFunc); err != nil { + if err := mgr.GetFieldIndexer().IndexField(ctx, &egv1a1.EnvoyProxy{}, secretEnvoyProxyIndex, secretEnvoyProxyIndexFunc); err != nil { return err } @@ -142,7 +142,7 @@ func addEnvoyProxyIndexers(ctx context.Context, mgr manager.Manager) error { } func backendEnvoyProxyTelemetryIndexFunc(rawObj client.Object) []string { - ep := rawObj.(*v1alpha1.EnvoyProxy) + ep := rawObj.(*egv1a1.EnvoyProxy) refs := sets.New[string]() refs.Insert(accessLogRefs(ep)...) @@ -152,7 +152,7 @@ func backendEnvoyProxyTelemetryIndexFunc(rawObj client.Object) []string { return refs.UnsortedList() } -func accessLogRefs(ep *v1alpha1.EnvoyProxy) []string { +func accessLogRefs(ep *egv1a1.EnvoyProxy) []string { var refs []string if ep.Spec.Telemetry == nil || ep.Spec.Telemetry.Metrics == nil { @@ -180,7 +180,7 @@ func accessLogRefs(ep *v1alpha1.EnvoyProxy) []string { return refs } -func metricRefs(ep *v1alpha1.EnvoyProxy) []string { +func metricRefs(ep *egv1a1.EnvoyProxy) []string { var refs []string if ep.Spec.Telemetry == nil || ep.Spec.Telemetry.Metrics == nil { @@ -205,7 +205,7 @@ func metricRefs(ep *v1alpha1.EnvoyProxy) []string { return refs } -func traceRefs(ep *v1alpha1.EnvoyProxy) []string { +func traceRefs(ep *egv1a1.EnvoyProxy) []string { var refs []string if ep.Spec.Telemetry == nil || ep.Spec.Telemetry.Tracing == nil { @@ -264,7 +264,7 @@ func backendGRPCRouteIndexFunc(rawObj client.Object) []string { var backendRefs []string for _, rule := range grpcroute.Spec.Rules { for _, backend := range rule.BackendRefs { - if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == v1alpha1.KindBackend { + if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == egv1a1.KindBackend { // If an explicit Backend namespace is not provided, use the GRPCRoute namespace to // lookup the provided Gateway Name. backendRefs = append(backendRefs, @@ -314,7 +314,7 @@ func backendTLSRouteIndexFunc(rawObj client.Object) []string { var backendRefs []string for _, rule := range tlsroute.Spec.Rules { for _, backend := range rule.BackendRefs { - if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == v1alpha1.KindBackend { + if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == egv1a1.KindBackend { // If an explicit Backend namespace is not provided, use the TLSRoute namespace to // lookup the provided Gateway Name. backendRefs = append(backendRefs, @@ -364,7 +364,7 @@ func backendTCPRouteIndexFunc(rawObj client.Object) []string { var backendRefs []string for _, rule := range tcpRoute.Spec.Rules { for _, backend := range rule.BackendRefs { - if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == v1alpha1.KindBackend { + if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == egv1a1.KindBackend { // If an explicit Backend namespace is not provided, use the TCPRoute namespace to // lookup the provided Gateway Name. backendRefs = append(backendRefs, @@ -416,7 +416,7 @@ func backendUDPRouteIndexFunc(rawObj client.Object) []string { var backendRefs []string for _, rule := range udproute.Spec.Rules { for _, backend := range rule.BackendRefs { - if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == v1alpha1.KindBackend { + if backend.Kind == nil || string(*backend.Kind) == gatewayapi.KindService || string(*backend.Kind) == egv1a1.KindBackend { // If an explicit Backend namespace is not provided, use the UDPRoute namespace to // lookup the provided Gateway Name. backendRefs = append(backendRefs, @@ -482,13 +482,13 @@ func addSecurityPolicyIndexers(ctx context.Context, mgr manager.Manager) error { var err error if err = mgr.GetFieldIndexer().IndexField( - ctx, &v1alpha1.SecurityPolicy{}, secretSecurityPolicyIndex, + ctx, &egv1a1.SecurityPolicy{}, secretSecurityPolicyIndex, secretSecurityPolicyIndexFunc); err != nil { return err } if err = mgr.GetFieldIndexer().IndexField( - ctx, &v1alpha1.SecurityPolicy{}, backendSecurityPolicyIndex, + ctx, &egv1a1.SecurityPolicy{}, backendSecurityPolicyIndex, backendSecurityPolicyIndexFunc); err != nil { return err } @@ -497,7 +497,7 @@ func addSecurityPolicyIndexers(ctx context.Context, mgr manager.Manager) error { } func secretSecurityPolicyIndexFunc(rawObj client.Object) []string { - securityPolicy := rawObj.(*v1alpha1.SecurityPolicy) + securityPolicy := rawObj.(*egv1a1.SecurityPolicy) var ( secretReferences []gwapiv1b1.SecretObjectReference @@ -523,7 +523,7 @@ func secretSecurityPolicyIndexFunc(rawObj client.Object) []string { } func backendSecurityPolicyIndexFunc(rawObj client.Object) []string { - securityPolicy := rawObj.(*v1alpha1.SecurityPolicy) + securityPolicy := rawObj.(*egv1a1.SecurityPolicy) var backendRef *gwapiv1.BackendObjectReference @@ -532,13 +532,13 @@ func backendSecurityPolicyIndexFunc(rawObj client.Object) []string { http := securityPolicy.Spec.ExtAuth.HTTP backendRef = http.BackendRef if len(http.BackendRefs) > 0 { - backendRef = v1alpha1.ToBackendObjectReference(http.BackendRefs[0]) + backendRef = egv1a1.ToBackendObjectReference(http.BackendRefs[0]) } } else if securityPolicy.Spec.ExtAuth.GRPC != nil { grpc := securityPolicy.Spec.ExtAuth.GRPC backendRef = grpc.BackendRef if len(grpc.BackendRefs) > 0 { - backendRef = v1alpha1.ToBackendObjectReference(grpc.BackendRefs[0]) + backendRef = egv1a1.ToBackendObjectReference(grpc.BackendRefs[0]) } } } @@ -560,10 +560,10 @@ func backendSecurityPolicyIndexFunc(rawObj client.Object) []string { // referenced in ClientTrafficPolicy objects. This helps in querying for ClientTrafficPolicies that are // affected by a particular ConfigMap or Secret CRUD. func addCtpIndexers(ctx context.Context, mgr manager.Manager) error { - if err := mgr.GetFieldIndexer().IndexField(ctx, &v1alpha1.ClientTrafficPolicy{}, configMapCtpIndex, configMapCtpIndexFunc); err != nil { + if err := mgr.GetFieldIndexer().IndexField(ctx, &egv1a1.ClientTrafficPolicy{}, configMapCtpIndex, configMapCtpIndexFunc); err != nil { return err } - if err := mgr.GetFieldIndexer().IndexField(ctx, &v1alpha1.ClientTrafficPolicy{}, secretCtpIndex, secretCtpIndexFunc); err != nil { + if err := mgr.GetFieldIndexer().IndexField(ctx, &egv1a1.ClientTrafficPolicy{}, secretCtpIndex, secretCtpIndexFunc); err != nil { return err } @@ -571,7 +571,7 @@ func addCtpIndexers(ctx context.Context, mgr manager.Manager) error { } func configMapCtpIndexFunc(rawObj client.Object) []string { - ctp := rawObj.(*v1alpha1.ClientTrafficPolicy) + ctp := rawObj.(*egv1a1.ClientTrafficPolicy) var configMapReferences []string if ctp.Spec.TLS != nil && ctp.Spec.TLS.ClientValidation != nil { for _, caCertRef := range ctp.Spec.TLS.ClientValidation.CACertificateRefs { @@ -591,7 +591,7 @@ func configMapCtpIndexFunc(rawObj client.Object) []string { } func secretCtpIndexFunc(rawObj client.Object) []string { - ctp := rawObj.(*v1alpha1.ClientTrafficPolicy) + ctp := rawObj.(*egv1a1.ClientTrafficPolicy) var secretReferences []string if ctp.Spec.TLS != nil && ctp.Spec.TLS.ClientValidation != nil { for _, caCertRef := range ctp.Spec.TLS.ClientValidation.CACertificateRefs { @@ -647,7 +647,7 @@ func addEnvoyExtensionPolicyIndexers(ctx context.Context, mgr manager.Manager) e var err error if err = mgr.GetFieldIndexer().IndexField( - ctx, &v1alpha1.EnvoyExtensionPolicy{}, backendEnvoyExtensionPolicyIndex, + ctx, &egv1a1.EnvoyExtensionPolicy{}, backendEnvoyExtensionPolicyIndex, backendEnvoyExtensionPolicyIndexFunc); err != nil { return err } @@ -656,7 +656,7 @@ func addEnvoyExtensionPolicyIndexers(ctx context.Context, mgr manager.Manager) e } func backendEnvoyExtensionPolicyIndexFunc(rawObj client.Object) []string { - envoyExtensionPolicy := rawObj.(*v1alpha1.EnvoyExtensionPolicy) + envoyExtensionPolicy := rawObj.(*egv1a1.EnvoyExtensionPolicy) var ret []string diff --git a/internal/provider/kubernetes/predicates.go b/internal/provider/kubernetes/predicates.go index 3200939800a..a2d456c72ac 100644 --- a/internal/provider/kubernetes/predicates.go +++ b/internal/provider/kubernetes/predicates.go @@ -21,7 +21,7 @@ import ( gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" - mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + mcsapiv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -326,7 +326,7 @@ func (r *gatewayAPIReconciler) isSecurityPolicyReferencingBackend(nsName *types. // if it exists, finds the Gateway's Deployment, and further updates the Gateway // status Ready condition. All Services are pushed for reconciliation. func (r *gatewayAPIReconciler) validateServiceImportForReconcile(obj client.Object) bool { - svcImport, ok := obj.(*mcsapi.ServiceImport) + svcImport, ok := obj.(*mcsapiv1a1.ServiceImport) if !ok { r.log.Info("unexpected object type, bypassing reconciliation", "object", obj) return false @@ -400,7 +400,7 @@ func (r *gatewayAPIReconciler) validateEndpointSliceForReconcile(obj client.Obje } svcName, ok := ep.GetLabels()[discoveryv1.LabelServiceName] - multiClusterSvcName, isMCS := ep.GetLabels()[mcsapi.LabelServiceName] + multiClusterSvcName, isMCS := ep.GetLabels()[mcsapiv1a1.LabelServiceName] if !ok && !isMCS { r.log.Info("endpointslice is missing kubernetes.io/service-name or multicluster.kubernetes.io/service-name label", "object", obj) return false diff --git a/internal/provider/kubernetes/predicates_test.go b/internal/provider/kubernetes/predicates_test.go index c27caa97ef8..ac1113ffb40 100644 --- a/internal/provider/kubernetes/predicates_test.go +++ b/internal/provider/kubernetes/predicates_test.go @@ -21,7 +21,7 @@ import ( gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway" "github.com/envoyproxy/gateway/internal/gatewayapi" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/proxy" @@ -40,7 +40,7 @@ func TestGatewayClassHasMatchingController(t *testing.T) { }{ { name: "matching controller name", - gc: test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + gc: test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), expect: true, }, { @@ -51,10 +51,10 @@ func TestGatewayClassHasMatchingController(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, } @@ -104,13 +104,13 @@ func TestGatewayClassHasMatchingNamespaceLabels(t *testing.T) { }, } - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) for _, tc := range testCases { tc := tc r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, namespaceLabel: &metav1.LabelSelector{MatchExpressions: matchExpressions(tc.namespaceLabels, metav1.LabelSelectorOpExists, []string{})}, log: logger, client: fakeclient.NewClientBuilder(). @@ -151,7 +151,7 @@ func TestValidateGatewayForReconcile(t *testing.T) { }{ { name: "references class with matching controller name", - configs: []client.Object{test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil)}, + configs: []client.Object{test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil)}, gateway: test.GetGateway(types.NamespacedName{Name: "scheduled-status-test"}, "test-gc", 8080), expect: true, }, @@ -164,10 +164,10 @@ func TestValidateGatewayForReconcile(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, } @@ -184,18 +184,18 @@ func TestValidateGatewayForReconcile(t *testing.T) { // TestValidateSecretForReconcile tests the validateSecretForReconcile // predicate function. func TestValidateSecretForReconcile(t *testing.T) { - mtlsEnabledEnvoyProxyConfig := &v1alpha1.EnvoyProxy{ + mtlsEnabledEnvoyProxyConfig := &egv1a1.EnvoyProxy{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "mtls-settings", }, - Spec: v1alpha1.EnvoyProxySpec{ - BackendTLS: &v1alpha1.BackendTLSConfig{ + Spec: egv1a1.EnvoyProxySpec{ + BackendTLS: &egv1a1.BackendTLSConfig{ ClientCertificateRef: &gwapiv1.SecretObjectReference{ Kind: gatewayapi.KindPtr("Secret"), Name: "client-tls-certificate", }, - TLSSettings: v1alpha1.TLSSettings{}, + TLSSettings: egv1a1.TLSSettings{}, }, }, } @@ -208,7 +208,7 @@ func TestValidateSecretForReconcile(t *testing.T) { { name: "envoy proxy references a secret", configs: []client.Object{ - test.GetGatewayClass("test-secret-ref", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-secret-ref", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(mtlsEnabledEnvoyProxyConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(mtlsEnabledEnvoyProxyConfig.Kind), Namespace: gwapiv1.Namespace(mtlsEnabledEnvoyProxyConfig.Namespace), @@ -223,7 +223,7 @@ func TestValidateSecretForReconcile(t *testing.T) { { name: "references valid gateway", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), test.GetSecureGateway(types.NamespacedName{Name: "scheduled-status-test"}, "test-gc", test.GroupKindNamespacedName{ Kind: gatewayapi.KindSecret, Name: "secret", @@ -247,21 +247,21 @@ func TestValidateSecretForReconcile(t *testing.T) { { name: "references SecurityPolicy OIDC", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), test.GetGateway(types.NamespacedName{Name: "scheduled-status-test"}, "test-gc", 8080), - &v1alpha1.SecurityPolicy{ + &egv1a1.SecurityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "oidc", }, - Spec: v1alpha1.SecurityPolicySpec{ + Spec: egv1a1.SecurityPolicySpec{ TargetRef: gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Kind: "Gateway", Name: "scheduled-status-test", }, }, - OIDC: &v1alpha1.OIDC{ - Provider: v1alpha1.OIDCProvider{ + OIDC: &egv1a1.OIDC{ + Provider: egv1a1.OIDCProvider{ Issuer: "https://accounts.google.com", AuthorizationEndpoint: ptr.To("https://accounts.google.com/o/oauth2/v2/auth"), TokenEndpoint: ptr.To("https://oauth2.googleapis.com/token"), @@ -280,20 +280,20 @@ func TestValidateSecretForReconcile(t *testing.T) { { name: "references SecurityPolicy Basic Auth", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), test.GetGateway(types.NamespacedName{Name: "scheduled-status-test"}, "test-gc", 8080), - &v1alpha1.SecurityPolicy{ + &egv1a1.SecurityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "basic-auth", }, - Spec: v1alpha1.SecurityPolicySpec{ + Spec: egv1a1.SecurityPolicySpec{ TargetRef: gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Kind: "Gateway", Name: "scheduled-status-test", }, }, - BasicAuth: &v1alpha1.BasicAuth{ + BasicAuth: &egv1a1.BasicAuth{ Users: gwapiv1b1.SecretObjectReference{ Name: "secret", }, @@ -307,7 +307,7 @@ func TestValidateSecretForReconcile(t *testing.T) { { name: "secret is not referenced by any EG CRs", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), }, secret: test.GetSecret(types.NamespacedName{Name: "secret"}), expect: false, @@ -315,10 +315,10 @@ func TestValidateSecretForReconcile(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, } @@ -328,8 +328,8 @@ func TestValidateSecretForReconcile(t *testing.T) { WithScheme(envoygateway.GetScheme()). WithObjects(tc.configs...). WithIndex(&gwapiv1.Gateway{}, secretGatewayIndex, secretGatewayIndexFunc). - WithIndex(&v1alpha1.SecurityPolicy{}, secretSecurityPolicyIndex, secretSecurityPolicyIndexFunc). - WithIndex(&v1alpha1.EnvoyProxy{}, secretEnvoyProxyIndex, secretEnvoyProxyIndexFunc). + WithIndex(&egv1a1.SecurityPolicy{}, secretSecurityPolicyIndex, secretSecurityPolicyIndexFunc). + WithIndex(&egv1a1.EnvoyProxy{}, secretEnvoyProxyIndex, secretEnvoyProxyIndexFunc). Build() t.Run(tc.name, func(t *testing.T) { res := r.validateSecretForReconcile(tc.secret) @@ -352,7 +352,7 @@ func TestValidateEndpointSliceForReconcile(t *testing.T) { { name: "route service but no routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, }, endpointSlice: test.GetEndpointSlice(types.NamespacedName{Name: "endpointslice"}, "service"), @@ -361,7 +361,7 @@ func TestValidateEndpointSliceForReconcile(t *testing.T) { { name: "http route service routes exist, but endpointslice is associated with another service", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetHTTPRoute(types.NamespacedName{Name: "httproute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), }, @@ -371,7 +371,7 @@ func TestValidateEndpointSliceForReconcile(t *testing.T) { { name: "http route service routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetHTTPRoute(types.NamespacedName{Name: "httproute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), }, @@ -381,10 +381,10 @@ func TestValidateEndpointSliceForReconcile(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, } @@ -411,21 +411,21 @@ func TestValidateEndpointSliceForReconcile(t *testing.T) { func TestValidateServiceForReconcile(t *testing.T) { sampleGateway := test.GetGateway(types.NamespacedName{Namespace: "default", Name: "scheduled-status-test"}, "test-gc", 8080) mergeGatewaysConfig := test.GetEnvoyProxy(types.NamespacedName{Namespace: "default", Name: "merge-gateways-config"}, true) - telemetryEnabledGatewaysConfig := &v1alpha1.EnvoyProxy{ + telemetryEnabledGatewaysConfig := &egv1a1.EnvoyProxy{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "telemetry", }, - Spec: v1alpha1.EnvoyProxySpec{ - Telemetry: &v1alpha1.ProxyTelemetry{ - AccessLog: &v1alpha1.ProxyAccessLog{ - Settings: []v1alpha1.ProxyAccessLogSetting{ + Spec: egv1a1.EnvoyProxySpec{ + Telemetry: &egv1a1.ProxyTelemetry{ + AccessLog: &egv1a1.ProxyAccessLog{ + Settings: []egv1a1.ProxyAccessLogSetting{ { - Sinks: []v1alpha1.ProxyAccessLogSink{ + Sinks: []egv1a1.ProxyAccessLogSink{ { - Type: v1alpha1.ProxyAccessLogSinkTypeOpenTelemetry, - OpenTelemetry: &v1alpha1.OpenTelemetryEnvoyProxyAccessLog{ - BackendRefs: []v1alpha1.BackendRef{ + Type: egv1a1.ProxyAccessLogSinkTypeOpenTelemetry, + OpenTelemetry: &egv1a1.OpenTelemetryEnvoyProxyAccessLog{ + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "otel-collector", @@ -440,12 +440,12 @@ func TestValidateServiceForReconcile(t *testing.T) { }, }, }, - Metrics: &v1alpha1.ProxyMetrics{ - Sinks: []v1alpha1.ProxyMetricSink{ + Metrics: &egv1a1.ProxyMetrics{ + Sinks: []egv1a1.ProxyMetricSink{ { - Type: v1alpha1.MetricSinkTypeOpenTelemetry, - OpenTelemetry: &v1alpha1.ProxyOpenTelemetrySink{ - BackendRefs: []v1alpha1.BackendRef{ + Type: egv1a1.MetricSinkTypeOpenTelemetry, + OpenTelemetry: &egv1a1.ProxyOpenTelemetrySink{ + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "otel-collector", @@ -458,10 +458,10 @@ func TestValidateServiceForReconcile(t *testing.T) { }, }, }, - Tracing: &v1alpha1.ProxyTracing{ - Provider: v1alpha1.TracingProvider{ - Type: v1alpha1.TracingProviderTypeOpenTelemetry, - BackendRefs: []v1alpha1.BackendRef{ + Tracing: &egv1a1.ProxyTracing{ + Provider: egv1a1.TracingProvider{ + Type: egv1a1.TracingProviderTypeOpenTelemetry, + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "otel-collector", @@ -485,7 +485,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "gateway service but deployment does not exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, }, service: test.GetService(types.NamespacedName{Name: "service"}, map[string]string{ @@ -497,7 +497,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "gateway service deployment also exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetGatewayDeployment(types.NamespacedName{Name: proxy.ExpectedResourceHashedName("default/scheduled-status-test")}, nil), }, @@ -512,7 +512,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "route service but no routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, }, service: test.GetService(types.NamespacedName{Name: "service"}, nil, nil), @@ -521,7 +521,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "http route service routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetHTTPRoute(types.NamespacedName{Name: "httproute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), }, @@ -534,7 +534,7 @@ func TestValidateServiceForReconcile(t *testing.T) { // in which case we'll have to reconcile the bad config, and remove listeners accordingly. name: "route service routes exist but with non-existing gateway reference", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), test.GetHTTPRoute(types.NamespacedName{Name: "httproute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), }, service: test.GetService(types.NamespacedName{Name: "service"}, nil, nil), @@ -543,7 +543,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "grpc route service routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetGRPCRoute(types.NamespacedName{Name: "grpcroute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), }, @@ -553,7 +553,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "tls route service routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetTLSRoute(types.NamespacedName{Name: "tlsroute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 443), @@ -564,7 +564,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "udp route service routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetUDPRoute(types.NamespacedName{Name: "udproute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), @@ -575,7 +575,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "tcp route service routes exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetTCPRoute(types.NamespacedName{Name: "tcproute-test"}, "scheduled-status-test", types.NamespacedName{Name: "service"}, 80), @@ -586,7 +586,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "service referenced by EnvoyProxy updated", configs: []client.Object{ - test.GetGatewayClass("test-mg", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-mg", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(telemetryEnabledGatewaysConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(telemetryEnabledGatewaysConfig.Kind), Namespace: gwapiv1.Namespace(telemetryEnabledGatewaysConfig.Namespace), @@ -600,7 +600,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "service referenced by EnvoyProxy unrelated", configs: []client.Object{ - test.GetGatewayClass("test-mg", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-mg", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(telemetryEnabledGatewaysConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(telemetryEnabledGatewaysConfig.Kind), Namespace: gwapiv1.Namespace(telemetryEnabledGatewaysConfig.Namespace), @@ -614,20 +614,20 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "service referenced by SecurityPolicy ExtAuth HTTP service", configs: []client.Object{ - &v1alpha1.SecurityPolicy{ + &egv1a1.SecurityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "ext-auth-http", }, - Spec: v1alpha1.SecurityPolicySpec{ + Spec: egv1a1.SecurityPolicySpec{ TargetRef: gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Kind: "Gateway", Name: "scheduled-status-test", }, }, - ExtAuth: &v1alpha1.ExtAuth{ - HTTP: &v1alpha1.HTTPExtAuthService{ - BackendRefs: []v1alpha1.BackendRef{ + ExtAuth: &egv1a1.ExtAuth{ + HTTP: &egv1a1.HTTPExtAuthService{ + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "ext-auth-http-service", @@ -645,20 +645,20 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "service referenced by SecurityPolicy ExtAuth GRPC service", configs: []client.Object{ - &v1alpha1.SecurityPolicy{ + &egv1a1.SecurityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "ext-auth-http", }, - Spec: v1alpha1.SecurityPolicySpec{ + Spec: egv1a1.SecurityPolicySpec{ TargetRef: gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Kind: "Gateway", Name: "scheduled-status-test", }, }, - ExtAuth: &v1alpha1.ExtAuth{ - GRPC: &v1alpha1.GRPCExtAuthService{ - BackendRefs: []v1alpha1.BackendRef{ + ExtAuth: &egv1a1.ExtAuth{ + GRPC: &egv1a1.GRPCExtAuthService{ + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "ext-auth-grpc-service", @@ -676,20 +676,20 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "service referenced by EnvoyExtensionPolicy ExtPrc GRPC service", configs: []client.Object{ - &v1alpha1.EnvoyExtensionPolicy{ + &egv1a1.EnvoyExtensionPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "ext-proc", }, - Spec: v1alpha1.EnvoyExtensionPolicySpec{ + Spec: egv1a1.EnvoyExtensionPolicySpec{ TargetRef: gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Kind: "Gateway", Name: "scheduled-status-test", }, }, - ExtProc: []v1alpha1.ExtProc{ + ExtProc: []egv1a1.ExtProc{ { - BackendRefs: []v1alpha1.BackendRef{ + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "ext-proc-service", @@ -707,20 +707,20 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "service referenced by EnvoyExtensionPolicy ExtPrc GRPC service unrelated", configs: []client.Object{ - &v1alpha1.EnvoyExtensionPolicy{ + &egv1a1.EnvoyExtensionPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "ext-proc", }, - Spec: v1alpha1.EnvoyExtensionPolicySpec{ + Spec: egv1a1.EnvoyExtensionPolicySpec{ TargetRef: gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{ LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{ Kind: "Gateway", Name: "scheduled-status-test", }, }, - ExtProc: []v1alpha1.ExtProc{ + ExtProc: []egv1a1.ExtProc{ { - BackendRefs: []v1alpha1.BackendRef{ + BackendRefs: []egv1a1.BackendRef{ { BackendObjectReference: gwapiv1.BackendObjectReference{ Name: "ext-proc-service", @@ -738,7 +738,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "update status of all gateways under gatewayclass when MergeGateways enabled", configs: []client.Object{ - test.GetGatewayClass("test-mg", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-mg", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(mergeGatewaysConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(mergeGatewaysConfig.Kind), Namespace: gwapiv1.Namespace(mergeGatewaysConfig.Namespace), @@ -757,7 +757,7 @@ func TestValidateServiceForReconcile(t *testing.T) { { name: "no gateways found under gatewayclass when MergeGateways enabled", configs: []client.Object{ - test.GetGatewayClass("test-mg", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-mg", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(mergeGatewaysConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(mergeGatewaysConfig.Kind), Namespace: gwapiv1.Namespace(mergeGatewaysConfig.Namespace), @@ -773,10 +773,10 @@ func TestValidateServiceForReconcile(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, mergeGateways: sets.New[string]("test-mg"), } @@ -791,9 +791,9 @@ func TestValidateServiceForReconcile(t *testing.T) { WithIndex(&gwapiv1a2.TLSRoute{}, backendTLSRouteIndex, backendTLSRouteIndexFunc). WithIndex(&gwapiv1a2.TCPRoute{}, backendTCPRouteIndex, backendTCPRouteIndexFunc). WithIndex(&gwapiv1a2.UDPRoute{}, backendUDPRouteIndex, backendUDPRouteIndexFunc). - WithIndex(&v1alpha1.SecurityPolicy{}, backendSecurityPolicyIndex, backendSecurityPolicyIndexFunc). - WithIndex(&v1alpha1.EnvoyExtensionPolicy{}, backendEnvoyExtensionPolicyIndex, backendEnvoyExtensionPolicyIndexFunc). - WithIndex(&v1alpha1.EnvoyProxy{}, backendEnvoyProxyTelemetryIndex, backendEnvoyProxyTelemetryIndexFunc). + WithIndex(&egv1a1.SecurityPolicy{}, backendSecurityPolicyIndex, backendSecurityPolicyIndexFunc). + WithIndex(&egv1a1.EnvoyExtensionPolicy{}, backendEnvoyExtensionPolicyIndex, backendEnvoyExtensionPolicyIndexFunc). + WithIndex(&egv1a1.EnvoyProxy{}, backendEnvoyProxyTelemetryIndex, backendEnvoyProxyTelemetryIndexFunc). Build() t.Run(tc.name, func(t *testing.T) { res := r.validateServiceForReconcile(tc.service) @@ -819,7 +819,7 @@ func TestValidateDeploymentForReconcile(t *testing.T) { // purpose of the Deployment watcher is just for update Gateway object statuses. name: "gateway deployment deployment also exist", configs: []client.Object{ - test.GetGatewayClass("test-gc", v1alpha1.GatewayControllerName, nil), + test.GetGatewayClass("test-gc", egv1a1.GatewayControllerName, nil), sampleGateway, test.GetService(types.NamespacedName{Name: "deployment"}, map[string]string{ gatewayapi.OwningGatewayNameLabel: "scheduled-status-test", @@ -835,7 +835,7 @@ func TestValidateDeploymentForReconcile(t *testing.T) { { name: "update status of all gateways under gatewayclass when MergeGateways enabled", configs: []client.Object{ - test.GetGatewayClass("test-mg", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-mg", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(mergeGatewaysConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(mergeGatewaysConfig.Kind), Namespace: gwapiv1.Namespace(mergeGatewaysConfig.Namespace), @@ -851,7 +851,7 @@ func TestValidateDeploymentForReconcile(t *testing.T) { { name: "no gateways found under gatewayclass when MergeGateways enabled", configs: []client.Object{ - test.GetGatewayClass("test-mg", v1alpha1.GatewayControllerName, &test.GroupKindNamespacedName{ + test.GetGatewayClass("test-mg", egv1a1.GatewayControllerName, &test.GroupKindNamespacedName{ Group: gwapiv1.Group(mergeGatewaysConfig.GroupVersionKind().Group), Kind: gwapiv1.Kind(mergeGatewaysConfig.Kind), Namespace: gwapiv1.Namespace(mergeGatewaysConfig.Namespace), @@ -870,10 +870,10 @@ func TestValidateDeploymentForReconcile(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, mergeGateways: sets.New[string]("test-mg"), } @@ -977,10 +977,10 @@ func TestCheckObjectNamespaceLabels(t *testing.T) { } // Create the reconciler. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) r := gatewayAPIReconciler{ - classController: v1alpha1.GatewayControllerName, + classController: egv1a1.GatewayControllerName, log: logger, } diff --git a/internal/provider/kubernetes/status.go b/internal/provider/kubernetes/status.go index b80a854f120..85e9ff99310 100644 --- a/internal/provider/kubernetes/status.go +++ b/internal/provider/kubernetes/status.go @@ -17,7 +17,7 @@ import ( gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi/status" "github.com/envoyproxy/gateway/internal/message" "github.com/envoyproxy/gateway/internal/utils" @@ -29,7 +29,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // Gateway object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "gateway-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "gateway-status"}, r.resources.GatewayStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1.GatewayStatus], errChan chan error) { // skip delete updates. @@ -54,7 +54,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // HTTPRoute object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "httproute-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "httproute-status"}, r.resources.HTTPRouteStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1.HTTPRouteStatus], errChan chan error) { // skip delete updates. @@ -85,7 +85,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // GRPCRoute object status updater go func() { - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "grpcroute-status"}, r.resources.GRPCRouteStatuses.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "grpcroute-status"}, r.resources.GRPCRouteStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1.GRPCRouteStatus], errChan chan error) { // skip delete updates. if update.Delete { @@ -116,7 +116,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // TLSRoute object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "tlsroute-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "tlsroute-status"}, r.resources.TLSRouteStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.TLSRouteStatus], errChan chan error) { // skip delete updates. @@ -148,7 +148,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // TCPRoute object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "tcproute-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "tcproute-status"}, r.resources.TCPRouteStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.TCPRouteStatus], errChan chan error) { // skip delete updates. @@ -180,7 +180,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // UDPRoute object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "udproute-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "udproute-status"}, r.resources.UDPRouteStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.UDPRouteStatus], errChan chan error) { // skip delete updates. @@ -212,7 +212,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // EnvoyPatchPolicy object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "envoypatchpolicy-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "envoypatchpolicy-status"}, r.resources.EnvoyPatchPolicyStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. @@ -223,9 +223,9 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext val := update.Value r.statusUpdater.Send(Update{ NamespacedName: key, - Resource: new(v1alpha1.EnvoyPatchPolicy), + Resource: new(egv1a1.EnvoyPatchPolicy), Mutator: MutatorFunc(func(obj client.Object) client.Object { - t, ok := obj.(*v1alpha1.EnvoyPatchPolicy) + t, ok := obj.(*egv1a1.EnvoyPatchPolicy) if !ok { err := fmt.Errorf("unsupported object type %T", obj) errChan <- err @@ -244,7 +244,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // ClientTrafficPolicy object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "clienttrafficpolicy-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "clienttrafficpolicy-status"}, r.resources.ClientTrafficPolicyStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. @@ -255,9 +255,9 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext val := update.Value r.statusUpdater.Send(Update{ NamespacedName: key, - Resource: new(v1alpha1.ClientTrafficPolicy), + Resource: new(egv1a1.ClientTrafficPolicy), Mutator: MutatorFunc(func(obj client.Object) client.Object { - t, ok := obj.(*v1alpha1.ClientTrafficPolicy) + t, ok := obj.(*egv1a1.ClientTrafficPolicy) if !ok { err := fmt.Errorf("unsupported object type %T", obj) errChan <- err @@ -276,7 +276,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // BackendTrafficPolicy object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "backendtrafficpolicy-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "backendtrafficpolicy-status"}, r.resources.BackendTrafficPolicyStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. @@ -287,9 +287,9 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext val := update.Value r.statusUpdater.Send(Update{ NamespacedName: key, - Resource: new(v1alpha1.BackendTrafficPolicy), + Resource: new(egv1a1.BackendTrafficPolicy), Mutator: MutatorFunc(func(obj client.Object) client.Object { - t, ok := obj.(*v1alpha1.BackendTrafficPolicy) + t, ok := obj.(*egv1a1.BackendTrafficPolicy) if !ok { err := fmt.Errorf("unsupported object type %T", obj) errChan <- err @@ -308,7 +308,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // SecurityPolicy object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "securitypolicy-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "securitypolicy-status"}, r.resources.SecurityPolicyStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. @@ -319,9 +319,9 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext val := update.Value r.statusUpdater.Send(Update{ NamespacedName: key, - Resource: new(v1alpha1.SecurityPolicy), + Resource: new(egv1a1.SecurityPolicy), Mutator: MutatorFunc(func(obj client.Object) client.Object { - t, ok := obj.(*v1alpha1.SecurityPolicy) + t, ok := obj.(*egv1a1.SecurityPolicy) if !ok { err := fmt.Errorf("unsupported object type %T", obj) errChan <- err @@ -339,7 +339,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // BackendTLSPolicy object status updater go func() { - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "backendtlspolicy-status"}, r.resources.BackendTLSPolicyStatuses.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "backendtlspolicy-status"}, r.resources.BackendTLSPolicyStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. if update.Delete { @@ -370,7 +370,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // EnvoyExtensionPolicy object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "envoyextensionpolicy-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "envoyextensionpolicy-status"}, r.resources.EnvoyExtensionPolicyStatuses.Subscribe(ctx), func(update message.Update[types.NamespacedName, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. @@ -381,9 +381,9 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext val := update.Value r.statusUpdater.Send(Update{ NamespacedName: key, - Resource: new(v1alpha1.EnvoyExtensionPolicy), + Resource: new(egv1a1.EnvoyExtensionPolicy), Mutator: MutatorFunc(func(obj client.Object) client.Object { - t, ok := obj.(*v1alpha1.EnvoyExtensionPolicy) + t, ok := obj.(*egv1a1.EnvoyExtensionPolicy) if !ok { err := fmt.Errorf("unsupported object type %T", obj) errChan <- err @@ -403,7 +403,7 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext // EnvoyExtensionPolicy object status updater go func() { message.HandleSubscription( - message.Metadata{Runner: string(v1alpha1.LogComponentProviderRunner), Message: "extensionserverpolicies-status"}, + message.Metadata{Runner: string(egv1a1.LogComponentProviderRunner), Message: "extensionserverpolicies-status"}, r.resources.ExtensionPolicyStatuses.Subscribe(ctx), func(update message.Update[message.NamespacedNameAndGVK, *gwapiv1a2.PolicyStatus], errChan chan error) { // skip delete updates. diff --git a/internal/provider/kubernetes/store_test.go b/internal/provider/kubernetes/store_test.go index d2082100083..07289d8b135 100644 --- a/internal/provider/kubernetes/store_test.go +++ b/internal/provider/kubernetes/store_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestNodeDetailsAddressStore(t *testing.T) { @@ -23,7 +23,7 @@ func TestNodeDetailsAddressStore(t *testing.T) { { name: "No node addresses", nodeObject: &corev1.Node{ - ObjectMeta: v1.ObjectMeta{Name: "node1"}, + ObjectMeta: metav1.ObjectMeta{Name: "node1"}, Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{}}}, }, expectedAddresses: []string{}, @@ -31,7 +31,7 @@ func TestNodeDetailsAddressStore(t *testing.T) { { name: "only external address", nodeObject: &corev1.Node{ - ObjectMeta: v1.ObjectMeta{Name: "node1"}, + ObjectMeta: metav1.ObjectMeta{Name: "node1"}, Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{ Address: "1.1.1.1", Type: corev1.NodeExternalIP, @@ -42,7 +42,7 @@ func TestNodeDetailsAddressStore(t *testing.T) { { name: "only internal address", nodeObject: &corev1.Node{ - ObjectMeta: v1.ObjectMeta{Name: "node1"}, + ObjectMeta: metav1.ObjectMeta{Name: "node1"}, Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{ Address: "1.1.1.1", Type: corev1.NodeInternalIP, @@ -53,7 +53,7 @@ func TestNodeDetailsAddressStore(t *testing.T) { { name: "prefer external address", nodeObject: &corev1.Node{ - ObjectMeta: v1.ObjectMeta{Name: "node1"}, + ObjectMeta: metav1.ObjectMeta{Name: "node1"}, Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{ { Address: "1.1.1.1", @@ -84,7 +84,7 @@ func TestRace(t *testing.T) { go func() { for { s.addNode(&corev1.Node{ - ObjectMeta: v1.ObjectMeta{Name: "node1"}, + ObjectMeta: metav1.ObjectMeta{Name: "node1"}, Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{}}}, }) } diff --git a/internal/provider/runner/runner.go b/internal/provider/runner/runner.go index 7e298948321..32f5a30fe8c 100644 --- a/internal/provider/runner/runner.go +++ b/internal/provider/runner/runner.go @@ -11,7 +11,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/message" "github.com/envoyproxy/gateway/internal/provider/kubernetes" @@ -31,21 +31,21 @@ func New(cfg *Config) *Runner { } func (r *Runner) Name() string { - return string(v1alpha1.LogComponentProviderRunner) + return string(egv1a1.LogComponentProviderRunner) } // Start the provider runner func (r *Runner) Start(ctx context.Context) (err error) { r.Logger = r.Logger.WithName(r.Name()).WithValues("runner", r.Name()) - if r.EnvoyGateway.Provider.Type == v1alpha1.ProviderTypeKubernetes { - r.Logger.Info("Using provider", "type", v1alpha1.ProviderTypeKubernetes) + if r.EnvoyGateway.Provider.Type == egv1a1.ProviderTypeKubernetes { + r.Logger.Info("Using provider", "type", egv1a1.ProviderTypeKubernetes) cfg, err := ctrl.GetConfig() if err != nil { return fmt.Errorf("failed to get kubeconfig: %w", err) } p, err := kubernetes.New(cfg, &r.Config.Server, r.ProviderResources) if err != nil { - return fmt.Errorf("failed to create provider %s: %w", v1alpha1.ProviderTypeKubernetes, err) + return fmt.Errorf("failed to create provider %s: %w", egv1a1.ProviderTypeKubernetes, err) } go func() { err := p.Start(ctx) diff --git a/internal/provider/runner/runner_test.go b/internal/provider/runner/runner_test.go index d7fcd1092af..a393462da94 100644 --- a/internal/provider/runner/runner_test.go +++ b/internal/provider/runner/runner_test.go @@ -12,14 +12,14 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/logging" "github.com/envoyproxy/gateway/internal/message" ) func TestStart(t *testing.T) { - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) testCases := []struct { name string @@ -29,14 +29,14 @@ func TestStart(t *testing.T) { { name: "file provider", cfg: &config.Server{ - EnvoyGateway: &v1alpha1.EnvoyGateway{ + EnvoyGateway: &egv1a1.EnvoyGateway{ TypeMeta: metav1.TypeMeta{ - APIVersion: v1alpha1.GroupVersion.String(), - Kind: v1alpha1.KindEnvoyGateway, + APIVersion: egv1a1.GroupVersion.String(), + Kind: egv1a1.KindEnvoyGateway, }, - EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ - Provider: &v1alpha1.EnvoyGatewayProvider{ - Type: v1alpha1.ProviderTypeFile, + EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ + Provider: &egv1a1.EnvoyGatewayProvider{ + Type: egv1a1.ProviderTypeFile, }, }, }, diff --git a/internal/xds/server/runner/runner.go b/internal/xds/server/runner/runner.go index f0812752524..d8acab8d951 100644 --- a/internal/xds/server/runner/runner.go +++ b/internal/xds/server/runner/runner.go @@ -28,7 +28,7 @@ import ( "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/message" "github.com/envoyproxy/gateway/internal/xds/bootstrap" @@ -66,7 +66,7 @@ func New(cfg *Config) *Runner { } func (r *Runner) Name() string { - return string(v1alpha1.LogComponentXdsServerRunner) + return string(egv1a1.LogComponentXdsServerRunner) } // Start starts the xds-server runner @@ -132,7 +132,7 @@ func registerServer(srv serverv3.Server, g *grpc.Server) { func (r *Runner) subscribeAndTranslate(ctx context.Context) { // Subscribe to resources - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentXdsServerRunner), Message: "xds"}, r.Xds.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentXdsServerRunner), Message: "xds"}, r.Xds.Subscribe(ctx), func(update message.Update[string, *xdstypes.ResourceVersionTable], errChan chan error) { key := update.Key val := update.Value diff --git a/internal/xds/server/runner/runner_test.go b/internal/xds/server/runner/runner_test.go index ced3aa20bbb..45f59da0edc 100644 --- a/internal/xds/server/runner/runner_test.go +++ b/internal/xds/server/runner/runner_test.go @@ -23,7 +23,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/logging" "github.com/envoyproxy/gateway/internal/xds/bootstrap" @@ -107,7 +107,7 @@ func TestTLSConfig(t *testing.T) { require.NoError(t, err) // Start a dummy server. - logger := logging.DefaultLogger(v1alpha1.LogLevelInfo) + logger := logging.DefaultLogger(egv1a1.LogLevelInfo) cfg := &Config{ Server: config.Server{ diff --git a/internal/xds/translator/extension.go b/internal/xds/translator/extension.go index a3072911105..5a14bd2f7cb 100644 --- a/internal/xds/translator/extension.go +++ b/internal/xds/translator/extension.go @@ -21,7 +21,7 @@ import ( resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" extensionTypes "github.com/envoyproxy/gateway/internal/extension/types" "github.com/envoyproxy/gateway/internal/ir" "github.com/envoyproxy/gateway/internal/xds/types" @@ -35,7 +35,7 @@ func processExtensionPostRouteHook(route *routev3.Route, vHost *routev3.VirtualH // Check if an extension want to modify the route that was just configured/created extManager := *em - extRouteHookClient := extManager.GetPostXDSHookClient(v1alpha1.XDSRoute) + extRouteHookClient := extManager.GetPostXDSHookClient(egv1a1.XDSRoute) if extRouteHookClient == nil { return nil } @@ -71,7 +71,7 @@ func processExtensionPostVHostHook(vHost *routev3.VirtualHost, em *extensionType // Check if an extension want to modify the route that was just configured/created extManager := *em - extVHHookClient := extManager.GetPostXDSHookClient(v1alpha1.XDSVirtualHost) + extVHHookClient := extManager.GetPostXDSHookClient(egv1a1.XDSVirtualHost) if extVHHookClient == nil { return nil } @@ -100,7 +100,7 @@ func processExtensionPostListenerHook(tCtx *types.ResourceVersionTable, xdsListe // Check if an extension want to modify the listener that was just configured/created extManager := *em - extListenerHookClient := extManager.GetPostXDSHookClient(v1alpha1.XDSHTTPListener) + extListenerHookClient := extManager.GetPostXDSHookClient(egv1a1.XDSHTTPListener) if extListenerHookClient != nil { unstructuredResources := make([]*unstructured.Unstructured, len(extensionRefs)) for refIdx, ref := range extensionRefs { @@ -140,7 +140,7 @@ func processExtensionPostTranslationHook(tCtx *types.ResourceVersionTable, em *e // that is non-static. If a cluster definition is unlikely to change over the course of an extension's lifetime then the custom bootstrap config // is the preferred way of adding it. extManager := *em - extensionInsertHookClient := extManager.GetPostXDSHookClient(v1alpha1.XDSTranslation) + extensionInsertHookClient := extManager.GetPostXDSHookClient(egv1a1.XDSTranslation) if extensionInsertHookClient == nil { return nil } diff --git a/internal/xds/translator/jwt.go b/internal/xds/translator/jwt.go index 5a2b35ca696..ee6c52326b7 100644 --- a/internal/xds/translator/jwt.go +++ b/internal/xds/translator/jwt.go @@ -20,7 +20,7 @@ import ( "google.golang.org/protobuf/types/known/emptypb" "k8s.io/utils/ptr" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/ir" "github.com/envoyproxy/gateway/internal/xds/types" ) @@ -313,7 +313,7 @@ func routeContainsJWTAuthn(irRoute *ir.HTTPRoute) bool { } // buildJwtFromHeaders returns a list of JwtHeader transformed from JWTFromHeader struct -func buildJwtFromHeaders(headers []v1alpha1.JWTHeaderExtractor) []*jwtauthnv3.JwtHeader { +func buildJwtFromHeaders(headers []egv1a1.JWTHeaderExtractor) []*jwtauthnv3.JwtHeader { jwtHeaders := make([]*jwtauthnv3.JwtHeader, 0, len(headers)) for _, header := range headers { diff --git a/internal/xds/translator/runner/runner.go b/internal/xds/translator/runner/runner.go index 6e2c8ba7880..6c802a76f77 100644 --- a/internal/xds/translator/runner/runner.go +++ b/internal/xds/translator/runner/runner.go @@ -11,7 +11,7 @@ import ( ktypes "k8s.io/apimachinery/pkg/types" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" extension "github.com/envoyproxy/gateway/internal/extension/types" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/ratelimit" @@ -37,7 +37,7 @@ func New(cfg *Config) *Runner { } func (r *Runner) Name() string { - return string(v1alpha1.LogComponentXdsTranslatorRunner) + return string(egv1a1.LogComponentXdsTranslatorRunner) } // Start starts the xds-translator runner @@ -50,7 +50,7 @@ func (r *Runner) Start(ctx context.Context) (err error) { func (r *Runner) subscribeAndTranslate(ctx context.Context) { // Subscribe to resources - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentXdsTranslatorRunner), Message: "xds-ir"}, r.XdsIR.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(egv1a1.LogComponentXdsTranslatorRunner), Message: "xds-ir"}, r.XdsIR.Subscribe(ctx), func(update message.Update[string, *ir.Xds], errChan chan error) { r.Logger.Info("received an update") key := update.Key diff --git a/internal/xds/translator/runner/runner_test.go b/internal/xds/translator/runner/runner_test.go index 7928f582316..e6c9eebe90d 100644 --- a/internal/xds/translator/runner/runner_test.go +++ b/internal/xds/translator/runner/runner_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/envoygateway/config" "github.com/envoyproxy/gateway/internal/extension/types" "github.com/envoyproxy/gateway/internal/ir" @@ -170,8 +170,8 @@ type extManagerMock struct { types.Manager } -func (m *extManagerMock) GetPostXDSHookClient(xdsHookType v1alpha1.XDSTranslatorHook) types.XDSHookClient { - if xdsHookType == v1alpha1.XDSHTTPListener { +func (m *extManagerMock) GetPostXDSHookClient(xdsHookType egv1a1.XDSTranslatorHook) types.XDSHookClient { + if xdsHookType == egv1a1.XDSHTTPListener { return &xdsHookClientMock{} } diff --git a/internal/xds/translator/translator.go b/internal/xds/translator/translator.go index be9b03cfa09..707e8d32995 100644 --- a/internal/xds/translator/translator.go +++ b/internal/xds/translator/translator.go @@ -26,7 +26,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" "k8s.io/utils/ptr" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" extensionTypes "github.com/envoyproxy/gateway/internal/extension/types" "github.com/envoyproxy/gateway/internal/ir" "github.com/envoyproxy/gateway/internal/utils/protocov" @@ -51,7 +51,7 @@ type Translator struct { ExtensionManager *extensionTypes.Manager // FilterOrder holds the custom order of the HTTP filters - FilterOrder []v1alpha1.FilterPosition + FilterOrder []egv1a1.FilterPosition } type GlobalRateLimitSettings struct { diff --git a/internal/xds/translator/translator_test.go b/internal/xds/translator/translator_test.go index bcb18461efa..751224b6e12 100644 --- a/internal/xds/translator/translator_test.go +++ b/internal/xds/translator/translator_test.go @@ -22,7 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/extension/registry" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/ratelimit" "github.com/envoyproxy/gateway/internal/ir" @@ -229,28 +229,28 @@ func TestTranslateXdsWithExtension(t *testing.T) { ServiceURL: ratelimit.GetServiceURL("envoy-gateway-system", "cluster.local"), }, } - ext := v1alpha1.ExtensionManager{ - Resources: []v1alpha1.GroupVersionKind{ + ext := egv1a1.ExtensionManager{ + Resources: []egv1a1.GroupVersionKind{ { Group: "foo.example.io", Version: "v1alpha1", Kind: "examplefilter", }, }, - PolicyResources: []v1alpha1.GroupVersionKind{ + PolicyResources: []egv1a1.GroupVersionKind{ { Group: "bar.example.io", Version: "v1alpha1", Kind: "ExtensionPolicy", }, }, - Hooks: &v1alpha1.ExtensionHooks{ - XDSTranslator: &v1alpha1.XDSTranslatorHooks{ - Post: []v1alpha1.XDSTranslatorHook{ - v1alpha1.XDSRoute, - v1alpha1.XDSVirtualHost, - v1alpha1.XDSHTTPListener, - v1alpha1.XDSTranslation, + Hooks: &egv1a1.ExtensionHooks{ + XDSTranslator: &egv1a1.XDSTranslatorHooks{ + Post: []egv1a1.XDSTranslatorHook{ + egv1a1.XDSRoute, + egv1a1.XDSVirtualHost, + egv1a1.XDSHTTPListener, + egv1a1.XDSTranslation, }, }, }, diff --git a/test/e2e/tests/authorization-client-ip.go b/test/e2e/tests/authorization-client-ip.go index 0a0d2056ab2..594ae19483f 100644 --- a/test/e2e/tests/authorization-client-ip.go +++ b/test/e2e/tests/authorization-client-ip.go @@ -12,8 +12,8 @@ import ( "testing" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -36,11 +36,11 @@ var AuthorizationClientIPTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), route1NN, route2NN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "authorization-client-ip-1", Namespace: ns}, suite.ControllerName, ancestorRef) SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "authorization-client-ip-2", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/authorization-default-action.go b/test/e2e/tests/authorization-default-action.go index 1a58c32e381..7cd649e3fec 100644 --- a/test/e2e/tests/authorization-default-action.go +++ b/test/e2e/tests/authorization-default-action.go @@ -12,8 +12,8 @@ import ( "testing" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -36,11 +36,11 @@ var AuthorizationDefaultActionTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), route1NN, route2NN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "authorization-empty", Namespace: ns}, suite.ControllerName, ancestorRef) SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "authorization-allow-all", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/backend_tls_settings.go b/test/e2e/tests/backend_tls_settings.go index 14205b6e0b2..0fdbdf10d62 100644 --- a/test/e2e/tests/backend_tls_settings.go +++ b/test/e2e/tests/backend_tls_settings.go @@ -21,7 +21,7 @@ import ( "github.com/google/go-cmp/cmp" appsv1 "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" @@ -29,14 +29,14 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha3" + gwapiv1a3 "sigs.k8s.io/gateway-api/apis/v1alpha3" "sigs.k8s.io/gateway-api/conformance/utils/config" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" "sigs.k8s.io/yaml" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" ) @@ -58,7 +58,7 @@ var BackendTLSSettingsTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "backend-namespaces", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) kubernetes.NamespacesMustBeReady(t, suite.Client, suite.TimeoutConfig, []string{depNS}) - backendTLSPolicy := &v1alpha3.BackendTLSPolicy{} + backendTLSPolicy := &gwapiv1a3.BackendTLSPolicy{} btpNN := types.NamespacedName{Name: "policy-btls", Namespace: ns} err := suite.Client.Get(context.Background(), btpNN, backendTLSPolicy) if err != nil { @@ -66,15 +66,15 @@ var BackendTLSSettingsTest = suite.ConformanceTest{ } proxyNN := types.NamespacedName{Name: "proxy-config", Namespace: "envoy-gateway-system"} - config := &v1alpha1.BackendTLSConfig{ + config := &egv1a1.BackendTLSConfig{ ClientCertificateRef: &gwapiv1.SecretObjectReference{ Kind: gatewayapi.KindPtr("Secret"), Name: "client-tls-certificate", Namespace: gatewayapi.NamespacePtr(depNS), }, - TLSSettings: v1alpha1.TLSSettings{ - MinVersion: ptr.To(v1alpha1.TLSv13), - MaxVersion: ptr.To(v1alpha1.TLSv13), + TLSSettings: egv1a1.TLSSettings{ + MinVersion: ptr.To(egv1a1.TLSv13), + MaxVersion: ptr.To(egv1a1.TLSv13), }, } err = UpdateProxyConfig(suite.Client, proxyNN, config) @@ -130,9 +130,9 @@ var BackendTLSSettingsTest = suite.ConformanceTest{ t.Error(err) } - config.TLSSettings = v1alpha1.TLSSettings{ - MinVersion: ptr.To(v1alpha1.TLSv12), - MaxVersion: ptr.To(v1alpha1.TLSv12), + config.TLSSettings = egv1a1.TLSSettings{ + MinVersion: ptr.To(egv1a1.TLSv12), + MaxVersion: ptr.To(egv1a1.TLSv12), Ciphers: []string{"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"}, } @@ -155,9 +155,9 @@ var BackendTLSSettingsTest = suite.ConformanceTest{ } // Cleanup backend tls settings. - err = UpdateProxyConfig(suite.Client, proxyNN, &v1alpha1.BackendTLSConfig{ + err = UpdateProxyConfig(suite.Client, proxyNN, &egv1a1.BackendTLSConfig{ ClientCertificateRef: nil, - TLSSettings: v1alpha1.TLSSettings{}, + TLSSettings: egv1a1.TLSSettings{}, }) if err != nil { t.Error(err) @@ -185,8 +185,8 @@ func confirmEchoBackendRes(httpRes *http.ExpectedResponse, expectedResBody *Resp } // UpdateProxyConfig updates the proxy configuration with BackendTLS settings. -func UpdateProxyConfig(client client.Client, proxyNN types.NamespacedName, config *v1alpha1.BackendTLSConfig) error { - proxyConfig := &v1alpha1.EnvoyProxy{} +func UpdateProxyConfig(client client.Client, proxyNN types.NamespacedName, config *egv1a1.BackendTLSConfig) error { + proxyConfig := &egv1a1.EnvoyProxy{} err := client.Get(context.Background(), proxyNN, proxyConfig) if err != nil { return err @@ -282,7 +282,7 @@ func restartDeploymentAndWaitForRollout(t *testing.T, timeoutConfig config.Timeo return wait.PollUntilContextTimeout(ctx, 1*time.Second, timeoutConfig.CreateTimeout, true, func(ctx context.Context) (bool, error) { // wait for replicaset with the same annotation to reach ready status - podList := &v1.PodList{} + podList := &corev1.PodList{} listOpts := []client.ListOption{ client.InNamespace(dp.Namespace), client.MatchingLabelsSelector{Selector: labels.SelectorFromSet(dp.Spec.Selector.MatchLabels)}, diff --git a/test/e2e/tests/basic_auth.go b/test/e2e/tests/basic_auth.go index 5791b35b97c..7f61067c1c8 100644 --- a/test/e2e/tests/basic_auth.go +++ b/test/e2e/tests/basic_auth.go @@ -12,8 +12,8 @@ import ( "testing" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -36,11 +36,11 @@ var BasicAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "basic-auth-1", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -75,11 +75,11 @@ var BasicAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "basic-auth-1", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -111,11 +111,11 @@ var BasicAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "basic-auth-1", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -150,11 +150,11 @@ var BasicAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "basic-auth-2", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -190,11 +190,11 @@ var BasicAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "basic-auth-1", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/connection_limit.go b/test/e2e/tests/connection_limit.go index 952a6086da6..a6f334e832b 100644 --- a/test/e2e/tests/connection_limit.go +++ b/test/e2e/tests/connection_limit.go @@ -16,8 +16,8 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -41,11 +41,11 @@ var ConnectionLimitTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "connection-limit-gateway", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } ClientTrafficPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "connection-limit-ctp", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/envoy_shutdown.go b/test/e2e/tests/envoy_shutdown.go index 4cb1e68ac7b..7634a29ae94 100644 --- a/test/e2e/tests/envoy_shutdown.go +++ b/test/e2e/tests/envoy_shutdown.go @@ -19,7 +19,7 @@ import ( "fortio.org/fortio/periodic" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" @@ -29,7 +29,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" - "github.com/envoyproxy/gateway/api/v1alpha1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" "github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/proxy" ) @@ -129,15 +129,15 @@ func restartProxyAndWaitForRollout(t *testing.T, timeoutConfig config.TimeoutCon const egRestartAnnotation = "gateway.envoyproxy.io/restartedAt" restartTime := time.Now().Format(time.RFC3339) ctx := context.Background() - ep := v1alpha1.EnvoyProxy{} + ep := egv1a1.EnvoyProxy{} if err := c.Get(context.Background(), epNN, &ep); err != nil { return err } jsonData := fmt.Sprintf("{\"metadata\": {\"annotations\": {\"gateway.envoyproxy.io/restartedAt\": \"%s\"}}, \"spec\": {\"template\": {\"metadata\": {\"annotations\": {\"gateway.envoyproxy.io/restartedAt\": \"%s\"}}}}}", restartTime, restartTime) - ep.Spec.Provider.Kubernetes.EnvoyDeployment.Patch = &v1alpha1.KubernetesPatchSpec{ - Value: v1.JSON{ + ep.Spec.Provider.Kubernetes.EnvoyDeployment.Patch = &egv1a1.KubernetesPatchSpec{ + Value: apiextensionsv1.JSON{ Raw: []byte(jsonData), }, } diff --git a/test/e2e/tests/ext_auth_grpc_service.go b/test/e2e/tests/ext_auth_grpc_service.go index 4d550d8443d..439ba8596ac 100644 --- a/test/e2e/tests/ext_auth_grpc_service.go +++ b/test/e2e/tests/ext_auth_grpc_service.go @@ -13,8 +13,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,11 +40,11 @@ var GRPCExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -84,11 +84,11 @@ var GRPCExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -125,11 +125,11 @@ var GRPCExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -169,11 +169,11 @@ var GRPCExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/ext_auth_http_service.go b/test/e2e/tests/ext_auth_http_service.go index 7005004b221..f610898abbd 100644 --- a/test/e2e/tests/ext_auth_http_service.go +++ b/test/e2e/tests/ext_auth_http_service.go @@ -13,8 +13,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,11 +40,11 @@ var HTTPExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -87,11 +87,11 @@ var HTTPExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -128,11 +128,11 @@ var HTTPExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -172,11 +172,11 @@ var HTTPExtAuthTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-auth-test", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/ext_proc.go b/test/e2e/tests/ext_proc.go index afa10772551..45cda23c0c3 100644 --- a/test/e2e/tests/ext_proc.go +++ b/test/e2e/tests/ext_proc.go @@ -13,8 +13,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -38,11 +38,11 @@ var ExtProcTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } EnvoyExtensionPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-proc-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -91,11 +91,11 @@ var ExtProcTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } EnvoyExtensionPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-proc-no-procmode-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -140,11 +140,11 @@ var ExtProcTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } EnvoyExtensionPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ext-proc-uds-test", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/local_ratelimit.go b/test/e2e/tests/local_ratelimit.go index 1237da50b39..896ecbba5ee 100644 --- a/test/e2e/tests/local_ratelimit.go +++ b/test/e2e/tests/local_ratelimit.go @@ -12,8 +12,8 @@ import ( "testing" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -38,11 +38,11 @@ var LocalRateLimitSpecificUserTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } BackendTrafficPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ratelimit-specific-user", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -123,11 +123,11 @@ var LocalRateLimitAllTrafficTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } BackendTrafficPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "ratelimit-all-traffic", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/oidc.go b/test/e2e/tests/oidc.go index ec162294d9c..f279d2eddcb 100644 --- a/test/e2e/tests/oidc.go +++ b/test/e2e/tests/oidc.go @@ -17,8 +17,8 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwhttp "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -51,11 +51,11 @@ var OIDCTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "oidc-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -130,11 +130,11 @@ var OIDCTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "oidc-test", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/test/e2e/tests/tcp_route.go b/test/e2e/tests/tcp_route.go index bb4d80ff6d6..8a703e08b92 100644 --- a/test/e2e/tests/tcp_route.go +++ b/test/e2e/tests/tcp_route.go @@ -23,8 +23,8 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" - gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/config" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" @@ -82,7 +82,7 @@ var TCPRouteTest = suite.ConformanceTest{ func GatewayAndTCPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeNNs ...types.NamespacedName) string { t.Helper() - tcpRoute := &v1alpha2.TCPRoute{} + tcpRoute := &gwapiv1a2.TCPRoute{} err := c.Get(context.Background(), routeNNs[0], tcpRoute) if err != nil { t.Logf("error fetching TCPRoute: %v", err) @@ -91,8 +91,8 @@ func GatewayAndTCPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutCon gwAddr, err := WaitForGatewayAddress(t, c, timeoutConfig, gw.NamespacedName, string(*tcpRoute.Spec.ParentRefs[0].SectionName)) require.NoErrorf(t, err, "timed out waiting for Gateway address to be assigned") - ns := gatewayv1.Namespace(gw.Namespace) - kind := gatewayv1.Kind("Gateway") + ns := gwapiv1.Namespace(gw.Namespace) + kind := gwapiv1.Kind("Gateway") for _, routeNN := range routeNNs { namespaceRequired := true @@ -100,21 +100,21 @@ func GatewayAndTCPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutCon namespaceRequired = false } - var parents []gatewayv1.RouteParentStatus + var parents []gwapiv1.RouteParentStatus for _, listener := range gw.listenerNames { - parents = append(parents, gatewayv1.RouteParentStatus{ - ParentRef: gatewayv1.ParentReference{ - Group: (*gatewayv1.Group)(&gatewayv1.GroupVersion.Group), + parents = append(parents, gwapiv1.RouteParentStatus{ + ParentRef: gwapiv1.ParentReference{ + Group: (*gwapiv1.Group)(&gwapiv1.GroupVersion.Group), Kind: &kind, - Name: gatewayv1.ObjectName(gw.Name), + Name: gwapiv1.ObjectName(gw.Name), Namespace: &ns, SectionName: listener, }, - ControllerName: gatewayv1.GatewayController(controllerName), + ControllerName: gwapiv1.GatewayController(controllerName), Conditions: []metav1.Condition{{ - Type: string(gatewayv1.RouteConditionAccepted), + Type: string(gwapiv1.RouteConditionAccepted), Status: metav1.ConditionTrue, - Reason: string(gatewayv1.RouteReasonAccepted), + Reason: string(gwapiv1.RouteReasonAccepted), }}, }) } @@ -131,7 +131,7 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con var ipAddr, port string waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, timeoutConfig.GatewayMustHaveAddress, true, func(ctx context.Context) (bool, error) { - gw := &gatewayv1.Gateway{} + gw := &gwapiv1.Gateway{} err := client.Get(ctx, gwName, gw) if err != nil { t.Logf("error fetching Gateway: %v", err) @@ -144,7 +144,7 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con } if sectionName != "" { for i, val := range gw.Spec.Listeners { - if val.Name == gatewayv1.SectionName(sectionName) { + if val.Name == gwapiv1.SectionName(sectionName) { port = strconv.FormatInt(int64(gw.Spec.Listeners[i].Port), 10) } } @@ -154,7 +154,7 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con // TODO: Support more than IPAddress for _, address := range gw.Status.Addresses { - if address.Type != nil && *address.Type == gatewayv1.IPAddressType { + if address.Type != nil && *address.Type == gwapiv1.IPAddressType { ipAddr = address.Value return true, nil } @@ -166,12 +166,12 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con return net.JoinHostPort(ipAddr, port), waitErr } -func TCPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gatewayv1.RouteParentStatus, namespaceRequired bool) { +func TCPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gwapiv1.RouteParentStatus, namespaceRequired bool) { t.Helper() - var actual []gatewayv1.RouteParentStatus + var actual []gwapiv1.RouteParentStatus waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, timeoutConfig.RouteMustHaveParents, true, func(ctx context.Context) (bool, error) { - route := &v1alpha2.TCPRoute{} + route := &gwapiv1a2.TCPRoute{} err := client.Get(ctx, routeName, route) if err != nil { return false, fmt.Errorf("error fetching HTTPRoute: %w", err) diff --git a/test/e2e/tests/udproute.go b/test/e2e/tests/udproute.go index 019d90060af..aed3258990d 100644 --- a/test/e2e/tests/udproute.go +++ b/test/e2e/tests/udproute.go @@ -23,8 +23,8 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" - gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/config" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -69,19 +69,19 @@ var UDPRouteTest = suite.ConformanceTest{ // relying on a specific api version. type GatewayRef struct { types.NamespacedName - listenerNames []*gatewayv1.SectionName + listenerNames []*gwapiv1.SectionName } // NewGatewayRef creates a GatewayRef resource. ListenerNames are optional. func NewGatewayRef(nn types.NamespacedName, listenerNames ...string) GatewayRef { - var listeners []*gatewayv1.SectionName + var listeners []*gwapiv1.SectionName if len(listenerNames) == 0 { listenerNames = append(listenerNames, "") } for _, listener := range listenerNames { - sectionName := gatewayv1.SectionName(listener) + sectionName := gwapiv1.SectionName(listener) listeners = append(listeners, §ionName) } return GatewayRef{ @@ -102,8 +102,8 @@ func GatewayAndUDPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutCon }) require.NoErrorf(t, err, "timed out waiting for Gateway address to be assigned") - ns := gatewayv1.Namespace(gw.Namespace) - kind := gatewayv1.Kind("Gateway") + ns := gwapiv1.Namespace(gw.Namespace) + kind := gwapiv1.Kind("Gateway") for _, routeNN := range routeNNs { namespaceRequired := true @@ -111,22 +111,22 @@ func GatewayAndUDPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutCon namespaceRequired = false } - var parents []gatewayv1.RouteParentStatus + var parents []gwapiv1.RouteParentStatus for _, listener := range gw.listenerNames { - parents = append(parents, gatewayv1.RouteParentStatus{ - ParentRef: gatewayv1.ParentReference{ - Group: (*gatewayv1.Group)(&gatewayv1.GroupVersion.Group), + parents = append(parents, gwapiv1.RouteParentStatus{ + ParentRef: gwapiv1.ParentReference{ + Group: (*gwapiv1.Group)(&gwapiv1.GroupVersion.Group), Kind: &kind, - Name: gatewayv1.ObjectName(gw.Name), + Name: gwapiv1.ObjectName(gw.Name), Namespace: &ns, SectionName: listener, }, - ControllerName: gatewayv1.GatewayController(controllerName), + ControllerName: gwapiv1.GatewayController(controllerName), Conditions: []metav1.Condition{ { - Type: string(gatewayv1.RouteConditionAccepted), + Type: string(gwapiv1.RouteConditionAccepted), Status: metav1.ConditionTrue, - Reason: string(gatewayv1.RouteReasonAccepted), + Reason: string(gwapiv1.RouteReasonAccepted), }, }, }) @@ -137,12 +137,12 @@ func GatewayAndUDPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutCon return gwAddr } -func UDPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gatewayv1.RouteParentStatus, namespaceRequired bool) { +func UDPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gwapiv1.RouteParentStatus, namespaceRequired bool) { t.Helper() - var actual []gatewayv1.RouteParentStatus + var actual []gwapiv1.RouteParentStatus waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, timeoutConfig.RouteMustHaveParents, true, func(ctx context.Context) (bool, error) { - route := &v1alpha2.UDPRoute{} + route := &gwapiv1a2.UDPRoute{} err := client.Get(ctx, routeName, route) if err != nil { return false, fmt.Errorf("error fetching UDPRoute: %w", err) @@ -154,7 +154,7 @@ func UDPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig c require.NoErrorf(t, waitErr, "error waiting for UDPRoute to have parents matching expectations") } -func parentsForRouteMatch(t *testing.T, routeName types.NamespacedName, expected, actual []gatewayv1.RouteParentStatus, namespaceRequired bool) bool { +func parentsForRouteMatch(t *testing.T, routeName types.NamespacedName, expected, actual []gwapiv1.RouteParentStatus, namespaceRequired bool) bool { t.Helper() if len(expected) != len(actual) { diff --git a/test/e2e/tests/utils.go b/test/e2e/tests/utils.go index c33cc9e3fc8..b0a5d24269c 100644 --- a/test/e2e/tests/utils.go +++ b/test/e2e/tests/utils.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/config" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" @@ -72,7 +72,7 @@ func WaitForPods(t *testing.T, cl client.Client, namespace string, selectors map } // SecurityPolicyMustBeAccepted waits for the specified SecurityPolicy to be accepted. -func SecurityPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwv1a2.ParentReference) { +func SecurityPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwapiv1a2.ParentReference) { t.Helper() waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { @@ -94,7 +94,7 @@ func SecurityPolicyMustBeAccepted(t *testing.T, client client.Client, policyName } // BackendTrafficPolicyMustBeAccepted waits for the specified BackendTrafficPolicy to be accepted. -func BackendTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwv1a2.ParentReference) { +func BackendTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwapiv1a2.ParentReference) { t.Helper() waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { @@ -116,7 +116,7 @@ func BackendTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, poli } // ClientTrafficPolicyMustBeAccepted waits for the specified ClientTrafficPolicy to be accepted. -func ClientTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwv1a2.ParentReference) { +func ClientTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwapiv1a2.ParentReference) { t.Helper() waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { @@ -187,11 +187,11 @@ func runLoadAndWait(t *testing.T, timeoutConfig config.TimeoutConfig, done chan done <- false } -func policyAcceptedByAncestor(ancestors []gwv1a2.PolicyAncestorStatus, controllerName string, ancestorRef gwv1a2.ParentReference) bool { +func policyAcceptedByAncestor(ancestors []gwapiv1a2.PolicyAncestorStatus, controllerName string, ancestorRef gwapiv1a2.ParentReference) bool { for _, ancestor := range ancestors { if string(ancestor.ControllerName) == controllerName && cmp.Equal(ancestor.AncestorRef, ancestorRef) { for _, condition := range ancestor.Conditions { - if condition.Type == string(gwv1a2.PolicyConditionAccepted) && condition.Status == metav1.ConditionTrue { + if condition.Type == string(gwapiv1a2.PolicyConditionAccepted) && condition.Status == metav1.ConditionTrue { return true } } @@ -201,7 +201,7 @@ func policyAcceptedByAncestor(ancestors []gwv1a2.PolicyAncestorStatus, controlle } // EnvoyExtensionPolicyMustBeAccepted waits for the specified EnvoyExtensionPolicy to be accepted. -func EnvoyExtensionPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwv1a2.ParentReference) { +func EnvoyExtensionPolicyMustBeAccepted(t *testing.T, client client.Client, policyName types.NamespacedName, controllerName string, ancestorRef gwapiv1a2.ParentReference) { t.Helper() waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { diff --git a/test/e2e/tests/wasm.go b/test/e2e/tests/wasm.go index d4a36029f3b..7211c13e943 100644 --- a/test/e2e/tests/wasm.go +++ b/test/e2e/tests/wasm.go @@ -12,8 +12,8 @@ import ( "testing" "k8s.io/apimachinery/pkg/types" - gwv1 "sigs.k8s.io/gateway-api/apis/v1" - gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -37,11 +37,11 @@ var WasmTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } EnvoyExtensionPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "http-wasm-source-test", Namespace: ns}, suite.ControllerName, ancestorRef) @@ -83,11 +83,11 @@ var WasmTest = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ancestorRef := gwv1a2.ParentReference{ - Group: gatewayapi.GroupPtr(gwv1.GroupName), + ancestorRef := gwapiv1a2.ParentReference{ + Group: gatewayapi.GroupPtr(gwapiv1.GroupName), Kind: gatewayapi.KindPtr(gatewayapi.KindGateway), Namespace: gatewayapi.NamespacePtr(gwNN.Namespace), - Name: gwv1.ObjectName(gwNN.Name), + Name: gwapiv1.ObjectName(gwNN.Name), } EnvoyExtensionPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "http-wasm-source-test", Namespace: ns}, suite.ControllerName, ancestorRef) diff --git a/tools/linter/golangci-lint/.golangci.yml b/tools/linter/golangci-lint/.golangci.yml index 10c9da6ce54..3a83d0841a4 100644 --- a/tools/linter/golangci-lint/.golangci.yml +++ b/tools/linter/golangci-lint/.golangci.yml @@ -7,6 +7,7 @@ linters: - depguard - errorlint - exportloopref + - importas - gci - gofmt - gofumpt @@ -37,6 +38,32 @@ linters-settings: desc: "use k8s.io/utils/ptr instead" - pkg: github.com/tetratelabs/multierror desc: "use errors instead" + importas: + # Do not allow unaliased imports of aliased packages. + no-unaliased: true + # Do not allow non-required aliases. + no-extra-aliases: false + alias: + # gateway-api + - pkg: sigs.k8s.io/gateway-api/apis/v1 + alias: gwapiv1 + - pkg: sigs.k8s.io/gateway-api/apis/v1alpha2 + alias: gwapiv1a2 + - pkg: sigs.k8s.io/gateway-api/apis/v1alpha3 + alias: gwapiv1a3 + - pkg: sigs.k8s.io/gateway-api/apis/v1beta1 + alias: gwapiv1b1 + - pkg: github.com/envoyproxy/gateway/api/v1alpha1 + alias: egv1a1 + # kubernetes api + - pkg: k8s.io/apimachinery/pkg/apis/meta/v1 + alias: metav1 + - pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 + alias: apiextensionsv1 + - pkg: sigs.k8s.io/mcs-api/pkg/apis/v1alpha1 + alias: mcsapiv1a1 + - pkg: k8s.io/api/(\w+)/(v[\w\d]+) + alias: $1$2 gci: sections: # Captures all standard packages if they do not match another section.