From 5ffbb92e0ce6dccea798786541505fa41f51f266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20St=C3=A4bler?= Date: Mon, 6 Jun 2022 15:15:57 +0200 Subject: [PATCH] Update to operator-sdk 1.21 (#1094) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christoph Stäbler --- Makefile | 21 +++++++++++++++++---- bundle.Dockerfile | 2 +- bundle/metadata/annotations.yaml | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 943cec4a64..c62c4dea1f 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ export SSH ?= ./cluster/ssh.sh export KUBECTL ?= ./cluster/kubectl.sh KUBECTL ?= ./cluster/kubectl.sh -OPERATOR_SDK ?= $(GOBIN)/operator-sdk +OPERATOR_SDK_VERSION ?= 1.21.0 GINKGO = GOFLAGS=-mod=mod go run github.com/onsi/ginkgo/v2/ginkgo@v2.1.4 CONTROLLER_GEN = GOFLAGS=-mod=mod go run sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.0 @@ -114,8 +114,20 @@ gofmt-check: lint: hack/lint.sh -$(OPERATOR_SDK): - curl https://github.com/operator-framework/operator-sdk/releases/download/v1.15.0/operator-sdk_linux_amd64 -o $(OPERATOR_SDK) +OPERATOR_SDK = $(CURDIR)/build/_output/bin/operator-sdk_${OPERATOR_SDK_VERSION} +operator-sdk: ## Download operator-sdk locally. +ifneq (,$(shell operator-sdk version 2>/dev/null | grep "operator-sdk version: \"v$(OPERATOR_SDK_VERSION)\"" )) +OPERATOR_SDK = $(shell which operator-sdk) +else +ifeq (,$(wildcard $(OPERATOR_SDK))) + @{ \ + set -e ;\ + mkdir -p $(dir $(OPERATOR_SDK)) ;\ + curl -Lo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v$(OPERATOR_SDK_VERSION)/operator-sdk_$$(go env GOOS)_$$(go env GOARCH) ;\ + chmod +x $(OPERATOR_SDK) ;\ + } +endif +endif gen-k8s: cd api && $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." @@ -200,7 +212,7 @@ vendor: go mod vendor # Generate bundle manifests and metadata, then validate generated files. -bundle: $(OPERATOR_SDK) gen-crds manifests +bundle: operator-sdk gen-crds manifests cp -r deploy/bases $(MANIFESTS_DIR)/bases $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) --deploy-dir $(MANIFESTS_DIR) --crds-dir deploy/crds $(OPERATOR_SDK) bundle validate ./bundle @@ -231,6 +243,7 @@ olm-push: bundle-push index-push test/unit \ generate \ check-gen \ + operator-sdk \ test-e2e-handler \ test-e2e-operator \ test-e2e \ diff --git a/bundle.Dockerfile b/bundle.Dockerfile index 1725a90216..511f7accb4 100644 --- a/bundle.Dockerfile +++ b/bundle.Dockerfile @@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ LABEL operators.operatorframework.io.bundle.package.v1=kubernetes-nmstate-operator LABEL operators.operatorframework.io.bundle.channels.v1=alpha -LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.13.0+git +LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.21.0 LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 diff --git a/bundle/metadata/annotations.yaml b/bundle/metadata/annotations.yaml index d5fc691a68..47755ad60d 100644 --- a/bundle/metadata/annotations.yaml +++ b/bundle/metadata/annotations.yaml @@ -5,7 +5,7 @@ annotations: operators.operatorframework.io.bundle.metadata.v1: metadata/ operators.operatorframework.io.bundle.package.v1: kubernetes-nmstate-operator operators.operatorframework.io.bundle.channels.v1: alpha - operators.operatorframework.io.metrics.builder: operator-sdk-v1.13.0+git + operators.operatorframework.io.metrics.builder: operator-sdk-v1.21.0 operators.operatorframework.io.metrics.mediatype.v1: metrics+v1 operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3