diff --git a/common/common.mk b/common/common.mk index addeccbc..3d490c12 100644 --- a/common/common.mk +++ b/common/common.mk @@ -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)