@@ -43,6 +43,11 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)
4343# Image URL to use all building/pushing image targets
4444IMG ?= $(IMAGE ) :$(VERSION )
4545
46+ # Set the Operator SDK version to use.
47+ # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
48+ OPERATOR_SDK_VERSION ?= v1.22.2
49+
50+
4651# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
4752ifeq (,$(shell go env GOBIN) )
4853GOBIN =$(shell go env GOPATH) /bin
@@ -149,6 +154,31 @@ docker-build: test ## Build docker image with the manager.
149154docker-push : # # Push docker image with the manager.
150155 docker push ${IMG}
151156
157+ # #@ Build Dependencies
158+
159+ # # Location to install dependencies to
160+ LOCALBIN ?= $(shell pwd) /bin
161+ $(LOCALBIN ) :
162+ mkdir -p $(LOCALBIN )
163+
164+ .PHONY : operator-sdk
165+ OPERATOR_SDK ?= $(LOCALBIN ) /operator-sdk
166+ operator-sdk : # # Download operator-sdk locally if necessary.
167+ ifeq (,$(wildcard $(OPERATOR_SDK ) ) )
168+ ifeq (,$(shell which operator-sdk 2>/dev/null) )
169+ @{ \
170+ set -e ;\
171+ mkdir -p $(dir $(OPERATOR_SDK)) ;\
172+ OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
173+ curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
174+ chmod +x $(OPERATOR_SDK) ;\
175+ }
176+ else
177+ OPERATOR_SDK = $(shell which operator-sdk)
178+ endif
179+ endif
180+
181+
152182# #@ Deployment
153183
154184install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
@@ -193,11 +223,11 @@ rm -rf $$TMP_DIR ;\
193223endef
194224
195225.PHONY : bundle
196- bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
197- operator-sdk generate kustomize manifests -q
226+ bundle : operator-sdk manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
227+ $( OPERATOR_SDK ) generate kustomize manifests -q
198228 cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
199- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
200- operator-sdk bundle validate ./bundle
229+ $(KUSTOMIZE ) build config/manifests | $( OPERATOR_SDK ) generate bundle -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
230+ $( OPERATOR_SDK ) bundle validate ./bundle
201231
202232.PHONY : bundle-build
203233bundle-build : # # Build the bundle image.
@@ -224,23 +254,7 @@ OPM = $(shell which opm)
224254endif
225255endif
226256
227- .PHONY : operator-sdk
228- OPERATOR_SDK = ./bin/operator-sdk
229- operator-sdk : # # Download operator-sdk locally if necessary.
230- ifeq (,$(wildcard $(OPERATOR_SDK ) ) )
231- ifeq (,$(shell which operator-sdk 2>/dev/null) )
232- @{ \
233- set -e ;\
234- mkdir -p $(dir $(OPERATOR_SDK)) ;\
235- OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
236- curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.22.2/operator-sdk_$${OS}_$${ARCH} ;\
237- chmod +x $(OPERATOR_SDK) ;\
238- $(OPERATOR_SDK) version ; \
239- }
240- else
241- OPERATOR_SDK = $(shell which operator-sdk)
242- endif
243- endif
257+
244258
245259# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
246260# These images MUST exist in a registry and be pull-able.
0 commit comments