From 276dd706c2e6edec1993775871a36eb271d9215e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 23:54:09 +0000 Subject: [PATCH] build(deps): bump sigs.k8s.io/controller-tools from 0.17.1 to 0.17.2 Bumps [sigs.k8s.io/controller-tools](https://github.com/kubernetes-sigs/controller-tools) from 0.17.1 to 0.17.2. - [Release notes](https://github.com/kubernetes-sigs/controller-tools/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-tools/blob/main/envtest-releases.yaml) - [Commits](https://github.com/kubernetes-sigs/controller-tools/compare/v0.17.1...v0.17.2) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-tools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/modules.txt | 2 +- .../pkg/crd/markers/validation.go | 19 +++++----- .../controller-tools/pkg/deepcopy/traverse.go | 37 +++++++++++-------- .../controller-tools/pkg/webhook/parser.go | 37 +++++++++++++++++-- .../pkg/webhook/zz_generated.markerhelp.go | 12 ++++++ 7 files changed, 80 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index 7bea807bf3..ac73d36f3b 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/controller-runtime v0.20.1 - sigs.k8s.io/controller-tools v0.17.1 + sigs.k8s.io/controller-tools v0.17.2 ) require ( diff --git a/go.sum b/go.sum index c933c0c004..abe376b687 100644 --- a/go.sum +++ b/go.sum @@ -2935,8 +2935,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 h1:CPT0ExVicCzcp sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/controller-runtime v0.20.1 h1:JbGMAG/X94NeM3xvjenVUaBjy6Ui4Ogd/J5ZtjZnHaE= sigs.k8s.io/controller-runtime v0.20.1/go.mod h1:BrP3w158MwvB3ZbNpaAcIKkHQ7YGpYnzpoSTZ8E14WU= -sigs.k8s.io/controller-tools v0.17.1 h1:bQ+dKCS7jY9AgpefenBDtm6geJZCHVKbegpLynxgyus= -sigs.k8s.io/controller-tools v0.17.1/go.mod h1:3QXAdrmdxYuQ4MifvbCAFD9wLXn7jylnfBPYS4yVDdc= +sigs.k8s.io/controller-tools v0.17.2 h1:jNFOKps8WnaRKZU2R+4vRCHnXyJanVmXBWqkuUPFyFg= +sigs.k8s.io/controller-tools v0.17.2/go.mod h1:4q5tZG2JniS5M5bkiXY2/potOiXyhoZVw/U48vLkXk0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= diff --git a/vendor/modules.txt b/vendor/modules.txt index 68d962aa4a..b7a3036af9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1849,7 +1849,7 @@ sigs.k8s.io/controller-runtime/pkg/webhook/admission sigs.k8s.io/controller-runtime/pkg/webhook/admission/metrics sigs.k8s.io/controller-runtime/pkg/webhook/conversion sigs.k8s.io/controller-runtime/pkg/webhook/internal/metrics -# sigs.k8s.io/controller-tools v0.17.1 +# sigs.k8s.io/controller-tools v0.17.2 ## explicit; go 1.23.0 sigs.k8s.io/controller-tools/cmd/controller-gen sigs.k8s.io/controller-tools/pkg/crd 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 08d28612ce..5cd5daf69d 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 @@ -316,6 +316,10 @@ func hasNumericType(schema *apiext.JSONSchemaProps) bool { return schema.Type == "integer" || schema.Type == "number" } +func hasTextualType(schema *apiext.JSONSchemaProps) bool { + return schema.Type == "string" || schema.XIntOrString +} + func isIntegral(value float64) bool { return value == math.Trunc(value) && !math.IsNaN(value) && !math.IsInf(value, 0) } @@ -394,8 +398,8 @@ func (m MultipleOf) ApplyToSchema(schema *apiext.JSONSchemaProps) error { } func (m MaxLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "string" { - return fmt.Errorf("must apply maxlength to a string") + if !hasTextualType(schema) { + return fmt.Errorf("must apply maxlength to a textual value, found type %q", schema.Type) } val := int64(m) schema.MaxLength = &val @@ -403,8 +407,8 @@ func (m MaxLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { } func (m MinLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if schema.Type != "string" { - return fmt.Errorf("must apply minlength to a string") + if !hasTextualType(schema) { + return fmt.Errorf("must apply minlength to a textual value, found type %q", schema.Type) } val := int64(m) schema.MinLength = &val @@ -412,11 +416,8 @@ func (m MinLength) ApplyToSchema(schema *apiext.JSONSchemaProps) error { } 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 - // will not apply to ints though. - if schema.Type != "string" && !schema.XIntOrString { - return fmt.Errorf("must apply pattern to a `string` or `IntOrString`") + if !hasTextualType(schema) { + return fmt.Errorf("must apply pattern to a textual value, found type %q", schema.Type) } schema.Pattern = string(m) return nil diff --git a/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/traverse.go b/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/traverse.go index 8634088735..fe279f7be4 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/traverse.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/deepcopy/traverse.go @@ -173,18 +173,12 @@ func (n *namingInfo) Syntax(basePkg *loader.Package, imports *importsList) strin // NB(directxman12): typeInfo.String gets us most of the way there, // but fails (for us) on named imports, since it uses the full package path. + var typeName *types.TypeName switch typeInfo := n.typeInfo.(type) { + case *types.Alias: + typeName = typeInfo.Obj() case *types.Named: - // register that we need an import for this type, - // so we can get the appropriate alias to use. - typeName := typeInfo.Obj() - otherPkg := typeName.Pkg() - if otherPkg == basePkg.Types { - // local import - return typeName.Name() - } - alias := imports.NeedImport(loader.NonVendorPath(otherPkg.Path())) - return alias + "." + typeName.Name() + typeName = typeInfo.Obj() case *types.Basic: return typeInfo.String() case *types.Pointer: @@ -200,6 +194,16 @@ func (n *namingInfo) Syntax(basePkg *loader.Package, imports *importsList) strin basePkg.AddError(fmt.Errorf("name requested for invalid type: %s", typeInfo)) return typeInfo.String() } + + // register that we need an import for this type, + // so we can get the appropriate alias to use. + otherPkg := typeName.Pkg() + if otherPkg == basePkg.Types { + // local import + return typeName.Name() + } + alias := imports.NeedImport(loader.NonVendorPath(otherPkg.Path())) + return alias + "." + typeName.Name() } // copyMethodMakers makes DeepCopy (and related) methods for Go types, @@ -618,14 +622,15 @@ func shouldBeCopied(pkg *loader.Package, info *markers.TypeInfo) bool { return false } - // according to gengo, everything named is an alias, except for an alias to a pointer, - // which is just a pointer, afaict. Just roll with it. - if asPtr, isPtr := typeInfo.(*types.Named).Underlying().(*types.Pointer); isPtr { - typeInfo = asPtr - } - lastType := typeInfo if _, isNamed := typeInfo.(*types.Named); isNamed { + // according to gengo, everything named is an alias, except for an alias to a pointer, + // which is just a pointer, afaict. Just roll with it. + if asPtr, isPtr := typeInfo.(*types.Named).Underlying().(*types.Pointer); isPtr { + lastType = asPtr + typeInfo = asPtr + } + // if it has a manual deepcopy or deepcopyinto, we're fine if hasAnyDeepCopyMethod(pkg, typeInfo) { return true 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 2ee6302fce..780294abe1 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/webhook/parser.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/webhook/parser.go @@ -38,8 +38,10 @@ import ( // The default {Mutating,Validating}WebhookConfiguration version to generate. const ( - v1 = "v1" - defaultWebhookVersion = v1 + v1 = "v1" + defaultWebhookVersion = v1 + defaultServiceName = "webhook-service" + defaultServiceNamespace = "system" ) var ( @@ -118,6 +120,12 @@ type Config struct { // Name indicates the name of this webhook configuration. Should be a domain with at least three segments separated by dots Name string + // ServiceName indicates the name of the K8s Service the webhook uses. + ServiceName string `marker:"serviceName,optional"` + + // ServiceNamespace indicates the namespace of the K8s Service the webhook uses. + ServiceNamespace string `marker:"serviceNamespace,optional"` + // Path specifies that path that the API server should connect to this webhook on. Must be // prefixed with a '/validate-' or '/mutate-' depending on the type, and followed by // $GROUP-$VERSION-$KIND where all values are lower-cased and the periods in the group @@ -126,6 +134,9 @@ type Config struct { // /validate-batch-tutorial-kubebuilder-io-v1-cronjob Path string `marker:"path,optional"` + // ServicePort indicates the port of the K8s Service the webhook uses + ServicePort *int32 `marker:"servicePort,optional"` + // WebhookVersions specifies the target API versions of the {Mutating,Validating}WebhookConfiguration objects // itself to generate. The only supported value is v1. Defaults to v1. WebhookVersions []string `marker:"webhookVersions,optional"` @@ -318,11 +329,29 @@ func (c Config) clientConfig() (admissionregv1.WebhookClientConfig, error) { path := c.Path if path != "" { + var name, namespace string + var port *int32 + + if c.ServiceName != "" { + name = c.ServiceName + } else { + name = defaultServiceName + } + if c.ServiceNamespace != "" { + namespace = c.ServiceNamespace + } else { + namespace = defaultServiceNamespace + } + if c.ServicePort != nil { + port = c.ServicePort + } + return admissionregv1.WebhookClientConfig{ Service: &admissionregv1.ServiceReference{ - Name: "webhook-service", - Namespace: "system", + Name: name, + Namespace: namespace, Path: &path, + Port: port, }, }, nil } 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 d44e31ccc5..53ce42f59f 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 @@ -72,10 +72,22 @@ func (Config) Help() *markers.DefinitionHelp { Summary: "indicates the name of this webhook configuration. Should be a domain with at least three segments separated by dots", Details: "", }, + "ServiceName": { + Summary: "indicates the name of the K8s Service the webhook uses.", + Details: "", + }, + "ServiceNamespace": { + Summary: "indicates the namespace of the K8s Service the webhook uses.", + Details: "", + }, "Path": { Summary: "specifies that path that the API server should connect to this webhook on. Must be", Details: "prefixed with a '/validate-' or '/mutate-' depending on the type, and followed by\n$GROUP-$VERSION-$KIND where all values are lower-cased and the periods in the group\nare substituted for hyphens. For example, a validating webhook path for type\nbatch.tutorial.kubebuilder.io/v1,Kind=CronJob would be\n/validate-batch-tutorial-kubebuilder-io-v1-cronjob", }, + "ServicePort": { + Summary: "indicates the port of the K8s Service the webhook uses", + Details: "", + }, "WebhookVersions": { Summary: "specifies the target API versions of the {Mutating,Validating}WebhookConfiguration objects", Details: "itself to generate. The only supported value is v1. Defaults to v1.",