Skip to content

Commit 3652d39

Browse files
committed
force GOTOOLCHAIN="go${GO_VERSION}" for now
TODO: look at using deprecating .go-version in favor of GOTOOLCHAIN existing knobs
1 parent 2b793f9 commit 3652d39

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ COMMIT_COUNT?=$(shell git describe --tags | rev | cut -d- -f2 | rev)
3333
# ========================= Setup Go With Gimme ================================
3434
# go version to use for build etc.
3535
# setup correct go version with gimme
36+
GOTOOLCHAIN:=$(shell . hack/build/gotoolchain.sh && echo "$${GOTOOLCHAIN}")
3637
PATH:=$(shell . hack/build/setup-go.sh && echo "$${PATH}")
3738
# go1.9+ can autodetect GOROOT, but if some other tool sets it ...
3839
GOROOT:=
3940
# enable modules
4041
GO111MODULE=on
4142
# disable CGO by default for static binaries
4243
CGO_ENABLED=0
43-
export PATH GOROOT GO111MODULE CGO_ENABLED
44+
export PATH GOROOT GO111MODULE CGO_ENABLED GOTOOLCHAIN
4445
# work around broken PATH export
4546
SPACE:=$(subst ,, )
4647
SHELL:=env PATH=$(subst $(SPACE),\$(SPACE),$(PATH)) $(SHELL)

hack/build/gotoolchain.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# Copyright 2020 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# script to set GOTOOLCHAIN as needed
17+
# MUST BE RUN FROM THE REPO ROOT DIRECTORY
18+
19+
# read go-version file unless GO_VERSION is set
20+
GO_VERSION="${GO_VERSION:-"$(cat .go-version)"}"
21+
22+
GOTOOLCHAIN="go${GO_VERSION}"
23+
export GOTOOLCHAIN GO_VERSION

hack/build/setup-go.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
# MUST BE RUN FROM THE REPO ROOT DIRECTORY
1818

1919
# read go-version file unless GO_VERSION is set
20-
GO_VERSION="${GO_VERSION:-"$(cat .go-version)"}"
20+
# override GOTOOLCHAIN unless set as well
21+
. ./hack/build/gotoolchain.sh
2122

2223
# we don't actually care where the .env files are
2324
# however, GIMME_SILENT_ENV doesn't trigger re-generating a .env if it

images/base/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ RUN dpkg --add-architecture arm64 && dpkg --add-architecture amd64 \
115115
# set by makefile to .go-version
116116
ARG GO_VERSION
117117
RUN eval "$(gimme "${GO_VERSION}")" \
118+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
118119
&& GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest
119120

120121

@@ -130,6 +131,7 @@ RUN git clone --filter=tree:0 "${CONTAINERD_CLONE_URL}" /containerd \
130131
&& cd /containerd \
131132
&& git checkout "${CONTAINERD_VERSION}" \
132133
&& eval "$(gimme "${GO_VERSION}")" \
134+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
133135
&& export GOARCH=$TARGETARCH && export CC=$(target-cc) && export CGO_ENABLED=1 \
134136
&& make bin/ctr bin/containerd bin/containerd-shim-runc-v2 \
135137
&& GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES \
@@ -144,6 +146,7 @@ RUN git clone --filter=tree:0 "${RUNC_CLONE_URL}" /runc \
144146
&& cd /runc \
145147
&& git checkout "${RUNC_VERSION}" \
146148
&& eval "$(gimme "${GO_VERSION}")" \
149+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
147150
&& export GOARCH=$TARGETARCH && export CC=$(target-cc) && export CGO_ENABLED=1 \
148151
&& make runc \
149152
&& GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES .
@@ -170,6 +173,7 @@ RUN git clone --filter=tree:0 "${CNI_PLUGINS_CLONE_URL}" /cni-plugins \
170173
&& cd /cni-plugins \
171174
&& git checkout "${CNI_PLUGINS_VERSION}" \
172175
&& eval "$(gimme "${GO_VERSION}")" \
176+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
173177
&& mkdir ./bin \
174178
&& export GOARCH=$TARGETARCH && export CC=$(target-cc) && export CGO_ENABLED=1 \
175179
&& go build -o ./bin/host-local -mod=vendor ./plugins/ipam/host-local \
@@ -190,6 +194,7 @@ RUN git clone --filter=tree:0 "${CONTAINERD_FUSE_OVERLAYFS_CLONE_URL}" /fuse-ove
190194
&& cd /fuse-overlayfs-snapshotter \
191195
&& git checkout "${CONTAINERD_FUSE_OVERLAYFS_VERSION}" \
192196
&& eval "$(gimme "${GO_VERSION}")" \
197+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
193198
&& export GOARCH=$TARGETARCH && export CC=$(target-cc) && export CGO_ENABLED=1 \
194199
&& make bin/containerd-fuse-overlayfs-grpc \
195200
&& GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES ./cmd/containerd-fuse-overlayfs-grpc

images/kindnetd/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ COPY go.mod go.sum ./
2222
# set by makefile to .go-version
2323
ARG GO_VERSION
2424
RUN eval "$(gimme "${GO_VERSION}")" \
25+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
2526
&& go mod download \
2627
&& GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest
2728
# build
2829
COPY . .
2930
ARG TARGETARCH
3031
RUN eval "$(gimme "${GO_VERSION}")" \
32+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
3133
&& CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o ./kindnetd ./cmd/kindnetd \
3234
&& GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES ./cmd/kindnetd
3335

images/local-path-provisioner/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ARG VERSION
2020
# set by makefile to .go-version
2121
ARG TARGETARCH GO_VERSION
2222
RUN eval "$(gimme "${GO_VERSION}")" \
23+
&& export GOTOOLCHAIN="go${GO_VERSION}" \
2324
&& cd local-path-provisioner \
2425
&& git fetch && git checkout "${VERSION}" \
2526
&& GOARCH=$TARGETARCH scripts/build \

0 commit comments

Comments
 (0)