diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2ff665bcc..4c446dcb53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,8 +222,7 @@ jobs: make create-kind-cluster KIND_KUBE_CONFIG=${kube_config} echo "KUBECONFIG=${kube_config}" >> "$GITHUB_ENV" kind load docker-image ${{ steps.ngf-meta.outputs.tags }} ${{ steps.nginx-meta.outputs.tags }} - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml - kubectl wait --for=condition=complete job/gateway-api-admission-patch job/gateway-api-admission -n gateway-system + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml - name: Install Chart run: > diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index b84d35e26f..d53ad637dc 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -145,6 +145,7 @@ jobs: ngf_prefix=$(echo ${{ steps.ngf-meta.outputs.tags }} | cut -d ":" -f 1) ngf_tag=$(echo ${{ steps.ngf-meta.outputs.tags }} | cut -d ":" -f 2) if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi + if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi make install-ngf-local-no-build NGF_PREFIX=${ngf_prefix} NGF_TAG=${ngf_tag} working-directory: ./conformance diff --git a/README.md b/README.md index e806c33e75..cf92fdfc55 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,9 @@ from the main branch. The table below summarizes the options regarding the images, manifests, documentation and examples and gives your links to the correct versions: -| Version | Description | Installation Manifests | Documentation and Examples | -|----------------|------------------------------------------|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Latest release | For production use | [Manifests](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/deploy). | [Documentation](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/docs). [Examples](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/examples). | +| Version | Description | Installation Manifests | Documentation and Examples | +|----------------|------------------------------------------|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Latest release | For production use | [Manifests](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/deploy). | [Documentation](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/docs). [Examples](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/examples). | | Edge | For experimental use and latest features | [Manifests](https://github.com/nginxinc/nginx-gateway-fabric/tree/main/deploy). | [Documentation](https://github.com/nginxinc/nginx-gateway-fabric/tree/main/docs). [Examples](https://github.com/nginxinc/nginx-gateway-fabric/tree/main/examples). | ### Versioning @@ -61,15 +61,15 @@ the [Issue Lifecycle](ISSUE_LIFECYCLE.md) document for information on issue crea The following table lists the software versions NGINX Gateway Fabric supports. | NGINX Gateway Fabric | Gateway API | Kubernetes | NGINX OSS | -|--------------------------|-------------|------------|-----------| -| Edge | 0.8.1 | 1.23+ | 1.25.2 | -| 1.0.0 | 0.8.1 | 1.23+ | 1.25.2 | -| 0.6.0 | 0.8.0 | 1.23+ | 1.25.2 | -| 0.5.0 | 0.7.1 | 1.21+ | 1.25.x * | -| 0.4.0 | 0.7.1 | 1.21+ | 1.25.x * | -| 0.3.0 | 0.6.2 | 1.21+ | 1.23.x * | -| 0.2.0 | 0.5.1 | 1.21+ | 1.21.x * | -| 0.1.0 | 0.5.0 | 1.19+ | 1.21.3 | +|----------------------|-------------|------------|-----------| +| Edge | 1.0.0 | 1.23+ | 1.25.3 | +| 1.0.0 | 0.8.1 | 1.23+ | 1.25.2 | +| 0.6.0 | 0.8.0 | 1.23+ | 1.25.2 | +| 0.5.0 | 0.7.1 | 1.21+ | 1.25.x * | +| 0.4.0 | 0.7.1 | 1.21+ | 1.25.x * | +| 0.3.0 | 0.6.2 | 1.21+ | 1.23.x * | +| 0.2.0 | 0.5.1 | 1.21+ | 1.21.x * | +| 0.1.0 | 0.5.0 | 1.19+ | 1.21.3 | \*the installation manifests use the minor version of NGINX container image (e.g. 1.25) and the patch version is not specified. This means that the latest available patch version is used. diff --git a/cmd/gateway/validation.go b/cmd/gateway/validation.go index 736921d36c..103231071a 100644 --- a/cmd/gateway/validation.go +++ b/cmd/gateway/validation.go @@ -13,7 +13,7 @@ import ( const ( // nolint:lll - // Regex from: https://github.com/kubernetes-sigs/gateway-api/blob/v0.8.1/apis/v1beta1/shared_types.go#L551 + // Regex from: https://github.com/kubernetes-sigs/gateway-api/blob/v1.0.0/apis/v1/shared_types.go#L640 controllerNameRegex = `^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$` //nolint:lll ) diff --git a/conformance/Makefile b/conformance/Makefile index f61d6930a1..47078450f0 100644 --- a/conformance/Makefile +++ b/conformance/Makefile @@ -1,7 +1,7 @@ NGF_TAG = edge NGF_PREFIX = nginx-gateway-fabric NGINX_IMAGE_NAME = $(NGF_PREFIX)/nginx -GW_API_VERSION ?= 0.8.1 +GW_API_VERSION ?= 1.0.0 GATEWAY_CLASS = nginx SUPPORTED_FEATURES = HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect,GatewayClassObservedGenerationBump KIND_IMAGE ?= $(shell grep -m1 'FROM kindest/node' Note: The Gateway API resources from the standard channel (the CRDs and the validating webhook) must be installed +> **Note** +> +> The Gateway API resources from the standard channel must be installed > before deploying NGINX Gateway Fabric. If they are already installed in your cluster, please ensure they are > the correct version as supported by the NGINX Gateway Fabric - > [see the Technical Specifications](https://github.com/nginxinc/nginx-gateway-fabric/blob/main/README.md#technical-specifications). -To install the Gateway resources from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: +To install the Gateway API CRDs from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: + +```shell +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml +``` + +If you are running on Kubernetes 1.23 or 1.24, you also need to install the validating webhook. To do so, run: ```shell -kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml ``` +> **Important** +> +> The validating webhook is not needed if you are running Kubernetes 1.25+. Validation is done using CEL on the +> CRDs. See the [resource validation doc](https://github.com/nginxinc/nginx-gateway-fabric/blob/main/docs/resource-validation.md) +> for more information. + ## Installing the Chart ### Installing the Chart from the OCI Registry @@ -79,6 +93,7 @@ helm install my-release . --create-namespace --wait -n nginx-gateway ## Upgrading the Chart > **Note** +> > See [below](#configure-delayed-termination-for-zero-downtime-upgrades) for instructions on how to configure delayed > termination if required for zero downtime upgrades in your environment. @@ -87,10 +102,23 @@ helm install my-release . --create-namespace --wait -n nginx-gateway Before you upgrade a release, ensure the Gateway API resources are the correct version as supported by the NGINX Gateway Fabric - [see the Technical Specifications](../../README.md#technical-specifications).: -To upgrade the Gateway resources from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: +To upgrade the Gateway CRDs from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: + +```shell +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml +``` + +If you are running on Kubernetes 1.23 or 1.24, you also need to update the validating webhook. To do so, run: + +```shell +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml +``` + +If you are running on Kubernetes 1.25 or newer and have the validating webhook installed, you should remove the +webhook. To do so, run: ```shell -kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml +kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml ``` ### Upgrading the CRDs @@ -134,6 +162,7 @@ To achieve zero downtime upgrades (meaning clients will not see any interruption being performed on NGF), you may need to configure delayed termination on the NGF Pod, depending on your environment. > **Note** +> > When proxying Websocket or any long-lived connections, NGINX will not terminate until that connection is closed > by either the client or the backend. This means that unless all those connections are closed by clients/backends > before or during an upgrade, NGINX will not terminate, which means Kubernetes will kill NGINX. As a result, the @@ -172,6 +201,7 @@ being performed on NGF), you may need to configure delayed termination on the NG ``` > **Note** +> > More information on container lifecycle hooks can be found > [here](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks) and a detailed > description of Pod termination behavior can be found in @@ -195,49 +225,55 @@ These commands remove all the Kubernetes components associated with the release Please ensure there are no custom resources that you want to keep and there are no other Gateway API implementations running in the cluster!** -To delete the Gateway resources using [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: +To delete the Gateway API CRDs from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: + +```shell +kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml +``` + +If you are running on Kubernetes 1.23 or 1.24, you also need to delete the validating webhook. To do so, run: ```shell -kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml +kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml ``` ## Configuration The following tables lists the configurable parameters of the NGINX Gateway Fabric chart and their default values. -| Parameter | Description | Default Value | -|---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| -| `nginxGateway.image.repository` | The repository for the NGINX Gateway Fabric image. | ghcr.io/nginxinc/nginx-gateway-fabric | +| Parameter | Description | Default Value | +|---------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| +| `nginxGateway.image.repository` | The repository for the NGINX Gateway Fabric image. | ghcr.io/nginxinc/nginx-gateway-fabric | | `nginxGateway.image.tag` | The tag for the NGINX Gateway Fabric image. | edge | | `nginxGateway.image.pullPolicy` | The `imagePullPolicy` for the NGINX Gateway Fabric image. | Always | -| `nginxGateway.lifecycle` | The `lifecycle` of the nginx-gateway container. | {} | -| `nginxGateway.extraVolumeMounts` | Extra `volumeMounts` for the nginxGateway container. | {} | +| `nginxGateway.lifecycle` | The `lifecycle` of the nginx-gateway container. | {} | +| `nginxGateway.extraVolumeMounts` | Extra `volumeMounts` for the nginxGateway container. | {} | | `nginxGateway.gatewayClassName` | The name of the GatewayClass for the NGINX Gateway Fabric deployment. | nginx | -| `nginxGateway.gatewayControllerName` | The name of the Gateway controller. The controller name must be of the form: DOMAIN/PATH. The controller's domain is gateway.nginx.org. | gateway.nginx.org/nginx-gateway-controller | +| `nginxGateway.gatewayControllerName` | The name of the Gateway controller. The controller name must be of the form: DOMAIN/PATH. The controller's domain is gateway.nginx.org. | gateway.nginx.org/nginx-gateway-controller | | `nginxGateway.kind` | The kind of the NGINX Gateway Fabric installation - currently, only Deployment is supported. | deployment | -| `nginxGateway.config` | The dynamic configuration for the control plane that is contained in the NginxGateway resource | [See nginxGateway.config section](values.yaml) | -| `nginxGateway.readinessProbe.enable` | Enable the /readyz endpoint on the control plane. | true | -| `nginxGateway.readinessProbe.port` | Port in which the readiness endpoint is exposed. | 8081 | -| `nginxGateway.readinessProbe.initialDelaySeconds` | The number of seconds after the Pod has started before the readiness probes are initiated. | 3 | +| `nginxGateway.config` | The dynamic configuration for the control plane that is contained in the NginxGateway resource | [See nginxGateway.config section](values.yaml) | +| `nginxGateway.readinessProbe.enable` | Enable the /readyz endpoint on the control plane. | true | +| `nginxGateway.readinessProbe.port` | Port in which the readiness endpoint is exposed. | 8081 | +| `nginxGateway.readinessProbe.initialDelaySeconds` | The number of seconds after the Pod has started before the readiness probes are initiated. | 3 | | `nginxGateway.replicaCount` | The number of replicas of the NGINX Gateway Fabric Deployment. | 1 | | `nginxGateway.leaderElection.enable` | Enable leader election. Leader election is used to avoid multiple replicas of the NGINX Gateway Fabric reporting the status of the Gateway API resources. | true | -| `nginxGateway.leaderElection.lockName` | The name of the leader election lock. A Lease object with this name will be created in the same Namespace as the controller. | Autogenerated | -| `nginx.image.repository` | The repository for the NGINX image. | ghcr.io/nginxinc/nginx-gateway-fabric/nginx | -| `nginx.image.tag` | The tag for the NGINX image. | edge | -| `nginx.image.pullPolicy` | The `imagePullPolicy` for the NGINX image. | Always | -| `nginx.lifecycle` | The `lifecycle` of the nginx container. | {} | +| `nginxGateway.leaderElection.lockName` | The name of the leader election lock. A Lease object with this name will be created in the same Namespace as the controller. | Autogenerated | +| `nginx.image.repository` | The repository for the NGINX image. | ghcr.io/nginxinc/nginx-gateway-fabric/nginx | +| `nginx.image.tag` | The tag for the NGINX image. | edge | +| `nginx.image.pullPolicy` | The `imagePullPolicy` for the NGINX image. | Always | +| `nginx.lifecycle` | The `lifecycle` of the nginx container. | {} | | `nginx.extraVolumeMounts` | Extra `volumeMounts` for the nginx container. | {} | -| `terminationGracePeriodSeconds` | The termination grace period of the NGINX Gateway Fabric pod. | 30 | -| `tolerations` | The `tolerations` of the NGINX Gateway Fabric pod. | [] | -| `affinity` | The `affinity` of the NGINX Gateway Fabric pod. | {} | +| `terminationGracePeriodSeconds` | The termination grace period of the NGINX Gateway Fabric pod. | 30 | +| `tolerations` | The `tolerations` of the NGINX Gateway Fabric pod. | [] | +| `affinity` | The `affinity` of the NGINX Gateway Fabric pod. | {} | | `serviceAccount.annotations` | The `annotations` for the ServiceAccount used by the NGINX Gateway Fabric deployment. | {} | | `serviceAccount.name` | Name of the ServiceAccount used by the NGINX Gateway Fabric deployment. | Autogenerated | | `service.create` | Creates a service to expose the NGINX Gateway Fabric pods. | true | | `service.type` | The type of service to create for the NGINX Gateway Fabric. | Loadbalancer | -| `service.externalTrafficPolicy` | The `externalTrafficPolicy` of the service. The value `Local` preserves the client source IP. | Local | +| `service.externalTrafficPolicy` | The `externalTrafficPolicy` of the service. The value `Local` preserves the client source IP. | Local | | `service.annotations` | The `annotations` of the NGINX Gateway Fabric service. | {} | | `service.ports` | A list of ports to expose through the NGINX Gateway Fabric service. Update it to match the listener ports from your Gateway resource. Follows the conventional Kubernetes yaml syntax for service ports. | [ port: 80, targetPort: 80, protocol: TCP, name: http; port: 443, targetPort: 443, protocol: TCP, name: https ] | -| `metrics.disable` | Disable exposing metrics in the Prometheus format. | false | -| `metrics.port` | Set the port where the Prometheus metrics are exposed. Format: [1024 - 65535] | 9113 | -| `metrics.secure` | Enable serving metrics via https. By default metrics are served via http. Please note that this endpoint will be secured with a self-signed certificate. | false | -| `extraVolumes` | Extra `volumes` for the NGINX Gateway Fabric pod. | [] | +| `metrics.disable` | Disable exposing metrics in the Prometheus format. | false | +| `metrics.port` | Set the port where the Prometheus metrics are exposed. Format: [1024 - 65535] | 9113 | +| `metrics.secure` | Enable serving metrics via https. By default metrics are served via http. Please note that this endpoint will be secured with a self-signed certificate. | false | +| `extraVolumes` | Extra `volumes` for the NGINX Gateway Fabric pod. | [] | diff --git a/deploy/helm-chart/templates/gatewayclass.yaml b/deploy/helm-chart/templates/gatewayclass.yaml index b1288ba38b..9bb6a01c17 100644 --- a/deploy/helm-chart/templates/gatewayclass.yaml +++ b/deploy/helm-chart/templates/gatewayclass.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: name: {{ .Values.nginxGateway.gatewayClassName }} diff --git a/deploy/manifests/nginx-gateway.yaml b/deploy/manifests/nginx-gateway.yaml index 045c81c679..48e1f6accf 100644 --- a/deploy/manifests/nginx-gateway.yaml +++ b/deploy/manifests/nginx-gateway.yaml @@ -234,7 +234,7 @@ spec: emptyDir: {} --- # Source: nginx-gateway-fabric/templates/gatewayclass.yaml -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: name: nginx diff --git a/design/control-data-plane-separation/design.md b/design/control-data-plane-separation/design.md index 655aa06b7c..ccd8be3a53 100644 --- a/design/control-data-plane-separation/design.md +++ b/design/control-data-plane-separation/design.md @@ -676,7 +676,7 @@ the `CommandChannel` in a `NginxConfigResponse` message. [config-descriptor]:https://github.com/nginx/agent/blob/ea3a1b4df5d7ecf95bd3d9297d26e420f5e1dd57/sdk/proto/config.pb.go#L81 -[gw-tls-config]: https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io%2fv1beta1.GatewayTLSConfig +[gw-tls-config]: https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.GatewayTLSConfig [sds]: https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret diff --git a/design/resource-validation.md b/design/resource-validation.md index 5e1b441e84..bd774158aa 100644 --- a/design/resource-validation.md +++ b/design/resource-validation.md @@ -99,7 +99,7 @@ We will introduce two validation methods to be run by NGF control plane: ### Re-run of Webhook Validation Before processing a resource, NGF will validate it using the functions from -the [validation package](https://github.com/kubernetes-sigs/gateway-api/tree/b241afc88e68c952cc0a59a5c72a51358dc2bada/apis/v1beta1/validation) +the [validation package](https://github.com/kubernetes-sigs/gateway-api/tree/fa4b0a519b30a33b205ac0256876afc1456f2dd3/apis/v1/validation) from the Gateway API. This will ensure that the webhook validation cannot be bypassed (it can be bypassed if the webhook is not installed, misconfigured, or running a different version), and it will allow us to avoid repeating the same validation in our code. diff --git a/docs/developer/logging-guidelines.md b/docs/developer/logging-guidelines.md index dfda385fdf..9948011b5e 100644 --- a/docs/developer/logging-guidelines.md +++ b/docs/developer/logging-guidelines.md @@ -188,7 +188,7 @@ The next section shows how to add context. ```go // hr implements client.Object (controller-runtime) - // hr is *v1beta1.HTTPRoute + // hr is *v1.HTTPRoute logger.Info( "Processed resource", "resource", hr, @@ -196,7 +196,7 @@ The next section shows how to add context. ``` ```json - {"level":"info","ts":"2023-07-20T15:10:03-04:00","msg":"Processed resource","resource":{"apiVersion":"gateway.networking.k8s.io/v1beta1","kind":"HTTPRoute","namespace":"test","name":"hr-1"}} + {"level":"info","ts":"2023-07-20T15:10:03-04:00","msg":"Processed resource","resource":{"apiVersion":"gateway.networking.k8s.io/v1","kind":"HTTPRoute","namespace":"test","name":"hr-1"}} ``` > The resource must include `TypeMeta`, otherwise its `apiVersion` and `kind` will not be printed. @@ -276,7 +276,7 @@ For the developer, log messages are formatted as text strings (except key/values example: ```text -2023-07-21T12:41:37.640-0400 INFO Processed resource {"resource": {"apiVersion": "gateway.networking.k8s.io/v1beta1", "kind": "HTTPRoute", "namespace": "test", "name": "hr-1"}} +2023-07-21T12:41:37.640-0400 INFO Processed resource {"resource": {"apiVersion": "gateway.networking.k8s.io/v1", "kind": "HTTPRoute", "namespace": "test", "name": "hr-1"}} ``` The formatting is controlled during the logger initialization. diff --git a/docs/developer/quickstart.md b/docs/developer/quickstart.md index b02b37517d..8276761ea6 100644 --- a/docs/developer/quickstart.md +++ b/docs/developer/quickstart.md @@ -84,10 +84,10 @@ This will build the docker images `nginx-gateway-fabric:` and `nginx- kind load docker-image nginx-gateway-fabric:$(whoami) nginx-gateway-fabric/nginx:$(whoami) ``` -3. Install Gateway API Resources +3. Install Gateway API CRDs: ```shell - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml ``` 4. Install NGF using your custom image and expose NGF with a NodePort Service: diff --git a/docs/gateway-api-compatibility.md b/docs/gateway-api-compatibility.md index 32eb1a7703..32380fbaa1 100644 --- a/docs/gateway-api-compatibility.md +++ b/docs/gateway-api-compatibility.md @@ -6,9 +6,9 @@ This document describes which Gateway API resources NGINX Gateway Fabric support | Resource | Core Support Level | Extended Support Level | Implementation-Specific Support Level | API Version | |-------------------------------------|--------------------|------------------------|---------------------------------------|-------------| -| [GatewayClass](#gatewayclass) | Supported | Not supported | Not Supported | v1beta1 | -| [Gateway](#gateway) | Supported | Not supported | Not Supported | v1beta1 | -| [HTTPRoute](#httproute) | Supported | Partially supported | Not Supported | v1beta1 | +| [GatewayClass](#gatewayclass) | Supported | Not supported | Not Supported | v1 | +| [Gateway](#gateway) | Supported | Not supported | Not Supported | v1 | +| [HTTPRoute](#httproute) | Supported | Partially supported | Not Supported | v1 | | [ReferenceGrant](#referencegrant) | Supported | N/A | Not Supported | v1beta1 | | [Custom policies](#custom-policies) | Not supported | N/A | Not Supported | N/A | | [TLSRoute](#tlsroute) | Not supported | Not supported | Not Supported | N/A | diff --git a/docs/guides/advanced-routing.md b/docs/guides/advanced-routing.md index 6ddba9249b..81f67fdf06 100644 --- a/docs/guides/advanced-routing.md +++ b/docs/guides/advanced-routing.md @@ -46,7 +46,7 @@ The [Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/) resource is ty ```yaml kubectl apply -f - < Note: By default, NGINX Gateway Fabric (NGF) will be installed into the nginx-gateway Namespace. +> **Note** +> +> By default, NGINX Gateway Fabric (NGF) will be installed into the nginx-gateway Namespace. > It is possible to run NGF in a different Namespace, although you'll need to make modifications to the installation > manifests. -1. Install the Gateway API resources from the standard channel (the CRDs and the validating webhook): +1. To install the Gateway API CRDs from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: - ```shell - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml - ``` + ```shell + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml + ``` + + If you are running on Kubernetes 1.23 or 1.24, you also need to install the validating webhook. To do so, run: + + ```shell + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml + ``` -1. Deploy the NGINX Gateway Fabric CRDs: + > **Important** + > + > The validating webhook is not needed if you are running Kubernetes 1.25+. Validation is done using CEL on the + > CRDs. See the [resource validation doc](https://github.com/nginxinc/nginx-gateway-fabric/blob/main/docs/resource-validation.md) + > for more information. + +2. Deploy the NGINX Gateway Fabric CRDs: ```shell kubectl apply -f https://github.com/nginxinc/nginx-gateway-fabric/releases/download/v1.0.0/crds.yaml ``` -1. Deploy the NGINX Gateway Fabric: +3. Deploy the NGINX Gateway Fabric: ```shell kubectl apply -f https://github.com/nginxinc/nginx-gateway-fabric/releases/download/v1.0.0/nginx-gateway.yaml ``` -1. Confirm the NGINX Gateway Fabric is running in `nginx-gateway` namespace: +4. Confirm the NGINX Gateway Fabric is running in `nginx-gateway` namespace: ```shell kubectl get pods -n nginx-gateway @@ -70,8 +84,9 @@ This Service must live in the same Namespace as the controller. The name of this the `--service` argument to the controller. > **Important** +> > The Service manifests expose NGINX Gateway Fabric on ports 80 and 443, which exposes any -> Gateway [Listener](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.Listener) +> Gateway [Listener](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1.Listener) > configured for those ports. If you'd like to use different ports in your listeners, > update the manifests accordingly. > @@ -134,6 +149,7 @@ Create a Service with type `LoadBalancer` using the appropriate manifest for you ## Upgrading NGINX Gateway Fabric > **Note** +> > See [below](#configure-delayed-termination-for-zero-downtime-upgrades) for instructions on how to configure delayed > termination if required for zero downtime upgrades in your environment. @@ -141,19 +157,32 @@ Create a Service with type `LoadBalancer` using the appropriate manifest for you 1. Upgrade the Gateway Resources - Before you upgrade, ensure the Gateway API resources are the correct version as supported by the NGINX Gateway - Fabric - [see the Technical Specifications](/README.md#technical-specifications). - The [release notes](https://github.com/kubernetes-sigs/gateway-api/releases/tag/v0.8.1) of the new version of the - Gateway API might include important upgrade-specific notes and instructions. We advise to check the release notes of - all versions between the one you're using and the new one. + Before you upgrade, ensure the Gateway API resources are the correct version as supported by the NGINX Gateway + Fabric - [see the Technical Specifications](/README.md#technical-specifications). + The [release notes](https://github.com/kubernetes-sigs/gateway-api/releases/tag/v1.0.0) of the new version of the + Gateway API might include important upgrade-specific notes and instructions. We advise to check the release notes of + all versions between the one you're using and the new one. - To upgrade the Gateway resources from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: + To upgrade the Gateway CRDs from [the Gateway API repo](https://github.com/kubernetes-sigs/gateway-api), run: ```shell - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml ``` -1. Upgrade the NGINX Gateway Fabric CRDs + If you are running on Kubernetes 1.23 or 1.24, you also need to update the validating webhook. To do so, run: + + ```shell + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml + ``` + + If you are running on Kubernetes 1.25 or newer and have the validating webhook installed, you should remove the + webhook. To do so, run: + + ```shell + kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml + ``` + +2. Upgrade the NGINX Gateway Fabric CRDs Run the following command to upgrade the NGINX Gateway Fabric CRDs: @@ -161,7 +190,7 @@ Create a Service with type `LoadBalancer` using the appropriate manifest for you kubectl apply -f https://github.com/nginxinc/nginx-gateway-fabric/releases/download/v1.0.0/crds.yaml ``` -1. Upgrade NGINX Gateway Fabric Deployment +3. Upgrade NGINX Gateway Fabric Deployment Run the following command to upgrade NGINX Gateway Fabric: @@ -180,6 +209,7 @@ To achieve zero downtime upgrades (meaning clients will not see any interruption being performed on NGF), you may need to configure delayed termination on the NGF Pod, depending on your environment. > **Note** +> > When proxying Websocket or any long-lived connections, NGINX will not terminate until that connection is closed > by either the client or the backend. This means that unless all those connections are closed by clients/backends > before or during an upgrade, NGINX will not terminate, which means Kubernetes will kill NGINX. As a result, the @@ -218,6 +248,7 @@ Edit the `nginx-gateway.yaml` to include the following: is 30). This is to ensure Kubernetes does not terminate the Pod before the `preStopHook` is complete. > **Note** +> > More information on container lifecycle hooks can be found > [here](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks) and a detailed > description of Pod termination behavior can be found in @@ -242,15 +273,23 @@ To configure delayed termination on the NGF Pod when the deployment method is He kubectl delete -f https://github.com/nginxinc/nginx-gateway-fabric/releases/download/v1.0.0/crds.yaml ``` -1. Uninstall the Gateway API resources from the standard channel (the CRDs and the validating webhook): +2. Uninstall the Gateway API CRDs: - >**Warning: This command will delete all the corresponding custom resources in your cluster across all namespaces! - Please ensure there are no custom resources that you want to keep and there are no other Gateway API implementations - running in the cluster!** + >**Warning** + > + > This command will delete all the corresponding custom resources in your cluster across all namespaces! + > Please ensure there are no custom resources that you want to keep and there are no other Gateway API + > implementations running in the cluster! - ```shell - kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml - ``` + ```shell + kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml + ``` + + If you are running on Kubernetes 1.23 or 1.24, you also need to delete the validating webhook. To do so, run: + + ```shell + kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/webhook-install.yaml + ``` ### Uninstall NGINX Gateway Fabric using Helm diff --git a/examples/advanced-routing/cafe-routes.yaml b/examples/advanced-routing/cafe-routes.yaml index 6cc3039f99..7430ca1a0e 100644 --- a/examples/advanced-routing/cafe-routes.yaml +++ b/examples/advanced-routing/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -32,7 +32,7 @@ spec: - name: coffee-v2-svc port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/examples/advanced-routing/gateway.yaml b/examples/advanced-routing/gateway.yaml index 1d029ef08a..794b1825f5 100644 --- a/examples/advanced-routing/gateway.yaml +++ b/examples/advanced-routing/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: cafe diff --git a/examples/cafe-example/cafe-routes.yaml b/examples/cafe-example/cafe-routes.yaml index 1fd9e95a88..67927335cb 100644 --- a/examples/cafe-example/cafe-routes.yaml +++ b/examples/cafe-example/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -17,7 +17,7 @@ spec: - name: coffee port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/examples/cafe-example/gateway.yaml b/examples/cafe-example/gateway.yaml index 81601058c4..e6507f613b 100644 --- a/examples/cafe-example/gateway.yaml +++ b/examples/cafe-example/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/examples/cross-namespace-routing/cafe-routes.yaml b/examples/cross-namespace-routing/cafe-routes.yaml index 6f78c36803..2f669cf057 100644 --- a/examples/cross-namespace-routing/cafe-routes.yaml +++ b/examples/cross-namespace-routing/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -18,7 +18,7 @@ spec: namespace: cafe port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/examples/cross-namespace-routing/gateway.yaml b/examples/cross-namespace-routing/gateway.yaml index 81601058c4..e6507f613b 100644 --- a/examples/cross-namespace-routing/gateway.yaml +++ b/examples/cross-namespace-routing/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/examples/http-header-filter/echo-route.yaml b/examples/http-header-filter/echo-route.yaml index b92357128a..43ed5d52db 100644 --- a/examples/http-header-filter/echo-route.yaml +++ b/examples/http-header-filter/echo-route.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: headers diff --git a/examples/http-header-filter/gateway.yaml b/examples/http-header-filter/gateway.yaml index 03566e3f99..9d402bd5a1 100644 --- a/examples/http-header-filter/gateway.yaml +++ b/examples/http-header-filter/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/examples/https-termination/README.md b/examples/https-termination/README.md index 1fc37dab3c..6539b79758 100644 --- a/examples/https-termination/README.md +++ b/examples/https-termination/README.md @@ -81,7 +81,7 @@ reference a Secret in a different Namespace. To configure HTTPS termination for our cafe application, we will bind our `coffee` and `tea` HTTPRoutes to the `https` listener in [cafe-routes.yaml](./cafe-routes.yaml) using - the [`parentReference`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.ParentReference) + the [`parentReference`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1.ParentReference) field: ```yaml @@ -91,7 +91,7 @@ reference a Secret in a different Namespace. ``` To configure an HTTPS redirect from port 80 to 443, we will bind the special `cafe-tls-redirect` HTTPRoute with - a [`HTTPRequestRedirectFilter`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.HTTPRequestRedirectFilter) + a [`HTTPRequestRedirectFilter`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1.HTTPRequestRedirectFilter) to the `http` listener: ```yaml diff --git a/examples/https-termination/cafe-routes.yaml b/examples/https-termination/cafe-routes.yaml index 1940c76bf3..4c3b5ec633 100644 --- a/examples/https-termination/cafe-routes.yaml +++ b/examples/https-termination/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: cafe-tls-redirect @@ -15,7 +15,7 @@ spec: scheme: https port: 443 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -34,7 +34,7 @@ spec: - name: coffee port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/examples/https-termination/gateway.yaml b/examples/https-termination/gateway.yaml index 2c5f187068..d7ccb278d7 100644 --- a/examples/https-termination/gateway.yaml +++ b/examples/https-termination/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/examples/traffic-splitting/cafe-route-equal-weight.yaml b/examples/traffic-splitting/cafe-route-equal-weight.yaml index f979034e4c..1319e84798 100644 --- a/examples/traffic-splitting/cafe-route-equal-weight.yaml +++ b/examples/traffic-splitting/cafe-route-equal-weight.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: cafe-route diff --git a/examples/traffic-splitting/cafe-route.yaml b/examples/traffic-splitting/cafe-route.yaml index b25cf71d9b..5b715a7590 100644 --- a/examples/traffic-splitting/cafe-route.yaml +++ b/examples/traffic-splitting/cafe-route.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: cafe-route diff --git a/examples/traffic-splitting/gateway.yaml b/examples/traffic-splitting/gateway.yaml index 03566e3f99..9d402bd5a1 100644 --- a/examples/traffic-splitting/gateway.yaml +++ b/examples/traffic-splitting/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/go.mod b/go.mod index cf462530be..7ac5183946 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( k8s.io/client-go v0.28.3 sigs.k8s.io/controller-runtime v0.16.3 sigs.k8s.io/controller-tools v0.13.0 - sigs.k8s.io/gateway-api v0.8.1 + sigs.k8s.io/gateway-api v1.0.0 sigs.k8s.io/yaml v1.4.0 ) @@ -29,14 +29,14 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect + github.com/evanphx/json-patch v5.7.0+incompatible // indirect + github.com/evanphx/json-patch/v5 v5.7.0 // indirect github.com/fatih/color v1.15.0 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/zapr v1.2.4 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gobuffalo/flect v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -45,15 +45,15 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/imdario/mergo v0.3.6 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/moby/spdystream v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -61,23 +61,23 @@ require ( github.com/nginxinc/nginx-plus-go-client v0.10.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.1 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.8.4 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.8.0 // indirect + golang.org/x/oauth2 v0.13.0 // indirect golang.org/x/sys v0.14.0 // indirect golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.14.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -85,8 +85,8 @@ require ( k8s.io/apiextensions-apiserver v0.28.3 // indirect k8s.io/component-base v0.28.3 // indirect k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect ) diff --git a/go.sum b/go.sum index 16041dac8b..34a1d88b95 100644 --- a/go.sum +++ b/go.sum @@ -15,26 +15,28 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= +github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= +github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.7.0 h1:nJqP7uwL84RJInrohHfW0Fx3awjbm8qZeFv0nW9SYGc= +github.com/evanphx/json-patch/v5 v5.7.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= github.com/go-logr/zapr v1.2.4/go.mod h1:FyHWQIzQORZ0QVE1BtVHv3cKtNLuXsbNLtpuhNapBOA= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= +github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= @@ -43,9 +45,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= @@ -59,15 +60,14 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= +github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -89,8 +89,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/maxbrunsfeld/counterfeiter/v6 v6.7.0 h1:z0CfPybq3CxaJvrrpf7Gme1psZTqHhJxf83q6apkSpI= github.com/maxbrunsfeld/counterfeiter/v6 v6.7.0/go.mod h1:RVP6/F85JyxTrbJxWIdKU2vlSvK48iCMnMXRkSz7xtg= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= @@ -121,12 +121,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= -github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM= -github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= -github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -150,6 +150,7 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= @@ -163,30 +164,33 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= -golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= +golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -196,16 +200,20 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= @@ -216,6 +224,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -224,8 +233,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= @@ -256,19 +265,19 @@ k8s.io/component-base v0.28.3 h1:rDy68eHKxq/80RiMb2Ld/tbH8uAE75JdCqJyi6lXMzI= k8s.io/component-base v0.28.3/go.mod h1:fDJ6vpVNSk6cRo5wmDa6eKIG7UlIQkaFmZN2fYgIUD8= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= sigs.k8s.io/controller-tools v0.13.0 h1:NfrvuZ4bxyolhDBt/rCZhDnx3M2hzlhgo5n3Iv2RykI= sigs.k8s.io/controller-tools v0.13.0/go.mod h1:5vw3En2NazbejQGCeWKRrE7q4P+CW8/klfVqP8QZkgA= -sigs.k8s.io/gateway-api v0.8.1 h1:Bo4NMAQFYkQZnHXOfufbYwbPW7b3Ic5NjpbeW6EJxuU= -sigs.k8s.io/gateway-api v0.8.1/go.mod h1:0PteDrsrgkRmr13nDqFWnev8tOysAVrwnvfFM55tSVg= +sigs.k8s.io/gateway-api v1.0.0 h1:iPTStSv41+d9p0xFydll6d7f7MOBGuqXM6p2/zVYMAs= +sigs.k8s.io/gateway-api v1.0.0/go.mod h1:4cUgr0Lnp5FZ0Cdq8FdRwCvpiWws7LVhLHGIudLlf4c= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/framework/conditions/conditions.go b/internal/framework/conditions/conditions.go index 8e37e20617..2dfc21fdf7 100644 --- a/internal/framework/conditions/conditions.go +++ b/internal/framework/conditions/conditions.go @@ -2,7 +2,7 @@ package conditions import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) const ( @@ -10,7 +10,7 @@ const ( // that reference this controller, and we ignored the resource in question and picked the // GatewayClass that is referenced in the command-line argument. // This reason is used with GatewayClassConditionAccepted (false). - GatewayClassReasonGatewayClassConflict v1beta1.GatewayClassConditionReason = "GatewayClassConflict" + GatewayClassReasonGatewayClassConflict v1.GatewayClassConditionReason = "GatewayClassConflict" // GatewayClassMessageGatewayClassConflict is a message that describes GatewayClassReasonGatewayClassConflict. GatewayClassMessageGatewayClassConflict = "The resource is ignored due to a conflicting GatewayClass resource" @@ -28,9 +28,9 @@ type Condition struct { func NewDefaultGatewayClassConditions() []Condition { return []Condition{ { - Type: string(v1beta1.GatewayClassConditionStatusAccepted), + Type: string(v1.GatewayClassConditionStatusAccepted), Status: metav1.ConditionTrue, - Reason: string(v1beta1.GatewayClassReasonAccepted), + Reason: string(v1.GatewayClassReasonAccepted), Message: "GatewayClass is accepted", }, } @@ -40,7 +40,7 @@ func NewDefaultGatewayClassConditions() []Condition { // due to a conflict with another GatewayClass. func NewGatewayClassConflict() Condition { return Condition{ - Type: string(v1beta1.GatewayClassConditionStatusAccepted), + Type: string(v1.GatewayClassConditionStatusAccepted), Status: metav1.ConditionFalse, Reason: string(GatewayClassReasonGatewayClassConflict), Message: GatewayClassMessageGatewayClassConflict, diff --git a/internal/framework/controller/predicate/gatewayclass.go b/internal/framework/controller/predicate/gatewayclass.go index 1a69d86d2a..3e915b0117 100644 --- a/internal/framework/controller/predicate/gatewayclass.go +++ b/internal/framework/controller/predicate/gatewayclass.go @@ -3,7 +3,7 @@ package predicate import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) // GatewayClassPredicate implements a predicate function based on the controllerName of a GatewayClass. @@ -19,7 +19,7 @@ func (gcp GatewayClassPredicate) Create(e event.CreateEvent) bool { return false } - gc, ok := e.Object.(*v1beta1.GatewayClass) + gc, ok := e.Object.(*v1.GatewayClass) if !ok { return false } @@ -30,14 +30,14 @@ func (gcp GatewayClassPredicate) Create(e event.CreateEvent) bool { // Update implements default UpdateEvent filter for validating a GatewayClass controllerName. func (gcp GatewayClassPredicate) Update(e event.UpdateEvent) bool { if e.ObjectOld != nil { - gcOld, ok := e.ObjectOld.(*v1beta1.GatewayClass) + gcOld, ok := e.ObjectOld.(*v1.GatewayClass) if ok && string(gcOld.Spec.ControllerName) == gcp.ControllerName { return true } } if e.ObjectNew != nil { - gcNew, ok := e.ObjectNew.(*v1beta1.GatewayClass) + gcNew, ok := e.ObjectNew.(*v1.GatewayClass) if ok && string(gcNew.Spec.ControllerName) == gcp.ControllerName { return true } diff --git a/internal/framework/controller/predicate/gatewayclass_test.go b/internal/framework/controller/predicate/gatewayclass_test.go index b2814c6fcf..be5c8c32c0 100644 --- a/internal/framework/controller/predicate/gatewayclass_test.go +++ b/internal/framework/controller/predicate/gatewayclass_test.go @@ -5,7 +5,7 @@ import ( . "github.com/onsi/gomega" "sigs.k8s.io/controller-runtime/pkg/event" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) func TestGatewayClassPredicate(t *testing.T) { @@ -13,8 +13,8 @@ func TestGatewayClassPredicate(t *testing.T) { p := GatewayClassPredicate{ControllerName: "nginx-ctlr"} - gc := &v1beta1.GatewayClass{ - Spec: v1beta1.GatewayClassSpec{ + gc := &v1.GatewayClass{ + Spec: v1.GatewayClassSpec{ ControllerName: "nginx-ctlr", }, } @@ -22,8 +22,8 @@ func TestGatewayClassPredicate(t *testing.T) { g.Expect(p.Create(event.CreateEvent{Object: gc})).To(BeTrue()) g.Expect(p.Update(event.UpdateEvent{ObjectNew: gc})).To(BeTrue()) - gc2 := &v1beta1.GatewayClass{ - Spec: v1beta1.GatewayClassSpec{ + gc2 := &v1.GatewayClass{ + Spec: v1.GatewayClassSpec{ ControllerName: "unknown", }, } diff --git a/internal/framework/controller/reconciler.go b/internal/framework/controller/reconciler.go index 7d7f84115f..43a5ac2002 100644 --- a/internal/framework/controller/reconciler.go +++ b/internal/framework/controller/reconciler.go @@ -50,7 +50,7 @@ func NewReconciler(cfg ReconcilerConfig) *Reconciler { } func newObject(objectType client.Object) client.Object { - // without Elem(), t will be a pointer to the type. For example, *v1beta1.Gateway, not v1beta1.Gateway + // without Elem(), t will be a pointer to the type. For example, *v1.Gateway, not v1.Gateway t := reflect.TypeOf(objectType).Elem() // We could've used objectType.DeepCopyObject() here, but it's a bit slower confirmed by benchmarks. diff --git a/internal/framework/controller/reconciler_test.go b/internal/framework/controller/reconciler_test.go index 120a40a2ee..af7fe7af7e 100644 --- a/internal/framework/controller/reconciler_test.go +++ b/internal/framework/controller/reconciler_test.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/controllerfakes" @@ -37,7 +37,7 @@ var _ = Describe("Reconciler", func() { Name: "hr-1", } - hr1 = &v1beta1.HTTPRoute{ + hr1 = &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: hr1NsName.Namespace, Name: hr1NsName.Name, @@ -49,7 +49,7 @@ var _ = Describe("Reconciler", func() { Name: "hr-2", } - hr2 = &v1beta1.HTTPRoute{ + hr2 = &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: hr2NsName.Namespace, Name: hr2NsName.Name, @@ -57,30 +57,30 @@ var _ = Describe("Reconciler", func() { } ) - getReturnsHRForHR := func(hr *v1beta1.HTTPRoute) getFunc { + getReturnsHRForHR := func(hr *v1.HTTPRoute) getFunc { return func( ctx context.Context, nsname types.NamespacedName, object client.Object, option ...client.GetOption, ) error { - Expect(object).To(BeAssignableToTypeOf(&v1beta1.HTTPRoute{})) + Expect(object).To(BeAssignableToTypeOf(&v1.HTTPRoute{})) Expect(nsname).To(Equal(client.ObjectKeyFromObject(hr))) - hr.DeepCopyInto(object.(*v1beta1.HTTPRoute)) + hr.DeepCopyInto(object.(*v1.HTTPRoute)) return nil } } - getReturnsNotFoundErrorForHR := func(hr *v1beta1.HTTPRoute) getFunc { + getReturnsNotFoundErrorForHR := func(hr *v1.HTTPRoute) getFunc { return func( ctx context.Context, nsname types.NamespacedName, object client.Object, option ...client.GetOption, ) error { - Expect(object).To(BeAssignableToTypeOf(&v1beta1.HTTPRoute{})) + Expect(object).To(BeAssignableToTypeOf(&v1.HTTPRoute{})) Expect(nsname).To(Equal(client.ObjectKeyFromObject(hr))) return apierrors.NewNotFound(schema.GroupResource{}, "not found") @@ -112,7 +112,7 @@ var _ = Describe("Reconciler", func() { }) Describe("Normal cases", func() { - testUpsert := func(hr *v1beta1.HTTPRoute) { + testUpsert := func(hr *v1.HTTPRoute) { fakeGetter.GetCalls(getReturnsHRForHR(hr)) resultCh := startReconciling(client.ObjectKeyFromObject(hr)) @@ -121,14 +121,14 @@ var _ = Describe("Reconciler", func() { Eventually(resultCh).Should(Receive(Equal(result{err: nil, reconcileResult: reconcile.Result{}}))) } - testDelete := func(hr *v1beta1.HTTPRoute) { + testDelete := func(hr *v1.HTTPRoute) { fakeGetter.GetCalls(getReturnsNotFoundErrorForHR(hr)) resultCh := startReconciling(client.ObjectKeyFromObject(hr)) Eventually(eventCh).Should(Receive(Equal(&events.DeleteEvent{ NamespacedName: client.ObjectKeyFromObject(hr), - Type: &v1beta1.HTTPRoute{}, + Type: &v1.HTTPRoute{}, }))) Eventually(resultCh).Should(Receive(Equal(result{err: nil, reconcileResult: reconcile.Result{}}))) } @@ -137,7 +137,7 @@ var _ = Describe("Reconciler", func() { BeforeEach(func() { rec = controller.NewReconciler(controller.ReconcilerConfig{ Getter: fakeGetter, - ObjectType: &v1beta1.HTTPRoute{}, + ObjectType: &v1.HTTPRoute{}, EventCh: eventCh, }) }) @@ -162,7 +162,7 @@ var _ = Describe("Reconciler", func() { rec = controller.NewReconciler(controller.ReconcilerConfig{ Getter: fakeGetter, - ObjectType: &v1beta1.HTTPRoute{}, + ObjectType: &v1.HTTPRoute{}, EventCh: eventCh, NamespacedNameFilter: filter, }) @@ -204,7 +204,7 @@ var _ = Describe("Reconciler", func() { BeforeEach(func() { rec = controller.NewReconciler(controller.ReconcilerConfig{ Getter: fakeGetter, - ObjectType: &v1beta1.HTTPRoute{}, + ObjectType: &v1.HTTPRoute{}, EventCh: eventCh, }) }) diff --git a/internal/framework/controller/register_test.go b/internal/framework/controller/register_test.go index ea55464088..3a591b9e6d 100644 --- a/internal/framework/controller/register_test.go +++ b/internal/framework/controller/register_test.go @@ -14,7 +14,8 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" + v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/controllerfakes" @@ -30,6 +31,7 @@ func TestRegister(t *testing.T) { getDefaultFakes := func() fakes { scheme := runtime.NewScheme() + utilruntime.Must(v1.AddToScheme(scheme)) utilruntime.Must(v1beta1.AddToScheme(scheme)) indexer := &controllerfakes.FakeFieldIndexer{} @@ -80,7 +82,7 @@ func TestRegister(t *testing.T) { }, } - objectType := &v1beta1.HTTPRoute{} + objectType := &v1.HTTPRoute{} nsNameFilter := func(nsname types.NamespacedName) (bool, string) { return true, "" } diff --git a/internal/framework/events/event.go b/internal/framework/events/event.go index 6d0a6717a5..2d3944854d 100644 --- a/internal/framework/events/event.go +++ b/internal/framework/events/event.go @@ -16,7 +16,7 @@ type UpsertEvent struct { // DeleteEvent representing deleting a resource. type DeleteEvent struct { - // Type is the resource type. For example, if the event is for *v1beta1.HTTPRoute, pass &v1beta1.HTTPRoute{} as Type. + // Type is the resource type. For example, if the event is for *v1.HTTPRoute, pass &v1.HTTPRoute{} as Type. Type client.Object // NamespacedName is the namespace & name of the deleted resource. NamespacedName types.NamespacedName diff --git a/internal/framework/events/first_eventbatch_preparer_test.go b/internal/framework/events/first_eventbatch_preparer_test.go index 5450325528..67e49f0ddf 100644 --- a/internal/framework/events/first_eventbatch_preparer_test.go +++ b/internal/framework/events/first_eventbatch_preparer_test.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/events" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/events/eventsfakes" @@ -32,9 +32,9 @@ var _ = Describe("FirstEventBatchPreparer", func() { fakeReader = &eventsfakes.FakeReader{} preparer = events.NewFirstEventBatchPreparerImpl( fakeReader, - []client.Object{&v1beta1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}}}, + []client.Object{&v1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}}}, []client.ObjectList{ - &v1beta1.HTTPRouteList{}, + &v1.HTTPRouteList{}, }) }) @@ -48,7 +48,7 @@ var _ = Describe("FirstEventBatchPreparer", func() { fakeReader.GetCalls( func(ctx context.Context, name types.NamespacedName, object client.Object, opts ...client.GetOption) error { Expect(name).Should(Equal(types.NamespacedName{Name: gcName})) - Expect(object).Should(BeAssignableToTypeOf(&v1beta1.GatewayClass{})) + Expect(object).Should(BeAssignableToTypeOf(&v1.GatewayClass{})) return apierrors.NewNotFound(schema.GroupResource{}, "test") }, @@ -62,25 +62,25 @@ var _ = Describe("FirstEventBatchPreparer", func() { }) It("should prepare one event for each resource type", func() { - gatewayClass := v1beta1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}} + gatewayClass := v1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}} fakeReader.GetCalls( func(ctx context.Context, name types.NamespacedName, object client.Object, opts ...client.GetOption) error { Expect(name).Should(Equal(types.NamespacedName{Name: gcName})) - Expect(object).Should(BeAssignableToTypeOf(&v1beta1.GatewayClass{})) + Expect(object).Should(BeAssignableToTypeOf(&v1.GatewayClass{})) reflect.Indirect(reflect.ValueOf(object)).Set(reflect.Indirect(reflect.ValueOf(&gatewayClass))) return nil }, ) - httpRoute := v1beta1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}} + httpRoute := v1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}} fakeReader.ListCalls(func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error { Expect(option).To(BeEmpty()) switch typedList := list.(type) { - case *v1beta1.HTTPRouteList: + case *v1.HTTPRouteList: typedList.Items = append(typedList.Items, httpRoute) default: Fail(fmt.Sprintf("unknown type: %T", typedList)) @@ -107,8 +107,8 @@ var _ = Describe("FirstEventBatchPreparer", func() { fakeReader.GetReturns(apierrors.NewNotFound(schema.GroupResource{}, "test")) fakeReader.ListCalls( func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error { - httpRoute := v1beta1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}} - typedList := list.(*v1beta1.HTTPRouteList) + httpRoute := v1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}} + typedList := list.(*v1.HTTPRouteList) typedList.Items = append(typedList.Items, httpRoute) return nil @@ -147,9 +147,9 @@ var _ = Describe("FirstEventBatchPreparer", func() { fakeReader.ListReturns(nil) switch obj.(type) { - case *v1beta1.GatewayClass: + case *v1.GatewayClass: fakeReader.GetReturns(readerError) - case *v1beta1.HTTPRoute: + case *v1.HTTPRoute: fakeReader.ListReturnsOnCall(0, readerError) default: Fail(fmt.Sprintf("Unknown type: %T", obj)) @@ -159,8 +159,8 @@ var _ = Describe("FirstEventBatchPreparer", func() { Expect(batch).To(BeNil()) Expect(err).To(MatchError(readerError)) }, - Entry("GatewayClass", &v1beta1.GatewayClass{}), - Entry("HTTPRoute", &v1beta1.HTTPRoute{}), + Entry("GatewayClass", &v1.GatewayClass{}), + Entry("HTTPRoute", &v1.HTTPRoute{}), ) }) }) diff --git a/internal/framework/status/gateway.go b/internal/framework/status/gateway.go index 644be890e5..f91c7f244f 100644 --- a/internal/framework/status/gateway.go +++ b/internal/framework/status/gateway.go @@ -4,15 +4,15 @@ import ( "sort" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) // prepareGatewayStatus prepares the status for a Gateway resource. func prepareGatewayStatus( gatewayStatus GatewayStatus, transitionTime metav1.Time, -) v1beta1.GatewayStatus { - listenerStatuses := make([]v1beta1.ListenerStatus, 0, len(gatewayStatus.ListenerStatuses)) +) v1.GatewayStatus { + listenerStatuses := make([]v1.ListenerStatus, 0, len(gatewayStatus.ListenerStatuses)) // FIXME(pleshakov) Maintain the order from the Gateway resource // https://github.com/nginxinc/nginx-gateway-fabric/issues/689 @@ -25,15 +25,15 @@ func prepareGatewayStatus( for _, name := range names { s := gatewayStatus.ListenerStatuses[name] - listenerStatuses = append(listenerStatuses, v1beta1.ListenerStatus{ - Name: v1beta1.SectionName(name), + listenerStatuses = append(listenerStatuses, v1.ListenerStatus{ + Name: v1.SectionName(name), SupportedKinds: s.SupportedKinds, AttachedRoutes: s.AttachedRoutes, Conditions: convertConditions(s.Conditions, gatewayStatus.ObservedGeneration, transitionTime), }) } - return v1beta1.GatewayStatus{ + return v1.GatewayStatus{ Listeners: listenerStatuses, Addresses: gatewayStatus.Addresses, Conditions: convertConditions(gatewayStatus.Conditions, gatewayStatus.ObservedGeneration, transitionTime), diff --git a/internal/framework/status/gateway_test.go b/internal/framework/status/gateway_test.go index 7ff2d23d0f..cff7e509a3 100644 --- a/internal/framework/status/gateway_test.go +++ b/internal/framework/status/gateway_test.go @@ -6,14 +6,14 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" ) func TestPrepareGatewayStatus(t *testing.T) { - podIP := v1beta1.GatewayStatusAddress{ - Type: helpers.GetPointer(v1beta1.IPAddressType), + podIP := v1.GatewayStatusAddress{ + Type: helpers.GetPointer(v1.IPAddressType), Value: "1.2.3.4", } status := GatewayStatus{ @@ -22,25 +22,25 @@ func TestPrepareGatewayStatus(t *testing.T) { "listener": { AttachedRoutes: 3, Conditions: CreateTestConditions("ListenerTest"), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ { - Kind: v1beta1.Kind("HTTPRoute"), + Kind: v1.Kind("HTTPRoute"), }, }, }, }, - Addresses: []v1beta1.GatewayStatusAddress{podIP}, + Addresses: []v1.GatewayStatusAddress{podIP}, ObservedGeneration: 1, } transitionTime := metav1.NewTime(time.Now()) - expected := v1beta1.GatewayStatus{ + expected := v1.GatewayStatus{ Conditions: CreateExpectedAPIConditions("GatewayTest", 1, transitionTime), - Listeners: []v1beta1.ListenerStatus{ + Listeners: []v1.ListenerStatus{ { Name: "listener", - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ { Kind: "HTTPRoute", }, @@ -49,7 +49,7 @@ func TestPrepareGatewayStatus(t *testing.T) { Conditions: CreateExpectedAPIConditions("ListenerTest", 1, transitionTime), }, }, - Addresses: []v1beta1.GatewayStatusAddress{podIP}, + Addresses: []v1.GatewayStatusAddress{podIP}, } g := NewWithT(t) diff --git a/internal/framework/status/gatewayclass.go b/internal/framework/status/gatewayclass.go index 3cccf3414b..9b4337a035 100644 --- a/internal/framework/status/gatewayclass.go +++ b/internal/framework/status/gatewayclass.go @@ -2,12 +2,12 @@ package status import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) // prepareGatewayClassStatus prepares the status for the GatewayClass resource. -func prepareGatewayClassStatus(status GatewayClassStatus, transitionTime metav1.Time) v1beta1.GatewayClassStatus { - return v1beta1.GatewayClassStatus{ +func prepareGatewayClassStatus(status GatewayClassStatus, transitionTime metav1.Time) v1.GatewayClassStatus { + return v1.GatewayClassStatus{ Conditions: convertConditions(status.Conditions, status.ObservedGeneration, transitionTime), } } diff --git a/internal/framework/status/gatewayclass_test.go b/internal/framework/status/gatewayclass_test.go index 9918c603c4..aa76dd6369 100644 --- a/internal/framework/status/gatewayclass_test.go +++ b/internal/framework/status/gatewayclass_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" ) @@ -18,7 +18,7 @@ func TestPrepareGatewayClassStatus(t *testing.T) { ObservedGeneration: 1, Conditions: CreateTestConditions("Test"), } - expected := v1beta1.GatewayClassStatus{ + expected := v1.GatewayClassStatus{ Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), } diff --git a/internal/framework/status/httproute.go b/internal/framework/status/httproute.go index 1912f80c87..d79178dae2 100644 --- a/internal/framework/status/httproute.go +++ b/internal/framework/status/httproute.go @@ -2,20 +2,20 @@ package status import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) // prepareHTTPRouteStatus prepares the status for an HTTPRoute resource. func prepareHTTPRouteStatus( - oldStatus v1beta1.HTTPRouteStatus, + oldStatus v1.HTTPRouteStatus, status HTTPRouteStatus, gatewayCtlrName string, transitionTime metav1.Time, -) v1beta1.HTTPRouteStatus { +) v1.HTTPRouteStatus { // maxParents is the max number of parent statuses which is the sum of all new parent statuses and all old parent // statuses. maxParents := len(status.ParentStatuses) + len(oldStatus.Parents) - parents := make([]v1beta1.RouteParentStatus, 0, maxParents) + parents := make([]v1.RouteParentStatus, 0, maxParents) // keep all the parent statuses that belong to other controllers for _, os := range oldStatus.Parents { @@ -27,20 +27,20 @@ func prepareHTTPRouteStatus( for _, ps := range status.ParentStatuses { // reassign the iteration variable inside the loop to fix implicit memory aliasing ps := ps - p := v1beta1.RouteParentStatus{ - ParentRef: v1beta1.ParentReference{ - Namespace: (*v1beta1.Namespace)(&ps.GatewayNsName.Namespace), - Name: v1beta1.ObjectName(ps.GatewayNsName.Name), + p := v1.RouteParentStatus{ + ParentRef: v1.ParentReference{ + Namespace: (*v1.Namespace)(&ps.GatewayNsName.Namespace), + Name: v1.ObjectName(ps.GatewayNsName.Name), SectionName: ps.SectionName, }, - ControllerName: v1beta1.GatewayController(gatewayCtlrName), + ControllerName: v1.GatewayController(gatewayCtlrName), Conditions: convertConditions(ps.Conditions, status.ObservedGeneration, transitionTime), } parents = append(parents, p) } - return v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ + return v1.HTTPRouteStatus{ + RouteStatus: v1.RouteStatus{ Parents: parents, }, } diff --git a/internal/framework/status/httproute_test.go b/internal/framework/status/httproute_test.go index 1c31ae43b2..3ea82c25e3 100644 --- a/internal/framework/status/httproute_test.go +++ b/internal/framework/status/httproute_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" ) @@ -21,7 +21,7 @@ func TestPrepareHTTPRouteStatus(t *testing.T) { ParentStatuses: []ParentStatus{ { GatewayNsName: gwNsName1, - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + SectionName: helpers.GetPointer[v1.SectionName]("http"), Conditions: CreateTestConditions("Test"), }, { @@ -35,86 +35,86 @@ func TestPrepareHTTPRouteStatus(t *testing.T) { gatewayCtlrName := "test.example.com" transitionTime := metav1.NewTime(time.Now()) - oldStatus := v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + oldStatus := v1.HTTPRouteStatus{ + RouteStatus: v1.RouteStatus{ + Parents: []v1.RouteParentStatus{ { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), - Name: v1beta1.ObjectName(gwNsName1.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName1.Namespace)), + Name: v1.ObjectName(gwNsName1.Name), + SectionName: helpers.GetPointer[v1.SectionName]("http"), }, - ControllerName: v1beta1.GatewayController(gatewayCtlrName), + ControllerName: v1.GatewayController(gatewayCtlrName), Conditions: CreateExpectedAPIConditions("Old", 1, transitionTime), }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), - Name: v1beta1.ObjectName(gwNsName1.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName1.Namespace)), + Name: v1.ObjectName(gwNsName1.Name), + SectionName: helpers.GetPointer[v1.SectionName]("http"), }, - ControllerName: v1beta1.GatewayController("not-our-controller"), + ControllerName: v1.GatewayController("not-our-controller"), Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName2.Namespace)), - Name: v1beta1.ObjectName(gwNsName2.Name), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName2.Namespace)), + Name: v1.ObjectName(gwNsName2.Name), SectionName: nil, }, - ControllerName: v1beta1.GatewayController(gatewayCtlrName), + ControllerName: v1.GatewayController(gatewayCtlrName), Conditions: CreateExpectedAPIConditions("Old", 1, transitionTime), }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName2.Namespace)), - Name: v1beta1.ObjectName(gwNsName2.Name), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName2.Namespace)), + Name: v1.ObjectName(gwNsName2.Name), SectionName: nil, }, - ControllerName: v1beta1.GatewayController("not-our-controller"), + ControllerName: v1.GatewayController("not-our-controller"), Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), }, }, }, } - expected := v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + expected := v1.HTTPRouteStatus{ + RouteStatus: v1.RouteStatus{ + Parents: []v1.RouteParentStatus{ { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), - Name: v1beta1.ObjectName(gwNsName1.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName1.Namespace)), + Name: v1.ObjectName(gwNsName1.Name), + SectionName: helpers.GetPointer[v1.SectionName]("http"), }, - ControllerName: v1beta1.GatewayController("not-our-controller"), + ControllerName: v1.GatewayController("not-our-controller"), Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName2.Namespace)), - Name: v1beta1.ObjectName(gwNsName2.Name), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName2.Namespace)), + Name: v1.ObjectName(gwNsName2.Name), SectionName: nil, }, - ControllerName: v1beta1.GatewayController("not-our-controller"), + ControllerName: v1.GatewayController("not-our-controller"), Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), - Name: v1beta1.ObjectName(gwNsName1.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName1.Namespace)), + Name: v1.ObjectName(gwNsName1.Name), + SectionName: helpers.GetPointer[v1.SectionName]("http"), }, - ControllerName: v1beta1.GatewayController(gatewayCtlrName), + ControllerName: v1.GatewayController(gatewayCtlrName), Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName2.Namespace)), - Name: v1beta1.ObjectName(gwNsName2.Name), + ParentRef: v1.ParentReference{ + Namespace: helpers.GetPointer(v1.Namespace(gwNsName2.Namespace)), + Name: v1.ObjectName(gwNsName2.Name), SectionName: nil, }, - ControllerName: v1beta1.GatewayController(gatewayCtlrName), + ControllerName: v1.GatewayController(gatewayCtlrName), Conditions: CreateExpectedAPIConditions("Test", 1, transitionTime), }, }, diff --git a/internal/framework/status/setters.go b/internal/framework/status/setters.go index 3f4f1982d6..fc67136bd0 100644 --- a/internal/framework/status/setters.go +++ b/internal/framework/status/setters.go @@ -5,7 +5,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" ) @@ -37,7 +37,7 @@ func newNginxGatewayStatusSetter(clock Clock, status NginxGatewayStatus) func(cl func newGatewayClassStatusSetter(clock Clock, gcs GatewayClassStatus) func(client.Object) bool { return func(object client.Object) bool { - gc := object.(*v1beta1.GatewayClass) + gc := object.(*gatewayv1.GatewayClass) status := prepareGatewayClassStatus(gcs, clock.Now()) if conditionsEqual(gc.Status.Conditions, status.Conditions) { @@ -52,7 +52,7 @@ func newGatewayClassStatusSetter(clock Clock, gcs GatewayClassStatus) func(clien func newGatewayStatusSetter(clock Clock, gs GatewayStatus) func(client.Object) bool { return func(object client.Object) bool { - gw := object.(*v1beta1.Gateway) + gw := object.(*gatewayv1.Gateway) status := prepareGatewayStatus(gs, clock.Now()) if gwStatusEqual(gw.Status, status) { @@ -67,7 +67,7 @@ func newGatewayStatusSetter(clock Clock, gs GatewayStatus) func(client.Object) b func newHTTPRouteStatusSetter(gatewayCtlrName string, clock Clock, rs HTTPRouteStatus) func(client.Object) bool { return func(object client.Object) bool { - hr := object.(*v1beta1.HTTPRoute) + hr := object.(*gatewayv1.HTTPRoute) status := prepareHTTPRouteStatus( hr.Status, rs, @@ -85,9 +85,9 @@ func newHTTPRouteStatusSetter(gatewayCtlrName string, clock Clock, rs HTTPRouteS } } -func gwStatusEqual(prev, cur v1beta1.GatewayStatus) bool { - addressesEqual := slices.EqualFunc(prev.Addresses, cur.Addresses, func(a1, a2 v1beta1.GatewayStatusAddress) bool { - if !equalPointers[v1beta1.AddressType](a1.Type, a2.Type) { +func gwStatusEqual(prev, cur gatewayv1.GatewayStatus) bool { + addressesEqual := slices.EqualFunc(prev.Addresses, cur.Addresses, func(a1, a2 gatewayv1.GatewayStatusAddress) bool { + if !equalPointers[gatewayv1.AddressType](a1.Type, a2.Type) { return false } @@ -102,7 +102,7 @@ func gwStatusEqual(prev, cur v1beta1.GatewayStatus) bool { return false } - return slices.EqualFunc(prev.Listeners, cur.Listeners, func(s1, s2 v1beta1.ListenerStatus) bool { + return slices.EqualFunc(prev.Listeners, cur.Listeners, func(s1, s2 gatewayv1.ListenerStatus) bool { if s1.Name != s2.Name { return false } @@ -115,7 +115,7 @@ func gwStatusEqual(prev, cur v1beta1.GatewayStatus) bool { return false } - return slices.EqualFunc(s1.SupportedKinds, s2.SupportedKinds, func(k1, k2 v1beta1.RouteGroupKind) bool { + return slices.EqualFunc(s1.SupportedKinds, s2.SupportedKinds, func(k1, k2 gatewayv1.RouteGroupKind) bool { if k1.Kind != k2.Kind { return false } @@ -125,18 +125,18 @@ func gwStatusEqual(prev, cur v1beta1.GatewayStatus) bool { }) } -func hrStatusEqual(gatewayCtlrName string, prev, cur v1beta1.HTTPRouteStatus) bool { +func hrStatusEqual(gatewayCtlrName string, prev, cur gatewayv1.HTTPRouteStatus) bool { // Since other controllers may update HTTPRoute status we can't assume anything about the order of the statuses, // and we have to ignore statuses written by other controllers when checking for equality. // Therefore, we can't use slices.EqualFunc here because it cares about the order. // First, we check if the prev status has any RouteParentStatuses that are no longer present in the cur status. for _, prevParent := range prev.Parents { - if prevParent.ControllerName != v1beta1.GatewayController(gatewayCtlrName) { + if prevParent.ControllerName != gatewayv1.GatewayController(gatewayCtlrName) { continue } - exists := slices.ContainsFunc(cur.Parents, func(curParent v1beta1.RouteParentStatus) bool { + exists := slices.ContainsFunc(cur.Parents, func(curParent gatewayv1.RouteParentStatus) bool { return routeParentStatusEqual(prevParent, curParent) }) @@ -147,7 +147,7 @@ func hrStatusEqual(gatewayCtlrName string, prev, cur v1beta1.HTTPRouteStatus) bo // Then, we check if the cur status has any RouteParentStatuses that are no longer present in the prev status. for _, curParent := range cur.Parents { - exists := slices.ContainsFunc(prev.Parents, func(prevParent v1beta1.RouteParentStatus) bool { + exists := slices.ContainsFunc(prev.Parents, func(prevParent gatewayv1.RouteParentStatus) bool { return routeParentStatusEqual(curParent, prevParent) }) @@ -159,7 +159,7 @@ func hrStatusEqual(gatewayCtlrName string, prev, cur v1beta1.HTTPRouteStatus) bo return true } -func routeParentStatusEqual(p1, p2 v1beta1.RouteParentStatus) bool { +func routeParentStatusEqual(p1, p2 gatewayv1.RouteParentStatus) bool { if p1.ControllerName != p2.ControllerName { return false } diff --git a/internal/framework/status/setters_test.go b/internal/framework/status/setters_test.go index f379e369ee..c00fb2b447 100644 --- a/internal/framework/status/setters_test.go +++ b/internal/framework/status/setters_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/gomega" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" @@ -66,7 +66,7 @@ func TestNewNginxGatewayStatusSetter(t *testing.T) { func TestNewGatewayClassStatusSetter(t *testing.T) { tests := []struct { name string - status v1beta1.GatewayClassStatus + status gatewayv1.GatewayClassStatus newStatus GatewayClassStatus expStatusSet bool }{ @@ -82,7 +82,7 @@ func TestNewGatewayClassStatusSetter(t *testing.T) { newStatus: GatewayClassStatus{ Conditions: []conditions.Condition{{Message: "new condition"}}, }, - status: v1beta1.GatewayClassStatus{ + status: gatewayv1.GatewayClassStatus{ Conditions: []v1.Condition{{Message: "old condition"}}, }, expStatusSet: true, @@ -92,7 +92,7 @@ func TestNewGatewayClassStatusSetter(t *testing.T) { newStatus: GatewayClassStatus{ Conditions: []conditions.Condition{{Message: "same condition"}}, }, - status: v1beta1.GatewayClassStatus{ + status: gatewayv1.GatewayClassStatus{ Conditions: []v1.Condition{{Message: "same condition"}}, }, expStatusSet: false, @@ -106,21 +106,21 @@ func TestNewGatewayClassStatusSetter(t *testing.T) { g := NewWithT(t) setter := newGatewayClassStatusSetter(clock, test.newStatus) - statusSet := setter(&v1beta1.GatewayClass{Status: test.status}) + statusSet := setter(&gatewayv1.GatewayClass{Status: test.status}) g.Expect(statusSet).To(Equal(test.expStatusSet)) }) } } func TestNewGatewayStatusSetter(t *testing.T) { - expAddress := v1beta1.GatewayStatusAddress{ - Type: helpers.GetPointer(v1beta1.IPAddressType), + expAddress := gatewayv1.GatewayStatusAddress{ + Type: helpers.GetPointer(gatewayv1.IPAddressType), Value: "10.0.0.0", } tests := []struct { name string - status v1beta1.GatewayStatus + status gatewayv1.GatewayStatus newStatus GatewayStatus expStatusSet bool }{ @@ -128,7 +128,7 @@ func TestNewGatewayStatusSetter(t *testing.T) { name: "Gateway has no status", newStatus: GatewayStatus{ Conditions: []conditions.Condition{{Message: "new condition"}}, - Addresses: []v1beta1.GatewayStatusAddress{expAddress}, + Addresses: []gatewayv1.GatewayStatusAddress{expAddress}, }, expStatusSet: true, }, @@ -136,11 +136,11 @@ func TestNewGatewayStatusSetter(t *testing.T) { name: "Gateway has old status", newStatus: GatewayStatus{ Conditions: []conditions.Condition{{Message: "new condition"}}, - Addresses: []v1beta1.GatewayStatusAddress{expAddress}, + Addresses: []gatewayv1.GatewayStatusAddress{expAddress}, }, - status: v1beta1.GatewayStatus{ + status: gatewayv1.GatewayStatus{ Conditions: []v1.Condition{{Message: "old condition"}}, - Addresses: []v1beta1.GatewayStatusAddress{expAddress}, + Addresses: []gatewayv1.GatewayStatusAddress{expAddress}, }, expStatusSet: true, }, @@ -148,11 +148,11 @@ func TestNewGatewayStatusSetter(t *testing.T) { name: "Gateway has same status", newStatus: GatewayStatus{ Conditions: []conditions.Condition{{Message: "same condition"}}, - Addresses: []v1beta1.GatewayStatusAddress{expAddress}, + Addresses: []gatewayv1.GatewayStatusAddress{expAddress}, }, - status: v1beta1.GatewayStatus{ + status: gatewayv1.GatewayStatus{ Conditions: []v1.Condition{{Message: "same condition"}}, - Addresses: []v1beta1.GatewayStatusAddress{expAddress}, + Addresses: []gatewayv1.GatewayStatusAddress{expAddress}, }, expStatusSet: false, }, @@ -166,7 +166,7 @@ func TestNewGatewayStatusSetter(t *testing.T) { setter := newGatewayStatusSetter(clock, test.newStatus) - statusSet := setter(&v1beta1.Gateway{Status: test.status}) + statusSet := setter(&gatewayv1.Gateway{Status: test.status}) g.Expect(statusSet).To(Equal(test.expStatusSet)) }) } @@ -177,7 +177,7 @@ func TestNewHTTPRouteStatusSetter(t *testing.T) { tests := []struct { name string - status v1beta1.HTTPRouteStatus + status gatewayv1.HTTPRouteStatus newStatus HTTPRouteStatus expStatusSet bool }{ @@ -201,12 +201,12 @@ func TestNewHTTPRouteStatusSetter(t *testing.T) { }, }, }, - status: v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + status: gatewayv1.HTTPRouteStatus{ + RouteStatus: gatewayv1.RouteStatus{ + Parents: []gatewayv1.RouteParentStatus{ { - ParentRef: v1beta1.ParentReference{}, - ControllerName: v1beta1.GatewayController(controllerName), + ParentRef: gatewayv1.ParentReference{}, + ControllerName: gatewayv1.GatewayController(controllerName), Conditions: []v1.Condition{{Message: "old condition"}}, }, }, @@ -223,12 +223,12 @@ func TestNewHTTPRouteStatusSetter(t *testing.T) { }, }, }, - status: v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + status: gatewayv1.HTTPRouteStatus{ + RouteStatus: gatewayv1.RouteStatus{ + Parents: []gatewayv1.RouteParentStatus{ { - ParentRef: v1beta1.ParentReference{}, - ControllerName: v1beta1.GatewayController(controllerName), + ParentRef: gatewayv1.ParentReference{}, + ControllerName: gatewayv1.GatewayController(controllerName), Conditions: []v1.Condition{{Message: "same condition"}}, }, }, @@ -246,22 +246,22 @@ func TestNewHTTPRouteStatusSetter(t *testing.T) { setter := newHTTPRouteStatusSetter(controllerName, clock, test.newStatus) - statusSet := setter(&v1beta1.HTTPRoute{Status: test.status}) + statusSet := setter(&gatewayv1.HTTPRoute{Status: test.status}) g.Expect(statusSet).To(Equal(test.expStatusSet)) }) } } func TestGWStatusEqual(t *testing.T) { - getDefaultStatus := func() v1beta1.GatewayStatus { - return v1beta1.GatewayStatus{ - Addresses: []v1beta1.GatewayStatusAddress{ + getDefaultStatus := func() gatewayv1.GatewayStatus { + return gatewayv1.GatewayStatus{ + Addresses: []gatewayv1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(gatewayv1.IPAddressType), Value: "10.0.0.0", }, { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(gatewayv1.IPAddressType), Value: "11.0.0.0", }, }, @@ -270,16 +270,16 @@ func TestGWStatusEqual(t *testing.T) { Type: "type", /* conditions are covered by another test*/ }, }, - Listeners: []v1beta1.ListenerStatus{ + Listeners: []gatewayv1.ListenerStatus{ { Name: "listener1", - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []gatewayv1.RouteGroupKind{ { - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[gatewayv1.Group](gatewayv1.GroupName), Kind: "HTTPRoute", }, { - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[gatewayv1.Group](gatewayv1.GroupName), Kind: "TCPRoute", }, }, @@ -292,9 +292,9 @@ func TestGWStatusEqual(t *testing.T) { }, { Name: "listener2", - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []gatewayv1.RouteGroupKind{ { - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[gatewayv1.Group](gatewayv1.GroupName), Kind: "HTTPRoute", }, }, @@ -307,9 +307,9 @@ func TestGWStatusEqual(t *testing.T) { }, { Name: "listener3", - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []gatewayv1.RouteGroupKind{ { - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[gatewayv1.Group](gatewayv1.GroupName), Kind: "HTTPRoute", }, }, @@ -324,20 +324,20 @@ func TestGWStatusEqual(t *testing.T) { } } - getModifiedStatus := func(mod func(v1beta1.GatewayStatus) v1beta1.GatewayStatus) v1beta1.GatewayStatus { + getModifiedStatus := func(mod func(gatewayv1.GatewayStatus) gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { return mod(getDefaultStatus()) } tests := []struct { name string - prevStatus v1beta1.GatewayStatus - curStatus v1beta1.GatewayStatus + prevStatus gatewayv1.GatewayStatus + curStatus gatewayv1.GatewayStatus expEqual bool }{ { name: "different number of addresses", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Addresses = status.Addresses[:1] return status }), @@ -346,8 +346,8 @@ func TestGWStatusEqual(t *testing.T) { { name: "different address type", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { - status.Addresses[1].Type = helpers.GetPointer(v1beta1.HostnameAddressType) + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { + status.Addresses[1].Type = helpers.GetPointer(gatewayv1.HostnameAddressType) return status }), expEqual: false, @@ -355,7 +355,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different address value", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Addresses[0].Value = "12.0.0.0" return status }), @@ -364,7 +364,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different conditions", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Conditions[0].Type = "different" return status }), @@ -373,7 +373,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different number of listener statuses", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Listeners = status.Listeners[:2] return status }), @@ -382,7 +382,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different listener status name", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Listeners[2].Name = "different" return status }), @@ -391,7 +391,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different listener status attached routes", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Listeners[1].AttachedRoutes++ return status }), @@ -400,7 +400,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different listener status conditions", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Listeners[0].Conditions[0].Type = "different" return status }), @@ -409,7 +409,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different listener status supported kinds (different number)", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Listeners[0].SupportedKinds = status.Listeners[0].SupportedKinds[:1] return status }), @@ -418,7 +418,7 @@ func TestGWStatusEqual(t *testing.T) { { name: "different listener status supported kinds (different kind)", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { status.Listeners[1].SupportedKinds[0].Kind = "TCPRoute" return status }), @@ -427,8 +427,8 @@ func TestGWStatusEqual(t *testing.T) { { name: "different listener status supported kinds (different group)", prevStatus: getDefaultStatus(), - curStatus: getModifiedStatus(func(status v1beta1.GatewayStatus) v1beta1.GatewayStatus { - status.Listeners[1].SupportedKinds[0].Group = helpers.GetPointer[v1beta1.Group]("different") + curStatus: getModifiedStatus(func(status gatewayv1.GatewayStatus) gatewayv1.GatewayStatus { + status.Listeners[1].SupportedKinds[0].Group = helpers.GetPointer[gatewayv1.Group]("different") return status }), expEqual: false, @@ -458,41 +458,41 @@ func TestHRStatusEqual(t *testing.T) { }, } - previousStatus := v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + previousStatus := gatewayv1.HTTPRouteStatus{ + RouteStatus: gatewayv1.RouteStatus{ + Parents: []gatewayv1.RouteParentStatus{ { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section1"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section1"), }, ControllerName: "ours", Conditions: testConds, }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "not-our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section1"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section1"), }, ControllerName: "not-ours", Conditions: testConds, }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section2"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section2"), }, ControllerName: "ours", Conditions: testConds, }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "not-our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section2"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section2"), }, ControllerName: "not-ours", Conditions: testConds, @@ -501,24 +501,24 @@ func TestHRStatusEqual(t *testing.T) { }, } - getDefaultStatus := func() v1beta1.HTTPRouteStatus { - return v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + getDefaultStatus := func() gatewayv1.HTTPRouteStatus { + return gatewayv1.HTTPRouteStatus{ + RouteStatus: gatewayv1.RouteStatus{ + Parents: []gatewayv1.RouteParentStatus{ { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section1"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section1"), }, ControllerName: "ours", Conditions: testConds, }, { - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section2"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section2"), }, ControllerName: "ours", Conditions: testConds, @@ -528,30 +528,32 @@ func TestHRStatusEqual(t *testing.T) { } } - newParentStatus := v1beta1.RouteParentStatus{ - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + newParentStatus := gatewayv1.RouteParentStatus{ + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "our-parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section3"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section3"), }, ControllerName: "ours", Conditions: testConds, } - getModifiedStatus := func(mod func(status v1beta1.HTTPRouteStatus) v1beta1.HTTPRouteStatus) v1beta1.HTTPRouteStatus { + getModifiedStatus := func( + mod func(status gatewayv1.HTTPRouteStatus) gatewayv1.HTTPRouteStatus, + ) gatewayv1.HTTPRouteStatus { return mod(getDefaultStatus()) } tests := []struct { name string - prevStatus v1beta1.HTTPRouteStatus - curStatus v1beta1.HTTPRouteStatus + prevStatus gatewayv1.HTTPRouteStatus + curStatus gatewayv1.HTTPRouteStatus expEqual bool }{ { name: "stale status", prevStatus: previousStatus, - curStatus: getModifiedStatus(func(status v1beta1.HTTPRouteStatus) v1beta1.HTTPRouteStatus { + curStatus: getModifiedStatus(func(status gatewayv1.HTTPRouteStatus) gatewayv1.HTTPRouteStatus { // remove last parent status status.Parents = status.Parents[:1] return status @@ -561,7 +563,7 @@ func TestHRStatusEqual(t *testing.T) { { name: "new status", prevStatus: previousStatus, - curStatus: getModifiedStatus(func(status v1beta1.HTTPRouteStatus) v1beta1.HTTPRouteStatus { + curStatus: getModifiedStatus(func(status gatewayv1.HTTPRouteStatus) gatewayv1.HTTPRouteStatus { // add another parent status status.Parents = append(status.Parents, newParentStatus) return status @@ -586,12 +588,12 @@ func TestHRStatusEqual(t *testing.T) { } func TestRouteParentStatusEqual(t *testing.T) { - getDefaultStatus := func() v1beta1.RouteParentStatus { - return v1beta1.RouteParentStatus{ - ParentRef: v1beta1.ParentReference{ - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + getDefaultStatus := func() gatewayv1.RouteParentStatus { + return gatewayv1.RouteParentStatus{ + ParentRef: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Name: "parent", - SectionName: helpers.GetPointer[v1beta1.SectionName]("section"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("section"), }, ControllerName: "controller", Conditions: []v1.Condition{ @@ -602,20 +604,22 @@ func TestRouteParentStatusEqual(t *testing.T) { } } - getModifiedStatus := func(mod func(v1beta1.RouteParentStatus) v1beta1.RouteParentStatus) v1beta1.RouteParentStatus { + getModifiedStatus := func( + mod func(gatewayv1.RouteParentStatus) gatewayv1.RouteParentStatus, + ) gatewayv1.RouteParentStatus { return mod(getDefaultStatus()) } tests := []struct { name string - p1 v1beta1.RouteParentStatus - p2 v1beta1.RouteParentStatus + p1 gatewayv1.RouteParentStatus + p2 gatewayv1.RouteParentStatus expEqual bool }{ { name: "different controller name", p1: getDefaultStatus(), - p2: getModifiedStatus(func(status v1beta1.RouteParentStatus) v1beta1.RouteParentStatus { + p2: getModifiedStatus(func(status gatewayv1.RouteParentStatus) gatewayv1.RouteParentStatus { status.ControllerName = "different" return status }), @@ -624,7 +628,7 @@ func TestRouteParentStatusEqual(t *testing.T) { { name: "different parentRef name", p1: getDefaultStatus(), - p2: getModifiedStatus(func(status v1beta1.RouteParentStatus) v1beta1.RouteParentStatus { + p2: getModifiedStatus(func(status gatewayv1.RouteParentStatus) gatewayv1.RouteParentStatus { status.ParentRef.Name = "different" return status }), @@ -633,8 +637,8 @@ func TestRouteParentStatusEqual(t *testing.T) { { name: "different parentRef namespace", p1: getDefaultStatus(), - p2: getModifiedStatus(func(status v1beta1.RouteParentStatus) v1beta1.RouteParentStatus { - status.ParentRef.Namespace = helpers.GetPointer[v1beta1.Namespace]("different") + p2: getModifiedStatus(func(status gatewayv1.RouteParentStatus) gatewayv1.RouteParentStatus { + status.ParentRef.Namespace = helpers.GetPointer[gatewayv1.Namespace]("different") return status }), expEqual: false, @@ -642,8 +646,8 @@ func TestRouteParentStatusEqual(t *testing.T) { { name: "different parentRef section name", p1: getDefaultStatus(), - p2: getModifiedStatus(func(status v1beta1.RouteParentStatus) v1beta1.RouteParentStatus { - status.ParentRef.SectionName = helpers.GetPointer[v1beta1.SectionName]("different") + p2: getModifiedStatus(func(status gatewayv1.RouteParentStatus) gatewayv1.RouteParentStatus { + status.ParentRef.SectionName = helpers.GetPointer[gatewayv1.SectionName]("different") return status }), expEqual: false, @@ -651,7 +655,7 @@ func TestRouteParentStatusEqual(t *testing.T) { { name: "different conditions", p1: getDefaultStatus(), - p2: getModifiedStatus(func(status v1beta1.RouteParentStatus) v1beta1.RouteParentStatus { + p2: getModifiedStatus(func(status gatewayv1.RouteParentStatus) gatewayv1.RouteParentStatus { status.Conditions[0].Type = "different" return status }), diff --git a/internal/framework/status/statuses.go b/internal/framework/status/statuses.go index 9af0108aa7..d6761be5e6 100644 --- a/internal/framework/status/statuses.go +++ b/internal/framework/status/statuses.go @@ -2,7 +2,7 @@ package status import ( "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" @@ -22,7 +22,7 @@ type GatewayAPIStatuses struct { } func (g GatewayAPIStatuses) APIGroup() string { - return v1beta1.GroupName + return v1.GroupName } // NginxGatewayStatus holds status-related information about the NginxGateway resource. @@ -58,7 +58,7 @@ type GatewayStatus struct { // Conditions is the list of conditions for this Gateway. Conditions []conditions.Condition // Addresses holds the list of GatewayStatusAddresses. - Addresses []v1beta1.GatewayStatusAddress + Addresses []v1.GatewayStatusAddress // ObservedGeneration is the generation of the resource that was processed. ObservedGeneration int64 // Ignored tells whether or not this Gateway is ignored. @@ -70,7 +70,7 @@ type ListenerStatus struct { // Conditions is the list of conditions for this listener. Conditions []conditions.Condition // SupportedKinds is the list of SupportedKinds for this listener. - SupportedKinds []v1beta1.RouteGroupKind + SupportedKinds []v1.RouteGroupKind // AttachedRoutes is the number of routes attached to the listener. AttachedRoutes int32 } @@ -88,7 +88,7 @@ type ParentStatus struct { // GatewayNsName is the Namespaced name of the Gateway, which the parentRef references. GatewayNsName types.NamespacedName // SectionName is the SectionName of the parentRef. - SectionName *v1beta1.SectionName + SectionName *v1.SectionName // Conditions is the list of conditions that are relevant to the parentRef. Conditions []conditions.Condition } diff --git a/internal/framework/status/statusfakes/fake_updater.go b/internal/framework/status/statusfakes/fake_updater.go index 6ca5b60c32..77b1242567 100644 --- a/internal/framework/status/statusfakes/fake_updater.go +++ b/internal/framework/status/statusfakes/fake_updater.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/status" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) type FakeUpdater struct { @@ -25,11 +25,11 @@ type FakeUpdater struct { arg1 context.Context arg2 status.Status } - UpdateAddressesStub func(context.Context, []v1beta1.GatewayStatusAddress) + UpdateAddressesStub func(context.Context, []v1.GatewayStatusAddress) updateAddressesMutex sync.RWMutex updateAddressesArgsForCall []struct { arg1 context.Context - arg2 []v1beta1.GatewayStatusAddress + arg2 []v1.GatewayStatusAddress } invocations map[string][][]interface{} invocationsMutex sync.RWMutex @@ -124,16 +124,16 @@ func (fake *FakeUpdater) UpdateArgsForCall(i int) (context.Context, status.Statu return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeUpdater) UpdateAddresses(arg1 context.Context, arg2 []v1beta1.GatewayStatusAddress) { - var arg2Copy []v1beta1.GatewayStatusAddress +func (fake *FakeUpdater) UpdateAddresses(arg1 context.Context, arg2 []v1.GatewayStatusAddress) { + var arg2Copy []v1.GatewayStatusAddress if arg2 != nil { - arg2Copy = make([]v1beta1.GatewayStatusAddress, len(arg2)) + arg2Copy = make([]v1.GatewayStatusAddress, len(arg2)) copy(arg2Copy, arg2) } fake.updateAddressesMutex.Lock() fake.updateAddressesArgsForCall = append(fake.updateAddressesArgsForCall, struct { arg1 context.Context - arg2 []v1beta1.GatewayStatusAddress + arg2 []v1.GatewayStatusAddress }{arg1, arg2Copy}) stub := fake.UpdateAddressesStub fake.recordInvocation("UpdateAddresses", []interface{}{arg1, arg2Copy}) @@ -149,13 +149,13 @@ func (fake *FakeUpdater) UpdateAddressesCallCount() int { return len(fake.updateAddressesArgsForCall) } -func (fake *FakeUpdater) UpdateAddressesCalls(stub func(context.Context, []v1beta1.GatewayStatusAddress)) { +func (fake *FakeUpdater) UpdateAddressesCalls(stub func(context.Context, []v1.GatewayStatusAddress)) { fake.updateAddressesMutex.Lock() defer fake.updateAddressesMutex.Unlock() fake.UpdateAddressesStub = stub } -func (fake *FakeUpdater) UpdateAddressesArgsForCall(i int) (context.Context, []v1beta1.GatewayStatusAddress) { +func (fake *FakeUpdater) UpdateAddressesArgsForCall(i int) (context.Context, []v1.GatewayStatusAddress) { fake.updateAddressesMutex.RLock() defer fake.updateAddressesMutex.RUnlock() argsForCall := fake.updateAddressesArgsForCall[i] diff --git a/internal/framework/status/updater.go b/internal/framework/status/updater.go index 3397915e23..c2ff173ba0 100644 --- a/internal/framework/status/updater.go +++ b/internal/framework/status/updater.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller" @@ -28,7 +28,7 @@ type Updater interface { // Update updates the statuses of the resources. Update(context.Context, Status) // UpdateAddresses updates the Gateway Addresses when the Gateway Service changes. - UpdateAddresses(context.Context, []v1beta1.GatewayStatusAddress) + UpdateAddresses(context.Context, []v1.GatewayStatusAddress) // Enable enables status updates. The updater will update the statuses in Kubernetes API to ensure they match the // statuses of the last Update invocation. Enable(ctx context.Context) @@ -176,7 +176,7 @@ func (upd *UpdaterImpl) updateGatewayAPI(ctx context.Context, statuses GatewayAP default: } - upd.writeStatuses(ctx, nsname, &v1beta1.GatewayClass{}, newGatewayClassStatusSetter(upd.cfg.Clock, gcs)) + upd.writeStatuses(ctx, nsname, &v1.GatewayClass{}, newGatewayClassStatusSetter(upd.cfg.Clock, gcs)) } } @@ -187,7 +187,7 @@ func (upd *UpdaterImpl) updateGatewayAPI(ctx context.Context, statuses GatewayAP default: } - upd.writeStatuses(ctx, nsname, &v1beta1.Gateway{}, newGatewayStatusSetter(upd.cfg.Clock, gs)) + upd.writeStatuses(ctx, nsname, &v1.Gateway{}, newGatewayStatusSetter(upd.cfg.Clock, gs)) } for nsname, rs := range statuses.HTTPRouteStatuses { @@ -200,7 +200,7 @@ func (upd *UpdaterImpl) updateGatewayAPI(ctx context.Context, statuses GatewayAP upd.writeStatuses( ctx, nsname, - &v1beta1.HTTPRoute{}, + &v1.HTTPRoute{}, newHTTPRouteStatusSetter(upd.cfg.GatewayCtlrName, upd.cfg.Clock, rs), ) } @@ -235,7 +235,7 @@ func (upd *UpdaterImpl) writeStatuses( } // UpdateAddresses is called when the Gateway Status needs its addresses updated. -func (upd *UpdaterImpl) UpdateAddresses(ctx context.Context, addresses []v1beta1.GatewayStatusAddress) { +func (upd *UpdaterImpl) UpdateAddresses(ctx context.Context, addresses []v1.GatewayStatusAddress) { defer upd.lock.Unlock() upd.lock.Lock() diff --git a/internal/framework/status/updater_retry_test.go b/internal/framework/status/updater_retry_test.go index c2f084e0e7..69a8b5e388 100644 --- a/internal/framework/status/updater_retry_test.go +++ b/internal/framework/status/updater_retry_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/controllerfakes" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/status" @@ -83,7 +83,7 @@ func TestNewRetryUpdateFunc(t *testing.T) { fakeGetter, fakeStatusUpdater, types.NamespacedName{}, - &v1beta1.GatewayClass{}, + &v1.GatewayClass{}, zap.New(), func(client.Object) bool { return test.statusSetterReturns }, ) diff --git a/internal/framework/status/updater_test.go b/internal/framework/status/updater_test.go index 786ce10c26..34d72c7986 100644 --- a/internal/framework/status/updater_test.go +++ b/internal/framework/status/updater_test.go @@ -13,7 +13,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" @@ -41,15 +41,15 @@ var _ = Describe("Updater", func() { BeforeEach(OncePerOrdered, func() { scheme := runtime.NewScheme() - Expect(v1beta1.AddToScheme(scheme)).Should(Succeed()) + Expect(v1.AddToScheme(scheme)).Should(Succeed()) Expect(ngfAPI.AddToScheme(scheme)).Should(Succeed()) client = fake.NewClientBuilder(). WithScheme(scheme). WithStatusSubresource( - &v1beta1.GatewayClass{}, - &v1beta1.Gateway{}, - &v1beta1.HTTPRoute{}, + &v1.GatewayClass{}, + &v1.Gateway{}, + &v1.HTTPRoute{}, &ngfAPI.NginxGateway{}, ). Build() @@ -69,12 +69,12 @@ var _ = Describe("Updater", func() { var ( updater *status.UpdaterImpl - gc *v1beta1.GatewayClass - gw, ignoredGw *v1beta1.Gateway - hr *v1beta1.HTTPRoute + gc *v1.GatewayClass + gw, ignoredGw *v1.Gateway + hr *v1.HTTPRoute ng *ngfAPI.NginxGateway - addr = v1beta1.GatewayStatusAddress{ - Type: helpers.GetPointer(v1beta1.IPAddressType), + addr = v1.GatewayStatusAddress{ + Type: helpers.GetPointer(v1.IPAddressType), Value: "1.2.3.4", } @@ -93,10 +93,10 @@ var _ = Describe("Updater", func() { "http": { AttachedRoutes: 1, Conditions: status.CreateTestConditions("Test"), - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []v1.RouteGroupKind{{Kind: "HTTPRoute"}}, }, }, - Addresses: []v1beta1.GatewayStatusAddress{addr}, + Addresses: []v1.GatewayStatusAddress{addr}, ObservedGeneration: gens.gateways, }, {Namespace: "test", Name: "ignored-gateway"}: { @@ -111,7 +111,7 @@ var _ = Describe("Updater", func() { ParentStatuses: []status.ParentStatus{ { GatewayNsName: types.NamespacedName{Namespace: "test", Name: "gateway"}, - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + SectionName: helpers.GetPointer[v1.SectionName]("http"), Conditions: status.CreateTestConditions("Test"), }, }, @@ -131,60 +131,60 @@ var _ = Describe("Updater", func() { } } - createExpectedGCWithGeneration = func(generation int64) *v1beta1.GatewayClass { - return &v1beta1.GatewayClass{ + createExpectedGCWithGeneration = func(generation int64) *v1.GatewayClass { + return &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, TypeMeta: metav1.TypeMeta{ Kind: "GatewayClass", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, - Status: v1beta1.GatewayClassStatus{ + Status: v1.GatewayClassStatus{ Conditions: status.CreateExpectedAPIConditions("Test", generation, fakeClockTime), }, } } - createExpectedGwWithGeneration = func(generation int64) *v1beta1.Gateway { - return &v1beta1.Gateway{ + createExpectedGwWithGeneration = func(generation int64) *v1.Gateway { + return &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway", }, TypeMeta: metav1.TypeMeta{ Kind: "Gateway", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, - Status: v1beta1.GatewayStatus{ + Status: v1.GatewayStatus{ Conditions: status.CreateExpectedAPIConditions("Test", generation, fakeClockTime), - Listeners: []v1beta1.ListenerStatus{ + Listeners: []v1.ListenerStatus{ { Name: "http", AttachedRoutes: 1, Conditions: status.CreateExpectedAPIConditions("Test", generation, fakeClockTime), - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []v1.RouteGroupKind{{Kind: "HTTPRoute"}}, }, }, - Addresses: []v1beta1.GatewayStatusAddress{addr}, + Addresses: []v1.GatewayStatusAddress{addr}, }, } } - createExpectedIgnoredGw = func() *v1beta1.Gateway { - return &v1beta1.Gateway{ + createExpectedIgnoredGw = func() *v1.Gateway { + return &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "ignored-gateway", }, TypeMeta: metav1.TypeMeta{ Kind: "Gateway", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, - Status: v1beta1.GatewayStatus{ + Status: v1.GatewayStatus{ Conditions: []metav1.Condition{ { - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionFalse, ObservedGeneration: 1, LastTransitionTime: fakeClockTime, @@ -192,7 +192,7 @@ var _ = Describe("Updater", func() { Message: staticConds.GatewayMessageGatewayConflict, }, { - Type: string(v1beta1.GatewayConditionProgrammed), + Type: string(v1.GatewayConditionProgrammed), Status: metav1.ConditionFalse, ObservedGeneration: 1, LastTransitionTime: fakeClockTime, @@ -204,25 +204,25 @@ var _ = Describe("Updater", func() { } } - createExpectedHR = func() *v1beta1.HTTPRoute { - return &v1beta1.HTTPRoute{ + createExpectedHR = func() *v1.HTTPRoute { + return &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "route1", }, TypeMeta: metav1.TypeMeta{ Kind: "HTTPRoute", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, - Status: v1beta1.HTTPRouteStatus{ - RouteStatus: v1beta1.RouteStatus{ - Parents: []v1beta1.RouteParentStatus{ + Status: v1.HTTPRouteStatus{ + RouteStatus: v1.RouteStatus{ + Parents: []v1.RouteParentStatus{ { - ControllerName: v1beta1.GatewayController(gatewayCtrlName), - ParentRef: v1beta1.ParentReference{ - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), + ControllerName: v1.GatewayController(gatewayCtrlName), + ParentRef: v1.ParentReference{ + Namespace: (*v1.Namespace)(helpers.GetPointer("test")), Name: "gateway", - SectionName: (*v1beta1.SectionName)(helpers.GetPointer("http")), + SectionName: (*v1.SectionName)(helpers.GetPointer("http")), }, Conditions: status.CreateExpectedAPIConditions("Test", 5, fakeClockTime), }, @@ -259,43 +259,43 @@ var _ = Describe("Updater", func() { UpdateGatewayClassStatus: true, }) - gc = &v1beta1.GatewayClass{ + gc = &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, TypeMeta: metav1.TypeMeta{ Kind: "GatewayClass", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, } - gw = &v1beta1.Gateway{ + gw = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway", }, TypeMeta: metav1.TypeMeta{ Kind: "Gateway", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, } - ignoredGw = &v1beta1.Gateway{ + ignoredGw = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "ignored-gateway", }, TypeMeta: metav1.TypeMeta{ Kind: "Gateway", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, } - hr = &v1beta1.HTTPRoute{ + hr = &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "route1", }, TypeMeta: metav1.TypeMeta{ Kind: "HTTPRoute", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, } ng = &ngfAPI.NginxGateway{ @@ -326,7 +326,7 @@ var _ = Describe("Updater", func() { }) It("should have the updated status of GatewayClass in the API server", func() { - latestGc := &v1beta1.GatewayClass{} + latestGc := &v1.GatewayClass{} expectedGc := createExpectedGCWithGeneration(1) err := client.Get(context.Background(), types.NamespacedName{Name: gcName}, latestGc) @@ -338,7 +338,7 @@ var _ = Describe("Updater", func() { }) It("should have the updated status of Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedGwWithGeneration(1) err := client.Get(context.Background(), types.NamespacedName{Namespace: "test", Name: "gateway"}, latestGw) @@ -350,7 +350,7 @@ var _ = Describe("Updater", func() { }) It("should have the updated status of ignored Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedIgnoredGw() err := client.Get( @@ -366,7 +366,7 @@ var _ = Describe("Updater", func() { }) It("should have the updated status of HTTPRoute in the API server", func() { - latestHR := &v1beta1.HTTPRoute{} + latestHR := &v1.HTTPRoute{} expectedHR := createExpectedHR() err := client.Get(context.Background(), types.NamespacedName{Namespace: "test", Name: "route1"}, latestHR) @@ -400,22 +400,22 @@ var _ = Describe("Updater", func() { When("the Gateway Service is updated with a new address", func() { AfterEach(func() { // reset the IP for the remaining tests - updater.UpdateAddresses(context.Background(), []v1beta1.GatewayStatusAddress{ + updater.UpdateAddresses(context.Background(), []v1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(v1.IPAddressType), Value: "1.2.3.4", }, }) }) It("should update the previous Gateway statuses with new address", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedGwWithGeneration(1) expectedGw.Status.Addresses[0].Value = "5.6.7.8" - updater.UpdateAddresses(context.Background(), []v1beta1.GatewayStatusAddress{ + updater.UpdateAddresses(context.Background(), []v1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(v1.IPAddressType), Value: "5.6.7.8", }, }) @@ -444,7 +444,7 @@ var _ = Describe("Updater", func() { When("updating with canceled context", func() { It("should not have the updated status of GatewayClass in the API server", func() { - latestGc := &v1beta1.GatewayClass{} + latestGc := &v1.GatewayClass{} expectedGc := createExpectedGCWithGeneration(1) err := client.Get(context.Background(), types.NamespacedName{Name: gcName}, latestGc) @@ -456,7 +456,7 @@ var _ = Describe("Updater", func() { }) It("should not have the updated status of Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedGwWithGeneration(1) err := client.Get( @@ -472,7 +472,7 @@ var _ = Describe("Updater", func() { }) It("should not have the updated status of ignored Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedIgnoredGw() err := client.Get( @@ -489,7 +489,7 @@ var _ = Describe("Updater", func() { }) It("should not have the updated status of HTTPRoute in the API server", func() { - latestHR := &v1beta1.HTTPRoute{} + latestHR := &v1.HTTPRoute{} expectedHR := createExpectedHR() err := client.Get( @@ -540,7 +540,7 @@ var _ = Describe("Updater", func() { }) It("should not have the updated status of Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} // testing that the generation has not changed from 1 to 3 expectedGw := createExpectedGwWithGeneration(1) @@ -578,7 +578,7 @@ var _ = Describe("Updater", func() { }) It("should have the updated status of Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedGwWithGeneration(3) err := client.Get( @@ -618,7 +618,7 @@ var _ = Describe("Updater", func() { }) It("should have the updated status of Gateway in the API server", func() { - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} expectedGw := createExpectedGwWithGeneration(4) err := client.Get( @@ -676,7 +676,7 @@ var _ = Describe("Updater", func() { wg.Wait() - latestGw := &v1beta1.Gateway{} + latestGw := &v1.Gateway{} err := client.Get( context.Background(), @@ -695,7 +695,7 @@ var _ = Describe("Updater", func() { Describe("Skip GatewayClass updates", Ordered, func() { var ( updater status.Updater - gc *v1beta1.GatewayClass + gc *v1.GatewayClass ) BeforeAll(func() { @@ -708,13 +708,13 @@ var _ = Describe("Updater", func() { UpdateGatewayClassStatus: false, }) - gc = &v1beta1.GatewayClass{ + gc = &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, TypeMeta: metav1.TypeMeta{ Kind: "GatewayClass", - APIVersion: "gateway.networking.k8s.io/v1beta1", + APIVersion: "gateway.networking.k8s.io/v1", }, } }) @@ -736,7 +736,7 @@ var _ = Describe("Updater", func() { }, ) - latestGc := &v1beta1.GatewayClass{} + latestGc := &v1.GatewayClass{} err := client.Get(context.Background(), types.NamespacedName{Name: gcName}, latestGc) Expect(err).ToNot(HaveOccurred()) diff --git a/internal/mode/provisioner/handler_test.go b/internal/mode/provisioner/handler_test.go index da29a9c1a2..ada3cce1db 100644 --- a/internal/mode/provisioner/handler_test.go +++ b/internal/mode/provisioner/handler_test.go @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" . "github.com/onsi/gomega" @@ -39,14 +39,14 @@ var _ = Describe("handler", func() { BeforeEach(OncePerOrdered, func() { scheme := runtime.NewScheme() - Expect(v1beta1.AddToScheme(scheme)).Should(Succeed()) + Expect(gatewayv1.AddToScheme(scheme)).Should(Succeed()) Expect(v1.AddToScheme(scheme)).Should(Succeed()) k8sclient = fake.NewClientBuilder(). WithScheme(scheme). WithStatusSubresource( - &v1beta1.Gateway{}, - &v1beta1.GatewayClass{}, + &gatewayv1.Gateway{}, + &gatewayv1.GatewayClass{}, ). Build() @@ -64,13 +64,13 @@ var _ = Describe("handler", func() { }) }) - createGateway := func(gwNsName types.NamespacedName) *v1beta1.Gateway { - return &v1beta1.Gateway{ + createGateway := func(gwNsName types.NamespacedName) *gatewayv1.Gateway { + return &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: gwNsName.Namespace, Name: gwNsName.Name, }, - Spec: v1beta1.GatewaySpec{ + Spec: gatewayv1.GatewaySpec{ GatewayClassName: gcName, }, } @@ -79,7 +79,7 @@ var _ = Describe("handler", func() { itShouldUpsertGatewayClass := func() { // Add GatewayClass to the cluster - gc := &v1beta1.GatewayClass{ + gc := &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, @@ -99,14 +99,14 @@ var _ = Describe("handler", func() { // Ensure GatewayClass is accepted - clusterGc := &v1beta1.GatewayClass{} + clusterGc := &gatewayv1.GatewayClass{} err = k8sclient.Get(context.Background(), client.ObjectKeyFromObject(gc), clusterGc) Expect(err).ShouldNot(HaveOccurred()) expectedConditions := []metav1.Condition{ { - Type: string(v1beta1.GatewayClassConditionStatusAccepted), + Type: string(gatewayv1.GatewayClassConditionStatusAccepted), Status: metav1.ConditionTrue, ObservedGeneration: 0, LastTransitionTime: fakeClockTime, @@ -210,7 +210,7 @@ var _ = Describe("handler", func() { It("should remove first Deployment", func() { batch := []interface{}{ &events.DeleteEvent{ - Type: &v1beta1.Gateway{}, + Type: &gatewayv1.Gateway{}, NamespacedName: gwNsName1, }, } @@ -230,7 +230,7 @@ var _ = Describe("handler", func() { It("should remove second Deployment", func() { batch := []interface{}{ &events.DeleteEvent{ - Type: &v1beta1.Gateway{}, + Type: &gatewayv1.Gateway{}, NamespacedName: gwNsName2, }, } @@ -248,12 +248,12 @@ var _ = Describe("handler", func() { When("upserting Gateway for a different GatewayClass", func() { It("should not create Deployment", func() { - gw := &v1beta1.Gateway{ + gw := &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "test-gw-3", Namespace: "test-ns-3", }, - Spec: v1beta1.GatewaySpec{ + Spec: gatewayv1.GatewaySpec{ GatewayClassName: "some-class", }, } @@ -276,11 +276,11 @@ var _ = Describe("handler", func() { When("upserting GatewayClass that is not set in command-line argument", func() { It("should set the proper status if this controller is referenced", func() { - gc := &v1beta1.GatewayClass{ + gc := &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: "unknown-gc", }, - Spec: v1beta1.GatewayClassSpec{ + Spec: gatewayv1.GatewayClassSpec{ ControllerName: "test.example.com", }, } @@ -295,13 +295,13 @@ var _ = Describe("handler", func() { handler.HandleEventBatch(context.Background(), zap.New(), batch) - unknownGC := &v1beta1.GatewayClass{} + unknownGC := &gatewayv1.GatewayClass{} err = k8sclient.Get(context.Background(), client.ObjectKeyFromObject(gc), unknownGC) Expect(err).ShouldNot(HaveOccurred()) expectedConditions := []metav1.Condition{ { - Type: string(v1beta1.GatewayClassConditionStatusAccepted), + Type: string(gatewayv1.GatewayClassConditionStatusAccepted), Status: metav1.ConditionFalse, ObservedGeneration: 0, LastTransitionTime: fakeClockTime, @@ -346,11 +346,11 @@ var _ = Describe("handler", func() { &struct{}{}), Entry("should panic for an unknown type of resource in upsert event", &events.UpsertEvent{ - Resource: &v1beta1.HTTPRoute{}, + Resource: &gatewayv1.HTTPRoute{}, }), Entry("should panic for an unknown type of resource in delete event", &events.DeleteEvent{ - Type: &v1beta1.HTTPRoute{}, + Type: &gatewayv1.HTTPRoute{}, }), ) @@ -399,7 +399,7 @@ var _ = Describe("handler", func() { batch := []interface{}{ &events.DeleteEvent{ - Type: &v1beta1.Gateway{}, + Type: &gatewayv1.Gateway{}, NamespacedName: gwNsName, }, } @@ -418,7 +418,7 @@ var _ = Describe("handler", func() { batch := []interface{}{ &events.DeleteEvent{ - Type: &v1beta1.GatewayClass{}, + Type: &gatewayv1.GatewayClass{}, NamespacedName: types.NamespacedName{ Name: gcName, }, diff --git a/internal/mode/provisioner/manager.go b/internal/mode/provisioner/manager.go index 0639a7ec6e..1454111578 100644 --- a/internal/mode/provisioner/manager.go +++ b/internal/mode/provisioner/manager.go @@ -11,7 +11,7 @@ import ( ctlr "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" embeddedfiles "github.com/nginxinc/nginx-gateway-fabric" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller" @@ -37,7 +37,7 @@ type Config struct { // many important features. See https://github.com/nginxinc/nginx-gateway-fabric/issues/634 for more details. func StartManager(cfg Config) error { scheme := runtime.NewScheme() - utilruntime.Must(gatewayv1beta1.AddToScheme(scheme)) + utilruntime.Must(gatewayv1.AddToScheme(scheme)) utilruntime.Must(v1.AddToScheme(scheme)) options := manager.Options{ @@ -58,13 +58,13 @@ func StartManager(cfg Config) error { options []controller.Option }{ { - objectType: &gatewayv1beta1.GatewayClass{}, + objectType: &gatewayv1.GatewayClass{}, options: []controller.Option{ controller.WithK8sPredicate(predicate.GatewayClassPredicate{ControllerName: cfg.GatewayCtlrName}), }, }, { - objectType: &gatewayv1beta1.Gateway{}, + objectType: &gatewayv1.Gateway{}, }, } @@ -86,10 +86,10 @@ func StartManager(cfg Config) error { firstBatchPreparer := events.NewFirstEventBatchPreparerImpl( mgr.GetCache(), []client.Object{ - &gatewayv1beta1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: cfg.GatewayClassName}}, + &gatewayv1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: cfg.GatewayClassName}}, }, []client.ObjectList{ - &gatewayv1beta1.GatewayList{}, + &gatewayv1.GatewayList{}, }, ) diff --git a/internal/mode/provisioner/store.go b/internal/mode/provisioner/store.go index 2c262ed1c1..a3e521f4e2 100644 --- a/internal/mode/provisioner/store.go +++ b/internal/mode/provisioner/store.go @@ -5,21 +5,21 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/events" ) // store stores the cluster state needed by the provisioner and allows to update it from the events. type store struct { - gatewayClasses map[types.NamespacedName]*v1beta1.GatewayClass - gateways map[types.NamespacedName]*v1beta1.Gateway + gatewayClasses map[types.NamespacedName]*v1.GatewayClass + gateways map[types.NamespacedName]*v1.Gateway } func newStore() *store { return &store{ - gatewayClasses: make(map[types.NamespacedName]*v1beta1.GatewayClass), - gateways: make(map[types.NamespacedName]*v1beta1.Gateway), + gatewayClasses: make(map[types.NamespacedName]*v1.GatewayClass), + gateways: make(map[types.NamespacedName]*v1.Gateway), } } @@ -28,18 +28,18 @@ func (s *store) update(batch events.EventBatch) { switch e := event.(type) { case *events.UpsertEvent: switch obj := e.Resource.(type) { - case *v1beta1.GatewayClass: + case *v1.GatewayClass: s.gatewayClasses[client.ObjectKeyFromObject(obj)] = obj - case *v1beta1.Gateway: + case *v1.Gateway: s.gateways[client.ObjectKeyFromObject(obj)] = obj default: panic(fmt.Errorf("unknown resource type %T", e.Resource)) } case *events.DeleteEvent: switch e.Type.(type) { - case *v1beta1.GatewayClass: + case *v1.GatewayClass: delete(s.gatewayClasses, e.NamespacedName) - case *v1beta1.Gateway: + case *v1.Gateway: delete(s.gateways, e.NamespacedName) default: panic(fmt.Errorf("unknown resource type %T", e.Type)) diff --git a/internal/mode/static/build_statuses.go b/internal/mode/static/build_statuses.go index 2a009f5580..5589922161 100644 --- a/internal/mode/static/build_statuses.go +++ b/internal/mode/static/build_statuses.go @@ -3,7 +3,7 @@ package static import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/status" @@ -18,7 +18,7 @@ type nginxReloadResult struct { // buildGatewayAPIStatuses builds status.Statuses from a Graph. func buildGatewayAPIStatuses( graph *graph.Graph, - gwAddresses []v1beta1.GatewayStatusAddress, + gwAddresses []v1.GatewayStatusAddress, nginxReloadRes nginxReloadResult, ) status.GatewayAPIStatuses { statuses := status.GatewayAPIStatuses{ @@ -76,7 +76,7 @@ func buildGatewayAPIStatuses( func buildGatewayClassStatuses( gc *graph.GatewayClass, - ignoredGwClasses map[types.NamespacedName]*v1beta1.GatewayClass, + ignoredGwClasses map[types.NamespacedName]*v1.GatewayClass, ) status.GatewayClassStatuses { statuses := make(status.GatewayClassStatuses) @@ -108,8 +108,8 @@ func buildGatewayClassStatuses( func buildGatewayStatuses( gateway *graph.Gateway, - ignoredGateways map[types.NamespacedName]*v1beta1.Gateway, - gwAddresses []v1beta1.GatewayStatusAddress, + ignoredGateways map[types.NamespacedName]*v1.Gateway, + gwAddresses []v1.GatewayStatusAddress, nginxReloadRes nginxReloadResult, ) status.GatewayStatuses { statuses := make(status.GatewayStatuses) @@ -131,7 +131,7 @@ func buildGatewayStatuses( func buildGatewayStatus( gateway *graph.Gateway, - gwAddresses []v1beta1.GatewayStatusAddress, + gwAddresses []v1.GatewayStatusAddress, nginxReloadRes nginxReloadResult, ) status.GatewayStatus { if !gateway.Valid { diff --git a/internal/mode/static/build_statuses_test.go b/internal/mode/static/build_statuses_test.go index 74010237be..440cb82f80 100644 --- a/internal/mode/static/build_statuses_test.go +++ b/internal/mode/static/build_statuses_test.go @@ -8,7 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" @@ -18,7 +18,7 @@ import ( ) var ( - gw = &v1beta1.Gateway{ + gw = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway", @@ -26,7 +26,7 @@ var ( }, } - ignoredGw = &v1beta1.Gateway{ + ignoredGw = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "ignored-gateway", @@ -36,9 +36,9 @@ var ( ) func TestBuildStatuses(t *testing.T) { - addr := []v1beta1.GatewayStatusAddress{ + addr := []v1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(v1.IPAddressType), Value: "1.2.3.4", }, } @@ -55,18 +55,18 @@ func TestBuildStatuses(t *testing.T) { routes := map[types.NamespacedName]*graph.Route{ {Namespace: "test", Name: "hr-valid"}: { Valid: true, - Source: &v1beta1.HTTPRoute{ + Source: &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Generation: 3, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: v1.HTTPRouteSpec{ + CommonRouteSpec: v1.CommonRouteSpec{ + ParentRefs: []v1.ParentReference{ { - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-1"), }, { - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-2"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-2"), }, }, }, @@ -93,15 +93,15 @@ func TestBuildStatuses(t *testing.T) { {Namespace: "test", Name: "hr-invalid"}: { Valid: false, Conditions: []conditions.Condition{invalidRouteCondition}, - Source: &v1beta1.HTTPRoute{ + Source: &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Generation: 3, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: v1.HTTPRouteSpec{ + CommonRouteSpec: v1.CommonRouteSpec{ + ParentRefs: []v1.ParentReference{ { - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-1"), }, }, }, @@ -119,7 +119,7 @@ func TestBuildStatuses(t *testing.T) { graph := &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{ + Source: &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{Generation: 1}, }, Valid: true, @@ -136,7 +136,7 @@ func TestBuildStatuses(t *testing.T) { }, Valid: true, }, - IgnoredGateways: map[types.NamespacedName]*v1beta1.Gateway{ + IgnoredGateways: map[types.NamespacedName]*v1.Gateway{ client.ObjectKeyFromObject(ignoredGw): ignoredGw, }, Routes: routes, @@ -173,12 +173,12 @@ func TestBuildStatuses(t *testing.T) { ParentStatuses: []status.ParentStatus{ { GatewayNsName: client.ObjectKeyFromObject(gw), - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-1"), Conditions: staticConds.NewDefaultRouteConditions(), }, { GatewayNsName: client.ObjectKeyFromObject(gw), - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-2"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-2"), Conditions: append( staticConds.NewDefaultRouteConditions(), invalidAttachmentCondition, @@ -191,7 +191,7 @@ func TestBuildStatuses(t *testing.T) { ParentStatuses: []status.ParentStatus{ { GatewayNsName: client.ObjectKeyFromObject(gw), - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-1"), Conditions: append( staticConds.NewDefaultRouteConditions(), invalidRouteCondition, @@ -210,9 +210,9 @@ func TestBuildStatuses(t *testing.T) { } func TestBuildStatusesNginxErr(t *testing.T) { - addr := []v1beta1.GatewayStatusAddress{ + addr := []v1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(v1.IPAddressType), Value: "1.2.3.4", }, } @@ -220,15 +220,15 @@ func TestBuildStatusesNginxErr(t *testing.T) { routes := map[types.NamespacedName]*graph.Route{ {Namespace: "test", Name: "hr-valid"}: { Valid: true, - Source: &v1beta1.HTTPRoute{ + Source: &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Generation: 3, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: v1.HTTPRouteSpec{ + CommonRouteSpec: v1.CommonRouteSpec{ + ParentRefs: []v1.ParentReference{ { - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-1"), }, }, }, @@ -291,7 +291,7 @@ func TestBuildStatusesNginxErr(t *testing.T) { ParentStatuses: []status.ParentStatus{ { GatewayNsName: client.ObjectKeyFromObject(gw), - SectionName: helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), + SectionName: helpers.GetPointer[v1.SectionName]("listener-80-1"), Conditions: []conditions.Condition{ staticConds.NewRouteResolvedRefs(), staticConds.NewRouteGatewayNotProgrammed(staticConds.RouteMessageFailedNginxReload), @@ -312,7 +312,7 @@ func TestBuildStatusesNginxErr(t *testing.T) { func TestBuildGatewayClassStatuses(t *testing.T) { tests := []struct { gc *graph.GatewayClass - ignoredClasses map[types.NamespacedName]*v1beta1.GatewayClass + ignoredClasses map[types.NamespacedName]*v1.GatewayClass expected status.GatewayClassStatuses name string }{ @@ -322,7 +322,7 @@ func TestBuildGatewayClassStatuses(t *testing.T) { }, { name: "nil gatewayclass and ignored gatewayclasses", - ignoredClasses: map[types.NamespacedName]*v1beta1.GatewayClass{ + ignoredClasses: map[types.NamespacedName]*v1.GatewayClass{ {Name: "ignored-1"}: { ObjectMeta: metav1.ObjectMeta{ Generation: 1, @@ -348,7 +348,7 @@ func TestBuildGatewayClassStatuses(t *testing.T) { { name: "valid gatewayclass", gc: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{ + Source: &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-gc", Generation: 1, @@ -375,9 +375,9 @@ func TestBuildGatewayClassStatuses(t *testing.T) { } func TestBuildGatewayStatuses(t *testing.T) { - addr := []v1beta1.GatewayStatusAddress{ + addr := []v1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(v1.IPAddressType), Value: "1.2.3.4", }, } @@ -385,7 +385,7 @@ func TestBuildGatewayStatuses(t *testing.T) { tests := []struct { nginxReloadRes nginxReloadResult gateway *graph.Gateway - ignoredGateways map[types.NamespacedName]*v1beta1.Gateway + ignoredGateways map[types.NamespacedName]*v1.Gateway expected status.GatewayStatuses name string }{ @@ -395,7 +395,7 @@ func TestBuildGatewayStatuses(t *testing.T) { }, { name: "nil gateway and ignored gateways", - ignoredGateways: map[types.NamespacedName]*v1beta1.Gateway{ + ignoredGateways: map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "ignored-1"}: { ObjectMeta: metav1.ObjectMeta{ Generation: 1, diff --git a/internal/mode/static/handler.go b/internal/mode/static/handler.go index 5ac9812525..f20980316a 100644 --- a/internal/mode/static/handler.go +++ b/internal/mode/static/handler.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" @@ -235,10 +235,10 @@ func getGatewayAddresses( k8sClient client.Client, svc *v1.Service, podConfig config.GatewayPodConfig, -) ([]v1beta1.GatewayStatusAddress, error) { - podAddress := []v1beta1.GatewayStatusAddress{ +) ([]gatewayv1.GatewayStatusAddress, error) { + podAddress := []gatewayv1.GatewayStatusAddress{ { - Type: helpers.GetPointer(v1beta1.IPAddressType), + Type: helpers.GetPointer(gatewayv1.IPAddressType), Value: podConfig.PodIP, }, } @@ -265,18 +265,18 @@ func getGatewayAddresses( } } - gwAddresses := make([]v1beta1.GatewayStatusAddress, 0, len(addresses)+len(hostnames)) + gwAddresses := make([]gatewayv1.GatewayStatusAddress, 0, len(addresses)+len(hostnames)) for _, addr := range addresses { - statusAddr := v1beta1.GatewayStatusAddress{ - Type: helpers.GetPointer(v1beta1.IPAddressType), + statusAddr := gatewayv1.GatewayStatusAddress{ + Type: helpers.GetPointer(gatewayv1.IPAddressType), Value: addr, } gwAddresses = append(gwAddresses, statusAddr) } for _, hostname := range hostnames { - statusAddr := v1beta1.GatewayStatusAddress{ - Type: helpers.GetPointer(v1beta1.HostnameAddressType), + statusAddr := gatewayv1.GatewayStatusAddress{ + Type: helpers.GetPointer(gatewayv1.HostnameAddressType), Value: hostname, } gwAddresses = append(gwAddresses, statusAddr) diff --git a/internal/mode/static/handler_test.go b/internal/mode/static/handler_test.go index d5f3b5377c..80dc803f30 100644 --- a/internal/mode/static/handler_test.go +++ b/internal/mode/static/handler_test.go @@ -13,7 +13,7 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client/fake" ctlrZap "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" @@ -121,7 +121,7 @@ var _ = Describe("eventHandler", func() { When("a batch has one event", func() { It("should process Upsert", func() { - e := &events.UpsertEvent{Resource: &v1beta1.HTTPRoute{}} + e := &events.UpsertEvent{Resource: &gatewayv1.HTTPRoute{}} batch := []interface{}{e} handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) @@ -132,7 +132,7 @@ var _ = Describe("eventHandler", func() { It("should process Delete", func() { e := &events.DeleteEvent{ - Type: &v1beta1.HTTPRoute{}, + Type: &gatewayv1.HTTPRoute{}, NamespacedName: types.NamespacedName{Namespace: "test", Name: "route"}, } batch := []interface{}{e} @@ -146,9 +146,9 @@ var _ = Describe("eventHandler", func() { When("a batch has multiple events", func() { It("should process events", func() { - upsertEvent := &events.UpsertEvent{Resource: &v1beta1.HTTPRoute{}} + upsertEvent := &events.UpsertEvent{Resource: &gatewayv1.HTTPRoute{}} deleteEvent := &events.DeleteEvent{ - Type: &v1beta1.HTTPRoute{}, + Type: &gatewayv1.HTTPRoute{}, NamespacedName: types.NamespacedName{Namespace: "test", Name: "route"}, } batch := []interface{}{upsertEvent, deleteEvent} @@ -279,7 +279,7 @@ var _ = Describe("eventHandler", func() { }) It("should set the health checker status properly when there are changes", func() { - e := &events.UpsertEvent{Resource: &v1beta1.HTTPRoute{}} + e := &events.UpsertEvent{Resource: &gatewayv1.HTTPRoute{}} batch := []interface{}{e} fakeProcessor.ProcessReturns(true, &graph.Graph{}) @@ -290,7 +290,7 @@ var _ = Describe("eventHandler", func() { }) It("should set the health checker status properly when there are no changes or errors", func() { - e := &events.UpsertEvent{Resource: &v1beta1.HTTPRoute{}} + e := &events.UpsertEvent{Resource: &gatewayv1.HTTPRoute{}} batch := []interface{}{e} Expect(handler.cfg.healthChecker.readyCheck(nil)).ToNot(Succeed()) @@ -299,7 +299,7 @@ var _ = Describe("eventHandler", func() { }) It("should set the health checker status properly when there is an error", func() { - e := &events.UpsertEvent{Resource: &v1beta1.HTTPRoute{}} + e := &events.UpsertEvent{Resource: &gatewayv1.HTTPRoute{}} batch := []interface{}{e} fakeProcessor.ProcessReturns(true, &graph.Graph{}) diff --git a/internal/mode/static/manager.go b/internal/mode/static/manager.go index 3eca635143..3d0c4de05a 100644 --- a/internal/mode/static/manager.go +++ b/internal/mode/static/manager.go @@ -20,6 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/metrics" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" k8spredicate "sigs.k8s.io/controller-runtime/pkg/predicate" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" @@ -50,6 +51,7 @@ var scheme = runtime.NewScheme() func init() { utilruntime.Must(gatewayv1beta1.AddToScheme(scheme)) + utilruntime.Must(gatewayv1.AddToScheme(scheme)) utilruntime.Must(apiv1.AddToScheme(scheme)) utilruntime.Must(discoveryV1.AddToScheme(scheme)) utilruntime.Must(ngfAPI.AddToScheme(scheme)) @@ -244,13 +246,13 @@ func registerControllers( // make sure to also update prepareFirstEventBatchPreparerArgs() controllerRegCfgs := []ctlrCfg{ { - objectType: &gatewayv1beta1.GatewayClass{}, + objectType: &gatewayv1.GatewayClass{}, options: []controller.Option{ controller.WithK8sPredicate(predicate.GatewayClassPredicate{ControllerName: cfg.GatewayCtlrName}), }, }, { - objectType: &gatewayv1beta1.Gateway{}, + objectType: &gatewayv1.Gateway{}, options: func() []controller.Option { if cfg.GatewayNsName != nil { return []controller.Option{ @@ -261,7 +263,7 @@ func registerControllers( }(), }, { - objectType: &gatewayv1beta1.HTTPRoute{}, + objectType: &gatewayv1.HTTPRoute{}, }, { objectType: &apiv1.Service{}, @@ -340,23 +342,23 @@ func prepareFirstEventBatchPreparerArgs( gwNsName *types.NamespacedName, ) ([]client.Object, []client.ObjectList) { objects := []client.Object{ - &gatewayv1beta1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}}, + &gatewayv1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}}, } objectLists := []client.ObjectList{ &apiv1.ServiceList{}, &apiv1.SecretList{}, &apiv1.NamespaceList{}, &discoveryV1.EndpointSliceList{}, - &gatewayv1beta1.HTTPRouteList{}, + &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, } if gwNsName == nil { - objectLists = append(objectLists, &gatewayv1beta1.GatewayList{}) + objectLists = append(objectLists, &gatewayv1.GatewayList{}) } else { objects = append( objects, - &gatewayv1beta1.Gateway{ObjectMeta: metav1.ObjectMeta{Name: gwNsName.Name, Namespace: gwNsName.Namespace}}, + &gatewayv1.Gateway{ObjectMeta: metav1.ObjectMeta{Name: gwNsName.Name, Namespace: gwNsName.Namespace}}, ) } diff --git a/internal/mode/static/manager_test.go b/internal/mode/static/manager_test.go index 4bd34230ed..fd8e540adb 100644 --- a/internal/mode/static/manager_test.go +++ b/internal/mode/static/manager_test.go @@ -10,6 +10,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/config" @@ -28,15 +29,15 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { name: "gwNsName is nil", gwNsName: nil, expectedObjects: []client.Object{ - &gatewayv1beta1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: "nginx"}}, + &gatewayv1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: "nginx"}}, }, expectedObjectLists: []client.ObjectList{ &apiv1.ServiceList{}, &apiv1.SecretList{}, &apiv1.NamespaceList{}, &discoveryV1.EndpointSliceList{}, - &gatewayv1beta1.HTTPRouteList{}, - &gatewayv1beta1.GatewayList{}, + &gatewayv1.HTTPRouteList{}, + &gatewayv1.GatewayList{}, &gatewayv1beta1.ReferenceGrantList{}, }, }, @@ -47,15 +48,15 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { Name: "my-gateway", }, expectedObjects: []client.Object{ - &gatewayv1beta1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: "nginx"}}, - &gatewayv1beta1.Gateway{ObjectMeta: metav1.ObjectMeta{Name: "my-gateway", Namespace: "test"}}, + &gatewayv1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: "nginx"}}, + &gatewayv1.Gateway{ObjectMeta: metav1.ObjectMeta{Name: "my-gateway", Namespace: "test"}}, }, expectedObjectLists: []client.ObjectList{ &apiv1.ServiceList{}, &apiv1.SecretList{}, &apiv1.NamespaceList{}, &discoveryV1.EndpointSliceList{}, - &gatewayv1beta1.HTTPRouteList{}, + &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, }, }, diff --git a/internal/mode/static/nginx/config/servers.go b/internal/mode/static/nginx/config/servers.go index d91d33d8f1..9b77d71ba0 100644 --- a/internal/mode/static/nginx/config/servers.go +++ b/internal/mode/static/nginx/config/servers.go @@ -103,10 +103,10 @@ func createLocations(pathRules []dataplane.PathRule, listenerPort int32) []http. } // There could be a case when the filter has the type set but not the corresponding field. - // For example, type is v1beta1.HTTPRouteFilterRequestRedirect, but RequestRedirect field is nil. + // For example, type is v1.HTTPRouteFilterRequestRedirect, but RequestRedirect field is nil. // The imported Webhook validation webhook catches that. - // FIXME(pleshakov): Ensure dataplane.Configuration -related types don't include v1beta1 types, so that + // FIXME(pleshakov): Ensure dataplane.Configuration -related types don't include v1 types, so that // we don't need to make any assumptions like above here. After fixing this, ensure that there is a test // for checking the imported Webhook validation catches the case above. // https://github.com/nginxinc/nginx-gateway-fabric/issues/660 diff --git a/internal/mode/static/state/change_processor.go b/internal/mode/static/state/change_processor.go index 368556a424..42d92f8fce 100644 --- a/internal/mode/static/state/change_processor.go +++ b/internal/mode/static/state/change_processor.go @@ -13,9 +13,10 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + v1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1beta1" - gwapivalidation "sigs.k8s.io/gateway-api/apis/v1beta1/validation" + gwapivalidation "sigs.k8s.io/gateway-api/apis/v1/validation" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/relationship" @@ -87,9 +88,9 @@ type ChangeProcessorImpl struct { // NewChangeProcessorImpl creates a new ChangeProcessorImpl for the Gateway resource with the configured namespace name. func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl { clusterStore := graph.ClusterState{ - GatewayClasses: make(map[types.NamespacedName]*v1beta1.GatewayClass), - Gateways: make(map[types.NamespacedName]*v1beta1.Gateway), - HTTPRoutes: make(map[types.NamespacedName]*v1beta1.HTTPRoute), + GatewayClasses: make(map[types.NamespacedName]*v1.GatewayClass), + Gateways: make(map[types.NamespacedName]*v1.Gateway), + HTTPRoutes: make(map[types.NamespacedName]*v1.HTTPRoute), Services: make(map[types.NamespacedName]*apiv1.Service), Namespaces: make(map[types.NamespacedName]*apiv1.Namespace), ReferenceGrants: make(map[types.NamespacedName]*v1beta1.ReferenceGrant), @@ -119,17 +120,17 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl { extractGVK, []changeTrackingUpdaterObjectTypeCfg{ { - gvk: extractGVK(&v1beta1.GatewayClass{}), + gvk: extractGVK(&v1.GatewayClass{}), store: newObjectStoreMapAdapter(clusterStore.GatewayClasses), trackUpsertDelete: true, }, { - gvk: extractGVK(&v1beta1.Gateway{}), + gvk: extractGVK(&v1.Gateway{}), store: newObjectStoreMapAdapter(clusterStore.Gateways), trackUpsertDelete: true, }, { - gvk: extractGVK(&v1beta1.HTTPRoute{}), + gvk: extractGVK(&v1.HTTPRoute{}), store: newObjectStoreMapAdapter(clusterStore.HTTPRoutes), trackUpsertDelete: true, }, @@ -173,10 +174,10 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl { // the webhook doesn't validate them. // It only validates a GatewayClass update that requires the previous version of the resource, // which NGF cannot reliably provide - for example, after NGF restarts). - // https://github.com/kubernetes-sigs/gateway-api/blob/v0.8.1/apis/v1beta1/validation/gatewayclass.go#L28 - case *v1beta1.Gateway: + // https://github.com/kubernetes-sigs/gateway-api/blob/v1.0.0/apis/v1/validation/gatewayclass.go#L28 + case *v1.Gateway: err = gwapivalidation.ValidateGateway(o).ToAggregate() - case *v1beta1.HTTPRoute: + case *v1.HTTPRoute: err = gwapivalidation.ValidateHTTPRoute(o).ToAggregate() } diff --git a/internal/mode/static/state/change_processor_test.go b/internal/mode/static/state/change_processor_test.go index 1a3fee8bb4..8d1a397990 100644 --- a/internal/mode/static/state/change_processor_test.go +++ b/internal/mode/static/state/change_processor_test.go @@ -13,6 +13,7 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log/zap" + v1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/apis/v1beta1" @@ -37,42 +38,42 @@ func createRoute( name string, gateway string, hostname string, - backendRefs ...v1beta1.HTTPBackendRef, -) *v1beta1.HTTPRoute { - return &v1beta1.HTTPRoute{ + backendRefs ...v1.HTTPBackendRef, +) *v1.HTTPRoute { + return &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, Generation: 1, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: v1.HTTPRouteSpec{ + CommonRouteSpec: v1.CommonRouteSpec{ + ParentRefs: []v1.ParentReference{ { - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), - Name: v1beta1.ObjectName(gateway), - SectionName: (*v1beta1.SectionName)( + Namespace: (*v1.Namespace)(helpers.GetPointer("test")), + Name: v1.ObjectName(gateway), + SectionName: (*v1.SectionName)( helpers.GetPointer("listener-80-1"), ), }, { - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), - Name: v1beta1.ObjectName(gateway), - SectionName: (*v1beta1.SectionName)( + Namespace: (*v1.Namespace)(helpers.GetPointer("test")), + Name: v1.ObjectName(gateway), + SectionName: (*v1.SectionName)( helpers.GetPointer("listener-443-1"), ), }, }, }, - Hostnames: []v1beta1.Hostname{ - v1beta1.Hostname(hostname), + Hostnames: []v1.Hostname{ + v1.Hostname(hostname), }, - Rules: []v1beta1.HTTPRouteRule{ + Rules: []v1.HTTPRouteRule{ { - Matches: []v1beta1.HTTPRouteMatch{ + Matches: []v1.HTTPRouteMatch{ { - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + Path: &v1.HTTPPathMatch{ + Type: helpers.GetPointer(v1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), }, }, @@ -84,42 +85,42 @@ func createRoute( } } -func createGateway(name string) *v1beta1.Gateway { - return &v1beta1.Gateway{ +func createGateway(name string) *v1.Gateway { + return &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, Generation: 1, }, - Spec: v1beta1.GatewaySpec{ + Spec: v1.GatewaySpec{ GatewayClassName: gcName, - Listeners: []v1beta1.Listener{ + Listeners: []v1.Listener{ { Name: "listener-80-1", Hostname: nil, Port: 80, - Protocol: v1beta1.HTTPProtocolType, + Protocol: v1.HTTPProtocolType, }, }, }, } } -func createGatewayWithTLSListener(name string, tlsSecret *apiv1.Secret) *v1beta1.Gateway { +func createGatewayWithTLSListener(name string, tlsSecret *apiv1.Secret) *v1.Gateway { gw := createGateway(name) - l := v1beta1.Listener{ + l := v1.Listener{ Name: "listener-443-1", Hostname: nil, Port: 443, - Protocol: v1beta1.HTTPSProtocolType, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + Protocol: v1.HTTPSProtocolType, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: (*v1beta1.Kind)(helpers.GetPointer("Secret")), - Name: v1beta1.ObjectName(tlsSecret.Name), - Namespace: (*v1beta1.Namespace)(&tlsSecret.Namespace), + Kind: (*v1.Kind)(helpers.GetPointer("Secret")), + Name: v1.ObjectName(tlsSecret.Name), + Namespace: (*v1.Namespace)(&tlsSecret.Namespace), }, }, }, @@ -131,20 +132,20 @@ func createGatewayWithTLSListener(name string, tlsSecret *apiv1.Secret) *v1beta1 func createRouteWithMultipleRules( name, gateway, hostname string, - rules []v1beta1.HTTPRouteRule, -) *v1beta1.HTTPRoute { + rules []v1.HTTPRouteRule, +) *v1.HTTPRoute { hr := createRoute(name, gateway, hostname) hr.Spec.Rules = rules return hr } -func createHTTPRule(path string, backendRefs ...v1beta1.HTTPBackendRef) v1beta1.HTTPRouteRule { - return v1beta1.HTTPRouteRule{ - Matches: []v1beta1.HTTPRouteMatch{ +func createHTTPRule(path string, backendRefs ...v1.HTTPBackendRef) v1.HTTPRouteRule { + return v1.HTTPRouteRule{ + Matches: []v1.HTTPRouteMatch{ { - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + Path: &v1.HTTPPathMatch{ + Type: helpers.GetPointer(v1.PathMatchPathPrefix), Value: &path, }, }, @@ -154,17 +155,17 @@ func createHTTPRule(path string, backendRefs ...v1beta1.HTTPBackendRef) v1beta1. } func createBackendRef( - kind *v1beta1.Kind, - name v1beta1.ObjectName, - namespace *v1beta1.Namespace, -) v1beta1.HTTPBackendRef { - return v1beta1.HTTPBackendRef{ - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ + kind *v1.Kind, + name v1.ObjectName, + namespace *v1.Namespace, +) v1.HTTPBackendRef { + return v1.HTTPBackendRef{ + BackendRef: v1.BackendRef{ + BackendObjectReference: v1.BackendObjectReference{ Kind: kind, Name: name, Namespace: namespace, - Port: helpers.GetPointer[v1beta1.PortNumber](80), + Port: helpers.GetPointer[v1.PortNumber](80), }, }, } @@ -181,6 +182,7 @@ func createAlwaysValidValidators() validation.Validators { func createScheme() *runtime.Scheme { scheme := runtime.NewScheme() + utilruntime.Must(v1.AddToScheme(scheme)) utilruntime.Must(v1beta1.AddToScheme(scheme)) utilruntime.Must(apiv1.AddToScheme(scheme)) utilruntime.Must(discoveryV1.AddToScheme(scheme)) @@ -243,12 +245,12 @@ var _ = Describe("ChangeProcessor", func() { format.MaxLength = 0 Describe("Normal cases of processing changes", func() { var ( - gc = &v1beta1.GatewayClass{ + gc = &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, Generation: 1, }, - Spec: v1beta1.GatewayClassSpec{ + Spec: v1.GatewayClassSpec{ ControllerName: controllerName, }, } @@ -268,10 +270,10 @@ var _ = Describe("ChangeProcessor", func() { Describe("Process gateway resources", Ordered, func() { var ( - gcUpdated *v1beta1.GatewayClass + gcUpdated *v1.GatewayClass diffNsTLSSecret, sameNsTLSSecret *apiv1.Secret - hr1, hr1Updated, hr2 *v1beta1.HTTPRoute - gw1, gw1Updated, gw2 *v1beta1.Gateway + hr1, hr1Updated, hr2 *v1.HTTPRoute + gw1, gw1Updated, gw2 *v1.Gateway refGrant1, refGrant2 *v1beta1.ReferenceGrant expGraph *graph.Graph expRouteHR1, expRouteHR2 *graph.Route @@ -281,13 +283,13 @@ var _ = Describe("ChangeProcessor", func() { gcUpdated = gc.DeepCopy() gcUpdated.Generation++ - crossNsBackendRef := v1beta1.HTTPBackendRef{ - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ - Kind: helpers.GetPointer[v1beta1.Kind]("Service"), + crossNsBackendRef := v1.HTTPBackendRef{ + BackendRef: v1.BackendRef{ + BackendObjectReference: v1.BackendObjectReference{ + Kind: helpers.GetPointer[v1.Kind]("Service"), Name: "service", - Namespace: helpers.GetPointer[v1beta1.Namespace]("service-ns"), - Port: helpers.GetPointer[v1beta1.PortNumber](80), + Namespace: helpers.GetPointer[v1.Namespace]("service-ns"), + Port: helpers.GetPointer[v1.PortNumber](80), }, }, } @@ -309,7 +311,7 @@ var _ = Describe("ChangeProcessor", func() { Spec: v1beta1.ReferenceGrantSpec{ From: []v1beta1.ReferenceGrantFrom{ { - Group: v1beta1.GroupName, + Group: v1.GroupName, Kind: "Gateway", Namespace: "test", }, @@ -330,7 +332,7 @@ var _ = Describe("ChangeProcessor", func() { Spec: v1beta1.ReferenceGrantSpec{ From: []v1beta1.ReferenceGrantFrom{ { - Group: v1beta1.GroupName, + Group: v1.GroupName, Kind: "HTTPRoute", Namespace: "test", }, @@ -452,7 +454,7 @@ var _ = Describe("ChangeProcessor", func() { Routes: map[types.NamespacedName]*graph.Route{ {Namespace: "test", Name: "hr-1"}: expRouteHR1, }, - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []v1.RouteGroupKind{{Kind: "HTTPRoute"}}, }, "listener-443-1": { Source: gw1.Spec.Listeners[1], @@ -461,12 +463,12 @@ var _ = Describe("ChangeProcessor", func() { {Namespace: "test", Name: "hr-1"}: expRouteHR1, }, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(diffNsTLSSecret)), - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []v1.RouteGroupKind{{Kind: "HTTPRoute"}}, }, }, Valid: true, }, - IgnoredGateways: map[types.NamespacedName]*v1beta1.Gateway{}, + IgnoredGateways: map[types.NamespacedName]*v1.Gateway{}, Routes: map[types.NamespacedName]*graph.Route{ {Namespace: "test", Name: "hr-1"}: expRouteHR1, }, @@ -547,7 +549,7 @@ var _ = Describe("ChangeProcessor", func() { Conditions: staticConds.NewListenerRefNotPermitted( "Certificate ref to secret cert-ns/different-ns-tls-secret not permitted by any ReferenceGrant", ), - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []v1.RouteGroupKind{{Kind: "HTTPRoute"}}, } expAttachment := &graph.ParentRefAttachmentStatus{ @@ -718,7 +720,7 @@ var _ = Describe("ChangeProcessor", func() { It("returns populated graph using first gateway", func() { processor.CaptureUpsertChange(gw2) - expGraph.IgnoredGateways = map[types.NamespacedName]*v1beta1.Gateway{ + expGraph.IgnoredGateways = map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "gateway-2"}: gw2, } expGraph.ReferencedSecrets[client.ObjectKeyFromObject(diffNsTLSSecret)] = &graph.Secret{ @@ -734,7 +736,7 @@ var _ = Describe("ChangeProcessor", func() { It("returns populated graph", func() { processor.CaptureUpsertChange(hr2) - expGraph.IgnoredGateways = map[types.NamespacedName]*v1beta1.Gateway{ + expGraph.IgnoredGateways = map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "gateway-2"}: gw2, } expGraph.Routes[hr2Name] = expRouteHR2 @@ -758,7 +760,7 @@ var _ = Describe("ChangeProcessor", func() { When("the first Gateway is deleted", func() { It("returns updated graph", func() { processor.CaptureDeleteChange( - &v1beta1.Gateway{}, + &v1.Gateway{}, types.NamespacedName{Namespace: "test", Name: "gateway-1"}, ) @@ -787,7 +789,7 @@ var _ = Describe("ChangeProcessor", func() { When("the second HTTPRoute is deleted", func() { It("returns updated graph", func() { processor.CaptureDeleteChange( - &v1beta1.HTTPRoute{}, + &v1.HTTPRoute{}, types.NamespacedName{Namespace: "test", Name: "hr-2"}, ) @@ -813,7 +815,7 @@ var _ = Describe("ChangeProcessor", func() { When("the GatewayClass is deleted", func() { It("returns updated graph", func() { processor.CaptureDeleteChange( - &v1beta1.GatewayClass{}, + &v1.GatewayClass{}, types.NamespacedName{Name: gcName}, ) @@ -833,7 +835,7 @@ var _ = Describe("ChangeProcessor", func() { When("the second Gateway is deleted", func() { It("returns empty graph", func() { processor.CaptureDeleteChange( - &v1beta1.Gateway{}, + &v1.Gateway{}, types.NamespacedName{Namespace: "test", Name: "gateway-2"}, ) @@ -845,7 +847,7 @@ var _ = Describe("ChangeProcessor", func() { When("the first HTTPRoute is deleted", func() { It("returns empty graph", func() { processor.CaptureDeleteChange( - &v1beta1.HTTPRoute{}, + &v1.HTTPRoute{}, types.NamespacedName{Namespace: "test", Name: "hr-1"}, ) @@ -857,7 +859,7 @@ var _ = Describe("ChangeProcessor", func() { }) Describe("Process services and endpoints", Ordered, func() { var ( - hr1, hr2, hr3, hrInvalidBackendRef, hrMultipleRules *v1beta1.HTTPRoute + hr1, hr2, hr3, hrInvalidBackendRef, hrMultipleRules *v1.HTTPRoute hr1svc, sharedSvc, bazSvc1, bazSvc2, bazSvc3, invalidSvc, notRefSvc *apiv1.Service hr1slice1, hr1slice2, noRefSlice, missingSvcNameSlice *discoveryV1.EndpointSlice ) @@ -882,9 +884,9 @@ var _ = Describe("ChangeProcessor", func() { } BeforeAll(func() { - testNamespace := v1beta1.Namespace("test") - kindService := v1beta1.Kind("Service") - kindInvalid := v1beta1.Kind("Invalid") + testNamespace := v1.Namespace("test") + kindService := v1.Kind("Service") + kindInvalid := v1.Kind("Invalid") // backend Refs fooRef := createBackendRef(&kindService, "foo-svc", &testNamespace) @@ -904,7 +906,7 @@ var _ = Describe("ChangeProcessor", func() { "hr-multiple-rules", "gw", "mutli.example.com", - []v1beta1.HTTPRouteRule{ + []v1.HTTPRouteRule{ createHTTPRule("/baz-v1", baz1NilNamespace), createHTTPRule("/baz-v2", baz2Ref), createHTTPRule("/baz-v3", baz3Ref), @@ -1198,16 +1200,16 @@ var _ = Describe("ChangeProcessor", func() { }, }, } - gw := &v1beta1.Gateway{ + gw := &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gw", }, - Spec: v1beta1.GatewaySpec{ - Listeners: []v1beta1.Listener{ + Spec: v1.GatewaySpec{ + Listeners: []v1.Listener{ { - AllowedRoutes: &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + AllowedRoutes: &v1.AllowedRoutes{ + Namespaces: &v1.RouteNamespaces{ + From: helpers.GetPointer(v1.NamespacesFromSelector), Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app": "allowed", @@ -1246,9 +1248,9 @@ var _ = Describe("ChangeProcessor", func() { fakeRelationshipCapturer *relationshipfakes.FakeCapturer gcNsName, gwNsName, hrNsName, hr2NsName, rgNsName types.NamespacedName svcNsName, sliceNsName, secretNsName types.NamespacedName - gc, gcUpdated *v1beta1.GatewayClass - gw1, gw1Updated, gw2 *v1beta1.Gateway - hr1, hr1Updated, hr2 *v1beta1.HTTPRoute + gc, gcUpdated *v1.GatewayClass + gw1, gw1Updated, gw2 *v1.Gateway + hr1, hr1Updated, hr2 *v1.HTTPRoute rg1, rg1Updated, rg2 *v1beta1.ReferenceGrant svc *apiv1.Service slice *discoveryV1.EndpointSlice @@ -1268,11 +1270,11 @@ var _ = Describe("ChangeProcessor", func() { gcNsName = types.NamespacedName{Name: "my-class"} - gc = &v1beta1.GatewayClass{ + gc = &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcNsName.Name, }, - Spec: v1beta1.GatewayClassSpec{ + Spec: v1.GatewayClassSpec{ ControllerName: "test.controller", }, } @@ -1282,7 +1284,7 @@ var _ = Describe("ChangeProcessor", func() { gwNsName = types.NamespacedName{Namespace: "test", Name: "gw-1"} - gw1 = &v1beta1.Gateway{ + gw1 = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: gwNsName.Namespace, Name: gwNsName.Name, @@ -1297,7 +1299,7 @@ var _ = Describe("ChangeProcessor", func() { hrNsName = types.NamespacedName{Namespace: "test", Name: "hr-1"} - hr1 = &v1beta1.HTTPRoute{ + hr1 = &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: hrNsName.Namespace, Name: hrNsName.Name, @@ -1410,9 +1412,9 @@ var _ = Describe("ChangeProcessor", func() { When("resources are deleted followed by upserts with the same generations", func() { It("should report changed", func() { // these are changing changes - processor.CaptureDeleteChange(&v1beta1.GatewayClass{}, gcNsName) - processor.CaptureDeleteChange(&v1beta1.Gateway{}, gwNsName) - processor.CaptureDeleteChange(&v1beta1.HTTPRoute{}, hrNsName) + processor.CaptureDeleteChange(&v1.GatewayClass{}, gcNsName) + processor.CaptureDeleteChange(&v1.Gateway{}, gwNsName) + processor.CaptureDeleteChange(&v1.HTTPRoute{}, hrNsName) processor.CaptureDeleteChange(&v1beta1.ReferenceGrant{}, rgNsName) // these are non-changing changes @@ -1425,7 +1427,7 @@ var _ = Describe("ChangeProcessor", func() { }) }) It("should report changed after deleting resources", func() { - processor.CaptureDeleteChange(&v1beta1.HTTPRoute{}, hr2NsName) + processor.CaptureDeleteChange(&v1.HTTPRoute{}, hr2NsName) changed, _ := processor.Process() Expect(changed).To(BeTrue()) @@ -1433,10 +1435,10 @@ var _ = Describe("ChangeProcessor", func() { }) Describe("Deleting non-existing Gateway API resource", func() { It("should not report changed after deleting non-existing", func() { - processor.CaptureDeleteChange(&v1beta1.GatewayClass{}, gcNsName) - processor.CaptureDeleteChange(&v1beta1.Gateway{}, gwNsName) - processor.CaptureDeleteChange(&v1beta1.HTTPRoute{}, hrNsName) - processor.CaptureDeleteChange(&v1beta1.HTTPRoute{}, hr2NsName) + processor.CaptureDeleteChange(&v1.GatewayClass{}, gcNsName) + processor.CaptureDeleteChange(&v1.Gateway{}, gwNsName) + processor.CaptureDeleteChange(&v1.HTTPRoute{}, hrNsName) + processor.CaptureDeleteChange(&v1.HTTPRoute{}, hr2NsName) processor.CaptureDeleteChange(&v1beta1.ReferenceGrant{}, rgNsName) changed, _ := processor.Process() @@ -1602,11 +1604,11 @@ var _ = Describe("ChangeProcessor", func() { processor state.ChangeProcessor fakeEventRecorder *record.FakeRecorder - gc *v1beta1.GatewayClass + gc *v1.GatewayClass gwNsName, hrNsName types.NamespacedName - gw, gwInvalid *v1beta1.Gateway - hr, hrInvalid *v1beta1.HTTPRoute + gw, gwInvalid *v1.Gateway + hr, hrInvalid *v1.HTTPRoute ) BeforeAll(func() { fakeEventRecorder = record.NewFakeRecorder(2 /* number of buffered events */) @@ -1621,12 +1623,12 @@ var _ = Describe("ChangeProcessor", func() { Scheme: createScheme(), }) - gc = &v1beta1.GatewayClass{ + gc = &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, Generation: 1, }, - Spec: v1beta1.GatewayClassSpec{ + Spec: v1.GatewayClassSpec{ ControllerName: controllerName, }, } @@ -1634,19 +1636,19 @@ var _ = Describe("ChangeProcessor", func() { gwNsName = types.NamespacedName{Namespace: "test", Name: "gateway"} hrNsName = types.NamespacedName{Namespace: "test", Name: "hr"} - gw = &v1beta1.Gateway{ + gw = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: gwNsName.Namespace, Name: gwNsName.Name, }, - Spec: v1beta1.GatewaySpec{ + Spec: v1.GatewaySpec{ GatewayClassName: gcName, - Listeners: []v1beta1.Listener{ + Listeners: []v1.Listener{ { Name: "listener-80-1", - Hostname: helpers.GetPointer[v1beta1.Hostname]("foo.example.com"), + Hostname: helpers.GetPointer[v1.Hostname]("foo.example.com"), Port: 80, - Protocol: v1beta1.HTTPProtocolType, + Protocol: v1.HTTPProtocolType, }, }, }, @@ -1654,34 +1656,34 @@ var _ = Describe("ChangeProcessor", func() { gwInvalid = gw.DeepCopy() // cannot have hostname for TCP protocol - gwInvalid.Spec.Listeners[0].Protocol = v1beta1.TCPProtocolType + gwInvalid.Spec.Listeners[0].Protocol = v1.TCPProtocolType - hr = &v1beta1.HTTPRoute{ + hr = &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: hrNsName.Namespace, Name: hrNsName.Name, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: v1.HTTPRouteSpec{ + CommonRouteSpec: v1.CommonRouteSpec{ + ParentRefs: []v1.ParentReference{ { - Namespace: (*v1beta1.Namespace)(&gw.Namespace), - Name: v1beta1.ObjectName(gw.Name), - SectionName: (*v1beta1.SectionName)( + Namespace: (*v1.Namespace)(&gw.Namespace), + Name: v1.ObjectName(gw.Name), + SectionName: (*v1.SectionName)( helpers.GetPointer("listener-80-1"), ), }, }, }, - Hostnames: []v1beta1.Hostname{ + Hostnames: []v1.Hostname{ "foo.example.com", }, - Rules: []v1beta1.HTTPRouteRule{ + Rules: []v1.HTTPRouteRule{ { - Matches: []v1beta1.HTTPRouteMatch{ + Matches: []v1.HTTPRouteMatch{ { - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + Path: &v1.HTTPPathMatch{ + Type: helpers.GetPointer(v1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), }, }, @@ -1795,22 +1797,22 @@ var _ = Describe("ChangeProcessor", func() { }) }) - createInvalidHTTPRoute := func(invalidator func(hr *v1beta1.HTTPRoute)) *v1beta1.HTTPRoute { + createInvalidHTTPRoute := func(invalidator func(hr *v1.HTTPRoute)) *v1.HTTPRoute { hr := createRoute( "hr", "gateway", "foo.example.com", createBackendRef( - helpers.GetPointer[v1beta1.Kind]("Service"), + helpers.GetPointer[v1.Kind]("Service"), "test", - helpers.GetPointer[v1beta1.Namespace]("namespace"), + helpers.GetPointer[v1.Namespace]("namespace"), ), ) invalidator(hr) return hr } - createInvalidGateway := func(invalidator func(gw *v1beta1.Gateway)) *v1beta1.Gateway { + createInvalidGateway := func(invalidator func(gw *v1.Gateway)) *v1.Gateway { gw := createGateway("gateway") invalidator(gw) return gw @@ -1821,7 +1823,7 @@ var _ = Describe("ChangeProcessor", func() { } DescribeTable("Invalid HTTPRoutes", - func(hr *v1beta1.HTTPRoute) { + func(hr *v1.HTTPRoute) { processor.CaptureUpsertChange(hr) changed, graphCfg := processor.Process() @@ -1833,39 +1835,39 @@ var _ = Describe("ChangeProcessor", func() { }, Entry( "duplicate parentRefs", - createInvalidHTTPRoute(func(hr *v1beta1.HTTPRoute) { + createInvalidHTTPRoute(func(hr *v1.HTTPRoute) { hr.Spec.ParentRefs = append(hr.Spec.ParentRefs, hr.Spec.ParentRefs[len(hr.Spec.ParentRefs)-1]) }), ), Entry( "nil path.Type", - createInvalidHTTPRoute(func(hr *v1beta1.HTTPRoute) { + createInvalidHTTPRoute(func(hr *v1.HTTPRoute) { hr.Spec.Rules[0].Matches[0].Path.Type = nil }), ), Entry("nil path.Value", - createInvalidHTTPRoute(func(hr *v1beta1.HTTPRoute) { + createInvalidHTTPRoute(func(hr *v1.HTTPRoute) { hr.Spec.Rules[0].Matches[0].Path.Value = nil }), ), Entry( "nil request.Redirect", - createInvalidHTTPRoute(func(hr *v1beta1.HTTPRoute) { - hr.Spec.Rules[0].Filters = append(hr.Spec.Rules[0].Filters, v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, + createInvalidHTTPRoute(func(hr *v1.HTTPRoute) { + hr.Spec.Rules[0].Filters = append(hr.Spec.Rules[0].Filters, v1.HTTPRouteFilter{ + Type: v1.HTTPRouteFilterRequestRedirect, RequestRedirect: nil, }) }), ), Entry("nil port in BackendRef", - createInvalidHTTPRoute(func(hr *v1beta1.HTTPRoute) { + createInvalidHTTPRoute(func(hr *v1.HTTPRoute) { hr.Spec.Rules[0].BackendRefs[0].Port = nil }), ), ) DescribeTable("Invalid Gateway resources", - func(gw *v1beta1.Gateway) { + func(gw *v1.Gateway) { processor.CaptureUpsertChange(gw) changed, graphCfg := processor.Process() @@ -1876,32 +1878,32 @@ var _ = Describe("ChangeProcessor", func() { assertRejectedEvent() }, Entry("tls in HTTP listener", - createInvalidGateway(func(gw *v1beta1.Gateway) { - gw.Spec.Listeners[0].TLS = &v1beta1.GatewayTLSConfig{} + createInvalidGateway(func(gw *v1.Gateway) { + gw.Spec.Listeners[0].TLS = &v1.GatewayTLSConfig{} }), ), Entry("tls is nil in HTTPS listener", - createInvalidGateway(func(gw *v1beta1.Gateway) { - gw.Spec.Listeners[0].Protocol = v1beta1.HTTPSProtocolType + createInvalidGateway(func(gw *v1.Gateway) { + gw.Spec.Listeners[0].Protocol = v1.HTTPSProtocolType gw.Spec.Listeners[0].TLS = nil }), ), Entry("zero certificateRefs in HTTPS listener", - createInvalidGateway(func(gw *v1beta1.Gateway) { - gw.Spec.Listeners[0].Protocol = v1beta1.HTTPSProtocolType - gw.Spec.Listeners[0].TLS = &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), + createInvalidGateway(func(gw *v1.Gateway) { + gw.Spec.Listeners[0].Protocol = v1.HTTPSProtocolType + gw.Spec.Listeners[0].TLS = &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), CertificateRefs: nil, } }), ), Entry("listener hostnames conflict", - createInvalidGateway(func(gw *v1beta1.Gateway) { - gw.Spec.Listeners = append(gw.Spec.Listeners, v1beta1.Listener{ + createInvalidGateway(func(gw *v1.Gateway) { + gw.Spec.Listeners = append(gw.Spec.Listeners, v1.Listener{ Name: "listener-80-2", Hostname: nil, Port: 80, - Protocol: v1beta1.HTTPProtocolType, + Protocol: v1.HTTPProtocolType, }) }), ), diff --git a/internal/mode/static/state/conditions/conditions.go b/internal/mode/static/state/conditions/conditions.go index 2154a3197e..2703da1efc 100644 --- a/internal/mode/static/state/conditions/conditions.go +++ b/internal/mode/static/state/conditions/conditions.go @@ -4,7 +4,7 @@ import ( "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" @@ -13,7 +13,7 @@ import ( const ( // ListenerReasonUnsupportedValue is used with the "Accepted" condition when a value of a field in a Listener // is invalid or not supported. - ListenerReasonUnsupportedValue v1beta1.ListenerConditionReason = "UnsupportedValue" + ListenerReasonUnsupportedValue v1.ListenerConditionReason = "UnsupportedValue" // ListenerMessageFailedNginxReload is a message used with ListenerConditionProgrammed (false) // when nginx fails to reload. @@ -29,23 +29,23 @@ const ( RouteReasonInvalidGateway = "InvalidGateway" // RouteReasonInvalidListener is used with the "Accepted" condition when the Route references an invalid listener. - RouteReasonInvalidListener v1beta1.RouteConditionReason = "InvalidListener" + RouteReasonInvalidListener v1.RouteConditionReason = "InvalidListener" // RouteReasonGatewayNotProgrammed is used when the associated Gateway is not programmed. // Used with Accepted (false). - RouteReasonGatewayNotProgrammed v1beta1.RouteConditionReason = "GatewayNotProgrammed" + RouteReasonGatewayNotProgrammed v1.RouteConditionReason = "GatewayNotProgrammed" // GatewayReasonGatewayConflict indicates there are multiple Gateway resources to choose from, // and we ignored the resource in question and picked another Gateway as the winner. // This reason is used with GatewayConditionAccepted (false). - GatewayReasonGatewayConflict v1beta1.GatewayConditionReason = "GatewayConflict" + GatewayReasonGatewayConflict v1.GatewayConditionReason = "GatewayConflict" // GatewayMessageGatewayConflict is a message that describes GatewayReasonGatewayConflict. GatewayMessageGatewayConflict = "The resource is ignored due to a conflicting Gateway resource" // GatewayReasonUnsupportedValue is used with GatewayConditionAccepted (false) when a value of a field in a Gateway // is invalid or not supported. - GatewayReasonUnsupportedValue v1beta1.GatewayConditionReason = "UnsupportedValue" + GatewayReasonUnsupportedValue v1.GatewayConditionReason = "UnsupportedValue" // GatewayMessageFailedNginxReload is a message used with GatewayConditionProgrammed (false) // when nginx fails to reload. @@ -57,12 +57,6 @@ const ( RouteMessageFailedNginxReload = GatewayMessageFailedNginxReload + ". NGINX may still be configured " + "for this HTTPRoute. However, future updates to this resource will not be configured until the Gateway " + "is programmed again" - // RouteConditionPartiallyInvalid is a condition which indicates that the Route contains - // a combination of both valid and invalid rules. - // - // FIXME(bjee19): Update to Gateway sig v1 version when released. - // https://github.com/nginxinc/nginx-gateway-fabric/issues/1168 - RouteConditionPartiallyInvalid v1beta1.RouteConditionType = "PartiallyInvalid" ) // DeduplicateConditions removes duplicate conditions based on the condition type. @@ -119,9 +113,9 @@ func NewDefaultRouteConditions() []conditions.Condition { // any listener. func NewRouteNotAllowedByListeners() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonNotAllowedByListeners), + Reason: string(v1.RouteReasonNotAllowedByListeners), Message: "HTTPRoute is not allowed by any listener", } } @@ -130,9 +124,9 @@ func NewRouteNotAllowedByListeners() conditions.Condition { // does not match the hostnames of the HTTPRoute. func NewRouteNoMatchingListenerHostname() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonNoMatchingListenerHostname), + Reason: string(v1.RouteReasonNoMatchingListenerHostname), Message: "Listener hostname does not match the HTTPRoute hostnames", } } @@ -140,9 +134,9 @@ func NewRouteNoMatchingListenerHostname() conditions.Condition { // NewRouteAccepted returns a Condition that indicates that the HTTPRoute is accepted. func NewRouteAccepted() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionTrue, - Reason: string(v1beta1.RouteReasonAccepted), + Reason: string(v1.RouteReasonAccepted), Message: "The route is accepted", } } @@ -150,9 +144,9 @@ func NewRouteAccepted() conditions.Condition { // NewRouteUnsupportedValue returns a Condition that indicates that the HTTPRoute includes an unsupported value. func NewRouteUnsupportedValue(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonUnsupportedValue), + Reason: string(v1.RouteReasonUnsupportedValue), Message: msg, } } @@ -165,9 +159,9 @@ func NewRouteUnsupportedValue(msg string) conditions.Condition { // See https://github.com/kubernetes-sigs/gateway-api/blob/37d81593e5a965ed76582dbc1a2f56bbd57c0622/apis/v1/shared_types.go#L408-L413 func NewRoutePartiallyInvalid(msg string) conditions.Condition { return conditions.Condition{ - Type: string(RouteConditionPartiallyInvalid), + Type: string(v1.RouteConditionPartiallyInvalid), Status: metav1.ConditionTrue, - Reason: string(v1beta1.RouteReasonUnsupportedValue), + Reason: string(v1.RouteReasonUnsupportedValue), Message: "Dropped Rule(s): " + msg, } } @@ -176,7 +170,7 @@ func NewRoutePartiallyInvalid(msg string) conditions.Condition { // invalid listener. func NewRouteInvalidListener() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, Reason: string(RouteReasonInvalidListener), Message: "Listener is invalid for this parent ref", @@ -186,9 +180,9 @@ func NewRouteInvalidListener() conditions.Condition { // NewRouteResolvedRefs returns a Condition that indicates that all the references on the Route are resolved. func NewRouteResolvedRefs() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), + Type: string(v1.RouteConditionResolvedRefs), Status: metav1.ConditionTrue, - Reason: string(v1beta1.RouteReasonResolvedRefs), + Reason: string(v1.RouteReasonResolvedRefs), Message: "All references are resolved", } } @@ -197,9 +191,9 @@ func NewRouteResolvedRefs() conditions.Condition { // invalid kind. func NewRouteBackendRefInvalidKind(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), + Type: string(v1.RouteConditionResolvedRefs), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonInvalidKind), + Reason: string(v1.RouteReasonInvalidKind), Message: msg, } } @@ -208,9 +202,9 @@ func NewRouteBackendRefInvalidKind(msg string) conditions.Condition { // is not permitted. func NewRouteBackendRefRefNotPermitted(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), + Type: string(v1.RouteConditionResolvedRefs), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonRefNotPermitted), + Reason: string(v1.RouteReasonRefNotPermitted), Message: msg, } } @@ -219,9 +213,9 @@ func NewRouteBackendRefRefNotPermitted(msg string) conditions.Condition { // points to non-existing backend. func NewRouteBackendRefRefBackendNotFound(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), + Type: string(v1.RouteConditionResolvedRefs), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonBackendNotFound), + Reason: string(v1.RouteReasonBackendNotFound), Message: msg, } } @@ -230,7 +224,7 @@ func NewRouteBackendRefRefBackendNotFound(msg string) conditions.Condition { // an unsupported value. func NewRouteBackendRefUnsupportedValue(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), + Type: string(v1.RouteConditionResolvedRefs), Status: metav1.ConditionFalse, Reason: RouteReasonBackendRefUnsupportedValue, Message: msg, @@ -241,7 +235,7 @@ func NewRouteBackendRefUnsupportedValue(msg string) conditions.Condition { // references is invalid. func NewRouteInvalidGateway() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, Reason: RouteReasonInvalidGateway, Message: "Gateway is invalid", @@ -252,9 +246,9 @@ func NewRouteInvalidGateway() conditions.Condition { // it specifies a Port and/or SectionName that does not match any Listeners in the Gateway. func NewRouteNoMatchingParent() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.RouteReasonNoMatchingParent), + Reason: string(v1.RouteReasonNoMatchingParent), Message: "Listener is not found for this parent ref", } } @@ -263,7 +257,7 @@ func NewRouteNoMatchingParent() conditions.Condition { // which does not guarantee that the HTTPRoute has been configured. func NewRouteGatewayNotProgrammed(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.RouteConditionAccepted), + Type: string(v1.RouteConditionAccepted), Status: metav1.ConditionFalse, Reason: string(RouteReasonGatewayNotProgrammed), Message: msg, @@ -283,9 +277,9 @@ func NewDefaultListenerConditions() []conditions.Condition { // NewListenerAccepted returns a Condition that indicates that the Listener is accepted. func NewListenerAccepted() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.ListenerConditionAccepted), + Type: string(v1.ListenerConditionAccepted), Status: metav1.ConditionTrue, - Reason: string(v1beta1.ListenerReasonAccepted), + Reason: string(v1.ListenerReasonAccepted), Message: "Listener is accepted", } } @@ -293,9 +287,9 @@ func NewListenerAccepted() conditions.Condition { // NewListenerProgrammed returns a Condition that indicates the Listener is programmed. func NewListenerProgrammed() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.ListenerConditionProgrammed), + Type: string(v1.ListenerConditionProgrammed), Status: metav1.ConditionTrue, - Reason: string(v1beta1.ListenerReasonProgrammed), + Reason: string(v1.ListenerReasonProgrammed), Message: "Listener is programmed", } } @@ -303,9 +297,9 @@ func NewListenerProgrammed() conditions.Condition { // NewListenerResolvedRefs returns a Condition that indicates that all references in a Listener are resolved. func NewListenerResolvedRefs() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.ListenerConditionResolvedRefs), + Type: string(v1.ListenerConditionResolvedRefs), Status: metav1.ConditionTrue, - Reason: string(v1beta1.ListenerReasonResolvedRefs), + Reason: string(v1.ListenerReasonResolvedRefs), Message: "All references are resolved", } } @@ -313,9 +307,9 @@ func NewListenerResolvedRefs() conditions.Condition { // NewListenerNoConflicts returns a Condition that indicates that there are no conflicts in a Listener. func NewListenerNoConflicts() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.ListenerConditionConflicted), + Type: string(v1.ListenerConditionConflicted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonNoConflicts), + Reason: string(v1.ListenerReasonNoConflicts), Message: "No conflicts", } } @@ -324,9 +318,9 @@ func NewListenerNoConflicts() conditions.Condition { // semantically or syntactically invalid. The provided message contains the details of why the Listener is invalid. func NewListenerNotProgrammedInvalid(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.ListenerConditionProgrammed), + Type: string(v1.ListenerConditionProgrammed), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonInvalid), + Reason: string(v1.ListenerReasonInvalid), Message: msg, } } @@ -336,7 +330,7 @@ func NewListenerNotProgrammedInvalid(msg string) conditions.Condition { func NewListenerUnsupportedValue(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.ListenerConditionAccepted), + Type: string(v1.ListenerConditionAccepted), Status: metav1.ConditionFalse, Reason: string(ListenerReasonUnsupportedValue), Message: msg, @@ -349,15 +343,15 @@ func NewListenerUnsupportedValue(msg string) []conditions.Condition { func NewListenerInvalidCertificateRef(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.ListenerConditionAccepted), + Type: string(v1.ListenerConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonInvalidCertificateRef), + Reason: string(v1.ListenerReasonInvalidCertificateRef), Message: msg, }, { - Type: string(v1beta1.ListenerReasonResolvedRefs), + Type: string(v1.ListenerReasonResolvedRefs), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonInvalidCertificateRef), + Reason: string(v1.ListenerReasonInvalidCertificateRef), Message: msg, }, NewListenerNotProgrammedInvalid(msg), @@ -369,9 +363,9 @@ func NewListenerInvalidCertificateRef(msg string) []conditions.Condition { func NewListenerInvalidRouteKinds(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.ListenerReasonResolvedRefs), + Type: string(v1.ListenerReasonResolvedRefs), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonInvalidRouteKinds), + Reason: string(v1.ListenerReasonInvalidRouteKinds), Message: msg, }, NewListenerNotProgrammedInvalid(msg), @@ -383,15 +377,15 @@ func NewListenerInvalidRouteKinds(msg string) []conditions.Condition { func NewListenerProtocolConflict(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.ListenerConditionAccepted), + Type: string(v1.ListenerConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonProtocolConflict), + Reason: string(v1.ListenerReasonProtocolConflict), Message: msg, }, { - Type: string(v1beta1.ListenerConditionConflicted), + Type: string(v1.ListenerConditionConflicted), Status: metav1.ConditionTrue, - Reason: string(v1beta1.ListenerReasonProtocolConflict), + Reason: string(v1.ListenerReasonProtocolConflict), Message: msg, }, NewListenerNotProgrammedInvalid(msg), @@ -402,9 +396,9 @@ func NewListenerProtocolConflict(msg string) []conditions.Condition { func NewListenerUnsupportedProtocol(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.ListenerConditionAccepted), + Type: string(v1.ListenerConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonUnsupportedProtocol), + Reason: string(v1.ListenerReasonUnsupportedProtocol), Message: msg, }, NewListenerNotProgrammedInvalid(msg), @@ -416,15 +410,15 @@ func NewListenerUnsupportedProtocol(msg string) []conditions.Condition { func NewListenerRefNotPermitted(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.ListenerConditionAccepted), + Type: string(v1.ListenerConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonRefNotPermitted), + Reason: string(v1.ListenerReasonRefNotPermitted), Message: msg, }, { - Type: string(v1beta1.ListenerReasonResolvedRefs), + Type: string(v1.ListenerReasonResolvedRefs), Status: metav1.ConditionFalse, - Reason: string(v1beta1.ListenerReasonRefNotPermitted), + Reason: string(v1.ListenerReasonRefNotPermitted), Message: msg, }, NewListenerNotProgrammedInvalid(msg), @@ -434,9 +428,9 @@ func NewListenerRefNotPermitted(msg string) []conditions.Condition { // NewGatewayClassInvalidParameters returns a Condition that indicates that the GatewayClass has invalid parameters. func NewGatewayClassInvalidParameters(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.GatewayClassConditionStatusAccepted), + Type: string(v1.GatewayClassConditionStatusAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.GatewayClassReasonInvalidParameters), + Reason: string(v1.GatewayClassReasonInvalidParameters), Message: msg, } } @@ -452,9 +446,9 @@ func NewDefaultGatewayConditions() []conditions.Condition { // NewGatewayAccepted returns a Condition that indicates the Gateway is accepted. func NewGatewayAccepted() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionTrue, - Reason: string(v1beta1.GatewayReasonAccepted), + Reason: string(v1.GatewayReasonAccepted), Message: "Gateway is accepted", } } @@ -463,7 +457,7 @@ func NewGatewayAccepted() conditions.Condition { func NewGatewayConflict() []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionFalse, Reason: string(GatewayReasonGatewayConflict), Message: GatewayMessageGatewayConflict, @@ -476,9 +470,9 @@ func NewGatewayConflict() []conditions.Condition { // but has at least one listener that is invalid. func NewGatewayAcceptedListenersNotValid() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionTrue, - Reason: string(v1beta1.GatewayReasonListenersNotValid), + Reason: string(v1.GatewayReasonListenersNotValid), Message: "Gateway has at least one valid listener", } } @@ -489,9 +483,9 @@ func NewGatewayNotAcceptedListenersNotValid() []conditions.Condition { msg := "Gateway has no valid listeners" return []conditions.Condition{ { - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.GatewayReasonListenersNotValid), + Reason: string(v1.GatewayReasonListenersNotValid), Message: msg, }, NewGatewayNotProgrammedInvalid(msg), @@ -503,9 +497,9 @@ func NewGatewayNotAcceptedListenersNotValid() []conditions.Condition { func NewGatewayInvalid(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionFalse, - Reason: string(v1beta1.GatewayReasonInvalid), + Reason: string(v1.GatewayReasonInvalid), Message: msg, }, NewGatewayNotProgrammedInvalid(msg), @@ -517,13 +511,13 @@ func NewGatewayInvalid(msg string) []conditions.Condition { func NewGatewayUnsupportedValue(msg string) []conditions.Condition { return []conditions.Condition{ { - Type: string(v1beta1.GatewayConditionAccepted), + Type: string(v1.GatewayConditionAccepted), Status: metav1.ConditionFalse, Reason: string(GatewayReasonUnsupportedValue), Message: msg, }, { - Type: string(v1beta1.GatewayConditionProgrammed), + Type: string(v1.GatewayConditionProgrammed), Status: metav1.ConditionFalse, Reason: string(GatewayReasonUnsupportedValue), Message: msg, @@ -534,9 +528,9 @@ func NewGatewayUnsupportedValue(msg string) []conditions.Condition { // NewGatewayProgrammed returns a Condition that indicates the Gateway is programmed. func NewGatewayProgrammed() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.GatewayConditionProgrammed), + Type: string(v1.GatewayConditionProgrammed), Status: metav1.ConditionTrue, - Reason: string(v1beta1.GatewayReasonProgrammed), + Reason: string(v1.GatewayReasonProgrammed), Message: "Gateway is programmed", } } @@ -546,9 +540,9 @@ func NewGatewayProgrammed() conditions.Condition { // why the Gateway is invalid. func NewGatewayNotProgrammedInvalid(msg string) conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.GatewayConditionProgrammed), + Type: string(v1.GatewayConditionProgrammed), Status: metav1.ConditionFalse, - Reason: string(v1beta1.GatewayReasonInvalid), + Reason: string(v1.GatewayReasonInvalid), Message: msg, } } @@ -557,7 +551,7 @@ func NewGatewayNotProgrammedInvalid(msg string) conditions.Condition { // conflict with another Gateway. func NewGatewayConflictNotProgrammed() conditions.Condition { return conditions.Condition{ - Type: string(v1beta1.GatewayConditionProgrammed), + Type: string(v1.GatewayConditionProgrammed), Status: metav1.ConditionFalse, Reason: string(GatewayReasonGatewayConflict), Message: GatewayMessageGatewayConflict, diff --git a/internal/mode/static/state/dataplane/configuration.go b/internal/mode/static/state/dataplane/configuration.go index f47eed14f2..887467b13c 100644 --- a/internal/mode/static/state/dataplane/configuration.go +++ b/internal/mode/static/state/dataplane/configuration.go @@ -7,7 +7,7 @@ import ( apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/resolver" @@ -132,9 +132,9 @@ func newBackendGroup(refs []graph.BackendRef, sourceNsName types.NamespacedName, } func buildServers(listeners map[string]*graph.Listener) (http, ssl []VirtualServer) { - rulesForProtocol := map[v1beta1.ProtocolType]portPathRules{ - v1beta1.HTTPProtocolType: make(portPathRules), - v1beta1.HTTPSProtocolType: make(portPathRules), + rulesForProtocol := map[v1.ProtocolType]portPathRules{ + v1.HTTPProtocolType: make(portPathRules), + v1.HTTPSProtocolType: make(portPathRules), } for _, l := range listeners { @@ -149,14 +149,14 @@ func buildServers(listeners map[string]*graph.Listener) (http, ssl []VirtualServ } } - httpRules := rulesForProtocol[v1beta1.HTTPProtocolType] - sslRules := rulesForProtocol[v1beta1.HTTPSProtocolType] + httpRules := rulesForProtocol[v1.HTTPProtocolType] + sslRules := rulesForProtocol[v1.HTTPSProtocolType] return httpRules.buildServers(), sslRules.buildServers() } // portPathRules keeps track of hostPathRules per port -type portPathRules map[v1beta1.PortNumber]*hostPathRules +type portPathRules map[v1.PortNumber]*hostPathRules func (p portPathRules) buildServers() []VirtualServer { serverCount := 0 @@ -175,7 +175,7 @@ func (p portPathRules) buildServers() []VirtualServer { type pathAndType struct { path string - pathType v1beta1.PathMatchType + pathType v1.PathMatchType } type hostPathRules struct { @@ -198,7 +198,7 @@ func (hpr *hostPathRules) upsertListener(l *graph.Listener) { hpr.listenersExist = true hpr.port = int32(l.Source.Port) - if l.Source.Protocol == v1beta1.HTTPSProtocolType { + if l.Source.Protocol == v1.HTTPSProtocolType { hpr.httpsListeners = append(hpr.httpsListeners, l) } @@ -415,7 +415,7 @@ func buildUpstreams( return upstreams } -func getListenerHostname(h *v1beta1.Hostname) string { +func getListenerHostname(h *v1.Hostname) string { if h == nil || *h == "" { return wildcardHostname } @@ -423,24 +423,24 @@ func getListenerHostname(h *v1beta1.Hostname) string { return string(*h) } -func getPath(path *v1beta1.HTTPPathMatch) string { +func getPath(path *v1.HTTPPathMatch) string { if path == nil || path.Value == nil || *path.Value == "" { return "/" } return *path.Value } -func createHTTPFilters(filters []v1beta1.HTTPRouteFilter) HTTPFilters { +func createHTTPFilters(filters []v1.HTTPRouteFilter) HTTPFilters { var result HTTPFilters for _, f := range filters { switch f.Type { - case v1beta1.HTTPRouteFilterRequestRedirect: + case v1.HTTPRouteFilterRequestRedirect: if result.RequestRedirect == nil { // using the first filter result.RequestRedirect = convertHTTPRequestRedirectFilter(f.RequestRedirect) } - case v1beta1.HTTPRouteFilterRequestHeaderModifier: + case v1.HTTPRouteFilterRequestHeaderModifier: if result.RequestHeaderModifiers == nil { // using the first filter result.RequestHeaderModifiers = convertHTTPHeaderFilter(f.RequestHeaderModifier) @@ -451,7 +451,7 @@ func createHTTPFilters(filters []v1beta1.HTTPRouteFilter) HTTPFilters { } // listenerHostnameMoreSpecific returns true if host1 is more specific than host2. -func listenerHostnameMoreSpecific(host1, host2 *v1beta1.Hostname) bool { +func listenerHostnameMoreSpecific(host1, host2 *v1.Hostname) bool { var host1Str, host2Str string if host1 != nil { host1Str = string(*host1) diff --git a/internal/mode/static/state/dataplane/configuration_test.go b/internal/mode/static/state/dataplane/configuration_test.go index a2c819edae..be671119ca 100644 --- a/internal/mode/static/state/dataplane/configuration_test.go +++ b/internal/mode/static/state/dataplane/configuration_test.go @@ -11,7 +11,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph" @@ -25,13 +25,13 @@ func TestBuildConfiguration(t *testing.T) { invalidFiltersPath = "/not-valid-filters" ) - createRoute := func(name, hostname, listenerName string, paths ...pathAndType) *v1beta1.HTTPRoute { - rules := make([]v1beta1.HTTPRouteRule, 0, len(paths)) + createRoute := func(name, hostname, listenerName string, paths ...pathAndType) *v1.HTTPRoute { + rules := make([]v1.HTTPRouteRule, 0, len(paths)) for _, p := range paths { - rules = append(rules, v1beta1.HTTPRouteRule{ - Matches: []v1beta1.HTTPRouteMatch{ + rules = append(rules, v1.HTTPRouteRule{ + Matches: []v1.HTTPRouteMatch{ { - Path: &v1beta1.HTTPPathMatch{ + Path: &v1.HTTPPathMatch{ Value: helpers.GetPointer(p.path), Type: helpers.GetPointer(p.pathType), }, @@ -39,30 +39,30 @@ func TestBuildConfiguration(t *testing.T) { }, }) } - return &v1beta1.HTTPRoute{ + return &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: v1.HTTPRouteSpec{ + CommonRouteSpec: v1.CommonRouteSpec{ + ParentRefs: []v1.ParentReference{ { - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), + Namespace: (*v1.Namespace)(helpers.GetPointer("test")), Name: "gateway", - SectionName: (*v1beta1.SectionName)(helpers.GetPointer(listenerName)), + SectionName: (*v1.SectionName)(helpers.GetPointer(listenerName)), }, }, }, - Hostnames: []v1beta1.Hostname{ - v1beta1.Hostname(hostname), + Hostnames: []v1.Hostname{ + v1.Hostname(hostname), }, Rules: rules, }, } } - addFilters := func(hr *v1beta1.HTTPRoute, filters []v1beta1.HTTPRouteFilter) { + addFilters := func(hr *v1.HTTPRoute, filters []v1.HTTPRouteFilter) { for i := range hr.Spec.Rules { hr.Spec.Rules[i].Filters = filters } @@ -108,7 +108,7 @@ func TestBuildConfiguration(t *testing.T) { return []graph.BackendRef{validBackendRef} } - createRules := func(hr *v1beta1.HTTPRoute, paths []pathAndType) []graph.Rule { + createRules := func(hr *v1.HTTPRoute, paths []pathAndType) []graph.Rule { rules := make([]graph.Rule, len(hr.Spec.Rules)) for i := range paths { @@ -127,7 +127,7 @@ func TestBuildConfiguration(t *testing.T) { } createInternalRoute := func( - source *v1beta1.HTTPRoute, + source *v1.HTTPRoute, listenerName string, paths []pathAndType, ) *graph.Route { @@ -171,7 +171,7 @@ func TestBuildConfiguration(t *testing.T) { } createTestResources := func(name, hostname, listenerName string, paths ...pathAndType) ( - *v1beta1.HTTPRoute, []BackendGroup, *graph.Route, + *v1.HTTPRoute, []BackendGroup, *graph.Route, ) { hr := createRoute(name, hostname, listenerName, paths...) route := createInternalRoute(hr, listenerName, paths) @@ -179,7 +179,7 @@ func TestBuildConfiguration(t *testing.T) { return hr, groups, route } - prefix := v1beta1.PathMatchPathPrefix + prefix := v1.PathMatchPathPrefix hr1, expHR1Groups, routeHR1 := createTestResources( "hr-1", @@ -215,13 +215,13 @@ func TestBuildConfiguration(t *testing.T) { pathAndType{path: "/", pathType: prefix}, pathAndType{path: invalidFiltersPath, pathType: prefix}, ) - redirect := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Hostname: (*v1beta1.PreciseHostname)(helpers.GetPointer("foo.example.com")), + redirect := v1.HTTPRouteFilter{ + Type: v1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &v1.HTTPRequestRedirectFilter{ + Hostname: (*v1.PreciseHostname)(helpers.GetPointer("foo.example.com")), }, } - addFilters(hr5, []v1beta1.HTTPRouteFilter{redirect}) + addFilters(hr5, []v1.HTTPRouteFilter{redirect}) expRedirect := HTTPRequestRedirectFilter{ Hostname: helpers.GetPointer("foo.example.com"), } @@ -237,7 +237,7 @@ func TestBuildConfiguration(t *testing.T) { "hr-7", "foo.example.com", "listener-80-1", - pathAndType{path: "/valid", pathType: prefix}, pathAndType{path: "/valid", pathType: v1beta1.PathMatchExact}, + pathAndType{path: "/valid", pathType: prefix}, pathAndType{path: "/valid", pathType: v1.PathMatchExact}, ) hr8, expHR8Groups, routeHR8 := createTestResources( @@ -327,85 +327,85 @@ func TestBuildConfiguration(t *testing.T) { }, } - listener80 := v1beta1.Listener{ + listener80 := v1.Listener{ Name: "listener-80-1", Hostname: nil, Port: 80, - Protocol: v1beta1.HTTPProtocolType, + Protocol: v1.HTTPProtocolType, } - listener8080 := v1beta1.Listener{ + listener8080 := v1.Listener{ Name: "listener-8080", Hostname: nil, Port: 8080, - Protocol: v1beta1.HTTPProtocolType, + Protocol: v1.HTTPProtocolType, } - listener443 := v1beta1.Listener{ + listener443 := v1.Listener{ Name: "listener-443-1", Hostname: nil, Port: 443, - Protocol: v1beta1.HTTPSProtocolType, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + Protocol: v1.HTTPSProtocolType, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: (*v1beta1.Kind)(helpers.GetPointer("Secret")), - Namespace: helpers.GetPointer(v1beta1.Namespace(secret1NsName.Namespace)), - Name: v1beta1.ObjectName(secret1NsName.Name), + Kind: (*v1.Kind)(helpers.GetPointer("Secret")), + Namespace: helpers.GetPointer(v1.Namespace(secret1NsName.Namespace)), + Name: v1.ObjectName(secret1NsName.Name), }, }, }, } - listener8443 := v1beta1.Listener{ + listener8443 := v1.Listener{ Name: "listener-8443", Hostname: nil, Port: 8443, - Protocol: v1beta1.HTTPSProtocolType, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + Protocol: v1.HTTPSProtocolType, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: (*v1beta1.Kind)(helpers.GetPointer("Secret")), - Namespace: helpers.GetPointer(v1beta1.Namespace(secret2NsName.Namespace)), - Name: v1beta1.ObjectName(secret2NsName.Name), + Kind: (*v1.Kind)(helpers.GetPointer("Secret")), + Namespace: helpers.GetPointer(v1.Namespace(secret2NsName.Namespace)), + Name: v1.ObjectName(secret2NsName.Name), }, }, }, } - hostname := v1beta1.Hostname("example.com") + hostname := v1.Hostname("example.com") - listener443WithHostname := v1beta1.Listener{ + listener443WithHostname := v1.Listener{ Name: "listener-443-with-hostname", Hostname: &hostname, Port: 443, - Protocol: v1beta1.HTTPSProtocolType, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + Protocol: v1.HTTPSProtocolType, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: (*v1beta1.Kind)(helpers.GetPointer("Secret")), - Namespace: helpers.GetPointer(v1beta1.Namespace(secret2NsName.Namespace)), - Name: v1beta1.ObjectName(secret2NsName.Name), + Kind: (*v1.Kind)(helpers.GetPointer("Secret")), + Namespace: helpers.GetPointer(v1.Namespace(secret2NsName.Namespace)), + Name: v1.ObjectName(secret2NsName.Name), }, }, }, } - invalidListener := v1beta1.Listener{ + invalidListener := v1.Listener{ Name: "invalid-listener", Hostname: nil, Port: 443, - Protocol: v1beta1.HTTPSProtocolType, - TLS: &v1beta1.GatewayTLSConfig{ + Protocol: v1.HTTPSProtocolType, + TLS: &v1.GatewayTLSConfig{ // Mode is missing, that's why invalid - CertificateRefs: []v1beta1.SecretObjectReference{ + CertificateRefs: []v1.SecretObjectReference{ { - Kind: helpers.GetPointer[v1beta1.Kind]("Secret"), - Namespace: helpers.GetPointer(v1beta1.Namespace(secret1NsName.Namespace)), - Name: v1beta1.ObjectName(secret1NsName.Name), + Kind: helpers.GetPointer[v1.Kind]("Secret"), + Namespace: helpers.GetPointer(v1.Namespace(secret1NsName.Namespace)), + Name: v1.ObjectName(secret1NsName.Name), }, }, }, @@ -419,11 +419,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{}, }, Routes: map[types.NamespacedName]*graph.Route{}, @@ -438,11 +438,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -468,11 +468,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-443-1": { Source: listener443, // nil hostname @@ -528,11 +528,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "invalid-listener": { Source: invalidListener, @@ -559,11 +559,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -629,11 +629,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-443-1": { Source: listener443, @@ -746,11 +746,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -903,11 +903,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -1112,11 +1112,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: false, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -1138,7 +1138,7 @@ func TestBuildConfiguration(t *testing.T) { graph: &graph.Graph{ GatewayClass: nil, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -1159,7 +1159,7 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: nil, @@ -1171,11 +1171,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -1239,11 +1239,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -1338,11 +1338,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-80-1": { Source: listener80, @@ -1400,11 +1400,11 @@ func TestBuildConfiguration(t *testing.T) { { graph: &graph.Graph{ GatewayClass: &graph.GatewayClass{ - Source: &v1beta1.GatewayClass{}, + Source: &v1.GatewayClass{}, Valid: true, }, Gateway: &graph.Gateway{ - Source: &v1beta1.Gateway{}, + Source: &v1.Gateway{}, Listeners: map[string]*graph.Listener{ "listener-443-with-hostname": { Source: listener443WithHostname, @@ -1502,12 +1502,12 @@ func TestBuildConfiguration(t *testing.T) { func TestGetPath(t *testing.T) { tests := []struct { - path *v1beta1.HTTPPathMatch + path *v1.HTTPPathMatch expected string msg string }{ { - path: &v1beta1.HTTPPathMatch{Value: helpers.GetPointer("/abc")}, + path: &v1.HTTPPathMatch{Value: helpers.GetPointer("/abc")}, expected: "/abc", msg: "normal case", }, @@ -1517,12 +1517,12 @@ func TestGetPath(t *testing.T) { msg: "nil path", }, { - path: &v1beta1.HTTPPathMatch{Value: nil}, + path: &v1.HTTPPathMatch{Value: nil}, expected: "/", msg: "nil value", }, { - path: &v1beta1.HTTPPathMatch{Value: helpers.GetPointer("")}, + path: &v1.HTTPPathMatch{Value: helpers.GetPointer("")}, expected: "/", msg: "empty value", }, @@ -1538,22 +1538,22 @@ func TestGetPath(t *testing.T) { } func TestCreateFilters(t *testing.T) { - redirect1 := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Hostname: helpers.GetPointer[v1beta1.PreciseHostname]("foo.example.com"), + redirect1 := v1.HTTPRouteFilter{ + Type: v1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &v1.HTTPRequestRedirectFilter{ + Hostname: helpers.GetPointer[v1.PreciseHostname]("foo.example.com"), }, } - redirect2 := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Hostname: helpers.GetPointer[v1beta1.PreciseHostname]("bar.example.com"), + redirect2 := v1.HTTPRouteFilter{ + Type: v1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &v1.HTTPRequestRedirectFilter{ + Hostname: helpers.GetPointer[v1.PreciseHostname]("bar.example.com"), }, } - requestHeaderModifiers1 := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ - Set: []v1beta1.HTTPHeader{ + requestHeaderModifiers1 := v1.HTTPRouteFilter{ + Type: v1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &v1.HTTPHeaderFilter{ + Set: []v1.HTTPHeader{ { Name: "MyBespokeHeader", Value: "my-value", @@ -1561,10 +1561,10 @@ func TestCreateFilters(t *testing.T) { }, }, } - requestHeaderModifiers2 := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ - Add: []v1beta1.HTTPHeader{ + requestHeaderModifiers2 := v1.HTTPRouteFilter{ + Type: v1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &v1.HTTPHeaderFilter{ + Add: []v1.HTTPHeader{ { Name: "Content-Accepted", Value: "gzip", @@ -1588,15 +1588,15 @@ func TestCreateFilters(t *testing.T) { tests := []struct { expected HTTPFilters msg string - filters []v1beta1.HTTPRouteFilter + filters []v1.HTTPRouteFilter }{ { - filters: []v1beta1.HTTPRouteFilter{}, + filters: []v1.HTTPRouteFilter{}, expected: HTTPFilters{}, msg: "no filters", }, { - filters: []v1beta1.HTTPRouteFilter{ + filters: []v1.HTTPRouteFilter{ redirect1, }, expected: HTTPFilters{ @@ -1605,7 +1605,7 @@ func TestCreateFilters(t *testing.T) { msg: "one filter", }, { - filters: []v1beta1.HTTPRouteFilter{ + filters: []v1.HTTPRouteFilter{ redirect1, redirect2, }, @@ -1615,7 +1615,7 @@ func TestCreateFilters(t *testing.T) { msg: "two filters, first wins", }, { - filters: []v1beta1.HTTPRouteFilter{ + filters: []v1.HTTPRouteFilter{ redirect1, redirect2, requestHeaderModifiers1, @@ -1627,7 +1627,7 @@ func TestCreateFilters(t *testing.T) { msg: "two redirect filters, one request header modifier, first redirect wins", }, { - filters: []v1beta1.HTTPRouteFilter{ + filters: []v1.HTTPRouteFilter{ redirect1, redirect2, requestHeaderModifiers1, @@ -1652,11 +1652,11 @@ func TestCreateFilters(t *testing.T) { } func TestGetListenerHostname(t *testing.T) { - var emptyHostname v1beta1.Hostname - var hostname v1beta1.Hostname = "example.com" + var emptyHostname v1.Hostname + var hostname v1.Hostname = "example.com" tests := []struct { - hostname *v1beta1.Hostname + hostname *v1.Hostname expected string msg string }{ @@ -1948,50 +1948,50 @@ func TestBuildBackendGroups(t *testing.T) { func TestHostnameMoreSpecific(t *testing.T) { tests := []struct { - host1 *v1beta1.Hostname - host2 *v1beta1.Hostname + host1 *v1.Hostname + host2 *v1.Hostname msg string host1Wins bool }{ { host1: nil, - host2: helpers.GetPointer(v1beta1.Hostname("")), + host2: helpers.GetPointer(v1.Hostname("")), host1Wins: true, msg: "host1 nil; host2 empty", }, { - host1: helpers.GetPointer(v1beta1.Hostname("")), + host1: helpers.GetPointer(v1.Hostname("")), host2: nil, host1Wins: true, msg: "host1 empty; host2 nil", }, { - host1: helpers.GetPointer(v1beta1.Hostname("")), - host2: helpers.GetPointer(v1beta1.Hostname("")), + host1: helpers.GetPointer(v1.Hostname("")), + host2: helpers.GetPointer(v1.Hostname("")), host1Wins: true, msg: "both hosts empty", }, { - host1: helpers.GetPointer(v1beta1.Hostname("example.com")), - host2: helpers.GetPointer(v1beta1.Hostname("")), + host1: helpers.GetPointer(v1.Hostname("example.com")), + host2: helpers.GetPointer(v1.Hostname("")), host1Wins: true, msg: "host1 has value; host2 empty", }, { - host1: helpers.GetPointer(v1beta1.Hostname("")), - host2: helpers.GetPointer(v1beta1.Hostname("example.com")), + host1: helpers.GetPointer(v1.Hostname("")), + host2: helpers.GetPointer(v1.Hostname("example.com")), host1Wins: false, msg: "host2 has value; host1 empty", }, { - host1: helpers.GetPointer(v1beta1.Hostname("foo.example.com")), - host2: helpers.GetPointer(v1beta1.Hostname("*.example.com")), + host1: helpers.GetPointer(v1.Hostname("foo.example.com")), + host2: helpers.GetPointer(v1.Hostname("*.example.com")), host1Wins: true, msg: "host1 more specific than host2", }, { - host1: helpers.GetPointer(v1beta1.Hostname("*.example.com")), - host2: helpers.GetPointer(v1beta1.Hostname("foo.example.com")), + host1: helpers.GetPointer(v1.Hostname("*.example.com")), + host2: helpers.GetPointer(v1.Hostname("foo.example.com")), host1Wins: false, msg: "host2 more specific than host1", }, diff --git a/internal/mode/static/state/dataplane/convert.go b/internal/mode/static/state/dataplane/convert.go index d96e763c74..2ca8713e85 100644 --- a/internal/mode/static/state/dataplane/convert.go +++ b/internal/mode/static/state/dataplane/convert.go @@ -3,10 +3,10 @@ package dataplane import ( "fmt" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) -func convertMatch(m v1beta1.HTTPRouteMatch) Match { +func convertMatch(m v1.HTTPRouteMatch) Match { match := Match{} if m.Method != nil { @@ -37,7 +37,7 @@ func convertMatch(m v1beta1.HTTPRouteMatch) Match { return match } -func convertHTTPRequestRedirectFilter(filter *v1beta1.HTTPRequestRedirectFilter) *HTTPRequestRedirectFilter { +func convertHTTPRequestRedirectFilter(filter *v1.HTTPRequestRedirectFilter) *HTTPRequestRedirectFilter { return &HTTPRequestRedirectFilter{ Scheme: filter.Scheme, Hostname: (*string)(filter.Hostname), @@ -46,7 +46,7 @@ func convertHTTPRequestRedirectFilter(filter *v1beta1.HTTPRequestRedirectFilter) } } -func convertHTTPHeaderFilter(filter *v1beta1.HTTPHeaderFilter) *HTTPHeaderFilter { +func convertHTTPHeaderFilter(filter *v1.HTTPHeaderFilter) *HTTPHeaderFilter { result := &HTTPHeaderFilter{ Remove: filter.Remove, } @@ -68,11 +68,11 @@ func convertHTTPHeaderFilter(filter *v1beta1.HTTPHeaderFilter) *HTTPHeaderFilter return result } -func convertPathType(pathType v1beta1.PathMatchType) PathType { +func convertPathType(pathType v1.PathMatchType) PathType { switch pathType { - case v1beta1.PathMatchPathPrefix: + case v1.PathMatchPathPrefix: return PathTypePrefix - case v1beta1.PathMatchExact: + case v1.PathMatchExact: return PathTypeExact default: panic(fmt.Sprintf("unsupported path type: %s", pathType)) diff --git a/internal/mode/static/state/dataplane/convert_test.go b/internal/mode/static/state/dataplane/convert_test.go index 0d944d6e37..27feeec417 100644 --- a/internal/mode/static/state/dataplane/convert_test.go +++ b/internal/mode/static/state/dataplane/convert_test.go @@ -4,33 +4,33 @@ import ( "testing" . "github.com/onsi/gomega" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" ) func TestConvertMatch(t *testing.T) { - path := v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + path := v1.HTTPPathMatch{ + Type: helpers.GetPointer(v1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), } tests := []struct { - match v1beta1.HTTPRouteMatch + match v1.HTTPRouteMatch name string expected Match }{ { - match: v1beta1.HTTPRouteMatch{ + match: v1.HTTPRouteMatch{ Path: &path, }, expected: Match{}, name: "path only", }, { - match: v1beta1.HTTPRouteMatch{ + match: v1.HTTPRouteMatch{ Path: &path, - Method: helpers.GetPointer(v1beta1.HTTPMethodGet), + Method: helpers.GetPointer(v1.HTTPMethodGet), }, expected: Match{ Method: helpers.GetPointer("GET"), @@ -38,9 +38,9 @@ func TestConvertMatch(t *testing.T) { name: "path and method", }, { - match: v1beta1.HTTPRouteMatch{ + match: v1.HTTPRouteMatch{ Path: &path, - Headers: []v1beta1.HTTPHeaderMatch{ + Headers: []v1.HTTPHeaderMatch{ { Name: "Test-Header", Value: "test-header-value", @@ -58,9 +58,9 @@ func TestConvertMatch(t *testing.T) { name: "path and header", }, { - match: v1beta1.HTTPRouteMatch{ + match: v1.HTTPRouteMatch{ Path: &path, - QueryParams: []v1beta1.HTTPQueryParamMatch{ + QueryParams: []v1.HTTPQueryParamMatch{ { Name: "Test-Param", Value: "test-param-value", @@ -78,16 +78,16 @@ func TestConvertMatch(t *testing.T) { name: "path and query param", }, { - match: v1beta1.HTTPRouteMatch{ + match: v1.HTTPRouteMatch{ Path: &path, - Method: helpers.GetPointer(v1beta1.HTTPMethodGet), - Headers: []v1beta1.HTTPHeaderMatch{ + Method: helpers.GetPointer(v1.HTTPMethodGet), + Headers: []v1.HTTPHeaderMatch{ { Name: "Test-Header", Value: "test-header-value", }, }, - QueryParams: []v1beta1.HTTPQueryParamMatch{ + QueryParams: []v1.HTTPQueryParamMatch{ { Name: "Test-Param", Value: "test-param-value", @@ -125,20 +125,20 @@ func TestConvertMatch(t *testing.T) { func TestConvertHTTPRequestRedirectFilter(t *testing.T) { tests := []struct { - filter *v1beta1.HTTPRequestRedirectFilter + filter *v1.HTTPRequestRedirectFilter expected *HTTPRequestRedirectFilter name string }{ { - filter: &v1beta1.HTTPRequestRedirectFilter{}, + filter: &v1.HTTPRequestRedirectFilter{}, expected: &HTTPRequestRedirectFilter{}, name: "empty", }, { - filter: &v1beta1.HTTPRequestRedirectFilter{ + filter: &v1.HTTPRequestRedirectFilter{ Scheme: helpers.GetPointer("https"), - Hostname: helpers.GetPointer[v1beta1.PreciseHostname]("example.com"), - Port: helpers.GetPointer[v1beta1.PortNumber](8443), + Hostname: helpers.GetPointer[v1.PreciseHostname]("example.com"), + Port: helpers.GetPointer[v1.PortNumber](8443), StatusCode: helpers.GetPointer(302), }, expected: &HTTPRequestRedirectFilter{ @@ -163,22 +163,22 @@ func TestConvertHTTPRequestRedirectFilter(t *testing.T) { func TestConvertHTTPHeaderFilter(t *testing.T) { tests := []struct { - filter *v1beta1.HTTPHeaderFilter + filter *v1.HTTPHeaderFilter expected *HTTPHeaderFilter name string }{ { - filter: &v1beta1.HTTPHeaderFilter{}, + filter: &v1.HTTPHeaderFilter{}, expected: &HTTPHeaderFilter{}, name: "empty", }, { - filter: &v1beta1.HTTPHeaderFilter{ - Set: []v1beta1.HTTPHeader{{ + filter: &v1.HTTPHeaderFilter{ + Set: []v1.HTTPHeader{{ Name: "My-Set-Header", Value: "my-value", }}, - Add: []v1beta1.HTTPHeader{{ + Add: []v1.HTTPHeader{{ Name: "My-Add-Header", Value: "my-value", }}, @@ -213,20 +213,20 @@ func TestConvertPathType(t *testing.T) { g := NewWithT(t) tests := []struct { - pathType v1beta1.PathMatchType + pathType v1.PathMatchType expected PathType panic bool }{ { expected: PathTypePrefix, - pathType: v1beta1.PathMatchPathPrefix, + pathType: v1.PathMatchPathPrefix, }, { expected: PathTypeExact, - pathType: v1beta1.PathMatchExact, + pathType: v1.PathMatchExact, }, { - pathType: v1beta1.PathMatchRegularExpression, + pathType: v1.PathMatchRegularExpression, panic: true, }, } diff --git a/internal/mode/static/state/graph/backend_refs.go b/internal/mode/static/state/graph/backend_refs.go index 2bfbb5695d..5bc1203ebd 100644 --- a/internal/mode/static/state/graph/backend_refs.go +++ b/internal/mode/static/state/graph/backend_refs.go @@ -6,7 +6,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" @@ -85,7 +85,7 @@ func addBackendRefsToRules( } func createBackendRef( - ref v1beta1.HTTPBackendRef, + ref gatewayv1.HTTPBackendRef, sourceNamespace string, refGrantResolver *referenceGrantResolver, services map[types.NamespacedName]*v1.Service, @@ -138,7 +138,7 @@ func createBackendRef( } func getServiceAndPortFromRef( - ref v1beta1.BackendRef, + ref gatewayv1.BackendRef, routeNamespace string, services map[types.NamespacedName]*v1.Service, refPath *field.Path, @@ -160,7 +160,7 @@ func getServiceAndPortFromRef( } func validateHTTPBackendRef( - ref v1beta1.HTTPBackendRef, + ref gatewayv1.HTTPBackendRef, routeNs string, refGrantResolver *referenceGrantResolver, path *field.Path, @@ -176,7 +176,7 @@ func validateHTTPBackendRef( } func validateBackendRef( - ref v1beta1.BackendRef, + ref gatewayv1.BackendRef, routeNs string, refGrantResolver *referenceGrantResolver, path *field.Path, diff --git a/internal/mode/static/state/graph/backend_refs_test.go b/internal/mode/static/state/graph/backend_refs_test.go index b5ed7e5f91..d81cf386bc 100644 --- a/internal/mode/static/state/graph/backend_refs_test.go +++ b/internal/mode/static/state/graph/backend_refs_test.go @@ -9,6 +9,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" @@ -16,19 +17,19 @@ import ( staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" ) -func getNormalRef() v1beta1.BackendRef { - return v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ - Kind: helpers.GetPointer[v1beta1.Kind]("Service"), +func getNormalRef() gatewayv1.BackendRef { + return gatewayv1.BackendRef{ + BackendObjectReference: gatewayv1.BackendObjectReference{ + Kind: helpers.GetPointer[gatewayv1.Kind]("Service"), Name: "service1", - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), - Port: helpers.GetPointer[v1beta1.PortNumber](80), + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), + Port: helpers.GetPointer[gatewayv1.PortNumber](80), }, Weight: helpers.GetPointer[int32](5), } } -func getModifiedRef(mod func(ref v1beta1.BackendRef) v1beta1.BackendRef) v1beta1.BackendRef { +func getModifiedRef(mod func(ref gatewayv1.BackendRef) gatewayv1.BackendRef) gatewayv1.BackendRef { return mod(getNormalRef()) } @@ -36,12 +37,12 @@ func TestValidateHTTPBackendRef(t *testing.T) { tests := []struct { expectedCondition conditions.Condition name string - ref v1beta1.HTTPBackendRef + ref gatewayv1.HTTPBackendRef expectedValid bool }{ { name: "normal case", - ref: v1beta1.HTTPBackendRef{ + ref: gatewayv1.HTTPBackendRef{ BackendRef: getNormalRef(), Filters: nil, }, @@ -49,11 +50,11 @@ func TestValidateHTTPBackendRef(t *testing.T) { }, { name: "filters not supported", - ref: v1beta1.HTTPBackendRef{ + ref: gatewayv1.HTTPBackendRef{ BackendRef: getNormalRef(), - Filters: []v1beta1.HTTPRouteFilter{ + Filters: []gatewayv1.HTTPRouteFilter{ { - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, }, }, }, @@ -64,9 +65,9 @@ func TestValidateHTTPBackendRef(t *testing.T) { }, { name: "invalid base ref", - ref: v1beta1.HTTPBackendRef{ - BackendRef: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Kind = helpers.GetPointer[v1beta1.Kind]("NotService") + ref: gatewayv1.HTTPBackendRef{ + BackendRef: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Kind = helpers.GetPointer[gatewayv1.Kind]("NotService") return backend }), }, @@ -96,12 +97,12 @@ func TestValidateBackendRef(t *testing.T) { To: []v1beta1.ReferenceGrantTo{ { Kind: "Service", - Name: helpers.GetPointer[v1beta1.ObjectName]("service1"), + Name: helpers.GetPointer[gatewayv1.ObjectName]("service1"), }, }, From: []v1beta1.ReferenceGrantFrom{ { - Group: v1beta1.GroupName, + Group: gatewayv1.GroupName, Kind: "HTTPRoute", Namespace: "test", }, @@ -113,7 +114,7 @@ func TestValidateBackendRef(t *testing.T) { allInNamespaceRefGrant.Spec.To[0].Name = nil tests := []struct { - ref v1beta1.BackendRef + ref gatewayv1.BackendRef refGrants map[types.NamespacedName]*v1beta1.ReferenceGrant expectedCondition conditions.Condition name string @@ -126,7 +127,7 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "normal case with implicit namespace", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Namespace = nil return backend }), @@ -134,7 +135,7 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "normal case with implicit kind Service", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Kind = nil return backend }), @@ -142,8 +143,8 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "normal case with backend ref allowed by specific reference grant", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Namespace = helpers.GetPointer[v1beta1.Namespace]("cross-ns") + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Namespace = helpers.GetPointer[gatewayv1.Namespace]("cross-ns") return backend }), refGrants: map[types.NamespacedName]*v1beta1.ReferenceGrant{ @@ -153,8 +154,8 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "normal case with backend ref allowed by all-in-namespace reference grant", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Namespace = helpers.GetPointer[v1beta1.Namespace]("cross-ns") + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Namespace = helpers.GetPointer[gatewayv1.Namespace]("cross-ns") return backend }), refGrants: map[types.NamespacedName]*v1beta1.ReferenceGrant{ @@ -164,8 +165,8 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "invalid group", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Group = helpers.GetPointer[v1beta1.Group]("invalid") + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Group = helpers.GetPointer[gatewayv1.Group]("invalid") return backend }), expectedValid: false, @@ -175,8 +176,8 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "not a service kind", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Kind = helpers.GetPointer[v1beta1.Kind]("NotService") + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Kind = helpers.GetPointer[gatewayv1.Kind]("NotService") return backend }), expectedValid: false, @@ -186,8 +187,8 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "backend ref not allowed by reference grant", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Namespace = helpers.GetPointer[v1beta1.Namespace]("invalid") + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Namespace = helpers.GetPointer[gatewayv1.Namespace]("invalid") return backend }), expectedValid: false, @@ -197,7 +198,7 @@ func TestValidateBackendRef(t *testing.T) { }, { name: "invalid weight", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Weight = helpers.GetPointer[int32](-1) return backend }), @@ -253,7 +254,7 @@ func TestGetServiceAndPortFromRef(t *testing.T) { } tests := []struct { - ref v1beta1.BackendRef + ref gatewayv1.BackendRef expService *v1.Service name string expPort int32 @@ -267,7 +268,7 @@ func TestGetServiceAndPortFromRef(t *testing.T) { }, { name: "service does not exist", - ref: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Name = "does-not-exist" return backend }), @@ -296,21 +297,26 @@ func TestGetServiceAndPortFromRef(t *testing.T) { } func TestAddBackendRefsToRulesTest(t *testing.T) { - createRoute := func(name string, kind v1beta1.Kind, refsPerBackend int, serviceNames ...string) *v1beta1.HTTPRoute { - hr := &v1beta1.HTTPRoute{ + createRoute := func( + name string, + kind gatewayv1.Kind, + refsPerBackend int, + serviceNames ...string, + ) *gatewayv1.HTTPRoute { + hr := &gatewayv1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, }, } - createHTTPBackendRef := func(svcName string, port v1beta1.PortNumber, weight *int32) v1beta1.HTTPBackendRef { - return v1beta1.HTTPBackendRef{ - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ + createHTTPBackendRef := func(svcName string, port gatewayv1.PortNumber, weight *int32) gatewayv1.HTTPBackendRef { + return gatewayv1.HTTPBackendRef{ + BackendRef: gatewayv1.BackendRef{ + BackendObjectReference: gatewayv1.BackendObjectReference{ Kind: helpers.GetPointer(kind), - Name: v1beta1.ObjectName(svcName), - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + Name: gatewayv1.ObjectName(svcName), + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), Port: helpers.GetPointer(port), }, Weight: weight, @@ -318,10 +324,10 @@ func TestAddBackendRefsToRulesTest(t *testing.T) { } } - hr.Spec.Rules = make([]v1beta1.HTTPRouteRule, len(serviceNames)) + hr.Spec.Rules = make([]gatewayv1.HTTPRouteRule, len(serviceNames)) for idx, svcName := range serviceNames { - refs := []v1beta1.HTTPBackendRef{ + refs := []gatewayv1.HTTPBackendRef{ createHTTPBackendRef(svcName, 80, nil), } if refsPerBackend == 2 { @@ -331,7 +337,7 @@ func TestAddBackendRefsToRulesTest(t *testing.T) { panic("invalid refsPerBackend") } - hr.Spec.Rules[idx] = v1beta1.HTTPRouteRule{ + hr.Spec.Rules[idx] = gatewayv1.HTTPRouteRule{ BackendRefs: refs, } } @@ -343,7 +349,7 @@ func TestAddBackendRefsToRulesTest(t *testing.T) { allInvalid = false ) - createRules := func(hr *v1beta1.HTTPRoute, validMatches, validFilters bool) []Rule { + createRules := func(hr *gatewayv1.HTTPRoute, validMatches, validFilters bool) []Rule { rules := make([]Rule, len(hr.Spec.Rules)) for i := range rules { rules[i].ValidMatches = validMatches @@ -510,11 +516,11 @@ func TestCreateBackend(t *testing.T) { expectedCondition *conditions.Condition name string expectedServicePortReference string - ref v1beta1.HTTPBackendRef + ref gatewayv1.HTTPBackendRef expectedBackend BackendRef }{ { - ref: v1beta1.HTTPBackendRef{ + ref: gatewayv1.HTTPBackendRef{ BackendRef: getNormalRef(), }, expectedBackend: BackendRef{ @@ -528,8 +534,8 @@ func TestCreateBackend(t *testing.T) { name: "normal case", }, { - ref: v1beta1.HTTPBackendRef{ - BackendRef: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: gatewayv1.HTTPBackendRef{ + BackendRef: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Weight = nil return backend }), @@ -545,8 +551,8 @@ func TestCreateBackend(t *testing.T) { name: "normal with nil weight", }, { - ref: v1beta1.HTTPBackendRef{ - BackendRef: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: gatewayv1.HTTPBackendRef{ + BackendRef: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Weight = helpers.GetPointer[int32](-1) return backend }), @@ -566,9 +572,9 @@ func TestCreateBackend(t *testing.T) { name: "invalid weight", }, { - ref: v1beta1.HTTPBackendRef{ - BackendRef: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { - backend.Kind = helpers.GetPointer[v1beta1.Kind]("NotService") + ref: gatewayv1.HTTPBackendRef{ + BackendRef: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { + backend.Kind = helpers.GetPointer[gatewayv1.Kind]("NotService") return backend }), }, @@ -587,8 +593,8 @@ func TestCreateBackend(t *testing.T) { name: "invalid kind", }, { - ref: v1beta1.HTTPBackendRef{ - BackendRef: getModifiedRef(func(backend v1beta1.BackendRef) v1beta1.BackendRef { + ref: gatewayv1.HTTPBackendRef{ + BackendRef: getModifiedRef(func(backend gatewayv1.BackendRef) gatewayv1.BackendRef { backend.Name = "not-exist" return backend }), diff --git a/internal/mode/static/state/graph/gateway.go b/internal/mode/static/state/graph/gateway.go index a7eb0b150c..1e3ea986f7 100644 --- a/internal/mode/static/state/graph/gateway.go +++ b/internal/mode/static/state/graph/gateway.go @@ -6,7 +6,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" ngfsort "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/sort" @@ -16,7 +16,7 @@ import ( // Gateway represents the winning Gateway resource. type Gateway struct { // Source is the corresponding Gateway resource. - Source *v1beta1.Gateway + Source *v1.Gateway // Listeners include the listeners of the Gateway. Listeners map[string]*Listener // Conditions holds the conditions for the Gateway. @@ -27,8 +27,8 @@ type Gateway struct { // processedGateways holds the resources that belong to NGF. type processedGateways struct { - Winner *v1beta1.Gateway - Ignored map[types.NamespacedName]*v1beta1.Gateway + Winner *v1.Gateway + Ignored map[types.NamespacedName]*v1.Gateway } // GetAllNsNames returns all the NamespacedNames of the Gateway resources that belong to NGF @@ -57,10 +57,10 @@ func (gws processedGateways) GetAllNsNames() []types.NamespacedName { // processGateways determines which Gateway resource belong to NGF (determined by the Gateway GatewayClassName field). func processGateways( - gws map[types.NamespacedName]*v1beta1.Gateway, + gws map[types.NamespacedName]*v1.Gateway, gcName string, ) processedGateways { - referencedGws := make([]*v1beta1.Gateway, 0, len(gws)) + referencedGws := make([]*v1.Gateway, 0, len(gws)) for _, gw := range gws { if string(gw.Spec.GatewayClassName) != gcName { @@ -78,7 +78,7 @@ func processGateways( return ngfsort.LessObjectMeta(&referencedGws[i].ObjectMeta, &referencedGws[j].ObjectMeta) }) - ignoredGws := make(map[types.NamespacedName]*v1beta1.Gateway) + ignoredGws := make(map[types.NamespacedName]*v1.Gateway) for _, gw := range referencedGws[1:] { ignoredGws[client.ObjectKeyFromObject(gw)] = gw @@ -91,7 +91,7 @@ func processGateways( } func buildGateway( - gw *v1beta1.Gateway, + gw *v1.Gateway, secretResolver *secretResolver, gc *GatewayClass, refGrantResolver *referenceGrantResolver, @@ -118,7 +118,7 @@ func buildGateway( } } -func validateGateway(gw *v1beta1.Gateway, gc *GatewayClass) []conditions.Condition { +func validateGateway(gw *v1.Gateway, gc *GatewayClass) []conditions.Condition { var conds []conditions.Condition if gc == nil { diff --git a/internal/mode/static/state/graph/gateway_listener.go b/internal/mode/static/state/graph/gateway_listener.go index 5bea0aa545..8927cbf677 100644 --- a/internal/mode/static/state/graph/gateway_listener.go +++ b/internal/mode/static/state/graph/gateway_listener.go @@ -8,7 +8,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" @@ -18,7 +18,7 @@ import ( // For now, we only support HTTP and HTTPS listeners. type Listener struct { // Source holds the source of the Listener from the Gateway resource. - Source v1beta1.Listener + Source v1.Listener // Routes holds the routes attached to the Listener. // Only valid routes are attached. Routes map[types.NamespacedName]*Route @@ -30,14 +30,14 @@ type Listener struct { // Conditions holds the conditions of the Listener. Conditions []conditions.Condition // SupportedKinds is the list of RouteGroupKinds allowed by the listener. - SupportedKinds []v1beta1.RouteGroupKind + SupportedKinds []v1.RouteGroupKind // Valid shows whether the Listener is valid. // A Listener is considered valid if NGF can generate valid NGINX configuration for it. Valid bool } func buildListeners( - gw *v1beta1.Gateway, + gw *v1.Gateway, secretResolver *secretResolver, refGrantResolver *referenceGrantResolver, protectedPorts ProtectedPorts, @@ -58,11 +58,11 @@ type listenerConfiguratorFactory struct { http, https, unsupportedProtocol *listenerConfigurator } -func (f *listenerConfiguratorFactory) getConfiguratorForListener(l v1beta1.Listener) *listenerConfigurator { +func (f *listenerConfiguratorFactory) getConfiguratorForListener(l v1.Listener) *listenerConfigurator { switch l.Protocol { - case v1beta1.HTTPProtocolType: + case v1.HTTPProtocolType: return f.http - case v1beta1.HTTPSProtocolType: + case v1.HTTPSProtocolType: return f.https default: return f.unsupportedProtocol @@ -70,7 +70,7 @@ func (f *listenerConfiguratorFactory) getConfiguratorForListener(l v1beta1.Liste } func newListenerConfiguratorFactory( - gw *v1beta1.Gateway, + gw *v1.Gateway, secretResolver *secretResolver, refGrantResolver *referenceGrantResolver, protectedPorts ProtectedPorts, @@ -80,11 +80,11 @@ func newListenerConfiguratorFactory( return &listenerConfiguratorFactory{ unsupportedProtocol: &listenerConfigurator{ validators: []listenerValidator{ - func(listener v1beta1.Listener) []conditions.Condition { + func(listener v1.Listener) []conditions.Condition { valErr := field.NotSupported( field.NewPath("protocol"), listener.Protocol, - []string{string(v1beta1.HTTPProtocolType), string(v1beta1.HTTPSProtocolType)}, + []string{string(v1.HTTPProtocolType), string(v1.HTTPSProtocolType)}, ) return staticConds.NewListenerUnsupportedProtocol(valErr.Error()) }, @@ -119,7 +119,7 @@ func newListenerConfiguratorFactory( } // listenerValidator validates a listener. If the listener is invalid, the validator will return appropriate conditions. -type listenerValidator func(v1beta1.Listener) []conditions.Condition +type listenerValidator func(v1.Listener) []conditions.Condition // listenerConflictResolver resolves conflicts between listeners. In case of a conflict, the resolver will make // the conflicting listeners invalid - i.e. it will modify the passed listener and the previously processed conflicting @@ -145,7 +145,7 @@ type listenerConfigurator struct { externalReferenceResolvers []listenerExternalReferenceResolver } -func (c *listenerConfigurator) configure(listener v1beta1.Listener) *Listener { +func (c *listenerConfigurator) configure(listener v1.Listener) *Listener { var conds []conditions.Condition // validators might return different conditions, so we run them all. @@ -195,7 +195,7 @@ func (c *listenerConfigurator) configure(listener v1beta1.Listener) *Listener { return l } -func validateListenerHostname(listener v1beta1.Listener) []conditions.Condition { +func validateListenerHostname(listener v1.Listener) []conditions.Condition { if listener.Hostname == nil { return nil } @@ -214,12 +214,12 @@ func validateListenerHostname(listener v1beta1.Listener) []conditions.Condition return nil } -func getAndValidateListenerSupportedKinds(listener v1beta1.Listener) ( +func getAndValidateListenerSupportedKinds(listener v1.Listener) ( []conditions.Condition, - []v1beta1.RouteGroupKind, + []v1.RouteGroupKind, ) { if listener.AllowedRoutes == nil || listener.AllowedRoutes.Kinds == nil { - return nil, []v1beta1.RouteGroupKind{ + return nil, []v1.RouteGroupKind{ { Kind: "HTTPRoute", }, @@ -227,20 +227,20 @@ func getAndValidateListenerSupportedKinds(listener v1beta1.Listener) ( } var conds []conditions.Condition - supportedKinds := make([]v1beta1.RouteGroupKind, 0, len(listener.AllowedRoutes.Kinds)) + supportedKinds := make([]v1.RouteGroupKind, 0, len(listener.AllowedRoutes.Kinds)) - validHTTPRouteKind := func(kind v1beta1.RouteGroupKind) bool { - if kind.Kind != v1beta1.Kind("HTTPRoute") { + validHTTPRouteKind := func(kind v1.RouteGroupKind) bool { + if kind.Kind != v1.Kind("HTTPRoute") { return false } - if kind.Group == nil || *kind.Group != v1beta1.GroupName { + if kind.Group == nil || *kind.Group != v1.GroupName { return false } return true } switch listener.Protocol { - case v1beta1.HTTPProtocolType, v1beta1.HTTPSProtocolType: + case v1.HTTPProtocolType, v1.HTTPSProtocolType: for _, kind := range listener.AllowedRoutes.Kinds { if !validHTTPRouteKind(kind) { msg := fmt.Sprintf("Unsupported route kind \"%s/%s\"", *kind.Group, kind.Kind) @@ -253,21 +253,21 @@ func getAndValidateListenerSupportedKinds(listener v1beta1.Listener) ( return conds, supportedKinds } -func validateListenerAllowedRouteKind(listener v1beta1.Listener) []conditions.Condition { +func validateListenerAllowedRouteKind(listener v1.Listener) []conditions.Condition { conds, _ := getAndValidateListenerSupportedKinds(listener) return conds } -func getListenerSupportedKinds(listener v1beta1.Listener) []v1beta1.RouteGroupKind { +func getListenerSupportedKinds(listener v1.Listener) []v1.RouteGroupKind { _, kinds := getAndValidateListenerSupportedKinds(listener) return kinds } -func validateListenerLabelSelector(listener v1beta1.Listener) []conditions.Condition { +func validateListenerLabelSelector(listener v1.Listener) []conditions.Condition { if listener.AllowedRoutes != nil && listener.AllowedRoutes.Namespaces != nil && listener.AllowedRoutes.Namespaces.From != nil && - *listener.AllowedRoutes.Namespaces.From == v1beta1.NamespacesFromSelector && + *listener.AllowedRoutes.Namespaces.From == v1.NamespacesFromSelector && listener.AllowedRoutes.Namespaces.Selector == nil { msg := "Listener's AllowedRoutes Selector must be set when From is set to type Selector" return staticConds.NewListenerUnsupportedValue(msg) @@ -277,7 +277,7 @@ func validateListenerLabelSelector(listener v1beta1.Listener) []conditions.Condi } func createHTTPListenerValidator(protectedPorts ProtectedPorts) listenerValidator { - return func(listener v1beta1.Listener) []conditions.Condition { + return func(listener v1.Listener) []conditions.Condition { var conds []conditions.Condition if err := validateListenerPort(listener.Port, protectedPorts); err != nil { @@ -294,7 +294,7 @@ func createHTTPListenerValidator(protectedPorts ProtectedPorts) listenerValidato } } -func validateListenerPort(port v1beta1.PortNumber, protectedPorts ProtectedPorts) error { +func validateListenerPort(port v1.PortNumber, protectedPorts ProtectedPorts) error { if port < 1 || port > 65535 { return errors.New("port must be between 1-65535") } @@ -307,7 +307,7 @@ func validateListenerPort(port v1beta1.PortNumber, protectedPorts ProtectedPorts } func createHTTPSListenerValidator(protectedPorts ProtectedPorts) listenerValidator { - return func(listener v1beta1.Listener) []conditions.Condition { + return func(listener v1.Listener) []conditions.Condition { var conds []conditions.Condition if err := validateListenerPort(listener.Port, protectedPorts); err != nil { @@ -322,11 +322,11 @@ func createHTTPSListenerValidator(protectedPorts ProtectedPorts) listenerValidat tlsPath := field.NewPath("tls") - if *listener.TLS.Mode != v1beta1.TLSModeTerminate { + if *listener.TLS.Mode != v1.TLSModeTerminate { valErr := field.NotSupported( tlsPath.Child("mode"), *listener.TLS.Mode, - []string{string(v1beta1.TLSModeTerminate)}, + []string{string(v1.TLSModeTerminate)}, ) conds = append(conds, staticConds.NewListenerUnsupportedValue(valErr.Error())...) } @@ -369,9 +369,9 @@ func createHTTPSListenerValidator(protectedPorts ProtectedPorts) listenerValidat } func createPortConflictResolver() listenerConflictResolver { - conflictedPorts := make(map[v1beta1.PortNumber]bool) - portProtocolOwner := make(map[v1beta1.PortNumber]v1beta1.ProtocolType) - listenersByPort := make(map[v1beta1.PortNumber][]*Listener) + conflictedPorts := make(map[v1.PortNumber]bool) + portProtocolOwner := make(map[v1.PortNumber]v1.ProtocolType) + listenersByPort := make(map[v1.PortNumber][]*Listener) format := "Multiple listeners for the same port %d specify incompatible protocols; " + "ensure only one protocol per port" @@ -454,9 +454,9 @@ func createExternalReferencesForTLSSecretsResolver( } // GetAllowedRouteLabelSelector returns a listener's AllowedRoutes label selector if it exists. -func GetAllowedRouteLabelSelector(l v1beta1.Listener) *metav1.LabelSelector { +func GetAllowedRouteLabelSelector(l v1.Listener) *metav1.LabelSelector { if l.AllowedRoutes != nil && l.AllowedRoutes.Namespaces != nil { - if *l.AllowedRoutes.Namespaces.From == v1beta1.NamespacesFromSelector && + if *l.AllowedRoutes.Namespaces.From == v1.NamespacesFromSelector && l.AllowedRoutes.Namespaces.Selector != nil { return l.AllowedRoutes.Namespaces.Selector } diff --git a/internal/mode/static/state/graph/gateway_listener_test.go b/internal/mode/static/state/graph/gateway_listener_test.go index a1b25bf08f..7adb935900 100644 --- a/internal/mode/static/state/graph/gateway_listener_test.go +++ b/internal/mode/static/state/graph/gateway_listener_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" @@ -17,26 +17,26 @@ func TestValidateHTTPListener(t *testing.T) { protectedPorts := ProtectedPorts{9113: "MetricsPort"} tests := []struct { - l v1beta1.Listener + l v1.Listener name string expected []conditions.Condition }{ { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 80, }, expected: nil, name: "valid", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 0, }, expected: staticConds.NewListenerUnsupportedValue(`port: Invalid value: 0: port must be between 1-65535`), name: "invalid port", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 9113, }, expected: staticConds.NewListenerUnsupportedValue( @@ -62,60 +62,60 @@ func TestValidateHTTPListener(t *testing.T) { func TestValidateHTTPSListener(t *testing.T) { secretNs := "secret-ns" - validSecretRef := v1beta1.SecretObjectReference{ - Kind: (*v1beta1.Kind)(helpers.GetPointer("Secret")), + validSecretRef := v1.SecretObjectReference{ + Kind: (*v1.Kind)(helpers.GetPointer("Secret")), Name: "secret", - Namespace: (*v1beta1.Namespace)(helpers.GetPointer(secretNs)), + Namespace: (*v1.Namespace)(helpers.GetPointer(secretNs)), } - invalidSecretRefGroup := v1beta1.SecretObjectReference{ - Group: (*v1beta1.Group)(helpers.GetPointer("some-group")), - Kind: (*v1beta1.Kind)(helpers.GetPointer("Secret")), + invalidSecretRefGroup := v1.SecretObjectReference{ + Group: (*v1.Group)(helpers.GetPointer("some-group")), + Kind: (*v1.Kind)(helpers.GetPointer("Secret")), Name: "secret", - Namespace: (*v1beta1.Namespace)(helpers.GetPointer(secretNs)), + Namespace: (*v1.Namespace)(helpers.GetPointer(secretNs)), } - invalidSecretRefKind := v1beta1.SecretObjectReference{ - Kind: (*v1beta1.Kind)(helpers.GetPointer("ConfigMap")), + invalidSecretRefKind := v1.SecretObjectReference{ + Kind: (*v1.Kind)(helpers.GetPointer("ConfigMap")), Name: "secret", - Namespace: (*v1beta1.Namespace)(helpers.GetPointer(secretNs)), + Namespace: (*v1.Namespace)(helpers.GetPointer(secretNs)), } protectedPorts := ProtectedPorts{9113: "MetricsPort"} tests := []struct { - l v1beta1.Listener + l v1.Listener name string expected []conditions.Condition }{ { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{validSecretRef}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{validSecretRef}, }, }, expected: nil, name: "valid", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 0, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{validSecretRef}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{validSecretRef}, }, }, expected: staticConds.NewListenerUnsupportedValue(`port: Invalid value: 0: port must be between 1-65535`), name: "invalid port", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 9113, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{validSecretRef}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{validSecretRef}, }, }, expected: staticConds.NewListenerUnsupportedValue( @@ -124,23 +124,23 @@ func TestValidateHTTPSListener(t *testing.T) { name: "invalid protected port", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{validSecretRef}, - Options: map[v1beta1.AnnotationKey]v1beta1.AnnotationValue{"key": "val"}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{validSecretRef}, + Options: map[v1.AnnotationKey]v1.AnnotationValue{"key": "val"}, }, }, expected: staticConds.NewListenerUnsupportedValue("tls.options: Forbidden: options are not supported"), name: "invalid options", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModePassthrough), - CertificateRefs: []v1beta1.SecretObjectReference{validSecretRef}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModePassthrough), + CertificateRefs: []v1.SecretObjectReference{validSecretRef}, }, }, expected: staticConds.NewListenerUnsupportedValue( @@ -149,11 +149,11 @@ func TestValidateHTTPSListener(t *testing.T) { name: "invalid tls mode", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{invalidSecretRefGroup}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{invalidSecretRefGroup}, }, }, expected: staticConds.NewListenerInvalidCertificateRef( @@ -162,11 +162,11 @@ func TestValidateHTTPSListener(t *testing.T) { name: "invalid cert ref group", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{invalidSecretRefKind}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{invalidSecretRefKind}, }, }, expected: staticConds.NewListenerInvalidCertificateRef( @@ -175,11 +175,11 @@ func TestValidateHTTPSListener(t *testing.T) { name: "invalid cert ref kind", }, { - l: v1beta1.Listener{ + l: v1.Listener{ Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{validSecretRef, validSecretRef}, + TLS: &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{validSecretRef, validSecretRef}, }, }, expected: staticConds.NewListenerUnsupportedValue( @@ -203,7 +203,7 @@ func TestValidateHTTPSListener(t *testing.T) { func TestValidateListenerHostname(t *testing.T) { tests := []struct { - hostname *v1beta1.Hostname + hostname *v1.Hostname name string expectErr bool }{ @@ -213,22 +213,22 @@ func TestValidateListenerHostname(t *testing.T) { name: "nil hostname", }, { - hostname: (*v1beta1.Hostname)(helpers.GetPointer("")), + hostname: (*v1.Hostname)(helpers.GetPointer("")), expectErr: false, name: "empty hostname", }, { - hostname: (*v1beta1.Hostname)(helpers.GetPointer("foo.example.com")), + hostname: (*v1.Hostname)(helpers.GetPointer("foo.example.com")), expectErr: false, name: "valid hostname", }, { - hostname: (*v1beta1.Hostname)(helpers.GetPointer("*.example.com")), + hostname: (*v1.Hostname)(helpers.GetPointer("*.example.com")), expectErr: false, name: "wildcard hostname", }, { - hostname: (*v1beta1.Hostname)(helpers.GetPointer("example$com")), + hostname: (*v1.Hostname)(helpers.GetPointer("example$com")), expectErr: true, name: "invalid hostname", }, @@ -238,7 +238,7 @@ func TestValidateListenerHostname(t *testing.T) { t.Run(test.name, func(t *testing.T) { g := NewWithT(t) - conds := validateListenerHostname(v1beta1.Listener{Hostname: test.hostname}) + conds := validateListenerHostname(v1.Listener{Hostname: test.hostname}) if test.expectErr { g.Expect(conds).ToNot(BeEmpty()) @@ -250,85 +250,85 @@ func TestValidateListenerHostname(t *testing.T) { } func TestGetAndValidateListenerSupportedKinds(t *testing.T) { - HTTPRouteGroupKind := []v1beta1.RouteGroupKind{ + HTTPRouteGroupKind := []v1.RouteGroupKind{ { Kind: "HTTPRoute", - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[v1.Group](v1.GroupName), }, } - TCPRouteGroupKind := []v1beta1.RouteGroupKind{ + TCPRouteGroupKind := []v1.RouteGroupKind{ { Kind: "TCPRoute", - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[v1.Group](v1.GroupName), }, } tests := []struct { - protocol v1beta1.ProtocolType + protocol v1.ProtocolType name string - kind []v1beta1.RouteGroupKind - expected []v1beta1.RouteGroupKind + kind []v1.RouteGroupKind + expected []v1.RouteGroupKind expectErr bool }{ { - protocol: v1beta1.TCPProtocolType, + protocol: v1.TCPProtocolType, expectErr: false, name: "unsupported protocol is ignored", kind: TCPRouteGroupKind, - expected: []v1beta1.RouteGroupKind{}, + expected: []v1.RouteGroupKind{}, }, { - protocol: v1beta1.HTTPProtocolType, - kind: []v1beta1.RouteGroupKind{ + protocol: v1.HTTPProtocolType, + kind: []v1.RouteGroupKind{ { Kind: "HTTPRoute", - Group: helpers.GetPointer[v1beta1.Group]("bad-group"), + Group: helpers.GetPointer[v1.Group]("bad-group"), }, }, expectErr: true, name: "invalid group", - expected: []v1beta1.RouteGroupKind{}, + expected: []v1.RouteGroupKind{}, }, { - protocol: v1beta1.HTTPProtocolType, + protocol: v1.HTTPProtocolType, kind: TCPRouteGroupKind, expectErr: true, name: "invalid kind", - expected: []v1beta1.RouteGroupKind{}, + expected: []v1.RouteGroupKind{}, }, { - protocol: v1beta1.HTTPProtocolType, + protocol: v1.HTTPProtocolType, kind: HTTPRouteGroupKind, expectErr: false, name: "valid HTTP", expected: HTTPRouteGroupKind, }, { - protocol: v1beta1.HTTPSProtocolType, + protocol: v1.HTTPSProtocolType, kind: HTTPRouteGroupKind, expectErr: false, name: "valid HTTPS", expected: HTTPRouteGroupKind, }, { - protocol: v1beta1.HTTPSProtocolType, + protocol: v1.HTTPSProtocolType, expectErr: false, name: "valid HTTPS no kind specified", - expected: []v1beta1.RouteGroupKind{ + expected: []v1.RouteGroupKind{ { Kind: "HTTPRoute", }, }, }, { - protocol: v1beta1.HTTPProtocolType, - kind: []v1beta1.RouteGroupKind{ + protocol: v1.HTTPProtocolType, + kind: []v1.RouteGroupKind{ { Kind: "HTTPRoute", - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[v1.Group](v1.GroupName), }, { Kind: "bad-kind", - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), + Group: helpers.GetPointer[v1.Group](v1.GroupName), }, }, expectErr: true, @@ -341,12 +341,12 @@ func TestGetAndValidateListenerSupportedKinds(t *testing.T) { t.Run(test.name, func(t *testing.T) { g := NewWithT(t) - listener := v1beta1.Listener{ + listener := v1.Listener{ Protocol: test.protocol, } if test.kind != nil { - listener.AllowedRoutes = &v1beta1.AllowedRoutes{ + listener.AllowedRoutes = &v1.AllowedRoutes{ Kinds: test.kind, } } @@ -365,24 +365,24 @@ func TestGetAndValidateListenerSupportedKinds(t *testing.T) { func TestValidateListenerLabelSelector(t *testing.T) { tests := []struct { selector *metav1.LabelSelector - from v1beta1.FromNamespaces + from v1.FromNamespaces name string expectErr bool }{ { - from: v1beta1.NamespacesFromSelector, + from: v1.NamespacesFromSelector, selector: &metav1.LabelSelector{}, expectErr: false, name: "valid spec", }, { - from: v1beta1.NamespacesFromSelector, + from: v1.NamespacesFromSelector, selector: nil, expectErr: true, name: "invalid spec", }, { - from: v1beta1.NamespacesFromAll, + from: v1.NamespacesFromAll, selector: nil, expectErr: false, name: "ignored from type", @@ -396,9 +396,9 @@ func TestValidateListenerLabelSelector(t *testing.T) { // create iteration variable inside the loop to fix implicit memory aliasing from := test.from - listener := v1beta1.Listener{ - AllowedRoutes: &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ + listener := v1.Listener{ + AllowedRoutes: &v1.AllowedRoutes{ + Namespaces: &v1.RouteNamespaces{ From: &from, Selector: test.selector, }, @@ -416,8 +416,8 @@ func TestValidateListenerLabelSelector(t *testing.T) { } func TestValidateListenerPort(t *testing.T) { - validPorts := []v1beta1.PortNumber{1, 80, 443, 1000, 50000, 65535} - invalidPorts := []v1beta1.PortNumber{-1, 0, 65536, 80000, 9113} + validPorts := []v1.PortNumber{1, 80, 443, 1000, 50000, 65535} + invalidPorts := []v1.PortNumber{-1, 0, 65536, 80000, 9113} protectedPorts := ProtectedPorts{9113: "MetricsPort"} for _, p := range validPorts { diff --git a/internal/mode/static/state/graph/gateway_test.go b/internal/mode/static/state/graph/gateway_test.go index 6816e6c5a5..fa550c0856 100644 --- a/internal/mode/static/state/graph/gateway_test.go +++ b/internal/mode/static/state/graph/gateway_test.go @@ -10,20 +10,21 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" + v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" ) func TestProcessedGatewaysGetAllNsNames(t *testing.T) { - winner := &v1beta1.Gateway{ + winner := &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway-1", }, } - loser := &v1beta1.Gateway{ + loser := &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway-2", @@ -43,7 +44,7 @@ func TestProcessedGatewaysGetAllNsNames(t *testing.T) { { gws: processedGateways{ Winner: winner, - Ignored: map[types.NamespacedName]*v1beta1.Gateway{ + Ignored: map[types.NamespacedName]*v1.Gateway{ client.ObjectKeyFromObject(loser): loser, }, }, @@ -67,27 +68,27 @@ func TestProcessedGatewaysGetAllNsNames(t *testing.T) { func TestProcessGateways(t *testing.T) { const gcName = "test-gc" - winner := &v1beta1.Gateway{ + winner := &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway-1", }, - Spec: v1beta1.GatewaySpec{ + Spec: v1.GatewaySpec{ GatewayClassName: gcName, }, } - loser := &v1beta1.Gateway{ + loser := &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway-2", }, - Spec: v1beta1.GatewaySpec{ + Spec: v1.GatewaySpec{ GatewayClassName: gcName, }, } tests := []struct { - gws map[types.NamespacedName]*v1beta1.Gateway + gws map[types.NamespacedName]*v1.Gateway expected processedGateways name string }{ @@ -97,32 +98,32 @@ func TestProcessGateways(t *testing.T) { name: "no gateways", }, { - gws: map[types.NamespacedName]*v1beta1.Gateway{ + gws: map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "some-gateway"}: { - Spec: v1beta1.GatewaySpec{GatewayClassName: "some-class"}, + Spec: v1.GatewaySpec{GatewayClassName: "some-class"}, }, }, expected: processedGateways{}, name: "unrelated gateway", }, { - gws: map[types.NamespacedName]*v1beta1.Gateway{ + gws: map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "gateway-1"}: winner, }, expected: processedGateways{ Winner: winner, - Ignored: map[types.NamespacedName]*v1beta1.Gateway{}, + Ignored: map[types.NamespacedName]*v1.Gateway{}, }, name: "one gateway", }, { - gws: map[types.NamespacedName]*v1beta1.Gateway{ + gws: map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "gateway-1"}: winner, {Namespace: "test", Name: "gateway-2"}: loser, }, expected: processedGateways{ Winner: winner, - Ignored: map[types.NamespacedName]*v1beta1.Gateway{ + Ignored: map[types.NamespacedName]*v1.Gateway{ {Namespace: "test", Name: "gateway-2"}: loser, }, }, @@ -148,17 +149,17 @@ func TestBuildGateway(t *testing.T) { protectedPorts := ProtectedPorts{ 9113: "MetricsPort", } - listenerAllowedRoutes := v1beta1.Listener{ + listenerAllowedRoutes := v1.Listener{ Name: "listener-with-allowed-routes", - Hostname: helpers.GetPointer[v1beta1.Hostname]("foo.example.com"), + Hostname: helpers.GetPointer[v1.Hostname]("foo.example.com"), Port: 80, - Protocol: v1beta1.HTTPProtocolType, - AllowedRoutes: &v1beta1.AllowedRoutes{ - Kinds: []v1beta1.RouteGroupKind{ - {Kind: "HTTPRoute", Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName)}, + Protocol: v1.HTTPProtocolType, + AllowedRoutes: &v1.AllowedRoutes{ + Kinds: []v1.RouteGroupKind{ + {Kind: "HTTPRoute", Group: helpers.GetPointer[v1.Group](v1.GroupName)}, }, - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + Namespaces: &v1.RouteNamespaces{ + From: helpers.GetPointer(v1.NamespacesFromSelector), Selector: &metav1.LabelSelector{MatchLabels: labelSet}, }, }, @@ -183,24 +184,24 @@ func TestBuildGateway(t *testing.T) { Type: apiv1.SecretTypeTLS, } - gatewayTLSConfigSameNs := &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + gatewayTLSConfigSameNs := &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: helpers.GetPointer[v1beta1.Kind]("Secret"), - Name: v1beta1.ObjectName(secretSameNs.Name), - Namespace: (*v1beta1.Namespace)(&secretSameNs.Namespace), + Kind: helpers.GetPointer[v1.Kind]("Secret"), + Name: v1.ObjectName(secretSameNs.Name), + Namespace: (*v1.Namespace)(&secretSameNs.Namespace), }, }, } - tlsConfigInvalidSecret := &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + tlsConfigInvalidSecret := &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: helpers.GetPointer[v1beta1.Kind]("Secret"), + Kind: helpers.GetPointer[v1.Kind]("Secret"), Name: "does-not-exist", - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), + Namespace: helpers.GetPointer[v1.Namespace]("test"), }, }, } @@ -217,13 +218,13 @@ func TestBuildGateway(t *testing.T) { Type: apiv1.SecretTypeTLS, } - gatewayTLSConfigDiffNs := &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + gatewayTLSConfigDiffNs := &v1.GatewayTLSConfig{ + Mode: helpers.GetPointer(v1.TLSModeTerminate), + CertificateRefs: []v1.SecretObjectReference{ { - Kind: helpers.GetPointer[v1beta1.Kind]("Secret"), - Name: v1beta1.ObjectName(secretDiffNamespace.Name), - Namespace: (*v1beta1.Namespace)(&secretDiffNamespace.Namespace), + Kind: helpers.GetPointer[v1.Kind]("Secret"), + Name: v1.ObjectName(secretDiffNamespace.Name), + Namespace: (*v1.Namespace)(&secretDiffNamespace.Namespace), }, }, } @@ -232,25 +233,25 @@ func TestBuildGateway(t *testing.T) { name string, hostname string, port int, - protocol v1beta1.ProtocolType, - tls *v1beta1.GatewayTLSConfig, - ) v1beta1.Listener { - return v1beta1.Listener{ - Name: v1beta1.SectionName(name), - Hostname: (*v1beta1.Hostname)(helpers.GetPointer(hostname)), - Port: v1beta1.PortNumber(port), + protocol v1.ProtocolType, + tls *v1.GatewayTLSConfig, + ) v1.Listener { + return v1.Listener{ + Name: v1.SectionName(name), + Hostname: (*v1.Hostname)(helpers.GetPointer(hostname)), + Port: v1.PortNumber(port), Protocol: protocol, TLS: tls, } } - createHTTPListener := func(name, hostname string, port int) v1beta1.Listener { - return createListener(name, hostname, port, v1beta1.HTTPProtocolType, nil) + createHTTPListener := func(name, hostname string, port int) v1.Listener { + return createListener(name, hostname, port, v1.HTTPProtocolType, nil) } - createTCPListener := func(name, hostname string, port int) v1beta1.Listener { - return createListener(name, hostname, port, v1beta1.TCPProtocolType, nil) + createTCPListener := func(name, hostname string, port int) v1.Listener { + return createListener(name, hostname, port, v1.TCPProtocolType, nil) } - createHTTPSListener := func(name, hostname string, port int, tls *v1beta1.GatewayTLSConfig) v1beta1.Listener { - return createListener(name, hostname, port, v1beta1.HTTPSProtocolType, tls) + createHTTPSListener := func(name, hostname string, port int, tls *v1.GatewayTLSConfig) v1.Listener { + return createListener(name, hostname, port, v1.HTTPSProtocolType, tls) } // foo http listeners @@ -312,17 +313,17 @@ func TestBuildGateway(t *testing.T) { ) type gatewayCfg struct { - listeners []v1beta1.Listener - addresses []v1beta1.GatewayAddress + listeners []v1.Listener + addresses []v1.GatewayAddress } - var lastCreatedGateway *v1beta1.Gateway - createGateway := func(cfg gatewayCfg) *v1beta1.Gateway { - lastCreatedGateway = &v1beta1.Gateway{ + var lastCreatedGateway *v1.Gateway + createGateway := func(cfg gatewayCfg) *v1.Gateway { + lastCreatedGateway = &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", }, - Spec: v1beta1.GatewaySpec{ + Spec: v1.GatewaySpec{ GatewayClassName: gcName, Listeners: cfg.listeners, Addresses: cfg.addresses, @@ -330,7 +331,7 @@ func TestBuildGateway(t *testing.T) { } return lastCreatedGateway } - getLastCreatedGetaway := func() *v1beta1.Gateway { + getLastCreatedGetaway := func() *v1.Gateway { return lastCreatedGateway } @@ -342,14 +343,14 @@ func TestBuildGateway(t *testing.T) { } tests := []struct { - gateway *v1beta1.Gateway + gateway *v1.Gateway gatewayClass *GatewayClass refGrants map[types.NamespacedName]*v1beta1.ReferenceGrant expected *Gateway name string }{ { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{foo80Listener1, foo8080Listener}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{foo80Listener1, foo8080Listener}}), gatewayClass: validGC, expected: &Gateway{ Source: getLastCreatedGetaway(), @@ -358,7 +359,7 @@ func TestBuildGateway(t *testing.T) { Source: foo80Listener1, Valid: true, Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -366,7 +367,7 @@ func TestBuildGateway(t *testing.T) { Source: foo8080Listener, Valid: true, Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -377,7 +378,7 @@ func TestBuildGateway(t *testing.T) { }, { gateway: createGateway( - gatewayCfg{listeners: []v1beta1.Listener{foo443HTTPSListener1, foo8443HTTPSListener}}, + gatewayCfg{listeners: []v1.Listener{foo443HTTPSListener1, foo8443HTTPSListener}}, ), gatewayClass: validGC, expected: &Gateway{ @@ -388,7 +389,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -397,7 +398,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -407,7 +408,7 @@ func TestBuildGateway(t *testing.T) { name: "valid https listeners", }, { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{listenerAllowedRoutes}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{listenerAllowedRoutes}}), gatewayClass: validGC, expected: &Gateway{ Source: getLastCreatedGetaway(), @@ -417,8 +418,8 @@ func TestBuildGateway(t *testing.T) { Valid: true, AllowedRouteLabelSelector: labels.SelectorFromSet(labels.Set(labelSet)), Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ - {Kind: "HTTPRoute", Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName)}, + SupportedKinds: []v1.RouteGroupKind{ + {Kind: "HTTPRoute", Group: helpers.GetPointer[v1.Group](v1.GroupName)}, }, }, }, @@ -427,7 +428,7 @@ func TestBuildGateway(t *testing.T) { name: "valid http listener with allowed routes label selector", }, { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{crossNamespaceSecretListener}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{crossNamespaceSecretListener}}), gatewayClass: validGC, refGrants: map[types.NamespacedName]*v1beta1.ReferenceGrant{ {Name: "ref-grant", Namespace: "diff-ns"}: { @@ -438,7 +439,7 @@ func TestBuildGateway(t *testing.T) { Spec: v1beta1.ReferenceGrantSpec{ From: []v1beta1.ReferenceGrantFrom{ { - Group: v1beta1.GroupName, + Group: v1.GroupName, Kind: "Gateway", Namespace: "test", }, @@ -447,7 +448,7 @@ func TestBuildGateway(t *testing.T) { { Group: "core", Kind: "Secret", - Name: helpers.GetPointer[v1beta1.ObjectName]("secret"), + Name: helpers.GetPointer[v1.ObjectName]("secret"), }, }, }, @@ -461,7 +462,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretDiffNamespace)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -471,7 +472,7 @@ func TestBuildGateway(t *testing.T) { name: "valid https listener with cross-namespace secret; allowed by reference grant", }, { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{crossNamespaceSecretListener}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{crossNamespaceSecretListener}}), gatewayClass: validGC, expected: &Gateway{ Source: getLastCreatedGetaway(), @@ -483,7 +484,7 @@ func TestBuildGateway(t *testing.T) { `Certificate ref to secret diff-ns/secret not permitted by any ReferenceGrant`, ), Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -493,7 +494,7 @@ func TestBuildGateway(t *testing.T) { name: "invalid https listener with cross-namespace secret; no reference grant", }, { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{listenerInvalidSelector}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{listenerInvalidSelector}}), gatewayClass: validGC, expected: &Gateway{ Source: getLastCreatedGetaway(), @@ -504,8 +505,8 @@ func TestBuildGateway(t *testing.T) { Conditions: staticConds.NewListenerUnsupportedValue( `invalid label selector: "invalid" is not a valid label selector operator`, ), - SupportedKinds: []v1beta1.RouteGroupKind{ - {Kind: "HTTPRoute", Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName)}, + SupportedKinds: []v1.RouteGroupKind{ + {Kind: "HTTPRoute", Group: helpers.GetPointer[v1.Group](v1.GroupName)}, }, }, }, @@ -514,7 +515,7 @@ func TestBuildGateway(t *testing.T) { name: "http listener with invalid label selector", }, { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{invalidProtocolListener}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{invalidProtocolListener}}), gatewayClass: validGC, expected: &Gateway{ Source: getLastCreatedGetaway(), @@ -525,7 +526,7 @@ func TestBuildGateway(t *testing.T) { Conditions: staticConds.NewListenerUnsupportedProtocol( `protocol: Unsupported value: "TCP": supported values: "HTTP", "HTTPS"`, ), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -537,7 +538,7 @@ func TestBuildGateway(t *testing.T) { { gateway: createGateway( gatewayCfg{ - listeners: []v1beta1.Listener{ + listeners: []v1.Listener{ invalidPortListener, invalidHTTPSPortListener, invalidProtectedPortListener, @@ -554,7 +555,7 @@ func TestBuildGateway(t *testing.T) { Conditions: staticConds.NewListenerUnsupportedValue( `port: Invalid value: 0: port must be between 1-65535`, ), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -564,7 +565,7 @@ func TestBuildGateway(t *testing.T) { Conditions: staticConds.NewListenerUnsupportedValue( `port: Invalid value: 0: port must be between 1-65535`, ), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -574,7 +575,7 @@ func TestBuildGateway(t *testing.T) { Conditions: staticConds.NewListenerUnsupportedValue( `port: Invalid value: 9113: port is already in use as MetricsPort`, ), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -585,7 +586,7 @@ func TestBuildGateway(t *testing.T) { }, { gateway: createGateway( - gatewayCfg{listeners: []v1beta1.Listener{invalidHostnameListener, invalidHTTPSHostnameListener}}, + gatewayCfg{listeners: []v1.Listener{invalidHostnameListener, invalidHTTPSHostnameListener}}, ), gatewayClass: validGC, expected: &Gateway{ @@ -595,7 +596,7 @@ func TestBuildGateway(t *testing.T) { Source: invalidHostnameListener, Valid: false, Conditions: staticConds.NewListenerUnsupportedValue(invalidHostnameMsg), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -603,7 +604,7 @@ func TestBuildGateway(t *testing.T) { Source: invalidHTTPSHostnameListener, Valid: false, Conditions: staticConds.NewListenerUnsupportedValue(invalidHostnameMsg), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -613,7 +614,7 @@ func TestBuildGateway(t *testing.T) { name: "invalid hostnames", }, { - gateway: createGateway(gatewayCfg{listeners: []v1beta1.Listener{invalidTLSConfigListener}}), + gateway: createGateway(gatewayCfg{listeners: []v1.Listener{invalidTLSConfigListener}}), gatewayClass: validGC, expected: &Gateway{ Source: getLastCreatedGetaway(), @@ -625,7 +626,7 @@ func TestBuildGateway(t *testing.T) { Conditions: staticConds.NewListenerInvalidCertificateRef( `tls.certificateRefs[0]: Invalid value: test/does-not-exist: secret does not exist`, ), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -637,7 +638,7 @@ func TestBuildGateway(t *testing.T) { { gateway: createGateway( gatewayCfg{ - listeners: []v1beta1.Listener{ + listeners: []v1.Listener{ foo80Listener1, foo8080Listener, foo8081Listener, @@ -657,7 +658,7 @@ func TestBuildGateway(t *testing.T) { Source: foo80Listener1, Valid: true, Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -665,7 +666,7 @@ func TestBuildGateway(t *testing.T) { Source: foo8080Listener, Valid: true, Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -673,7 +674,7 @@ func TestBuildGateway(t *testing.T) { Source: foo8081Listener, Valid: true, Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -681,7 +682,7 @@ func TestBuildGateway(t *testing.T) { Source: bar80Listener, Valid: true, Routes: map[types.NamespacedName]*Route{}, - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -690,7 +691,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -699,7 +700,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -708,7 +709,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -717,7 +718,7 @@ func TestBuildGateway(t *testing.T) { Valid: true, Routes: map[types.NamespacedName]*Route{}, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -729,7 +730,7 @@ func TestBuildGateway(t *testing.T) { { gateway: createGateway( gatewayCfg{ - listeners: []v1beta1.Listener{ + listeners: []v1.Listener{ foo80Listener1, bar80Listener, foo443Listener, @@ -748,7 +749,7 @@ func TestBuildGateway(t *testing.T) { Valid: false, Routes: map[types.NamespacedName]*Route{}, Conditions: staticConds.NewListenerProtocolConflict(conflict80PortMsg), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -757,7 +758,7 @@ func TestBuildGateway(t *testing.T) { Valid: false, Routes: map[types.NamespacedName]*Route{}, Conditions: staticConds.NewListenerProtocolConflict(conflict80PortMsg), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -766,7 +767,7 @@ func TestBuildGateway(t *testing.T) { Valid: false, Routes: map[types.NamespacedName]*Route{}, Conditions: staticConds.NewListenerProtocolConflict(conflict443PortMsg), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -776,7 +777,7 @@ func TestBuildGateway(t *testing.T) { Routes: map[types.NamespacedName]*Route{}, Conditions: staticConds.NewListenerProtocolConflict(conflict80PortMsg), ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -786,7 +787,7 @@ func TestBuildGateway(t *testing.T) { Routes: map[types.NamespacedName]*Route{}, Conditions: staticConds.NewListenerProtocolConflict(conflict443PortMsg), ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -796,7 +797,7 @@ func TestBuildGateway(t *testing.T) { Routes: map[types.NamespacedName]*Route{}, Conditions: staticConds.NewListenerProtocolConflict(conflict443PortMsg), ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secretSameNs)), - SupportedKinds: []v1beta1.RouteGroupKind{ + SupportedKinds: []v1.RouteGroupKind{ {Kind: "HTTPRoute"}, }, }, @@ -808,8 +809,8 @@ func TestBuildGateway(t *testing.T) { { gateway: createGateway( gatewayCfg{ - listeners: []v1beta1.Listener{foo80Listener1, foo443HTTPSListener1}, - addresses: []v1beta1.GatewayAddress{{}}, + listeners: []v1.Listener{foo80Listener1, foo443HTTPSListener1}, + addresses: []v1.GatewayAddress{{}}, }, ), gatewayClass: validGC, @@ -829,7 +830,7 @@ func TestBuildGateway(t *testing.T) { }, { gateway: createGateway( - gatewayCfg{listeners: []v1beta1.Listener{foo80Listener1, invalidProtocolListener}}, + gatewayCfg{listeners: []v1.Listener{foo80Listener1, invalidProtocolListener}}, ), gatewayClass: invalidGC, expected: &Gateway{ @@ -841,7 +842,7 @@ func TestBuildGateway(t *testing.T) { }, { gateway: createGateway( - gatewayCfg{listeners: []v1beta1.Listener{foo80Listener1, invalidProtocolListener}}, + gatewayCfg{listeners: []v1.Listener{foo80Listener1, invalidProtocolListener}}, ), gatewayClass: nil, expected: &Gateway{ diff --git a/internal/mode/static/state/graph/gatewayclass.go b/internal/mode/static/state/graph/gatewayclass.go index 819f7a4860..929bf1611b 100644 --- a/internal/mode/static/state/graph/gatewayclass.go +++ b/internal/mode/static/state/graph/gatewayclass.go @@ -4,7 +4,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" @@ -13,7 +13,7 @@ import ( // GatewayClass represents the GatewayClass resource. type GatewayClass struct { // Source is the source resource. - Source *v1beta1.GatewayClass + Source *v1.GatewayClass // Conditions include Conditions for the GatewayClass. Conditions []conditions.Condition // Valid shows whether the GatewayClass is valid. @@ -22,8 +22,8 @@ type GatewayClass struct { // processedGatewayClasses holds the resources that belong to NGF. type processedGatewayClasses struct { - Winner *v1beta1.GatewayClass - Ignored map[types.NamespacedName]*v1beta1.GatewayClass + Winner *v1.GatewayClass + Ignored map[types.NamespacedName]*v1.GatewayClass } // processGatewayClasses returns the "Winner" GatewayClass, which is defined in @@ -32,7 +32,7 @@ type processedGatewayClasses struct { // Also returns a boolean that says whether or not the GatewayClass defined // in the command-line argument exists, regardless of which controller it references. func processGatewayClasses( - gcs map[types.NamespacedName]*v1beta1.GatewayClass, + gcs map[types.NamespacedName]*v1.GatewayClass, gcName string, controllerName string, ) (processedGatewayClasses, bool) { @@ -47,7 +47,7 @@ func processGatewayClasses( } } else if string(gc.Spec.ControllerName) == controllerName { if processedGwClasses.Ignored == nil { - processedGwClasses.Ignored = make(map[types.NamespacedName]*v1beta1.GatewayClass) + processedGwClasses.Ignored = make(map[types.NamespacedName]*v1.GatewayClass) } processedGwClasses.Ignored[client.ObjectKeyFromObject(gc)] = gc } @@ -56,7 +56,7 @@ func processGatewayClasses( return processedGwClasses, gcExists } -func buildGatewayClass(gc *v1beta1.GatewayClass) *GatewayClass { +func buildGatewayClass(gc *v1.GatewayClass) *GatewayClass { if gc == nil { return nil } @@ -75,7 +75,7 @@ func buildGatewayClass(gc *v1beta1.GatewayClass) *GatewayClass { } } -func validateGatewayClass(gc *v1beta1.GatewayClass) error { +func validateGatewayClass(gc *v1.GatewayClass) error { if gc.Spec.ParametersRef != nil { path := field.NewPath("spec").Child("parametersRef") return field.Forbidden(path, "parametersRef is not supported") diff --git a/internal/mode/static/state/graph/gatewayclass_test.go b/internal/mode/static/state/graph/gatewayclass_test.go index b5e899b00b..4ad77bd3c9 100644 --- a/internal/mode/static/state/graph/gatewayclass_test.go +++ b/internal/mode/static/state/graph/gatewayclass_test.go @@ -7,7 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" @@ -17,26 +17,26 @@ import ( func TestProcessGatewayClasses(t *testing.T) { gcName := "test-gc" ctlrName := "test-ctlr" - winner := &v1beta1.GatewayClass{ + winner := &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, - Spec: v1beta1.GatewayClassSpec{ - ControllerName: v1beta1.GatewayController(ctlrName), + Spec: v1.GatewayClassSpec{ + ControllerName: v1.GatewayController(ctlrName), }, } - ignored := &v1beta1.GatewayClass{ + ignored := &v1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: "test-gc-ignored", }, - Spec: v1beta1.GatewayClassSpec{ - ControllerName: v1beta1.GatewayController(ctlrName), + Spec: v1.GatewayClassSpec{ + ControllerName: v1.GatewayController(ctlrName), }, } tests := []struct { expected processedGatewayClasses - gcs map[types.NamespacedName]*v1beta1.GatewayClass + gcs map[types.NamespacedName]*v1.GatewayClass name string exists bool }{ @@ -46,7 +46,7 @@ func TestProcessGatewayClasses(t *testing.T) { name: "no gatewayclasses", }, { - gcs: map[types.NamespacedName]*v1beta1.GatewayClass{ + gcs: map[types.NamespacedName]*v1.GatewayClass{ {Name: gcName}: winner, }, expected: processedGatewayClasses{ @@ -56,13 +56,13 @@ func TestProcessGatewayClasses(t *testing.T) { name: "one valid gatewayclass", }, { - gcs: map[types.NamespacedName]*v1beta1.GatewayClass{ + gcs: map[types.NamespacedName]*v1.GatewayClass{ {Name: gcName}: { ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, - Spec: v1beta1.GatewayClassSpec{ - ControllerName: v1beta1.GatewayController("not ours"), + Spec: v1.GatewayClassSpec{ + ControllerName: v1.GatewayController("not ours"), }, }, }, @@ -71,21 +71,21 @@ func TestProcessGatewayClasses(t *testing.T) { name: "one valid gatewayclass, but references wrong controller", }, { - gcs: map[types.NamespacedName]*v1beta1.GatewayClass{ + gcs: map[types.NamespacedName]*v1.GatewayClass{ {Name: ignored.Name}: ignored, }, expected: processedGatewayClasses{ - Ignored: map[types.NamespacedName]*v1beta1.GatewayClass{ + Ignored: map[types.NamespacedName]*v1.GatewayClass{ client.ObjectKeyFromObject(ignored): ignored, }, }, name: "one non-referenced gatewayclass with our controller", }, { - gcs: map[types.NamespacedName]*v1beta1.GatewayClass{ + gcs: map[types.NamespacedName]*v1.GatewayClass{ {Name: "completely ignored"}: { - Spec: v1beta1.GatewayClassSpec{ - ControllerName: v1beta1.GatewayController("not ours"), + Spec: v1.GatewayClassSpec{ + ControllerName: v1.GatewayController("not ours"), }, }, }, @@ -93,13 +93,13 @@ func TestProcessGatewayClasses(t *testing.T) { name: "one non-referenced gatewayclass without our controller", }, { - gcs: map[types.NamespacedName]*v1beta1.GatewayClass{ + gcs: map[types.NamespacedName]*v1.GatewayClass{ {Name: gcName}: winner, {Name: ignored.Name}: ignored, }, expected: processedGatewayClasses{ Winner: winner, - Ignored: map[types.NamespacedName]*v1beta1.GatewayClass{ + Ignored: map[types.NamespacedName]*v1.GatewayClass{ client.ObjectKeyFromObject(ignored): ignored, }, }, @@ -119,16 +119,16 @@ func TestProcessGatewayClasses(t *testing.T) { } func TestBuildGatewayClass(t *testing.T) { - validGC := &v1beta1.GatewayClass{} + validGC := &v1.GatewayClass{} - invalidGC := &v1beta1.GatewayClass{ - Spec: v1beta1.GatewayClassSpec{ - ParametersRef: &v1beta1.ParametersReference{}, + invalidGC := &v1.GatewayClass{ + Spec: v1.GatewayClassSpec{ + ParametersRef: &v1.ParametersReference{}, }, } tests := []struct { - gc *v1beta1.GatewayClass + gc *v1.GatewayClass expected *GatewayClass name string }{ diff --git a/internal/mode/static/state/graph/graph.go b/internal/mode/static/state/graph/graph.go index f5b0102ead..8e370011e3 100644 --- a/internal/mode/static/state/graph/graph.go +++ b/internal/mode/static/state/graph/graph.go @@ -4,6 +4,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/validation" @@ -11,9 +12,9 @@ import ( // ClusterState includes cluster resources necessary to build the Graph. type ClusterState struct { - GatewayClasses map[types.NamespacedName]*v1beta1.GatewayClass - Gateways map[types.NamespacedName]*v1beta1.Gateway - HTTPRoutes map[types.NamespacedName]*v1beta1.HTTPRoute + GatewayClasses map[types.NamespacedName]*gatewayv1.GatewayClass + Gateways map[types.NamespacedName]*gatewayv1.Gateway + HTTPRoutes map[types.NamespacedName]*gatewayv1.HTTPRoute Services map[types.NamespacedName]*v1.Service Namespaces map[types.NamespacedName]*v1.Namespace ReferenceGrants map[types.NamespacedName]*v1beta1.ReferenceGrant @@ -29,11 +30,11 @@ type Graph struct { // IgnoredGatewayClasses holds the ignored GatewayClass resources, which reference NGINX Gateway Fabric in the // controllerName, but are not configured via the NGINX Gateway Fabric CLI argument. It doesn't hold the GatewayClass // resources that do not belong to the NGINX Gateway Fabric. - IgnoredGatewayClasses map[types.NamespacedName]*v1beta1.GatewayClass + IgnoredGatewayClasses map[types.NamespacedName]*gatewayv1.GatewayClass // IgnoredGateways holds the ignored Gateway resources, which belong to the NGINX Gateway Fabric (based on the // GatewayClassName field of the resource) but ignored. It doesn't hold the Gateway resources that do not belong to // the NGINX Gateway Fabric. - IgnoredGateways map[types.NamespacedName]*v1beta1.Gateway + IgnoredGateways map[types.NamespacedName]*gatewayv1.Gateway // Routes holds Route resources. Routes map[types.NamespacedName]*Route // ReferencedSecrets includes Secrets referenced by Gateway Listeners, including invalid ones. diff --git a/internal/mode/static/state/graph/graph_test.go b/internal/mode/static/state/graph/graph_test.go index bdd16771c0..84091377e9 100644 --- a/internal/mode/static/state/graph/graph_test.go +++ b/internal/mode/static/state/graph/graph_test.go @@ -9,7 +9,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" + v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/validation" @@ -35,43 +36,43 @@ func TestBuildGraph(t *testing.T) { } } - createRoute := func(name string, gatewayName string, listenerName string) *v1beta1.HTTPRoute { - return &v1beta1.HTTPRoute{ + createRoute := func(name string, gatewayName string, listenerName string) *gatewayv1.HTTPRoute { + return &gatewayv1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: gatewayv1.HTTPRouteSpec{ + CommonRouteSpec: gatewayv1.CommonRouteSpec{ + ParentRefs: []gatewayv1.ParentReference{ { - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), - Name: v1beta1.ObjectName(gatewayName), - SectionName: (*v1beta1.SectionName)(helpers.GetPointer(listenerName)), + Namespace: (*gatewayv1.Namespace)(helpers.GetPointer("test")), + Name: gatewayv1.ObjectName(gatewayName), + SectionName: (*gatewayv1.SectionName)(helpers.GetPointer(listenerName)), }, }, }, - Hostnames: []v1beta1.Hostname{ + Hostnames: []gatewayv1.Hostname{ "foo.example.com", }, - Rules: []v1beta1.HTTPRouteRule{ + Rules: []gatewayv1.HTTPRouteRule{ { - Matches: []v1beta1.HTTPRouteMatch{ + Matches: []gatewayv1.HTTPRouteMatch{ { - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), }, }, }, - BackendRefs: []v1beta1.HTTPBackendRef{ + BackendRefs: []gatewayv1.HTTPBackendRef{ { - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ - Kind: (*v1beta1.Kind)(helpers.GetPointer("Service")), + BackendRef: gatewayv1.BackendRef{ + BackendObjectReference: gatewayv1.BackendObjectReference{ + Kind: (*gatewayv1.Kind)(helpers.GetPointer("Service")), Name: "foo", - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("service")), - Port: (*v1beta1.PortNumber)(helpers.GetPointer[int32](80)), + Namespace: (*gatewayv1.Namespace)(helpers.GetPointer("service")), + Port: (*gatewayv1.PortNumber)(helpers.GetPointer[int32](80)), }, }, }, @@ -118,37 +119,37 @@ func TestBuildGraph(t *testing.T) { Type: v1.SecretTypeTLS, } - createGateway := func(name string) *v1beta1.Gateway { - return &v1beta1.Gateway{ + createGateway := func(name string) *gatewayv1.Gateway { + return &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, }, - Spec: v1beta1.GatewaySpec{ + Spec: gatewayv1.GatewaySpec{ GatewayClassName: gcName, - Listeners: []v1beta1.Listener{ + Listeners: []gatewayv1.Listener{ { Name: "listener-80-1", Hostname: nil, Port: 80, - Protocol: v1beta1.HTTPProtocolType, + Protocol: gatewayv1.HTTPProtocolType, }, { Name: "listener-443-1", Hostname: nil, Port: 443, - TLS: &v1beta1.GatewayTLSConfig{ - Mode: helpers.GetPointer(v1beta1.TLSModeTerminate), - CertificateRefs: []v1beta1.SecretObjectReference{ + TLS: &gatewayv1.GatewayTLSConfig{ + Mode: helpers.GetPointer(gatewayv1.TLSModeTerminate), + CertificateRefs: []gatewayv1.SecretObjectReference{ { - Kind: helpers.GetPointer[v1beta1.Kind]("Secret"), - Name: v1beta1.ObjectName(secret.Name), - Namespace: helpers.GetPointer(v1beta1.Namespace(secret.Namespace)), + Kind: helpers.GetPointer[gatewayv1.Kind]("Secret"), + Name: gatewayv1.ObjectName(secret.Name), + Namespace: helpers.GetPointer(gatewayv1.Namespace(secret.Namespace)), }, }, }, - Protocol: v1beta1.HTTPSProtocolType, + Protocol: gatewayv1.HTTPSProtocolType, }, }, }, @@ -168,7 +169,7 @@ func TestBuildGraph(t *testing.T) { Spec: v1beta1.ReferenceGrantSpec{ From: []v1beta1.ReferenceGrantFrom{ { - Group: v1beta1.GroupName, + Group: gatewayv1.GroupName, Kind: "Gateway", Namespace: "test", }, @@ -189,7 +190,7 @@ func TestBuildGraph(t *testing.T) { Spec: v1beta1.ReferenceGrantSpec{ From: []v1beta1.ReferenceGrantFrom{ { - Group: v1beta1.GroupName, + Group: gatewayv1.GroupName, Kind: "HTTPRoute", Namespace: "test", }, @@ -202,16 +203,16 @@ func TestBuildGraph(t *testing.T) { }, } - createStateWithGatewayClass := func(gc *v1beta1.GatewayClass) ClusterState { + createStateWithGatewayClass := func(gc *gatewayv1.GatewayClass) ClusterState { return ClusterState{ - GatewayClasses: map[types.NamespacedName]*v1beta1.GatewayClass{ + GatewayClasses: map[types.NamespacedName]*gatewayv1.GatewayClass{ client.ObjectKeyFromObject(gc): gc, }, - Gateways: map[types.NamespacedName]*v1beta1.Gateway{ + Gateways: map[types.NamespacedName]*gatewayv1.Gateway{ client.ObjectKeyFromObject(gw1): gw1, client.ObjectKeyFromObject(gw2): gw2, }, - HTTPRoutes: map[types.NamespacedName]*v1beta1.HTTPRoute{ + HTTPRoutes: map[types.NamespacedName]*gatewayv1.HTTPRoute{ client.ObjectKeyFromObject(hr1): hr1, client.ObjectKeyFromObject(hr2): hr2, client.ObjectKeyFromObject(hr3): hr3, @@ -261,7 +262,7 @@ func TestBuildGraph(t *testing.T) { Rules: []Rule{createValidRuleWithBackendRefs(hr3Refs)}, } - createExpectedGraphWithGatewayClass := func(gc *v1beta1.GatewayClass) *Graph { + createExpectedGraphWithGatewayClass := func(gc *gatewayv1.GatewayClass) *Graph { return &Graph{ GatewayClass: &GatewayClass{ Source: gc, @@ -276,7 +277,7 @@ func TestBuildGraph(t *testing.T) { Routes: map[types.NamespacedName]*Route{ {Namespace: "test", Name: "hr-1"}: routeHR1, }, - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []gatewayv1.RouteGroupKind{{Kind: "HTTPRoute"}}, }, "listener-443-1": { Source: gw1.Spec.Listeners[1], @@ -285,12 +286,12 @@ func TestBuildGraph(t *testing.T) { {Namespace: "test", Name: "hr-3"}: routeHR3, }, ResolvedSecret: helpers.GetPointer(client.ObjectKeyFromObject(secret)), - SupportedKinds: []v1beta1.RouteGroupKind{{Kind: "HTTPRoute"}}, + SupportedKinds: []gatewayv1.RouteGroupKind{{Kind: "HTTPRoute"}}, }, }, Valid: true, }, - IgnoredGateways: map[types.NamespacedName]*v1beta1.Gateway{ + IgnoredGateways: map[types.NamespacedName]*gatewayv1.Gateway{ {Namespace: "test", Name: "gateway-2"}: gw2, }, Routes: map[types.NamespacedName]*Route{ @@ -305,19 +306,19 @@ func TestBuildGraph(t *testing.T) { } } - normalGC := &v1beta1.GatewayClass{ + normalGC := &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, - Spec: v1beta1.GatewayClassSpec{ + Spec: gatewayv1.GatewayClassSpec{ ControllerName: controllerName, }, } - differentControllerGC := &v1beta1.GatewayClass{ + differentControllerGC := &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: gcName, }, - Spec: v1beta1.GatewayClassSpec{ + Spec: gatewayv1.GatewayClassSpec{ ControllerName: "different-controller", }, } diff --git a/internal/mode/static/state/graph/httproute.go b/internal/mode/static/state/graph/httproute.go index c60e2bb15d..4baa67e589 100644 --- a/internal/mode/static/state/graph/httproute.go +++ b/internal/mode/static/state/graph/httproute.go @@ -10,7 +10,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" @@ -57,7 +57,7 @@ type ParentRefAttachmentStatus struct { // Route represents an HTTPRoute. type Route struct { // Source is the source resource of the Route. - Source *v1beta1.HTTPRoute + Source *v1.HTTPRoute // ParentRefs includes ParentRefs with NGF Gateways only. ParentRefs []ParentRef // Conditions include Conditions for the HTTPRoute. @@ -73,7 +73,7 @@ type Route struct { // buildRoutesForGateways builds routes from HTTPRoutes that reference any of the specified Gateways. func buildRoutesForGateways( validator validation.HTTPFieldsValidator, - httpRoutes map[types.NamespacedName]*v1beta1.HTTPRoute, + httpRoutes map[types.NamespacedName]*v1.HTTPRoute, gatewayNsNames []types.NamespacedName, ) map[types.NamespacedName]*Route { if len(gatewayNsNames) == 0 { @@ -93,7 +93,7 @@ func buildRoutesForGateways( } func buildSectionNameRefs( - parentRefs []v1beta1.ParentReference, + parentRefs []v1.ParentReference, routeNamespace string, gatewayNsNames []types.NamespacedName, ) []ParentRef { @@ -138,14 +138,14 @@ func buildSectionNameRefs( } func findGatewayForParentRef( - ref v1beta1.ParentReference, + ref v1.ParentReference, routeNamespace string, gatewayNsNames []types.NamespacedName, ) (gwNsName types.NamespacedName, found bool) { if ref.Kind != nil && *ref.Kind != "Gateway" { return types.NamespacedName{}, false } - if ref.Group != nil && *ref.Group != v1beta1.GroupName { + if ref.Group != nil && *ref.Group != v1.GroupName { return types.NamespacedName{}, false } @@ -166,7 +166,7 @@ func findGatewayForParentRef( func buildRoute( validator validation.HTTPFieldsValidator, - ghr *v1beta1.HTTPRoute, + ghr *v1.HTTPRoute, gatewayNsNames []types.NamespacedName, ) *Route { sectionNameRefs := buildSectionNameRefs(ghr.Spec.ParentRefs, ghr.Namespace, gatewayNsNames) @@ -317,7 +317,7 @@ func bindRouteToListeners(r *Route, gw *Gateway, namespaces map[types.Namespaced // If it fails to attach the route, it will return false and the failure condition. func tryToAttachRouteToListeners( refStatus *ParentRefAttachmentStatus, - sectionName *v1beta1.SectionName, + sectionName *v1.SectionName, route *Route, gw *Gateway, namespaces map[types.NamespacedName]*apiv1.Namespace, @@ -392,7 +392,7 @@ func findValidListeners(sectionName string, listeners map[string]*Listener) ([]* return validListeners, true } -func findAcceptedHostnames(listenerHostname *v1beta1.Hostname, routeHostnames []v1beta1.Hostname) []string { +func findAcceptedHostnames(listenerHostname *v1.Hostname, routeHostnames []v1.Hostname) []string { hostname := getHostname(listenerHostname) if len(routeHostnames) == 0 { @@ -483,11 +483,11 @@ func routeAllowedByListener( ) bool { if listener.Source.AllowedRoutes != nil { switch *listener.Source.AllowedRoutes.Namespaces.From { - case v1beta1.NamespacesFromAll: + case v1.NamespacesFromAll: return true - case v1beta1.NamespacesFromSame: + case v1.NamespacesFromSame: return routeNS == gwNS - case v1beta1.NamespacesFromSelector: + case v1.NamespacesFromSelector: if listener.AllowedRouteLabelSelector == nil { return false } @@ -502,21 +502,21 @@ func routeAllowedByListener( return true } -func getHostname(h *v1beta1.Hostname) string { +func getHostname(h *v1.Hostname) string { if h == nil { return "" } return string(*h) } -func getSectionName(s *v1beta1.SectionName) string { +func getSectionName(s *v1.SectionName) string { if s == nil { return "" } return string(*s) } -func validateHostnames(hostnames []v1beta1.Hostname, path *field.Path) error { +func validateHostnames(hostnames []v1.Hostname, path *field.Path) error { var allErrs field.ErrorList for i := range hostnames { @@ -531,7 +531,7 @@ func validateHostnames(hostnames []v1beta1.Hostname, path *field.Path) error { func validateMatch( validator validation.HTTPFieldsValidator, - match v1beta1.HTTPRouteMatch, + match v1.HTTPRouteMatch, matchPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList @@ -562,7 +562,7 @@ func validateMatch( func validateMethodMatch( validator validation.HTTPFieldsValidator, - method *v1beta1.HTTPMethod, + method *v1.HTTPMethod, methodPath *field.Path, ) *field.Error { if method == nil { @@ -578,15 +578,15 @@ func validateMethodMatch( func validateQueryParamMatch( validator validation.HTTPFieldsValidator, - q v1beta1.HTTPQueryParamMatch, + q v1.HTTPQueryParamMatch, queryParamPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList if q.Type == nil { allErrs = append(allErrs, field.Required(queryParamPath.Child("type"), "cannot be empty")) - } else if *q.Type != v1beta1.QueryParamMatchExact { - valErr := field.NotSupported(queryParamPath.Child("type"), *q.Type, []string{string(v1beta1.QueryParamMatchExact)}) + } else if *q.Type != v1.QueryParamMatchExact { + valErr := field.NotSupported(queryParamPath.Child("type"), *q.Type, []string{string(v1.QueryParamMatchExact)}) allErrs = append(allErrs, valErr) } @@ -605,18 +605,18 @@ func validateQueryParamMatch( func validateHeaderMatch( validator validation.HTTPFieldsValidator, - header v1beta1.HTTPHeaderMatch, + header v1.HTTPHeaderMatch, headerPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList if header.Type == nil { allErrs = append(allErrs, field.Required(headerPath.Child("type"), "cannot be empty")) - } else if *header.Type != v1beta1.HeaderMatchExact { + } else if *header.Type != v1.HeaderMatchExact { valErr := field.NotSupported( headerPath.Child("type"), *header.Type, - []string{string(v1beta1.HeaderMatchExact)}, + []string{string(v1.HeaderMatchExact)}, ) allErrs = append(allErrs, valErr) } @@ -636,7 +636,7 @@ func validateHeaderMatch( func validatePathMatch( validator validation.HTTPFieldsValidator, - path *v1beta1.HTTPPathMatch, + path *v1.HTTPPathMatch, fieldPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList @@ -652,9 +652,9 @@ func validatePathMatch( panicForBrokenWebhookAssumption(errors.New("path value cannot be nil")) } - if *path.Type != v1beta1.PathMatchPathPrefix && *path.Type != v1beta1.PathMatchExact { + if *path.Type != v1.PathMatchPathPrefix && *path.Type != v1.PathMatchExact { valErr := field.NotSupported(fieldPath.Child("type"), *path.Type, - []string{string(v1beta1.PathMatchExact), string(v1beta1.PathMatchPathPrefix)}) + []string{string(v1.PathMatchExact), string(v1.PathMatchPathPrefix)}) allErrs = append(allErrs, valErr) } @@ -668,23 +668,23 @@ func validatePathMatch( func validateFilter( validator validation.HTTPFieldsValidator, - filter v1beta1.HTTPRouteFilter, + filter v1.HTTPRouteFilter, filterPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList switch filter.Type { - case v1beta1.HTTPRouteFilterRequestRedirect: + case v1.HTTPRouteFilterRequestRedirect: return validateFilterRedirect(validator, filter, filterPath) - case v1beta1.HTTPRouteFilterRequestHeaderModifier: + case v1.HTTPRouteFilterRequestHeaderModifier: return validateFilterHeaderModifier(validator, filter, filterPath) default: valErr := field.NotSupported( filterPath.Child("type"), filter.Type, []string{ - string(v1beta1.HTTPRouteFilterRequestRedirect), - string(v1beta1.HTTPRouteFilterRequestHeaderModifier), + string(v1.HTTPRouteFilterRequestRedirect), + string(v1.HTTPRouteFilterRequestHeaderModifier), }, ) allErrs = append(allErrs, valErr) @@ -694,7 +694,7 @@ func validateFilter( func validateFilterRedirect( validator validation.HTTPFieldsValidator, - filter v1beta1.HTTPRouteFilter, + filter v1.HTTPRouteFilter, filterPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList @@ -745,7 +745,7 @@ func validateFilterRedirect( func validateFilterHeaderModifier( validator validation.HTTPFieldsValidator, - filter v1beta1.HTTPRouteFilter, + filter v1.HTTPRouteFilter, filterPath *field.Path, ) field.ErrorList { headerModifier := filter.RequestHeaderModifier @@ -761,7 +761,7 @@ func validateFilterHeaderModifier( func validateFilterHeaderModifierFields( validator validation.HTTPFieldsValidator, - headerModifier *v1beta1.HTTPHeaderFilter, + headerModifier *v1.HTTPHeaderFilter, headerModifierPath *field.Path, ) field.ErrorList { var allErrs field.ErrorList diff --git a/internal/mode/static/state/graph/httproute_test.go b/internal/mode/static/state/graph/httproute_test.go index 31cf5f76b7..fc4222f2e1 100644 --- a/internal/mode/static/state/graph/httproute_test.go +++ b/internal/mode/static/state/graph/httproute_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" @@ -26,17 +26,17 @@ const ( func createHTTPRoute( name string, refName string, - hostname v1beta1.Hostname, + hostname gatewayv1.Hostname, paths ...string, -) *v1beta1.HTTPRoute { - rules := make([]v1beta1.HTTPRouteRule, 0, len(paths)) +) *gatewayv1.HTTPRoute { + rules := make([]gatewayv1.HTTPRouteRule, 0, len(paths)) for _, path := range paths { - rules = append(rules, v1beta1.HTTPRouteRule{ - Matches: []v1beta1.HTTPRouteMatch{ + rules = append(rules, gatewayv1.HTTPRouteRule{ + Matches: []gatewayv1.HTTPRouteMatch{ { - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchPathPrefix), Value: helpers.GetPointer(path), }, }, @@ -44,28 +44,28 @@ func createHTTPRoute( }) } - return &v1beta1.HTTPRoute{ + return &gatewayv1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: name, }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: gatewayv1.HTTPRouteSpec{ + CommonRouteSpec: gatewayv1.CommonRouteSpec{ + ParentRefs: []gatewayv1.ParentReference{ { - Namespace: helpers.GetPointer[v1beta1.Namespace]("test"), - Name: v1beta1.ObjectName(refName), - SectionName: helpers.GetPointer[v1beta1.SectionName](sectionNameOfCreateHTTPRoute), + Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"), + Name: gatewayv1.ObjectName(refName), + SectionName: helpers.GetPointer[gatewayv1.SectionName](sectionNameOfCreateHTTPRoute), }, }, }, - Hostnames: []v1beta1.Hostname{hostname}, + Hostnames: []gatewayv1.Hostname{hostname}, Rules: rules, }, } } -func addFilterToPath(hr *v1beta1.HTTPRoute, path string, filter v1beta1.HTTPRouteFilter) { +func addFilterToPath(hr *gatewayv1.HTTPRoute, path string, filter gatewayv1.HTTPRouteFilter) { for i := range hr.Spec.Rules { for _, match := range hr.Spec.Rules[i].Matches { if match.Path == nil { @@ -84,7 +84,7 @@ func TestBuildRoutes(t *testing.T) { hr := createHTTPRoute("hr-1", gwNsName.Name, "example.com", "/") hrWrongGateway := createHTTPRoute("hr-2", "some-gateway", "example.com", "/") - hrRoutes := map[types.NamespacedName]*v1beta1.HTTPRoute{ + hrRoutes := map[types.NamespacedName]*gatewayv1.HTTPRoute{ client.ObjectKeyFromObject(hr): hr, client.ObjectKeyFromObject(hrWrongGateway): hrWrongGateway, } @@ -140,30 +140,30 @@ func TestBuildSectionNameRefs(t *testing.T) { gwNsName1 := types.NamespacedName{Namespace: routeNamespace, Name: "gateway-1"} gwNsName2 := types.NamespacedName{Namespace: routeNamespace, Name: "gateway-2"} - parentRefs := []v1beta1.ParentReference{ + parentRefs := []gatewayv1.ParentReference{ { - Name: v1beta1.ObjectName(gwNsName1.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("one"), + Name: gatewayv1.ObjectName(gwNsName1.Name), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("one"), }, { - Name: v1beta1.ObjectName("some-other-gateway"), - SectionName: helpers.GetPointer[v1beta1.SectionName]("two"), + Name: gatewayv1.ObjectName("some-other-gateway"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("two"), }, { - Name: v1beta1.ObjectName(gwNsName2.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("three"), + Name: gatewayv1.ObjectName(gwNsName2.Name), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("three"), }, { - Name: v1beta1.ObjectName(gwNsName1.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("same-name"), + Name: gatewayv1.ObjectName(gwNsName1.Name), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("same-name"), }, { - Name: v1beta1.ObjectName(gwNsName2.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("same-name"), + Name: gatewayv1.ObjectName(gwNsName2.Name), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("same-name"), }, { - Name: v1beta1.ObjectName("some-other-gateway"), - SectionName: helpers.GetPointer[v1beta1.SectionName]("same-name"), + Name: gatewayv1.ObjectName("some-other-gateway"), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("same-name"), }, } @@ -199,29 +199,29 @@ func TestBuildSectionNameRefsPanicsForDuplicateParentRefs(t *testing.T) { tests := []struct { name string - parentRefs []v1beta1.ParentReference + parentRefs []gatewayv1.ParentReference }{ { - parentRefs: []v1beta1.ParentReference{ + parentRefs: []gatewayv1.ParentReference{ { - Name: v1beta1.ObjectName(gwNsName.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + Name: gatewayv1.ObjectName(gwNsName.Name), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("http"), }, { - Name: v1beta1.ObjectName(gwNsName.Name), - SectionName: helpers.GetPointer[v1beta1.SectionName]("http"), + Name: gatewayv1.ObjectName(gwNsName.Name), + SectionName: helpers.GetPointer[gatewayv1.SectionName]("http"), }, }, name: "with sectionNames", }, { - parentRefs: []v1beta1.ParentReference{ + parentRefs: []gatewayv1.ParentReference{ { - Name: v1beta1.ObjectName(gwNsName.Name), + Name: gatewayv1.ObjectName(gwNsName.Name), SectionName: nil, }, { - Name: v1beta1.ObjectName(gwNsName.Name), + Name: gatewayv1.ObjectName(gwNsName.Name), SectionName: nil, }, }, @@ -245,60 +245,60 @@ func TestFindGatewayForParentRef(t *testing.T) { gwNsName2 := types.NamespacedName{Namespace: "test-2", Name: "gateway-2"} tests := []struct { - ref v1beta1.ParentReference + ref gatewayv1.ParentReference expectedGwNsName types.NamespacedName name string expectedFound bool }{ { - ref: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), - Name: v1beta1.ObjectName(gwNsName1.Name), + ref: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer(gatewayv1.Namespace(gwNsName1.Namespace)), + Name: gatewayv1.ObjectName(gwNsName1.Name), }, expectedFound: true, expectedGwNsName: gwNsName1, name: "found", }, { - ref: v1beta1.ParentReference{ - Group: helpers.GetPointer[v1beta1.Group](v1beta1.GroupName), - Kind: helpers.GetPointer[v1beta1.Kind]("Gateway"), - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), - Name: v1beta1.ObjectName(gwNsName1.Name), + ref: gatewayv1.ParentReference{ + Group: helpers.GetPointer[gatewayv1.Group](gatewayv1.GroupName), + Kind: helpers.GetPointer[gatewayv1.Kind]("Gateway"), + Namespace: helpers.GetPointer(gatewayv1.Namespace(gwNsName1.Namespace)), + Name: gatewayv1.ObjectName(gwNsName1.Name), }, expectedFound: true, expectedGwNsName: gwNsName1, name: "found with explicit group and kind", }, { - ref: v1beta1.ParentReference{ - Name: v1beta1.ObjectName(gwNsName2.Name), + ref: gatewayv1.ParentReference{ + Name: gatewayv1.ObjectName(gwNsName2.Name), }, expectedFound: true, expectedGwNsName: gwNsName2, name: "found with implicit namespace", }, { - ref: v1beta1.ParentReference{ - Kind: helpers.GetPointer[v1beta1.Kind]("NotGateway"), - Name: v1beta1.ObjectName(gwNsName2.Name), + ref: gatewayv1.ParentReference{ + Kind: helpers.GetPointer[gatewayv1.Kind]("NotGateway"), + Name: gatewayv1.ObjectName(gwNsName2.Name), }, expectedFound: false, expectedGwNsName: types.NamespacedName{}, name: "wrong kind", }, { - ref: v1beta1.ParentReference{ - Group: helpers.GetPointer[v1beta1.Group]("wrong-group"), - Name: v1beta1.ObjectName(gwNsName2.Name), + ref: gatewayv1.ParentReference{ + Group: helpers.GetPointer[gatewayv1.Group]("wrong-group"), + Name: gatewayv1.ObjectName(gwNsName2.Name), }, expectedFound: false, expectedGwNsName: types.NamespacedName{}, name: "wrong group", }, { - ref: v1beta1.ParentReference{ - Namespace: helpers.GetPointer(v1beta1.Namespace(gwNsName1.Namespace)), + ref: gatewayv1.ParentReference{ + Namespace: helpers.GetPointer(gatewayv1.Namespace(gwNsName1.Namespace)), Name: "some-gateway", }, expectedFound: false, @@ -333,14 +333,14 @@ func TestBuildRoute(t *testing.T) { gatewayNsName := types.NamespacedName{Namespace: "test", Name: "gateway"} - validFilter := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{}, + validFilter := gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{}, } - invalidFilter := v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Hostname: helpers.GetPointer[v1beta1.PreciseHostname](invalidRedirectHostname), + invalidFilter := gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ + Hostname: helpers.GetPointer[gatewayv1.PreciseHostname](invalidRedirectHostname), }, } @@ -384,7 +384,7 @@ func TestBuildRoute(t *testing.T) { tests := []struct { validator *validationfakes.FakeHTTPFieldsValidator - hr *v1beta1.HTTPRoute + hr *gatewayv1.HTTPRoute expected *Route name string }{ @@ -608,9 +608,9 @@ func TestBindRouteToListeners(t *testing.T) { // we create a new listener each time because the function under test can modify it createListener := func(name string) *Listener { return &Listener{ - Source: v1beta1.Listener{ - Name: v1beta1.SectionName(name), - Hostname: (*v1beta1.Hostname)(helpers.GetPointer("foo.example.com")), + Source: gatewayv1.Listener{ + Name: gatewayv1.SectionName(name), + Hostname: (*gatewayv1.Hostname)(helpers.GetPointer("foo.example.com")), }, Valid: true, Routes: map[types.NamespacedName]*Route{}, @@ -622,13 +622,13 @@ func TestBindRouteToListeners(t *testing.T) { return l } - gw := &v1beta1.Gateway{ + gw := &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "gateway", }, } - gwDiffNamespace := &v1beta1.Gateway{ + gwDiffNamespace := &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "diff-namespace", Name: "gateway", @@ -636,45 +636,45 @@ func TestBindRouteToListeners(t *testing.T) { } createHTTPRouteWithSectionNameAndPort := func( - sectionName *v1beta1.SectionName, - port *v1beta1.PortNumber, - ) *v1beta1.HTTPRoute { - return &v1beta1.HTTPRoute{ + sectionName *gatewayv1.SectionName, + port *gatewayv1.PortNumber, + ) *gatewayv1.HTTPRoute { + return &gatewayv1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", Name: "hr", }, - Spec: v1beta1.HTTPRouteSpec{ - CommonRouteSpec: v1beta1.CommonRouteSpec{ - ParentRefs: []v1beta1.ParentReference{ + Spec: gatewayv1.HTTPRouteSpec{ + CommonRouteSpec: gatewayv1.CommonRouteSpec{ + ParentRefs: []gatewayv1.ParentReference{ { - Name: v1beta1.ObjectName(gw.Name), + Name: gatewayv1.ObjectName(gw.Name), SectionName: sectionName, Port: port, }, }, }, - Hostnames: []v1beta1.Hostname{ + Hostnames: []gatewayv1.Hostname{ "foo.example.com", }, }, } } - hr := createHTTPRouteWithSectionNameAndPort(helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), nil) + hr := createHTTPRouteWithSectionNameAndPort(helpers.GetPointer[gatewayv1.SectionName]("listener-80-1"), nil) hrWithNilSectionName := createHTTPRouteWithSectionNameAndPort(nil, nil) - hrWithEmptySectionName := createHTTPRouteWithSectionNameAndPort(helpers.GetPointer[v1beta1.SectionName](""), nil) + hrWithEmptySectionName := createHTTPRouteWithSectionNameAndPort(helpers.GetPointer[gatewayv1.SectionName](""), nil) hrWithPort := createHTTPRouteWithSectionNameAndPort( - helpers.GetPointer[v1beta1.SectionName]("listener-80-1"), - helpers.GetPointer[v1beta1.PortNumber](80), + helpers.GetPointer[gatewayv1.SectionName]("listener-80-1"), + helpers.GetPointer[gatewayv1.PortNumber](80), ) hrWithNonExistingListener := createHTTPRouteWithSectionNameAndPort( - helpers.GetPointer[v1beta1.SectionName]("listener-80-2"), + helpers.GetPointer[gatewayv1.SectionName]("listener-80-2"), nil, ) var normalRoute *Route - createNormalRoute := func(gateway *v1beta1.Gateway) *Route { + createNormalRoute := func(gateway *gatewayv1.Gateway) *Route { normalRoute = &Route{ Source: hr, Valid: true, @@ -756,7 +756,7 @@ func TestBindRouteToListeners(t *testing.T) { l.Valid = false }) nonMatchingHostnameListener := createModifiedListener("", func(l *Listener) { - l.Source.Hostname = helpers.GetPointer[v1beta1.Hostname]("bar.example.com") + l.Source.Hostname = helpers.GetPointer[gatewayv1.Hostname]("bar.example.com") }) tests := []struct { @@ -1068,9 +1068,9 @@ func TestBindRouteToListeners(t *testing.T) { Valid: true, Listeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSelector), }, } allowedLabels := map[string]string{"app": "not-allowed"} @@ -1091,9 +1091,9 @@ func TestBindRouteToListeners(t *testing.T) { }, expectedGatewayListeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSelector), }, } allowedLabels := map[string]string{"app": "not-allowed"} @@ -1109,9 +1109,9 @@ func TestBindRouteToListeners(t *testing.T) { Valid: true, Listeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSelector), }, } allowedLabels := map[string]string{"app": "allowed"} @@ -1135,9 +1135,9 @@ func TestBindRouteToListeners(t *testing.T) { "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { allowedLabels := map[string]string{"app": "allowed"} l.AllowedRouteLabelSelector = labels.SelectorFromSet(allowedLabels) - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSelector), }, } l.Routes = map[types.NamespacedName]*Route{ @@ -1154,9 +1154,9 @@ func TestBindRouteToListeners(t *testing.T) { Valid: true, Listeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSame), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSame), }, } }), @@ -1175,9 +1175,9 @@ func TestBindRouteToListeners(t *testing.T) { }, expectedGatewayListeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSame), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSame), }, } }), @@ -1191,9 +1191,9 @@ func TestBindRouteToListeners(t *testing.T) { Valid: true, Listeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSame), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSame), }, } }), @@ -1213,9 +1213,9 @@ func TestBindRouteToListeners(t *testing.T) { }, expectedGatewayListeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSame), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSame), }, } l.Routes = map[types.NamespacedName]*Route{ @@ -1232,9 +1232,9 @@ func TestBindRouteToListeners(t *testing.T) { Valid: true, Listeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromAll), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromAll), }, } }), @@ -1254,9 +1254,9 @@ func TestBindRouteToListeners(t *testing.T) { }, expectedGatewayListeners: map[string]*Listener{ "listener-80-1": createModifiedListener("listener-80-1", func(l *Listener) { - l.Source.AllowedRoutes = &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromAll), + l.Source.AllowedRoutes = &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromAll), }, } l.Routes = map[types.NamespacedName]*Route{ @@ -1289,15 +1289,15 @@ func TestBindRouteToListeners(t *testing.T) { } func TestFindAcceptedHostnames(t *testing.T) { - var listenerHostnameFoo v1beta1.Hostname = "foo.example.com" - var listenerHostnameCafe v1beta1.Hostname = "cafe.example.com" - var listenerHostnameWildcard v1beta1.Hostname = "*.example.com" - routeHostnames := []v1beta1.Hostname{"foo.example.com", "bar.example.com"} + var listenerHostnameFoo gatewayv1.Hostname = "foo.example.com" + var listenerHostnameCafe gatewayv1.Hostname = "cafe.example.com" + var listenerHostnameWildcard gatewayv1.Hostname = "*.example.com" + routeHostnames := []gatewayv1.Hostname{"foo.example.com", "bar.example.com"} tests := []struct { - listenerHostname *v1beta1.Hostname + listenerHostname *gatewayv1.Hostname msg string - routeHostnames []v1beta1.Hostname + routeHostnames []gatewayv1.Hostname expected []string }{ { @@ -1338,7 +1338,7 @@ func TestFindAcceptedHostnames(t *testing.T) { }, { listenerHostname: &listenerHostnameFoo, - routeHostnames: []v1beta1.Hostname{"*.example.com"}, + routeHostnames: []gatewayv1.Hostname{"*.example.com"}, expected: []string{"foo.example.com"}, msg: "route wildcard hostname; specific listener hostname", }, @@ -1350,13 +1350,13 @@ func TestFindAcceptedHostnames(t *testing.T) { }, { listenerHostname: nil, - routeHostnames: []v1beta1.Hostname{"*.example.com"}, + routeHostnames: []gatewayv1.Hostname{"*.example.com"}, expected: []string{"*.example.com"}, msg: "route wildcard hostname; nil listener hostname", }, { listenerHostname: &listenerHostnameWildcard, - routeHostnames: []v1beta1.Hostname{"*.bar.example.com"}, + routeHostnames: []gatewayv1.Hostname{"*.bar.example.com"}, expected: []string{"*.bar.example.com"}, msg: "route and listener wildcard hostnames", }, @@ -1372,11 +1372,11 @@ func TestFindAcceptedHostnames(t *testing.T) { } func TestGetHostname(t *testing.T) { - var emptyHostname v1beta1.Hostname - var hostname v1beta1.Hostname = "example.com" + var emptyHostname gatewayv1.Hostname + var hostname gatewayv1.Hostname = "example.com" tests := []struct { - h *v1beta1.Hostname + h *gatewayv1.Hostname expected string msg string }{ @@ -1411,11 +1411,11 @@ func TestValidateHostnames(t *testing.T) { tests := []struct { name string - hostnames []v1beta1.Hostname + hostnames []gatewayv1.Hostname expectErr bool }{ { - hostnames: []v1beta1.Hostname{ + hostnames: []gatewayv1.Hostname{ validHostname, "example.org", "foo.example.net", @@ -1424,7 +1424,7 @@ func TestValidateHostnames(t *testing.T) { name: "multiple valid", }, { - hostnames: []v1beta1.Hostname{ + hostnames: []gatewayv1.Hostname{ validHostname, "", }, @@ -1458,42 +1458,42 @@ func TestValidateMatch(t *testing.T) { } tests := []struct { - match v1beta1.HTTPRouteMatch + match gatewayv1.HTTPRouteMatch validator *validationfakes.FakeHTTPFieldsValidator name string expectErrCount int }{ { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + match: gatewayv1.HTTPRouteMatch{ + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), }, - Headers: []v1beta1.HTTPHeaderMatch{ + Headers: []gatewayv1.HTTPHeaderMatch{ { - Type: helpers.GetPointer(v1beta1.HeaderMatchExact), + Type: helpers.GetPointer(gatewayv1.HeaderMatchExact), Name: "header", Value: "x", }, }, - QueryParams: []v1beta1.HTTPQueryParamMatch{ + QueryParams: []gatewayv1.HTTPQueryParamMatch{ { - Type: helpers.GetPointer(v1beta1.QueryParamMatchExact), + Type: helpers.GetPointer(gatewayv1.QueryParamMatchExact), Name: "param", Value: "y", }, }, - Method: helpers.GetPointer(v1beta1.HTTPMethodGet), + Method: helpers.GetPointer(gatewayv1.HTTPMethodGet), }, expectErrCount: 0, name: "valid", }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchExact), + match: gatewayv1.HTTPRouteMatch{ + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchExact), Value: helpers.GetPointer("/"), }, }, @@ -1502,9 +1502,9 @@ func TestValidateMatch(t *testing.T) { }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchRegularExpression), + match: gatewayv1.HTTPRouteMatch{ + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchRegularExpression), Value: helpers.GetPointer("/"), }, }, @@ -1517,9 +1517,9 @@ func TestValidateMatch(t *testing.T) { validator.ValidatePathInMatchReturns(errors.New("invalid path value")) return validator }(), - match: v1beta1.HTTPRouteMatch{ - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchPathPrefix), + match: gatewayv1.HTTPRouteMatch{ + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), }, }, @@ -1528,8 +1528,8 @@ func TestValidateMatch(t *testing.T) { }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - Headers: []v1beta1.HTTPHeaderMatch{ + match: gatewayv1.HTTPRouteMatch{ + Headers: []gatewayv1.HTTPHeaderMatch{ { Type: nil, Name: "header", @@ -1542,10 +1542,10 @@ func TestValidateMatch(t *testing.T) { }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - Headers: []v1beta1.HTTPHeaderMatch{ + match: gatewayv1.HTTPRouteMatch{ + Headers: []gatewayv1.HTTPHeaderMatch{ { - Type: helpers.GetPointer(v1beta1.HeaderMatchRegularExpression), + Type: helpers.GetPointer(gatewayv1.HeaderMatchRegularExpression), Name: "header", Value: "x", }, @@ -1560,10 +1560,10 @@ func TestValidateMatch(t *testing.T) { validator.ValidateHeaderNameInMatchReturns(errors.New("invalid header name")) return validator }(), - match: v1beta1.HTTPRouteMatch{ - Headers: []v1beta1.HTTPHeaderMatch{ + match: gatewayv1.HTTPRouteMatch{ + Headers: []gatewayv1.HTTPHeaderMatch{ { - Type: helpers.GetPointer(v1beta1.HeaderMatchExact), + Type: helpers.GetPointer(gatewayv1.HeaderMatchExact), Name: "header", // any value is invalid by the validator Value: "x", }, @@ -1578,10 +1578,10 @@ func TestValidateMatch(t *testing.T) { validator.ValidateHeaderValueInMatchReturns(errors.New("invalid header value")) return validator }(), - match: v1beta1.HTTPRouteMatch{ - Headers: []v1beta1.HTTPHeaderMatch{ + match: gatewayv1.HTTPRouteMatch{ + Headers: []gatewayv1.HTTPHeaderMatch{ { - Type: helpers.GetPointer(v1beta1.HeaderMatchExact), + Type: helpers.GetPointer(gatewayv1.HeaderMatchExact), Name: "header", Value: "x", // any value is invalid by the validator }, @@ -1592,8 +1592,8 @@ func TestValidateMatch(t *testing.T) { }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - QueryParams: []v1beta1.HTTPQueryParamMatch{ + match: gatewayv1.HTTPRouteMatch{ + QueryParams: []gatewayv1.HTTPQueryParamMatch{ { Type: nil, Name: "param", @@ -1606,10 +1606,10 @@ func TestValidateMatch(t *testing.T) { }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - QueryParams: []v1beta1.HTTPQueryParamMatch{ + match: gatewayv1.HTTPRouteMatch{ + QueryParams: []gatewayv1.HTTPQueryParamMatch{ { - Type: helpers.GetPointer(v1beta1.QueryParamMatchRegularExpression), + Type: helpers.GetPointer(gatewayv1.QueryParamMatchRegularExpression), Name: "param", Value: "y", }, @@ -1624,10 +1624,10 @@ func TestValidateMatch(t *testing.T) { validator.ValidateQueryParamNameInMatchReturns(errors.New("invalid query param name")) return validator }(), - match: v1beta1.HTTPRouteMatch{ - QueryParams: []v1beta1.HTTPQueryParamMatch{ + match: gatewayv1.HTTPRouteMatch{ + QueryParams: []gatewayv1.HTTPQueryParamMatch{ { - Type: helpers.GetPointer(v1beta1.QueryParamMatchExact), + Type: helpers.GetPointer(gatewayv1.QueryParamMatchExact), Name: "param", // any value is invalid by the validator Value: "y", }, @@ -1642,10 +1642,10 @@ func TestValidateMatch(t *testing.T) { validator.ValidateQueryParamValueInMatchReturns(errors.New("invalid query param value")) return validator }(), - match: v1beta1.HTTPRouteMatch{ - QueryParams: []v1beta1.HTTPQueryParamMatch{ + match: gatewayv1.HTTPRouteMatch{ + QueryParams: []gatewayv1.HTTPQueryParamMatch{ { - Type: helpers.GetPointer(v1beta1.QueryParamMatchExact), + Type: helpers.GetPointer(gatewayv1.QueryParamMatchExact), Name: "param", Value: "y", // any value is invalid by the validator }, @@ -1660,29 +1660,29 @@ func TestValidateMatch(t *testing.T) { validator.ValidateMethodInMatchReturns(false, []string{"VALID_METHOD"}) return validator }(), - match: v1beta1.HTTPRouteMatch{ - Method: helpers.GetPointer(v1beta1.HTTPMethodGet), // any value is invalid by the validator + match: gatewayv1.HTTPRouteMatch{ + Method: helpers.GetPointer(gatewayv1.HTTPMethodGet), // any value is invalid by the validator }, expectErrCount: 1, name: "method is invalid", }, { validator: createAllValidValidator(), - match: v1beta1.HTTPRouteMatch{ - Path: &v1beta1.HTTPPathMatch{ - Type: helpers.GetPointer(v1beta1.PathMatchRegularExpression), // invalid + match: gatewayv1.HTTPRouteMatch{ + Path: &gatewayv1.HTTPPathMatch{ + Type: helpers.GetPointer(gatewayv1.PathMatchRegularExpression), // invalid Value: helpers.GetPointer("/"), }, - Headers: []v1beta1.HTTPHeaderMatch{ + Headers: []gatewayv1.HTTPHeaderMatch{ { - Type: helpers.GetPointer(v1beta1.HeaderMatchRegularExpression), // invalid + Type: helpers.GetPointer(gatewayv1.HeaderMatchRegularExpression), // invalid Name: "header", Value: "x", }, }, - QueryParams: []v1beta1.HTTPQueryParamMatch{ + QueryParams: []gatewayv1.HTTPQueryParamMatch{ { - Type: helpers.GetPointer(v1beta1.QueryParamMatchRegularExpression), // invalid + Type: helpers.GetPointer(gatewayv1.QueryParamMatchRegularExpression), // invalid Name: "param", Value: "y", }, @@ -1704,29 +1704,29 @@ func TestValidateMatch(t *testing.T) { func TestValidateFilter(t *testing.T) { tests := []struct { - filter v1beta1.HTTPRouteFilter + filter gatewayv1.HTTPRouteFilter name string expectErrCount int }{ { - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{}, + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{}, }, expectErrCount: 0, name: "valid redirect filter", }, { - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{}, + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gatewayv1.HTTPHeaderFilter{}, }, expectErrCount: 0, name: "valid request header modifiers filter", }, { - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterURLRewrite, + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterURLRewrite, }, expectErrCount: 1, name: "unsupported filter", @@ -1755,19 +1755,19 @@ func TestValidateFilterRedirect(t *testing.T) { } tests := []struct { - filter v1beta1.HTTPRouteFilter + filter gatewayv1.HTTPRouteFilter validator *validationfakes.FakeHTTPFieldsValidator name string expectErrCount int }{ { validator: createAllValidValidator(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ Scheme: helpers.GetPointer("http"), - Hostname: helpers.GetPointer[v1beta1.PreciseHostname]("example.com"), - Port: helpers.GetPointer[v1beta1.PortNumber](80), + Hostname: helpers.GetPointer[gatewayv1.PreciseHostname]("example.com"), + Port: helpers.GetPointer[gatewayv1.PortNumber](80), StatusCode: helpers.GetPointer(301), }, }, @@ -1776,9 +1776,9 @@ func TestValidateFilterRedirect(t *testing.T) { }, { validator: createAllValidValidator(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{}, + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{}, }, expectErrCount: 0, name: "valid redirect filter with no fields set", @@ -1789,9 +1789,9 @@ func TestValidateFilterRedirect(t *testing.T) { validator.ValidateRedirectSchemeReturns(false, []string{"valid-scheme"}) return validator }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ Scheme: helpers.GetPointer("http"), // any value is invalid by the validator }, }, @@ -1804,10 +1804,10 @@ func TestValidateFilterRedirect(t *testing.T) { validator.ValidateRedirectHostnameReturns(errors.New("invalid hostname")) return validator }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Hostname: helpers.GetPointer[v1beta1.PreciseHostname]( + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ + Hostname: helpers.GetPointer[gatewayv1.PreciseHostname]( "example.com", ), // any value is invalid by the validator }, @@ -1821,10 +1821,10 @@ func TestValidateFilterRedirect(t *testing.T) { validator.ValidateRedirectPortReturns(errors.New("invalid port")) return validator }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Port: helpers.GetPointer[v1beta1.PortNumber](80), // any value is invalid by the validator + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ + Port: helpers.GetPointer[gatewayv1.PortNumber](80), // any value is invalid by the validator }, }, expectErrCount: 1, @@ -1832,10 +1832,10 @@ func TestValidateFilterRedirect(t *testing.T) { }, { validator: createAllValidValidator(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Path: &v1beta1.HTTPPathModifier{}, + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ + Path: &gatewayv1.HTTPPathModifier{}, }, }, expectErrCount: 1, @@ -1847,9 +1847,9 @@ func TestValidateFilterRedirect(t *testing.T) { validator.ValidateRedirectStatusCodeReturns(false, []string{"200"}) return validator }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ StatusCode: helpers.GetPointer(301), // any value is invalid by the validator }, }, @@ -1863,13 +1863,13 @@ func TestValidateFilterRedirect(t *testing.T) { validator.ValidateRedirectPortReturns(errors.New("invalid port")) return validator }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestRedirect, - RequestRedirect: &v1beta1.HTTPRequestRedirectFilter{ - Hostname: helpers.GetPointer[v1beta1.PreciseHostname]( + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gatewayv1.HTTPRequestRedirectFilter{ + Hostname: helpers.GetPointer[gatewayv1.PreciseHostname]( "example.com", ), // any value is invalid by the validator - Port: helpers.GetPointer[v1beta1.PortNumber]( + Port: helpers.GetPointer[gatewayv1.PortNumber]( 80, ), // any value is invalid by the validator }, @@ -1897,20 +1897,20 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { } tests := []struct { - filter v1beta1.HTTPRouteFilter + filter gatewayv1.HTTPRouteFilter validator *validationfakes.FakeHTTPFieldsValidator name string expectErrCount int }{ { validator: createAllValidValidator(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ - Set: []v1beta1.HTTPHeader{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gatewayv1.HTTPHeaderFilter{ + Set: []gatewayv1.HTTPHeader{ {Name: "MyBespokeHeader", Value: "my-value"}, }, - Add: []v1beta1.HTTPHeader{ + Add: []gatewayv1.HTTPHeader{ {Name: "Accept-Encoding", Value: "gzip"}, }, Remove: []string{"Cache-Control"}, @@ -1925,10 +1925,10 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { v.ValidateRequestHeaderNameReturns(errors.New("Invalid header")) return v }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ - Add: []v1beta1.HTTPHeader{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gatewayv1.HTTPHeaderFilter{ + Add: []gatewayv1.HTTPHeader{ {Name: "$var_name", Value: "gzip"}, }, }, @@ -1942,9 +1942,9 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { v.ValidateRequestHeaderNameReturns(errors.New("Invalid header")) return v }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gatewayv1.HTTPHeaderFilter{ Remove: []string{"$var-name"}, }, }, @@ -1957,10 +1957,10 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { v.ValidateRequestHeaderValueReturns(errors.New("Invalid header value")) return v }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ - Add: []v1beta1.HTTPHeader{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gatewayv1.HTTPHeaderFilter{ + Add: []gatewayv1.HTTPHeader{ {Name: "Accept-Encoding", Value: "yhu$"}, }, }, @@ -1975,13 +1975,13 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { v.ValidateRequestHeaderNameReturns(errors.New("Invalid header")) return v }(), - filter: v1beta1.HTTPRouteFilter{ - Type: v1beta1.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &v1beta1.HTTPHeaderFilter{ - Set: []v1beta1.HTTPHeader{ + filter: gatewayv1.HTTPRouteFilter{ + Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gatewayv1.HTTPHeaderFilter{ + Set: []gatewayv1.HTTPHeader{ {Name: "Host", Value: "my_host"}, }, - Add: []v1beta1.HTTPHeader{ + Add: []gatewayv1.HTTPHeader{ {Name: "}90yh&$", Value: "gzip$"}, {Name: "}67yh&$", Value: "compress$"}, }, diff --git a/internal/mode/static/state/graph/reference_grant.go b/internal/mode/static/state/graph/reference_grant.go index 7afb7e67b2..c0db702732 100644 --- a/internal/mode/static/state/graph/reference_grant.go +++ b/internal/mode/static/state/graph/reference_grant.go @@ -2,7 +2,8 @@ package graph import ( "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" + v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) // referenceGrantResolver resolves references from one resource to another. @@ -17,7 +18,7 @@ type allowedReference struct { } // toResource represents the resource that the ReferenceGrant is granting access to. -// Maps to the v1beta1.ReferenceGrantTo. +// Maps to the v1.ReferenceGrantTo. type toResource struct { // if group is core, this should be set to "". group string @@ -27,7 +28,7 @@ type toResource struct { } // fromResource represents the resource that the ReferenceGrant is granting access from. -// Maps to the v1beta1.ReferenceGrantFrom. +// Maps to the v1.ReferenceGrantFrom. type fromResource struct { group string kind string @@ -56,7 +57,7 @@ func toService(nsname types.NamespacedName) toResource { func fromGateway(namespace string) fromResource { return fromResource{ - group: v1beta1.GroupName, + group: v1.GroupName, kind: "Gateway", namespace: namespace, } @@ -64,7 +65,7 @@ func fromGateway(namespace string) fromResource { func fromHTTPRoute(namespace string) fromResource { return fromResource{ - group: v1beta1.GroupName, + group: v1.GroupName, kind: "HTTPRoute", namespace: namespace, } diff --git a/internal/mode/static/state/relationship/capturer.go b/internal/mode/static/state/relationship/capturer.go index bd76ccd5e3..48d08250d0 100644 --- a/internal/mode/static/state/relationship/capturer.go +++ b/internal/mode/static/state/relationship/capturer.go @@ -7,7 +7,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/index" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph" @@ -75,7 +75,7 @@ func NewCapturerImpl() *CapturerImpl { // Capture captures relationships for the given object. func (c *CapturerImpl) Capture(obj client.Object) { switch o := obj.(type) { - case *v1beta1.HTTPRoute: + case *gatewayv1.HTTPRoute: c.upsertForRoute(o) case *discoveryV1.EndpointSlice: svcName := index.GetServiceNameFromEndpointSlice(o) @@ -85,7 +85,7 @@ func (c *CapturerImpl) Capture(obj client.Object) { Name: svcName, } } - case *v1beta1.Gateway: + case *gatewayv1.Gateway: var selectors []labels.Selector for _, listener := range o.Spec.Listeners { if selector := graph.GetAllowedRouteLabelSelector(listener); selector != nil { @@ -132,11 +132,11 @@ func (c *CapturerImpl) Capture(obj client.Object) { // Remove removes the relationship for the given object from the CapturerImpl. func (c *CapturerImpl) Remove(resourceType client.Object, nsname types.NamespacedName) { switch resourceType.(type) { - case *v1beta1.HTTPRoute: + case *gatewayv1.HTTPRoute: c.deleteForRoute(nsname) case *discoveryV1.EndpointSlice: delete(c.endpointSliceOwners, nsname) - case *v1beta1.Gateway: + case *gatewayv1.Gateway: c.removeGatewayLabelSelector(nsname) case *v1.Namespace: delete(c.namespaces, nsname) @@ -164,7 +164,7 @@ func (c *CapturerImpl) GetRefCountForService(svcName types.NamespacedName) int { return c.serviceRefCount[svcName] } -func (c *CapturerImpl) upsertForRoute(route *v1beta1.HTTPRoute) { +func (c *CapturerImpl) upsertForRoute(route *gatewayv1.HTTPRoute) { oldServices := c.routesToServices[client.ObjectKeyFromObject(route)] newServices := getBackendServiceNamesFromRoute(route) @@ -205,7 +205,7 @@ func (c *CapturerImpl) decrementRefCount(svcName types.NamespacedName) { } } -func getBackendServiceNamesFromRoute(hr *v1beta1.HTTPRoute) map[types.NamespacedName]struct{} { +func getBackendServiceNamesFromRoute(hr *gatewayv1.HTTPRoute) map[types.NamespacedName]struct{} { svcNames := make(map[types.NamespacedName]struct{}) for _, rule := range hr.Spec.Rules { diff --git a/internal/mode/static/state/relationship/capturer_test.go b/internal/mode/static/state/relationship/capturer_test.go index 8f9321ef4b..ca66e730e0 100644 --- a/internal/mode/static/state/relationship/capturer_test.go +++ b/internal/mode/static/state/relationship/capturer_test.go @@ -8,22 +8,22 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/gateway-api/apis/v1beta1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/index" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/relationship" ) -func createBackendRefs(backendNames ...v1beta1.ObjectName) []v1beta1.HTTPBackendRef { - refs := make([]v1beta1.HTTPBackendRef, 0, len(backendNames)) +func createBackendRefs(backendNames ...gatewayv1.ObjectName) []gatewayv1.HTTPBackendRef { + refs := make([]gatewayv1.HTTPBackendRef, 0, len(backendNames)) for _, name := range backendNames { - refs = append(refs, v1beta1.HTTPBackendRef{ - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ - Kind: (*v1beta1.Kind)(helpers.GetPointer("Service")), + refs = append(refs, gatewayv1.HTTPBackendRef{ + BackendRef: gatewayv1.BackendRef{ + BackendObjectReference: gatewayv1.BackendObjectReference{ + Kind: (*gatewayv1.Kind)(helpers.GetPointer("Service")), Name: name, - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), + Namespace: (*gatewayv1.Namespace)(helpers.GetPointer("test")), }, }, }) @@ -32,19 +32,19 @@ func createBackendRefs(backendNames ...v1beta1.ObjectName) []v1beta1.HTTPBackend return refs } -func createRules(backendRefs ...[]v1beta1.HTTPBackendRef) []v1beta1.HTTPRouteRule { - rules := make([]v1beta1.HTTPRouteRule, 0, len(backendRefs)) +func createRules(backendRefs ...[]gatewayv1.HTTPBackendRef) []gatewayv1.HTTPRouteRule { + rules := make([]gatewayv1.HTTPRouteRule, 0, len(backendRefs)) for _, refs := range backendRefs { - rules = append(rules, v1beta1.HTTPRouteRule{BackendRefs: refs}) + rules = append(rules, gatewayv1.HTTPRouteRule{BackendRefs: refs}) } return rules } -func createRoute(name string, rules []v1beta1.HTTPRouteRule) *v1beta1.HTTPRoute { - return &v1beta1.HTTPRoute{ +func createRoute(name string, rules []gatewayv1.HTTPRouteRule) *gatewayv1.HTTPRoute { + return &gatewayv1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{Namespace: "test", Name: name}, - Spec: v1beta1.HTTPRouteSpec{Rules: rules}, + Spec: gatewayv1.HTTPRouteSpec{Rules: rules}, } } @@ -129,7 +129,7 @@ var _ = Describe("Capturer", func() { }) When("a route with multiple backend services is removed", func() { It("removes all service relationships", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hr2Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hr2Name) assertServiceExists(svc2, false, 0) assertServiceExists(svc3, false, 0) @@ -141,7 +141,7 @@ var _ = Describe("Capturer", func() { }) When("a route is removed", func() { It("removes service relationships", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hr1Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hr1Name) assertServiceExists(svc1, false, 0) }) @@ -163,7 +163,7 @@ var _ = Describe("Capturer", func() { }) When("one route is removed", func() { It("reports remaining service relationships", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hr1Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hr1Name) // ref count for svc1 should decrease by one assertServiceExists(svc1, true, 3) @@ -176,7 +176,7 @@ var _ = Describe("Capturer", func() { }) When("another route is removed", func() { It("reports remaining service relationships", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hrSvc1AndSvc2Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hrSvc1AndSvc2Name) // svc2 should no longer exist assertServiceExists(svc2, false, 0) @@ -191,7 +191,7 @@ var _ = Describe("Capturer", func() { }) When("another route is removed", func() { It("reports remaining service relationships", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hrSvc1AndSvc3Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hrSvc1AndSvc3Name) // svc3 should no longer exist assertServiceExists(svc3, false, 0) @@ -207,7 +207,7 @@ var _ = Describe("Capturer", func() { }) When("final route is removed", func() { It("removes all service relationships", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hrSvc1AndSvc4Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hrSvc1AndSvc4Name) // no services should exist and all ref counts should be 0 assertServiceExists(svc1, false, 0) @@ -218,7 +218,7 @@ var _ = Describe("Capturer", func() { }) When("route is removed again", func() { It("service ref counts remain at 0", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hrSvc1AndSvc4Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hrSvc1AndSvc4Name) // no services should exist and all ref counts should still be 0 assertServiceExists(svc1, false, 0) @@ -307,7 +307,7 @@ var _ = Describe("Capturer", func() { }) When("service relationship is removed", func() { It("removes the endpoint slice relationship", func() { - capturer.Remove(&v1beta1.HTTPRoute{}, hr1Name) + capturer.Remove(&gatewayv1.HTTPRoute{}, hr1Name) Expect(capturer.Exists(&discoveryV1.EndpointSlice{}, slice1Name)).To(BeFalse()) }) @@ -316,21 +316,21 @@ var _ = Describe("Capturer", func() { }) }) Describe("Capture namespace and gateway relationships", func() { - var gw *v1beta1.Gateway + var gw *gatewayv1.Gateway var nsNoLabels, ns *v1.Namespace BeforeEach(func() { capturer = relationship.NewCapturerImpl() - gw = &v1beta1.Gateway{ + gw = &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gw", }, - Spec: v1beta1.GatewaySpec{ - Listeners: []v1beta1.Listener{ + Spec: gatewayv1.GatewaySpec{ + Listeners: []gatewayv1.Listener{ { - AllowedRoutes: &v1beta1.AllowedRoutes{ - Namespaces: &v1beta1.RouteNamespaces{ - From: helpers.GetPointer(v1beta1.NamespacesFromSelector), + AllowedRoutes: &gatewayv1.AllowedRoutes{ + Namespaces: &gatewayv1.RouteNamespaces{ + From: helpers.GetPointer(gatewayv1.NamespacesFromSelector), Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app": "valid", @@ -447,16 +447,16 @@ var _ = Describe("Capturer", func() { }) It("Capture does not panic when passed an unsupported resource type", func() { Expect(func() { - capturer.Capture(&v1beta1.GatewayClass{}) + capturer.Capture(&gatewayv1.GatewayClass{}) }).ToNot(Panic()) }) It("Remove does not panic when passed an unsupported resource type", func() { Expect(func() { - capturer.Remove(&v1beta1.GatewayClass{}, types.NamespacedName{}) + capturer.Remove(&gatewayv1.GatewayClass{}, types.NamespacedName{}) }).ToNot(Panic()) }) It("Exist returns false if passed an unsupported resource type", func() { - Expect(capturer.Exists(&v1beta1.GatewayClass{}, types.NamespacedName{})).To(BeFalse()) + Expect(capturer.Exists(&gatewayv1.GatewayClass{}, types.NamespacedName{})).To(BeFalse()) }) }) }) diff --git a/internal/mode/static/state/relationship/relationships_test.go b/internal/mode/static/state/relationship/relationships_test.go index 838ac52172..fee64b5936 100644 --- a/internal/mode/static/state/relationship/relationships_test.go +++ b/internal/mode/static/state/relationship/relationships_test.go @@ -6,21 +6,21 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/gateway-api/apis/v1beta1" + v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" ) func TestGetBackendServiceNamesFromRoute(t *testing.T) { - getNormalRefs := func(svcName v1beta1.ObjectName) []v1beta1.HTTPBackendRef { - return []v1beta1.HTTPBackendRef{ + getNormalRefs := func(svcName v1.ObjectName) []v1.HTTPBackendRef { + return []v1.HTTPBackendRef{ { - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ - Kind: (*v1beta1.Kind)(helpers.GetPointer("Service")), + BackendRef: v1.BackendRef{ + BackendObjectReference: v1.BackendObjectReference{ + Kind: (*v1.Kind)(helpers.GetPointer("Service")), Name: svcName, - Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")), - Port: (*v1beta1.PortNumber)(helpers.GetPointer[int32](80)), + Namespace: (*v1.Namespace)(helpers.GetPointer("test")), + Port: (*v1.PortNumber)(helpers.GetPointer[int32](80)), }, }, }, @@ -28,16 +28,16 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) { } getModifiedRefs := func( - svcName v1beta1.ObjectName, - mod func([]v1beta1.HTTPBackendRef) []v1beta1.HTTPBackendRef, - ) []v1beta1.HTTPBackendRef { + svcName v1.ObjectName, + mod func([]v1.HTTPBackendRef) []v1.HTTPBackendRef, + ) []v1.HTTPBackendRef { return mod(getNormalRefs(svcName)) } - hr := &v1beta1.HTTPRoute{ + hr := &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{Namespace: "test"}, - Spec: v1beta1.HTTPRouteSpec{ - Rules: []v1beta1.HTTPRouteRule{ + Spec: v1.HTTPRouteSpec{ + Rules: []v1.HTTPRouteRule{ { BackendRefs: getNormalRefs("svc1"), }, @@ -47,8 +47,8 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) { { BackendRefs: getModifiedRefs( "invalid-kind", - func(refs []v1beta1.HTTPBackendRef) []v1beta1.HTTPBackendRef { - refs[0].Kind = (*v1beta1.Kind)(helpers.GetPointer("Invalid")) + func(refs []v1.HTTPBackendRef) []v1.HTTPBackendRef { + refs[0].Kind = (*v1.Kind)(helpers.GetPointer("Invalid")) return refs }, ), @@ -56,7 +56,7 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) { { BackendRefs: getModifiedRefs( "nil-namespace", - func(refs []v1beta1.HTTPBackendRef) []v1beta1.HTTPBackendRef { + func(refs []v1.HTTPBackendRef) []v1.HTTPBackendRef { refs[0].Namespace = nil return refs }, @@ -65,8 +65,8 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) { { BackendRefs: getModifiedRefs( "diff-namespace", - func(refs []v1beta1.HTTPBackendRef) []v1beta1.HTTPBackendRef { - refs[0].Namespace = (*v1beta1.Namespace)( + func(refs []v1.HTTPBackendRef) []v1.HTTPBackendRef { + refs[0].Namespace = (*v1.Namespace)( helpers.GetPointer("not-test"), ) return refs @@ -82,18 +82,18 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) { { BackendRefs: getModifiedRefs( "multiple-refs", - func(refs []v1beta1.HTTPBackendRef) []v1beta1.HTTPBackendRef { - return append(refs, v1beta1.HTTPBackendRef{ - BackendRef: v1beta1.BackendRef{ - BackendObjectReference: v1beta1.BackendObjectReference{ - Kind: (*v1beta1.Kind)( + func(refs []v1.HTTPBackendRef) []v1.HTTPBackendRef { + return append(refs, v1.HTTPBackendRef{ + BackendRef: v1.BackendRef{ + BackendObjectReference: v1.BackendObjectReference{ + Kind: (*v1.Kind)( helpers.GetPointer("Service"), ), Name: "multiple-refs2", - Namespace: (*v1beta1.Namespace)( + Namespace: (*v1.Namespace)( helpers.GetPointer("test"), ), - Port: (*v1beta1.PortNumber)( + Port: (*v1.PortNumber)( helpers.GetPointer[int32](80), ), }, diff --git a/internal/mode/static/state/store.go b/internal/mode/static/state/store.go index 5e776d0ce2..0c6adf4731 100644 --- a/internal/mode/static/state/store.go +++ b/internal/mode/static/state/store.go @@ -26,7 +26,7 @@ type objectStore interface { } // objectStoreMapAdapter wraps maps of types.NamespacedName to Kubernetes resources -// (e.g. map[types.NamespacedName]*v1beta1.Gateway) so that they can be used through objectStore interface. +// (e.g. map[types.NamespacedName]*v1.Gateway) so that they can be used through objectStore interface. type objectStoreMapAdapter[T client.Object] struct { objects map[types.NamespacedName]T } diff --git a/tests/dataplane-performance/manifests/cafe-routes.yaml b/tests/dataplane-performance/manifests/cafe-routes.yaml index 95d0252842..f074bb0546 100644 --- a/tests/dataplane-performance/manifests/cafe-routes.yaml +++ b/tests/dataplane-performance/manifests/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -32,7 +32,7 @@ spec: - name: coffee-svc port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/tests/dataplane-performance/manifests/gateway.yaml b/tests/dataplane-performance/manifests/gateway.yaml index 1d029ef08a..794b1825f5 100644 --- a/tests/dataplane-performance/manifests/gateway.yaml +++ b/tests/dataplane-performance/manifests/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: cafe diff --git a/tests/dataplane-performance/setup.md b/tests/dataplane-performance/setup.md index 979f007046..170150922e 100644 --- a/tests/dataplane-performance/setup.md +++ b/tests/dataplane-performance/setup.md @@ -28,7 +28,7 @@ 2. Deploy CRDs: ```bash - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml ``` 3. Deploy NGF from edge using Helm install, and expose using an internal LoadBalancer service: diff --git a/tests/longevity/manifests/cafe-routes.yaml b/tests/longevity/manifests/cafe-routes.yaml index e679756d6e..d8ea5a2f4a 100644 --- a/tests/longevity/manifests/cafe-routes.yaml +++ b/tests/longevity/manifests/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -17,7 +17,7 @@ spec: - name: coffee port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/tests/longevity/manifests/gateway.yaml b/tests/longevity/manifests/gateway.yaml index 593d17e496..6789002abb 100644 --- a/tests/longevity/manifests/gateway.yaml +++ b/tests/longevity/manifests/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/reconfig/scripts/cafe-routes.yaml b/tests/reconfig/scripts/cafe-routes.yaml index 3d182d0ada..f4d9823da9 100644 --- a/tests/reconfig/scripts/cafe-routes.yaml +++ b/tests/reconfig/scripts/cafe-routes.yaml @@ -1,10 +1,10 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: cafe-tls-redirect spec: parentRefs: - - name: gateway.networking.k8s.io/v1beta1 + - name: gateway.networking.k8s.io/v1 namespace: default sectionName: http hostnames: @@ -16,7 +16,7 @@ spec: scheme: https port: 443 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -36,7 +36,7 @@ spec: - name: coffee port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/tests/reconfig/scripts/gateway.yaml b/tests/reconfig/scripts/gateway.yaml index a0fd45cc28..fd9d52675b 100644 --- a/tests/reconfig/scripts/gateway.yaml +++ b/tests/reconfig/scripts/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/reconfig/setup.md b/tests/reconfig/setup.md index 52ded61509..6462fe4629 100644 --- a/tests/reconfig/setup.md +++ b/tests/reconfig/setup.md @@ -35,7 +35,7 @@ 2. Deploy CRDs: ```bash - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml ``` 3. Deploy NGF from edge using Helm install and wait for LoadBalancer Service to be ready diff --git a/tests/scale/generate_manifests.go b/tests/scale/generate_manifests.go index 025744344a..88f752141d 100644 --- a/tests/scale/generate_manifests.go +++ b/tests/scale/generate_manifests.go @@ -11,7 +11,7 @@ import ( "text/template" ) -var gwTmplTxt = `apiVersion: gateway.networking.k8s.io/v1beta1 +var gwTmplTxt = `apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway @@ -33,7 +33,7 @@ spec: {{- end -}} {{- end -}}` -var hrTmplTxt = `apiVersion: gateway.networking.k8s.io/v1beta1 +var hrTmplTxt = `apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: {{ .Name }} diff --git a/tests/scale/manifests/scale-matches.yaml b/tests/scale/manifests/scale-matches.yaml index 553b5ea88b..939e62df84 100644 --- a/tests/scale/manifests/scale-matches.yaml +++ b/tests/scale/manifests/scale-matches.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway @@ -42,7 +42,7 @@ spec: selector: app: backend --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: route diff --git a/tests/scale/manifests/scale-upstreams.yaml b/tests/scale/manifests/scale-upstreams.yaml index 298a4b876f..96ffe87bb6 100644 --- a/tests/scale/manifests/scale-upstreams.yaml +++ b/tests/scale/manifests/scale-upstreams.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway @@ -10,7 +10,7 @@ spec: port: 80 protocol: HTTP --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: route diff --git a/tests/scale/scale.md b/tests/scale/scale.md index c638809fb9..b3b342eb59 100644 --- a/tests/scale/scale.md +++ b/tests/scale/scale.md @@ -45,7 +45,7 @@ are listed in the [Scale Upstream Servers](#scale-upstream-servers) test steps. - Install Gateway API Resources: ```console - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml ``` - Install edge NGF and save the Pod Name and LoadBalancer IP for tests: diff --git a/tests/zero-downtime-scaling/manifests/cafe-routes.yaml b/tests/zero-downtime-scaling/manifests/cafe-routes.yaml index e679756d6e..d8ea5a2f4a 100644 --- a/tests/zero-downtime-scaling/manifests/cafe-routes.yaml +++ b/tests/zero-downtime-scaling/manifests/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -17,7 +17,7 @@ spec: - name: coffee port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/tests/zero-downtime-scaling/manifests/gateway-1.yaml b/tests/zero-downtime-scaling/manifests/gateway-1.yaml index 7bfcc34a7e..04f3e86f80 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-1.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-1.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-10.yaml b/tests/zero-downtime-scaling/manifests/gateway-10.yaml index 6f99f1bcab..a3f8452bdc 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-10.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-10.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-11.yaml b/tests/zero-downtime-scaling/manifests/gateway-11.yaml index 5b6dc70280..7ea0ddaf90 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-11.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-11.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-12.yaml b/tests/zero-downtime-scaling/manifests/gateway-12.yaml index e60e6d4130..9897e99e39 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-12.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-12.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-13.yaml b/tests/zero-downtime-scaling/manifests/gateway-13.yaml index 074e6ddbd9..35fce379b8 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-13.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-13.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-14.yaml b/tests/zero-downtime-scaling/manifests/gateway-14.yaml index 64dd43603b..c9e1b038cb 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-14.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-14.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-15.yaml b/tests/zero-downtime-scaling/manifests/gateway-15.yaml index 840bb8ce00..67c32776dc 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-15.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-15.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-16.yaml b/tests/zero-downtime-scaling/manifests/gateway-16.yaml index 42b36d14a5..941dbd4278 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-16.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-16.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-17.yaml b/tests/zero-downtime-scaling/manifests/gateway-17.yaml index a191a08f06..a36c71359d 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-17.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-17.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-18.yaml b/tests/zero-downtime-scaling/manifests/gateway-18.yaml index f6ff37b30f..bc4c1e431e 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-18.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-18.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-19.yaml b/tests/zero-downtime-scaling/manifests/gateway-19.yaml index 3e9ae7f0ea..cf503bc938 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-19.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-19.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-2.yaml b/tests/zero-downtime-scaling/manifests/gateway-2.yaml index 02406e0983..3e1a2458ba 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-2.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-2.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-20.yaml b/tests/zero-downtime-scaling/manifests/gateway-20.yaml index ca5441073b..3a72b45c06 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-20.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-20.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-21.yaml b/tests/zero-downtime-scaling/manifests/gateway-21.yaml index df0abce378..11bf1c872e 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-21.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-21.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-22.yaml b/tests/zero-downtime-scaling/manifests/gateway-22.yaml index 58ba2c68b6..7562118d21 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-22.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-22.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-23.yaml b/tests/zero-downtime-scaling/manifests/gateway-23.yaml index 936fa7312b..8785675d39 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-23.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-23.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-24.yaml b/tests/zero-downtime-scaling/manifests/gateway-24.yaml index a972c146fe..86f02b1dd5 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-24.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-24.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-25.yaml b/tests/zero-downtime-scaling/manifests/gateway-25.yaml index d0c5d9ae74..02034a59b6 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-25.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-25.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-3.yaml b/tests/zero-downtime-scaling/manifests/gateway-3.yaml index e332b45f5c..d0b3a2c63c 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-3.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-3.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-4.yaml b/tests/zero-downtime-scaling/manifests/gateway-4.yaml index 4158396f70..9be9b7acaf 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-4.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-4.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-5.yaml b/tests/zero-downtime-scaling/manifests/gateway-5.yaml index 4b724c0904..902a315e09 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-5.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-5.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-6.yaml b/tests/zero-downtime-scaling/manifests/gateway-6.yaml index 61ae1f9956..8043ec9fa0 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-6.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-6.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-7.yaml b/tests/zero-downtime-scaling/manifests/gateway-7.yaml index 3522ffafab..90dd490f06 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-7.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-7.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-8.yaml b/tests/zero-downtime-scaling/manifests/gateway-8.yaml index 592fff4797..6e15236dfc 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-8.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-8.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-scaling/manifests/gateway-9.yaml b/tests/zero-downtime-scaling/manifests/gateway-9.yaml index 10946ad9c7..aab0679dc9 100644 --- a/tests/zero-downtime-scaling/manifests/gateway-9.yaml +++ b/tests/zero-downtime-scaling/manifests/gateway-9.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-upgrades/manifests/cafe-routes.yaml b/tests/zero-downtime-upgrades/manifests/cafe-routes.yaml index e679756d6e..d8ea5a2f4a 100644 --- a/tests/zero-downtime-upgrades/manifests/cafe-routes.yaml +++ b/tests/zero-downtime-upgrades/manifests/cafe-routes.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: coffee @@ -17,7 +17,7 @@ spec: - name: coffee port: 80 --- -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: tea diff --git a/tests/zero-downtime-upgrades/manifests/gateway-updated.yaml b/tests/zero-downtime-upgrades/manifests/gateway-updated.yaml index c501ce8395..a54e48eed7 100644 --- a/tests/zero-downtime-upgrades/manifests/gateway-updated.yaml +++ b/tests/zero-downtime-upgrades/manifests/gateway-updated.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway diff --git a/tests/zero-downtime-upgrades/manifests/gateway.yaml b/tests/zero-downtime-upgrades/manifests/gateway.yaml index 593d17e496..6789002abb 100644 --- a/tests/zero-downtime-upgrades/manifests/gateway.yaml +++ b/tests/zero-downtime-upgrades/manifests/gateway.yaml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 +apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway