@@ -18,13 +18,13 @@ ROOT_DIR_RELATIVE := .
18
18
19
19
include $(ROOT_DIR_RELATIVE ) /common.mk
20
20
21
- GO_VERSION ?= 1.20.12
22
-
23
21
# Image URL to use all building/pushing image targets
24
22
IMG ?= controller:latest
25
23
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
26
24
CRD_OPTIONS ?= "crd:crdVersions=v1"
27
25
26
+ SHELL =/bin/bash
27
+
28
28
# Directories.
29
29
REPO_ROOT := $(shell git rev-parse --show-toplevel)
30
30
ARTIFACTS ?= $(REPO_ROOT ) /_artifacts
@@ -62,6 +62,10 @@ RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
62
62
RELEASE_DIR := out
63
63
OUTPUT_TYPE ?= type=registry
64
64
65
+ # Go
66
+ GO_VERSION ?=1.20.12
67
+ GO_CONTAINER_IMAGE ?= golang:$(GO_VERSION )
68
+
65
69
# kind
66
70
CAPI_KIND_CLUSTER_NAME ?= capi-test
67
71
@@ -281,7 +285,7 @@ $(ARTIFACTS):
281
285
282
286
.PHONY : build-toolchain
283
287
build-toolchain : # # Build the toolchain
284
- docker build --target toolchain -t $(TOOLCHAIN_IMAGE ) .
288
+ docker build --target toolchain --build-arg golang_image= $( GO_CONTAINER_IMAGE ) - t $(TOOLCHAIN_IMAGE ) .
285
289
286
290
.PHONY : list-staging-releases
287
291
list-staging-releases : # # List staging images for image promotion
@@ -416,7 +420,7 @@ ensure-buildx:
416
420
417
421
.PHONY : docker-build
418
422
docker-build : docker-pull-prerequisites ensure-buildx # # Build the docker image for controller-manager
419
- docker buildx build --platform linux/$(ARCH ) --output=$(OUTPUT_TYPE ) --pull --build-arg LDFLAGS=" $( LDFLAGS) " -t $(CORE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG ) .
423
+ docker buildx build --platform linux/$(ARCH ) --output=$(OUTPUT_TYPE ) --pull --build-arg golang_image= $( GO_CONTAINER_IMAGE ) --build-arg LDFLAGS=" $( LDFLAGS) " -t $(CORE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG ) .
420
424
421
425
.PHONY : docker-pull-prerequisites
422
426
docker-pull-prerequisites :
@@ -425,7 +429,7 @@ docker-pull-prerequisites:
425
429
426
430
.PHONY : e2e-image
427
431
e2e-image : docker-pull-prerequisites ensure-buildx
428
- docker buildx build --platform linux/$(ARCH ) --load --tag=$(CORE_CONTROLLER_ORIGINAL_IMG ) :e2e .
432
+ docker buildx build --platform linux/$(ARCH ) --load --build-arg golang_image= $( GO_CONTAINER_IMAGE ) -- tag=$(CORE_CONTROLLER_ORIGINAL_IMG ) :e2e .
429
433
$(MAKE ) set-manifest-image MANIFEST_IMG=$(CORE_CONTROLLER_ORIGINAL_IMG ) :e2e TARGET_RESOURCE=" ./config/default/manager_image_patch.yaml"
430
434
$(MAKE ) set-manifest-pull-policy PULL_POLICY=Never TARGET_RESOURCE=" ./config/default/manager_pull_policy.yaml"
431
435
@@ -451,8 +455,8 @@ docker-build-%:
451
455
452
456
.PHONY : docker-build-core-image
453
457
docker-build-core-image : ensure-buildx # # Build the multiarch core docker image
454
- docker buildx build --builder capibm --platform $(BUILDX_PLATFORMS ) --output=$(OUTPUT_TYPE ) \
455
- --pull --build-arg ldflags=" $( LDFLAGS) " \
458
+ docker buildx build --builder capibm --platform $(BUILDX_PLATFORMS ) --output=$(OUTPUT_TYPE ) \
459
+ --pull --build-arg golang_image= $( GO_CONTAINER_IMAGE ) --build-arg ldflags=" $( LDFLAGS) " \
456
460
-t $(CORE_CONTROLLER_IMG ) :$(TAG ) .
457
461
458
462
# # --------------------------------------
@@ -483,7 +487,7 @@ define checkdiff
483
487
git --no-pager diff --name-only FETCH_HEAD
484
488
endef
485
489
486
- ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions
490
+ ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions go-version
487
491
488
492
.PHONY : verify
489
493
verify : $(addprefix verify-,$(ALL_VERIFY_CHECKS ) ) # # Run all verify-* targets
@@ -539,6 +543,17 @@ verify-security: ## Verify code and images for vulnerabilities
539
543
exit 1; \
540
544
fi
541
545
546
+
547
+ SUBMAKEFILE_GO_VERSION =$(shell grep "GO_VERSION" -m1 hack/ccm/Makefile | cut -d '=' -f2 )
548
+ .SILENT :
549
+ .PHONY : verify-go-version
550
+ verify-go-version : # # Confirms the version of go used in Makefiles are uniform
551
+ ifeq ($(strip $(SUBMAKEFILE_GO_VERSION ) ) , $(strip $(GO_VERSION ) ) )
552
+ echo "Versions are uniform across Makefile, the go-version used is $(GO_VERSION)"
553
+ else
554
+ echo "Versions are different across Makefiles. Please ensure to keep them uniform."
555
+ endif
556
+
542
557
# # --------------------------------------
543
558
# # Cleanup / Verification
544
559
# # --------------------------------------
@@ -600,3 +615,23 @@ kind-cluster: ## Create a new kind cluster designed for development with Tilt
600
615
601
616
go-version : # # Print the go version we use to compile our binaries and images
602
617
@echo $(GO_VERSION )
618
+
619
+ # # --------------------------------------
620
+ # # Documentation and Publishing
621
+ # # --------------------------------------
622
+
623
+ .PHONY : serve
624
+ serve : # # Build the CAPIBM book and serve it locally to validate changes in documentation.
625
+ $(MAKE ) -C docs/book/ serve
626
+
627
+ # # --------------------------------------
628
+ # # Update Go Version
629
+ # # --------------------------------------
630
+ .PHONY : update-go
631
+ update-go : # # Update Go version across files: Usage make update-go VERSION=X.YY.ZZ- Use only if you know what you're doing.
632
+ ifndef VERSION
633
+ echo "VERSION not set. Usage: make update-go VERSION=X.YY.ZZ"
634
+ else
635
+ sed -i '' "s/GO_VERSION ?=[[:digit:]].[[:digit:]]\{1,\}.[[:digit:]]\{1,\}/GO_VERSION ?=$(VERSION)/" hack/ccm/Makefile
636
+ echo "Updated go version to $(VERSION) in Makefile"
637
+ endif
0 commit comments