Skip to content

Commit

Permalink
update golangci-lint to 1.48.0 (go 1.19 support) and fix linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Aug 11, 2022
1 parent 669468d commit 4b1e527
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 34 deletions.
7 changes: 4 additions & 3 deletions cache/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ func loadCredentials(opts *withCredentials) (grpc.DialOption, error) {
return nil, errors.Wrap(err, "could not read certificate/key")
}
cfg.Certificates = []tls.Certificate{cert}
cfg.BuildNameToCertificate()
}

return grpc.WithTransportCredentials(credentials.NewTLS(cfg)), nil
Expand Down
4 changes: 3 additions & 1 deletion frontend/dockerfile/instructions/bflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions frontend/dockerfile/instructions/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions frontend/dockerfile/parser/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
Expand Down
1 change: 0 additions & 1 deletion frontend/dockerfile/parser/line_parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion frontend/dockerfile/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hack/dockerfiles/lint.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.45.0
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 && \
Expand Down
8 changes: 4 additions & 4 deletions solver/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions util/archutil/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions util/gitutil/git_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4b1e527

Please sign in to comment.