Skip to content

Commit ded3363

Browse files
committed
remove gopath for accessing binaries.
get gobin folder if set make gobin globally available.
1 parent de15359 commit ded3363

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pkg/scaffold/v2/makefile.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ IMG ?= {{ .Image }}
4848
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
4949
CRD_OPTIONS ?= "crd:trivialVersions=true"
5050
51+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
52+
ifeq (,$(shell go env GOBIN))
53+
GOBIN=$(shell go env GOPATH)/bin
54+
else
55+
GOBIN=$(shell go env GOBIN)
56+
endif
57+
5158
all: manager
5259
5360
# Run tests
@@ -102,7 +109,7 @@ docker-push:
102109
controller-gen:
103110
ifeq (, $(shell which controller-gen))
104111
go get sigs.k8s.io/controller-tools/cmd/[email protected]
105-
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
112+
CONTROLLER_GEN=$(GOBIN)/controller-gen
106113
else
107114
CONTROLLER_GEN=$(shell which controller-gen)
108115
endif

testdata/project-v2/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ IMG ?= controller:latest
44
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
55
CRD_OPTIONS ?= "crd:trivialVersions=true"
66

7+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8+
ifeq (,$(shell go env GOBIN))
9+
GOBIN=$(shell go env GOPATH)/bin
10+
else
11+
GOBIN=$(shell go env GOBIN)
12+
endif
13+
714
all: manager
815

916
# Run tests
@@ -58,7 +65,7 @@ docker-push:
5865
controller-gen:
5966
ifeq (, $(shell which controller-gen))
6067
go get sigs.k8s.io/controller-tools/cmd/[email protected]
61-
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
68+
CONTROLLER_GEN=$(GOBIN)/controller-gen
6269
else
6370
CONTROLLER_GEN=$(shell which controller-gen)
6471
endif

0 commit comments

Comments
 (0)