From 1353f411d9040365da6f8f1c653dae046cc02ded Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 11 Aug 2022 15:57:35 +0200 Subject: [PATCH 1/2] update to go 1.19 Signed-off-by: CrazyMax --- .github/workflows/build.yml | 3 ++- Dockerfile | 2 +- examples/buildkit0/buildkit.go | 2 +- examples/buildkit1/buildkit.go | 2 +- examples/buildkit2/buildkit.go | 2 +- examples/buildkit3/buildkit.go | 2 +- examples/buildkit4/buildkit.go | 2 +- examples/nested-llb/main.go | 2 +- frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile | 2 +- frontend/gateway/pb/gateway.pb.go | 2 ++ hack/dockerfiles/generated-files.Dockerfile | 2 +- hack/dockerfiles/lint.Dockerfile | 2 +- hack/dockerfiles/vendor.Dockerfile | 2 +- solver/errdefs/errdefs.pb.go | 1 + solver/pb/ops.pb.go | 3 +++ util/archutil/Dockerfile | 2 +- 16 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bca0fe9605a3..12335828afa7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,7 @@ env: CACHE_GHA_SCOPE_CROSS: "cross" TESTFLAGS: "-v --parallel=6 --timeout=30m" BUILDX_VERSION: "v0.8.2" # leave empty to use the one available on GitHub virtual environment + GO_VERSION: "1.19" jobs: base: @@ -170,7 +171,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: ${{ env.GO_VERSION }} - name: Cache Go modules uses: actions/cache@v2 diff --git a/Dockerfile b/Dockerfile index 186cc135440f..293070af477c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN apk add --no-cache git # xx is a helper for cross-compilation FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:1e96844fadaa2f9aea021b2b05299bc02fe4c39a92d8e735b93e8e2b15610128 AS xx -FROM --platform=$BUILDPLATFORM golang:1.18-alpine AS golatest +FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS golatest # gobuild is base stage for compiling go/cgo FROM golatest AS gobuild-base diff --git a/examples/buildkit0/buildkit.go b/examples/buildkit0/buildkit.go index 1a524347427d..24810e730ff5 100644 --- a/examples/buildkit0/buildkit.go +++ b/examples/buildkit0/buildkit.go @@ -33,7 +33,7 @@ func main() { } func goBuildBase() llb.State { - goAlpine := llb.Image("docker.io/library/golang:1.18-alpine") + goAlpine := llb.Image("docker.io/library/golang:1.19-alpine") return goAlpine. AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix). AddEnv("GOPATH", "/go"). diff --git a/examples/buildkit1/buildkit.go b/examples/buildkit1/buildkit.go index 9bbee5f84c21..9f8201b2bddf 100644 --- a/examples/buildkit1/buildkit.go +++ b/examples/buildkit1/buildkit.go @@ -33,7 +33,7 @@ func main() { } func goBuildBase() llb.State { - goAlpine := llb.Image("docker.io/library/golang:1.18-alpine") + goAlpine := llb.Image("docker.io/library/golang:1.19-alpine") return goAlpine. AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix). AddEnv("GOPATH", "/go"). diff --git a/examples/buildkit2/buildkit.go b/examples/buildkit2/buildkit.go index fed66079783f..5ae6b201678b 100644 --- a/examples/buildkit2/buildkit.go +++ b/examples/buildkit2/buildkit.go @@ -33,7 +33,7 @@ func main() { } func goBuildBase() llb.State { - goAlpine := llb.Image("docker.io/library/golang:1.18-alpine") + goAlpine := llb.Image("docker.io/library/golang:1.19-alpine") return goAlpine. AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix). AddEnv("GOPATH", "/go"). diff --git a/examples/buildkit3/buildkit.go b/examples/buildkit3/buildkit.go index ac1c18ecdc07..58de1ebe0666 100644 --- a/examples/buildkit3/buildkit.go +++ b/examples/buildkit3/buildkit.go @@ -34,7 +34,7 @@ func main() { } func goBuildBase() llb.State { - goAlpine := llb.Image("docker.io/library/golang:1.18-alpine") + goAlpine := llb.Image("docker.io/library/golang:1.19-alpine") return goAlpine. AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix). AddEnv("GOPATH", "/go"). diff --git a/examples/buildkit4/buildkit.go b/examples/buildkit4/buildkit.go index 399a7ac5a07e..0bae9e7899e8 100644 --- a/examples/buildkit4/buildkit.go +++ b/examples/buildkit4/buildkit.go @@ -37,7 +37,7 @@ func main() { } func goBuildBase() llb.State { - goAlpine := llb.Image("docker.io/library/golang:1.18-alpine") + goAlpine := llb.Image("docker.io/library/golang:1.19-alpine") return goAlpine. AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix). AddEnv("GOPATH", "/go"). diff --git a/examples/nested-llb/main.go b/examples/nested-llb/main.go index 180282e6eb19..93f9d41c2dcc 100644 --- a/examples/nested-llb/main.go +++ b/examples/nested-llb/main.go @@ -32,7 +32,7 @@ func main() { } func goBuildBase() llb.State { - goAlpine := llb.Image("docker.io/library/golang:1.18-alpine") + goAlpine := llb.Image("docker.io/library/golang:1.19-alpine") return goAlpine. AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnvUnix). AddEnv("GOPATH", "/go"). diff --git a/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile b/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile index 6c4428a06533..e71903902426 100644 --- a/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile +++ b/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile @@ -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.18-alpine AS base +FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS base RUN apk add git bash COPY --from=xx / / WORKDIR /src diff --git a/frontend/gateway/pb/gateway.pb.go b/frontend/gateway/pb/gateway.pb.go index 743ad2ec526d..40a62d86f21d 100644 --- a/frontend/gateway/pb/gateway.pb.go +++ b/frontend/gateway/pb/gateway.pb.go @@ -35,6 +35,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Result struct { // Types that are valid to be assigned to Result: + // // *Result_RefDeprecated // *Result_RefsDeprecated // *Result_Ref @@ -1678,6 +1679,7 @@ var xxx_messageInfo_ReleaseContainerResponse proto.InternalMessageInfo type ExecMessage struct { ProcessID string `protobuf:"bytes,1,opt,name=ProcessID,proto3" json:"ProcessID,omitempty"` // Types that are valid to be assigned to Input: + // // *ExecMessage_Init // *ExecMessage_File // *ExecMessage_Resize diff --git a/hack/dockerfiles/generated-files.Dockerfile b/hack/dockerfiles/generated-files.Dockerfile index 0bc0897e7ebc..4a98712c67a1 100644 --- a/hack/dockerfiles/generated-files.Dockerfile +++ b/hack/dockerfiles/generated-files.Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile-upstream:master # protoc is dynamically linked to glibc to can't use golang:1.10-alpine -FROM golang:1.18-buster AS gobuild-base +FROM golang:1.19-buster AS gobuild-base RUN apt-get update && apt-get --no-install-recommends install -y \ unzip \ diff --git a/hack/dockerfiles/lint.Dockerfile b/hack/dockerfiles/lint.Dockerfile index 5b7e0c158364..58803bd8b790 100644 --- a/hack/dockerfiles/lint.Dockerfile +++ b/hack/dockerfiles/lint.Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile-upstream:master -FROM golang:1.18-alpine +FROM golang:1.19-alpine ENV GOFLAGS="-buildvcs=false" 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.47.3 diff --git a/hack/dockerfiles/vendor.Dockerfile b/hack/dockerfiles/vendor.Dockerfile index 4387099d6895..4108aaaecf1b 100644 --- a/hack/dockerfiles/vendor.Dockerfile +++ b/hack/dockerfiles/vendor.Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile-upstream:master -FROM golang:1.18-alpine AS vendored +FROM golang:1.19-alpine AS vendored RUN apk add --no-cache git WORKDIR /src RUN --mount=target=/src,rw \ diff --git a/solver/errdefs/errdefs.pb.go b/solver/errdefs/errdefs.pb.go index 5da34b6e591b..e02cfb9696d8 100644 --- a/solver/errdefs/errdefs.pb.go +++ b/solver/errdefs/errdefs.pb.go @@ -186,6 +186,7 @@ type Solve struct { MountIDs []string `protobuf:"bytes,2,rep,name=mountIDs,proto3" json:"mountIDs,omitempty"` Op *pb.Op `protobuf:"bytes,3,opt,name=op,proto3" json:"op,omitempty"` // Types that are valid to be assigned to Subject: + // // *Solve_File // *Solve_Cache Subject isSolve_Subject `protobuf_oneof:"subject"` diff --git a/solver/pb/ops.pb.go b/solver/pb/ops.pb.go index 0cf15b077038..78e4121b47ee 100644 --- a/solver/pb/ops.pb.go +++ b/solver/pb/ops.pb.go @@ -154,6 +154,7 @@ type Op struct { // inputs is a set of input edges. Inputs []*Input `protobuf:"bytes,1,rep,name=inputs,proto3" json:"inputs,omitempty"` // Types that are valid to be assigned to Op: + // // *Op_Exec // *Op_Source // *Op_File @@ -1948,6 +1949,7 @@ type FileAction struct { SecondaryInput InputIndex `protobuf:"varint,2,opt,name=secondaryInput,proto3,customtype=InputIndex" json:"secondaryInput"` Output OutputIndex `protobuf:"varint,3,opt,name=output,proto3,customtype=OutputIndex" json:"output"` // Types that are valid to be assigned to Action: + // // *FileAction_Copy // *FileAction_Mkfile // *FileAction_Mkdir @@ -2465,6 +2467,7 @@ func (m *ChownOpt) GetGroup() *UserOpt { type UserOpt struct { // Types that are valid to be assigned to User: + // // *UserOpt_ByName // *UserOpt_ByID User isUserOpt_User `protobuf_oneof:"user"` diff --git a/util/archutil/Dockerfile b/util/archutil/Dockerfile index 985d980bf165..9f831b7bfd44 100644 --- a/util/archutil/Dockerfile +++ b/util/archutil/Dockerfile @@ -48,7 +48,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.18-alpine AS generate +FROM golang:1.19-alpine AS generate WORKDIR /src COPY --from=exit-amd64 /src/exit amd64 COPY --from=exit-386 /src/exit 386 From 4a15e742d8456d9978811bf1aa5d23ab43c76ab1 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 11 Aug 2022 13:02:56 +0200 Subject: [PATCH 2/2] update golangci-lint to 1.48.0 (go 1.19 support) and fix linting issues Signed-off-by: CrazyMax --- cache/refs.go | 7 ++++--- frontend/dockerfile/instructions/bflag.go | 4 +++- frontend/dockerfile/instructions/commands.go | 11 ----------- frontend/dockerfile/parser/json_test.go | 12 ++++++------ frontend/dockerfile/parser/line_parsers.go | 1 - frontend/dockerfile/parser/parser.go | 1 - hack/dockerfiles/lint.Dockerfile | 2 +- solver/edge.go | 8 ++++---- util/archutil/detect.go | 6 +++--- util/gitutil/git_ref.go | 4 ++-- 10 files changed, 23 insertions(+), 33 deletions(-) diff --git a/cache/refs.go b/cache/refs.go index 013a2804d96a..bbc38c481245 100644 --- a/cache/refs.go +++ b/cache/refs.go @@ -1590,9 +1590,10 @@ func (p sharableMountPool) setSharable(mounts snapshot.Mountable) snapshot.Mount // This is useful to share writable overlayfs mounts. // // NOTE: Mount() method doesn't return the underlying mount configuration (e.g. overlayfs mounts) -// instead it always return bind mounts of the temporary mount point. So if the caller -// needs to inspect the underlying mount configuration (e.g. for optimized differ for -// overlayfs), this wrapper shouldn't be used. +// +// instead it always return bind mounts of the temporary mount point. So if the caller +// needs to inspect the underlying mount configuration (e.g. for optimized differ for +// overlayfs), this wrapper shouldn't be used. type sharableMountable struct { snapshot.Mountable diff --git a/frontend/dockerfile/instructions/bflag.go b/frontend/dockerfile/instructions/bflag.go index 1cfbf760006a..c57a2d21391c 100644 --- a/frontend/dockerfile/instructions/bflag.go +++ b/frontend/dockerfile/instructions/bflag.go @@ -134,7 +134,9 @@ func (fl *Flag) IsTrue() bool { // compile time error so it doesn't matter too much when we stop our // processing as long as we do stop it, so this allows the code // around AddXXX() to be just: -// defFlag := AddString("description", "") +// +// defFlag := AddString("description", "") +// // w/o needing to add an if-statement around each one. func (bf *BFlags) Parse() error { // If there was an error while defining the possible flags diff --git a/frontend/dockerfile/instructions/commands.go b/frontend/dockerfile/instructions/commands.go index 284a1a0831bb..cbb111a235ed 100644 --- a/frontend/dockerfile/instructions/commands.go +++ b/frontend/dockerfile/instructions/commands.go @@ -157,7 +157,6 @@ func NewLabelCommand(k string, v string, NoExp bool) *LabelCommand { // LabelCommand : LABEL some json data describing the image // // Sets the Label variable foo to bar, -// type LabelCommand struct { withNameAndCode Labels KeyValuePairs // kvp slice instead of map to preserve ordering @@ -220,7 +219,6 @@ func (s *SourcesAndDest) ExpandRaw(expander SingleWordExpander) error { // // Add the file 'foo' to '/path'. Tarball and Remote URL (http, https) handling // exist here. If you do not wish to have this automatic handling, use COPY. -// type AddCommand struct { withNameAndCode SourcesAndDest @@ -244,7 +242,6 @@ func (c *AddCommand) Expand(expander SingleWordExpander) error { // CopyCommand : COPY foo /path // // Same as 'ADD' but without the tar and remote url handling. -// type CopyCommand struct { withNameAndCode SourcesAndDest @@ -274,7 +271,6 @@ type OnbuildCommand struct { // WorkdirCommand : WORKDIR /tmp // // Set the working directory for future RUN/CMD/etc statements. -// type WorkdirCommand struct { withNameAndCode Path string @@ -313,7 +309,6 @@ type ShellDependantCmdLine struct { // RUN echo hi # sh -c echo hi (Linux) // RUN echo hi # cmd /S /C echo hi (Windows) // RUN [ "echo", "hi" ] # echo hi -// type RunCommand struct { withNameAndCode withExternalData @@ -332,7 +327,6 @@ func (c *RunCommand) Expand(expander SingleWordExpander) error { // // Set the default command to run in the container (which may be empty). // Argument handling is the same as RUN. -// type CmdCommand struct { withNameAndCode ShellDependantCmdLine @@ -342,7 +336,6 @@ type CmdCommand struct { // // Set the default healthcheck command to run in the container (which may be empty). // Argument handling is the same as RUN. -// type HealthCheckCommand struct { withNameAndCode Health *container.HealthConfig @@ -355,7 +348,6 @@ type HealthCheckCommand struct { // // Handles command processing similar to CMD and RUN, only req.runConfig.Entrypoint // is initialized at newBuilder time instead of through argument parsing. -// type EntrypointCommand struct { withNameAndCode ShellDependantCmdLine @@ -365,7 +357,6 @@ type EntrypointCommand struct { // // Expose ports for links and port mappings. This all ends up in // req.runConfig.ExposedPorts for runconfig. -// type ExposeCommand struct { withNameAndCode Ports []string @@ -375,7 +366,6 @@ type ExposeCommand struct { // // Set the user to 'foo' for future commands and when running the // ENTRYPOINT/CMD at container run time. -// type UserCommand struct { withNameAndCode User string @@ -394,7 +384,6 @@ func (c *UserCommand) Expand(expander SingleWordExpander) error { // VolumeCommand : VOLUME /foo // // Expose the volume /foo for use. Will also accept the JSON array form. -// type VolumeCommand struct { withNameAndCode Volumes []string diff --git a/frontend/dockerfile/parser/json_test.go b/frontend/dockerfile/parser/json_test.go index 5ffd9bd2572d..d25804cd04d4 100644 --- a/frontend/dockerfile/parser/json_test.go +++ b/frontend/dockerfile/parser/json_test.go @@ -16,12 +16,12 @@ var invalidJSONArraysOfStrings = []string{ } var validJSONArraysOfStrings = map[string][]string{ - `[]`: {}, - `[""]`: {""}, - `["a"]`: {"a"}, - `["a","b"]`: {"a", "b"}, - `[ "a", "b" ]`: {"a", "b"}, - `[ "a", "b" ]`: {"a", "b"}, + `[]`: {}, + `[""]`: {""}, + `["a"]`: {"a"}, + `["a","b"]`: {"a", "b"}, + `[ "a", "b" ]`: {"a", "b"}, + `[ "a", "b" ]`: {"a", "b"}, ` [ "a", "b" ] `: {"a", "b"}, `["abc 123", "♥", "☃", "\" \\ \/ \b \f \n \r \t \u0000"]`: {"abc 123", "♥", "☃", "\" \\ / \b \f \n \r \t \u0000"}, } diff --git a/frontend/dockerfile/parser/line_parsers.go b/frontend/dockerfile/parser/line_parsers.go index c0d0a55d1224..2e3039f63e9a 100644 --- a/frontend/dockerfile/parser/line_parsers.go +++ b/frontend/dockerfile/parser/line_parsers.go @@ -34,7 +34,6 @@ func parseIgnore(rest string, d *directives) (*Node, map[string]bool, error) { // statement with sub-statements. // // ONBUILD RUN foo bar -> (onbuild (run foo bar)) -// func parseSubCommand(rest string, d *directives) (*Node, map[string]bool, error) { if rest == "" { return nil, nil, nil diff --git a/frontend/dockerfile/parser/parser.go b/frontend/dockerfile/parser/parser.go index 53165e0a481d..a9f6709d4d40 100644 --- a/frontend/dockerfile/parser/parser.go +++ b/frontend/dockerfile/parser/parser.go @@ -27,7 +27,6 @@ import ( // This data structure is frankly pretty lousy for handling complex languages, // but lucky for us the Dockerfile isn't very complicated. This structure // works a little more effectively than a "proper" parse tree for our needs. -// type Node struct { Value string // actual content Next *Node // the next item in the current sexp diff --git a/hack/dockerfiles/lint.Dockerfile b/hack/dockerfiles/lint.Dockerfile index 58803bd8b790..257a9e878196 100644 --- a/hack/dockerfiles/lint.Dockerfile +++ b/hack/dockerfiles/lint.Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.19-alpine ENV GOFLAGS="-buildvcs=false" 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.47.3 +RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.48.0 WORKDIR /go/src/github.com/moby/buildkit RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache \ GOARCH=amd64 golangci-lint run && \ diff --git a/solver/edge.go b/solver/edge.go index 8504d9f657d6..3493054d3e97 100644 --- a/solver/edge.go +++ b/solver/edge.go @@ -317,10 +317,10 @@ func (e *edge) skipPhase2FastCache(dep *dep) bool { // previous calls. // To avoid deadlocks and resource leaks this function needs to follow // following rules: -// 1) this function needs to return unclosed outgoing requests if some incoming -// requests were not completed -// 2) this function may not return outgoing requests if it has completed all -// incoming requests +// 1. this function needs to return unclosed outgoing requests if some incoming +// requests were not completed +// 2. this function may not return outgoing requests if it has completed all +// incoming requests func (e *edge) unpark(incoming []pipe.Sender, updates, allPipes []pipe.Receiver, f *pipeFactory) { // process all incoming changes depChanged := false diff --git a/util/archutil/detect.go b/util/archutil/detect.go index 44cb3133e1b6..837b05791a83 100644 --- a/util/archutil/detect.go +++ b/util/archutil/detect.go @@ -87,9 +87,9 @@ func SupportedPlatforms(noCache bool) []ocispecs.Platform { return arr } -//WarnIfUnsupported validates the platforms and show warning message if there is, -//the end user could fix the issue based on those warning, and thus no need to drop -//the platform from the candidates. +// WarnIfUnsupported validates the platforms and show warning message if there is, +// the end user could fix the issue based on those warning, and thus no need to drop +// the platform from the candidates. func WarnIfUnsupported(pfs []ocispecs.Platform) { def := nativePlatform() for _, p := range pfs { diff --git a/util/gitutil/git_ref.go b/util/gitutil/git_ref.go index 863691aeb123..05ae9a02ec0b 100644 --- a/util/gitutil/git_ref.go +++ b/util/gitutil/git_ref.go @@ -10,8 +10,8 @@ import ( // GitRef represents a git ref. // // Examples: -// - "https://github.com/foo/bar.git#baz/qux:quux/quuz" is parsed into: -// {Remote: "https://github.com/foo/bar.git", ShortName: "bar", Commit:"baz/qux", SubDir: "quux/quuz"}. +// - "https://github.com/foo/bar.git#baz/qux:quux/quuz" is parsed into: +// {Remote: "https://github.com/foo/bar.git", ShortName: "bar", Commit:"baz/qux", SubDir: "quux/quuz"}. type GitRef struct { // Remote is the remote repository path. Remote string