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
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 committed Feb 7, 2024
1 parent d027371 commit a3c3ce2
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ARG GO_VERSION=1.20.12

# Build the manager binary
FROM --platform=${BUILDPLATFORM} golang:1.20.12 as toolchain
FROM --platform=${BUILDPLATFORM} golang:$GO_VERSION 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
38 changes: 33 additions & 5 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 @@ -56,7 +56,7 @@ STAGING_BUCKET ?= artifacts.k8s-staging-capi-ibmcloud.appspot.com
BUCKET ?= $(STAGING_BUCKET)
PROD_REGISTRY := registry.k8s.io/capi-ibmcloud
REGISTRY ?= $(STAGING_REGISTRY)
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
RELEASE_TAG ?= $(shell git describe --always --abbrev=0 2>/dev/null)
PULL_BASE_REF ?= $(RELEASE_TAG) # PULL_BASE_REF will be provided by Prow
RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
RELEASE_DIR := out
Expand Down Expand Up @@ -88,6 +88,9 @@ CORE_MANIFEST_FILE := infrastructure-components
CORE_CONFIG_DIR := config/default
CORE_NAMESPACE := capi-ibmcloud-system

# List of space-separated files whose Go-version needs to be uniform.
DOCKERFILES="Dockerfile hack/ccm/Dockerfile"

PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -483,7 +486,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 +542,15 @@ verify-security: ## Verify code and images for vulnerabilities
exit 1; \
fi

.SILENT:
.PHONY: verify-go-version
verify-go-version: ## Confirms the version of go used in Dockerfiles are uniform
grep "ARG GO_VERSION=" $$(echo ${DOCKERFILES} | tr -d '"') | cut -d '=' -f2 | uniq -c |\
if [[ $$(wc -l) -eq 1 ]]; then \
$(MAKE) go-version | xargs echo "Versions are uniform across Dockerfiles, the go-version used is";\
else \
echo "Versions are different across Dockerfiles, please use 'make update-go-version'";\
fi
## --------------------------------------
## Cleanup / Verification
## --------------------------------------
Expand Down Expand Up @@ -599,4 +611,20 @@ kind-cluster: ## Create a new kind cluster designed for development with Tilt
##@ helpers:

go-version: ## Print the go version we use to compile our binaries and images
@echo $(GO_VERSION)
@grep -m 1 "GO_VERSION=" Dockerfile | cut -d '=' -f2

## --------------------------------------
## 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-version VERSION=X.YY.ZZ
echo ${DOCKERFILES} | xargs sed -i '' "s/ARG GO_VERSION=[[:digit:]].[[:digit:]]\{1,\}.[[:digit:]]\{1,\}/ARG GO_VERSION=$(VERSION)/"
echo "Updated go version to $(VERSION) across $(DOCKERFILES)"
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 @@ -16,9 +16,10 @@

ARG TARGETPLATFORM=linux/amd64
ARG ARCH=amd64
ARG GO_VERSION=1.20.12

# Build IBM cloud controller manager binary
FROM golang:1.20.12 AS ccm-builder
FROM golang:$GO_VERSION AS ccm-builder
ARG ARCH
ARG POWERVS_CLOUD_CONTROLLER_COMMIT
WORKDIR /build
Expand Down
4 changes: 2 additions & 2 deletions hack/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ version::get_version_vars() {

# stolen from k8s.io/hack/lib/version.sh
# Use git describe to find the version based on annotated tags.
if GIT_VERSION=$(git describe --abbrev=14 --match "v[0-9]*" 2>/dev/null); then
if GIT_VERSION=$(git describe --always --abbrev=14 --match "v[0-9]*" 2>/dev/null); then
# This translates the "git describe" to an actual semver.org
# compatible semantic version that looks something like this:
# v1.1.0-alpha.0.6+84c76d1142ea4d
Expand Down Expand Up @@ -71,7 +71,7 @@ version::get_version_vars() {
fi
fi

GIT_RELEASE_TAG=$(git describe --abbrev=0 --tags)
GIT_RELEASE_TAG=$(git describe --always --abbrev=0 --tags)
GIT_RELEASE_COMMIT=$(git rev-list -n 1 "${GIT_RELEASE_TAG}")
}

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 a3c3ce2

Please sign in to comment.