From da301d43678a7fec719a5f4c7182c563203c9b4d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 11 Aug 2022 13:02:56 +0200 Subject: [PATCH] update golangci-lint to 1.48.0 (go 1.19 support) and fix linting issues Signed-off-by: CrazyMax (cherry picked from commit 4a15e742d8456d9978811bf1aa5d23ab43c76ab1) Signed-off-by: Sebastiaan van Stijn --- 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 +++--- 9 files changed, 21 insertions(+), 31 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 48ebf183a965..df040e35f7da 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 @@ -243,7 +241,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 @@ -273,7 +270,6 @@ type OnbuildCommand struct { // WorkdirCommand : WORKDIR /tmp // // Set the working directory for future RUN/CMD/etc statements. -// type WorkdirCommand struct { withNameAndCode Path string @@ -312,7 +308,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 @@ -331,7 +326,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 @@ -341,7 +335,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 @@ -354,7 +347,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 @@ -364,7 +356,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 @@ -374,7 +365,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 @@ -393,7 +383,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 {