From 4c85931f0ba80113aec5e67cb8e3e549917728e9 Mon Sep 17 00:00:00 2001 From: "cilium-renovate[bot]" <134692979+cilium-renovate[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:57:17 +0000 Subject: [PATCH] fix(deps): update module sigs.k8s.io/controller-tools to v0.16.5 Signed-off-by: cilium-renovate[bot] <134692979+cilium-renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 +- .../tetragon/crds-yaml/cilium.io_podinfo.yaml | 2 +- .../crds-yaml/cilium.io_tracingpolicies.yaml | 2 +- .../cilium.io_tracingpoliciesnamespaced.yaml | 2 +- .../crds/v1alpha1/cilium.io_podinfo.yaml | 2 +- .../v1alpha1/cilium.io_tracingpolicies.yaml | 2 +- .../cilium.io_tracingpoliciesnamespaced.yaml | 2 +- pkg/k8s/go.mod | 2 +- pkg/k8s/go.sum | 4 +- pkg/k8s/vendor/modules.txt | 2 +- .../controller-tools/pkg/crd/markers/crd.go | 32 +++++++++++ .../crd/markers/zz_generated.markerhelp.go | 28 +++++++--- .../controller-tools/pkg/crd/schema.go | 54 ++++++++++++++----- .../pkg/crd/zz_generated.markerhelp.go | 6 +-- .../pkg/genall/zz_generated.markerhelp.go | 2 +- .../crds/v1alpha1/cilium.io_podinfo.yaml | 2 +- .../v1alpha1/cilium.io_tracingpolicies.yaml | 2 +- .../cilium.io_tracingpoliciesnamespaced.yaml | 2 +- vendor/modules.txt | 2 +- .../controller-tools/pkg/crd/markers/crd.go | 32 +++++++++++ .../crd/markers/zz_generated.markerhelp.go | 28 +++++++--- .../controller-tools/pkg/crd/schema.go | 54 ++++++++++++++----- .../pkg/crd/zz_generated.markerhelp.go | 6 +-- .../pkg/genall/zz_generated.markerhelp.go | 2 +- 25 files changed, 215 insertions(+), 63 deletions(-) diff --git a/go.mod b/go.mod index a1421cf5a2d..14616610b7e 100644 --- a/go.mod +++ b/go.mod @@ -57,7 +57,7 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f sigs.k8s.io/controller-runtime v0.19.1 - sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4 + sigs.k8s.io/controller-tools v0.16.5 sigs.k8s.io/e2e-framework v0.2.0 sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index c4cc68e42b6..2304edcc58c 100644 --- a/go.sum +++ b/go.sum @@ -613,8 +613,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsA sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/controller-runtime v0.19.1 h1:Son+Q40+Be3QWb+niBXAg2vFiYWolDjjRfO8hn/cxOk= sigs.k8s.io/controller-runtime v0.19.1/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= -sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4 h1:haAjjin8KL06HAWvDf7+kGq6d7rykR3phGpXjF7Xn7o= -sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4/go.mod h1:Duo4XTq7gaTyV2YRPCFnqg6bihcDjUAGoRPoPZY40i0= +sigs.k8s.io/controller-tools v0.16.5 h1:5k9FNRqziBPwqr17AMEPPV/En39ZBplLAdOwwQHruP4= +sigs.k8s.io/controller-tools v0.16.5/go.mod h1:8vztuRVzs8IuuJqKqbXCSlXcw+lkAv/M2sTpg55qjMY= sigs.k8s.io/e2e-framework v0.2.0 h1:gD6AWWAHFcHibI69E9TgkNFhh0mVwWtRCHy2RU057jQ= sigs.k8s.io/e2e-framework v0.2.0/go.mod h1:E6JXj/V4PIlb95jsn2WrNKG+Shb45xaaI7C0+BH4PL8= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/install/kubernetes/tetragon/crds-yaml/cilium.io_podinfo.yaml b/install/kubernetes/tetragon/crds-yaml/cilium.io_podinfo.yaml index 77067d9b514..d93009b588f 100644 --- a/install/kubernetes/tetragon/crds-yaml/cilium.io_podinfo.yaml +++ b/install/kubernetes/tetragon/crds-yaml/cilium.io_podinfo.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: podinfo.cilium.io spec: group: cilium.io diff --git a/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml b/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml index c0505a4c59c..641d9379157 100644 --- a/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml +++ b/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: tracingpolicies.cilium.io spec: group: cilium.io diff --git a/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpoliciesnamespaced.yaml b/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpoliciesnamespaced.yaml index c40265e704a..a4cd73714ab 100644 --- a/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpoliciesnamespaced.yaml +++ b/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpoliciesnamespaced.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: tracingpoliciesnamespaced.cilium.io spec: group: cilium.io diff --git a/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml b/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml index 77067d9b514..d93009b588f 100644 --- a/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml +++ b/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: podinfo.cilium.io spec: group: cilium.io diff --git a/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml b/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml index c0505a4c59c..641d9379157 100644 --- a/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml +++ b/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: tracingpolicies.cilium.io spec: group: cilium.io diff --git a/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml b/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml index c40265e704a..a4cd73714ab 100644 --- a/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml +++ b/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: tracingpoliciesnamespaced.cilium.io spec: group: cilium.io diff --git a/pkg/k8s/go.mod b/pkg/k8s/go.mod index 5d17c2c784f..1641ce3d4b4 100644 --- a/pkg/k8s/go.mod +++ b/pkg/k8s/go.mod @@ -14,7 +14,7 @@ require ( k8s.io/apimachinery v0.31.2 k8s.io/client-go v0.31.2 k8s.io/code-generator v0.31.2 - sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4 + sigs.k8s.io/controller-tools v0.16.5 sigs.k8s.io/yaml v1.4.0 ) diff --git a/pkg/k8s/go.sum b/pkg/k8s/go.sum index 537b3d5ee44..482a9a6efd9 100644 --- a/pkg/k8s/go.sum +++ b/pkg/k8s/go.sum @@ -191,8 +191,8 @@ k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 h1:Q8Z7VlGhcJgBHJHYugJ/K/ k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY9mD9fNT47QO6HI= k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4 h1:haAjjin8KL06HAWvDf7+kGq6d7rykR3phGpXjF7Xn7o= -sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4/go.mod h1:Duo4XTq7gaTyV2YRPCFnqg6bihcDjUAGoRPoPZY40i0= +sigs.k8s.io/controller-tools v0.16.5 h1:5k9FNRqziBPwqr17AMEPPV/En39ZBplLAdOwwQHruP4= +sigs.k8s.io/controller-tools v0.16.5/go.mod h1:8vztuRVzs8IuuJqKqbXCSlXcw+lkAv/M2sTpg55qjMY= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/pkg/k8s/vendor/modules.txt b/pkg/k8s/vendor/modules.txt index 48a8000734f..c87bf300093 100644 --- a/pkg/k8s/vendor/modules.txt +++ b/pkg/k8s/vendor/modules.txt @@ -570,7 +570,7 @@ k8s.io/utils/pointer k8s.io/utils/ptr k8s.io/utils/strings/slices k8s.io/utils/trace -# sigs.k8s.io/controller-tools v0.16.4-0.20240923084800-3b70a40398f4 +# sigs.k8s.io/controller-tools v0.16.5 ## explicit; go 1.22.0 sigs.k8s.io/controller-tools/cmd/controller-gen sigs.k8s.io/controller-tools/pkg/crd diff --git a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go index 1b1cf5ede18..36f3fcec305 100644 --- a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go +++ b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go @@ -55,6 +55,9 @@ var CRDMarkers = []*definitionWithHelp{ must(markers.MakeDefinition("kubebuilder:metadata", markers.DescribesType, Metadata{})). WithHelp(Metadata{}.Help()), + + must(markers.MakeDefinition("kubebuilder:selectablefield", markers.DescribesType, SelectableField{})). + WithHelp(SelectableField{}.Help()), } // TODO: categories and singular used to be annotations types @@ -388,3 +391,32 @@ func (s Metadata) ApplyToCRD(crd *apiext.CustomResourceDefinition, _ string) err return nil } + +// +controllertools:marker:generateHelp:category=CRD + +// SelectableField adds a field that may be used with field selectors. +type SelectableField struct { + // JSONPath specifies the jsonpath expression which is used to produce a field selector value. + JSONPath string `marker:"JSONPath"` +} + +func (s SelectableField) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error { + var selectableFields *[]apiext.SelectableField + for i := range crd.Versions { + ver := &crd.Versions[i] + if ver.Name != version { + continue + } + selectableFields = &ver.SelectableFields + break + } + if selectableFields == nil { + return fmt.Errorf("selectable field applied to version %q not in CRD", version) + } + + *selectableFields = append(*selectableFields, apiext.SelectableField{ + JSONPath: s.JSONPath, + }) + + return nil +} diff --git a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go index 7fb1b216430..e2db2b9902e 100644 --- a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go +++ b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/zz_generated.markerhelp.go @@ -148,7 +148,7 @@ func (ListType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the type of data-structure that the list", - Details: "represents (map, set, atomic).\n\n\nPossible data-structure types of a list are:\n\n\n - \"map\": it needs to have a key field, which will be used to build an\n associative list. A typical example is a the pod container list,\n which is indexed by the container name.\n\n\n - \"set\": Fields need to be \"scalar\", and there can be only one\n occurrence of each.\n\n\n - \"atomic\": All the fields in the list are treated as a single value,\n are typically manipulated together by the same actor.", + Details: "represents (map, set, atomic).\n\nPossible data-structure types of a list are:\n\n - \"map\": it needs to have a key field, which will be used to build an\n associative list. A typical example is a the pod container list,\n which is indexed by the container name.\n\n - \"set\": Fields need to be \"scalar\", and there can be only one\n occurrence of each.\n\n - \"atomic\": All the fields in the list are treated as a single value,\n are typically manipulated together by the same actor.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -159,7 +159,7 @@ func (MapType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the level of atomicity of the map;", - Details: "i.e. whether each item in the map is independent of the others,\nor all fields are treated as a single unit.\n\n\nPossible values:\n\n\n - \"granular\": items in the map are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire map.", + Details: "i.e. whether each item in the map is independent of the others,\nor all fields are treated as a single unit.\n\nPossible values:\n\n - \"granular\": items in the map are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire map.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -385,6 +385,22 @@ func (Schemaless) Help() *markers.DefinitionHelp { } } +func (SelectableField) Help() *markers.DefinitionHelp { + return &markers.DefinitionHelp{ + Category: "CRD", + DetailedHelp: markers.DetailedHelp{ + Summary: "adds a field that may be used with field selectors.", + Details: "", + }, + FieldHelp: map[string]markers.DetailedHelp{ + "JSONPath": { + Summary: "specifies the jsonpath expression which is used to produce a field selector value.", + Details: "", + }, + }, + } +} + func (SkipVersion) Help() *markers.DefinitionHelp { return &markers.DefinitionHelp{ Category: "CRD", @@ -412,7 +428,7 @@ func (StructType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the level of atomicity of the struct;", - Details: "i.e. whether each field in the struct is independent of the others,\nor all fields are treated as a single unit.\n\n\nPossible values:\n\n\n - \"granular\": fields in the struct are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire struct.", + Details: "i.e. whether each field in the struct is independent of the others,\nor all fields are treated as a single unit.\n\nPossible values:\n\n - \"granular\": fields in the struct are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire struct.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -502,7 +518,7 @@ func (XIntOrString) Help() *markers.DefinitionHelp { Category: "CRD validation", DetailedHelp: markers.DetailedHelp{ Summary: "IntOrString marks a fields as an IntOrString.", - Details: "This is required when applying patterns or other validations to an IntOrString\nfield. Knwon information about the type is applied during the collapse phase\nand as such is not normally available during marker application.", + Details: "This is required when applying patterns or other validations to an IntOrString\nfield. Known information about the type is applied during the collapse phase\nand as such is not normally available during marker application.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -513,7 +529,7 @@ func (XPreserveUnknownFields) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "PreserveUnknownFields stops the apiserver from pruning fields which are not specified.", - Details: "By default the apiserver drops unknown fields from the request payload\nduring the decoding step. This marker stops the API server from doing so.\nIt affects fields recursively, but switches back to normal pruning behaviour\nif nested properties or additionalProperties are specified in the schema.\nThis can either be true or undefined. False\nis forbidden.\n\n\nNB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated\nin favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function\nidentically.", + Details: "By default the apiserver drops unknown fields from the request payload\nduring the decoding step. This marker stops the API server from doing so.\nIt affects fields recursively, but switches back to normal pruning behaviour\nif nested properties or additionalProperties are specified in the schema.\nThis can either be true or undefined. False\nis forbidden.\n\nNB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated\nin favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function\nidentically.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -524,7 +540,7 @@ func (XValidation) Help() *markers.DefinitionHelp { Category: "CRD validation", DetailedHelp: markers.DetailedHelp{ Summary: "marks a field as requiring a value for which a given", - Details: "expression evaluates to true.\n\n\nThis marker may be repeated to specify multiple expressions, all of\nwhich must evaluate to true.", + Details: "expression evaluates to true.\n\nThis marker may be repeated to specify multiple expressions, all of\nwhich must evaluate to true.", }, FieldHelp: map[string]markers.DetailedHelp{ "Rule": { diff --git a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go index d2955c510bc..219d0dbb68b 100644 --- a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go +++ b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go @@ -125,29 +125,38 @@ func infoToSchema(ctx *schemaContext) *apiext.JSONSchemaProps { return typeToSchema(ctx, ctx.info.RawSpec.Type) } +type schemaMarkerWithName struct { + SchemaMarker SchemaMarker + Name string +} + // applyMarkers applies schema markers given their priority to the given schema func applyMarkers(ctx *schemaContext, markerSet markers.MarkerValues, props *apiext.JSONSchemaProps, node ast.Node) { - markers := make([]SchemaMarker, 0, len(markerSet)) - itemsMarkers := make([]SchemaMarker, 0, len(markerSet)) - itemsMarkerNames := make(map[SchemaMarker]string) + markers := make([]schemaMarkerWithName, 0, len(markerSet)) + itemsMarkers := make([]schemaMarkerWithName, 0, len(markerSet)) for markerName, markerValues := range markerSet { for _, markerValue := range markerValues { if schemaMarker, isSchemaMarker := markerValue.(SchemaMarker); isSchemaMarker { if strings.HasPrefix(markerName, crdmarkers.ValidationItemsPrefix) { - itemsMarkers = append(itemsMarkers, schemaMarker) - itemsMarkerNames[schemaMarker] = markerName + itemsMarkers = append(itemsMarkers, schemaMarkerWithName{ + SchemaMarker: schemaMarker, + Name: markerName, + }) } else { - markers = append(markers, schemaMarker) + markers = append(markers, schemaMarkerWithName{ + SchemaMarker: schemaMarker, + Name: markerName, + }) } } } } - cmpPriority := func(markers []SchemaMarker, i, j int) bool { + cmpPriority := func(markers []schemaMarkerWithName, i, j int) bool { var iPriority, jPriority crdmarkers.ApplyPriority - switch m := markers[i].(type) { + switch m := markers[i].SchemaMarker.(type) { case crdmarkers.ApplyPriorityMarker: iPriority = m.ApplyPriority() case applyFirstMarker: @@ -156,7 +165,7 @@ func applyMarkers(ctx *schemaContext, markerSet markers.MarkerValues, props *api iPriority = crdmarkers.ApplyPriorityDefault } - switch m := markers[j].(type) { + switch m := markers[j].SchemaMarker.(type) { case crdmarkers.ApplyPriorityMarker: jPriority = m.ApplyPriority() case applyFirstMarker: @@ -171,18 +180,18 @@ func applyMarkers(ctx *schemaContext, markerSet markers.MarkerValues, props *api sort.Slice(itemsMarkers, func(i, j int) bool { return cmpPriority(itemsMarkers, i, j) }) for _, schemaMarker := range markers { - if err := schemaMarker.ApplyToSchema(props); err != nil { + if err := schemaMarker.SchemaMarker.ApplyToSchema(props); err != nil { ctx.pkg.AddError(loader.ErrFromNode(err /* an okay guess */, node)) } } for _, schemaMarker := range itemsMarkers { if props.Type != "array" || props.Items == nil || props.Items.Schema == nil { - err := fmt.Errorf("must apply %s to an array value, found %s", itemsMarkerNames[schemaMarker], props.Type) + err := fmt.Errorf("must apply %s to an array value, found %s", schemaMarker.Name, props.Type) ctx.pkg.AddError(loader.ErrFromNode(err, node)) } else { itemsSchema := props.Items.Schema - if err := schemaMarker.ApplyToSchema(itemsSchema); err != nil { + if err := schemaMarker.SchemaMarker.ApplyToSchema(itemsSchema); err != nil { ctx.pkg.AddError(loader.ErrFromNode(err /* an okay guess */, node)) } } @@ -242,11 +251,30 @@ func localNamedToSchema(ctx *schemaContext, ident *ast.Ident) *apiext.JSONSchema ctx.pkg.AddError(loader.ErrFromNode(fmt.Errorf("unknown type %s", ident.Name), ident)) return &apiext.JSONSchemaProps{} } + // This reproduces the behavior we had pre gotypesalias=1 (needed if this + // project is compiled with default settings and Go >= 1.23). + if aliasInfo, isAlias := typeInfo.(*types.Alias); isAlias { + typeInfo = aliasInfo.Underlying() + } if basicInfo, isBasic := typeInfo.(*types.Basic); isBasic { typ, fmt, err := builtinToType(basicInfo, ctx.allowDangerousTypes) if err != nil { ctx.pkg.AddError(loader.ErrFromNode(err, ident)) } + // Check for type aliasing to a basic type for gotypesalias=0. See more + // in documentation https://pkg.go.dev/go/types#Alias: + // > For gotypesalias=1, alias declarations produce an Alias type. + // > Otherwise, the alias information is only in the type name, which + // > points directly to the actual (aliased) type. + if basicInfo.Name() != ident.Name { + ctx.requestSchema("", ident.Name) + link := TypeRefLink("", ident.Name) + return &apiext.JSONSchemaProps{ + Type: typ, + Format: fmt, + Ref: &link, + } + } return &apiext.JSONSchemaProps{ Type: typ, Format: fmt, @@ -274,7 +302,7 @@ func namedToSchema(ctx *schemaContext, named *ast.SelectorExpr) *apiext.JSONSche ctx.pkg.AddError(loader.ErrFromNode(fmt.Errorf("unknown type %v.%s", named.X, named.Sel.Name), named)) return &apiext.JSONSchemaProps{} } - typeInfo := typeInfoRaw.(*types.Named) + typeInfo := typeInfoRaw.(interface{ Obj() *types.TypeName }) typeNameInfo := typeInfo.Obj() nonVendorPath := loader.NonVendorPath(typeNameInfo.Pkg().Path()) ctx.requestSchema(nonVendorPath, typeNameInfo.Name()) diff --git a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go index c1aa3853f77..bf480ded9e8 100644 --- a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go +++ b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/crd/zz_generated.markerhelp.go @@ -38,7 +38,7 @@ func (Generator) Help() *markers.DefinitionHelp { }, "AllowDangerousTypes": { Summary: "allows types which are usually omitted from CRD generation", - Details: "because they are not recommended.\n\n\nCurrently the following additional types are allowed when this is true:\nfloat32\nfloat64\n\n\nLeft unspecified, the default is false", + Details: "because they are not recommended.\n\nCurrently the following additional types are allowed when this is true:\nfloat32\nfloat64\n\nLeft unspecified, the default is false", }, "MaxDescLen": { Summary: "specifies the maximum description length for fields in CRD's OpenAPI schema.", @@ -46,7 +46,7 @@ func (Generator) Help() *markers.DefinitionHelp { }, "CRDVersions": { Summary: "specifies the target API versions of the CRD type itself to", - Details: "generate. Defaults to v1.\n\n\nCurrently, the only supported value is v1.\n\n\nThe first version listed will be assumed to be the \"default\" version and\nwill not get a version suffix in the output filename.\n\n\nYou'll need to use \"v1\" to get support for features like defaulting,\nalong with an API server that supports it (Kubernetes 1.16+).", + Details: "generate. Defaults to v1.\n\nCurrently, the only supported value is v1.\n\nThe first version listed will be assumed to be the \"default\" version and\nwill not get a version suffix in the output filename.\n\nYou'll need to use \"v1\" to get support for features like defaulting,\nalong with an API server that supports it (Kubernetes 1.16+).", }, "GenerateEmbeddedObjectMeta": { Summary: "specifies if any embedded ObjectMeta in the CRD should be generated", @@ -62,7 +62,7 @@ func (Generator) Help() *markers.DefinitionHelp { }, "DeprecatedV1beta1CompatibilityPreserveUnknownFields": { Summary: "indicates whether", - Details: "or not we should turn off field pruning for this resource.\n\n\nSpecifies spec.preserveUnknownFields value that is false and omitted by default.\nThis value can only be specified for CustomResourceDefinitions that were created with\n`apiextensions.k8s.io/v1beta1`.\n\n\nThe field can be set for compatiblity reasons, although strongly discouraged, resource\nauthors should move to a structural OpenAPI schema instead.\n\n\nSee https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning\nfor more information about field pruning and v1beta1 resources compatibility.", + Details: "or not we should turn off field pruning for this resource.\n\nSpecifies spec.preserveUnknownFields value that is false and omitted by default.\nThis value can only be specified for CustomResourceDefinitions that were created with\n`apiextensions.k8s.io/v1beta1`.\n\nThe field can be set for compatiblity reasons, although strongly discouraged, resource\nauthors should move to a structural OpenAPI schema instead.\n\nSee https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning\nfor more information about field pruning and v1beta1 resources compatibility.", }, }, } diff --git a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go index 998061b9bbe..b33c2392e7b 100644 --- a/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go +++ b/pkg/k8s/vendor/sigs.k8s.io/controller-tools/pkg/genall/zz_generated.markerhelp.go @@ -40,7 +40,7 @@ func (OutputArtifacts) Help() *markers.DefinitionHelp { Category: "", DetailedHelp: markers.DetailedHelp{ Summary: "outputs artifacts to different locations, depending on", - Details: "whether they're package-associated or not.\n\n\nNon-package associated artifacts\nare output to the Config directory, while package-associated ones are output\nto their package's source files' directory, unless an alternate path is\nspecified in Code.", + Details: "whether they're package-associated or not.\n\nNon-package associated artifacts\nare output to the Config directory, while package-associated ones are output\nto their package's source files' directory, unless an alternate path is\nspecified in Code.", }, FieldHelp: map[string]markers.DetailedHelp{ "Config": { diff --git a/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml b/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml index 77067d9b514..d93009b588f 100644 --- a/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml +++ b/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_podinfo.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: podinfo.cilium.io spec: group: cilium.io diff --git a/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml b/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml index c0505a4c59c..641d9379157 100644 --- a/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml +++ b/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpolicies.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: tracingpolicies.cilium.io spec: group: cilium.io diff --git a/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml b/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml index c40265e704a..a4cd73714ab 100644 --- a/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml +++ b/vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/client/crds/v1alpha1/cilium.io_tracingpoliciesnamespaced.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4-0.20240923084800-3b70a40398f4 + controller-gen.kubebuilder.io/version: v0.16.5 name: tracingpoliciesnamespaced.cilium.io spec: group: cilium.io diff --git a/vendor/modules.txt b/vendor/modules.txt index 83ffbf74fe6..eaf39f2bf1c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1476,7 +1476,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.16.4-0.20240923084800-3b70a40398f4 +# sigs.k8s.io/controller-tools v0.16.5 ## explicit; go 1.22.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/crd.go b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go index 1b1cf5ede18..36f3fcec305 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/markers/crd.go @@ -55,6 +55,9 @@ var CRDMarkers = []*definitionWithHelp{ must(markers.MakeDefinition("kubebuilder:metadata", markers.DescribesType, Metadata{})). WithHelp(Metadata{}.Help()), + + must(markers.MakeDefinition("kubebuilder:selectablefield", markers.DescribesType, SelectableField{})). + WithHelp(SelectableField{}.Help()), } // TODO: categories and singular used to be annotations types @@ -388,3 +391,32 @@ func (s Metadata) ApplyToCRD(crd *apiext.CustomResourceDefinition, _ string) err return nil } + +// +controllertools:marker:generateHelp:category=CRD + +// SelectableField adds a field that may be used with field selectors. +type SelectableField struct { + // JSONPath specifies the jsonpath expression which is used to produce a field selector value. + JSONPath string `marker:"JSONPath"` +} + +func (s SelectableField) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error { + var selectableFields *[]apiext.SelectableField + for i := range crd.Versions { + ver := &crd.Versions[i] + if ver.Name != version { + continue + } + selectableFields = &ver.SelectableFields + break + } + if selectableFields == nil { + return fmt.Errorf("selectable field applied to version %q not in CRD", version) + } + + *selectableFields = append(*selectableFields, apiext.SelectableField{ + JSONPath: s.JSONPath, + }) + + 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 7fb1b216430..e2db2b9902e 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 @@ -148,7 +148,7 @@ func (ListType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the type of data-structure that the list", - Details: "represents (map, set, atomic).\n\n\nPossible data-structure types of a list are:\n\n\n - \"map\": it needs to have a key field, which will be used to build an\n associative list. A typical example is a the pod container list,\n which is indexed by the container name.\n\n\n - \"set\": Fields need to be \"scalar\", and there can be only one\n occurrence of each.\n\n\n - \"atomic\": All the fields in the list are treated as a single value,\n are typically manipulated together by the same actor.", + Details: "represents (map, set, atomic).\n\nPossible data-structure types of a list are:\n\n - \"map\": it needs to have a key field, which will be used to build an\n associative list. A typical example is a the pod container list,\n which is indexed by the container name.\n\n - \"set\": Fields need to be \"scalar\", and there can be only one\n occurrence of each.\n\n - \"atomic\": All the fields in the list are treated as a single value,\n are typically manipulated together by the same actor.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -159,7 +159,7 @@ func (MapType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the level of atomicity of the map;", - Details: "i.e. whether each item in the map is independent of the others,\nor all fields are treated as a single unit.\n\n\nPossible values:\n\n\n - \"granular\": items in the map are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire map.", + Details: "i.e. whether each item in the map is independent of the others,\nor all fields are treated as a single unit.\n\nPossible values:\n\n - \"granular\": items in the map are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire map.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -385,6 +385,22 @@ func (Schemaless) Help() *markers.DefinitionHelp { } } +func (SelectableField) Help() *markers.DefinitionHelp { + return &markers.DefinitionHelp{ + Category: "CRD", + DetailedHelp: markers.DetailedHelp{ + Summary: "adds a field that may be used with field selectors.", + Details: "", + }, + FieldHelp: map[string]markers.DetailedHelp{ + "JSONPath": { + Summary: "specifies the jsonpath expression which is used to produce a field selector value.", + Details: "", + }, + }, + } +} + func (SkipVersion) Help() *markers.DefinitionHelp { return &markers.DefinitionHelp{ Category: "CRD", @@ -412,7 +428,7 @@ func (StructType) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "specifies the level of atomicity of the struct;", - Details: "i.e. whether each field in the struct is independent of the others,\nor all fields are treated as a single unit.\n\n\nPossible values:\n\n\n - \"granular\": fields in the struct are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire struct.", + Details: "i.e. whether each field in the struct is independent of the others,\nor all fields are treated as a single unit.\n\nPossible values:\n\n - \"granular\": fields in the struct are independent of each other,\n and can be manipulated by different actors.\n This is the default behavior.\n\n - \"atomic\": all fields are treated as one unit.\n Any changes have to replace the entire struct.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -502,7 +518,7 @@ func (XIntOrString) Help() *markers.DefinitionHelp { Category: "CRD validation", DetailedHelp: markers.DetailedHelp{ Summary: "IntOrString marks a fields as an IntOrString.", - Details: "This is required when applying patterns or other validations to an IntOrString\nfield. Knwon information about the type is applied during the collapse phase\nand as such is not normally available during marker application.", + Details: "This is required when applying patterns or other validations to an IntOrString\nfield. Known information about the type is applied during the collapse phase\nand as such is not normally available during marker application.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -513,7 +529,7 @@ func (XPreserveUnknownFields) Help() *markers.DefinitionHelp { Category: "CRD processing", DetailedHelp: markers.DetailedHelp{ Summary: "PreserveUnknownFields stops the apiserver from pruning fields which are not specified.", - Details: "By default the apiserver drops unknown fields from the request payload\nduring the decoding step. This marker stops the API server from doing so.\nIt affects fields recursively, but switches back to normal pruning behaviour\nif nested properties or additionalProperties are specified in the schema.\nThis can either be true or undefined. False\nis forbidden.\n\n\nNB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated\nin favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function\nidentically.", + Details: "By default the apiserver drops unknown fields from the request payload\nduring the decoding step. This marker stops the API server from doing so.\nIt affects fields recursively, but switches back to normal pruning behaviour\nif nested properties or additionalProperties are specified in the schema.\nThis can either be true or undefined. False\nis forbidden.\n\nNB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated\nin favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function\nidentically.", }, FieldHelp: map[string]markers.DetailedHelp{}, } @@ -524,7 +540,7 @@ func (XValidation) Help() *markers.DefinitionHelp { Category: "CRD validation", DetailedHelp: markers.DetailedHelp{ Summary: "marks a field as requiring a value for which a given", - Details: "expression evaluates to true.\n\n\nThis marker may be repeated to specify multiple expressions, all of\nwhich must evaluate to true.", + Details: "expression evaluates to true.\n\nThis marker may be repeated to specify multiple expressions, all of\nwhich must evaluate to true.", }, FieldHelp: map[string]markers.DetailedHelp{ "Rule": { 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 d2955c510bc..219d0dbb68b 100644 --- a/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go +++ b/vendor/sigs.k8s.io/controller-tools/pkg/crd/schema.go @@ -125,29 +125,38 @@ func infoToSchema(ctx *schemaContext) *apiext.JSONSchemaProps { return typeToSchema(ctx, ctx.info.RawSpec.Type) } +type schemaMarkerWithName struct { + SchemaMarker SchemaMarker + Name string +} + // applyMarkers applies schema markers given their priority to the given schema func applyMarkers(ctx *schemaContext, markerSet markers.MarkerValues, props *apiext.JSONSchemaProps, node ast.Node) { - markers := make([]SchemaMarker, 0, len(markerSet)) - itemsMarkers := make([]SchemaMarker, 0, len(markerSet)) - itemsMarkerNames := make(map[SchemaMarker]string) + markers := make([]schemaMarkerWithName, 0, len(markerSet)) + itemsMarkers := make([]schemaMarkerWithName, 0, len(markerSet)) for markerName, markerValues := range markerSet { for _, markerValue := range markerValues { if schemaMarker, isSchemaMarker := markerValue.(SchemaMarker); isSchemaMarker { if strings.HasPrefix(markerName, crdmarkers.ValidationItemsPrefix) { - itemsMarkers = append(itemsMarkers, schemaMarker) - itemsMarkerNames[schemaMarker] = markerName + itemsMarkers = append(itemsMarkers, schemaMarkerWithName{ + SchemaMarker: schemaMarker, + Name: markerName, + }) } else { - markers = append(markers, schemaMarker) + markers = append(markers, schemaMarkerWithName{ + SchemaMarker: schemaMarker, + Name: markerName, + }) } } } } - cmpPriority := func(markers []SchemaMarker, i, j int) bool { + cmpPriority := func(markers []schemaMarkerWithName, i, j int) bool { var iPriority, jPriority crdmarkers.ApplyPriority - switch m := markers[i].(type) { + switch m := markers[i].SchemaMarker.(type) { case crdmarkers.ApplyPriorityMarker: iPriority = m.ApplyPriority() case applyFirstMarker: @@ -156,7 +165,7 @@ func applyMarkers(ctx *schemaContext, markerSet markers.MarkerValues, props *api iPriority = crdmarkers.ApplyPriorityDefault } - switch m := markers[j].(type) { + switch m := markers[j].SchemaMarker.(type) { case crdmarkers.ApplyPriorityMarker: jPriority = m.ApplyPriority() case applyFirstMarker: @@ -171,18 +180,18 @@ func applyMarkers(ctx *schemaContext, markerSet markers.MarkerValues, props *api sort.Slice(itemsMarkers, func(i, j int) bool { return cmpPriority(itemsMarkers, i, j) }) for _, schemaMarker := range markers { - if err := schemaMarker.ApplyToSchema(props); err != nil { + if err := schemaMarker.SchemaMarker.ApplyToSchema(props); err != nil { ctx.pkg.AddError(loader.ErrFromNode(err /* an okay guess */, node)) } } for _, schemaMarker := range itemsMarkers { if props.Type != "array" || props.Items == nil || props.Items.Schema == nil { - err := fmt.Errorf("must apply %s to an array value, found %s", itemsMarkerNames[schemaMarker], props.Type) + err := fmt.Errorf("must apply %s to an array value, found %s", schemaMarker.Name, props.Type) ctx.pkg.AddError(loader.ErrFromNode(err, node)) } else { itemsSchema := props.Items.Schema - if err := schemaMarker.ApplyToSchema(itemsSchema); err != nil { + if err := schemaMarker.SchemaMarker.ApplyToSchema(itemsSchema); err != nil { ctx.pkg.AddError(loader.ErrFromNode(err /* an okay guess */, node)) } } @@ -242,11 +251,30 @@ func localNamedToSchema(ctx *schemaContext, ident *ast.Ident) *apiext.JSONSchema ctx.pkg.AddError(loader.ErrFromNode(fmt.Errorf("unknown type %s", ident.Name), ident)) return &apiext.JSONSchemaProps{} } + // This reproduces the behavior we had pre gotypesalias=1 (needed if this + // project is compiled with default settings and Go >= 1.23). + if aliasInfo, isAlias := typeInfo.(*types.Alias); isAlias { + typeInfo = aliasInfo.Underlying() + } if basicInfo, isBasic := typeInfo.(*types.Basic); isBasic { typ, fmt, err := builtinToType(basicInfo, ctx.allowDangerousTypes) if err != nil { ctx.pkg.AddError(loader.ErrFromNode(err, ident)) } + // Check for type aliasing to a basic type for gotypesalias=0. See more + // in documentation https://pkg.go.dev/go/types#Alias: + // > For gotypesalias=1, alias declarations produce an Alias type. + // > Otherwise, the alias information is only in the type name, which + // > points directly to the actual (aliased) type. + if basicInfo.Name() != ident.Name { + ctx.requestSchema("", ident.Name) + link := TypeRefLink("", ident.Name) + return &apiext.JSONSchemaProps{ + Type: typ, + Format: fmt, + Ref: &link, + } + } return &apiext.JSONSchemaProps{ Type: typ, Format: fmt, @@ -274,7 +302,7 @@ func namedToSchema(ctx *schemaContext, named *ast.SelectorExpr) *apiext.JSONSche ctx.pkg.AddError(loader.ErrFromNode(fmt.Errorf("unknown type %v.%s", named.X, named.Sel.Name), named)) return &apiext.JSONSchemaProps{} } - typeInfo := typeInfoRaw.(*types.Named) + typeInfo := typeInfoRaw.(interface{ Obj() *types.TypeName }) typeNameInfo := typeInfo.Obj() nonVendorPath := loader.NonVendorPath(typeNameInfo.Pkg().Path()) ctx.requestSchema(nonVendorPath, typeNameInfo.Name()) 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 c1aa3853f77..bf480ded9e8 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 @@ -38,7 +38,7 @@ func (Generator) Help() *markers.DefinitionHelp { }, "AllowDangerousTypes": { Summary: "allows types which are usually omitted from CRD generation", - Details: "because they are not recommended.\n\n\nCurrently the following additional types are allowed when this is true:\nfloat32\nfloat64\n\n\nLeft unspecified, the default is false", + Details: "because they are not recommended.\n\nCurrently the following additional types are allowed when this is true:\nfloat32\nfloat64\n\nLeft unspecified, the default is false", }, "MaxDescLen": { Summary: "specifies the maximum description length for fields in CRD's OpenAPI schema.", @@ -46,7 +46,7 @@ func (Generator) Help() *markers.DefinitionHelp { }, "CRDVersions": { Summary: "specifies the target API versions of the CRD type itself to", - Details: "generate. Defaults to v1.\n\n\nCurrently, the only supported value is v1.\n\n\nThe first version listed will be assumed to be the \"default\" version and\nwill not get a version suffix in the output filename.\n\n\nYou'll need to use \"v1\" to get support for features like defaulting,\nalong with an API server that supports it (Kubernetes 1.16+).", + Details: "generate. Defaults to v1.\n\nCurrently, the only supported value is v1.\n\nThe first version listed will be assumed to be the \"default\" version and\nwill not get a version suffix in the output filename.\n\nYou'll need to use \"v1\" to get support for features like defaulting,\nalong with an API server that supports it (Kubernetes 1.16+).", }, "GenerateEmbeddedObjectMeta": { Summary: "specifies if any embedded ObjectMeta in the CRD should be generated", @@ -62,7 +62,7 @@ func (Generator) Help() *markers.DefinitionHelp { }, "DeprecatedV1beta1CompatibilityPreserveUnknownFields": { Summary: "indicates whether", - Details: "or not we should turn off field pruning for this resource.\n\n\nSpecifies spec.preserveUnknownFields value that is false and omitted by default.\nThis value can only be specified for CustomResourceDefinitions that were created with\n`apiextensions.k8s.io/v1beta1`.\n\n\nThe field can be set for compatiblity reasons, although strongly discouraged, resource\nauthors should move to a structural OpenAPI schema instead.\n\n\nSee https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning\nfor more information about field pruning and v1beta1 resources compatibility.", + Details: "or not we should turn off field pruning for this resource.\n\nSpecifies spec.preserveUnknownFields value that is false and omitted by default.\nThis value can only be specified for CustomResourceDefinitions that were created with\n`apiextensions.k8s.io/v1beta1`.\n\nThe field can be set for compatiblity reasons, although strongly discouraged, resource\nauthors should move to a structural OpenAPI schema instead.\n\nSee https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning\nfor more information about field pruning and v1beta1 resources compatibility.", }, }, } 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 998061b9bbe..b33c2392e7b 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 @@ -40,7 +40,7 @@ func (OutputArtifacts) Help() *markers.DefinitionHelp { Category: "", DetailedHelp: markers.DetailedHelp{ Summary: "outputs artifacts to different locations, depending on", - Details: "whether they're package-associated or not.\n\n\nNon-package associated artifacts\nare output to the Config directory, while package-associated ones are output\nto their package's source files' directory, unless an alternate path is\nspecified in Code.", + Details: "whether they're package-associated or not.\n\nNon-package associated artifacts\nare output to the Config directory, while package-associated ones are output\nto their package's source files' directory, unless an alternate path is\nspecified in Code.", }, FieldHelp: map[string]markers.DetailedHelp{ "Config": {