From c8dbf0fb83d45c73686116d7af17487890cd2ca8 Mon Sep 17 00:00:00 2001 From: Varsha Prasad Narsing Date: Fri, 27 Oct 2023 18:30:11 -0400 Subject: [PATCH] [Add] CEL rules for validating App and PackageInstall Spec This PR: - Adds KB marker to ensure that either spec.ServiceAccount or spec.Cluster is present in App and PackageInstall CR. - Bumps controller-tools to 0.10.0 to support CEL based validation marker. That is the latest version compatible with the k8s release the project is currently at. Signed-off-by: Varsha Prasad Narsing --- config/config/crds.yml | 9 + go.mod | 4 +- go.sum | 55 +--- pkg/apis/kappctrl/v1alpha1/types.go | 1 + .../packaging/v1alpha1/package_install.go | 1 + vendor/github.com/gobuffalo/flect/camelize.go | 4 - .../github.com/gobuffalo/flect/pascalize.go | 11 +- .../gobuffalo/flect/plural_rules.go | 15 +- .../gobuffalo/flect/singular_rules.go | 8 +- vendor/modules.txt | 6 +- .../cmd/controller-gen/main.go | 2 +- .../controller-tools/pkg/crd/doc.go | 8 +- .../controller-tools/pkg/crd/flatten.go | 4 + .../controller-tools/pkg/crd/gen.go | 39 ++- .../controller-tools/pkg/crd/known_types.go | 5 +- .../controller-tools/pkg/crd/markers/doc.go | 6 +- .../pkg/crd/markers/topology.go | 42 +-- .../pkg/crd/markers/validation.go | 105 +++++-- .../crd/markers/zz_generated.markerhelp.go | 29 +- .../controller-tools/pkg/crd/parser.go | 5 +- .../controller-tools/pkg/crd/schema.go | 26 +- .../controller-tools/pkg/crd/spec.go | 8 +- .../pkg/crd/zz_generated.markerhelp.go | 5 + .../controller-tools/pkg/deepcopy/gen.go | 3 +- .../pkg/deepcopy/zz_generated.markerhelp.go | 1 + .../controller-tools/pkg/genall/doc.go | 8 +- .../controller-tools/pkg/genall/genall.go | 56 +++- .../pkg/genall/help/pretty/doc.go | 4 +- .../controller-tools/pkg/genall/options.go | 2 + .../pkg/genall/zz_generated.markerhelp.go | 5 +- .../controller-tools/pkg/loader/doc.go | 8 +- .../controller-tools/pkg/loader/loader.go | 277 +++++++++++++++++- .../controller-tools/pkg/loader/refs.go | 11 +- .../controller-tools/pkg/markers/collect.go | 12 +- .../controller-tools/pkg/markers/doc.go | 22 +- .../controller-tools/pkg/markers/parse.go | 44 ++- .../controller-tools/pkg/markers/reg.go | 3 +- .../controller-tools/pkg/markers/zip.go | 22 +- .../controller-tools/pkg/rbac/parser.go | 4 +- .../pkg/rbac/zz_generated.markerhelp.go | 1 + .../controller-tools/pkg/schemapatcher/gen.go | 12 +- .../schemapatcher/zz_generated.markerhelp.go | 1 + .../controller-tools/pkg/version/version.go | 12 +- .../controller-tools/pkg/webhook/parser.go | 27 +- .../pkg/webhook/zz_generated.markerhelp.go | 5 + 45 files changed, 724 insertions(+), 214 deletions(-) diff --git a/config/config/crds.yml b/config/config/crds.yml index 38e4f04245..812426526c 100644 --- a/config/config/crds.yml +++ b/config/config/crds.yml @@ -690,6 +690,9 @@ spec: type: object type: array type: object + x-kubernetes-validations: + - message: Expected service account or cluster. + rule: has(self.serviceAccountName) || has(self.cluster) required: - spec type: object @@ -1306,6 +1309,9 @@ spec: type: object type: array type: object + x-kubernetes-validations: + - message: Expected service account or cluster. + rule: has(self.serviceAccountName) || has(self.cluster) status: properties: conditions: @@ -1555,6 +1561,9 @@ spec: type: object type: array type: object + x-kubernetes-validations: + - message: Expected service account or cluster. + rule: has(self.serviceAccountName) || has(self.cluster) status: properties: conditions: diff --git a/go.mod b/go.mod index b21b59d91c..41586d93ca 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( k8s.io/kube-aggregator v0.22.17 k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 sigs.k8s.io/controller-runtime v0.13.1 - sigs.k8s.io/controller-tools v0.7.0 + sigs.k8s.io/controller-tools v0.10.0 sigs.k8s.io/yaml v1.3.0 ) @@ -61,7 +61,7 @@ require ( github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect github.com/go-openapi/swag v0.19.15 // indirect - github.com/gobuffalo/flect v0.2.3 // indirect + github.com/gobuffalo/flect v0.2.5 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect diff --git a/go.sum b/go.sum index 09a966efab..0d692bb2c1 100644 --- a/go.sum +++ b/go.sum @@ -53,7 +53,6 @@ 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/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= @@ -122,7 +121,6 @@ github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQL 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/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= @@ -168,9 +166,8 @@ github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/ github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gobuffalo/flect v0.2.3 h1:f/ZukRnSNA/DUpSNDadko7Qc0PhGvsew35p/2tu+CRY= -github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= +github.com/gobuffalo/flect v0.2.5 h1:H6vvsv2an0lalEaCDRThvtBfmg44W/QHXBCYUXf/6S4= +github.com/gobuffalo/flect v0.2.5/go.mod h1:1ZyCLIbg0YD7sDkzvFdPoOydPtD8y9JQnrOROolUcM8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= 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= @@ -215,10 +212,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/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/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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= @@ -300,7 +295,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI 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= @@ -313,14 +307,12 @@ 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/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= 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-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= @@ -343,7 +335,6 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 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-20210610120745-9d4ed1856297/go.mod h1:vgPCkQMyxTZ7IDy8SXRufE172gr8+K/JE/7hHFxHW3A= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -369,7 +360,6 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.6 h1:Fx2POJZfKRQcM1pH49qSZiYeu319wji004qX+GDovrU= @@ -377,19 +367,16 @@ github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7 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.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= 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/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/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/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= @@ -452,19 +439,15 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.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/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= 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= @@ -522,7 +505,6 @@ 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= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/contrib v0.20.0 h1:ubFQUn0VCZ0gPwIoJfBJVpeBlyRMxu8Mm/huKWYd9p0= 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 h1:sO4WKdPAudZGKPcpZT4MJn6JaDmpyLrMPDGGyA1SttE= @@ -567,7 +549,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf 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= @@ -590,7 +571,6 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -631,13 +611,9 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/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-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -649,7 +625,6 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= @@ -705,11 +680,7 @@ golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7w 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-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-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-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -781,9 +752,7 @@ golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/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= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= @@ -805,7 +774,6 @@ google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/ google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -836,7 +804,6 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5/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-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= @@ -851,9 +818,7 @@ google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= @@ -884,7 +849,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= 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= @@ -912,30 +876,23 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.22.2/go.mod h1:y3ydYpLJAaDI+BbSe2xmGcqxiWHmWjkEeIbiwHvnPR8= k8s.io/api v0.22.17/go.mod h1:6qVojJ3y+qIq7JSMwTH0BcPHl3dch4HefIC+4nguZhs= k8s.io/api v0.25.6 h1:LwDY2H6kD/3R8TekJYYaJWOdekNdXDO44eVpX6sNtJA= k8s.io/api v0.25.6/go.mod h1:bVp01KUcl8VUHFBTJMOknWNo7XvR0cMbeTTuFg1zCUs= -k8s.io/apiextensions-apiserver v0.22.2/go.mod h1:2E0Ve/isxNl7tWLSUDgi6+cmwHi5fQRdwGVCxbC+KFA= 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.22.2/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= k8s.io/apimachinery v0.22.17/go.mod h1:ZvVLP5iLhwVFg2Yx9Gh5W0um0DUauExbRhe+2Z8I1EU= k8s.io/apimachinery v0.25.6 h1:r6KIF2AHwLqFfZ0LcOA3I11SF62YZK83dxj1fn14NOQ= k8s.io/apimachinery v0.25.6/go.mod h1:1S2i1QHkmxc8+EZCIxe/fX5hpldVXk4gvnJInMEb8D4= -k8s.io/apiserver v0.22.2/go.mod h1:vrpMmbyjWrgdyOvZTSpsusQq5iigKNWv9o9KlDAbBHI= k8s.io/apiserver v0.22.17/go.mod h1:zNXYCtXZ91AkmIUZgQ8lT9vdlDqgSkokJpds/F6DdGU= k8s.io/apiserver v0.25.6 h1:32mn8HAlsEl1tpuiVmhAl0YCVkOugjybsJ6l6kf0c8k= k8s.io/apiserver v0.25.6/go.mod h1:IEp2B2/FvQ8GmdspscUoUS0iFF/GGc6NVrJ/cTM4OaA= -k8s.io/client-go v0.22.2/go.mod h1:sAlhrkVDf50ZHx6z4K0S40wISNTarf1r800F+RlCF6U= k8s.io/client-go v0.22.17/go.mod h1:SQPVpN+E/5Q/aSV7fYDT8VKVdaljhxI/t/84ADVJoC4= k8s.io/client-go v0.25.6 h1:CHxACHi0DijmlYyUR7ooZoXnD5P8jYLgBHcxp775x/U= k8s.io/client-go v0.25.6/go.mod h1:s9mMAGFYiH3Z66j7BESzu0GEradT9GQ2LjFf/YRrnyc= -k8s.io/code-generator v0.22.2/go.mod h1:eV77Y09IopzeXOJzndrDyCI88UBok2h6WxAlBwpxa+o= k8s.io/code-generator v0.22.17/go.mod h1:iOZwYADSgFPNGWfqHFfg1V0TNJnl1t0WyZluQp4baqU= k8s.io/code-generator v0.25.6 h1:md8jqhQiMqos8WaTY0ZxhDk8ttlmJl/ijCneJ8ahBNQ= k8s.io/code-generator v0.25.6/go.mod h1:aDxzxJynLKQkaa117y0FFcgZ5jG8+GobxZ2JUntmvKk= -k8s.io/component-base v0.22.2/go.mod h1:5Br2QhI9OTe79p+TzPe9JKNQYvEKbq9rTJDWllunGug= k8s.io/component-base v0.22.17/go.mod h1:Mrcvmxs+Ctx/xCYGWoFAvfZO9DC4gDgLtUbPJ4PjjUE= k8s.io/component-base v0.25.6 h1:v3ci6FbXFcxpjyQJaaLq0MgzT3vyFzwUDWtO+KRv9Bk= k8s.io/component-base v0.25.6/go.mod h1:k7DfcfJ8cOI6A2xTCfU5LxsnXV+lWw1ME8cRCHzIh6o= @@ -950,28 +907,24 @@ k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-aggregator v0.22.17 h1:E8T1McXbB31Z7L71nR8/lMtWS01bhOE7AF8TF/sqDHw= k8s.io/kube-aggregator v0.22.17/go.mod h1:J557nueFVurHA1JiDrxT1HlgygNQ+2exsTVUXiz2T7k= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= 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-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20211116205334-6203023598ed/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/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.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 h1:+xBL5uTc+BkPBwmMi3vYfUJjq+N3K+H6PXeETwf5cPI= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35/go.mod h1:WxjusMwXlKzfAs4p9km6XJRndVt2FROgMVCE4cdohFo= sigs.k8s.io/controller-runtime v0.13.1 h1:tUsRCSJVM1QQOOeViGeX3GMT3dQF1eePPw6sEE3xSlg= sigs.k8s.io/controller-runtime v0.13.1/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= -sigs.k8s.io/controller-tools v0.7.0 h1:iZIz1vEcavyEfxjcTLs1WH/MPf4vhPCtTKhoHqV8/G0= -sigs.k8s.io/controller-tools v0.7.0/go.mod h1:bpBAo0VcSDDLuWt47evLhMLPxRPxMDInTEH/YbdeMK0= +sigs.k8s.io/controller-tools v0.10.0 h1:0L5DTDTFB67jm9DkfrONgTGmfc/zYow0ZaHyppizU2U= +sigs.k8s.io/controller-tools v0.10.0/go.mod h1:uvr0EW6IsprfB0jpQq6evtKy+hHyHCXNfdWI5ONPx94= 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.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= 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= diff --git a/pkg/apis/kappctrl/v1alpha1/types.go b/pkg/apis/kappctrl/v1alpha1/types.go index dc89189e4a..a50a2493af 100644 --- a/pkg/apis/kappctrl/v1alpha1/types.go +++ b/pkg/apis/kappctrl/v1alpha1/types.go @@ -44,6 +44,7 @@ type AppList struct { } // +k8s:openapi-gen=true +// +kubebuilder:validation:XValidation:rule="has(self.serviceAccountName) || has(self.cluster)", message="Expected service account or cluster." type AppSpec struct { // Specifies that app should be deployed authenticated via // given service account, found in this namespace (optional; v0.6.0+) diff --git a/pkg/apis/packaging/v1alpha1/package_install.go b/pkg/apis/packaging/v1alpha1/package_install.go index 0195b08409..787cdb7e54 100644 --- a/pkg/apis/packaging/v1alpha1/package_install.go +++ b/pkg/apis/packaging/v1alpha1/package_install.go @@ -43,6 +43,7 @@ type PackageInstallList struct { Items []PackageInstall `json:"items"` } +// +kubebuilder:validation:XValidation:rule="has(self.serviceAccountName) || has(self.cluster)", message="Expected service account or cluster." type PackageInstallSpec struct { // Specifies service account that will be used to install underlying package contents // +optional diff --git a/vendor/github.com/gobuffalo/flect/camelize.go b/vendor/github.com/gobuffalo/flect/camelize.go index 8a9928e8be..d8851c8f5e 100644 --- a/vendor/github.com/gobuffalo/flect/camelize.go +++ b/vendor/github.com/gobuffalo/flect/camelize.go @@ -22,10 +22,6 @@ func (i Ident) Camelize() Ident { for i, part := range i.Parts { var x string var capped bool - if strings.ToLower(part) == "id" { - out = append(out, "ID") - continue - } for _, c := range part { if unicode.IsLetter(c) || unicode.IsDigit(c) { if i == 0 { diff --git a/vendor/github.com/gobuffalo/flect/pascalize.go b/vendor/github.com/gobuffalo/flect/pascalize.go index 76f0c6a706..6396d0d4e7 100644 --- a/vendor/github.com/gobuffalo/flect/pascalize.go +++ b/vendor/github.com/gobuffalo/flect/pascalize.go @@ -1,7 +1,7 @@ package flect import ( - "unicode" + "strings" ) // Pascalize returns a string with each segment capitalized @@ -21,5 +21,12 @@ func (i Ident) Pascalize() Ident { if len(c.String()) == 0 { return c } - return New(string(unicode.ToUpper(rune(c.Original[0]))) + c.Original[1:]) + if len(i.Parts) == 0 { + return i + } + capLen := 1 + if _, ok := baseAcronyms[strings.ToUpper(i.Parts[0])]; ok { + capLen = len(i.Parts[0]) + } + return New(string(strings.ToUpper(c.Original[0:capLen])) + c.Original[capLen:]) } diff --git a/vendor/github.com/gobuffalo/flect/plural_rules.go b/vendor/github.com/gobuffalo/flect/plural_rules.go index ff67928438..61d34d393b 100644 --- a/vendor/github.com/gobuffalo/flect/plural_rules.go +++ b/vendor/github.com/gobuffalo/flect/plural_rules.go @@ -6,18 +6,18 @@ var pluralRules = []rule{} func AddPlural(suffix string, repl string) { pluralMoot.Lock() defer pluralMoot.Unlock() - pluralRules = append(pluralRules, rule{ + pluralRules = append([]rule{{ suffix: suffix, fn: func(s string) string { s = s[:len(s)-len(suffix)] return s + repl }, - }) + }}, pluralRules...) - pluralRules = append(pluralRules, rule{ + pluralRules = append([]rule{{ suffix: repl, fn: noop, - }) + }}, pluralRules...) } var singleToPlural = map[string]string{ @@ -224,7 +224,6 @@ var singularToPluralSuffixList = []singularToPluralSuffix{ {"oci", "ocus"}, {"ode", "odes"}, {"ofe", "oves"}, - {"oot", "eet"}, {"pfe", "pves"}, {"pse", "psis"}, {"qfe", "qves"}, @@ -281,8 +280,8 @@ var singularToPluralSuffixList = []singularToPluralSuffix{ } func init() { - for _, suffix := range singularToPluralSuffixList { - AddPlural(suffix.singular, suffix.plural) - AddSingular(suffix.plural, suffix.singular) + for i := len(singularToPluralSuffixList) - 1; i >= 0; i-- { + AddPlural(singularToPluralSuffixList[i].singular, singularToPluralSuffixList[i].plural) + AddSingular(singularToPluralSuffixList[i].plural, singularToPluralSuffixList[i].singular) } } diff --git a/vendor/github.com/gobuffalo/flect/singular_rules.go b/vendor/github.com/gobuffalo/flect/singular_rules.go index b20371b355..9b85a873b9 100644 --- a/vendor/github.com/gobuffalo/flect/singular_rules.go +++ b/vendor/github.com/gobuffalo/flect/singular_rules.go @@ -6,18 +6,18 @@ var singularRules = []rule{} func AddSingular(ext string, repl string) { singularMoot.Lock() defer singularMoot.Unlock() - singularRules = append(singularRules, rule{ + singularRules = append([]rule{{ suffix: ext, fn: func(s string) string { s = s[:len(s)-len(ext)] return s + repl }, - }) + }}, singularRules...) - singularRules = append(singularRules, rule{ + singularRules = append([]rule{{ suffix: repl, fn: func(s string) string { return s }, - }) + }}, singularRules...) } diff --git a/vendor/modules.txt b/vendor/modules.txt index a863317551..3106911910 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -79,7 +79,7 @@ github.com/go-openapi/jsonreference # github.com/go-openapi/swag v0.19.15 ## explicit; go 1.11 github.com/go-openapi/swag -# github.com/gobuffalo/flect v0.2.3 +# github.com/gobuffalo/flect v0.2.5 ## explicit; go 1.13 github.com/gobuffalo/flect # github.com/gogo/protobuf v1.3.2 @@ -1248,8 +1248,8 @@ sigs.k8s.io/controller-runtime/pkg/source/internal sigs.k8s.io/controller-runtime/pkg/webhook sigs.k8s.io/controller-runtime/pkg/webhook/admission sigs.k8s.io/controller-runtime/pkg/webhook/internal/metrics -# sigs.k8s.io/controller-tools v0.7.0 -## explicit; go 1.16 +# sigs.k8s.io/controller-tools v0.10.0 +## explicit; go 1.19 sigs.k8s.io/controller-tools/cmd/controller-gen sigs.k8s.io/controller-tools/pkg/crd sigs.k8s.io/controller-tools/pkg/crd/markers diff --git a/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go b/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go index 692b26c8da..c27bcda42c 100644 --- a/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go +++ b/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go @@ -5,7 +5,7 @@ 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 + 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, diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/doc.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/doc.go index fd48e44aec..914af94d91 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/doc.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/doc.go @@ -17,14 +17,14 @@ limitations under the License. // Package crd contains utilities for generating CustomResourceDefinitions and // their corresponding OpenAPI validation schemata. // -// Markers +// # Markers // // Markers live under the markers subpackage. Two types of markers exist: // those that modify schema generation (for validation), and those that modify // the rest of the CRD. See the subpackage for more information and all // supported markers. // -// Collecting Types and Generating CRDs +// # Collecting Types and Generating CRDs // // The Parser is the entrypoint for collecting the information required to // generate CRDs. Like loader and collector, its methods are idemptotent, not @@ -40,13 +40,13 @@ limitations under the License. // Errors are generally attached directly to the relevant Package with // AddError. // -// Known Packages +// # Known Packages // // There are a few types from Kubernetes that have special meaning, but don't // have validation markers attached. Those specific types have overrides // listed in KnownPackages that can be added as overrides to any parser. // -// Flattening +// # Flattening // // Once schemata are generated, they can be used directly by external tooling // (like JSONSchema validators), but must first be "flattened" to not contain diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/flatten.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/flatten.go index 00f4dc4c7d..9224c26b27 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/flatten.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/flatten.go @@ -143,6 +143,10 @@ func flattenAllOfInto(dst *apiext.JSONSchemaProps, src apiext.JSONSchemaProps, e dstProps.Schema = &apiext.JSONSchemaProps{} } flattenAllOfInto(dstProps.Schema, *srcProps.Schema, errRec) + case "XPreserveUnknownFields": + dstField.Set(srcField) + case "XMapType": + dstField.Set(srcField) // NB(directxman12): no need to explicitly handle nullable -- false is considered to be the zero value // TODO(directxman12): src isn't necessarily the field value -- it's just the most recent allOf entry default: diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/gen.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/gen.go index 9959874624..c6c5f88b8d 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/gen.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/gen.go @@ -20,6 +20,7 @@ import ( "fmt" "go/ast" "go/types" + "sort" apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -41,6 +42,11 @@ const defaultVersion = v1 // Generator generates CustomResourceDefinition objects. type Generator struct { + // IgnoreUnexportedFields indicates that we should skip unexported fields. + // + // Left unspecified, the default is false. + IgnoreUnexportedFields *bool `marker:",optional"` + // AllowDangerousTypes allows types which are usually omitted from CRD generation // because they are not recommended. // @@ -80,12 +86,20 @@ func (Generator) CheckFilter() loader.NodeFilter { func (Generator) RegisterMarkers(into *markers.Registry) error { return crdmarkers.Register(into) } + +// transformRemoveCRDStatus ensures we do not write the CRD status field. +func transformRemoveCRDStatus(obj map[string]interface{}) error { + delete(obj, "status") + return nil +} + func (g Generator) Generate(ctx *genall.GenerationContext) error { parser := &Parser{ Collector: ctx.Collector, Checker: ctx.Checker, // Perform defaulting here to avoid ambiguity later - AllowDangerousTypes: g.AllowDangerousTypes != nil && *g.AllowDangerousTypes == true, + IgnoreUnexportedFields: g.IgnoreUnexportedFields != nil && *g.IgnoreUnexportedFields == true, + AllowDangerousTypes: g.AllowDangerousTypes != nil && *g.AllowDangerousTypes == true, // Indicates the parser on whether to register the ObjectMeta type or not GenerateEmbeddedObjectMeta: g.GenerateEmbeddedObjectMeta != nil && *g.GenerateEmbeddedObjectMeta == true, } @@ -114,7 +128,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error { crdVersions = []string{defaultVersion} } - for groupKind := range kubeKinds { + for _, groupKind := range kubeKinds { parser.NeedCRDFor(groupKind, g.MaxDescLen) crdRaw := parser.CustomResourceDefinitions[groupKind] addAttribution(&crdRaw) @@ -139,7 +153,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error { } else { fileName = fmt.Sprintf("%s_%s.%s.yaml", crdRaw.Spec.Group, crdRaw.Spec.Names.Plural, crdVersions[i]) } - if err := ctx.WriteYAML(fileName, crd); err != nil { + if err := ctx.WriteYAML(fileName, []interface{}{crd}, genall.WithTransform(transformRemoveCRDStatus)); err != nil { return err } } @@ -203,7 +217,7 @@ func FindMetav1(roots []*loader.Package) *loader.Package { // FindKubeKinds locates all types that contain TypeMeta and ObjectMeta // (and thus may be a Kubernetes object), and returns the corresponding // group-kinds. -func FindKubeKinds(parser *Parser, metav1Pkg *loader.Package) map[schema.GroupKind]struct{} { +func FindKubeKinds(parser *Parser, metav1Pkg *loader.Package) []schema.GroupKind { // TODO(directxman12): technically, we should be finding metav1 per-package kubeKinds := map[schema.GroupKind]struct{}{} for typeIdent, info := range parser.Types { @@ -234,7 +248,12 @@ func FindKubeKinds(parser *Parser, metav1Pkg *loader.Package) map[schema.GroupKi } fieldPkgPath := loader.NonVendorPath(namedField.Obj().Pkg().Path()) fieldPkg := pkg.Imports()[fieldPkgPath] - if fieldPkg != metav1Pkg { + + // Compare the metav1 package by ID and not by the actual instance + // of the object. The objects in memory could be different due to + // loading from different root paths, even when they both refer to + // the same metav1 package. + if fieldPkg == nil || fieldPkg.ID != metav1Pkg.ID { continue } @@ -257,7 +276,15 @@ func FindKubeKinds(parser *Parser, metav1Pkg *loader.Package) map[schema.GroupKi kubeKinds[groupKind] = struct{}{} } - return kubeKinds + groupKindList := make([]schema.GroupKind, 0, len(kubeKinds)) + for groupKind := range kubeKinds { + groupKindList = append(groupKindList, groupKind) + } + sort.Slice(groupKindList, func(i, j int) bool { + return groupKindList[i].String() < groupKindList[j].String() + }) + + return groupKindList } // filterTypesForCRDs filters out all nodes that aren't used in CRD generation, diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/known_types.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/known_types.go index 7e862cfb17..9e8decb286 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/known_types.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/known_types.go @@ -5,7 +5,7 @@ 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 + 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, @@ -74,7 +74,8 @@ var KnownPackages = map[string]PackageOverride{ "k8s.io/apimachinery/pkg/runtime": func(p *Parser, pkg *loader.Package) { p.Schemata[TypeIdent{Name: "RawExtension", Package: pkg}] = apiext.JSONSchemaProps{ // TODO(directxman12): regexp validation for this (or get kube to support it as a format value) - Type: "object", + Type: "object", + XPreserveUnknownFields: boolPtr(true), } p.AddPackage(pkg) // get the rest of the types }, diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/doc.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/doc.go index 48736401cf..995af44b37 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/doc.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/doc.go @@ -19,7 +19,7 @@ limitations under the License. // // All markers related to CRD generation live in AllDefinitions. // -// Validation Markers +// # Validation Markers // // Validation markers have values that implement ApplyToSchema // (crd.SchemaMarker). Any marker implementing this will automatically @@ -31,7 +31,7 @@ limitations under the License. // All validation markers start with "+kubebuilder:validation", and // have the same name as their type name. // -// CRD Markers +// # CRD Markers // // Markers that modify anything in the CRD itself *except* for the schema // implement ApplyToCRD (crd.CRDMarker). They are expected to detect whether @@ -39,7 +39,7 @@ limitations under the License. // them), or to the root-level CRD for legacy cases. They are applied *after* // the rest of the CRD is computed. // -// Misc +// # Misc // // This package also defines the "+groupName" and "+versionName" package-level // markers, for defining package<->group-version mappings. diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/topology.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/topology.go index 0f4a94b180..a92995c802 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/topology.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/topology.go @@ -28,12 +28,20 @@ import ( var TopologyMarkers = []*definitionWithHelp{ must(markers.MakeDefinition("listMapKey", markers.DescribesField, ListMapKey(""))). WithHelp(ListMapKey("").Help()), + must(markers.MakeDefinition("listMapKey", markers.DescribesType, ListMapKey(""))). + WithHelp(ListMapKey("").Help()), must(markers.MakeDefinition("listType", markers.DescribesField, ListType(""))). WithHelp(ListType("").Help()), + must(markers.MakeDefinition("listType", markers.DescribesType, ListType(""))). + WithHelp(ListType("").Help()), must(markers.MakeDefinition("mapType", markers.DescribesField, MapType(""))). WithHelp(MapType("").Help()), + must(markers.MakeDefinition("mapType", markers.DescribesType, MapType(""))). + WithHelp(MapType("").Help()), must(markers.MakeDefinition("structType", markers.DescribesField, StructType(""))). WithHelp(StructType("").Help()), + must(markers.MakeDefinition("structType", markers.DescribesType, StructType(""))). + WithHelp(StructType("").Help()), } func init() { @@ -47,15 +55,15 @@ func init() { // // Possible data-structure types of a list are: // -// - "map": it needs to have a key field, which will be used to build an -// associative list. A typical example is a the pod container list, -// which is indexed by the container name. +// - "map": it needs to have a key field, which will be used to build an +// associative list. A typical example is a the pod container list, +// which is indexed by the container name. // -// - "set": Fields need to be "scalar", and there can be only one -// occurrence of each. +// - "set": Fields need to be "scalar", and there can be only one +// occurrence of each. // -// - "atomic": All the fields in the list are treated as a single value, -// are typically manipulated together by the same actor. +// - "atomic": All the fields in the list are treated as a single value, +// are typically manipulated together by the same actor. type ListType string // +controllertools:marker:generateHelp:category="CRD processing" @@ -75,12 +83,12 @@ type ListMapKey string // // Possible values: // -// - "granular": items in the map are independent of each other, -// and can be manipulated by different actors. -// This is the default behavior. +// - "granular": items in the map are independent of each other, +// and can be manipulated by different actors. +// This is the default behavior. // -// - "atomic": all fields are treated as one unit. -// Any changes have to replace the entire map. +// - "atomic": all fields are treated as one unit. +// Any changes have to replace the entire map. type MapType string // +controllertools:marker:generateHelp:category="CRD processing" @@ -91,12 +99,12 @@ type MapType string // // Possible values: // -// - "granular": fields in the struct are independent of each other, -// and can be manipulated by different actors. -// This is the default behavior. +// - "granular": fields in the struct are independent of each other, +// and can be manipulated by different actors. +// This is the default behavior. // -// - "atomic": all fields are treated as one unit. -// Any changes have to replace the entire struct. +// - "atomic": all fields are treated as one unit. +// Any changes have to replace the entire struct. type StructType string func (l ListType) ApplyToSchema(schema *apiext.JSONSchemaProps) error { diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/validation.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/validation.go index b20ff1623d..5d14961896 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/validation.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/validation.go @@ -17,9 +17,9 @@ limitations under the License. package markers import ( - "fmt" - "encoding/json" + "fmt" + "math" apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -37,7 +37,7 @@ const ( // reusable and writing complex validations on slice items. var ValidationMarkers = mustMakeAllWithPrefix("kubebuilder:validation", markers.DescribesField, - // integer markers + // numeric markers Maximum(0), Minimum(0), @@ -67,6 +67,7 @@ var ValidationMarkers = mustMakeAllWithPrefix("kubebuilder:validation", markers. XPreserveUnknownFields{}, XEmbeddedResource{}, XIntOrString{}, + XValidation{}, ) // FieldOnlyMarkers list field-specific validation markers (i.e. those markers that don't make @@ -122,11 +123,19 @@ func init() { // +controllertools:marker:generateHelp:category="CRD validation" // Maximum specifies the maximum numeric value that this field can have. -type Maximum int +type Maximum float64 + +func (m Maximum) Value() float64 { + return float64(m) +} // +controllertools:marker:generateHelp:category="CRD validation" -// Minimum specifies the minimum numeric value that this field can have. Negative integers are supported. -type Minimum int +// Minimum specifies the minimum numeric value that this field can have. Negative numbers are supported. +type Minimum float64 + +func (m Minimum) Value() float64 { + return float64(m) +} // +controllertools:marker:generateHelp:category="CRD validation" // ExclusiveMinimum indicates that the minimum is "up to" but not including that value. @@ -138,7 +147,11 @@ type ExclusiveMaximum bool // +controllertools:marker:generateHelp:category="CRD validation" // MultipleOf specifies that this field must have a numeric value that's a multiple of this one. -type MultipleOf int +type MultipleOf float64 + +func (m MultipleOf) Value() float64 { + return float64(m) +} // +controllertools:marker:generateHelp:category="CRD validation" // MaxLength specifies the maximum length for this string. @@ -251,41 +264,80 @@ type XIntOrString struct{} // to be used only as a last resort. type Schemaless struct{} +func hasNumericType(schema *apiext.JSONSchemaProps) bool { + return schema.Type == "integer" || schema.Type == "number" +} + +func isIntegral(value float64) bool { + return value == math.Trunc(value) && !math.IsNaN(value) && !math.IsInf(value, 0) +} + +// +controllertools:marker:generateHelp:category="CRD validation" +// XValidation marks a field as requiring a value for which a given +// expression evaluates to true. +// +// This marker may be repeated to specify multiple expressions, all of +// which must evaluate to true. +type XValidation struct { + Rule string + Message string `marker:",optional"` +} + func (m Maximum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "integer" { - return fmt.Errorf("must apply maximum to an integer") + if !hasNumericType(schema) { + return fmt.Errorf("must apply maximum to a numeric value, found %s", schema.Type) } - val := float64(m) + + if schema.Type == "integer" && !isIntegral(m.Value()) { + return fmt.Errorf("cannot apply non-integral maximum validation (%v) to integer value", m.Value()) + } + + val := m.Value() schema.Maximum = &val return nil } + func (m Minimum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "integer" { - return fmt.Errorf("must apply minimum to an integer") + if !hasNumericType(schema) { + return fmt.Errorf("must apply minimum to a numeric value, found %s", schema.Type) + } + + if schema.Type == "integer" && !isIntegral(m.Value()) { + return fmt.Errorf("cannot apply non-integral minimum validation (%v) to integer value", m.Value()) } - val := float64(m) + + val := m.Value() schema.Minimum = &val return nil } + func (m ExclusiveMaximum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "integer" { - return fmt.Errorf("must apply exclusivemaximum to an integer") + if !hasNumericType(schema) { + return fmt.Errorf("must apply exclusivemaximum to a numeric value, found %s", schema.Type) } schema.ExclusiveMaximum = bool(m) return nil } + func (m ExclusiveMinimum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "integer" { - return fmt.Errorf("must apply exclusiveminimum to an integer") + if !hasNumericType(schema) { + return fmt.Errorf("must apply exclusiveminimum to a numeric value, found %s", schema.Type) } + schema.ExclusiveMinimum = bool(m) return nil } + func (m MultipleOf) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "integer" { - return fmt.Errorf("must apply multipleof to an integer") + if !hasNumericType(schema) { + return fmt.Errorf("must apply multipleof to a numeric value, found %s", schema.Type) + } + + if schema.Type == "integer" && !isIntegral(m.Value()) { + return fmt.Errorf("cannot apply non-integral multipleof validation (%v) to integer value", m.Value()) } - val := float64(m) + + val := m.Value() schema.MultipleOf = &val return nil } @@ -298,6 +350,7 @@ func (m MaxLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { schema.MaxLength = &val return nil } + func (m MinLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { if schema.Type != "string" { return fmt.Errorf("must apply minlength to a string") @@ -306,6 +359,7 @@ func (m MinLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { schema.MinLength = &val return nil } + func (m Pattern) ApplyToSchema(schema *apiext.JSONSchemaProps) error { // Allow string types or IntOrStrings. An IntOrString will still // apply the pattern validation when a string is detected, the pattern @@ -325,6 +379,7 @@ func (m MaxItems) ApplyToSchema(schema *apiext.JSONSchemaProps) error { schema.MaxItems = &val return nil } + func (m MinItems) ApplyToSchema(schema *apiext.JSONSchemaProps) error { if schema.Type != "array" { return fmt.Errorf("must apply minitems to an array") @@ -333,6 +388,7 @@ func (m MinItems) ApplyToSchema(schema *apiext.JSONSchemaProps) error { schema.MinItems = &val return nil } + func (m UniqueItems) ApplyToSchema(schema *apiext.JSONSchemaProps) error { if schema.Type != "array" { return fmt.Errorf("must apply uniqueitems to an array") @@ -376,6 +432,7 @@ func (m Enum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { schema.Enum = vals return nil } + func (m Format) ApplyToSchema(schema *apiext.JSONSchemaProps) error { schema.Format = string(m) return nil @@ -428,3 +485,11 @@ func (m XIntOrString) ApplyToSchema(schema *apiext.JSONSchemaProps) error { } func (m XIntOrString) ApplyFirst() {} + +func (m XValidation) ApplyToSchema(schema *apiext.JSONSchemaProps) error { + schema.XValidations = append(schema.XValidations, apiext.ValidationRule{ + Rule: m.Rule, + Message: m.Message, + }) + return nil +} diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go index 03e3e44bf0..a3c0547486 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -116,7 +117,7 @@ func (ListType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the type of data-structure that the list represents (map, set, atomic). ", - Details: "Possible data-structure types of a list are: \n - \"map\": it needs to have a key field, which will be used to build an associative list. A typical example is a the pod container list, which is indexed by the container name. \n - \"set\": Fields need to be \"scalar\", and there can be only one occurrence of each. \n - \"atomic\": All the fields in the list are treated as a single value, are typically manipulated together by the same actor.", + Details: "Possible data-structure types of a list are: \n - \"map\": it needs to have a key field, which will be used to build an associative list. A typical example is a the pod container list, which is indexed by the container name. \n - \"set\": Fields need to be \"scalar\", and there can be only one occurrence of each. \n - \"atomic\": All the fields in the list are treated as a single value, are typically manipulated together by the same actor.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -127,7 +128,7 @@ func (MapType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the level of atomicity of the map; i.e. whether each item in the map is independent of the others, or all fields are treated as a single unit. ", - Details: "Possible values: \n - \"granular\": items in the map are independent of each other, and can be manipulated by different actors. This is the default behavior. \n - \"atomic\": all fields are treated as one unit. Any changes have to replace the entire map.", + Details: "Possible values: \n - \"granular\": items in the map are independent of each other, and can be manipulated by different actors. This is the default behavior. \n - \"atomic\": all fields are treated as one unit. Any changes have to replace the entire map.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -214,7 +215,7 @@ func (Minimum) Help() *markers.DefinitionHelp { return &markers.DefinitionHelp{ Category: "CRD validation", DetailedHelp: markers.DetailedHelp{ - Summary: "specifies the minimum numeric value that this field can have. Negative integers are supported.", + Summary: "specifies the minimum numeric value that this field can have. Negative numbers are supported.", Details: "", }, FieldHelp: map[string]markers.DetailedHelp{}, @@ -360,7 +361,7 @@ func (StructType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the level of atomicity of the struct; i.e. whether each field in the struct is independent of the others, or all fields are treated as a single unit. ", - Details: "Possible values: \n - \"granular\": fields in the struct are independent of each other, and can be manipulated by different actors. This is the default behavior. \n - \"atomic\": all fields are treated as one unit. Any changes have to replace the entire struct.", + Details: "Possible values: \n - \"granular\": fields in the struct are independent of each other, and can be manipulated by different actors. This is the default behavior. \n - \"atomic\": all fields are treated as one unit. Any changes have to replace the entire struct.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -466,3 +467,23 @@ func (XPreserveUnknownFields) Help() *markers.DefinitionHelp { FieldHelp: map[string]markers.DetailedHelp{}, } } + +func (XValidation) Help() *markers.DefinitionHelp { + return &markers.DefinitionHelp{ + Category: "CRD validation", + DetailedHelp: markers.DetailedHelp{ + Summary: "marks a field as requiring a value for which a given expression evaluates to true. ", + Details: "This marker may be repeated to specify multiple expressions, all of which must evaluate to true.", + }, + FieldHelp: map[string]markers.DetailedHelp{ + "Rule": { + Summary: "", + Details: "", + }, + "Message": { + Summary: "", + Details: "", + }, + }, + } +} diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/parser.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/parser.go index 164e4756d3..4c15de9072 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/parser.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/parser.go @@ -87,6 +87,9 @@ type Parser struct { // TODO: Should we have a more formal mechanism for putting "type patterns" in each of the above categories? AllowDangerousTypes bool + // IgnoreUnexportedFields specifies if unexported fields on the struct should be skipped + IgnoreUnexportedFields bool + // GenerateEmbeddedObjectMeta specifies if any embedded ObjectMeta should be generated GenerateEmbeddedObjectMeta bool } @@ -178,7 +181,7 @@ func (p *Parser) NeedSchemaFor(typ TypeIdent) { // avoid tripping recursive schemata, like ManagedFields, by adding an empty WIP schema p.Schemata[typ] = apiext.JSONSchemaProps{} - schemaCtx := newSchemaContext(typ.Package, p, p.AllowDangerousTypes) + schemaCtx := newSchemaContext(typ.Package, p, p.AllowDangerousTypes, p.IgnoreUnexportedFields) ctxForInfo := schemaCtx.ForInfo(info) pkgMarkers, err := markers.PackageMarkers(p.Collector, typ.Package) diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go index b665817f91..e76d3ea88c 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go @@ -69,17 +69,19 @@ type schemaContext struct { schemaRequester schemaRequester PackageMarkers markers.MarkerValues - allowDangerousTypes bool + allowDangerousTypes bool + ignoreUnexportedFields bool } // newSchemaContext constructs a new schemaContext for the given package and schema requester. // It must have type info added before use via ForInfo. -func newSchemaContext(pkg *loader.Package, req schemaRequester, allowDangerousTypes bool) *schemaContext { +func newSchemaContext(pkg *loader.Package, req schemaRequester, allowDangerousTypes, ignoreUnexportedFields bool) *schemaContext { pkg.NeedTypesInfo() return &schemaContext{ - pkg: pkg, - schemaRequester: req, - allowDangerousTypes: allowDangerousTypes, + pkg: pkg, + schemaRequester: req, + allowDangerousTypes: allowDangerousTypes, + ignoreUnexportedFields: ignoreUnexportedFields, } } @@ -87,10 +89,11 @@ func newSchemaContext(pkg *loader.Package, req schemaRequester, allowDangerousTy // as this one, except with the given type information. func (c *schemaContext) ForInfo(info *markers.TypeInfo) *schemaContext { return &schemaContext{ - pkg: c.pkg, - info: info, - schemaRequester: c.schemaRequester, - allowDangerousTypes: c.allowDangerousTypes, + pkg: c.pkg, + info: info, + schemaRequester: c.schemaRequester, + allowDangerousTypes: c.allowDangerousTypes, + ignoreUnexportedFields: c.ignoreUnexportedFields, } } @@ -339,6 +342,11 @@ func structToSchema(ctx *schemaContext, structType *ast.StructType) *apiext.JSON } for _, field := range ctx.info.Fields { + // Skip if the field is not an inline field, ignoreUnexportedFields is true, and the field is not exported + if field.Name != "" && ctx.ignoreUnexportedFields && !ast.IsExported(field.Name) { + continue + } + jsonTag, hasTag := field.Tag.Lookup("json") if !hasTag { // if the field doesn't have a JSON tag, it doesn't belong in output (and shouldn't exist in a serialized type) diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/spec.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/spec.go index d48ce25258..d7c1e4c286 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/spec.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/spec.go @@ -5,7 +5,7 @@ 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 + 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, @@ -164,11 +164,5 @@ func (p *Parser) NeedCRDFor(groupKind schema.GroupKind, maxDescLen *int) { packages[0].AddError(fmt.Errorf("CRD for %s with version(s) %v does not serve any version", groupKind, crd.Spec.Versions)) } - // NB(directxman12): CRD's status doesn't have omitempty markers, which means things - // get serialized as null, which causes the validator to freak out. Manually set - // these to empty till we get a better solution. - crd.Status.Conditions = []apiext.CustomResourceDefinitionCondition{} - crd.Status.StoredVersions = []string{} - p.CustomResourceDefinitions[groupKind] = crd } diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go index 5e30a191be..fee8de4b94 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -32,6 +33,10 @@ func (Generator) Help() *markers.DefinitionHelp { Details: "", }, FieldHelp: map[string]markers.DetailedHelp{ + "IgnoreUnexportedFields": { + Summary: "indicates that we should skip unexported fields. ", + Details: "Left unspecified, the default is false.", + }, "AllowDangerousTypes": { Summary: "allows types which are usually omitted from CRD generation because they are not recommended. ", Details: "Currently the following additional types are allowed when this is true: float32 float64 \n Left unspecified, the default is false", diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/gen.go b/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/gen.go index 54a72363b7..7e674a80aa 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/gen.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/gen.go @@ -175,7 +175,8 @@ type ObjectGenCtx struct { // writeHeader writes out the build tag, package declaration, and imports func writeHeader(pkg *loader.Package, out io.Writer, packageName string, imports *importsList, headerText string) { // NB(directxman12): blank line after build tags to distinguish them from comments - _, err := fmt.Fprintf(out, `// +build !ignore_autogenerated + _, err := fmt.Fprintf(out, `//go:build !ignore_autogenerated +// +build !ignore_autogenerated %[3]s diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/zz_generated.markerhelp.go index 6e001c6e25..913bc1fb7f 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/genall/doc.go b/vendor/sigs.k8s.io/controller-tools/pkg/genall/doc.go index df8dd71389..af67402e68 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/genall/doc.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/genall/doc.go @@ -17,14 +17,14 @@ limitations under the License. // Package genall defines entrypoints for generation tools to hook into and // share the same set of parsing, typechecking, and marker information. // -// Generators +// # Generators // // Each Generator knows how to register its markers into a central Registry, // and then how to generate output using a Collector and some root packages. // Each generator can be considered to be the output type of a marker, for easy // command line parsing. // -// Output and Input +// # Output and Input // // Generators output artifacts via an OutputRule. OutputRules know how to // write output for different package-associated (code) files, as well as @@ -40,7 +40,7 @@ limitations under the License. // InputRule defines custom input loading, but its shared across all // Generators. There's currently only a filesystem implementation. // -// Runtime and Context +// # Runtime and Context // // Runtime maps together Generators, and constructs "contexts" which provide // the common collector and roots, plus the output rule for that generator, and @@ -50,7 +50,7 @@ limitations under the License. // skipping type-checking errors (since those are commonly caused by the // partial type-checking of loader.TypeChecker). // -// Options +// # Options // // The FromOptions (and associated helpers) function makes it easy to use generators // and output rules as markers that can be parsed from the command line, producing diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/genall/genall.go b/vendor/sigs.k8s.io/controller-tools/pkg/genall/genall.go index 2cf4ec7e72..63afbac07c 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/genall/genall.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/genall/genall.go @@ -17,13 +17,14 @@ limitations under the License. package genall import ( + "encoding/json" "fmt" "io" "io/ioutil" "os" "golang.org/x/tools/go/packages" - "sigs.k8s.io/yaml" + rawyaml "gopkg.in/yaml.v2" "sigs.k8s.io/controller-tools/pkg/loader" "sigs.k8s.io/controller-tools/pkg/markers" @@ -120,10 +121,22 @@ type GenerationContext struct { InputRule } +// WriteYAMLOptions implements the Options Pattern for WriteYAML. +type WriteYAMLOptions struct { + transform func(obj map[string]interface{}) error +} + +// WithTransform applies a transformation to objects just before writing them. +func WithTransform(transform func(obj map[string]interface{}) error) *WriteYAMLOptions { + return &WriteYAMLOptions{ + transform: transform, + } +} + // WriteYAML writes the given objects out, serialized as YAML, using the // context's OutputRule. Objects are written as separate documents, separated // from each other by `---` (as per the YAML spec). -func (g GenerationContext) WriteYAML(itemPath string, objs ...interface{}) error { +func (g GenerationContext) WriteYAML(itemPath string, objs []interface{}, options ...*WriteYAMLOptions) error { out, err := g.Open(nil, itemPath) if err != nil { return err @@ -131,11 +144,11 @@ func (g GenerationContext) WriteYAML(itemPath string, objs ...interface{}) error defer out.Close() for _, obj := range objs { - yamlContent, err := yaml.Marshal(obj) + yamlContent, err := yamlMarshal(obj, options...) if err != nil { return err } - n, err := out.Write(append([]byte("\n---\n"), yamlContent...)) + n, err := out.Write(append([]byte("---\n"), yamlContent...)) if err != nil { return err } @@ -147,6 +160,41 @@ func (g GenerationContext) WriteYAML(itemPath string, objs ...interface{}) error return nil } +// yamlMarshal is based on sigs.k8s.io/yaml.Marshal, but allows for transforming the final data before writing. +func yamlMarshal(o interface{}, options ...*WriteYAMLOptions) ([]byte, error) { + j, err := json.Marshal(o) + if err != nil { + return nil, fmt.Errorf("error marshaling into JSON: %v", err) + } + + return yamlJSONToYAMLWithFilter(j, options...) +} + +// yamlJSONToYAMLWithFilter is based on sigs.k8s.io/yaml.JSONToYAML, but allows for transforming the final data before writing. +func yamlJSONToYAMLWithFilter(j []byte, options ...*WriteYAMLOptions) ([]byte, error) { + // Convert the JSON to an object. + var jsonObj map[string]interface{} + // We are using yaml.Unmarshal here (instead of json.Unmarshal) because the + // Go JSON library doesn't try to pick the right number type (int, float, + // etc.) when unmarshalling to interface{}, it just picks float64 + // universally. go-yaml does go through the effort of picking the right + // number type, so we can preserve number type throughout this process. + if err := rawyaml.Unmarshal(j, &jsonObj); err != nil { + return nil, err + } + + for _, option := range options { + if option.transform != nil { + if err := option.transform(jsonObj); err != nil { + return nil, err + } + } + } + + // Marshal this object into YAML. + return rawyaml.Marshal(jsonObj) +} + // ReadFile reads the given boilerplate artifact using the context's InputRule. func (g GenerationContext) ReadFile(path string) ([]byte, error) { file, err := g.OpenForRead(path) diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/genall/help/pretty/doc.go b/vendor/sigs.k8s.io/controller-tools/pkg/genall/help/pretty/doc.go index 06622db744..bc99e9ba99 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/genall/help/pretty/doc.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/genall/help/pretty/doc.go @@ -17,13 +17,13 @@ limitations under the License. // Package pretty contains utilities for formatting terminal help output, // and a use of those to display marker help. // -// Terminal Output +// # Terminal Output // // The Span interface and Table struct allow you to construct tables with // colored formatting, without causing ANSI formatting characters to mess up width // calculations. // -// Marker Help +// # Marker Help // // The MarkersSummary prints a summary table for marker help, while the MarkersDetails // prints out more detailed information, with explainations of the individual marker fields. diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/genall/options.go b/vendor/sigs.k8s.io/controller-tools/pkg/genall/options.go index 45e3bc41f3..836b1617e6 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/genall/options.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/genall/options.go @@ -30,6 +30,8 @@ var ( // +controllertools:marker:generateHelp:category="" // InputPaths represents paths and go-style path patterns to use as package roots. +// +// Multiple paths can be specified using "{path1, path2, path3}". type InputPaths []string // RegisterOptionsMarkers registers "mandatory" options markers for FromOptions into the given registry. diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go index 1319397e63..6428f0ce28 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -28,8 +29,8 @@ func (InputPaths) Help() *markers.DefinitionHelp { return &markers.DefinitionHelp{ Category: "", DetailedHelp: markers.DetailedHelp{ - Summary: "represents paths and go-style path patterns to use as package roots.", - Details: "", + Summary: "represents paths and go-style path patterns to use as package roots. ", + Details: "Multiple paths can be specified using \"{path1, path2, path3}\".", }, FieldHelp: map[string]markers.DetailedHelp{}, } diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/loader/doc.go b/vendor/sigs.k8s.io/controller-tools/pkg/loader/doc.go index a80065ec74..6853c062f4 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/loader/doc.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/loader/doc.go @@ -22,7 +22,7 @@ limitations under the License. // Because it uses go/packages, it's modules-aware, and works in both modules- // and non-modules environments. // -// Loading +// # Loading // // The main entrypoint for loading is LoadRoots, which traverse the package // graph starting at the given patterns (file, package, path, or ...-wildcard, @@ -33,7 +33,7 @@ limitations under the License. // Packages are suitable for comparison, as each unique package only ever has // one *Package object returned. // -// Syntax and TypeChecking +// # Syntax and TypeChecking // // ASTs and type-checking information can be loaded with NeedSyntax and // NeedTypesInfo, respectively. Both are idempotent -- repeated calls will @@ -41,14 +41,14 @@ limitations under the License. // check the current package -- if you want to type-check imports as well, // you'll need to type-check them first. // -// Reference Pruning and Recursive Checking +// # Reference Pruning and Recursive Checking // // In order to type-check using only the packages you care about, you can use a // TypeChecker. TypeChecker will visit each top-level type declaration, // collect (optionally filtered) references, and type-check references // packages. // -// Errors +// # Errors // // Errors can be added to each package. Use ErrFromNode to create an error // from an AST node. Errors can then be printed (complete with file and diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/loader/loader.go b/vendor/sigs.k8s.io/controller-tools/pkg/loader/loader.go index 35c2713357..b81acab2d2 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/loader/loader.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/loader/loader.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2019-2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -25,9 +25,12 @@ import ( "go/types" "io/ioutil" "os" + "path/filepath" + "regexp" "sync" "golang.org/x/tools/go/packages" + "k8s.io/apimachinery/pkg/util/sets" ) // Much of this is strongly inspired by the contents of go/packages, @@ -329,6 +332,40 @@ func LoadRoots(roots ...string) ([]*Package, error) { // // This is generally only useful for use in testing when you need to modify // loading settings to load from a fake location. +// +// This function will traverse Go module boundaries for roots that are file- +// system paths and end with "...". Please note this feature currently only +// supports roots that are filesystem paths. For more information, please +// refer to the high-level outline of this function's logic: +// +// 1. If no roots are provided then load the working directory and return +// early. +// +// 2. Otherwise sort the provided roots into two, distinct buckets: +// +// a. package/module names +// b. filesystem paths +// +// A filesystem path is distinguished from a Go package/module name by +// the same rules as followed by the "go" command. At a high level, a +// root is a filesystem path IFF it meets ANY of the following criteria: +// +// * is absolute +// * begins with . +// * begins with .. +// +// For more information please refer to the output of the command +// "go help packages". +// +// 3. Load the package/module roots as a single call to packages.Load. If +// there are no filesystem path roots then return early. +// +// 4. For filesystem path roots ending with "...", check to see if its +// descendants include any nested, Go modules. If so, add the directory +// that contains the nested Go module to the filesystem path roots. +// +// 5. Load the filesystem path roots and return the load packages for the +// package/module roots AND the filesystem path roots. func LoadRootsWithConfig(cfg *packages.Config, roots ...string) ([]*Package, error) { l := &loader{ cfg: cfg, @@ -341,18 +378,246 @@ func LoadRootsWithConfig(cfg *packages.Config, roots ...string) ([]*Package, err // put our build flags first so that callers can override them l.cfg.BuildFlags = append([]string{"-tags", "ignore_autogenerated"}, l.cfg.BuildFlags...) - rawPkgs, err := packages.Load(l.cfg, roots...) - if err != nil { - return nil, err + // Visit the import graphs of the loaded, root packages. If an imported + // package refers to another loaded, root package, then replace the + // instance of the imported package with a reference to the loaded, root + // package. This is required to make kubebuilder markers work correctly + // when multiple root paths are loaded and types from one path reference + // types from another root path. + defer func() { + for i := range l.Roots { + visitImports(l.Roots, l.Roots[i], nil) + } + }() + + // uniquePkgIDs is used to keep track of the discovered packages to be nice + // and try and prevent packages from showing up twice when nested module + // support is enabled. there is not harm that comes from this per se, but + // it makes testing easier when a known number of modules can be asserted + uniquePkgIDs := sets.String{} + + // loadPackages returns the Go packages for the provided roots + // + // if validatePkgFn is nil, a package will be returned in the slice, + // otherwise the package is only returned if the result of + // validatePkgFn(pkg.ID) is truthy + loadPackages := func(roots ...string) ([]*Package, error) { + rawPkgs, err := packages.Load(l.cfg, roots...) + if err != nil { + return nil, err + } + var pkgs []*Package + for _, rp := range rawPkgs { + p := l.packageFor(rp) + if !uniquePkgIDs.Has(p.ID) { + pkgs = append(pkgs, p) + uniquePkgIDs.Insert(p.ID) + } + } + return pkgs, nil + } + + // if no roots were provided then load the current package and return early + if len(roots) == 0 { + pkgs, err := loadPackages() + if err != nil { + return nil, err + } + l.Roots = append(l.Roots, pkgs...) + return l.Roots, nil + } + + // pkgRoots is a slice of roots that are package/modules and fspRoots + // is a slice of roots that are local filesystem paths. + // + // please refer to this function's godoc comments for more information on + // how these two types of roots are distinguished from one another + var ( + pkgRoots []string + fspRoots []string + fspRootRx = regexp.MustCompile(`^\.{1,2}`) + ) + for _, r := range roots { + if filepath.IsAbs(r) || fspRootRx.MatchString(r) { + fspRoots = append(fspRoots, r) + } else { + pkgRoots = append(pkgRoots, r) + } + } + + // handle the package roots by sending them into the packages.Load function + // all at once. this is more efficient, but cannot be used for the file- + // system path roots due to them needing a custom, calculated value for the + // cfg.Dir field + if len(pkgRoots) > 0 { + pkgs, err := loadPackages(pkgRoots...) + if err != nil { + return nil, err + } + l.Roots = append(l.Roots, pkgs...) + } + + // if there are no filesystem path roots then go ahead and return early + if len(fspRoots) == 0 { + return l.Roots, nil } - for _, rawPkg := range rawPkgs { - l.Roots = append(l.Roots, l.packageFor(rawPkg)) + // + // at this point we are handling filesystem path roots + // + + // ensure the cfg.Dir field is reset to its original value upon + // returning from this function. it should honestly be fine if it is + // not given most callers will not send in the cfg parameter directly, + // as it's largely for testing, but still, let's be good stewards. + defer func(d string) { + cfg.Dir = d + }(cfg.Dir) + + // store the value of cfg.Dir so we can use it later if it is non-empty. + // we need to store it now as the value of cfg.Dir will be updated by + // a loop below + cfgDir := cfg.Dir + + // addNestedGoModulesToRoots is given to filepath.WalkDir and adds the + // directory part of p to the list of filesystem path roots IFF p is the + // path to a file named "go.mod" + addNestedGoModulesToRoots := func( + p string, + d os.DirEntry, + e error) error { + + if e != nil { + return e + } + if !d.IsDir() && filepath.Base(p) == "go.mod" { + fspRoots = append(fspRoots, filepath.Join(filepath.Dir(p), "...")) + } + return nil + } + + // in the first pass over the filesystem path roots we: + // + // 1. make the root into an absolute path + // + // 2. check to see if a root uses the nested path syntax, ex. ... + // + // 3. if so, walk the root's descendants, searching for any nested Go + // modules + // + // 4. if found then the directory containing the Go module is added to + // the list of the filesystem path roots + for i := range fspRoots { + r := fspRoots[i] + + // clean up the root + r = filepath.Clean(r) + + // get the absolute path of the root + if !filepath.IsAbs(r) { + + // if the initial value of cfg.Dir was non-empty then use it when + // building the absolute path to this root. otherwise use the + // filepath.Abs function to get the absolute path of the root based + // on the working directory + if cfgDir != "" { + r = filepath.Join(cfgDir, r) + } else { + ar, err := filepath.Abs(r) + if err != nil { + return nil, err + } + r = ar + } + } + + // update the root to be an absolute path + fspRoots[i] = r + + b, d := filepath.Base(r), filepath.Dir(r) + + // if the base element is "..." then it means nested traversal is + // activated. this can be passed directly to the loader. however, if + // specified we also want to traverse the path manually to determine if + // there are any nested Go modules we want to add to the list of file- + // system path roots to process + if b == "..." { + if err := filepath.WalkDir( + d, + addNestedGoModulesToRoots); err != nil { + + return nil, err + } + } + } + + // in the second pass over the filesystem path roots we: + // + // 1. determine the directory from which to execute the loader + // + // 2. update the loader config's Dir property to be the directory from + // step one + // + // 3. determine whether the root passed to the loader should be "./." + // or "./..." + // + // 4. execute the loader with the value from step three + for _, r := range fspRoots { + b, d := filepath.Base(r), filepath.Dir(r) + + // we want the base part of the path to be either "..." or ".", except + // Go's filepath utilities clean paths during manipulation, removing the + // ".". thus, if not "...", let's update the path components so that: + // + // d = r + // b = "." + if b != "..." { + d = r + b = "." + } + + // update the loader configuration's Dir field to the directory part of + // the root + l.cfg.Dir = d + + // update the root to be "./..." or "./." + // (with OS-specific filepath separator). please note filepath.Join + // would clean up the trailing "." character that we want preserved, + // hence the more manual path concatenation logic + r = fmt.Sprintf(".%s%s", string(filepath.Separator), b) + + // load the packages from the roots + pkgs, err := loadPackages(r) + if err != nil { + return nil, err + } + l.Roots = append(l.Roots, pkgs...) } return l.Roots, nil } +// visitImports walks a dependency graph, replacing imported package +// references with those from the rootPkgs list. This ensures the +// kubebuilder marker generation is handled correctly. For more info, +// please see issue 680. +func visitImports(rootPkgs []*Package, pkg *Package, seen sets.String) { + if seen == nil { + seen = sets.String{} + } + for importedPkgID, importedPkg := range pkg.Imports() { + for i := range rootPkgs { + if importedPkgID == rootPkgs[i].ID { + pkg.imports[importedPkgID] = rootPkgs[i] + } + } + if !seen.Has(importedPkgID) { + seen.Insert(importedPkgID) + visitImports(rootPkgs, importedPkg, seen) + } + } +} + // importFunc is an implementation of the single-method // types.Importer interface based on a function value. type importerFunc func(path string) (*types.Package, error) diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/loader/refs.go b/vendor/sigs.k8s.io/controller-tools/pkg/loader/refs.go index 59ea262bb6..37c3295f14 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/loader/refs.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/loader/refs.go @@ -133,9 +133,14 @@ func (c *referenceCollector) Visit(node ast.Node) ast.Visitor { // local reference or dot-import, ignore return nil case *ast.SelectorExpr: - pkgName := typedNode.X.(*ast.Ident).Name - c.refs.external(pkgName) - return nil + switch x := typedNode.X.(type) { + case *ast.Ident: + pkgName := x.Name + c.refs.external(pkgName) + return nil + default: + return c + } default: return c } diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/markers/collect.go b/vendor/sigs.k8s.io/controller-tools/pkg/markers/collect.go index c5ea2345fd..b2f8219914 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/markers/collect.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/markers/collect.go @@ -65,13 +65,13 @@ func (c *Collector) init() { // // - it's in the Godoc for that AST node // -// - it's in the closest non-godoc comment group above that node, -// *and* that node is a type or field node, *and* [it's either -// registered as type-level *or* it's not registered as being -// package-level] +// - it's in the closest non-godoc comment group above that node, +// *and* that node is a type or field node, *and* [it's either +// registered as type-level *or* it's not registered as being +// package-level] // -// - it's not in the Godoc of a node, doesn't meet the above criteria, and -// isn't in a struct definition (in which case it's package-level) +// - it's not in the Godoc of a node, doesn't meet the above criteria, and +// isn't in a struct definition (in which case it's package-level) func (c *Collector) MarkersInPackage(pkg *loader.Package) (map[ast.Node]MarkerValues, error) { c.mu.Lock() c.init() diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/markers/doc.go b/vendor/sigs.k8s.io/controller-tools/pkg/markers/doc.go index 707036de8f..ab6947ccaf 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/markers/doc.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/markers/doc.go @@ -19,7 +19,7 @@ limitations under the License. // avoid confusing with struct tags). Parsed result (output) values take the // form of Go values, much like the "encoding/json" package. // -// Definitions and Parsing +// # Definitions and Parsing // // Markers are defined as structured Definitions which can be used to // consistently parse marker comments. A Definition contains an concrete @@ -29,20 +29,20 @@ limitations under the License. // // Markers take the general form // -// +path:to:marker=val +// +path:to:marker=val // -// +path:to:marker:arg1=val,arg2=val2 +// +path:to:marker:arg1=val,arg2=val2 // -// +path:to:marker +// +path:to:marker // // Arguments may be ints, bools, strings, and slices. Ints and bool take their // standard form from Go. Strings may take any of their standard forms, or any // sequence of unquoted characters up until a `,` or `;` is encountered. Lists // take either of the following forms: // -// val;val;val +// val;val;val // -// {val, val, val} +// {val, val, val} // // Note that the first form will not properly parse nested slices, but is // generally convenient and is the form used in many existing markers. @@ -61,7 +61,7 @@ limitations under the License. // non-optional fields aren't mentioned, an error will be raised unless // `Strict` is set to false. // -// Registries and Lookup +// # Registries and Lookup // // Definitions can be added to registries to facilitate lookups. Each // definition is marked as either describing a type, struct field, or package @@ -69,7 +69,7 @@ limitations under the License. // long as each describes a different construct (type, field, or package). // Definitions can then be looked up by passing unparsed markers. // -// Collection and Extraction +// # Collection and Extraction // // Markers can be collected from a loader.Package using a Collector. The // Collector will read from a given Registry, collecting comments that look @@ -85,7 +85,7 @@ limitations under the License. // Like loader.Package, Collector's methods are idempotent and will not // reperform work. // -// Traversal +// # Traversal // // EachType function iterates over each type in a Package, providing // conveniently structured type and field information with marker values @@ -93,14 +93,14 @@ limitations under the License. // // PackageMarkers can be used to fetch just package-level markers. // -// Help +// # Help // // Help can be defined for each marker using the DefinitionHelp struct. It's // mostly intended to be generated off of godocs using cmd/helpgen, which takes // the first line as summary (removing the type/field name), and considers the // rest as details. It looks for the // -// +controllertools:generateHelp[:category=] +// +controllertools:generateHelp[:category=] // // marker to start generation. // diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/markers/parse.go b/vendor/sigs.k8s.io/controller-tools/pkg/markers/parse.go index fcb33925e8..3e1d75a833 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/markers/parse.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/markers/parse.go @@ -84,6 +84,8 @@ const ( InvalidType ArgumentType = iota // IntType is an int IntType + // NumberType is a float64 + NumberType // StringType is a string StringType // BoolType is a bool @@ -127,6 +129,8 @@ func (a Argument) typeString(out *strings.Builder) { out.WriteString("") case IntType: out.WriteString("int") + case NumberType: + out.WriteString("float64") case StringType: out.WriteString("string") case BoolType: @@ -180,6 +184,8 @@ func makeSliceType(itemType Argument) (reflect.Type, error) { switch itemType.Type { case IntType: itemReflectedType = reflect.TypeOf(int(0)) + case NumberType: + itemReflectedType = reflect.TypeOf(float64(0)) case StringType: itemReflectedType = reflect.TypeOf("") case BoolType: @@ -215,6 +221,8 @@ func makeMapType(itemType Argument) (reflect.Type, error) { switch itemType.Type { case IntType: itemReflectedType = reflect.TypeOf(int(0)) + case NumberType: + itemReflectedType = reflect.TypeOf(float64(0)) case StringType: itemReflectedType = reflect.TypeOf("") case BoolType: @@ -346,9 +354,13 @@ func guessType(scanner *sc.Scanner, raw string, allowSlice bool) *Argument { if nextTok == '-' { nextTok = subScanner.Scan() } + if nextTok == sc.Int { return &Argument{Type: IntType} } + if nextTok == sc.Float { + return &Argument{Type: NumberType} + } } // otherwise assume bare strings @@ -471,7 +483,7 @@ func (a *Argument) parseMap(scanner *sc.Scanner, raw string, out reflect.Value) func (a *Argument) parse(scanner *sc.Scanner, raw string, out reflect.Value, inSlice bool) { // nolint:gocyclo if a.Type == InvalidType { - scanner.Error(scanner, fmt.Sprintf("cannot parse invalid type")) + scanner.Error(scanner, "cannot parse invalid type") return } if a.Pointer { @@ -485,6 +497,32 @@ func (a *Argument) parse(scanner *sc.Scanner, raw string, out reflect.Value, inS // consume everything else for tok := scanner.Scan(); tok != sc.EOF; tok = scanner.Scan() { } + case NumberType: + nextChar := scanner.Peek() + isNegative := false + if nextChar == '-' { + isNegative = true + scanner.Scan() // eat the '-' + } + + tok := scanner.Scan() + if tok != sc.Float && tok != sc.Int { + scanner.Error(scanner, fmt.Sprintf("expected integer or float, got %q", scanner.TokenText())) + return + } + + text := scanner.TokenText() + if isNegative { + text = "-" + text + } + + val, err := strconv.ParseFloat(text, 64) + if err != nil { + scanner.Error(scanner, fmt.Sprintf("unable to parse number: %v", err)) + return + } + + castAndSet(out, reflect.ValueOf(val)) case IntType: nextChar := scanner.Peek() isNegative := false @@ -597,6 +635,8 @@ func ArgumentFromType(rawType reflect.Type) (Argument, error) { arg.Type = StringType case reflect.Int, reflect.Int32: // NB(directxman12): all ints in kubernetes are int32, so explicitly support that arg.Type = IntType + case reflect.Float64: + arg.Type = NumberType case reflect.Bool: arg.Type = BoolType case reflect.Slice: @@ -755,7 +795,7 @@ func (d *Definition) loadFields() error { func parserScanner(raw string, err func(*sc.Scanner, string)) *sc.Scanner { scanner := &sc.Scanner{} scanner.Init(bytes.NewBufferString(raw)) - scanner.Mode = sc.ScanIdents | sc.ScanInts | sc.ScanStrings | sc.ScanRawStrings | sc.SkipComments + scanner.Mode = sc.ScanIdents | sc.ScanInts | sc.ScanFloats | sc.ScanStrings | sc.ScanRawStrings | sc.SkipComments scanner.Error = err return scanner diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/markers/reg.go b/vendor/sigs.k8s.io/controller-tools/pkg/markers/reg.go index b0124630f8..7dcd458994 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/markers/reg.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/markers/reg.go @@ -52,7 +52,8 @@ func (r *Registry) init() { // Define defines a new marker with the given name, target, and output type. // It's a shortcut around -// r.Register(MakeDefinition(name, target, obj)) +// +// r.Register(MakeDefinition(name, target, obj)) func (r *Registry) Define(name string, target TargetType, obj interface{}) error { def, err := MakeDefinition(name, target, obj) if err != nil { diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/markers/zip.go b/vendor/sigs.k8s.io/controller-tools/pkg/markers/zip.go index a9b4c98af5..b352ededc7 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/markers/zip.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/markers/zip.go @@ -67,12 +67,22 @@ func extractDoc(node ast.Node, decl *ast.GenDecl) string { // chop off the extraneous last part outLines = outLines[:len(outLines)-1] } - // respect double-newline meaning actual newline + for i, line := range outLines { + // Trim any extranous whitespace, + // for handling /*…*/-style comments, + // which have whitespace preserved in go/ast: + line = strings.TrimSpace(line) + + // Respect that double-newline means + // actual newline: if line == "" { outLines[i] = "\n" + } else { + outLines[i] = line } } + return strings.Join(outLines, " ") } @@ -139,11 +149,11 @@ type TypeCallback func(info *TypeInfo) // EachType collects all markers, then calls the given callback for each type declaration in a package. // Each individual spec is considered separate, so // -// type ( -// Foo string -// Bar int -// Baz struct{} -// ) +// type ( +// Foo string +// Bar int +// Baz struct{} +// ) // // yields three calls to the callback. func EachType(col *Collector, pkg *loader.Package, cb TypeCallback) error { diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/rbac/parser.go b/vendor/sigs.k8s.io/controller-tools/pkg/rbac/parser.go index 8adfb36638..c2a24f4710 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/rbac/parser.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/rbac/parser.go @@ -19,7 +19,7 @@ limitations under the License. // // The markers take the form: // -// +kubebuilder:rbac:groups=,resources=,resourceNames=,verbs=,urls= +// +kubebuilder:rbac:groups=,resources=,resourceNames=,verbs=,urls= package rbac import ( @@ -263,5 +263,5 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error { return nil } - return ctx.WriteYAML("role.yaml", objs...) + return ctx.WriteYAML("role.yaml", objs) } diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/rbac/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/rbac/zz_generated.markerhelp.go index 29deffea30..0e2083a23d 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/rbac/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/rbac/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/gen.go b/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/gen.go index 6aec36ca6e..e33ec11ff5 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/gen.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/gen.go @@ -113,7 +113,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) (result error) { } // generate schemata for the types we care about, and save them to be written later. - for groupKind := range crdgen.FindKubeKinds(parser, metav1Pkg) { + for _, groupKind := range crdgen.FindKubeKinds(parser, metav1Pkg) { existingSet, wanted := partialCRDSets[groupKind] if !wanted { continue @@ -358,12 +358,16 @@ func crdsFromDirectory(ctx *genall.GenerationContext, dir string) (map[schema.Gr if err := kyaml.Unmarshal(rawContent, &typeMeta); err != nil { continue } + + if typeMeta.APIVersion == "" || typeMeta.Kind != "CustomResourceDefinition" { + // If there's no API version this file probably isn't a CRD. + // Likewise we don't need to care if the Kind isn't CustomResourceDefinition. + continue + } + if !isSupportedAPIExtGroupVer(typeMeta.APIVersion) { return nil, fmt.Errorf("load %q: apiVersion %q not supported", filepath.Join(dir, fileInfo.Name()), typeMeta.APIVersion) } - if typeMeta.Kind != "CustomResourceDefinition" { - continue - } // collect the group-kind and versions from the actual structured form var actualCRD crdIsh diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/zz_generated.markerhelp.go index 96950a9d11..db9745d767 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/version/version.go b/vendor/sigs.k8s.io/controller-tools/pkg/version/version.go index 245826f692..09c8efcf40 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/version/version.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/version/version.go @@ -5,7 +5,7 @@ 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 + 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, @@ -23,8 +23,8 @@ import ( // Version returns the version of the main module func Version() string { info, ok := debug.ReadBuildInfo() - if !ok { - // binary has not been built with module support + if !ok || info == nil || info.Main.Version == "" { + // binary has not been built with module support or doesn't contain a version. return "(unknown)" } return info.Main.Version @@ -36,10 +36,10 @@ func Version() string { // // - "Version: v0.2.1" when the program has been compiled with: // -// $ go get github.com/controller-tools/cmd/controller-gen@v0.2.1 +// $ go get github.com/controller-tools/cmd/controller-gen@v0.2.1 // -// Note: go modules requires the usage of semver compatible tags starting with -// 'v' to have nice human-readable versions. +// Note: go modules requires the usage of semver compatible tags starting with +// 'v' to have nice human-readable versions. // // - "Version: (devel)" when the program is compiled from a local git checkout. // diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/webhook/parser.go b/vendor/sigs.k8s.io/controller-tools/pkg/webhook/parser.go index f3434e1ab2..a76dcdcbb4 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/webhook/parser.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/webhook/parser.go @@ -19,7 +19,7 @@ limitations under the License. // // The markers take the form: // -// +kubebuilder:webhook:webhookVersions=<[]string>,failurePolicy=,matchPolicy=,groups=<[]string>,resources=<[]string>,verbs=<[]string>,versions=<[]string>,name=,path=,mutating=,sideEffects=,admissionReviewVersions=<[]string> +// +kubebuilder:webhook:webhookVersions=<[]string>,failurePolicy=,matchPolicy=,groups=<[]string>,resources=<[]string>,verbs=<[]string>,versions=<[]string>,name=,path=,mutating=,sideEffects=,admissionReviewVersions=<[]string>,reinvocationPolicy= package webhook import ( @@ -111,6 +111,14 @@ type Config struct { // AdmissionReviewVersions is an ordered list of preferred `AdmissionReview` // versions the Webhook expects. AdmissionReviewVersions []string `marker:"admissionReviewVersions"` + + // ReinvocationPolicy allows mutating webhooks to request reinvocation after other mutations + // + // To allow mutating admission plugins to observe changes made by other plugins, + // built-in mutating admission plugins are re-run if a mutating webhook modifies + // an object, and mutating webhooks can specify a reinvocationPolicy to control + // whether they are reinvoked as well. + ReinvocationPolicy string `marker:"reinvocationPolicy,optional"` } // verbToAPIVariant converts a marker's verb to the proper value for the API. @@ -151,6 +159,7 @@ func (c Config) ToMutatingWebhook() (admissionregv1.MutatingWebhook, error) { ClientConfig: c.clientConfig(), SideEffects: c.sideEffects(), AdmissionReviewVersions: c.AdmissionReviewVersions, + ReinvocationPolicy: c.reinvocationPolicy(), }, nil } @@ -263,6 +272,20 @@ func (c Config) sideEffects() *admissionregv1.SideEffectClass { return &sideEffects } +// reinvocationPolicy returns the reinvocationPolicy config for a mutating webhook. +func (c Config) reinvocationPolicy() *admissionregv1.ReinvocationPolicyType { + var reinvocationPolicy admissionregv1.ReinvocationPolicyType + switch strings.ToLower(c.ReinvocationPolicy) { + case strings.ToLower(string(admissionregv1.NeverReinvocationPolicy)): + reinvocationPolicy = admissionregv1.NeverReinvocationPolicy + case strings.ToLower(string(admissionregv1.IfNeededReinvocationPolicy)): + reinvocationPolicy = admissionregv1.IfNeededReinvocationPolicy + default: + return nil + } + return &reinvocationPolicy +} + // webhookVersions returns the target API versions of the {Mutating,Validating}WebhookConfiguration objects for a webhook. func (c Config) webhookVersions() ([]string, error) { // If WebhookVersions is not specified, we default it to `v1`. @@ -389,7 +412,7 @@ func (Generator) Generate(ctx *genall.GenerationContext) error { } else { fileName = fmt.Sprintf("manifests.%s.yaml", k) } - if err := ctx.WriteYAML(fileName, v...); err != nil { + if err := ctx.WriteYAML(fileName, v); err != nil { return err } } diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/webhook/zz_generated.markerhelp.go b/vendor/sigs.k8s.io/controller-tools/pkg/webhook/zz_generated.markerhelp.go index 5e4e02f863..411c58e170 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/webhook/zz_generated.markerhelp.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/webhook/zz_generated.markerhelp.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -80,6 +81,10 @@ func (Config) Help() *markers.DefinitionHelp { Summary: "is an ordered list of preferred `AdmissionReview` versions the Webhook expects.", Details: "", }, + "ReinvocationPolicy": { + Summary: "allows mutating webhooks to request reinvocation after other mutations ", + Details: "To allow mutating admission plugins to observe changes made by other plugins, built-in mutating admission plugins are re-run if a mutating webhook modifies an object, and mutating webhooks can specify a reinvocationPolicy to control whether they are reinvoked as well.", + }, }, } }