Skip to content

Commit ea18e5b

Browse files
authored
Makefile command addition for go version update and add CAPI badge (#1522)
Update mdbook version and add target to sub-Makefile Update badges, align images Add make command to update go version across files Add verify-go-version target
1 parent da15d72 commit ea18e5b

File tree

7 files changed

+77
-14
lines changed

7 files changed

+77
-14
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# limitations under the License.
1616

1717
# Build the manager binary
18-
FROM --platform=${BUILDPLATFORM} golang:1.20.12 as toolchain
18+
ARG golang_image
19+
FROM --platform=${BUILDPLATFORM} ${golang_image} as toolchain
1920

2021
# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
2122
ARG goproxy=https://proxy.golang.org,direct

Makefile

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ ROOT_DIR_RELATIVE := .
1818

1919
include $(ROOT_DIR_RELATIVE)/common.mk
2020

21-
GO_VERSION ?= 1.20.12
22-
2321
# Image URL to use all building/pushing image targets
2422
IMG ?= controller:latest
2523
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
2624
CRD_OPTIONS ?= "crd:crdVersions=v1"
2725

26+
SHELL=/bin/bash
27+
2828
# Directories.
2929
REPO_ROOT := $(shell git rev-parse --show-toplevel)
3030
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
@@ -62,6 +62,10 @@ RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
6262
RELEASE_DIR := out
6363
OUTPUT_TYPE ?= type=registry
6464

65+
# Go
66+
GO_VERSION ?=1.20.12
67+
GO_CONTAINER_IMAGE ?= golang:$(GO_VERSION)
68+
6569
# kind
6670
CAPI_KIND_CLUSTER_NAME ?= capi-test
6771

@@ -281,7 +285,7 @@ $(ARTIFACTS):
281285

282286
.PHONY: build-toolchain
283287
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) .
285289

286290
.PHONY: list-staging-releases
287291
list-staging-releases: ## List staging images for image promotion
@@ -416,7 +420,7 @@ ensure-buildx:
416420

417421
.PHONY: docker-build
418422
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) .
420424

421425
.PHONY: docker-pull-prerequisites
422426
docker-pull-prerequisites:
@@ -425,7 +429,7 @@ docker-pull-prerequisites:
425429

426430
.PHONY: e2e-image
427431
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 .
429433
$(MAKE) set-manifest-image MANIFEST_IMG=$(CORE_CONTROLLER_ORIGINAL_IMG):e2e TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
430434
$(MAKE) set-manifest-pull-policy PULL_POLICY=Never TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
431435

@@ -451,8 +455,8 @@ docker-build-%:
451455

452456
.PHONY: docker-build-core-image
453457
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)" \
456460
-t $(CORE_CONTROLLER_IMG):$(TAG) .
457461

458462
## --------------------------------------
@@ -483,7 +487,7 @@ define checkdiff
483487
git --no-pager diff --name-only FETCH_HEAD
484488
endef
485489

486-
ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions
490+
ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions go-version
487491

488492
.PHONY: verify
489493
verify: $(addprefix verify-,$(ALL_VERIFY_CHECKS)) ## Run all verify-* targets
@@ -539,6 +543,17 @@ verify-security: ## Verify code and images for vulnerabilities
539543
exit 1; \
540544
fi
541545

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+
542557
## --------------------------------------
543558
## Cleanup / Verification
544559
## --------------------------------------
@@ -600,3 +615,23 @@ kind-cluster: ## Create a new kind cluster designed for development with Tilt
600615

601616
go-version: ## Print the go version we use to compile our binaries and images
602617
@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

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
[![LICENSE](https://img.shields.io/badge/license-apache2.0-green.svg)](https://sigs.k8s.io/cluster-api-provider-ibmcloud/blob/master/LICENSE)
2-
![GitHub release (latest by date)](https://img.shields.io/github/v/release/kubernetes-sigs/cluster-api-provider-ibmcloud?label=version)
3-
[![Go Report Card](https://goreportcard.com/badge/sigs.k8s.io/cluster-api-provider-ibmcloud)](https://goreportcard.com/report/sigs.k8s.io/cluster-api-provider-ibmcloud)
41

52
# Kubernetes Cluster API Provider IBM Cloud (CAPIBM)
63

4+
<p align="center">
75
<a href="https://github.com/kubernetes-sigs/cluster-api"><img src="https://github.com/kubernetes/kubernetes/raw/master/logo/logo.png" width="100"></a><a href="https://www.ibm.com/cloud/"><img hspace="90px" src="./docs/images/ibm-cloud.svg" alt="Powered by IBM Cloud" height="100"></a>
6+
</p>
7+
8+
<p align="center">
9+
<!-- Go Doc reference -->
10+
<a href="https://godoc.org/sigs.k8s.io/cluster-api-provider-ibmcloud">
11+
<img src="https://godoc.org/sigs.k8s.io/cluster-api-provider-ibmcloud?status.svg"></a>
12+
<!-- CAPIBM Version -->
13+
<a href="https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/releases/latest">
14+
<img src="https://img.shields.io/github/v/release/kubernetes-sigs/cluster-api-provider-ibmcloud?label=version"></a>
15+
<!-- Go Reportcard -->
16+
<a href="https://goreportcard.com/report/sigs.k8s.io/cluster-api-provider-ibmcloud">
17+
<img src="https://goreportcard.com/badge/sigs.k8s.io/cluster-api-provider-ibmcloud"></a>
18+
<!-- K8s - ClusterAPI Provider IBM Cloud slack channel -->
19+
<a href="http://slack.k8s.io/">
20+
<img src="https://img.shields.io/badge/join%20slack-%20%23cluster--api--ibmcloud-brightgreen"></a>
21+
<!-- License information -->
22+
<a href="https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/LICENSE">
23+
<img src="https://img.shields.io/badge/license-apache2.0-green.svg"></a>
24+
</p>
25+
826

927
------
1028

docs/book/theme/favicon.png

2.32 KB
Loading

hack/ccm/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ ARG TARGETPLATFORM=linux/amd64
1818
ARG ARCH=amd64
1919

2020
# Build IBM cloud controller manager binary
21-
FROM golang:1.20.12 AS ccm-builder
21+
ARG golang_image
22+
FROM ${golang_image} AS ccm-builder
2223
ARG ARCH
2324
ARG POWERVS_CLOUD_CONTROLLER_COMMIT
2425
WORKDIR /build

hack/ccm/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# Go
16+
GO_VERSION ?=1.20.12
17+
GO_CONTAINER_IMAGE ?= golang:$(GO_VERSION)
18+
1519
REGISTRY=gcr.io/k8s-staging-capi-ibmcloud
1620
IMG=powervs-cloud-controller-manager
1721

@@ -23,6 +27,7 @@ build-image-linux-amd64: init-buildx
2327
{ \
2428
set -e ; \
2529
docker buildx build \
30+
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
2631
--build-arg TARGETPLATFORM=linux/amd64 --build-arg ARCH=amd64 \
2732
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
2833
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 . --target centos-base; \
@@ -32,6 +37,7 @@ build-image-linux-ppc64le: init-buildx
3237
{ \
3338
set -e ; \
3439
docker buildx build \
40+
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
3541
--build-arg TARGETPLATFORM=linux/ppc64le --build-arg ARCH=ppc64le\
3642
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
3743
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le . --target centos-base; \
@@ -41,6 +47,7 @@ build-image-and-push-linux-amd64: init-buildx
4147
{ \
4248
set -e ; \
4349
docker buildx build \
50+
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
4451
--build-arg TARGETPLATFORM=linux/amd64 --build-arg ARCH=amd64 \
4552
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
4653
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 . --push --target centos-base; \
@@ -50,6 +57,7 @@ build-image-and-push-linux-ppc64le: init-buildx
5057
{ \
5158
set -e ; \
5259
docker buildx build \
60+
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
5361
--build-arg TARGETPLATFORM=linux/ppc64le --build-arg ARCH=ppc64le\
5462
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
5563
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le . --push --target centos-base; \

versions.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
MDBOOK_VERSION := v0.4.5
15+
MDBOOK_VERSION := v0.4.37

0 commit comments

Comments
 (0)