From 334a891523c868e5f46d47c2efb633e93d859182 Mon Sep 17 00:00:00 2001 From: Phil Brookes Date: Thu, 8 Apr 2021 11:31:26 +0100 Subject: [PATCH] add operator-sdk version check to makefile --- Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index eed8511c..20504629 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,14 @@ LOCAL=local GRAFANA_OPERATOR_VERSION=v3.8.1 AMO_VERSION=1.5.1 PREV_AMO_VERSION=1.5.0 - +OPERATOR_SDK_VERSION=0.15.2 AUTH_TOKEN=$(shell curl -sH "Content-Type: application/json" -XPOST https://quay.io/cnr/api/v1/users/login -d '{"user": {"username": "$(QUAY_USERNAME)", "password": "${QUAY_PASSWORD}"}}' | jq -r '.token') +ifeq ($(shell operator-sdk version 2> /dev/null | sed -e 's/", .*/"/' -e 's/.* //'), "v$(OPERATOR_SDK_VERSION)") + OPERATOR_SDK ?= operator-sdk +else + OPERATOR_SDK ?= go run github.com/operator-framework/operator-sdk/cmd/operator-sdk +endif .PHONY: setup/gomod setup/gomod: @@ -30,11 +35,11 @@ setup/gomod: .PHONY: setup/travis setup/travis: @echo Installing Operator SDK - @curl -Lo operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/v0.8.1/operator-sdk-v0.8.1-x86_64-linux-gnu && chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin/ + @curl -Lo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v0.8.1/operator-sdk-v0.8.1-x86_64-linux-gnu && chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin/ .PHONY: code/run code/run: - @operator-sdk up local --namespace=${NAMESPACE} + @$(OPERATOR_SDK) up local --namespace=${NAMESPACE} .PHONY: code/compile code/compile: @@ -42,12 +47,12 @@ code/compile: .PHONY: code/gen code/gen: - operator-sdk generate k8s + $(OPERATOR_SDK) generate k8s .PHONY: gen/csv gen/csv: sed -i.bak 's/image:.*/image: quay\.io\/integreatly\/application-monitoring-operator:v$(AMO_VERSION)/g' deploy/operator.yaml && rm deploy/operator.yaml.bak - @operator-sdk generate csv --operator-name=application-monitoring-operator --csv-version $(AMO_VERSION) --from-version $(PREV_AMO_VERSION) --update-crds --csv-channel=integreatly --default-channel + @$(OPERATOR_SDK) generate csv --operator-name=application-monitoring-operator --csv-version $(AMO_VERSION) --from-version $(PREV_AMO_VERSION) --update-crds --csv-channel=integreatly --default-channel @sed -i.bak 's/$(PREV_AMO_VERSION)/$(AMO_VERSION)/g' deploy/olm-catalog/application-monitoring-operator/application-monitoring-operator.package.yaml && rm deploy/olm-catalog/application-monitoring-operator/application-monitoring-operator.package.yaml.bak @sed -i.bak s/application-monitoring-operator:v$(PREV_AMO_VERSION)/application-monitoring-operator:v$(AMO_VERSION)/g deploy/olm-catalog/application-monitoring-operator/$(AMO_VERSION)/application-monitoring-operator.v$(AMO_VERSION).clusterserviceversion.yaml && rm deploy/olm-catalog/application-monitoring-operator/$(AMO_VERSION)/application-monitoring-operator.v$(AMO_VERSION).clusterserviceversion.yaml.bak @@ -61,7 +66,7 @@ code/fix: .PHONY: image/build image/build: code/compile - @operator-sdk build ${REG}/${ORG}/${PROJECT}:${AMO_VERSION} + @$(OPERATOR_SDK) build ${REG}/${ORG}/${PROJECT}:${AMO_VERSION} .PHONY: image/push image/push: @@ -72,7 +77,7 @@ image/build/push: image/build image/push .PHONY: image/build/test image/build/test: - operator-sdk build --enable-tests ${REG}/${ORG}/${PROJECT}:${AMO_VERSION} + $(OPERATOR_SDK) build --enable-tests ${REG}/${ORG}/${PROJECT}:${AMO_VERSION} .PHONY: test/unit test/unit: