diff --git a/go.mod b/go.mod index b2f22c2d..5d63a5d8 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/hashicorp/hcl/v2 v2.20.1 github.com/in-toto/in-toto-golang v0.5.0 github.com/mitchellh/hashstructure/v2 v2.0.2 - github.com/moby/buildkit v0.16.0-rc2.0.20241008173032-de2f8b6c5d1c + github.com/moby/buildkit v0.17.0-rc1 github.com/moby/sys/mountinfo v0.7.2 github.com/moby/sys/signal v0.7.1 github.com/morikuni/aec v1.0.0 diff --git a/go.sum b/go.sum index cd45800c..d2a92f56 100644 --- a/go.sum +++ b/go.sum @@ -301,8 +301,8 @@ github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/z github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 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.16.0-rc2.0.20241008173032-de2f8b6c5d1c h1:tO15fW0keg5tOfOZnNqLaKZMOezT4bOerluvrq1VtMM= -github.com/moby/buildkit v0.16.0-rc2.0.20241008173032-de2f8b6c5d1c/go.mod h1:BprE7bOBNMZPwd3YR7iUmHdqt618BDvS49hZySzr5Mg= +github.com/moby/buildkit v0.17.0-rc1 h1:LTHa+CEoGZGWWEJcOEUj/5fv+6FPvMZTOD/KVEW4syA= +github.com/moby/buildkit v0.17.0-rc1/go.mod h1:BprE7bOBNMZPwd3YR7iUmHdqt618BDvS49hZySzr5Mg= 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/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go index 083b07d6..2a776aa8 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go @@ -165,4 +165,12 @@ var ( }, Experimental: true, } + RuleInvalidDefinitionDescription = LinterRule[func(string, string) string]{ + Name: "InvalidDefinitionDescription", + Description: "Comment for build stage or argument should follow the format: `# `. If this is not intended to be a description comment, add an empty line or comment between the instruction and the comment.", + URL: "https://docs.docker.com/go/dockerfile/rule/invalid-definition-description/", + Format: func(instruction, defName string) string { + return fmt.Sprintf("Comment for %s should follow the format: `# %s `", instruction, defName) + }, + } ) 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 c70236ff..740f03b7 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go @@ -167,16 +167,17 @@ func (d *directives) setEscapeToken(s string) error { // possibleParserDirective looks for parser directives, eg '# escapeToken='. // Parser directives must precede any builder instruction or other comments, -// and cannot be repeated. -func (d *directives) possibleParserDirective(line []byte) error { +// and cannot be repeated. Returns true if a parser directive was found. +func (d *directives) possibleParserDirective(line []byte) (bool, error) { directive, err := d.parser.ParseLine(line) if err != nil { - return err + return false, err } if directive != nil && directive.Name == keyEscape { - return d.setEscapeToken(directive.Value) + err := d.setEscapeToken(directive.Value) + return err == nil, err } - return nil + return directive != nil, nil } // newDefaultDirectives returns a new directives structure with the default escapeToken token @@ -300,7 +301,13 @@ func Parse(rwc io.Reader) (*Result, error) { comments = append(comments, comment) } } - bytesRead, err = processLine(d, bytesRead, true) + var directiveOk bool + bytesRead, directiveOk, err = processLine(d, bytesRead, true) + // If the line is a directive, strip it from the comments + // so it doesn't get added to the AST. + if directiveOk { + comments = comments[:len(comments)-1] + } if err != nil { return nil, withLocation(err, currentLine, 0) } @@ -316,7 +323,7 @@ func Parse(rwc io.Reader) (*Result, error) { var hasEmptyContinuationLine bool for !isEndOfLine && scanner.Scan() { - bytesRead, err := processLine(d, scanner.Bytes(), false) + bytesRead, _, err := processLine(d, scanner.Bytes(), false) if err != nil { return nil, withLocation(err, currentLine, 0) } @@ -527,12 +534,13 @@ func trimContinuationCharacter(line []byte, d *directives) ([]byte, bool) { // TODO: remove stripLeftWhitespace after deprecation period. It seems silly // to preserve whitespace on continuation lines. Why is that done? -func processLine(d *directives, token []byte, stripLeftWhitespace bool) ([]byte, error) { +func processLine(d *directives, token []byte, stripLeftWhitespace bool) ([]byte, bool, error) { token = trimNewline(token) if stripLeftWhitespace { token = trimLeadingWhitespace(token) } - return trimComments(token), d.possibleParserDirective(token) + directiveOk, err := d.possibleParserDirective(token) + return trimComments(token), directiveOk, err } // Variation of bufio.ScanLines that preserves the line endings diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go b/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go index 6583079f..615700f5 100644 --- a/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go +++ b/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go @@ -429,28 +429,21 @@ func (c *grpcClient) Solve(ctx context.Context, creq client.SolveRequest) (res * } case *pb.Result_RefsDeprecated: for k, v := range pbRes.RefsDeprecated.Refs { - ref := &reference{id: v, c: c} - if v == "" { - ref = nil + var ref client.Reference + if v != "" { + ref = &reference{id: v, c: c} } res.AddRef(k, ref) } case *pb.Result_Ref: if pbRes.Ref.Id != "" { - ref, err := newReference(c, pbRes.Ref) - if err != nil { - return nil, err - } - res.SetRef(ref) + res.SetRef(newReference(c, pbRes.Ref)) } case *pb.Result_Refs: for k, v := range pbRes.Refs.Refs { - var ref *reference + var ref client.Reference if v.Id != "" { - ref, err = newReference(c, v) - if err != nil { - return nil, err - } + ref = newReference(c, v) } res.AddRef(k, ref) } @@ -464,11 +457,7 @@ func (c *grpcClient) Solve(ctx context.Context, creq client.SolveRequest) (res * return nil, err } if a.Ref.Id != "" { - ref, err := newReference(c, a.Ref) - if err != nil { - return nil, err - } - att.Ref = ref + att.Ref = newReference(c, a.Ref) } res.AddAttestation(p, *att) } @@ -1168,8 +1157,8 @@ type reference struct { def *opspb.Definition } -func newReference(c *grpcClient, ref *pb.Ref) (*reference, error) { - return &reference{c: c, id: ref.Id, def: ref.Def}, nil +func newReference(c *grpcClient, ref *pb.Ref) *reference { + return &reference{c: c, id: ref.Id, def: ref.Def} } func (r *reference) ToState() (st llb.State, err error) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6db82cf6..3ee0f5ed 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -482,7 +482,7 @@ github.com/mitchellh/go-wordwrap github.com/mitchellh/hashstructure/v2 # github.com/mitchellh/mapstructure v1.5.0 ## explicit; go 1.14 -# github.com/moby/buildkit v0.16.0-rc2.0.20241008173032-de2f8b6c5d1c +# github.com/moby/buildkit v0.17.0-rc1 ## explicit; go 1.22.0 github.com/moby/buildkit/api/services/control github.com/moby/buildkit/api/types