From 8599213b52b426ab6b7a01c83772e8978d462604 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 18 Jun 2024 08:35:29 -0700 Subject: [PATCH] vendor: update buildkit to v0.14.1 Signed-off-by: Tonis Tiigi --- vendor.mod | 2 +- vendor.sum | 4 ++-- .../exporter/containerimage/export.go | 13 +--------- .../dockerfile/dockerfile2llb/convert.go | 24 +++++++------------ .../frontend/dockerfile/linter/linter.go | 8 +++++-- .../frontend/dockerfile/linter/ruleset.go | 12 ++-------- .../buildkit/frontend/dockerfile/shell/lex.go | 3 ++- .../frontend/subrequests/lint/lint.go | 8 +++---- .../moby/buildkit/util/resolver/resolver.go | 21 ++++++++++++---- vendor/modules.txt | 2 +- 10 files changed, 44 insertions(+), 53 deletions(-) diff --git a/vendor.mod b/vendor.mod index 856c348a2f..46ba590a5e 100644 --- a/vendor.mod +++ b/vendor.mod @@ -60,7 +60,7 @@ require ( github.com/miekg/dns v1.1.57 github.com/mistifyio/go-zfs/v3 v3.0.1 github.com/mitchellh/copystructure v1.2.0 - github.com/moby/buildkit v0.14.0 + github.com/moby/buildkit v0.14.1 github.com/moby/docker-image-spec v1.3.1 github.com/moby/ipvs v1.1.0 github.com/moby/locker v1.0.1 diff --git a/vendor.sum b/vendor.sum index fb37deb4e7..7cf00b8757 100644 --- a/vendor.sum +++ b/vendor.sum @@ -479,8 +479,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs= -github.com/moby/buildkit v0.14.0 h1:mHv2lFS8znLDRc4SMyM2B9tPjxWh2blMvr0H7ARquNM= -github.com/moby/buildkit v0.14.0/go.mod h1:1XssG7cAqv5Bz1xcGMxJL123iCv5TYN4Z/qf647gfuk= +github.com/moby/buildkit v0.14.1 h1:2epLCZTkn4CikdImtsLtIa++7DzCimrrZCT1sway+oI= +github.com/moby/buildkit v0.14.1/go.mod h1:1XssG7cAqv5Bz1xcGMxJL123iCv5TYN4Z/qf647gfuk= 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/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ= diff --git a/vendor/github.com/moby/buildkit/exporter/containerimage/export.go b/vendor/github.com/moby/buildkit/exporter/containerimage/export.go index 63cab282a3..199fd63cc4 100644 --- a/vendor/github.com/moby/buildkit/exporter/containerimage/export.go +++ b/vendor/github.com/moby/buildkit/exporter/containerimage/export.go @@ -339,18 +339,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source } } if e.push { - if opts.RewriteTimestamp { - annotations := map[digest.Digest]map[string]string{} - addAnnotations(annotations, *desc) - // e.pushImage cannot be used because src ref does not point to the rewritten image - // - // TODO: change e.pushImage so that it takes Result[Remote] as parameter. - // https://github.com/moby/buildkit/pull/4057#discussion_r1324106088 - err = push.Push(ctx, e.opt.SessionManager, sessionID, e.opt.ImageWriter.opt.ContentStore, e.opt.ImageWriter.ContentStore(), - desc.Digest, targetName, e.insecure, e.opt.RegistryHosts, e.pushByDigest, annotations) - } else { - err = e.pushImage(ctx, src, sessionID, targetName, desc.Digest) - } + err = e.pushImage(ctx, src, sessionID, targetName, desc.Digest) if err != nil { return nil, nil, errors.Wrapf(err, "failed to push %v", targetName) } diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go index 2ff6edb25f..0de62bc6dc 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go @@ -1035,6 +1035,7 @@ func (ds *dispatchState) init() { // the paths we use back to the base image. ds.paths = ds.base.paths ds.workdirSet = ds.base.workdirSet + ds.buildArgs = append(ds.buildArgs, ds.base.buildArgs...) } type dispatchStates struct { @@ -2163,22 +2164,15 @@ func validateCommandCasing(dockerfile *parser.Result, lint *linter.Linter) { // Here, we check both if the command is consistent per command (ie, "CMD" or "cmd", not "Cmd") // as well as ensuring that the casing is consistent throughout the dockerfile by comparing the // command to the casing of the majority of commands. - if !isSelfConsistentCasing(node.Value) { - msg := linter.RuleConsistentInstructionCasing.Format(node.Value) + var correctCasing string + if isMajorityLower && strings.ToLower(node.Value) != node.Value { + correctCasing = "lowercase" + } else if !isMajorityLower && strings.ToUpper(node.Value) != node.Value { + correctCasing = "uppercase" + } + if correctCasing != "" { + msg := linter.RuleConsistentInstructionCasing.Format(node.Value, correctCasing) lint.Run(&linter.RuleConsistentInstructionCasing, node.Location(), msg) - } else { - var msg string - var needsLintWarn bool - if isMajorityLower && strings.ToUpper(node.Value) == node.Value { - msg = linter.RuleFileConsistentCommandCasing.Format(node.Value, "lowercase") - needsLintWarn = true - } else if !isMajorityLower && strings.ToLower(node.Value) == node.Value { - msg = linter.RuleFileConsistentCommandCasing.Format(node.Value, "uppercase") - needsLintWarn = true - } - if needsLintWarn { - lint.Run(&linter.RuleFileConsistentCommandCasing, node.Location(), msg) - } } } } diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/linter.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/linter.go index bb33a14229..a8f9e0ad0f 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/linter.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/linter.go @@ -91,8 +91,12 @@ func (rule *LinterRule[F]) Run(warn LintWarnFunc, location []parser.Range, txt . warn(rule.Name, rule.Description, rule.URL, short, location) } -func LintFormatShort(rulename, msg string, startLine int) string { - return fmt.Sprintf("%s: %s (line %d)", rulename, msg, startLine) +func LintFormatShort(rulename, msg string, line int) string { + msg = fmt.Sprintf("%s: %s", rulename, msg) + if line > 0 { + msg = fmt.Sprintf("%s (line %d)", msg, line) + } + return msg } type LintWarnFunc func(rulename, description, url, fmtmsg string, location []parser.Range) 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 40b3b643cf..6c70c8ee0c 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go @@ -29,18 +29,10 @@ var ( return "Empty continuation line" }, } - RuleConsistentInstructionCasing = LinterRule[func(string) string]{ + RuleConsistentInstructionCasing = LinterRule[func(string, string) string]{ Name: "ConsistentInstructionCasing", - Description: "Instructions should be in consistent casing (all lower or all upper)", - URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/", - Format: func(command string) string { - return fmt.Sprintf("Command '%s' should be consistently cased", command) - }, - } - RuleFileConsistentCommandCasing = LinterRule[func(string, string) string]{ - Name: "FileConsistentCommandCasing", Description: "All commands within the Dockerfile should use the same casing (either upper or lower)", - URL: "https://docs.docker.com/go/dockerfile/rule/file-consistent-command-casing/", + URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/", Format: func(violatingCommand, correctCasing string) string { return fmt.Sprintf("Command '%s' should match the case of the command majority (%s)", violatingCommand, correctCasing) }, 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 306eb5e819..86df5b6c43 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go @@ -429,7 +429,8 @@ func (sw *shellWord) processDollar() (string, error) { case '%', '#': // %/# matches the shortest pattern expansion, %%/## the longest greedy := false - if word[0] == byte(ch) { + + if len(word) > 0 && word[0] == byte(ch) { greedy = true word = word[1:] } diff --git a/vendor/github.com/moby/buildkit/frontend/subrequests/lint/lint.go b/vendor/github.com/moby/buildkit/frontend/subrequests/lint/lint.go index 402a704b95..d207fba3c0 100644 --- a/vendor/github.com/moby/buildkit/frontend/subrequests/lint/lint.go +++ b/vendor/github.com/moby/buildkit/frontend/subrequests/lint/lint.go @@ -108,7 +108,7 @@ func (results *LintResults) ToResult() (*client.Result, error) { res.AddMeta("result.txt", b.Bytes()) status := 0 - if len(results.Warnings) > 0 { + if len(results.Warnings) > 0 || results.Error != nil { status = 1 } res.AddMeta("result.statuscode", []byte(fmt.Sprintf("%d", status))) @@ -169,11 +169,11 @@ func PrintLintViolations(dt []byte, w io.Writer) error { }) for _, warning := range results.Warnings { - fmt.Fprintf(w, "%s", warning.RuleName) + fmt.Fprintf(w, "\nWARNING: %s", warning.RuleName) if warning.URL != "" { fmt.Fprintf(w, " - %s", warning.URL) } - fmt.Fprintf(w, "\n%s\n", warning.Description) + fmt.Fprintf(w, "\n%s\n", warning.Detail) if warning.Location.SourceIndex < 0 { continue @@ -187,8 +187,8 @@ func PrintLintViolations(dt []byte, w io.Writer) error { if err != nil { return err } - fmt.Fprintln(w) } + return nil } diff --git a/vendor/github.com/moby/buildkit/util/resolver/resolver.go b/vendor/github.com/moby/buildkit/util/resolver/resolver.go index d6b7bc381e..77250bf0b8 100644 --- a/vendor/github.com/moby/buildkit/util/resolver/resolver.go +++ b/vendor/github.com/moby/buildkit/util/resolver/resolver.go @@ -10,6 +10,7 @@ import ( "path/filepath" "runtime" "strings" + "sync" "syscall" "time" @@ -213,13 +214,18 @@ func newDefaultTransport() *http.Transport { } type httpFallback struct { - super http.RoundTripper - host string + super http.RoundTripper + host string + hostMut sync.Mutex } func (f *httpFallback) RoundTrip(r *http.Request) (*http.Response, error) { - // only fall back if the same host had previously fell back - if f.host != r.URL.Host { + f.hostMut.Lock() + // Skip the HTTPS call only if the same host had previously fell back + tryHTTPSFirst := f.host != r.URL.Host + f.hostMut.Unlock() + + if tryHTTPSFirst { resp, err := f.super.RoundTrip(r) if !isTLSError(err) && !isPortError(err, r.URL.Host) { return resp, err @@ -232,8 +238,13 @@ func (f *httpFallback) RoundTrip(r *http.Request) (*http.Response, error) { plainHTTPRequest := *r plainHTTPRequest.URL = &plainHTTPUrl - if f.host != r.URL.Host { + // We tried HTTPS first but it failed. + // Mark the host so we don't try HTTPS for this host next time + // and refresh the request body. + if tryHTTPSFirst { + f.hostMut.Lock() f.host = r.URL.Host + f.hostMut.Unlock() // update body on the second attempt if r.Body != nil && r.GetBody != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index a08758e72f..83fcf09768 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -709,7 +709,7 @@ github.com/mitchellh/hashstructure/v2 # github.com/mitchellh/reflectwalk v1.0.2 ## explicit github.com/mitchellh/reflectwalk -# github.com/moby/buildkit v0.14.0 +# github.com/moby/buildkit v0.14.1 ## explicit; go 1.21 github.com/moby/buildkit/api/services/control github.com/moby/buildkit/api/types