Merge pull request #48028 from tonistiigi/update-buildkit-v0.14.1

vendor: update buildkit to v0.14.1
This commit is contained in:
Sebastiaan van Stijn
2024-06-18 19:12:51 +02:00
committed by GitHub
10 changed files with 44 additions and 53 deletions

View File

@@ -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

View File

@@ -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=

View File

@@ -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)
}

View File

@@ -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)
}
}
}
}

View File

@@ -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)

View File

@@ -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)
},

View File

@@ -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:]
}

View File

@@ -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
}

View File

@@ -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 {

2
vendor/modules.txt vendored
View File

@@ -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