From b4eafecd232bf649db37948019fe340f68829d37 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Jun 2022 14:03:48 -0400 Subject: [PATCH 01/17] deps: bump gateway-api to sigs.k8s.io/gateway-api@v0.5.0-rc1 --- go.mod | 68 +++++++++--------- go.sum | 223 ++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 177 insertions(+), 114 deletions(-) diff --git a/go.mod b/go.mod index e2a6abe75..18357280a 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/envoyproxy/go-control-plane v0.9.10-0.20211015211602-cfdef0997689 github.com/getkin/kin-openapi v0.97.0 github.com/go-chi/chi/v5 v5.0.7 - github.com/go-logr/logr v0.4.0 + github.com/go-logr/logr v1.2.0 github.com/golang/mock v1.6.0 github.com/google/uuid v1.2.0 github.com/hashicorp/consul/api v1.12.1-0.20220111183205-dcf1cd485363 @@ -17,21 +17,21 @@ require ( github.com/hashicorp/go-hclog v0.16.2 github.com/hashicorp/go-multierror v1.1.0 github.com/mitchellh/cli v1.1.2 - github.com/prometheus/client_golang v1.11.0 + github.com/prometheus/client_golang v1.12.1 github.com/stretchr/testify v1.7.2 github.com/vladimirvivien/gexe v0.1.1 golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf - golang.org/x/net v0.0.0-20210825183410-e898025ed96a + golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd golang.org/x/sync v0.0.0-20210220032951-036812b2e83c google.golang.org/grpc v1.40.0 - k8s.io/api v0.22.1 - k8s.io/apiextensions-apiserver v0.21.3 - k8s.io/apimachinery v0.22.1 - k8s.io/client-go v0.22.1 - k8s.io/klog/v2 v2.10.0 - sigs.k8s.io/controller-runtime v0.9.6 + k8s.io/api v0.24.1 + k8s.io/apiextensions-apiserver v0.24.1 + k8s.io/apimachinery v0.24.1 + k8s.io/client-go v0.24.1 + k8s.io/klog/v2 v2.60.1 + sigs.k8s.io/controller-runtime v0.12.1 sigs.k8s.io/e2e-framework v0.0.3 - sigs.k8s.io/gateway-api v0.4.1 + sigs.k8s.io/gateway-api v0.5.0-rc1 ) require ( @@ -40,11 +40,13 @@ require ( github.com/Masterminds/sprig v2.22.0+incompatible // indirect github.com/Microsoft/go-winio v0.4.17 // indirect github.com/Microsoft/hcsshim v0.9.0 // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/census-instrumentation/opencensus-proto v0.2.1 // indirect - github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe // indirect github.com/containerd/cgroups v1.0.1 // indirect github.com/containerd/containerd v1.5.7 // indirect @@ -53,18 +55,20 @@ require ( github.com/docker/distribution v2.7.1+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect + github.com/emicklei/go-restful v2.9.5+incompatible // indirect github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect - github.com/evanphx/json-patch v4.11.0+incompatible // indirect + github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/fatih/color v1.12.0 // indirect - github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.5 // indirect github.com/go-openapi/swag v0.19.14 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect + github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/google/gofuzz v1.1.0 // indirect - github.com/googleapis/gnostic v0.5.5 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.1 // indirect @@ -77,7 +81,7 @@ require ( github.com/imdario/mergo v0.3.12 // indirect github.com/invopop/yaml v0.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.11 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.12 // indirect @@ -91,7 +95,7 @@ require ( github.com/moby/sys/mountinfo v0.4.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/onsi/gomega v1.15.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect github.com/opencontainers/runc v1.0.2 // indirect @@ -99,28 +103,28 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.26.0 // indirect - github.com/prometheus/procfs v0.6.0 // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect go.opencensus.io v0.23.0 // indirect - go.uber.org/zap v1.19.0 // indirect - golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect - golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect - golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect - golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect - golang.org/x/text v0.3.6 // indirect - golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect + golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect + golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect + golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect - google.golang.org/protobuf v1.26.0 // indirect + google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368 // indirect + google.golang.org/protobuf v1.27.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/component-base v0.21.3 // indirect - k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect - k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect - sigs.k8s.io/yaml v1.2.0 // indirect + k8s.io/component-base v0.24.1 // indirect + k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect + k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect + sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index 1d41ecbcb..0df2516cf 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,9 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v10.8.1+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= @@ -90,11 +91,12 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0 github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= -github.com/ahmetb/gen-crd-api-reference-docs v0.3.0/go.mod h1:TdjdkYhlOifCQWPs1UdTma97kQQMozf5h26hTuG70u8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -102,6 +104,7 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210826220005-b48c857c3a0e/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -110,8 +113,10 @@ github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4 github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -123,9 +128,9 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= @@ -136,9 +141,12 @@ github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEe github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -159,6 +167,9 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe h1:QJDJubh0OEcpeGjC7/8uF9tt4e39U/Ya1uyK+itnNPQ= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= +github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE= github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU= github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU= @@ -264,6 +275,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -304,6 +316,7 @@ github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:Htrtb github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -318,22 +331,27 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrp github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.11.0+incompatible h1:glyUF9yIYtMHzn8xaKw5rMhdWcwsYV8dZHIq5567/xs= github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= +github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= github.com/getkin/kin-openapi v0.97.0 h1:bsvXZeuGiCW43ZKy6xOY5qfT5fCRYmnJwierblSrHCU= github.com/getkin/kin-openapi v0.97.0/go.mod h1:w4lRPHiyOdwGbOkLIyk+P0qCwlu7TXPCHD/64nSXzgE= +github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= @@ -350,10 +368,12 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/zapr v0.4.0 h1:uc1uML3hRYL9/ZZPdgHS/n8Nzo+eaYL/Efxkkamf7OM= +github.com/go-logr/logr v1.2.0 h1:QK40JKJyMdUDz+h+xvCsru/bJhvG0UxvePV0ufL/AcE= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/zapr v0.4.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= +github.com/go-logr/zapr v1.2.0 h1:n4JnPI1T3Qq1SFEi/F8rwLrZERp2bso19PJZDB9dayk= +github.com/go-logr/zapr v1.2.0/go.mod h1:Qa4Bsj2Vb+FAVeAKsLD8RLQ+YRJB8YDmOAKxaBQf7Ro= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= @@ -362,6 +382,7 @@ github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34 github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= @@ -373,7 +394,6 @@ github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5F github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= @@ -389,6 +409,7 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -428,6 +449,10 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= +github.com/google/cel-go v0.10.1/go.mod h1:U7ayypeSkw23szu4GaQTPJGx66c20mx8JklMSxrmI1w= +github.com/google/cel-spec v0.6.0/go.mod h1:Nwjgxy5CbjlPrtCWjeDjUyKMl8w41YBYGjsyDdqk0xA= +github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= +github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -468,8 +493,6 @@ github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= -github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= -github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= @@ -483,6 +506,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -555,6 +579,7 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= 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/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -562,8 +587,9 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -589,10 +615,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo= -github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -654,8 +678,9 @@ github.com/moby/sys/mountinfo v0.4.1 h1:1O+1cHA1aujwEwwVMa2Xm2l+gIpUHyd3+D+d7LZh github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGqsZeMYowQ= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= -github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= +github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= +github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -667,6 +692,7 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -690,8 +716,8 @@ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -701,9 +727,7 @@ github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= -github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= -github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU= -github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -730,12 +754,12 @@ github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mo github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqiriPsEqVhc+svHE= github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -756,8 +780,9 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -771,8 +796,9 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -783,8 +809,9 @@ github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDa github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -812,19 +839,19 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= +github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -833,7 +860,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -857,6 +883,7 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -885,6 +912,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/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.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= @@ -894,8 +922,15 @@ go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= +go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= +go.etcd.io/etcd/client/v3 v3.5.1/go.mod h1:OnjH4M8OnAotwaB2l9bVgZzRFKru7/ZMoS46OtKyd3Q= +go.etcd.io/etcd/pkg/v3 v3.5.0/go.mod h1:UzJGatBQ1lXChBkQF0AuAtkRQMYnHubxAEYIrC3MSsE= +go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc= +go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVdCRJoS4= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -905,21 +940,31 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/contrib v0.20.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0/go.mod h1:oVGt1LRbBOBq1A5BQLlUg9UaU/54aiHw8cgjV3aWZ/E= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4= +go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= +go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= +go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= +go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= +go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= +go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= +go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= +go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -937,8 +982,10 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -964,7 +1011,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -978,6 +1024,7 @@ golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hM golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/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.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1022,6 +1069,7 @@ golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -1031,9 +1079,12 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1045,8 +1096,9 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 h1:0Ja1LBD+yisY6RWM/BH7TJVXWsSjs2VwBSmvSX4HdBc= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1152,14 +1204,20 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/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-20210603081109-ebe580a85c40/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-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1167,8 +1225,9 @@ 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.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1176,8 +1235,8 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1243,7 +1302,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10-0.20220218145154-897bd77cd717/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1273,7 +1332,6 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1306,6 +1364,7 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= @@ -1318,6 +1377,7 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201102152239-715cce707fb0/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1328,8 +1388,10 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368 h1:Et6SkiuvnBn+SgrSYXs/BrUpGB4mbdwt4R3vaPIlicA= +google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1353,6 +1415,7 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5 google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= @@ -1367,8 +1430,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1384,7 +1448,6 @@ gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKW gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= @@ -1424,41 +1487,37 @@ k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo= k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ= k8s.io/api v0.20.6/go.mod h1:X9e8Qag6JV/bL5G6bU8sdVRltWKmdHsFUGS3eVndqE8= k8s.io/api v0.21.1/go.mod h1:FstGROTmsSHBarKc8bylzXih8BLNYTiS3TZcsoEDg2s= -k8s.io/api v0.21.3/go.mod h1:hUgeYHUbBp23Ue4qdX9tR8/ANi/g3ehylAqDn9NWVOg= -k8s.io/api v0.22.1 h1:ISu3tD/jRhYfSW8jI/Q1e+lRxkR7w9UwQEZ7FgslrwY= -k8s.io/api v0.22.1/go.mod h1:bh13rkTp3F1XEaLGykbyRD2QaTTzPm0e/BMd8ptFONY= +k8s.io/api v0.24.1 h1:BjCMRDcyEYz03joa3K1+rbshwh1Ay6oB53+iUx2H8UY= +k8s.io/api v0.24.1/go.mod h1:JhoOvNiLXKTPQ60zh2g0ewpA+bnEYf5q44Flhquh4vQ= k8s.io/apiextensions-apiserver v0.21.1/go.mod h1:KESQFCGjqVcVsZ9g0xX5bacMjyX5emuWcS2arzdEouA= -k8s.io/apiextensions-apiserver v0.21.3 h1:+B6biyUWpqt41kz5x6peIsljlsuwvNAp/oFax/j2/aY= -k8s.io/apiextensions-apiserver v0.21.3/go.mod h1:kl6dap3Gd45+21Jnh6utCx8Z2xxLm8LGDkprcd+KbsE= +k8s.io/apiextensions-apiserver v0.24.1 h1:5yBh9+ueTq/kfnHQZa0MAo6uNcPrtxPMpNQgorBaKS0= +k8s.io/apiextensions-apiserver v0.24.1/go.mod h1:A6MHfaLDGfjOc/We2nM7uewD5Oa/FnEbZ6cD7g2ca4Q= k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= k8s.io/apimachinery v0.20.6/go.mod h1:ejZXtW1Ra6V1O5H8xPBGz+T3+4gfkTCeExAHKU57MAc= k8s.io/apimachinery v0.21.1/go.mod h1:jbreFvJo3ov9rj7eWT7+sYiRx+qZuCYXwWT1bcDswPY= -k8s.io/apimachinery v0.21.3/go.mod h1:H/IM+5vH9kZRNJ4l3x/fXP/5bOPJaVP/guptnZPeCFI= -k8s.io/apimachinery v0.22.1 h1:DTARnyzmdHMz7bFWFDDm22AM4pLWTQECMpRTFu2d2OM= -k8s.io/apimachinery v0.22.1/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= +k8s.io/apimachinery v0.24.1 h1:ShD4aDxTQKN5zNf8K1RQ2u98ELLdIW7jEnlO9uAMX/I= +k8s.io/apimachinery v0.24.1/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU= k8s.io/apiserver v0.20.4/go.mod h1:Mc80thBKOyy7tbvFtB4kJv1kbdD0eIH8k8vianJcbFM= k8s.io/apiserver v0.20.6/go.mod h1:QIJXNt6i6JB+0YQRNcS0hdRHJlMhflFmsBDeSgT1r8Q= k8s.io/apiserver v0.21.1/go.mod h1:nLLYZvMWn35glJ4/FZRhzLG/3MPxAaZTgV4FJZdr+tY= -k8s.io/apiserver v0.21.3/go.mod h1:eDPWlZG6/cCCMj/JBcEpDoK+I+6i3r9GsChYBHSbAzU= +k8s.io/apiserver v0.24.1/go.mod h1:dQWNMx15S8NqJMp0gpYfssyvhYnkilc1LpExd/dkLh0= k8s.io/client-go v0.20.1/go.mod h1:/zcHdt1TeWSd5HoUe6elJmHSQ6uLLgp4bIJHVEuy+/Y= k8s.io/client-go v0.20.4/go.mod h1:LiMv25ND1gLUdBeYxBIwKpkSC5IsozMMmOOeSJboP+k= k8s.io/client-go v0.20.6/go.mod h1:nNQMnOvEUEsOzRRFIIkdmYOjAZrC8bgq0ExboWSU1I0= k8s.io/client-go v0.21.1/go.mod h1:/kEw4RgW+3xnBGzvp9IWxKSNA+lXn3A7AuH3gdOAzLs= -k8s.io/client-go v0.21.3/go.mod h1:+VPhCgTsaFmGILxR/7E1N0S+ryO010QBeNCv5JwRGYU= -k8s.io/client-go v0.22.1 h1:jW0ZSHi8wW260FvcXHkIa0NLxFBQszTlhiAVsU5mopw= -k8s.io/client-go v0.22.1/go.mod h1:BquC5A4UOo4qVDUtoc04/+Nxp1MeHcVc1HJm1KmG8kk= +k8s.io/client-go v0.24.1 h1:w1hNdI9PFrzu3OlovVeTnf4oHDt+FJLd9Ndluvnb42E= +k8s.io/client-go v0.24.1/go.mod h1:f1kIDqcEYmwXS/vTbbhopMUbhKp2JhOeVTfxgaCIlF8= k8s.io/code-generator v0.19.7/go.mod h1:lwEq3YnLYb/7uVXLorOJfxg+cUu2oihFhHZ0n9NIla0= k8s.io/code-generator v0.21.1/go.mod h1:hUlps5+9QaTrKx+jiM4rmq7YmH8wPOIko64uZCHDh6Q= -k8s.io/code-generator v0.21.3/go.mod h1:K3y0Bv9Cz2cOW2vXUrNZlFbflhuPvuadW6JdnN6gGKo= -k8s.io/code-generator v0.22.0/go.mod h1:eV77Y09IopzeXOJzndrDyCI88UBok2h6WxAlBwpxa+o= +k8s.io/code-generator v0.24.1/go.mod h1:dpVhs00hTuTdTY6jvVxvTFCk6gSMrtfRydbhZwHI15w= k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeYNLk= k8s.io/component-base v0.20.4/go.mod h1:t4p9EdiagbVCJKrQ1RsA5/V4rFQNDfRlevJajlGwgjI= k8s.io/component-base v0.20.6/go.mod h1:6f1MPBAeI+mvuts3sIdtpjljHWBQ2cIy38oBIWMYnrM= k8s.io/component-base v0.21.1/go.mod h1:NgzFZ2qu4m1juby4TnrmpR8adRk6ka62YdH5DkIIyKA= -k8s.io/component-base v0.21.3 h1:4WuuXY3Npa+iFfi2aDRiOz+anhNvRfye0859ZgfC5Og= -k8s.io/component-base v0.21.3/go.mod h1:kkuhtfEHeZM6LkX0saqSK8PbdO7A0HigUngmhhrwfGQ= +k8s.io/component-base v0.24.1 h1:APv6W/YmfOWZfo+XJ1mZwep/f7g7Tpwvdbo9CQLDuts= +k8s.io/component-base v0.24.1/go.mod h1:DW5vQGYVCog8WYpNob3PMmmsY8A3L9QZNg4j/dV3s38= k8s.io/cri-api v0.17.3/go.mod h1:X1sbHmuXhwaHs9xxYffLqJogVsnI+f6cPRcgPel7ywM= k8s.io/cri-api v0.20.1/go.mod h1:2JRbKt+BFLTjtrILYVqQK5jqhI+XNdF6UiGMgczeBCI= k8s.io/cri-api v0.20.4/go.mod h1:2JRbKt+BFLTjtrILYVqQK5jqhI+XNdF6UiGMgczeBCI= @@ -1466,48 +1525,48 @@ k8s.io/cri-api v0.20.6/go.mod h1:ew44AjNXwyn1s0U4xCKGodU7J1HzBeZ1MpGrpa5r8Yc= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/gengo v0.0.0-20201203183100-97869a43a9d9/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/klog v0.2.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/gengo v0.0.0-20211129171323-c02415ce4185/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/klog/v2 v2.10.0 h1:R2HDMDJsHVTHA2n4RjwbeYXdOcBymXdX/JRb1v0VGhE= -k8s.io/klog/v2 v2.10.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= +k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc= +k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM= k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e h1:KLHHjkdQFomZy8+06csTWZ0m1343QqxZhR2LJ1OxCYM= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= +k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 h1:Gii5eqf+GmIEwGNKQYQClCayuJCe2/4fZUvF7VG99sU= +k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk= k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210527160623-6fdb442a123b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e h1:ldQh+neBabomh7+89dTpiFAB8tGdfVmuIzAHbvtl+9I= -k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc= +k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.19/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= sigs.k8s.io/controller-runtime v0.9.0/go.mod h1:TgkfvrhhEw3PlI0BRL/5xM+89y3/yc0ZDfdbTl84si8= -sigs.k8s.io/controller-runtime v0.9.6 h1:EevVMlgUj4fC1NVM4+DB3iPkWkmGRNarA66neqv9Qew= -sigs.k8s.io/controller-runtime v0.9.6/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA= -sigs.k8s.io/controller-tools v0.6.2/go.mod h1:oaeGpjXn6+ZSEIQkUe/+3I40PNiDYp9aeawbt3xTgJ8= +sigs.k8s.io/controller-runtime v0.12.1 h1:4BJY01xe9zKQti8oRjj/NeHKRXthf1YkYJAgLONFFoI= +sigs.k8s.io/controller-runtime v0.12.1/go.mod h1:BKhxlA4l7FPK4AQcsuL4X6vZeWnKDXez/vp1Y8dxTU0= sigs.k8s.io/e2e-framework v0.0.3 h1:OShxX6BXwsEpP077MP/rjrDmt1YF9l/27D1heQeuNTo= sigs.k8s.io/e2e-framework v0.0.3/go.mod h1:C4T2QK8Hs+o89wQSz3cnAiDjzJnC50bqbSLuKbp0DQY= -sigs.k8s.io/gateway-api v0.4.1 h1:Tof9/PNSZXyfDuTTe1XFvaTlvBRE6bKq1kmV6jj6rQE= -sigs.k8s.io/gateway-api v0.4.1/go.mod h1:r3eiNP+0el+NTLwaTfOrCNXy8TukC+dIM3ggc+fbNWk= +sigs.k8s.io/gateway-api v0.5.0-rc1 h1:r5+fm/ErAJp9fyKMpra5PDUPpOWDbNF5uQuaHrCScOM= +sigs.k8s.io/gateway-api v0.5.0-rc1/go.mod h1:x0AP6gugkFV8fC/oTlnOMU0pnmuzIR8LfIPRVUjxSqA= +sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87JJaPNLh5tIzYHgStQ9Y= +sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= +sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y= +sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= From 086387dfb3e2733246981bfd913b993f514ec981 Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Fri, 13 May 2022 14:22:14 -0400 Subject: [PATCH 02/17] gateway-api: update ParentRef -> ParentReference --- internal/commands/server/k8s_e2e_test.go | 35 +++++++++-------- internal/k8s/gatewayclient/gatewayclient.go | 4 +- .../k8s/gatewayclient/mocks/gatewayclient.go | 2 +- internal/k8s/reconciler/gateway_test.go | 5 ++- internal/k8s/reconciler/listener.go | 2 +- internal/k8s/reconciler/listener_test.go | 22 +++++------ internal/k8s/reconciler/manager.go | 2 +- internal/k8s/reconciler/manager_test.go | 5 ++- internal/k8s/reconciler/route.go | 2 +- internal/k8s/reconciler/route_test.go | 38 +++++++++---------- internal/k8s/reconciler/utils.go | 4 +- internal/k8s/reconciler/utils_test.go | 2 +- internal/k8s/utils/reference.go | 2 +- 13 files changed, 63 insertions(+), 62 deletions(-) diff --git a/internal/commands/server/k8s_e2e_test.go b/internal/commands/server/k8s_e2e_test.go index cc14b3f65..43da56cc6 100644 --- a/internal/commands/server/k8s_e2e_test.go +++ b/internal/commands/server/k8s_e2e_test.go @@ -29,7 +29,6 @@ import ( gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/consul/api" - appsv1 "k8s.io/api/apps/v1" "github.com/hashicorp/consul-api-gateway/internal/k8s" "github.com/hashicorp/consul-api-gateway/internal/testing/e2e" @@ -136,7 +135,7 @@ func TestGatewayWithReplicas(t *testing.T) { checkGatewayConfigAnnotation(ctx, t, resources, gatewayName, namespace, gcc) // Fetch the deployment created by the gateway and check the number of replicas - deployment := &appsv1.Deployment{} + deployment := &apps.Deployment{} assert.NoError(t, resources.Get(ctx, gatewayName, namespace, deployment)) assert.Equal(t, numberOfReplicas, *deployment.Spec.Replicas) @@ -172,7 +171,7 @@ func TestGatewayWithReplicasCanScale(t *testing.T) { checkGatewayConfigAnnotation(ctx, t, resources, gatewayName, namespace, gcc) // Fetch the deployment created by the gateway and check the number of replicas - deployment := &appsv1.Deployment{} + deployment := &apps.Deployment{} assert.NoError(t, resources.Get(ctx, gatewayName, namespace, deployment)) assert.Equal(t, initialReplicas, *deployment.Spec.Replicas) @@ -227,7 +226,7 @@ func TestGatewayWithReplicasRespectMinMax(t *testing.T) { checkGatewayConfigAnnotation(ctx, t, resources, gatewayName, namespace, gatewayClassConfig) // Fetch the deployment created by the gateway and check the number of replicas - deployment := &appsv1.Deployment{} + deployment := &apps.Deployment{} require.NoError(t, resources.Get(ctx, gatewayName, namespace, deployment)) assert.Equal(t, initialReplicas, *deployment.Spec.Replicas) @@ -408,7 +407,7 @@ func TestHTTPRouteFlattening(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -443,7 +442,7 @@ func TestHTTPRouteFlattening(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -545,7 +544,7 @@ func TestHTTPMeshService(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -582,7 +581,7 @@ func TestHTTPMeshService(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -634,7 +633,7 @@ func TestHTTPMeshService(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -798,7 +797,7 @@ func TestTCPMeshService(t *testing.T) { }, Spec: gateway.TCPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -849,7 +848,7 @@ func TestTCPMeshService(t *testing.T) { }, Spec: gateway.TCPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), }}, }, @@ -1079,7 +1078,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), Namespace: &gwNamespace, }}, @@ -1125,7 +1124,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { }, Spec: gateway.TCPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), Namespace: &gwNamespace, }}, @@ -1431,7 +1430,7 @@ func TestRouteParentRefChange(t *testing.T) { }, Spec: gateway.HTTPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(firstGatewayName), }}, }, @@ -1492,7 +1491,7 @@ func TestRouteParentRefChange(t *testing.T) { // Update httpRoute from remote, then add second gateway ParentRef require.NoError(t, resources.Get(ctx, httpRouteName, namespace, httpRoute)) - httpRoute.Spec.CommonRouteSpec.ParentRefs = []gateway.ParentRef{ + httpRoute.Spec.CommonRouteSpec.ParentRefs = []gateway.ParentReference{ { Name: gateway.ObjectName(firstGatewayName), Namespace: &gwNamespace, @@ -1537,7 +1536,7 @@ func TestRouteParentRefChange(t *testing.T) { // Update httpRoute from remote, then remove first gateway ParentRef require.NoError(t, resources.Get(ctx, httpRouteName, namespace, httpRoute)) - httpRoute.Spec.CommonRouteSpec.ParentRefs = []gateway.ParentRef{{ + httpRoute.Spec.CommonRouteSpec.ParentRefs = []gateway.ParentReference{{ Name: gateway.ObjectName(secondGatewayName), Namespace: &gwNamespace, }} @@ -1591,7 +1590,7 @@ func gatewayStatusCheck(ctx context.Context, resources *resources.Resources, gat func deploymentReplicasSetAsExpected(ctx context.Context, resources *resources.Resources, gatewayName, namespace string, expectedReplicas int32) func() bool { return func() bool { - deployment := &appsv1.Deployment{} + deployment := &apps.Deployment{} if err := resources.Get(ctx, gatewayName, namespace, deployment); err != nil { return false } @@ -1862,7 +1861,7 @@ func createTCPRoute(ctx context.Context, t *testing.T, resources *resources.Reso }, Spec: gateway.TCPRouteSpec{ CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentRef{{ + ParentRefs: []gateway.ParentReference{{ Name: gateway.ObjectName(gatewayName), SectionName: &listenerName, }}, diff --git a/internal/k8s/gatewayclient/gatewayclient.go b/internal/k8s/gatewayclient/gatewayclient.go index 169670506..e3f0da95f 100644 --- a/internal/k8s/gatewayclient/gatewayclient.go +++ b/internal/k8s/gatewayclient/gatewayclient.go @@ -52,7 +52,7 @@ type Client interface { // relationships HasManagedDeployment(ctx context.Context, gw *gateway.Gateway) (bool, error) - IsManagedRoute(ctx context.Context, namespace string, parents []gateway.ParentRef) (bool, error) + IsManagedRoute(ctx context.Context, namespace string, parents []gateway.ParentReference) (bool, error) GetConfigForGatewayClassName(ctx context.Context, name string) (apigwv1alpha1.GatewayClassConfig, bool, error) DeploymentForGateway(ctx context.Context, gw *gateway.Gateway) (*apps.Deployment, error) SetControllerOwnership(owner, object client.Object) error @@ -480,7 +480,7 @@ func (g *gatewayClient) GetConfigForGatewayClassName(ctx context.Context, name s return apigwv1alpha1.GatewayClassConfig{}, true, nil } -func (g *gatewayClient) IsManagedRoute(ctx context.Context, namespace string, parents []gateway.ParentRef) (bool, error) { +func (g *gatewayClient) IsManagedRoute(ctx context.Context, namespace string, parents []gateway.ParentReference) (bool, error) { // we look up a list of deployments that are managed by us, and try and check our references based on them. list := &apps.DeploymentList{} if err := g.Client.List(ctx, list, client.MatchingLabels(map[string]string{ diff --git a/internal/k8s/gatewayclient/mocks/gatewayclient.go b/internal/k8s/gatewayclient/mocks/gatewayclient.go index 10b22cf3d..b76f6e06f 100644 --- a/internal/k8s/gatewayclient/mocks/gatewayclient.go +++ b/internal/k8s/gatewayclient/mocks/gatewayclient.go @@ -425,7 +425,7 @@ func (mr *MockClientMockRecorder) HasManagedDeployment(ctx, gw interface{}) *gom } // IsManagedRoute mocks base method. -func (m *MockClient) IsManagedRoute(ctx context.Context, namespace string, parents []v1alpha2.ParentRef) (bool, error) { +func (m *MockClient) IsManagedRoute(ctx context.Context, namespace string, parents []v1alpha2.ParentReference) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsManagedRoute", ctx, namespace, parents) ret0, _ := ret[0].(bool) diff --git a/internal/k8s/reconciler/gateway_test.go b/internal/k8s/reconciler/gateway_test.go index 606e0a5fe..b6d33e028 100644 --- a/internal/k8s/reconciler/gateway_test.go +++ b/internal/k8s/reconciler/gateway_test.go @@ -14,12 +14,13 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + "github.com/hashicorp/go-hclog" + internalCore "github.com/hashicorp/consul-api-gateway/internal/core" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient/mocks" "github.com/hashicorp/consul-api-gateway/internal/k8s/service" storeMocks "github.com/hashicorp/consul-api-gateway/internal/store/mocks" apigwv1alpha1 "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" - "github.com/hashicorp/go-hclog" ) func TestGatewayValidate(t *testing.T) { @@ -629,7 +630,7 @@ func TestGatewayShouldBind(t *testing.T) { require.True(t, gateway.ShouldBind(NewK8sRoute(&gw.HTTPRoute{ Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "name", }}, }, diff --git a/internal/k8s/reconciler/listener.go b/internal/k8s/reconciler/listener.go index 5568596b5..83db72e39 100644 --- a/internal/k8s/reconciler/listener.go +++ b/internal/k8s/reconciler/listener.go @@ -351,7 +351,7 @@ func (l *K8sListener) CanBind(ctx context.Context, route store.Route) (bool, err return false, nil } -func (l *K8sListener) canBind(ctx context.Context, ref gw.ParentRef, route *K8sRoute) (bool, error) { +func (l *K8sListener) canBind(ctx context.Context, ref gw.ParentReference, route *K8sRoute) (bool, error) { if l.status.Ready.HasError() { l.logger.Trace("listener not ready, unable to bind", "route", route.ID()) return false, nil diff --git a/internal/k8s/reconciler/listener_test.go b/internal/k8s/reconciler/listener_test.go index 8cb85d0ef..5b60ae37f 100644 --- a/internal/k8s/reconciler/listener_test.go +++ b/internal/k8s/reconciler/listener_test.go @@ -493,7 +493,7 @@ func TestListenerCanBind(t *testing.T) { canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", }}, }, @@ -516,7 +516,7 @@ func TestListenerCanBind(t *testing.T) { canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", }}, }, @@ -553,7 +553,7 @@ func TestListenerCanBind_RouteKind(t *testing.T) { TypeMeta: routeMeta, Spec: gw.UDPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", }}, }, @@ -579,7 +579,7 @@ func TestListenerCanBind_RouteKind(t *testing.T) { TypeMeta: routeMeta, Spec: gw.UDPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", SectionName: &name, }}, @@ -626,7 +626,7 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { TypeMeta: routeMeta, Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", Namespace: &other, SectionName: &name, @@ -641,7 +641,7 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { TypeMeta: routeMeta, Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", Namespace: &other, }}, @@ -680,7 +680,7 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { TypeMeta: routeMeta, Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", Namespace: &other, SectionName: &name, @@ -695,7 +695,7 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { TypeMeta: routeMeta, Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", Namespace: &other, }}, @@ -734,7 +734,7 @@ func TestListenerCanBind_HostnameMatch(t *testing.T) { TypeMeta: routeMeta, Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", SectionName: &name, }}, @@ -750,7 +750,7 @@ func TestListenerCanBind_HostnameMatch(t *testing.T) { TypeMeta: routeMeta, Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", }}, }, @@ -781,7 +781,7 @@ func TestListenerCanBind_NameMatch(t *testing.T) { canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", SectionName: &otherName, }}, diff --git a/internal/k8s/reconciler/manager.go b/internal/k8s/reconciler/manager.go index ed3c912c9..3ffa99da9 100644 --- a/internal/k8s/reconciler/manager.go +++ b/internal/k8s/reconciler/manager.go @@ -280,7 +280,7 @@ func (m *GatewayReconcileManager) deleteUnmanagedRoute(ctx context.Context, rout return true, nil } -func (m *GatewayReconcileManager) managedByCachedGatewaysForRoute(namespace string, parents []gw.ParentRef) bool { +func (m *GatewayReconcileManager) managedByCachedGatewaysForRoute(namespace string, parents []gw.ParentReference) bool { for _, parent := range parents { name, isGateway := utils.ReferencesGateway(namespace, parent) if isGateway { diff --git a/internal/k8s/reconciler/manager_test.go b/internal/k8s/reconciler/manager_test.go index bef8e547f..cfcb5087c 100644 --- a/internal/k8s/reconciler/manager_test.go +++ b/internal/k8s/reconciler/manager_test.go @@ -10,10 +10,11 @@ import ( "k8s.io/apimachinery/pkg/types" gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient/mocks" storeMocks "github.com/hashicorp/consul-api-gateway/internal/store/mocks" apigwv1alpha1 "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" - "github.com/hashicorp/go-hclog" ) func testNamespaceMapper(namespace string) string { @@ -128,7 +129,7 @@ func TestUpsertHTTPRoute(t *testing.T) { require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{ Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "gateway", }}, }, diff --git a/internal/k8s/reconciler/route.go b/internal/k8s/reconciler/route.go index 801533592..89faddc92 100644 --- a/internal/k8s/reconciler/route.go +++ b/internal/k8s/reconciler/route.go @@ -344,7 +344,7 @@ func (r *K8sRoute) Resolve(listener store.Listener) *core.ResolvedRoute { } } -func (r *K8sRoute) Parents() []gw.ParentRef { +func (r *K8sRoute) Parents() []gw.ParentReference { // filter for this controller switch route := r.Route.(type) { case *gw.HTTPRoute: diff --git a/internal/k8s/reconciler/route_test.go b/internal/k8s/reconciler/route_test.go index 5c0d54a42..c50bd79a9 100644 --- a/internal/k8s/reconciler/route_test.go +++ b/internal/k8s/reconciler/route_test.go @@ -57,7 +57,7 @@ func TestRouteCommonRouteSpec(t *testing.T) { } expected := gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "expected", }}, } @@ -91,7 +91,7 @@ func TestRouteFilterParentStatuses(t *testing.T) { route := NewK8sRoute(&gw.HTTPRoute{ Spec: gw.HTTPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "expected", }, { Name: "other", @@ -101,17 +101,17 @@ func TestRouteFilterParentStatuses(t *testing.T) { Status: gw.HTTPRouteStatus{ RouteStatus: gw.RouteStatus{ Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "other", }, ControllerName: "other", @@ -152,7 +152,7 @@ func TestRouteMergedStatusAndBinding(t *testing.T) { inner := &gw.TLSRoute{ Spec: gw.TLSRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "expected", }, { Name: "other", @@ -162,17 +162,17 @@ func TestRouteMergedStatusAndBinding(t *testing.T) { Status: gw.TLSRouteStatus{ RouteStatus: gw.RouteStatus{ Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "other", }, ControllerName: "other", @@ -304,7 +304,7 @@ func TestRouteNeedsStatusUpdate(t *testing.T) { route := NewK8sRoute(&gw.TCPRoute{ Spec: gw.TCPRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "expected", }, { Name: "other", @@ -314,17 +314,17 @@ func TestRouteNeedsStatusUpdate(t *testing.T) { Status: gw.TCPRouteStatus{ RouteStatus: gw.RouteStatus{ Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "other", }, ControllerName: "other", @@ -363,7 +363,7 @@ func TestRouteSetStatus(t *testing.T) { expected := gw.RouteStatus{ Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, }}, @@ -406,7 +406,7 @@ func TestRouteParents(t *testing.T) { } expected := gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "expected", }}, } @@ -741,7 +741,7 @@ func TestRouteSyncStatus(t *testing.T) { inner := &gw.TLSRoute{ Spec: gw.TLSRouteSpec{ CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentRef{{ + ParentRefs: []gw.ParentReference{{ Name: "expected", }, { Name: "other", @@ -751,17 +751,17 @@ func TestRouteSyncStatus(t *testing.T) { Status: gw.TLSRouteStatus{ RouteStatus: gw.RouteStatus{ Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "other", }, ControllerName: "other", diff --git a/internal/k8s/reconciler/utils.go b/internal/k8s/reconciler/utils.go index cbfe97ff3..f5a863d43 100644 --- a/internal/k8s/reconciler/utils.go +++ b/internal/k8s/reconciler/utils.go @@ -273,8 +273,8 @@ func asJSON(item interface{}) string { return string(data) } -func parseParent(stringified string) gw.ParentRef { - var ref gw.ParentRef +func parseParent(stringified string) gw.ParentReference { + var ref gw.ParentReference if err := json.Unmarshal([]byte(stringified), &ref); err != nil { // everything passed to this internally should be // deserializable, if something is passed to it that diff --git a/internal/k8s/reconciler/utils_test.go b/internal/k8s/reconciler/utils_test.go index a771cb31a..a7e0a25d4 100644 --- a/internal/k8s/reconciler/utils_test.go +++ b/internal/k8s/reconciler/utils_test.go @@ -345,7 +345,7 @@ func TestParentStatusEqual(t *testing.T) { ControllerName: "other", })) require.False(t, parentStatusEqual(gw.RouteParentStatus{}, gw.RouteParentStatus{ - ParentRef: gw.ParentRef{ + ParentRef: gw.ParentReference{ Name: "other", }, })) diff --git a/internal/k8s/utils/reference.go b/internal/k8s/utils/reference.go index 3eb5d6c85..3fe764755 100644 --- a/internal/k8s/utils/reference.go +++ b/internal/k8s/utils/reference.go @@ -10,7 +10,7 @@ var ( gatewayKind = gw.Kind("Gateway") ) -func ReferencesGateway(namespace string, ref gw.ParentRef) (types.NamespacedName, bool) { +func ReferencesGateway(namespace string, ref gw.ParentReference) (types.NamespacedName, bool) { if ref.Group != nil && *ref.Group != gatewayGroup { return types.NamespacedName{}, false } From 19578a0dea874a79702069bb26d156ab445c390b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Jun 2022 12:11:01 -0400 Subject: [PATCH 03/17] k8s: update Handler->ProbeHandler for compat with v0.23+ --- internal/k8s/builder/gateway.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/k8s/builder/gateway.go b/internal/k8s/builder/gateway.go index c0f87fb81..8e9fe63a6 100644 --- a/internal/k8s/builder/gateway.go +++ b/internal/k8s/builder/gateway.go @@ -247,7 +247,7 @@ func (b *GatewayDeploymentBuilder) podSpec() corev1.PodSpec { }, Command: b.execCommand(), ReadinessProbe: &corev1.Probe{ - Handler: corev1.Handler{ + ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/ready", Port: intstr.FromInt(20000), From 5caf5c84ed411b34b78279da9796c02fb2dbc221 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Jun 2022 12:14:27 -0400 Subject: [PATCH 04/17] k8s/reconciler: deref for l.listener.TLS.CertificateRefs no longer needed --- internal/k8s/reconciler/listener.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/k8s/reconciler/listener.go b/internal/k8s/reconciler/listener.go index 83db72e39..c06fab504 100644 --- a/internal/k8s/reconciler/listener.go +++ b/internal/k8s/reconciler/listener.go @@ -120,7 +120,7 @@ func (l *K8sListener) validateTLS(ctx context.Context) error { } // we only support a single certificate for now - ref := *l.listener.TLS.CertificateRefs[0] + ref := l.listener.TLS.CertificateRefs[0] // require ReferencePolicy for cross-namespace certificateRef allowed, err := gatewayAllowedForSecretRef(ctx, l.gateway, ref, l.client) From 62e08a3f15391a46480ff2c73259683764ed92cf Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Jun 2022 13:36:19 -0400 Subject: [PATCH 05/17] k8s/logger: reimplement k8s logger as LogSink --- internal/k8s/logger.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/internal/k8s/logger.go b/internal/k8s/logger.go index 4b82fb14b..061ddd0e5 100644 --- a/internal/k8s/logger.go +++ b/internal/k8s/logger.go @@ -7,30 +7,38 @@ import ( ) func fromHCLogger(log hclog.Logger) logr.Logger { - return &logger{log} + return logr.New(&logger{log}) } +// logger is a LogSink that wraps hclog type logger struct { hclog.Logger } -func (l *logger) Enabled() bool { +// Verify that it actually implements the interface +var _ logr.LogSink = logger{} + +func (l logger) Init(logr.RuntimeInfo) { +} + +func (l logger) Enabled(_ int) bool { return true } -func (l *logger) Error(err error, msg string, keysAndValues ...interface{}) { - keysAndValues = append([]interface{}{"error", err}, keysAndValues...) - l.Logger.Error(msg, keysAndValues...) +func (l logger) Info(_ int, msg string, keysAndValues ...interface{}) { + keysAndValues = append([]interface{}{"info", msg}, keysAndValues...) + l.Logger.Info(msg, keysAndValues...) } -func (l *logger) V(_ int) logr.Logger { - return l +func (l logger) Error(err error, msg string, keysAndValues ...interface{}) { + keysAndValues = append([]interface{}{"error", err}, keysAndValues...) + l.Logger.Error(msg, keysAndValues...) } -func (l *logger) WithValues(keysAndValues ...interface{}) logr.Logger { +func (l logger) WithValues(keysAndValues ...interface{}) logr.LogSink { return &logger{l.With(keysAndValues...)} } -func (l *logger) WithName(name string) logr.Logger { +func (l logger) WithName(name string) logr.LogSink { return &logger{l.Named(name)} } From 171e10e122e2d816cd59e95f4065d19f8f0c63c9 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Jun 2022 14:00:18 -0400 Subject: [PATCH 06/17] gateway-api: update CertificateRefs to []SecretObjectReference from pointer --- internal/commands/server/k8s_e2e_test.go | 10 +++++----- internal/k8s/reconciler/gateway_test.go | 4 ++-- internal/k8s/reconciler/listener_test.go | 22 +++++++++++----------- internal/k8s/reconciler/utils_test.go | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/commands/server/k8s_e2e_test.go b/internal/commands/server/k8s_e2e_test.go index 43da56cc6..3eaff0d6c 100644 --- a/internal/commands/server/k8s_e2e_test.go +++ b/internal/commands/server/k8s_e2e_test.go @@ -908,7 +908,7 @@ func TestTCPMeshService(t *testing.T) { Port: gateway.PortNumber(listenerOnePort), Protocol: gateway.TCPProtocolType, TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []*gateway.SecretObjectReference{{ + CertificateRefs: []gateway.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gatewayNamespace, }}, @@ -919,7 +919,7 @@ func TestTCPMeshService(t *testing.T) { Port: gateway.PortNumber(listenerTwoPort), Protocol: gateway.TCPProtocolType, TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []*gateway.SecretObjectReference{{ + CertificateRefs: []gateway.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gatewayNamespace, }}, @@ -1014,7 +1014,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { Port: gateway.PortNumber(httpCheckPort), Protocol: gateway.HTTPSProtocolType, TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []*gateway.SecretObjectReference{{ + CertificateRefs: []gateway.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gwNamespace, }}, @@ -1317,7 +1317,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { Port: gateway.PortNumber(e2e.HTTPReferencePolicyPort(ctx)), Protocol: gateway.HTTPSProtocolType, TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []*gateway.SecretObjectReference{{ + CertificateRefs: []gateway.SecretObjectReference{{ Name: gateway.ObjectName(certName), Namespace: &certNamespaceTyped, }}, @@ -1737,7 +1737,7 @@ func createHTTPSListener(ctx context.Context, t *testing.T, port gateway.PortNum Port: port, Protocol: gateway.HTTPSProtocolType, TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []*gateway.SecretObjectReference{{ + CertificateRefs: []gateway.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gatewayNamespace, }}, diff --git a/internal/k8s/reconciler/gateway_test.go b/internal/k8s/reconciler/gateway_test.go index b6d33e028..093b7d8f5 100644 --- a/internal/k8s/reconciler/gateway_test.go +++ b/internal/k8s/reconciler/gateway_test.go @@ -37,7 +37,7 @@ func TestGatewayValidate(t *testing.T) { Hostname: &hostname, Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{}}, + CertificateRefs: []gw.SecretObjectReference{{}}, }, }}, }, @@ -82,7 +82,7 @@ func TestGatewayValidateGatewayIP(t *testing.T) { Hostname: &hostname, Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{}}, + CertificateRefs: []gw.SecretObjectReference{{}}, }, }}, }, diff --git a/internal/k8s/reconciler/listener_test.go b/internal/k8s/reconciler/listener_test.go index 5b60ae37f..53d0b8507 100644 --- a/internal/k8s/reconciler/listener_test.go +++ b/internal/k8s/reconciler/listener_test.go @@ -126,7 +126,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, }, @@ -142,7 +142,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, }, @@ -161,7 +161,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Namespace: &otherNamespace, Name: "secret", }}, @@ -186,7 +186,7 @@ func TestListenerValidate(t *testing.T) { gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Namespace: &secretNamespace, Name: "secret", }}, @@ -222,7 +222,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, }, @@ -246,7 +246,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Group: &group, Kind: &kind, Name: "secret", @@ -265,7 +265,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, Options: map[gw.AnnotationKey]gw.AnnotationValue{ @@ -291,7 +291,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, Options: map[gw.AnnotationKey]gw.AnnotationValue{ @@ -317,7 +317,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, Options: map[gw.AnnotationKey]gw.AnnotationValue{ @@ -343,7 +343,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, Options: map[gw.AnnotationKey]gw.AnnotationValue{ @@ -370,7 +370,7 @@ func TestListenerValidate(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Name: "secret", }}, Options: map[gw.AnnotationKey]gw.AnnotationValue{ diff --git a/internal/k8s/reconciler/utils_test.go b/internal/k8s/reconciler/utils_test.go index a7e0a25d4..aa04edc71 100644 --- a/internal/k8s/reconciler/utils_test.go +++ b/internal/k8s/reconciler/utils_test.go @@ -415,7 +415,7 @@ func TestGatewayAllowedForSecretRef(t *testing.T) { Spec: gw.GatewaySpec{ Listeners: []gw.Listener{{ TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []*gw.SecretObjectReference{{ + CertificateRefs: []gw.SecretObjectReference{{ Group: &group, Name: gw.ObjectName(tc.toName), }}, From 25c3fbc8bdcceabbf21da619253c4db9a8b8ca65 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 1 Jun 2022 15:34:02 -0400 Subject: [PATCH 07/17] e2e: update readCRDs signature to return []*api.CustomResourceDefinition to match envtest requirements --- internal/testing/e2e/gateway.go | 4 ++-- internal/testing/e2e/kubernetes.go | 5 ++--- internal/testing/e2e/kustomize.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/testing/e2e/gateway.go b/internal/testing/e2e/gateway.go index 9185ebc0a..e30489954 100644 --- a/internal/testing/e2e/gateway.go +++ b/internal/testing/e2e/gateway.go @@ -9,8 +9,8 @@ import ( "time" "golang.org/x/sync/errgroup" + api "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/e2e-framework/pkg/env" "sigs.k8s.io/e2e-framework/pkg/envconf" @@ -159,7 +159,7 @@ func DestroyTestGatewayServer(ctx context.Context, cfg *envconf.Config) (context func InstallConsulAPIGatewayCRDs(ctx context.Context, cfg *envconf.Config) (context.Context, error) { directory := path.Join("..", "..", "..", "config", "crd", "bases") entries, err := os.ReadDir(directory) - crds := []client.Object{} + crds := []*api.CustomResourceDefinition{} if err != nil { return nil, err } diff --git a/internal/testing/e2e/kubernetes.go b/internal/testing/e2e/kubernetes.go index 581abeeec..bc6bd4b68 100644 --- a/internal/testing/e2e/kubernetes.go +++ b/internal/testing/e2e/kubernetes.go @@ -17,7 +17,6 @@ import ( "k8s.io/apimachinery/pkg/util/yaml" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/e2e-framework/klient" "sigs.k8s.io/e2e-framework/pkg/env" @@ -226,9 +225,9 @@ func serviceClusterRoleAuthBinding(namespace, accountName string) *rbac.ClusterR } } -func readCRDs(data []byte) ([]client.Object, error) { +func readCRDs(data []byte) ([]*api.CustomResourceDefinition, error) { decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(data), len(data)) - crds := []client.Object{} + crds := []*api.CustomResourceDefinition{} for { crd := &api.CustomResourceDefinition{} err := decoder.Decode(crd) diff --git a/internal/testing/e2e/kustomize.go b/internal/testing/e2e/kustomize.go index 2d4b22b4d..cf312eed0 100644 --- a/internal/testing/e2e/kustomize.go +++ b/internal/testing/e2e/kustomize.go @@ -6,10 +6,10 @@ import ( "os/exec" "time" - "sigs.k8s.io/controller-runtime/pkg/client" + api "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) -func kubectlKustomizeCRDs(ctx context.Context, url string) ([]client.Object, error) { +func kubectlKustomizeCRDs(ctx context.Context, url string) ([]*api.CustomResourceDefinition, error) { var stdout, stderr bytes.Buffer timeoutContext, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() From 511ab58c8ad1ab87b64d5407cc88a6a25b15a67a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Jun 2022 14:13:37 -0400 Subject: [PATCH 08/17] gateway-api: update ReferencePolicy -> ReferenceGrant k8s/controllers: minor refactor and mocking up future ReferencePolicy support for backwards compatibility k8s/gatewayclient: regenerate mocks after ReferenceGrant rename docs: update supported-features.md for ReferenceGrant k8s/controller: update http and tcp route controller tests for ReferenceGrant k8s/reconciler: update listener test for ReferenceGrant k8s/reconciler: update route test for ReferenceGrant e2e: update ReferencePolicy -> ReferenceGrant k8s/reconciler: update utils test for ReferenceGrant k8s/reconciler: update statuses for ReferenceGrant rbac: add gateway controller permissions to read ReferenceGrants --- config/rbac/role.yaml | 8 ++ dev/docs/supported-features.md | 5 +- internal/commands/server/k8s_e2e_test.go | 88 ++++++------- .../k8s/controllers/gateway_controller.go | 35 +++-- .../k8s/controllers/http_route_controller.go | 39 ++++-- .../controllers/http_route_controller_test.go | 106 ++++++++++++++-- .../k8s/controllers/tcp_route_controller.go | 33 +++-- .../controllers/tcp_route_controller_test.go | 106 ++++++++++++++-- internal/k8s/gatewayclient/gatewayclient.go | 38 +++++- .../k8s/gatewayclient/mocks/gatewayclient.go | 14 +- internal/k8s/reconciler/config/statuses.yaml | 4 +- internal/k8s/reconciler/listener.go | 6 +- internal/k8s/reconciler/listener_test.go | 18 +-- internal/k8s/reconciler/route.go | 8 +- internal/k8s/reconciler/route_test.go | 30 ++--- internal/k8s/reconciler/utils.go | 26 ++-- internal/k8s/reconciler/utils_test.go | 120 +++++++++--------- .../k8s/reconciler/zz_generated_status.go | 8 +- internal/testing/e2e/consul.go | 20 +-- internal/testing/e2e/kind.go | 24 ++-- internal/testing/e2e/kubernetes.go | 1 + 21 files changed, 498 insertions(+), 239 deletions(-) diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 331ed7717..721f517a7 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -195,6 +195,14 @@ rules: - get - patch - update +- apiGroups: + - gateway.networking.k8s.io + resources: + - referencegrants + verbs: + - get + - list + - watch - apiGroups: - gateway.networking.k8s.io resources: diff --git a/dev/docs/supported-features.md b/dev/docs/supported-features.md index 89a10c3d6..ea9a0f965 100644 --- a/dev/docs/supported-features.md +++ b/dev/docs/supported-features.md @@ -125,12 +125,12 @@ Supported features are marked with a grey checkbox - [x] *ResolvedRefs* indicates that we were able to resolve all route references to things like Kubernetes/Consul services - [x] *ServiceNotFound* weren't able to find the referenced Kubernetes service - [x] *ConsulServiceNotFound* weren't able to find the referenced Consul mesh service - - [x] *RefNotPermitted* weren't able to route across namespaces due to a missing ReferencePolicy + - [x] *RefNotPermitted* weren't able to route across namespaces due to a missing ReferenceGrant - [x] TCPRoute - we are limited by Consul's ability to only route to a single TCP-based upstream, so TCP-based Gateway listeners only support a single TCPRoute with a single rule with a single backend; otherwise, either the TCPRoute is considered invalid or the Gateway status is set as having conflicting routes. - [ ] TLSRoute - TODO - [x] UDPRoute *not supported* -- [x] ReferencePolicy - Routes currently require ReferencePolicies for all BackendRefs, and do not support partial acceptance if any BackendRefs are unpermitted +- [x] ReferenceGrant - Routes currently require ReferenceGrant for all BackendRefs, and do not support partial acceptance if any BackendRefs are unpermitted - [x] From - [x] HTTPRoute - [x] TCPRoute @@ -140,3 +140,4 @@ Supported features are marked with a grey checkbox - [x] To - [x] Service - [x] Secret +- [x] ReferencePolicy - Supported for backwards compatibility, will be removed in a future release diff --git a/internal/commands/server/k8s_e2e_test.go b/internal/commands/server/k8s_e2e_test.go index 3eaff0d6c..efbdcec78 100644 --- a/internal/commands/server/k8s_e2e_test.go +++ b/internal/commands/server/k8s_e2e_test.go @@ -978,9 +978,9 @@ func TestTCPMeshService(t *testing.T) { testenv.Test(t, feature.Feature()) } -func TestReferencePolicyLifecycle(t *testing.T) { - feature := features.New("reference policy"). - Assess("route controllers watch reference policy changes", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { +func TestReferenceGrantLifecycle(t *testing.T) { + feature := features.New("reference grant"). + Assess("route controllers watch reference grant changes", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { serviceOne, err := e2e.DeployHTTPMeshService(ctx, cfg) require.NoError(t, err) serviceTwo, err := e2e.DeployTCPMeshService(ctx, cfg) @@ -990,21 +990,21 @@ func TestReferencePolicyLifecycle(t *testing.T) { gatewayName := envconf.RandomName("gw", 16) httpRouteName := envconf.RandomName("httproute", 16) httpRouteNamespace := envconf.RandomName("ns", 16) - httpRouteRefPolicyName := envconf.RandomName("refpolicy", 16) + httpRouteRefGrantName := envconf.RandomName("refgrant", 16) tcpRouteName := envconf.RandomName("tcproute", 16) tcpRouteNamespace := envconf.RandomName("ns", 16) - tcpRouteRefPolicyName := envconf.RandomName("refpolicy", 16) + tcpRouteRefGrantName := envconf.RandomName("refgrant", 16) resources := cfg.Client().Resources(namespace) _, gc := createGatewayClass(ctx, t, resources) require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") - httpCheckPort := e2e.HTTPReferencePolicyPort(ctx) - tcpCheckPort := e2e.TCPReferencePolicyPort(ctx) + httpCheckPort := e2e.HTTPReferenceGrantPort(ctx) + tcpCheckPort := e2e.TCPReferenceGrantPort(ctx) // Allow routes to bind from a different namespace for testing - // cross-namespace ReferencePolicy enforcement + // cross-namespace ReferenceGrant enforcement fromSelector := gateway.NamespacesFromSelector gwNamespace := gateway.Namespace(namespace) @@ -1102,7 +1102,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { // Expect that HTTPRoute sets // ResolvedRefs{ status: False, reason: RefNotPermitted } - // due to missing ReferencePolicy for BackendRef in other namespace + // due to missing ReferenceGrant for BackendRef in other namespace httpRouteStatusCheckRefNotPermitted := httpRouteStatusCheck( ctx, resources, @@ -1143,32 +1143,32 @@ func TestReferencePolicyLifecycle(t *testing.T) { err = resources.Create(ctx, tcpRoute) require.NoError(t, err) - // create ReferencePolicy allowing HTTPRoute BackendRef + // create ReferenceGrant allowing HTTPRoute BackendRef serviceOneObjectName := gateway.ObjectName(serviceOne.Name) - httpRouteReferencePolicy := &gateway.ReferencePolicy{ + httpRouteReferenceGrant := &gateway.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{ - Name: httpRouteRefPolicyName, + Name: httpRouteRefGrantName, Namespace: namespace, }, - Spec: gateway.ReferencePolicySpec{ - From: []gateway.ReferencePolicyFrom{{ + Spec: gateway.ReferenceGrantSpec{ + From: []gateway.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "HTTPRoute", Namespace: gateway.Namespace(httpRouteNamespace), }}, - To: []gateway.ReferencePolicyTo{{ + To: []gateway.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: &serviceOneObjectName, }}, }, } - err = resources.Create(ctx, httpRouteReferencePolicy) + err = resources.Create(ctx, httpRouteReferenceGrant) require.NoError(t, err) // Expect that HTTPRoute sets // ResolvedRefs{ status: True, reason: ResolvedRefs } - // now that ReferencePolicy allows BackendRef in other namespace + // now that ReferenceGrant allows BackendRef in other namespace require.Eventually(t, httpRouteStatusCheck( ctx, resources, @@ -1191,7 +1191,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { // Expect that TCPRoute still sets // ResolvedRefs{ status: False, reason: RefNotPermitted } - // due to missing ReferencePolicy for BackendRef in other namespace + // due to missing ReferenceGrant for BackendRef in other namespace tcpRouteStatusCheckRefNotPermitted := tcpRouteStatusCheck( ctx, resources, @@ -1205,32 +1205,32 @@ func TestReferencePolicyLifecycle(t *testing.T) { ) require.Eventually(t, tcpRouteStatusCheckRefNotPermitted, checkTimeout, checkInterval, "TCPRoute status not set in allotted time") - // create ReferencePolicy allowing TCPRoute BackendRef + // create ReferenceGrant allowing TCPRoute BackendRef serviceTwoObjectName := gateway.ObjectName(serviceTwo.Name) - tcpRouteReferencePolicy := &gateway.ReferencePolicy{ + tcpRouteReferenceGrant := &gateway.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{ - Name: tcpRouteRefPolicyName, + Name: tcpRouteRefGrantName, Namespace: namespace, }, - Spec: gateway.ReferencePolicySpec{ - From: []gateway.ReferencePolicyFrom{{ + Spec: gateway.ReferenceGrantSpec{ + From: []gateway.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "TCPRoute", Namespace: gateway.Namespace(tcpRouteNamespace), }}, - To: []gateway.ReferencePolicyTo{{ + To: []gateway.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: &serviceTwoObjectName, }}, }, } - err = resources.Create(ctx, tcpRouteReferencePolicy) + err = resources.Create(ctx, tcpRouteReferenceGrant) require.NoError(t, err) // Expect that TCPRoute sets // ResolvedRefs{ status: True, reason: ResolvedRefs } - // now that ReferencePolicy allows BackendRef in other namespace + // now that ReferenceGrant allows BackendRef in other namespace require.Eventually(t, tcpRouteStatusCheck( ctx, resources, @@ -1246,9 +1246,9 @@ func TestReferencePolicyLifecycle(t *testing.T) { // Check that TCPRoute is successfully resolved and routing traffic checkTCPRoute(t, tcpCheckPort, serviceTwo.Name, false, "service two not routable in allotted time") - // Delete TCPRoute ReferencePolicy, check for RefNotPermitted again + // Delete TCPRoute ReferenceGrant, check for RefNotPermitted again // Check that Gateway has cleaned up stale route and is no longer routing traffic - err = resources.Delete(ctx, tcpRouteReferencePolicy) + err = resources.Delete(ctx, tcpRouteReferenceGrant) require.NoError(t, err) require.Eventually(t, tcpRouteStatusCheckRefNotPermitted, checkTimeout, checkInterval, "TCPRoute status not set in allotted time") require.Eventually(t, listenerStatusCheck( @@ -1262,9 +1262,9 @@ func TestReferencePolicyLifecycle(t *testing.T) { // [WARN] [core]grpc: Server.Serve failed to complete security handshake: remote error: tls: unknown certificate authority checkTCPRoute(t, tcpCheckPort, "", true, "service two still routable in allotted time") - // Delete HTTPRoute ReferencePolicy, check for RefNotPermitted again + // Delete HTTPRoute ReferenceGrant, check for RefNotPermitted again // Check that Gateway has cleaned up stale route and is no longer routing traffic - err = resources.Delete(ctx, httpRouteReferencePolicy) + err = resources.Delete(ctx, httpRouteReferenceGrant) require.NoError(t, err) require.Eventually(t, httpRouteStatusCheckRefNotPermitted, checkTimeout, checkInterval, "HTTPRoute status not set in allotted time") require.Eventually(t, listenerStatusCheck( @@ -1285,13 +1285,13 @@ func TestReferencePolicyLifecycle(t *testing.T) { return ctx }). - Assess("gateway controller watches reference policy changes", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { + Assess("gateway controller watches reference grant changes", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { namespace := e2e.Namespace(ctx) gatewayNamespace := namespace gatewayName := envconf.RandomName("gw", 16) certNamespace := envconf.RandomName("ns", 16) certName := "consul-server-cert" - gatewayRefPolicyName := envconf.RandomName("refpolicy", 16) + gatewayRefGrantName := envconf.RandomName("refgrant", 16) resources := cfg.Client().Resources(namespace) @@ -1314,7 +1314,7 @@ func TestReferencePolicyLifecycle(t *testing.T) { gw := createGateway(ctx, t, resources, gatewayName, gatewayNamespace, gc, []gateway.Listener{ { Name: "https", - Port: gateway.PortNumber(e2e.HTTPReferencePolicyPort(ctx)), + Port: gateway.PortNumber(e2e.HTTPReferenceGrantPort(ctx)), Protocol: gateway.HTTPSProtocolType, TLS: &gateway.GatewayTLSConfig{ CertificateRefs: []gateway.SecretObjectReference{{ @@ -1331,37 +1331,37 @@ func TestReferencePolicyLifecycle(t *testing.T) { }) // Expect that Gateway has expected error condition - // due to missing ReferencePolicy for CertificateRef in other namespace + // due to missing ReferenceGrant for CertificateRef in other namespace gatewayConditionCheck := createConditionsCheck([]meta.Condition{{Type: "Ready", Status: "False", Reason: "ListenersNotValid"}}) gatewayCheck := gatewayStatusCheck(ctx, resources, gatewayName, gatewayNamespace, gatewayConditionCheck) require.Eventually(t, gatewayCheck, checkTimeout, checkInterval, "Gateway status not set in allotted time") // Expect that Gateway listener has expected error condition - // due to missing ReferencePolicy for CertificateRef in other namespace + // due to missing ReferenceGrant for CertificateRef in other namespace listenerConditionCheck := createListenerStatusConditionsCheck([]meta.Condition{{Type: "ResolvedRefs", Status: "False", Reason: "InvalidCertificateRef"}}) listenerCheck := listenerStatusCheck(ctx, resources, gatewayName, gatewayNamespace, listenerConditionCheck) require.Eventually(t, listenerCheck, checkTimeout, checkInterval, "Gateway listener status not set in allotted time") - // Create ReferencePolicy allowing Gateway CertificateRef - certReferencePolicy := &gateway.ReferencePolicy{ + // Create ReferenceGrant allowing Gateway CertificateRef + certReferenceGrant := &gateway.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{ - Name: gatewayRefPolicyName, + Name: gatewayRefGrantName, Namespace: string(certNamespace), }, - Spec: gateway.ReferencePolicySpec{ - From: []gateway.ReferencePolicyFrom{{ + Spec: gateway.ReferenceGrantSpec{ + From: []gateway.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "Gateway", Namespace: gateway.Namespace(gatewayNamespace), }}, - To: []gateway.ReferencePolicyTo{{ + To: []gateway.ReferenceGrantTo{{ Group: "", Kind: "Secret", Name: nil, }}, }, } - require.NoError(t, resources.Create(ctx, certReferencePolicy)) + require.NoError(t, resources.Create(ctx, certReferenceGrant)) // Expect that Gateway has expected success condition gatewayCheck = gatewayStatusCheck(ctx, resources, gatewayName, gatewayNamespace, conditionReady) @@ -1372,8 +1372,8 @@ func TestReferencePolicyLifecycle(t *testing.T) { listenerCheck = listenerStatusCheck(ctx, resources, gatewayName, gatewayNamespace, listenerConditionCheck) require.Eventually(t, listenerCheck, checkTimeout, checkInterval, "Gateway listener status not set in allotted time") - // Delete Gateway ReferencePolicy - require.NoError(t, resources.Delete(ctx, certReferencePolicy)) + // Delete Gateway ReferenceGrant + require.NoError(t, resources.Delete(ctx, certReferenceGrant)) // Check for error status conditions again gatewayConditionCheck = createConditionsCheck([]meta.Condition{{Type: "Ready", Status: "False", Reason: "ListenersNotValid"}}) diff --git a/internal/k8s/controllers/gateway_controller.go b/internal/k8s/controllers/gateway_controller.go index 0573c6626..962e57d7f 100644 --- a/internal/k8s/controllers/gateway_controller.go +++ b/internal/k8s/controllers/gateway_controller.go @@ -35,6 +35,7 @@ type GatewayReconciler struct { } //+kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gateways,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=referencegrants,verbs=get;list;watch //+kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=referencepolicies,verbs=get;list;watch //+kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gateways/status,verbs=get;update;patch @@ -95,9 +96,14 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { builder.WithPredicates(predicate), ). Watches( - &source.Kind{Type: &gateway.ReferencePolicy{}}, - handler.EnqueueRequestsFromMapFunc(r.referencePolicyToGatewayRequests), + &source.Kind{Type: &gateway.ReferenceGrant{}}, + handler.EnqueueRequestsFromMapFunc(r.referenceGrantToGatewayRequests), ). + // TODO: this can't be enabled until the ReferencePolicy object is restored + // Watches( + // &source.Kind{Type: &gateway.ReferencePolicy{}}, + // handler.EnqueueRequestsFromMapFunc(r.referencePolicyToGatewayRequests), + // ). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } @@ -115,10 +121,19 @@ func podToGatewayRequest(object client.Object) []reconcile.Request { return nil } -func (r *GatewayReconciler) referencePolicyToGatewayRequests(object client.Object) []reconcile.Request { - refPolicy := object.(*gateway.ReferencePolicy) +func (r *GatewayReconciler) referenceGrantToGatewayRequests(object client.Object) []reconcile.Request { + return r.getRequestsFromReferenceGrant(object.(*gateway.ReferenceGrant)) +} + +// TODO: this can't be enabled until the ReferencePolicy object is restored +// func (r *GatewayReconciler) referencePolicyToGatewayRequests(object client.Object) []reconcile.Request { +// refPolicy := object.(*gateway.ReferencePolicy) +// // TODO: Convert to ReferenceGrant +// return r.getRequestsFromReferenceGrant(refGrant) +// } - gateways := r.getGatewaysAffectedByReferencePolicy(refPolicy) +func (r *GatewayReconciler) getRequestsFromReferenceGrant(refGrant *gateway.ReferenceGrant) []reconcile.Request { + gateways := r.getGatewaysAffectedByReferenceGrant(refGrant) requests := make([]reconcile.Request, 0, len(gateways)) @@ -134,14 +149,14 @@ func (r *GatewayReconciler) referencePolicyToGatewayRequests(object client.Objec return requests } -// getGatewaysAffectedByReferencePolicy retrieves all Gateways potentially impacted by the ReferencePolicy +// getGatewaysAffectedByReferenceGrant retrieves all Gateways potentially impacted by the ReferenceGrant // modification. Currently, this is unfiltered and so returns all Gateways in the namespace referenced by -// the ReferencePolicy. -func (r *GatewayReconciler) getGatewaysAffectedByReferencePolicy(refPolicy *gateway.ReferencePolicy) []gateway.Gateway { +// the ReferenceGrant. +func (r *GatewayReconciler) getGatewaysAffectedByReferenceGrant(refGrant *gateway.ReferenceGrant) []gateway.Gateway { var matches []gateway.Gateway - for _, from := range refPolicy.Spec.From { - // TODO: search by from.Group and from.Kind instead of assuming this ReferencePolicy references a Gateway + for _, from := range refGrant.Spec.From { + // TODO: search by from.Group and from.Kind instead of assuming this ReferenceGrant references a Gateway gateways, err := r.Client.GetGatewaysInNamespace(r.Context, string(from.Namespace)) if err != nil { r.Log.Error("error fetching gateways", err) diff --git a/internal/k8s/controllers/http_route_controller.go b/internal/k8s/controllers/http_route_controller.go index cf2c3e4ad..3cf0c0899 100644 --- a/internal/k8s/controllers/http_route_controller.go +++ b/internal/k8s/controllers/http_route_controller.go @@ -61,26 +61,39 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&gateway.HTTPRoute{}). Watches( - &source.Kind{Type: &gateway.ReferencePolicy{}}, - handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), + &source.Kind{Type: &gateway.ReferenceGrant{}}, + handler.EnqueueRequestsFromMapFunc(r.referenceGrantToRouteRequests), ). + // Watches( + // &source.Kind{Type: &gateway.ReferencePolicy{}}, + // handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), + // ). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } +func (r *HTTPRouteReconciler) referenceGrantToRouteRequests(object client.Object) []reconcile.Request { + return r.getRouteRequestsFromReferenceGrant(object.(*gateway.ReferenceGrant)) +} + +// TODO: this can't be enabled until the ReferencePolicy object is restored +// func (r *HTTPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { +// refPolicy := object.(*gateway.ReferencePolicy) +// // TODO: Convert to ReferenceGrant +// return r.getRouteRequestsFromReferenceGrant(refGrant) +// } + // For UpdateEvents which contain both a new and old object, this transformation // function is run on both objects and both sets of Requests are enqueued. // // This is needed to reconcile any objects matched by both current and prior -// state in case a ReferencePolicy has been modified to revoke permission from a +// state in case a ReferenceGrant has been modified to revoke permission from a // namespace or to a service // // It may be possible to improve performance here by filtering Routes by // BackendRefs selectable by the To fields, but currently we just revalidate // all Routes allowed in the From Namespaces -func (r *HTTPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { - refPolicy := object.(*gateway.ReferencePolicy) - - routes := r.getRoutesAffectedByReferencePolicy(refPolicy) +func (r *HTTPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gateway.ReferenceGrant) []reconcile.Request { + routes := r.getRoutesAffectedByReferenceGrant(refGrant) requests := []reconcile.Request{} for _, route := range routes { @@ -95,14 +108,14 @@ func (r *HTTPRouteReconciler) referencePolicyToRouteRequests(object client.Objec return requests } -// getRoutesAffectedByReferencePolicy retrieves all HTTPRoutes potentially impacted -// by the ReferencePolicy being modified. Currently, this is unfiltered and so returns -// all HTTPRoutes in the namespace referenced by the ReferencePolicy. -func (r *HTTPRouteReconciler) getRoutesAffectedByReferencePolicy(refPolicy *gateway.ReferencePolicy) []gateway.HTTPRoute { +// getRoutesAffectedByReferenceGrant retrieves all HTTPRoutes potentially impacted +// by the ReferenceGrant being modified. Currently, this is unfiltered and so returns +// all HTTPRoutes in the namespace referenced by the ReferenceGrant. +func (r *HTTPRouteReconciler) getRoutesAffectedByReferenceGrant(refGrant *gateway.ReferenceGrant) []gateway.HTTPRoute { var matches []gateway.HTTPRoute - for _, from := range refPolicy.Spec.From { - // TODO: search by from.Group and from.Kind instead of assuming this ReferencePolicy references a HTTPRoute + for _, from := range refGrant.Spec.From { + // TODO: search by from.Group and from.Kind instead of assuming this ReferenceGrant references a HTTPRoute routes, err := r.Client.GetHTTPRoutesInNamespace(r.Context, string(from.Namespace)) if err != nil { r.Log.Error("error fetching routes", err) diff --git a/internal/k8s/controllers/http_route_controller_test.go b/internal/k8s/controllers/http_route_controller_test.go index 7ba54ee2d..d49722e9a 100644 --- a/internal/k8s/controllers/http_route_controller_test.go +++ b/internal/k8s/controllers/http_route_controller_test.go @@ -80,7 +80,7 @@ func TestHTTPRoute(t *testing.T) { } } -func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { +func TestHTTPRouteReferenceGrantToRouteRequests(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -111,16 +111,16 @@ func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { }}, } - refPolicy := gw.ReferencePolicy{ - TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, + refGrant := gw.ReferenceGrant{ + TypeMeta: metav1.TypeMeta{Kind: "ReferenceGrant"}, ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{ + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "HTTPRoute", Namespace: "namespace1", }}, - To: []gw.ReferencePolicyTo{{ + To: []gw.ReferenceGrantTo{{ Kind: "Service", }}, }, @@ -149,7 +149,7 @@ func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { }, Spec: tcpRouteSpec, }, - &refPolicy, + &refGrant, ) controller := &HTTPRouteReconciler{ @@ -159,7 +159,7 @@ func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { Manager: reconcilerMocks.NewMockReconcileManager(ctrl), } - requests := controller.referencePolicyToRouteRequests(&refPolicy) + requests := controller.referenceGrantToRouteRequests(&refGrant) require.Equal(t, []reconcile.Request{{ NamespacedName: types.NamespacedName{ @@ -168,3 +168,93 @@ func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { }, }}, requests) } + +// TODO: this can't be enabled until the ReferencePolicy object is restored +// func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { +// t.Parallel() + +// ctrl := gomock.NewController(t) +// defer ctrl.Finish() + +// serviceNamespace := gw.Namespace("namespace3") + +// backendObjRef := gw.BackendObjectReference{ +// Name: gw.ObjectName("service"), +// Namespace: &serviceNamespace, +// } + +// httpRouteSpec := gw.HTTPRouteSpec{ +// Rules: []gw.HTTPRouteRule{{ +// BackendRefs: []gw.HTTPBackendRef{{ +// BackendRef: gw.BackendRef{ +// BackendObjectReference: backendObjRef, +// }, +// }}, +// }}, +// } + +// tcpRouteSpec := gw.TCPRouteSpec{ +// Rules: []gw.TCPRouteRule{{ +// BackendRefs: []gw.BackendRef{{ +// BackendObjectReference: backendObjRef, +// }}, +// }}, +// } + +// refPolicy := gw.ReferencePolicy{ +// TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, +// ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, +// Spec: gw.ReferencePolicySpec{ +// From: []gw.ReferencePolicyFrom{{ +// Group: "gateway.networking.k8s.io", +// Kind: "HTTPRoute", +// Namespace: "namespace1", +// }}, +// To: []gw.ReferencePolicyTo{{ +// Kind: "Service", +// }}, +// }, +// } + +// client := gatewayclient.NewTestClient( +// nil, +// &gw.HTTPRoute{ +// ObjectMeta: metav1.ObjectMeta{ +// Name: "httproute", +// Namespace: "namespace1", +// }, +// Spec: httpRouteSpec, +// }, +// &gw.HTTPRoute{ +// ObjectMeta: metav1.ObjectMeta{ +// Name: "httproute", +// Namespace: "namespace2", +// }, +// Spec: httpRouteSpec, +// }, +// &gw.TCPRoute{ +// ObjectMeta: metav1.ObjectMeta{ +// Name: "tcproute", +// Namespace: "namespace1", +// }, +// Spec: tcpRouteSpec, +// }, +// &refPolicy, +// ) + +// controller := &HTTPRouteReconciler{ +// Client: client, +// Log: hclog.NewNullLogger(), +// ControllerName: mockControllerName, +// Manager: reconcilerMocks.NewMockReconcileManager(ctrl), +// } + +// requests := controller.referencePolicyToRouteRequests(&refPolicy) + +// require.Equal(t, []reconcile.Request{{ +// NamespacedName: types.NamespacedName{ +// Name: "httproute", +// Namespace: "namespace1", +// }, +// }}, requests) +// } diff --git a/internal/k8s/controllers/tcp_route_controller.go b/internal/k8s/controllers/tcp_route_controller.go index d3373a70e..26231b228 100644 --- a/internal/k8s/controllers/tcp_route_controller.go +++ b/internal/k8s/controllers/tcp_route_controller.go @@ -61,26 +61,39 @@ func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&gateway.TCPRoute{}). Watches( - &source.Kind{Type: &gateway.ReferencePolicy{}}, - handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), + &source.Kind{Type: &gateway.ReferenceGrant{}}, + handler.EnqueueRequestsFromMapFunc(r.referenceGrantToRouteRequests), ). + // Watches( + // &source.Kind{Type: &gateway.ReferencePolicy{}}, + // handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), + // ). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } +func (r *TCPRouteReconciler) referenceGrantToRouteRequests(object client.Object) []reconcile.Request { + return r.getRouteRequestsFromReferenceGrant(object.(*gateway.ReferenceGrant)) +} + +// TODO: this can't be enabled until the ReferencePolicy object is restored +// func (r *TCPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { +// refPolicy := object.(*gateway.ReferencePolicy) +// // TODO: Convert to ReferenceGrant +// return r.getRouteRequestsFromReferenceGrant(refGrant) +// } + // For UpdateEvents which contain both a new and old object, this transformation // function is run on both objects and both sets of Requests are enqueued. // // This is needed to reconcile any objects matched by both current and prior -// state in case a ReferencePolicy has been modified to revoke permission from a +// state in case a ReferenceGrant has been modified to revoke permission from a // namespace or to a service // // It may be possible to improve performance here by filtering Routes by // BackendRefs selectable by the To fields, but currently we just revalidate // all Routes allowed in the From Namespaces -func (r *TCPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { - refPolicy := object.(*gateway.ReferencePolicy) - - routes := r.getRoutesAffectedByReferencePolicy(refPolicy) +func (r *TCPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gateway.ReferenceGrant) []reconcile.Request { + routes := r.getRoutesAffectedByReferenceGrant(refGrant) requests := []reconcile.Request{} for _, route := range routes { @@ -98,11 +111,11 @@ func (r *TCPRouteReconciler) referencePolicyToRouteRequests(object client.Object // getRoutesAffectedByReferencePolicy retrieves all TCPRoutes potentially impacted // by the ReferencePolicy being modified. Currently, this is unfiltered and so returns // all TCPRoutes in the namespace referenced by the ReferencePolicy. -func (r *TCPRouteReconciler) getRoutesAffectedByReferencePolicy(refPolicy *gateway.ReferencePolicy) []gateway.TCPRoute { +func (r *TCPRouteReconciler) getRoutesAffectedByReferenceGrant(refGrant *gateway.ReferenceGrant) []gateway.TCPRoute { var matches []gateway.TCPRoute - for _, from := range refPolicy.Spec.From { - // TODO: search by from.Group and from.Kind instead of assuming this ReferencePolicy references a TCPRoute + for _, from := range refGrant.Spec.From { + // TODO: search by from.Group and from.Kind instead of assuming this ReferenceGrant references a TCPRoute routes, err := r.Client.GetTCPRoutesInNamespace(r.Context, string(from.Namespace)) if err != nil { r.Log.Error("error fetching routes", err) diff --git a/internal/k8s/controllers/tcp_route_controller_test.go b/internal/k8s/controllers/tcp_route_controller_test.go index 16a9ebb36..c5805b865 100644 --- a/internal/k8s/controllers/tcp_route_controller_test.go +++ b/internal/k8s/controllers/tcp_route_controller_test.go @@ -79,7 +79,7 @@ func TestTCPRoute(t *testing.T) { } } -func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { +func TestTCPRouteReferenceGrantToRouteRequests(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -110,16 +110,16 @@ func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { }}, } - refPolicy := gw.ReferencePolicy{ - TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, + refGrant := gw.ReferenceGrant{ + TypeMeta: metav1.TypeMeta{Kind: "ReferenceGrant"}, ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{ + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "TCPRoute", Namespace: "namespace1", }}, - To: []gw.ReferencePolicyTo{{ + To: []gw.ReferenceGrantTo{{ Kind: "Service", }}, }, @@ -148,7 +148,7 @@ func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { }, Spec: tcpRouteSpec, }, - &refPolicy, + &refGrant, ) controller := &TCPRouteReconciler{ @@ -158,7 +158,7 @@ func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { Manager: reconcilerMocks.NewMockReconcileManager(ctrl), } - requests := controller.referencePolicyToRouteRequests(&refPolicy) + requests := controller.referenceGrantToRouteRequests(&refGrant) require.Equal(t, []reconcile.Request{{ NamespacedName: types.NamespacedName{ @@ -167,3 +167,93 @@ func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { }, }}, requests) } + +// TODO: this can't be enabled until the ReferencePolicy object is restored +// func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { +// t.Parallel() + +// ctrl := gomock.NewController(t) +// defer ctrl.Finish() + +// serviceNamespace := gw.Namespace("namespace3") + +// backendObjRef := gw.BackendObjectReference{ +// Name: gw.ObjectName("service"), +// Namespace: &serviceNamespace, +// } + +// httpRouteSpec := gw.HTTPRouteSpec{ +// Rules: []gw.HTTPRouteRule{{ +// BackendRefs: []gw.HTTPBackendRef{{ +// BackendRef: gw.BackendRef{ +// BackendObjectReference: backendObjRef, +// }, +// }}, +// }}, +// } + +// tcpRouteSpec := gw.TCPRouteSpec{ +// Rules: []gw.TCPRouteRule{{ +// BackendRefs: []gw.BackendRef{{ +// BackendObjectReference: backendObjRef, +// }}, +// }}, +// } + +// refPolicy := gw.ReferencePolicy{ +// TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, +// ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, +// Spec: gw.ReferencePolicySpec{ +// From: []gw.ReferencePolicyFrom{{ +// Group: "gateway.networking.k8s.io", +// Kind: "TCPRoute", +// Namespace: "namespace1", +// }}, +// To: []gw.ReferencePolicyTo{{ +// Kind: "Service", +// }}, +// }, +// } + +// client := gatewayclient.NewTestClient( +// nil, +// &gw.HTTPRoute{ +// ObjectMeta: metav1.ObjectMeta{ +// Name: "httproute", +// Namespace: "namespace1", +// }, +// Spec: httpRouteSpec, +// }, +// &gw.TCPRoute{ +// ObjectMeta: metav1.ObjectMeta{ +// Name: "tcproute", +// Namespace: "namespace1", +// }, +// Spec: tcpRouteSpec, +// }, +// &gw.TCPRoute{ +// ObjectMeta: metav1.ObjectMeta{ +// Name: "tcproute", +// Namespace: "namespace2", +// }, +// Spec: tcpRouteSpec, +// }, +// &refPolicy, +// ) + +// controller := &TCPRouteReconciler{ +// Client: client, +// Log: hclog.NewNullLogger(), +// ControllerName: mockControllerName, +// Manager: reconcilerMocks.NewMockReconcileManager(ctrl), +// } + +// requests := controller.referencePolicyToRouteRequests(&refPolicy) + +// require.Equal(t, []reconcile.Request{{ +// NamespacedName: types.NamespacedName{ +// Name: "tcproute", +// Namespace: "namespace1", +// }, +// }}, requests) +// } diff --git a/internal/k8s/gatewayclient/gatewayclient.go b/internal/k8s/gatewayclient/gatewayclient.go index e3f0da95f..6b929ea7b 100644 --- a/internal/k8s/gatewayclient/gatewayclient.go +++ b/internal/k8s/gatewayclient/gatewayclient.go @@ -77,7 +77,7 @@ type Client interface { EnsureServiceAccount(ctx context.Context, owner *gateway.Gateway, serviceAccount *core.ServiceAccount) error //referencepolicy - GetReferencePoliciesInNamespace(ctx context.Context, namespace string) ([]gateway.ReferencePolicy, error) + GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]gateway.ReferenceGrant, error) } type gatewayClient struct { @@ -511,10 +511,38 @@ func (g *gatewayClient) HasManagedDeployment(ctx context.Context, gw *gateway.Ga return len(list.Items) > 0, nil } -func (g *gatewayClient) GetReferencePoliciesInNamespace(ctx context.Context, namespace string) ([]gateway.ReferencePolicy, error) { - list := &gateway.ReferencePolicyList{} - if err := g.Client.List(ctx, list, client.InNamespace(namespace)); err != nil { +func (g *gatewayClient) GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]gateway.ReferenceGrant, error) { + refGrantList := &gateway.ReferenceGrantList{} + if err := g.Client.List(ctx, refGrantList, client.InNamespace(namespace)); err != nil { return nil, NewK8sError(err) } - return list.Items, nil + refGrants := refGrantList.Items + + // TODO: this can't be enabled until the ReferencePolicy object is restored + // lookup ReferencePolicies here too for backwards compatibility, create + // ReferenceGrants from them and add to list + // refPolicyList := &gateway.ReferencePolicyList{} + // if err := g.Client.List(ctx, refPolicyList, client.InNamespace(namespace)); err != nil { + // return nil, NewK8sError(err) + // } + // for _, refPolicy := range refPolicyList { + // refGrant := gateway.ReferenceGrant{} + // for _, refPolicyFrom := range refPolicy.Spec.From { + // refGrant.Spec.From = append(refGrant.Spec.From, gateway.ReferenceGrantFrom{ + // Group: refPolicyFrom.Group, + // Kind: refPolicyFrom.Kind, + // Namespace: refPolicyFrom.Namespace, + // }) + // } + // for _, refPolicyTo := range refPolicy.Spec.To { + // refGrant.Spec.To = append(refGrant.Spec.To, gateway.ReferenceGrantTo{ + // Group: refPolicyTo.Group, + // Kind: refPolicyTo.Kind, + // Name: refPolicyTo.Name, + // }) + // } + // refGrants = append(refGrants, refGrant) + // } + + return refGrants, nil } diff --git a/internal/k8s/gatewayclient/mocks/gatewayclient.go b/internal/k8s/gatewayclient/mocks/gatewayclient.go index b76f6e06f..6538797c3 100644 --- a/internal/k8s/gatewayclient/mocks/gatewayclient.go +++ b/internal/k8s/gatewayclient/mocks/gatewayclient.go @@ -334,19 +334,19 @@ func (mr *MockClientMockRecorder) GetNamespace(ctx, key interface{}) *gomock.Cal return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNamespace", reflect.TypeOf((*MockClient)(nil).GetNamespace), ctx, key) } -// GetReferencePoliciesInNamespace mocks base method. -func (m *MockClient) GetReferencePoliciesInNamespace(ctx context.Context, namespace string) ([]v1alpha2.ReferencePolicy, error) { +// GetReferenceGrantsInNamespace mocks base method. +func (m *MockClient) GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]v1alpha2.ReferenceGrant, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetReferencePoliciesInNamespace", ctx, namespace) - ret0, _ := ret[0].([]v1alpha2.ReferencePolicy) + ret := m.ctrl.Call(m, "GetReferenceGrantsInNamespace", ctx, namespace) + ret0, _ := ret[0].([]v1alpha2.ReferenceGrant) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetReferencePoliciesInNamespace indicates an expected call of GetReferencePoliciesInNamespace. -func (mr *MockClientMockRecorder) GetReferencePoliciesInNamespace(ctx, namespace interface{}) *gomock.Call { +// GetReferenceGrantsInNamespace indicates an expected call of GetReferenceGrantsInNamespace. +func (mr *MockClientMockRecorder) GetReferenceGrantsInNamespace(ctx, namespace interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetReferencePoliciesInNamespace", reflect.TypeOf((*MockClient)(nil).GetReferencePoliciesInNamespace), ctx, namespace) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetReferenceGrantsInNamespace", reflect.TypeOf((*MockClient)(nil).GetReferenceGrantsInNamespace), ctx, namespace) } // GetSecret mocks base method. diff --git a/internal/k8s/reconciler/config/statuses.yaml b/internal/k8s/reconciler/config/statuses.yaml index 56b06826c..0fa3959d7 100644 --- a/internal/k8s/reconciler/config/statuses.yaml +++ b/internal/k8s/reconciler/config/statuses.yaml @@ -152,7 +152,7 @@ - name: RefNotPermitted description: > This reason is used with the “ResolvedRefs” condition when one of the Listener’s Routes has a BackendRef - to an object in another namespace, where the object in the other namespace does not have a ReferencePolicy + to an object in another namespace, where the object in the other namespace does not have a ReferenceGrant explicitly allowing the reference. @@ -264,5 +264,5 @@ - name: RefNotPermitted description: > This reason is used with the “ResolvedRefs” condition when one of the Listener’s Routes has a BackendRef - to an object in another namespace, where the object in the other namespace does not have a ReferencePolicy + to an object in another namespace, where the object in the other namespace does not have a ReferenceGrant explicitly allowing the reference. diff --git a/internal/k8s/reconciler/listener.go b/internal/k8s/reconciler/listener.go index c06fab504..d27b668fd 100644 --- a/internal/k8s/reconciler/listener.go +++ b/internal/k8s/reconciler/listener.go @@ -122,15 +122,15 @@ func (l *K8sListener) validateTLS(ctx context.Context) error { // we only support a single certificate for now ref := l.listener.TLS.CertificateRefs[0] - // require ReferencePolicy for cross-namespace certificateRef + // require ReferenceGrant for cross-namespace certificateRef allowed, err := gatewayAllowedForSecretRef(ctx, l.gateway, ref, l.client) if err != nil { return err } else if !allowed { nsName := getNamespacedName(ref.Name, ref.Namespace, l.gateway.Namespace) - l.logger.Warn("Cross-namespace listener certificate not allowed without matching ReferencePolicy", "refName", nsName.Name, "refNamespace", nsName.Namespace) + l.logger.Warn("Cross-namespace listener certificate not allowed without matching ReferenceGrant", "refName", nsName.Name, "refNamespace", nsName.Namespace) l.status.ResolvedRefs.InvalidCertificateRef = NewCertificateResolutionErrorNotPermitted( - fmt.Sprintf("Cross-namespace listener certificate not allowed without matching ReferencePolicy for Secret %q", nsName)) + fmt.Sprintf("Cross-namespace listener certificate not allowed without matching ReferenceGrant for Secret %q", nsName)) return nil } diff --git a/internal/k8s/reconciler/listener_test.go b/internal/k8s/reconciler/listener_test.go index 53d0b8507..1e134ca29 100644 --- a/internal/k8s/reconciler/listener_test.go +++ b/internal/k8s/reconciler/listener_test.go @@ -156,7 +156,7 @@ func TestListenerValidate(t *testing.T) { require.Equal(t, ListenerConditionReasonInvalidCertificateRef, condition.Reason) }) - t.Run("Invalid cross-namespace secret ref with no ReferencePolicy", func(t *testing.T) { + t.Run("Invalid cross-namespace secret ref with no ReferenceGrant", func(t *testing.T) { otherNamespace := gw.Namespace("other-namespace") listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, @@ -170,13 +170,13 @@ func TestListenerValidate(t *testing.T) { Logger: hclog.NewNullLogger(), Client: client, }) - client.EXPECT().GetReferencePoliciesInNamespace(gomock.Any(), string(otherNamespace)).Return([]gw.ReferencePolicy{}, nil) + client.EXPECT().GetReferenceGrantsInNamespace(gomock.Any(), string(otherNamespace)).Return([]gw.ReferenceGrant{}, nil) require.NoError(t, listener.Validate(context.Background())) condition := listener.status.ResolvedRefs.Condition(0) assert.Equal(t, ListenerConditionReasonInvalidCertificateRef, condition.Reason) }) - t.Run("Valid cross-namespace secret ref with ReferencePolicy", func(t *testing.T) { + t.Run("Valid cross-namespace secret ref with ReferenceGrant", func(t *testing.T) { gatewayNamespace := gw.Namespace("gateway-namespace") secretNamespace := gw.Namespace("secret-namespace") listener := NewK8sListener( @@ -195,15 +195,15 @@ func TestListenerValidate(t *testing.T) { Logger: hclog.NewNullLogger(), Client: client, }) - client.EXPECT().GetReferencePoliciesInNamespace(gomock.Any(), string(secretNamespace)). - Return([]gw.ReferencePolicy{{ - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{ + client.EXPECT().GetReferenceGrantsInNamespace(gomock.Any(), string(secretNamespace)). + Return([]gw.ReferenceGrant{{ + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "Gateway", Namespace: gatewayNamespace, }}, - To: []gw.ReferencePolicyTo{{ + To: []gw.ReferenceGrantTo{{ Kind: "Secret", }}, }, @@ -218,7 +218,7 @@ func TestListenerValidate(t *testing.T) { assert.Equal(t, meta.ConditionTrue, condition.Status) }) - t.Run("Valid same-namespace secret ref without ReferencePolicy", func(t *testing.T) { + t.Run("Valid same-namespace secret ref without ReferenceGrant", func(t *testing.T) { listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ Protocol: gw.HTTPSProtocolType, TLS: &gw.GatewayTLSConfig{ diff --git a/internal/k8s/reconciler/route.go b/internal/k8s/reconciler/route.go index 89faddc92..a47ae75bf 100644 --- a/internal/k8s/reconciler/route.go +++ b/internal/k8s/reconciler/route.go @@ -374,8 +374,8 @@ func (r *K8sRoute) Validate(ctx context.Context) error { return err } else if !allowed { nsName := getNamespacedName(ref.Name, ref.Namespace, route.Namespace) - msg := fmt.Sprintf("Cross-namespace routing not allowed without matching ReferencePolicy for Service %q", nsName) - r.logger.Warn("Cross-namespace routing not allowed without matching ReferencePolicy", "refName", nsName.Name, "refNamespace", nsName.Namespace) + msg := fmt.Sprintf("Cross-namespace routing not allowed without matching ReferenceGrant for Service %q", nsName) + r.logger.Warn("Cross-namespace routing not allowed without matching ReferenceGrant", "refName", nsName.Name, "refNamespace", nsName.Namespace) r.resolutionErrors.Add(service.NewRefNotPermittedError(msg)) continue } @@ -417,8 +417,8 @@ func (r *K8sRoute) Validate(ctx context.Context) error { return err } else if !allowed { nsName := getNamespacedName(ref.Name, ref.Namespace, route.Namespace) - msg := fmt.Sprintf("Cross-namespace routing not allowed without matching ReferencePolicy for Service %q", nsName) - r.logger.Warn("Cross-namespace routing not allowed without matching ReferencePolicy", "refName", nsName.Name, "refNamespace", nsName.Namespace) + msg := fmt.Sprintf("Cross-namespace routing not allowed without matching ReferenceGrant for Service %q", nsName) + r.logger.Warn("Cross-namespace routing not allowed without matching ReferenceGrant", "refName", nsName.Name, "refNamespace", nsName.Namespace) r.resolutionErrors.Add(service.NewRefNotPermittedError(msg)) return nil } diff --git a/internal/k8s/reconciler/route_test.go b/internal/k8s/reconciler/route_test.go index c50bd79a9..c52926069 100644 --- a/internal/k8s/reconciler/route_test.go +++ b/internal/k8s/reconciler/route_test.go @@ -535,23 +535,23 @@ func TestRouteValidateDontAllowCrossNamespace(t *testing.T) { }) client.EXPECT(). - GetReferencePoliciesInNamespace(gomock.Any(), gomock.Any()). - Return([]gw.ReferencePolicy{ + GetReferenceGrantsInNamespace(gomock.Any(), gomock.Any()). + Return([]gw.ReferenceGrant{ { - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{}, - To: []gw.ReferencePolicyTo{}, + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{}, + To: []gw.ReferenceGrantTo{}, }, }, }, nil) - // FUTURE Assert appropriate status set on route and !route.IsValid() once ReferencePolicy requirement is enforced + // FUTURE Assert appropriate status set on route and !route.IsValid() once ReferenceGrant requirement is enforced _ = route.Validate(context.Background()) } -// TestRouteValidateAllowCrossNamespaceWithReferencePolicy verifies that a cross-namespace -// route + backend combination is allowed if an applicable ReferencePolicy is found. -func TestRouteValidateAllowCrossNamespaceWithReferencePolicy(t *testing.T) { +// TestRouteValidateAllowCrossNamespaceWithReferenceGrant verifies that a cross-namespace +// route + backend combination is allowed if an applicable ReferenceGrant is found. +func TestRouteValidateAllowCrossNamespaceWithReferenceGrant(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -587,16 +587,16 @@ func TestRouteValidateAllowCrossNamespaceWithReferencePolicy(t *testing.T) { Resolver: resolver, }) - referencePolicy := gw.ReferencePolicy{ + refGrant := gw.ReferenceGrant{ TypeMeta: meta.TypeMeta{}, ObjectMeta: meta.ObjectMeta{Namespace: "namespace2"}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{ + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "HTTPRoute", Namespace: "namespace1", }}, - To: []gw.ReferencePolicyTo{{ + To: []gw.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: &backendName, @@ -605,8 +605,8 @@ func TestRouteValidateAllowCrossNamespaceWithReferencePolicy(t *testing.T) { } client.EXPECT(). - GetReferencePoliciesInNamespace(gomock.Any(), gomock.Any()). - Return([]gw.ReferencePolicy{referencePolicy}, nil) + GetReferenceGrantsInNamespace(gomock.Any(), gomock.Any()). + Return([]gw.ReferenceGrant{refGrant}, nil) resolver.EXPECT(). Resolve(gomock.Any(), gomock.Any()). diff --git a/internal/k8s/reconciler/utils.go b/internal/k8s/reconciler/utils.go index f5a863d43..aa5686091 100644 --- a/internal/k8s/reconciler/utils.go +++ b/internal/k8s/reconciler/utils.go @@ -122,7 +122,7 @@ func routeAllowedForListenerNamespaces(ctx context.Context, gatewayNS string, al // gatewayAllowedForSecretRef determines whether the gateway is allowed // for the secret either by being in the same namespace or by having -// an applicable ReferencePolicy in the same namespace as the secret. +// an applicable ReferenceGrant in the same namespace as the secret. func gatewayAllowedForSecretRef(ctx context.Context, gateway *gw.Gateway, secretRef gw.SecretObjectReference, c gatewayclient.Client) (bool, error) { fromNS := gateway.GetNamespace() fromGK := metav1.GroupKind{ @@ -151,10 +151,10 @@ func gatewayAllowedForSecretRef(ctx context.Context, gateway *gw.Gateway, secret // routeAllowedForBackendRef determines whether the route is allowed // for the backend either by being in the same namespace or by having -// an applicable ReferencePolicy in the same namespace as the backend. +// an applicable ReferenceGrant in the same namespace as the backend. // // TODO This func is currently called once for each backendRef on a route and results -// in fetching ReferencePolicies more than we technically have to in some cases +// in fetching ReferenceGrants more than we technically have to in some cases func routeAllowedForBackendRef(ctx context.Context, route Route, backendRef gw.BackendRef, c gatewayclient.Client) (bool, error) { fromNS := route.GetNamespace() fromGK := metav1.GroupKind{ @@ -183,27 +183,27 @@ func routeAllowedForBackendRef(ctx context.Context, route Route, backendRef gw.B // referenceAllowed checks to see if a reference between resources is allowed. // In particular, references from one namespace to a resource in a different namespace -// require an applicable ReferencePolicy be found in the namespace containing the resource +// require an applicable ReferenceGrant be found in the namespace containing the resource // being referred to. // // For example, a Gateway in namespace "foo" may only reference a Secret in namespace "bar" -// if a ReferencePolicy in namespace "bar" allows references from namespace "foo". +// if a ReferenceGrant in namespace "bar" allows references from namespace "foo". func referenceAllowed(ctx context.Context, fromGK metav1.GroupKind, fromNamespace string, toGK metav1.GroupKind, toNamespace, toName string, c gatewayclient.Client) (bool, error) { // Reference does not cross namespaces if toNamespace == "" || toNamespace == fromNamespace { return true, nil } - // Fetch all ReferencePolicies in the referenced namespace - refPolicies, err := c.GetReferencePoliciesInNamespace(ctx, toNamespace) - if err != nil || len(refPolicies) == 0 { + // Fetch all ReferenceGrants in the referenced namespace + refGrants, err := c.GetReferenceGrantsInNamespace(ctx, toNamespace) + if err != nil || len(refGrants) == 0 { return false, err } - for _, refPolicy := range refPolicies { + for _, refGrant := range refGrants { // Check for a From that applies fromMatch := false - for _, from := range refPolicy.Spec.From { + for _, from := range refGrant.Spec.From { if fromGK.Group == string(from.Group) && fromGK.Kind == string(from.Kind) && fromNamespace == string(from.Namespace) { fromMatch = true break @@ -215,7 +215,7 @@ func referenceAllowed(ctx context.Context, fromGK metav1.GroupKind, fromNamespac } // Check for a To that applies - for _, to := range refPolicy.Spec.To { + for _, to := range refGrant.Spec.To { if toGK.Group == string(to.Group) && toGK.Kind == string(to.Kind) { if to.Name == nil || *to.Name == "" { // No name specified is treated as a wildcard within the namespace @@ -223,14 +223,14 @@ func referenceAllowed(ctx context.Context, fromGK metav1.GroupKind, fromNamespac } if gw.ObjectName(toName) == *to.Name { - // The ReferencePolicy specifically targets this object + // The ReferenceGrant specifically targets this object return true, nil } } } } - // No ReferencePolicy was found which allows this cross-namespace reference + // No ReferenceGrant was found which allows this cross-namespace reference return false, nil } diff --git a/internal/k8s/reconciler/utils_test.go b/internal/k8s/reconciler/utils_test.go index aa04edc71..0ca5aa591 100644 --- a/internal/k8s/reconciler/utils_test.go +++ b/internal/k8s/reconciler/utils_test.go @@ -365,27 +365,27 @@ func TestGatewayStatusEqual(t *testing.T) { func TestGatewayAllowedForSecretRef(t *testing.T) { type testCase struct { - name string - fromNS string - toNS *string - toKind *string - toName string - policyFromNS string - policyToName *string - allowed bool + name string + fromNS string + toNS *string + toKind *string + toName string + grantFromNS string + grantToName *string + allowed bool } ns1, ns2, ns3 := "namespace1", "namespace2", "namespace3" secret1, secret2, secret3 := "secret1", "secret2", "secret3" for _, tc := range []testCase{ - {name: "unspecified-secret-namespace-allowed", fromNS: ns1, toNS: nil, toName: secret1, policyFromNS: ns1, policyToName: nil, allowed: true}, - {name: "same-namespace-no-name-allowed", fromNS: ns1, toNS: &ns1, toName: secret1, policyFromNS: ns1, policyToName: nil, allowed: true}, - {name: "same-namespace-with-name-allowed", fromNS: ns1, toNS: &ns1, toName: secret1, policyFromNS: ns1, policyToName: &secret1, allowed: true}, - {name: "different-namespace-no-name-allowed", fromNS: ns1, toNS: &ns2, toName: secret2, policyFromNS: ns1, policyToName: nil, allowed: true}, - {name: "different-namespace-with-name-allowed", fromNS: ns1, toNS: &ns2, toName: secret2, policyFromNS: ns1, policyToName: &secret2, allowed: true}, - {name: "mismatched-policy-from-namespace-disallowed", fromNS: ns1, toNS: &ns2, toName: secret2, policyFromNS: ns3, policyToName: &secret2, allowed: false}, - {name: "mismatched-policy-to-name-disallowed", fromNS: ns1, toNS: &ns2, toName: secret2, policyFromNS: ns1, policyToName: &secret3, allowed: false}, + {name: "unspecified-secret-namespace-allowed", fromNS: ns1, toNS: nil, toName: secret1, grantToName: nil, allowed: true}, + {name: "same-namespace-no-name-allowed", fromNS: ns1, toNS: &ns1, toName: secret1, grantToName: nil, allowed: true}, + {name: "same-namespace-with-name-allowed", fromNS: ns1, toNS: &ns1, toName: secret1, grantToName: &secret1, allowed: true}, + {name: "different-namespace-no-name-allowed", fromNS: ns1, toNS: &ns2, toName: secret2, grantFromNS: ns1, grantToName: nil, allowed: true}, + {name: "different-namespace-with-name-allowed", fromNS: ns1, toNS: &ns2, toName: secret2, grantFromNS: ns1, grantToName: &secret2, allowed: true}, + {name: "mismatched-grant-from-namespace-disallowed", fromNS: ns1, toNS: &ns2, toName: secret2, grantFromNS: ns3, grantToName: &secret2, allowed: false}, + {name: "mismatched-grant-to-name-disallowed", fromNS: ns1, toNS: &ns2, toName: secret2, grantFromNS: ns1, grantToName: &secret3, allowed: false}, } { t.Run(tc.name, func(t *testing.T) { ctrl := gomock.NewController(t) @@ -425,44 +425,44 @@ func TestGatewayAllowedForSecretRef(t *testing.T) { } var toName *gw.ObjectName - if tc.policyToName != nil { - on := gw.ObjectName(*tc.policyToName) + if tc.grantToName != nil { + on := gw.ObjectName(*tc.grantToName) toName = &on } if tc.toNS != nil && tc.fromNS != *tc.toNS { otherName := gw.ObjectName("blah") - refPolicies := []gw.ReferencePolicy{ - // Create a ReferencePolicy that does not match at all (kind, etc.) + refGrants := []gw.ReferenceGrant{ + // Create a ReferenceGrant that does not match at all (kind, etc.) { ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{Group: "Kool & The Gang", Kind: "Jungle Boogie", Namespace: "Wild And Peaceful"}}, - To: []gw.ReferencePolicyTo{{Group: "does not exist", Kind: "does not exist", Name: nil}}, + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{Group: "Kool & The Gang", Kind: "Jungle Boogie", Namespace: "Wild And Peaceful"}}, + To: []gw.ReferenceGrantTo{{Group: "does not exist", Kind: "does not exist", Name: nil}}, }, }, - // Create a ReferencePolicy that matches completely except for To.Name + // Create a ReferenceGrant that matches completely except for To.Name { ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{Group: "gateway.networking.k8s.io", Kind: gw.Kind("Gateway"), Namespace: gw.Namespace(tc.policyFromNS)}}, - To: []gw.ReferencePolicyTo{{Group: "", Kind: "Secret", Name: &otherName}}, + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{Group: "gateway.networking.k8s.io", Kind: gw.Kind("Gateway"), Namespace: gw.Namespace(tc.grantFromNS)}}, + To: []gw.ReferenceGrantTo{{Group: "", Kind: "Secret", Name: &otherName}}, }, }, - // Create a ReferencePolicy that matches completely + // Create a ReferenceGrant that matches completely { ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{Group: "gateway.networking.k8s.io", Kind: gw.Kind("Gateway"), Namespace: gw.Namespace(tc.policyFromNS)}}, - To: []gw.ReferencePolicyTo{{Group: "", Kind: "Secret", Name: toName}}, + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{Group: "gateway.networking.k8s.io", Kind: gw.Kind("Gateway"), Namespace: gw.Namespace(tc.grantFromNS)}}, + To: []gw.ReferenceGrantTo{{Group: "", Kind: "Secret", Name: toName}}, }, }, } client.EXPECT(). - GetReferencePoliciesInNamespace(gomock.Any(), *tc.toNS). - Return(refPolicies, nil) + GetReferenceGrantsInNamespace(gomock.Any(), *tc.toNS). + Return(refGrants, nil) } allowed, err := gatewayAllowedForSecretRef(context.Background(), gateway, secretRef, client) @@ -474,27 +474,27 @@ func TestGatewayAllowedForSecretRef(t *testing.T) { func TestRouteAllowedForBackendRef(t *testing.T) { type testCase struct { - name string - fromNS string - toNS *string - toKind *string - toName string - policyFromNS string - policyToName *string - allowed bool + name string + fromNS string + toNS *string + toKind *string + toName string + grantFromNS string + grantToName *string + allowed bool } ns1, ns2, ns3 := "namespace1", "namespace2", "namespace3" backend1, backend2, backend3 := "backend1", "backend2", "backend3" for _, tc := range []testCase{ - {name: "unspecified-backend-namespace-allowed", fromNS: ns1, toNS: nil, toName: backend1, policyFromNS: ns1, policyToName: nil, allowed: true}, - {name: "same-namespace-no-name-allowed", fromNS: ns1, toNS: &ns1, toName: backend1, policyFromNS: ns1, policyToName: nil, allowed: true}, - {name: "same-namespace-with-name-allowed", fromNS: ns1, toNS: &ns1, toName: backend1, policyFromNS: ns1, policyToName: &backend1, allowed: true}, - {name: "different-namespace-no-name-allowed", fromNS: ns1, toNS: &ns2, toName: backend2, policyFromNS: ns1, policyToName: nil, allowed: true}, - {name: "different-namespace-with-name-allowed", fromNS: ns1, toNS: &ns2, toName: backend2, policyFromNS: ns1, policyToName: &backend2, allowed: true}, - {name: "mismatched-policy-from-namespace-disallowed", fromNS: ns1, toNS: &ns2, toName: backend2, policyFromNS: ns3, policyToName: &backend2, allowed: false}, - {name: "mismatched-policy-to-name-disallowed", fromNS: ns1, toNS: &ns2, toName: backend2, policyFromNS: ns1, policyToName: &backend3, allowed: false}, + {name: "unspecified-backend-namespace-allowed", fromNS: ns1, toNS: nil, toName: backend1, grantFromNS: ns1, grantToName: nil, allowed: true}, + {name: "same-namespace-no-name-allowed", fromNS: ns1, toNS: &ns1, toName: backend1, grantFromNS: ns1, grantToName: nil, allowed: true}, + {name: "same-namespace-with-name-allowed", fromNS: ns1, toNS: &ns1, toName: backend1, grantFromNS: ns1, grantToName: &backend1, allowed: true}, + {name: "different-namespace-no-name-allowed", fromNS: ns1, toNS: &ns2, toName: backend2, grantFromNS: ns1, grantToName: nil, allowed: true}, + {name: "different-namespace-with-name-allowed", fromNS: ns1, toNS: &ns2, toName: backend2, grantFromNS: ns1, grantToName: &backend2, allowed: true}, + {name: "mismatched-grant-from-namespace-disallowed", fromNS: ns1, toNS: &ns2, toName: backend2, grantFromNS: ns3, grantToName: &backend2, allowed: false}, + {name: "mismatched-grant-to-name-disallowed", fromNS: ns1, toNS: &ns2, toName: backend2, grantFromNS: ns1, grantToName: &backend3, allowed: false}, } { // Test each case for both HTTPRoute + TCPRoute which should function identically for _, routeType := range []string{"HTTPRoute", "TCPRoute"} { @@ -549,22 +549,22 @@ func TestRouteAllowedForBackendRef(t *testing.T) { } var toName *gw.ObjectName - if tc.policyToName != nil { - on := gw.ObjectName(*tc.policyToName) + if tc.grantToName != nil { + on := gw.ObjectName(*tc.grantToName) toName = &on } if tc.toNS != nil && tc.fromNS != *tc.toNS { - referencePolicy := gw.ReferencePolicy{ + referenceGrant := gw.ReferenceGrant{ TypeMeta: meta.TypeMeta{}, ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{ + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: gw.Kind(routeType), - Namespace: gw.Namespace(tc.policyFromNS), + Namespace: gw.Namespace(tc.grantFromNS), }}, - To: []gw.ReferencePolicyTo{{ + To: []gw.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: toName, @@ -572,15 +572,15 @@ func TestRouteAllowedForBackendRef(t *testing.T) { }, } - throwawayPolicy := gw.ReferencePolicy{ + throwawayGrant := gw.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferencePolicySpec{ - From: []gw.ReferencePolicyFrom{{ + Spec: gw.ReferenceGrantSpec{ + From: []gw.ReferenceGrantFrom{{ Group: "Kool & The Gang", Kind: "Jungle Boogie", Namespace: "Wild And Peaceful", }}, - To: []gw.ReferencePolicyTo{{ + To: []gw.ReferenceGrantTo{{ Group: "does not exist", Kind: "does not exist", Name: nil, @@ -589,8 +589,8 @@ func TestRouteAllowedForBackendRef(t *testing.T) { } client.EXPECT(). - GetReferencePoliciesInNamespace(gomock.Any(), *tc.toNS). - Return([]gw.ReferencePolicy{throwawayPolicy, referencePolicy}, nil) + GetReferenceGrantsInNamespace(gomock.Any(), *tc.toNS). + Return([]gw.ReferenceGrant{throwawayGrant, referenceGrant}, nil) } allowed, err := routeAllowedForBackendRef(context.Background(), route, backendRef, client) diff --git a/internal/k8s/reconciler/zz_generated_status.go b/internal/k8s/reconciler/zz_generated_status.go index be7bd3abd..d37fba9df 100644 --- a/internal/k8s/reconciler/zz_generated_status.go +++ b/internal/k8s/reconciler/zz_generated_status.go @@ -604,7 +604,7 @@ type RouteResolvedRefsStatus struct { ConsulServiceNotFound error // This reason is used with the “ResolvedRefs” condition when one of the // Listener’s Routes has a BackendRef to an object in another namespace, where - // the object in the other namespace does not have a ReferencePolicy explicitly + // the object in the other namespace does not have a ReferenceGrant explicitly // allowing the reference. // // [spec] @@ -641,7 +641,7 @@ const ( // RouteConditionReasonRefNotPermitted - This reason is used with the // “ResolvedRefs” condition when one of the Listener’s Routes has a // BackendRef to an object in another namespace, where the object in the other - // namespace does not have a ReferencePolicy explicitly allowing the reference. + // namespace does not have a ReferenceGrant explicitly allowing the reference. // // [spec] RouteConditionReasonRefNotPermitted = "RefNotPermitted" @@ -1104,7 +1104,7 @@ type ListenerResolvedRefsStatus struct { InvalidRouteKinds error // This reason is used with the “ResolvedRefs” condition when one of the // Listener’s Routes has a BackendRef to an object in another namespace, where - // the object in the other namespace does not have a ReferencePolicy explicitly + // the object in the other namespace does not have a ReferenceGrant explicitly // allowing the reference. // // [spec] @@ -1137,7 +1137,7 @@ const ( // ListenerConditionReasonRefNotPermitted - This reason is used with the // “ResolvedRefs” condition when one of the Listener’s Routes has a // BackendRef to an object in another namespace, where the object in the other - // namespace does not have a ReferencePolicy explicitly allowing the reference. + // namespace does not have a ReferenceGrant explicitly allowing the reference. // // [spec] ListenerConditionReasonRefNotPermitted = "RefNotPermitted" diff --git a/internal/testing/e2e/consul.go b/internal/testing/e2e/consul.go index d0528e2be..230b281e0 100644 --- a/internal/testing/e2e/consul.go +++ b/internal/testing/e2e/consul.go @@ -90,8 +90,8 @@ type consulTestEnvironment struct { policy *api.ACLPolicy httpPort int httpFlattenedPort int - httpReferencePolicyPort int - tcpReferencePolicyPort int + httpReferenceGrantPort int + tcpReferenceGrantPort int parentRefChangeFirstGatewayPort int parentRefChangeSecondGatewayPort int grpcPort int @@ -114,8 +114,8 @@ func CreateTestConsulContainer(name, namespace string) env.Func { cluster := clusterVal.(*kindCluster) httpsPort := cluster.httpsPort httpFlattenedPort := cluster.httpsFlattenedPort - httpReferencePolicyPort := cluster.httpsReferencePolicyPort - tcpReferencePolicyPort := cluster.tcpReferencePolicyPort + httpReferenceGrantPort := cluster.httpsReferenceGrantPort + tcpReferenceGrantPort := cluster.tcpReferenceGrantPort parentRefChangeFirstGatewayPort := cluster.parentRefChangeFirstGatewayPort parentRefChangeSecondGatewayPort := cluster.parentRefChangeSecondGatewayPort grpcPort := cluster.grpcPort @@ -210,8 +210,8 @@ func CreateTestConsulContainer(name, namespace string) env.Func { consulClient: consulClient, httpPort: httpsPort, httpFlattenedPort: httpFlattenedPort, - httpReferencePolicyPort: httpReferencePolicyPort, - tcpReferencePolicyPort: tcpReferencePolicyPort, + httpReferenceGrantPort: httpReferenceGrantPort, + tcpReferenceGrantPort: tcpReferenceGrantPort, parentRefChangeFirstGatewayPort: parentRefChangeFirstGatewayPort, parentRefChangeSecondGatewayPort: parentRefChangeSecondGatewayPort, grpcPort: grpcPort, @@ -460,12 +460,12 @@ func HTTPFlattenedPort(ctx context.Context) int { return mustGetTestEnvironment(ctx).httpFlattenedPort } -func HTTPReferencePolicyPort(ctx context.Context) int { - return mustGetTestEnvironment(ctx).httpReferencePolicyPort +func HTTPReferenceGrantPort(ctx context.Context) int { + return mustGetTestEnvironment(ctx).httpReferenceGrantPort } -func TCPReferencePolicyPort(ctx context.Context) int { - return mustGetTestEnvironment(ctx).tcpReferencePolicyPort +func TCPReferenceGrantPort(ctx context.Context) int { + return mustGetTestEnvironment(ctx).tcpReferenceGrantPort } func ParentRefChangeFirstGatewayPort(ctx context.Context) int { diff --git a/internal/testing/e2e/kind.go b/internal/testing/e2e/kind.go index 9bddde213..6ef24b434 100644 --- a/internal/testing/e2e/kind.go +++ b/internal/testing/e2e/kind.go @@ -41,11 +41,11 @@ nodes: - containerPort: {{ .HTTPSFlattenedPort }} hostPort: {{ .HTTPSFlattenedPort }} protocol: TCP - - containerPort: {{ .HTTPSReferencePolicyPort }} - hostPort: {{ .HTTPSReferencePolicyPort }} + - containerPort: {{ .HTTPSReferenceGrantPort }} + hostPort: {{ .HTTPSReferenceGrantPort }} protocol: TCP - - containerPort: {{ .TCPReferencePolicyPort }} - hostPort: {{ .TCPReferencePolicyPort }} + - containerPort: {{ .TCPReferenceGrantPort }} + hostPort: {{ .TCPReferenceGrantPort }} protocol: TCP - containerPort: {{ .ParentRefChangeFirstGatewayPort }} hostPort: {{ .ParentRefChangeFirstGatewayPort }} @@ -85,8 +85,8 @@ type kindCluster struct { config string httpsPort int httpsFlattenedPort int - httpsReferencePolicyPort int - tcpReferencePolicyPort int + httpsReferenceGrantPort int + tcpReferenceGrantPort int parentRefChangeFirstGatewayPort int parentRefChangeSecondGatewayPort int grpcPort int @@ -103,8 +103,8 @@ func newKindCluster(name string) *kindCluster { e: gexe.New(), httpsPort: ports[0], httpsFlattenedPort: ports[1], - httpsReferencePolicyPort: ports[2], - tcpReferencePolicyPort: ports[3], + httpsReferenceGrantPort: ports[2], + tcpReferenceGrantPort: ports[3], parentRefChangeFirstGatewayPort: ports[4], parentRefChangeSecondGatewayPort: ports[5], grpcPort: ports[6], @@ -122,8 +122,8 @@ func (k *kindCluster) Create() (string, error) { err := kindTemplate.Execute(&kindConfig, &struct { HTTPSPort int HTTPSFlattenedPort int - HTTPSReferencePolicyPort int - TCPReferencePolicyPort int + HTTPSReferenceGrantPort int + TCPReferenceGrantPort int ParentRefChangeFirstGatewayPort int ParentRefChangeSecondGatewayPort int GRPCPort int @@ -134,8 +134,8 @@ func (k *kindCluster) Create() (string, error) { }{ HTTPSPort: k.httpsPort, HTTPSFlattenedPort: k.httpsFlattenedPort, - HTTPSReferencePolicyPort: k.httpsReferencePolicyPort, - TCPReferencePolicyPort: k.tcpReferencePolicyPort, + HTTPSReferenceGrantPort: k.httpsReferenceGrantPort, + TCPReferenceGrantPort: k.tcpReferenceGrantPort, ParentRefChangeFirstGatewayPort: k.parentRefChangeFirstGatewayPort, ParentRefChangeSecondGatewayPort: k.parentRefChangeSecondGatewayPort, GRPCPort: k.grpcPort, diff --git a/internal/testing/e2e/kubernetes.go b/internal/testing/e2e/kubernetes.go index bc6bd4b68..64704f278 100644 --- a/internal/testing/e2e/kubernetes.go +++ b/internal/testing/e2e/kubernetes.go @@ -54,6 +54,7 @@ func InstallGatewayCRDs(ctx context.Context, cfg *envconf.Config) (context.Conte &gateway.HTTPRouteList{}, &gateway.TCPRoute{}, &gateway.TCPRouteList{}, + &gateway.ReferenceGrant{}, &gateway.ReferencePolicy{}, ) meta.AddToGroupVersion(scheme.Scheme, gateway.SchemeGroupVersion) From d5c2691aacecbee16b14de36e7e5b457a6fa9d6a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Jun 2022 16:58:55 -0400 Subject: [PATCH 09/17] changelog: add entry for gateway-api@v0.5.0 --- .changelog/224.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changelog/224.txt diff --git a/.changelog/224.txt b/.changelog/224.txt new file mode 100644 index 000000000..2ba4f4f94 --- /dev/null +++ b/.changelog/224.txt @@ -0,0 +1,6 @@ +```release-note:feature +gateway-api: update to the [v0.5.0-rc1](https://github.com/kubernetes-sigs/gateway-api/releases/tag/v0.5.0-rc1) release with v1beta1 resource support +``` +```release-note:deprecation +gateway-api: ReferencePolicy is deprecated and will be removed in a future release. The functionally identical ReferenceGrant should be used instead. +``` From 63e14f6072b7309e30419530dd0c23f599b362e4 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 15 Jun 2022 13:26:23 -0400 Subject: [PATCH 10/17] config/crd: install Gateway API experimental channel CRDs --- config/crd/kustomization.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index a4550e0c2..a607d40ba 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -2,6 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1 +- github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.0-rc1 - bases/api-gateway.consul.hashicorp.com_gatewayclassconfigs.yaml -- bases/api-gateway.consul.hashicorp.com_meshservices.yaml \ No newline at end of file +- bases/api-gateway.consul.hashicorp.com_meshservices.yaml From daa9b0294e24ac66ce41d771e6e99f9b426cf1a1 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 17 Jun 2022 10:29:03 -0400 Subject: [PATCH 11/17] dev/run: install CRDs from config/crd --- dev/run | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/dev/run b/dev/run index 698ec12f1..e4ba5ce10 100755 --- a/dev/run +++ b/dev/run @@ -24,8 +24,8 @@ createCluster() { } installGatewayCRDs() { - echo "Installing Gateway CRDs" - kubectl apply -k "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1" 2>&1 > /dev/null + echo "Installing Gateway API and Consul API Gateway CRDs" + kubectl apply -k config/crd } createServiceAccountForRBAC() { @@ -70,11 +70,6 @@ setupAuthMethod() { echo $CONSUL_HTTP_TOKEN > token } -installAPIGatewayCRDs() { - kubectl apply -f config/crd/bases/api-gateway.consul.hashicorp.com_gatewayclassconfigs.yaml - kubectl apply -f config/crd/bases/api-gateway.consul.hashicorp.com_meshservices.yaml -} - buildAPIGateway() { echo "Cross-compiling consul-api-gateway for Linux" GOOS=linux go build 2>&1 > /dev/null @@ -108,7 +103,6 @@ main() { setupAuthMethod fi if [[ "${load}" == "TRUE" ]]; then - installAPIGatewayCRDs buildAPIGateway buildDocker loadDockerImage From 1c5e8047be19c571f2fc3538ff85906b54730c8d Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 16 Jun 2022 15:21:36 -0400 Subject: [PATCH 12/17] e2e/kubernetes: install Consul API Gateway CRDs alongside Gateway API CRDs e2e: rename kubectlKustomizeCRDs arg from url to path --- internal/testing/e2e/gateway.go | 38 ------------------------------ internal/testing/e2e/kubernetes.go | 15 ++++++++---- internal/testing/e2e/kustomize.go | 5 ++-- internal/testing/e2e/stack.go | 3 +-- 4 files changed, 14 insertions(+), 47 deletions(-) diff --git a/internal/testing/e2e/gateway.go b/internal/testing/e2e/gateway.go index e30489954..38ed2fed0 100644 --- a/internal/testing/e2e/gateway.go +++ b/internal/testing/e2e/gateway.go @@ -4,14 +4,9 @@ import ( "context" "log" "os" - "path" - "strings" "time" "golang.org/x/sync/errgroup" - api "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/e2e-framework/pkg/env" "sigs.k8s.io/e2e-framework/pkg/envconf" @@ -20,7 +15,6 @@ import ( "github.com/hashicorp/consul-api-gateway/internal/envoy" "github.com/hashicorp/consul-api-gateway/internal/k8s" "github.com/hashicorp/consul-api-gateway/internal/store/memory" - apigwv1alpha1 "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" "github.com/hashicorp/go-hclog" ) @@ -155,35 +149,3 @@ func DestroyTestGatewayServer(ctx context.Context, cfg *envconf.Config) (context } return ctx, nil } - -func InstallConsulAPIGatewayCRDs(ctx context.Context, cfg *envconf.Config) (context.Context, error) { - directory := path.Join("..", "..", "..", "config", "crd", "bases") - entries, err := os.ReadDir(directory) - crds := []*api.CustomResourceDefinition{} - if err != nil { - return nil, err - } - for _, file := range entries { - if strings.HasPrefix(file.Name(), ".") { - continue - } - data, err := os.ReadFile(path.Join(directory, file.Name())) - if err != nil { - return nil, err - } - fileCRDs, err := readCRDs(data) - if err != nil { - return nil, err - } - crds = append(crds, fileCRDs...) - } - if _, err := envtest.InstallCRDs(cfg.Client().RESTConfig(), envtest.CRDInstallOptions{ - CRDs: crds, - }); err != nil { - return nil, err - } - - apigwv1alpha1.RegisterTypes(scheme.Scheme) - - return ctx, nil -} diff --git a/internal/testing/e2e/kubernetes.go b/internal/testing/e2e/kubernetes.go index 64704f278..467cbeb50 100644 --- a/internal/testing/e2e/kubernetes.go +++ b/internal/testing/e2e/kubernetes.go @@ -8,8 +8,10 @@ import ( "io" "log" "os" + "path" "github.com/cenkalti/backoff" + consulapigw "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" core "k8s.io/api/core/v1" rbac "k8s.io/api/rbac/v1" api "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -28,12 +30,11 @@ type k8sTokenContext struct{} var k8sTokenContextKey = k8sTokenContext{} -const gatewayCRDs = "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1" +func InstallCRDs(ctx context.Context, cfg *envconf.Config) (context.Context, error) { + log.Print("Installing CRDs") -func InstallGatewayCRDs(ctx context.Context, cfg *envconf.Config) (context.Context, error) { - log.Print("Installing Gateway CRDs") - - crds, err := kubectlKustomizeCRDs(ctx, gatewayCRDs) + dir := path.Join("..", "..", "..", "config", "crd") + crds, err := kubectlKustomizeCRDs(ctx, dir) if err != nil { return nil, err } @@ -44,6 +45,7 @@ func InstallGatewayCRDs(ctx context.Context, cfg *envconf.Config) (context.Conte return nil, err } + // Register Gateway API types scheme.Scheme.AddKnownTypes( gateway.SchemeGroupVersion, &gateway.GatewayClass{}, @@ -59,6 +61,9 @@ func InstallGatewayCRDs(ctx context.Context, cfg *envconf.Config) (context.Conte ) meta.AddToGroupVersion(scheme.Scheme, gateway.SchemeGroupVersion) + // Register Consul API Gateway types + consulapigw.RegisterTypes(scheme.Scheme) + return ctx, nil } diff --git a/internal/testing/e2e/kustomize.go b/internal/testing/e2e/kustomize.go index cf312eed0..ca8be9ced 100644 --- a/internal/testing/e2e/kustomize.go +++ b/internal/testing/e2e/kustomize.go @@ -9,11 +9,12 @@ import ( api "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) -func kubectlKustomizeCRDs(ctx context.Context, url string) ([]*api.CustomResourceDefinition, error) { +// TODO: switch this to krusty implementation after integration for conformance tests +func kubectlKustomizeCRDs(ctx context.Context, path string) ([]*api.CustomResourceDefinition, error) { var stdout, stderr bytes.Buffer timeoutContext, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - cmd := exec.CommandContext(timeoutContext, "kubectl", "kustomize", url) + cmd := exec.CommandContext(timeoutContext, "kubectl", "kustomize", path) cmd.Stderr = &stderr cmd.Stdout = &stdout if err := cmd.Run(); err != nil { diff --git a/internal/testing/e2e/stack.go b/internal/testing/e2e/stack.go index 6ae7bfa3e..118361dc6 100644 --- a/internal/testing/e2e/stack.go +++ b/internal/testing/e2e/stack.go @@ -30,13 +30,12 @@ func SetUpStack(hostRoute string) env.Func { CreateKindCluster(kindClusterName), LoadKindDockerImage(kindClusterName), envfuncs.CreateNamespace(namespace), - InstallGatewayCRDs, + InstallCRDs, CreateServiceAccount(namespace, "consul-api-gateway", getBasePath()+"/config/rbac/role.yaml"), CreateTestConsulContainer(kindClusterName, namespace), CreateConsulACLPolicy, CreateConsulAuthMethod(), CreateConsulNamespace, - InstallConsulAPIGatewayCRDs, CreateTestGatewayServer(namespace), } { ctx, err = f(ctx, cfg) From 18c457f2a9f66994fac1f421d27a83b10bf8d8b9 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 15 Jun 2022 13:46:04 -0400 Subject: [PATCH 13/17] e2e: import both Gateway API v1alpha2 and v1beta1, split usage e2e/kubernetes: add v1beta1 known types separately from v1alpha2 known types --- internal/commands/server/k8s_e2e_test.go | 553 ++++++++++++----------- internal/testing/e2e/kubernetes.go | 32 +- 2 files changed, 297 insertions(+), 288 deletions(-) diff --git a/internal/commands/server/k8s_e2e_test.go b/internal/commands/server/k8s_e2e_test.go index efbdcec78..ca57cd74a 100644 --- a/internal/commands/server/k8s_e2e_test.go +++ b/internal/commands/server/k8s_e2e_test.go @@ -26,7 +26,8 @@ import ( "sigs.k8s.io/e2e-framework/pkg/env" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/features" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul/api" @@ -83,7 +84,7 @@ func TestGatewayWithClassConfigChange(t *testing.T) { // Create a Gateway and wait for it to be ready firstGatewayName := envconf.RandomName("gw", 16) - firstGateway := createGateway(ctx, t, resources, firstGatewayName, namespace, gc, []gateway.Listener{httpsListener}) + firstGateway := createGateway(ctx, t, resources, firstGatewayName, namespace, gc, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, gatewayStatusCheck(ctx, resources, firstGatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") checkGatewayConfigAnnotation(ctx, t, resources, firstGatewayName, namespace, firstConfig) @@ -97,7 +98,7 @@ func TestGatewayWithClassConfigChange(t *testing.T) { // Create a second Gateway and wait for it to be ready secondGatewayName := envconf.RandomName("gw", 16) - secondGateway := createGateway(ctx, t, resources, secondGatewayName, namespace, gc, []gateway.Listener{httpsListener}) + secondGateway := createGateway(ctx, t, resources, secondGatewayName, namespace, gc, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, gatewayStatusCheck(ctx, resources, secondGatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") // Verify that 1st Gateway retains initial GatewayClassConfig and 2nd Gateway retains updated GatewayClassConfig @@ -130,7 +131,7 @@ func TestGatewayWithReplicas(t *testing.T) { // Create a Gateway and wait for it to be ready gatewayName := envconf.RandomName("gw", 16) - gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{createHTTPSListener(ctx, t, 443)}) + gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{createHTTPSListener(ctx, t, 443)}) require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") checkGatewayConfigAnnotation(ctx, t, resources, gatewayName, namespace, gcc) @@ -166,7 +167,7 @@ func TestGatewayWithReplicasCanScale(t *testing.T) { // Create a Gateway and wait for it to be ready gatewayName := envconf.RandomName("gw", 16) - gateway := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{createHTTPSListener(ctx, t, 443)}) + gateway := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{createHTTPSListener(ctx, t, 443)}) require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") checkGatewayConfigAnnotation(ctx, t, resources, gatewayName, namespace, gcc) @@ -220,7 +221,7 @@ func TestGatewayWithReplicasRespectMinMax(t *testing.T) { // Create a Gateway and wait for it to be ready gatewayName := envconf.RandomName("gw", 16) - gateway := createGateway(ctx, t, resources, gatewayName, namespace, gatewayClass, []gateway.Listener{httpsListener}) + gateway := createGateway(ctx, t, resources, gatewayName, namespace, gatewayClass, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") checkGatewayConfigAnnotation(ctx, t, resources, gatewayName, namespace, gatewayClassConfig) @@ -269,7 +270,7 @@ func TestGatewayBasic(t *testing.T) { require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") httpsListener := createHTTPSListener(ctx, t, 443) - gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{httpsListener}) + gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, func() bool { err := resources.Get(ctx, gatewayName, namespace, &apps.Deployment{}) @@ -332,7 +333,7 @@ func TestServiceListeners(t *testing.T) { require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") httpsListener := createHTTPSListener(ctx, t, 443) - gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{httpsListener}) + gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, func() bool { service := &core.Service{} @@ -385,8 +386,8 @@ func TestHTTPRouteFlattening(t *testing.T) { routeOneName := envconf.RandomName("route", 16) routeTwoName := envconf.RandomName("route", 16) - prefixMatch := gateway.PathMatchPathPrefix - headerMatch := gateway.HeaderMatchExact + prefixMatch := gwv1alpha2.PathMatchPathPrefix + headerMatch := gwv1alpha2.HeaderMatchExact resources := cfg.Client().Resources(namespace) @@ -394,35 +395,35 @@ func TestHTTPRouteFlattening(t *testing.T) { require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") checkPort := e2e.HTTPFlattenedPort(ctx) - httpsListener := createHTTPSListener(ctx, t, gateway.PortNumber(checkPort)) - gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{httpsListener}) + httpsListener := createHTTPSListener(ctx, t, gwv1beta1.PortNumber(checkPort)) + gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") - port := gateway.PortNumber(serviceOne.Spec.Ports[0].Port) + port := gwv1alpha2.PortNumber(serviceOne.Spec.Ports[0].Port) path := "/" - route := &gateway.HTTPRoute{ + route := &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeOneName, Namespace: namespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Hostnames: []gateway.Hostname{"test.foo", "test.example"}, - Rules: []gateway.HTTPRouteRule{{ - Matches: []gateway.HTTPRouteMatch{{ - Path: &gateway.HTTPPathMatch{ + Hostnames: []gwv1alpha2.Hostname{"test.foo", "test.example"}, + Rules: []gwv1alpha2.HTTPRouteRule{{ + Matches: []gwv1alpha2.HTTPRouteMatch{{ + Path: &gwv1alpha2.HTTPPathMatch{ Type: &prefixMatch, Value: &path, }, }}, - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceOne.Name), + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceOne.Name), Port: &port, }, }, @@ -433,37 +434,37 @@ func TestHTTPRouteFlattening(t *testing.T) { err = resources.Create(ctx, route) require.NoError(t, err) - port = gateway.PortNumber(serviceTwo.Spec.Ports[0].Port) + port = gwv1alpha2.PortNumber(serviceTwo.Spec.Ports[0].Port) path = "/v2" - route = &gateway.HTTPRoute{ + route = &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeTwoName, Namespace: namespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Hostnames: []gateway.Hostname{"test.foo"}, - Rules: []gateway.HTTPRouteRule{{ - Matches: []gateway.HTTPRouteMatch{{ - Path: &gateway.HTTPPathMatch{ + Hostnames: []gwv1alpha2.Hostname{"test.foo"}, + Rules: []gwv1alpha2.HTTPRouteRule{{ + Matches: []gwv1alpha2.HTTPRouteMatch{{ + Path: &gwv1alpha2.HTTPPathMatch{ Type: &prefixMatch, Value: &path, }, }, { - Headers: []gateway.HTTPHeaderMatch{{ + Headers: []gwv1alpha2.HTTPHeaderMatch{{ Type: &headerMatch, - Name: gateway.HTTPHeaderName("x-v2"), + Name: gwv1alpha2.HTTPHeaderName("x-v2"), Value: "v2", }}, }}, - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceTwo.Name), + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceTwo.Name), Port: &port, }, }, @@ -529,36 +530,36 @@ func TestHTTPMeshService(t *testing.T) { _, gc := createGatewayClass(ctx, t, resources) require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") - httpsListener := createHTTPSListener(ctx, t, gateway.PortNumber(e2e.HTTPPort(ctx))) - gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{httpsListener}) + httpsListener := createHTTPSListener(ctx, t, gwv1beta1.PortNumber(e2e.HTTPPort(ctx))) + gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{httpsListener}) require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") // route 1 - port := gateway.PortNumber(serviceOne.Spec.Ports[0].Port) + port := gwv1alpha2.PortNumber(serviceOne.Spec.Ports[0].Port) path := "/v1" - pathMatch := gateway.PathMatchExact - routeOne := &gateway.HTTPRoute{ + pathMatch := gwv1alpha2.PathMatchExact + routeOne := &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeOneName, Namespace: namespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Rules: []gateway.HTTPRouteRule{{ - Matches: []gateway.HTTPRouteMatch{{ - Path: &gateway.HTTPPathMatch{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + Matches: []gwv1alpha2.HTTPRouteMatch{{ + Path: &gwv1alpha2.HTTPPathMatch{ Type: &pathMatch, Value: &path, }, }}, - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceOne.Name), + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceOne.Name), Port: &port, }, }, @@ -570,48 +571,48 @@ func TestHTTPMeshService(t *testing.T) { require.NoError(t, err) // route 2 - port = gateway.PortNumber(serviceTwo.Spec.Ports[0].Port) - portFour := gateway.PortNumber(serviceFour.Spec.Ports[0].Port) - portFive := gateway.PortNumber(serviceFive.Spec.Ports[0].Port) + port = gwv1alpha2.PortNumber(serviceTwo.Spec.Ports[0].Port) + portFour := gwv1alpha2.PortNumber(serviceFour.Spec.Ports[0].Port) + portFive := gwv1alpha2.PortNumber(serviceFive.Spec.Ports[0].Port) path = "/v2" - route := &gateway.HTTPRoute{ + route := &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeTwoName, Namespace: namespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Rules: []gateway.HTTPRouteRule{{ - Matches: []gateway.HTTPRouteMatch{{ - Path: &gateway.HTTPPathMatch{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + Matches: []gwv1alpha2.HTTPRouteMatch{{ + Path: &gwv1alpha2.HTTPPathMatch{ Type: &pathMatch, Value: &path, }, }}, - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceTwo.Name), + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceTwo.Name), Port: &port, }, }, }}, }, { - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceFour.Name), + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceFour.Name), Port: &portFour, }, }, }, { - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceFive.Name), + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceFive.Name), Port: &portFive, }, }, @@ -623,37 +624,37 @@ func TestHTTPMeshService(t *testing.T) { require.NoError(t, err) // route 3 - port = gateway.PortNumber(serviceThree.Spec.Ports[0].Port) + port = gwv1alpha2.PortNumber(serviceThree.Spec.Ports[0].Port) path = "/v3" - headerMatch := gateway.HeaderMatchExact - route = &gateway.HTTPRoute{ + headerMatch := gwv1alpha2.HeaderMatchExact + route = &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeThreeName, Namespace: namespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Hostnames: []gateway.Hostname{"test.host"}, - Rules: []gateway.HTTPRouteRule{{ - Matches: []gateway.HTTPRouteMatch{{ - Path: &gateway.HTTPPathMatch{ + Hostnames: []gwv1alpha2.Hostname{"test.host"}, + Rules: []gwv1alpha2.HTTPRouteRule{{ + Matches: []gwv1alpha2.HTTPRouteMatch{{ + Path: &gwv1alpha2.HTTPPathMatch{ Type: &pathMatch, Value: &path, }, - Headers: []gateway.HTTPHeaderMatch{{ + Headers: []gwv1alpha2.HTTPHeaderMatch{{ Type: &headerMatch, - Name: gateway.HTTPHeaderName("x-v3"), + Name: gwv1alpha2.HTTPHeaderName("x-v3"), Value: "v3", }}, }}, - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceThree.Name), + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceThree.Name), Port: &port, }, }, @@ -768,17 +769,17 @@ func TestTCPMeshService(t *testing.T) { _, gc := createGatewayClass(ctx, t, resources) require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") - gw := &gateway.Gateway{ + gw := &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: gatewayName, Namespace: namespace, }, - Spec: gateway.GatewaySpec{ - GatewayClassName: gateway.ObjectName(gc.Name), - Listeners: []gateway.Listener{{ + Spec: gwv1beta1.GatewaySpec{ + GatewayClassName: gwv1beta1.ObjectName(gc.Name), + Listeners: []gwv1beta1.Listener{{ Name: "tcp", - Port: gateway.PortNumber(e2e.TCPPort(ctx)), - Protocol: gateway.TCPProtocolType, + Port: gwv1beta1.PortNumber(e2e.TCPPort(ctx)), + Protocol: gwv1beta1.TCPProtocolType, }}, }, } @@ -787,36 +788,36 @@ func TestTCPMeshService(t *testing.T) { require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") // route 1 - portOne := gateway.PortNumber(serviceOne.Spec.Ports[0].Port) - portTwo := gateway.PortNumber(serviceTwo.Spec.Ports[0].Port) - portThree := gateway.PortNumber(serviceThree.Spec.Ports[0].Port) - routeOne := &gateway.TCPRoute{ + portOne := gwv1alpha2.PortNumber(serviceOne.Spec.Ports[0].Port) + portTwo := gwv1alpha2.PortNumber(serviceTwo.Spec.Ports[0].Port) + portThree := gwv1alpha2.PortNumber(serviceThree.Spec.Ports[0].Port) + routeOne := &gwv1alpha2.TCPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeOneName, Namespace: namespace, }, - Spec: gateway.TCPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.TCPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Rules: []gateway.TCPRouteRule{{ - BackendRefs: []gateway.BackendRef{{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceOne.Name), + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceOne.Name), Port: &portOne, }, }, { - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceTwo.Name), + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceTwo.Name), Port: &portTwo, }, }}, }, { - BackendRefs: []gateway.BackendRef{{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceThree.Name), + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceThree.Name), Port: &portThree, }, }}, @@ -838,26 +839,26 @@ func TestTCPMeshService(t *testing.T) { ), checkTimeout, checkInterval, "route status not set in allotted time") // route 2 - meshServiceGroup := gateway.Group(apigwv1alpha1.Group) - meshServiceKind := gateway.Kind(apigwv1alpha1.MeshServiceKind) + meshServiceGroup := gwv1alpha2.Group(apigwv1alpha1.Group) + meshServiceKind := gwv1alpha2.Kind(apigwv1alpha1.MeshServiceKind) // this routes to service four - route := &gateway.TCPRoute{ + route := &gwv1alpha2.TCPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeTwoName, Namespace: namespace, }, - Spec: gateway.TCPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.TCPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), }}, }, - Rules: []gateway.TCPRouteRule{{ - BackendRefs: []gateway.BackendRef{{ - BackendObjectReference: gateway.BackendObjectReference{ + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ Group: &meshServiceGroup, Kind: &meshServiceKind, - Name: gateway.ObjectName(meshServiceName), + Name: gwv1alpha2.ObjectName(meshServiceName), }, }}, }}, @@ -889,41 +890,41 @@ func TestTCPMeshService(t *testing.T) { listenerOnePort := e2e.TCPTLSPort(ctx) listenerTwoPort := e2e.ExtraTCPTLSPort(ctx) - gatewayNamespace := gateway.Namespace(namespace) + gatewayNamespace := gwv1beta1.Namespace(namespace) resources := cfg.Client().Resources(namespace) _, gc := createGatewayClass(ctx, t, resources) require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") - gw := &gateway.Gateway{ + gw := &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: gatewayName, Namespace: namespace, }, - Spec: gateway.GatewaySpec{ - GatewayClassName: gateway.ObjectName(gc.Name), - Listeners: []gateway.Listener{ + Spec: gwv1beta1.GatewaySpec{ + GatewayClassName: gwv1beta1.ObjectName(gc.Name), + Listeners: []gwv1beta1.Listener{ { - Name: gateway.SectionName(listenerOneName), - Port: gateway.PortNumber(listenerOnePort), - Protocol: gateway.TCPProtocolType, - TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []gateway.SecretObjectReference{{ + Name: gwv1beta1.SectionName(listenerOneName), + Port: gwv1beta1.PortNumber(listenerOnePort), + Protocol: gwv1beta1.TCPProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gatewayNamespace, }}, }, }, { - Name: gateway.SectionName(listenerTwoName), - Port: gateway.PortNumber(listenerTwoPort), - Protocol: gateway.TCPProtocolType, - TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []gateway.SecretObjectReference{{ + Name: gwv1beta1.SectionName(listenerTwoName), + Port: gwv1beta1.PortNumber(listenerTwoPort), + Protocol: gwv1beta1.TCPProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gatewayNamespace, }}, - Options: map[gateway.AnnotationKey]gateway.AnnotationValue{ + Options: map[gwv1beta1.AnnotationKey]gwv1beta1.AnnotationValue{ "api-gateway.consul.hashicorp.com/tls_min_version": "TLSv1_1", "api-gateway.consul.hashicorp.com/tls_cipher_suites": "TLS_RSA_WITH_AES_128_CBC_SHA", }, @@ -936,8 +937,8 @@ func TestTCPMeshService(t *testing.T) { require.NoError(t, err) require.Eventually(t, gatewayStatusCheck(ctx, resources, gatewayName, namespace, conditionReady), checkTimeout, checkInterval, "no gateway found in the allotted time") - createTCPRoute(ctx, t, resources, namespace, gatewayName, gateway.SectionName(listenerOneName), routeOneName, serviceOne.Name, gateway.PortNumber(serviceOne.Spec.Ports[0].Port)) - createTCPRoute(ctx, t, resources, namespace, gatewayName, gateway.SectionName(listenerTwoName), routeTwoName, serviceTwo.Name, gateway.PortNumber(serviceTwo.Spec.Ports[0].Port)) + createTCPRoute(ctx, t, resources, namespace, gatewayName, gwv1alpha2.SectionName(listenerOneName), routeOneName, serviceOne.Name, gwv1alpha2.PortNumber(serviceOne.Spec.Ports[0].Port)) + createTCPRoute(ctx, t, resources, namespace, gatewayName, gwv1alpha2.SectionName(listenerTwoName), routeTwoName, serviceTwo.Name, gwv1alpha2.PortNumber(serviceTwo.Spec.Ports[0].Port)) checkTCPTLSRoute(t, listenerOnePort, &tls.Config{ InsecureSkipVerify: true, @@ -1005,22 +1006,23 @@ func TestReferenceGrantLifecycle(t *testing.T) { // Allow routes to bind from a different namespace for testing // cross-namespace ReferenceGrant enforcement - fromSelector := gateway.NamespacesFromSelector + fromSelector := gwv1beta1.NamespacesFromSelector - gwNamespace := gateway.Namespace(namespace) - gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gateway.Listener{ + gwNamespace := gwv1beta1.Namespace(namespace) + routeGatewayNamespace := gwv1alpha2.Namespace(namespace) + gw := createGateway(ctx, t, resources, gatewayName, namespace, gc, []gwv1beta1.Listener{ { Name: "https", - Port: gateway.PortNumber(httpCheckPort), - Protocol: gateway.HTTPSProtocolType, - TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []gateway.SecretObjectReference{{ + Port: gwv1beta1.PortNumber(httpCheckPort), + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gwNamespace, }}, }, - AllowedRoutes: &gateway.AllowedRoutes{ - Namespaces: &gateway.RouteNamespaces{ + AllowedRoutes: &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &fromSelector, Selector: &meta.LabelSelector{ MatchExpressions: []meta.LabelSelectorRequirement{{ @@ -1034,10 +1036,10 @@ func TestReferenceGrantLifecycle(t *testing.T) { }, { Name: "tcp", - Port: gateway.PortNumber(tcpCheckPort), - Protocol: gateway.TCPProtocolType, - AllowedRoutes: &gateway.AllowedRoutes{ - Namespaces: &gateway.RouteNamespaces{ + Port: gwv1beta1.PortNumber(tcpCheckPort), + Protocol: gwv1beta1.TCPProtocolType, + AllowedRoutes: &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &fromSelector, Selector: &meta.LabelSelector{ MatchExpressions: []meta.LabelSelectorRequirement{{ @@ -1070,26 +1072,26 @@ func TestReferenceGrantLifecycle(t *testing.T) { err = resources.Create(ctx, tcpNs) require.NoError(t, err) - httpPort := gateway.PortNumber(serviceOne.Spec.Ports[0].Port) - httpRoute := &gateway.HTTPRoute{ + httpPort := gwv1alpha2.PortNumber(serviceOne.Spec.Ports[0].Port) + httpRoute := &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: httpRouteName, Namespace: httpRouteNamespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), - Namespace: &gwNamespace, + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), + Namespace: &routeGatewayNamespace, }}, }, - Hostnames: []gateway.Hostname{"test.foo"}, - Rules: []gateway.HTTPRouteRule{{ - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceOne.Name), - Namespace: &gwNamespace, + Hostnames: []gwv1alpha2.Hostname{"test.foo"}, + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceOne.Name), + Namespace: &routeGatewayNamespace, Port: &httpPort, }, }, @@ -1116,24 +1118,25 @@ func TestReferenceGrantLifecycle(t *testing.T) { ) require.Eventually(t, httpRouteStatusCheckRefNotPermitted, checkTimeout, checkInterval, "HTTPRoute status not set in allotted time") - tcpPort := gateway.PortNumber(serviceTwo.Spec.Ports[0].Port) - tcpRoute := &gateway.TCPRoute{ + tcpNamespace := gwv1alpha2.Namespace(namespace) + tcpPort := gwv1alpha2.PortNumber(serviceTwo.Spec.Ports[0].Port) + tcpRoute := &gwv1alpha2.TCPRoute{ ObjectMeta: meta.ObjectMeta{ Name: tcpRouteName, Namespace: tcpRouteNamespace, }, - Spec: gateway.TCPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), - Namespace: &gwNamespace, + Spec: gwv1alpha2.TCPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), + Namespace: &tcpNamespace, }}, }, - Rules: []gateway.TCPRouteRule{{ - BackendRefs: []gateway.BackendRef{{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceTwo.Name), - Namespace: &gwNamespace, + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceTwo.Name), + Namespace: &tcpNamespace, Port: &tcpPort, }, }}, @@ -1144,19 +1147,19 @@ func TestReferenceGrantLifecycle(t *testing.T) { require.NoError(t, err) // create ReferenceGrant allowing HTTPRoute BackendRef - serviceOneObjectName := gateway.ObjectName(serviceOne.Name) - httpRouteReferenceGrant := &gateway.ReferenceGrant{ + serviceOneObjectName := gwv1alpha2.ObjectName(serviceOne.Name) + httpRouteReferenceGrant := &gwv1alpha2.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{ Name: httpRouteRefGrantName, Namespace: namespace, }, - Spec: gateway.ReferenceGrantSpec{ - From: []gateway.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "HTTPRoute", - Namespace: gateway.Namespace(httpRouteNamespace), + Namespace: gwv1alpha2.Namespace(httpRouteNamespace), }}, - To: []gateway.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: &serviceOneObjectName, @@ -1206,19 +1209,19 @@ func TestReferenceGrantLifecycle(t *testing.T) { require.Eventually(t, tcpRouteStatusCheckRefNotPermitted, checkTimeout, checkInterval, "TCPRoute status not set in allotted time") // create ReferenceGrant allowing TCPRoute BackendRef - serviceTwoObjectName := gateway.ObjectName(serviceTwo.Name) - tcpRouteReferenceGrant := &gateway.ReferenceGrant{ + serviceTwoObjectName := gwv1alpha2.ObjectName(serviceTwo.Name) + tcpRouteReferenceGrant := &gwv1alpha2.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{ Name: tcpRouteRefGrantName, Namespace: namespace, }, - Spec: gateway.ReferenceGrantSpec{ - From: []gateway.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "TCPRoute", - Namespace: gateway.Namespace(tcpRouteNamespace), + Namespace: gwv1alpha2.Namespace(tcpRouteNamespace), }}, - To: []gateway.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: &serviceTwoObjectName, @@ -1307,23 +1310,23 @@ func TestReferenceGrantLifecycle(t *testing.T) { _, gc := createGatewayClass(ctx, t, resources) require.Eventually(t, gatewayClassStatusCheck(ctx, resources, gc.Name, namespace, conditionAccepted), checkTimeout, checkInterval, "gatewayclass not accepted in the allotted time") - fromSelector := gateway.NamespacesFromAll + fromSelector := gwv1beta1.NamespacesFromAll // Create a Gateway with a listener that has a CertificateRef to a different namespace - certNamespaceTyped := gateway.Namespace(certNamespace) - gw := createGateway(ctx, t, resources, gatewayName, gatewayNamespace, gc, []gateway.Listener{ + certNamespaceTyped := gwv1beta1.Namespace(certNamespace) + gw := createGateway(ctx, t, resources, gatewayName, gatewayNamespace, gc, []gwv1beta1.Listener{ { Name: "https", - Port: gateway.PortNumber(e2e.HTTPReferenceGrantPort(ctx)), - Protocol: gateway.HTTPSProtocolType, - TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []gateway.SecretObjectReference{{ - Name: gateway.ObjectName(certName), + Port: gwv1beta1.PortNumber(e2e.HTTPReferenceGrantPort(ctx)), + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ + Name: gwv1beta1.ObjectName(certName), Namespace: &certNamespaceTyped, }}, }, - AllowedRoutes: &gateway.AllowedRoutes{ - Namespaces: &gateway.RouteNamespaces{ + AllowedRoutes: &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &fromSelector, }, }, @@ -1343,18 +1346,18 @@ func TestReferenceGrantLifecycle(t *testing.T) { require.Eventually(t, listenerCheck, checkTimeout, checkInterval, "Gateway listener status not set in allotted time") // Create ReferenceGrant allowing Gateway CertificateRef - certReferenceGrant := &gateway.ReferenceGrant{ + certReferenceGrant := &gwv1alpha2.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{ Name: gatewayRefGrantName, Namespace: string(certNamespace), }, - Spec: gateway.ReferenceGrantSpec{ - From: []gateway.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "Gateway", - Namespace: gateway.Namespace(gatewayNamespace), + Namespace: gwv1alpha2.Namespace(gatewayNamespace), }}, - To: []gateway.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Group: "", Kind: "Secret", Name: nil, @@ -1400,7 +1403,7 @@ func TestRouteParentRefChange(t *testing.T) { require.NoError(t, err) namespace := e2e.Namespace(ctx) - gwNamespace := gateway.Namespace(namespace) + routeGatewayNamespace := gwv1alpha2.Namespace(namespace) resources := cfg.Client().Resources(namespace) _, gc := createGatewayClass(ctx, t, resources) @@ -1416,29 +1419,29 @@ func TestRouteParentRefChange(t *testing.T) { firstGatewayName, namespace, gc, - []gateway.Listener{createHTTPSListener(ctx, t, gateway.PortNumber(firstGatewayCheckPort))}, + []gwv1beta1.Listener{createHTTPSListener(ctx, t, gwv1beta1.PortNumber(firstGatewayCheckPort))}, ) require.Eventually(t, gatewayStatusCheck(ctx, resources, firstGatewayName, namespace, conditionReady), 30*time.Second, checkInterval, "no gateway found in the allotted time") // Create route with ParentRef targeting first gateway httpRouteName := envconf.RandomName("httproute", 16) - httpPort := gateway.PortNumber(serviceOne.Spec.Ports[0].Port) - httpRoute := &gateway.HTTPRoute{ + httpPort := gwv1alpha2.PortNumber(serviceOne.Spec.Ports[0].Port) + httpRoute := &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: httpRouteName, Namespace: namespace, }, - Spec: gateway.HTTPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(firstGatewayName), + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(firstGatewayName), }}, }, - Rules: []gateway.HTTPRouteRule{{ - BackendRefs: []gateway.HTTPBackendRef{{ - BackendRef: gateway.BackendRef{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceOne.Name), + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceOne.Name), Port: &httpPort, }, }, @@ -1485,20 +1488,20 @@ func TestRouteParentRefChange(t *testing.T) { secondGatewayName, namespace, gc, - []gateway.Listener{createHTTPSListener(ctx, t, gateway.PortNumber(secondGatewayCheckPort))}, + []gwv1beta1.Listener{createHTTPSListener(ctx, t, gwv1beta1.PortNumber(secondGatewayCheckPort))}, ) require.Eventually(t, gatewayStatusCheck(ctx, resources, secondGatewayName, namespace, conditionReady), 30*time.Second, checkInterval, "no gateway found in the allotted time") // Update httpRoute from remote, then add second gateway ParentRef require.NoError(t, resources.Get(ctx, httpRouteName, namespace, httpRoute)) - httpRoute.Spec.CommonRouteSpec.ParentRefs = []gateway.ParentReference{ + httpRoute.Spec.CommonRouteSpec.ParentRefs = []gwv1alpha2.ParentReference{ { - Name: gateway.ObjectName(firstGatewayName), - Namespace: &gwNamespace, + Name: gwv1alpha2.ObjectName(firstGatewayName), + Namespace: &routeGatewayNamespace, }, { - Name: gateway.ObjectName(secondGatewayName), - Namespace: &gwNamespace, + Name: gwv1alpha2.ObjectName(secondGatewayName), + Namespace: &routeGatewayNamespace, }, } require.NoError(t, resources.Update(ctx, httpRoute)) @@ -1536,15 +1539,15 @@ func TestRouteParentRefChange(t *testing.T) { // Update httpRoute from remote, then remove first gateway ParentRef require.NoError(t, resources.Get(ctx, httpRouteName, namespace, httpRoute)) - httpRoute.Spec.CommonRouteSpec.ParentRefs = []gateway.ParentReference{{ - Name: gateway.ObjectName(secondGatewayName), - Namespace: &gwNamespace, + httpRoute.Spec.CommonRouteSpec.ParentRefs = []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(secondGatewayName), + Namespace: &routeGatewayNamespace, }} require.NoError(t, resources.Update(ctx, httpRoute)) // Check that route unbinds from first gateway listener successfully require.Eventually(t, func() bool { - updated := &gateway.HTTPRoute{} + updated := &gwv1alpha2.HTTPRoute{} if err := resources.Get(ctx, httpRouteName, namespace, updated); err != nil { return false } @@ -1579,7 +1582,7 @@ func TestRouteParentRefChange(t *testing.T) { func gatewayStatusCheck(ctx context.Context, resources *resources.Resources, gatewayName, namespace string, checkFn func([]meta.Condition) bool) func() bool { return func() bool { - updated := &gateway.Gateway{} + updated := &gwv1beta1.Gateway{} if err := resources.Get(ctx, gatewayName, namespace, updated); err != nil { return false } @@ -1605,7 +1608,7 @@ func deploymentReplicasSetAsExpected(ctx context.Context, resources *resources.R func gatewayClassStatusCheck(ctx context.Context, resources *resources.Resources, gatewayClassName, namespace string, checkFn func([]meta.Condition) bool) func() bool { return func() bool { - updated := &gateway.GatewayClass{} + updated := &gwv1beta1.GatewayClass{} if err := resources.Get(ctx, gatewayClassName, namespace, updated); err != nil { return false } @@ -1614,9 +1617,9 @@ func gatewayClassStatusCheck(ctx context.Context, resources *resources.Resources } } -func listenerStatusCheck(ctx context.Context, resources *resources.Resources, gatewayName, namespace string, checkFn func(gateway.ListenerStatus) bool) func() bool { +func listenerStatusCheck(ctx context.Context, resources *resources.Resources, gatewayName, namespace string, checkFn func(gwv1beta1.ListenerStatus) bool) func() bool { return func() bool { - updated := &gateway.Gateway{} + updated := &gwv1beta1.Gateway{} if err := resources.Get(ctx, gatewayName, namespace, updated); err != nil { return false } @@ -1633,7 +1636,7 @@ func listenerStatusCheck(ctx context.Context, resources *resources.Resources, ga func httpRouteStatusCheck(ctx context.Context, resources *resources.Resources, gatewayName, routeName, namespace string, checkFn func([]meta.Condition) bool) func() bool { return func() bool { - updated := &gateway.HTTPRoute{} + updated := &gwv1alpha2.HTTPRoute{} if err := resources.Get(ctx, routeName, namespace, updated); err != nil { return false } @@ -1648,7 +1651,7 @@ func httpRouteStatusCheck(ctx context.Context, resources *resources.Resources, g func tcpRouteStatusCheck(ctx context.Context, resources *resources.Resources, gatewayName, routeName, namespace string, checkFn func([]meta.Condition) bool) func() bool { return func() bool { - updated := &gateway.TCPRoute{} + updated := &gwv1alpha2.TCPRoute{} if err := resources.Get(ctx, routeName, namespace, updated); err != nil { return false } @@ -1661,18 +1664,18 @@ func tcpRouteStatusCheck(ctx context.Context, resources *resources.Resources, ga } } -func createListenerStatusConditionsCheck(expected []meta.Condition) func(gateway.ListenerStatus) bool { +func createListenerStatusConditionsCheck(expected []meta.Condition) func(gwv1beta1.ListenerStatus) bool { return createListenerStatusConditionsFnCheck(createConditionsCheck(expected)) } -func createListenerStatusConditionsFnCheck(checkFn func([]meta.Condition) bool) func(gateway.ListenerStatus) bool { - return func(actual gateway.ListenerStatus) bool { +func createListenerStatusConditionsFnCheck(checkFn func([]meta.Condition) bool) func(gwv1beta1.ListenerStatus) bool { + return func(actual gwv1beta1.ListenerStatus) bool { return checkFn(actual.Conditions) } } -func listenerAttachedRoutes(expectedRoutes int32, listenerNames ...string) func(gateway.ListenerStatus) bool { - return func(actual gateway.ListenerStatus) bool { +func listenerAttachedRoutes(expectedRoutes int32, listenerNames ...string) func(gwv1beta1.ListenerStatus) bool { + return func(actual gwv1beta1.ListenerStatus) bool { // Allow optionally specifying a specific listener name if len(listenerNames) > 0 && !slices.Contains(listenerNames, string(actual.Name)) { return false @@ -1726,18 +1729,18 @@ func conditionInSync(conditions []meta.Condition) bool { })(conditions) } -func createHTTPSListener(ctx context.Context, t *testing.T, port gateway.PortNumber) gateway.Listener { +func createHTTPSListener(ctx context.Context, t *testing.T, port gwv1beta1.PortNumber) gwv1beta1.Listener { t.Helper() namespace := e2e.Namespace(ctx) - gatewayNamespace := gateway.Namespace(namespace) + gatewayNamespace := gwv1beta1.Namespace(namespace) - return gateway.Listener{ + return gwv1beta1.Listener{ Name: "https", Port: port, - Protocol: gateway.HTTPSProtocolType, - TLS: &gateway.GatewayTLSConfig{ - CertificateRefs: []gateway.SecretObjectReference{{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "consul-server-cert", Namespace: &gatewayNamespace, }}, @@ -1745,16 +1748,16 @@ func createHTTPSListener(ctx context.Context, t *testing.T, port gateway.PortNum } } -func createGateway(ctx context.Context, t *testing.T, resources *resources.Resources, gatewayName, gatewayNamespace string, gc *gateway.GatewayClass, listeners []gateway.Listener) *gateway.Gateway { +func createGateway(ctx context.Context, t *testing.T, resources *resources.Resources, gatewayName, gatewayNamespace string, gc *gwv1beta1.GatewayClass, listeners []gwv1beta1.Listener) *gwv1beta1.Gateway { t.Helper() - gw := &gateway.Gateway{ + gw := &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: gatewayName, Namespace: gatewayNamespace, }, - Spec: gateway.GatewaySpec{ - GatewayClassName: gateway.ObjectName(gc.Name), + Spec: gwv1beta1.GatewaySpec{ + GatewayClassName: gwv1beta1.ObjectName(gc.Name), Listeners: listeners, }, } @@ -1772,11 +1775,11 @@ type GatewayClassConfigParams struct { MaxInstances *int32 } -func createGatewayClass(ctx context.Context, t *testing.T, resources *resources.Resources) (*apigwv1alpha1.GatewayClassConfig, *gateway.GatewayClass) { +func createGatewayClass(ctx context.Context, t *testing.T, resources *resources.Resources) (*apigwv1alpha1.GatewayClassConfig, *gwv1beta1.GatewayClass) { return createGatewayClassWithParams(ctx, t, resources, GatewayClassConfigParams{}) } -func createGatewayClassWithParams(ctx context.Context, t *testing.T, resources *resources.Resources, params GatewayClassConfigParams) (*apigwv1alpha1.GatewayClassConfig, *gateway.GatewayClass) { +func createGatewayClassWithParams(ctx context.Context, t *testing.T, resources *resources.Resources, params GatewayClassConfigParams) (*apigwv1alpha1.GatewayClassConfig, *gwv1beta1.GatewayClass) { t.Helper() // Expose ports on the Docker host @@ -1832,13 +1835,13 @@ func createGatewayClassWithParams(ctx context.Context, t *testing.T, resources * err := resources.Create(ctx, gcc) require.NoError(t, err) - gc := &gateway.GatewayClass{ + gc := &gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ Name: className, }, - Spec: gateway.GatewayClassSpec{ + Spec: gwv1beta1.GatewayClassSpec{ ControllerName: k8s.ControllerName, - ParametersRef: &gateway.ParametersReference{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: configName, @@ -1851,25 +1854,25 @@ func createGatewayClassWithParams(ctx context.Context, t *testing.T, resources * return gcc, gc } -func createTCPRoute(ctx context.Context, t *testing.T, resources *resources.Resources, namespace string, gatewayName string, listenerName gateway.SectionName, routeName string, serviceName string, port gateway.PortNumber) { +func createTCPRoute(ctx context.Context, t *testing.T, resources *resources.Resources, namespace string, gatewayName string, listenerName gwv1alpha2.SectionName, routeName string, serviceName string, port gwv1alpha2.PortNumber) { t.Helper() - route := &gateway.TCPRoute{ + route := &gwv1alpha2.TCPRoute{ ObjectMeta: meta.ObjectMeta{ Name: routeName, Namespace: namespace, }, - Spec: gateway.TCPRouteSpec{ - CommonRouteSpec: gateway.CommonRouteSpec{ - ParentRefs: []gateway.ParentReference{{ - Name: gateway.ObjectName(gatewayName), + Spec: gwv1alpha2.TCPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ + Name: gwv1alpha2.ObjectName(gatewayName), SectionName: &listenerName, }}, }, - Rules: []gateway.TCPRouteRule{{ - BackendRefs: []gateway.BackendRef{{ - BackendObjectReference: gateway.BackendObjectReference{ - Name: gateway.ObjectName(serviceName), + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName(serviceName), Port: &port, }, }}, @@ -1889,7 +1892,7 @@ func checkGatewayConfigAnnotation(ctx context.Context, t *testing.T, resources * expectedCfg, err := json.Marshal(gcc.Spec) require.NoError(t, err) - gw := &gateway.Gateway{} + gw := &gwv1beta1.Gateway{} require.Eventually(t, func() bool { err := resources.Get(ctx, gatewayName, namespace, gw) return err == nil diff --git a/internal/testing/e2e/kubernetes.go b/internal/testing/e2e/kubernetes.go index 467cbeb50..d4da3a8ce 100644 --- a/internal/testing/e2e/kubernetes.go +++ b/internal/testing/e2e/kubernetes.go @@ -23,7 +23,8 @@ import ( "sigs.k8s.io/e2e-framework/klient" "sigs.k8s.io/e2e-framework/pkg/env" "sigs.k8s.io/e2e-framework/pkg/envconf" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) type k8sTokenContext struct{} @@ -47,19 +48,24 @@ func InstallCRDs(ctx context.Context, cfg *envconf.Config) (context.Context, err // Register Gateway API types scheme.Scheme.AddKnownTypes( - gateway.SchemeGroupVersion, - &gateway.GatewayClass{}, - &gateway.GatewayClassList{}, - &gateway.Gateway{}, - &gateway.GatewayList{}, - &gateway.HTTPRoute{}, - &gateway.HTTPRouteList{}, - &gateway.TCPRoute{}, - &gateway.TCPRouteList{}, - &gateway.ReferenceGrant{}, - &gateway.ReferencePolicy{}, + gwv1beta1.SchemeGroupVersion, + &gwv1beta1.GatewayClass{}, + &gwv1beta1.GatewayClassList{}, + &gwv1beta1.Gateway{}, + &gwv1beta1.GatewayList{}, ) - meta.AddToGroupVersion(scheme.Scheme, gateway.SchemeGroupVersion) + meta.AddToGroupVersion(scheme.Scheme, gwv1beta1.SchemeGroupVersion) + + scheme.Scheme.AddKnownTypes( + gwv1alpha2.SchemeGroupVersion, + &gwv1alpha2.HTTPRoute{}, + &gwv1alpha2.HTTPRouteList{}, + &gwv1alpha2.TCPRoute{}, + &gwv1alpha2.TCPRouteList{}, + &gwv1alpha2.ReferenceGrant{}, + &gwv1alpha2.ReferencePolicy{}, + ) + meta.AddToGroupVersion(scheme.Scheme, gwv1alpha2.SchemeGroupVersion) // Register Consul API Gateway types consulapigw.RegisterTypes(scheme.Scheme) From 6bbb8040c8e5f00755b05fbe2c99ceb40fb0327c Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 16 Jun 2022 18:37:37 -0400 Subject: [PATCH 14/17] k8s: move Gateway API usage to v1beta1 or explicitly v1alpha2 for Routes and ReferenceGrant gateway-api: add ReferencePolicy backwards compatibility support mocks: regenerate k8s/controller: add gwv1alpha2 to scheme k8s/gatewayclient: add gwv1alpha2 to scheme for test helpers --- internal/k8s/builder/gateway.go | 10 +- internal/k8s/builder/gateway_test.go | 10 +- internal/k8s/controller.go | 6 +- .../gateway_class_config_controller_test.go | 16 +- .../controllers/gateway_class_controller.go | 4 +- .../gateway_class_controller_test.go | 50 +-- .../k8s/controllers/gateway_controller.go | 35 +- .../k8s/controllers/http_route_controller.go | 33 +- .../controllers/http_route_controller_test.go | 193 ++++---- .../k8s/controllers/tcp_route_controller.go | 33 +- .../controllers/tcp_route_controller_test.go | 193 ++++---- internal/k8s/gatewayclient/gatewayclient.go | 100 +++-- .../k8s/gatewayclient/gatewayclient_test.go | 51 +-- .../k8s/gatewayclient/mocks/gatewayclient.go | 25 +- internal/k8s/gatewayclient/test_helpers.go | 6 +- internal/k8s/reconciler/gateway.go | 24 +- internal/k8s/reconciler/gateway_test.go | 161 +++---- internal/k8s/reconciler/gatewayclass.go | 6 +- internal/k8s/reconciler/gatewayclass_test.go | 28 +- internal/k8s/reconciler/http_route.go | 58 +-- internal/k8s/reconciler/http_route_test.go | 54 +-- internal/k8s/reconciler/listener.go | 45 +- internal/k8s/reconciler/listener_test.go | 417 +++++++++--------- internal/k8s/reconciler/manager.go | 13 +- internal/k8s/reconciler/manager_test.go | 47 +- internal/k8s/reconciler/mocks/manager.go | 6 +- internal/k8s/reconciler/route.go | 103 ++--- internal/k8s/reconciler/route_test.go | 269 +++++------ internal/k8s/reconciler/tcp_route.go | 4 +- internal/k8s/reconciler/utils.go | 63 +-- internal/k8s/reconciler/utils_test.go | 246 ++++++----- internal/k8s/service/resolver.go | 17 +- internal/k8s/service/rule.go | 18 +- internal/k8s/utils/consul.go | 14 +- internal/k8s/utils/consul_test.go | 14 +- internal/k8s/utils/labels.go | 4 +- internal/k8s/utils/labels_test.go | 4 +- internal/k8s/utils/reference.go | 9 +- pkg/apis/v1alpha1/types.go | 4 +- 39 files changed, 1211 insertions(+), 1182 deletions(-) diff --git a/internal/k8s/builder/gateway.go b/internal/k8s/builder/gateway.go index 8e9fe63a6..4ca6a1cf2 100644 --- a/internal/k8s/builder/gateway.go +++ b/internal/k8s/builder/gateway.go @@ -10,18 +10,18 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/k8s/utils" "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" ) type GatewayServiceBuilder struct { - gateway *gw.Gateway + gateway *gwv1beta1.Gateway gwConfig *v1alpha1.GatewayClassConfig } -func NewGatewayService(gw *gw.Gateway) *GatewayServiceBuilder { +func NewGatewayService(gw *gwv1beta1.Gateway) *GatewayServiceBuilder { return &GatewayServiceBuilder{gateway: gw} } @@ -80,7 +80,7 @@ func filterAnnotations(annotations map[string]string, allowed []string) map[stri } type GatewayDeploymentBuilder struct { - gateway *gw.Gateway + gateway *gwv1beta1.Gateway gwConfig *v1alpha1.GatewayClassConfig sdsHost string sdsPort int @@ -88,7 +88,7 @@ type GatewayDeploymentBuilder struct { consulGatewayNamespace string } -func NewGatewayDeployment(gw *gw.Gateway) *GatewayDeploymentBuilder { +func NewGatewayDeployment(gw *gwv1beta1.Gateway) *GatewayDeploymentBuilder { return &GatewayDeploymentBuilder{gateway: gw} } diff --git a/internal/k8s/builder/gateway_test.go b/internal/k8s/builder/gateway_test.go index c9e917a56..447999061 100644 --- a/internal/k8s/builder/gateway_test.go +++ b/internal/k8s/builder/gateway_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/apimachinery/pkg/util/yaml" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" ) @@ -37,15 +37,15 @@ func init() { type gatewayTestConfig struct { gatewayClassConfig *v1alpha1.GatewayClassConfig - gatewayClass *gateway.GatewayClass - gateway *gateway.Gateway + gatewayClass *gwv1beta1.GatewayClass + gateway *gwv1beta1.Gateway } func newGatewayTestConfig() *gatewayTestConfig { return &gatewayTestConfig{ gatewayClassConfig: &v1alpha1.GatewayClassConfig{}, - gatewayClass: &gateway.GatewayClass{}, - gateway: &gateway.Gateway{}, + gatewayClass: &gwv1beta1.GatewayClass{}, + gateway: &gwv1beta1.Gateway{}, } } diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index e44cb2bab..5a8629879 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -11,7 +11,8 @@ import ( klogv2 "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/healthz" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-hclog" @@ -41,7 +42,8 @@ const ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(gw.AddToScheme(scheme)) + utilruntime.Must(gwv1beta1.AddToScheme(scheme)) + utilruntime.Must(gwv1alpha2.AddToScheme(scheme)) } type ConsulNamespaceConfig struct { diff --git a/internal/k8s/controllers/gateway_class_config_controller_test.go b/internal/k8s/controllers/gateway_class_config_controller_test.go index f1f7a4788..f1c838984 100644 --- a/internal/k8s/controllers/gateway_class_config_controller_test.go +++ b/internal/k8s/controllers/gateway_class_config_controller_test.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/reconcile" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -106,23 +106,23 @@ func TestGatewayClassConfig(t *testing.T) { err: errExpected, expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { client.EXPECT().GetGatewayClassConfig(gomock.Any(), classConfigName).Return(&apigwv1alpha1.GatewayClassConfig{}, nil) - client.EXPECT().GatewayClassesUsingConfig(gomock.Any(), gomock.Any()).Return(&gateway.GatewayClassList{}, nil) + client.EXPECT().GatewayClassesUsingConfig(gomock.Any(), gomock.Any()).Return(&gwv1beta1.GatewayClassList{}, nil) client.EXPECT().EnsureFinalizer(gomock.Any(), gomock.Any(), gatewayClassConfigFinalizer).Return(false, errExpected) }, }, { name: "create", expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { client.EXPECT().GetGatewayClassConfig(gomock.Any(), classConfigName).Return(&apigwv1alpha1.GatewayClassConfig{}, nil) - client.EXPECT().GatewayClassesUsingConfig(gomock.Any(), gomock.Any()).Return(&gateway.GatewayClassList{}, nil) + client.EXPECT().GatewayClassesUsingConfig(gomock.Any(), gomock.Any()).Return(&gwv1beta1.GatewayClassList{}, nil) client.EXPECT().EnsureFinalizer(gomock.Any(), gomock.Any(), gatewayClassConfigFinalizer).Return(true, nil) }, }, { name: "update-in-use", expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { - gcUsing := gateway.GatewayClass{ + gcUsing := gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{Name: "class"}, - Spec: gateway.GatewayClassSpec{ - ParametersRef: &gateway.ParametersReference{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "config", @@ -131,8 +131,8 @@ func TestGatewayClassConfig(t *testing.T) { } client.EXPECT().GetGatewayClassConfig(gomock.Any(), classConfigName).Return(&apigwv1alpha1.GatewayClassConfig{}, nil) - client.EXPECT().GatewayClassesUsingConfig(gomock.Any(), gomock.Any()).Return(&gateway.GatewayClassList{ - Items: []gateway.GatewayClass{gcUsing}, + client.EXPECT().GatewayClassesUsingConfig(gomock.Any(), gomock.Any()).Return(&gwv1beta1.GatewayClassList{ + Items: []gwv1beta1.GatewayClass{gcUsing}, }, nil) reconciler.EXPECT().DeleteGatewayClass(gomock.Any(), gcUsing.Name).Return(nil) client.EXPECT().EnsureFinalizer(gomock.Any(), gomock.Any(), gatewayClassConfigFinalizer).Return(true, nil) diff --git a/internal/k8s/controllers/gateway_class_controller.go b/internal/k8s/controllers/gateway_class_controller.go index 7c51955e1..79c63a455 100644 --- a/internal/k8s/controllers/gateway_class_controller.go +++ b/internal/k8s/controllers/gateway_class_controller.go @@ -5,7 +5,7 @@ import ( "time" ctrl "sigs.k8s.io/controller-runtime" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient" "github.com/hashicorp/consul-api-gateway/internal/k8s/reconciler" @@ -92,6 +92,6 @@ func (r *GatewayClassReconciler) Reconcile(ctx context.Context, req ctrl.Request // SetupWithManager sets up the controller with the Manager. func (r *GatewayClassReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&gateway.GatewayClass{}). + For(&gwv1beta1.GatewayClass{}). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } diff --git a/internal/k8s/controllers/gateway_class_controller_test.go b/internal/k8s/controllers/gateway_class_controller_test.go index f9ae79f86..8856fb38a 100644 --- a/internal/k8s/controllers/gateway_class_controller_test.go +++ b/internal/k8s/controllers/gateway_class_controller_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/reconcile" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient/mocks" reconcilerMocks "github.com/hashicorp/consul-api-gateway/internal/k8s/reconciler/mocks" @@ -53,9 +53,9 @@ func TestGatewayClass(t *testing.T) { }, { name: "not-managed", expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController("other"), + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController("other"), }, }, nil) }, @@ -64,12 +64,12 @@ func TestGatewayClass(t *testing.T) { err: errExpected, expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { now := meta.Now() - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ DeletionTimestamp: &now, }, - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().GatewayClassInUse(gomock.Any(), gomock.Any()).Return(false, errExpected) @@ -79,12 +79,12 @@ func TestGatewayClass(t *testing.T) { result: ctrl.Result{RequeueAfter: 10 * time.Second}, expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { now := meta.Now() - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ DeletionTimestamp: &now, }, - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().GatewayClassInUse(gomock.Any(), gomock.Any()).Return(true, nil) @@ -94,12 +94,12 @@ func TestGatewayClass(t *testing.T) { err: errExpected, expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { now := meta.Now() - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ DeletionTimestamp: &now, }, - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().GatewayClassInUse(gomock.Any(), gomock.Any()).Return(false, nil) @@ -109,12 +109,12 @@ func TestGatewayClass(t *testing.T) { name: "deleting", expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { now := meta.Now() - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ DeletionTimestamp: &now, }, - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().GatewayClassInUse(gomock.Any(), gomock.Any()).Return(false, nil) @@ -124,9 +124,9 @@ func TestGatewayClass(t *testing.T) { name: "create-finalizer-error", err: errExpected, expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().EnsureFinalizer(gomock.Any(), gomock.Any(), gatewayClassFinalizer).Return(false, errExpected) @@ -134,9 +134,9 @@ func TestGatewayClass(t *testing.T) { }, { name: "create-finalizer-updated", expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().EnsureFinalizer(gomock.Any(), gomock.Any(), gatewayClassFinalizer).Return(true, nil) @@ -145,9 +145,9 @@ func TestGatewayClass(t *testing.T) { name: "create-upsert-error", err: errExpected, expectationCB: func(client *mocks.MockClient, reconciler *reconcilerMocks.MockReconcileManager) { - client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gateway.GatewayClass{ - Spec: gateway.GatewayClassSpec{ - ControllerName: gateway.GatewayController(mockControllerName), + client.EXPECT().GetGatewayClass(gomock.Any(), className).Return(&gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ControllerName: gwv1beta1.GatewayController(mockControllerName), }, }, nil) client.EXPECT().EnsureFinalizer(gomock.Any(), gomock.Any(), gatewayClassFinalizer).Return(false, nil) diff --git a/internal/k8s/controllers/gateway_controller.go b/internal/k8s/controllers/gateway_controller.go index 962e57d7f..ef710af84 100644 --- a/internal/k8s/controllers/gateway_controller.go +++ b/internal/k8s/controllers/gateway_controller.go @@ -14,7 +14,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -86,7 +87,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { ) return ctrl.NewControllerManagedBy(mgr). - For(&gateway.Gateway{}). + For(&gwv1beta1.Gateway{}). Owns(&appsv1.Deployment{}). Owns(&corev1.Service{}). Owns(&corev1.ServiceAccount{}). @@ -96,14 +97,13 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { builder.WithPredicates(predicate), ). Watches( - &source.Kind{Type: &gateway.ReferenceGrant{}}, + &source.Kind{Type: &gwv1alpha2.ReferenceGrant{}}, handler.EnqueueRequestsFromMapFunc(r.referenceGrantToGatewayRequests), ). - // TODO: this can't be enabled until the ReferencePolicy object is restored - // Watches( - // &source.Kind{Type: &gateway.ReferencePolicy{}}, - // handler.EnqueueRequestsFromMapFunc(r.referencePolicyToGatewayRequests), - // ). + Watches( + &source.Kind{Type: &gwv1alpha2.ReferencePolicy{}}, + handler.EnqueueRequestsFromMapFunc(r.referencePolicyToGatewayRequests), + ). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } @@ -122,17 +122,16 @@ func podToGatewayRequest(object client.Object) []reconcile.Request { } func (r *GatewayReconciler) referenceGrantToGatewayRequests(object client.Object) []reconcile.Request { - return r.getRequestsFromReferenceGrant(object.(*gateway.ReferenceGrant)) + return r.getRequestsFromReferenceGrant(object.(*gwv1alpha2.ReferenceGrant)) } -// TODO: this can't be enabled until the ReferencePolicy object is restored -// func (r *GatewayReconciler) referencePolicyToGatewayRequests(object client.Object) []reconcile.Request { -// refPolicy := object.(*gateway.ReferencePolicy) -// // TODO: Convert to ReferenceGrant -// return r.getRequestsFromReferenceGrant(refGrant) -// } +func (r *GatewayReconciler) referencePolicyToGatewayRequests(object client.Object) []reconcile.Request { + refPolicy := object.(*gwv1alpha2.ReferencePolicy) + refGrant := gwv1alpha2.ReferenceGrant{Spec: refPolicy.Spec} + return r.getRequestsFromReferenceGrant(&refGrant) +} -func (r *GatewayReconciler) getRequestsFromReferenceGrant(refGrant *gateway.ReferenceGrant) []reconcile.Request { +func (r *GatewayReconciler) getRequestsFromReferenceGrant(refGrant *gwv1alpha2.ReferenceGrant) []reconcile.Request { gateways := r.getGatewaysAffectedByReferenceGrant(refGrant) requests := make([]reconcile.Request, 0, len(gateways)) @@ -152,8 +151,8 @@ func (r *GatewayReconciler) getRequestsFromReferenceGrant(refGrant *gateway.Refe // getGatewaysAffectedByReferenceGrant retrieves all Gateways potentially impacted by the ReferenceGrant // modification. Currently, this is unfiltered and so returns all Gateways in the namespace referenced by // the ReferenceGrant. -func (r *GatewayReconciler) getGatewaysAffectedByReferenceGrant(refGrant *gateway.ReferenceGrant) []gateway.Gateway { - var matches []gateway.Gateway +func (r *GatewayReconciler) getGatewaysAffectedByReferenceGrant(refGrant *gwv1alpha2.ReferenceGrant) []gwv1beta1.Gateway { + var matches []gwv1beta1.Gateway for _, from := range refGrant.Spec.From { // TODO: search by from.Group and from.Kind instead of assuming this ReferenceGrant references a Gateway diff --git a/internal/k8s/controllers/http_route_controller.go b/internal/k8s/controllers/http_route_controller.go index 3cf0c0899..9e819af97 100644 --- a/internal/k8s/controllers/http_route_controller.go +++ b/internal/k8s/controllers/http_route_controller.go @@ -9,7 +9,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/go-hclog" @@ -59,28 +59,27 @@ func (r *HTTPRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // SetupWithManager sets up the controller with the Manager. func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&gateway.HTTPRoute{}). + For(&gwv1alpha2.HTTPRoute{}). Watches( - &source.Kind{Type: &gateway.ReferenceGrant{}}, + &source.Kind{Type: &gwv1alpha2.ReferenceGrant{}}, handler.EnqueueRequestsFromMapFunc(r.referenceGrantToRouteRequests), ). - // Watches( - // &source.Kind{Type: &gateway.ReferencePolicy{}}, - // handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), - // ). + Watches( + &source.Kind{Type: &gwv1alpha2.ReferencePolicy{}}, + handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), + ). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } func (r *HTTPRouteReconciler) referenceGrantToRouteRequests(object client.Object) []reconcile.Request { - return r.getRouteRequestsFromReferenceGrant(object.(*gateway.ReferenceGrant)) + return r.getRouteRequestsFromReferenceGrant(object.(*gwv1alpha2.ReferenceGrant)) } -// TODO: this can't be enabled until the ReferencePolicy object is restored -// func (r *HTTPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { -// refPolicy := object.(*gateway.ReferencePolicy) -// // TODO: Convert to ReferenceGrant -// return r.getRouteRequestsFromReferenceGrant(refGrant) -// } +func (r *HTTPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { + refPolicy := object.(*gwv1alpha2.ReferencePolicy) + refGrant := gwv1alpha2.ReferenceGrant{Spec: refPolicy.Spec} + return r.getRouteRequestsFromReferenceGrant(&refGrant) +} // For UpdateEvents which contain both a new and old object, this transformation // function is run on both objects and both sets of Requests are enqueued. @@ -92,7 +91,7 @@ func (r *HTTPRouteReconciler) referenceGrantToRouteRequests(object client.Object // It may be possible to improve performance here by filtering Routes by // BackendRefs selectable by the To fields, but currently we just revalidate // all Routes allowed in the From Namespaces -func (r *HTTPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gateway.ReferenceGrant) []reconcile.Request { +func (r *HTTPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gwv1alpha2.ReferenceGrant) []reconcile.Request { routes := r.getRoutesAffectedByReferenceGrant(refGrant) requests := []reconcile.Request{} @@ -111,8 +110,8 @@ func (r *HTTPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gatew // getRoutesAffectedByReferenceGrant retrieves all HTTPRoutes potentially impacted // by the ReferenceGrant being modified. Currently, this is unfiltered and so returns // all HTTPRoutes in the namespace referenced by the ReferenceGrant. -func (r *HTTPRouteReconciler) getRoutesAffectedByReferenceGrant(refGrant *gateway.ReferenceGrant) []gateway.HTTPRoute { - var matches []gateway.HTTPRoute +func (r *HTTPRouteReconciler) getRoutesAffectedByReferenceGrant(refGrant *gwv1alpha2.ReferenceGrant) []gwv1alpha2.HTTPRoute { + var matches []gwv1alpha2.HTTPRoute for _, from := range refGrant.Spec.From { // TODO: search by from.Group and from.Kind instead of assuming this ReferenceGrant references a HTTPRoute diff --git a/internal/k8s/controllers/http_route_controller_test.go b/internal/k8s/controllers/http_route_controller_test.go index d49722e9a..8ca0db2bf 100644 --- a/internal/k8s/controllers/http_route_controller_test.go +++ b/internal/k8s/controllers/http_route_controller_test.go @@ -9,7 +9,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/reconcile" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient/mocks" @@ -86,41 +86,41 @@ func TestHTTPRouteReferenceGrantToRouteRequests(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - serviceNamespace := gw.Namespace("namespace3") + serviceNamespace := gwv1alpha2.Namespace("namespace3") - backendObjRef := gw.BackendObjectReference{ - Name: gw.ObjectName("service"), + backendObjRef := gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName("service"), Namespace: &serviceNamespace, } - httpRouteSpec := gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{ - BackendRef: gw.BackendRef{ + httpRouteSpec := gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ BackendObjectReference: backendObjRef, }, }}, }}, } - tcpRouteSpec := gw.TCPRouteSpec{ - Rules: []gw.TCPRouteRule{{ - BackendRefs: []gw.BackendRef{{ + tcpRouteSpec := gwv1alpha2.TCPRouteSpec{ + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ BackendObjectReference: backendObjRef, }}, }}, } - refGrant := gw.ReferenceGrant{ + refGrant := gwv1alpha2.ReferenceGrant{ TypeMeta: metav1.TypeMeta{Kind: "ReferenceGrant"}, ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "HTTPRoute", Namespace: "namespace1", }}, - To: []gw.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Kind: "Service", }}, }, @@ -128,21 +128,21 @@ func TestHTTPRouteReferenceGrantToRouteRequests(t *testing.T) { client := gatewayclient.NewTestClient( nil, - &gw.HTTPRoute{ + &gwv1alpha2.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Name: "httproute", Namespace: "namespace1", }, Spec: httpRouteSpec, }, - &gw.HTTPRoute{ + &gwv1alpha2.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Name: "httproute", Namespace: "namespace2", }, Spec: httpRouteSpec, }, - &gw.TCPRoute{ + &gwv1alpha2.TCPRoute{ ObjectMeta: metav1.ObjectMeta{ Name: "tcproute", Namespace: "namespace1", @@ -169,92 +169,91 @@ func TestHTTPRouteReferenceGrantToRouteRequests(t *testing.T) { }}, requests) } -// TODO: this can't be enabled until the ReferencePolicy object is restored -// func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { -// t.Parallel() +func TestHTTPRouteReferencePolicyToRouteRequests(t *testing.T) { + t.Parallel() -// ctrl := gomock.NewController(t) -// defer ctrl.Finish() + ctrl := gomock.NewController(t) + defer ctrl.Finish() -// serviceNamespace := gw.Namespace("namespace3") + serviceNamespace := gwv1alpha2.Namespace("namespace3") -// backendObjRef := gw.BackendObjectReference{ -// Name: gw.ObjectName("service"), -// Namespace: &serviceNamespace, -// } + backendObjRef := gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName("service"), + Namespace: &serviceNamespace, + } -// httpRouteSpec := gw.HTTPRouteSpec{ -// Rules: []gw.HTTPRouteRule{{ -// BackendRefs: []gw.HTTPBackendRef{{ -// BackendRef: gw.BackendRef{ -// BackendObjectReference: backendObjRef, -// }, -// }}, -// }}, -// } + httpRouteSpec := gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: backendObjRef, + }, + }}, + }}, + } -// tcpRouteSpec := gw.TCPRouteSpec{ -// Rules: []gw.TCPRouteRule{{ -// BackendRefs: []gw.BackendRef{{ -// BackendObjectReference: backendObjRef, -// }}, -// }}, -// } + tcpRouteSpec := gwv1alpha2.TCPRouteSpec{ + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: backendObjRef, + }}, + }}, + } -// refPolicy := gw.ReferencePolicy{ -// TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, -// ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, -// Spec: gw.ReferencePolicySpec{ -// From: []gw.ReferencePolicyFrom{{ -// Group: "gateway.networking.k8s.io", -// Kind: "HTTPRoute", -// Namespace: "namespace1", -// }}, -// To: []gw.ReferencePolicyTo{{ -// Kind: "Service", -// }}, -// }, -// } + refPolicy := gwv1alpha2.ReferencePolicy{ + TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, + ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ + Group: "gateway.networking.k8s.io", + Kind: "HTTPRoute", + Namespace: "namespace1", + }}, + To: []gwv1alpha2.ReferenceGrantTo{{ + Kind: "Service", + }}, + }, + } -// client := gatewayclient.NewTestClient( -// nil, -// &gw.HTTPRoute{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: "httproute", -// Namespace: "namespace1", -// }, -// Spec: httpRouteSpec, -// }, -// &gw.HTTPRoute{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: "httproute", -// Namespace: "namespace2", -// }, -// Spec: httpRouteSpec, -// }, -// &gw.TCPRoute{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: "tcproute", -// Namespace: "namespace1", -// }, -// Spec: tcpRouteSpec, -// }, -// &refPolicy, -// ) + client := gatewayclient.NewTestClient( + nil, + &gwv1alpha2.HTTPRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "httproute", + Namespace: "namespace1", + }, + Spec: httpRouteSpec, + }, + &gwv1alpha2.HTTPRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "httproute", + Namespace: "namespace2", + }, + Spec: httpRouteSpec, + }, + &gwv1alpha2.TCPRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "tcproute", + Namespace: "namespace1", + }, + Spec: tcpRouteSpec, + }, + &refPolicy, + ) -// controller := &HTTPRouteReconciler{ -// Client: client, -// Log: hclog.NewNullLogger(), -// ControllerName: mockControllerName, -// Manager: reconcilerMocks.NewMockReconcileManager(ctrl), -// } + controller := &HTTPRouteReconciler{ + Client: client, + Log: hclog.NewNullLogger(), + ControllerName: mockControllerName, + Manager: reconcilerMocks.NewMockReconcileManager(ctrl), + } -// requests := controller.referencePolicyToRouteRequests(&refPolicy) + requests := controller.referencePolicyToRouteRequests(&refPolicy) -// require.Equal(t, []reconcile.Request{{ -// NamespacedName: types.NamespacedName{ -// Name: "httproute", -// Namespace: "namespace1", -// }, -// }}, requests) -// } + require.Equal(t, []reconcile.Request{{ + NamespacedName: types.NamespacedName{ + Name: "httproute", + Namespace: "namespace1", + }, + }}, requests) +} diff --git a/internal/k8s/controllers/tcp_route_controller.go b/internal/k8s/controllers/tcp_route_controller.go index 26231b228..3a4b2f38d 100644 --- a/internal/k8s/controllers/tcp_route_controller.go +++ b/internal/k8s/controllers/tcp_route_controller.go @@ -9,7 +9,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/go-hclog" @@ -59,28 +59,27 @@ func (r *TCPRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c // SetupWithManager sets up the controller with the Manager. func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&gateway.TCPRoute{}). + For(&gwv1alpha2.TCPRoute{}). Watches( - &source.Kind{Type: &gateway.ReferenceGrant{}}, + &source.Kind{Type: &gwv1alpha2.ReferenceGrant{}}, handler.EnqueueRequestsFromMapFunc(r.referenceGrantToRouteRequests), ). - // Watches( - // &source.Kind{Type: &gateway.ReferencePolicy{}}, - // handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), - // ). + Watches( + &source.Kind{Type: &gwv1alpha2.ReferencePolicy{}}, + handler.EnqueueRequestsFromMapFunc(r.referencePolicyToRouteRequests), + ). Complete(gatewayclient.NewRequeueingMiddleware(r.Log, r)) } func (r *TCPRouteReconciler) referenceGrantToRouteRequests(object client.Object) []reconcile.Request { - return r.getRouteRequestsFromReferenceGrant(object.(*gateway.ReferenceGrant)) + return r.getRouteRequestsFromReferenceGrant(object.(*gwv1alpha2.ReferenceGrant)) } -// TODO: this can't be enabled until the ReferencePolicy object is restored -// func (r *TCPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { -// refPolicy := object.(*gateway.ReferencePolicy) -// // TODO: Convert to ReferenceGrant -// return r.getRouteRequestsFromReferenceGrant(refGrant) -// } +func (r *TCPRouteReconciler) referencePolicyToRouteRequests(object client.Object) []reconcile.Request { + refPolicy := object.(*gwv1alpha2.ReferencePolicy) + refGrant := gwv1alpha2.ReferenceGrant{Spec: refPolicy.Spec} + return r.getRouteRequestsFromReferenceGrant(&refGrant) +} // For UpdateEvents which contain both a new and old object, this transformation // function is run on both objects and both sets of Requests are enqueued. @@ -92,7 +91,7 @@ func (r *TCPRouteReconciler) referenceGrantToRouteRequests(object client.Object) // It may be possible to improve performance here by filtering Routes by // BackendRefs selectable by the To fields, but currently we just revalidate // all Routes allowed in the From Namespaces -func (r *TCPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gateway.ReferenceGrant) []reconcile.Request { +func (r *TCPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gwv1alpha2.ReferenceGrant) []reconcile.Request { routes := r.getRoutesAffectedByReferenceGrant(refGrant) requests := []reconcile.Request{} @@ -111,8 +110,8 @@ func (r *TCPRouteReconciler) getRouteRequestsFromReferenceGrant(refGrant *gatewa // getRoutesAffectedByReferencePolicy retrieves all TCPRoutes potentially impacted // by the ReferencePolicy being modified. Currently, this is unfiltered and so returns // all TCPRoutes in the namespace referenced by the ReferencePolicy. -func (r *TCPRouteReconciler) getRoutesAffectedByReferenceGrant(refGrant *gateway.ReferenceGrant) []gateway.TCPRoute { - var matches []gateway.TCPRoute +func (r *TCPRouteReconciler) getRoutesAffectedByReferenceGrant(refGrant *gwv1alpha2.ReferenceGrant) []gwv1alpha2.TCPRoute { + var matches []gwv1alpha2.TCPRoute for _, from := range refGrant.Spec.From { // TODO: search by from.Group and from.Kind instead of assuming this ReferenceGrant references a TCPRoute diff --git a/internal/k8s/controllers/tcp_route_controller_test.go b/internal/k8s/controllers/tcp_route_controller_test.go index c5805b865..f80b58718 100644 --- a/internal/k8s/controllers/tcp_route_controller_test.go +++ b/internal/k8s/controllers/tcp_route_controller_test.go @@ -9,7 +9,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/reconcile" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient/mocks" @@ -85,41 +85,41 @@ func TestTCPRouteReferenceGrantToRouteRequests(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - serviceNamespace := gw.Namespace("namespace3") + serviceNamespace := gwv1alpha2.Namespace("namespace3") - backendObjRef := gw.BackendObjectReference{ - Name: gw.ObjectName("service"), + backendObjRef := gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName("service"), Namespace: &serviceNamespace, } - httpRouteSpec := gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{ - BackendRef: gw.BackendRef{ + httpRouteSpec := gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ BackendObjectReference: backendObjRef, }, }}, }}, } - tcpRouteSpec := gw.TCPRouteSpec{ - Rules: []gw.TCPRouteRule{{ - BackendRefs: []gw.BackendRef{{ + tcpRouteSpec := gwv1alpha2.TCPRouteSpec{ + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ BackendObjectReference: backendObjRef, }}, }}, } - refGrant := gw.ReferenceGrant{ + refGrant := gwv1alpha2.ReferenceGrant{ TypeMeta: metav1.TypeMeta{Kind: "ReferenceGrant"}, ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "TCPRoute", Namespace: "namespace1", }}, - To: []gw.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Kind: "Service", }}, }, @@ -127,21 +127,21 @@ func TestTCPRouteReferenceGrantToRouteRequests(t *testing.T) { client := gatewayclient.NewTestClient( nil, - &gw.HTTPRoute{ + &gwv1alpha2.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Name: "httproute", Namespace: "namespace1", }, Spec: httpRouteSpec, }, - &gw.TCPRoute{ + &gwv1alpha2.TCPRoute{ ObjectMeta: metav1.ObjectMeta{ Name: "tcproute", Namespace: "namespace1", }, Spec: tcpRouteSpec, }, - &gw.TCPRoute{ + &gwv1alpha2.TCPRoute{ ObjectMeta: metav1.ObjectMeta{ Name: "tcproute", Namespace: "namespace2", @@ -168,92 +168,91 @@ func TestTCPRouteReferenceGrantToRouteRequests(t *testing.T) { }}, requests) } -// TODO: this can't be enabled until the ReferencePolicy object is restored -// func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { -// t.Parallel() +func TestTCPRouteReferencePolicyToRouteRequests(t *testing.T) { + t.Parallel() -// ctrl := gomock.NewController(t) -// defer ctrl.Finish() + ctrl := gomock.NewController(t) + defer ctrl.Finish() -// serviceNamespace := gw.Namespace("namespace3") + serviceNamespace := gwv1alpha2.Namespace("namespace3") -// backendObjRef := gw.BackendObjectReference{ -// Name: gw.ObjectName("service"), -// Namespace: &serviceNamespace, -// } + backendObjRef := gwv1alpha2.BackendObjectReference{ + Name: gwv1alpha2.ObjectName("service"), + Namespace: &serviceNamespace, + } -// httpRouteSpec := gw.HTTPRouteSpec{ -// Rules: []gw.HTTPRouteRule{{ -// BackendRefs: []gw.HTTPBackendRef{{ -// BackendRef: gw.BackendRef{ -// BackendObjectReference: backendObjRef, -// }, -// }}, -// }}, -// } + httpRouteSpec := gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: backendObjRef, + }, + }}, + }}, + } -// tcpRouteSpec := gw.TCPRouteSpec{ -// Rules: []gw.TCPRouteRule{{ -// BackendRefs: []gw.BackendRef{{ -// BackendObjectReference: backendObjRef, -// }}, -// }}, -// } + tcpRouteSpec := gwv1alpha2.TCPRouteSpec{ + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{{ + BackendObjectReference: backendObjRef, + }}, + }}, + } -// refPolicy := gw.ReferencePolicy{ -// TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, -// ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, -// Spec: gw.ReferencePolicySpec{ -// From: []gw.ReferencePolicyFrom{{ -// Group: "gateway.networking.k8s.io", -// Kind: "TCPRoute", -// Namespace: "namespace1", -// }}, -// To: []gw.ReferencePolicyTo{{ -// Kind: "Service", -// }}, -// }, -// } + refPolicy := gwv1alpha2.ReferencePolicy{ + TypeMeta: metav1.TypeMeta{Kind: "ReferencePolicy"}, + ObjectMeta: metav1.ObjectMeta{Namespace: "namespace3"}, + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ + Group: "gateway.networking.k8s.io", + Kind: "TCPRoute", + Namespace: "namespace1", + }}, + To: []gwv1alpha2.ReferenceGrantTo{{ + Kind: "Service", + }}, + }, + } -// client := gatewayclient.NewTestClient( -// nil, -// &gw.HTTPRoute{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: "httproute", -// Namespace: "namespace1", -// }, -// Spec: httpRouteSpec, -// }, -// &gw.TCPRoute{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: "tcproute", -// Namespace: "namespace1", -// }, -// Spec: tcpRouteSpec, -// }, -// &gw.TCPRoute{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: "tcproute", -// Namespace: "namespace2", -// }, -// Spec: tcpRouteSpec, -// }, -// &refPolicy, -// ) + client := gatewayclient.NewTestClient( + nil, + &gwv1alpha2.HTTPRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "httproute", + Namespace: "namespace1", + }, + Spec: httpRouteSpec, + }, + &gwv1alpha2.TCPRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "tcproute", + Namespace: "namespace1", + }, + Spec: tcpRouteSpec, + }, + &gwv1alpha2.TCPRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "tcproute", + Namespace: "namespace2", + }, + Spec: tcpRouteSpec, + }, + &refPolicy, + ) -// controller := &TCPRouteReconciler{ -// Client: client, -// Log: hclog.NewNullLogger(), -// ControllerName: mockControllerName, -// Manager: reconcilerMocks.NewMockReconcileManager(ctrl), -// } + controller := &TCPRouteReconciler{ + Client: client, + Log: hclog.NewNullLogger(), + ControllerName: mockControllerName, + Manager: reconcilerMocks.NewMockReconcileManager(ctrl), + } -// requests := controller.referencePolicyToRouteRequests(&refPolicy) + requests := controller.referencePolicyToRouteRequests(&refPolicy) -// require.Equal(t, []reconcile.Request{{ -// NamespacedName: types.NamespacedName{ -// Name: "tcproute", -// Namespace: "namespace1", -// }, -// }}, requests) -// } + require.Equal(t, []reconcile.Request{{ + NamespacedName: types.NamespacedName{ + Name: "tcproute", + Namespace: "namespace1", + }, + }}, requests) +} diff --git a/internal/k8s/gatewayclient/gatewayclient.go b/internal/k8s/gatewayclient/gatewayclient.go index 6b929ea7b..142b53216 100644 --- a/internal/k8s/gatewayclient/gatewayclient.go +++ b/internal/k8s/gatewayclient/gatewayclient.go @@ -12,7 +12,8 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/k8s/utils" "github.com/hashicorp/consul-api-gateway/internal/metrics" @@ -28,33 +29,33 @@ import ( type Client interface { // getters GetGatewayClassConfig(ctx context.Context, key types.NamespacedName) (*apigwv1alpha1.GatewayClassConfig, error) - GetGatewayClass(ctx context.Context, key types.NamespacedName) (*gateway.GatewayClass, error) - GetGateway(ctx context.Context, key types.NamespacedName) (*gateway.Gateway, error) - GetGatewaysInNamespace(ctx context.Context, ns string) ([]gateway.Gateway, error) + GetGatewayClass(ctx context.Context, key types.NamespacedName) (*gwv1beta1.GatewayClass, error) + GetGateway(ctx context.Context, key types.NamespacedName) (*gwv1beta1.Gateway, error) + GetGatewaysInNamespace(ctx context.Context, ns string) ([]gwv1beta1.Gateway, error) GetSecret(ctx context.Context, key types.NamespacedName) (*core.Secret, error) GetService(ctx context.Context, key types.NamespacedName) (*core.Service, error) - GetHTTPRoute(ctx context.Context, key types.NamespacedName) (*gateway.HTTPRoute, error) - GetHTTPRoutesInNamespace(ctx context.Context, ns string) ([]gateway.HTTPRoute, error) - GetTCPRoute(ctx context.Context, key types.NamespacedName) (*gateway.TCPRoute, error) - GetTCPRoutesInNamespace(ctx context.Context, ns string) ([]gateway.TCPRoute, error) + GetHTTPRoute(ctx context.Context, key types.NamespacedName) (*gwv1alpha2.HTTPRoute, error) + GetHTTPRoutesInNamespace(ctx context.Context, ns string) ([]gwv1alpha2.HTTPRoute, error) + GetTCPRoute(ctx context.Context, key types.NamespacedName) (*gwv1alpha2.TCPRoute, error) + GetTCPRoutesInNamespace(ctx context.Context, ns string) ([]gwv1alpha2.TCPRoute, error) GetMeshService(ctx context.Context, key types.NamespacedName) (*apigwv1alpha1.MeshService, error) GetNamespace(ctx context.Context, key types.NamespacedName) (*core.Namespace, error) GetDeployment(ctx context.Context, key types.NamespacedName) (*apps.Deployment, error) // finalizer helpers - GatewayClassInUse(ctx context.Context, gc *gateway.GatewayClass) (bool, error) + GatewayClassInUse(ctx context.Context, gc *gwv1beta1.GatewayClass) (bool, error) GatewayClassConfigInUse(ctx context.Context, gcc *apigwv1alpha1.GatewayClassConfig) (bool, error) - GatewayClassesUsingConfig(ctx context.Context, gcc *apigwv1alpha1.GatewayClassConfig) (*gateway.GatewayClassList, error) + GatewayClassesUsingConfig(ctx context.Context, gcc *apigwv1alpha1.GatewayClassConfig) (*gwv1beta1.GatewayClassList, error) RemoveFinalizer(ctx context.Context, object client.Object, finalizer string) (bool, error) EnsureFinalizer(ctx context.Context, object client.Object, finalizer string) (bool, error) // relationships - HasManagedDeployment(ctx context.Context, gw *gateway.Gateway) (bool, error) - IsManagedRoute(ctx context.Context, namespace string, parents []gateway.ParentReference) (bool, error) + HasManagedDeployment(ctx context.Context, gw *gwv1beta1.Gateway) (bool, error) + IsManagedRoute(ctx context.Context, namespace string, parents []gwv1alpha2.ParentReference) (bool, error) GetConfigForGatewayClassName(ctx context.Context, name string) (apigwv1alpha1.GatewayClassConfig, bool, error) - DeploymentForGateway(ctx context.Context, gw *gateway.Gateway) (*apps.Deployment, error) + DeploymentForGateway(ctx context.Context, gw *gwv1beta1.Gateway) (*apps.Deployment, error) SetControllerOwnership(owner, object client.Object) error // general utilities @@ -74,10 +75,10 @@ type Client interface { CreateOrUpdateDeployment(ctx context.Context, deployment *apps.Deployment, mutators ...func() error) (bool, error) CreateOrUpdateService(ctx context.Context, service *core.Service, mutators ...func() error) (bool, error) DeleteService(ctx context.Context, service *core.Service) error - EnsureServiceAccount(ctx context.Context, owner *gateway.Gateway, serviceAccount *core.ServiceAccount) error + EnsureServiceAccount(ctx context.Context, owner *gwv1beta1.Gateway, serviceAccount *core.ServiceAccount) error //referencepolicy - GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]gateway.ReferenceGrant, error) + GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]gwv1alpha2.ReferenceGrant, error) } type gatewayClient struct { @@ -97,7 +98,7 @@ func New(client client.Client, scheme *runtime.Scheme, controllerName string) Cl // gatewayClassUsesConfig determines whether a given GatewayClass references a // given GatewayClassConfig. Since these resources are scoped to the cluster, // namespace is not considered. -func gatewayClassUsesConfig(gc gateway.GatewayClass, gcc *apigwv1alpha1.GatewayClassConfig) bool { +func gatewayClassUsesConfig(gc gwv1beta1.GatewayClass, gcc *apigwv1alpha1.GatewayClassConfig) bool { paramaterRef := gc.Spec.ParametersRef return paramaterRef != nil && paramaterRef.Group == apigwv1alpha1.Group && @@ -108,7 +109,7 @@ func gatewayClassUsesConfig(gc gateway.GatewayClass, gcc *apigwv1alpha1.GatewayC // GatewayClassConfigInUse determines whether any GatewayClass in the cluster // references the provided GatewayClassConfig. func (g *gatewayClient) GatewayClassConfigInUse(ctx context.Context, gcc *apigwv1alpha1.GatewayClassConfig) (bool, error) { - list := &gateway.GatewayClassList{} + list := &gwv1beta1.GatewayClassList{} if err := g.List(ctx, list); err != nil { return false, NewK8sError(err) } @@ -124,8 +125,8 @@ func (g *gatewayClient) GatewayClassConfigInUse(ctx context.Context, gcc *apigwv // GatewayClassesUsingConfig returns the list of all GatewayClasses in the // cluster that reference the provided GatewayClassConfig. -func (g *gatewayClient) GatewayClassesUsingConfig(ctx context.Context, gcc *apigwv1alpha1.GatewayClassConfig) (*gateway.GatewayClassList, error) { - list, filteredList := &gateway.GatewayClassList{}, &gateway.GatewayClassList{} +func (g *gatewayClient) GatewayClassesUsingConfig(ctx context.Context, gcc *apigwv1alpha1.GatewayClassConfig) (*gwv1beta1.GatewayClassList, error) { + list, filteredList := &gwv1beta1.GatewayClassList{}, &gwv1beta1.GatewayClassList{} if err := g.List(ctx, list); err != nil { return nil, NewK8sError(err) } @@ -141,8 +142,8 @@ func (g *gatewayClient) GatewayClassesUsingConfig(ctx context.Context, gcc *apig // GatewayClassInUse determines whether any Gateway in the cluster // references the provided GatewayClass. -func (g *gatewayClient) GatewayClassInUse(ctx context.Context, gc *gateway.GatewayClass) (bool, error) { - list := &gateway.GatewayList{} +func (g *gatewayClient) GatewayClassInUse(ctx context.Context, gc *gwv1beta1.GatewayClass) (bool, error) { + list := &gwv1beta1.GatewayList{} if err := g.List(ctx, list); err != nil { return false, NewK8sError(err) } @@ -172,7 +173,7 @@ func (g *gatewayClient) PodsWithLabels(ctx context.Context, labels map[string]st return items, nil } -func (g *gatewayClient) DeploymentForGateway(ctx context.Context, gw *gateway.Gateway) (*apps.Deployment, error) { +func (g *gatewayClient) DeploymentForGateway(ctx context.Context, gw *gwv1beta1.Gateway) (*apps.Deployment, error) { deployment := &apps.Deployment{} key := types.NamespacedName{Name: gw.Name, Namespace: gw.Namespace} if err := g.Client.Get(ctx, key, deployment); err != nil { @@ -195,8 +196,8 @@ func (g *gatewayClient) GetGatewayClassConfig(ctx context.Context, key types.Nam return gcc, nil } -func (g *gatewayClient) GetGatewayClass(ctx context.Context, key types.NamespacedName) (*gateway.GatewayClass, error) { - gc := &gateway.GatewayClass{} +func (g *gatewayClient) GetGatewayClass(ctx context.Context, key types.NamespacedName) (*gwv1beta1.GatewayClass, error) { + gc := &gwv1beta1.GatewayClass{} if err := g.Client.Get(ctx, key, gc); err != nil { if k8serrors.IsNotFound(err) { return nil, nil @@ -206,8 +207,8 @@ func (g *gatewayClient) GetGatewayClass(ctx context.Context, key types.Namespace return gc, nil } -func (g *gatewayClient) GetGateway(ctx context.Context, key types.NamespacedName) (*gateway.Gateway, error) { - gw := &gateway.Gateway{} +func (g *gatewayClient) GetGateway(ctx context.Context, key types.NamespacedName) (*gwv1beta1.Gateway, error) { + gw := &gwv1beta1.Gateway{} if err := g.Client.Get(ctx, key, gw); err != nil { if k8serrors.IsNotFound(err) { return nil, nil @@ -217,10 +218,10 @@ func (g *gatewayClient) GetGateway(ctx context.Context, key types.NamespacedName return gw, nil } -func (g *gatewayClient) GetGatewaysInNamespace(ctx context.Context, ns string) ([]gateway.Gateway, error) { - gwList := &gateway.GatewayList{} +func (g *gatewayClient) GetGatewaysInNamespace(ctx context.Context, ns string) ([]gwv1beta1.Gateway, error) { + gwList := &gwv1beta1.GatewayList{} if err := g.Client.List(ctx, gwList, client.InNamespace(ns)); err != nil { - return []gateway.Gateway{}, NewK8sError(err) + return []gwv1beta1.Gateway{}, NewK8sError(err) } return gwList.Items, nil } @@ -258,8 +259,8 @@ func (g *gatewayClient) GetSecret(ctx context.Context, key types.NamespacedName) return secret, nil } -func (g *gatewayClient) GetHTTPRoute(ctx context.Context, key types.NamespacedName) (*gateway.HTTPRoute, error) { - route := &gateway.HTTPRoute{} +func (g *gatewayClient) GetHTTPRoute(ctx context.Context, key types.NamespacedName) (*gwv1alpha2.HTTPRoute, error) { + route := &gwv1alpha2.HTTPRoute{} if err := g.Client.Get(ctx, key, route); err != nil { if k8serrors.IsNotFound(err) { return nil, nil @@ -270,16 +271,16 @@ func (g *gatewayClient) GetHTTPRoute(ctx context.Context, key types.NamespacedNa } // TODO: Make this generic over Group and Kind, returning []client.Object -func (g *gatewayClient) GetHTTPRoutesInNamespace(ctx context.Context, ns string) ([]gateway.HTTPRoute, error) { - routeList := &gateway.HTTPRouteList{} +func (g *gatewayClient) GetHTTPRoutesInNamespace(ctx context.Context, ns string) ([]gwv1alpha2.HTTPRoute, error) { + routeList := &gwv1alpha2.HTTPRouteList{} if err := g.Client.List(ctx, routeList, client.InNamespace(ns)); err != nil { - return []gateway.HTTPRoute{}, NewK8sError(err) + return []gwv1alpha2.HTTPRoute{}, NewK8sError(err) } return routeList.Items, nil } -func (g *gatewayClient) GetTCPRoute(ctx context.Context, key types.NamespacedName) (*gateway.TCPRoute, error) { - route := &gateway.TCPRoute{} +func (g *gatewayClient) GetTCPRoute(ctx context.Context, key types.NamespacedName) (*gwv1alpha2.TCPRoute, error) { + route := &gwv1alpha2.TCPRoute{} if err := g.Client.Get(ctx, key, route); err != nil { if k8serrors.IsNotFound(err) { return nil, nil @@ -289,10 +290,10 @@ func (g *gatewayClient) GetTCPRoute(ctx context.Context, key types.NamespacedNam return route, nil } -func (g *gatewayClient) GetTCPRoutesInNamespace(ctx context.Context, ns string) ([]gateway.TCPRoute, error) { - routeList := &gateway.TCPRouteList{} +func (g *gatewayClient) GetTCPRoutesInNamespace(ctx context.Context, ns string) ([]gwv1alpha2.TCPRoute, error) { + routeList := &gwv1alpha2.TCPRouteList{} if err := g.Client.List(ctx, routeList, client.InNamespace(ns)); err != nil { - return []gateway.TCPRoute{}, NewK8sError(err) + return []gwv1alpha2.TCPRoute{}, NewK8sError(err) } return routeList.Items, nil } @@ -412,7 +413,7 @@ func (g *gatewayClient) DeleteService(ctx context.Context, service *core.Service return nil } -func (g *gatewayClient) EnsureServiceAccount(ctx context.Context, owner *gateway.Gateway, serviceAccount *core.ServiceAccount) error { +func (g *gatewayClient) EnsureServiceAccount(ctx context.Context, owner *gwv1beta1.Gateway, serviceAccount *core.ServiceAccount) error { created := &core.ServiceAccount{} key := types.NamespacedName{Name: serviceAccount.Name, Namespace: serviceAccount.Namespace} if err := g.Client.Get(ctx, key, created); err != nil { @@ -453,7 +454,7 @@ func (g *gatewayClient) GetConfigForGatewayClassName(ctx context.Context, name s // no class found return apigwv1alpha1.GatewayClassConfig{}, false, nil } - if class.Spec.ControllerName != gateway.GatewayController(g.controllerName) { + if class.Spec.ControllerName != gwv1beta1.GatewayController(g.controllerName) { // we're not owned by this controller, so pretend we don't exist return apigwv1alpha1.GatewayClassConfig{}, false, nil } @@ -480,7 +481,8 @@ func (g *gatewayClient) GetConfigForGatewayClassName(ctx context.Context, name s return apigwv1alpha1.GatewayClassConfig{}, true, nil } -func (g *gatewayClient) IsManagedRoute(ctx context.Context, namespace string, parents []gateway.ParentReference) (bool, error) { +// TODO: this likely needs to support gwv1alpha2.ParentReference too +func (g *gatewayClient) IsManagedRoute(ctx context.Context, namespace string, parents []gwv1alpha2.ParentReference) (bool, error) { // we look up a list of deployments that are managed by us, and try and check our references based on them. list := &apps.DeploymentList{} if err := g.Client.List(ctx, list, client.MatchingLabels(map[string]string{ @@ -503,7 +505,7 @@ func (g *gatewayClient) IsManagedRoute(ctx context.Context, namespace string, pa return false, nil } -func (g *gatewayClient) HasManagedDeployment(ctx context.Context, gw *gateway.Gateway) (bool, error) { +func (g *gatewayClient) HasManagedDeployment(ctx context.Context, gw *gwv1beta1.Gateway) (bool, error) { list := &apps.DeploymentList{} if err := g.Client.List(ctx, list, client.MatchingLabels(utils.LabelsForGateway(gw))); err != nil { return false, NewK8sError(err) @@ -511,8 +513,8 @@ func (g *gatewayClient) HasManagedDeployment(ctx context.Context, gw *gateway.Ga return len(list.Items) > 0, nil } -func (g *gatewayClient) GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]gateway.ReferenceGrant, error) { - refGrantList := &gateway.ReferenceGrantList{} +func (g *gatewayClient) GetReferenceGrantsInNamespace(ctx context.Context, namespace string) ([]gwv1alpha2.ReferenceGrant, error) { + refGrantList := &gwv1alpha2.ReferenceGrantList{} if err := g.Client.List(ctx, refGrantList, client.InNamespace(namespace)); err != nil { return nil, NewK8sError(err) } @@ -521,21 +523,21 @@ func (g *gatewayClient) GetReferenceGrantsInNamespace(ctx context.Context, names // TODO: this can't be enabled until the ReferencePolicy object is restored // lookup ReferencePolicies here too for backwards compatibility, create // ReferenceGrants from them and add to list - // refPolicyList := &gateway.ReferencePolicyList{} + // refPolicyList := &gwv1alpha2.ReferencePolicyList{} // if err := g.Client.List(ctx, refPolicyList, client.InNamespace(namespace)); err != nil { // return nil, NewK8sError(err) // } // for _, refPolicy := range refPolicyList { - // refGrant := gateway.ReferenceGrant{} + // refGrant := gwv1alpha2.ReferenceGrant{} // for _, refPolicyFrom := range refPolicy.Spec.From { - // refGrant.Spec.From = append(refGrant.Spec.From, gateway.ReferenceGrantFrom{ + // refGrant.Spec.From = append(refGrant.Spec.From, gwv1alpha2.ReferenceGrantFrom{ // Group: refPolicyFrom.Group, // Kind: refPolicyFrom.Kind, // Namespace: refPolicyFrom.Namespace, // }) // } // for _, refPolicyTo := range refPolicy.Spec.To { - // refGrant.Spec.To = append(refGrant.Spec.To, gateway.ReferenceGrantTo{ + // refGrant.Spec.To = append(refGrant.Spec.To, gwv1alpha2.ReferenceGrantTo{ // Group: refPolicyTo.Group, // Kind: refPolicyTo.Kind, // Name: refPolicyTo.Name, diff --git a/internal/k8s/gatewayclient/gatewayclient_test.go b/internal/k8s/gatewayclient/gatewayclient_test.go index 25d16fbe6..fb1a6c549 100644 --- a/internal/k8s/gatewayclient/gatewayclient_test.go +++ b/internal/k8s/gatewayclient/gatewayclient_test.go @@ -8,7 +8,8 @@ import ( core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -19,7 +20,7 @@ import ( func TestGetGateway(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(nil, &gateway.Gateway{ + gatewayclient := NewTestClient(nil, &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", Namespace: "namespace", @@ -66,7 +67,7 @@ func TestGetGatewayClassConfig(t *testing.T) { func TestGetHTTPRoute(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(nil, &gateway.HTTPRoute{ + gatewayclient := NewTestClient(nil, &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: "httproute", Namespace: "namespace", @@ -98,7 +99,7 @@ func TestGetHTTPRoute(t *testing.T) { func TestGetHTTPRoutesInNamespace(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(nil, &gateway.HTTPRoute{ + gatewayclient := NewTestClient(nil, &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Name: "httproute", Namespace: "namespace1", @@ -117,7 +118,7 @@ func TestGetHTTPRoutesInNamespace(t *testing.T) { func TestGetGatewayClass(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(nil, &gateway.GatewayClass{ + gatewayclient := NewTestClient(nil, &gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ Name: "gatewayclass", }, @@ -146,7 +147,7 @@ func TestDeploymentForGateway(t *testing.T) { }, }) - deployment, err := gatewayclient.DeploymentForGateway(context.Background(), &gateway.Gateway{ + deployment, err := gatewayclient.DeploymentForGateway(context.Background(), &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "notgateway", Namespace: "namespace", @@ -155,7 +156,7 @@ func TestDeploymentForGateway(t *testing.T) { require.NoError(t, err) require.Nil(t, deployment) - deployment, err = gatewayclient.DeploymentForGateway(context.Background(), &gateway.Gateway{ + deployment, err = gatewayclient.DeploymentForGateway(context.Background(), &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", Namespace: "notnamespace", @@ -164,7 +165,7 @@ func TestDeploymentForGateway(t *testing.T) { require.NoError(t, err) require.Nil(t, deployment) - deployment, err = gatewayclient.DeploymentForGateway(context.Background(), &gateway.Gateway{ + deployment, err = gatewayclient.DeploymentForGateway(context.Background(), &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", Namespace: "namespace", @@ -177,7 +178,7 @@ func TestDeploymentForGateway(t *testing.T) { func TestEnsureFinalizer(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(nil, &gateway.GatewayClass{ + gatewayclient := NewTestClient(nil, &gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ Name: "gatewayclass", }, @@ -211,7 +212,7 @@ func TestEnsureFinalizer(t *testing.T) { func TestRemoveFinalizer(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(nil, &gateway.GatewayClass{ + gatewayclient := NewTestClient(nil, &gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ Name: "gatewayclass", Finalizers: []string{"finalizer", "other"}, @@ -253,12 +254,12 @@ func TestRemoveFinalizer(t *testing.T) { func TestGatewayClassesUsingConfig(t *testing.T) { t.Parallel() - gatewayClient := NewTestClient(&gateway.GatewayClassList{ - Items: []gateway.GatewayClass{ + gatewayClient := NewTestClient(&gwv1beta1.GatewayClassList{ + Items: []gwv1beta1.GatewayClass{ { ObjectMeta: meta.ObjectMeta{Name: "gatewayclass1"}, - Spec: gateway.GatewayClassSpec{ - ParametersRef: &gateway.ParametersReference{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "gatewayclassconfig", @@ -267,8 +268,8 @@ func TestGatewayClassesUsingConfig(t *testing.T) { }, { ObjectMeta: meta.ObjectMeta{Name: "gatewayclass2"}, - Spec: gateway.GatewayClassSpec{ - ParametersRef: &gateway.ParametersReference{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "gatewayclassconfig", @@ -300,13 +301,13 @@ func TestGatewayClassesUsingConfig(t *testing.T) { func TestGatewayClassConfigInUse(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(&gateway.GatewayClassList{ - Items: []gateway.GatewayClass{{ + gatewayclient := NewTestClient(&gwv1beta1.GatewayClassList{ + Items: []gwv1beta1.GatewayClass{{ ObjectMeta: meta.ObjectMeta{ Name: "gatewayclass", }, - Spec: gateway.GatewayClassSpec{ - ParametersRef: &gateway.ParametersReference{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "gatewayclassconfig", @@ -334,17 +335,17 @@ func TestGatewayClassConfigInUse(t *testing.T) { func TestGatewayClassInUse(t *testing.T) { t.Parallel() - gatewayclient := NewTestClient(&gateway.GatewayList{ - Items: []gateway.Gateway{{ + gatewayclient := NewTestClient(&gwv1beta1.GatewayList{ + Items: []gwv1beta1.Gateway{{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - Spec: gateway.GatewaySpec{ + Spec: gwv1beta1.GatewaySpec{ GatewayClassName: "gatewayclass", }, }}}) - used, err := gatewayclient.GatewayClassInUse(context.Background(), &gateway.GatewayClass{ + used, err := gatewayclient.GatewayClassInUse(context.Background(), &gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ Name: "gatewayclass", }, @@ -352,7 +353,7 @@ func TestGatewayClassInUse(t *testing.T) { require.NoError(t, err) require.True(t, used) - used, err = gatewayclient.GatewayClassInUse(context.Background(), &gateway.GatewayClass{ + used, err = gatewayclient.GatewayClassInUse(context.Background(), &gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ Name: "nogatewayclass", }, diff --git a/internal/k8s/gatewayclient/mocks/gatewayclient.go b/internal/k8s/gatewayclient/mocks/gatewayclient.go index 6538797c3..ebcd882eb 100644 --- a/internal/k8s/gatewayclient/mocks/gatewayclient.go +++ b/internal/k8s/gatewayclient/mocks/gatewayclient.go @@ -15,6 +15,7 @@ import ( types "k8s.io/apimachinery/pkg/types" client "sigs.k8s.io/controller-runtime/pkg/client" v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) // MockClient is a mock of Client interface. @@ -95,7 +96,7 @@ func (mr *MockClientMockRecorder) DeleteService(ctx, service interface{}) *gomoc } // DeploymentForGateway mocks base method. -func (m *MockClient) DeploymentForGateway(ctx context.Context, gw *v1alpha2.Gateway) (*v1.Deployment, error) { +func (m *MockClient) DeploymentForGateway(ctx context.Context, gw *v1beta1.Gateway) (*v1.Deployment, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeploymentForGateway", ctx, gw) ret0, _ := ret[0].(*v1.Deployment) @@ -125,7 +126,7 @@ func (mr *MockClientMockRecorder) EnsureFinalizer(ctx, object, finalizer interfa } // EnsureServiceAccount mocks base method. -func (m *MockClient) EnsureServiceAccount(ctx context.Context, owner *v1alpha2.Gateway, serviceAccount *v10.ServiceAccount) error { +func (m *MockClient) EnsureServiceAccount(ctx context.Context, owner *v1beta1.Gateway, serviceAccount *v10.ServiceAccount) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EnsureServiceAccount", ctx, owner, serviceAccount) ret0, _ := ret[0].(error) @@ -154,7 +155,7 @@ func (mr *MockClientMockRecorder) GatewayClassConfigInUse(ctx, gcc interface{}) } // GatewayClassInUse mocks base method. -func (m *MockClient) GatewayClassInUse(ctx context.Context, gc *v1alpha2.GatewayClass) (bool, error) { +func (m *MockClient) GatewayClassInUse(ctx context.Context, gc *v1beta1.GatewayClass) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GatewayClassInUse", ctx, gc) ret0, _ := ret[0].(bool) @@ -169,10 +170,10 @@ func (mr *MockClientMockRecorder) GatewayClassInUse(ctx, gc interface{}) *gomock } // GatewayClassesUsingConfig mocks base method. -func (m *MockClient) GatewayClassesUsingConfig(ctx context.Context, gcc *v1alpha1.GatewayClassConfig) (*v1alpha2.GatewayClassList, error) { +func (m *MockClient) GatewayClassesUsingConfig(ctx context.Context, gcc *v1alpha1.GatewayClassConfig) (*v1beta1.GatewayClassList, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GatewayClassesUsingConfig", ctx, gcc) - ret0, _ := ret[0].(*v1alpha2.GatewayClassList) + ret0, _ := ret[0].(*v1beta1.GatewayClassList) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -215,10 +216,10 @@ func (mr *MockClientMockRecorder) GetDeployment(ctx, key interface{}) *gomock.Ca } // GetGateway mocks base method. -func (m *MockClient) GetGateway(ctx context.Context, key types.NamespacedName) (*v1alpha2.Gateway, error) { +func (m *MockClient) GetGateway(ctx context.Context, key types.NamespacedName) (*v1beta1.Gateway, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGateway", ctx, key) - ret0, _ := ret[0].(*v1alpha2.Gateway) + ret0, _ := ret[0].(*v1beta1.Gateway) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -230,10 +231,10 @@ func (mr *MockClientMockRecorder) GetGateway(ctx, key interface{}) *gomock.Call } // GetGatewayClass mocks base method. -func (m *MockClient) GetGatewayClass(ctx context.Context, key types.NamespacedName) (*v1alpha2.GatewayClass, error) { +func (m *MockClient) GetGatewayClass(ctx context.Context, key types.NamespacedName) (*v1beta1.GatewayClass, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGatewayClass", ctx, key) - ret0, _ := ret[0].(*v1alpha2.GatewayClass) + ret0, _ := ret[0].(*v1beta1.GatewayClass) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -260,10 +261,10 @@ func (mr *MockClientMockRecorder) GetGatewayClassConfig(ctx, key interface{}) *g } // GetGatewaysInNamespace mocks base method. -func (m *MockClient) GetGatewaysInNamespace(ctx context.Context, ns string) ([]v1alpha2.Gateway, error) { +func (m *MockClient) GetGatewaysInNamespace(ctx context.Context, ns string) ([]v1beta1.Gateway, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGatewaysInNamespace", ctx, ns) - ret0, _ := ret[0].([]v1alpha2.Gateway) + ret0, _ := ret[0].([]v1beta1.Gateway) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -410,7 +411,7 @@ func (mr *MockClientMockRecorder) GetTCPRoutesInNamespace(ctx, ns interface{}) * } // HasManagedDeployment mocks base method. -func (m *MockClient) HasManagedDeployment(ctx context.Context, gw *v1alpha2.Gateway) (bool, error) { +func (m *MockClient) HasManagedDeployment(ctx context.Context, gw *v1beta1.Gateway) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "HasManagedDeployment", ctx, gw) ret0, _ := ret[0].(bool) diff --git a/internal/k8s/gatewayclient/test_helpers.go b/internal/k8s/gatewayclient/test_helpers.go index 55bed53d2..13491c7bb 100644 --- a/internal/k8s/gatewayclient/test_helpers.go +++ b/internal/k8s/gatewayclient/test_helpers.go @@ -6,7 +6,8 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" apigwv1alpha1 "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" ) @@ -14,7 +15,8 @@ import ( func NewTestClient(list client.ObjectList, objects ...client.Object) Client { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(gw.AddToScheme(scheme)) + utilruntime.Must(gwv1beta1.AddToScheme(scheme)) + utilruntime.Must(gwv1alpha2.AddToScheme(scheme)) apigwv1alpha1.RegisterTypes(scheme) builder := fake. diff --git a/internal/k8s/reconciler/gateway.go b/internal/k8s/reconciler/gateway.go index 1b23ba9fa..85089f8ad 100644 --- a/internal/k8s/reconciler/gateway.go +++ b/internal/k8s/reconciler/gateway.go @@ -9,7 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" "golang.org/x/exp/slices" @@ -26,7 +26,7 @@ type K8sGateway struct { consulNamespace string logger hclog.Logger client gatewayclient.Client - gateway *gw.Gateway + gateway *gwv1beta1.Gateway config apigwv1alpha1.GatewayClassConfig deploymentBuilder builder.DeploymentBuilder serviceBuilder builder.ServiceBuilder @@ -50,7 +50,7 @@ type K8sGatewayConfig struct { Client gatewayclient.Client } -func NewK8sGateway(gateway *gw.Gateway, config K8sGatewayConfig) *K8sGateway { +func NewK8sGateway(gateway *gwv1beta1.Gateway, config K8sGatewayConfig) *K8sGateway { gatewayLogger := config.Logger.Named("gateway").With("name", gateway.Name, "namespace", gateway.Namespace) listeners := make(map[string]*K8sListener) for _, listener := range gateway.Spec.Listeners { @@ -104,14 +104,14 @@ func (g *K8sGateway) Validate(ctx context.Context) error { } type mergedListener struct { - port gw.PortNumber + port gwv1beta1.PortNumber listeners []*K8sListener protocols map[string]struct{} hostnames map[string]struct{} } -func (g *K8sGateway) mergeListenersByPort() map[gw.PortNumber]mergedListener { - mergedListeners := make(map[gw.PortNumber]mergedListener) +func (g *K8sGateway) mergeListenersByPort() map[gwv1beta1.PortNumber]mergedListener { + mergedListeners := make(map[gwv1beta1.PortNumber]mergedListener) for _, listener := range g.listeners { merged, found := mergedListeners[listener.listener.Port] if !found { @@ -395,8 +395,8 @@ func (g *K8sGateway) ShouldBind(route store.Route) bool { return false } -func (g *K8sGateway) Status() gw.GatewayStatus { - listenerStatuses := []gw.ListenerStatus{} +func (g *K8sGateway) Status() gwv1beta1.GatewayStatus { + listenerStatuses := []gwv1beta1.ListenerStatus{} listenersReady := true listenersInvalid := false for _, listener := range g.listeners { @@ -426,16 +426,16 @@ func (g *K8sGateway) Status() gw.GatewayStatus { conditions = g.gateway.Status.Conditions } - ipType := gw.IPAddressType - addresses := make([]gw.GatewayAddress, 0, len(g.addresses)) + ipType := gwv1beta1.IPAddressType + addresses := make([]gwv1beta1.GatewayAddress, 0, len(g.addresses)) for _, address := range g.addresses { - addresses = append(addresses, gw.GatewayAddress{ + addresses = append(addresses, gwv1beta1.GatewayAddress{ Type: &ipType, Value: address, }) } - return gw.GatewayStatus{ + return gwv1beta1.GatewayStatus{ Addresses: addresses, Conditions: conditions, Listeners: listenerStatuses, diff --git a/internal/k8s/reconciler/gateway_test.go b/internal/k8s/reconciler/gateway_test.go index 093b7d8f5..9370bd2d8 100644 --- a/internal/k8s/reconciler/gateway_test.go +++ b/internal/k8s/reconciler/gateway_test.go @@ -12,7 +12,8 @@ import ( "github.com/stretchr/testify/require" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -30,14 +31,14 @@ func TestGatewayValidate(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - hostname := gw.Hostname("*") - gateway := NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ + hostname := gwv1beta1.Hostname("*") + gateway := NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ Hostname: &hostname, - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{}}, + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{}}, }, }}, }, @@ -74,15 +75,15 @@ func TestGatewayValidateGatewayIP(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - hostname := gw.Hostname("*") + hostname := gwv1beta1.Hostname("*") - gwDef := &gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ + gwDef := &gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ Hostname: &hostname, - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{}}, + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{}}, }, }}, }, @@ -183,16 +184,16 @@ func TestGatewayValidate_ListenerProtocolConflicts(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - gateway := NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), - Protocol: gw.HTTPProtocolType, - Port: gw.PortNumber(1), + gateway := NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), + Protocol: gwv1beta1.HTTPProtocolType, + Port: gwv1beta1.PortNumber(1), }, { - Name: gw.SectionName("2"), - Protocol: gw.UDPProtocolType, - Port: gw.PortNumber(1), + Name: gwv1beta1.SectionName("2"), + Protocol: gwv1beta1.UDPProtocolType, + Port: gwv1beta1.PortNumber(1), }}, }, }, K8sGatewayConfig{ @@ -220,20 +221,20 @@ func TestGatewayValidate_ListenerHostnameConflicts(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - hostname := gw.Hostname("1") - other := gw.Hostname("2") - gateway := NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), - Protocol: gw.HTTPProtocolType, + hostname := gwv1beta1.Hostname("1") + other := gwv1beta1.Hostname("2") + gateway := NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), + Protocol: gwv1beta1.HTTPProtocolType, Hostname: &hostname, - Port: gw.PortNumber(1), + Port: gwv1beta1.PortNumber(1), }, { - Name: gw.SectionName("2"), - Protocol: gw.HTTPProtocolType, + Name: gwv1beta1.SectionName("2"), + Protocol: gwv1beta1.HTTPProtocolType, Hostname: &other, - Port: gw.PortNumber(1), + Port: gwv1beta1.PortNumber(1), }}, }, }, K8sGatewayConfig{ @@ -261,9 +262,9 @@ func TestGatewayValidate_Pods(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - gateway := NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{}}, + gateway := NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{}}, }, }, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ @@ -344,7 +345,7 @@ func TestGatewayValidate_Pods(t *testing.T) { func TestGatewayID(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "name", Namespace: "namespace", @@ -359,7 +360,7 @@ func TestGatewayID(t *testing.T) { func TestGatewayMeta(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "name", Namespace: "namespace", @@ -374,9 +375,9 @@ func TestGatewayMeta(t *testing.T) { func TestGatewayListeners(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{}}, + gateway := NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{}}, }, }, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), @@ -388,10 +389,10 @@ func TestGatewayOutputStatus(t *testing.T) { t.Parallel() // Pending listener - gateway := NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), + gateway := NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), }}, }, }, K8sGatewayConfig{ @@ -403,10 +404,10 @@ func TestGatewayOutputStatus(t *testing.T) { assert.Equal(t, GatewayConditionReasonListenersNotReady, gateway.status.Ready.Condition(0).Reason) // Service ready, pods not - gateway = NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), + gateway = NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), }}, }, }, K8sGatewayConfig{ @@ -419,10 +420,10 @@ func TestGatewayOutputStatus(t *testing.T) { assert.Equal(t, GatewayConditionReasonListenersNotValid, gateway.status.Ready.Condition(0).Reason) // Pods ready, service not - gateway = NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), + gateway = NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), }}, }, }, K8sGatewayConfig{ @@ -435,12 +436,12 @@ func TestGatewayOutputStatus(t *testing.T) { assert.Equal(t, GatewayConditionReasonListenersNotValid, gateway.status.Ready.Condition(0).Reason) // Pods + service ready - gateway = NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), + gateway = NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), }}, - Addresses: []gw.GatewayAddress{{}}, + Addresses: []gwv1beta1.GatewayAddress{{}}, }, }, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), @@ -450,12 +451,12 @@ func TestGatewayOutputStatus(t *testing.T) { require.Len(t, gateway.Status().Listeners, 1) assert.Equal(t, GatewayConditionReasonAddressNotAssigned, gateway.status.Ready.Condition(0).Reason) - gateway = NewK8sGateway(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - Name: gw.SectionName("1"), + gateway = NewK8sGateway(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + Name: gwv1beta1.SectionName("1"), }}, - Addresses: []gw.GatewayAddress{{}}, + Addresses: []gwv1beta1.GatewayAddress{{}}, }, }, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), @@ -471,7 +472,7 @@ func TestGatewayTrackSync(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - gateway := NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ Output: io.Discard, Level: hclog.Trace, @@ -486,7 +487,7 @@ func TestGatewayTrackSync(t *testing.T) { })) var instances int32 = 2 - gateway = NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway = NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ Output: io.Discard, Level: hclog.Trace, @@ -510,7 +511,7 @@ func TestGatewayTrackSync(t *testing.T) { expected := errors.New("expected") - gateway = NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway = NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ Output: io.Discard, Level: hclog.Trace, @@ -523,7 +524,7 @@ func TestGatewayTrackSync(t *testing.T) { return false, nil }), expected)) - gateway = NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway = NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ Output: io.Discard, Level: hclog.Trace, @@ -537,7 +538,7 @@ func TestGatewayTrackSync(t *testing.T) { return false, nil })) - gateway = NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway = NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ Output: io.Discard, Level: hclog.Trace, @@ -552,7 +553,7 @@ func TestGatewayTrackSync(t *testing.T) { return true, nil })) - gateway = NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway = NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.New(&hclog.LoggerOptions{ Output: io.Discard, Level: hclog.Trace, @@ -570,11 +571,11 @@ func TestGatewayTrackSync(t *testing.T) { func TestGatewayShouldUpdate(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), }) - other := NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + other := NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), }) @@ -614,23 +615,23 @@ func TestGatewayShouldUpdate(t *testing.T) { func TestGatewayShouldBind(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{}, K8sGatewayConfig{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{}, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), }) gateway.gateway.Name = "name" require.False(t, gateway.ShouldBind(storeMocks.NewMockRoute(nil))) - route := NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + route := NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) route.resolutionErrors.Add(service.NewConsulResolutionError("test")) require.False(t, gateway.ShouldBind(route)) - require.True(t, gateway.ShouldBind(NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + require.True(t, gateway.ShouldBind(NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "name", }}, }, @@ -639,7 +640,7 @@ func TestGatewayShouldBind(t *testing.T) { Logger: hclog.NewNullLogger(), }))) - require.False(t, gateway.ShouldBind(NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + require.False(t, gateway.ShouldBind(NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }))) } diff --git a/internal/k8s/reconciler/gatewayclass.go b/internal/k8s/reconciler/gatewayclass.go index 0146d626c..733b041bd 100644 --- a/internal/k8s/reconciler/gatewayclass.go +++ b/internal/k8s/reconciler/gatewayclass.go @@ -10,7 +10,7 @@ import ( apigwv1alpha1 "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" "github.com/hashicorp/go-hclog" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) type K8sGatewayClasses struct { @@ -73,7 +73,7 @@ type K8sGatewayClass struct { client gatewayclient.Client status GatewayClassStatus - class *gw.GatewayClass + class *gwv1beta1.GatewayClass config apigwv1alpha1.GatewayClassConfig } @@ -82,7 +82,7 @@ type K8sGatewayClassConfig struct { Client gatewayclient.Client } -func NewK8sGatewayClass(class *gw.GatewayClass, config K8sGatewayClassConfig) *K8sGatewayClass { +func NewK8sGatewayClass(class *gwv1beta1.GatewayClass, config K8sGatewayClassConfig) *K8sGatewayClass { classLogger := config.Logger.Named("gatewayclass").With("name", class.Name) return &K8sGatewayClass{ logger: classLogger, diff --git a/internal/k8s/reconciler/gatewayclass_test.go b/internal/k8s/reconciler/gatewayclass_test.go index a4066a53f..f28f71c44 100644 --- a/internal/k8s/reconciler/gatewayclass_test.go +++ b/internal/k8s/reconciler/gatewayclass_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/go-hclog" "github.com/stretchr/testify/require" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) func TestGatewayClassValidate(t *testing.T) { @@ -21,7 +21,7 @@ func TestGatewayClassValidate(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - gatewayClass := NewK8sGatewayClass(&gw.GatewayClass{}, K8sGatewayClassConfig{ + gatewayClass := NewK8sGatewayClass(&gwv1beta1.GatewayClass{}, K8sGatewayClassConfig{ Logger: hclog.NewNullLogger(), Client: client, }) @@ -29,9 +29,9 @@ func TestGatewayClassValidate(t *testing.T) { require.Equal(t, GatewayClassConditionReasonAccepted, gatewayClass.status.Accepted.Condition(0).Reason) require.NoError(t, gatewayClass.Validate(context.Background())) - gatewayClass = NewK8sGatewayClass(&gw.GatewayClass{ - Spec: gw.GatewayClassSpec{ - ParametersRef: &gw.ParametersReference{ + gatewayClass = NewK8sGatewayClass(&gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: "group", Kind: "kind", }, @@ -44,9 +44,9 @@ func TestGatewayClassValidate(t *testing.T) { require.Equal(t, GatewayClassConditionReasonInvalidParameters, gatewayClass.status.Accepted.Condition(0).Reason) require.NoError(t, gatewayClass.Validate(context.Background())) - gatewayClass = NewK8sGatewayClass(&gw.GatewayClass{ - Spec: gw.GatewayClassSpec{ - ParametersRef: &gw.ParametersReference{ + gatewayClass = NewK8sGatewayClass(&gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "config", @@ -80,12 +80,12 @@ func TestGatewayClasses(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - gatewayClass := NewK8sGatewayClass(&gw.GatewayClass{ + gatewayClass := NewK8sGatewayClass(&gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ ResourceVersion: "1", }, - Spec: gw.GatewayClassSpec{ - ParametersRef: &gw.ParametersReference{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "config", @@ -115,12 +115,12 @@ func TestGatewayClasses(t *testing.T) { _, found = classes.GetConfig("") require.True(t, found) - gatewayClass = NewK8sGatewayClass(&gw.GatewayClass{ + gatewayClass = NewK8sGatewayClass(&gwv1beta1.GatewayClass{ ObjectMeta: meta.ObjectMeta{ ResourceVersion: "0", }, - Spec: gw.GatewayClassSpec{ - ParametersRef: &gw.ParametersReference{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, Name: "config", diff --git a/internal/k8s/reconciler/http_route.go b/internal/k8s/reconciler/http_route.go index 7130d123a..dcc5f652a 100644 --- a/internal/k8s/reconciler/http_route.go +++ b/internal/k8s/reconciler/http_route.go @@ -4,14 +4,14 @@ import ( "github.com/hashicorp/consul-api-gateway/internal/core" "github.com/hashicorp/consul-api-gateway/internal/k8s/service" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) func HTTPRouteID(namespacedName types.NamespacedName) string { return "http-" + namespacedName.String() } -func convertHTTPRoute(namespace, hostname, prefix string, meta map[string]string, route *gw.HTTPRoute, k8sRoute *K8sRoute) *core.ResolvedRoute { +func convertHTTPRoute(namespace, hostname, prefix string, meta map[string]string, route *gwv1alpha2.HTTPRoute, k8sRoute *K8sRoute) *core.ResolvedRoute { hostnames := []string{} for _, hostname := range route.Spec.Hostnames { hostnames = append(hostnames, string(hostname)) @@ -37,32 +37,32 @@ func convertHTTPRoute(namespace, hostname, prefix string, meta map[string]string return &resolved } -var methodMappings = map[gw.HTTPMethod]core.HTTPMethod{ - gw.HTTPMethodConnect: core.HTTPMethodConnect, - gw.HTTPMethodDelete: core.HTTPMethodDelete, - gw.HTTPMethodPost: core.HTTPMethodPost, - gw.HTTPMethodPut: core.HTTPMethodPut, - gw.HTTPMethodPatch: core.HTTPMethodPatch, - gw.HTTPMethodGet: core.HTTPMethodGet, - gw.HTTPMethodOptions: core.HTTPMethodOptions, - gw.HTTPMethodTrace: core.HTTPMethodTrace, - gw.HTTPMethodHead: core.HTTPMethodHead, +var methodMappings = map[gwv1alpha2.HTTPMethod]core.HTTPMethod{ + gwv1alpha2.HTTPMethodConnect: core.HTTPMethodConnect, + gwv1alpha2.HTTPMethodDelete: core.HTTPMethodDelete, + gwv1alpha2.HTTPMethodPost: core.HTTPMethodPost, + gwv1alpha2.HTTPMethodPut: core.HTTPMethodPut, + gwv1alpha2.HTTPMethodPatch: core.HTTPMethodPatch, + gwv1alpha2.HTTPMethodGet: core.HTTPMethodGet, + gwv1alpha2.HTTPMethodOptions: core.HTTPMethodOptions, + gwv1alpha2.HTTPMethodTrace: core.HTTPMethodTrace, + gwv1alpha2.HTTPMethodHead: core.HTTPMethodHead, } -var pathMappings = map[gw.PathMatchType]core.HTTPPathMatchType{ - gw.PathMatchExact: core.HTTPPathMatchExactType, - gw.PathMatchPathPrefix: core.HTTPPathMatchPrefixType, - gw.PathMatchRegularExpression: core.HTTPPathMatchRegularExpressionType, +var pathMappings = map[gwv1alpha2.PathMatchType]core.HTTPPathMatchType{ + gwv1alpha2.PathMatchExact: core.HTTPPathMatchExactType, + gwv1alpha2.PathMatchPathPrefix: core.HTTPPathMatchPrefixType, + gwv1alpha2.PathMatchRegularExpression: core.HTTPPathMatchRegularExpressionType, } -var queryMappings = map[gw.QueryParamMatchType]core.HTTPQueryMatchType{ - gw.QueryParamMatchExact: core.HTTPQueryMatchExactType, - gw.QueryParamMatchRegularExpression: core.HTTPQueryMatchRegularExpressionType, +var queryMappings = map[gwv1alpha2.QueryParamMatchType]core.HTTPQueryMatchType{ + gwv1alpha2.QueryParamMatchExact: core.HTTPQueryMatchExactType, + gwv1alpha2.QueryParamMatchRegularExpression: core.HTTPQueryMatchRegularExpressionType, } -var headerMappings = map[gw.HeaderMatchType]core.HTTPHeaderMatchType{ - gw.HeaderMatchExact: core.HTTPHeaderMatchExactType, - gw.HeaderMatchRegularExpression: core.HTTPHeaderMatchRegularExpressionType, +var headerMappings = map[gwv1alpha2.HeaderMatchType]core.HTTPHeaderMatchType{ + gwv1alpha2.HeaderMatchExact: core.HTTPHeaderMatchExactType, + gwv1alpha2.HeaderMatchRegularExpression: core.HTTPHeaderMatchRegularExpressionType, } func httpReferencesToRules(referenceMap service.RouteRuleReferenceMap) []core.HTTPRouteRule { @@ -79,7 +79,7 @@ func httpReferencesToRules(referenceMap service.RouteRuleReferenceMap) []core.HT } } if match.Path != nil && match.Path.Value != nil { - matchType := gw.PathMatchExact + matchType := gwv1alpha2.PathMatchExact if match.Path.Type != nil { matchType = *match.Path.Type } @@ -91,7 +91,7 @@ func httpReferencesToRules(referenceMap service.RouteRuleReferenceMap) []core.HT } } for _, param := range match.QueryParams { - matchType := gw.QueryParamMatchExact + matchType := gwv1alpha2.QueryParamMatchExact if param.Type != nil { matchType = *param.Type } @@ -104,7 +104,7 @@ func httpReferencesToRules(referenceMap service.RouteRuleReferenceMap) []core.HT } } for _, header := range match.Headers { - matchType := gw.HeaderMatchExact + matchType := gwv1alpha2.HeaderMatchExact if header.Type != nil { matchType = *header.Type } @@ -150,11 +150,11 @@ func httpReferencesToRules(referenceMap service.RouteRuleReferenceMap) []core.HT return resolved } -func convertHTTPRouteFilters(routeFilters []gw.HTTPRouteFilter) []core.HTTPFilter { +func convertHTTPRouteFilters(routeFilters []gwv1alpha2.HTTPRouteFilter) []core.HTTPFilter { filters := []core.HTTPFilter{} for _, filter := range routeFilters { switch filter.Type { - case gw.HTTPRouteFilterRequestHeaderModifier: + case gwv1alpha2.HTTPRouteFilterRequestHeaderModifier: filters = append(filters, core.HTTPFilter{ Type: core.HTTPHeaderFilterType, Header: core.HTTPHeaderFilter{ @@ -163,7 +163,7 @@ func convertHTTPRouteFilters(routeFilters []gw.HTTPRouteFilter) []core.HTTPFilte Remove: filter.RequestHeaderModifier.Remove, }, }) - case gw.HTTPRouteFilterRequestRedirect: + case gwv1alpha2.HTTPRouteFilterRequestRedirect: scheme := "" if filter.RequestRedirect.Scheme != nil { scheme = *filter.RequestRedirect.Scheme @@ -194,7 +194,7 @@ func convertHTTPRouteFilters(routeFilters []gw.HTTPRouteFilter) []core.HTTPFilte return filters } -func httpHeadersToMap(headers []gw.HTTPHeader) map[string]string { +func httpHeadersToMap(headers []gwv1alpha2.HTTPHeader) map[string]string { resolved := make(map[string]string) for _, header := range headers { resolved[string(header.Name)] = header.Value diff --git a/internal/k8s/reconciler/http_route_test.go b/internal/k8s/reconciler/http_route_test.go index 947644e78..46b79f8ef 100644 --- a/internal/k8s/reconciler/http_route_test.go +++ b/internal/k8s/reconciler/http_route_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/consul-api-gateway/internal/k8s/service" ) @@ -21,62 +21,62 @@ func TestConvertHTTPRoute(t *testing.T) { t.Parallel() path := "/" - method := gw.HTTPMethodPost - matchType := gw.PathMatchExact - queryMatchType := gw.QueryParamMatchExact - headerMatchType := gw.HeaderMatchExact + method := gwv1alpha2.HTTPMethodPost + matchType := gwv1alpha2.PathMatchExact + queryMatchType := gwv1alpha2.QueryParamMatchExact + headerMatchType := gwv1alpha2.HeaderMatchExact weight := int32(10) protocol := "https" - hostname := gw.PreciseHostname("example.com") - port := gw.PortNumber(8443) + hostname := gwv1alpha2.PreciseHostname("example.com") + port := gwv1alpha2.PortNumber(8443) statusCode := 302 for _, test := range []struct { name string namespace string hostname string meta map[string]string - route *gw.HTTPRoute + route *gwv1alpha2.HTTPRoute references service.RouteRuleReferenceMap expected string }{{ name: "kitchen-sink", - route: &gw.HTTPRoute{}, + route: &gwv1alpha2.HTTPRoute{}, references: service.RouteRuleReferenceMap{ service.RouteRule{ - HTTPRule: &gw.HTTPRouteRule{ - Matches: []gw.HTTPRouteMatch{{ + HTTPRule: &gwv1alpha2.HTTPRouteRule{ + Matches: []gwv1alpha2.HTTPRouteMatch{{ Method: &method, - Path: &gw.HTTPPathMatch{ + Path: &gwv1alpha2.HTTPPathMatch{ Value: &path, Type: &matchType, }, - QueryParams: []gw.HTTPQueryParamMatch{{ + QueryParams: []gwv1alpha2.HTTPQueryParamMatch{{ Type: &queryMatchType, Name: "a", Value: "b", }}, - Headers: []gw.HTTPHeaderMatch{{ + Headers: []gwv1alpha2.HTTPHeaderMatch{{ Type: &headerMatchType, - Name: gw.HTTPHeaderName("a"), + Name: gwv1alpha2.HTTPHeaderName("a"), Value: "b", }}, }}, - Filters: []gw.HTTPRouteFilter{{ - Type: gw.HTTPRouteFilterRequestRedirect, - RequestRedirect: &gw.HTTPRequestRedirectFilter{ + Filters: []gwv1alpha2.HTTPRouteFilter{{ + Type: gwv1alpha2.HTTPRouteFilterRequestRedirect, + RequestRedirect: &gwv1alpha2.HTTPRequestRedirectFilter{ Scheme: &protocol, Hostname: &hostname, Port: &port, StatusCode: &statusCode, }, }, { - Type: gw.HTTPRouteFilterRequestHeaderModifier, - RequestHeaderModifier: &gw.HTTPRequestHeaderFilter{ - Set: []gw.HTTPHeader{{ + Type: gwv1alpha2.HTTPRouteFilterRequestHeaderModifier, + RequestHeaderModifier: &gwv1alpha2.HTTPRequestHeaderFilter{ + Set: []gwv1alpha2.HTTPHeader{{ Name: "x-a", Value: "a", }}, - Add: []gw.HTTPHeader{{ + Add: []gwv1alpha2.HTTPHeader{{ Name: "x-b", Value: "b", }}, @@ -91,8 +91,8 @@ func TestConvertHTTPRoute(t *testing.T) { Namespace: "namespace", }, Reference: &service.BackendReference{ - HTTPRef: &gw.HTTPBackendRef{ - BackendRef: gw.BackendRef{ + HTTPRef: &gwv1alpha2.HTTPBackendRef{ + BackendRef: gwv1alpha2.BackendRef{ Weight: &weight, }, }, @@ -186,9 +186,9 @@ func TestConvertHTTPRoute(t *testing.T) { `, }, { name: "hostnames", - route: &gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - Hostnames: []gw.Hostname{"*"}, + route: &gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Hostnames: []gwv1alpha2.Hostname{"*"}, }, }, references: service.RouteRuleReferenceMap{}, diff --git a/internal/k8s/reconciler/listener.go b/internal/k8s/reconciler/listener.go index d27b668fd..0dd97af06 100644 --- a/internal/k8s/reconciler/listener.go +++ b/internal/k8s/reconciler/listener.go @@ -9,7 +9,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -21,17 +22,17 @@ import ( ) var ( - supportedProtocols = map[gw.ProtocolType][]gw.RouteGroupKind{ - gw.HTTPProtocolType: {{ - Group: (*gw.Group)(&gw.GroupVersion.Group), + supportedProtocols = map[gwv1beta1.ProtocolType][]gwv1beta1.RouteGroupKind{ + gwv1beta1.HTTPProtocolType: {{ + Group: (*gwv1beta1.Group)(&gwv1beta1.GroupVersion.Group), Kind: "HTTPRoute", }}, - gw.HTTPSProtocolType: {{ - Group: (*gw.Group)(&gw.GroupVersion.Group), + gwv1beta1.HTTPSProtocolType: {{ + Group: (*gwv1beta1.Group)(&gwv1beta1.GroupVersion.Group), Kind: "HTTPRoute", }}, - gw.TCPProtocolType: {{ - Group: (*gw.Group)(&gw.GroupVersion.Group), + gwv1beta1.TCPProtocolType: {{ + Group: (*gwv1beta1.Group)(&gwv1alpha2.GroupVersion.Group), Kind: "TCPRoute", }}, } @@ -48,14 +49,14 @@ const ( type K8sListener struct { consulNamespace string logger hclog.Logger - gateway *gw.Gateway - listener gw.Listener + gateway *gwv1beta1.Gateway + listener gwv1beta1.Listener client gatewayclient.Client status ListenerStatus tls core.TLSParams routeCount int32 - supportedKinds []gw.RouteGroupKind + supportedKinds []gwv1beta1.RouteGroupKind } var _ store.RouteTrackingListener = &K8sListener{} @@ -66,7 +67,7 @@ type K8sListenerConfig struct { Client gatewayclient.Client } -func NewK8sListener(gateway *gw.Gateway, listener gw.Listener, config K8sListenerConfig) *K8sListener { +func NewK8sListener(gateway *gwv1beta1.Gateway, listener gwv1beta1.Listener, config K8sListenerConfig) *K8sListener { listenerLogger := config.Logger.Named("listener").With("listener", string(listener.Name)) return &K8sListener{ @@ -109,7 +110,7 @@ func (l *K8sListener) validateTLS(ctx context.Context) error { return nil } - if l.listener.TLS.Mode != nil && *l.listener.TLS.Mode == gw.TLSModePassthrough { + if l.listener.TLS.Mode != nil && *l.listener.TLS.Mode == gwv1beta1.TLSModePassthrough { l.status.Ready.Invalid = errors.New("tls passthrough not supported") return nil } @@ -241,8 +242,8 @@ func (l *K8sListener) validateProtocols() { } } -func kindsNotInSet(set, parent []gw.RouteGroupKind) []gw.RouteGroupKind { - kinds := []gw.RouteGroupKind{} +func kindsNotInSet(set, parent []gwv1beta1.RouteGroupKind) []gwv1beta1.RouteGroupKind { + kinds := []gwv1beta1.RouteGroupKind{} for _, kind := range set { if !isKindInSet(kind, parent) { kinds = append(kinds, kind) @@ -251,7 +252,7 @@ func kindsNotInSet(set, parent []gw.RouteGroupKind) []gw.RouteGroupKind { return kinds } -func isKindInSet(value gw.RouteGroupKind, set []gw.RouteGroupKind) bool { +func isKindInSet(value gwv1beta1.RouteGroupKind, set []gwv1beta1.RouteGroupKind) bool { for _, kind := range set { groupsMatch := false if value.Group == nil && kind.Group == nil { @@ -266,7 +267,7 @@ func isKindInSet(value gw.RouteGroupKind, set []gw.RouteGroupKind) bool { return false } -func (l *K8sListener) resolveCertificateReference(ctx context.Context, ref gw.SecretObjectReference) (string, error) { +func (l *K8sListener) resolveCertificateReference(ctx context.Context, ref gwv1beta1.SecretObjectReference) (string, error) { group := corev1.GroupName kind := "Secret" namespace := l.gateway.Namespace @@ -351,7 +352,7 @@ func (l *K8sListener) CanBind(ctx context.Context, route store.Route) (bool, err return false, nil } -func (l *K8sListener) canBind(ctx context.Context, ref gw.ParentReference, route *K8sRoute) (bool, error) { +func (l *K8sListener) canBind(ctx context.Context, ref gwv1alpha2.ParentReference, route *K8sRoute) (bool, error) { if l.status.Ready.HasError() { l.logger.Trace("listener not ready, unable to bind", "route", route.ID()) return false, nil @@ -410,16 +411,16 @@ func (l *K8sListener) OnRouteRemoved(_ string) { atomic.AddInt32(&l.routeCount, -1) } -func (l *K8sListener) Status() gw.ListenerStatus { +func (l *K8sListener) Status() gwv1beta1.ListenerStatus { routeCount := atomic.LoadInt32(&l.routeCount) - if l.listener.Protocol == gw.TCPProtocolType { + if l.listener.Protocol == gwv1beta1.TCPProtocolType { if routeCount > 1 { l.status.Conflicted.RouteConflict = errors.New("only a single TCP route can be bound to a TCP listener") } else { l.status.Conflicted.RouteConflict = nil } } - return gw.ListenerStatus{ + return gwv1beta1.ListenerStatus{ Name: l.listener.Name, SupportedKinds: l.supportedKinds, AttachedRoutes: routeCount, @@ -429,7 +430,7 @@ func (l *K8sListener) Status() gw.ListenerStatus { func (l *K8sListener) IsValid() bool { routeCount := atomic.LoadInt32(&l.routeCount) - if l.listener.Protocol == gw.TCPProtocolType { + if l.listener.Protocol == gwv1beta1.TCPProtocolType { if routeCount > 1 { return false } diff --git a/internal/k8s/reconciler/listener_test.go b/internal/k8s/reconciler/listener_test.go index 1e134ca29..a0a58920e 100644 --- a/internal/k8s/reconciler/listener_test.go +++ b/internal/k8s/reconciler/listener_test.go @@ -11,7 +11,8 @@ import ( k8s "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -24,11 +25,11 @@ import ( func TestListenerID(t *testing.T) { t.Parallel() - require.Equal(t, "", NewK8sListener(&gw.Gateway{}, gw.Listener{}, K8sListenerConfig{ + require.Equal(t, "", NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }).ID()) - require.Equal(t, "test", NewK8sListener(&gw.Gateway{}, gw.Listener{ - Name: gw.SectionName("test"), + require.Equal(t, "test", NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Name: gwv1beta1.SectionName("test"), }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }).ID()) @@ -43,7 +44,7 @@ func TestListenerValidate(t *testing.T) { client := mocks.NewMockClient(ctrl) t.Run("Unsupported protocol", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{}, K8sListenerConfig{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) require.NoError(t, listener.Validate(context.Background())) @@ -54,10 +55,10 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid route kinds", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPProtocolType, - AllowedRoutes: &gw.AllowedRoutes{ - Kinds: []gw.RouteGroupKind{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPProtocolType, + AllowedRoutes: &gwv1beta1.AllowedRoutes{ + Kinds: []gwv1beta1.RouteGroupKind{{ Kind: "UDPRoute", }}, }, @@ -70,12 +71,12 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Unsupported address", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{ - Spec: gw.GatewaySpec{ - Addresses: []gw.GatewayAddress{{}}, + listener := NewK8sListener(&gwv1beta1.Gateway{ + Spec: gwv1beta1.GatewaySpec{ + Addresses: []gwv1beta1.GatewayAddress{{}}, }, - }, gw.Listener{ - Protocol: gw.HTTPProtocolType, + }, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPProtocolType, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) @@ -85,8 +86,8 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid TLS config", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) @@ -96,10 +97,10 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid TLS passthrough", func(t *testing.T) { - mode := gw.TLSModePassthrough - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ + mode := gwv1beta1.TLSModePassthrough + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ Mode: &mode, }, }, K8sListenerConfig{ @@ -111,9 +112,9 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid certificate ref", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{}, + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{}, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) @@ -123,10 +124,10 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Fail to retrieve secret", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, }, @@ -139,10 +140,10 @@ func TestListenerValidate(t *testing.T) { }) t.Run("No secret found", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, }, @@ -157,11 +158,11 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid cross-namespace secret ref with no ReferenceGrant", func(t *testing.T) { - otherNamespace := gw.Namespace("other-namespace") - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + otherNamespace := gwv1beta1.Namespace("other-namespace") + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Namespace: &otherNamespace, Name: "secret", }}, @@ -170,23 +171,24 @@ func TestListenerValidate(t *testing.T) { Logger: hclog.NewNullLogger(), Client: client, }) - client.EXPECT().GetReferenceGrantsInNamespace(gomock.Any(), string(otherNamespace)).Return([]gw.ReferenceGrant{}, nil) + client.EXPECT().GetReferenceGrantsInNamespace(gomock.Any(), string(otherNamespace)).Return([]gwv1alpha2.ReferenceGrant{}, nil) require.NoError(t, listener.Validate(context.Background())) condition := listener.status.ResolvedRefs.Condition(0) assert.Equal(t, ListenerConditionReasonInvalidCertificateRef, condition.Reason) }) t.Run("Valid cross-namespace secret ref with ReferenceGrant", func(t *testing.T) { - gatewayNamespace := gw.Namespace("gateway-namespace") - secretNamespace := gw.Namespace("secret-namespace") + gatewayNamespace := gwv1beta1.Namespace("gateway-namespace") + refGrantGatewayNamespace := gwv1alpha2.Namespace("gateway-namespace") + secretNamespace := gwv1beta1.Namespace("secret-namespace") listener := NewK8sListener( - &gw.Gateway{ + &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{Namespace: string(gatewayNamespace)}, TypeMeta: meta.TypeMeta{APIVersion: "gateway.networking.k8s.io/v1alpha2", Kind: "Gateway"}}, - gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Namespace: &secretNamespace, Name: "secret", }}, @@ -196,14 +198,14 @@ func TestListenerValidate(t *testing.T) { Client: client, }) client.EXPECT().GetReferenceGrantsInNamespace(gomock.Any(), string(secretNamespace)). - Return([]gw.ReferenceGrant{{ - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{ + Return([]gwv1alpha2.ReferenceGrant{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "Gateway", - Namespace: gatewayNamespace, + Namespace: refGrantGatewayNamespace, }}, - To: []gw.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Kind: "Secret", }}, }, @@ -219,10 +221,10 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Valid same-namespace secret ref without ReferenceGrant", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, }, @@ -241,12 +243,12 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Unsupported certificate type", func(t *testing.T) { - group := gw.Group("group") - kind := gw.Kind("kind") - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + group := gwv1beta1.Group("group") + kind := gwv1beta1.Kind("kind") + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Group: &group, Kind: &kind, Name: "secret", @@ -262,13 +264,13 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Valid minimum TLS version", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, - Options: map[gw.AnnotationKey]gw.AnnotationValue{ + Options: map[gwv1beta1.AnnotationKey]gwv1beta1.AnnotationValue{ "api-gateway.consul.hashicorp.com/tls_min_version": "TLSv1_2", }, }, @@ -288,13 +290,13 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid minimum TLS version", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, - Options: map[gw.AnnotationKey]gw.AnnotationValue{ + Options: map[gwv1beta1.AnnotationKey]gwv1beta1.AnnotationValue{ "api-gateway.consul.hashicorp.com/tls_min_version": "foo", }, }, @@ -314,13 +316,13 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Valid TLS cipher suite", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, - Options: map[gw.AnnotationKey]gw.AnnotationValue{ + Options: map[gwv1beta1.AnnotationKey]gwv1beta1.AnnotationValue{ "api-gateway.consul.hashicorp.com/tls_cipher_suites": "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", }, }, @@ -340,13 +342,13 @@ func TestListenerValidate(t *testing.T) { }) t.Run("TLS cipher suite not allowed", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, - Options: map[gw.AnnotationKey]gw.AnnotationValue{ + Options: map[gwv1beta1.AnnotationKey]gwv1beta1.AnnotationValue{ "api-gateway.consul.hashicorp.com/tls_min_version": "TLSv1_3", "api-gateway.consul.hashicorp.com/tls_cipher_suites": "foo", }, @@ -367,13 +369,13 @@ func TestListenerValidate(t *testing.T) { }) t.Run("Invalid TLS cipher suite", func(t *testing.T) { - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{ - Protocol: gw.HTTPSProtocolType, - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPSProtocolType, + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Name: "secret", }}, - Options: map[gw.AnnotationKey]gw.AnnotationValue{ + Options: map[gwv1beta1.AnnotationKey]gwv1beta1.AnnotationValue{ "api-gateway.consul.hashicorp.com/tls_cipher_suites": "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, foo", }, }, @@ -396,21 +398,21 @@ func TestListenerValidate(t *testing.T) { func TestIsKindInSet(t *testing.T) { t.Parallel() - require.False(t, isKindInSet(gw.RouteGroupKind{ - Kind: gw.Kind("test"), - }, []gw.RouteGroupKind{})) - require.True(t, isKindInSet(gw.RouteGroupKind{ - Kind: gw.Kind("test"), - }, []gw.RouteGroupKind{{ - Kind: gw.Kind("test"), + require.False(t, isKindInSet(gwv1beta1.RouteGroupKind{ + Kind: gwv1beta1.Kind("test"), + }, []gwv1beta1.RouteGroupKind{})) + require.True(t, isKindInSet(gwv1beta1.RouteGroupKind{ + Kind: gwv1beta1.Kind("test"), + }, []gwv1beta1.RouteGroupKind{{ + Kind: gwv1beta1.Kind("test"), }})) - group := gw.Group("group") - require.True(t, isKindInSet(gw.RouteGroupKind{ - Kind: gw.Kind("test"), + group := gwv1beta1.Group("group") + require.True(t, isKindInSet(gwv1beta1.RouteGroupKind{ + Kind: gwv1beta1.Kind("test"), Group: &group, - }, []gw.RouteGroupKind{{ - Kind: gw.Kind("test"), + }, []gwv1beta1.RouteGroupKind{{ + Kind: gwv1beta1.Kind("test"), Group: &group, }})) } @@ -421,18 +423,18 @@ func TestListenerConfig(t *testing.T) { require.Equal(t, store.ListenerConfig{ Name: "listener", TLS: core.TLSParams{Enabled: false}, - }, NewK8sListener(&gw.Gateway{}, gw.Listener{ - Name: gw.SectionName("listener"), + }, NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ + Name: gwv1beta1.SectionName("listener"), }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }).Config()) - hostname := gw.Hostname("hostname") + hostname := gwv1beta1.Hostname("hostname") require.Equal(t, store.ListenerConfig{ Name: "default", Hostname: "hostname", TLS: core.TLSParams{Enabled: false}, - }, NewK8sListener(&gw.Gateway{}, gw.Listener{ + }, NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{ Hostname: &hostname, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), @@ -442,7 +444,7 @@ func TestListenerConfig(t *testing.T) { func TestRouteAddedCallbacks(t *testing.T) { t.Parallel() - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{}, K8sListenerConfig{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, int32(0), listener.routeCount) @@ -455,7 +457,7 @@ func TestRouteAddedCallbacks(t *testing.T) { func TestListenerStatusConditions(t *testing.T) { t.Parallel() - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{}, K8sListenerConfig{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) require.Len(t, listener.Status().Conditions, 4) @@ -465,7 +467,7 @@ func TestListenerCanBind(t *testing.T) { t.Parallel() // alternative type - listener := NewK8sListener(&gw.Gateway{}, gw.Listener{}, K8sListenerConfig{ + listener := NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) canBind, err := listener.CanBind(context.Background(), storeMocks.NewMockRoute(nil)) @@ -473,27 +475,27 @@ func TestListenerCanBind(t *testing.T) { require.False(t, canBind) // no match - listener = NewK8sListener(&gw.Gateway{}, gw.Listener{}, K8sListenerConfig{ + listener = NewK8sListener(&gwv1beta1.Gateway{}, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), })) require.NoError(t, err) require.False(t, canBind) // match - listener = NewK8sListener(&gw.Gateway{ + listener = NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - }, gw.Listener{}, K8sListenerConfig{ + }, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", }}, }, @@ -505,18 +507,18 @@ func TestListenerCanBind(t *testing.T) { require.True(t, canBind) // not ready - listener = NewK8sListener(&gw.Gateway{ + listener = NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - }, gw.Listener{}, K8sListenerConfig{ + }, gwv1beta1.Listener{}, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) listener.status.Ready.Invalid = errors.New("invalid") - canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + canBind, err = listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", }}, }, @@ -533,27 +535,28 @@ func TestListenerCanBind_RouteKind(t *testing.T) { routeMeta := meta.TypeMeta{} routeMeta.SetGroupVersionKind(schema.GroupVersionKind{ - Group: gw.GroupVersion.Group, - Version: gw.GroupVersion.Version, + Group: gwv1alpha2.GroupVersion.Group, + Version: gwv1alpha2.GroupVersion.Version, Kind: "UDPRoute", }) - name := gw.SectionName("listener") + listenerName := gwv1beta1.SectionName("listener") + routeSectionName := gwv1alpha2.SectionName("listener") - listener := NewK8sListener(&gw.Gateway{ + listener := NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - }, gw.Listener{ - Protocol: gw.HTTPProtocolType, + }, gwv1beta1.Listener{ + Protocol: gwv1beta1.HTTPProtocolType, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) require.NoError(t, listener.Validate(context.Background())) - canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.UDPRoute{ + canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.UDPRoute{ TypeMeta: routeMeta, - Spec: gw.UDPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.UDPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", }}, }, @@ -564,24 +567,24 @@ func TestListenerCanBind_RouteKind(t *testing.T) { require.NoError(t, err) require.False(t, canBind) - listener = NewK8sListener(&gw.Gateway{ + listener = NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - }, gw.Listener{ - Name: name, - Protocol: gw.HTTPProtocolType, + }, gwv1beta1.Listener{ + Name: listenerName, + Protocol: gwv1beta1.HTTPProtocolType, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - listener.supportedKinds = supportedProtocols[gw.HTTPProtocolType] - _, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.UDPRoute{ + listener.supportedKinds = supportedProtocols[gwv1beta1.HTTPProtocolType] + _, err = listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.UDPRoute{ TypeMeta: routeMeta, - Spec: gw.UDPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.UDPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", - SectionName: &name, + SectionName: &routeSectionName, }}, }, }, @@ -594,42 +597,43 @@ func TestListenerCanBind_RouteKind(t *testing.T) { func TestListenerCanBind_AllowedNamespaces(t *testing.T) { t.Parallel() - name := gw.SectionName("listener") - same := gw.NamespacesFromSame - selector := gw.NamespacesFromSelector - other := gw.Namespace("other") + listenerName := gwv1beta1.SectionName("listener") + routeSectionName := gwv1alpha2.SectionName("listener") + same := gwv1beta1.NamespacesFromSame + selector := gwv1beta1.NamespacesFromSelector + other := gwv1alpha2.Namespace("other") routeMeta := meta.TypeMeta{} routeMeta.SetGroupVersionKind(schema.GroupVersionKind{ - Group: gw.GroupVersion.Group, - Version: gw.GroupVersion.Version, + Group: gwv1beta1.GroupVersion.Group, + Version: gwv1beta1.GroupVersion.Version, Kind: "HTTPRoute", }) - listener := NewK8sListener(&gw.Gateway{ + listener := NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", Namespace: "other", }, - }, gw.Listener{ - Name: name, - Protocol: gw.HTTPProtocolType, - AllowedRoutes: &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + }, gwv1beta1.Listener{ + Name: listenerName, + Protocol: gwv1beta1.HTTPProtocolType, + AllowedRoutes: &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &same, }, }, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - listener.supportedKinds = supportedProtocols[gw.HTTPProtocolType] - _, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ + listener.supportedKinds = supportedProtocols[gwv1beta1.HTTPProtocolType] + _, err := listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", Namespace: &other, - SectionName: &name, + SectionName: &routeSectionName, }}, }, }, @@ -637,11 +641,11 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { Logger: hclog.NewNullLogger(), })) require.Error(t, err) - canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ + canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", Namespace: &other, }}, @@ -653,16 +657,16 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { require.NoError(t, err) require.False(t, canBind) - listener = NewK8sListener(&gw.Gateway{ + listener = NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", Namespace: "other", }, - }, gw.Listener{ - Name: name, - Protocol: gw.HTTPProtocolType, - AllowedRoutes: &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + }, gwv1beta1.Listener{ + Name: listenerName, + Protocol: gwv1beta1.HTTPProtocolType, + AllowedRoutes: &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &selector, Selector: &meta.LabelSelector{ MatchExpressions: []meta.LabelSelectorRequirement{{ @@ -675,15 +679,15 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - listener.supportedKinds = supportedProtocols[gw.HTTPProtocolType] - _, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ + listener.supportedKinds = supportedProtocols[gwv1beta1.HTTPProtocolType] + _, err = listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", Namespace: &other, - SectionName: &name, + SectionName: &routeSectionName, }}, }, }, @@ -691,11 +695,11 @@ func TestListenerCanBind_AllowedNamespaces(t *testing.T) { Logger: hclog.NewNullLogger(), })) require.Error(t, err) - _, err = listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ + _, err = listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", Namespace: &other, }}, @@ -712,49 +716,50 @@ func TestListenerCanBind_HostnameMatch(t *testing.T) { routeMeta := meta.TypeMeta{} routeMeta.SetGroupVersionKind(schema.GroupVersionKind{ - Group: gw.GroupVersion.Group, - Version: gw.GroupVersion.Version, + Group: gwv1beta1.GroupVersion.Group, + Version: gwv1beta1.GroupVersion.Version, Kind: "HTTPRoute", }) - name := gw.SectionName("listener") - hostname := gw.Hostname("hostname") - listener := NewK8sListener(&gw.Gateway{ + listenerName := gwv1beta1.SectionName("listener") + routeSectionName := gwv1alpha2.SectionName("listener") + hostname := gwv1beta1.Hostname("hostname") + listener := NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - }, gw.Listener{ - Name: name, + }, gwv1beta1.Listener{ + Name: listenerName, Hostname: &hostname, - Protocol: gw.HTTPProtocolType, + Protocol: gwv1beta1.HTTPProtocolType, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - listener.supportedKinds = supportedProtocols[gw.HTTPProtocolType] - _, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ + listener.supportedKinds = supportedProtocols[gwv1beta1.HTTPProtocolType] + _, err := listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", - SectionName: &name, + SectionName: &routeSectionName, }}, }, - Hostnames: []gw.Hostname{"other"}, + Hostnames: []gwv1alpha2.Hostname{"other"}, }, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), })) require.Error(t, err) - canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ + canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", }}, }, - Hostnames: []gw.Hostname{"other"}, + Hostnames: []gwv1alpha2.Hostname{"other"}, }, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), @@ -766,27 +771,27 @@ func TestListenerCanBind_HostnameMatch(t *testing.T) { func TestListenerCanBind_NameMatch(t *testing.T) { t.Parallel() - name := gw.SectionName("listener") - otherName := gw.SectionName("other") - listener := NewK8sListener(&gw.Gateway{ + listenerName := gwv1beta1.SectionName("listener") + otherName := gwv1alpha2.SectionName("other") + listener := NewK8sListener(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", }, - }, gw.Listener{ - Name: name, - Protocol: gw.HTTPProtocolType, + }, gwv1beta1.Listener{ + Name: listenerName, + Protocol: gwv1beta1.HTTPProtocolType, }, K8sListenerConfig{ Logger: hclog.NewNullLogger(), }) - canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + canBind, err := listener.CanBind(context.Background(), NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", SectionName: &otherName, }}, }, - Hostnames: []gw.Hostname{"other"}, + Hostnames: []gwv1alpha2.Hostname{"other"}, }, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), diff --git a/internal/k8s/reconciler/manager.go b/internal/k8s/reconciler/manager.go index 3ffa99da9..4b8d0a923 100644 --- a/internal/k8s/reconciler/manager.go +++ b/internal/k8s/reconciler/manager.go @@ -6,7 +6,8 @@ import ( "sync" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-hclog" @@ -27,8 +28,8 @@ const ( ) type ReconcileManager interface { - UpsertGatewayClass(ctx context.Context, gc *gw.GatewayClass) error - UpsertGateway(ctx context.Context, g *gw.Gateway) error + UpsertGatewayClass(ctx context.Context, gc *gwv1beta1.GatewayClass) error + UpsertGateway(ctx context.Context, g *gwv1beta1.Gateway) error UpsertHTTPRoute(ctx context.Context, r Route) error UpsertTCPRoute(ctx context.Context, r Route) error UpsertTLSRoute(ctx context.Context, r Route) error @@ -90,7 +91,7 @@ func NewReconcileManager(config ManagerConfig) *GatewayReconcileManager { } } -func (m *GatewayReconcileManager) UpsertGatewayClass(ctx context.Context, gc *gw.GatewayClass) error { +func (m *GatewayReconcileManager) UpsertGatewayClass(ctx context.Context, gc *gwv1beta1.GatewayClass) error { class := NewK8sGatewayClass(gc, K8sGatewayClassConfig{ Logger: m.logger, Client: m.client, @@ -103,7 +104,7 @@ func (m *GatewayReconcileManager) UpsertGatewayClass(ctx context.Context, gc *gw return m.gatewayClasses.Upsert(ctx, class) } -func (m *GatewayReconcileManager) UpsertGateway(ctx context.Context, g *gw.Gateway) error { +func (m *GatewayReconcileManager) UpsertGateway(ctx context.Context, g *gwv1beta1.Gateway) error { m.mutex.Lock() defer m.mutex.Unlock() @@ -280,7 +281,7 @@ func (m *GatewayReconcileManager) deleteUnmanagedRoute(ctx context.Context, rout return true, nil } -func (m *GatewayReconcileManager) managedByCachedGatewaysForRoute(namespace string, parents []gw.ParentReference) bool { +func (m *GatewayReconcileManager) managedByCachedGatewaysForRoute(namespace string, parents []gwv1alpha2.ParentReference) bool { for _, parent := range parents { name, isGateway := utils.ReferencesGateway(namespace, parent) if isGateway { diff --git a/internal/k8s/reconciler/manager_test.go b/internal/k8s/reconciler/manager_test.go index cfcb5087c..819a1f26a 100644 --- a/internal/k8s/reconciler/manager_test.go +++ b/internal/k8s/reconciler/manager_test.go @@ -8,7 +8,8 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -33,7 +34,7 @@ func TestUpsertGatewayClass(t *testing.T) { Logger: hclog.NewNullLogger(), }) - inner := &gw.GatewayClass{} + inner := &gwv1beta1.GatewayClass{} expected := errors.New("expected") client.EXPECT().UpdateStatus(gomock.Any(), inner).Return(expected) require.Equal(t, expected, manager.UpsertGatewayClass(context.Background(), inner)) @@ -43,9 +44,9 @@ func TestUpsertGatewayClass(t *testing.T) { // validation client.EXPECT().GetGatewayClassConfig(gomock.Any(), gomock.Any()).Return(nil, expected) - require.Equal(t, expected, manager.UpsertGatewayClass(context.Background(), &gw.GatewayClass{ - Spec: gw.GatewayClassSpec{ - ParametersRef: &gw.ParametersReference{ + require.Equal(t, expected, manager.UpsertGatewayClass(context.Background(), &gwv1beta1.GatewayClass{ + Spec: gwv1beta1.GatewayClassSpec{ + ParametersRef: &gwv1beta1.ParametersReference{ Group: apigwv1alpha1.Group, Kind: apigwv1alpha1.GatewayClassConfigKind, }, @@ -68,7 +69,7 @@ func TestUpsertGateway(t *testing.T) { ConsulNamespaceMapper: testNamespaceMapper, }) - inner := &gw.Gateway{} + inner := &gwv1beta1.Gateway{} expected := errors.New("expected") client.EXPECT().GetConfigForGatewayClassName(gomock.Any(), "").Return(apigwv1alpha1.GatewayClassConfig{}, false, expected) @@ -114,22 +115,22 @@ func TestUpsertHTTPRoute(t *testing.T) { expected := errors.New("expected") client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, expected) - require.Equal(t, expected, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{})) + require.Equal(t, expected, manager.UpsertHTTPRoute(context.Background(), &gwv1alpha2.HTTPRoute{})) client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil) store.EXPECT().DeleteRoute(gomock.Any(), gomock.Any()).Return(expected) - require.Equal(t, expected, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{})) + require.Equal(t, expected, manager.UpsertHTTPRoute(context.Background(), &gwv1alpha2.HTTPRoute{})) client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil) store.EXPECT().DeleteRoute(gomock.Any(), gomock.Any()).Return(nil) - require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{})) + require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gwv1alpha2.HTTPRoute{})) manager.namespaceMap[types.NamespacedName{Name: "gateway"}] = "" store.EXPECT().UpsertRoute(gomock.Any(), gomock.Any()).Return(nil) - require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "gateway", }}, }, @@ -138,17 +139,17 @@ func TestUpsertHTTPRoute(t *testing.T) { client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) store.EXPECT().UpsertRoute(gomock.Any(), gomock.Any()).Return(nil) - require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{})) + require.NoError(t, manager.UpsertHTTPRoute(context.Background(), &gwv1alpha2.HTTPRoute{})) client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) client.EXPECT().GetService(gomock.Any(), gomock.Any()).Return(nil, expected) - port := gw.PortNumber(1) - require.Equal(t, expected, manager.UpsertHTTPRoute(context.Background(), &gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{ - BackendRef: gw.BackendRef{ - BackendObjectReference: gw.BackendObjectReference{ + port := gwv1alpha2.PortNumber(1) + require.Equal(t, expected, manager.UpsertHTTPRoute(context.Background(), &gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ Name: "name", Port: &port, }, @@ -176,7 +177,7 @@ func TestUpsertTCPRoute(t *testing.T) { client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) store.EXPECT().UpsertRoute(gomock.Any(), gomock.Any()).Return(nil) - require.NoError(t, manager.UpsertTCPRoute(context.Background(), &gw.TCPRoute{})) + require.NoError(t, manager.UpsertTCPRoute(context.Background(), &gwv1alpha2.TCPRoute{})) } func TestUpsertTLSRoute(t *testing.T) { @@ -196,7 +197,7 @@ func TestUpsertTLSRoute(t *testing.T) { client.EXPECT().IsManagedRoute(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) store.EXPECT().UpsertRoute(gomock.Any(), gomock.Any()).Return(nil) - require.NoError(t, manager.UpsertTLSRoute(context.Background(), &gw.TLSRoute{})) + require.NoError(t, manager.UpsertTLSRoute(context.Background(), &gwv1alpha2.TLSRoute{})) } func TestDeleteGatewayClass(t *testing.T) { diff --git a/internal/k8s/reconciler/mocks/manager.go b/internal/k8s/reconciler/mocks/manager.go index 1417248f0..0207522e3 100644 --- a/internal/k8s/reconciler/mocks/manager.go +++ b/internal/k8s/reconciler/mocks/manager.go @@ -11,7 +11,7 @@ import ( gomock "github.com/golang/mock/gomock" reconciler "github.com/hashicorp/consul-api-gateway/internal/k8s/reconciler" types "k8s.io/apimachinery/pkg/types" - v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) // MockReconcileManager is a mock of ReconcileManager interface. @@ -108,7 +108,7 @@ func (mr *MockReconcileManagerMockRecorder) DeleteTLSRoute(ctx, name interface{} } // UpsertGateway mocks base method. -func (m *MockReconcileManager) UpsertGateway(ctx context.Context, g *v1alpha2.Gateway) error { +func (m *MockReconcileManager) UpsertGateway(ctx context.Context, g *v1beta1.Gateway) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpsertGateway", ctx, g) ret0, _ := ret[0].(error) @@ -122,7 +122,7 @@ func (mr *MockReconcileManagerMockRecorder) UpsertGateway(ctx, g interface{}) *g } // UpsertGatewayClass mocks base method. -func (m *MockReconcileManager) UpsertGatewayClass(ctx context.Context, gc *v1alpha2.GatewayClass) error { +func (m *MockReconcileManager) UpsertGatewayClass(ctx context.Context, gc *v1beta1.GatewayClass) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpsertGatewayClass", ctx, gc) ret0, _ := ret[0].(error) diff --git a/internal/k8s/reconciler/route.go b/internal/k8s/reconciler/route.go index a47ae75bf..f1967864c 100644 --- a/internal/k8s/reconciler/route.go +++ b/internal/k8s/reconciler/route.go @@ -11,7 +11,8 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/core" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient" @@ -74,84 +75,84 @@ func (r *K8sRoute) parentKeyForGateway(parent types.NamespacedName) (string, boo func (r *K8sRoute) ID() string { switch r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: return HTTPRouteID(utils.NamespacedName(r.Route)) - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: return TCPRouteID(utils.NamespacedName(r.Route)) - case *gw.UDPRoute: + case *gwv1alpha2.UDPRoute: return UDPRouteID(utils.NamespacedName(r.Route)) - case *gw.TLSRoute: + case *gwv1alpha2.TLSRoute: return TLSRouteID(utils.NamespacedName(r.Route)) } return "" } -func (r *K8sRoute) MatchesHostname(hostname *gw.Hostname) bool { +func (r *K8sRoute) MatchesHostname(hostname *gwv1beta1.Hostname) bool { switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: return routeMatchesListenerHostname(hostname, route.Spec.Hostnames) default: return true } } -func (r *K8sRoute) CommonRouteSpec() gw.CommonRouteSpec { +func (r *K8sRoute) CommonRouteSpec() gwv1alpha2.CommonRouteSpec { switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: return route.Spec.CommonRouteSpec - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: return route.Spec.CommonRouteSpec - case *gw.UDPRoute: + case *gwv1alpha2.UDPRoute: return route.Spec.CommonRouteSpec - case *gw.TLSRoute: + case *gwv1alpha2.TLSRoute: return route.Spec.CommonRouteSpec } - return gw.CommonRouteSpec{} + return gwv1alpha2.CommonRouteSpec{} } -func (r *K8sRoute) routeStatus() gw.RouteStatus { +func (r *K8sRoute) routeStatus() gwv1alpha2.RouteStatus { switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: return route.Status.RouteStatus - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: return route.Status.RouteStatus - case *gw.UDPRoute: + case *gwv1alpha2.UDPRoute: return route.Status.RouteStatus - case *gw.TLSRoute: + case *gwv1alpha2.TLSRoute: return route.Status.RouteStatus } - return gw.RouteStatus{} + return gwv1alpha2.RouteStatus{} } -func (r *K8sRoute) SetStatus(updated gw.RouteStatus) { +func (r *K8sRoute) SetStatus(updated gwv1alpha2.RouteStatus) { switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: route.Status.RouteStatus = updated - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: route.Status.RouteStatus = updated - case *gw.UDPRoute: + case *gwv1alpha2.UDPRoute: route.Status.RouteStatus = updated - case *gw.TLSRoute: + case *gwv1alpha2.TLSRoute: route.Status.RouteStatus = updated } } -func (r *K8sRoute) ParentStatuses() []gw.RouteParentStatus { - statuses := []gw.RouteParentStatus{} +func (r *K8sRoute) ParentStatuses() []gwv1alpha2.RouteParentStatus { + statuses := []gwv1alpha2.RouteParentStatus{} for ref, status := range r.parentStatuses { - statuses = append(statuses, gw.RouteParentStatus{ + statuses = append(statuses, gwv1alpha2.RouteParentStatus{ ParentRef: parseParent(ref), - ControllerName: gw.GatewayController(r.controllerName), + ControllerName: gwv1alpha2.GatewayController(r.controllerName), Conditions: status.Conditions(r.GetGeneration()), }) } return statuses } -func (r *K8sRoute) FilterParentStatuses() []gw.RouteParentStatus { - filtered := []gw.RouteParentStatus{} +func (r *K8sRoute) FilterParentStatuses() []gwv1alpha2.RouteParentStatus { + filtered := []gwv1alpha2.RouteParentStatus{} for _, status := range r.routeStatus().Parents { - if status.ControllerName != gw.GatewayController(r.controllerName) { + if status.ControllerName != gwv1alpha2.GatewayController(r.controllerName) { filtered = append(filtered, status) continue } @@ -159,14 +160,14 @@ func (r *K8sRoute) FilterParentStatuses() []gw.RouteParentStatus { return filtered } -func (r *K8sRoute) MergedStatus() gw.RouteStatus { - return gw.RouteStatus{ +func (r *K8sRoute) MergedStatus() gwv1alpha2.RouteStatus { + return gwv1alpha2.RouteStatus{ Parents: sortParents(append(r.FilterParentStatuses(), r.ParentStatuses()...)), } } func (r *K8sRoute) NeedsStatusUpdate() bool { - currentStatus := gw.RouteStatus{Parents: sortParents(r.routeStatus().Parents)} + currentStatus := gwv1alpha2.RouteStatus{Parents: sortParents(r.routeStatus().Parents)} updatedStatus := r.MergedStatus() return !routeStatusEqual(currentStatus, updatedStatus) } @@ -288,23 +289,23 @@ func (r *K8sRoute) isEqual(k8sRoute *K8sRoute) bool { } switch route := r.Route.(type) { - case *gw.HTTPRoute: - if otherRoute, ok := k8sRoute.Route.(*gw.HTTPRoute); ok { + case *gwv1alpha2.HTTPRoute: + if otherRoute, ok := k8sRoute.Route.(*gwv1alpha2.HTTPRoute); ok { return reflect.DeepEqual(route.Spec, otherRoute.Spec) } return false - case *gw.TCPRoute: - if otherRoute, ok := k8sRoute.Route.(*gw.TCPRoute); ok { + case *gwv1alpha2.TCPRoute: + if otherRoute, ok := k8sRoute.Route.(*gwv1alpha2.TCPRoute); ok { return reflect.DeepEqual(route.Spec, otherRoute.Spec) } return false - case *gw.UDPRoute: - if otherRoute, ok := k8sRoute.Route.(*gw.UDPRoute); ok { + case *gwv1alpha2.UDPRoute: + if otherRoute, ok := k8sRoute.Route.(*gwv1alpha2.UDPRoute); ok { return reflect.DeepEqual(route.Spec, otherRoute.Spec) } return false - case *gw.TLSRoute: - if otherRoute, ok := k8sRoute.Route.(*gw.TLSRoute); ok { + case *gwv1alpha2.TLSRoute: + if otherRoute, ok := k8sRoute.Route.(*gwv1alpha2.TLSRoute); ok { return reflect.DeepEqual(route.Spec, otherRoute.Spec) } return false @@ -322,7 +323,7 @@ func (r *K8sRoute) Resolve(listener store.Listener) *core.ResolvedRoute { namespace := k8sListener.consulNamespace hostname := k8sListener.Config().Hostname switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: return convertHTTPRoute(namespace, hostname, prefix, map[string]string{ "external-source": "consul-api-gateway", "consul-api-gateway/k8s/Gateway.Name": k8sListener.gateway.Name, @@ -330,7 +331,7 @@ func (r *K8sRoute) Resolve(listener store.Listener) *core.ResolvedRoute { "consul-api-gateway/k8s/HTTPRoute.Name": r.GetName(), "consul-api-gateway/k8s/HTTPRoute.Namespace": r.GetNamespace(), }, route, r) - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: return convertTCPRoute(namespace, prefix, map[string]string{ "external-source": "consul-api-gateway", "consul-api-gateway/k8s/Gateway.Name": k8sListener.gateway.Name, @@ -344,16 +345,16 @@ func (r *K8sRoute) Resolve(listener store.Listener) *core.ResolvedRoute { } } -func (r *K8sRoute) Parents() []gw.ParentReference { +func (r *K8sRoute) Parents() []gwv1alpha2.ParentReference { // filter for this controller switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: return route.Spec.ParentRefs - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: return route.Spec.ParentRefs - case *gw.UDPRoute: + case *gwv1alpha2.UDPRoute: return route.Spec.ParentRefs - case *gw.TLSRoute: + case *gwv1alpha2.TLSRoute: return route.Spec.ParentRefs } return nil @@ -361,7 +362,7 @@ func (r *K8sRoute) Parents() []gw.ParentReference { func (r *K8sRoute) Validate(ctx context.Context) error { switch route := r.Route.(type) { - case *gw.HTTPRoute: + case *gwv1alpha2.HTTPRoute: for _, httpRule := range route.Spec.Rules { rule := httpRule routeRule := service.NewRouteRule(&rule) @@ -393,7 +394,7 @@ func (r *K8sRoute) Validate(ctx context.Context) error { r.references.Add(routeRule, *reference) } } - case *gw.TCPRoute: + case *gwv1alpha2.TCPRoute: if len(route.Spec.Rules) != 1 { err := service.NewResolutionError("a single tcp rule is required") r.resolutionErrors.Add(err) diff --git a/internal/k8s/reconciler/route_test.go b/internal/k8s/reconciler/route_test.go index c52926069..3350fa8c8 100644 --- a/internal/k8s/reconciler/route_test.go +++ b/internal/k8s/reconciler/route_test.go @@ -11,7 +11,8 @@ import ( "github.com/stretchr/testify/require" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" clientMocks "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient/mocks" "github.com/hashicorp/consul-api-gateway/internal/k8s/service" @@ -32,16 +33,16 @@ func TestRouteID(t *testing.T) { Namespace: "namespace", } - require.Equal(t, "http-namespace/name", NewK8sRoute(&gw.HTTPRoute{ + require.Equal(t, "http-namespace/name", NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta, }, config).ID()) - require.Equal(t, "udp-namespace/name", NewK8sRoute(&gw.UDPRoute{ + require.Equal(t, "udp-namespace/name", NewK8sRoute(&gwv1alpha2.UDPRoute{ ObjectMeta: meta, }, config).ID()) - require.Equal(t, "tcp-namespace/name", NewK8sRoute(&gw.TCPRoute{ + require.Equal(t, "tcp-namespace/name", NewK8sRoute(&gwv1alpha2.TCPRoute{ ObjectMeta: meta, }, config).ID()) - require.Equal(t, "tls-namespace/name", NewK8sRoute(&gw.TLSRoute{ + require.Equal(t, "tls-namespace/name", NewK8sRoute(&gwv1alpha2.TLSRoute{ ObjectMeta: meta, }, config).ID()) require.Equal(t, "", NewK8sRoute(&core.Pod{ @@ -56,62 +57,62 @@ func TestRouteCommonRouteSpec(t *testing.T) { Logger: hclog.NewNullLogger(), } - expected := gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + expected := gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "expected", }}, } - require.Equal(t, expected, NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ + require.Equal(t, expected, NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ CommonRouteSpec: expected, }, }, config).CommonRouteSpec()) - require.Equal(t, expected, NewK8sRoute(&gw.UDPRoute{ - Spec: gw.UDPRouteSpec{ + require.Equal(t, expected, NewK8sRoute(&gwv1alpha2.UDPRoute{ + Spec: gwv1alpha2.UDPRouteSpec{ CommonRouteSpec: expected, }, }, config).CommonRouteSpec()) - require.Equal(t, expected, NewK8sRoute(&gw.TCPRoute{ - Spec: gw.TCPRouteSpec{ + require.Equal(t, expected, NewK8sRoute(&gwv1alpha2.TCPRoute{ + Spec: gwv1alpha2.TCPRouteSpec{ CommonRouteSpec: expected, }, }, config).CommonRouteSpec()) - require.Equal(t, expected, NewK8sRoute(&gw.TLSRoute{ - Spec: gw.TLSRouteSpec{ + require.Equal(t, expected, NewK8sRoute(&gwv1alpha2.TLSRoute{ + Spec: gwv1alpha2.TLSRouteSpec{ CommonRouteSpec: expected, }, }, config).CommonRouteSpec()) - require.Equal(t, gw.CommonRouteSpec{}, NewK8sRoute(&core.Pod{}, config).CommonRouteSpec()) + require.Equal(t, gwv1alpha2.CommonRouteSpec{}, NewK8sRoute(&core.Pod{}, config).CommonRouteSpec()) } func TestRouteFilterParentStatuses(t *testing.T) { t.Parallel() - route := NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + route := NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "expected", }, { Name: "other", }}, }, }, - Status: gw.HTTPRouteStatus{ - RouteStatus: gw.RouteStatus{ - Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentReference{ + Status: gwv1alpha2.HTTPRouteStatus{ + RouteStatus: gwv1alpha2.RouteStatus{ + Parents: []gwv1alpha2.RouteParentStatus{{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "other", }, ControllerName: "other", @@ -123,7 +124,7 @@ func TestRouteFilterParentStatuses(t *testing.T) { Logger: hclog.NewNullLogger(), }) - route.OnBound(NewK8sGateway(&gw.Gateway{ + route.OnBound(NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "expected", }, @@ -142,37 +143,37 @@ func TestRouteFilterParentStatuses(t *testing.T) { func TestRouteMergedStatusAndBinding(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "expected", }, }, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), }) - inner := &gw.TLSRoute{ - Spec: gw.TLSRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + inner := &gwv1alpha2.TLSRoute{ + Spec: gwv1alpha2.TLSRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "expected", }, { Name: "other", }}, }, }, - Status: gw.TLSRouteStatus{ - RouteStatus: gw.RouteStatus{ - Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentReference{ + Status: gwv1alpha2.TLSRouteStatus{ + RouteStatus: gwv1alpha2.RouteStatus{ + Parents: []gwv1alpha2.RouteParentStatus{{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "other", }, ControllerName: "other", @@ -281,7 +282,7 @@ func TestRouteMergedStatusAndBinding(t *testing.T) { require.Equal(t, RouteConditionReasonRefNotPermitted, statuses[0].Conditions[1].Reason) // check binding for non-existent route - gateway = NewK8sGateway(&gw.Gateway{ + gateway = NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "nothing", }, @@ -301,30 +302,30 @@ func TestRouteMergedStatusAndBinding(t *testing.T) { func TestRouteNeedsStatusUpdate(t *testing.T) { t.Parallel() - route := NewK8sRoute(&gw.TCPRoute{ - Spec: gw.TCPRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + route := NewK8sRoute(&gwv1alpha2.TCPRoute{ + Spec: gwv1alpha2.TCPRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "expected", }, { Name: "other", }}, }, }, - Status: gw.TCPRouteStatus{ - RouteStatus: gw.RouteStatus{ - Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentReference{ + Status: gwv1alpha2.TCPRouteStatus{ + RouteStatus: gwv1alpha2.RouteStatus{ + Parents: []gwv1alpha2.RouteParentStatus{{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "other", }, ControllerName: "other", @@ -339,7 +340,7 @@ func TestRouteNeedsStatusUpdate(t *testing.T) { require.False(t, route.NeedsStatusUpdate()) - route.OnBound(NewK8sGateway(&gw.Gateway{ + route.OnBound(NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "expected", }, @@ -361,33 +362,33 @@ func TestRouteSetStatus(t *testing.T) { Logger: hclog.NewNullLogger(), } - expected := gw.RouteStatus{ - Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentReference{ + expected := gwv1alpha2.RouteStatus{ + Parents: []gwv1alpha2.RouteParentStatus{{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, }}, } - httpRoute := &gw.HTTPRoute{} + httpRoute := &gwv1alpha2.HTTPRoute{} route := NewK8sRoute(httpRoute, config) route.SetStatus(expected) require.Equal(t, expected, httpRoute.Status.RouteStatus) require.Equal(t, expected, route.routeStatus()) - tcpRoute := &gw.TCPRoute{} + tcpRoute := &gwv1alpha2.TCPRoute{} route = NewK8sRoute(tcpRoute, config) route.SetStatus(expected) require.Equal(t, expected, tcpRoute.Status.RouteStatus) require.Equal(t, expected, route.routeStatus()) - tlsRoute := &gw.TLSRoute{} + tlsRoute := &gwv1alpha2.TLSRoute{} route = NewK8sRoute(tlsRoute, config) route.SetStatus(expected) require.Equal(t, expected, tlsRoute.Status.RouteStatus) require.Equal(t, expected, route.routeStatus()) - udpRoute := &gw.UDPRoute{} + udpRoute := &gwv1alpha2.UDPRoute{} route = NewK8sRoute(udpRoute, config) route.SetStatus(expected) require.Equal(t, expected, udpRoute.Status.RouteStatus) @@ -395,7 +396,7 @@ func TestRouteSetStatus(t *testing.T) { route = NewK8sRoute(&core.Pod{}, config) route.SetStatus(expected) - require.Equal(t, gw.RouteStatus{}, route.routeStatus()) + require.Equal(t, gwv1alpha2.RouteStatus{}, route.routeStatus()) } func TestRouteParents(t *testing.T) { @@ -405,22 +406,22 @@ func TestRouteParents(t *testing.T) { Logger: hclog.NewNullLogger(), } - expected := gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + expected := gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "expected", }}, } - parents := NewK8sRoute(&gw.HTTPRoute{Spec: gw.HTTPRouteSpec{CommonRouteSpec: expected}}, config).Parents() + parents := NewK8sRoute(&gwv1alpha2.HTTPRoute{Spec: gwv1alpha2.HTTPRouteSpec{CommonRouteSpec: expected}}, config).Parents() require.Equal(t, expected.ParentRefs, parents) - parents = NewK8sRoute(&gw.TCPRoute{Spec: gw.TCPRouteSpec{CommonRouteSpec: expected}}, config).Parents() + parents = NewK8sRoute(&gwv1alpha2.TCPRoute{Spec: gwv1alpha2.TCPRouteSpec{CommonRouteSpec: expected}}, config).Parents() require.Equal(t, expected.ParentRefs, parents) - parents = NewK8sRoute(&gw.TLSRoute{Spec: gw.TLSRouteSpec{CommonRouteSpec: expected}}, config).Parents() + parents = NewK8sRoute(&gwv1alpha2.TLSRoute{Spec: gwv1alpha2.TLSRouteSpec{CommonRouteSpec: expected}}, config).Parents() require.Equal(t, expected.ParentRefs, parents) - parents = NewK8sRoute(&gw.UDPRoute{Spec: gw.UDPRouteSpec{CommonRouteSpec: expected}}, config).Parents() + parents = NewK8sRoute(&gwv1alpha2.UDPRoute{Spec: gwv1alpha2.UDPRouteSpec{CommonRouteSpec: expected}}, config).Parents() require.Equal(t, expected.ParentRefs, parents) require.Nil(t, NewK8sRoute(&core.Pod{}, config).Parents()) @@ -429,19 +430,19 @@ func TestRouteParents(t *testing.T) { func TestRouteMatchesHostname(t *testing.T) { t.Parallel() - hostname := gw.Hostname("domain.test") + hostname := gwv1beta1.Hostname("domain.test") - require.True(t, NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - Hostnames: []gw.Hostname{"*"}, + require.True(t, NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Hostnames: []gwv1alpha2.Hostname{"*"}, }, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }).MatchesHostname(&hostname)) - require.False(t, NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - Hostnames: []gw.Hostname{"other.text"}, + require.False(t, NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Hostnames: []gwv1alpha2.Hostname{"other.text"}, }, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), @@ -449,7 +450,7 @@ func TestRouteMatchesHostname(t *testing.T) { // check where the underlying route doesn't implement // a matching routine - require.True(t, NewK8sRoute(&gw.TCPRoute{}, K8sRouteConfig{ + require.True(t, NewK8sRoute(&gwv1alpha2.TCPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }).MatchesHostname(&hostname)) } @@ -461,7 +462,7 @@ func TestRouteValidate(t *testing.T) { Logger: hclog.NewNullLogger(), }).Validate(context.Background())) - require.True(t, NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + require.True(t, NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }).IsValid()) @@ -469,7 +470,7 @@ func TestRouteValidate(t *testing.T) { defer ctrl.Finish() resolver := mocks.NewMockBackendResolver(ctrl) - reference := gw.BackendObjectReference{ + reference := gwv1alpha2.BackendObjectReference{ Name: "expected", } resolved := &service.ResolvedReference{ @@ -479,11 +480,11 @@ func TestRouteValidate(t *testing.T) { resolver.EXPECT().Resolve(gomock.Any(), reference).Return(resolved, nil) - route := NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{ - BackendRef: gw.BackendRef{ + route := NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ BackendObjectReference: reference, }, }}, @@ -514,13 +515,13 @@ func TestRouteValidateDontAllowCrossNamespace(t *testing.T) { client := clientMocks.NewMockClient(ctrl) //set up backend ref with a different namespace - namespace := gw.Namespace("test") - route := NewK8sRoute(&gw.HTTPRoute{ - Spec: gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{ - BackendRef: gw.BackendRef{ - BackendObjectReference: gw.BackendObjectReference{ + namespace := gwv1alpha2.Namespace("test") + route := NewK8sRoute(&gwv1alpha2.HTTPRoute{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ Name: "expected", Namespace: &namespace, }, @@ -536,11 +537,11 @@ func TestRouteValidateDontAllowCrossNamespace(t *testing.T) { client.EXPECT(). GetReferenceGrantsInNamespace(gomock.Any(), gomock.Any()). - Return([]gw.ReferenceGrant{ + Return([]gwv1alpha2.ReferenceGrant{ { - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{}, - To: []gw.ReferenceGrantTo{}, + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{}, + To: []gwv1alpha2.ReferenceGrantTo{}, }, }, }, nil) @@ -560,18 +561,18 @@ func TestRouteValidateAllowCrossNamespaceWithReferenceGrant(t *testing.T) { client := clientMocks.NewMockClient(ctrl) //set up backend ref with a different namespace - backendGroup := gw.Group("") - backendKind := gw.Kind("Service") - backendNamespace := gw.Namespace("namespace2") - backendName := gw.ObjectName("backend2") - route := NewK8sRoute(&gw.HTTPRoute{ + backendGroup := gwv1alpha2.Group("") + backendKind := gwv1alpha2.Kind("Service") + backendNamespace := gwv1alpha2.Namespace("namespace2") + backendName := gwv1alpha2.ObjectName("backend2") + route := NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{Namespace: "namespace1"}, TypeMeta: meta.TypeMeta{APIVersion: "gateway.networking.k8s.io/v1alpha2", Kind: "HTTPRoute"}, - Spec: gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{ - BackendRef: gw.BackendRef{ - BackendObjectReference: gw.BackendObjectReference{ + Spec: gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{ + BackendRef: gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ Group: &backendGroup, Kind: &backendKind, Name: backendName, @@ -587,16 +588,16 @@ func TestRouteValidateAllowCrossNamespaceWithReferenceGrant(t *testing.T) { Resolver: resolver, }) - refGrant := gw.ReferenceGrant{ + refGrant := gwv1alpha2.ReferenceGrant{ TypeMeta: meta.TypeMeta{}, ObjectMeta: meta.ObjectMeta{Namespace: "namespace2"}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", Kind: "HTTPRoute", Namespace: "namespace1", }}, - To: []gw.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: &backendName, @@ -606,7 +607,7 @@ func TestRouteValidateAllowCrossNamespaceWithReferenceGrant(t *testing.T) { client.EXPECT(). GetReferenceGrantsInNamespace(gomock.Any(), gomock.Any()). - Return([]gw.ReferenceGrant{refGrant}, nil) + Return([]gwv1alpha2.ReferenceGrant{refGrant}, nil) resolver.EXPECT(). Resolve(gomock.Any(), gomock.Any()). @@ -618,14 +619,14 @@ func TestRouteValidateAllowCrossNamespaceWithReferenceGrant(t *testing.T) { func TestRouteResolve(t *testing.T) { t.Parallel() - gateway := &gw.Gateway{ + gateway := &gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "expected", }, } - listener := gw.Listener{} + listener := gwv1beta1.Listener{} - require.Nil(t, NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + require.Nil(t, NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }).Resolve(nil)) @@ -635,7 +636,7 @@ func TestRouteResolve(t *testing.T) { Logger: hclog.NewNullLogger(), }))) - require.NotNil(t, NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + require.NotNil(t, NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }).Resolve(NewK8sListener(gateway, listener, K8sListenerConfig{ Logger: hclog.NewNullLogger(), @@ -659,16 +660,16 @@ func TestRouteCompare(t *testing.T) { require.Equal(t, store.CompareResultNotEqual, route.Compare(other)) // http route comparison - route = NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + route = NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) - other = NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultEqual, route.Compare(other)) other.resolutionErrors.Add(service.NewConsulResolutionError("error")) require.Equal(t, store.CompareResultNotEqual, route.Compare(other)) - route = NewK8sRoute(&gw.HTTPRoute{ + route = NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ ResourceVersion: "1", }, @@ -677,49 +678,49 @@ func TestRouteCompare(t *testing.T) { }) require.Equal(t, store.CompareResultNewer, route.Compare(other)) - route = NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + route = NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) - other = NewK8sRoute(&gw.TCPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.TCPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultNotEqual, route.Compare(other)) // tcp route comparison - route = NewK8sRoute(&gw.TCPRoute{}, K8sRouteConfig{ + route = NewK8sRoute(&gwv1alpha2.TCPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) - other = NewK8sRoute(&gw.TCPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.TCPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultEqual, route.Compare(other)) - other = NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultNotEqual, route.Compare(other)) // tls route comparison - route = NewK8sRoute(&gw.TLSRoute{}, K8sRouteConfig{ + route = NewK8sRoute(&gwv1alpha2.TLSRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) - other = NewK8sRoute(&gw.TLSRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.TLSRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultEqual, route.Compare(other)) - other = NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultNotEqual, route.Compare(other)) // udp route comparison - route = NewK8sRoute(&gw.UDPRoute{}, K8sRouteConfig{ + route = NewK8sRoute(&gwv1alpha2.UDPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) - other = NewK8sRoute(&gw.UDPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.UDPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultEqual, route.Compare(other)) - other = NewK8sRoute(&gw.HTTPRoute{}, K8sRouteConfig{ + other = NewK8sRoute(&gwv1alpha2.HTTPRoute{}, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }) require.Equal(t, store.CompareResultNotEqual, route.Compare(other)) @@ -731,37 +732,37 @@ func TestRouteCompare(t *testing.T) { func TestRouteSyncStatus(t *testing.T) { t.Parallel() - gateway := NewK8sGateway(&gw.Gateway{ + gateway := NewK8sGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "expected", }, }, K8sGatewayConfig{ Logger: hclog.NewNullLogger(), }) - inner := &gw.TLSRoute{ - Spec: gw.TLSRouteSpec{ - CommonRouteSpec: gw.CommonRouteSpec{ - ParentRefs: []gw.ParentReference{{ + inner := &gwv1alpha2.TLSRoute{ + Spec: gwv1alpha2.TLSRouteSpec{ + CommonRouteSpec: gwv1alpha2.CommonRouteSpec{ + ParentRefs: []gwv1alpha2.ParentReference{{ Name: "expected", }, { Name: "other", }}, }, }, - Status: gw.TLSRouteStatus{ - RouteStatus: gw.RouteStatus{ - Parents: []gw.RouteParentStatus{{ - ParentRef: gw.ParentReference{ + Status: gwv1alpha2.TLSRouteStatus{ + RouteStatus: gwv1alpha2.RouteStatus{ + Parents: []gwv1alpha2.RouteParentStatus{{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "expected", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "expected", }, ControllerName: "other", }, { - ParentRef: gw.ParentReference{ + ParentRef: gwv1alpha2.ParentReference{ Name: "other", }, ControllerName: "other", diff --git a/internal/k8s/reconciler/tcp_route.go b/internal/k8s/reconciler/tcp_route.go index 6f9667d61..93bea7bba 100644 --- a/internal/k8s/reconciler/tcp_route.go +++ b/internal/k8s/reconciler/tcp_route.go @@ -4,14 +4,14 @@ import ( "github.com/hashicorp/consul-api-gateway/internal/core" "github.com/hashicorp/consul-api-gateway/internal/k8s/service" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) func TCPRouteID(namespacedName types.NamespacedName) string { return "tcp-" + namespacedName.String() } -func convertTCPRoute(namespace, prefix string, meta map[string]string, route *gw.TCPRoute, k8sRoute *K8sRoute) *core.ResolvedRoute { +func convertTCPRoute(namespace, prefix string, meta map[string]string, route *gwv1alpha2.TCPRoute, k8sRoute *K8sRoute) *core.ResolvedRoute { name := prefix + route.Name resolved := core.NewTCPRouteBuilder(). diff --git a/internal/k8s/reconciler/utils.go b/internal/k8s/reconciler/utils.go index aa5686091..2e4bebee2 100644 --- a/internal/k8s/reconciler/utils.go +++ b/internal/k8s/reconciler/utils.go @@ -12,7 +12,8 @@ import ( klabels "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient" ) @@ -22,14 +23,14 @@ const ( NamespaceNameLabel = "kubernetes.io/metadata.name" ) -func routeMatchesListener(listenerName gw.SectionName, sectionName *gw.SectionName) (bool, bool) { - if sectionName == nil { +func routeMatchesListener(listenerName gwv1beta1.SectionName, routeSectionName *gwv1alpha2.SectionName) (can bool, must bool) { + if routeSectionName == nil { return true, false } - return listenerName == *sectionName, true + return string(listenerName) == string(*routeSectionName), true } -func routeMatchesListenerHostname(listenerHostname *gw.Hostname, hostnames []gw.Hostname) bool { +func routeMatchesListenerHostname(listenerHostname *gwv1beta1.Hostname, hostnames []gwv1alpha2.Hostname) bool { if listenerHostname == nil || len(hostnames) == 0 { return true } @@ -42,7 +43,7 @@ func routeMatchesListenerHostname(listenerHostname *gw.Hostname, hostnames []gw. return false } -func hostnamesMatch(a, b gw.Hostname) bool { +func hostnamesMatch(a gwv1alpha2.Hostname, b gwv1beta1.Hostname) bool { if a == "" || a == "*" || b == "" || b == "*" { // any wildcard always matches return true @@ -62,17 +63,17 @@ func hostnamesMatch(a, b gw.Hostname) bool { return true } - return a == b + return string(a) == string(b) } -func routeKindIsAllowedForListener(kinds []gw.RouteGroupKind, route *K8sRoute) bool { +func routeKindIsAllowedForListener(kinds []gwv1beta1.RouteGroupKind, route *K8sRoute) bool { if kinds == nil { return true } gvk := route.GroupVersionKind() for _, kind := range kinds { - group := gw.GroupName + group := gwv1beta1.GroupName if kind.Group != nil && *kind.Group != "" { group = string(*kind.Group) } @@ -86,24 +87,24 @@ func routeKindIsAllowedForListener(kinds []gw.RouteGroupKind, route *K8sRoute) b // routeAllowedForListenerNamespaces determines whether the route is allowed // to bind to the Gateway based on the AllowedRoutes namespace selectors. -func routeAllowedForListenerNamespaces(ctx context.Context, gatewayNS string, allowedRoutes *gw.AllowedRoutes, route *K8sRoute, c gatewayclient.Client) (bool, error) { - var namespaceSelector *gw.RouteNamespaces +func routeAllowedForListenerNamespaces(ctx context.Context, gatewayNS string, allowedRoutes *gwv1beta1.AllowedRoutes, route *K8sRoute, c gatewayclient.Client) (bool, error) { + var namespaceSelector *gwv1beta1.RouteNamespaces if allowedRoutes != nil { // check gateway namespace namespaceSelector = allowedRoutes.Namespaces } // set default if namespace selector is nil - from := gw.NamespacesFromSame + from := gwv1beta1.NamespacesFromSame if namespaceSelector != nil && namespaceSelector.From != nil && *namespaceSelector.From != "" { from = *namespaceSelector.From } switch from { - case gw.NamespacesFromAll: + case gwv1beta1.NamespacesFromAll: return true, nil - case gw.NamespacesFromSame: + case gwv1beta1.NamespacesFromSame: return gatewayNS == route.GetNamespace(), nil - case gw.NamespacesFromSelector: + case gwv1beta1.NamespacesFromSelector: namespaceSelector, err := metav1.LabelSelectorAsSelector(namespaceSelector.Selector) if err != nil { return false, fmt.Errorf("error parsing label selector: %w", err) @@ -123,7 +124,7 @@ func routeAllowedForListenerNamespaces(ctx context.Context, gatewayNS string, al // gatewayAllowedForSecretRef determines whether the gateway is allowed // for the secret either by being in the same namespace or by having // an applicable ReferenceGrant in the same namespace as the secret. -func gatewayAllowedForSecretRef(ctx context.Context, gateway *gw.Gateway, secretRef gw.SecretObjectReference, c gatewayclient.Client) (bool, error) { +func gatewayAllowedForSecretRef(ctx context.Context, gateway *gwv1beta1.Gateway, secretRef gwv1beta1.SecretObjectReference, c gatewayclient.Client) (bool, error) { fromNS := gateway.GetNamespace() fromGK := metav1.GroupKind{ Group: gateway.GroupVersionKind().Group, @@ -155,7 +156,7 @@ func gatewayAllowedForSecretRef(ctx context.Context, gateway *gw.Gateway, secret // // TODO This func is currently called once for each backendRef on a route and results // in fetching ReferenceGrants more than we technically have to in some cases -func routeAllowedForBackendRef(ctx context.Context, route Route, backendRef gw.BackendRef, c gatewayclient.Client) (bool, error) { +func routeAllowedForBackendRef(ctx context.Context, route Route, backendRef gwv1alpha2.BackendRef, c gatewayclient.Client) (bool, error) { fromNS := route.GetNamespace() fromGK := metav1.GroupKind{ Group: route.GroupVersionKind().Group, @@ -222,7 +223,7 @@ func referenceAllowed(ctx context.Context, fromGK metav1.GroupKind, fromNamespac return true, nil } - if gw.ObjectName(toName) == *to.Name { + if gwv1alpha2.ObjectName(toName) == *to.Name { // The ReferenceGrant specifically targets this object return true, nil } @@ -249,7 +250,7 @@ func toNamespaceSet(name string, labels map[string]string) klabels.Labels { return klabels.Set(ret) } -func sortParents(parents []gw.RouteParentStatus) []gw.RouteParentStatus { +func sortParents(parents []gwv1alpha2.RouteParentStatus) []gwv1alpha2.RouteParentStatus { for _, parent := range parents { sort.SliceStable(parent.Conditions, func(i, j int) bool { return asJSON(parent.Conditions[i]) < asJSON(parent.Conditions[j]) @@ -273,8 +274,8 @@ func asJSON(item interface{}) string { return string(data) } -func parseParent(stringified string) gw.ParentReference { - var ref gw.ParentReference +func parseParent(stringified string) gwv1alpha2.ParentReference { + var ref gwv1alpha2.ParentReference if err := json.Unmarshal([]byte(stringified), &ref); err != nil { // everything passed to this internally should be // deserializable, if something is passed to it that @@ -310,7 +311,7 @@ func conditionsEqual(a, b []metav1.Condition) bool { return true } -func listenerStatusEqual(a, b gw.ListenerStatus) bool { +func listenerStatusEqual(a, b gwv1beta1.ListenerStatus) bool { if a.Name != b.Name { return false } @@ -323,7 +324,7 @@ func listenerStatusEqual(a, b gw.ListenerStatus) bool { return conditionsEqual(a.Conditions, b.Conditions) } -func listenerStatusesEqual(a, b []gw.ListenerStatus) bool { +func listenerStatusesEqual(a, b []gwv1beta1.ListenerStatus) bool { if len(a) != len(b) { // we have a different number of conditions, so they aren't the same return false @@ -336,7 +337,7 @@ func listenerStatusesEqual(a, b []gw.ListenerStatus) bool { return true } -func parentStatusEqual(a, b gw.RouteParentStatus) bool { +func parentStatusEqual(a, b gwv1alpha2.RouteParentStatus) bool { if a.ControllerName != b.ControllerName { return false } @@ -347,7 +348,7 @@ func parentStatusEqual(a, b gw.RouteParentStatus) bool { return conditionsEqual(a.Conditions, b.Conditions) } -func routeStatusEqual(a, b gw.RouteStatus) bool { +func routeStatusEqual(a, b gwv1alpha2.RouteStatus) bool { if len(a.Parents) != len(b.Parents) { return false } @@ -360,7 +361,7 @@ func routeStatusEqual(a, b gw.RouteStatus) bool { return true } -func gatewayStatusEqual(a, b gw.GatewayStatus) bool { +func gatewayStatusEqual(a, b gwv1beta1.GatewayStatus) bool { if !conditionsEqual(a.Conditions, b.Conditions) { return false } @@ -372,9 +373,17 @@ func gatewayStatusEqual(a, b gw.GatewayStatus) bool { return true } +type gwObjectName interface { + gwv1beta1.ObjectName | gwv1alpha2.ObjectName +} + +type gwNamespace interface { + gwv1beta1.Namespace | gwv1alpha2.Namespace +} + // getNamespacedName returns types.NamespacedName defaulted to a parent // namespace in the case where the provided namespace is nil. -func getNamespacedName(name gw.ObjectName, namespace *gw.Namespace, parentNamespace string) types.NamespacedName { +func getNamespacedName[O gwObjectName, N gwNamespace](name O, namespace *N, parentNamespace string) types.NamespacedName { if namespace != nil { return types.NamespacedName{Namespace: string(*namespace), Name: string(name)} } diff --git a/internal/k8s/reconciler/utils_test.go b/internal/k8s/reconciler/utils_test.go index 0ca5aa591..affed2348 100644 --- a/internal/k8s/reconciler/utils_test.go +++ b/internal/k8s/reconciler/utils_test.go @@ -12,7 +12,8 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/go-hclog" @@ -22,16 +23,17 @@ import ( func TestRouteMatchesListener(t *testing.T) { t.Parallel() - name := gw.SectionName("name") - can, must := routeMatchesListener(name, &name) + listenerName := gwv1beta1.SectionName("name") + routeSectionName := gwv1alpha2.SectionName("name") + can, must := routeMatchesListener(listenerName, &routeSectionName) require.True(t, can) require.True(t, must) - can, must = routeMatchesListener(name, nil) + can, must = routeMatchesListener(listenerName, nil) require.True(t, can) require.False(t, must) - can, must = routeMatchesListener(gw.SectionName("other"), &name) + can, must = routeMatchesListener(gwv1beta1.SectionName("other"), &routeSectionName) require.False(t, can) require.True(t, must) } @@ -39,11 +41,11 @@ func TestRouteMatchesListener(t *testing.T) { func TestRouteMatchesListenerHostname(t *testing.T) { t.Parallel() - hostname := gw.Hostname("name") + hostname := gwv1beta1.Hostname("name") require.True(t, routeMatchesListenerHostname(nil, nil)) require.True(t, routeMatchesListenerHostname(&hostname, nil)) - require.True(t, routeMatchesListenerHostname(&hostname, []gw.Hostname{"*"})) - require.False(t, routeMatchesListenerHostname(&hostname, []gw.Hostname{"other"})) + require.True(t, routeMatchesListenerHostname(&hostname, []gwv1alpha2.Hostname{"*"})) + require.False(t, routeMatchesListenerHostname(&hostname, []gwv1alpha2.Hostname{"other"})) } func TestHostnamesMatch(t *testing.T) { @@ -69,22 +71,22 @@ func TestRouteKindIsAllowedForListener(t *testing.T) { routeMeta := meta.TypeMeta{} routeMeta.SetGroupVersionKind(schema.GroupVersionKind{ - Group: gw.GroupVersion.Group, - Version: gw.GroupVersion.Version, + Group: gwv1alpha2.GroupVersion.Group, + Version: gwv1alpha2.GroupVersion.Version, Kind: "HTTPRoute", }) - require.True(t, routeKindIsAllowedForListener([]gw.RouteGroupKind{{ - Group: (*gw.Group)(&gw.GroupVersion.Group), + require.True(t, routeKindIsAllowedForListener([]gwv1beta1.RouteGroupKind{{ + Group: (*gwv1beta1.Group)(&gwv1alpha2.GroupVersion.Group), Kind: "HTTPRoute", - }}, NewK8sRoute(&gw.HTTPRoute{ + }}, NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), }))) - require.False(t, routeKindIsAllowedForListener([]gw.RouteGroupKind{{ - Group: (*gw.Group)(&gw.GroupVersion.Group), + require.False(t, routeKindIsAllowedForListener([]gwv1beta1.RouteGroupKind{{ + Group: (*gwv1beta1.Group)(&gwv1alpha2.GroupVersion.Group), Kind: "TCPRoute", - }}, NewK8sRoute(&gw.HTTPRoute{ + }}, NewK8sRoute(&gwv1alpha2.HTTPRoute{ TypeMeta: routeMeta, }, K8sRouteConfig{ Logger: hclog.NewNullLogger(), @@ -99,13 +101,13 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { client := mocks.NewMockClient(ctrl) // same - same := gw.NamespacesFromSame + same := gwv1beta1.NamespacesFromSame - allowed, err := routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + allowed, err := routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &same, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "expected", }, @@ -115,11 +117,11 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { require.NoError(t, err) require.True(t, allowed) - allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &same, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "other", }, @@ -130,12 +132,12 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { require.False(t, allowed) // all - all := gw.NamespacesFromAll - allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + all := gwv1beta1.NamespacesFromAll + allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &all, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "other", }, @@ -146,7 +148,7 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { require.True(t, allowed) // selector - selector := gw.NamespacesFromSelector + selector := gwv1beta1.NamespacesFromSelector matchingNamespace := &core.Namespace{ ObjectMeta: meta.ObjectMeta{ @@ -157,8 +159,8 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { invalidNamespace := &core.Namespace{ObjectMeta: meta.ObjectMeta{Labels: map[string]string{}}} client.EXPECT().GetNamespace(context.Background(), types.NamespacedName{Name: "expected"}).Return(invalidNamespace, nil).Times(1) - allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &selector, Selector: &meta.LabelSelector{ MatchLabels: map[string]string{ @@ -166,7 +168,7 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { }, }, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "expected", }, @@ -177,8 +179,8 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { require.False(t, allowed) client.EXPECT().GetNamespace(context.Background(), types.NamespacedName{Name: "expected"}).Return(matchingNamespace, nil).Times(1) - allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &selector, Selector: &meta.LabelSelector{ MatchLabels: map[string]string{ @@ -186,7 +188,7 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { }, }, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "expected", }, @@ -196,8 +198,8 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { require.NoError(t, err) require.True(t, allowed) - _, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + _, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &selector, Selector: &meta.LabelSelector{ MatchExpressions: []meta.LabelSelectorRequirement{{ @@ -206,7 +208,7 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { }}, }, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "expected", }, @@ -216,12 +218,12 @@ func TestRouteAllowedForListenerNamespaces(t *testing.T) { require.Error(t, err) // unknown - unknown := gw.FromNamespaces("unknown") - allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gw.AllowedRoutes{ - Namespaces: &gw.RouteNamespaces{ + unknown := gwv1beta1.FromNamespaces("unknown") + allowed, err = routeAllowedForListenerNamespaces(context.Background(), "expected", &gwv1beta1.AllowedRoutes{ + Namespaces: &gwv1beta1.RouteNamespaces{ From: &unknown, }, - }, NewK8sRoute(&gw.HTTPRoute{ + }, NewK8sRoute(&gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{ Namespace: "expected", }, @@ -283,42 +285,42 @@ func TestConditionsEqual(t *testing.T) { func TestListenerStatusEqual(t *testing.T) { t.Parallel() - require.True(t, listenerStatusEqual(gw.ListenerStatus{}, gw.ListenerStatus{})) - require.False(t, listenerStatusEqual(gw.ListenerStatus{ + require.True(t, listenerStatusEqual(gwv1beta1.ListenerStatus{}, gwv1beta1.ListenerStatus{})) + require.False(t, listenerStatusEqual(gwv1beta1.ListenerStatus{ Name: "expected", - }, gw.ListenerStatus{ + }, gwv1beta1.ListenerStatus{ Name: "other", })) - require.False(t, listenerStatusEqual(gw.ListenerStatus{ + require.False(t, listenerStatusEqual(gwv1beta1.ListenerStatus{ AttachedRoutes: 1, - }, gw.ListenerStatus{ + }, gwv1beta1.ListenerStatus{ AttachedRoutes: 2, })) - groupOne := gw.Group("group") - kindOne := gw.Kind("kind") - groupTwo := gw.Group("group") - kindTwo := gw.Kind("kind") - require.True(t, listenerStatusEqual(gw.ListenerStatus{ - SupportedKinds: []gw.RouteGroupKind{{ + groupOne := gwv1beta1.Group("group") + kindOne := gwv1beta1.Kind("kind") + groupTwo := gwv1beta1.Group("group") + kindTwo := gwv1beta1.Kind("kind") + require.True(t, listenerStatusEqual(gwv1beta1.ListenerStatus{ + SupportedKinds: []gwv1beta1.RouteGroupKind{{ Group: &groupOne, Kind: kindOne, }}, - }, gw.ListenerStatus{ - SupportedKinds: []gw.RouteGroupKind{{ + }, gwv1beta1.ListenerStatus{ + SupportedKinds: []gwv1beta1.RouteGroupKind{{ Group: &groupTwo, Kind: kindTwo, }}, })) - groupTwo = gw.Group("other") - require.False(t, listenerStatusEqual(gw.ListenerStatus{ - SupportedKinds: []gw.RouteGroupKind{{ + groupTwo = gwv1beta1.Group("other") + require.False(t, listenerStatusEqual(gwv1beta1.ListenerStatus{ + SupportedKinds: []gwv1beta1.RouteGroupKind{{ Group: &groupOne, Kind: kindOne, }}, - }, gw.ListenerStatus{ - SupportedKinds: []gw.RouteGroupKind{{ + }, gwv1beta1.ListenerStatus{ + SupportedKinds: []gwv1beta1.RouteGroupKind{{ Group: &groupTwo, Kind: kindTwo, }}, @@ -328,11 +330,11 @@ func TestListenerStatusEqual(t *testing.T) { func TestListenerStatusesEqual(t *testing.T) { t.Parallel() - require.True(t, listenerStatusesEqual([]gw.ListenerStatus{}, []gw.ListenerStatus{})) - require.False(t, listenerStatusesEqual([]gw.ListenerStatus{}, []gw.ListenerStatus{{}})) - require.False(t, listenerStatusesEqual([]gw.ListenerStatus{{ + require.True(t, listenerStatusesEqual([]gwv1beta1.ListenerStatus{}, []gwv1beta1.ListenerStatus{})) + require.False(t, listenerStatusesEqual([]gwv1beta1.ListenerStatus{}, []gwv1beta1.ListenerStatus{{}})) + require.False(t, listenerStatusesEqual([]gwv1beta1.ListenerStatus{{ Name: "expected", - }}, []gw.ListenerStatus{{ + }}, []gwv1beta1.ListenerStatus{{ Name: "other", }})) } @@ -340,12 +342,12 @@ func TestListenerStatusesEqual(t *testing.T) { func TestParentStatusEqual(t *testing.T) { t.Parallel() - require.True(t, parentStatusEqual(gw.RouteParentStatus{}, gw.RouteParentStatus{})) - require.False(t, parentStatusEqual(gw.RouteParentStatus{}, gw.RouteParentStatus{ + require.True(t, parentStatusEqual(gwv1alpha2.RouteParentStatus{}, gwv1alpha2.RouteParentStatus{})) + require.False(t, parentStatusEqual(gwv1alpha2.RouteParentStatus{}, gwv1alpha2.RouteParentStatus{ ControllerName: "other", })) - require.False(t, parentStatusEqual(gw.RouteParentStatus{}, gw.RouteParentStatus{ - ParentRef: gw.ParentReference{ + require.False(t, parentStatusEqual(gwv1alpha2.RouteParentStatus{}, gwv1alpha2.RouteParentStatus{ + ParentRef: gwv1alpha2.ParentReference{ Name: "other", }, })) @@ -354,12 +356,12 @@ func TestParentStatusEqual(t *testing.T) { func TestGatewayStatusEqual(t *testing.T) { t.Parallel() - require.True(t, gatewayStatusEqual(gw.GatewayStatus{}, gw.GatewayStatus{})) - require.False(t, gatewayStatusEqual(gw.GatewayStatus{}, gw.GatewayStatus{ + require.True(t, gatewayStatusEqual(gwv1beta1.GatewayStatus{}, gwv1beta1.GatewayStatus{})) + require.False(t, gatewayStatusEqual(gwv1beta1.GatewayStatus{}, gwv1beta1.GatewayStatus{ Conditions: []meta.Condition{{}}, })) - require.False(t, gatewayStatusEqual(gw.GatewayStatus{}, gw.GatewayStatus{ - Listeners: []gw.ListenerStatus{{}}, + require.False(t, gatewayStatusEqual(gwv1beta1.GatewayStatus{}, gwv1beta1.GatewayStatus{ + Listeners: []gwv1beta1.ListenerStatus{{}}, })) } @@ -392,70 +394,70 @@ func TestGatewayAllowedForSecretRef(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - group := gw.Group("") + group := gwv1beta1.Group("") - secretRef := gw.SecretObjectReference{ + secretRef := gwv1beta1.SecretObjectReference{ Group: &group, - Name: gw.ObjectName(tc.toName), + Name: gwv1beta1.ObjectName(tc.toName), } if tc.toNS != nil { - ns := gw.Namespace(*tc.toNS) + ns := gwv1beta1.Namespace(*tc.toNS) secretRef.Namespace = &ns } if tc.toKind != nil { - k := gw.Kind(*tc.toKind) + k := gwv1beta1.Kind(*tc.toKind) secretRef.Kind = &k } - gateway := &gw.Gateway{ + gateway := &gwv1beta1.Gateway{ TypeMeta: meta.TypeMeta{APIVersion: "gateway.networking.k8s.io/v1alpha2", Kind: "Gateway"}, ObjectMeta: meta.ObjectMeta{Namespace: tc.fromNS}, - Spec: gw.GatewaySpec{ - Listeners: []gw.Listener{{ - TLS: &gw.GatewayTLSConfig{ - CertificateRefs: []gw.SecretObjectReference{{ + Spec: gwv1beta1.GatewaySpec{ + Listeners: []gwv1beta1.Listener{{ + TLS: &gwv1beta1.GatewayTLSConfig{ + CertificateRefs: []gwv1beta1.SecretObjectReference{{ Group: &group, - Name: gw.ObjectName(tc.toName), + Name: gwv1beta1.ObjectName(tc.toName), }}, }, }}, }, } - var toName *gw.ObjectName + var toName *gwv1alpha2.ObjectName if tc.grantToName != nil { - on := gw.ObjectName(*tc.grantToName) + on := gwv1alpha2.ObjectName(*tc.grantToName) toName = &on } if tc.toNS != nil && tc.fromNS != *tc.toNS { - otherName := gw.ObjectName("blah") + otherName := gwv1alpha2.ObjectName("blah") - refGrants := []gw.ReferenceGrant{ + refGrants := []gwv1alpha2.ReferenceGrant{ // Create a ReferenceGrant that does not match at all (kind, etc.) { ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{Group: "Kool & The Gang", Kind: "Jungle Boogie", Namespace: "Wild And Peaceful"}}, - To: []gw.ReferenceGrantTo{{Group: "does not exist", Kind: "does not exist", Name: nil}}, + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{Group: "Kool & The Gang", Kind: "Jungle Boogie", Namespace: "Wild And Peaceful"}}, + To: []gwv1alpha2.ReferenceGrantTo{{Group: "does not exist", Kind: "does not exist", Name: nil}}, }, }, // Create a ReferenceGrant that matches completely except for To.Name { ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{Group: "gateway.networking.k8s.io", Kind: gw.Kind("Gateway"), Namespace: gw.Namespace(tc.grantFromNS)}}, - To: []gw.ReferenceGrantTo{{Group: "", Kind: "Secret", Name: &otherName}}, + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{Group: "gateway.networking.k8s.io", Kind: gwv1alpha2.Kind("Gateway"), Namespace: gwv1alpha2.Namespace(tc.grantFromNS)}}, + To: []gwv1alpha2.ReferenceGrantTo{{Group: "", Kind: "Secret", Name: &otherName}}, }, }, // Create a ReferenceGrant that matches completely { ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{Group: "gateway.networking.k8s.io", Kind: gw.Kind("Gateway"), Namespace: gw.Namespace(tc.grantFromNS)}}, - To: []gw.ReferenceGrantTo{{Group: "", Kind: "Secret", Name: toName}}, + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{Group: "gateway.networking.k8s.io", Kind: gwv1alpha2.Kind("Gateway"), Namespace: gwv1alpha2.Namespace(tc.grantFromNS)}}, + To: []gwv1alpha2.ReferenceGrantTo{{Group: "", Kind: "Secret", Name: toName}}, }, }, } @@ -503,44 +505,44 @@ func TestRouteAllowedForBackendRef(t *testing.T) { defer ctrl.Finish() client := mocks.NewMockClient(ctrl) - group := gw.Group("") + group := gwv1alpha2.Group("") - backendRef := gw.BackendRef{ - BackendObjectReference: gw.BackendObjectReference{ + backendRef := gwv1alpha2.BackendRef{ + BackendObjectReference: gwv1alpha2.BackendObjectReference{ Group: &group, - Name: gw.ObjectName(tc.toName), + Name: gwv1alpha2.ObjectName(tc.toName), }, } if tc.toNS != nil { - ns := gw.Namespace(*tc.toNS) + ns := gwv1alpha2.Namespace(*tc.toNS) backendRef.BackendObjectReference.Namespace = &ns } if tc.toKind != nil { - k := gw.Kind(*tc.toKind) + k := gwv1alpha2.Kind(*tc.toKind) backendRef.Kind = &k } var route Route switch routeType { case "HTTPRoute": - route = &gw.HTTPRoute{ + route = &gwv1alpha2.HTTPRoute{ ObjectMeta: meta.ObjectMeta{Namespace: tc.fromNS}, TypeMeta: meta.TypeMeta{APIVersion: "gateway.networking.k8s.io/v1alpha2", Kind: "HTTPRoute"}, - Spec: gw.HTTPRouteSpec{ - Rules: []gw.HTTPRouteRule{{ - BackendRefs: []gw.HTTPBackendRef{{BackendRef: backendRef}}, + Spec: gwv1alpha2.HTTPRouteSpec{ + Rules: []gwv1alpha2.HTTPRouteRule{{ + BackendRefs: []gwv1alpha2.HTTPBackendRef{{BackendRef: backendRef}}, }}, }, } case "TCPRoute": - route = &gw.TCPRoute{ + route = &gwv1alpha2.TCPRoute{ ObjectMeta: meta.ObjectMeta{Namespace: tc.fromNS}, TypeMeta: meta.TypeMeta{APIVersion: "gateway.networking.k8s.io/v1alpha2", Kind: "TCPRoute"}, - Spec: gw.TCPRouteSpec{ - Rules: []gw.TCPRouteRule{{ - BackendRefs: []gw.BackendRef{backendRef}, + Spec: gwv1alpha2.TCPRouteSpec{ + Rules: []gwv1alpha2.TCPRouteRule{{ + BackendRefs: []gwv1alpha2.BackendRef{backendRef}, }}, }, } @@ -548,23 +550,23 @@ func TestRouteAllowedForBackendRef(t *testing.T) { require.Fail(t, fmt.Sprintf("unhandled route type %q", routeType)) } - var toName *gw.ObjectName + var toName *gwv1alpha2.ObjectName if tc.grantToName != nil { - on := gw.ObjectName(*tc.grantToName) + on := gwv1alpha2.ObjectName(*tc.grantToName) toName = &on } if tc.toNS != nil && tc.fromNS != *tc.toNS { - referenceGrant := gw.ReferenceGrant{ + referenceGrant := gwv1alpha2.ReferenceGrant{ TypeMeta: meta.TypeMeta{}, ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "gateway.networking.k8s.io", - Kind: gw.Kind(routeType), - Namespace: gw.Namespace(tc.grantFromNS), + Kind: gwv1alpha2.Kind(routeType), + Namespace: gwv1alpha2.Namespace(tc.grantFromNS), }}, - To: []gw.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Group: "", Kind: "Service", Name: toName, @@ -572,15 +574,15 @@ func TestRouteAllowedForBackendRef(t *testing.T) { }, } - throwawayGrant := gw.ReferenceGrant{ + throwawayGrant := gwv1alpha2.ReferenceGrant{ ObjectMeta: meta.ObjectMeta{Namespace: *tc.toNS}, - Spec: gw.ReferenceGrantSpec{ - From: []gw.ReferenceGrantFrom{{ + Spec: gwv1alpha2.ReferenceGrantSpec{ + From: []gwv1alpha2.ReferenceGrantFrom{{ Group: "Kool & The Gang", Kind: "Jungle Boogie", Namespace: "Wild And Peaceful", }}, - To: []gw.ReferenceGrantTo{{ + To: []gwv1alpha2.ReferenceGrantTo{{ Group: "does not exist", Kind: "does not exist", Name: nil, @@ -590,7 +592,7 @@ func TestRouteAllowedForBackendRef(t *testing.T) { client.EXPECT(). GetReferenceGrantsInNamespace(gomock.Any(), *tc.toNS). - Return([]gw.ReferenceGrant{throwawayGrant, referenceGrant}, nil) + Return([]gwv1alpha2.ReferenceGrant{throwawayGrant, referenceGrant}, nil) } allowed, err := routeAllowedForBackendRef(context.Background(), route, backendRef, client) diff --git a/internal/k8s/service/resolver.go b/internal/k8s/service/resolver.go index eb5bdb92b..ebb298b4c 100644 --- a/internal/k8s/service/resolver.go +++ b/internal/k8s/service/resolver.go @@ -13,7 +13,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" "github.com/hashicorp/consul-api-gateway/internal/common" "github.com/hashicorp/consul-api-gateway/internal/k8s/gatewayclient" @@ -135,15 +135,18 @@ type ConsulService struct { } type BackendReference struct { - HTTPRef *gw.HTTPBackendRef - BackendRef *gw.BackendRef + HTTPRef *gwv1alpha2.HTTPBackendRef + BackendRef *gwv1alpha2.BackendRef } +// TODO: this will require a little extra work to return +// gwv1alpha2.BackendObjectReference for TCPRoute BackendRef +// and gwv1beta1.BackendObjectReference for HTTPRoute HTTPBackendRef func (b *BackendReference) Set(reference interface{}) { switch ref := reference.(type) { - case *gw.HTTPBackendRef: + case *gwv1alpha2.HTTPBackendRef: b.HTTPRef = ref - case *gw.BackendRef: + case *gwv1alpha2.BackendRef: b.BackendRef = ref } } @@ -169,7 +172,7 @@ func (r *ResolvedReference) Item() client.Object { } type BackendResolver interface { - Resolve(ctx context.Context, ref gw.BackendObjectReference) (*ResolvedReference, error) + Resolve(ctx context.Context, ref gwv1alpha2.BackendObjectReference) (*ResolvedReference, error) } type backendResolver struct { @@ -190,7 +193,7 @@ func NewBackendResolver(logger hclog.Logger, namespace string, mapper common.Con } } -func (r *backendResolver) Resolve(ctx context.Context, ref gw.BackendObjectReference) (*ResolvedReference, error) { +func (r *backendResolver) Resolve(ctx context.Context, ref gwv1alpha2.BackendObjectReference) (*ResolvedReference, error) { group := corev1.GroupName kind := "Service" namespace := r.namespace diff --git a/internal/k8s/service/rule.go b/internal/k8s/service/rule.go index 63dd01a7c..4b7b44db7 100644 --- a/internal/k8s/service/rule.go +++ b/internal/k8s/service/rule.go @@ -1,26 +1,26 @@ package service import ( - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) type RouteRule struct { - HTTPRule *gw.HTTPRouteRule - TCPRule *gw.TCPRouteRule - TLSRule *gw.TLSRouteRule - UDPRule *gw.UDPRouteRule + HTTPRule *gwv1alpha2.HTTPRouteRule + TCPRule *gwv1alpha2.TCPRouteRule + TLSRule *gwv1alpha2.TLSRouteRule + UDPRule *gwv1alpha2.UDPRouteRule } func NewRouteRule(rule interface{}) RouteRule { r := RouteRule{} switch routeRule := rule.(type) { - case *gw.HTTPRouteRule: + case *gwv1alpha2.HTTPRouteRule: r.HTTPRule = routeRule - case *gw.TCPRouteRule: + case *gwv1alpha2.TCPRouteRule: r.TCPRule = routeRule - case *gw.UDPRouteRule: + case *gwv1alpha2.UDPRouteRule: r.UDPRule = routeRule - case *gw.TLSRouteRule: + case *gwv1alpha2.TLSRouteRule: r.TLSRule = routeRule } return r diff --git a/internal/k8s/utils/consul.go b/internal/k8s/utils/consul.go index da7d784d3..387d4033c 100644 --- a/internal/k8s/utils/consul.go +++ b/internal/k8s/utils/consul.go @@ -1,16 +1,16 @@ package utils import ( - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) -func ProtocolToConsul(protocolType gateway.ProtocolType) (proto string, tls bool) { +func ProtocolToConsul(protocolType gwv1beta1.ProtocolType) (proto string, tls bool) { switch protocolType { - case gateway.TCPProtocolType, gateway.TLSProtocolType: - return "tcp", protocolType == gateway.TLSProtocolType - case gateway.HTTPProtocolType, gateway.HTTPSProtocolType: - return "http", protocolType == gateway.HTTPSProtocolType - case gateway.UDPProtocolType: + case gwv1beta1.TCPProtocolType, gwv1beta1.TLSProtocolType: + return "tcp", protocolType == gwv1beta1.TLSProtocolType + case gwv1beta1.HTTPProtocolType, gwv1beta1.HTTPSProtocolType: + return "http", protocolType == gwv1beta1.HTTPSProtocolType + case gwv1beta1.UDPProtocolType: return "", false // unsupported default: return "", false // unknown/unsupported diff --git a/internal/k8s/utils/consul_test.go b/internal/k8s/utils/consul_test.go index f85355280..b07e6110b 100644 --- a/internal/k8s/utils/consul_test.go +++ b/internal/k8s/utils/consul_test.go @@ -4,33 +4,33 @@ import ( "testing" "github.com/stretchr/testify/require" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) func TestProtocolToConsul(t *testing.T) { t.Parallel() - proto, tls := ProtocolToConsul(gateway.TCPProtocolType) + proto, tls := ProtocolToConsul(gwv1beta1.TCPProtocolType) require.Equal(t, proto, "tcp") require.False(t, tls) - proto, tls = ProtocolToConsul(gateway.TLSProtocolType) + proto, tls = ProtocolToConsul(gwv1beta1.TLSProtocolType) require.Equal(t, proto, "tcp") require.True(t, tls) - proto, tls = ProtocolToConsul(gateway.HTTPProtocolType) + proto, tls = ProtocolToConsul(gwv1beta1.HTTPProtocolType) require.Equal(t, proto, "http") require.False(t, tls) - proto, tls = ProtocolToConsul(gateway.HTTPSProtocolType) + proto, tls = ProtocolToConsul(gwv1beta1.HTTPSProtocolType) require.Equal(t, proto, "http") require.True(t, tls) - proto, tls = ProtocolToConsul(gateway.UDPProtocolType) + proto, tls = ProtocolToConsul(gwv1beta1.UDPProtocolType) require.Equal(t, proto, "") require.False(t, tls) - proto, tls = ProtocolToConsul(gateway.ProtocolType("unknown")) + proto, tls = ProtocolToConsul(gwv1beta1.ProtocolType("unknown")) require.Equal(t, proto, "") require.False(t, tls) } diff --git a/internal/k8s/utils/labels.go b/internal/k8s/utils/labels.go index 2e3730b50..a3a6ffec8 100644 --- a/internal/k8s/utils/labels.go +++ b/internal/k8s/utils/labels.go @@ -5,7 +5,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) const ( @@ -15,7 +15,7 @@ const ( createdAtLabel = "api-gateway.consul.hashicorp.com/created" ) -func LabelsForGateway(gw *gateway.Gateway) map[string]string { +func LabelsForGateway(gw *gwv1beta1.Gateway) map[string]string { return map[string]string{ nameLabel: gw.Name, namespaceLabel: gw.Namespace, diff --git a/internal/k8s/utils/labels_test.go b/internal/k8s/utils/labels_test.go index b50c1f0db..e0220783e 100644 --- a/internal/k8s/utils/labels_test.go +++ b/internal/k8s/utils/labels_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) func TestIsManagedGateway(t *testing.T) { @@ -48,7 +48,7 @@ func TestIsManagedGateway(t *testing.T) { func TestLabelsForGateway(t *testing.T) { t.Parallel() - labels := LabelsForGateway(&gateway.Gateway{ + labels := LabelsForGateway(&gwv1beta1.Gateway{ ObjectMeta: meta.ObjectMeta{ Name: "gateway", Namespace: "default", diff --git a/internal/k8s/utils/reference.go b/internal/k8s/utils/reference.go index 3fe764755..b7057ec0b 100644 --- a/internal/k8s/utils/reference.go +++ b/internal/k8s/utils/reference.go @@ -2,15 +2,16 @@ package utils import ( "k8s.io/apimachinery/pkg/types" - gw "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) var ( - gatewayGroup = gw.Group(gw.GroupName) - gatewayKind = gw.Kind("Gateway") + gatewayGroup = gwv1alpha2.Group(gwv1beta1.GroupName) + gatewayKind = gwv1alpha2.Kind("Gateway") ) -func ReferencesGateway(namespace string, ref gw.ParentReference) (types.NamespacedName, bool) { +func ReferencesGateway(namespace string, ref gwv1alpha2.ParentReference) (types.NamespacedName, bool) { if ref.Group != nil && *ref.Group != gatewayGroup { return types.NamespacedName{}, false } diff --git a/pkg/apis/v1alpha1/types.go b/pkg/apis/v1alpha1/types.go index 6469a8a79..d792409d5 100644 --- a/pkg/apis/v1alpha1/types.go +++ b/pkg/apis/v1alpha1/types.go @@ -5,7 +5,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gateway "sigs.k8s.io/gateway-api/apis/v1alpha2" + gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/hashicorp/consul-api-gateway/internal/k8s/utils" ) @@ -132,7 +132,7 @@ type GatewayClassConfigList struct { } // ServicesAccountFor returns the service account to be created for the given gateway. -func (c *GatewayClassConfig) ServiceAccountFor(gw *gateway.Gateway) *corev1.ServiceAccount { +func (c *GatewayClassConfig) ServiceAccountFor(gw *gwv1beta1.Gateway) *corev1.ServiceAccount { if !c.Spec.ConsulSpec.AuthSpec.Managed { return nil } From 6fee687e2475ccc0ebda9b6cfb548773bcceb6d6 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 20 Jun 2022 17:39:32 -0400 Subject: [PATCH 15/17] config/crd: install deprecated ReferencePolicies CRD explicitly --- config/crd/kustomization.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index a607d40ba..e3ddacb4c 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -3,5 +3,6 @@ kind: Kustomization resources: - github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.0-rc1 +- https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v0.5.0-rc1/config/crd/experimental/gateway.networking.k8s.io_referencepolicies.yaml - bases/api-gateway.consul.hashicorp.com_gatewayclassconfigs.yaml - bases/api-gateway.consul.hashicorp.com_meshservices.yaml From 09fede18fbe4e79e667177d626c8981a35879f0f Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 21 Jun 2022 16:45:42 -0400 Subject: [PATCH 16/17] ci: clone consul-k8s repo and install Consul Helm chart from custom branch --- .github/workflows/conformance.yml | 15 +++++++++++---- .github/workflows/conformance_with_build.yml | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 4e0ca6b49..0fc27b13c 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -33,12 +33,12 @@ jobs: api-gateway-image: "hashicorppreview/consul-api-gateway:0.4-dev" consul-image: "hashicorp/consul:1.11" envoy-image: "envoyproxy/envoy:v1.20-latest" - consul-k8s-version: "0.45.0" + consul-k8s-version: refs/tags/v0.45.0 - name: "consul@v1.12 + consul-k8s@v0.45.0" api-gateway-image: "hashicorppreview/consul-api-gateway:0.4-dev" consul-image: "hashicorp/consul:1.12" envoy-image: "envoyproxy/envoy:v1.22-latest" - consul-k8s-version: "0.45.0" + consul-k8s-version: refs/tags/v0.45.0 fail-fast: true name: "${{ matrix.cluster-type }} - ${{ matrix.config.name }}" concurrency: @@ -47,12 +47,20 @@ jobs: # Clone repos side-by-side: # GITHUB_WORKSPACE/ # consul-api-gateway/ + # consul-k8s/ # gateway-api/ - name: Checkout consul-api-gateway uses: actions/checkout@v2 with: path: "consul-api-gateway" + - name: Clone consul-k8s + uses: actions/checkout@v2 + with: + repository: "hashicorp/consul-k8s" + ref: ${{ matrix.config.consul-k8s-version }} + path: "consul-k8s" + - name: Clone gateway-api uses: actions/checkout@v2 with: @@ -88,8 +96,7 @@ jobs: - name: Install Consul working-directory: "consul-api-gateway/internal/testing/conformance" run: | - helm repo add hashicorp https://helm.releases.hashicorp.com - helm install --values ./consul-config.yaml consul hashicorp/consul --version "${{ matrix.config.consul-k8s-version }}" --set global.image=${{ matrix.config.consul-image }} --set global.imageEnvoy=${{ matrix.config.envoy-image }} --set apiGateway.image=${{ matrix.config.api-gateway-image }} --create-namespace --namespace=consul + helm install --values ./consul-config.yaml consul $GITHUB_WORKSPACE/consul-k8s/charts/consul --set global.image=${{ matrix.config.consul-image }} --set global.imageEnvoy=${{ matrix.config.envoy-image }} --set apiGateway.image=${{ matrix.config.api-gateway-image }} --create-namespace --namespace=consul kubectl wait --for=condition=Ready --timeout=120s --namespace=consul pods --all - name: Patch testing resources diff --git a/.github/workflows/conformance_with_build.yml b/.github/workflows/conformance_with_build.yml index 30adfd36b..cabe155ac 100644 --- a/.github/workflows/conformance_with_build.yml +++ b/.github/workflows/conformance_with_build.yml @@ -35,12 +35,12 @@ jobs: api-gateway-image: "consul-api-gateway:local-build" consul-image: "hashicorp/consul:1.11" envoy-image: "envoyproxy/envoy:v1.20-latest" - consul-k8s-version: "0.45.0" + consul-k8s-version: charts/capigw-controller-clusterrole-referencegrants - name: "consul@v1.12 + consul-k8s@v0.45.0" api-gateway-image: "consul-api-gateway:local-build" consul-image: "hashicorp/consul:1.12" envoy-image: "envoyproxy/envoy:v1.22-latest" - consul-k8s-version: "0.45.0" + consul-k8s-version: charts/capigw-controller-clusterrole-referencegrants fail-fast: true name: "${{ matrix.config.name }}" @@ -48,12 +48,20 @@ jobs: # Clone repos side-by-side: # GITHUB_WORKSPACE/ # consul-api-gateway/ + # consul-k8s/ # gateway-api/ - name: Checkout consul-api-gateway uses: actions/checkout@v2 with: path: "consul-api-gateway" + - name: Clone consul-k8s + uses: actions/checkout@v2 + with: + repository: "hashicorp/consul-k8s" + ref: ${{ matrix.config.consul-k8s-version }} + path: "consul-k8s" + - name: Clone gateway-api uses: actions/checkout@v2 with: @@ -101,8 +109,7 @@ jobs: - name: Install Consul working-directory: "consul-api-gateway/internal/testing/conformance" run: | - helm repo add hashicorp https://helm.releases.hashicorp.com - helm install --values ./consul-config.yaml consul hashicorp/consul --version "${{ matrix.config.consul-k8s-version }}" --set global.image=${{ matrix.config.consul-image }} --set global.imageEnvoy=${{ matrix.config.envoy-image }} --set apiGateway.image=${{ matrix.config.api-gateway-image }} --create-namespace --namespace=consul + helm install --values ./consul-config.yaml consul $GITHUB_WORKSPACE/consul-k8s/charts/consul --set global.image=${{ matrix.config.consul-image }} --set global.imageEnvoy=${{ matrix.config.envoy-image }} --set apiGateway.image=${{ matrix.config.api-gateway-image }} --create-namespace --namespace=consul kubectl wait --for=condition=Ready --timeout=60s --namespace=consul pods --all - name: Patch testing resources From 04935cd1c4e9a4dd54e9575914bb40b014726440 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 1 Jul 2022 12:28:25 -0400 Subject: [PATCH 17/17] Apply suggestions from code review --- .github/workflows/conformance.yml | 4 ++-- .github/workflows/conformance_with_build.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 0fc27b13c..d9a01f8c7 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -33,12 +33,12 @@ jobs: api-gateway-image: "hashicorppreview/consul-api-gateway:0.4-dev" consul-image: "hashicorp/consul:1.11" envoy-image: "envoyproxy/envoy:v1.20-latest" - consul-k8s-version: refs/tags/v0.45.0 + consul-k8s-version: "charts/capigw-controller-clusterrole-referencegrants" - name: "consul@v1.12 + consul-k8s@v0.45.0" api-gateway-image: "hashicorppreview/consul-api-gateway:0.4-dev" consul-image: "hashicorp/consul:1.12" envoy-image: "envoyproxy/envoy:v1.22-latest" - consul-k8s-version: refs/tags/v0.45.0 + consul-k8s-version: "charts/capigw-controller-clusterrole-referencegrants" fail-fast: true name: "${{ matrix.cluster-type }} - ${{ matrix.config.name }}" concurrency: diff --git a/.github/workflows/conformance_with_build.yml b/.github/workflows/conformance_with_build.yml index cabe155ac..be78a5da3 100644 --- a/.github/workflows/conformance_with_build.yml +++ b/.github/workflows/conformance_with_build.yml @@ -35,12 +35,12 @@ jobs: api-gateway-image: "consul-api-gateway:local-build" consul-image: "hashicorp/consul:1.11" envoy-image: "envoyproxy/envoy:v1.20-latest" - consul-k8s-version: charts/capigw-controller-clusterrole-referencegrants + consul-k8s-version: "charts/capigw-controller-clusterrole-referencegrants" - name: "consul@v1.12 + consul-k8s@v0.45.0" api-gateway-image: "consul-api-gateway:local-build" consul-image: "hashicorp/consul:1.12" envoy-image: "envoyproxy/envoy:v1.22-latest" - consul-k8s-version: charts/capigw-controller-clusterrole-referencegrants + consul-k8s-version: "charts/capigw-controller-clusterrole-referencegrants" fail-fast: true name: "${{ matrix.config.name }}"