Skip to content

Commit

Permalink
Merge pull request #266 from thaJeztah/improve_golang_handling
Browse files Browse the repository at this point in the history
Makefile: allow GOVERSION to be passed, but being empty
  • Loading branch information
thaJeztah authored Feb 15, 2022
2 parents 123b569 + bf26309 commit 8d47786
Showing 1 changed file with 11 additions and 7 deletions.
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)

0 comments on commit 8d47786

Please sign in to comment.