Skip to content

Commit e32261b

Browse files
authored
Move operator-sdk target version to env var in Makefile, remove unused scripts (#722)
Signed-off-by: Jonathan West <[email protected]>
1 parent 841bc0e commit e32261b

File tree

3 files changed

+35
-44
lines changed

3 files changed

+35
-44
lines changed

Makefile

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)
4343
# Image URL to use all building/pushing image targets
4444
IMG ?= $(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)
4752
ifeq (,$(shell go env GOBIN))
4853
GOBIN=$(shell go env GOPATH)/bin
@@ -149,6 +154,31 @@ docker-build: test ## Build docker image with the manager.
149154
docker-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

154184
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
@@ -193,11 +223,11 @@ rm -rf $$TMP_DIR ;\
193223
endef
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
203233
bundle-build: ## Build the bundle image.
@@ -224,23 +254,7 @@ OPM = $(shell which opm)
224254
endif
225255
endif
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.

scripts/install-operator-sdk.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

scripts/openshiftci-presubmit-all-tests.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ go mod vendor
1414

1515
export PATH="$PATH:$(pwd)"
1616

17-
# INSTALL_OPERATOR_SDK="./scripts/install-operator-sdk.sh"
18-
# sh $INSTALL_OPERATOR_SDK
19-
2017
# Copy kubeconfig to temporary kubeconfig file and grant
2118
# read and Write permission to temporary kubeconfig file
2219
TMP_DIR=$(mktemp -d)
@@ -27,5 +24,3 @@ export KUBECONFIG=$TMP_DIR/kubeconfig
2724
# Run e2e test
2825
make test-e2e
2926

30-
31-

0 commit comments

Comments
 (0)