Skip to content

Commit 414852f

Browse files
committed
fix(Makefile): Remove duplicate operator-sdk goal, simplify code
The goal was duplicate with similar (but not same) logic - eliminated. The implementation was silently picking operator-sdk when on PATH - must be provided through OPERATOR_SDK now. Element of least astonishment. Conditional Makefile logic removed leveraging native make features. Signed-off-by: Oliver Gondža <[email protected]>
1 parent 2f4984c commit 414852f

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

Makefile

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ IMG ?= $(IMAGE):$(VERSION)
5757
# Set the Operator SDK version to use.
5858
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
5959
OPERATOR_SDK_VERSION ?= v1.35.0
60-
60+
# Set the path to Operator SDK - OPERATOR_SDK_VERSION will be ignored.
61+
OPERATOR_SDK ?= bin/operator-sdk
6162

6263
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6364
ifeq (,$(shell go env GOBIN))
@@ -123,19 +124,6 @@ test-e2e: manifests generate fmt vet ## Run e2e tests.
123124
test-metrics:
124125
go test -timeout 30m ./test/e2e -ginkgo.focus="Argo CD metrics controller" -coverprofile cover.out -ginkgo.v
125126

126-
.PHONY: operator-sdk
127-
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
128-
operator-sdk: ## Download operator-sdk locally if necessary.
129-
ifeq (,$(wildcard $(OPERATOR_SDK)))
130-
@{ \
131-
set -e ;\
132-
mkdir -p $(dir $(OPERATOR_SDK)) ;\
133-
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
134-
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
135-
chmod +x $(OPERATOR_SDK) ;\
136-
}
137-
endif
138-
139127
.PHONY: test-route
140128
test-route:
141129
go test -timeout 30m ./test/e2e -ginkgo.focus="Argo CD ConsoleLink controller" -coverprofile cover.out -ginkgo.v
@@ -166,16 +154,16 @@ e2e-tests-sequential-ginkgo: ginkgo ## Runs kuttl e2e sequential tests
166154
.PHONY: e2e-tests-parallel-ginkgo ## Runs kuttl e2e parallel tests, (Defaults to 5 runs at a time)
167155
e2e-tests-parallel-ginkgo: ginkgo
168156
@echo "Running GitOps Operator parallel Ginkgo E2E tests..."
169-
$(GINKGO_CLI) -p -v -procs=5 --trace --timeout 30m -r ./test/openshift/e2e/ginkgo/parallel
157+
$(GINKGO_CLI) -p -v -procs=5 --trace --timeout 30m -r ./test/openshift/e2e/ginkgo/parallel
170158

171159
.PHONY: e2e-tests-sequential
172-
e2e-tests-sequential:
160+
e2e-tests-sequential:
173161
CI=prow make e2e-tests-sequential-ginkgo ## Runs kuttl e2e sequentail tests
174162
# @echo "Running GitOps Operator sequential E2E tests..."
175163
# . ./scripts/run-kuttl-tests.sh sequential
176164

177165
.PHONY: e2e-tests-parallel ## Runs kuttl e2e parallel tests, (Defaults to 5 runs at a time)
178-
e2e-tests-parallel:
166+
e2e-tests-parallel:
179167
CI=prow make e2e-tests-parallel-ginkgo
180168
# @echo "Running GitOps Operator parallel E2E tests..."
181169
# . ./scripts/run-kuttl-tests.sh parallel
@@ -188,12 +176,12 @@ e2e-non-olm-tests-sequential: ## Runs kuttl non-olm e2e sequentail tests
188176
.PHONY: e2e-non-olm-tests-parallel ## Runs kuttl non-olm e2e parallel tests, (Defaults to 5 runs at a time)
189177
e2e-non-olm-tests-parallel:
190178
@echo "Running Non-OLM GitOps Operator parallel E2E tests..."
191-
. ./hack/scripts/run-non-olm-kuttl-test.sh -t parallel
179+
. ./hack/scripts/run-non-olm-kuttl-test.sh -t parallel
192180

193181
.PHONY: e2e-non-olm-tests-all ## Runs kuttl non-olm e2e parallel tests, (Defaults to 5 runs at a time)
194182
e2e-non-olm-tests-all:
195183
@echo "Running Non-OLM GitOps Operator E2E tests..."
196-
. ./hack/scripts/run-non-olm-kuttl-test.sh -t all
184+
. ./hack/scripts/run-non-olm-kuttl-test.sh -t all
197185

198186
##@ Build
199187

@@ -215,27 +203,17 @@ docker-push: ## Push docker image with the manager.
215203

216204
##@ Build Dependencies
217205

218-
## Location to install dependencies to
219-
LOCALBIN ?= $(shell pwd)/bin
220-
$(LOCALBIN):
221-
mkdir -p $(LOCALBIN)
206+
# Do not use OPERATOR_SDK variable not to overwrite the user provided path
207+
bin/operator-sdk:
208+
mkdir -p bin
209+
curl -sSLo bin/operator-sdk \
210+
https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(shell go env GOOS)_$(shell go env GOARCH)
211+
chmod +x bin/operator-sdk
222212

213+
# Install to bin/operator-sdk unless already there or explicit OPERATOR_SDK provided
223214
.PHONY: operator-sdk
224-
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
225-
operator-sdk: ## Download operator-sdk locally if necessary.
226-
ifeq (,$(wildcard $(OPERATOR_SDK)))
227-
ifeq (,$(shell which operator-sdk 2>/dev/null))
228-
@{ \
229-
set -e ;\
230-
mkdir -p $(dir $(OPERATOR_SDK)) ;\
231-
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
232-
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
233-
chmod +x $(OPERATOR_SDK) ;\
234-
}
235-
else
236-
OPERATOR_SDK = $(shell which operator-sdk)
237-
endif
238-
endif
215+
operator-sdk: $(OPERATOR_SDK)
216+
@$(OPERATOR_SDK) version
239217

240218
ifndef ignore-not-found
241219
ignore-not-found = false

0 commit comments

Comments
 (0)