diff --git a/Makefile b/Makefile index 771000fbf7..272bffa724 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,16 @@ LOCALBIN=$(shell pwd)/bin +GOHOSTOS=$(shell go env GOHOSTOS) +GOHOSTARCH=$(shell go env GOHOSTARCH) + KUSTOMIZE_VERSION=v4.5.5 KUSTOMIZE=$(LOCALBIN)/kustomize CONTROLLER_GEN_VERSION=v0.9.2 CONTROLLER_GEN=$(LOCALBIN)/controller-gen - +OPERATOR_SDK_VERSION=v1.25.4 +OPERATOR_SDK=$(LOCALBIN)/operator-sdk-$(OPERATOR_SDK_VERSION) +OPM_VERSION=v1.28.0 +OPM=$(LOCALBIN)/opm-$(OPM_VERSION) .PHONY: \ build \ @@ -177,6 +183,30 @@ else endif export KUSTOMIZE +# find or download operator-sdk if necessary +operator-sdk: +ifeq ($(wildcard ${OPERATOR_SDK}),) + @echo "Installing operator-sdk@${OPERATOR_SDK_VERSION} at ${OPERATOR_SDK}" + @mkdir -p $(LOCALBIN) + @curl -JL "https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_${GOHOSTOS}_${GOHOSTARCH}" -o ${OPERATOR_SDK} + @chmod +x ${OPERATOR_SDK} +else + @echo "Using existing operator-sdk@${OPERATOR_SDK_VERSION} at ${OPERATOR_SDK}" +endif +export OPERATOR_SDK + +# find or download opm if necessary +opm: +ifeq ($(wildcard ${OPM}),) + @echo "Installing opm@${OPM_VERSION} at ${OPM}" + @mkdir -p $(LOCALBIN) + @curl -JL "https://github.com/operator-framework/operator-registry/releases/download/${OPM_VERSION}/${GOHOSTOS}-${GOHOSTARCH}-opm" -o ${OPM} + @chmod +x ${OPM} +else + @echo "Using existing opm@${OPM_VERSION} at ${OPM}" +endif +export OPM + install-noobaa: operator-sdk @echo "Installing noobaa operator" hack/install-noobaa.sh diff --git a/hack/build-operator-catalog.sh b/hack/build-operator-catalog.sh index b16a4772f9..2f2fcc0995 100755 --- a/hack/build-operator-catalog.sh +++ b/hack/build-operator-catalog.sh @@ -4,7 +4,6 @@ set -e source hack/common.sh source hack/docker-common.sh -source hack/ensure-opm.sh echo echo "Did you push the bundle image? It must be pullable from '$IMAGE_REGISTRY'." diff --git a/hack/common.sh b/hack/common.sh index be3406adb8..99e8c49635 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -20,10 +20,6 @@ LDFLAGS="-X github.com/red-hat-storage/ocs-operator/v4/version.Version=${CSV_VER # Tools & binaries versions and locations LOCALBIN="$(pwd)/bin" -OPERATOR_SDK_VERSION="v1.25.4" -OPERATOR_SDK="${LOCALBIN}/operator-sdk-${OPERATOR_SDK_VERSION}" -OPM_VERSION="v1.28.0" -OPM="${LOCALBIN}/opm-${OPM_VERSION}" GINKGO="${LOCALBIN}/ginkgo" GOLANGCI_LINT_VERSION="v1.51.1" GOLANGCI_LINT="${LOCALBIN}/golangci-lint" diff --git a/hack/ensure-operator-sdk.sh b/hack/ensure-operator-sdk.sh deleted file mode 100755 index d6411d8265..0000000000 --- a/hack/ensure-operator-sdk.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e - -source hack/common.sh - -OPERATOR_SDK_DL_URL="https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_${GOHOSTOS}_${GOHOSTARCH}" - -mkdir -p "${LOCALBIN}" - -if [ ! -x "${OPERATOR_SDK}" ]; then - echo "Installing operator-sdk CLI at ${OPERATOR_SDK}" - curl -JL "${OPERATOR_SDK_DL_URL}" -o "${OPERATOR_SDK}" - chmod +x "${OPERATOR_SDK}" -else - echo "Using operator-sdk CLI present at ${OPERATOR_SDK}" -fi diff --git a/hack/ensure-opm.sh b/hack/ensure-opm.sh deleted file mode 100755 index 926df9cfe3..0000000000 --- a/hack/ensure-opm.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -e - -source hack/common.sh - -OPM_DL_URL="https://github.com/operator-framework/operator-registry/releases/download/${OPM_VERSION}/${GOHOSTOS}-${GOHOSTARCH}-opm" -mkdir -p "${LOCALBIN}" - -if [ ! -x "${OPM}" ]; then - echo "Installing opm CLI at ${OPM}" - curl -JL "${OPM_DL_URL}" -o "${OPM}" - chmod +x "${OPM}" -else - echo "Using opm CLI present at ${OPM}" -fi diff --git a/hack/verify-operator-bundle.sh b/hack/verify-operator-bundle.sh index 33697a9f2a..62fcacec17 100755 --- a/hack/verify-operator-bundle.sh +++ b/hack/verify-operator-bundle.sh @@ -2,6 +2,6 @@ set -e -source hack/ensure-operator-sdk.sh +source hack/common.sh ${OPERATOR_SDK} bundle validate "$(dirname $OCS_FINAL_DIR)" --verbose \ No newline at end of file