diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 88202180b..ef3c61b1d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -31,8 +31,8 @@ jobs: with: go-version: ${{ steps.vars.outputs.go_version }} - name: golangci-lint - uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2 + uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0 with: - version: v1.64.8 - args: --out-format=colored-line-number + version: v2.1.6 + args: --output.text.print-linter-name=true --output.text.colors=true --timeout 10m working-directory: ${{matrix.working-directory}} diff --git a/.golangci.yml b/.golangci.yml index 112ae58ad..58706c462 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,14 +1,12 @@ +version: "2" run: - allow-parallel-runners: true - modules-download-mode: readonly - # Increase the default deadline from 1m as some module operations can take a - # while if uncached! - timeout: 10m go: "1.24" - + timeout: 10m + modules-download-mode: readonly + allow-parallel-runners: true linters: # sync from https://github.com/kubernetes-sigs/controller-runtime/blob/main/.golangci.yml - disable-all: true + default: none enable: - asasalint - asciicheck @@ -25,10 +23,7 @@ linters: - goconst - gocritic - gocyclo - - gofmt - - goimports - goprintffuncname - - gosimple - govet - importas - ineffassign @@ -40,74 +35,95 @@ linters: - prealloc - revive - staticcheck - - stylecheck - tagliatelle - - typecheck - unconvert - unparam - unused - whitespace - -issues: - exclude-rules: - # Dot imports for gomega and ginkgo are allowed - # within test files. - - path: _test\.go - text: should not use dot imports - # Ignore error type switch case - - path: "pkg/loader/loader.go" - linters: - - errorlint - # Ignore test files - - linters: - - dupl - - ginkgolinter - path: _test\.go - - linters: - - gocritic - path: "pkg/markers/help.go" - - linters: - - exhaustive - path: "pkg/markers/parse.go|pkg/deepcopy/traverse.go|pkg/genall/help/types.go|pkg/crd/schema.go|pkg/crd/flatten.go" - # Ignore consider pre-allocating variables - - linters: - - prealloc - text: Consider pre-allocating -linters-settings: - govet: - enable-all: true - disable: - - fieldalignment - - shadow - importas: - no-unaliased: true - revive: - # By default, revive will enable only the linting rules that are named in the configuration file. - # So, it's needed to explicitly enable all required rules here. + settings: + govet: + disable: + - fieldalignment + - shadow + enable-all: true + importas: + no-unaliased: true + revive: + # By default, revive will enable only the linting rules that are named in the configuration file. + # So, it's needed to explicitly enable all required rules here. + rules: + # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: superfluous-else + - name: unreachable-code + - name: redefines-builtin-id + # + # Rules in addition to the recommended configuration above. + # + - name: bool-literal-in-expr + - name: constant-logical-expr + exclusions: + generated: strict + paths: + - zz_generated.*\.go$ + - .*conversion.*\.go$ + presets: + - comments + - common-false-positives + - legacy + - std-error-handling rules: - # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: error-return - - name: error-strings - - name: error-naming - - name: if-return - - name: increment-decrement - - name: var-naming - - name: var-declaration - - name: range - - name: receiver-naming - - name: time-naming - - name: unexported-return - - name: indent-error-flow - - name: errorf - - name: superfluous-else - - name: unreachable-code - - name: redefines-builtin-id - # - # Rules in addition to the recommended configuration above. - # - - name: bool-literal-in-expr - - name: constant-logical-expr + # Dot imports for gomega and ginkgo are allowed + # within test files. + - linters: + - revive + path: _test\.go + text: should not use dot imports + # Ignore error type switch case + - linters: + - errorlint + path: pkg/loader/loader.go + # Ignore test files + - linters: + - dupl + - ginkgolinter + path: _test\.go + - linters: + - gocritic + path: pkg/markers/help.go + - linters: + - exhaustive + path: pkg/markers/parse.go|pkg/deepcopy/traverse.go|pkg/genall/help/types.go|pkg/crd/schema.go|pkg/crd/flatten.go + # Ignore consider pre-allocating variables + - linters: + - prealloc + text: Consider pre-allocating + - linters: + - staticcheck + path: (.+)\.go$ + text: (QF1008) +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: strict + paths: + - zz_generated.*\.go$ + - .*conversion.*\.go$ diff --git a/Makefile b/Makefile index 570d5f956..48df4470e 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ GO_INSTALL := ./hack/go-install.sh GOLANGCI_LINT_BIN := golangci-lint GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version: | sed 's/.*version: //') GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)) -GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint +GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/v2/cmd/golangci-lint $(GOLANGCI_LINT): # Build golangci-lint from tools folder. GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER) diff --git a/envtest-releases.yaml b/envtest-releases.yaml index 74ddcef36..ee4ab63d0 100644 --- a/envtest-releases.yaml +++ b/envtest-releases.yaml @@ -461,25 +461,3 @@ releases: envtest-v1.33.0-alpha.2-windows-amd64.tar.gz: hash: 93b9203ee2ac59f8bdacc996afc664925bb86a9d73c7a32effbda3fdce360464158966727557603a097beffcf0c11320034dc58febd2aaff8ef48e2080270619 selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0-alpha.2/envtest-v1.33.0-alpha.2-windows-amd64.tar.gz - v1.33.0: - envtest-v1.33.0-darwin-amd64.tar.gz: - hash: 71a387a4cac32b17e22046df594090b6503fc074be8caae78bc80ef83949e292a1290eefe725acd41ce4bec730f7442006f2a9eb19d8e2d4d9df2feb67da04ba - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-darwin-amd64.tar.gz - envtest-v1.33.0-darwin-arm64.tar.gz: - hash: 623dc02432905e58738c5611b8b0808437762755003dbaee266ded27dfe9a37d5a75ed6578ac4fbb261c7cd19c0199a7428de77b40b2f881912a4468c4d98d61 - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-darwin-arm64.tar.gz - envtest-v1.33.0-linux-amd64.tar.gz: - hash: 2cb7f5468ed7cea1492f971b715bcc27069e824cf7d5927b7f127f1e8c75cf086eea050543cdb5f79faee0a2bf775f160adf27443aa7ee845d962d04e9d43ac9 - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-linux-amd64.tar.gz - envtest-v1.33.0-linux-arm64.tar.gz: - hash: 366ba32b2154c16e0ce952ed69731feefed187c88030f76a14bda5921a498d0aa25528629fc41c225cf78c91fd4a424a472e38efec91e8fcbd254fac0e150a54 - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-linux-arm64.tar.gz - envtest-v1.33.0-linux-ppc64le.tar.gz: - hash: 5dff159c89176833c3c6c58ed3c4e6e5ccb9a14b69d1800038bd366bacbdf28a382ceaab17d5eed57395048d455f4f6b37aaf5a31a2cd5b2fe967ad855927426 - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-linux-ppc64le.tar.gz - envtest-v1.33.0-linux-s390x.tar.gz: - hash: 79ff5dbe13c051fa0e9da3043d4f70b360b222d5853c2300298be4964ae0dccd7460988bddd0b552b32382c3686c6ebbe33556655f8aa857495497f3f16015ff - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-linux-s390x.tar.gz - envtest-v1.33.0-windows-amd64.tar.gz: - hash: a90dd67faca93467e6b3d3e275937681e3cb50e00e206a60984ba2ee75c8c237624ee5577ae64773a8eeae726bd8c8b12a45e76d9da1809e76faf975fee77191 - selfLink: https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-v1.33.0/envtest-v1.33.0-windows-amd64.tar.gz diff --git a/go.mod b/go.mod index 45b9dc85b..b603f9a15 100644 --- a/go.mod +++ b/go.mod @@ -7,16 +7,16 @@ require ( github.com/gobuffalo/flect v1.0.3 github.com/google/go-cmp v0.7.0 github.com/onsi/ginkgo v1.16.5 - github.com/onsi/gomega v1.37.0 + github.com/onsi/gomega v1.36.3 github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 golang.org/x/tools v0.33.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.33.0 - k8s.io/apiextensions-apiserver v0.33.0 - k8s.io/apimachinery v0.33.0 - k8s.io/code-generator v0.33.0 + k8s.io/api v0.33.0-beta.0 + k8s.io/apiextensions-apiserver v0.33.0-beta.0 + k8s.io/apimachinery v0.33.0-beta.0 + k8s.io/code-generator v0.33.0-beta.0 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/yaml v1.4.0 @@ -50,7 +50,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect diff --git a/go.sum b/go.sum index 89e1cd567..36bfb483a 100644 --- a/go.sum +++ b/go.sum @@ -86,8 +86,8 @@ github.com/onsi/ginkgo/v2 v2.23.3 h1:edHxnszytJ4lD9D5Jjc4tiDkPBZ3siDeJJkUZJJVkp0 github.com/onsi/ginkgo/v2 v2.23.3/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM= 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.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y= -github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= +github.com/onsi/gomega v1.36.3 h1:hID7cr8t3Wp26+cYnfcjR6HpJ00fdogN6dqZ1t6IylU= +github.com/onsi/gomega v1.36.3/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= 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/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= @@ -184,20 +184,20 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.33.0 h1:yTgZVn1XEe6opVpP1FylmNrIFWuDqe2H0V8CT5gxfIU= -k8s.io/api v0.33.0/go.mod h1:CTO61ECK/KU7haa3qq8sarQ0biLq2ju405IZAd9zsiM= -k8s.io/apiextensions-apiserver v0.33.0 h1:d2qpYL7Mngbsc1taA4IjJPRJ9ilnsXIrndH+r9IimOs= -k8s.io/apiextensions-apiserver v0.33.0/go.mod h1:VeJ8u9dEEN+tbETo+lFkwaaZPg6uFKLGj5vyNEwwSzc= -k8s.io/apimachinery v0.33.0 h1:1a6kHrJxb2hs4t8EE5wuR/WxKDwGN1FKH3JvDtA0CIQ= -k8s.io/apimachinery v0.33.0/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= -k8s.io/code-generator v0.33.0 h1:B212FVl6EFqNmlgdOZYWNi77yBv+ed3QgQsMR8YQCw4= -k8s.io/code-generator v0.33.0/go.mod h1:KnJRokGxjvbBQkSJkbVuBbu6z4B0rC7ynkpY5Aw6m9o= +k8s.io/api v0.33.0-beta.0 h1:/sAUrfXsjKPST2mZjpWhjRdzSR6SD5KlJpiOgCQQhAQ= +k8s.io/api v0.33.0-beta.0/go.mod h1:TYyCgedkG4OVS4+4D2n25BdbMcexMSLx6Y7OkAzkxLQ= +k8s.io/apiextensions-apiserver v0.33.0-beta.0 h1:3oqBvfd26IOekt96KEfE8A0wA/k1wDSBfTPirkRun1Q= +k8s.io/apiextensions-apiserver v0.33.0-beta.0/go.mod h1:TKTeoFcmGvtiDNV+wj8wJfZhamZNOhvi9yOIE2d1iWs= +k8s.io/apimachinery v0.33.0-beta.0 h1:vLDBChfQwyimk6AbuT7OZOIqxSg/44JlXuxqBk85j68= +k8s.io/apimachinery v0.33.0-beta.0/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo= +k8s.io/code-generator v0.33.0-beta.0 h1:QYiWYFUT9G7lnF1ucDYr/sZUaG/kptrooX2PJxEL+Go= +k8s.io/code-generator v0.33.0-beta.0/go.mod h1:RBvFpvqtyQygCBjMayNyYqdzy+89LdzqAx0Th+dgmzQ= k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1PoqTlYqEq5H2oetog= k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= diff --git a/hack/envtest/_matrix/v1.33.0.yaml b/hack/envtest/_matrix/v1.33.0.yaml deleted file mode 100644 index ccbb940fb..000000000 --- a/hack/envtest/_matrix/v1.33.0.yaml +++ /dev/null @@ -1,3 +0,0 @@ -go: 1.24.2 -etcd: v3.5.21 - diff --git a/pkg/applyconfiguration/testdata/cronjob/go.mod b/pkg/applyconfiguration/testdata/cronjob/go.mod index 8d7ba43e2..5e5314ee9 100644 --- a/pkg/applyconfiguration/testdata/cronjob/go.mod +++ b/pkg/applyconfiguration/testdata/cronjob/go.mod @@ -5,9 +5,9 @@ go 1.24.0 toolchain go1.24.1 require ( - k8s.io/api v0.33.0 - k8s.io/apimachinery v0.33.0 - k8s.io/client-go v0.33.0 + k8s.io/api v0.33.0-beta.0 + k8s.io/apimachinery v0.33.0-beta.0 + k8s.io/client-go v0.33.0-beta.0 sigs.k8s.io/structured-merge-diff/v4 v4.6.0 ) @@ -30,18 +30,18 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/net v0.38.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.27.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/term v0.30.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/term v0.29.0 // indirect + golang.org/x/text v0.22.0 // indirect golang.org/x/time v0.9.0 // indirect google.golang.org/protobuf v1.36.5 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect sigs.k8s.io/randfill v1.0.0 // indirect diff --git a/pkg/applyconfiguration/testdata/cronjob/go.sum b/pkg/applyconfiguration/testdata/cronjob/go.sum index c0c57d7a1..730d19731 100644 --- a/pkg/applyconfiguration/testdata/cronjob/go.sum +++ b/pkg/applyconfiguration/testdata/cronjob/go.sum @@ -89,8 +89,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M= golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -99,14 +99,14 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= -golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -131,16 +131,16 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.33.0 h1:yTgZVn1XEe6opVpP1FylmNrIFWuDqe2H0V8CT5gxfIU= -k8s.io/api v0.33.0/go.mod h1:CTO61ECK/KU7haa3qq8sarQ0biLq2ju405IZAd9zsiM= -k8s.io/apimachinery v0.33.0 h1:1a6kHrJxb2hs4t8EE5wuR/WxKDwGN1FKH3JvDtA0CIQ= -k8s.io/apimachinery v0.33.0/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= -k8s.io/client-go v0.33.0 h1:UASR0sAYVUzs2kYuKn/ZakZlcs2bEHaizrrHUZg0G98= -k8s.io/client-go v0.33.0/go.mod h1:kGkd+l/gNGg8GYWAPr0xF1rRKvVWvzh9vmZAMXtaKOg= +k8s.io/api v0.33.0-beta.0 h1:/sAUrfXsjKPST2mZjpWhjRdzSR6SD5KlJpiOgCQQhAQ= +k8s.io/api v0.33.0-beta.0/go.mod h1:TYyCgedkG4OVS4+4D2n25BdbMcexMSLx6Y7OkAzkxLQ= +k8s.io/apimachinery v0.33.0-beta.0 h1:vLDBChfQwyimk6AbuT7OZOIqxSg/44JlXuxqBk85j68= +k8s.io/apimachinery v0.33.0-beta.0/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo= +k8s.io/client-go v0.33.0-beta.0 h1:xRGKK5hU39pb6CFDCDOOlG+LEenB93/RK9hoP4eyAsU= +k8s.io/client-go v0.33.0-beta.0/go.mod h1:RF6hSu+FncpgHQs1zA1UfGbMq8gxay89r37bCQe+Mj4= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= diff --git a/pkg/crd/markers/validation.go b/pkg/crd/markers/validation.go index e1cad593c..ccd52e53c 100644 --- a/pkg/crd/markers/validation.go +++ b/pkg/crd/markers/validation.go @@ -103,9 +103,6 @@ var FieldOnlyMarkers = []*definitionWithHelp{ must(markers.MakeDefinition(SchemalessName, markers.DescribesField, Schemaless{})). WithHelp(Schemaless{}.Help()), - - must(markers.MakeAnyTypeDefinition("kubebuilder:title", markers.DescribesField, Title{})). - WithHelp(Title{}.Help()), } // ValidationIshMarkers are field-and-type markers that don't fall under the @@ -245,17 +242,6 @@ type Default struct { Value interface{} } -// +controllertools:marker:generateHelp:category="CRD validation" -// Title sets the title for this field. -// -// The title is metadata that makes the OpenAPI documentation more user-friendly, -// making the schema more understandable when viewed in documentation tools. -// It's a metadata field that doesn't affect validation but provides -// important context about what the schema represents. -type Title struct { - Value interface{} -} - // +controllertools:marker:generateHelp:category="CRD validation" // Default sets the default value for this field. // @@ -541,19 +527,6 @@ func (m Default) ApplyPriority() ApplyPriority { return 10 } -func (m Title) ApplyToSchema(schema *apiext.JSONSchemaProps) error { - if m.Value == nil { - // only apply to the schema if we have a non-nil title - return nil - } - title, isStr := m.Value.(string) - if !isStr { - return fmt.Errorf("expected string, got %T", m.Value) - } - schema.Title = title - return nil -} - func (m *KubernetesDefault) ParseMarker(_ string, _ string, restFields string) error { if strings.HasPrefix(strings.TrimSpace(restFields), "ref(") { // Skip +default=ref(...) values for now, since we don't have a good way to evaluate go constant values via AST. diff --git a/pkg/crd/markers/zz_generated.markerhelp.go b/pkg/crd/markers/zz_generated.markerhelp.go index 7d8282cfc..a9ee23311 100644 --- a/pkg/crd/markers/zz_generated.markerhelp.go +++ b/pkg/crd/markers/zz_generated.markerhelp.go @@ -469,22 +469,6 @@ func (SubresourceStatus) Help() *markers.DefinitionHelp { } } -func (Title) Help() *markers.DefinitionHelp { - return &markers.DefinitionHelp{ - Category: "CRD validation", - DetailedHelp: markers.DetailedHelp{ - Summary: "sets the title for this field.", - Details: "The title is metadata that makes the OpenAPI documentation more user-friendly,\nmaking the schema more understandable when viewed in documentation tools.\nIt's a metadata field that doesn't affect validation but provides\nimportant context about what the schema represents.", - }, - FieldHelp: map[string]markers.DetailedHelp{ - "Value": { - Summary: "", - Details: "", - }, - }, - } -} - func (Type) Help() *markers.DefinitionHelp { return &markers.DefinitionHelp{ Category: "CRD validation", diff --git a/pkg/crd/parser_integration_test.go b/pkg/crd/parser_integration_test.go index 59e62cff8..6065fc45b 100644 --- a/pkg/crd/parser_integration_test.go +++ b/pkg/crd/parser_integration_test.go @@ -187,19 +187,6 @@ var _ = Describe("CRD Generation From Parsing to CustomResourceDefinition", func }) }) - Context("Field with unvalid title format", func() { - BeforeEach(func() { - pkgPaths = []string{"./wrong_title_format"} - expPkgLen = 1 - }) - It("cannot generate title field from integer", func() { - assertError(pkgs[0], "JobSpec", "expected string, got int") - }) - It("cannot generate title field from map", func() { - assertError(pkgs[0], "TestType", "expected string, got map[string]interface {}") - }) - }) - Context("CronJob API without group", func() { BeforeEach(func() { pkgPaths = []string{"./nogroup"} diff --git a/pkg/crd/testdata/cronjob_types.go b/pkg/crd/testdata/cronjob_types.go index e496407b2..c7c96103e 100644 --- a/pkg/crd/testdata/cronjob_types.go +++ b/pkg/crd/testdata/cronjob_types.go @@ -113,24 +113,20 @@ type CronJobSpec struct { // This tests that primitive defaulting can be performed. // +kubebuilder:default=forty-two // +kubebuilder:example=forty-two - // +kubebuilder:title=DefaultedString DefaultedString string `json:"defaultedString"` // This tests that slice defaulting can be performed. // +kubebuilder:default={a,b} // +kubebuilder:example={a,b} - // +kubebuilder:title=DefaultedSlice DefaultedSlice []string `json:"defaultedSlice"` // This tests that slice and object defaulting can be performed. // +kubebuilder:default={{nested: {foo: "baz", bar: true}},{nested: {foo: "qux", bar: false}}} // +kubebuilder:example={{nested: {foo: "baz", bar: true}},{nested: {foo: "qux", bar: false}}} - // +kubebuilder:title="124" DefaultedObject []RootObject `json:"defaultedObject"` // This tests that empty slice defaulting can be performed. // +kubebuilder:default={} - // +kubebuilder:title="{}" DefaultedEmptySlice []string `json:"defaultedEmptySlice"` // This tests that an empty object defaulting can be performed on a map. diff --git a/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml b/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml index 8bbbaf1a1..ab81550fc 100644 --- a/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml +++ b/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml @@ -131,7 +131,6 @@ spec: description: This tests that empty slice defaulting can be performed. items: type: string - title: '{}' type: array defaultedObject: default: @@ -164,7 +163,6 @@ spec: required: - nested type: object - title: "124" type: array defaultedSlice: default: @@ -176,13 +174,11 @@ spec: - b items: type: string - title: DefaultedSlice type: array defaultedString: default: forty-two description: This tests that primitive defaulting can be performed. example: forty-two - title: DefaultedString type: string doubleDefaultedString: default: kubebuilder-default diff --git a/pkg/crd/testdata/wrong_title_format/types.go b/pkg/crd/testdata/wrong_title_format/types.go deleted file mode 100644 index 998866184..000000000 --- a/pkg/crd/testdata/wrong_title_format/types.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +groupName=testdata.kubebuilder.io -// +versionName=v1beta1 -package job - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "testdata.kubebuilder.io/cronjob/unserved" -) - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:singular=job - -type TestType struct { - // Count is the number of times a job may be executed. - // - // +kubebuilder:title={} - Count int32 `json:"count"` -} - -// JobSpec is the spec for the jobs API. -type JobSpec struct { - // FriendlyName is the friendly name for the job. - // - // +kubebuilder:title=123 - FriendlyName string `json:"friendlyName"` - - // CronJob is the spec for the related CrongJob. - CronnJob unserved.CronJobSpec `json:"crongJob"` -} - -// Job is the Schema for the jobs API -type Job struct { - /* - */ - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec JobSpec `json:"spec"` -} - -// +kubebuilder:object:root=true - -// JobList contains a list of Job -type JobList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Job `json:"items"` -} diff --git a/pkg/markers/parse.go b/pkg/markers/parse.go index f42dec0cf..d61e1d561 100644 --- a/pkg/markers/parse.go +++ b/pkg/markers/parse.go @@ -868,11 +868,9 @@ func (d *Definition) Parse(rawMarker string) (interface{}, error) { seen[""] = struct{}{} // mark as seen for strict definitions } else if !d.Empty() && scanner.Peek() != sc.EOF { // if we expect *and* actually have arguments passed - for { + for expect(scanner, sc.Ident, "argument name") { // parse the argument name - if !expect(scanner, sc.Ident, "argument name") { - break - } + argName := scanner.TokenText() if !expect(scanner, '=', "equals") { break diff --git a/pkg/rbac/parser.go b/pkg/rbac/parser.go index 6521d2658..ccb3c58de 100644 --- a/pkg/rbac/parser.go +++ b/pkg/rbac/parser.go @@ -161,9 +161,6 @@ type Generator struct { // RoleName sets the name of the generated ClusterRole. RoleName string - // FileName sets the file name for the generated manifest(s). If not set, defaults to "role.yaml". - FileName string `marker:",optional"` - // HeaderFile specifies the header text (e.g. license) to prepend to generated files. HeaderFile string `marker:",optional"` @@ -386,10 +383,5 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error { } headerText = strings.ReplaceAll(headerText, " YEAR", " "+g.Year) - fileName := "role.yaml" - if g.FileName != "" { - fileName = g.FileName - } - - return ctx.WriteYAML(fileName, headerText, objs, genall.WithTransform(genall.TransformRemoveCreationTimestamp)) + return ctx.WriteYAML("role.yaml", headerText, objs, genall.WithTransform(genall.TransformRemoveCreationTimestamp)) } diff --git a/pkg/rbac/zz_generated.markerhelp.go b/pkg/rbac/zz_generated.markerhelp.go index 085898ab5..20c707b1d 100644 --- a/pkg/rbac/zz_generated.markerhelp.go +++ b/pkg/rbac/zz_generated.markerhelp.go @@ -36,10 +36,6 @@ func (Generator) Help() *markers.DefinitionHelp { Summary: "sets the name of the generated ClusterRole.", Details: "", }, - "FileName": { - Summary: "sets the file name for the generated manifest(s). If not set, defaults to \"role.yaml\".", - Details: "", - }, "HeaderFile": { Summary: "specifies the header text (e.g. license) to prepend to generated files.", Details: "",