Skip to content

Commit 0741dca

Browse files
authored
Merge pull request #6507 from thaJeztah/toml_v2
migrate to github.com/pelletier/go-toml/v2
2 parents e07b5ed + 6f97c96 commit 0741dca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+7611
-5779
lines changed

cmd/buildkitd/config/load.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ import (
44
"io"
55
"os"
66

7-
"github.com/pelletier/go-toml"
7+
"github.com/pelletier/go-toml/v2"
88
"github.com/pkg/errors"
99
)
1010

1111
// Load loads buildkitd config
1212
func Load(r io.Reader) (Config, error) {
1313
var c Config
14-
t, err := toml.LoadReader(r)
15-
if err != nil {
16-
return c, errors.Wrap(err, "failed to parse config")
17-
}
18-
err = t.Unmarshal(&c)
19-
if err != nil {
14+
if err := toml.NewDecoder(r).Decode(&c); err != nil {
2015
return c, errors.Wrap(err, "failed to parse config")
2116
}
2217
return c, nil

cmd/buildkitd/main_containerd_worker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/moby/buildkit/worker/base"
2121
"github.com/moby/buildkit/worker/containerd"
2222
"github.com/moby/sys/userns"
23-
"github.com/pelletier/go-toml"
23+
"github.com/pelletier/go-toml/v2"
2424
"github.com/pkg/errors"
2525
"github.com/urfave/cli"
2626
"golang.org/x/sync/semaphore"
@@ -321,11 +321,11 @@ func containerdWorkerInitializer(c *cli.Context, common workerInitializerOpt) ([
321321
if cfg.Runtime.Name != "" {
322322
opts := getRuntimeOptionsType(cfg.Runtime.Name)
323323

324-
t, err := toml.TreeFromMap(cfg.Runtime.Options)
324+
b, err := toml.Marshal(cfg.Runtime.Options)
325325
if err != nil {
326326
return nil, errors.Wrapf(err, "failed to parse runtime options config")
327327
}
328-
err = t.Unmarshal(opts)
328+
err = toml.Unmarshal(b, opts)
329329
if err != nil {
330330
return nil, errors.Wrapf(err, "failed to parse runtime options config")
331331
}

cmd/buildkitd/main_oci_worker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141
"github.com/moby/buildkit/worker/base"
4242
"github.com/moby/buildkit/worker/runc"
4343
"github.com/moby/sys/userns"
44-
"github.com/pelletier/go-toml"
44+
"github.com/pelletier/go-toml/v2"
4545
"github.com/pkg/errors"
4646
"github.com/sirupsen/logrus"
4747
"github.com/urfave/cli"
@@ -422,11 +422,11 @@ func snapshotterFactory(commonRoot string, cfg config.OCIConfig, sm *session.Man
422422
// the main BuildKit config, the main config Unmarshalls it into a
423423
// generic map[string]interface{}. Here we convert it back into TOML
424424
// tree, and unmarshal it to the actual type.
425-
t, err := toml.TreeFromMap(cfg.StargzSnapshotterConfig)
425+
b, err := toml.Marshal(cfg.StargzSnapshotterConfig)
426426
if err != nil {
427427
return snFactory, errors.Wrapf(err, "failed to parse stargz config")
428428
}
429-
err = t.Unmarshal(&sgzCfg)
429+
err = toml.Unmarshal(b, &sgzCfg)
430430
if err != nil {
431431
return snFactory, errors.Wrapf(err, "failed to parse stargz config")
432432
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ require (
6565
github.com/opencontainers/runtime-spec v1.3.0
6666
github.com/opencontainers/selinux v1.13.1
6767
github.com/package-url/packageurl-go v0.1.1
68-
github.com/pelletier/go-toml v1.9.5
68+
github.com/pelletier/go-toml/v2 v2.2.4
6969
github.com/pkg/errors v0.9.1
7070
github.com/pkg/profile v1.7.0
7171
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ github.com/opencontainers/selinux v1.13.1 h1:A8nNeceYngH9Ow++M+VVEwJVpdFmrlxsN22
488488
github.com/opencontainers/selinux v1.13.1/go.mod h1:S10WXZ/osk2kWOYKy1x2f/eXF5ZHJoUs8UU/2caNRbg=
489489
github.com/package-url/packageurl-go v0.1.1 h1:KTRE0bK3sKbFKAk3yy63DpeskU7Cvs/x/Da5l+RtzyU=
490490
github.com/package-url/packageurl-go v0.1.1/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c=
491-
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
492-
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
491+
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
492+
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
493493
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw=
494494
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
495495
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=

vendor/github.com/pelletier/go-toml/CONTRIBUTING.md

Lines changed: 0 additions & 132 deletions
This file was deleted.

vendor/github.com/pelletier/go-toml/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)