Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: allow GOVERSION to be passed, but being empty #266

Merged
merged 3 commits into from
Feb 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ RUNC_REMOTE ?=https://github.com/opencontainers/runc.git
REF?=HEAD

# Select the default version of Golang and runc based on the containerd source.
GOVERSION?=$(shell grep "ARG GOLANG_VERSION" src/github.com/containerd/containerd/contrib/Dockerfile.test | awk -F'=' '{print $$2}')
GOLANG_VERSION?=$(shell grep "ARG GOLANG_VERSION" src/github.com/containerd/containerd/contrib/Dockerfile.test | awk -F'=' '{print $$2}')

GOLANG_IMAGE=golang:$(GOVERSION)
ifeq ($(OS),Windows_NT)
GOLANG_IMAGE=docker.io/library/golang:$(GOVERSION)
else
GOLANG_IMAGE=docker.io/library/golang:$(GOVERSION)-buster
# Allow GOLANG_VERSION to be overridden through GOVERSION.
#
# We're using a separate variable for this to account for make being called as
# either `GOVERSION=x make foo` or `make GOVERSION=x foo`, while also accounting
# for `GOVERSION` to be an empty string (which may happen when triggered by some
# Jenkins jobs in our pipeline).
ifneq ($(strip $(GOVERSION)),)
GOLANG_VERSION=$(GOVERSION)
endif
GOARCH=$(shell docker run --rm $(GOLANG_IMAGE) go env GOARCH 2>/dev/null)

GOLANG_IMAGE=golang:$(GOLANG_VERSION)