33# To re-generate a bundle for another specific version without changing the standard setup, you can:
44# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6- VERSION ?= 1.0.0
6+ VERSION ?= 1.0.1
77
88# CHANNELS define the bundle channels used in the bundle.
99# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
@@ -28,8 +28,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
2828# This variable is used to construct full image tags for bundle and catalog images.
2929#
3030# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
31- # aureumcloud /frp-operator-bundle:$VERSION and aureumcloud /frp-operator-catalog:$VERSION.
32- IMAGE_TAG_BASE ?= aureumcloud /frp-operator
31+ # aureum.cloud /frp-operator-bundle:$VERSION and aureum.cloud /frp-operator-catalog:$VERSION.
32+ IMAGE_TAG_BASE ?= aureum.cloud /frp-operator
3333
3434# BUNDLE_IMG defines the image:tag used for the bundle.
3535# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
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.38.0
51+ OPERATOR_SDK_VERSION ?= v1.42.2
5252# Image URL to use all building/pushing image targets
5353IMG ?= controller:latest
54- # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
55- ENVTEST_K8S_VERSION = 1.30.0
5654
5755# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5856ifeq (,$(shell go env GOBIN) )
@@ -111,13 +109,37 @@ vet: ## Run go vet against code.
111109 go vet ./...
112110
113111.PHONY : test
114- test : manifests generate fmt vet envtest # # Run tests.
112+ test : manifests generate fmt vet setup- envtest # # Run tests.
115113 KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go test $$(go list ./... | grep -v /e2e ) -coverprofile cover.out
116114
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
115+ # TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
116+ # The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
117+ # CertManager is installed by default; skip with:
118+ # - CERT_MANAGER_INSTALL_SKIP=true
119+ KIND_CLUSTER ?= frp-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+ @case " $$ ($( KIND) get clusters)" in \
128+ * " $( KIND_CLUSTER) " * ) \
129+ echo " Kind cluster '$( KIND_CLUSTER) ' already exists. Skipping creation." ;; \
130+ * ) \
131+ echo " Creating Kind cluster '$( KIND_CLUSTER) '..." ; \
132+ $(KIND ) create cluster --name $(KIND_CLUSTER ) ;; \
133+ esac
134+
135+ .PHONY : test-e2e
136+ test-e2e : setup-test-e2e manifests generate fmt vet # # Run the e2e tests. Expected an isolated environment using Kind.
137+ KIND_CLUSTER=$(KIND_CLUSTER ) go test ./test/e2e/ -v -ginkgo.v
138+ $(MAKE ) cleanup-test-e2e
139+
140+ .PHONY : cleanup-test-e2e
141+ cleanup-test-e2e : # # Tear down the Kind cluster used for e2e tests
142+ @$(KIND ) delete cluster --name $(KIND_CLUSTER )
121143
122144.PHONY : lint
123145lint : golangci-lint # # Run golangci-lint linter
@@ -127,6 +149,10 @@ lint: golangci-lint ## Run golangci-lint linter
127149lint-fix : golangci-lint # # Run golangci-lint linter and perform fixes
128150 $(GOLANGCI_LINT ) run --fix
129151
152+ .PHONY : lint-config
153+ lint-config : golangci-lint # # Verify golangci-lint linter configuration
154+ $(GOLANGCI_LINT ) config verify
155+
130156# #@ Build
131157
132158.PHONY : build
@@ -203,16 +229,20 @@ $(LOCALBIN):
203229
204230# # Tool Binaries
205231KUBECTL ?= kubectl
232+ KIND ?= kind
206233KUSTOMIZE ?= $(LOCALBIN ) /kustomize
207234CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
208235ENVTEST ?= $(LOCALBIN ) /setup-envtest
209236GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
210237
211238# # Tool Versions
212- KUSTOMIZE_VERSION ?= v5.4.2
213- CONTROLLER_TOOLS_VERSION ?= v0.15.0
214- ENVTEST_VERSION ?= release-0.18
215- GOLANGCI_LINT_VERSION ?= v1.59.1
239+ KUSTOMIZE_VERSION ?= v5.6.0
240+ CONTROLLER_TOOLS_VERSION ?= v0.18.0
241+ # ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
242+ ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-% d.% d", $$2, $$3}')
243+ # ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
244+ ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.% d", $$3}')
245+ GOLANGCI_LINT_VERSION ?= v2.1.0
216246
217247.PHONY : kustomize
218248kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -224,6 +254,14 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
224254$(CONTROLLER_GEN ) : $(LOCALBIN )
225255 $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION ) )
226256
257+ .PHONY : setup-envtest
258+ setup-envtest : envtest # # Download the binaries required for ENVTEST in the local bin directory.
259+ @echo " Setting up envtest binaries for Kubernetes version $( ENVTEST_K8S_VERSION) ..."
260+ @$(ENVTEST ) use $(ENVTEST_K8S_VERSION ) --bin-dir $(LOCALBIN ) -p path || { \
261+ echo " Error: Failed to set up envtest binaries for version $( ENVTEST_K8S_VERSION) ." ; \
262+ exit 1; \
263+ }
264+
227265.PHONY : envtest
228266envtest : $(ENVTEST ) # # Download setup-envtest locally if necessary.
229267$(ENVTEST ) : $(LOCALBIN )
@@ -232,7 +270,7 @@ $(ENVTEST): $(LOCALBIN)
232270.PHONY : golangci-lint
233271golangci-lint : $(GOLANGCI_LINT ) # # Download golangci-lint locally if necessary.
234272$(GOLANGCI_LINT ) : $(LOCALBIN )
235- $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
273+ $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/v2/ cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
236274
237275# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
238276# $1 - target path with name of binary
@@ -276,7 +314,7 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
276314
277315.PHONY : bundle-build
278316bundle-build : # # Build the bundle image.
279- docker build -f bundle.Dockerfile -t $(BUNDLE_IMG ) .
317+ $( CONTAINER_TOOL ) build -f bundle.Dockerfile -t $(BUNDLE_IMG ) .
280318
281319.PHONY : bundle-push
282320bundle-push : # # Push the bundle image.
@@ -291,7 +329,7 @@ ifeq (,$(shell which opm 2>/dev/null))
291329 set -e ;\
292330 mkdir -p $(dir $(OPM)) ;\
293331 OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
294- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23 .0/$${OS}-$${ARCH}-opm ;\
332+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.55 .0/$${OS}-$${ARCH}-opm ;\
295333 chmod +x $(OPM) ;\
296334 }
297335else
@@ -316,7 +354,7 @@ endif
316354# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
317355.PHONY : catalog-build
318356catalog-build : opm # # Build a catalog image.
319- $(OPM ) index add --container-tool docker --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMGS ) $(FROM_INDEX_OPT )
357+ $(OPM ) index add --container-tool $( CONTAINER_TOOL ) --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMGS ) $(FROM_INDEX_OPT )
320358
321359# Push the catalog image.
322360.PHONY : catalog-push
0 commit comments