From cf00a86fc204c80036537140e59c0c1df0560b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 26 Mar 2021 09:21:33 +0100 Subject: [PATCH] ceph: force yq and controller-gen versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's not use any controllen-gen version we might find on the system, always pull the version we need. Same goes for yq. Signed-off-by: Sébastien Han --- .github/workflows/crds-gen.yml | 3 --- Makefile | 8 +++----- build/crds/build-crds.sh | 9 +++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/crds-gen.yml b/.github/workflows/crds-gen.yml index f7cb2a177..f38345101 100644 --- a/.github/workflows/crds-gen.yml +++ b/.github/workflows/crds-gen.yml @@ -15,9 +15,6 @@ jobs: - name: checkout uses: actions/checkout@v2 - - name: install yq - run: sudo snap install yq --channel=v3/stable - - name: copy working directory to GOPATH run: sudo mkdir -p /home/runner/go/src/github.com && sudo cp -a /home/runner/work/rook /home/runner/go/src/github.com/ diff --git a/Makefile b/Makefile index cdcc3823b..a1a8fcbf6 100644 --- a/Makefile +++ b/Makefile @@ -175,23 +175,21 @@ csv-clean: ## Remove existing OLM files. @rm -fr cluster/olm/ceph/deploy/* cluster/olm/ceph/templates/* controller-gen: -ifeq (, $(shell command -v controller-gen)) @{ \ set -e ;\ CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ cd $$CONTROLLER_GEN_TMP_DIR ;\ go mod init tmp;\ go get sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION);\ + go get github.com/mikefarah/yq/v3;\ rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ } CONTROLLER_GEN=$(GOBIN)/controller-gen -else -CONTROLLER_GEN=$(shell command -v controller-gen) -endif +YQ=$(GOBIN)/yq crds: controller-gen @echo Updating CRD manifests - @build/crds/build-crds.sh $(CONTROLLER_GEN) + @build/crds/build-crds.sh $(CONTROLLER_GEN) $(YQ) .PHONY: all build.common cross.build.parallel .PHONY: build build.all install test check vet fmt codegen mod.check clean distclean prune diff --git a/build/crds/build-crds.sh b/build/crds/build-crds.sh index 82a253fea..aa40970cc 100755 --- a/build/crds/build-crds.sh +++ b/build/crds/build-crds.sh @@ -20,6 +20,7 @@ set -o pipefail SCRIPT_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd -P) CONTROLLER_GEN_BIN_PATH=$1 +YQ_BIN_PATH=$2 # allowDangerousTypes is used to accept float64 CRD_OPTIONS="crd:trivialVersions=true,allowDangerousTypes=true" OLM_CATALOG_DIR="${SCRIPT_ROOT}/cluster/olm/ceph/deploy/crds" @@ -67,17 +68,17 @@ EOF build_helm_resources() { # Add helm annotations to all CRDS - yq w -i -d'*' "$HELM_CRDS_FILE_PATH" "metadata.annotations[helm.sh/resource-policy]" keep - + "$YQ_BIN_PATH" w -i -d'*' "$HELM_CRDS_FILE_PATH" "metadata.annotations[helm.sh/resource-policy]" keep + # add header sed -i '1s/^/{{- if semverCompare ">=1.16.0" .Capabilities.KubeVersion.GitVersion }}\n/' "$HELM_CRDS_FILE_PATH" sed -i '1s/^/{{- if .Values.crds.enabled }}\n/' "$HELM_CRDS_FILE_PATH" - + echo "Generating helm resources.yaml" { # add else echo "{{- else }}" - + # add footer cat "$CRDS_BEFORE_1_16_FILE_PATH" # DO NOT REMOVE the empty line, it is necessary