@@ -43,6 +43,11 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)
43
43
# Image URL to use all building/pushing image targets
44
44
IMG ?= $(IMAGE ) :$(VERSION )
45
45
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
+
46
51
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
47
52
ifeq (,$(shell go env GOBIN) )
48
53
GOBIN =$(shell go env GOPATH) /bin
@@ -149,6 +154,31 @@ docker-build: test ## Build docker image with the manager.
149
154
docker-push : # # Push docker image with the manager.
150
155
docker push ${IMG}
151
156
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
+
152
182
# #@ Deployment
153
183
154
184
install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
@@ -193,11 +223,11 @@ rm -rf $$TMP_DIR ;\
193
223
endef
194
224
195
225
.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
198
228
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
201
231
202
232
.PHONY : bundle-build
203
233
bundle-build : # # Build the bundle image.
@@ -224,23 +254,7 @@ OPM = $(shell which opm)
224
254
endif
225
255
endif
226
256
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
+
244
258
245
259
# 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).
246
260
# These images MUST exist in a registry and be pull-able.
0 commit comments