From 067f38b8d4114357f97433f280202c61c36f53ea Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Mon, 3 Aug 2026 13:53:50 +0200 Subject: [PATCH 1/4] refactor: modernize `make/generate.mk` with versioned tool binaries and modernize project docs - Update code generation instructions in API type comments from `"operator-sdk generate k8s"` to `"make generate"` - Delete `cmd/manager/main.go` dummy entrypoint that only existed for `operator-sdk generate csv` - Replace `README.adoc` with `README.md` and update build instructions - Adopt the Kubebuilder v4 pattern for local tool management: - Add `LOCALBIN` and `go-install-tool` helper for version-pinned binaries - Pin `controller-gen` to `v0.18.0`, `operator-sdk` to `v1.42.0` - Split `generate` (DeepCopy code) and `manifests` (CRD/webhook) targets - Regenerate `zz_generated.openapi.go` with updated tooling Assisted-by: Claude Opus 4.6 (1M context) Signed-off-by: Xavier Coulon --- make/generate.mk | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/make/generate.mk b/make/generate.mk index 598a0c3a..e9aba41a 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -29,6 +29,31 @@ $(CRD_REF_DOCS): go.mod | $(LOCALBIN) ## install crd-ref-docs locally if necessa manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + + +## Tool Binaries +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen +PATH_TO_CRD_BASES=config/crd/bases +CONTROLLER_TOOLS_VERSION ?= v0.18.0 + +$(CONTROLLER_GEN): ## install controller-gen locally if necessary. + GOBIN=$(LOCALBIN) $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen + +$(OPENAPI_GEN): ## install openapi-gen locally if necessary. + GOBIN=$(LOCALBIN) $(GO) install k8s.io/kube-openapi/cmd/openapi-gen + +$(CRD_REF_DOCS): ## install crd-ref-docs locally if necessary. + GOBIN=$(LOCALBIN) $(GO) install github.com/elastic/crd-ref-docs@latest + +.PHONY: manifests +manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. + $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases + .PHONY: generate generate: generate-object generate-crd gen-crd-ref-docs generate-openapi dispatch-crds ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. From 6267eab4a103486135b84c5355f40163fa981d76 Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Wed, 5 Aug 2026 10:21:55 +0200 Subject: [PATCH 2/4] build: upgrade to Go 1.26.5 also, remvoed outdated vulnerability exclusions also, remove the `check-format` target and move the formatting logic into `go.mk` Signed-off-by: Xavier Coulon --- .github/workflows/ci-build.yml | 2 +- .github/workflows/verify-dependencies.yml | 2 +- .govulncheck.yaml | 20 +--------------- go.mod | 17 +++++++------- go.sum | 28 +++++++++++++---------- make/format.mk | 17 -------------- make/go.mk | 8 +++++++ gofmt_exclude => make/gofmt_exclude | 0 8 files changed, 36 insertions(+), 58 deletions(-) delete mode 100644 make/format.mk rename gofmt_exclude => make/gofmt_exclude (100%) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 2bde9867..771ced39 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v7 - name: Install Go - uses: actions/setup-go@v6 + uses: actions/setup-go@v7 with: go-version-file: go.mod diff --git a/.github/workflows/verify-dependencies.yml b/.github/workflows/verify-dependencies.yml index 8aecb806..b0c831ad 100644 --- a/.github/workflows/verify-dependencies.yml +++ b/.github/workflows/verify-dependencies.yml @@ -20,7 +20,7 @@ jobs: - name: Install golangci-lint run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2 + curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.12.2 - name: Verify run: | diff --git a/.govulncheck.yaml b/.govulncheck.yaml index f1c3aaed..fb027e09 100644 --- a/.govulncheck.yaml +++ b/.govulncheck.yaml @@ -1,19 +1 @@ -ignored-vulnerabilities: - # Incorrect parsing of IPv6 host literals in net/url - # Found in: net/url@go1.24.13 - # Fixed in: net/url@go1.25.8 - - id: GO-2026-4601 - silence-until: 2026-09-03 - info: https://pkg.go.dev/vuln/GO-2026-4601 - # Inefficient candidate hostname parsing in crypto/x509 - # Found in: crypto/x509@go1.24.13 - # Fixed in: crypto/x509@go1.25.11 - - id: GO-2026-5037 - silence-until: 2026-09-03 - info: https://pkg.go.dev/vuln/GO-2026-5037 - # FileInfo can escape from a Root in os - # Found in: os@go1.24.13 - # Fixed in: os@go1.25.8 - - id: GO-2026-4602 - info: https://pkg.go.dev/vuln/GO-2026-4602 - silence-until: 2026-09-03 +ignored-vulnerabilities: [] diff --git a/go.mod b/go.mod index 85a94569..d36c7637 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/codeready-toolchain/api -go 1.24.4 +go 1.26.0 -toolchain go1.24.13 +toolchain go1.26.5 require ( // using latest commit from 'github.com/openshift/api branch release-4.20' @@ -37,12 +37,13 @@ require ( github.com/spf13/cobra v1.9.1 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/mod v0.24.0 // indirect - golang.org/x/net v0.39.0 // indirect - golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.32.0 // indirect - golang.org/x/text v0.24.0 // indirect - golang.org/x/tools v0.32.0 // indirect + golang.org/x/mod v0.35.0 // indirect + golang.org/x/net v0.55.0 // indirect + golang.org/x/sync v0.20.0 // indirect + golang.org/x/sys v0.45.0 // indirect + golang.org/x/text v0.37.0 // indirect + golang.org/x/tools v0.44.0 // indirect + golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect google.golang.org/protobuf v1.36.5 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 47573d27..cf6b5383 100644 --- a/go.sum +++ b/go.sum @@ -100,36 +100,40 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= +golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 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.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8= +golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= 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.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= +golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= 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.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= +golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= +golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= +golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= +golang.org/x/tools/go/expect v0.1.0-deprecated h1:jY2C5HGYR5lqex3gEniOQL0r7Dq5+VGVgY1nudX5lXY= +golang.org/x/tools/go/expect v0.1.0-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= +golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= +golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/make/format.mk b/make/format.mk deleted file mode 100644 index a54b38e6..00000000 --- a/make/format.mk +++ /dev/null @@ -1,17 +0,0 @@ -GOFORMAT_FILES := $(shell find . -name '*.go' | grep -vEf ./gofmt_exclude) - -.PHONY: check-go-format -## Exits with an error if there are files that do not match formatting defined by gofmt -check-go-format: - $(Q)gofmt -s -l ${GOFORMAT_FILES} 2>&1 \ - | tee ./out/gofmt-errors \ - | read \ - && echo "ERROR: These files differ from gofmt's style (run 'make format-go-code' to fix this):" \ - && cat ./out/gofmt-errors \ - && exit 1 \ - || true - -.PHONY: format-go-code -## Formats any go file that does not match formatting defined by gofmt -format-go-code: - $(Q)gofmt -s -l -w ${GOFORMAT_FILES} diff --git a/make/go.mk b/make/go.mk index 91222198..9b0dcf7f 100644 --- a/make/go.mk +++ b/make/go.mk @@ -8,6 +8,13 @@ GO_PACKAGE_ORG_NAME ?= $(shell basename $$(dirname $$PWD)) GO_PACKAGE_REPO_NAME ?= $(shell basename $$PWD) GO_PACKAGE_PATH ?= github.com/${GO_PACKAGE_ORG_NAME}/${GO_PACKAGE_REPO_NAME} +GOFORMAT_FILES := $(shell find . -name '*.go' | grep -vEf ./make/gofmt_exclude) + +.PHONY: format-go-code +## Formats any go file that does not match formatting defined by gofmt +format-go-code: + $(Q)gofmt -s -l -w ${GOFORMAT_FILES} + .PHONY: build ## Build build: @@ -17,3 +24,4 @@ build: .PHONY: verify-replace-run verify-replace-run: ./scripts/verify-replace.sh; + diff --git a/gofmt_exclude b/make/gofmt_exclude similarity index 100% rename from gofmt_exclude rename to make/gofmt_exclude From 20ed932fa61fdcfca0acf84a87a20ae27951dfee Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Thu, 6 Aug 2026 17:26:37 +0200 Subject: [PATCH 3/4] update format-go-code syntax Signed-off-by: Xavier Coulon --- make/generate.mk | 10 ---------- make/go.mk | 7 ++++--- make/gofmt_exclude | 1 - 3 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 make/gofmt_exclude diff --git a/make/generate.mk b/make/generate.mk index e9aba41a..4bbcf2b6 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -3,12 +3,6 @@ API_GROUPNAME=toolchain API_FULL_GROUPNAME=toolchain.dev.openshift.com API_VERSION:=v1alpha1 -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - - ## Tool Binaries CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen @@ -50,10 +44,6 @@ $(OPENAPI_GEN): ## install openapi-gen locally if necessary. $(CRD_REF_DOCS): ## install crd-ref-docs locally if necessary. GOBIN=$(LOCALBIN) $(GO) install github.com/elastic/crd-ref-docs@latest -.PHONY: manifests -manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases - .PHONY: generate generate: generate-object generate-crd gen-crd-ref-docs generate-openapi dispatch-crds ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. diff --git a/make/go.mk b/make/go.mk index 9b0dcf7f..97018536 100644 --- a/make/go.mk +++ b/make/go.mk @@ -8,12 +8,13 @@ GO_PACKAGE_ORG_NAME ?= $(shell basename $$(dirname $$PWD)) GO_PACKAGE_REPO_NAME ?= $(shell basename $$PWD) GO_PACKAGE_PATH ?= github.com/${GO_PACKAGE_ORG_NAME}/${GO_PACKAGE_REPO_NAME} -GOFORMAT_FILES := $(shell find . -name '*.go' | grep -vEf ./make/gofmt_exclude) - .PHONY: format-go-code ## Formats any go file that does not match formatting defined by gofmt format-go-code: - $(Q)gofmt -s -l -w ${GOFORMAT_FILES} +# The + tells find to batch multiple found files into a single gofmt invocation (like xargs), +# which is much faster than the alternative \;, which runs gofmt once per file. Removing it +# would be a syntax error — find -exec requires either + or \; as a terminator. + $(Q)find . -name '*.go' -not -path '*/vendor/*' -not -path '*/.git/*' -exec gofmt -s -l -w {} + .PHONY: build ## Build diff --git a/make/gofmt_exclude b/make/gofmt_exclude deleted file mode 100644 index fa4d8332..00000000 --- a/make/gofmt_exclude +++ /dev/null @@ -1 +0,0 @@ -vendor/.* \ No newline at end of file From 5c91a7342da94743ac001f36b7ee0d93a797ff9b Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Thu, 6 Aug 2026 17:32:12 +0200 Subject: [PATCH 4/4] add check-go-format makefile goal Signed-off-by: Xavier Coulon --- make/go.mk | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/make/go.mk b/make/go.mk index 97018536..e977bb69 100644 --- a/make/go.mk +++ b/make/go.mk @@ -16,6 +16,17 @@ format-go-code: # would be a syntax error — find -exec requires either + or \; as a terminator. $(Q)find . -name '*.go' -not -path '*/vendor/*' -not -path '*/.git/*' -exec gofmt -s -l -w {} + +.PHONY: check-go-format +## Verify the formatting defined by 'gofmt' +check-go-format: + $(Q)find . -name '*.go' -not -path '*/vendor/*' -not -path '*/.git/*' -exec gofmt -s -l {} + 2>&1 \ + | tee $(OUT_DIR)/gofmt-errors \ + | read \ + && echo "ERROR: These files differ from gofmt's style (run 'make format-go-code' to fix this):" \ + && cat $(OUT_DIR)/gofmt-errors \ + && exit 1 \ + || true + .PHONY: build ## Build build: