Skip to content

Commit

Permalink
Makefile command addition for go version update and add CAPI badge (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
kishen-v authored Feb 9, 2024
1 parent da15d72 commit ea18e5b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# limitations under the License.

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

# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
ARG goproxy=https://proxy.golang.org,direct
Expand Down
51 changes: 43 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ ROOT_DIR_RELATIVE := .

include $(ROOT_DIR_RELATIVE)/common.mk

GO_VERSION ?= 1.20.12

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:crdVersions=v1"

SHELL=/bin/bash

# Directories.
REPO_ROOT := $(shell git rev-parse --show-toplevel)
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
Expand Down Expand Up @@ -62,6 +62,10 @@ RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
RELEASE_DIR := out
OUTPUT_TYPE ?= type=registry

# Go
GO_VERSION ?=1.20.12
GO_CONTAINER_IMAGE ?= golang:$(GO_VERSION)

# kind
CAPI_KIND_CLUSTER_NAME ?= capi-test

Expand Down Expand Up @@ -281,7 +285,7 @@ $(ARTIFACTS):

.PHONY: build-toolchain
build-toolchain: ## Build the toolchain
docker build --target toolchain -t $(TOOLCHAIN_IMAGE) .
docker build --target toolchain --build-arg golang_image=$(GO_CONTAINER_IMAGE) -t $(TOOLCHAIN_IMAGE) .

.PHONY: list-staging-releases
list-staging-releases: ## List staging images for image promotion
Expand Down Expand Up @@ -416,7 +420,7 @@ ensure-buildx:

.PHONY: docker-build
docker-build: docker-pull-prerequisites ensure-buildx ## Build the docker image for controller-manager
docker buildx build --platform linux/$(ARCH) --output=$(OUTPUT_TYPE) --pull --build-arg LDFLAGS="$(LDFLAGS)" -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG) .
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) .

.PHONY: docker-pull-prerequisites
docker-pull-prerequisites:
Expand All @@ -425,7 +429,7 @@ docker-pull-prerequisites:

.PHONY: e2e-image
e2e-image: docker-pull-prerequisites ensure-buildx
docker buildx build --platform linux/$(ARCH) --load --tag=$(CORE_CONTROLLER_ORIGINAL_IMG):e2e .
docker buildx build --platform linux/$(ARCH) --load --build-arg golang_image=$(GO_CONTAINER_IMAGE) --tag=$(CORE_CONTROLLER_ORIGINAL_IMG):e2e .
$(MAKE) set-manifest-image MANIFEST_IMG=$(CORE_CONTROLLER_ORIGINAL_IMG):e2e TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy PULL_POLICY=Never TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"

Expand All @@ -451,8 +455,8 @@ docker-build-%:

.PHONY: docker-build-core-image
docker-build-core-image: ensure-buildx ## Build the multiarch core docker image
docker buildx build --builder capibm --platform $(BUILDX_PLATFORMS) --output=$(OUTPUT_TYPE) \
--pull --build-arg ldflags="$(LDFLAGS)" \
docker buildx build --builder capibm --platform $(BUILDX_PLATFORMS) --output=$(OUTPUT_TYPE) \
--pull --build-arg golang_image=$(GO_CONTAINER_IMAGE) --build-arg ldflags="$(LDFLAGS)" \
-t $(CORE_CONTROLLER_IMG):$(TAG) .

## --------------------------------------
Expand Down Expand Up @@ -483,7 +487,7 @@ define checkdiff
git --no-pager diff --name-only FETCH_HEAD
endef

ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions
ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions go-version

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


SUBMAKEFILE_GO_VERSION=$(shell grep "GO_VERSION" -m1 hack/ccm/Makefile | cut -d '=' -f2 )
.SILENT:
.PHONY: verify-go-version
verify-go-version: ## Confirms the version of go used in Makefiles are uniform
ifeq ($(strip $(SUBMAKEFILE_GO_VERSION)), $(strip $(GO_VERSION)))
echo "Versions are uniform across Makefile, the go-version used is $(GO_VERSION)"
else
echo "Versions are different across Makefiles. Please ensure to keep them uniform."
endif

## --------------------------------------
## Cleanup / Verification
## --------------------------------------
Expand Down Expand Up @@ -600,3 +615,23 @@ kind-cluster: ## Create a new kind cluster designed for development with Tilt

go-version: ## Print the go version we use to compile our binaries and images
@echo $(GO_VERSION)

## --------------------------------------
## Documentation and Publishing
## --------------------------------------

.PHONY: serve
serve: ## Build the CAPIBM book and serve it locally to validate changes in documentation.
$(MAKE) -C docs/book/ serve

## --------------------------------------
## Update Go Version
## --------------------------------------
.PHONY: update-go
update-go: ## Update Go version across files: Usage make update-go VERSION=X.YY.ZZ- Use only if you know what you're doing.
ifndef VERSION
echo "VERSION not set. Usage: make update-go VERSION=X.YY.ZZ"
else
sed -i '' "s/GO_VERSION ?=[[:digit:]].[[:digit:]]\{1,\}.[[:digit:]]\{1,\}/GO_VERSION ?=$(VERSION)/" hack/ccm/Makefile
echo "Updated go version to $(VERSION) in Makefile"
endif
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
[![LICENSE](https://img.shields.io/badge/license-apache2.0-green.svg)](https://sigs.k8s.io/cluster-api-provider-ibmcloud/blob/master/LICENSE)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/kubernetes-sigs/cluster-api-provider-ibmcloud?label=version)
[![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)

# Kubernetes Cluster API Provider IBM Cloud (CAPIBM)

<p align="center">
<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>
</p>

<p align="center">
<!-- Go Doc reference -->
<a href="https://godoc.org/sigs.k8s.io/cluster-api-provider-ibmcloud">
<img src="https://godoc.org/sigs.k8s.io/cluster-api-provider-ibmcloud?status.svg"></a>
<!-- CAPIBM Version -->
<a href="https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/releases/latest">
<img src="https://img.shields.io/github/v/release/kubernetes-sigs/cluster-api-provider-ibmcloud?label=version"></a>
<!-- Go Reportcard -->
<a href="https://goreportcard.com/report/sigs.k8s.io/cluster-api-provider-ibmcloud">
<img src="https://goreportcard.com/badge/sigs.k8s.io/cluster-api-provider-ibmcloud"></a>
<!-- K8s - ClusterAPI Provider IBM Cloud slack channel -->
<a href="http://slack.k8s.io/">
<img src="https://img.shields.io/badge/join%20slack-%20%23cluster--api--ibmcloud-brightgreen"></a>
<!-- License information -->
<a href="https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/LICENSE">
<img src="https://img.shields.io/badge/license-apache2.0-green.svg"></a>
</p>


------

Expand Down
Binary file added docs/book/theme/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion hack/ccm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ ARG TARGETPLATFORM=linux/amd64
ARG ARCH=amd64

# Build IBM cloud controller manager binary
FROM golang:1.20.12 AS ccm-builder
ARG golang_image
FROM ${golang_image} AS ccm-builder
ARG ARCH
ARG POWERVS_CLOUD_CONTROLLER_COMMIT
WORKDIR /build
Expand Down
8 changes: 8 additions & 0 deletions hack/ccm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Go
GO_VERSION ?=1.20.12
GO_CONTAINER_IMAGE ?= golang:$(GO_VERSION)

REGISTRY=gcr.io/k8s-staging-capi-ibmcloud
IMG=powervs-cloud-controller-manager

Expand All @@ -23,6 +27,7 @@ build-image-linux-amd64: init-buildx
{ \
set -e ; \
docker buildx build \
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
--build-arg TARGETPLATFORM=linux/amd64 --build-arg ARCH=amd64 \
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 . --target centos-base; \
Expand All @@ -32,6 +37,7 @@ build-image-linux-ppc64le: init-buildx
{ \
set -e ; \
docker buildx build \
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
--build-arg TARGETPLATFORM=linux/ppc64le --build-arg ARCH=ppc64le\
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le . --target centos-base; \
Expand All @@ -41,6 +47,7 @@ build-image-and-push-linux-amd64: init-buildx
{ \
set -e ; \
docker buildx build \
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
--build-arg TARGETPLATFORM=linux/amd64 --build-arg ARCH=amd64 \
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 . --push --target centos-base; \
Expand All @@ -50,6 +57,7 @@ build-image-and-push-linux-ppc64le: init-buildx
{ \
set -e ; \
docker buildx build \
--build-arg golang_image=$(GO_CONTAINER_IMAGE)\
--build-arg TARGETPLATFORM=linux/ppc64le --build-arg ARCH=ppc64le\
--build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le . --push --target centos-base; \
Expand Down
2 changes: 1 addition & 1 deletion versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

MDBOOK_VERSION := v0.4.5
MDBOOK_VERSION := v0.4.37

0 comments on commit ea18e5b

Please sign in to comment.