Skip to content

Commit df5c1e8

Browse files
Upgrade from Kubebuilder 4.5.2 to 4.6.0 and add support for k8s 1.33
1 parent 0da7ea3 commit df5c1e8

File tree

42 files changed

+405
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+405
-385
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export IMAGE_VERSION = v1.39.2
99
export SIMPLE_VERSION = $(shell (test "$(shell git describe --tags)" = "$(shell git describe --tags --abbrev=0)" && echo $(shell git describe --tags)) || echo $(shell git describe --tags --abbrev=0)+git)
1010
export GIT_VERSION = $(shell git describe --dirty --tags --always)
1111
export GIT_COMMIT = $(shell git rev-parse HEAD)
12-
export K8S_VERSION = 1.32.0
12+
export K8S_VERSION = 1.33.0
1313

1414
# Build settings
1515
export TOOLS_DIR = tools/bin

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/operator-framework/operator-sdk
22

3-
go 1.23.6
3+
go 1.24.3
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
@@ -41,7 +41,7 @@ require (
4141
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
4242
sigs.k8s.io/controller-runtime v0.20.4
4343
sigs.k8s.io/controller-tools v0.17.2
44-
sigs.k8s.io/kubebuilder/v4 v4.5.2
44+
sigs.k8s.io/kubebuilder/v4 v4.6.0
4545
sigs.k8s.io/yaml v1.4.0
4646
)
4747

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ sigs.k8s.io/controller-tools v0.17.2 h1:jNFOKps8WnaRKZU2R+4vRCHnXyJanVmXBWqkuUPF
874874
sigs.k8s.io/controller-tools v0.17.2/go.mod h1:4q5tZG2JniS5M5bkiXY2/potOiXyhoZVw/U48vLkXk0=
875875
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
876876
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
877-
sigs.k8s.io/kubebuilder/v4 v4.5.2 h1:57lmVU1zwjOZAF28hBhZyaxE6qXreHYekI4yt/Q5rEU=
878-
sigs.k8s.io/kubebuilder/v4 v4.5.2/go.mod h1:oJrPYf8hkfLCh2vb40vD/Gm22CJsFHlGQz1mw2ZiQaY=
877+
sigs.k8s.io/kubebuilder/v4 v4.6.0 h1:SBc37jghs3L2UaEL91A1t5K5dANrEviUDuNic9hMQSw=
878+
sigs.k8s.io/kubebuilder/v4 v4.6.0/go.mod h1:zlXrnLiJPDPpK4hKCUrlgzzLOusfA8Sd8tpYGIrvD00=
879879
sigs.k8s.io/kustomize/api v0.18.0 h1:hTzp67k+3NEVInwz5BHyzc9rGxIauoXferXyjv5lWPo=
880880
sigs.k8s.io/kustomize/api v0.18.0/go.mod h1:f8isXnX+8b+SGLHQ6yO4JG1rdkZlvhaCf/uZbLVMb0U=
881881
sigs.k8s.io/kustomize/kyaml v0.18.1 h1:WvBo56Wzw3fjS+7vBjN6TeivvpbW9GmRaWZ9CIVmt4E=

images/custom-scorecard-tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the custom-scorecard-tests binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

images/helm-operator/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

images/operator-sdk/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the operator-sdk binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

images/scorecard-test-kuttl/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the scorecard-test-kuttl binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44
ARG BUILDPLATFORM
55

images/scorecard-test/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the scorecard-test binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

internal/plugins/manifests/v2/init.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"path/filepath"
2222
"strings"
2323

24-
"sigs.k8s.io/kubebuilder/v4/pkg/plugin/util"
25-
2624
"github.com/spf13/afero"
2725
"sigs.k8s.io/kubebuilder/v4/pkg/config"
2826
"sigs.k8s.io/kubebuilder/v4/pkg/machinery"
@@ -127,15 +125,6 @@ func (s *initSubcommand) Scaffold(fs machinery.Filesystem) error {
127125
return err
128126
}
129127

130-
// TODO: remove this when we bump kubebuilder to v5.x
131-
// Not adopt changes introduced by mistake in the default Makefile of kubebuilder v4.x.
132-
if operatorType == projutil.OperatorTypeGo {
133-
err = util.ReplaceInFile("Makefile", makefileTestE2ETarget, "")
134-
if err != nil {
135-
return fmt.Errorf("error replacing Makefile: %w", err)
136-
}
137-
}
138-
139128
return nil
140129
}
141130

@@ -322,17 +311,4 @@ catalog-build: opm ## Build a catalog image.
322311
catalog-push: ## Push a catalog image.
323312
$(MAKE) docker-push IMG=$(CATALOG_IMG)
324313
`
325-
326-
// TODO: remove it when we bump kubebuilder to v5.x
327-
// We will not adopt this change since it did not work and was a bug introduced in the
328-
// default Makefile of kubebuilder v4.x.
329-
makefileTestE2ETarget = `@command -v $(KIND) >/dev/null 2>&1 || { \
330-
echo "Kind is not installed. Please install Kind manually."; \
331-
exit 1; \
332-
}
333-
@$(KIND) get clusters | grep -q 'kind' || { \
334-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
335-
exit 1; \
336-
}
337-
`
338314
)

testdata/go/v4/memcached-operator/.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Kubebuilder DevContainer",
3-
"image": "docker.io/golang:1.23",
3+
"image": "golang:1.24",
44
"features": {
55
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
66
"ghcr.io/devcontainers/features/git:1": {}

testdata/go/v4/memcached-operator/.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
go-version-file: go.mod
1919

2020
- name: Run linter
21-
uses: golangci/golangci-lint-action@v6
21+
uses: golangci/golangci-lint-action@v8
2222
with:
23-
version: v1.63.4
23+
version: v2.1.0

testdata/go/v4/memcached-operator/.github/workflows/test-e2e.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy
Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
16-
linters:
17-
- dupl
18-
- lll
194
linters:
20-
disable-all: true
5+
default: none
216
enable:
7+
- copyloopvar
228
- dupl
239
- errcheck
24-
- copyloopvar
2510
- ginkgolinter
2611
- goconst
2712
- gocyclo
28-
- gofmt
29-
- goimports
30-
- gosimple
3113
- govet
3214
- ineffassign
3315
- lll
@@ -36,12 +18,35 @@ linters:
3618
- prealloc
3719
- revive
3820
- staticcheck
39-
- typecheck
4021
- unconvert
4122
- unparam
4223
- unused
43-
44-
linters-settings:
45-
revive:
24+
settings:
25+
revive:
26+
rules:
27+
- name: comment-spacings
28+
- name: import-shadowing
29+
exclusions:
30+
generated: lax
4631
rules:
47-
- name: comment-spacings
32+
- linters:
33+
- lll
34+
path: api/*
35+
- linters:
36+
- dupl
37+
- lll
38+
path: internal/*
39+
paths:
40+
- third_party$
41+
- builtin$
42+
- examples$
43+
formatters:
44+
enable:
45+
- gofmt
46+
- goimports
47+
exclusions:
48+
generated: lax
49+
paths:
50+
- third_party$
51+
- builtin$
52+
- examples$

testdata/go/v4/memcached-operator/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM docker.io/golang:1.23 AS builder
2+
FROM golang:1.24 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

testdata/go/v4/memcached-operator/Makefile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,24 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
116116
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
117117
# CertManager is installed by default; skip with:
118118
# - CERT_MANAGER_INSTALL_SKIP=true
119+
KIND_CLUSTER ?= memcached-operator-test-e2e
120+
121+
.PHONY: setup-test-e2e
122+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
123+
@command -v $(KIND) >/dev/null 2>&1 || { \
124+
echo "Kind is not installed. Please install Kind manually."; \
125+
exit 1; \
126+
}
127+
$(KIND) create cluster --name $(KIND_CLUSTER)
128+
119129
.PHONY: test-e2e
120-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
121-
go test ./test/e2e/ -v -ginkgo.v
130+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
131+
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
132+
$(MAKE) cleanup-test-e2e
133+
134+
.PHONY: cleanup-test-e2e
135+
cleanup-test-e2e: ## Tear down the Kind cluster used for e2e tests
136+
@$(KIND) delete cluster --name $(KIND_CLUSTER)
122137

123138
.PHONY: lint
124139
lint: golangci-lint ## Run golangci-lint linter
@@ -216,12 +231,12 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
216231

217232
## Tool Versions
218233
KUSTOMIZE_VERSION ?= v5.6.0
219-
CONTROLLER_TOOLS_VERSION ?= v0.17.2
234+
CONTROLLER_TOOLS_VERSION ?= v0.18.0
220235
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
221236
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
222237
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
223238
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
224-
GOLANGCI_LINT_VERSION ?= v1.63.4
239+
GOLANGCI_LINT_VERSION ?= v2.1.0
225240

226241
.PHONY: kustomize
227242
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -249,7 +264,7 @@ $(ENVTEST): $(LOCALBIN)
249264
.PHONY: golangci-lint
250265
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
251266
$(GOLANGCI_LINT): $(LOCALBIN)
252-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
267+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
253268

254269
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
255270
# $1 - target path with name of binary

testdata/go/v4/memcached-operator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## Getting Started
88

99
### Prerequisites
10-
- go version v1.23.0+
10+
- go version v1.24.0+
1111
- docker version 17.03+.
1212
- kubectl version v1.11.3+.
1313
- Access to a Kubernetes v1.11.3+ cluster.

testdata/go/v4/memcached-operator/bundle/manifests/cache.example.com_memcacheds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.17.2
5+
controller-gen.kubebuilder.io/version: v0.18.0
66
creationTimestamp: null
77
name: memcacheds.cache.example.com
88
spec:

testdata/go/v4/memcached-operator/cmd/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939

4040
cachev1alpha1 "github.com/example/memcached-operator/api/v1alpha1"
4141
"github.com/example/memcached-operator/internal/controller"
42-
webhookcachev1alpha1 "github.com/example/memcached-operator/internal/webhook/v1alpha1"
42+
webhookv1alpha1 "github.com/example/memcached-operator/internal/webhook/v1alpha1"
4343
// +kubebuilder:scaffold:imports
4444
)
4545

@@ -136,7 +136,7 @@ func main() {
136136

137137
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
138138
// More info:
139-
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.4/pkg/metrics/server
139+
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.21.0/pkg/metrics/server
140140
// - https://book.kubebuilder.io/reference/metrics.html
141141
metricsServerOptions := metricsserver.Options{
142142
BindAddress: metricsAddr,
@@ -148,7 +148,7 @@ func main() {
148148
// FilterProvider is used to protect the metrics endpoint with authn/authz.
149149
// These configurations ensure that only authorized users and service accounts
150150
// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
151-
// https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.4/pkg/metrics/filters#WithAuthenticationAndAuthorization
151+
// https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.21.0/pkg/metrics/filters#WithAuthenticationAndAuthorization
152152
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization
153153
}
154154

@@ -203,7 +203,7 @@ func main() {
203203
os.Exit(1)
204204
}
205205

206-
if err = (&controller.MemcachedReconciler{
206+
if err := (&controller.MemcachedReconciler{
207207
Client: mgr.GetClient(),
208208
Scheme: mgr.GetScheme(),
209209
// Add a Recorder to the reconciler.
@@ -215,7 +215,7 @@ func main() {
215215
}
216216
// nolint:goconst
217217
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
218-
if err = webhookcachev1alpha1.SetupMemcachedWebhookWithManager(mgr); err != nil {
218+
if err := webhookv1alpha1.SetupMemcachedWebhookWithManager(mgr); err != nil {
219219
setupLog.Error(err, "unable to create webhook", "webhook", "Memcached")
220220
os.Exit(1)
221221
}

testdata/go/v4/memcached-operator/config/crd/bases/cache.example.com_memcacheds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.17.2
6+
controller-gen.kubebuilder.io/version: v0.18.0
77
name: memcacheds.cache.example.com
88
spec:
99
group: cache.example.com

testdata/go/v4/memcached-operator/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the memcached-operator itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- memcached_admin_role.yaml
2626
- memcached_editor_role.yaml

0 commit comments

Comments
 (0)