Skip to content

Commit 48b06a2

Browse files
committed
update to operator-sdk 1.41
Signed-off-by: Scott Trent <[email protected]>
1 parent ea27842 commit 48b06a2

File tree

16 files changed

+261
-170
lines changed

16 files changed

+261
-170
lines changed

.golangci.yml

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-
- exportloopref
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$

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.23-alpine as builder
2+
FROM golang:1.24-alpine as builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -14,7 +14,7 @@ RUN apk upgrade --no-cache && \
1414
# Copy the go source
1515
COPY cmd/ cmd/
1616
COPY api/ api/
17-
COPY internal/controller/ internal/controller/
17+
COPY internal/ internal/
1818

1919
# Build
2020
# the GOARCH has not a default value to allow the binary be built according to the host where the command

Makefile

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ endif
5252

5353
# Set the Operator SDK version to use. By default, what is installed on the system is used.
5454
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
55-
OPERATOR_SDK_VERSION ?= v1.38.0
55+
OPERATOR_SDK_VERSION ?= v1.40.0
5656
# Image URL to use all building/pushing image targets
5757
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
58-
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
59-
ENVTEST_K8S_VERSION = 1.31.0
6058

6159
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6260
ifeq (,$(shell go env GOBIN))
@@ -119,13 +117,37 @@ vet: ## Run go vet against code.
119117
go vet ./...
120118

121119
.PHONY: test
122-
test: manifests generate fmt vet envtest ## Run tests.
123-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
124-
125-
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
126-
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
127-
test-e2e:
128-
go test ./test/e2e/ -v -ginkgo.v
120+
test: manifests generate fmt vet setup-envtest ## Run tests.
121+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $(shell go list ./... | grep -v /test/) -coverprofile cover.out
122+
123+
# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
124+
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
125+
# CertManager is installed by default; skip with:
126+
# - CERT_MANAGER_INSTALL_SKIP=true
127+
KIND_CLUSTER ?= susql-operator-test-e2e
128+
129+
.PHONY: setup-test-e2e
130+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
131+
@command -v $(KIND) >/dev/null 2>&1 || { \
132+
echo "Kind is not installed. Please install Kind manually."; \
133+
exit 1; \
134+
}
135+
@case "$$($(KIND) get clusters)" in \
136+
*"$(KIND_CLUSTER)"*) \
137+
echo "Kind cluster '$(KIND_CLUSTER)' already exists. Skipping creation." ;; \
138+
*) \
139+
echo "Creating Kind cluster '$(KIND_CLUSTER)'..."; \
140+
$(KIND) create cluster --name $(KIND_CLUSTER) ;; \
141+
esac
142+
143+
.PHONY: test-e2e
144+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
145+
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
146+
$(MAKE) cleanup-test-e2e
147+
148+
.PHONY: cleanup-test-e2e
149+
cleanup-test-e2e: ## Tear down the Kind cluster used for e2e tests
150+
@$(KIND) delete cluster --name $(KIND_CLUSTER)
129151

130152
.PHONY: lint
131153
lint: golangci-lint ## Run golangci-lint linter
@@ -135,6 +157,10 @@ lint: golangci-lint ## Run golangci-lint linter
135157
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
136158
$(GOLANGCI_LINT) run --fix
137159

160+
.PHONY: lint-config
161+
lint-config: golangci-lint ## Verify golangci-lint linter configuration
162+
$(GOLANGCI_LINT) config verify
163+
138164
##@ Build
139165

140166
.PHONY: build
@@ -195,10 +221,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
195221
docker-buildx: ## Build and push docker image for the manager for cross-platform support
196222
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
197223
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
198-
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
199-
$(CONTAINER_TOOL) buildx use project-v3-builder
224+
- $(CONTAINER_TOOL) buildx create --name susql-operator-builder
225+
$(CONTAINER_TOOL) buildx use susql-operator-builder
200226
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
201-
- $(CONTAINER_TOOL) buildx rm project-v3-builder
227+
- $(CONTAINER_TOOL) buildx rm susql-operator-builder
202228
rm Dockerfile.cross
203229

204230
.PHONY: build-installer
@@ -239,16 +265,19 @@ $(LOCALBIN):
239265

240266
## Tool Binaries
241267
KUBECTL ?= kubectl
268+
KIND ?= kind
242269
KUSTOMIZE ?= $(LOCALBIN)/kustomize
243270
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
244271
ENVTEST ?= $(LOCALBIN)/setup-envtest
245272
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
246273

247274
## Tool Versions
248-
KUSTOMIZE_VERSION ?= v5.4.3
249-
CONTROLLER_TOOLS_VERSION ?= v0.16.1
250-
ENVTEST_VERSION ?= release-0.19
251-
GOLANGCI_LINT_VERSION ?= v1.59.1
275+
KUSTOMIZE_VERSION ?= v5.6.0
276+
CONTROLLER_TOOLS_VERSION ?= v0.18.0
277+
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
278+
#ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
279+
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
280+
GOLANGCI_LINT_VERSION ?= v2.1.0
252281

253282
.PHONY: kustomize
254283
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -260,6 +289,14 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
260289
$(CONTROLLER_GEN): $(LOCALBIN)
261290
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
262291

292+
.PHONY: setup-envtest
293+
setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory.
294+
@echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..."
295+
@$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path || { \
296+
echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \
297+
exit 1; \
298+
}
299+
263300
.PHONY: envtest
264301
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
265302
$(ENVTEST): $(LOCALBIN)
@@ -268,10 +305,10 @@ $(ENVTEST): $(LOCALBIN)
268305
.PHONY: golangci-lint
269306
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
270307
$(GOLANGCI_LINT): $(LOCALBIN)
271-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
308+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
272309

273310
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
274-
# $1 - target path with name of binary (ideally with version)
311+
# $1 - target path with name of binary
275312
# $2 - package url which can be installed
276313
# $3 - specific version of package
277314
define go-install-tool
@@ -322,7 +359,7 @@ bundle-push: ## Push the bundle image.
322359
$(call docker_push,$(BUNDLE_IMG))
323360

324361
.PHONY: opm
325-
const opmVersion = "v1.55.0"
362+
opmVersion = "v1.55.0"
326363
OPM = $(LOCALBIN)/opm
327364
opm: ## Download opm locally if necessary.
328365
ifeq (,$(wildcard $(OPM)))

bundle.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
66
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
77
LABEL operators.operatorframework.io.bundle.package.v1=susql-operator
88
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
9-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.38.0
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.41.0
1010
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
1111
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4
1212

bundle/manifests/susql-operator.clusterserviceversion.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ metadata:
2727
]
2828
capabilities: Basic Install
2929
categories: Monitoring
30-
containerImage: quay.io/sustainable_computing_io/susql_operator:0.0.33
31-
createdAt: "2025-01-28T07:27:19Z"
30+
containerImage: quay.io/trent_s/susql-controller:0.0.34
31+
createdAt: "2025-07-09T03:53:07Z"
3232
description: 'Aggregates energy and CO2 emission data for pods tagged with SusQL
3333
labels '
3434
features.operators.openshift.io/disconnected: "false"
@@ -38,11 +38,11 @@ metadata:
3838
features.operators.openshift.io/token-auth-aws: "false"
3939
features.operators.openshift.io/token-auth-azure: "false"
4040
features.operators.openshift.io/token-auth-gcp: "false"
41-
operators.operatorframework.io/builder: operator-sdk-v1.38.0
41+
operators.operatorframework.io/builder: operator-sdk-v1.40.0
4242
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
4343
repository: https://github.com/sustainable-computing-io/susql-operator
4444
support: https://github.com/sustainable-computing-io/susql-operator/issues
45-
name: susql-operator.v0.0.33
45+
name: susql-operator.v0.0.34
4646
namespace: placeholder
4747
spec:
4848
apiservicedefinitions: {}
@@ -170,7 +170,7 @@ spec:
170170
app.kubernetes.io/created-by: susql-operator
171171
app.kubernetes.io/instance: susql-controller-manager
172172
app.kubernetes.io/managed-by: kustomize
173-
app.kubernetes.io/name: controller-manager
173+
app.kubernetes.io/name: susql-operator
174174
app.kubernetes.io/part-of: susql-operator
175175
control-plane: susql-controller-manager
176176
name: susql-operator-susql-controller-manager
@@ -185,6 +185,7 @@ spec:
185185
annotations:
186186
kubectl.kubernetes.io/default-container: manager
187187
labels:
188+
app.kubernetes.io/name: susql-operator
188189
control-plane: susql-controller-manager
189190
spec:
190191
containers:
@@ -283,7 +284,7 @@ spec:
283284
key: CARBON-QUERY-CONV-2J
284285
name: susql-config
285286
optional: true
286-
image: quay.io/sustainable_computing_io/susql_operator:0.0.33
287+
image: quay.io/trent_s/susql-controller:0.0.34
287288
imagePullPolicy: Always
288289
livenessProbe:
289290
httpGet:
@@ -390,4 +391,4 @@ spec:
390391
name: SusQL Operator Contributors
391392
url: https://github.com/sustainable-computing-io/susql-operator
392393
replaces: susql-operator.v0.0.32
393-
version: 0.0.33
394+
version: 0.0.34

bundle/manifests/susql.ibm.com_labelgroups.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.15.0
5+
controller-gen.kubebuilder.io/version: v0.16.1
66
creationTimestamp: null
77
name: labelgroups.susql.ibm.com
88
spec:

bundle/metadata/annotations.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ annotations:
55
operators.operatorframework.io.bundle.metadata.v1: metadata/
66
operators.operatorframework.io.bundle.package.v1: susql-operator
77
operators.operatorframework.io.bundle.channels.v1: alpha
8-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.38.0
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.40.0
99
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
1010
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v4
1111

1212
# Annotations for testing.
1313
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
1414
operators.operatorframework.io.test.config.v1: tests/scorecard/
15-
16-
# Annotations for OpenShift version
17-
com.redhat.openshift.versions: v4.13-v4.17

config/crd/bases/susql.ibm.com_labelgroups.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.15.0
6+
controller-gen.kubebuilder.io/version: v0.16.1
77
name: labelgroups.susql.ibm.com
88
spec:
99
group: susql.ibm.com

config/manager/kustomization.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: quay.io/sustainable_computing_io/susql_operator
8-
newTag: 0.0.33
7+
newName: quay.io/trent_s/susql-controller

config/manager/manager.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ metadata:
1818
namespace: system
1919
labels:
2020
control-plane: susql-controller-manager
21-
app.kubernetes.io/name: controller-manager
21+
app.kubernetes.io/name: susql-operator
2222
app.kubernetes.io/instance: susql-controller-manager
2323
app.kubernetes.io/component: manager
2424
app.kubernetes.io/part-of: susql-operator
@@ -35,6 +35,7 @@ spec:
3535
kubectl.kubernetes.io/default-container: manager
3636
labels:
3737
control-plane: susql-controller-manager
38+
app.kubernetes.io/name: susql-operator
3839
spec:
3940
# TODO(user): Uncomment the following code to configure the nodeAffinity expression
4041
# according to the platforms which are supported by your solution.

0 commit comments

Comments
 (0)