diff --git a/go.mod b/go.mod index 4c3707248..61aa1a028 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/fsouza/go-dockerclient v1.12.0 github.com/hashicorp/go-multierror v1.1.1 github.com/mattn/go-shellwords v1.0.12 - github.com/moby/buildkit v0.21.1 + github.com/moby/buildkit v0.22.0 github.com/moby/sys/capability v0.4.0 github.com/moby/sys/userns v0.1.0 github.com/opencontainers/cgroups v0.0.2 @@ -111,7 +111,6 @@ require ( github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/go-archive v0.1.0 // indirect github.com/moby/patternmatcher v0.6.0 // indirect - github.com/moby/sys/atomicwriter v0.1.0 // indirect github.com/moby/sys/mountinfo v0.7.2 // indirect github.com/moby/sys/sequential v0.6.0 // indirect github.com/moby/sys/user v0.4.0 // indirect diff --git a/go.sum b/go.sum index 05824fb7c..c2ac5399b 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/disiqueira/gotree/v3 v3.0.2 h1:ik5iuLQQoufZBNPY518dXhiO5056hyNBIK9lWh github.com/disiqueira/gotree/v3 v3.0.2/go.mod h1:ZuyjE4+mUQZlbpkI24AmruZKhg3VHEgPLDY8Qk+uUu8= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v28.0.4+incompatible h1:pBJSJeNd9QeIWPjRcV91RVJihd/TXB77q1ef64XEu4A= -github.com/docker/cli v28.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k= +github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I= @@ -235,8 +235,8 @@ github.com/mistifyio/go-zfs/v3 v3.0.1 h1:YaoXgBePoMA12+S1u/ddkv+QqxcfiZK4prI6HPn github.com/mistifyio/go-zfs/v3 v3.0.1/go.mod h1:CzVgeB0RvF2EGzQnytKVvVSDwmKJXxkOTUGbNrTja/k= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/buildkit v0.21.1 h1:wTjVLfirh7skZt9piaIlNo8WdiPjza1CDl2EArDV9bA= -github.com/moby/buildkit v0.21.1/go.mod h1:mBq0D44uCyz2PdX8T/qym5LBbkBO3GGv0wqgX9ABYYw= +github.com/moby/buildkit v0.22.0 h1:aWN06w1YGSVN1XfeZbj2ZbgY+zi5xDAjEFI8Cy9fTjA= +github.com/moby/buildkit v0.22.0/go.mod h1:j4pP5hxiTWcz7xuTK2cyxQislHl/N2WWHzOy43DlLJw= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ= diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/errors.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/errors.go index 08a40c5d4..b3bcf2ae8 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/errors.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/errors.go @@ -5,14 +5,14 @@ import ( "github.com/pkg/errors" ) -// ErrorLocation gives a location in source code that caused the error -type ErrorLocation struct { +// LocationError gives a location in source code that caused the error +type LocationError struct { Locations [][]Range error } // Unwrap unwraps to the next error -func (e *ErrorLocation) Unwrap() error { +func (e *LocationError) Unwrap() error { return e.error } @@ -45,7 +45,7 @@ func setLocation(err error, location []Range, add bool) error { if err == nil { return nil } - var el *ErrorLocation + var el *LocationError if errors.As(err, &el) { if add { el.Locations = append(el.Locations, location) @@ -54,7 +54,7 @@ func setLocation(err error, location []Range, add bool) error { } return err } - return stack.Enable(&ErrorLocation{ + return stack.Enable(&LocationError{ error: err, Locations: [][]Range{location}, }) diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go index 104978164..eb86e73b4 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go @@ -318,7 +318,7 @@ func parseMaybeJSON(rest string, d *directives) (*Node, map[string]bool, error) if err == nil { return node, attrs, nil } - if err == errDockerfileNotStringArray { + if errors.Is(err, errDockerfileNotStringArray) { return nil, nil, err } @@ -336,7 +336,7 @@ func parseMaybeJSONToList(rest string, d *directives) (*Node, map[string]bool, e if err == nil { return node, attrs, nil } - if err == errDockerfileNotStringArray { + if errors.Is(err, errDockerfileNotStringArray) { return nil, nil, err } diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go index f1667a108..2f0da0222 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go @@ -114,7 +114,7 @@ type Heredoc struct { var ( dispatch map[string]func(string, *directives) (*Node, map[string]bool, error) reWhitespace = regexp.MustCompile(`[\t\v\f\r ]+`) - reHeredoc = regexp.MustCompile(`^(\d*)<<(-?)([^<]*)$`) + reHeredoc = regexp.MustCompile(`^(\d*)<<(-?)\s*([^<]*)$`) reLeadingTabs = regexp.MustCompile(`(?m)^\t+`) ) @@ -556,8 +556,8 @@ func scanLines(data []byte, atEOF bool) (advance int, token []byte, err error) { } func handleScannerError(err error) error { - switch err { - case bufio.ErrTooLong: + switch { + case errors.Is(err, bufio.ErrTooLong): return errors.Errorf("dockerfile line greater than max allowed size of %d", bufio.MaxScanTokenSize-1) default: return err diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go index 18da29334..b8a307a06 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go @@ -177,6 +177,7 @@ func (sw *shellWord) processStopOn(stopChar rune, rawEscapes bool) (string, []st // no need to initialize all the time var charFuncMapping = map[rune]func() (string, error){ '$': sw.processDollar, + '<': sw.processPossibleHeredoc, } if !sw.SkipProcessQuotes { charFuncMapping['\''] = sw.processSingleQuote @@ -512,6 +513,25 @@ func (sw *shellWord) processName() string { return name.String() } +func (sw *shellWord) processPossibleHeredoc() (string, error) { + sw.scanner.Next() + if sw.scanner.Peek() != '<' { + return "<", nil // not a heredoc + } + sw.scanner.Next() + + // heredoc might have whitespace between << and word terminator + var space bytes.Buffer + nextCh := sw.scanner.Peek() + for isWhitespace(nextCh) { + space.WriteRune(nextCh) + sw.scanner.Next() + nextCh = sw.scanner.Peek() + } + result := "<<" + space.String() + return result, nil +} + // isSpecialParam checks if the provided character is a special parameters, // as defined in http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_05_02 func isSpecialParam(char rune) bool { @@ -677,3 +697,11 @@ func trimSuffix(pattern, word string, greedy bool) (string, error) { } return reverseString(str), nil } + +func isWhitespace(r rune) bool { + switch r { + case '\t', '\r', ' ': + return true + } + return false +} diff --git a/vendor/github.com/moby/buildkit/util/stack/compress.go b/vendor/github.com/moby/buildkit/util/stack/compress.go index 6d9a78f34..e09ea1518 100644 --- a/vendor/github.com/moby/buildkit/util/stack/compress.go +++ b/vendor/github.com/moby/buildkit/util/stack/compress.go @@ -25,7 +25,7 @@ loop0: } // full match, potentially skip all if idx == len(st.Frames)-1 { - if st.Pid == prev.Pid && st.Version == prev.Version && slices.Compare(st.Cmdline, st.Cmdline) == 0 { + if st.Pid == prev.Pid && st.Version == prev.Version && slices.Equal(st.Cmdline, prev.Cmdline) { continue loop0 } } diff --git a/vendor/github.com/moby/buildkit/util/stack/stack.go b/vendor/github.com/moby/buildkit/util/stack/stack.go index 458a1a781..d9bacd410 100644 --- a/vendor/github.com/moby/buildkit/util/stack/stack.go +++ b/vendor/github.com/moby/buildkit/util/stack/stack.go @@ -50,7 +50,7 @@ func Traces(err error) []*Stack { func traces(err error) []*Stack { var st []*Stack - switch e := err.(type) { + switch e := err.(type) { //nolint:errorlint case interface{ Unwrap() error }: st = Traces(e.Unwrap()) case interface{ Unwrap() []error }: @@ -63,7 +63,7 @@ func traces(err error) []*Stack { } } - switch ste := err.(type) { + switch ste := err.(type) { //nolint:errorlint case interface{ StackTrace() errors.StackTrace }: st = append(st, convertStack(ste.StackTrace())) case interface{ StackTrace() *Stack }: @@ -85,7 +85,7 @@ func Enable(err error) error { } func Wrap(err error, s *Stack) error { - return &withStack{stack: s, error: err} + return &withStackError{stack: s, error: err} } func hasLocalStackTrace(err error) bool { @@ -173,15 +173,15 @@ func convertStack(s errors.StackTrace) *Stack { return &out } -type withStack struct { +type withStackError struct { stack *Stack error } -func (e *withStack) Unwrap() error { +func (e *withStackError) Unwrap() error { return e.error } -func (e *withStack) StackTrace() *Stack { +func (e *withStackError) StackTrace() *Stack { return e.stack } diff --git a/vendor/modules.txt b/vendor/modules.txt index 7f6c62f22..3bab878cd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -511,7 +511,7 @@ github.com/mistifyio/go-zfs/v3 # github.com/mitchellh/mapstructure v1.5.0 ## explicit; go 1.14 github.com/mitchellh/mapstructure -# github.com/moby/buildkit v0.21.1 +# github.com/moby/buildkit v0.22.0 ## explicit; go 1.23.0 github.com/moby/buildkit/frontend/dockerfile/command github.com/moby/buildkit/frontend/dockerfile/parser @@ -528,8 +528,6 @@ github.com/moby/go-archive/tarheader # github.com/moby/patternmatcher v0.6.0 ## explicit; go 1.19 github.com/moby/patternmatcher -# github.com/moby/sys/atomicwriter v0.1.0 -## explicit; go 1.18 # github.com/moby/sys/capability v0.4.0 ## explicit; go 1.21 github.com/moby/sys/capability