Skip to content

Commit

Permalink
PVCViewers Controller: Makefile: Use local controller-gen
Browse files Browse the repository at this point in the history
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 <kimwnasptd@arrikto.com>
Reviewed-by: Yannis Zarkadas <yanniszark@arrikto.com>
Github-PR: kubeflow#34
Related-to: arrikto/dev#77
Related-to: arrikto/dev#333
  • Loading branch information
yanniszark authored and kimwnasptd committed Sep 2, 2021
1 parent 60a3af4 commit 8e56262
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions components/pvcviewer-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

0 comments on commit 8e56262

Please sign in to comment.