From a59724bdd4cb98424740a6271f44359fb6f85dab Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 23:52:41 +0000 Subject: [PATCH 01/54] chore(deps): update module github.com/onsi/gomega to v1.22.1 --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index e0c6beeff..2a57c77c4 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/gravitee-io/gravitee-kubernetes-operator go 1.19 require ( - github.com/onsi/ginkgo/v2 v2.2.0 - github.com/onsi/gomega v1.20.1 + github.com/onsi/ginkgo/v2 v2.3.0 + github.com/onsi/gomega v1.22.1 k8s.io/apimachinery v0.25.2 k8s.io/client-go v0.25.2 sigs.k8s.io/controller-runtime v0.13.0 diff --git a/go.sum b/go.sum index ebb4a6b92..4990ba4cb 100644 --- a/go.sum +++ b/go.sum @@ -408,6 +408,8 @@ github.com/onsi/ginkgo/v2 v2.1.6 h1:Fx2POJZfKRQcM1pH49qSZiYeu319wji004qX+GDovrU= github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= +github.com/onsi/ginkgo/v2 v2.3.0 h1:kUMoxMoQG3ogk/QWyKh3zibV7BKZ+xBpWil1cTylVqc= +github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -415,6 +417,8 @@ github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= +github.com/onsi/gomega v1.22.1 h1:pY8O4lBfsHKZHM/6nrxkhVPUznOlIu3quZcKP/M20KI= +github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= 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/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= From c9ff25b65c467b8cb4a409f0553898c675ed9922 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 10 Oct 2022 02:10:36 +0000 Subject: [PATCH 02/54] chore(deps): update cimg/go docker tag to v1.19.2 --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aa1ff6820..7b32faa26 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,7 @@ executors: jobs: lint: docker: - - image: cimg/go:1.19.1-node + - image: cimg/go:1.19.2-node steps: - checkout - go/mod-download-cached @@ -144,7 +144,7 @@ jobs: deploy-gko-image: docker: - - image: cimg/go:1.19.1 + - image: cimg/go:1.19.2 steps: - attach_workspace: at: ~/ @@ -155,7 +155,7 @@ jobs: semantic-release: docker: - - image: cimg/go:1.19.1-node + - image: cimg/go:1.19.2-node environment: GITHUB_TOKEN: "keeper://TIlcGPFq4rN5GvgnZb9hng/field/password" GIT_AUTHOR_NAME: "keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login" From 79757d07e7502409855aa4053f9456ade0b625e2 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 13 Oct 2022 18:14:55 +0200 Subject: [PATCH 03/54] fix: add base href for k3d uri --- scripts/k3d.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/k3d.sh b/scripts/k3d.sh index 9aa5d7d30..a102195ae 100755 --- a/scripts/k3d.sh +++ b/scripts/k3d.sh @@ -217,15 +217,17 @@ helm install \ --set "api.env[1].value=1024m" \ --set "api.startupProbe.initialDelaySeconds=5" \ --set "api.startupProbe.timeoutSeconds=10" \ + --set "api.image.repository=${K3D_IMAGES_REGISTRY}/graviteeio/apim-management-api" \ --set "ui.ingress.hosts[0]=localhost" \ --set "ui.ingress.tls=false" \ --set "ui.autoscaling.enabled=false" \ - --set "api.image.repository=${K3D_IMAGES_REGISTRY}/graviteeio/apim-management-api" \ --set "ui.image.repository=${K3D_IMAGES_REGISTRY}/graviteeio/apim-management-ui" \ + --set "ui.env[0].name=CONSOLE_BASE_HREF" \ + --set "ui.env[0].value=/console/" \ + --set "ui.image.tag=${APIM_IMAGE_TAG}" \ + --set "ui.baseURL=http://localhost:${K3D_LOAD_BALANCER_PORT}/management/organizations/DEFAULT/environments/DEFAULT" \ --set "gateway.image.tag=${APIM_IMAGE_TAG}" \ --set "api.image.tag=${APIM_IMAGE_TAG}" \ - --set "ui.image.tag=${APIM_IMAGE_TAG}" \ - --set "ui.baseURL=http://localhost:${K3D_LOAD_BALANCER_PORT}/management/organizations/DEFAULT/environments/DEFAULT/" \ --set "elasticsearch.enabled=false" \ --set "es.endpoints[0]=http://elasticsearch-master:9200" \ --set "mongo.dbhost=mongodb" \ From 59b42b584b8efb68744e22014a057cf675523089 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Fri, 14 Oct 2022 07:49:13 +0000 Subject: [PATCH 04/54] chore(release): 0.1.0-alpha.6 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c84c9a8ae..41419cae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.6](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.5...0.1.0-alpha.6) (2022-10-14) + + +### Bug Fixes + +* add base href for k3d uri ([79757d0](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/79757d07e7502409855aa4053f9456ade0b625e2)) + # [0.1.0-alpha.5](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.4...0.1.0-alpha.5) (2022-09-30) diff --git a/bundle.yml b/bundle.yml index 6550c21bd..0910740e7 100644 --- a/bundle.yml +++ b/bundle.yml @@ -1373,7 +1373,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.5 + image: graviteeio/kubernetes-operator:0.1.0-alpha.6 imagePullPolicy: Always livenessProbe: httpGet: From f2b16f0a6a346ea2bc5dffe3d1418d3fd4188798 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 00:22:19 +0000 Subject: [PATCH 05/54] chore(deps): update gravitee orb to v2.1.16 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7b32faa26..e1a72f4ba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ orbs: go: circleci/go@1.7.1 helm: circleci/helm@2.0.1 keeper: gravitee-io/keeper@0.6.2 - gravitee: gravitee-io/gravitee@2.1.15 + gravitee: gravitee-io/gravitee@2.1.16 executors: azure-cli: From 8a20fcf4f6bc3c3b9909caaaef13abd4f041557c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 00:22:57 +0000 Subject: [PATCH 06/54] chore(deps): update kubernetes packages to v0.25.3 --- go.mod | 6 +++--- go.sum | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2a57c77c4..37668fe40 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.19 require ( github.com/onsi/ginkgo/v2 v2.3.0 github.com/onsi/gomega v1.22.1 - k8s.io/apimachinery v0.25.2 - k8s.io/client-go v0.25.2 + k8s.io/apimachinery v0.25.3 + k8s.io/client-go v0.25.3 sigs.k8s.io/controller-runtime v0.13.0 ) @@ -76,7 +76,7 @@ require ( 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/api v0.25.2 + k8s.io/api v0.25.3 k8s.io/apiextensions-apiserver v0.25.0 // indirect k8s.io/component-base v0.25.0 // indirect k8s.io/klog/v2 v2.70.1 // indirect diff --git a/go.sum b/go.sum index 4990ba4cb..153603789 100644 --- a/go.sum +++ b/go.sum @@ -1043,6 +1043,8 @@ k8s.io/api v0.25.1 h1:yL7du50yc93k17nH/Xe9jujAYrcDkI/i5DL1jPz4E3M= k8s.io/api v0.25.1/go.mod h1:hh4itDvrWSJsmeUc28rIFNri8MatNAAxJjKcQmhX6TU= k8s.io/api v0.25.2 h1:v6G8RyFcwf0HR5jQGIAYlvtRNrxMJQG1xJzaSeVnIS8= k8s.io/api v0.25.2/go.mod h1:qP1Rn4sCVFwx/xIhe+we2cwBLTXNcheRyYXwajonhy0= +k8s.io/api v0.25.3 h1:Q1v5UFfYe87vi5H7NU0p4RXC26PPMT8KOpr1TLQbCMQ= +k8s.io/api v0.25.3/go.mod h1:o42gKscFrEVjHdQnyRenACrMtbuJsVdP+WVjqejfzmI= k8s.io/apiextensions-apiserver v0.24.2 h1:/4NEQHKlEz1MlaK/wHT5KMKC9UKYz6NZz6JE6ov4G6k= k8s.io/apiextensions-apiserver v0.24.2/go.mod h1:e5t2GMFVngUEHUd0wuCJzw8YDwZoqZfJiGOW6mm2hLQ= k8s.io/apiextensions-apiserver v0.25.0 h1:CJ9zlyXAbq0FIW8CD7HHyozCMBpDSiH7EdrSTCZcZFY= @@ -1056,6 +1058,8 @@ k8s.io/apimachinery v0.25.1 h1:t0XrnmCEHVgJlR2arwO8Awp9ylluDic706WePaYCBTI= k8s.io/apimachinery v0.25.1/go.mod h1:hqqA1X0bsgsxI6dXsJ4HnNTBOmJNxyPp8dw3u2fSHwA= k8s.io/apimachinery v0.25.2 h1:WbxfAjCx+AeN8Ilp9joWnyJ6xu9OMeS/fsfjK/5zaQs= k8s.io/apimachinery v0.25.2/go.mod h1:hqqA1X0bsgsxI6dXsJ4HnNTBOmJNxyPp8dw3u2fSHwA= +k8s.io/apimachinery v0.25.3 h1:7o9ium4uyUOM76t6aunP0nZuex7gDf8VGwkR5RcJnQc= +k8s.io/apimachinery v0.25.3/go.mod h1:jaF9C/iPNM1FuLl7Zuy5b9v+n35HGSh6AQ4HYRkCqwo= k8s.io/apiserver v0.24.2/go.mod h1:pSuKzr3zV+L+MWqsEo0kHHYwCo77AT5qXbFXP2jbvFI= k8s.io/client-go v0.24.2/go.mod h1:zg4Xaoo+umDsfCWr4fCnmLEtQXyCNXCvJuSsglNcV30= k8s.io/client-go v0.24.3 h1:Nl1840+6p4JqkFWEW2LnMKU667BUxw03REfLAVhuKQY= @@ -1066,6 +1070,8 @@ k8s.io/client-go v0.25.1 h1:uFj4AJKtE1/ckcSKz8IhgAuZTdRXZDKev8g387ndD58= k8s.io/client-go v0.25.1/go.mod h1:rdFWTLV/uj2C74zGbQzOsmXPUtMAjSf7ajil4iJUNKo= k8s.io/client-go v0.25.2 h1:SUPp9p5CwM0yXGQrwYurw9LWz+YtMwhWd0GqOsSiefo= k8s.io/client-go v0.25.2/go.mod h1:i7cNU7N+yGQmJkewcRD2+Vuj4iz7b30kI8OcL3horQ4= +k8s.io/client-go v0.25.3 h1:oB4Dyl8d6UbfDHD8Bv8evKylzs3BXzzufLiO27xuPs0= +k8s.io/client-go v0.25.3/go.mod h1:t39LPczAIMwycjcXkVc+CB+PZV69jQuNx4um5ORDjQA= k8s.io/code-generator v0.24.2/go.mod h1:dpVhs00hTuTdTY6jvVxvTFCk6gSMrtfRydbhZwHI15w= k8s.io/component-base v0.24.2 h1:kwpQdoSfbcH+8MPN4tALtajLDfSfYxBDYlXobNWI6OU= k8s.io/component-base v0.24.2/go.mod h1:ucHwW76dajvQ9B7+zecZAP3BVqvrHoOxm8olHEg0nmM= From 2278a16707d002c7012efa17e7f2c873cdfaa44d Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 14 Oct 2022 11:15:25 +0200 Subject: [PATCH 07/54] fix: rename cors fields to match v3 definition --- api/model/http.go | 19 ++++++----- api/model/zz_generated.deepcopy.go | 5 --- .../crd/bases/gravitee.io_apidefinitions.yaml | 29 +++++++---------- docs/api/reference.md | 32 ++++++------------- 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/api/model/http.go b/api/model/http.go index a7ab9f740..bd40a45a2 100644 --- a/api/model/http.go +++ b/api/model/http.go @@ -218,16 +218,15 @@ type Proxy struct { type HttpMethod string type Cors struct { - Enabled bool `json:"enabled"` // Java - AccessControlAllowOrigin []string `json:"accessControlAllowOrigin,omitempty"` - AccessControlAllowOriginRegex []string `json:"accessControlAllowOriginRegex,omitempty"` - AccessControlExposeHeaders []string `json:"accessControlExposeHeaders,omitempty"` - AccessControlMaxAge int `json:"accessControlMaxAge"` - AccessControlAllowCredentials bool `json:"accessControlAllowCredentials"` - AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty"` - AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty"` - ErrorStatusCode int `json:"errorStatusCode"` - RunPolicies bool `json:"runPolicies"` // java + Enabled bool `json:"enabled"` + AccessControlAllowOrigin []string `json:"allowOrigin,omitempty"` + AccessControlExposeHeaders []string `json:"exposeHeaders,omitempty"` + AccessControlMaxAge int `json:"maxAge"` + AccessControlAllowCredentials bool `json:"allowCredentials"` + AccessControlAllowMethods []string `json:"allowMethods,omitempty"` + AccessControlAllowHeaders []string `json:"allowHeaders,omitempty"` + // +kubebuilder:default:=false + RunPolicies bool `json:"runPolicies,omitempty"` } type Plugin struct { diff --git a/api/model/zz_generated.deepcopy.go b/api/model/zz_generated.deepcopy.go index 8eeb7b8ee..4d77ecc41 100644 --- a/api/model/zz_generated.deepcopy.go +++ b/api/model/zz_generated.deepcopy.go @@ -242,11 +242,6 @@ func (in *Cors) DeepCopyInto(out *Cors) { *out = make([]string, len(*in)) copy(*out, *in) } - if in.AccessControlAllowOriginRegex != nil { - in, out := &in.AccessControlAllowOriginRegex, &out.AccessControlAllowOriginRegex - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.AccessControlExposeHeaders != nil { in, out := &in.AccessControlExposeHeaders, &out.AccessControlExposeHeaders *out = make([]string, len(*in)) diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index 35e25bf83..0f7fc8a1a 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -437,42 +437,35 @@ spec: properties: cors: properties: - accessControlAllowCredentials: + allowCredentials: type: boolean - accessControlAllowHeaders: + allowHeaders: items: type: string type: array - accessControlAllowMethods: + allowMethods: items: type: string type: array - accessControlAllowOrigin: + allowOrigin: items: type: string type: array - accessControlAllowOriginRegex: - items: - type: string - type: array - accessControlExposeHeaders: + enabled: + type: boolean + exposeHeaders: items: type: string type: array - accessControlMaxAge: - type: integer - enabled: - type: boolean - errorStatusCode: + maxAge: type: integer runPolicies: + default: false type: boolean required: - - accessControlAllowCredentials - - accessControlMaxAge + - allowCredentials - enabled - - errorStatusCode - - runPolicies + - maxAge type: object failover: properties: diff --git a/docs/api/reference.md b/docs/api/reference.md index 5f0c1f01b..b93009917 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -1356,19 +1356,12 @@ The context is specifying the namespace and the name of a ManagementContext used - accessControlAllowCredentials + allowCredentials boolean
true - - accessControlMaxAge - integer - -
- - true enabled boolean @@ -1377,52 +1370,47 @@ The context is specifying the namespace and the name of a ManagementContext used true - errorStatusCode + maxAge integer
true - runPolicies - boolean - -
- - true - - accessControlAllowHeaders + allowHeaders []string
false - accessControlAllowMethods + allowMethods []string
false - accessControlAllowOrigin + allowOrigin []string
false - accessControlAllowOriginRegex + exposeHeaders []string
false - accessControlExposeHeaders - []string + runPolicies + boolean
+
+ Default: false
false From 8be05d870879ffe151c49a0f8aade580033d5c1a Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Mon, 17 Oct 2022 15:46:47 +0000 Subject: [PATCH 08/54] chore(release): 0.1.0-alpha.7 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 31 ++++++++++++------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41419cae6..e27a7b5c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.7](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.6...0.1.0-alpha.7) (2022-10-17) + + +### Bug Fixes + +* rename cors fields to match v3 definition ([2278a16](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/2278a16707d002c7012efa17e7f2c873cdfaa44d)) + # [0.1.0-alpha.6](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.5...0.1.0-alpha.6) (2022-10-14) diff --git a/bundle.yml b/bundle.yml index 0910740e7..04eba6ad7 100644 --- a/bundle.yml +++ b/bundle.yml @@ -449,42 +449,35 @@ spec: properties: cors: properties: - accessControlAllowCredentials: + allowCredentials: type: boolean - accessControlAllowHeaders: + allowHeaders: items: type: string type: array - accessControlAllowMethods: + allowMethods: items: type: string type: array - accessControlAllowOrigin: + allowOrigin: items: type: string type: array - accessControlAllowOriginRegex: - items: - type: string - type: array - accessControlExposeHeaders: + enabled: + type: boolean + exposeHeaders: items: type: string type: array - accessControlMaxAge: - type: integer - enabled: - type: boolean - errorStatusCode: + maxAge: type: integer runPolicies: + default: false type: boolean required: - - accessControlAllowCredentials - - accessControlMaxAge + - allowCredentials - enabled - - errorStatusCode - - runPolicies + - maxAge type: object failover: properties: @@ -1373,7 +1366,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.6 + image: graviteeio/kubernetes-operator:0.1.0-alpha.7 imagePullPolicy: Always livenessProbe: httpGet: From 19e9dd35448e373d3f3173a3c6ef456d5ec27ae2 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Tue, 18 Oct 2022 11:45:47 +0200 Subject: [PATCH 09/54] fix: merge create and update of api definition --- .../apidefinition/apidefinition_controller.go | 6 +- .../apidefinition_controller_create_test.go | 2 +- ...n_controller_plan_and_subscription_test.go | 3 +- .../apim/apidefinition/internal/create.go | 110 ------------------ .../apim/apidefinition/internal/error.go | 2 + .../apim/apidefinition/internal/helper.go | 33 ++++-- .../apim/apidefinition/internal/update.go | 96 +++++++++------ .../internal/update_api_state.go | 3 +- internal/apim/managementapi/apis.go | 17 +-- 9 files changed, 98 insertions(+), 174 deletions(-) delete mode 100644 controllers/apim/apidefinition/internal/create.go diff --git a/controllers/apim/apidefinition/apidefinition_controller.go b/controllers/apim/apidefinition/apidefinition_controller.go index 769982db5..322de0a0f 100644 --- a/controllers/apim/apidefinition/apidefinition_controller.go +++ b/controllers/apim/apidefinition/apidefinition_controller.go @@ -143,7 +143,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu case apiDefinition.IsBeingCreated(): log.Info("Creating API definition") event.NormalEvent(apiDefinition, "Creating", "Creating API definition") - err = apisDelegate.Create(apiDefinition) + err = apisDelegate.CreateOrUpdate(apiDefinition) if err != nil { break } @@ -152,7 +152,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu case apiDefinition.IsBeingUpdated(): log.Info("Updating API definition") event.NormalEvent(apiDefinition, "Updating", "Updating API definition") - err = apisDelegate.Update(apiDefinition) + err = apisDelegate.CreateOrUpdate(apiDefinition) if err != nil { break } @@ -166,6 +166,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu return ctrl.Result{}, nil } + log.Error(err, "API Definition has not been reconciled") + // Error handling err = apisDelegate.UpdateStatusAndReturnError(apiDefinition, err) event.WarningEvent(apiDefinition, string(apiDefinition.Status.ProcessingStatus), err.Error()) diff --git a/controllers/apim/apidefinition/apidefinition_controller_create_test.go b/controllers/apim/apidefinition/apidefinition_controller_create_test.go index 760568489..d8d07d0de 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_create_test.go +++ b/controllers/apim/apidefinition/apidefinition_controller_create_test.go @@ -235,7 +235,7 @@ var _ = Describe("API Definition Controller", func() { apiJson, err := json.Marshal(existingApiSpec) Expect(err).ToNot(HaveOccurred()) - _, err = apimClient.CreateApi(apiJson) + _, err = apimClient.ImportApi(http.MethodPost, apiJson) Expect(err).ToNot(HaveOccurred()) By("Create a management context to synchronize with the REST API") diff --git a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go b/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go index 36bc847d1..e196c8636 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go +++ b/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go @@ -132,7 +132,8 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { // Wait for the ApiDefinition to be updated Eventually(func() bool { k8sErr := k8sClient.Get(ctx, apiLookupKey, updatedApiDefinition) - return k8sErr == nil && updatedApiDefinition.Status.Generation == savedApiDefinition.Status.Generation+1 + return k8sErr == nil && + updatedApiDefinition.Status.Generation == savedApiDefinition.Status.Generation+1 }, timeout, interval).Should(BeTrue()) // Update savedApiDefinition & global var with last Get diff --git a/controllers/apim/apidefinition/internal/create.go b/controllers/apim/apidefinition/internal/create.go deleted file mode 100644 index bfc79358a..000000000 --- a/controllers/apim/apidefinition/internal/create.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2015 The Gravitee team (http://gravitee.io) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package internal - -import ( - "encoding/json" - "errors" - "fmt" - - "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" - gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - managementapierror "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" - "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" -) - -func (d *Delegate) Create( - apiDefinition *gio.ApiDefinition, -) error { - apiDefinition.Status.CrossID = retrieveCrossId(apiDefinition) - apiDefinition.Status.State = model.StateStarted // API is considered started by default and updated later if needed - - // Generate new Id or use existing one if is found in Management API - apiDefinition.Status.ID = utils.NewUUID() - if d.IsConnectedToManagementApi() { - api, findApiErr := d.apimClient.GetByCrossId(apiDefinition.Status.CrossID) - var crossIdNotFoundError *managementapierror.CrossIdNotFoundError - - switch { - case findApiErr != nil && errors.As(findApiErr, &crossIdNotFoundError): - // Do nothing. API is just not existing in the Management API - case findApiErr != nil: - d.log.Error(findApiErr, "Error while trying to find API in the Management API") - return findApiErr - default: - // Api found in the Management API - // Update status with the found ID to trigger new reconcile to update the existing API - apiDefinition.Status.ID = api.Id - d.log.Info(fmt.Sprintf("API \"%s\" found in the Management API. Continue with update process", api.Name), - "id", api.Id, "crossId", apiDefinition.Status.CrossID, "name", api.Name) - return d.k8sClient.Status().Update(d.ctx, apiDefinition.DeepCopy()) - } - } - - // Add required fields to the API definition spec - // ⚠️ This filed should not be added in ApiDefinition resource - apiDefinition.Spec.Id = apiDefinition.Status.ID - apiDefinition.Spec.CrossId = apiDefinition.Status.CrossID - // Plan is not required from the CRD, but is expected by the Gateway, so we must create at least one - addDefaultPlan(apiDefinition) - retrievePlansCrossId(apiDefinition) - apiDefinition.Spec.DefinitionContext = &model.DefinitionContext{ - Origin: origin, - Mode: mode, - } - - if d.IsConnectedToManagementApi() { - apiJson, marshalErr := json.Marshal(apiDefinition.Spec) - if marshalErr != nil { - d.log.Error(marshalErr, "Unable to marshall API definition as JSON") - return marshalErr - } - mgmtApi, mgmtErr := d.apimClient.CreateApi(apiJson) - - if mgmtErr != nil { - d.log.Error(mgmtErr, "Unable to create API to the Management API") - return mgmtErr - } - - d.log.Info("Api has been created to the Management API") - - // Get Plan Id from the Management API to send it to the Gateway. (Used by the Gateway to find subscription) - retrieveMgmtPlanIds(apiDefinition, mgmtApi) - } - - err := d.saveConfigMap(apiDefinition) - if err != nil { - d.log.Error(err, "Unable to create or update ConfigMap from API definition") - return err - } - - err = d.updateApiState(apiDefinition) - if err != nil { - d.log.Error(err, "Unable to update api state to the Management API") - return err - } - - // Creation succeed, update Status - apiDefinition.Status.Generation = apiDefinition.ObjectMeta.Generation - apiDefinition.Status.ProcessingStatus = gio.ProcessingStatusCompleted - err = d.k8sClient.Status().Update(d.ctx, apiDefinition.DeepCopy()) - - if err != nil { - d.log.Error(err, "Unable to update API definition status") - return err - } - - return nil -} diff --git a/controllers/apim/apidefinition/internal/error.go b/controllers/apim/apidefinition/internal/error.go index ec14914d2..6f165ed4b 100644 --- a/controllers/apim/apidefinition/internal/error.go +++ b/controllers/apim/apidefinition/internal/error.go @@ -64,6 +64,8 @@ func wrapError(err error) error { switch { case errors.As(err, new(managementapierror.ApiUnauthorizedError)): return NonRecoverableError{cause: err} + case errors.As(err, new(managementapierror.CrossIdUnauthorizedError)): + return NonRecoverableError{cause: err} default: return err } diff --git a/controllers/apim/apidefinition/internal/helper.go b/controllers/apim/apidefinition/internal/helper.go index c59ad67e7..af13328d2 100644 --- a/controllers/apim/apidefinition/internal/helper.go +++ b/controllers/apim/apidefinition/internal/helper.go @@ -23,16 +23,31 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" ) -// Return Spec CrossId or generate a new one from api Name & Namespace. -func retrieveCrossId(api *gio.ApiDefinition) string { - // If a CrossID is defined at the API level, reuse it. - // If not, just generate a new CrossID - if api.Spec.CrossId == "" { - // The ID of the API will be based on the API Name and Namespace to ensure consistency - return utils.ToUUID(types.NamespacedName{Namespace: api.Namespace, Name: api.Name}.String()) +func getOrGenerateCrossId(api *gio.ApiDefinition) string { + // If a CrossID is defined at the API status level, reuse it. + if api.Status.CrossID != "" { + return api.Status.CrossID } - return api.Spec.CrossId + // If a CrossID is defined at the API spec level, reuse it. + if api.Spec.CrossId != "" { + return api.Spec.CrossId + } + + // The ID of the API will be based on the API Name and Namespace to ensure consistency + return utils.ToUUID(types.NamespacedName{Namespace: api.Namespace, Name: api.Name}.String()) +} + +func getOrGenerateId(api *gio.ApiDefinition) string { + if api.Status.ID != "" { + return api.Status.ID + } + + if api.Spec.Id != "" { + return api.Spec.Id + } + + return utils.NewUUID() } // Add a default keyless plan to the api definition if no plan is defined. @@ -51,7 +66,7 @@ func addDefaultPlan(api *gio.ApiDefinition) { } // For each plan, generate a CrossId from Api Id & Plan Name if not defined. -func retrievePlansCrossId(api *gio.ApiDefinition) { +func generateEmptyPlanCrossIds(api *gio.ApiDefinition) { plans := api.Spec.Plans for _, plan := range plans { diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index 9f2f2f35b..afa7666be 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -16,67 +16,95 @@ package internal import ( "encoding/json" + "errors" + "net/http" "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" ) -func (d *Delegate) Update(apiDefinition *gio.ApiDefinition) error { - // Add required fields to the API definition spec - // ⚠️ This filed should not be added in ApiDefinition resource - apiDefinition.Spec.CrossId = apiDefinition.Status.CrossID +//nolint:gocognit +func (d *Delegate) CreateOrUpdate( + apiDefinition *gio.ApiDefinition, +) error { + updating := apiDefinition.Status.CrossID != "" + + apiDefinition.Status.CrossID = getOrGenerateCrossId(apiDefinition) + apiDefinition.Status.ID = getOrGenerateId(apiDefinition) apiDefinition.Spec.Id = apiDefinition.Status.ID + apiDefinition.Spec.CrossId = apiDefinition.Status.CrossID + + // TODO Check if Management context is provided and don't add default plan if it is the case ? addDefaultPlan(apiDefinition) - retrievePlansCrossId(apiDefinition) + + // TODO do we really need to do this for plans or should it be done by the management api ? + generateEmptyPlanCrossIds(apiDefinition) + + apiDefinition.Spec.DefinitionContext = &model.DefinitionContext{ + Origin: origin, + Mode: mode, + } if d.IsConnectedToManagementApi() { - apiJson, err := json.Marshal(apiDefinition.Spec) - if err != nil { - d.log.Error(err, "Unable to marshall API definition as JSON") - return err + apiJson, marshalErr := json.Marshal(apiDefinition.Spec) + if marshalErr != nil { + d.log.Error(marshalErr, "Unable to marshall API definition as JSON") + return marshalErr } - mgmtApi, err := d.apimClient.UpdateApi(apiJson) - if err != nil { - d.log.Error(err, "Unable to update API to the Management API") - return err + _, findErr := d.apimClient.GetByCrossId(apiDefinition.Status.CrossID) + + var notFoundError *clienterror.CrossIdNotFoundError + if findErr != nil && !errors.As(findErr, ¬FoundError) { + return findErr + } + + importMethod := http.MethodPost + if findErr == nil { + importMethod = http.MethodPut + } + + mgmtApi, mgmtErr := d.apimClient.ImportApi(importMethod, apiJson) + if mgmtErr != nil { + d.log.Error(mgmtErr, "Unable to create API to the Management API") + return mgmtErr } - d.log.Info("Api has been update to the Management API") + d.log.Info("Api has been created to the Management API") // Get Plan Id from the Management API to send it to the Gateway. (Used by the Gateway to find subscription) retrieveMgmtPlanIds(apiDefinition, mgmtApi) + apiDefinition.Spec.Id = mgmtApi.Id } - // Handle Gateway with ConfigMap - // Delete ConfigMap if api is stopped or save it - switch { - case apiDefinition.Spec.State == model.StateStopped: - err := d.deleteConfigMap(apiDefinition.Namespace, apiDefinition.Name) - if err != nil { + if updating || apiDefinition.Spec.State == model.StateStopped { + if err := d.updateApiState(apiDefinition); err != nil { + d.log.Error(err, "Unable to update api state to the Management API") + return err + } + } + + if apiDefinition.Spec.State == model.StateStopped { + if err := d.deleteConfigMap(apiDefinition.Namespace, apiDefinition.Name); err != nil { d.log.Error(err, "Unable to delete ConfigMap from API definition") return err } - default: - err := d.saveConfigMap(apiDefinition) - if err != nil { - d.log.Error(err, "Unable to save ConfigMap from API definition") + } else { + if err := d.saveConfigMap(apiDefinition); err != nil { + d.log.Error(err, "Unable to create or update ConfigMap from API definition") return err } } - err := d.updateApiState(apiDefinition) - if err != nil { - d.log.Error(err, "Unable to update api state to the Management API") - return err - } - - // Updated succeed, update Status + // Creation succeeded, update Status apiDefinition.Status.Generation = apiDefinition.ObjectMeta.Generation apiDefinition.Status.ProcessingStatus = gio.ProcessingStatusCompleted - err = d.k8sClient.Status().Update(d.ctx, apiDefinition.DeepCopy()) - if err != nil { - d.log.Error(err, "Unexpected error while updating API definition status") + apiDefinition.Status.State = apiDefinition.Spec.State + apiDefinition.Status.ID = apiDefinition.Spec.Id + + if err := d.k8sClient.Status().Update(d.ctx, apiDefinition.DeepCopy()); err != nil { + d.log.Error(err, "Unable to update API definition status") return err } diff --git a/controllers/apim/apidefinition/internal/update_api_state.go b/controllers/apim/apidefinition/internal/update_api_state.go index 591db0f3b..53bd18c84 100644 --- a/controllers/apim/apidefinition/internal/update_api_state.go +++ b/controllers/apim/apidefinition/internal/update_api_state.go @@ -35,7 +35,7 @@ func (d *Delegate) updateApiState( return nil } - // Do noting if state not change + // Do noting if state did not change if apiDefinition.Spec.State == apiDefinition.Status.State { return nil } @@ -48,6 +48,5 @@ func (d *Delegate) updateApiState( d.log.Info(fmt.Sprintf("API state updated to \"%s\" to the Management API ", apiDefinition.Spec.State)) - apiDefinition.Status.State = apiDefinition.Spec.State return nil } diff --git a/internal/apim/managementapi/apis.go b/internal/apim/managementapi/apis.go index ee3713b37..dbac6e76a 100644 --- a/internal/apim/managementapi/apis.go +++ b/internal/apim/managementapi/apis.go @@ -50,7 +50,7 @@ func (client *Client) GetByCrossId( case http.StatusOK: break case http.StatusUnauthorized: - return nil, &clienterror.CrossIdUnauthorizedError{CrossId: crossId} + return nil, clienterror.CrossIdUnauthorizedError{CrossId: crossId} default: return nil, fmt.Errorf("an error as occurred trying to find API %s, HTTP Status: %d ", crossId, resp.StatusCode) } @@ -127,20 +127,7 @@ func (client *Client) GetApiById( return &api, nil } -func (client *Client) CreateApi( - apiJson []byte, -) (*model.ApiEntity, error) { - return importApi(client, http.MethodPost, apiJson) -} - -func (client *Client) UpdateApi( - apiJson []byte, -) (*model.ApiEntity, error) { - return importApi(client, http.MethodPut, apiJson) -} - -func importApi( - client *Client, +func (client *Client) ImportApi( importHttpMethod string, apiJson []byte, ) (*model.ApiEntity, error) { From 83bb2c5de687a58221ba50d3a98f332d4dbe4317 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 20 Oct 2022 14:56:43 +0200 Subject: [PATCH 10/54] refactor: rename status generation --- api/v1alpha1/apidefinition_types.go | 20 +++++++++++++------ ...n_controller_plan_and_subscription_test.go | 4 ++-- .../apim/apidefinition/internal/error.go | 2 +- .../apim/apidefinition/internal/update.go | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/api/v1alpha1/apidefinition_types.go b/api/v1alpha1/apidefinition_types.go index 624f064bb..99e2dbdf4 100644 --- a/api/v1alpha1/apidefinition_types.go +++ b/api/v1alpha1/apidefinition_types.go @@ -35,11 +35,11 @@ type ApiDefinitionSpec struct { // ApiDefinitionStatus defines the observed state of ApiDefinition. type ApiDefinitionStatus struct { - ID string `json:"id"` - CrossID string `json:"crossId"` - State model.State `json:"state"` - ProcessingStatus ProcessingStatus `json:"processingStatus,omitempty"` - Generation int64 `json:"generation"` + ID string `json:"id"` + CrossID string `json:"crossId"` + State model.State `json:"state"` + ProcessingStatus ProcessingStatus `json:"processingStatus,omitempty"` + ObservedGeneration int64 `json:"generation"` } // +kubebuilder:object:root=true @@ -79,13 +79,21 @@ func (api *ApiDefinition) IsBeingDeleted() bool { } func (api *ApiDefinition) IsBeingUpdated() bool { - return api.Status.Generation != api.ObjectMeta.Generation || api.Status.ProcessingStatus == ProcessingStatusReconciling + return api.hasNewGeneration() || api.isReconciling() } func (api *ApiDefinition) IsBeingCreated() bool { return api.Status.CrossID == "" } +func (api *ApiDefinition) hasNewGeneration() bool { + return api.Status.ObservedGeneration != api.ObjectMeta.Generation +} + +func (api *ApiDefinition) isReconciling() bool { + return api.Status.ProcessingStatus == ProcessingStatusReconciling +} + // +kubebuilder:object:root=true // ApiDefinitionList contains a list of ApiDefinition. type ApiDefinitionList struct { diff --git a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go b/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go index e196c8636..080fd2e7d 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go +++ b/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go @@ -133,7 +133,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { Eventually(func() bool { k8sErr := k8sClient.Get(ctx, apiLookupKey, updatedApiDefinition) return k8sErr == nil && - updatedApiDefinition.Status.Generation == savedApiDefinition.Status.Generation+1 + updatedApiDefinition.Status.ObservedGeneration == savedApiDefinition.Status.ObservedGeneration+1 }, timeout, interval).Should(BeTrue()) // Update savedApiDefinition & global var with last Get @@ -157,7 +157,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { Eventually(func() bool { k8sErr := k8sClient.Get(ctx, apiLookupKey, updatedApiDefinition) return k8sErr == nil && - updatedApiDefinition.Status.Generation == savedApiDefinition.Status.Generation+1 + updatedApiDefinition.Status.ObservedGeneration == savedApiDefinition.Status.ObservedGeneration+1 }, timeout, interval).Should(BeTrue()) // Update savedApiDefinition & global var with last Get diff --git a/controllers/apim/apidefinition/internal/error.go b/controllers/apim/apidefinition/internal/error.go index 6f165ed4b..fff7677e6 100644 --- a/controllers/apim/apidefinition/internal/error.go +++ b/controllers/apim/apidefinition/internal/error.go @@ -50,7 +50,7 @@ func (d *Delegate) UpdateStatusAndReturnError(apiDefinition *gio.ApiDefinition, apiDefinition.Status.ProcessingStatus = processingStatus // Updated succeed, update Generation & Status - apiDefinition.Status.Generation = apiDefinition.ObjectMeta.Generation + apiDefinition.Status.ObservedGeneration = apiDefinition.ObjectMeta.Generation err := d.k8sClient.Status().Update(d.ctx, apiDefinition.DeepCopy()) if err != nil { d.log.Info("Unexpected error while updating API definition status.", "err", err) diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index afa7666be..fcb0e6539 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -98,7 +98,7 @@ func (d *Delegate) CreateOrUpdate( } // Creation succeeded, update Status - apiDefinition.Status.Generation = apiDefinition.ObjectMeta.Generation + apiDefinition.Status.ObservedGeneration = apiDefinition.ObjectMeta.Generation apiDefinition.Status.ProcessingStatus = gio.ProcessingStatusCompleted apiDefinition.Status.State = apiDefinition.Spec.State apiDefinition.Status.ID = apiDefinition.Spec.Id From b309629f5e640f839b8056c368867b06a01ef2e2 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 20 Oct 2022 14:57:09 +0200 Subject: [PATCH 11/54] refactor: rename add finalizer method --- controllers/apim/apidefinition/apidefinition_controller.go | 2 +- controllers/apim/apidefinition/internal/finalizer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/apim/apidefinition/apidefinition_controller.go b/controllers/apim/apidefinition/apidefinition_controller.go index 322de0a0f..6a4d33846 100644 --- a/controllers/apim/apidefinition/apidefinition_controller.go +++ b/controllers/apim/apidefinition/apidefinition_controller.go @@ -125,7 +125,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu switch { case !apiDefinition.HasFinalizer(): log.Info("Add Finalizer to API definition") - err = apisDelegate.Finalizer(apiDefinition) + err = apisDelegate.AddDeletionFinalizer(apiDefinition) if err != nil { break } diff --git a/controllers/apim/apidefinition/internal/finalizer.go b/controllers/apim/apidefinition/internal/finalizer.go index fc3dcf0e0..92c2233bc 100644 --- a/controllers/apim/apidefinition/internal/finalizer.go +++ b/controllers/apim/apidefinition/internal/finalizer.go @@ -20,7 +20,7 @@ import ( util "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) -func (d *Delegate) Finalizer( +func (d *Delegate) AddDeletionFinalizer( apiDefinition *gio.ApiDefinition, ) error { util.AddFinalizer(apiDefinition, keys.ApiDefinitionDeletionFinalizer) From 78ed8e2d9ed39ec7a48c6236eec44b53ef7f5b38 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 20 Oct 2022 14:58:41 +0200 Subject: [PATCH 12/54] refactor: rename has finalizer method --- api/v1alpha1/apidefinition_types.go | 2 +- controllers/apim/apidefinition/apidefinition_controller.go | 2 +- controllers/apim/apidefinition/internal/update.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/apidefinition_types.go b/api/v1alpha1/apidefinition_types.go index 99e2dbdf4..c56ea1fd8 100644 --- a/api/v1alpha1/apidefinition_types.go +++ b/api/v1alpha1/apidefinition_types.go @@ -70,7 +70,7 @@ const ( ProcessingStatusReconciling ProcessingStatus = "Reconciling" ) -func (api *ApiDefinition) HasFinalizer() bool { +func (api *ApiDefinition) HasDeletionFinalizer() bool { return util.ContainsFinalizer(api, keys.ApiDefinitionDeletionFinalizer) } diff --git a/controllers/apim/apidefinition/apidefinition_controller.go b/controllers/apim/apidefinition/apidefinition_controller.go index 6a4d33846..12f098d6f 100644 --- a/controllers/apim/apidefinition/apidefinition_controller.go +++ b/controllers/apim/apidefinition/apidefinition_controller.go @@ -123,7 +123,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu // Executes delegate actions switch { - case !apiDefinition.HasFinalizer(): + case !apiDefinition.HasDeletionFinalizer(): log.Info("Add Finalizer to API definition") err = apisDelegate.AddDeletionFinalizer(apiDefinition) if err != nil { diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index fcb0e6539..261c3f241 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -38,7 +38,6 @@ func (d *Delegate) CreateOrUpdate( // TODO Check if Management context is provided and don't add default plan if it is the case ? addDefaultPlan(apiDefinition) - // TODO do we really need to do this for plans or should it be done by the management api ? generateEmptyPlanCrossIds(apiDefinition) apiDefinition.Spec.DefinitionContext = &model.DefinitionContext{ @@ -75,6 +74,8 @@ func (d *Delegate) CreateOrUpdate( // Get Plan Id from the Management API to send it to the Gateway. (Used by the Gateway to find subscription) retrieveMgmtPlanIds(apiDefinition, mgmtApi) + + // Make sure status ID will match APIM ID (could be different if APIM generated it) apiDefinition.Spec.Id = mgmtApi.Id } From 7f68a690c9ebc399ee948aba9dc64cd3e9fef1f5 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Thu, 20 Oct 2022 17:04:46 +0000 Subject: [PATCH 13/54] chore(release): 0.1.0-alpha.8 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e27a7b5c2..c4476f11a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.8](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.7...0.1.0-alpha.8) (2022-10-20) + + +### Bug Fixes + +* merge create and update of api definition ([19e9dd3](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/19e9dd35448e373d3f3173a3c6ef456d5ec27ae2)) + # [0.1.0-alpha.7](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.6...0.1.0-alpha.7) (2022-10-17) diff --git a/bundle.yml b/bundle.yml index 04eba6ad7..e9fd13c65 100644 --- a/bundle.yml +++ b/bundle.yml @@ -1366,7 +1366,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.7 + image: graviteeio/kubernetes-operator:0.1.0-alpha.8 imagePullPolicy: Always livenessProbe: httpGet: From 400c1606134c98be56241a3fbaaad5b6b85e1cda Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 21 Oct 2022 17:21:41 +0200 Subject: [PATCH 14/54] refactor: rename has management context method As having a management context does not implie being connected to mapi this seems more appropriate (eg, the context could point to a bad url) --- controllers/apim/apidefinition/internal/delegate.go | 4 ++-- controllers/apim/apidefinition/internal/delete.go | 2 +- controllers/apim/apidefinition/internal/update.go | 2 +- controllers/apim/apidefinition/internal/update_api_state.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/apim/apidefinition/internal/delegate.go b/controllers/apim/apidefinition/internal/delegate.go index 8ff938955..04a75be67 100644 --- a/controllers/apim/apidefinition/internal/delegate.go +++ b/controllers/apim/apidefinition/internal/delegate.go @@ -60,6 +60,6 @@ func (d *Delegate) SetManagementContext(managementContext *gio.ManagementContext d.apimClient = managementapi.NewClient(d.ctx, d.managementContext, httpClient) } -func (d *Delegate) IsConnectedToManagementApi() bool { - return d.apimClient != nil +func (d *Delegate) HasManagementContext() bool { + return d.managementContext != nil } diff --git a/controllers/apim/apidefinition/internal/delete.go b/controllers/apim/apidefinition/internal/delete.go index cf263a2d4..d866b177e 100644 --- a/controllers/apim/apidefinition/internal/delete.go +++ b/controllers/apim/apidefinition/internal/delete.go @@ -32,7 +32,7 @@ func (d *Delegate) Delete( } var apiNotFoundError *managementapierror.ApiNotFoundError - if d.IsConnectedToManagementApi() && apiDefinition.Status.ID != "" { + if d.HasManagementContext() && apiDefinition.Status.ID != "" { d.log.Info("Delete API definition into Management API") err := d.apimClient.DeleteApi(apiDefinition.Status.ID) if errors.As(err, &apiNotFoundError) { diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index 261c3f241..9022523a6 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -45,7 +45,7 @@ func (d *Delegate) CreateOrUpdate( Mode: mode, } - if d.IsConnectedToManagementApi() { + if d.HasManagementContext() { apiJson, marshalErr := json.Marshal(apiDefinition.Spec) if marshalErr != nil { d.log.Error(marshalErr, "Unable to marshall API definition as JSON") diff --git a/controllers/apim/apidefinition/internal/update_api_state.go b/controllers/apim/apidefinition/internal/update_api_state.go index 53bd18c84..23eb59842 100644 --- a/controllers/apim/apidefinition/internal/update_api_state.go +++ b/controllers/apim/apidefinition/internal/update_api_state.go @@ -31,7 +31,7 @@ func (d *Delegate) updateApiState( apiDefinition *gio.ApiDefinition, ) error { // Check if Management context is provided - if !d.IsConnectedToManagementApi() { + if !d.HasManagementContext() { return nil } From 9c69558bf9ec3679115db626cac8e44a5eb54140 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 00:38:36 +0000 Subject: [PATCH 15/54] chore(deps): update mcr.microsoft.com/azure-cli docker tag to v2.41.0 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e1a72f4ba..51954a4a1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ executors: docker: # Version can be found here https://docs.microsoft.com/en-us/cli/azure/release-notes-azure-cli # be careful when updating the version as it looks it is not following semver - - image: mcr.microsoft.com/azure-cli:2.40.0 + - image: mcr.microsoft.com/azure-cli:2.41.0 resource_class: <> jobs: From 97901edc8a3f0f806c2ca1f8789362e8fe4e0279 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 00:39:19 +0000 Subject: [PATCH 16/54] chore(deps): update module github.com/onsi/ginkgo/v2 to v2.4.0 --- go.mod | 10 +++++----- go.sum | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 37668fe40..47bd6fa6e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/gravitee-io/gravitee-kubernetes-operator go 1.19 require ( - github.com/onsi/ginkgo/v2 v2.3.0 + github.com/onsi/ginkgo/v2 v2.4.0 github.com/onsi/gomega v1.22.1 k8s.io/apimachinery v0.25.3 k8s.io/client-go v0.25.3 @@ -64,11 +64,11 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect - golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/net v0.1.0 // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/sys v0.1.0 // indirect + golang.org/x/term v0.1.0 // indirect + golang.org/x/text v0.4.0 // indirect golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 153603789..0bbbb327e 100644 --- a/go.sum +++ b/go.sum @@ -410,6 +410,8 @@ github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/ginkgo/v2 v2.3.0 h1:kUMoxMoQG3ogk/QWyKh3zibV7BKZ+xBpWil1cTylVqc= github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= +github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= +github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -664,6 +666,8 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3 golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= 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= @@ -767,9 +771,13 @@ golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/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/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= +golang.org/x/term v0.1.0/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= @@ -780,6 +788,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 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/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 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= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 7427457a1ba4abf81b2e19dc61f8fc6152987469 Mon Sep 17 00:00:00 2001 From: Okhelifi Date: Tue, 25 Oct 2022 12:18:23 +0200 Subject: [PATCH 17/54] fix: import api with life cycle state --- .../apim/apidefinition/internal/update.go | 13 +---- .../internal/update_api_state.go | 52 ------------------- 2 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 controllers/apim/apidefinition/internal/update_api_state.go diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index 9022523a6..b2d7d1d29 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -17,6 +17,7 @@ package internal import ( "encoding/json" "errors" + "fmt" "net/http" "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" @@ -24,12 +25,9 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" ) -//nolint:gocognit func (d *Delegate) CreateOrUpdate( apiDefinition *gio.ApiDefinition, ) error { - updating := apiDefinition.Status.CrossID != "" - apiDefinition.Status.CrossID = getOrGenerateCrossId(apiDefinition) apiDefinition.Status.ID = getOrGenerateId(apiDefinition) apiDefinition.Spec.Id = apiDefinition.Status.ID @@ -70,7 +68,7 @@ func (d *Delegate) CreateOrUpdate( return mgmtErr } - d.log.Info("Api has been created to the Management API") + d.log.Info(fmt.Sprintf("Api has been %s to the Management API", importMethod)) // Get Plan Id from the Management API to send it to the Gateway. (Used by the Gateway to find subscription) retrieveMgmtPlanIds(apiDefinition, mgmtApi) @@ -79,13 +77,6 @@ func (d *Delegate) CreateOrUpdate( apiDefinition.Spec.Id = mgmtApi.Id } - if updating || apiDefinition.Spec.State == model.StateStopped { - if err := d.updateApiState(apiDefinition); err != nil { - d.log.Error(err, "Unable to update api state to the Management API") - return err - } - } - if apiDefinition.Spec.State == model.StateStopped { if err := d.deleteConfigMap(apiDefinition.Namespace, apiDefinition.Name); err != nil { d.log.Error(err, "Unable to delete ConfigMap from API definition") diff --git a/controllers/apim/apidefinition/internal/update_api_state.go b/controllers/apim/apidefinition/internal/update_api_state.go deleted file mode 100644 index 23eb59842..000000000 --- a/controllers/apim/apidefinition/internal/update_api_state.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2015 The Gravitee team (http://gravitee.io) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package internal - -import ( - "fmt" - - "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" - gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - managementapimodel "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/model" -) - -var stateToAction = map[model.State]managementapimodel.Action{ - model.StateStarted: managementapimodel.ActionStart, - model.StateStopped: managementapimodel.ActionStop, -} - -func (d *Delegate) updateApiState( - apiDefinition *gio.ApiDefinition, -) error { - // Check if Management context is provided - if !d.HasManagementContext() { - return nil - } - - // Do noting if state did not change - if apiDefinition.Spec.State == apiDefinition.Status.State { - return nil - } - - err := d.apimClient.UpdateApiState(apiDefinition.Status.ID, stateToAction[apiDefinition.Spec.State]) - if err != nil { - d.log.Error(err, "Unable to update api state to the Management API") - return err - } - - d.log.Info(fmt.Sprintf("API state updated to \"%s\" to the Management API ", apiDefinition.Spec.State)) - - return nil -} From 3b98614254a676260319f8f621f701e67e858684 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 21 Oct 2022 15:45:01 +0200 Subject: [PATCH 18/54] test: add context ref on update --- .../apidefinition_controller_udpate_test.go | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/controllers/apim/apidefinition/apidefinition_controller_udpate_test.go b/controllers/apim/apidefinition/apidefinition_controller_udpate_test.go index c6a82a5b5..dd739e720 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_udpate_test.go +++ b/controllers/apim/apidefinition/apidefinition_controller_udpate_test.go @@ -35,6 +35,7 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" + "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/test" @@ -187,4 +188,62 @@ var _ = Describe("API Definition Controller", func() { }, timeout, interval).Should(BeTrue()) }) }) + + Context("With basic ApiDefinition & ManagementContext adding context ref on update", func() { + var managementContextFixture *gio.ManagementContext + var apiDefinitionFixture *gio.ApiDefinition + var apiLookupKey types.NamespacedName + + BeforeEach(func() { + By("Create a management context to synchronize with the REST API") + + managementContext, err := test.NewManagementContext( + "../../../config/samples/context/dev/managementcontext_credentials.yaml") + Expect(err).ToNot(HaveOccurred()) + Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) + + By("Create an API definition resource without a management context") + + apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example.yml") + Expect(err).ToNot(HaveOccurred()) + Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) + + apiDefinitionFixture = apiDefinition + managementContextFixture = managementContext + apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} + }) + + AfterEach(func() { + cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) + }) + + It("Should update an API Definition, adding a management context", func() { + createdApiDefinition := new(gio.ApiDefinition) + + Eventually(func() bool { + err := k8sClient.Get(ctx, apiLookupKey, createdApiDefinition) + return err == nil && createdApiDefinition.Status.CrossID != "" + }, timeout, interval).Should(BeTrue()) + + By("Updating the context ref in API definition, expecting no error") + + updatedApiDefinition := createdApiDefinition.DeepCopy() + + updatedApiDefinition.Spec.Context = &model.ContextRef{ + Name: managementContextFixture.Name, + Namespace: managementContextFixture.Namespace, + } + + err := k8sClient.Update(ctx, updatedApiDefinition) + Expect(err).ToNot(HaveOccurred()) + + By("Calling rest API, expecting one API matching status ID") + + apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + Eventually(func() bool { + api, apiErr := apimClient.GetByCrossId(updatedApiDefinition.Status.CrossID) + return apiErr == nil && api.Id == updatedApiDefinition.Status.ID + }, timeout, interval).Should(BeTrue()) + }) + }) }) From b75aec8dbb9d319ec5f2ddee195fb88d19932ef6 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Tue, 25 Oct 2022 13:37:11 +0000 Subject: [PATCH 19/54] chore(release): 0.1.0-alpha.9 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4476f11a..650fd6f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.9](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.8...0.1.0-alpha.9) (2022-10-25) + + +### Bug Fixes + +* import api with life cycle state ([7427457](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/7427457a1ba4abf81b2e19dc61f8fc6152987469)) + # [0.1.0-alpha.8](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.7...0.1.0-alpha.8) (2022-10-20) diff --git a/bundle.yml b/bundle.yml index e9fd13c65..982a0a02d 100644 --- a/bundle.yml +++ b/bundle.yml @@ -1366,7 +1366,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.8 + image: graviteeio/kubernetes-operator:0.1.0-alpha.9 imagePullPolicy: Always livenessProbe: httpGet: From 933af8d4cd1c718b593cebebf86ac2c1507d5064 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 21 Oct 2022 15:49:23 +0200 Subject: [PATCH 20/54] ci: remove wait step from test job This step is know performed by the k3d script --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 51954a4a1..7ce1266a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,9 +91,6 @@ jobs: export APIM_IMAGE_REGISTRY=graviteeio.azurecr.io export APIM_IMAGE_TAG=master-latest make k3d-apim-init - - run: - name: Wait for APIM to be ready - command: kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=apim3 --timeout 300s - run: name: Run tests command: GOTESTARGS="--junitfile=/tmp/junit/reports/junit.xml" make test From c73cc63301542ac89880008434b503feda5eee1c Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 21 Oct 2022 11:37:12 +0200 Subject: [PATCH 21/54] refactor: error handling --- .../apidefinition_controller_delete_test.go | 7 +- ...n_controller_plan_and_subscription_test.go | 4 +- .../apim/apidefinition/internal/delete.go | 7 +- .../apim/apidefinition/internal/error.go | 4 +- .../apim/apidefinition/internal/error_test.go | 65 +++++++++ .../apim/apidefinition/internal/update.go | 4 +- internal/apim/managementapi/apis.go | 20 +-- .../managementapi/clienterror/errors_test.go | 129 ++++++++++++++++++ .../{api_unauthorized.go => illegal_state.go} | 26 +++- .../{api_not_found_error.go => not_found.go} | 25 +++- .../{cross_id_error.go => unauthorized.go} | 34 ++--- 11 files changed, 265 insertions(+), 60 deletions(-) create mode 100644 controllers/apim/apidefinition/internal/error_test.go create mode 100644 internal/apim/managementapi/clienterror/errors_test.go rename internal/apim/managementapi/clienterror/{api_unauthorized.go => illegal_state.go} (58%) rename internal/apim/managementapi/clienterror/{api_not_found_error.go => not_found.go} (56%) rename internal/apim/managementapi/clienterror/{cross_id_error.go => unauthorized.go} (50%) diff --git a/controllers/apim/apidefinition/apidefinition_controller_delete_test.go b/controllers/apim/apidefinition/apidefinition_controller_delete_test.go index c1f2c21a0..73f2fcaf0 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_delete_test.go +++ b/controllers/apim/apidefinition/apidefinition_controller_delete_test.go @@ -31,8 +31,6 @@ import ( "net/http" "time" - "errors" - "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" clientError "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" . "github.com/onsi/ginkgo/v2" @@ -107,9 +105,8 @@ var _ = Describe("API Definition Controller", func() { By("Call rest API and expect DELETED api") apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) Eventually(func() bool { - _, apiErr := apimClient.GetApiById(createdApiDefinition.Status.CrossID) - var apiNotFoundError *clientError.ApiNotFoundError - return apiErr != nil && errors.As(apiErr, &apiNotFoundError) + _, apiErr := apimClient.GetApiById(createdApiDefinition.Status.ID) + return apiErr != nil && clientError.IsNotFound(apiErr) }, timeout, interval).Should(BeTrue()) By("Expect that the ConfigMap has been deleted") diff --git a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go b/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go index 080fd2e7d..d98867b9d 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go +++ b/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go @@ -28,7 +28,6 @@ limitations under the License. package apidefinition import ( - "errors" "net/http" "time" @@ -198,8 +197,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { Eventually(func() bool { _, apiErr := mgmtClient.GetApiById(savedApiDefinition.Status.ID) - var apiNotFoundError *clientError.ApiNotFoundError - return apiErr != nil && errors.As(apiErr, &apiNotFoundError) + return apiErr != nil && clientError.IsNotFound(apiErr) }, timeout, interval).Should(BeTrue()) }) }) diff --git a/controllers/apim/apidefinition/internal/delete.go b/controllers/apim/apidefinition/internal/delete.go index d866b177e..b3a881bd3 100644 --- a/controllers/apim/apidefinition/internal/delete.go +++ b/controllers/apim/apidefinition/internal/delete.go @@ -19,8 +19,6 @@ import ( managementapierror "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" "github.com/gravitee-io/gravitee-kubernetes-operator/pkg/keys" util "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - - "errors" ) func (d *Delegate) Delete( @@ -31,14 +29,13 @@ func (d *Delegate) Delete( return nil } - var apiNotFoundError *managementapierror.ApiNotFoundError if d.HasManagementContext() && apiDefinition.Status.ID != "" { d.log.Info("Delete API definition into Management API") err := d.apimClient.DeleteApi(apiDefinition.Status.ID) - if errors.As(err, &apiNotFoundError) { + if managementapierror.IsNotFound(err) { d.log.Info("The API has already been deleted", "id", apiDefinition.Status.ID) } - if err != nil && !errors.As(err, &apiNotFoundError) { + if err != nil && !managementapierror.IsNotFound(err) { d.log.Error(err, "Unable to delete API definition into Management API") return err } diff --git a/controllers/apim/apidefinition/internal/error.go b/controllers/apim/apidefinition/internal/error.go index fff7677e6..c5d2a4e37 100644 --- a/controllers/apim/apidefinition/internal/error.go +++ b/controllers/apim/apidefinition/internal/error.go @@ -62,9 +62,7 @@ func (d *Delegate) UpdateStatusAndReturnError(apiDefinition *gio.ApiDefinition, // Wraps the error in a NonRecoverableError if it's not recoverable. func wrapError(err error) error { switch { - case errors.As(err, new(managementapierror.ApiUnauthorizedError)): - return NonRecoverableError{cause: err} - case errors.As(err, new(managementapierror.CrossIdUnauthorizedError)): + case managementapierror.IsUnauthorized(err): return NonRecoverableError{cause: err} default: return err diff --git a/controllers/apim/apidefinition/internal/error_test.go b/controllers/apim/apidefinition/internal/error_test.go new file mode 100644 index 000000000..6339b0728 --- /dev/null +++ b/controllers/apim/apidefinition/internal/error_test.go @@ -0,0 +1,65 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "fmt" + "testing" + + "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" +) + +func Test_wrapError(t *testing.T) { + tests := []struct { + name string + err error + expected bool + }{ + { + "Should be recoverable with raw error", + fmt.Errorf("raw error"), + true, + }, + { + "Should be recoverable with not found error", + clienterror.NewCrossIdNotFoundError("cross-id"), + true, + }, + { + "Should be recoverable with illegal state error", + clienterror.NewAmbiguousCrossIdError("cross-id", 2), + true, + }, + { + "Should not be recoverable with unauthorized api request error", + clienterror.NewUnauthorizedApiRequestError("api-id"), + false, + }, + { + "Should not be recoverable with unauthorized cross ID request error", + clienterror.NewUnauthorizedCrossIdRequestError("cross-id"), + false, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + given := IsRecoverableError(wrapError(test.err)) + if given != test.expected { + t.Fail() + t.Logf("Expected %t to be %t", given, test.expected) + } + }) + } +} diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index b2d7d1d29..2ae02adaf 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -16,7 +16,6 @@ package internal import ( "encoding/json" - "errors" "fmt" "net/http" @@ -52,8 +51,7 @@ func (d *Delegate) CreateOrUpdate( _, findErr := d.apimClient.GetByCrossId(apiDefinition.Status.CrossID) - var notFoundError *clienterror.CrossIdNotFoundError - if findErr != nil && !errors.As(findErr, ¬FoundError) { + if findErr != nil && !clienterror.IsNotFound(findErr) { return findErr } diff --git a/internal/apim/managementapi/apis.go b/internal/apim/managementapi/apis.go index dbac6e76a..f8dd4136f 100644 --- a/internal/apim/managementapi/apis.go +++ b/internal/apim/managementapi/apis.go @@ -50,7 +50,7 @@ func (client *Client) GetByCrossId( case http.StatusOK: break case http.StatusUnauthorized: - return nil, clienterror.CrossIdUnauthorizedError{CrossId: crossId} + return nil, clienterror.NewUnauthorizedCrossIdRequestError(crossId) default: return nil, fmt.Errorf("an error as occurred trying to find API %s, HTTP Status: %d ", crossId, resp.StatusCode) } @@ -68,11 +68,11 @@ func (client *Client) GetByCrossId( } if len(apis) == 0 { - return nil, &clienterror.CrossIdNotFoundError{CrossId: crossId} + return nil, clienterror.NewCrossIdNotFoundError(crossId) } if len(apis) > 1 { - return nil, &clienterror.CrossIdMultipleFoundError{CrossId: crossId, Apis: apis} + return nil, clienterror.NewAmbiguousCrossIdError(crossId, len(apis)) } return &apis[0], nil @@ -102,9 +102,9 @@ func (client *Client) GetApiById( case http.StatusOK: break case http.StatusUnauthorized: - return nil, &clienterror.ApiUnauthorizedError{ApiId: apiId} + return nil, clienterror.NewUnauthorizedApiRequestError(apiId) case http.StatusNotFound: - return nil, &clienterror.ApiNotFoundError{ApiId: apiId} + return nil, clienterror.NewApiNotFoundError(apiId) default: return nil, fmt.Errorf( "an error as occurred trying to get API matching id %s, HTTP Status: %d ", @@ -154,7 +154,7 @@ func (client *Client) ImportApi( case http.StatusOK: break case http.StatusUnauthorized: - return nil, clienterror.ApiUnauthorizedError{} + return nil, clienterror.UnauthorizedError{} default: return nil, fmt.Errorf("an error as occurred trying to import API definition, HTTP Status: %d ", resp.StatusCode) } @@ -197,9 +197,9 @@ func (client *Client) UpdateApiState( case http.StatusNoContent: return nil case http.StatusUnauthorized: - return &clienterror.ApiUnauthorizedError{ApiId: apiId} + return clienterror.NewUnauthorizedApiRequestError(apiId) case http.StatusNotFound: - return &clienterror.ApiNotFoundError{ApiId: apiId} + return clienterror.NewApiNotFoundError(apiId) default: return fmt.Errorf( "an error as occurred trying to update API state matching id %s, HTTP Status: %d ", @@ -230,9 +230,9 @@ func (client *Client) DeleteApi( case http.StatusNoContent: return nil case http.StatusUnauthorized: - return &clienterror.ApiUnauthorizedError{ApiId: apiId} + return clienterror.NewUnauthorizedApiRequestError(apiId) case http.StatusNotFound: - return &clienterror.ApiNotFoundError{ApiId: apiId} + return clienterror.NewApiNotFoundError(apiId) default: return fmt.Errorf( "an error as occurred trying to delete API matching id %s, HTTP Status: %d ", diff --git a/internal/apim/managementapi/clienterror/errors_test.go b/internal/apim/managementapi/clienterror/errors_test.go new file mode 100644 index 000000000..0f9d17637 --- /dev/null +++ b/internal/apim/managementapi/clienterror/errors_test.go @@ -0,0 +1,129 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package clienterror + +import ( + "fmt" + "testing" +) + +func Test_IsUnauthorizedError(t *testing.T) { + tests := []struct { + name string + err error + expected bool + }{ + { + "Should not be unauthorized with raw error", + fmt.Errorf("raw error"), + false, + }, + { + "Should not be unauthorized with nil error", + nil, + false, + }, + { + "Should be unauthorized with unauthorized API error", + NewUnauthorizedApiRequestError("api-id"), + true, + }, + { + "Should be unauthorized with unauthorized crossId error", + NewUnauthorizedCrossIdRequestError("cross-id"), + true, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + given := IsUnauthorized(test.err) + if given != test.expected { + t.Fail() + t.Logf("Expected %t to be %t", given, test.expected) + } + }) + } +} + +func Test_IsNotFoundError(t *testing.T) { + tests := []struct { + name string + err error + expected bool + }{ + { + "Should not be not found with raw error", + fmt.Errorf("raw error"), + false, + }, + { + "Should not be not found with nil error", + nil, + false, + }, + { + "Should be not found with API error", + NewApiNotFoundError("api-id"), + true, + }, + { + "Should be not found with crossId error", + NewCrossIdNotFoundError("cross-id"), + true, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + given := IsNotFound(test.err) + if given != test.expected { + t.Fail() + t.Logf("Expected %t to be %t", given, test.expected) + } + }) + } +} + +func Test_IsIllegalStateError(t *testing.T) { + tests := []struct { + name string + err error + expected bool + }{ + { + "Should not be illegal state error with raw error", + fmt.Errorf("raw error"), + false, + }, + { + "Should not be illegal state error not found with nil error", + nil, + false, + }, + { + "Should be illegal state error with ambiguous crossId error", + NewAmbiguousCrossIdError("cross-id", 2), + true, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + given := IsIllegalState(test.err) + if given != test.expected { + t.Fail() + t.Logf("Expected %t to be %t", given, test.expected) + } + }) + } +} diff --git a/internal/apim/managementapi/clienterror/api_unauthorized.go b/internal/apim/managementapi/clienterror/illegal_state.go similarity index 58% rename from internal/apim/managementapi/clienterror/api_unauthorized.go rename to internal/apim/managementapi/clienterror/illegal_state.go index 1667360d0..2d6637f38 100644 --- a/internal/apim/managementapi/clienterror/api_unauthorized.go +++ b/internal/apim/managementapi/clienterror/illegal_state.go @@ -14,14 +14,26 @@ package clienterror -type ApiUnauthorizedError struct { - ApiId string +import ( + "errors" + "strconv" +) + +type IllegalStateError struct { + message string } -func (e ApiUnauthorizedError) Error() string { - msg := "Unauthorized error" - if e.ApiId != "" { - msg += " for API " + e.ApiId +func (e IllegalStateError) Error() string { + if e.message == "" { + return "ILLEGAL STATE" } - return msg + return e.message +} + +func NewAmbiguousCrossIdError(crossId string, count int) IllegalStateError { + return IllegalStateError{message: "Expected one API with CrossId " + crossId + "but found " + strconv.Itoa(count)} +} + +func IsIllegalState(err error) bool { + return errors.As(err, &IllegalStateError{}) } diff --git a/internal/apim/managementapi/clienterror/api_not_found_error.go b/internal/apim/managementapi/clienterror/not_found.go similarity index 56% rename from internal/apim/managementapi/clienterror/api_not_found_error.go rename to internal/apim/managementapi/clienterror/not_found.go index f8a1dd9f8..31af5715d 100644 --- a/internal/apim/managementapi/clienterror/api_not_found_error.go +++ b/internal/apim/managementapi/clienterror/not_found.go @@ -14,10 +14,27 @@ package clienterror -type ApiNotFoundError struct { - ApiId string +import "errors" + +type NotFoundError struct { + message string +} + +func (e NotFoundError) Error() string { + if e.message == "" { + return "NOT FOUND" + } + return e.message +} + +func NewCrossIdNotFoundError(crossId string) NotFoundError { + return NotFoundError{message: "No API found for CrossId " + crossId} +} + +func NewApiNotFoundError(apiId string) NotFoundError { + return NotFoundError{message: "No API found for API " + apiId} } -func (e *ApiNotFoundError) Error() string { - return "No API found for ApiId " + e.ApiId +func IsNotFound(err error) bool { + return errors.As(err, &NotFoundError{}) } diff --git a/internal/apim/managementapi/clienterror/cross_id_error.go b/internal/apim/managementapi/clienterror/unauthorized.go similarity index 50% rename from internal/apim/managementapi/clienterror/cross_id_error.go rename to internal/apim/managementapi/clienterror/unauthorized.go index 650dc365e..e9cdf11f5 100644 --- a/internal/apim/managementapi/clienterror/cross_id_error.go +++ b/internal/apim/managementapi/clienterror/unauthorized.go @@ -14,33 +14,27 @@ package clienterror -import ( - "fmt" +import "errors" - "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/model" -) - -type CrossIdNotFoundError struct { - CrossId string -} - -func (e *CrossIdNotFoundError) Error() string { - return "No API found for CrossId " + e.CrossId +type UnauthorizedError struct { + message string } -type CrossIdMultipleFoundError struct { - CrossId string - Apis []model.ApiListItem +func (e UnauthorizedError) Error() string { + if e.message == "" { + return "UNAUTHORIZED" + } + return e.message } -func (e *CrossIdMultipleFoundError) Error() string { - return fmt.Sprintf("Multiple APIs found for CrossId %s. (%d APIs found)", e.CrossId, len(e.Apis)) +func NewUnauthorizedCrossIdRequestError(crossId string) UnauthorizedError { + return UnauthorizedError{message: "Unauthorized error for CrossId " + crossId} } -type CrossIdUnauthorizedError struct { - CrossId string +func NewUnauthorizedApiRequestError(apiId string) UnauthorizedError { + return UnauthorizedError{message: "Unauthorized error for API " + apiId} } -func (e CrossIdUnauthorizedError) Error() string { - return "Unauthorized error for CrossId " + e.CrossId +func IsUnauthorized(err error) bool { + return errors.As(err, &UnauthorizedError{}) } From dd74bba9ef97e45664cfae3dbbdce798dcd83d9d Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 27 Oct 2022 14:34:10 +0200 Subject: [PATCH 22/54] refactor: move integration tests to their own package --- .../apidefinition_controller_create_test.go | 19 +- .../apidefinition_controller_delete_test.go | 13 +- .../apidefinition_controller_error_test.go | 25 +- ...n_controller_plan_and_subscription_test.go | 13 +- ...pidefinition_controller_start_stop_test.go | 11 +- .../apidefinition_controller_udpate_test.go | 25 +- test/suite_test.go | 233 ++++++++++++++++++ 7 files changed, 285 insertions(+), 54 deletions(-) rename {controllers/apim/apidefinition => test}/apidefinition_controller_create_test.go (92%) rename {controllers/apim/apidefinition => test}/apidefinition_controller_delete_test.go (91%) rename {controllers/apim/apidefinition => test}/apidefinition_controller_error_test.go (89%) rename {controllers/apim/apidefinition => test}/apidefinition_controller_plan_and_subscription_test.go (94%) rename {controllers/apim/apidefinition => test}/apidefinition_controller_start_stop_test.go (90%) rename {controllers/apim/apidefinition => test}/apidefinition_controller_udpate_test.go (89%) create mode 100644 test/suite_test.go diff --git a/controllers/apim/apidefinition/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go similarity index 92% rename from controllers/apim/apidefinition/apidefinition_controller_create_test.go rename to test/apidefinition_controller_create_test.go index d8d07d0de..fe9853ca7 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package apidefinition +package test import ( "encoding/json" @@ -40,7 +40,6 @@ import ( gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" - "github.com/gravitee-io/gravitee-kubernetes-operator/test" ) var _ = Describe("API Definition Controller", func() { @@ -59,7 +58,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Without a management context") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example.yml") Expect(err).ToNot(HaveOccurred()) apiDefinitionFixture = apiDefinition @@ -83,7 +82,7 @@ var _ = Describe("API Definition Controller", func() { return err == nil && apiDefinition.Status.CrossID != "" }, timeout, interval).Should(BeTrue()) - var endpoint = test.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path expectedApiName := apiDefinitionFixture.Spec.Name Expect(apiDefinition.Spec.Name).Should(Equal(expectedApiName)) @@ -104,11 +103,11 @@ var _ = Describe("API Definition Controller", func() { var contextLookupKey types.NamespacedName BeforeEach(func() { - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) apiDefinitionFixture = apiDefinition @@ -146,7 +145,7 @@ var _ = Describe("API Definition Controller", func() { By("Call gateway endpoint and expect the API to be available") - var endpoint = test.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpoint) @@ -196,7 +195,7 @@ var _ = Describe("API Definition Controller", func() { By("Call gateway endpoint and expect the API not to be available") - var endpoint = test.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpoint) @@ -262,7 +261,7 @@ var _ = Describe("API Definition Controller", func() { By("Call gateway endpoint and expect the API to be available") - var endpoint = test.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpoint) diff --git a/controllers/apim/apidefinition/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go similarity index 91% rename from controllers/apim/apidefinition/apidefinition_controller_delete_test.go rename to test/apidefinition_controller_delete_test.go index 73f2fcaf0..7bf8dfbf8 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package apidefinition +package test import ( "net/http" @@ -39,7 +39,6 @@ import ( "k8s.io/apimachinery/pkg/types" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - "github.com/gravitee-io/gravitee-kubernetes-operator/test" ) var _ = Describe("API Definition Controller", func() { @@ -53,13 +52,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -84,7 +83,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var gatewayEndpoint = test.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var gatewayEndpoint = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) @@ -138,7 +137,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var gatewayEndpoint = test.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var gatewayEndpoint = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) diff --git a/controllers/apim/apidefinition/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go similarity index 89% rename from controllers/apim/apidefinition/apidefinition_controller_error_test.go rename to test/apidefinition_controller_error_test.go index 1da81f1d0..95018fdb7 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -25,17 +25,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package apidefinition +package test import ( + "net/http" + "time" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" k8sUtil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + managementApi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/pkg/keys" - "github.com/gravitee-io/gravitee-kubernetes-operator/test" ) var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("DisableSmokeExpect"), func() { @@ -50,13 +53,13 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -109,12 +112,12 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable err = k8sClient.Update(ctx, managementContextRight) Expect(err).ToNot(HaveOccurred()) - By("Update the API definition") - // TODO: find a way to reconcile the API definition when management context is updated ? - apiDefinition = savedApiDefinition.DeepCopy() - apiDefinition.Spec.Name = "new-name-v2" - err = k8sClient.Update(ctx, apiDefinition) - Expect(err).ToNot(HaveOccurred()) + httpClient := http.Client{Timeout: 5 * time.Second} + apimClient := managementApi.NewClient(ctx, managementContextFixture, httpClient) + Eventually(func() bool { + api, apiErr := apimClient.GetByCrossId(apiDefinition.Status.CrossID) + return apiErr == nil && api.Name == "new-name" && api.Id == apiDefinition.Status.ID + }, timeout, interval).Should(BeTrue()) By("Check API definition processing status") Eventually(func() bool { diff --git a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go similarity index 94% rename from controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go rename to test/apidefinition_controller_plan_and_subscription_test.go index d98867b9d..21f712957 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package apidefinition +package test import ( "net/http" @@ -42,7 +42,6 @@ import ( managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" managementapimodel "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/model" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" - "github.com/gravitee-io/gravitee-kubernetes-operator/test" ) var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { @@ -62,13 +61,13 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { BeforeAll(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/apikey-example-with-ctx.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/apikey-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -83,7 +82,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { return k8sErr == nil && savedApiDefinition.Status.CrossID != "" }, timeout, interval).Should(BeTrue()) - gatewayEndpoint = test.GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path + gatewayEndpoint = GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path mgmtClient = managementapi.NewClient(ctx, managementContextFixture, httpClient) }) @@ -137,7 +136,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { // Update savedApiDefinition & global var with last Get savedApiDefinition = updatedApiDefinition.DeepCopy() - gatewayEndpoint = test.GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path + gatewayEndpoint = GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path By("Update ApiDefinition add ApiKey plan") diff --git a/controllers/apim/apidefinition/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go similarity index 90% rename from controllers/apim/apidefinition/apidefinition_controller_start_stop_test.go rename to test/apidefinition_controller_start_stop_test.go index 059f88800..e0d8c16b1 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package apidefinition +package test import ( "net/http" @@ -37,7 +37,6 @@ import ( gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" - "github.com/gravitee-io/gravitee-kubernetes-operator/test" ) var _ = Describe("API Definition Controller", func() { @@ -51,13 +50,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -82,7 +81,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var gatewayEndpoint = test.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var gatewayEndpoint = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) diff --git a/controllers/apim/apidefinition/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go similarity index 89% rename from controllers/apim/apidefinition/apidefinition_controller_udpate_test.go rename to test/apidefinition_controller_udpate_test.go index dd739e720..0a7d898a4 100644 --- a/controllers/apim/apidefinition/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package apidefinition +package test import ( "net/http" @@ -38,7 +38,6 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" - "github.com/gravitee-io/gravitee-kubernetes-operator/test" ) var _ = Describe("API Definition Controller", func() { @@ -52,7 +51,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create an API definition resource without a management context") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -75,7 +74,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var endpointInitial = test.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpointInitial = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpointInitial) @@ -94,7 +93,7 @@ var _ = Describe("API Definition Controller", func() { By("Call updated API definition URL and expect no error") - var endpointUpdated = test.GatewayUrl + expectedPath + var endpointUpdated = GatewayUrl + expectedPath Eventually(func() bool { res, callErr := httpClient.Get(endpointUpdated) @@ -118,14 +117,14 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource without a management context") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -149,7 +148,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var endpointInitial = test.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpointInitial = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpointInitial) @@ -170,7 +169,7 @@ var _ = Describe("API Definition Controller", func() { By("Call updated API definition URL and expect no error") - var endpointUpdated = test.GatewayUrl + expectedPath + var endpointUpdated = GatewayUrl + expectedPath Eventually(func() bool { res, callErr := httpClient.Get(endpointUpdated) @@ -197,14 +196,14 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := test.NewManagementContext( - "../../../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := NewManagementContext( + "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource without a management context") - apiDefinition, err := test.NewApiDefinition("../../../config/samples/apim/basic-example.yml") + apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) diff --git a/test/suite_test.go b/test/suite_test.go new file mode 100644 index 000000000..0d63e98b6 --- /dev/null +++ b/test/suite_test.go @@ -0,0 +1,233 @@ +/* +Copyright 2022 DAVID BRASSELY. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package test + +import ( + "context" + "strings" + "testing" + "time" + + . "github.com/onsi/ginkgo/v2" + ginkgotypes "github.com/onsi/ginkgo/v2/types" + . "github.com/onsi/gomega" + v1 "k8s.io/api/core/v1" + k8sErr "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/kubernetes/scheme" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + + "github.com/onsi/gomega/gexec" + + gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/apidefinition" + "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/managementcontext" + //+kubebuilder:scaffold:imports +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var k8sClient client.Client +var k8sManager ctrl.Manager +var ctx = context.Background() + +// Define utility constants for object names and testing timeouts/durations and intervals. +const ( + metricsAddr = ":10000" + probeAddr = ":10001" + managerPort = 10002 + + namespace = "default" + timeout = time.Second * 30 + interval = time.Millisecond * 250 +) + +func TestAPIs(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecs(t, "GKO Controllers Suite") +} + +var _ = BeforeSuite(func() { + logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + + err := gio.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + //+kubebuilder:scaffold:scheme + + k8sManager, err = ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme.Scheme, + Port: managerPort, + MetricsBindAddress: metricsAddr, + HealthProbeBindAddress: probeAddr, + }) + + Expect(err).ToNot(HaveOccurred()) + + err = addEventIndexes() + + Expect(err).ToNot(HaveOccurred()) + + err = (&apidefinition.Reconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("apidefinition_controller"), + }).SetupWithManager(k8sManager) + + Expect(err).ToNot(HaveOccurred()) + + err = (&managementcontext.Reconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + }).SetupWithManager(k8sManager) + + Expect(err).ToNot(HaveOccurred()) + + cache := k8sManager.GetCache() + + err = cache.IndexField(ctx, &gio.ApiDefinition{}, "spec.contextRef.name", func(obj client.Object) []string { + api, ok := obj.(*gio.ApiDefinition) + if !ok || api.Spec.Context == nil { + return []string{} + } + return []string{api.Spec.Context.Name} + }) + + Expect(err).ToNot(HaveOccurred()) + + err = cache.IndexField(ctx, &gio.ApiDefinition{}, "spec.contextRef.namespace", func(obj client.Object) []string { + api, ok := obj.(*gio.ApiDefinition) + if !ok || api.Spec.Context == nil { + return []string{} + } + return []string{api.Spec.Context.Namespace} + }) + + Expect(err).ToNot(HaveOccurred()) + + err = cache.IndexField(ctx, &gio.ApiDefinition{}, "status.processingStatus", func(obj client.Object) []string { + api, ok := obj.(*gio.ApiDefinition) + if !ok { + return []string{} + } + return []string{string(api.Status.ProcessingStatus)} + }) + + Expect(err).ToNot(HaveOccurred()) + + go func() { + err = k8sManager.Start(ctrl.SetupSignalHandler()) + Expect(err).ToNot(HaveOccurred()) + }() + + k8sClient = k8sManager.GetClient() + + Expect(k8sClient).ToNot(BeNil()) + +}) + +var _ = AfterSuite(func() { + By("tearing down the test environment") + gexec.KillAndWait(5 * time.Second) + // err := testEnv.Stop() + // Expect(err).ToNot(HaveOccurred()) +}) + +var _ = ReportAfterEach(func(specReport ginkgotypes.SpecReport) { + enableDSmokeExpect := true + for _, label := range specReport.Labels() { + if label == "DisableSmokeExpect" { + enableDSmokeExpect = false + } + } + + if enableDSmokeExpect { + // Smoke test to check there was no unwanted error in the operator's logs. masked by a reconcile for example + Expect( + strings.Contains(specReport.CapturedGinkgoWriterOutput, "\tERROR\t"), + ).To( + BeFalse(), "[Smoke Test] There are errors in the operator logs", + ) + } +}) + +func cleanupApiDefinitionAndManagementContext( + apiDefinition *gio.ApiDefinition, + managementContext *gio.ManagementContext, +) { + cleanupApiDefinition(apiDefinition) + + contextLookupKey := types.NamespacedName{Name: managementContext.Name, Namespace: managementContext.Namespace} + + err := k8sClient.Delete(ctx, managementContext) + if !k8sErr.IsNotFound(err) { + // wait deleted only if not already deleted + Eventually(func() error { + return k8sClient.Get(ctx, contextLookupKey, managementContext) + }, timeout, interval).ShouldNot(Succeed()) + } +} + +// Add filed indexes for event to be able to filter on it. +func addEventIndexes() error { + err := k8sManager.GetFieldIndexer().IndexField( + ctx, + &v1.Event{}, + "involvedObject.name", + func(rawObj client.Object) []string { + event, _ := rawObj.(*v1.Event) + return []string{event.InvolvedObject.Name} + }, + ) + return err +} + +func cleanupApiDefinition(apiDefinition *gio.ApiDefinition) { + apiLookupKey := types.NamespacedName{Name: apiDefinition.Name, Namespace: apiDefinition.Namespace} + + err := k8sClient.Delete(ctx, apiDefinition) + if !k8sErr.IsNotFound(err) { + // wait deleted only if not already deleted + Eventually(func() error { + return k8sClient.Get(ctx, apiLookupKey, apiDefinition) + }, timeout, interval).ShouldNot(Succeed()) + } +} + +func getEventsReason(apiDefinition *gio.ApiDefinition) []string { + eventsReason := []string{} + + events := &v1.EventList{} + + err := k8sClient.List( + ctx, + events, + &client.ListOptions{Namespace: apiDefinition.GetNamespace()}, + client.MatchingFields{"involvedObject.name": apiDefinition.GetName()}, + ) + Expect(err).ToNot(HaveOccurred()) + + for _, event := range events.Items { + eventsReason = append(eventsReason, event.Reason) + } + return eventsReason +} From 43276ce640bf2774b99d5edbd381e637c94cb908 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 27 Oct 2022 14:34:34 +0200 Subject: [PATCH 23/54] fix: reconcile api resources on context updates --- api/model/api.go | 10 +- api/model/context.go | 11 - api/model/context_test.go | 133 ------------ api/v1alpha1/apidefinition_types.go | 2 +- .../crd/bases/gravitee.io_apidefinitions.yaml | 4 - .../apim/apidefinition/internal/update.go | 20 +- controllers/apim/apidefinition/suite_test.go | 192 ------------------ .../managementcontext_controller.go | 52 ++++- docs/api/reference.md | 12 +- .../apim/managementapi/api_subscription.go | 4 +- internal/apim/managementapi/apis.go | 10 +- internal/apim/managementapi/applications.go | 2 +- internal/apim/managementapi/managementapi.go | 16 +- main.go | 53 ++++- test/apidefinition_controller_error_test.go | 2 + 15 files changed, 146 insertions(+), 377 deletions(-) delete mode 100644 api/model/context_test.go delete mode 100644 controllers/apim/apidefinition/suite_test.go diff --git a/api/model/api.go b/api/model/api.go index 959b1ea77..0f9f064bf 100644 --- a/api/model/api.go +++ b/api/model/api.go @@ -32,7 +32,8 @@ type Api struct { // +kubebuilder:default:=`2.0.0` DefinitionVersion DefinitionVersion `json:"gravitee,omitempty"` // +kubebuilder:default:=`STARTED` - State State `json:"state,omitempty"` + // +kubebuilder:validation:Enum=STARTED;STOPPED; + State string `json:"state,omitempty"` // +kubebuilder:default:=`CREATED` LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` // +kubebuilder:validation:Required @@ -75,12 +76,9 @@ const ( // +kubebuilder:validation:Enum=CREATED;PUBLISHED;UNPUBLISHED;DEPRECATED;ARCHIVED; type LifecycleState string -// +kubebuilder:validation:Enum=STARTED;STOPPED; -type State string - const ( - StateStarted State = "STARTED" - StateStopped State = "STOPPED" + StateStarted string = "STARTED" + StateStopped string = "STOPPED" ) type Resource struct { diff --git a/api/model/context.go b/api/model/context.go index 021f651b1..450750061 100644 --- a/api/model/context.go +++ b/api/model/context.go @@ -17,7 +17,6 @@ package model import ( "net/http" - "strings" ) type ContextRef struct { @@ -48,16 +47,6 @@ type BasicAuth struct { Password string `json:"password,omitempty"` } -func (ctx Context) BuildUrl(path string) string { - orgId, envId := ctx.OrgId, ctx.EnvId - baseUrl := strings.TrimSuffix(ctx.BaseUrl, "/") - url := baseUrl + "/management/organizations/" + orgId - if envId != "" { - url = url + "/environments/" + envId - } - return url + path -} - func (ctx Context) Authenticate(req *http.Request) { if ctx.Auth == nil { return diff --git a/api/model/context_test.go b/api/model/context_test.go deleted file mode 100644 index 7ca617d7d..000000000 --- a/api/model/context_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (C) 2015 The Gravitee team (http://gravitee.io) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package model - -import ( - "net/http" - "testing" -) - -func Test_BuildUrl(t *testing.T) { - tests := []struct { - name string - ctx Context - path string - expected string - }{ - { - "With Context with an env and an org ID", - Context{ - BaseUrl: "http://localhost:8083", - EnvId: "DEFAULT", - OrgId: "DEFAULT", - Auth: nil, - }, - "/apis", - "http://localhost:8083/management/organizations/DEFAULT/environments/DEFAULT/apis", - }, - { - "With Context with only an org ID", - Context{ - BaseUrl: "http://localhost:8083", - EnvId: "", - OrgId: "DEFAULT", - Auth: nil, - }, - "/user", - "http://localhost:8083/management/organizations/DEFAULT/user", - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - given := test.ctx.BuildUrl(test.path) - if given != test.expected { - t.Fail() - t.Logf("Expected %s to be %s", given, test.expected) - } - }) - } -} - -func Test_Authenticate(t *testing.T) { - tests := []struct { - name string - ctx Context - expected string - }{ - { - "With basic auth", - Context{ - BaseUrl: "http://localhost:8083", - EnvId: "DEFAULT", - OrgId: "DEFAULT", - Auth: &Auth{ - Credentials: &BasicAuth{ - Username: "admin", - Password: "admin", - }, - }, - }, - "Basic YWRtaW46YWRtaW4=", - }, - { - "With empty credentials", - Context{ - BaseUrl: "http://localhost:8083", - EnvId: "DEFAULT", - OrgId: "DEFAULT", - Auth: &Auth{ - Credentials: &BasicAuth{ - Username: "", - Password: "", - }, - }, - }, - "", - }, - { - "With bearer token", - Context{ - BaseUrl: "http://localhost:8083", - EnvId: "DEFAULT", - OrgId: "DEFAULT", - Auth: &Auth{ - BearerToken: "563c8597-7ec8-4cf2-aee4-97acb22a52c5", - }, - }, - "Bearer 563c8597-7ec8-4cf2-aee4-97acb22a52c5", - }, - { - "With no auth", - Context{ - BaseUrl: "http://localhost:8083", - EnvId: "DEFAULT", - OrgId: "DEFAULT", - Auth: nil, - }, - "", - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - req := &http.Request{Header: make(map[string][]string)} - test.ctx.Authenticate(req) - given := req.Header.Get("Authorization") - if given != test.expected { - t.Fail() - t.Logf("Expected %s to be %s", given, test.expected) - } - }) - } -} diff --git a/api/v1alpha1/apidefinition_types.go b/api/v1alpha1/apidefinition_types.go index c56ea1fd8..006c3c765 100644 --- a/api/v1alpha1/apidefinition_types.go +++ b/api/v1alpha1/apidefinition_types.go @@ -37,7 +37,7 @@ type ApiDefinitionSpec struct { type ApiDefinitionStatus struct { ID string `json:"id"` CrossID string `json:"crossId"` - State model.State `json:"state"` + State string `json:"state,omitempty"` ProcessingStatus ProcessingStatus `json:"processingStatus,omitempty"` ObservedGeneration int64 `json:"generation"` } diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index 0f7fc8a1a..ca2b86d18 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -961,15 +961,11 @@ spec: - Reconciling type: string state: - enum: - - STARTED - - STOPPED type: string required: - crossId - generation - id - - state type: object type: object served: true diff --git a/controllers/apim/apidefinition/internal/update.go b/controllers/apim/apidefinition/internal/update.go index 2ae02adaf..a8ddbf981 100644 --- a/controllers/apim/apidefinition/internal/update.go +++ b/controllers/apim/apidefinition/internal/update.go @@ -22,6 +22,7 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" + "k8s.io/apimachinery/pkg/types" ) func (d *Delegate) CreateOrUpdate( @@ -88,10 +89,21 @@ func (d *Delegate) CreateOrUpdate( } // Creation succeeded, update Status - apiDefinition.Status.ObservedGeneration = apiDefinition.ObjectMeta.Generation - apiDefinition.Status.ProcessingStatus = gio.ProcessingStatusCompleted - apiDefinition.Status.State = apiDefinition.Spec.State - apiDefinition.Status.ID = apiDefinition.Spec.Id + status := apiDefinition.Status.DeepCopy() + status.ObservedGeneration = apiDefinition.ObjectMeta.Generation + status.ProcessingStatus = gio.ProcessingStatusCompleted + status.State = apiDefinition.Spec.State + status.ID = apiDefinition.Spec.Id + + // If reconcile is triggered by a management context update, the status update may result in a conflict error + // For this reason, we need to fetch the last resource version before updating the status + namespacedName := types.NamespacedName{Namespace: apiDefinition.Namespace, Name: apiDefinition.Name} + if err := d.k8sClient.Get(d.ctx, namespacedName, apiDefinition); err != nil { + d.log.Error(err, "Unable to update API definition status (Failed to refresh api definition resource version") + return err + } + + apiDefinition.Status = *status if err := d.k8sClient.Status().Update(d.ctx, apiDefinition.DeepCopy()); err != nil { d.log.Error(err, "Unable to update API definition status") diff --git a/controllers/apim/apidefinition/suite_test.go b/controllers/apim/apidefinition/suite_test.go deleted file mode 100644 index 3250ffc37..000000000 --- a/controllers/apim/apidefinition/suite_test.go +++ /dev/null @@ -1,192 +0,0 @@ -/* -Copyright 2022 DAVID BRASSELY. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package apidefinition - -import ( - "context" - "strings" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - ginkgotypes "github.com/onsi/ginkgo/v2/types" - . "github.com/onsi/gomega" - v1 "k8s.io/api/core/v1" - k8sErr "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/kubernetes/scheme" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - "github.com/onsi/gomega/gexec" - - gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - //+kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var k8sClient client.Client -var k8sManager ctrl.Manager -var ctx = context.Background() - -// Define utility constants for object names and testing timeouts/durations and intervals. -const ( - metricsAddr = ":10000" - probeAddr = ":10001" - managerPort = 10002 - - namespace = "default" - timeout = time.Second * 30 - interval = time.Millisecond * 250 -) - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "GKO Controllers Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - err := gio.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:scheme - - k8sManager, err = ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme.Scheme, - Port: managerPort, - MetricsBindAddress: metricsAddr, - HealthProbeBindAddress: probeAddr, - }) - - Expect(err).ToNot(HaveOccurred()) - - err = addEventIndexes() - - Expect(err).ToNot(HaveOccurred()) - - err = (&Reconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("apidefinition_controller"), - }).SetupWithManager(k8sManager) - - Expect(err).ToNot(HaveOccurred()) - - go func() { - err = k8sManager.Start(ctrl.SetupSignalHandler()) - Expect(err).ToNot(HaveOccurred()) - }() - - k8sClient = k8sManager.GetClient() - - Expect(k8sClient).ToNot(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - gexec.KillAndWait(5 * time.Second) - // err := testEnv.Stop() - // Expect(err).ToNot(HaveOccurred()) -}) - -var _ = ReportAfterEach(func(specReport ginkgotypes.SpecReport) { - enableDSmokeExpect := true - for _, label := range specReport.Labels() { - if label == "DisableSmokeExpect" { - enableDSmokeExpect = false - } - } - - if enableDSmokeExpect { - // Smoke test to check there was no unwanted error in the operator's logs. masked by a reconcile for example - Expect( - strings.Contains(specReport.CapturedGinkgoWriterOutput, "\tERROR\t"), - ).To( - BeFalse(), "[Smoke Test] There are errors in the operator logs", - ) - } -}) - -func cleanupApiDefinitionAndManagementContext( - apiDefinition *gio.ApiDefinition, - managementContext *gio.ManagementContext, -) { - cleanupApiDefinition(apiDefinition) - - contextLookupKey := types.NamespacedName{Name: managementContext.Name, Namespace: managementContext.Namespace} - - err := k8sClient.Delete(ctx, managementContext) - if !k8sErr.IsNotFound(err) { - // wait deleted only if not already deleted - Eventually(func() error { - return k8sClient.Get(ctx, contextLookupKey, managementContext) - }, timeout, interval).ShouldNot(Succeed()) - } -} - -// Add filed indexes for event to be able to filter on it. -func addEventIndexes() error { - err := k8sManager.GetFieldIndexer().IndexField( - ctx, - &v1.Event{}, - "involvedObject.name", - func(rawObj client.Object) []string { - event, _ := rawObj.(*v1.Event) - return []string{event.InvolvedObject.Name} - }, - ) - return err -} - -func cleanupApiDefinition(apiDefinition *gio.ApiDefinition) { - apiLookupKey := types.NamespacedName{Name: apiDefinition.Name, Namespace: apiDefinition.Namespace} - - err := k8sClient.Delete(ctx, apiDefinition) - if !k8sErr.IsNotFound(err) { - // wait deleted only if not already deleted - Eventually(func() error { - return k8sClient.Get(ctx, apiLookupKey, apiDefinition) - }, timeout, interval).ShouldNot(Succeed()) - } -} - -func getEventsReason(apiDefinition *gio.ApiDefinition) []string { - eventsReason := []string{} - - events := &v1.EventList{} - - err := k8sClient.List( - ctx, - events, - &client.ListOptions{Namespace: apiDefinition.GetNamespace()}, - client.MatchingFields{"involvedObject.name": apiDefinition.GetName()}, - ) - Expect(err).ToNot(HaveOccurred()) - - for _, event := range events.Items { - eventsReason = append(eventsReason, event.Reason) - } - return eventsReason -} diff --git a/controllers/apim/managementcontext/managementcontext_controller.go b/controllers/apim/managementcontext/managementcontext_controller.go index 8d1889988..685101de6 100644 --- a/controllers/apim/managementcontext/managementcontext_controller.go +++ b/controllers/apim/managementcontext/managementcontext_controller.go @@ -19,12 +19,13 @@ package managementcontext import ( "context" + "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - graviteeiov1alpha1 "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" ) // Reconciler reconciles a ManagementContext object. @@ -49,8 +50,7 @@ type Reconciler struct { func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := log.FromContext(ctx).WithValues("ManagementContext", req.NamespacedName) - // Fetch the ApiDefinition instance - instance := &graviteeiov1alpha1.ManagementContext{} + instance := &gio.ManagementContext{} if err := r.Get(ctx, req.NamespacedName, instance); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) @@ -58,12 +58,56 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu log.Info("Reconciling ManagementContext instance") + // Update API resources that reference this context and are in a failed state + apis, err := r.listFailedApiDefinitionResources(ctx, instance.Name, instance.Namespace) + if err != nil { + log.Error(err, "unable to list API definitions resources, skipping update") + return ctrl.Result{}, nil + } + + for i := range apis { + api := apis[i] + + api.Status.ProcessingStatus = gio.ProcessingStatusReconciling + + if err = r.Status().Update(ctx, &api); err != nil { + log.Error(err, "unable to update API definition status, skipping update") + } + } + return ctrl.Result{}, nil } +func (r *Reconciler) listFailedApiDefinitionResources( + ctx context.Context, contextName, contextNamespace string, +) ([]gio.ApiDefinition, error) { + log := log.FromContext(ctx) + statusFailed := string(gio.ProcessingStatusFailed) + apiDefinitionList := &gio.ApiDefinitionList{} + + contextNameFilter := &client.ListOptions{ + FieldSelector: fields.SelectorFromSet(fields.Set{"spec.contextRef.name": contextName}), + } + + contextNamespaceFilter := &client.ListOptions{ + FieldSelector: fields.SelectorFromSet(fields.Set{"spec.contextRef.namespace": contextNamespace}), + } + + statusFilter := &client.ListOptions{ + FieldSelector: fields.SelectorFromSet(fields.Set{"status.processingStatus": statusFailed}), + } + + if err := r.Client.List(ctx, apiDefinitionList, contextNameFilter, contextNamespaceFilter, statusFilter); err != nil { + log.Error(err, "unable to list API definitions, skipping update") + return nil, err + } + + return apiDefinitionList.Items, nil +} + // SetupWithManager sets up the controller with the Manager. func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&graviteeiov1alpha1.ManagementContext{}). + For(&gio.ManagementContext{}). Complete(r) } diff --git a/docs/api/reference.md b/docs/api/reference.md index b93009917..51e9d80fd 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -3442,21 +3442,19 @@ ApiDefinitionStatus defines the observed state of ApiDefinition. true - state + processingStatus enum

- Enum: STARTED, STOPPED
+ Enum: Completed, Failed, Reconciling
- true + false - processingStatus - enum + state + string
-
- Enum: Completed, Failed, Reconciling
false diff --git a/internal/apim/managementapi/api_subscription.go b/internal/apim/managementapi/api_subscription.go index a6ceec384..7351e306a 100644 --- a/internal/apim/managementapi/api_subscription.go +++ b/internal/apim/managementapi/api_subscription.go @@ -30,7 +30,7 @@ func (client *Client) SubscribeToPlan( ) (*model.Subscription, error) { queryParams := "?application=" + applicationId + "&plan=" + planId - url := client.buildUrl("/apis/" + apiId + "/subscriptions" + queryParams) + url := client.envUrl + "/apis/" + apiId + "/subscriptions" + queryParams req, err := http.NewRequestWithContext(client.ctx, http.MethodPost, url, nil) if err != nil { @@ -75,7 +75,7 @@ func (client *Client) GetSubscriptionApiKey( req, err := http.NewRequestWithContext( client.ctx, http.MethodGet, - client.buildUrl("/apis/"+apiId+"/subscriptions/"+subscriptionId+"/apikeys"), + client.envUrl+"/apis/"+apiId+"/subscriptions/"+subscriptionId+"/apikeys", nil, ) diff --git a/internal/apim/managementapi/apis.go b/internal/apim/managementapi/apis.go index f8dd4136f..eea7ed5a7 100644 --- a/internal/apim/managementapi/apis.go +++ b/internal/apim/managementapi/apis.go @@ -31,7 +31,7 @@ func (client *Client) GetByCrossId( req, err := http.NewRequestWithContext( client.ctx, http.MethodGet, - client.buildUrl("/apis?crossId="+crossId), + client.envUrl+"/apis?crossId="+crossId, nil, ) @@ -84,7 +84,7 @@ func (client *Client) GetApiById( req, err := http.NewRequestWithContext( client.ctx, http.MethodGet, - client.buildUrl("/apis/"+apiId), + client.envUrl+"/apis/"+apiId, nil, ) @@ -131,7 +131,7 @@ func (client *Client) ImportApi( importHttpMethod string, apiJson []byte, ) (*model.ApiEntity, error) { - url := client.buildUrl("/apis/import?definitionVersion=2.0.0") + url := client.envUrl + "/apis/import?definitionVersion=2.0.0" req, err := http.NewRequestWithContext(client.ctx, importHttpMethod, url, bytes.NewBuffer(apiJson)) if err != nil { @@ -178,7 +178,7 @@ func (client *Client) UpdateApiState( apiId string, action model.Action, ) error { - url := client.buildUrl("/apis/" + apiId + "?action=" + string(action)) + url := client.envUrl + "/apis/" + apiId + "?action=" + string(action) req, err := http.NewRequestWithContext(client.ctx, http.MethodPost, url, nil) if err != nil { return fmt.Errorf("unable to update the api state into the Management API. Action: %s", action) @@ -211,7 +211,7 @@ func (client *Client) UpdateApiState( func (client *Client) DeleteApi( apiId string, ) error { - url := client.buildUrl("/apis/" + apiId + "?closePlans=true") + url := client.envUrl + "/apis/" + apiId + "?closePlans=true" req, err := http.NewRequestWithContext(client.ctx, http.MethodDelete, url, nil) if err != nil { return fmt.Errorf("unable to delete the api into the Management API") diff --git a/internal/apim/managementapi/applications.go b/internal/apim/managementapi/applications.go index 269ebf34e..ab172237f 100644 --- a/internal/apim/managementapi/applications.go +++ b/internal/apim/managementapi/applications.go @@ -30,7 +30,7 @@ func (client *Client) SearchApplications( req, err := http.NewRequestWithContext( client.ctx, http.MethodGet, - client.buildUrl("/applications?status="+status+"&query="+query), + client.envUrl+"/applications?status="+status+"&query="+query, nil, ) diff --git a/internal/apim/managementapi/managementapi.go b/internal/apim/managementapi/managementapi.go index 905bc7f1e..58a9c9928 100644 --- a/internal/apim/managementapi/managementapi.go +++ b/internal/apim/managementapi/managementapi.go @@ -17,14 +17,17 @@ package managementapi import ( "context" "net/http" + "strings" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" ) type Client struct { - ctx context.Context - buildUrl func(string) string - http http.Client + ctx context.Context + baseUrl string + orgUrl string + envUrl string + http http.Client } type AuthenticatedRoundTripper struct { @@ -47,11 +50,14 @@ func (t *AuthenticatedRoundTripper) RoundTrip(req *http.Request) (*http.Response } func NewClient(ctx context.Context, apimCtx *gio.ManagementContext, httpCli http.Client) *Client { - buildUrl := apimCtx.Spec.BuildUrl + baseUrl := strings.TrimSuffix(apimCtx.Spec.BaseUrl, "/") + orgUrl := baseUrl + "/management/organizations/" + apimCtx.Spec.OrgId + envUrl := orgUrl + "/environments/" + apimCtx.Spec.EnvId + authRoundTripper := newAuthenticatedRoundTripper(apimCtx, http.DefaultTransport) httpCli.Transport = authRoundTripper return &Client{ - ctx, buildUrl, httpCli, + ctx, baseUrl, orgUrl, envUrl, httpCli, } } diff --git a/main.go b/main.go index c1fb8c9e8..c918d42de 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "context" "flag" "os" @@ -28,10 +29,11 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - graviteeiov1alpha1 "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" "github.com/gravitee-io/gravitee-kubernetes-operator/controllers" "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/apidefinition" "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/managementcontext" @@ -48,7 +50,7 @@ const managerPort = 9443 func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(graviteeiov1alpha1.AddToScheme(scheme)) + utilruntime.Must(gio.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -77,11 +79,19 @@ func main() { LeaderElection: enableLeaderElection, LeaderElectionID: "24d975d3.gravitee.io", }) + if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) } + err = indexApiDefinitionFields(mgr) + + if err != nil { + setupLog.Error(err, "unable to start manager (Indexing fields in API definition)") + os.Exit(1) + } + if err = (&apidefinition.Reconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -121,3 +131,42 @@ func main() { os.Exit(1) } } + +func indexApiDefinitionFields(manager ctrl.Manager) error { + cache := manager.GetCache() + ctx := context.Background() + + err := cache.IndexField(ctx, &gio.ApiDefinition{}, "spec.contextRef.name", func(obj client.Object) []string { + api, ok := obj.(*gio.ApiDefinition) + if !ok || api.Spec.Context == nil { + return []string{} + } + return []string{api.Spec.Context.Name} + }) + + if err != nil { + return err + } + + err = cache.IndexField(ctx, &gio.ApiDefinition{}, "spec.contextRef.namespace", func(obj client.Object) []string { + api, ok := obj.(*gio.ApiDefinition) + if !ok || api.Spec.Context == nil { + return []string{} + } + return []string{api.Spec.Context.Namespace} + }) + + if err != nil { + return err + } + + err = cache.IndexField(ctx, &gio.ApiDefinition{}, "status.processingStatus", func(obj client.Object) []string { + api, ok := obj.(*gio.ApiDefinition) + if !ok { + return []string{} + } + return []string{string(api.Status.ProcessingStatus)} + }) + + return err +} diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index 95018fdb7..c22d1b110 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -112,6 +112,8 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable err = k8sClient.Update(ctx, managementContextRight) Expect(err).ToNot(HaveOccurred()) + By("Check that API definition has been reconciled on ManagementContext update") + httpClient := http.Client{Timeout: 5 * time.Second} apimClient := managementApi.NewClient(ctx, managementContextFixture, httpClient) Eventually(func() bool { From 8f4e099ce2fd9c4bf699de076f8191f326de17c4 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Thu, 27 Oct 2022 13:39:36 +0000 Subject: [PATCH 24/54] chore(release): 0.1.0-alpha.10 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 650fd6f87..cef95760a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.10](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.9...0.1.0-alpha.10) (2022-10-27) + + +### Bug Fixes + +* reconcile api resources on context updates ([43276ce](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/43276ce640bf2774b99d5edbd381e637c94cb908)) + # [0.1.0-alpha.9](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.8...0.1.0-alpha.9) (2022-10-25) diff --git a/bundle.yml b/bundle.yml index 982a0a02d..ceeaab6a8 100644 --- a/bundle.yml +++ b/bundle.yml @@ -973,15 +973,11 @@ spec: - Reconciling type: string state: - enum: - - STARTED - - STOPPED type: string required: - crossId - generation - id - - state type: object type: object served: true @@ -1366,7 +1362,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.9 + image: graviteeio/kubernetes-operator:0.1.0-alpha.10 imagePullPolicy: Always livenessProbe: httpGet: From bbe475adee1023f7f8fd603342ea69bdc8f84ca7 Mon Sep 17 00:00:00 2001 From: Okhelifi Date: Thu, 27 Oct 2022 15:12:40 +0200 Subject: [PATCH 25/54] fix: add enabled in health check model --- api/model/http.go | 1 + config/crd/bases/gravitee.io_apidefinitions.yaml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/api/model/http.go b/api/model/http.go index bd40a45a2..184f7ac50 100644 --- a/api/model/http.go +++ b/api/model/http.go @@ -116,6 +116,7 @@ func NewStep() *Step { } type HealthCheckService struct { + Enabled bool `json:"enabled,omitempty"` Steps []*Step `json:"steps,omitempty"` Schedule string `json:"schedule,omitempty"` } diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index ca2b86d18..a0fcc4def 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -707,6 +707,8 @@ spec: type: object health-check: properties: + enabled: + type: boolean schedule: type: string steps: @@ -876,6 +878,8 @@ spec: type: object health-check: properties: + enabled: + type: boolean schedule: type: string steps: From 71346fa278f3cf18efffe6e05aab7853369fe998 Mon Sep 17 00:00:00 2001 From: Okhelifi Date: Thu, 27 Oct 2022 15:34:26 +0200 Subject: [PATCH 26/54] fix: change fail over data type --- api/model/http.go | 8 ++------ config/crd/bases/gravitee.io_apidefinitions.yaml | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/api/model/http.go b/api/model/http.go index 184f7ac50..c6a3825c4 100644 --- a/api/model/http.go +++ b/api/model/http.go @@ -176,11 +176,7 @@ func NewLogging() *Logging { } } -type FailoverCase int - -const ( - TIMEOUT FailoverCase = iota -) +type FailoverCase string type Failover struct { MaxAttempts int `json:"maxAttempts,omitempty"` @@ -195,7 +191,7 @@ func NewFailover() *Failover { return &Failover{ MaxAttempts: maxAttempts, RetryTimeout: retryTimeout, - Cases: []FailoverCase{TIMEOUT}, + Cases: []FailoverCase{}, } } diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index a0fcc4def..5d8b71580 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -471,7 +471,7 @@ spec: properties: cases: items: - type: integer + type: string type: array maxAttempts: type: integer From 565d745b27a81c7ccf06cf682a0f7511e93a0666 Mon Sep 17 00:00:00 2001 From: Okhelifi Date: Thu, 27 Oct 2022 17:06:18 +0200 Subject: [PATCH 27/54] fix: align endpoint mapping with apim --- api/model/endpoint.go | 10 +-- api/model/keystore.go | 4 +- api/model/zz_generated.deepcopy.go | 26 +------ .../crd/bases/gravitee.io_apidefinitions.yaml | 77 ++++++++----------- 4 files changed, 42 insertions(+), 75 deletions(-) diff --git a/api/model/endpoint.go b/api/model/endpoint.go index 99dccc994..6d5fbfae7 100644 --- a/api/model/endpoint.go +++ b/api/model/endpoint.go @@ -64,17 +64,16 @@ type HttpEndpoint struct { EndpointType EndpointType `json:"type,omitempty"` Inherit bool `json:"inherit,omitempty"` - HttpProxy *HttpProxy `json:"httpProxy,omitempty"` - HttpClientOptions *HttpClientOptions `json:"httpClientOptions,omitempty"` - HttpClientSslOptions *HttpClientSslOptions `json:"httpClientSslOptions,omitempty"` - Headers map[string]string `json:"headers,omitempty"` + HttpProxy *HttpProxy `json:"proxy,omitempty"` + HttpClientOptions *HttpClientOptions `json:"http,omitempty"` + HttpClientSslOptions *HttpClientSslOptions `json:"ssl,omitempty"` + Headers []HttpHeader `json:"headers,omitempty"` HealthCheck *EndpointHealthCheckService `json:"healthCheck,omitempty"` } type EndpointDiscoveryService struct { Name string `json:"name,omitempty"` Enabled bool `json:"enabled,omitempty"` - Service *Service `json:"-,omitempty"` Provider string `json:"provider,omitempty"` Configuration *GenericStringMap `json:"configuration,omitempty"` } @@ -109,7 +108,6 @@ func NewService() *Service { } type Services struct { - Services map[Service]*Service `json:"-"` EndpointDiscoveryService *EndpointDiscoveryService `json:"discovery,omitempty"` HealthCheckService *HealthCheckService `json:"health-check,omitempty"` DynamicPropertyService *DynamicPropertyService `json:"dynamic-property,omitempty"` diff --git a/api/model/keystore.go b/api/model/keystore.go index f2ed15e48..29e09dc52 100644 --- a/api/model/keystore.go +++ b/api/model/keystore.go @@ -14,10 +14,10 @@ package model -type KeyStoreType int +type KeyStoreType string const ( - PEM KeyStoreType = iota + PEM KeyStoreType = "PEM" PKCS12 JKS ) diff --git a/api/model/zz_generated.deepcopy.go b/api/model/zz_generated.deepcopy.go index 4d77ecc41..bd0b03883 100644 --- a/api/model/zz_generated.deepcopy.go +++ b/api/model/zz_generated.deepcopy.go @@ -322,11 +322,6 @@ func (in *Endpoint) DeepCopy() *Endpoint { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EndpointDiscoveryService) DeepCopyInto(out *EndpointDiscoveryService) { *out = *in - if in.Service != nil { - in, out := &in.Service, &out.Service - *out = new(Service) - **out = **in - } if in.Configuration != nil { in, out := &in.Configuration, &out.Configuration *out = (*in).DeepCopy() @@ -603,10 +598,8 @@ func (in *HttpEndpoint) DeepCopyInto(out *HttpEndpoint) { } if in.Headers != nil { in, out := &in.Headers, &out.Headers - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = make([]HttpHeader, len(*in)) + copy(*out, *in) } if in.HealthCheck != nil { in, out := &in.HealthCheck, &out.HealthCheck @@ -1227,21 +1220,6 @@ func (in *Service) DeepCopy() *Service { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Services) DeepCopyInto(out *Services) { *out = *in - if in.Services != nil { - in, out := &in.Services, &out.Services - *out = make(map[Service]*Service, len(*in)) - for key, val := range *in { - var outVal *Service - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = new(Service) - **out = **in - } - (*out)[key] = outVal - } - } if in.EndpointDiscoveryService != nil { in, out := &in.EndpointDiscoveryService, &out.EndpointDiscoveryService *out = new(EndpointDiscoveryService) diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index 5d8b71580..26cfe13fd 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -490,9 +490,14 @@ spec: backup: type: boolean headers: - additionalProperties: - type: string - type: object + items: + properties: + name: + type: string + value: + type: string + type: object + type: array healthCheck: properties: inherit: @@ -546,7 +551,7 @@ spec: type: object type: array type: object - httpClientOptions: + http: properties: clearTextUpgrade: type: boolean @@ -572,24 +577,12 @@ spec: version: type: string type: object - httpClientSslOptions: - properties: - hostnameVerifier: - type: boolean - keyStore: - properties: - type: - type: integer - type: object - trustAll: - type: boolean - trustStore: - properties: - type: - type: integer - type: object - type: object - httpProxy: + inherit: + type: boolean + name: + description: From Endpoint + type: string + proxy: properties: enabled: type: boolean @@ -606,11 +599,23 @@ spec: username: type: string type: object - inherit: - type: boolean - name: - description: From Endpoint - type: string + ssl: + properties: + hostnameVerifier: + type: boolean + keyStore: + properties: + type: + type: string + type: object + trustAll: + type: boolean + trustStore: + properties: + type: + type: string + type: object + type: object target: type: string tenants: @@ -681,13 +686,6 @@ spec: properties: discovery: properties: - '-': - properties: - enabled: - type: boolean - name: - type: string - type: object configuration: type: object x-kubernetes-preserve-unknown-fields: true @@ -765,14 +763,14 @@ spec: keyStore: properties: type: - type: integer + type: string type: object trustAll: type: boolean trustStore: properties: type: - type: integer + type: string type: object type: object type: object @@ -852,13 +850,6 @@ spec: properties: discovery: properties: - '-': - properties: - enabled: - type: boolean - name: - type: string - type: object configuration: type: object x-kubernetes-preserve-unknown-fields: true From 62323fb3ec11dda95ca2cec708ef2391b1c3eb5d Mon Sep 17 00:00:00 2001 From: Okhelifi Date: Fri, 28 Oct 2022 09:34:51 +0200 Subject: [PATCH 28/54] docs: update reference --- docs/api/reference.md | 280 +++++++++++++++++++----------------------- 1 file changed, 123 insertions(+), 157 deletions(-) diff --git a/docs/api/reference.md b/docs/api/reference.md index 51e9d80fd..ad2bfd11a 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -1435,7 +1435,7 @@ The context is specifying the namespace and the name of a ManagementContext used cases - []integer + []string
@@ -1567,8 +1567,8 @@ The context is specifying the namespace and the name of a ManagementContext used false - headers - map[string]string + headers + []object
@@ -1581,38 +1581,38 @@ The context is specifying the namespace and the name of a ManagementContext used false - httpClientOptions + http object
false - httpClientSslOptions - object + inherit + boolean
false - httpProxy - object + name + string -
+ From Endpoint
false - inherit - boolean + proxy + object
false - name - string + ssl + object - From Endpoint
+
false @@ -1647,6 +1647,40 @@ The context is specifying the namespace and the name of a ManagementContext used +### ApiDefinition.spec.proxy.groups[index].endpoints[index].headers[index] +[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindex) + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
namestring +
+
false
valuestring +
+
false
+ + ### ApiDefinition.spec.proxy.groups[index].endpoints[index].healthCheck [↩ Parent](#apidefinitionspecproxygroupsindexendpointsindex) @@ -1847,7 +1881,7 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.proxy.groups[index].endpoints[index].httpClientOptions +### ApiDefinition.spec.proxy.groups[index].endpoints[index].http [↩ Parent](#apidefinitionspecproxygroupsindexendpointsindex) @@ -1943,7 +1977,7 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.proxy.groups[index].endpoints[index].httpClientSslOptions +### ApiDefinition.spec.proxy.groups[index].endpoints[index].proxy [↩ Parent](#apidefinitionspecproxygroupsindexendpointsindex) @@ -1960,29 +1994,50 @@ The context is specifying the namespace and the name of a ManagementContext used - hostnameVerifier + enabled boolean
false - keyStore - object + host + string
false - trustAll + password + string + +
+ + false + + port + integer + +
+ + false + + type + string + +
+ + false + + useSystemProxy boolean
false - trustStore - object + username + string
@@ -1991,8 +2046,8 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.proxy.groups[index].endpoints[index].httpClientSslOptions.keyStore -[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindexhttpclientssloptions) +### ApiDefinition.spec.proxy.groups[index].endpoints[index].ssl +[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindex) @@ -2008,8 +2063,29 @@ The context is specifying the namespace and the name of a ManagementContext used - type - integer + hostnameVerifier + boolean + +
+ + false + + keyStore + object + +
+ + false + + trustAll + boolean + +
+ + false + + trustStore + object
@@ -2018,8 +2094,8 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.proxy.groups[index].endpoints[index].httpClientSslOptions.trustStore -[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindexhttpclientssloptions) +### ApiDefinition.spec.proxy.groups[index].endpoints[index].ssl.keyStore +[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindexssl) @@ -2036,7 +2112,7 @@ The context is specifying the namespace and the name of a ManagementContext used type - integer + string
@@ -2045,8 +2121,8 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.proxy.groups[index].endpoints[index].httpProxy -[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindex) +### ApiDefinition.spec.proxy.groups[index].endpoints[index].ssl.trustStore +[↩ Parent](#apidefinitionspecproxygroupsindexendpointsindexssl) @@ -2062,54 +2138,12 @@ The context is specifying the namespace and the name of a ManagementContext used - enabled - boolean - -
- - false - - host - string - -
- - false - - password - string - -
- - false - - port - integer - -
- - false - type string
false - - useSystemProxy - boolean - -
- - false - - username - string - -
- - false @@ -2364,13 +2398,6 @@ The context is specifying the namespace and the name of a ManagementContext used - - - object - -
- - false - configuration object @@ -2402,40 +2429,6 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.proxy.groups[index].services.discovery.- -[↩ Parent](#apidefinitionspecproxygroupsindexservicesdiscovery) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
enabledboolean -
-
false
namestring -
-
false
- - ### ApiDefinition.spec.proxy.groups[index].services.dynamic-property [↩ Parent](#apidefinitionspecproxygroupsindexservices) @@ -2487,6 +2480,13 @@ The context is specifying the namespace and the name of a ManagementContext used + enabled + boolean + +
+ + false + schedule string @@ -2729,7 +2729,7 @@ The context is specifying the namespace and the name of a ManagementContext used type - integer + string
@@ -2756,7 +2756,7 @@ The context is specifying the namespace and the name of a ManagementContext used type - integer + string
@@ -3103,13 +3103,6 @@ The context is specifying the namespace and the name of a ManagementContext used - - - object - -
- - false - configuration object @@ -3141,40 +3134,6 @@ The context is specifying the namespace and the name of a ManagementContext used -### ApiDefinition.spec.services.discovery.- -[↩ Parent](#apidefinitionspecservicesdiscovery) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
enabledboolean -
-
false
namestring -
-
false
- - ### ApiDefinition.spec.services.dynamic-property [↩ Parent](#apidefinitionspecservices) @@ -3226,6 +3185,13 @@ The context is specifying the namespace and the name of a ManagementContext used + enabled + boolean + +
+ + false + schedule string From e7f10833e26ccc612ff8d57858161c8b3c479784 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Fri, 28 Oct 2022 08:18:32 +0000 Subject: [PATCH 29/54] chore(release): 0.1.0-alpha.11 [skip ci] --- CHANGELOG.md | 9 ++++++ bundle.yml | 85 +++++++++++++++++++++++++--------------------------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cef95760a..0d75a8b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [0.1.0-alpha.11](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.10...0.1.0-alpha.11) (2022-10-28) + + +### Bug Fixes + +* add enabled in health check model ([bbe475a](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/bbe475adee1023f7f8fd603342ea69bdc8f84ca7)) +* align endpoint mapping with apim ([565d745](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/565d745b27a81c7ccf06cf682a0f7511e93a0666)) +* change fail over data type ([71346fa](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/71346fa278f3cf18efffe6e05aab7853369fe998)) + # [0.1.0-alpha.10](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.9...0.1.0-alpha.10) (2022-10-27) diff --git a/bundle.yml b/bundle.yml index ceeaab6a8..160282c61 100644 --- a/bundle.yml +++ b/bundle.yml @@ -483,7 +483,7 @@ spec: properties: cases: items: - type: integer + type: string type: array maxAttempts: type: integer @@ -502,9 +502,14 @@ spec: backup: type: boolean headers: - additionalProperties: - type: string - type: object + items: + properties: + name: + type: string + value: + type: string + type: object + type: array healthCheck: properties: inherit: @@ -558,7 +563,7 @@ spec: type: object type: array type: object - httpClientOptions: + http: properties: clearTextUpgrade: type: boolean @@ -584,24 +589,12 @@ spec: version: type: string type: object - httpClientSslOptions: - properties: - hostnameVerifier: - type: boolean - keyStore: - properties: - type: - type: integer - type: object - trustAll: - type: boolean - trustStore: - properties: - type: - type: integer - type: object - type: object - httpProxy: + inherit: + type: boolean + name: + description: From Endpoint + type: string + proxy: properties: enabled: type: boolean @@ -618,11 +611,23 @@ spec: username: type: string type: object - inherit: - type: boolean - name: - description: From Endpoint - type: string + ssl: + properties: + hostnameVerifier: + type: boolean + keyStore: + properties: + type: + type: string + type: object + trustAll: + type: boolean + trustStore: + properties: + type: + type: string + type: object + type: object target: type: string tenants: @@ -693,13 +698,6 @@ spec: properties: discovery: properties: - '-': - properties: - enabled: - type: boolean - name: - type: string - type: object configuration: type: object x-kubernetes-preserve-unknown-fields: true @@ -719,6 +717,8 @@ spec: type: object health-check: properties: + enabled: + type: boolean schedule: type: string steps: @@ -775,14 +775,14 @@ spec: keyStore: properties: type: - type: integer + type: string type: object trustAll: type: boolean trustStore: properties: type: - type: integer + type: string type: object type: object type: object @@ -862,13 +862,6 @@ spec: properties: discovery: properties: - '-': - properties: - enabled: - type: boolean - name: - type: string - type: object configuration: type: object x-kubernetes-preserve-unknown-fields: true @@ -888,6 +881,8 @@ spec: type: object health-check: properties: + enabled: + type: boolean schedule: type: string steps: @@ -1362,7 +1357,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.10 + image: graviteeio/kubernetes-operator:0.1.0-alpha.11 imagePullPolicy: Always livenessProbe: httpGet: From b54d9a721d28002c83fe2b72d8bbe04acfc87cba Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 27 Oct 2022 18:10:37 +0200 Subject: [PATCH 30/54] fix: reference secret in context --- api/model/context.go | 27 ++------ api/model/zz_generated.deepcopy.go | 20 ++++++ api/v1alpha1/managementcontext_types.go | 41 ++++++++++++ .../bases/gravitee.io_managementcontexts.yaml | 9 +++ .../dev/managementcontext_secretRef.yaml | 28 ++++++++ .../apidefinition/apidefinition_controller.go | 4 +- .../internal/management_context.go | 64 +++++++++++++++++++ controllers/apim/managementcontext/get.go | 29 +++++++-- docs/api/reference.md | 41 ++++++++++++ internal/apim/managementapi/managementapi.go | 2 +- scripts/k3d.sh | 20 ++++++ test/apidefinition_controller_create_test.go | 2 +- 12 files changed, 255 insertions(+), 32 deletions(-) create mode 100644 config/samples/context/dev/managementcontext_secretRef.yaml create mode 100644 controllers/apim/apidefinition/internal/management_context.go diff --git a/api/model/context.go b/api/model/context.go index 450750061..9c94e6ca8 100644 --- a/api/model/context.go +++ b/api/model/context.go @@ -15,10 +15,6 @@ // +kubebuilder:object:generate=true package model -import ( - "net/http" -) - type ContextRef struct { Name string `json:"name"` Namespace string `json:"namespace,omitempty"` @@ -38,6 +34,7 @@ type Context struct { type Auth struct { BearerToken string `json:"bearerToken,omitempty"` Credentials *BasicAuth `json:"credentials,omitempty"` + SecretRef *SecretRef `json:"secretRef,omitempty"` } type BasicAuth struct { @@ -47,23 +44,7 @@ type BasicAuth struct { Password string `json:"password,omitempty"` } -func (ctx Context) Authenticate(req *http.Request) { - if ctx.Auth == nil { - return - } - - bearerToken := ctx.Auth.BearerToken - if bearerToken != "" { - req.Header.Add("Authorization", "Bearer "+bearerToken) - } else if ctx.Auth.Credentials != nil { - username := ctx.Auth.Credentials.Username - password := ctx.Auth.Credentials.Password - setBasicAuth(req, username, password) - } -} - -func setBasicAuth(request *http.Request, username, password string) { - if username != "" { - request.SetBasicAuth(username, password) - } +type SecretRef struct { + Name string `json:"name"` + Namespace string `json:"namespace,omitempty"` } diff --git a/api/model/zz_generated.deepcopy.go b/api/model/zz_generated.deepcopy.go index bd0b03883..97d6a68c9 100644 --- a/api/model/zz_generated.deepcopy.go +++ b/api/model/zz_generated.deepcopy.go @@ -157,6 +157,11 @@ func (in *Auth) DeepCopyInto(out *Auth) { *out = new(BasicAuth) **out = **in } + if in.SecretRef != nil { + in, out := &in.SecretRef, &out.SecretRef + *out = new(SecretRef) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Auth. @@ -1202,6 +1207,21 @@ func (in *Rule) DeepCopy() *Rule { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecretRef) DeepCopyInto(out *SecretRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretRef. +func (in *SecretRef) DeepCopy() *SecretRef { + if in == nil { + return nil + } + out := new(SecretRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Service) DeepCopyInto(out *Service) { *out = *in diff --git a/api/v1alpha1/managementcontext_types.go b/api/v1alpha1/managementcontext_types.go index 1977199ac..63be6ae96 100644 --- a/api/v1alpha1/managementcontext_types.go +++ b/api/v1alpha1/managementcontext_types.go @@ -17,6 +17,8 @@ package v1alpha1 import ( + "net/http" + "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -57,3 +59,42 @@ type ManagementContextList struct { func init() { SchemeBuilder.Register(&ManagementContext{}, &ManagementContextList{}) } + +func (ctx *ManagementContext) HasAuthentication() bool { + return ctx.Spec.Auth != nil +} + +func (ctx *ManagementContext) HasSecretRef() bool { + if !ctx.HasAuthentication() { + return false + } + + return ctx.Spec.Auth.SecretRef != nil +} + +func (ctx *ManagementContext) Authenticate(req *http.Request) { + if !ctx.HasAuthentication() { + return + } + + bearerToken := ctx.Spec.Auth.BearerToken + basicAuth := ctx.Spec.Auth.Credentials + + if bearerToken != "" { + setBearerToken(req, bearerToken) + } else if basicAuth != nil { + setBasicAuth(req, basicAuth) + } +} + +func setBearerToken(request *http.Request, token string) { + if token != "" { + request.Header.Add("Authorization", "Bearer "+token) + } +} + +func setBasicAuth(request *http.Request, auth *model.BasicAuth) { + if auth != nil && auth.Username != "" { + request.SetBasicAuth(auth.Username, auth.Password) + } +} diff --git a/config/crd/bases/gravitee.io_managementcontexts.yaml b/config/crd/bases/gravitee.io_managementcontexts.yaml index 7bf1ecf23..e4bc69726 100644 --- a/config/crd/bases/gravitee.io_managementcontexts.yaml +++ b/config/crd/bases/gravitee.io_managementcontexts.yaml @@ -56,6 +56,15 @@ spec: username: type: string type: object + secretRef: + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object type: object baseUrl: pattern: ^http(s?):\/\/.+$ diff --git a/config/samples/context/dev/managementcontext_secretRef.yaml b/config/samples/context/dev/managementcontext_secretRef.yaml new file mode 100644 index 000000000..d6d71f5d8 --- /dev/null +++ b/config/samples/context/dev/managementcontext_secretRef.yaml @@ -0,0 +1,28 @@ +# Copyright (C) 2015 The Gravitee team (http://gravitee.io) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use this context if you are running APIM in K3d and GKO locally +apiVersion: gravitee.io/v1alpha1 +kind: ManagementContext +metadata: + name: dev-mgmt-ctx + namespace: default +spec: + baseUrl: http://localhost:9000 + environmentId: DEFAULT + organizationId: DEFAULT + auth: + secretRef: + name: apim-context-credentials + namespace: apim-dev diff --git a/controllers/apim/apidefinition/apidefinition_controller.go b/controllers/apim/apidefinition/apidefinition_controller.go index 12f098d6f..d86d04d4d 100644 --- a/controllers/apim/apidefinition/apidefinition_controller.go +++ b/controllers/apim/apidefinition/apidefinition_controller.go @@ -32,7 +32,6 @@ import ( "github.com/go-logr/logr" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/apidefinition/internal" - "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/managementcontext" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" "github.com/gravitee-io/gravitee-kubernetes-operator/pkg/keys" @@ -91,7 +90,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu event := utils.NewEvent(r.Recorder) if apiDefinition.Spec.Context != nil { - managementContext, ctxErr := managementcontext.Get(ctx, r.Client, log, apiDefinition.Spec.Context) + managementContext, ctxErr := apisDelegate.ResolveContext(apiDefinition.Spec.Context) + if ctxErr != nil { log.Error(ctxErr, "And error has occurred while trying to retrieve ManagementContext") event.NormalEvent( diff --git a/controllers/apim/apidefinition/internal/management_context.go b/controllers/apim/apidefinition/internal/management_context.go new file mode 100644 index 000000000..0528259cc --- /dev/null +++ b/controllers/apim/apidefinition/internal/management_context.go @@ -0,0 +1,64 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" + gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + coreV1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" +) + +const ( + bearerTokenSecretKey = "bearerToken" + usernameSecretKey = "username" + passwordSecretKey = "password" +) + +func (d *Delegate) ResolveContext( + contextRef *model.ContextRef, +) (*gio.ManagementContext, error) { + apimContext := new(gio.ManagementContext) + ns := types.NamespacedName{Name: contextRef.Name, Namespace: contextRef.Namespace} + + d.log.Info("Looking for context from", "namespace", contextRef.Namespace, "name", contextRef.Name) + + if err := d.k8sClient.Get(d.ctx, ns, apimContext); err != nil { + return nil, err + } + + if apimContext.HasSecretRef() { + secret := new(coreV1.Secret) + secretName := apimContext.Spec.Auth.SecretRef.Name + secretNameSpace := apimContext.Spec.Auth.SecretRef.Namespace + secretKey := types.NamespacedName{Name: secretName, Namespace: secretNameSpace} + + if err := d.k8sClient.Get(d.ctx, secretKey, secret); err != nil { + return nil, err + } + + bearerToken := string(secret.Data[bearerTokenSecretKey]) + username := string(secret.Data[usernameSecretKey]) + password := string(secret.Data[passwordSecretKey]) + + apimContext.Spec.Auth.BearerToken = bearerToken + apimContext.Spec.Auth.Credentials = &model.BasicAuth{ + Username: username, + Password: password, + } + } + + return apimContext, nil +} diff --git a/controllers/apim/managementcontext/get.go b/controllers/apim/managementcontext/get.go index 0aa63ff41..bf0d3c9eb 100644 --- a/controllers/apim/managementcontext/get.go +++ b/controllers/apim/managementcontext/get.go @@ -16,10 +16,12 @@ package managementcontext import ( "context" + "fmt" - "github.com/go-logr/logr" + log "github.com/go-logr/logr" "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" + coreV1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -27,7 +29,7 @@ import ( func Get( ctx context.Context, k8sClient client.Client, - log logr.Logger, + log log.Logger, contextRef *model.ContextRef, ) (*gio.ManagementContext, error) { apimContext := new(gio.ManagementContext) @@ -35,11 +37,28 @@ func Get( log.Info("Looking for context from", "namespace", contextRef.Namespace, "name", contextRef.Name) - err := k8sClient.Get(ctx, ns, apimContext) - - if err != nil { + if err := k8sClient.Get(ctx, ns, apimContext); err != nil { return nil, err } + if apimContext.HasSecretRef() { + secret := new(coreV1.Secret) + secretName := apimContext.Spec.Auth.SecretRef.Name + secretNameSpace := apimContext.Spec.Auth.SecretRef.Namespace + secretKey := types.NamespacedName{Name: secretName, Namespace: secretNameSpace} + + if err := k8sClient.Get(ctx, secretKey, secret); err != nil { + return nil, err + } + + bearerToken, ok := secret.StringData["token"] + + if !ok { + return nil, fmt.Errorf("token not found in secret %s/%s", secretNameSpace, secretName) + } + + apimContext.Spec.Auth.BearerToken = bearerToken + } + return apimContext, nil } diff --git a/docs/api/reference.md b/docs/api/reference.md index ad2bfd11a..5aa4fb53c 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -3558,6 +3558,13 @@ ManagementContext represents the configuration for a Management API.
false + + secretRef + object + +
+ + false @@ -3593,4 +3600,38 @@ ManagementContext represents the configuration for a Management API. false + + + +### ManagementContext.spec.auth.secretRef +[↩ Parent](#managementcontextspecauth) + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
namestring +
+
true
namespacestring +
+
false
\ No newline at end of file diff --git a/internal/apim/managementapi/managementapi.go b/internal/apim/managementapi/managementapi.go index 58a9c9928..f7d93bcd5 100644 --- a/internal/apim/managementapi/managementapi.go +++ b/internal/apim/managementapi/managementapi.go @@ -45,7 +45,7 @@ func newAuthenticatedRoundTripper( } func (t *AuthenticatedRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - t.apimCtx.Spec.Authenticate(req) + t.apimCtx.Authenticate(req) return t.transport.RoundTrip(req) } diff --git a/scripts/k3d.sh b/scripts/k3d.sh index a102195ae..217da20ee 100755 --- a/scripts/k3d.sh +++ b/scripts/k3d.sh @@ -36,6 +36,9 @@ K3D_IMAGES_REGISTRY_NAME="${K3D_CLUSTER_NAME}.docker.localhost" K3D_IMAGES_REGISTRY_PORT=12345 K3D_IMAGES_REGISTRY="${K3D_IMAGES_REGISTRY_NAME}:${K3D_IMAGES_REGISTRY_PORT}" +# APIM credentials +APIM_CONTEXT_SECRET_NAME=apim-context-credentials + echo " Installing the latest version of k3d (if not present) ... @@ -134,6 +137,23 @@ echo " kubectl create namespace ${K3D_NAMESPACE_NAME} kubectl config set-context --current --namespace ${K3D_NAMESPACE_NAME} +echo " + + Storing APIM context credentials as a secret ... + + The following declaration can be used in your managament context to reference this secret: + + secretRef: + name: ${APIM_CONTEXT_SECRET_NAME} + namespace: ${K3D_NAMESPACE_NAME} + +" + +kubectl create secret generic ${APIM_CONTEXT_SECRET_NAME} \ + -n ${K3D_NAMESPACE_NAME} \ + --from-literal=username=admin \ + --from-literal=password=admin + echo " Adding Helm repositories (if not presents) ... diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index fe9853ca7..ed3e8f82a 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -104,7 +104,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { managementContext, err := NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + "../config/samples/context/dev/managementcontext_secretRef.yaml") Expect(err).ToNot(HaveOccurred()) apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") From 39c682f2bfd981db8caab4896893df82791efebe Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 28 Oct 2022 11:38:39 +0200 Subject: [PATCH 31/54] refactor: move test fixtures and const to internal --- test/apidefinition_controller_create_test.go | 19 ++++++++++--------- test/apidefinition_controller_delete_test.go | 9 +++++---- test/apidefinition_controller_error_test.go | 5 +++-- ...n_controller_plan_and_subscription_test.go | 9 +++++---- ...pidefinition_controller_start_stop_test.go | 7 ++++--- test/apidefinition_controller_udpate_test.go | 19 ++++++++++--------- test/{ => internal}/constants.go | 2 +- test/{ => internal}/fixtures.go | 2 +- 8 files changed, 39 insertions(+), 33 deletions(-) rename test/{ => internal}/constants.go (97%) rename test/{ => internal}/fixtures.go (99%) diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index ed3e8f82a..e4067a735 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -40,9 +40,10 @@ import ( gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) -var _ = Describe("API Definition Controller", func() { +var _ = FDescribe("API Definition Controller", func() { const ( origin = "kubernetes" mode = "fully_managed" @@ -58,7 +59,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Without a management context") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example.yml") Expect(err).ToNot(HaveOccurred()) apiDefinitionFixture = apiDefinition @@ -82,7 +83,7 @@ var _ = Describe("API Definition Controller", func() { return err == nil && apiDefinition.Status.CrossID != "" }, timeout, interval).Should(BeTrue()) - var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = internal.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path expectedApiName := apiDefinitionFixture.Spec.Name Expect(apiDefinition.Spec.Name).Should(Equal(expectedApiName)) @@ -96,18 +97,18 @@ var _ = Describe("API Definition Controller", func() { }) }) - Context("With basic ApiDefinition & ManagementContext", func() { + FContext("With basic ApiDefinition & ManagementContext", func() { var apiDefinitionFixture *gio.ApiDefinition var managementContextFixture *gio.ManagementContext var apiLookupKey types.NamespacedName var contextLookupKey types.NamespacedName BeforeEach(func() { - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_secretRef.yaml") Expect(err).ToNot(HaveOccurred()) - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) apiDefinitionFixture = apiDefinition @@ -145,7 +146,7 @@ var _ = Describe("API Definition Controller", func() { By("Call gateway endpoint and expect the API to be available") - var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = internal.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpoint) @@ -195,7 +196,7 @@ var _ = Describe("API Definition Controller", func() { By("Call gateway endpoint and expect the API not to be available") - var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = internal.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpoint) @@ -261,7 +262,7 @@ var _ = Describe("API Definition Controller", func() { By("Call gateway endpoint and expect the API to be available") - var endpoint = GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpoint = internal.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpoint) diff --git a/test/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go index 7bf8dfbf8..5bf0be451 100644 --- a/test/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -33,6 +33,7 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" clientError "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" @@ -52,13 +53,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -83,7 +84,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var gatewayEndpoint = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var gatewayEndpoint = internal.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) @@ -137,7 +138,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var gatewayEndpoint = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var gatewayEndpoint = internal.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index c22d1b110..4232a41b1 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -39,6 +39,7 @@ import ( gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementApi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/pkg/keys" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("DisableSmokeExpect"), func() { @@ -53,13 +54,13 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) diff --git a/test/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go index 21f712957..8883a4092 100644 --- a/test/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -32,6 +32,7 @@ import ( "time" clientError "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -61,13 +62,13 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { BeforeAll(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := NewApiDefinition("../config/samples/apim/apikey-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/apikey-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -82,7 +83,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { return k8sErr == nil && savedApiDefinition.Status.CrossID != "" }, timeout, interval).Should(BeTrue()) - gatewayEndpoint = GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path + gatewayEndpoint = internal.GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path mgmtClient = managementapi.NewClient(ctx, managementContextFixture, httpClient) }) @@ -136,7 +137,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { // Update savedApiDefinition & global var with last Get savedApiDefinition = updatedApiDefinition.DeepCopy() - gatewayEndpoint = GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path + gatewayEndpoint = internal.GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path By("Update ApiDefinition add ApiKey plan") diff --git a/test/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go index e0d8c16b1..a0573330f 100644 --- a/test/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -37,6 +37,7 @@ import ( gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) var _ = Describe("API Definition Controller", func() { @@ -50,13 +51,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -81,7 +82,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var gatewayEndpoint = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var gatewayEndpoint = internal.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) diff --git a/test/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go index 0a7d898a4..19a4c0670 100644 --- a/test/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -38,6 +38,7 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) var _ = Describe("API Definition Controller", func() { @@ -51,7 +52,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create an API definition resource without a management context") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -74,7 +75,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var endpointInitial = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpointInitial = internal.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpointInitial) @@ -93,7 +94,7 @@ var _ = Describe("API Definition Controller", func() { By("Call updated API definition URL and expect no error") - var endpointUpdated = GatewayUrl + expectedPath + var endpointUpdated = internal.GatewayUrl + expectedPath Eventually(func() bool { res, callErr := httpClient.Get(endpointUpdated) @@ -117,14 +118,14 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource without a management context") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -148,7 +149,7 @@ var _ = Describe("API Definition Controller", func() { By("Call initial API definition URL and expect no error") // Check created api is callable - var endpointInitial = GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path + var endpointInitial = internal.GatewayUrl + createdApiDefinition.Spec.Proxy.VirtualHosts[0].Path Eventually(func() bool { res, callErr := httpClient.Get(endpointInitial) @@ -169,7 +170,7 @@ var _ = Describe("API Definition Controller", func() { By("Call updated API definition URL and expect no error") - var endpointUpdated = GatewayUrl + expectedPath + var endpointUpdated = internal.GatewayUrl + expectedPath Eventually(func() bool { res, callErr := httpClient.Get(endpointUpdated) @@ -196,14 +197,14 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := NewManagementContext( + managementContext, err := internal.NewManagementContext( "../config/samples/context/dev/managementcontext_credentials.yaml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource without a management context") - apiDefinition, err := NewApiDefinition("../config/samples/apim/basic-example.yml") + apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example.yml") Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) diff --git a/test/constants.go b/test/internal/constants.go similarity index 97% rename from test/constants.go rename to test/internal/constants.go index c77c5e0d9..9176f9789 100644 --- a/test/constants.go +++ b/test/internal/constants.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package test +package internal const ( GatewayUrl = "http://localhost:9000/gateway" diff --git a/test/fixtures.go b/test/internal/fixtures.go similarity index 99% rename from test/fixtures.go rename to test/internal/fixtures.go index 23ed19175..418156840 100644 --- a/test/fixtures.go +++ b/test/internal/fixtures.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package test +package internal import ( "fmt" From 8a944247e628a398a8c23cb044d7072b30cbe4b9 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 28 Oct 2022 12:04:49 +0200 Subject: [PATCH 32/54] refactor: define fixture paths as constants --- controllers/apim/managementcontext/get.go | 64 ------------------- test/apidefinition_controller_create_test.go | 23 ++++--- test/apidefinition_controller_delete_test.go | 18 +++--- test/apidefinition_controller_error_test.go | 19 +++--- ...n_controller_plan_and_subscription_test.go | 13 ++-- ...pidefinition_controller_start_stop_test.go | 12 ++-- test/apidefinition_controller_udpate_test.go | 21 +++--- test/internal/apim.go | 33 ++++++++++ test/internal/constants.go | 12 +++- 9 files changed, 103 insertions(+), 112 deletions(-) delete mode 100644 controllers/apim/managementcontext/get.go create mode 100644 test/internal/apim.go diff --git a/controllers/apim/managementcontext/get.go b/controllers/apim/managementcontext/get.go deleted file mode 100644 index bf0d3c9eb..000000000 --- a/controllers/apim/managementcontext/get.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2015 The Gravitee team (http://gravitee.io) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package managementcontext - -import ( - "context" - "fmt" - - log "github.com/go-logr/logr" - "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" - gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - coreV1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func Get( - ctx context.Context, - k8sClient client.Client, - log log.Logger, - contextRef *model.ContextRef, -) (*gio.ManagementContext, error) { - apimContext := new(gio.ManagementContext) - ns := types.NamespacedName{Name: contextRef.Name, Namespace: contextRef.Namespace} - - log.Info("Looking for context from", "namespace", contextRef.Namespace, "name", contextRef.Name) - - if err := k8sClient.Get(ctx, ns, apimContext); err != nil { - return nil, err - } - - if apimContext.HasSecretRef() { - secret := new(coreV1.Secret) - secretName := apimContext.Spec.Auth.SecretRef.Name - secretNameSpace := apimContext.Spec.Auth.SecretRef.Namespace - secretKey := types.NamespacedName{Name: secretName, Namespace: secretNameSpace} - - if err := k8sClient.Get(ctx, secretKey, secret); err != nil { - return nil, err - } - - bearerToken, ok := secret.StringData["token"] - - if !ok { - return nil, fmt.Errorf("token not found in secret %s/%s", secretNameSpace, secretName) - } - - apimContext.Spec.Auth.BearerToken = bearerToken - } - - return apimContext, nil -} diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index e4067a735..4d46035c9 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -38,12 +38,11 @@ import ( model "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/utils" "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) -var _ = FDescribe("API Definition Controller", func() { +var _ = Describe("API Definition Controller", func() { const ( origin = "kubernetes" mode = "fully_managed" @@ -59,7 +58,7 @@ var _ = FDescribe("API Definition Controller", func() { BeforeEach(func() { By("Without a management context") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) apiDefinitionFixture = apiDefinition @@ -97,18 +96,17 @@ var _ = FDescribe("API Definition Controller", func() { }) }) - FContext("With basic ApiDefinition & ManagementContext", func() { + Context("With basic ApiDefinition & ManagementContext", func() { var apiDefinitionFixture *gio.ApiDefinition var managementContextFixture *gio.ManagementContext var apiLookupKey types.NamespacedName var contextLookupKey types.NamespacedName BeforeEach(func() { - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_secretRef.yaml") + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) Expect(err).ToNot(HaveOccurred()) apiDefinitionFixture = apiDefinition @@ -155,7 +153,9 @@ var _ = FDescribe("API Definition Controller", func() { By("Call rest API and expect one API matching status cross ID") - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { api, apiErr := apimClient.GetByCrossId(apiDefinition.Status.CrossID) return apiErr == nil && api.Id == apiDefinition.Status.ID @@ -205,7 +205,9 @@ var _ = FDescribe("API Definition Controller", func() { By("Call rest API and expect one API matching status cross ID and state STOPPED") - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { api, apiErr := apimClient.GetByCrossId(apiDefinition.Status.CrossID) return apiErr == nil && api.Id == apiDefinition.Status.ID && api.State == "STOPPED" @@ -213,7 +215,8 @@ var _ = FDescribe("API Definition Controller", func() { }) It("Should create an API Definition with existing api in Management Api", func() { - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) By("Init existing api in management api") existingApiSpec := apiDefinitionFixture.Spec.DeepCopy() diff --git a/test/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go index 5bf0be451..80055d3dd 100644 --- a/test/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -31,7 +31,6 @@ import ( "net/http" "time" - "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" clientError "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" . "github.com/onsi/ginkgo/v2" @@ -53,13 +52,12 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -103,7 +101,10 @@ var _ = Describe("API Definition Controller", func() { }, timeout, interval).Should(BeTrue()) By("Call rest API and expect DELETED api") - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { _, apiErr := apimClient.GetApiById(createdApiDefinition.Status.ID) return apiErr != nil && clientError.IsNotFound(apiErr) @@ -128,11 +129,12 @@ var _ = Describe("API Definition Controller", func() { It("Should detect when API has already been deleted", func() { createdApiDefinition := new(gio.ApiDefinition) - managementClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + managementClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) // Expect the API Definition is Ready Eventually(func() bool { - err := k8sClient.Get(ctx, apiLookupKey, createdApiDefinition) + err = k8sClient.Get(ctx, apiLookupKey, createdApiDefinition) return err == nil && createdApiDefinition.Status.CrossID != "" }, timeout, interval).Should(BeTrue()) @@ -150,7 +152,7 @@ var _ = Describe("API Definition Controller", func() { Expect(deleteErr).ToNot(HaveOccurred()) By("Delete the API Definition") - err := k8sClient.Delete(ctx, apiDefinitionFixture) + err = k8sClient.Delete(ctx, apiDefinitionFixture) Expect(err).ToNot(HaveOccurred()) By("Expect that the ConfigMap has been deleted") diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index 4232a41b1..80b7538eb 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -28,16 +28,12 @@ limitations under the License. package test import ( - "net/http" - "time" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" k8sUtil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - managementApi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/pkg/keys" "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) @@ -54,13 +50,14 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -84,7 +81,8 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable By("Set bad credentials in ManagementContext") managementContextBad := managementContextFixture.DeepCopy() - managementContextBad.Spec.Auth.Credentials.Username = "bad-username" + managementContextBad.Spec.Auth.SecretRef = nil + managementContextBad.Spec.Auth.BearerToken = "bad-token" err := k8sClient.Update(ctx, managementContextBad) Expect(err).ToNot(HaveOccurred()) @@ -115,8 +113,9 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable By("Check that API definition has been reconciled on ManagementContext update") - httpClient := http.Client{Timeout: 5 * time.Second} - apimClient := managementApi.NewClient(ctx, managementContextFixture, httpClient) + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { api, apiErr := apimClient.GetByCrossId(apiDefinition.Status.CrossID) return apiErr == nil && api.Name == "new-name" && api.Id == apiDefinition.Status.ID diff --git a/test/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go index 8883a4092..1ab80734f 100644 --- a/test/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -62,13 +62,15 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { BeforeAll(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) + Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/apikey-example-with-ctx.yml") + + apiDefinition, err := internal.NewApiDefinition(internal.ApiKeyApiWithContextFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -77,6 +79,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} By("Expect the API Definition is Ready") + savedApiDefinition = new(gio.ApiDefinition) Eventually(func() bool { k8sErr := k8sClient.Get(ctx, apiLookupKey, savedApiDefinition) @@ -84,7 +87,9 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { }, timeout, interval).Should(BeTrue()) gatewayEndpoint = internal.GatewayUrl + savedApiDefinition.Spec.Proxy.VirtualHosts[0].Path - mgmtClient = managementapi.NewClient(ctx, managementContextFixture, httpClient) + + mgmtClient, err = internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) }) diff --git a/test/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go index a0573330f..9dbc9f7fa 100644 --- a/test/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -36,7 +36,6 @@ import ( "k8s.io/apimachinery/pkg/types" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) @@ -51,13 +50,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) + Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -105,7 +104,10 @@ var _ = Describe("API Definition Controller", func() { }, timeout, interval).Should(BeTrue()) By("Call rest API and expect STOPPED state") - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { api, apiErr := apimClient.GetByCrossId(updatedApiDefinition.Status.CrossID) diff --git a/test/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go index 19a4c0670..12b8ea5c3 100644 --- a/test/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -37,7 +37,6 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" - managementapi "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) @@ -52,7 +51,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create an API definition resource without a management context") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -118,14 +117,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource without a management context") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example-with-ctx.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -179,7 +177,9 @@ var _ = Describe("API Definition Controller", func() { By("Call rest API and expect one API matching status cross ID & updated name") - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { api, apiErr := apimClient.GetByCrossId(updatedApiDefinition.Status.CrossID) return apiErr == nil && @@ -197,14 +197,13 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext( - "../config/samples/context/dev/managementcontext_credentials.yaml") + managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource without a management context") - apiDefinition, err := internal.NewApiDefinition("../config/samples/apim/basic-example.yml") + apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) @@ -239,7 +238,9 @@ var _ = Describe("API Definition Controller", func() { By("Calling rest API, expecting one API matching status ID") - apimClient := managementapi.NewClient(ctx, managementContextFixture, httpClient) + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + Eventually(func() bool { api, apiErr := apimClient.GetByCrossId(updatedApiDefinition.Status.CrossID) return apiErr == nil && api.Id == updatedApiDefinition.Status.ID diff --git a/test/internal/apim.go b/test/internal/apim.go new file mode 100644 index 000000000..cb3475b7f --- /dev/null +++ b/test/internal/apim.go @@ -0,0 +1,33 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "context" + "net/http" + + apim "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi" +) + +func NewApimClient(ctx context.Context) (*apim.Client, error) { + httpClient := http.Client{Timeout: apimClientTimeout} + + context, err := NewManagementContext(contextWithCredentialsFile) + if err != nil { + return nil, err + } + + return apim.NewClient(ctx, context, httpClient), nil +} diff --git a/test/internal/constants.go b/test/internal/constants.go index 9176f9789..9191572c0 100644 --- a/test/internal/constants.go +++ b/test/internal/constants.go @@ -14,6 +14,16 @@ package internal +import "time" + const ( - GatewayUrl = "http://localhost:9000/gateway" + GatewayUrl = "http://localhost:9000/gateway" + SamplesPath = "../config/samples" + ContextWithSecretFile = SamplesPath + "/context/dev/managementcontext_secretRef.yaml" + BasicApiFile = SamplesPath + "/apim/basic-example.yml" + BasicApiWithContextFile = SamplesPath + "/apim/basic-example-with-ctx.yml" + ApiKeyApiWithContextFile = SamplesPath + "/apim/apikey-example-with-ctx.yml" + + contextWithCredentialsFile = SamplesPath + "/context/dev/managementcontext_credentials.yaml" + apimClientTimeout = 5 * time.Second ) From 3907f834212e6de3d1bb6bcee679ba05eba70827 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 28 Oct 2022 15:18:26 +0200 Subject: [PATCH 33/54] refactor: default secret namespace to context one --- .../apim/apidefinition/internal/management_context.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/controllers/apim/apidefinition/internal/management_context.go b/controllers/apim/apidefinition/internal/management_context.go index 0528259cc..919fe8d4b 100644 --- a/controllers/apim/apidefinition/internal/management_context.go +++ b/controllers/apim/apidefinition/internal/management_context.go @@ -42,7 +42,8 @@ func (d *Delegate) ResolveContext( if apimContext.HasSecretRef() { secret := new(coreV1.Secret) secretName := apimContext.Spec.Auth.SecretRef.Name - secretNameSpace := apimContext.Spec.Auth.SecretRef.Namespace + secretNameSpace := getSecretNamespace(apimContext) + secretKey := types.NamespacedName{Name: secretName, Namespace: secretNameSpace} if err := d.k8sClient.Get(d.ctx, secretKey, secret); err != nil { @@ -62,3 +63,10 @@ func (d *Delegate) ResolveContext( return apimContext, nil } + +func getSecretNamespace(apimContext *gio.ManagementContext) string { + if apimContext.Spec.Auth.SecretRef.Namespace != "" { + return apimContext.Spec.Auth.SecretRef.Namespace + } + return apimContext.Namespace +} From 0ac9d4bb6731f980c6dd4c61f7a29e75e211f129 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Fri, 28 Oct 2022 14:29:38 +0000 Subject: [PATCH 34/54] chore(release): 0.1.0-alpha.12 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d75a8b32..4fa57188e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.12](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.11...0.1.0-alpha.12) (2022-10-28) + + +### Bug Fixes + +* reference secret in context ([b54d9a7](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/b54d9a721d28002c83fe2b72d8bbe04acfc87cba)) + # [0.1.0-alpha.11](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.10...0.1.0-alpha.11) (2022-10-28) diff --git a/bundle.yml b/bundle.yml index 160282c61..3570ded5e 100644 --- a/bundle.yml +++ b/bundle.yml @@ -1032,6 +1032,15 @@ spec: username: type: string type: object + secretRef: + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object type: object baseUrl: pattern: ^http(s?):\/\/.+$ @@ -1357,7 +1366,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.11 + image: graviteeio/kubernetes-operator:0.1.0-alpha.12 imagePullPolicy: Always livenessProbe: httpGet: From 3aebf3e99b915790b4b8bb18c605815d0d308976 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 00:41:27 +0000 Subject: [PATCH 35/54] chore(deps): update module github.com/onsi/gomega to v1.23.0 --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 47bd6fa6e..cbbfe3d97 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/onsi/ginkgo/v2 v2.4.0 - github.com/onsi/gomega v1.22.1 + github.com/onsi/gomega v1.23.0 k8s.io/apimachinery v0.25.3 k8s.io/client-go v0.25.3 sigs.k8s.io/controller-runtime v0.13.0 @@ -45,7 +45,7 @@ require ( 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/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/google/uuid v1.1.2 // indirect github.com/imdario/mergo v0.3.12 // indirect diff --git a/go.sum b/go.sum index 0bbbb327e..0508ec244 100644 --- a/go.sum +++ b/go.sum @@ -264,6 +264,8 @@ github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -421,6 +423,8 @@ github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/onsi/gomega v1.22.1 h1:pY8O4lBfsHKZHM/6nrxkhVPUznOlIu3quZcKP/M20KI= github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= +github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= +github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= 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/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= From 814794e1727e6b6c66104f8434648479e1bead70 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Mon, 31 Oct 2022 17:57:01 +0100 Subject: [PATCH 36/54] ci: update go version for machine executor to 1.19.2 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ce1266a2..001bc5597 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,7 +66,7 @@ jobs: steps: - checkout - go/install: - version: '1.18.4' + version: '1.19.2' - go/load-cache - kubernetes/install-kubectl - helm/install-helm-client From 4bd7456472aabe98aad95a7e14260dba42363a23 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Wed, 2 Nov 2022 09:44:22 +0100 Subject: [PATCH 37/54] fix: add rbac marker for secret lists --- bundle.yml | 31 ++++++++++++++----- config/manager/kustomization.yaml | 4 +-- config/rbac/role.yaml | 2 ++ .../apidefinition/apidefinition_controller.go | 2 +- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/bundle.yml b/bundle.yml index 3570ded5e..601c2e590 100644 --- a/bundle.yml +++ b/bundle.yml @@ -68,18 +68,25 @@ spec: description: ApiDefinition is the Schema for the apidefinitions API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: - description: APIDefinition represents the configuration for a single proxied API and it's versions. + description: APIDefinition represents the configuration for a single proxied + API and it's versions. properties: contextRef: - description: The context is specifying the namespace and the name of a ManagementContext used for managing the APIDefinition from the ManagementAPI + description: The context is specifying the namespace and the name + of a ManagementContext used for managing the APIDefinition from + the ManagementAPI properties: name: type: string @@ -111,7 +118,8 @@ spec: - BEST_MATCH type: string flows: - description: Paths map[string][]interface{} `json:"paths,omitempty"` // Different from Java + description: Paths map[string][]interface{} `json:"paths,omitempty"` + // Different from Java items: properties: condition: @@ -1011,15 +1019,20 @@ spec: description: ManagementContext is the Schema for the Management API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: - description: ManagementContext represents the configuration for a Management API. + description: ManagementContext represents the configuration for a Management + API. properties: auth: properties: @@ -1139,6 +1152,8 @@ rules: - secrets verbs: - get + - list + - watch - apiGroups: - gravitee.io resources: diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index bda5572cf..ce0841304 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -26,5 +26,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: controller - newTag: latest + newName: graviteeio/kubernetes-operator + newTag: 0.1.0-alpha.12 diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 2a4cf6070..18fd67158 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -30,6 +30,8 @@ rules: - secrets verbs: - get + - list + - watch - apiGroups: - gravitee.io resources: diff --git a/controllers/apim/apidefinition/apidefinition_controller.go b/controllers/apim/apidefinition/apidefinition_controller.go index d86d04d4d..0a7414a54 100644 --- a/controllers/apim/apidefinition/apidefinition_controller.go +++ b/controllers/apim/apidefinition/apidefinition_controller.go @@ -47,7 +47,7 @@ type Reconciler struct { Recorder record.EventRecorder } -//+kubebuilder:rbac:groups="",resources=secrets,verbs=get +//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch //+kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=gravitee.io,resources=apidefinitions,verbs=get;list;watch;create;update;patch;delete;deletecollection //+kubebuilder:rbac:groups=gravitee.io,resources=apidefinitions/status,verbs=get;update;patch From b3c431b56833e6e6c92d8229cf71520b15acdc09 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Wed, 2 Nov 2022 10:01:45 +0000 Subject: [PATCH 38/54] chore(release): 0.1.0-alpha.13 [skip ci] --- CHANGELOG.md | 7 +++++++ bundle.yml | 31 +++++++++---------------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa57188e..dd38c7690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.1.0-alpha.13](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.12...0.1.0-alpha.13) (2022-11-02) + + +### Bug Fixes + +* add rbac marker for secret lists ([4bd7456](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/4bd7456472aabe98aad95a7e14260dba42363a23)) + # [0.1.0-alpha.12](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.11...0.1.0-alpha.12) (2022-10-28) diff --git a/bundle.yml b/bundle.yml index 601c2e590..62bfe341f 100644 --- a/bundle.yml +++ b/bundle.yml @@ -68,25 +68,18 @@ spec: description: ApiDefinition is the Schema for the apidefinitions API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: - description: APIDefinition represents the configuration for a single proxied - API and it's versions. + description: APIDefinition represents the configuration for a single proxied API and it's versions. properties: contextRef: - description: The context is specifying the namespace and the name - of a ManagementContext used for managing the APIDefinition from - the ManagementAPI + description: The context is specifying the namespace and the name of a ManagementContext used for managing the APIDefinition from the ManagementAPI properties: name: type: string @@ -118,8 +111,7 @@ spec: - BEST_MATCH type: string flows: - description: Paths map[string][]interface{} `json:"paths,omitempty"` - // Different from Java + description: Paths map[string][]interface{} `json:"paths,omitempty"` // Different from Java items: properties: condition: @@ -1019,20 +1011,15 @@ spec: description: ManagementContext is the Schema for the Management API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: - description: ManagementContext represents the configuration for a Management - API. + description: ManagementContext represents the configuration for a Management API. properties: auth: properties: @@ -1381,7 +1368,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.12 + image: graviteeio/kubernetes-operator:0.1.0-alpha.13 imagePullPolicy: Always livenessProbe: httpGet: From 34a7b91581477a3d39556f2faa485f9b39ba487c Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 28 Oct 2022 16:35:52 +0200 Subject: [PATCH 39/54] refactor(tests): make context names random --- test/apidefinition_controller_create_test.go | 11 ++--- test/apidefinition_controller_delete_test.go | 12 +++++- test/apidefinition_controller_error_test.go | 10 +++-- ...n_controller_plan_and_subscription_test.go | 9 +++-- ...pidefinition_controller_start_stop_test.go | 11 +++-- test/apidefinition_controller_udpate_test.go | 24 +++++++---- test/internal/apim.go | 2 +- test/internal/fixtures.go | 40 ++++++++++++++++++- 8 files changed, 93 insertions(+), 26 deletions(-) diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index 4d46035c9..1b38218ea 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -103,14 +103,15 @@ var _ = Describe("API Definition Controller", func() { var contextLookupKey types.NamespacedName BeforeEach(func() { - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) - Expect(err).ToNot(HaveOccurred()) + apiWithContext, err := internal.NewApiWithRandomContext( + internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + ) - apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) Expect(err).ToNot(HaveOccurred()) - apiDefinitionFixture = apiDefinition - managementContextFixture = managementContext + apiDefinitionFixture = apiWithContext.Api + managementContextFixture = apiWithContext.Context + apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} contextLookupKey = types.NamespacedName{Name: managementContextFixture.Name, Namespace: namespace} }) diff --git a/test/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go index 80055d3dd..fa3a594cf 100644 --- a/test/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -52,12 +52,20 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) + + apiWithContext, err := internal.NewApiWithRandomContext( + internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + ) + Expect(err).ToNot(HaveOccurred()) + + apiDefinition := apiWithContext.Api + managementContext := apiWithContext.Context + Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) + Expect(err).ToNot(HaveOccurred()) Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index 80b7538eb..1730a4e95 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -51,14 +51,18 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) + apiWithContext, err := internal.NewApiWithRandomContext( + internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + ) + Expect(err).ToNot(HaveOccurred()) + + managementContext := apiWithContext.Context Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) - Expect(err).ToNot(HaveOccurred()) + apiDefinition := apiWithContext.Api Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition diff --git a/test/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go index 1ab80734f..3beaac30c 100644 --- a/test/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -63,15 +63,18 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { BeforeAll(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) + apiWithContext, err := internal.NewApiWithRandomContext( + internal.ApiKeyApiWithContextFile, internal.ContextWithSecretFile, + ) Expect(err).ToNot(HaveOccurred()) + managementContext := apiWithContext.Context + Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition(internal.ApiKeyApiWithContextFile) - Expect(err).ToNot(HaveOccurred()) + apiDefinition := apiWithContext.Api Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition diff --git a/test/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go index 9dbc9f7fa..4b5068159 100644 --- a/test/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -50,14 +50,19 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) + + apiWithContext, err := internal.NewApiWithRandomContext( + internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + ) + Expect(err).ToNot(HaveOccurred()) + + managementContext := apiWithContext.Context Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) - Expect(err).ToNot(HaveOccurred()) + apiDefinition := apiWithContext.Api Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition diff --git a/test/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go index 12b8ea5c3..7ed31a850 100644 --- a/test/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -117,14 +117,18 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) + apiWithContext, err := internal.NewApiWithRandomContext( + internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + ) + Expect(err).ToNot(HaveOccurred()) + + managementContext := apiWithContext.Context Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) - By("Create an API definition resource without a management context") + By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) - Expect(err).ToNot(HaveOccurred()) + apiDefinition := apiWithContext.Api Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition @@ -197,14 +201,18 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - managementContext, err := internal.NewManagementContext(internal.ContextWithSecretFile) + apiWithContext, err := internal.NewApiWithRandomContext( + internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + ) + Expect(err).ToNot(HaveOccurred()) + + managementContext := apiWithContext.Context Expect(k8sClient.Create(ctx, managementContext)).Should(Succeed()) - By("Create an API definition resource without a management context") + By("Create an API definition resource stared by default") - apiDefinition, err := internal.NewApiDefinition(internal.BasicApiWithContextFile) - Expect(err).ToNot(HaveOccurred()) + apiDefinition := apiWithContext.Api Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition diff --git a/test/internal/apim.go b/test/internal/apim.go index cb3475b7f..f62ed652b 100644 --- a/test/internal/apim.go +++ b/test/internal/apim.go @@ -24,7 +24,7 @@ import ( func NewApimClient(ctx context.Context) (*apim.Client, error) { httpClient := http.Client{Timeout: apimClientTimeout} - context, err := NewManagementContext(contextWithCredentialsFile) + context, err := newManagementContext(contextWithCredentialsFile) if err != nil { return nil, err } diff --git a/test/internal/fixtures.go b/test/internal/fixtures.go index 418156840..3429249ca 100644 --- a/test/internal/fixtures.go +++ b/test/internal/fixtures.go @@ -20,12 +20,18 @@ import ( "k8s.io/client-go/kubernetes/scheme" + "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" uuid "github.com/satori/go.uuid" //nolint:gomodguard // to replace with google implementation ) var decode = scheme.Codecs.UniversalDecoder().Decode +type ApiWithContext struct { + Api *gio.ApiDefinition + Context *gio.ManagementContext +} + func NewApiDefinition(path string, transforms ...func(*gio.ApiDefinition)) (*gio.ApiDefinition, error) { crd, err := os.ReadFile(path) if err != nil { @@ -52,7 +58,39 @@ func NewApiDefinition(path string, transforms ...func(*gio.ApiDefinition)) (*gio return api, nil } -func NewManagementContext(path string, transforms ...func(*gio.ManagementContext)) (*gio.ManagementContext, error) { +func NewApiWithRandomContext( + apiPath string, contextPath string, transforms ...func(*ApiWithContext), +) (*ApiWithContext, error) { + api, err := NewApiDefinition(apiPath) + if err != nil { + return nil, err + } + + ctx, err := newManagementContext(contextPath, func(ctx *gio.ManagementContext) { + ctx.Name += "-" + uuid.NewV4().String()[:7] + api.Spec.Context = &model.ContextRef{ + Name: ctx.Name, + Namespace: ctx.Namespace, + } + }) + + if err != nil { + return nil, err + } + + apiWithContext := &ApiWithContext{ + Api: api, + Context: ctx, + } + + for _, transform := range transforms { + transform(apiWithContext) + } + + return apiWithContext, nil +} + +func newManagementContext(path string, transforms ...func(*gio.ManagementContext)) (*gio.ManagementContext, error) { crd, err := os.ReadFile(path) if err != nil { return nil, err From 81933cb0207704f89586d6a9d2be637212db7d0f Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Sat, 29 Oct 2022 15:07:08 +0200 Subject: [PATCH 40/54] test: delete all resources at once after suite --- test/apidefinition_controller_create_test.go | 8 ----- test/apidefinition_controller_delete_test.go | 6 ---- test/apidefinition_controller_error_test.go | 4 --- ...n_controller_plan_and_subscription_test.go | 6 ---- ...pidefinition_controller_start_stop_test.go | 6 ---- test/apidefinition_controller_udpate_test.go | 14 -------- test/suite_test.go | 35 ++----------------- 7 files changed, 2 insertions(+), 77 deletions(-) diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index 1b38218ea..73a96f72f 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -65,10 +65,6 @@ var _ = Describe("API Definition Controller", func() { apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinition(apiDefinitionFixture) - }) - It("Should create an API Definition", func() { By("Create an API definition resource without a management context") @@ -116,10 +112,6 @@ var _ = Describe("API Definition Controller", func() { contextLookupKey = types.NamespacedName{Name: managementContextFixture.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should create an API Definition", func() { By("Create a management context to synchronize with the REST API") Expect(k8sClient.Create(ctx, managementContextFixture)).Should(Succeed()) diff --git a/test/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go index fa3a594cf..190b2a088 100644 --- a/test/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -46,7 +46,6 @@ var _ = Describe("API Definition Controller", func() { httpClient := http.Client{Timeout: 5 * time.Second} Context("With Started basic ApiDefinition & ManagementContext", func() { - var managementContextFixture *gio.ManagementContext var apiDefinitionFixture *gio.ApiDefinition var apiLookupKey types.NamespacedName @@ -70,14 +69,9 @@ var _ = Describe("API Definition Controller", func() { Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition - managementContextFixture = managementContext apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should Delete an API Definition", func() { createdApiDefinition := new(gio.ApiDefinition) diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index 1730a4e95..e484a3059 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -77,10 +77,6 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable }, timeout, interval).Should(BeTrue()) }) - AfterEach(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should not requeue reconcile with 401 error", func() { By("Set bad credentials in ManagementContext") diff --git a/test/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go index 3beaac30c..7e885fb43 100644 --- a/test/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -50,7 +50,6 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { httpClient := http.Client{Timeout: 5 * time.Second} Context("Checking ApiKey plan and subscription", Ordered, func() { - var managementContextFixture *gio.ManagementContext var apiDefinitionFixture *gio.ApiDefinition var savedApiDefinition *gio.ApiDefinition @@ -78,7 +77,6 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition - managementContextFixture = managementContext apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} By("Expect the API Definition is Ready") @@ -96,10 +94,6 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { }) - AfterAll(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should return unauthorize without subscription", func() { Eventually(func() bool { res, callErr := httpClient.Get(gatewayEndpoint) diff --git a/test/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go index 4b5068159..97d56276d 100644 --- a/test/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -44,7 +44,6 @@ var _ = Describe("API Definition Controller", func() { httpClient := http.Client{Timeout: 5 * time.Second} Context("With Started basic ApiDefinition & ManagementContext", func() { - var managementContextFixture *gio.ManagementContext var apiDefinitionFixture *gio.ApiDefinition var apiLookupKey types.NamespacedName @@ -66,14 +65,9 @@ var _ = Describe("API Definition Controller", func() { Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition - managementContextFixture = managementContext apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should Stop an API Definition", func() { createdApiDefinition := new(gio.ApiDefinition) diff --git a/test/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go index 7ed31a850..7fbb8f03d 100644 --- a/test/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -59,10 +59,6 @@ var _ = Describe("API Definition Controller", func() { apiLookupKey = types.NamespacedName{Name: apiDefinition.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinition(apiDefinitionFixture) - }) - It("Should update an API Definition", func() { createdApiDefinition := new(gio.ApiDefinition) @@ -110,7 +106,6 @@ var _ = Describe("API Definition Controller", func() { }) Context("With basic ApiDefinition & ManagementContext", func() { - var managementContextFixture *gio.ManagementContext var apiDefinitionFixture *gio.ApiDefinition var apiLookupKey types.NamespacedName @@ -132,14 +127,9 @@ var _ = Describe("API Definition Controller", func() { Expect(k8sClient.Create(ctx, apiDefinition)).Should(Succeed()) apiDefinitionFixture = apiDefinition - managementContextFixture = managementContext apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should update an API Definition", func() { createdApiDefinition := new(gio.ApiDefinition) @@ -220,10 +210,6 @@ var _ = Describe("API Definition Controller", func() { apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} }) - AfterEach(func() { - cleanupApiDefinitionAndManagementContext(apiDefinitionFixture, managementContextFixture) - }) - It("Should update an API Definition, adding a management context", func() { createdApiDefinition := new(gio.ApiDefinition) diff --git a/test/suite_test.go b/test/suite_test.go index 0d63e98b6..828f7d4d4 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -26,8 +26,6 @@ import ( ginkgotypes "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" - k8sErr "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -147,9 +145,9 @@ var _ = BeforeSuite(func() { var _ = AfterSuite(func() { By("tearing down the test environment") + Expect(k8sClient.DeleteAllOf(ctx, &gio.ApiDefinition{}, client.InNamespace(namespace))).To(Succeed()) + Expect(k8sClient.DeleteAllOf(ctx, &gio.ManagementContext{}, client.InNamespace(namespace))).To(Succeed()) gexec.KillAndWait(5 * time.Second) - // err := testEnv.Stop() - // Expect(err).ToNot(HaveOccurred()) }) var _ = ReportAfterEach(func(specReport ginkgotypes.SpecReport) { @@ -170,23 +168,6 @@ var _ = ReportAfterEach(func(specReport ginkgotypes.SpecReport) { } }) -func cleanupApiDefinitionAndManagementContext( - apiDefinition *gio.ApiDefinition, - managementContext *gio.ManagementContext, -) { - cleanupApiDefinition(apiDefinition) - - contextLookupKey := types.NamespacedName{Name: managementContext.Name, Namespace: managementContext.Namespace} - - err := k8sClient.Delete(ctx, managementContext) - if !k8sErr.IsNotFound(err) { - // wait deleted only if not already deleted - Eventually(func() error { - return k8sClient.Get(ctx, contextLookupKey, managementContext) - }, timeout, interval).ShouldNot(Succeed()) - } -} - // Add filed indexes for event to be able to filter on it. func addEventIndexes() error { err := k8sManager.GetFieldIndexer().IndexField( @@ -201,18 +182,6 @@ func addEventIndexes() error { return err } -func cleanupApiDefinition(apiDefinition *gio.ApiDefinition) { - apiLookupKey := types.NamespacedName{Name: apiDefinition.Name, Namespace: apiDefinition.Namespace} - - err := k8sClient.Delete(ctx, apiDefinition) - if !k8sErr.IsNotFound(err) { - // wait deleted only if not already deleted - Eventually(func() error { - return k8sClient.Get(ctx, apiLookupKey, apiDefinition) - }, timeout, interval).ShouldNot(Succeed()) - } -} - func getEventsReason(apiDefinition *gio.ApiDefinition) []string { eventsReason := []string{} From 1b29bd367ce23176d1ab4396f57030eaf61b692f Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Tue, 1 Nov 2022 13:48:46 +0100 Subject: [PATCH 41/54] refactor(test): move unit tests to ginkgo --- .../apim/apidefinition/internal/error_test.go | 56 ++----- .../apim/apidefinition/internal/suite_test.go | 27 ++++ .../managementapi/clienterror/errors_test.go | 138 ++++-------------- .../managementapi/clienterror/suite_test.go | 27 ++++ 4 files changed, 99 insertions(+), 149 deletions(-) create mode 100644 controllers/apim/apidefinition/internal/suite_test.go create mode 100644 internal/apim/managementapi/clienterror/suite_test.go diff --git a/controllers/apim/apidefinition/internal/error_test.go b/controllers/apim/apidefinition/internal/error_test.go index 6339b0728..0027057fa 100644 --- a/controllers/apim/apidefinition/internal/error_test.go +++ b/controllers/apim/apidefinition/internal/error_test.go @@ -16,50 +16,22 @@ package internal import ( "fmt" - "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/managementapi/clienterror" ) -func Test_wrapError(t *testing.T) { - tests := []struct { - name string - err error - expected bool - }{ - { - "Should be recoverable with raw error", - fmt.Errorf("raw error"), - true, - }, - { - "Should be recoverable with not found error", - clienterror.NewCrossIdNotFoundError("cross-id"), - true, - }, - { - "Should be recoverable with illegal state error", - clienterror.NewAmbiguousCrossIdError("cross-id", 2), - true, - }, - { - "Should not be recoverable with unauthorized api request error", - clienterror.NewUnauthorizedApiRequestError("api-id"), - false, - }, - { - "Should not be recoverable with unauthorized cross ID request error", - clienterror.NewUnauthorizedCrossIdRequestError("cross-id"), - false, +var _ = Describe("Errors", func() { + DescribeTable("wrap error", + func(given error, expected bool) { + Expect(IsRecoverableError(wrapError(given))).To(Equal(expected)) }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - given := IsRecoverableError(wrapError(test.err)) - if given != test.expected { - t.Fail() - t.Logf("Expected %t to be %t", given, test.expected) - } - }) - } -} + Entry("With raw error", fmt.Errorf("raw error"), true), + Entry("With not found error", clienterror.NewCrossIdNotFoundError("cross-id"), true), + Entry("With illegal state error", clienterror.NewAmbiguousCrossIdError("cross-id", 2), true), + Entry("With unauthorized api request error", clienterror.NewUnauthorizedApiRequestError("api-id"), false), + Entry("With unauthorized cross ID request error", clienterror.NewUnauthorizedCrossIdRequestError("api-id"), false), + ) +}) diff --git a/controllers/apim/apidefinition/internal/suite_test.go b/controllers/apim/apidefinition/internal/suite_test.go new file mode 100644 index 000000000..16c8a8f48 --- /dev/null +++ b/controllers/apim/apidefinition/internal/suite_test.go @@ -0,0 +1,27 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestErrors(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "API definition internal") +} diff --git a/internal/apim/managementapi/clienterror/errors_test.go b/internal/apim/managementapi/clienterror/errors_test.go index 0f9d17637..060e0c6d3 100644 --- a/internal/apim/managementapi/clienterror/errors_test.go +++ b/internal/apim/managementapi/clienterror/errors_test.go @@ -16,114 +16,38 @@ package clienterror import ( "fmt" - "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) -func Test_IsUnauthorizedError(t *testing.T) { - tests := []struct { - name string - err error - expected bool - }{ - { - "Should not be unauthorized with raw error", - fmt.Errorf("raw error"), - false, - }, - { - "Should not be unauthorized with nil error", - nil, - false, - }, - { - "Should be unauthorized with unauthorized API error", - NewUnauthorizedApiRequestError("api-id"), - true, - }, - { - "Should be unauthorized with unauthorized crossId error", - NewUnauthorizedCrossIdRequestError("cross-id"), - true, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - given := IsUnauthorized(test.err) - if given != test.expected { - t.Fail() - t.Logf("Expected %t to be %t", given, test.expected) - } - }) - } -} +var _ = Describe("Client Errors", func() { + DescribeTable("Is Unauthorized", + func(given error, expected bool) { + Expect(IsUnauthorized(given)).To(Equal(expected)) + }, + Entry("With raw error", fmt.Errorf("raw error"), false), + Entry("With nil error", nil, false), + Entry("With unauthorized API error", NewUnauthorizedApiRequestError("api-id"), true), + Entry("With unauthorized cross ID error", NewUnauthorizedCrossIdRequestError("cross-id"), true), + ) -func Test_IsNotFoundError(t *testing.T) { - tests := []struct { - name string - err error - expected bool - }{ - { - "Should not be not found with raw error", - fmt.Errorf("raw error"), - false, - }, - { - "Should not be not found with nil error", - nil, - false, - }, - { - "Should be not found with API error", - NewApiNotFoundError("api-id"), - true, - }, - { - "Should be not found with crossId error", - NewCrossIdNotFoundError("cross-id"), - true, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - given := IsNotFound(test.err) - if given != test.expected { - t.Fail() - t.Logf("Expected %t to be %t", given, test.expected) - } - }) - } -} + DescribeTable("Is Not Found", + func(given error, expected bool) { + Expect(IsNotFound(given)).To(Equal(expected)) + }, + Entry("With raw error", fmt.Errorf("raw error"), false), + Entry("With nil error", nil, false), + Entry("With API not found error", NewApiNotFoundError("api-id"), true), + Entry("With cross ID not found error", NewCrossIdNotFoundError("cross-id"), true), + ) -func Test_IsIllegalStateError(t *testing.T) { - tests := []struct { - name string - err error - expected bool - }{ - { - "Should not be illegal state error with raw error", - fmt.Errorf("raw error"), - false, - }, - { - "Should not be illegal state error not found with nil error", - nil, - false, - }, - { - "Should be illegal state error with ambiguous crossId error", - NewAmbiguousCrossIdError("cross-id", 2), - true, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - given := IsIllegalState(test.err) - if given != test.expected { - t.Fail() - t.Logf("Expected %t to be %t", given, test.expected) - } - }) - } -} + DescribeTable("Is Illegal State", + func(given error, expected bool) { + Expect(IsIllegalState(given)).To(Equal(expected)) + }, + Entry("With raw error", fmt.Errorf("raw error"), false), + Entry("With nil error", nil, false), + Entry("With ambiguous cross ID error", NewAmbiguousCrossIdError("cross-id", 2), true), + ) +}) diff --git a/internal/apim/managementapi/clienterror/suite_test.go b/internal/apim/managementapi/clienterror/suite_test.go new file mode 100644 index 000000000..c7e9995f8 --- /dev/null +++ b/internal/apim/managementapi/clienterror/suite_test.go @@ -0,0 +1,27 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package clienterror + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestErrors(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "APIM client errors") +} From 111cc3e5af9e94e9813f6825b831c84b345f6cd6 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Tue, 1 Nov 2022 13:58:49 +0100 Subject: [PATCH 42/54] ci: run tests with ginkgo cli --- .circleci/config.yml | 8 +- .gitignore | 4 +- Makefile | 14 +- go.mod | 4 +- go.sum | 325 +------------------------------------------ test/suite_test.go | 25 ++-- 6 files changed, 39 insertions(+), 341 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 001bc5597..b08a4ec38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,8 +83,8 @@ jobs: name: Docker login command: echo $AZURE_DOCKER_REGISTRY_PASSWORD | docker login --username $AZURE_DOCKER_REGISTRY_USERNAME --password-stdin graviteeio.azurecr.io - run: - name: Install gotestsum - command: make gotestsum + name: Install ginkgo + command: make ginkgo - run: name: Start APIM using k3d command: | @@ -93,9 +93,9 @@ jobs: make k3d-apim-init - run: name: Run tests - command: GOTESTARGS="--junitfile=/tmp/junit/reports/junit.xml" make test + command: GOTESTARGS="--output-dir=/tmp/junit/reports --junit-report=junit.xml" make test - store_test_results: - path: /tmp/junit + path: /tmp/junit/reports login-to-azure: executor: diff --git a/.gitignore b/.gitignore index 5013dd6ee..27facf77a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ testbin/* # Output of the go coverage tool, specifically when used with LiteIDE *.out +*.out.* +junit.xml # Kubernetes Generated files - skip generated files, except for vendored files @@ -32,4 +34,4 @@ gko-config-default.yml # K8S OLM cache/ -bundle/ \ No newline at end of file +bundle/ diff --git a/Makefile b/Makefile index 74a779f10..366a8dee5 100644 --- a/Makefile +++ b/Makefile @@ -120,9 +120,9 @@ lint-license: addlicense ## Run addlicense lint and fail on error GOTESTARGS ?= "" .PHONY: test -test: manifests generate install## Run tests. +test: manifests generate install ## Run tests. kubectl config use-context k3d-graviteeio - KUBEBUILDER_ASSETS=USE_EXISTING_CLUSTER=true $(GOTESTSUM) $(GOTESTARGS) ./... -timeout 380s -coverprofile cover.out + KUBEBUILDER_ASSETS=USE_EXISTING_CLUSTER=true $(GINKGO) $(GOTESTARGS) -timeout 380s --cover --coverprofile=cover.out ./... .PHONY: k3d-apim-init k3d-apim-init: ## Init APIM locally using k3d @@ -209,7 +209,7 @@ $(LOCALBIN): KUSTOMIZE ?= $(LOCALBIN)/kustomize CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest -GOTESTSUM ?= $(LOCALBIN)/gotestsum +GINKGO ?= $(LOCALBIN)/ginkgo CRDOC ?= $(LOCALBIN)/crdoc GOLANGCILINT ?= $(LOCALBIN)/golangci-lint ADDLICENSE ?= $(LOCALBIN)/addlicense @@ -235,10 +235,10 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest -.PHONY: gotestsum -gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary. -$(GOTESTSUM): $(LOCALBIN) - GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@latest +.PHONY: ginkgo +ginkgo: $(GINKGO) ## Download ginkgo cli locally if necessary. +$(GINKGO): $(LOCALBIN) + GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo@latest .PHONY: crdoc crdoc: $(CRDOC) diff --git a/go.mod b/go.mod index cbbfe3d97..492e3431f 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/gravitee-io/gravitee-kubernetes-operator go 1.19 require ( + github.com/onsi/ginkgo v1.16.5 github.com/onsi/ginkgo/v2 v2.4.0 github.com/onsi/gomega v1.23.0 k8s.io/apimachinery v0.25.3 @@ -13,7 +14,6 @@ require ( require ( github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/emicklei/go-restful v2.9.5+incompatible // indirect github.com/emicklei/go-restful/v3 v3.8.0 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect @@ -37,8 +37,6 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/evanphx/json-patch v4.12.0+incompatible // indirect - github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-logr/logr v1.2.3 github.com/go-logr/zapr v1.2.3 // indirect diff --git a/go.sum b/go.sum index 0508ec244..9872770f1 100644 --- a/go.sum +++ b/go.sum @@ -17,7 +17,6 @@ cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKP cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0 h1:at8Tk2zUz63cLPR0JPWm5vp77pEZmzxEQBEfRKn1VV8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= @@ -35,7 +34,6 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -46,22 +44,17 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= 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/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.18 h1:90Y4srNYrwOtAgVo3ndrQkTYn6kf1Eg/AjTFJ8Is2aM= -github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= github.com/Azure/go-autorest/autorest v0.11.27 h1:F3R3q42aWytozkV8ihzcgMO4OA4cuqr3bNlsEuF6//A= github.com/Azure/go-autorest/autorest v0.11.27/go.mod h1:7l8ybrIdUmGqZMTD0sRtAr8NvbHjfofbf8RSP2q7w7U= -github.com/Azure/go-autorest/autorest/adal v0.9.13 h1:Mp5hbtOePIzM8pJVRa3YLrWWmZtoxRXqUEzCfJt3+/Q= -github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= github.com/Azure/go-autorest/autorest/adal v0.9.18/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ= github.com/Azure/go-autorest/autorest/adal v0.9.20 h1:gJ3E98kMpFB1MFqQCvA1yFab8vthOeD4VlFRQULxahg= github.com/Azure/go-autorest/autorest/adal v0.9.20/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= +github.com/Azure/go-autorest/autorest/mocks v0.4.2 h1:PGN4EDXnuQbojHbU0UWoNvmu9AGVwYHG9/fkDYhtAfw= github.com/Azure/go-autorest/autorest/mocks v0.4.2/go.mod h1:Vy7OitM9Kei0i1Oj+LvyAWMXJHeKH1MVlzFugfVrmyU= github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= @@ -69,8 +62,6 @@ github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUM github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -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.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -82,25 +73,13 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= 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/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/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/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= 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/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= @@ -113,31 +92,11 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -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/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -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.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -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/emicklei/go-restful/v3 v3.8.0 h1:eCZ8ulSerjdAiaNpF7GxXIE7ZCMo1moN1qX+S609eVw= github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -150,22 +109,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m 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.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= -github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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 h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 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/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= -github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= -github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -177,37 +126,29 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 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 v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -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-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -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/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= 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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= 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-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -243,9 +184,6 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -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= @@ -258,12 +196,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -293,45 +227,15 @@ github.com/google/uuid v1.1.2/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/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -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.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.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -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= @@ -342,16 +246,12 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr 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= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -359,28 +259,13 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 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= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -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= @@ -388,63 +273,35 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -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= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 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.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= -github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= -github.com/onsi/ginkgo/v2 v2.1.6 h1:Fx2POJZfKRQcM1pH49qSZiYeu319wji004qX+GDovrU= -github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= -github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= -github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= -github.com/onsi/ginkgo/v2 v2.3.0 h1:kUMoxMoQG3ogk/QWyKh3zibV7BKZ+xBpWil1cTylVqc= -github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= -github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= -github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= -github.com/onsi/gomega v1.22.1 h1:pY8O4lBfsHKZHM/6nrxkhVPUznOlIu3quZcKP/M20KI= -github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= -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/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -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/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= 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_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -452,52 +309,28 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= 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-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= 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= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -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/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/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 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.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -506,30 +339,13 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -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/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 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= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -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.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -537,48 +353,25 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 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/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.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/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= 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.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= -go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -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/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38= golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -616,14 +409,10 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 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= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -654,7 +443,6 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R 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-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -662,14 +450,7 @@ 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-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 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/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -700,12 +481,9 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -719,7 +497,6 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -735,17 +512,16 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -753,7 +529,6 @@ golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/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-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -764,22 +539,12 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs= -golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/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/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -790,39 +555,29 @@ 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/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/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 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= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/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-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= -golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220609170525-579cf78fd858 h1:Dpdu/EMxGMFgq0CeYMh4fazTD2vtlZRYE7wyynxJb9U= golang.org/x/time v0.0.0-20220609170525-579cf78fd858/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-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -842,7 +597,6 @@ golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjs golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -854,6 +608,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -862,11 +617,9 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -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= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= @@ -927,7 +680,6 @@ 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= @@ -939,7 +691,6 @@ 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-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -964,7 +715,6 @@ google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1003,7 +753,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj 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/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= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= @@ -1017,13 +766,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 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/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= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1035,12 +779,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= -gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1048,83 +789,31 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.24.2/go.mod h1:AHqbSkTm6YrQ0ObxjO3Pmp/ubFF/KuM7jU+3khoBsOg= -k8s.io/api v0.24.3 h1:tt55QEmKd6L2k5DP6G/ZzdMQKvG5ro4H4teClqm0sTY= -k8s.io/api v0.24.3/go.mod h1:elGR/XSZrS7z7cSZPzVWaycpJuGIw57j9b95/1PdJNI= -k8s.io/api v0.25.0 h1:H+Q4ma2U/ww0iGB78ijZx6DRByPz6/733jIuFpX70e0= -k8s.io/api v0.25.0/go.mod h1:ttceV1GyV1i1rnmvzT3BST08N6nGt+dudGrquzVQWPk= -k8s.io/api v0.25.1 h1:yL7du50yc93k17nH/Xe9jujAYrcDkI/i5DL1jPz4E3M= -k8s.io/api v0.25.1/go.mod h1:hh4itDvrWSJsmeUc28rIFNri8MatNAAxJjKcQmhX6TU= -k8s.io/api v0.25.2 h1:v6G8RyFcwf0HR5jQGIAYlvtRNrxMJQG1xJzaSeVnIS8= -k8s.io/api v0.25.2/go.mod h1:qP1Rn4sCVFwx/xIhe+we2cwBLTXNcheRyYXwajonhy0= k8s.io/api v0.25.3 h1:Q1v5UFfYe87vi5H7NU0p4RXC26PPMT8KOpr1TLQbCMQ= k8s.io/api v0.25.3/go.mod h1:o42gKscFrEVjHdQnyRenACrMtbuJsVdP+WVjqejfzmI= -k8s.io/apiextensions-apiserver v0.24.2 h1:/4NEQHKlEz1MlaK/wHT5KMKC9UKYz6NZz6JE6ov4G6k= -k8s.io/apiextensions-apiserver v0.24.2/go.mod h1:e5t2GMFVngUEHUd0wuCJzw8YDwZoqZfJiGOW6mm2hLQ= k8s.io/apiextensions-apiserver v0.25.0 h1:CJ9zlyXAbq0FIW8CD7HHyozCMBpDSiH7EdrSTCZcZFY= k8s.io/apiextensions-apiserver v0.25.0/go.mod h1:3pAjZiN4zw7R8aZC5gR0y3/vCkGlAjCazcg1me8iB/E= -k8s.io/apimachinery v0.24.2/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= -k8s.io/apimachinery v0.24.3 h1:hrFiNSA2cBZqllakVYyH/VyEh4B581bQRmqATJSeQTg= -k8s.io/apimachinery v0.24.3/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= -k8s.io/apimachinery v0.25.0 h1:MlP0r6+3XbkUG2itd6vp3oxbtdQLQI94fD5gCS+gnoU= -k8s.io/apimachinery v0.25.0/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0= -k8s.io/apimachinery v0.25.1 h1:t0XrnmCEHVgJlR2arwO8Awp9ylluDic706WePaYCBTI= -k8s.io/apimachinery v0.25.1/go.mod h1:hqqA1X0bsgsxI6dXsJ4HnNTBOmJNxyPp8dw3u2fSHwA= -k8s.io/apimachinery v0.25.2 h1:WbxfAjCx+AeN8Ilp9joWnyJ6xu9OMeS/fsfjK/5zaQs= -k8s.io/apimachinery v0.25.2/go.mod h1:hqqA1X0bsgsxI6dXsJ4HnNTBOmJNxyPp8dw3u2fSHwA= k8s.io/apimachinery v0.25.3 h1:7o9ium4uyUOM76t6aunP0nZuex7gDf8VGwkR5RcJnQc= k8s.io/apimachinery v0.25.3/go.mod h1:jaF9C/iPNM1FuLl7Zuy5b9v+n35HGSh6AQ4HYRkCqwo= -k8s.io/apiserver v0.24.2/go.mod h1:pSuKzr3zV+L+MWqsEo0kHHYwCo77AT5qXbFXP2jbvFI= -k8s.io/client-go v0.24.2/go.mod h1:zg4Xaoo+umDsfCWr4fCnmLEtQXyCNXCvJuSsglNcV30= -k8s.io/client-go v0.24.3 h1:Nl1840+6p4JqkFWEW2LnMKU667BUxw03REfLAVhuKQY= -k8s.io/client-go v0.24.3/go.mod h1:AAovolf5Z9bY1wIg2FZ8LPQlEdKHjLI7ZD4rw920BJw= -k8s.io/client-go v0.25.0 h1:CVWIaCETLMBNiTUta3d5nzRbXvY5Hy9Dpl+VvREpu5E= -k8s.io/client-go v0.25.0/go.mod h1:lxykvypVfKilxhTklov0wz1FoaUZ8X4EwbhS6rpRfN8= -k8s.io/client-go v0.25.1 h1:uFj4AJKtE1/ckcSKz8IhgAuZTdRXZDKev8g387ndD58= -k8s.io/client-go v0.25.1/go.mod h1:rdFWTLV/uj2C74zGbQzOsmXPUtMAjSf7ajil4iJUNKo= -k8s.io/client-go v0.25.2 h1:SUPp9p5CwM0yXGQrwYurw9LWz+YtMwhWd0GqOsSiefo= -k8s.io/client-go v0.25.2/go.mod h1:i7cNU7N+yGQmJkewcRD2+Vuj4iz7b30kI8OcL3horQ4= k8s.io/client-go v0.25.3 h1:oB4Dyl8d6UbfDHD8Bv8evKylzs3BXzzufLiO27xuPs0= k8s.io/client-go v0.25.3/go.mod h1:t39LPczAIMwycjcXkVc+CB+PZV69jQuNx4um5ORDjQA= -k8s.io/code-generator v0.24.2/go.mod h1:dpVhs00hTuTdTY6jvVxvTFCk6gSMrtfRydbhZwHI15w= -k8s.io/component-base v0.24.2 h1:kwpQdoSfbcH+8MPN4tALtajLDfSfYxBDYlXobNWI6OU= -k8s.io/component-base v0.24.2/go.mod h1:ucHwW76dajvQ9B7+zecZAP3BVqvrHoOxm8olHEg0nmM= k8s.io/component-base v0.25.0 h1:haVKlLkPCFZhkcqB6WCvpVxftrg6+FK5x1ZuaIDaQ5Y= k8s.io/component-base v0.25.0/go.mod h1:F2Sumv9CnbBlqrpdf7rKZTmmd2meJq0HizeyY/yAFxk= -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.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc= -k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/klog/v2 v2.70.1 h1:7aaoSdahviPmR+XkS7FyxlkkXs6tHISSG03RxleQAVQ= k8s.io/klog/v2 v2.70.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -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/kube-openapi v0.0.0-20220803162953-67bda5d908f1 h1:MQ8BAZPZlWk3S9K4a9NCkIFQtZShWqoha7snGixVgEA= k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= -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= k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4= k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/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.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= -sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio= -sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0= sigs.k8s.io/controller-runtime v0.13.0 h1:iqa5RNciy7ADWnIc8QxCbOX5FEKVR3uxVxKHRMc2WIQ= sigs.k8s.io/controller-runtime v0.13.0/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= -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/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -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/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/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= diff --git a/test/suite_test.go b/test/suite_test.go index 828f7d4d4..9a489ee45 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -45,7 +45,7 @@ import ( var k8sClient client.Client var k8sManager ctrl.Manager -var ctx = context.Background() +var ctx context.Context // Define utility constants for object names and testing timeouts/durations and intervals. const ( @@ -64,7 +64,9 @@ func TestAPIs(t *testing.T) { RunSpecs(t, "GKO Controllers Suite") } -var _ = BeforeSuite(func() { +var _ = SynchronizedBeforeSuite(func() { + By("Setting up the test environment") + logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) err := gio.AddToScheme(scheme.Scheme) @@ -137,17 +139,24 @@ var _ = BeforeSuite(func() { Expect(err).ToNot(HaveOccurred()) }() - k8sClient = k8sManager.GetClient() - - Expect(k8sClient).ToNot(BeNil()) - +}, func() { + //+kubebuilder:scaffold:scheme + err := gio.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + cli, err := client.New(ctrl.GetConfigOrDie(), client.Options{Scheme: scheme.Scheme}) + Expect(err).ToNot(HaveOccurred()) + k8sClient = cli + ctx = context.Background() }) -var _ = AfterSuite(func() { - By("tearing down the test environment") +var _ = SynchronizedAfterSuite(func() { + By("Tearing down the test environment") + Expect(k8sClient.DeleteAllOf(ctx, &gio.ApiDefinition{}, client.InNamespace(namespace))).To(Succeed()) Expect(k8sClient.DeleteAllOf(ctx, &gio.ManagementContext{}, client.InNamespace(namespace))).To(Succeed()) gexec.KillAndWait(5 * time.Second) +}, func() { + }) var _ = ReportAfterEach(func(specReport ginkgotypes.SpecReport) { From 784abbe631eacfb17ba9961a20dc466ad56b9bd2 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Mon, 31 Oct 2022 17:48:16 +0100 Subject: [PATCH 43/54] refactor: log bad request error messages --- internal/apim/managementapi/apis.go | 2 + .../managementapi/clienterror/bad_request.go | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 internal/apim/managementapi/clienterror/bad_request.go diff --git a/internal/apim/managementapi/apis.go b/internal/apim/managementapi/apis.go index eea7ed5a7..69520d398 100644 --- a/internal/apim/managementapi/apis.go +++ b/internal/apim/managementapi/apis.go @@ -155,6 +155,8 @@ func (client *Client) ImportApi( break case http.StatusUnauthorized: return nil, clienterror.UnauthorizedError{} + case http.StatusBadRequest: + return nil, clienterror.NewBadRequestError(resp) default: return nil, fmt.Errorf("an error as occurred trying to import API definition, HTTP Status: %d ", resp.StatusCode) } diff --git a/internal/apim/managementapi/clienterror/bad_request.go b/internal/apim/managementapi/clienterror/bad_request.go new file mode 100644 index 000000000..2230836c0 --- /dev/null +++ b/internal/apim/managementapi/clienterror/bad_request.go @@ -0,0 +1,59 @@ +// Copyright (C) 2015 The Gravitee team (http://gravitee.io) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package clienterror + +import ( + "encoding/json" + "errors" + "io" + "net/http" +) + +type BadRequestError struct { + Message string `json:"message"` +} + +func (e BadRequestError) Error() string { + if e.Message == "" { + return "BAD REQUEST" + } + return e.Message +} + +func NewBadRequestError(resp *http.Response) BadRequestError { + if resp.Body == nil { + return BadRequestError{} + } + + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + + if err != nil { + return BadRequestError{} + } + + var badRequestErr BadRequestError + + if err = json.Unmarshal(body, &badRequestErr); err != nil { + return BadRequestError{} + } + + return badRequestErr +} + +func IsBadRequest(err error) bool { + return errors.As(err, &BadRequestError{}) +} From c4032eb4090057c6d4aac0ab4cc9b2711db0033a Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Mon, 31 Oct 2022 17:48:28 +0100 Subject: [PATCH 44/54] fix: import api with several endpoint groups --- api/model/endpoint.go | 2 +- .../crd/bases/gravitee.io_apidefinitions.yaml | 4 ++++ docs/api/reference.md | 20 +++++++++---------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api/model/endpoint.go b/api/model/endpoint.go index 6d5fbfae7..4902d6434 100644 --- a/api/model/endpoint.go +++ b/api/model/endpoint.go @@ -73,7 +73,7 @@ type HttpEndpoint struct { type EndpointDiscoveryService struct { Name string `json:"name,omitempty"` - Enabled bool `json:"enabled,omitempty"` + Enabled bool `json:"enabled"` Provider string `json:"provider,omitempty"` Configuration *GenericStringMap `json:"configuration,omitempty"` } diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index 26cfe13fd..f31bfa239 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -695,6 +695,8 @@ spec: type: string provider: type: string + required: + - enabled type: object dynamic-property: properties: @@ -859,6 +861,8 @@ spec: type: string provider: type: string + required: + - enabled type: object dynamic-property: properties: diff --git a/docs/api/reference.md b/docs/api/reference.md index 5aa4fb53c..c9122a54c 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -2398,15 +2398,15 @@ The context is specifying the namespace and the name of a ManagementContext used - configuration - object + enabled + boolean
- false + true - enabled - boolean + configuration + object
@@ -3103,15 +3103,15 @@ The context is specifying the namespace and the name of a ManagementContext used - configuration - object + enabled + boolean
- false + true - enabled - boolean + configuration + object
From a874ac68908f91890956e1077f5a447f68b36cc4 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Wed, 2 Nov 2022 11:37:03 +0100 Subject: [PATCH 45/54] fix: import api with disabled health check --- api/model/http.go | 3 ++- config/crd/bases/gravitee.io_apidefinitions.yaml | 6 ++++++ docs/api/reference.md | 8 ++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/api/model/http.go b/api/model/http.go index c6a3825c4..3aa7e3095 100644 --- a/api/model/http.go +++ b/api/model/http.go @@ -116,7 +116,8 @@ func NewStep() *Step { } type HealthCheckService struct { - Enabled bool `json:"enabled,omitempty"` + // +kubebuilder:default:=false + Enabled bool `json:"enabled"` Steps []*Step `json:"steps,omitempty"` Schedule string `json:"schedule,omitempty"` } diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index f31bfa239..3870d8f9c 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -708,6 +708,7 @@ spec: health-check: properties: enabled: + default: false type: boolean schedule: type: string @@ -756,6 +757,8 @@ spec: type: object type: object type: array + required: + - enabled type: object type: object ssl: @@ -874,6 +877,7 @@ spec: health-check: properties: enabled: + default: false type: boolean schedule: type: string @@ -922,6 +926,8 @@ spec: type: object type: object type: array + required: + - enabled type: object type: object state: diff --git a/docs/api/reference.md b/docs/api/reference.md index c9122a54c..c4cfb213c 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -2484,8 +2484,10 @@ The context is specifying the namespace and the name of a ManagementContext used boolean
+
+ Default: false
- false + true schedule string @@ -3189,8 +3191,10 @@ The context is specifying the namespace and the name of a ManagementContext used boolean
+
+ Default: false
- false + true schedule string From 7179561e64a2114c93031c2326b9b6a0227044c3 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Wed, 2 Nov 2022 11:51:44 +0100 Subject: [PATCH 46/54] fix: import API with logging --- api/model/http.go | 48 ++++---- api/model/zz_generated.deepcopy.go | 48 -------- .../crd/bases/gravitee.io_apidefinitions.yaml | 36 +++--- docs/api/reference.md | 114 ++---------------- 4 files changed, 48 insertions(+), 198 deletions(-) diff --git a/api/model/http.go b/api/model/http.go index 3aa7e3095..1e47728ce 100644 --- a/api/model/http.go +++ b/api/model/http.go @@ -126,40 +126,34 @@ func NewHealthCheckService() *HealthCheckService { return &HealthCheckService{Schedule: "health-check"} } -type LoggingMode struct { - Client bool `json:"client,omitempty"` - Proxy bool `json:"proxy,omitempty"` -} +// +kubebuilder:validation:Enum=NONE;CLIENT;PROXY;CLIENT_PROXY +type LoggingMode string -var ( - NoLoggingMode = LoggingMode{false, false} - ClientMode = LoggingMode{true, false} - ProxyMode = LoggingMode{false, true} - ClientProxyMode = LoggingMode{true, true} +const ( + NoLoggingMode = "NONE" + ClientMode = "CLIENT" + ProxyMode = "PROXY" + ClientProxyMode = "CLIENT_PROXY" ) -type LoggingScope struct { - Request bool `json:"request,omitempty"` - Response bool `json:"response,omitempty"` -} +// +kubebuilder:validation:Enum=NONE;REQUEST;RESPONSE;REQUEST_RESPONSE +type LoggingScope string -var ( - NoLoggingScope = LoggingScope{false, false} - RequestLoggingScope = LoggingScope{true, false} - ResponseLoggingScope = LoggingScope{false, true} - RequestResponseLoggingScope = LoggingScope{true, true} +const ( + NoLoggingScope = "NONE" + RequestLoggingScope = "REQUEST" + ResponseLoggingScope = "RESPONSE" + RequestResponseLoggingScope = "REQUEST_RESPONSE" ) -type LoggingContent struct { - Headers bool `json:"headers,omitempty"` - Payloads bool `json:"payloads,omitempty"` -} +// +kubebuilder:validation:Enum=NONE;HEADERS;PAYLOADS;HEADERS_PAYLOADS +type LoggingContent string -var ( - NoLoggingContent = LoggingContent{false, false} - HeadersLoggingContent = LoggingContent{true, false} - PayloadsLoggingContent = LoggingContent{false, true} - HeadersPayloadsLoggingContent = LoggingContent{true, true} +const ( + NoLoggingContent = "NONE" + HeadersLoggingContent = "HEADERS" + PayloadsLoggingContent = "PAYLOADS" + HeadersPayloadsLoggingContent = "HEADERS_PAYLOADS" ) type Logging struct { diff --git a/api/model/zz_generated.deepcopy.go b/api/model/zz_generated.deepcopy.go index 97d6a68c9..dc2aba4d2 100644 --- a/api/model/zz_generated.deepcopy.go +++ b/api/model/zz_generated.deepcopy.go @@ -716,9 +716,6 @@ func (in *LoadBalancer) DeepCopy() *LoadBalancer { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Logging) DeepCopyInto(out *Logging) { *out = *in - out.Mode = in.Mode - out.Scope = in.Scope - out.Content = in.Content } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Logging. @@ -731,51 +728,6 @@ func (in *Logging) DeepCopy() *Logging { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LoggingContent) DeepCopyInto(out *LoggingContent) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingContent. -func (in *LoggingContent) DeepCopy() *LoggingContent { - if in == nil { - return nil - } - out := new(LoggingContent) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LoggingMode) DeepCopyInto(out *LoggingMode) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingMode. -func (in *LoggingMode) DeepCopy() *LoggingMode { - if in == nil { - return nil - } - out := new(LoggingMode) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LoggingScope) DeepCopyInto(out *LoggingScope) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingScope. -func (in *LoggingScope) DeepCopy() *LoggingScope { - if in == nil { - return nil - } - out := new(LoggingScope) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Member) DeepCopyInto(out *Member) { *out = *in diff --git a/config/crd/bases/gravitee.io_apidefinitions.yaml b/config/crd/bases/gravitee.io_apidefinitions.yaml index 3870d8f9c..f010a270e 100644 --- a/config/crd/bases/gravitee.io_apidefinitions.yaml +++ b/config/crd/bases/gravitee.io_apidefinitions.yaml @@ -785,26 +785,26 @@ spec: condition: type: string content: - properties: - headers: - type: boolean - payloads: - type: boolean - type: object + enum: + - NONE + - HEADERS + - PAYLOADS + - HEADERS_PAYLOADS + type: string mode: - properties: - client: - type: boolean - proxy: - type: boolean - type: object + enum: + - NONE + - CLIENT + - PROXY + - CLIENT_PROXY + type: string scope: - properties: - request: - type: boolean - response: - type: boolean - type: object + enum: + - NONE + - REQUEST + - RESPONSE + - REQUEST_RESPONSE + type: string type: object preserve_host: type: boolean diff --git a/docs/api/reference.md b/docs/api/reference.md index c4cfb213c..c4e41aaf8 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -2791,126 +2791,30 @@ The context is specifying the namespace and the name of a ManagementContext used false - content - object + content + enum
- - false - - mode - object -
+ Enum: NONE, HEADERS, PAYLOADS, HEADERS_PAYLOADS
false - scope - object + mode + enum
- - false - - - - -### ApiDefinition.spec.proxy.logging.content -[↩ Parent](#apidefinitionspecproxylogging) - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
headersboolean
+ Enum: NONE, CLIENT, PROXY, CLIENT_PROXY
false
payloadsboolean -
-
false
- - -### ApiDefinition.spec.proxy.logging.mode -[↩ Parent](#apidefinitionspecproxylogging) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
clientboolean -
-
false
proxyboolean -
-
false
- - -### ApiDefinition.spec.proxy.logging.scope -[↩ Parent](#apidefinitionspecproxylogging) - - - - - - - - - - - - - - - - - + + - - - - - From 28c7acc6d2c1c658d1c10b97eda6426abdb22b36 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Wed, 2 Nov 2022 12:41:48 +0100 Subject: [PATCH 47/54] test: add table test with featured api definitions --- .../samples/apim/api-with-endpoint-groups.yml | 85 +++++++++++++++++++ .../apim/api-with-health-check-disabled.yml | 35 ++++++++ config/samples/apim/api-with-health-check.yml | 44 ++++++++++ ...pidefinition.yaml => api-with-logging.yml} | 21 ++++- test/apidefinition_controller_create_test.go | 83 +++++++++++++++--- test/internal/constants.go | 16 ++-- 6 files changed, 264 insertions(+), 20 deletions(-) create mode 100644 config/samples/apim/api-with-endpoint-groups.yml create mode 100644 config/samples/apim/api-with-health-check-disabled.yml create mode 100644 config/samples/apim/api-with-health-check.yml rename config/samples/apim/{_v1alpha1_apidefinition.yaml => api-with-logging.yml} (62%) diff --git a/config/samples/apim/api-with-endpoint-groups.yml b/config/samples/apim/api-with-endpoint-groups.yml new file mode 100644 index 000000000..5f8827019 --- /dev/null +++ b/config/samples/apim/api-with-endpoint-groups.yml @@ -0,0 +1,85 @@ +# +# Copyright (C) 2015 The Gravitee team (http://gravitee.io) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +apiVersion: gravitee.io/v1alpha1 +kind: ApiDefinition +metadata: + name: with-endpoint-groups + namespace: default +spec: + name: "With endpoint groups" + version: "1.0" + description: "API with endpoint groups and failover" + proxy: + virtual_hosts: + - path: "/with-endpoint-groups" + strip_context_path: false + preserve_host: false + groups: + - name: "default-group" + endpoints: + - backup: false + inherit: true + name: "default-primary" + weight: 1 + type: "http" + target: "https://api.gravitee.io/echo" + - backup: true + inherit: true + name: "default-secondary" + weight: 1 + type: "http" + target: "https://api.gravitee.io/echo" + load_balancing: + type: "ROUND_ROBIN" + http: + connectTimeout: 5000 + idleTimeout: 60000 + keepAlive: true + readTimeout: 10000 + pipelining: false + maxConcurrentConnections: 100 + useCompression: true + followRedirects: false + - name: "backup-group" + endpoints: + - backup: false + inherit: true + name: "backup-primary" + weight: 1 + type: "http" + target: "https://api.gravitee.io/echo" + - backup: true + inherit: true + name: "backup-secondary" + weight: 1 + type: "http" + target: "https://api.gravitee.io/echo" + load_balancing: + type: "ROUND_ROBIN" + http: + connectTimeout: 5000 + idleTimeout: 60000 + keepAlive: true + readTimeout: 10000 + pipelining: false + maxConcurrentConnections: 100 + useCompression: true + followRedirects: false + failover: + maxAttempts: 3 + retryTimeout: 10000 + cases: + - "TIMEOUT" diff --git a/config/samples/apim/api-with-health-check-disabled.yml b/config/samples/apim/api-with-health-check-disabled.yml new file mode 100644 index 000000000..1356bb666 --- /dev/null +++ b/config/samples/apim/api-with-health-check-disabled.yml @@ -0,0 +1,35 @@ +# +# Copyright (C) 2015 The Gravitee team (http://gravitee.io) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +apiVersion: gravitee.io/v1alpha1 +kind: ApiDefinition +metadata: + name: with-disabled-hc + namespace: default +spec: + name: "With disabled health check" + version: "1.0" + description: "API with disabled health check" + services: + health-check: + enabled: false + schedule: "*/1 * * * * *" + proxy: + virtual_hosts: + - path: "/with-disabled-hc" + groups: + - endpoints: + - name: "Default" + target: "https://api.gravitee.io/echo" diff --git a/config/samples/apim/api-with-health-check.yml b/config/samples/apim/api-with-health-check.yml new file mode 100644 index 000000000..6f5976e2d --- /dev/null +++ b/config/samples/apim/api-with-health-check.yml @@ -0,0 +1,44 @@ +# +# Copyright (C) 2015 The Gravitee team (http://gravitee.io) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +apiVersion: gravitee.io/v1alpha1 +kind: ApiDefinition +metadata: + name: with-hc + namespace: default +spec: + name: "With health check" + version: "1.0" + description: "API with health check" + services: + health-check: + enabled: true + schedule: "*/1 * * * * *" + steps: + - name: "default-step" + request: + path: "/" + method: "GET" + fromRoot: false + response: + assertions: + - "#response.status == 200" + proxy: + virtual_hosts: + - path: "/with-hc" + groups: + - endpoints: + - name: "Default" + target: "https://api.gravitee.io/echo" diff --git a/config/samples/apim/_v1alpha1_apidefinition.yaml b/config/samples/apim/api-with-logging.yml similarity index 62% rename from config/samples/apim/_v1alpha1_apidefinition.yaml rename to config/samples/apim/api-with-logging.yml index 35863acf4..261d21aea 100644 --- a/config/samples/apim/_v1alpha1_apidefinition.yaml +++ b/config/samples/apim/api-with-logging.yml @@ -1,3 +1,4 @@ +# # Copyright (C) 2015 The Gravitee team (http://gravitee.io) # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,10 +12,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +# apiVersion: gravitee.io/v1alpha1 kind: ApiDefinition metadata: - name: apidefinition-sample + name: with-logging + namespace: default spec: - # TODO(user): Add fields here + name: "With logging" + version: "1.0" + description: "API with logging" + proxy: + logging: + mode: "CLIENT_PROXY" + content: "HEADERS_PAYLOADS" + scope: "REQUEST_RESPONSE" + virtual_hosts: + - path: "/with-logging" + groups: + - endpoints: + - name: "Default" + target: "https://api.gravitee.io/echo" diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index 73a96f72f..1ed46623e 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -42,7 +42,7 @@ import ( "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" ) -var _ = Describe("API Definition Controller", func() { +var _ = Describe("Create", func() { const ( origin = "kubernetes" mode = "fully_managed" @@ -50,13 +50,13 @@ var _ = Describe("API Definition Controller", func() { httpClient := http.Client{Timeout: 5 * time.Second} - Context("With basic ApiDefinition", func() { + Context("a basic spec without a management context", func() { var apiDefinitionFixture *gio.ApiDefinition var apiLookupKey types.NamespacedName BeforeEach(func() { - By("Without a management context") + By("Initializing the API definition fixture") apiDefinition, err := internal.NewApiDefinition(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) @@ -65,12 +65,12 @@ var _ = Describe("API Definition Controller", func() { apiLookupKey = types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} }) - It("Should create an API Definition", func() { - By("Create an API definition resource without a management context") + It("should create an API Definition", func() { + By("Creating an API definition resource without a management context") Expect(k8sClient.Create(ctx, apiDefinitionFixture)).Should(Succeed()) - By("Get created resource and expect to find it") + By("Getting created resource and expect to find it") apiDefinition := new(gio.ApiDefinition) Eventually(func() bool { @@ -83,7 +83,7 @@ var _ = Describe("API Definition Controller", func() { expectedApiName := apiDefinitionFixture.Spec.Name Expect(apiDefinition.Spec.Name).Should(Equal(expectedApiName)) - By("Call gateway endpoint and expect the API to be available") + By("Calling gateway endpoint and expect the API to be available") Eventually(func() bool { res, callErr := httpClient.Get(endpoint) @@ -92,7 +92,7 @@ var _ = Describe("API Definition Controller", func() { }) }) - Context("With basic ApiDefinition & ManagementContext", func() { + Context("a basic spec with a management context", func() { var apiDefinitionFixture *gio.ApiDefinition var managementContextFixture *gio.ManagementContext var apiLookupKey types.NamespacedName @@ -112,7 +112,7 @@ var _ = Describe("API Definition Controller", func() { contextLookupKey = types.NamespacedName{Name: managementContextFixture.Name, Namespace: namespace} }) - It("Should create an API Definition", func() { + It("should create an API Definition", func() { By("Create a management context to synchronize with the REST API") Expect(k8sClient.Create(ctx, managementContextFixture)).Should(Succeed()) @@ -162,7 +162,7 @@ var _ = Describe("API Definition Controller", func() { ) }) - It("Should create a STOPPED API Definition", func() { + It("should create a STOPPED API Definition", func() { apiDefinitionFixture.Spec.State = model.StateStopped By("Create a management context to synchronize with the REST API") @@ -207,7 +207,7 @@ var _ = Describe("API Definition Controller", func() { }, timeout, interval).Should(BeTrue()) }) - It("Should create an API Definition with existing api in Management Api", func() { + It("should create an API Definition with existing api in Management Api", func() { apimClient, err := internal.NewApimClient(ctx) Expect(err).ToNot(HaveOccurred()) @@ -274,4 +274,65 @@ var _ = Describe("API Definition Controller", func() { }) }) + + DescribeTable("a featured API spec with a management context", + func(specFile string) { + apiWithContext, err := internal.NewApiWithRandomContext( + specFile, internal.ContextWithSecretFile, + ) + + Expect(err).ToNot(HaveOccurred()) + + apiDefinitionFixture := apiWithContext.Api + managementContextFixture := apiWithContext.Context + + apiLookupKey := types.NamespacedName{Name: apiDefinitionFixture.Name, Namespace: namespace} + contextLookupKey := types.NamespacedName{Name: managementContextFixture.Name, Namespace: namespace} + + By("Creating a management context to synchronize with the REST API") + Expect(k8sClient.Create(ctx, managementContextFixture)).Should(Succeed()) + + By("Creating an API definition resource referencing the management context") + Expect(k8sClient.Create(ctx, apiDefinitionFixture)).Should(Succeed()) + + By("Getting created resource") + + managementContext := new(gio.ManagementContext) + Eventually(func() error { + return k8sClient.Get(ctx, contextLookupKey, managementContext) + }, timeout, interval).Should(Succeed()) + + apiDefinition := new(gio.ApiDefinition) + Eventually(func() bool { + err = k8sClient.Get(ctx, apiLookupKey, apiDefinition) + return err == nil && apiDefinition.Status.CrossID != "" + }, timeout, interval).Should(BeTrue()) + + expectedApiName := apiDefinitionFixture.Spec.Name + Expect(apiDefinition.Spec.Name).Should(Equal(expectedApiName)) + + By("Calling gateway endpoint, expecting the API to be available") + + var endpoint = internal.GatewayUrl + apiDefinition.Spec.Proxy.VirtualHosts[0].Path + + Eventually(func() bool { + res, callErr := httpClient.Get(endpoint) + return callErr == nil && res.StatusCode == 200 + }, timeout, interval).Should(BeTrue()) + + By("Calling rest API, expecting one API to match status cross ID") + + apimClient, err := internal.NewApimClient(ctx) + Expect(err).ToNot(HaveOccurred()) + + Eventually(func() bool { + api, apiErr := apimClient.GetByCrossId(apiDefinition.Status.CrossID) + return apiErr == nil && api.Id == apiDefinition.Status.ID + }, timeout, interval).Should(BeTrue()) + }, + Entry("should import with health check", internal.ApiWithHCFile), + Entry("should import with disabled health check", internal.ApiWithDisabledHCFile), + Entry("should import with logging", internal.ApiWithLoggingFile), + Entry("should import with endpoint groups", internal.ApiWithEndpointGroupsFile), + ) }) diff --git a/test/internal/constants.go b/test/internal/constants.go index 9191572c0..c660e8a63 100644 --- a/test/internal/constants.go +++ b/test/internal/constants.go @@ -17,12 +17,16 @@ package internal import "time" const ( - GatewayUrl = "http://localhost:9000/gateway" - SamplesPath = "../config/samples" - ContextWithSecretFile = SamplesPath + "/context/dev/managementcontext_secretRef.yaml" - BasicApiFile = SamplesPath + "/apim/basic-example.yml" - BasicApiWithContextFile = SamplesPath + "/apim/basic-example-with-ctx.yml" - ApiKeyApiWithContextFile = SamplesPath + "/apim/apikey-example-with-ctx.yml" + GatewayUrl = "http://localhost:9000/gateway" + SamplesPath = "../config/samples" + ContextWithSecretFile = SamplesPath + "/context/dev/managementcontext_secretRef.yaml" + BasicApiFile = SamplesPath + "/apim/basic-example.yml" + BasicApiWithContextFile = SamplesPath + "/apim/basic-example-with-ctx.yml" + ApiWithDisabledHCFile = SamplesPath + "/apim/api-with-health-check-disabled.yml" + ApiWithHCFile = SamplesPath + "/apim/api-with-health-check.yml" + ApiWithEndpointGroupsFile = SamplesPath + "/apim/api-with-endpoint-groups.yml" + ApiWithLoggingFile = SamplesPath + "/apim/api-with-logging.yml" + ApiKeyApiWithContextFile = SamplesPath + "/apim/apikey-example-with-ctx.yml" contextWithCredentialsFile = SamplesPath + "/context/dev/managementcontext_credentials.yaml" apimClientTimeout = 5 * time.Second From 6e816193ffe7c31ce27bbec934fb6ed34e7d035c Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Wed, 2 Nov 2022 15:50:25 +0100 Subject: [PATCH 48/54] chore: clean up config sample files --- ...with-ctx.yml => api-with-api-key-plan.yml} | 0 ...mple-with-ctx.yml => api-with-context.yml} | 0 ...ple.yml => api-with-service-discovery.yml} | 42 ++-- config/samples/apim/apikey-example.yml | 35 --- .../apim/{basic-example.yml => basic-api.yml} | 0 config/samples/apim/complex-example.yml | 202 ------------------ config/samples/apim/devportal-example.yml | 31 --- config/samples/apim/flow-example.yml | 45 ---- config/samples/apim/oauth2-example.yml | 45 ---- ... management-context-with-credentials.yaml} | 0 ...management-context-with-bearer-token.yaml} | 0 ... management-context-with-credentials.yaml} | 0 ...> management-context-with-secret-ref.yaml} | 0 ... management-context-with-credentials.yaml} | 0 config/samples/{apim => }/kustomization.yaml | 4 +- test/apidefinition_controller_create_test.go | 3 +- test/apidefinition_controller_delete_test.go | 2 +- test/apidefinition_controller_error_test.go | 2 +- ...n_controller_plan_and_subscription_test.go | 2 +- ...pidefinition_controller_start_stop_test.go | 2 +- test/apidefinition_controller_udpate_test.go | 4 +- test/internal/constants.go | 22 +- 22 files changed, 44 insertions(+), 397 deletions(-) rename config/samples/apim/{apikey-example-with-ctx.yml => api-with-api-key-plan.yml} (100%) rename config/samples/apim/{basic-example-with-ctx.yml => api-with-context.yml} (100%) rename config/samples/apim/{policy-example.yml => api-with-service-discovery.yml} (54%) delete mode 100644 config/samples/apim/apikey-example.yml rename config/samples/apim/{basic-example.yml => basic-api.yml} (100%) delete mode 100644 config/samples/apim/complex-example.yml delete mode 100644 config/samples/apim/devportal-example.yml delete mode 100644 config/samples/apim/flow-example.yml delete mode 100644 config/samples/apim/oauth2-example.yml rename config/samples/context/debug/{managementcontext_credentials.yaml => management-context-with-credentials.yaml} (100%) rename config/samples/context/dev/{managementcontext_bearerToken.yaml => management-context-with-bearer-token.yaml} (100%) rename config/samples/context/dev/{managementcontext_credentials.yaml => management-context-with-credentials.yaml} (100%) rename config/samples/context/dev/{managementcontext_secretRef.yaml => management-context-with-secret-ref.yaml} (100%) rename config/samples/context/k3d/{managementcontext_credentials.yaml => management-context-with-credentials.yaml} (100%) rename config/samples/{apim => }/kustomization.yaml (90%) diff --git a/config/samples/apim/apikey-example-with-ctx.yml b/config/samples/apim/api-with-api-key-plan.yml similarity index 100% rename from config/samples/apim/apikey-example-with-ctx.yml rename to config/samples/apim/api-with-api-key-plan.yml diff --git a/config/samples/apim/basic-example-with-ctx.yml b/config/samples/apim/api-with-context.yml similarity index 100% rename from config/samples/apim/basic-example-with-ctx.yml rename to config/samples/apim/api-with-context.yml diff --git a/config/samples/apim/policy-example.yml b/config/samples/apim/api-with-service-discovery.yml similarity index 54% rename from config/samples/apim/policy-example.yml rename to config/samples/apim/api-with-service-discovery.yml index 44609b270..c68cbaae8 100644 --- a/config/samples/apim/policy-example.yml +++ b/config/samples/apim/api-with-service-discovery.yml @@ -16,27 +16,31 @@ apiVersion: gravitee.io/v1alpha1 kind: ApiDefinition metadata: - name: policy-api-example + name: with-service-discovery + namespace: default spec: - name: "K8s Policy Api Example" + name: "With service-discovery" version: "1.0" - description: "Api managed by Gravitee Kubernetes Operator with one policy" - flows: - - name: "Default" - pre: - - name: "Transform Headers" - description: "Add 'X-Test' request header" - policy: transform-headers - configuration: - addHeaders: - - name: "X-Test" - value: "MyHeaderValue" - scope: REQUEST + description: "API with service-discovery" proxy: virtual_hosts: - - path: "/k8s-policy" + - path: "/with-service-discovery" groups: - - name: default-group - endpoints: - - name: "Default" - target: "https://api.gravitee.io/echo" \ No newline at end of file + - name: "default" + endpoints: + - backup: false + name: "Default" + weight: 1 + type: "http" + target: "https://api.gravitee.io/echo" + load_balancing: + type: "ROUND_ROBIN" + services: + discovery: + enabled: true + provider: "consul-service-discovery" + configuration: + url: "http://localhost:8500" + trustStoreType: "NONE" + keyStoreType: "NONE" + service: "test" diff --git a/config/samples/apim/apikey-example.yml b/config/samples/apim/apikey-example.yml deleted file mode 100644 index 9459d1fbc..000000000 --- a/config/samples/apim/apikey-example.yml +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2015 The Gravitee team (http://gravitee.io) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -apiVersion: gravitee.io/v1alpha1 -kind: ApiDefinition -metadata: - name: apikey-example -spec: - name: "K8s ApiKey Example" - version: "1.0" - description: "Api managed by Gravitee Kubernetes Operator with Key plan" - plans: - - name: 'Apikey' - description: 'Api key plan' - security: API_KEY - proxy: - virtual_hosts: - - path: "/k8s-apikey" - groups: - - name: default-group - endpoints: - - name: "Default" - target: "https://api.gravitee.io/echo" \ No newline at end of file diff --git a/config/samples/apim/basic-example.yml b/config/samples/apim/basic-api.yml similarity index 100% rename from config/samples/apim/basic-example.yml rename to config/samples/apim/basic-api.yml diff --git a/config/samples/apim/complex-example.yml b/config/samples/apim/complex-example.yml deleted file mode 100644 index 3291845fd..000000000 --- a/config/samples/apim/complex-example.yml +++ /dev/null @@ -1,202 +0,0 @@ -# -# Copyright (C) 2015 The Gravitee team (http://gravitee.io) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -apiVersion: gravitee.io/v1alpha1 -kind: ApiDefinition -metadata: - name: complex-api-example -spec: - name: 0. ̆æÌ∫ê Planets - crossId: 778fba35-bdf6-4beb-8fba-35bdf68beb6a - version: '1' - description: The whole graviverse in your hands! - visibility: PUBLIC - gravitee: 2.0.0 - flow_mode: DEFAULT - flows: - - name: '' - path-operator: - path: "/" - operator: STARTS_WITH - condition: '' - consumers: [] - methods: [] - pre: - - name: Transform Headers - description: '' - enabled: true - policy: transform-headers - configuration: - addHeaders: - - name: x-demo-header - value: new-value - scope: REQUEST - - name: Assign content - description: '' - enabled: false - policy: policy-assign-content - condition: '{#request.heraders["application"][0] == "1"}' - configuration: - scope: REQUEST - body: '{ "key": "value" }' - - name: Assign content - description: '' - enabled: false - policy: policy-assign-content - configuration: - scope: REQUEST - body: '{ "key": "A second value that should be displayed"}' - - name: Api Key - description: sss - enabled: true - policy: api-key - configuration: {} - post: - - name: JSON to XML - description: '' - enabled: true - policy: json-xml - configuration: - rootElement: root - scope: RESPONSE - enabled: true - - name: '' - path-operator: - path: "/dby" - operator: STARTS_WITH - condition: '' - consumers: [] - methods: [] - pre: - - name: HTTP Callout - description: '' - enabled: true - policy: policy-http-callout - configuration: - variables: - - name: result - value: "{#calloutResponse.content}" - method: GET - fireAndForget: false - scope: REQUEST - errorStatusCode: '500' - errorCondition: "{#calloutResponse.status >= 400 and #calloutResponse.status - <= 599}" - url: https://api.gravitee.io/echo - exitOnError: false - - name: Mock - description: '' - enabled: true - policy: mock - configuration: - content: "{#context.attributes[‚Äòresult‚Äô]}" - status: '200' - post: [] - enabled: true - resources: [] - properties: - - key: test - value: toto - encrypted: false - labels: - - uranus - - venus - - saturne - - mars - - terre - - neptune - - jupiter - - mercure - - pluton - plans: - - id: 58e3f814-0150-428a-a3f8-140150c28af6 - crossId: 753f065f-2eb6-426d-bf06-5f2eb6326d8e - name: API Key - description: Api key needed! - validation: AUTO - security: API_KEY - securityDefinition: '{"propagateApiKey":true}' - type: API - status: PUBLISHED - api: 8be358c9-be95-4b18-a358-c9be95bb1847 - order: 1 - characteristics: [] - paths: {} - flows: [] - comment_required: false - - id: 833a2790-5445-44ba-ba27-90544554ba72 - crossId: 81053edc-1524-49be-853e-dc152419be8d - name: Keyless - description: No money needed! - validation: AUTO - security: KEY_LESS - securityDefinition: "{}" - type: API - status: PUBLISHED - api: 8be358c9-be95-4b18-a358-c9be95bb1847 - order: 0 - characteristics: [] - paths: - "/": [] - flows: [] - comment_required: false - metadata: - - key: email-support - name: email-support - format: MAIL - value: "${(api.primaryOwner.email)!''}" - defaultValue: support@change.me - id: 8be358c9-be95-4b18-a358-c9be95bb1847 - path_mappings: - - "/products/:id" - proxy: - virtual_hosts: - - path: "/planets" - - host: yann - path: "/planets" - strip_context_path: false - preserve_host: false - groups: - - name: default-group - endpoints: - - backup: false - inherit: true - name: default - weight: 1 - type: http - target: https://api.le-systeme-solaire.net/rest/ - - backup: false - inherit: true - name: kafka - weight: 1 - type: kafka - target: kafka - load_balancing: - type: ROUND_ROBIN - http: - connectTimeout: 5000 - idleTimeout: 60000 - keepAlive: true - readTimeout: 10000 - pipelining: false - maxConcurrentConnections: 100 - useCompression: true - followRedirects: false - response_templates: {} - primaryOwner: - id: 4015f9f2-c0a4-4c0c-95f9-f2c0a4fc0c4c - email: no-reply@graviteesource.com - displayName: Admin master - type: USER \ No newline at end of file diff --git a/config/samples/apim/devportal-example.yml b/config/samples/apim/devportal-example.yml deleted file mode 100644 index 11ed81501..000000000 --- a/config/samples/apim/devportal-example.yml +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2015 The Gravitee team (http://gravitee.io) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -apiVersion: gravitee.io/v1alpha1 -kind: ApiDefinition -metadata: - name: devportal-example -spec: - name: "K8s DevPortal Example" - version: "1.0" - description: "Api managed by Gravitee Kubernetes Operator and published to DevPortal" - lifecycle_state: PUBLISHED - proxy: - virtual_hosts: - - path: "/k8s-devportal" - groups: - - endpoints: - - name: "Default" - target: "https://api.gravitee.io/echo" \ No newline at end of file diff --git a/config/samples/apim/flow-example.yml b/config/samples/apim/flow-example.yml deleted file mode 100644 index 3f0027742..000000000 --- a/config/samples/apim/flow-example.yml +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2015 The Gravitee team (http://gravitee.io) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -apiVersion: gravitee.io/v1alpha1 -kind: ApiDefinition -metadata: - name: flow-example -spec: - name: "K8s Flow Example" - version: "1.0" - description: "Api managed by Gravitee Kubernetes Operator with plan flow" - plans: - - name: "Keyless" - description: "Keyless plan" - security: KEY_LESS - flows: - - pre: - - name: "Transform Headers" - description: "Add 'X-Test' request header" - policy: transform-headers - configuration: - addHeaders: - - name: "X-Test" - value: "MyHeaderValue" - scope: REQUEST - proxy: - virtual_hosts: - - path: "/k8s-flow" - groups: - - name: default-group - endpoints: - - name: "Default" - target: "https://api.gravitee.io/echo" \ No newline at end of file diff --git a/config/samples/apim/oauth2-example.yml b/config/samples/apim/oauth2-example.yml deleted file mode 100644 index 3826db4c6..000000000 --- a/config/samples/apim/oauth2-example.yml +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2015 The Gravitee team (http://gravitee.io) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -apiVersion: gravitee.io/v1alpha1 -kind: ApiDefinition -metadata: - name: apikey-example -spec: - name: "K8s OAuth2 Example" - version: "1.0" - description: "Api managed by Gravitee Kubernetes Operator with OAuth2 plan" - resources: - - name: "am-demo" - type: oauth2-am-resource - configuration: - version: V3_X - serverURL: "https://am-nightly-gateway.cloud.gravitee.io" - securityDomain: "test-jh" - clientId: "localjh" - clientSecret: "localjh" - plans: - - name: "OAuth2" - description: "Oauth2 plan" - security: OAUTH2 - securityDefinition: '{"oauthResource":"am-demo"}' - proxy: - virtual_hosts: - - path: "/k8s-oauth2" - groups: - - name: default-group - endpoints: - - name: "Default" - target: "https://api.gravitee.io/echo" \ No newline at end of file diff --git a/config/samples/context/debug/managementcontext_credentials.yaml b/config/samples/context/debug/management-context-with-credentials.yaml similarity index 100% rename from config/samples/context/debug/managementcontext_credentials.yaml rename to config/samples/context/debug/management-context-with-credentials.yaml diff --git a/config/samples/context/dev/managementcontext_bearerToken.yaml b/config/samples/context/dev/management-context-with-bearer-token.yaml similarity index 100% rename from config/samples/context/dev/managementcontext_bearerToken.yaml rename to config/samples/context/dev/management-context-with-bearer-token.yaml diff --git a/config/samples/context/dev/managementcontext_credentials.yaml b/config/samples/context/dev/management-context-with-credentials.yaml similarity index 100% rename from config/samples/context/dev/managementcontext_credentials.yaml rename to config/samples/context/dev/management-context-with-credentials.yaml diff --git a/config/samples/context/dev/managementcontext_secretRef.yaml b/config/samples/context/dev/management-context-with-secret-ref.yaml similarity index 100% rename from config/samples/context/dev/managementcontext_secretRef.yaml rename to config/samples/context/dev/management-context-with-secret-ref.yaml diff --git a/config/samples/context/k3d/managementcontext_credentials.yaml b/config/samples/context/k3d/management-context-with-credentials.yaml similarity index 100% rename from config/samples/context/k3d/managementcontext_credentials.yaml rename to config/samples/context/k3d/management-context-with-credentials.yaml diff --git a/config/samples/apim/kustomization.yaml b/config/samples/kustomization.yaml similarity index 90% rename from config/samples/apim/kustomization.yaml rename to config/samples/kustomization.yaml index ae04829fc..3b45c24c4 100644 --- a/config/samples/apim/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -14,6 +14,6 @@ ## Append samples you want in your CSV to this file as resources ## resources: -- _v1alpha1_apidefinition.yaml -- _v1alpha1_managementcontext.yaml +- apim/basic-api.yml +- context/dev/management-context-with-secret-ref.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index 1ed46623e..d2f88e81f 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -100,7 +100,7 @@ var _ = Describe("Create", func() { BeforeEach(func() { apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + internal.BasicApiFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) @@ -334,5 +334,6 @@ var _ = Describe("Create", func() { Entry("should import with disabled health check", internal.ApiWithDisabledHCFile), Entry("should import with logging", internal.ApiWithLoggingFile), Entry("should import with endpoint groups", internal.ApiWithEndpointGroupsFile), + Entry("should import with service discovery", internal.ApiWithServiceDiscoveryFile), ) }) diff --git a/test/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go index 190b2a088..744e28a6c 100644 --- a/test/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -53,7 +53,7 @@ var _ = Describe("API Definition Controller", func() { By("Create a management context to synchronize with the REST API") apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + internal.BasicApiFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index e484a3059..2b06ef6b9 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -52,7 +52,7 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable By("Create a management context to synchronize with the REST API") apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + internal.BasicApiFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go index 7e885fb43..f579f1cd3 100644 --- a/test/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -63,7 +63,7 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { By("Create a management context to synchronize with the REST API") apiWithContext, err := internal.NewApiWithRandomContext( - internal.ApiKeyApiWithContextFile, internal.ContextWithSecretFile, + internal.ApiWithApiKeyPlanFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go index 97d56276d..cedb1dad6 100644 --- a/test/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -51,7 +51,7 @@ var _ = Describe("API Definition Controller", func() { By("Create a management context to synchronize with the REST API") apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + internal.BasicApiFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go index 7fbb8f03d..4261a3d0e 100644 --- a/test/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -113,7 +113,7 @@ var _ = Describe("API Definition Controller", func() { By("Create a management context to synchronize with the REST API") apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + internal.BasicApiFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) @@ -192,7 +192,7 @@ var _ = Describe("API Definition Controller", func() { By("Create a management context to synchronize with the REST API") apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiWithContextFile, internal.ContextWithSecretFile, + internal.BasicApiFile, internal.ContextWithSecretFile, ) Expect(err).ToNot(HaveOccurred()) diff --git a/test/internal/constants.go b/test/internal/constants.go index c660e8a63..0d87a08dc 100644 --- a/test/internal/constants.go +++ b/test/internal/constants.go @@ -17,17 +17,17 @@ package internal import "time" const ( - GatewayUrl = "http://localhost:9000/gateway" - SamplesPath = "../config/samples" - ContextWithSecretFile = SamplesPath + "/context/dev/managementcontext_secretRef.yaml" - BasicApiFile = SamplesPath + "/apim/basic-example.yml" - BasicApiWithContextFile = SamplesPath + "/apim/basic-example-with-ctx.yml" - ApiWithDisabledHCFile = SamplesPath + "/apim/api-with-health-check-disabled.yml" - ApiWithHCFile = SamplesPath + "/apim/api-with-health-check.yml" - ApiWithEndpointGroupsFile = SamplesPath + "/apim/api-with-endpoint-groups.yml" - ApiWithLoggingFile = SamplesPath + "/apim/api-with-logging.yml" - ApiKeyApiWithContextFile = SamplesPath + "/apim/apikey-example-with-ctx.yml" + GatewayUrl = "http://localhost:9000/gateway" + SamplesPath = "../config/samples" + ContextWithSecretFile = SamplesPath + "/context/dev/management-context-with-secret-ref.yaml" + BasicApiFile = SamplesPath + "/apim/basic-api.yml" + ApiWithDisabledHCFile = SamplesPath + "/apim/api-with-health-check-disabled.yml" + ApiWithHCFile = SamplesPath + "/apim/api-with-health-check.yml" + ApiWithServiceDiscoveryFile = SamplesPath + "/apim/api-with-service-discovery.yml" + ApiWithEndpointGroupsFile = SamplesPath + "/apim/api-with-endpoint-groups.yml" + ApiWithLoggingFile = SamplesPath + "/apim/api-with-logging.yml" + ApiWithApiKeyPlanFile = SamplesPath + "/apim/api-with-api-key-plan.yml" - contextWithCredentialsFile = SamplesPath + "/context/dev/managementcontext_credentials.yaml" + contextWithCredentialsFile = SamplesPath + "/context/dev/management-context-with-credentials.yaml" apimClientTimeout = 5 * time.Second ) From 0afeb80d7e85f7284e3b4ab7407e56818ac0b347 Mon Sep 17 00:00:00 2001 From: "Gravitee.io Bot" Date: Thu, 3 Nov 2022 09:42:30 +0000 Subject: [PATCH 49/54] chore(release): 0.1.0-alpha.14 [skip ci] --- CHANGELOG.md | 9 +++++++++ bundle.yml | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd38c7690..10ab29fee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [0.1.0-alpha.14](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.13...0.1.0-alpha.14) (2022-11-03) + + +### Bug Fixes + +* import api with disabled health check ([a874ac6](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/a874ac68908f91890956e1077f5a447f68b36cc4)) +* import API with logging ([7179561](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/7179561e64a2114c93031c2326b9b6a0227044c3)) +* import api with several endpoint groups ([c4032eb](https://github.com/gravitee-io/gravitee-kubernetes-operator/commit/c4032eb4090057c6d4aac0ab4cc9b2711db0033a)) + # [0.1.0-alpha.13](https://github.com/gravitee-io/gravitee-kubernetes-operator/compare/0.1.0-alpha.12...0.1.0-alpha.13) (2022-11-02) diff --git a/bundle.yml b/bundle.yml index 62bfe341f..7ed03e0d5 100644 --- a/bundle.yml +++ b/bundle.yml @@ -707,6 +707,8 @@ spec: type: string provider: type: string + required: + - enabled type: object dynamic-property: properties: @@ -718,6 +720,7 @@ spec: health-check: properties: enabled: + default: false type: boolean schedule: type: string @@ -766,6 +769,8 @@ spec: type: object type: object type: array + required: + - enabled type: object type: object ssl: @@ -792,26 +797,26 @@ spec: condition: type: string content: - properties: - headers: - type: boolean - payloads: - type: boolean - type: object + enum: + - NONE + - HEADERS + - PAYLOADS + - HEADERS_PAYLOADS + type: string mode: - properties: - client: - type: boolean - proxy: - type: boolean - type: object + enum: + - NONE + - CLIENT + - PROXY + - CLIENT_PROXY + type: string scope: - properties: - request: - type: boolean - response: - type: boolean - type: object + enum: + - NONE + - REQUEST + - RESPONSE + - REQUEST_RESPONSE + type: string type: object preserve_host: type: boolean @@ -871,6 +876,8 @@ spec: type: string provider: type: string + required: + - enabled type: object dynamic-property: properties: @@ -882,6 +889,7 @@ spec: health-check: properties: enabled: + default: false type: boolean schedule: type: string @@ -930,6 +938,8 @@ spec: type: object type: object type: array + required: + - enabled type: object type: object state: @@ -1368,7 +1378,7 @@ spec: - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.13 + image: graviteeio/kubernetes-operator:0.1.0-alpha.14 imagePullPolicy: Always livenessProbe: httpGet: From 4e45fbc713863299c5f1b9624443e221666b3b07 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 4 Nov 2022 11:50:27 +0100 Subject: [PATCH 50/54] ci: fix ginkgo flags --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 366a8dee5..60e0fdf14 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ GOTESTARGS ?= "" .PHONY: test test: manifests generate install ## Run tests. kubectl config use-context k3d-graviteeio - KUBEBUILDER_ASSETS=USE_EXISTING_CLUSTER=true $(GINKGO) $(GOTESTARGS) -timeout 380s --cover --coverprofile=cover.out ./... + KUBEBUILDER_ASSETS=USE_EXISTING_CLUSTER=true $(GINKGO) $(GOTESTARGS) --timeout 380s --cover --coverprofile=cover.out ./... .PHONY: k3d-apim-init k3d-apim-init: ## Init APIM locally using k3d From 9f12dff3d9d15085b2175cee9903d530df1871c9 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 4 Nov 2022 11:46:35 +0100 Subject: [PATCH 51/54] test: add create test for api with metadata --- config/samples/apim/api-with-metadata.yml | 36 +++++++++++++++++++++++ config/samples/apim/basic-api.yml | 2 +- test/internal/constants.go | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 config/samples/apim/api-with-metadata.yml diff --git a/config/samples/apim/api-with-metadata.yml b/config/samples/apim/api-with-metadata.yml new file mode 100644 index 000000000..b18894fc5 --- /dev/null +++ b/config/samples/apim/api-with-metadata.yml @@ -0,0 +1,36 @@ +# +# Copyright (C) 2015 The Gravitee team (http://gravitee.io) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +apiVersion: gravitee.io/v1alpha1 +kind: ApiDefinition +metadata: + name: with-metadata + namespace: default +spec: + name: "With metadata" + version: "1.0" + description: "API with metadata" + proxy: + virtual_hosts: + - path: "/with-metadata" + groups: + - endpoints: + - name: "Default" + target: "https://api.gravitee.io/echo" + metadata: + - key: "build-version" + name: "build-version" + format: "STRING" + value: "0.0.1" diff --git a/config/samples/apim/basic-api.yml b/config/samples/apim/basic-api.yml index bd7a3a751..f8fabd6ed 100644 --- a/config/samples/apim/basic-api.yml +++ b/config/samples/apim/basic-api.yml @@ -21,7 +21,7 @@ metadata: spec: name: "K8s Basic Example" version: "1.0" - description: "Basic api managed by Gravitee Kubernetes Operator u2" + description: "Basic api managed by Gravitee Kubernetes Operator" proxy: virtual_hosts: - path: "/k8s-basic" diff --git a/test/internal/constants.go b/test/internal/constants.go index 0d87a08dc..3c95d2595 100644 --- a/test/internal/constants.go +++ b/test/internal/constants.go @@ -24,6 +24,7 @@ const ( ApiWithDisabledHCFile = SamplesPath + "/apim/api-with-health-check-disabled.yml" ApiWithHCFile = SamplesPath + "/apim/api-with-health-check.yml" ApiWithServiceDiscoveryFile = SamplesPath + "/apim/api-with-service-discovery.yml" + ApiWithMetadataFile = SamplesPath + "/apim/api-with-metadata.yml" ApiWithEndpointGroupsFile = SamplesPath + "/apim/api-with-endpoint-groups.yml" ApiWithLoggingFile = SamplesPath + "/apim/api-with-logging.yml" ApiWithApiKeyPlanFile = SamplesPath + "/apim/api-with-api-key-plan.yml" From 9867084b82b8b8a2994c34d1810ab55b352d8de8 Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 3 Nov 2022 10:43:29 +0100 Subject: [PATCH 52/54] test: add opt in option to run the operator locally --- test/suite_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/suite_test.go b/test/suite_test.go index 9a489ee45..5faac3424 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -18,6 +18,8 @@ package test import ( "context" + "fmt" + "os" "strings" "testing" "time" @@ -58,6 +60,8 @@ const ( interval = time.Millisecond * 250 ) +var startOperator = true + func TestAPIs(t *testing.T) { RegisterFailHandler(Fail) @@ -65,6 +69,11 @@ func TestAPIs(t *testing.T) { } var _ = SynchronizedBeforeSuite(func() { + if !startOperator { + fmt.Fprintln(GinkgoWriter, "Assuming the operator has been deployed before running tests") + return + } + By("Setting up the test environment") logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) @@ -209,3 +218,9 @@ func getEventsReason(apiDefinition *gio.ApiDefinition) []string { } return eventsReason } + +func init() { + if os.Getenv("ENV") == "ci" { + startOperator = false + } +} From ddc6af51d83efb3feaf829abee98a17963b36ebd Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Thu, 3 Nov 2022 15:46:38 +0100 Subject: [PATCH 53/54] test: update management context when running in cluster --- .circleci/config.yml | 8 ++++- Makefile | 4 +-- .../management-context-with-secret-ref.yaml | 29 +++++++++++++++++++ scripts/k3d.sh | 4 +-- test/apidefinition_controller_create_test.go | 8 ++--- test/apidefinition_controller_delete_test.go | 5 ++-- test/apidefinition_controller_error_test.go | 4 +-- ...n_controller_plan_and_subscription_test.go | 5 ++-- ...pidefinition_controller_start_stop_test.go | 4 +-- test/apidefinition_controller_udpate_test.go | 8 ++--- test/internal/constants.go | 5 +++- test/internal/fixtures.go | 11 ++++++- test/suite_test.go | 9 ++---- 13 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 config/samples/context/k3d/management-context-with-secret-ref.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index b08a4ec38..37c53193d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,9 +91,15 @@ jobs: export APIM_IMAGE_REGISTRY=graviteeio.azurecr.io export APIM_IMAGE_TAG=master-latest make k3d-apim-init + - run: + name: Deploy Operator bundle + command: make k3d-gko-deploy - run: name: Run tests - command: GOTESTARGS="--output-dir=/tmp/junit/reports --junit-report=junit.xml" make test + command: | + export KUBECONFIG=$HOME/.kube/config + export ENV=ci + GOTESTARGS="--output-dir=/tmp/junit/reports --junit-report=junit.xml" make test - store_test_results: path: /tmp/junit/reports diff --git a/Makefile b/Makefile index 60e0fdf14..f996f05b9 100644 --- a/Makefile +++ b/Makefile @@ -120,7 +120,7 @@ lint-license: addlicense ## Run addlicense lint and fail on error GOTESTARGS ?= "" .PHONY: test -test: manifests generate install ## Run tests. +test: manifests generate install ## Run tests with the operator running locally kubectl config use-context k3d-graviteeio KUBEBUILDER_ASSETS=USE_EXISTING_CLUSTER=true $(GINKGO) $(GOTESTARGS) --timeout 380s --cover --coverprofile=cover.out ./... @@ -149,7 +149,7 @@ k3d-gko-push: ## Push the gko image for k3d deployment $(MAKE) docker-push IMG=$(K3D_IMG) .PHONY: k3d-gko-deploy -k3d-gko-deploy: ## Push the gko image for k3d deployment +k3d-gko-deploy: k3d-gko-build k3d-gko-push ## Push the gko image for k3d deployment $(MAKE) deploy IMG=$(K3D_IMG) .PHONY: diff --git a/config/samples/context/k3d/management-context-with-secret-ref.yaml b/config/samples/context/k3d/management-context-with-secret-ref.yaml new file mode 100644 index 000000000..b0bf0596c --- /dev/null +++ b/config/samples/context/k3d/management-context-with-secret-ref.yaml @@ -0,0 +1,29 @@ +# Copyright (C) 2015 The Gravitee team (http://gravitee.io) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use this context if you are running APIM and GKO in k3d +apiVersion: gravitee.io/v1alpha1 +kind: ManagementContext +metadata: + name: dev-mgmt-ctx + namespace: default +spec: + baseUrl: http://apim-apim3-api.apim-dev.svc:83 + environmentId: DEFAULT + organizationId: DEFAULT + auth: + secretRef: + name: apim-context-credentials + namespace: apim-dev + diff --git a/scripts/k3d.sh b/scripts/k3d.sh index 217da20ee..ff81a0b76 100755 --- a/scripts/k3d.sh +++ b/scripts/k3d.sh @@ -187,8 +187,8 @@ helm install \ --set livenessProbe.timeoutSeconds=30 \ --set resources.limits.memory=2048Mi \ --set resources.requests.memory=2048Mi \ - --set resources.limits.cpu=2000m \ - --set resources.requests.cpu=2000m \ + --set resources.limits.cpu=1000m \ + --set resources.requests.cpu=1000m \ mongodb bitnami/mongodb helm install \ diff --git a/test/apidefinition_controller_create_test.go b/test/apidefinition_controller_create_test.go index d2f88e81f..26231151e 100644 --- a/test/apidefinition_controller_create_test.go +++ b/test/apidefinition_controller_create_test.go @@ -99,9 +99,7 @@ var _ = Describe("Create", func() { var contextLookupKey types.NamespacedName BeforeEach(func() { - apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) @@ -277,9 +275,7 @@ var _ = Describe("Create", func() { DescribeTable("a featured API spec with a management context", func(specFile string) { - apiWithContext, err := internal.NewApiWithRandomContext( - specFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(specFile) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_delete_test.go b/test/apidefinition_controller_delete_test.go index 744e28a6c..91a552002 100644 --- a/test/apidefinition_controller_delete_test.go +++ b/test/apidefinition_controller_delete_test.go @@ -52,9 +52,8 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.BasicApiFile) + Expect(err).ToNot(HaveOccurred()) apiDefinition := apiWithContext.Api diff --git a/test/apidefinition_controller_error_test.go b/test/apidefinition_controller_error_test.go index 2b06ef6b9..9cf58d4ac 100644 --- a/test/apidefinition_controller_error_test.go +++ b/test/apidefinition_controller_error_test.go @@ -51,9 +51,7 @@ var _ = Describe("Checking NoneRecoverable && Recoverable error", Label("Disable BeforeEach(func() { By("Create a management context to synchronize with the REST API") - apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_plan_and_subscription_test.go b/test/apidefinition_controller_plan_and_subscription_test.go index f579f1cd3..551fd2c27 100644 --- a/test/apidefinition_controller_plan_and_subscription_test.go +++ b/test/apidefinition_controller_plan_and_subscription_test.go @@ -62,9 +62,8 @@ var _ = Describe("Checking ApiKey plan and subscription", Ordered, func() { BeforeAll(func() { By("Create a management context to synchronize with the REST API") - apiWithContext, err := internal.NewApiWithRandomContext( - internal.ApiWithApiKeyPlanFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.ApiWithApiKeyPlanFile) + Expect(err).ToNot(HaveOccurred()) managementContext := apiWithContext.Context diff --git a/test/apidefinition_controller_start_stop_test.go b/test/apidefinition_controller_start_stop_test.go index cedb1dad6..a8cdc937c 100644 --- a/test/apidefinition_controller_start_stop_test.go +++ b/test/apidefinition_controller_start_stop_test.go @@ -50,9 +50,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) diff --git a/test/apidefinition_controller_udpate_test.go b/test/apidefinition_controller_udpate_test.go index 4261a3d0e..e5795bf1a 100644 --- a/test/apidefinition_controller_udpate_test.go +++ b/test/apidefinition_controller_udpate_test.go @@ -112,9 +112,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) @@ -191,9 +189,7 @@ var _ = Describe("API Definition Controller", func() { BeforeEach(func() { By("Create a management context to synchronize with the REST API") - apiWithContext, err := internal.NewApiWithRandomContext( - internal.BasicApiFile, internal.ContextWithSecretFile, - ) + apiWithContext, err := internal.NewApiWithRandomContext(internal.BasicApiFile) Expect(err).ToNot(HaveOccurred()) diff --git a/test/internal/constants.go b/test/internal/constants.go index 3c95d2595..20776168f 100644 --- a/test/internal/constants.go +++ b/test/internal/constants.go @@ -19,7 +19,6 @@ import "time" const ( GatewayUrl = "http://localhost:9000/gateway" SamplesPath = "../config/samples" - ContextWithSecretFile = SamplesPath + "/context/dev/management-context-with-secret-ref.yaml" BasicApiFile = SamplesPath + "/apim/basic-api.yml" ApiWithDisabledHCFile = SamplesPath + "/apim/api-with-health-check-disabled.yml" ApiWithHCFile = SamplesPath + "/apim/api-with-health-check.yml" @@ -29,6 +28,10 @@ const ( ApiWithLoggingFile = SamplesPath + "/apim/api-with-logging.yml" ApiWithApiKeyPlanFile = SamplesPath + "/apim/api-with-api-key-plan.yml" + ciContextWithSecretFile = SamplesPath + "/context/k3d/management-context-with-secret-ref.yaml" + devContextWithSecretFile = SamplesPath + "/context/dev/management-context-with-secret-ref.yaml" contextWithCredentialsFile = SamplesPath + "/context/dev/management-context-with-credentials.yaml" apimClientTimeout = 5 * time.Second ) + +var RunInCluster = false diff --git a/test/internal/fixtures.go b/test/internal/fixtures.go index 3429249ca..5bcb04f56 100644 --- a/test/internal/fixtures.go +++ b/test/internal/fixtures.go @@ -59,8 +59,10 @@ func NewApiDefinition(path string, transforms ...func(*gio.ApiDefinition)) (*gio } func NewApiWithRandomContext( - apiPath string, contextPath string, transforms ...func(*ApiWithContext), + apiPath string, transforms ...func(*ApiWithContext), ) (*ApiWithContext, error) { + contextPath := getManagementContextPath() + api, err := NewApiDefinition(apiPath) if err != nil { return nil, err @@ -114,6 +116,13 @@ func newManagementContext(path string, transforms ...func(*gio.ManagementContext return ctx, nil } +func getManagementContextPath() string { + if RunInCluster { + return ciContextWithSecretFile + } + return devContextWithSecretFile +} + func addRandomSuffixes(api *gio.ApiDefinition) { suffix := "-" + uuid.NewV4().String()[:7] api.Name += suffix diff --git a/test/suite_test.go b/test/suite_test.go index 5faac3424..6f5137b10 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -39,6 +39,7 @@ import ( gio "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/apidefinition" "github.com/gravitee-io/gravitee-kubernetes-operator/controllers/apim/managementcontext" + "github.com/gravitee-io/gravitee-kubernetes-operator/test/internal" //+kubebuilder:scaffold:imports ) @@ -60,8 +61,6 @@ const ( interval = time.Millisecond * 250 ) -var startOperator = true - func TestAPIs(t *testing.T) { RegisterFailHandler(Fail) @@ -69,7 +68,7 @@ func TestAPIs(t *testing.T) { } var _ = SynchronizedBeforeSuite(func() { - if !startOperator { + if internal.RunInCluster { fmt.Fprintln(GinkgoWriter, "Assuming the operator has been deployed before running tests") return } @@ -220,7 +219,5 @@ func getEventsReason(apiDefinition *gio.ApiDefinition) []string { } func init() { - if os.Getenv("ENV") == "ci" { - startOperator = false - } + internal.RunInCluster = os.Getenv("ENV") == "ci" } From 13921439cad14c1d3af9e245f927246a522ab5ca Mon Sep 17 00:00:00 2001 From: Antoine CORDIER Date: Fri, 4 Nov 2022 07:34:44 +0100 Subject: [PATCH 54/54] chore: generate management context webhook --- .circleci/config.yml | 7 +- PROJECT | 4 + api/v1alpha1/managementcontext_types.go | 18 +- api/v1alpha1/managementcontext_webhook.go | 109 +++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 2 +- bundle.yml | 185 ++++++++++++++++--- config/certmanager/certificate.yaml | 25 +++ config/certmanager/kustomization.yaml | 5 + config/certmanager/kustomizeconfig.yaml | 16 ++ config/crd/kustomization.yaml | 6 +- config/default/kustomization.yaml | 60 +++--- config/default/manager_webhook_patch.yaml | 23 +++ config/default/webhookcainjection_patch.yaml | 15 ++ config/manager/kustomization.yaml | 4 +- config/webhook/kustomization.yaml | 6 + config/webhook/kustomizeconfig.yaml | 25 +++ config/webhook/manifests.yaml | 54 ++++++ config/webhook/service.yaml | 13 ++ go.mod | 2 + main.go | 4 + 20 files changed, 507 insertions(+), 76 deletions(-) create mode 100644 api/v1alpha1/managementcontext_webhook.go create mode 100644 config/certmanager/certificate.yaml create mode 100644 config/certmanager/kustomization.yaml create mode 100644 config/certmanager/kustomizeconfig.yaml create mode 100644 config/default/manager_webhook_patch.yaml create mode 100644 config/default/webhookcainjection_patch.yaml create mode 100644 config/webhook/kustomization.yaml create mode 100644 config/webhook/kustomizeconfig.yaml create mode 100644 config/webhook/manifests.yaml create mode 100644 config/webhook/service.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index 37c53193d..a869e87a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,13 +86,16 @@ jobs: name: Install ginkgo command: make ginkgo - run: - name: Start APIM using k3d + name: Start test cluster command: | export APIM_IMAGE_REGISTRY=graviteeio.azurecr.io export APIM_IMAGE_TAG=master-latest make k3d-apim-init - run: - name: Deploy Operator bundle + name: Install cert-manager on test cluster + command: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.0/cert-manager.yaml + - run: + name: Deploy operator on test cluster command: make k3d-gko-deploy - run: name: Run tests diff --git a/PROJECT b/PROJECT index 440fd4e29..0344c650e 100644 --- a/PROJECT +++ b/PROJECT @@ -23,4 +23,8 @@ resources: kind: ManagementContext path: github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1 version: v1alpha1 + webhooks: + defaulting: true + validation: true + webhookVersion: v1 version: "3" diff --git a/api/v1alpha1/managementcontext_types.go b/api/v1alpha1/managementcontext_types.go index 63be6ae96..7f859bf4a 100644 --- a/api/v1alpha1/managementcontext_types.go +++ b/api/v1alpha1/managementcontext_types.go @@ -60,25 +60,25 @@ func init() { SchemeBuilder.Register(&ManagementContext{}, &ManagementContextList{}) } -func (ctx *ManagementContext) HasAuthentication() bool { - return ctx.Spec.Auth != nil +func (r *ManagementContext) HasAuthentication() bool { + return r.Spec.Auth != nil } -func (ctx *ManagementContext) HasSecretRef() bool { - if !ctx.HasAuthentication() { +func (r *ManagementContext) HasSecretRef() bool { + if !r.HasAuthentication() { return false } - return ctx.Spec.Auth.SecretRef != nil + return r.Spec.Auth.SecretRef != nil } -func (ctx *ManagementContext) Authenticate(req *http.Request) { - if !ctx.HasAuthentication() { +func (r *ManagementContext) Authenticate(req *http.Request) { + if !r.HasAuthentication() { return } - bearerToken := ctx.Spec.Auth.BearerToken - basicAuth := ctx.Spec.Auth.Credentials + bearerToken := r.Spec.Auth.BearerToken + basicAuth := r.Spec.Auth.Credentials if bearerToken != "" { setBearerToken(req, bearerToken) diff --git a/api/v1alpha1/managementcontext_webhook.go b/api/v1alpha1/managementcontext_webhook.go new file mode 100644 index 000000000..2bfe33c26 --- /dev/null +++ b/api/v1alpha1/managementcontext_webhook.go @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2015 The Gravitee team (http://gravitee.io) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v1alpha1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + logr "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// log is for logging in this package. +var log = logr.Log.WithName("managementcontext-resource") + +type validator struct{} + +func (v *validator) ValidateCreate(ctx context.Context, obj runtime.Object) error { + req, err := admission.RequestFromContext(ctx) + if err != nil { + log.Error(err, "failed to get admission request") + } + log.Info("custom validate create", "request", req) + return nil +} + +func (v *validator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error { + req, err := admission.RequestFromContext(ctx) + if err != nil { + log.Error(err, "failed to get admission request") + } + + log.Info("custom validate update", "request", req) + return nil +} + +func (v *validator) ValidateDelete(ctx context.Context, obj runtime.Object) error { + return nil +} + +func (r *ManagementContext) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + WithValidator(&validator{}). + Complete() +} + +//+kubebuilder:webhook:path=/mutate-gravitee-io-v1alpha1-managementcontext,mutating=true,failurePolicy=fail,sideEffects=None,groups=gravitee.io,resources=managementcontexts,verbs=create;update,versions=v1alpha1,name=mmanagementcontext.kb.io,admissionReviewVersions=v1 + +var _ webhook.Defaulter = &ManagementContext{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type. +func (r *ManagementContext) Default() { + log.Info("default", "name", r.Name) + + // TODO(user): fill in your defaulting logic. +} + +// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. +//+kubebuilder:webhook:path=/validate-gravitee-io-v1alpha1-managementcontext,mutating=false,failurePolicy=fail,sideEffects=None,groups=gravitee.io,resources=managementcontexts,verbs=create;update,versions=v1alpha1,name=vmanagementcontext.kb.io,admissionReviewVersions=v1 + +var _ webhook.Validator = &ManagementContext{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (r *ManagementContext) ValidateCreate() error { + log.Info("validate create", "name", r.Name) + + err := errors.NewInvalid(GroupVersion.WithKind("ManagementContext").GroupKind(), r.Name, field.ErrorList{ + field.Invalid(field.NewPath("spec").Child("field"), "r.Spec.Field", "invalid value"), + }) + + err.ErrStatus.Code = 299 + + return err +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (r *ManagementContext) ValidateUpdate(old runtime.Object) error { + log.Info("validate update", "name", r.Name) + + // TODO(user): fill in your validation logic upon object update. + return nil +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (r *ManagementContext) ValidateDelete() error { + log.Info("validate delete", "name", r.Name) + + // TODO(user): fill in your validation logic upon object deletion. + return nil +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index b8e5664ed..539da7e45 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -23,7 +23,7 @@ package v1alpha1 import ( "github.com/gravitee-io/gravitee-kubernetes-operator/api/model" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/bundle.yml b/bundle.yml index 7ed03e0d5..5252f7195 100644 --- a/bundle.yml +++ b/bundle.yml @@ -23,8 +23,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null name: apidefinitions.gravitee.io spec: group: gravitee.io @@ -68,18 +68,25 @@ spec: description: ApiDefinition is the Schema for the apidefinitions API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: - description: APIDefinition represents the configuration for a single proxied API and it's versions. + description: APIDefinition represents the configuration for a single proxied + API and it's versions. properties: contextRef: - description: The context is specifying the namespace and the name of a ManagementContext used for managing the APIDefinition from the ManagementAPI + description: The context is specifying the namespace and the name + of a ManagementContext used for managing the APIDefinition from + the ManagementAPI properties: name: type: string @@ -111,7 +118,8 @@ spec: - BEST_MATCH type: string flows: - description: Paths map[string][]interface{} `json:"paths,omitempty"` // Different from Java + description: Paths map[string][]interface{} `json:"paths,omitempty"` + // Different from Java items: properties: condition: @@ -994,10 +1002,20 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + cert-manager.io/inject-ca-from: gko-system/gko-serving-cert controller-gen.kubebuilder.io/version: v0.9.0 - creationTimestamp: null name: managementcontexts.gravitee.io spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + name: gko-webhook-service + namespace: gko-system + path: /convert + conversionReviewVersions: + - v1 group: gravitee.io names: kind: ManagementContext @@ -1021,15 +1039,20 @@ spec: description: ManagementContext is the Schema for the Management API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: - description: ManagementContext represents the configuration for a Management API. + description: ManagementContext represents the configuration for a Management + API. properties: auth: properties: @@ -1334,6 +1357,19 @@ spec: selector: control-plane: controller-manager --- +apiVersion: v1 +kind: Service +metadata: + name: gko-webhook-service + namespace: gko-system +spec: + ports: + - port: 443 + protocol: TCP + targetPort: 9443 + selector: + control-plane: controller-manager +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -1354,31 +1390,13 @@ spec: control-plane: controller-manager spec: containers: - - args: - - --secure-listen-address=0.0.0.0:8443 - - --upstream=http://127.0.0.1:8080/ - - --logtostderr=true - - --v=0 - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 - name: kube-rbac-proxy - ports: - - containerPort: 8443 - name: https - protocol: TCP - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 5m - memory: 64Mi - args: - --health-probe-bind-address=:8081 - --metrics-bind-address=127.0.0.1:8080 - --leader-elect command: - /manager - image: graviteeio/kubernetes-operator:0.1.0-alpha.14 + image: k3d-graviteeio.docker.localhost:12345/gko:latest imagePullPolicy: Always livenessProbe: httpGet: @@ -1387,6 +1405,10 @@ spec: initialDelaySeconds: 15 periodSeconds: 20 name: manager + ports: + - containerPort: 9443 + name: webhook-server + protocol: TCP readinessProbe: httpGet: path: /readyz @@ -1402,7 +1424,112 @@ spec: memory: 64Mi securityContext: allowPrivilegeEscalation: false + volumeMounts: + - mountPath: /tmp/k8s-webhook-server/serving-certs + name: cert + readOnly: true + - args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=0 + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https + protocol: TCP + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi securityContext: runAsNonRoot: true serviceAccountName: gko-controller-manager terminationGracePeriodSeconds: 10 + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: webhook-server-cert +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: gko-serving-cert + namespace: gko-system +spec: + dnsNames: + - gko-webhook-service.gko-system.svc + - gko-webhook-service.gko-system.svc.cluster.local + issuerRef: + kind: Issuer + name: gko-selfsigned-issuer + secretName: webhook-server-cert +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: gko-selfsigned-issuer + namespace: gko-system +spec: + selfSigned: {} +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + annotations: + cert-manager.io/inject-ca-from: gko-system/gko-serving-cert + name: gko-mutating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: gko-webhook-service + namespace: gko-system + path: /mutate-gravitee-io-v1alpha1-managementcontext + failurePolicy: Fail + name: mmanagementcontext.kb.io + rules: + - apiGroups: + - gravitee.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - managementcontexts + sideEffects: None +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + annotations: + cert-manager.io/inject-ca-from: gko-system/gko-serving-cert + name: gko-validating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: gko-webhook-service + namespace: gko-system + path: /validate-gravitee-io-v1alpha1-managementcontext + failurePolicy: Fail + name: vmanagementcontext.kb.io + rules: + - apiGroups: + - gravitee.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - managementcontexts + sideEffects: None diff --git a/config/certmanager/certificate.yaml b/config/certmanager/certificate.yaml new file mode 100644 index 000000000..52d866183 --- /dev/null +++ b/config/certmanager/certificate.yaml @@ -0,0 +1,25 @@ +# The following manifests contain a self-signed issuer CR and a certificate CR. +# More document can be found at https://docs.cert-manager.io +# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes. +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: selfsigned-issuer + namespace: system +spec: + selfSigned: {} +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml + namespace: system +spec: + # $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize + dnsNames: + - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc + - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local + issuerRef: + kind: Issuer + name: selfsigned-issuer + secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize diff --git a/config/certmanager/kustomization.yaml b/config/certmanager/kustomization.yaml new file mode 100644 index 000000000..bebea5a59 --- /dev/null +++ b/config/certmanager/kustomization.yaml @@ -0,0 +1,5 @@ +resources: +- certificate.yaml + +configurations: +- kustomizeconfig.yaml diff --git a/config/certmanager/kustomizeconfig.yaml b/config/certmanager/kustomizeconfig.yaml new file mode 100644 index 000000000..90d7c313c --- /dev/null +++ b/config/certmanager/kustomizeconfig.yaml @@ -0,0 +1,16 @@ +# This configuration is for teaching kustomize how to update name ref and var substitution +nameReference: +- kind: Issuer + group: cert-manager.io + fieldSpecs: + - kind: Certificate + group: cert-manager.io + path: spec/issuerRef/name + +varReference: +- kind: Certificate + group: cert-manager.io + path: spec/commonName +- kind: Certificate + group: cert-manager.io + path: spec/dnsNames diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index e6d820490..dbbbbd850 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -24,13 +24,13 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_apidefinitions.yaml -#- patches/webhook_in_managementcontexts.yaml + - patches/webhook_in_managementcontexts.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD - - patches/cainjection_in_apidefinitions.yaml -#- patches/cainjection_in_managementcontexts.yaml +#- patches/cainjection_in_apidefinitions.yaml + - patches/cainjection_in_managementcontexts.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index aa73b4e9b..9f071da17 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -32,9 +32,9 @@ bases: - ../manager # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -#- ../webhook +- ../webhook # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. -#- ../certmanager +- ../certmanager # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. #- ../prometheus @@ -50,39 +50,39 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -#- manager_webhook_patch.yaml +- manager_webhook_patch.yaml # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. # 'CERTMANAGER' needs to be enabled to use ca injection -#- webhookcainjection_patch.yaml +- webhookcainjection_patch.yaml # the following config is for teaching kustomize how to do var substitution vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldref: -# fieldpath: metadata.namespace -#- name: CERTIFICATE_NAME -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -#- name: SERVICE_NAMESPACE # namespace of the service -# objref: -# kind: Service -# version: v1 -# name: webhook-service -# fieldref: -# fieldpath: metadata.namespace -#- name: SERVICE_NAME -# objref: -# kind: Service -# version: v1 -# name: webhook-service +- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR + objref: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + fieldref: + fieldpath: metadata.namespace +- name: CERTIFICATE_NAME + objref: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml +- name: SERVICE_NAMESPACE # namespace of the service + objref: + kind: Service + version: v1 + name: webhook-service + fieldref: + fieldpath: metadata.namespace +- name: SERVICE_NAME + objref: + kind: Service + version: v1 + name: webhook-service diff --git a/config/default/manager_webhook_patch.yaml b/config/default/manager_webhook_patch.yaml new file mode 100644 index 000000000..738de350b --- /dev/null +++ b/config/default/manager_webhook_patch.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: controller-manager + namespace: system +spec: + template: + spec: + containers: + - name: manager + ports: + - containerPort: 9443 + name: webhook-server + protocol: TCP + volumeMounts: + - mountPath: /tmp/k8s-webhook-server/serving-certs + name: cert + readOnly: true + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: webhook-server-cert diff --git a/config/default/webhookcainjection_patch.yaml b/config/default/webhookcainjection_patch.yaml new file mode 100644 index 000000000..02ab515d4 --- /dev/null +++ b/config/default/webhookcainjection_patch.yaml @@ -0,0 +1,15 @@ +# This patch add annotation to admission webhook config and +# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + name: mutating-webhook-configuration + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: validating-webhook-configuration + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index ce0841304..3c7391fd0 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -26,5 +26,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: graviteeio/kubernetes-operator - newTag: 0.1.0-alpha.12 + newName: k3d-graviteeio.docker.localhost:12345/gko + newTag: latest diff --git a/config/webhook/kustomization.yaml b/config/webhook/kustomization.yaml new file mode 100644 index 000000000..9cf26134e --- /dev/null +++ b/config/webhook/kustomization.yaml @@ -0,0 +1,6 @@ +resources: +- manifests.yaml +- service.yaml + +configurations: +- kustomizeconfig.yaml diff --git a/config/webhook/kustomizeconfig.yaml b/config/webhook/kustomizeconfig.yaml new file mode 100644 index 000000000..25e21e3c9 --- /dev/null +++ b/config/webhook/kustomizeconfig.yaml @@ -0,0 +1,25 @@ +# the following config is for teaching kustomize where to look at when substituting vars. +# It requires kustomize v2.1.0 or newer to work properly. +nameReference: +- kind: Service + version: v1 + fieldSpecs: + - kind: MutatingWebhookConfiguration + group: admissionregistration.k8s.io + path: webhooks/clientConfig/service/name + - kind: ValidatingWebhookConfiguration + group: admissionregistration.k8s.io + path: webhooks/clientConfig/service/name + +namespace: +- kind: MutatingWebhookConfiguration + group: admissionregistration.k8s.io + path: webhooks/clientConfig/service/namespace + create: true +- kind: ValidatingWebhookConfiguration + group: admissionregistration.k8s.io + path: webhooks/clientConfig/service/namespace + create: true + +varReference: +- path: metadata/annotations diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml new file mode 100644 index 000000000..bb7f12758 --- /dev/null +++ b/config/webhook/manifests.yaml @@ -0,0 +1,54 @@ +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + creationTimestamp: null + name: mutating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-gravitee-io-v1alpha1-managementcontext + failurePolicy: Fail + name: mmanagementcontext.kb.io + rules: + - apiGroups: + - gravitee.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - managementcontexts + sideEffects: None +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + creationTimestamp: null + name: validating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-gravitee-io-v1alpha1-managementcontext + failurePolicy: Fail + name: vmanagementcontext.kb.io + rules: + - apiGroups: + - gravitee.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - managementcontexts + sideEffects: None diff --git a/config/webhook/service.yaml b/config/webhook/service.yaml new file mode 100644 index 000000000..3f638bd9c --- /dev/null +++ b/config/webhook/service.yaml @@ -0,0 +1,13 @@ + +apiVersion: v1 +kind: Service +metadata: + name: webhook-service + namespace: system +spec: + ports: + - port: 443 + protocol: TCP + targetPort: 9443 + selector: + control-plane: controller-manager diff --git a/go.mod b/go.mod index 492e3431f..4dc0b44f3 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,8 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/nxadm/tail v1.4.8 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect ) require ( diff --git a/main.go b/main.go index c918d42de..3a0f7c591 100644 --- a/main.go +++ b/main.go @@ -114,6 +114,10 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "Ingress") os.Exit(1) } + if err = (&gio.ManagementContext{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "ManagementContext") + os.Exit(1) + } //+kubebuilder:scaffold:builder if healthCheckErr := mgr.AddHealthzCheck("healthz", healthz.Ping); healthCheckErr != nil {
NameTypeDescriptionRequired
requestbooleanscopeenum
-
false
responseboolean
+ Enum: NONE, REQUEST, RESPONSE, REQUEST_RESPONSE
false