From 8e56262ab8e201682d4d917371ff389f945a10b1 Mon Sep 17 00:00:00 2001 From: Yannis Zarkadas Date: Mon, 24 Feb 2020 16:22:23 +0200 Subject: [PATCH] PVCViewers Controller: Makefile: Use local controller-gen This commit modifies the Makefile to download controller-gen to a folder inside the pvcviewer-controller. The goal is to make sure the specific version of controller-gen is used to generate manifests for the pvcviewer-controller. Signed-off-by: Kimonas Sotirchos Reviewed-by: Yannis Zarkadas Github-PR: #34 Related-to: arrikto/dev#77 Related-to: arrikto/dev#333 --- components/pvcviewer-controller/Makefile | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/components/pvcviewer-controller/Makefile b/components/pvcviewer-controller/Makefile index f5bc90dd1ae..7f89c6ecb9b 100644 --- a/components/pvcviewer-controller/Makefile +++ b/components/pvcviewer-controller/Makefile @@ -6,11 +6,8 @@ TAG ?= $(shell git describe --tags) CRD_OPTIONS ?= "crd:trivialVersions=true" # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) -ifeq (,$(shell go env GOBIN)) -GOBIN=$(shell go env GOPATH)/bin -else -GOBIN=$(shell go env GOBIN) -endif +GOBIN=$(shell pwd)/bin +CONTROLLER_GEN=$(GOBIN)/controller-gen all: manager @@ -71,7 +68,7 @@ delete-namespace: kubectl delete namespace pvc-viewer-controller-system # Generate manifests e.g. CRD, RBAC etc. -manifests: controller-gen +manifests: bin/controller-gen $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases # Run go fmt against code @@ -83,7 +80,7 @@ vet: go vet ./... # Generate code -generate: controller-gen +generate: bin/controller-gen $(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..." # Build the docker image (should add some tests) @@ -96,10 +93,6 @@ docker-push: # find or download controller-gen # download controller-gen if necessary -controller-gen: -ifeq (, $(shell which controller-gen)) - go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.1 -CONTROLLER_GEN=$(GOBIN)/controller-gen -else -CONTROLLER_GEN=$(shell which controller-gen) -endif +bin/controller-gen: + mkdir -p bin + GOBIN=$(GOBIN) go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.1