@@ -23,16 +23,19 @@ include $(ROOT_DIR_RELATIVE)/common.mk
23
23
export GO111MODULE =on
24
24
unexport GOPATH
25
25
26
+ # Enables shell script tracing. Enable by running: TRACE=1 make <target>
27
+ TRACE ?= 0
28
+
26
29
# Go
27
- GO_VERSION ?= 1.22.7
30
+ GO_VERSION ?= 1.23.8
28
31
29
32
# Directories.
30
33
ARTIFACTS ?= $(REPO_ROOT ) /_artifacts
31
34
TOOLS_DIR := hack/tools
35
+ BIN_DIR := bin
32
36
TOOLS_DIR_DEPS := $(TOOLS_DIR ) /go.sum $(TOOLS_DIR ) /go.mod $(TOOLS_DIR ) /Makefile
33
- TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
37
+ TOOLS_BIN_DIR := $(TOOLS_DIR ) /$( BIN_DIR )
34
38
35
- BIN_DIR := bin
36
39
REPO_ROOT := $(shell git rev-parse --show-toplevel)
37
40
GH_REPO ?= kubernetes-sigs/cluster-api-provider-openstack
38
41
TEST_E2E_DIR := test/e2e
@@ -49,6 +52,13 @@ GO_APIDIFF_VER := v0.8.2
49
52
GO_APIDIFF_BIN := go-apidiff
50
53
GO_APIDIFF_PKG := github.com/joelanford/go-apidiff
51
54
55
+ # govulncheck
56
+ GOVULNCHECK_VER := v1.1.4
57
+ GOVULNCHECK_BIN := govulncheck
58
+ GOVULNCHECK_PKG := golang.org/x/vuln/cmd/govulncheck
59
+
60
+ TRIVY_VER := 0.49.1
61
+
52
62
# Binaries.
53
63
CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /controller-gen
54
64
CONVERSION_GEN := $(TOOLS_BIN_DIR ) /conversion-gen
@@ -63,6 +73,7 @@ RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes
63
73
SETUP_ENVTEST := $(TOOLS_BIN_DIR ) /setup-envtest
64
74
GEN_CRD_API_REFERENCE_DOCS := $(TOOLS_BIN_DIR ) /gen-crd-api-reference-docs
65
75
GO_APIDIFF := $(TOOLS_BIN_DIR ) /$(GO_APIDIFF_BIN ) -$(GO_APIDIFF_VER )
76
+ GOVULNCHECK := $(TOOLS_BIN_DIR ) /$(GOVULNCHECK_BIN ) -$(GOVULNCHECK_VER )
66
77
67
78
# Kubebuilder
68
79
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.28.0
@@ -209,9 +220,9 @@ e2e-image: docker-build
209
220
210
221
# Pull all the images references in test/e2e/data/e2e_conf.yaml
211
222
test-e2e-image-prerequisites :
212
- docker pull registry.k8s.io/cluster-api/cluster-api-controller:v1.8.6
213
- docker pull registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.8.6
214
- docker pull registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.8.6
223
+ docker pull registry.k8s.io/cluster-api/cluster-api-controller:v1.8.8
224
+ docker pull registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.8.8
225
+ docker pull registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.8.8
215
226
216
227
CONFORMANCE_E2E_ARGS ?= -kubetest.config-file=$(KUBETEST_CONF_PATH )
217
228
CONFORMANCE_E2E_ARGS += $(E2E_ARGS )
@@ -252,6 +263,12 @@ $(GO_APIDIFF_BIN): $(GO_APIDIFF)
252
263
$(GO_APIDIFF ) : # Build go-apidiff.
253
264
GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(GO_APIDIFF_PKG ) $(GO_APIDIFF_BIN ) $(GO_APIDIFF_VER )
254
265
266
+ .PHONY : $(GOVULNCHECK_BIN )
267
+ $(GOVULNCHECK_BIN ) : $(GOVULNCHECK ) # # Build a local copy of govulncheck.
268
+
269
+ $(GOVULNCHECK ) : # Build govulncheck.
270
+ GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(GOVULNCHECK_PKG ) $(GOVULNCHECK_BIN ) $(GOVULNCHECK_VER )
271
+
255
272
# # --------------------------------------
256
273
# #@ Linting
257
274
# # --------------------------------------
@@ -358,7 +375,7 @@ generate-api-docs-%: $(GEN_CRD_API_REFERENCE_DOCS) FORCE
358
375
359
376
.PHONY : docker-build
360
377
docker-build : # # Build the docker image for controller-manager
361
- docker build -f Dockerfile --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " . -t $(CONTROLLER_IMG_TAG )
378
+ docker build -f Dockerfile --build-arg GO_VERSION= $( GO_VERSION ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " . -t $(CONTROLLER_IMG_TAG )
362
379
363
380
.PHONY : docker-push
364
381
docker-push : # # Push the docker image
@@ -579,8 +596,12 @@ clean-temporary: ## Remove all temporary files and folders
579
596
clean-release : # # Remove the release folder
580
597
rm -rf $(RELEASE_DIR )
581
598
599
+ .PHONY : clean-release-git
600
+ clean-release-git : # # Restores the git files usually modified during a release
601
+ git restore ./* manager_image_patch.yaml ./* manager_pull_policy.yaml
602
+
582
603
.PHONY : verify
583
- verify : verify-boilerplate verify-modules verify-gen verify-orc
604
+ verify : verify-boilerplate verify-modules verify-gen verify-orc verify-govulncheck
584
605
585
606
.PHONY : verify-boilerplate
586
607
verify-boilerplate :
@@ -604,6 +625,27 @@ verify-gen: generate
604
625
verify-orc :
605
626
$(MAKE ) -C $(REPO_ROOT ) /orc verify-generated
606
627
628
+ .PHONY : verify-container-images
629
+ verify-container-images : # # Verify container images
630
+ TRACE=$(TRACE ) ./hack/verify-container-images.sh $(TRIVY_VER )
631
+
632
+ .PHONY : verify-govulncheck
633
+ verify-govulncheck : $(GOVULNCHECK ) # # Verify code for vulnerabilities
634
+ $(GOVULNCHECK ) ./... && R1=$$? || R1=$$? ; \
635
+ $(GOVULNCHECK ) -C " $( TOOLS_DIR) " ./... && R2=$$? || R2=$$? ; \
636
+ if [ " $$ R1" -ne " 0" ] || [ " $$ R2" -ne " 0" ]; then \
637
+ exit 1; \
638
+ fi
639
+
640
+ .PHONY : verify-security
641
+ verify-security : # # Verify code and images for vulnerabilities
642
+ $(MAKE ) verify-container-images && R1=$$? || R1=$$? ; \
643
+ $(MAKE ) verify-govulncheck && R2=$$? || R2=$$? ; \
644
+ if [ " $$ R1" -ne " 0" ] || [ " $$ R2" -ne " 0" ]; then \
645
+ echo " Check for vulnerabilities failed! There are vulnerabilities to be fixed" ; \
646
+ exit 1; \
647
+ fi
648
+
607
649
.PHONY : vendor verify-vendoring
608
650
vendor :
609
651
go mod vendor
0 commit comments