update to go 1.16

This updates all occurrences of Go 1.13 to Go 1.16; also updated
the code that's used to redact credentials in URLs to use the Go
implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
v0.9
Sebastiaan van Stijn 2021-06-01 15:51:15 +02:00
parent 12cfc87450
commit 22dd74ae93
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
14 changed files with 47 additions and 28 deletions

View File

@ -169,7 +169,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.13
go-version: 1.16
-
name: Cache Go modules
uses: actions/cache@v2

View File

@ -22,10 +22,9 @@ RUN apk add --no-cache git
# xx is a helper for cross-compilation
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:810dc54d5144f133a218e88e319184bf8b9ce01d37d46ddb37573e90decd9eef AS xx
FROM --platform=$BUILDPLATFORM golang:1.13-alpine AS gostable
FROM --platform=$BUILDPLATFORM golang:1.16-alpine AS golatest
FROM gostable AS go-linux
FROM golatest AS go-linux
FROM golatest AS go-darwin
FROM golatest AS go-windows-amd64
FROM golatest AS go-windows-386
@ -51,7 +50,7 @@ WORKDIR $GOPATH/src/github.com/opencontainers/runc
ARG TARGETPLATFORM
# gcc is only installed for libgcc
# lld has issues building static binaries for ppc so prefer ld for it
RUN set -e; xx-apk add musl-dev gcc libseccomp-dev; \
RUN set -e; xx-apk add musl-dev gcc libseccomp-dev libseccomp-static; \
[ "$(xx-info arch)" != "ppc64le" ] || XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple
RUN --mount=from=runc-src,src=/usr/src/runc,target=. --mount=target=/root/.cache,type=cache \
CGO_ENABLED=1 xx-go build -mod=vendor -ldflags '-extldflags -static' -tags 'apparmor seccomp netgo cgo static_build osusergo' -o /usr/bin/runc ./ && \
@ -151,6 +150,7 @@ RUN --mount=from=containerd-src,src=/usr/src/containerd,readwrite --mount=target
# containerd v1.4 for integration tests
FROM containerd-base as containerd-alt
ARG CONTAINERD_ALT_VERSION
ARG GO111MODULE=off
RUN --mount=from=containerd-src,src=/usr/src/containerd,readwrite --mount=target=/root/.cache,type=cache \
git fetch origin \
&& git checkout -q "$CONTAINERD_ALT_VERSION" \

View File

@ -33,7 +33,7 @@ func main() {
}
func goBuildBase() llb.State {
goAlpine := llb.Image("docker.io/library/golang:1.13-alpine")
goAlpine := llb.Image("docker.io/library/golang:1.16-alpine")
return goAlpine.
AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix).
AddEnv("GOPATH", "/go").

View File

@ -33,7 +33,7 @@ func main() {
}
func goBuildBase() llb.State {
goAlpine := llb.Image("docker.io/library/golang:1.13-alpine")
goAlpine := llb.Image("docker.io/library/golang:1.16-alpine")
return goAlpine.
AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix).
AddEnv("GOPATH", "/go").

View File

@ -33,7 +33,7 @@ func main() {
}
func goBuildBase() llb.State {
goAlpine := llb.Image("docker.io/library/golang:1.13-alpine")
goAlpine := llb.Image("docker.io/library/golang:1.16-alpine")
return goAlpine.
AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix).
AddEnv("GOPATH", "/go").

View File

@ -34,7 +34,7 @@ func main() {
}
func goBuildBase() llb.State {
goAlpine := llb.Image("docker.io/library/golang:1.13-alpine")
goAlpine := llb.Image("docker.io/library/golang:1.16-alpine")
return goAlpine.
AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix).
AddEnv("GOPATH", "/go").

View File

@ -32,7 +32,7 @@ func main() {
}
func goBuildBase() llb.State {
goAlpine := llb.Image("docker.io/library/golang:1.13-alpine")
goAlpine := llb.Image("docker.io/library/golang:1.16-alpine")
return goAlpine.
AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix).
AddEnv("GOPATH", "/go").

View File

@ -3,7 +3,7 @@
# xx is a helper for cross-compilation
FROM --platform=$BUILDPLATFORM tonistiigi/xx:golang@sha256:810dc54d5144f133a218e88e319184bf8b9ce01d37d46ddb37573e90decd9eef AS xx
FROM --platform=$BUILDPLATFORM golang:1.13-alpine AS base
FROM --platform=$BUILDPLATFORM golang:1.16-alpine AS base
COPY --from=xx / /
WORKDIR /src
ENV GOFLAGS=-mod=vendor

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.2
# protoc is dynamically linked to glibc to can't use golang:1.10-alpine
FROM golang:1.13-buster AS gobuild-base
FROM golang:1.16-buster AS gobuild-base
# https://github.com/golang/protobuf/blob/v1.3.5/.travis.yml#L15
ARG PROTOC_VERSION=3.11.4
ARG GOGO_VERSION=v1.3.2

View File

@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.2
FROM golang:1.13-alpine
FROM golang:1.16-alpine
RUN apk add --no-cache gcc musl-dev yamllint
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.39.0
WORKDIR /go/src/github.com/moby/buildkit

View File

@ -1,5 +1,5 @@
# syntax = docker/dockerfile:1.2
FROM golang:1.13-alpine AS vendored
FROM golang:1.16-alpine AS vendored
RUN apk add --no-cache git
WORKDIR /src
RUN --mount=target=/src,rw \

View File

@ -1,3 +1,5 @@
// +build go1.15
package git
import "net/url"
@ -11,18 +13,5 @@ func redactCredentials(s string) string {
return s // string is not a URL, just return it
}
return urlRedacted(u)
}
// urlRedacted comes from go but isn't available under 1.13
func urlRedacted(u *url.URL) string {
if u == nil {
return ""
}
ru := *u
if _, has := ru.User.Password(); has {
ru.User = url.UserPassword(ru.User.Username(), "xxxxx")
}
return ru.String()
return u.Redacted()
}

View File

@ -0,0 +1,30 @@
// +build !go1.15
package git
import "net/url"
// redactCredentials takes a URL and redacts a password from it.
// e.g. "https://user:password@github.com/user/private-repo-failure.git" will be changed to
// "https://user:xxxxx@github.com/user/private-repo-failure.git"
func redactCredentials(s string) string {
u, err := url.Parse(s)
if err != nil {
return s // string is not a URL, just return it
}
return urlRedacted(u)
}
// urlRedacted comes from go's url.Redacted() which isn't available on go < 1.15
func urlRedacted(u *url.URL) string {
if u == nil {
return ""
}
ru := *u
if _, has := ru.User.Password(); has {
ru.User = url.UserPassword(ru.User.Username(), "xxxxx")
}
return ru.String()
}

View File

@ -49,7 +49,7 @@ FROM base AS exit-mips64
COPY fixtures/exit.mips64.s .
RUN mips64-linux-gnuabi64-as --noexecstack -o exit.o exit.mips64.s && mips64-linux-gnuabi64-ld -o exit -s exit.o
FROM golang:1.13-alpine AS generate
FROM golang:1.16-alpine AS generate
WORKDIR /src
COPY --from=exit-amd64 /src/exit amd64
COPY --from=exit-386 /src/exit 386