From b68212fa455ca2797d3de3cc9fe197af2dd952cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Apr 2025 23:44:34 +0000 Subject: [PATCH] Bump github.com/moby/buildkit from 0.19.0 to 0.21.0 Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.19.0 to 0.21.0. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](https://github.com/moby/buildkit/compare/v0.19.0...v0.21.0) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 7 +- go.sum | 12 +- .../dockerfile/instructions/commands.go | 8 +- .../instructions/commands_rundevice.go | 118 ++++++++++++++++++ .../frontend/dockerfile/instructions/parse.go | 11 +- .../frontend/dockerfile/parser/directives.go | 16 +-- .../dockerfile/parser/line_parsers.go | 2 +- .../frontend/dockerfile/parser/parser.go | 2 +- .../dockerfile/parser/split_command.go | 10 +- .../image-spec/specs-go/version.go | 2 +- vendor/modules.txt | 6 +- 11 files changed, 156 insertions(+), 38 deletions(-) create mode 100644 vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_rundevice.go diff --git a/go.mod b/go.mod index 96bb27d7..302c8386 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,10 @@ module github.com/keilerkonzept/dockerfile-json go 1.23 - -toolchain go1.23.1 +toolchain go1.24.1 require ( - github.com/moby/buildkit v0.19.0 + github.com/moby/buildkit v0.21.0 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 ) @@ -16,7 +15,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/opencontainers/image-spec v1.1.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/tonistiigi/go-csvvalue v0.0.0-20240710180619-ddb21b71c0b4 // indirect diff --git a/go.sum b/go.sum index 22f8c5d4..a19e0aa4 100644 --- a/go.sum +++ b/go.sum @@ -8,18 +8,18 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/moby/buildkit v0.19.0 h1:w9G1p7sArvCGNkpWstAqJfRQTXBKukMyMK1bsah1HNo= -github.com/moby/buildkit v0.19.0/go.mod h1:WiHBFTgWV8eB1AmPxIWsAlKjUACAwm3X/14xOV4VWew= +github.com/moby/buildkit v0.21.0 h1:+z4vVqgt0spLrOSxi4DLedRbIh2gbNVlZ5q4rsnNp60= +github.com/moby/buildkit v0.21.0/go.mod h1:mBq0D44uCyz2PdX8T/qym5LBbkBO3GGv0wqgX9ABYYw= 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/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go index b194a97e..bebce636 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go @@ -551,16 +551,16 @@ func HasStage(s []Stage, name string) (int, bool) { } type withExternalData struct { - m map[interface{}]interface{} + m map[any]any } -func (c *withExternalData) getExternalValue(k interface{}) interface{} { +func (c *withExternalData) getExternalValue(k any) any { return c.m[k] } -func (c *withExternalData) setExternalValue(k, v interface{}) { +func (c *withExternalData) setExternalValue(k, v any) { if c.m == nil { - c.m = map[interface{}]interface{}{} + c.m = map[any]any{} } c.m[k] = v } diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_rundevice.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_rundevice.go new file mode 100644 index 00000000..693f28bd --- /dev/null +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_rundevice.go @@ -0,0 +1,118 @@ +package instructions + +import ( + "strconv" + "strings" + + "github.com/moby/buildkit/util/suggest" + "github.com/pkg/errors" + "github.com/tonistiigi/go-csvvalue" +) + +var devicesKey = "dockerfile/run/devices" + +func init() { + parseRunPreHooks = append(parseRunPreHooks, runDevicePreHook) + parseRunPostHooks = append(parseRunPostHooks, runDevicePostHook) +} + +func runDevicePreHook(cmd *RunCommand, req parseRequest) error { + st := &deviceState{} + st.flag = req.flags.AddStrings("device") + cmd.setExternalValue(devicesKey, st) + return nil +} + +func runDevicePostHook(cmd *RunCommand, req parseRequest) error { + return setDeviceState(cmd) +} + +func setDeviceState(cmd *RunCommand) error { + st := getDeviceState(cmd) + if st == nil { + return errors.Errorf("no device state") + } + devices := make([]*Device, len(st.flag.StringValues)) + for i, str := range st.flag.StringValues { + d, err := ParseDevice(str) + if err != nil { + return err + } + devices[i] = d + } + st.devices = devices + return nil +} + +func getDeviceState(cmd *RunCommand) *deviceState { + v := cmd.getExternalValue(devicesKey) + if v == nil { + return nil + } + return v.(*deviceState) +} + +func GetDevices(cmd *RunCommand) []*Device { + return getDeviceState(cmd).devices +} + +type deviceState struct { + flag *Flag + devices []*Device +} + +type Device struct { + Name string + Required bool +} + +func ParseDevice(val string) (*Device, error) { + fields, err := csvvalue.Fields(val, nil) + if err != nil { + return nil, errors.Wrap(err, "failed to parse csv devices") + } + + d := &Device{} + + for _, field := range fields { + key, value, ok := strings.Cut(field, "=") + key = strings.ToLower(key) + + if !ok { + switch key { + case "required": + d.Required = true + continue + default: + if d.Name == "" { + d.Name = field + continue + } + // any other option requires a value. + return nil, errors.Errorf("invalid field '%s' must be a key=value pair", field) + } + } + + switch key { + case "name": + if d.Name != "" { + return nil, errors.Errorf("device name already set to %s", d.Name) + } + d.Name = value + case "required": + d.Required, err = strconv.ParseBool(value) + if err != nil { + return nil, errors.Errorf("invalid value for %s: %s", key, value) + } + default: + if d.Name == "" { + d.Name = field + continue + } + allKeys := []string{"name", "required"} + return nil, suggest.WrapError(errors.Errorf("unexpected key '%s' in '%s'", key, field), key, allKeys, true) + } + } + + return d, nil +} diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go index 49c8817c..666b86bc 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go @@ -7,6 +7,7 @@ package instructions import ( "fmt" "regexp" + "slices" "sort" "strconv" "strings" @@ -66,12 +67,12 @@ func newParseRequestFromNode(node *parser.Node) parseRequest { } } -func ParseInstruction(node *parser.Node) (v interface{}, err error) { +func ParseInstruction(node *parser.Node) (v any, err error) { return ParseInstructionWithLinter(node, nil) } // ParseInstruction converts an AST to a typed instruction (either a command or a build stage beginning when encountering a `FROM` statement) -func ParseInstructionWithLinter(node *parser.Node, lint *linter.Linter) (v interface{}, err error) { +func ParseInstructionWithLinter(node *parser.Node, lint *linter.Linter) (v any, err error) { defer func() { if err != nil { err = parser.WithLocation(err, node.Location()) @@ -880,10 +881,8 @@ func validateDefinitionDescription(instruction string, argKeys []string, descCom return } descCommentParts := strings.Split(descComments[len(descComments)-1], " ") - for _, key := range argKeys { - if key == descCommentParts[0] { - return - } + if slices.Contains(argKeys, descCommentParts[0]) { + return } exampleKey := argKeys[0] if len(argKeys) > 1 { diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/directives.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/directives.go index 4f1e1300..b757e754 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/directives.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/directives.go @@ -148,14 +148,16 @@ func parseDirective(key string, dt []byte, anyFormat bool) (string, string, []Ra } // use json directive, and search for { "key": "..." } - jsonDirective := map[string]string{} + jsonDirective := map[string]any{} if err := json.Unmarshal(dt, &jsonDirective); err == nil { - if v, ok := jsonDirective[key]; ok { - loc := []Range{{ - Start: Position{Line: line}, - End: Position{Line: line}, - }} - return v, v, loc, true + if vAny, ok := jsonDirective[key]; ok { + if v, ok := vAny.(string); ok { + loc := []Range{{ + Start: Position{Line: line}, + End: Position{Line: line}, + }} + return v, v, loc, true + } } } 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 f8d891c7..10497816 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 @@ -281,7 +281,7 @@ func parseJSON(rest string) (*Node, map[string]bool, error) { return nil, nil, errDockerfileNotJSONArray } - var myJSON []interface{} + var myJSON []any if err := json.Unmarshal([]byte(rest), &myJSON); err != nil { 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 1b0a9622..f1667a10 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go @@ -220,7 +220,7 @@ func init() { // based on the command and command arguments. A Node is created from the // result of the dispatch. func newNodeFromLine(line string, d *directives, comments []string) (*Node, error) { - cmd, flags, args, err := splitCommand(line) + cmd, flags, args, err := splitCommand(line, d) if err != nil { return nil, err } diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/split_command.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/split_command.go index d1c87522..87b73f24 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/split_command.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/split_command.go @@ -7,7 +7,7 @@ import ( // splitCommand takes a single line of text and parses out the cmd and args, // which are used for dispatching to more exact parsing functions. -func splitCommand(line string) (string, []string, string, error) { +func splitCommand(line string, d *directives) (string, []string, string, error) { var args string var flags []string @@ -16,7 +16,7 @@ func splitCommand(line string) (string, []string, string, error) { if len(cmdline) == 2 { var err error - args, flags, err = extractBuilderFlags(cmdline[1]) + args, flags, err = extractBuilderFlags(cmdline[1], d) if err != nil { return "", nil, "", err } @@ -25,7 +25,7 @@ func splitCommand(line string) (string, []string, string, error) { return cmdline[0], flags, strings.TrimSpace(args), nil } -func extractBuilderFlags(line string) (string, []string, error) { +func extractBuilderFlags(line string, d *directives) (string, []string, error) { // Parses the BuilderFlags and returns the remaining part of the line const ( @@ -87,7 +87,7 @@ func extractBuilderFlags(line string) (string, []string, error) { phase = inQuote continue } - if ch == '\\' { + if ch == d.escapeToken { if pos+1 == len(line) { continue // just skip \ at end } @@ -104,7 +104,7 @@ func extractBuilderFlags(line string) (string, []string, error) { phase = inWord continue } - if ch == '\\' { + if ch == d.escapeToken { if pos+1 == len(line) { phase = inWord continue // just skip \ at end diff --git a/vendor/github.com/opencontainers/image-spec/specs-go/version.go b/vendor/github.com/opencontainers/image-spec/specs-go/version.go index 7069ae44..c3897c7c 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/version.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/version.go @@ -22,7 +22,7 @@ const ( // VersionMinor is for functionality in a backwards-compatible manner VersionMinor = 1 // VersionPatch is for backwards-compatible bug fixes - VersionPatch = 0 + VersionPatch = 1 // VersionDev indicates development branch. Releases will be empty string. VersionDev = "" diff --git a/vendor/modules.txt b/vendor/modules.txt index f566edea..ac44e40d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,8 +10,8 @@ github.com/docker/go-units # github.com/gogo/protobuf v1.3.2 ## explicit; go 1.15 github.com/gogo/protobuf/proto -# github.com/moby/buildkit v0.19.0 -## explicit; go 1.22.0 +# github.com/moby/buildkit v0.21.0 +## explicit; go 1.23.0 github.com/moby/buildkit/frontend/dockerfile/command github.com/moby/buildkit/frontend/dockerfile/instructions github.com/moby/buildkit/frontend/dockerfile/linter @@ -25,7 +25,7 @@ github.com/moby/docker-image-spec/specs-go/v1 # github.com/opencontainers/go-digest v1.0.0 ## explicit; go 1.13 github.com/opencontainers/go-digest -# github.com/opencontainers/image-spec v1.1.0 +# github.com/opencontainers/image-spec v1.1.1 ## explicit; go 1.18 github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go/v1