5
5
# the allowDangerousTypes flag is needed for CRD manifests to generate correctly.
6
6
CRD_OPTIONS ?= "crd:allowDangerousTypes=true"
7
7
8
+ GO ?= go
9
+
8
10
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
9
- ifeq (,$(shell go env GOBIN) )
10
- GOBIN =$(shell go env GOPATH) /bin
11
+ ifeq (,$(shell $( GO ) env GOBIN) )
12
+ GOBIN =$(shell $( GO ) env GOPATH) /bin
11
13
else
12
- GOBIN =$(shell go env GOBIN)
14
+ GOBIN =$(shell $( GO ) env GOBIN)
13
15
endif
14
16
15
17
GO_VERSION := $(shell head -n 1 ../build/images/deps/go-version)
@@ -46,19 +48,18 @@ help: ## Display this help.
46
48
47
49
# #@ Development
48
50
49
- manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
50
- $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=controller-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
51
+ manifests : crdgen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
51
52
$(CURDIR ) /hack/generate-manifest.sh -g > build/yamls/antrea-multicluster-leader-global.yml
52
53
$(CURDIR ) /hack/generate-manifest.sh -n antrea-multicluster > build/yamls/antrea-multicluster-leader-namespaced.yml
53
54
$(CURDIR ) /hack/generate-manifest.sh -l antrea-multicluster > build/yamls/antrea-multicluster-leader.yml
54
55
$(CURDIR ) /hack/generate-manifest.sh -m > build/yamls/antrea-multicluster-member.yml
55
56
$(CURDIR ) /hack/update-checksum.sh
56
57
57
58
fmt : # # Run go fmt against code.
58
- go fmt ./...
59
+ $( GO ) fmt ./...
59
60
60
61
vet : # # Run go vet against code.
61
- go vet ./...
62
+ $( GO ) vet ./...
62
63
63
64
.PHONY : .coverage
64
65
.coverage :
@@ -67,28 +68,29 @@ vet: ## Run go vet against code.
67
68
.PHONY : test-unit test-integration
68
69
test-unit : fmt vet .coverage
69
70
@echo " ==> Running unit tests <=="
70
- go test -race -coverprofile=.coverage/coverage-unit.txt -covermode=atomic -cover antrea.io/antrea/multicluster/controllers/multicluster/...
71
+ $( GO ) test -race -coverprofile=.coverage/coverage-unit.txt -covermode=atomic -cover antrea.io/antrea/multicluster/controllers/multicluster/...
71
72
test-integration : .coverage
72
73
@echo " ==> Running Multi-cluster integration tests <=="
73
74
$(CURDIR ) /hack/verify-tools.sh
74
75
$(CURDIR ) /hack/mc-integration-test.sh
75
76
# #@ Build
76
77
77
78
bin : fmt vet # # Build manager binary.
78
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/antrea-mc-controller antrea.io/antrea/multicluster/cmd/...
79
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $( GO ) build -o bin/antrea-mc-controller antrea.io/antrea/multicluster/cmd/...
79
80
80
81
.PHONY : antrea-mc-instr-binary
81
82
antrea-mc-instr-binary :
82
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -cover -coverpkg=antrea.io/antrea/multicluster/...,antrea.io/antrea/multicluster/cmd/... -o bin/antrea-mc-controller-coverage antrea.io/antrea/multicluster/cmd/...
83
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $( GO ) build -cover -coverpkg=antrea.io/antrea/multicluster/...,antrea.io/antrea/multicluster/cmd/... -o bin/antrea-mc-controller-coverage antrea.io/antrea/multicluster/cmd/...
83
84
84
85
run : manifests generate fmt vet # # Run a controller from your host.
85
- go run ./main.go
86
+ $( GO ) run ./main.go
86
87
87
88
# #@ Deployment
88
89
89
- CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
90
- controller-gen : # # Download controller-gen locally if necessary.
91
- $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/[email protected] )
90
+ .PHONY : crdgen
91
+ crdgen :
92
+ @echo " ===> Updating generated base manifests <==="
93
+ $(CURDIR ) /hack/update-codegen.sh crdgen
92
94
93
95
codegen :
94
96
./hack/update-codegen.sh
@@ -97,17 +99,3 @@ codegen:
97
99
mockgen :
98
100
@echo " ===> Updating generated mock code <==="
99
101
$(CURDIR ) /hack/update-codegen.sh mockgen
100
-
101
- # go-get-tool will 'go get' any package $2 and install it to $1.
102
- PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
103
- define go-get-tool
104
- @[ -f $(1 ) ] || { \
105
- set -e ;\
106
- TMP_DIR=$$(mktemp -d ) ;\
107
- cd $$TMP_DIR ;\
108
- go mod init tmp ;\
109
- echo "Downloading $(2 ) " ;\
110
- GOBIN=$(PROJECT_DIR ) /bin go install $(2 ) ;\
111
- rm -rf $$TMP_DIR ;\
112
- }
113
- endef
0 commit comments