@@ -36,7 +36,7 @@ IMAGE_TAG_BASE ?= ghcr.io/isometry/$(OPERATOR_NAME)
3636
3737# BUNDLE_IMG defines the image:tag used for the bundle.
3838# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
39- BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) / bundle:v$(VERSION )
39+ BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) - bundle:v$(VERSION )
4040
4141# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
4242BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
5151
5252# Set the Operator SDK version to use. By default, what is installed on the system is used.
5353# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
54- OPERATOR_SDK_VERSION ?= v1.37 .0
54+ OPERATOR_SDK_VERSION ?= v1.38 .0
5555
5656# Image URL to use all building/pushing image targets
5757IMG ?= $(IMAGE_TAG_BASE ) :latest
@@ -132,17 +132,9 @@ test: manifests generate fmt vet envtest ## Run tests.
132132.PHONY : test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
133133test-e2e :
134134 go test ./test/e2e/ -v -ginkgo.v
135-
136- GOLANGCI_LINT = $(shell pwd) /bin/golangci-lint
137- GOLANGCI_LINT_VERSION ?= v1.61.0
138- golangci-lint :
139- @[ -f $( GOLANGCI_LINT) ] || { \
140- set -e ; \
141- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT ) ) $(GOLANGCI_LINT_VERSION ) ; \
142- }
143135
144136.PHONY : lint
145- lint : golangci-lint # # Run golangci-lint linter & yamllint
137+ lint : golangci-lint # # Run golangci-lint linter
146138 $(GOLANGCI_LINT ) run
147139
148140.PHONY : lint-fix
@@ -181,12 +173,18 @@ PLATFORMS ?= linux/arm64,linux/amd64
181173docker-buildx : # # Build and push docker image for the manager for cross-platform support
182174 # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
183175 sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
184- - $(CONTAINER_TOOL ) buildx create --name project-v3 -builder
185- $(CONTAINER_TOOL ) buildx use project-v3 -builder
176+ - $(CONTAINER_TOOL ) buildx create --name github-token-manager -builder
177+ $(CONTAINER_TOOL ) buildx use github-token-manager -builder
186178 - $(CONTAINER_TOOL ) buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
187- - $(CONTAINER_TOOL ) buildx rm project-v3 -builder
179+ - $(CONTAINER_TOOL ) buildx rm github-token-manager -builder
188180 rm Dockerfile.cross
189181
182+ .PHONY : build-installer
183+ build-installer : manifests generate kustomize # # Generate a consolidated YAML with CRDs and deployment.
184+ mkdir -p dist
185+ cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
186+ $(KUSTOMIZE ) build config/default > dist/install.yaml
187+
190188.PHONY : ko-build
191189ko-build : # # Build the manager image using ko.
192190 KO_DOCKER_REPO=$(IMAGE_TAG_BASE ) \
@@ -213,10 +211,10 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
213211 $(KUSTOMIZE ) build config/default | $(KUBECTL ) apply -f -
214212
215213.PHONY : undeploy
216- 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.
214+ 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.
217215 $(KUSTOMIZE ) build config/default | $(KUBECTL ) delete --ignore-not-found=$(ignore-not-found ) -f -
218216
219- # #@ Build Dependencies
217+ # #@ Dependencies
220218
221219# # Location to install dependencies to
222220LOCALBIN ?= $(shell pwd) /bin
@@ -228,30 +226,49 @@ KUBECTL ?= kubectl
228226KUSTOMIZE ?= $(LOCALBIN ) /kustomize
229227CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
230228ENVTEST ?= $(LOCALBIN ) /setup-envtest
229+ GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
231230
232231# # Tool Versions
233232KUSTOMIZE_VERSION ?= v5.5.0
234233CONTROLLER_TOOLS_VERSION ?= v0.16.4
234+ ENVTEST_VERSION ?= release-0.18
235+ GOLANGCI_LINT_VERSION ?= v1.59.1
235236
236237.PHONY : kustomize
237- kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
238+ kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
238239$(KUSTOMIZE ) : $(LOCALBIN )
239- @if test -x $(LOCALBIN ) /kustomize && ! $(LOCALBIN ) /kustomize version | grep -q $(KUSTOMIZE_VERSION ) ; then \
240- echo " $( LOCALBIN) /kustomize version is not expected $( KUSTOMIZE_VERSION) . Removing it before installing." ; \
241- rm -rf $(LOCALBIN ) /kustomize; \
242- fi
243- test -s $(LOCALBIN ) /kustomize || GOBIN=$(LOCALBIN ) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION )
240+ $(call go-install-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION ) )
244241
245242.PHONY : controller-gen
246- controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
243+ controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
247244$(CONTROLLER_GEN ) : $(LOCALBIN )
248- test -s $(LOCALBIN ) /controller-gen && $(LOCALBIN ) /controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION ) || \
249- GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION )
245+ $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION ) )
250246
251247.PHONY : envtest
252- envtest : $(ENVTEST ) # # Download envtest- setup locally if necessary.
248+ envtest : $(ENVTEST ) # # Download setup-envtest locally if necessary.
253249$(ENVTEST ) : $(LOCALBIN )
254- test -s $(LOCALBIN ) /setup-envtest || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
250+ $(call go-install-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION ) )
251+
252+ .PHONY : golangci-lint
253+ golangci-lint : $(GOLANGCI_LINT ) # # Download golangci-lint locally if necessary.
254+ $(GOLANGCI_LINT ) : $(LOCALBIN )
255+ $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
256+
257+ # go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
258+ # $1 - target path with name of binary
259+ # $2 - package url which can be installed
260+ # $3 - specific version of package
261+ define go-install-tool
262+ @[ -f "$(1 ) -$(3 ) " ] || { \
263+ set -e; \
264+ package=$(2 ) @$(3 ) ;\
265+ echo "Downloading $${package}" ;\
266+ rm -f $(1 ) || true ;\
267+ GOBIN=$(LOCALBIN ) go install $${package} ;\
268+ mv $(1 ) $(1 ) -$(3 ) ;\
269+ } ;\
270+ ln -sf $(1 ) -$(3 ) $(1 )
271+ endef
255272
256273.PHONY : operator-sdk
257274OPERATOR_SDK ?= $(LOCALBIN ) /operator-sdk
@@ -307,7 +324,7 @@ endif
307324BUNDLE_IMGS ?= $(BUNDLE_IMG )
308325
309326# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
310- CATALOG_IMG ?= $(IMAGE_TAG_BASE ) / catalog:v$(VERSION )
327+ CATALOG_IMG ?= $(IMAGE_TAG_BASE ) - catalog:v$(VERSION )
311328
312329# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
313330ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
0 commit comments