@@ -73,25 +73,8 @@ REGISTRY ?= quay.io/open-cluster-management
7373TAG ?= latest
7474IMAGE_NAME_AND_VERSION ?= $(REGISTRY ) /$(IMG )
7575
76- # go-get-tool will 'go install' any package $1 and install it to LOCAL_BIN.
77- define go-get-tool
78- @set -e ;\
79- echo "Checking installation of $(1 ) " ;\
80- GOBIN=$(LOCAL_BIN ) go install $(1 )
81- endef
82-
8376include build/common/Makefile.common.mk
8477
85- # ###########################################################
86- # work section
87- # ###########################################################
88-
89- $(GOBIN ) :
90- @mkdir -p $(GOBIN )
91-
92- $(LOCAL_BIN ) :
93- @mkdir -p $(LOCAL_BIN )
94-
9578# ###########################################################
9679# clean section
9780# ###########################################################
@@ -109,42 +92,15 @@ clean:
10992# format section
11093# ###########################################################
11194
112- .PHONY : fmt-dependencies
113- fmt-dependencies :
114- $(call go-get-tool,github.com/daixiang0/[email protected] ) 115- $(call go-get-tool,mvdan.cc/[email protected] ) 116-
117- # All available format: format-go format-protos format-python
118- # Default value will run all formats, override these make target with your requirements:
119- # eg: fmt: format-go format-protos
12095.PHONY : fmt
121- fmt : fmt-dependencies
122- find . -not \( -path " ./.go" -prune \) -name " *.go" | xargs gofmt -s -w
123- find . -not \( -path " ./.go" -prune \) -name " *.go" | xargs gofumpt -l -w
124- find . -not \( -path " ./.go" -prune \) -name " *.go" | xargs gci write -s standard -s default -s " prefix($( shell cat go.mod | head -1 | cut -d " " -f 2) )"
125-
126- # ###########################################################
127- # check section
128- # ###########################################################
129-
130- .PHONY : check
131- check : lint
132-
133- .PHONY : lint-dependencies
134- lint-dependencies :
135- $(call go-get-tool,github.com/golangci/golangci-lint/cmd/[email protected] ) 96+ fmt :
13697
13798.PHONY : lint
13899lint :
139100
140101# ###########################################################
141102# test section
142103# ###########################################################
143- GOSEC = $(LOCAL_BIN ) /gosec
144- KUBEBUILDER = $(LOCAL_BIN ) /kubebuilder
145- ENVTEST = $(LOCAL_BIN ) /setup-envtest
146- KBVERSION = 3.12.0
147- ENVTEST_K8S_VERSION = 1.26.x
148104
149105.PHONY : test
150106test : test-dependencies
@@ -157,26 +113,6 @@ test-coverage: test
157113.PHONY : test-dependencies
158114test-dependencies : envtest kubebuilder
159115
160- .PHONY : kubebuilder
161- kubebuilder :
162- @if [ " $$ ($( KUBEBUILDER) version 2>/dev/null | grep -o KubeBuilderVersion:\" [0-9]*\.[0-9]\.[0-9]*\" )" != " KubeBuilderVersion:\" $( KBVERSION) \" " ]; then \
163- echo " Installing Kubebuilder" ; \
164- curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v$(KBVERSION ) /kubebuilder_$(GOOS ) _$(GOARCH ) -o $(KUBEBUILDER ) ; \
165- chmod +x $(KUBEBUILDER ) ; \
166- fi
167-
168- .PHONY : envtest
169- envtest :
170- $(call go-get-tool,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
171-
172- .PHONY : gosec
173- gosec :
174- $(call go-get-tool,github.com/securego/gosec/v2/cmd/[email protected] ) 175-
176- .PHONY : gosec-scan
177- gosec-scan : gosec
178- $(GOSEC ) -fmt sonarqube -out gosec.json -stdout -exclude-dir=.go -exclude-dir=test ./...
179-
180116# ###########################################################
181117# build section
182118# ###########################################################
@@ -201,13 +137,10 @@ build-images:
201137.PHONY : deploy
202138deploy : generate-operator-yaml
203139 kubectl apply -f deploy/operator.yaml -n $(KIND_NAMESPACE ) --kubeconfig=$(MANAGED_CONFIG ) _e2e
204-
205140
206141# ###########################################################
207142# Generate manifests
208143# ###########################################################
209- CONTROLLER_GEN = $(LOCAL_BIN ) /controller-gen
210- KUSTOMIZE = $(LOCAL_BIN ) /kustomize
211144
212145.PHONY : manifests
213146manifests : controller-gen
@@ -221,18 +154,9 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
221154generate-operator-yaml : kustomize manifests
222155 $(KUSTOMIZE ) build deploy/manager > deploy/operator.yaml
223156
224- .PHONY : controller-gen
225- controller-gen : # # Download controller-gen locally if necessary.
226- $(call go-get-tool,sigs.k8s.io/controller-tools/cmd/[email protected] ) 227-
228- .PHONY : kustomize
229- kustomize : # # Download kustomize locally if necessary.
230- $(call go-get-tool,sigs.k8s.io/kustomize/kustomize/[email protected] ) 231-
232157# ###########################################################
233158# e2e test section
234159# ###########################################################
235- GINKGO = $(LOCAL_BIN ) /ginkgo
236160
237161.PHONY : kind-bootstrap-cluster
238162kind-bootstrap-cluster : kind-bootstrap-cluster-dev kind-deploy-controller
@@ -293,10 +217,6 @@ install-resources:
293217 kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper/v3.11.0/deploy/gatekeeper.yaml --kubeconfig=$(MANAGED_CONFIG ) _e2e; \
294218 fi
295219
296- .PHONY : e2e-dependencies
297- e2e-dependencies :
298- $(call go-get-tool,github.com/onsi/ginkgo/v2/ginkgo@$(shell awk '/github.com\/onsi\/ginkgo\/v2/ {print $$2}' go.mod) )
299-
300220.PHONY : e2e-test
301221e2e-test : e2e-dependencies
302222 $(GINKGO ) -v --fail-fast $(E2E_TEST_ARGS ) test/e2e
@@ -355,12 +275,8 @@ e2e-debug:
355275# ###########################################################
356276# test coverage
357277# ###########################################################
358- GOCOVMERGE = $(LOCAL_BIN ) /gocovmerge
359- .PHONY : coverage-dependencies
360- coverage-dependencies :
361- $(call go-get-tool,github.com/wadey/[email protected] ) 362-
363278COVERAGE_FILE = coverage.out
279+
364280.PHONY : coverage-merge
365281coverage-merge : coverage-dependencies
366282 @echo Merging the coverage reports into $(COVERAGE_FILE )
0 commit comments