Skip to content

Commit f2eb28f

Browse files
committed
feat: update operator sdk version
From 1.33 to 1.39.1 Fixes: #93
1 parent 2e1beb4 commit f2eb28f

File tree

62 files changed

+1103
-659
lines changed

Some content is hidden

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

62 files changed

+1103
-659
lines changed

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Binaries for programs and plugins
32
*.exe
43
*.exe~
@@ -9,14 +8,16 @@ bin/*
98
Dockerfile.cross
109
testbin/*
1110

12-
# Test binary, build with `go test -c`
11+
# Test binary, built with `go test -c`
1312
*.test
1413

1514
# Output of the go coverage tool, specifically when used with LiteIDE
1615
*.out
1716

18-
# Kubernetes Generated files - skip generated files, except for vendored files
17+
# Go workspace file
18+
go.work
1919

20+
# Kubernetes Generated files - skip generated files, except for vendored files
2021
!vendor/**/zz_generated.*
2122

2223
# editor and IDE paraphernalia

.golangci.yml

+38-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
11
run:
22
timeout: 5m
3+
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
319
linters:
20+
disable-all: true
421
enable:
5-
- nakedret
6-
- misspell
7-
- ineffassign
22+
- dupl
23+
- errcheck
24+
- exportloopref
825
- ginkgolinter
926
- goconst
10-
- errcheck
11-
- unparam
12-
- staticcheck
13-
- unused
27+
- gocyclo
28+
- gofmt
29+
- goimports
1430
- gosimple
15-
- gosec
16-
- dupl
31+
- govet
32+
- ineffassign
33+
- lll
34+
- misspell
35+
- nakedret
36+
- prealloc
37+
- revive
38+
- staticcheck
39+
- typecheck
1740
- unconvert
18-
- gocyclo
19-
# - goimports
20-
# - revive
41+
- unparam
42+
- unused
43+
2144
linters-settings:
45+
revive:
46+
rules:
47+
- name: comment-spacings
2248
dupl:
2349
# tokens count to trigger issue, 150 by default
2450
threshold: 300

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.21 as builder
2+
FROM golang:1.22 as builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

Makefile-dist.mk

+70-33
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ endif
4848

4949
# Set the Operator SDK version to use. By default, what is installed on the system is used.
5050
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51-
OPERATOR_SDK_VERSION ?= v1.33.0
52-
51+
OPERATOR_SDK_VERSION ?= v1.39.1
5352
# Image URL to use all building/pushing image targets
5453
IMG ?= controller:latest
5554
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
56-
ENVTEST_K8S_VERSION = 1.27.1
55+
ENVTEST_K8S_VERSION = 1.31.0
5756

5857
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5958
ifeq (,$(shell go env GOBIN))
@@ -80,7 +79,7 @@ all: build
8079

8180
# The help target prints out all targets with their descriptions organized
8281
# beneath their categories. The categories are represented by '##@' and the
83-
# target descriptions by '##'. The awk commands is responsible for reading the
82+
# target descriptions by '##'. The awk command is responsible for reading the
8483
# entire set of makefiles included in this invocation, looking for lines of the
8584
# file as xyz: ## something, and then pretty-format the target and help. Then,
8685
# if there's a line with ##@ something, that gets pretty-printed as a category.
@@ -113,7 +112,20 @@ vet: ## Run go vet against code.
113112

114113
.PHONY: test
115114
test: manifests generate fmt vet envtest ## Run tests.
116-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
115+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
116+
117+
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
118+
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
119+
test-e2e:
120+
go test ./test/e2e/ -v -ginkgo.v
121+
122+
.PHONY: lint
123+
lint: golangci-lint ## Run golangci-lint linter
124+
$(GOLANGCI_LINT) run
125+
126+
.PHONY: lint-fix
127+
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
128+
$(GOLANGCI_LINT) run --fix
117129

118130
##@ Build
119131

@@ -125,34 +137,40 @@ build: manifests generate fmt vet ## Build manager binary.
125137
run: manifests generate fmt vet ## Run a controller from your host.
126138
go run ./cmd/main.go
127139

128-
# If you wish built the manager image targeting other platforms you can use the --platform flag.
129-
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
140+
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
141+
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
130142
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
131143
.PHONY: docker-build
132-
docker-build: test ## Build docker image with the manager.
144+
docker-build: ## Build docker image with the manager.
133145
$(CONTAINER_TOOL) build -t ${IMG} .
134146

135147
.PHONY: docker-push
136148
docker-push: ## Push docker image with the manager.
137149
$(CONTAINER_TOOL) push ${IMG}
138150

139-
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
151+
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
140152
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
141-
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
142-
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
143-
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
144-
# To properly provided solutions that supports more than one platform you should use this option.
153+
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
154+
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
155+
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
156+
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
145157
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
146158
.PHONY: docker-buildx
147-
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
159+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
148160
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
149161
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
150-
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
151-
$(CONTAINER_TOOL) buildx use project-v3-builder
162+
- $(CONTAINER_TOOL) buildx create --name lms-moodle-operator-builder
163+
$(CONTAINER_TOOL) buildx use lms-moodle-operator-builder
152164
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
153-
- $(CONTAINER_TOOL) buildx rm project-v3-builder
165+
- $(CONTAINER_TOOL) buildx rm lms-moodle-operator-builder
154166
rm Dockerfile.cross
155167

168+
.PHONY: build-installer
169+
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
170+
mkdir -p dist
171+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
172+
$(KUSTOMIZE) build config/default > dist/install.yaml
173+
156174
##@ Deployment
157175

158176
ifndef ignore-not-found
@@ -173,10 +191,10 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
173191
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
174192

175193
.PHONY: undeploy
176-
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
194+
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
177195
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
178196

179-
##@ Build Dependencies
197+
##@ Dependencies
180198

181199
## Location to install dependencies to
182200
LOCALBIN ?= $(shell pwd)/bin
@@ -188,30 +206,49 @@ KUBECTL ?= kubectl
188206
KUSTOMIZE ?= $(LOCALBIN)/kustomize
189207
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
190208
ENVTEST ?= $(LOCALBIN)/setup-envtest
209+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
191210

192211
## Tool Versions
193-
KUSTOMIZE_VERSION ?= v5.0.1
194-
CONTROLLER_TOOLS_VERSION := v0.14.0
212+
KUSTOMIZE_VERSION ?= v5.4.3
213+
CONTROLLER_TOOLS_VERSION ?= v0.16.1
214+
ENVTEST_VERSION ?= release-0.19
215+
GOLANGCI_LINT_VERSION ?= v1.59.1
195216

196217
.PHONY: kustomize
197-
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
218+
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
198219
$(KUSTOMIZE): $(LOCALBIN)
199-
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
200-
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
201-
rm -rf $(LOCALBIN)/kustomize; \
202-
fi
203-
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION)
220+
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))
204221

205222
.PHONY: controller-gen
206-
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
223+
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
207224
$(CONTROLLER_GEN): $(LOCALBIN)
208-
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
209-
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
225+
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
210226

211227
.PHONY: envtest
212-
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
228+
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
213229
$(ENVTEST): $(LOCALBIN)
214-
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
230+
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))
231+
232+
.PHONY: golangci-lint
233+
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
234+
$(GOLANGCI_LINT): $(LOCALBIN)
235+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
236+
237+
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
238+
# $1 - target path with name of binary
239+
# $2 - package url which can be installed
240+
# $3 - specific version of package
241+
define go-install-tool
242+
@[ -f "$(1)-$(3)" ] || { \
243+
set -e; \
244+
package=$(2)@$(3) ;\
245+
echo "Downloading $${package}" ;\
246+
rm -f $(1) || true ;\
247+
GOBIN=$(LOCALBIN) go install $${package} ;\
248+
mv $(1) $(1)-$(3) ;\
249+
} ;\
250+
ln -sf $(1)-$(3) $(1)
251+
endef
215252

216253
.PHONY: operator-sdk
217254
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
@@ -246,7 +283,7 @@ bundle-push: ## Push the bundle image.
246283
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
247284

248285
.PHONY: opm
249-
OPM = ./bin/opm
286+
OPM = $(LOCALBIN)/opm
250287
opm: ## Download opm locally if necessary.
251288
ifeq (,$(wildcard $(OPM)))
252289
ifeq (,$(shell which opm 2>/dev/null))

api/lms/v1alpha1/lmsmoodle_types.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ const (
110110
SuspendedState string = "Suspended"
111111
)
112112

113-
//+kubebuilder:object:root=true
114-
//+kubebuilder:subresource:status
115-
//+kubebuilder:resource:scope=Cluster,categories={lms},shortName=lm
116-
//+kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="Age of the resource",priority=0
117-
//+kubebuilder:printcolumn:name="STATUS",type="string",description="LMSMoodle status such as Unknown/SettingUp/Ready/Failed/Terminating etc",JSONPath=".status.state",priority=0
118-
//+kubebuilder:printcolumn:name="SINCE",type="date",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",description="Time of latest transition",priority=0
119-
//+kubebuilder:printcolumn:name="TEMPLATE",type="string",description="LMSMoodleTemplate name",JSONPath=".spec.lmsMoodleTemplate",priority=0
120-
//+kubebuilder:printcolumn:name="URL",type="string",JSONPath=".status.url",description="LMSMoodle URL",priority=0
121-
//+kubebuilder:printcolumn:name="USERS",type="integer",JSONPath=".status.registeredUsers",description="LMSMoodle registered users",priority=0
122-
//+kubebuilder:printcolumn:name="GB",type="string",JSONPath=".status.storageGb",description="LMSMoodle storage usage in GB",priority=0
113+
// +kubebuilder:object:root=true
114+
// +kubebuilder:subresource:status
115+
// +kubebuilder:resource:scope=Cluster,categories={lms},shortName=lm
116+
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="Age of the resource",priority=0
117+
// +kubebuilder:printcolumn:name="STATUS",type="string",description="LMSMoodle status such as Unknown/SettingUp/Ready/Failed/Terminating etc",JSONPath=".status.state",priority=0
118+
// +kubebuilder:printcolumn:name="SINCE",type="date",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",description="Time of latest transition",priority=0
119+
// +kubebuilder:printcolumn:name="TEMPLATE",type="string",description="LMSMoodleTemplate name",JSONPath=".spec.lmsMoodleTemplate",priority=0
120+
// +kubebuilder:printcolumn:name="URL",type="string",JSONPath=".status.url",description="LMSMoodle URL",priority=0
121+
// +kubebuilder:printcolumn:name="USERS",type="integer",JSONPath=".status.registeredUsers",description="LMSMoodle registered users",priority=0
122+
// +kubebuilder:printcolumn:name="GB",type="string",JSONPath=".status.storageGb",description="LMSMoodle storage usage in GB",priority=0
123123

124124
// LMSMoodle is the Schema for the lmsmoodles API
125125
type LMSMoodle struct {
@@ -130,7 +130,7 @@ type LMSMoodle struct {
130130
Status LMSMoodleStatus `json:"status,omitempty"`
131131
}
132132

133-
//+kubebuilder:object:root=true
133+
// +kubebuilder:object:root=true
134134

135135
// LMSMoodleList contains a list of LMSMoodle
136136
type LMSMoodleList struct {

api/lms/v1alpha1/lmsmoodletemplate_types.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ type LMSMoodleTemplateStatus struct {
5555
State string `json:"state,omitempty"`
5656
}
5757

58-
//+kubebuilder:object:root=true
59-
//+kubebuilder:subresource:status
60-
//+kubebuilder:resource:scope=Cluster,categories={lms},shortName=lmt
61-
//+kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="Age of the resource",priority=0
62-
//+kubebuilder:printcolumn:name="STATUS",type="string",description="LMSMoodleTemplate status such as Unknown/Used/NotUsed/Terminating etc",JSONPath=".status.state",priority=0
58+
// +kubebuilder:object:root=true
59+
// +kubebuilder:subresource:status
60+
// +kubebuilder:resource:scope=Cluster,categories={lms},shortName=lmt
61+
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="Age of the resource",priority=0
62+
// +kubebuilder:printcolumn:name="STATUS",type="string",description="LMSMoodleTemplate status such as Unknown/Used/NotUsed/Terminating etc",JSONPath=".status.state",priority=0
6363

6464
// LMSMoodleTemplate is the Schema for the lmsmoodletemplates API
6565
type LMSMoodleTemplate struct {
@@ -70,7 +70,7 @@ type LMSMoodleTemplate struct {
7070
Status LMSMoodleTemplateStatus `json:"status,omitempty"`
7171
}
7272

73-
//+kubebuilder:object:root=true
73+
// +kubebuilder:object:root=true
7474

7575
// LMSMoodleTemplateList contains a list of Moodle Template
7676
type LMSMoodleTemplateList struct {

bundle.Dockerfile

+1-1
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=lms-moodle-operator
88
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
9-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.33.0
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.39.1
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/lms-moodle-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ metadata:
8484
containerImage: quay.io/krestomatio/lms-moodle-operator:0.4.8
8585
createdAt: "2024-08-08T00:17:33Z"
8686
description: Meta operator for the full stack of Moodle™ LMS on Kubernetes
87-
operators.operatorframework.io/builder: operator-sdk-v1.33.0
87+
operators.operatorframework.io/builder: operator-sdk-v1.39.1
8888
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
8989
repository: https://github.com/krestomatio/lms-moodle-operator
9090
labels:

bundle/metadata/annotations.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ annotations:
55
operators.operatorframework.io.bundle.metadata.v1: metadata/
66
operators.operatorframework.io.bundle.package.v1: lms-moodle-operator
77
operators.operatorframework.io.bundle.channels.v1: alpha
8-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.33.0
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.39.1
99
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
1010
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v4
1111

0 commit comments

Comments
 (0)