Skip to content

Commit

Permalink
deps: use v2 of go-toml
Browse files Browse the repository at this point in the history
v1 is no longer maintained.
  • Loading branch information
lukedirtwalker authored and matzf committed Mar 5, 2024
1 parent c5a8e6f commit 5559981
Show file tree
Hide file tree
Showing 25 changed files with 44 additions and 52 deletions.
2 changes: 1 addition & 1 deletion control/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ go_test(
"//private/mgmtapi/mgmtapitest:go_default_library",
"//private/storage:go_default_library",
"//private/storage/test:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
],
Expand Down
6 changes: 3 additions & 3 deletions control/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/pkg/log/logtest"
Expand All @@ -34,8 +34,8 @@ func TestConfigSample(t *testing.T) {
cfg.Sample(&sample, nil, nil)

InitTestConfig(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
assert.NoError(t, err)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err, "config: \n%s", sample.String())
CheckTestConfig(t, &cfg, idSample)
}

Expand Down
15 changes: 8 additions & 7 deletions control/config/drkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"os"
"testing"

toml "github.com/pelletier/go-toml"
toml "github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand All @@ -39,8 +39,8 @@ func TestSample(t *testing.T) {
var sample bytes.Buffer
var cfg DRKeyConfig
cfg.Sample(&sample, nil, nil)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
require.NoError(t, err)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
require.NoError(t, err, "config:\n%s", sample.String())
err = cfg.Validate()
assert.NoError(t, err)
}
Expand Down Expand Up @@ -94,14 +94,15 @@ func TestSecretValueHostListSyntax(t *testing.T) {
var cfg SecretValueHostList
var err error
sample1 := `scmp = ["1.1.1.1"]`
err = toml.NewDecoder(bytes.NewReader([]byte(sample1))).Strict(true).Decode(&cfg)
err = toml.NewDecoder(bytes.NewReader([]byte(sample1))).DisallowUnknownFields().Decode(&cfg)
require.NoError(t, err)
assert.NoError(t, cfg.Validate())

var cfg2 SecretValueHostList
sample2 := `scmp = ["not an address"]`
err = toml.NewDecoder(bytes.NewReader([]byte(sample2))).Strict(true).Decode(&cfg)
err = toml.NewDecoder(bytes.NewReader([]byte(sample2))).DisallowUnknownFields().Decode(&cfg2)
require.NoError(t, err)
assert.Error(t, cfg.Validate())
assert.Error(t, cfg2.Validate())
}

func TestToMapPerHost(t *testing.T) {
Expand All @@ -111,7 +112,7 @@ func TestToMapPerHost(t *testing.T) {
require.NoError(t, err)
ip2222, err := netip.ParseAddr("2.2.2.2")
require.NoError(t, err)
err = toml.NewDecoder(bytes.NewReader([]byte(sample))).Strict(true).Decode(&cfg)
err = toml.NewDecoder(bytes.NewReader([]byte(sample))).DisallowUnknownFields().Decode(&cfg)
require.NoError(t, err)
assert.NoError(t, cfg.Validate())
m := cfg.ToAllowedSet()
Expand Down
2 changes: 1 addition & 1 deletion daemon/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go_test(
"//private/env/envtest:go_default_library",
"//private/mgmtapi/mgmtapitest:go_default_library",
"//private/storage/test:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
4 changes: 2 additions & 2 deletions daemon/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/pkg/daemon"
Expand All @@ -34,7 +34,7 @@ func TestConfigSample(t *testing.T) {
cfg.Sample(&sample, nil, nil)

InitTestConfig(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckTestConfig(t, &cfg, idSample)
}
Expand Down
2 changes: 1 addition & 1 deletion dispatcher/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ go_test(
"//private/env/envtest:go_default_library",
"//private/mgmtapi/mgmtapitest:go_default_library",
"//private/topology:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
4 changes: 2 additions & 2 deletions dispatcher/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/pkg/log/logtest"
Expand All @@ -35,7 +35,7 @@ func TestConfigSample(t *testing.T) {
cfg.Sample(&sample, nil, nil)

InitTestConfig(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckTestConfig(t, &cfg, idSample)
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ go_test(
"//pkg/log/logtest:go_default_library",
"//private/env/envtest:go_default_library",
"//private/mgmtapi/mgmtapitest:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
4 changes: 2 additions & 2 deletions gateway/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

toml "github.com/pelletier/go-toml"
toml "github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/gateway/config"
Expand All @@ -34,7 +34,7 @@ func TestConfigSample(t *testing.T) {
cfg.Sample(&sample, nil, nil)

InitConfig(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckConfig(t, &cfg)
}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/opentracing/opentracing-go v1.2.0
github.com/patrickmn/go-cache v2.1.1-0.20180815053127-5633e0862627+incompatible
github.com/pelletier/go-toml v1.9.5
github.com/pelletier/go-toml/v2 v2.0.9
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/procfs v0.12.0
Expand Down Expand Up @@ -94,7 +94,6 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
github.com/perimeterx/marshmallow v1.1.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/patrickmn/go-cache v2.1.1-0.20180815053127-5633e0862627+incompatible h1:MUIwjEiAMYk8zkXXUQeb5itrXF+HpS2pfxNsA2a7AiY=
github.com/patrickmn/go-cache v2.1.1-0.20180815053127-5633e0862627+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0=
github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw=
Expand Down
6 changes: 0 additions & 6 deletions go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,6 @@ def go_deps():
sum = "h1:MUIwjEiAMYk8zkXXUQeb5itrXF+HpS2pfxNsA2a7AiY=",
version = "v2.1.1-0.20180815053127-5633e0862627+incompatible",
)
go_repository(
name = "com_github_pelletier_go_toml",
importpath = "github.com/pelletier/go-toml",
sum = "h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=",
version = "v1.9.5",
)
go_repository(
name = "com_github_pelletier_go_toml_v2",
importpath = "github.com/pelletier/go-toml/v2",
Expand Down
2 changes: 1 addition & 1 deletion pkg/log/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ go_test(
"//pkg/log/logtest:go_default_library",
"//pkg/private/common:go_default_library",
"//private/config:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
"@org_uber_go_zap//zapcore:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions pkg/log/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/pkg/log"
Expand All @@ -32,7 +32,7 @@ func TestLoggingSample(t *testing.T) {
var cfg log.Config
cfg.Sample(&sample, nil, map[string]string{config.ID: id})
logtest.InitTestLogging(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
logtest.CheckTestLogging(t, &cfg, id)
}
2 changes: 1 addition & 1 deletion private/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/private/serrors:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
],
)
4 changes: 2 additions & 2 deletions private/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import (
"os"
"strings"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"

"github.com/scionproto/scion/pkg/private/serrors"
)
Expand Down Expand Up @@ -162,7 +162,7 @@ func InitAll(defaulters ...Defaulter) {

// Decode decodes a raw config.
func Decode(raw []byte, cfg interface{}) error {
return toml.NewDecoder(bytes.NewReader(raw)).Strict(true).Decode(cfg)
return toml.NewDecoder(bytes.NewReader(raw)).DisallowUnknownFields().Decode(cfg)
}

// LoadFile loads the config from file.
Expand Down
2 changes: 1 addition & 1 deletion private/env/envtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ go_test(
deps = [
"//private/config:go_default_library",
"//private/env:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
10 changes: 5 additions & 5 deletions private/env/envtest/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/private/config"
Expand All @@ -30,7 +30,7 @@ func TestGeneralSample(t *testing.T) {
var cfg env.General
cfg.Sample(&sample, nil, map[string]string{config.ID: "general"})
InitTestGeneral(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckTestGeneral(t, &cfg, "general")
}
Expand All @@ -40,7 +40,7 @@ func TestMetricsSample(t *testing.T) {
var cfg env.Metrics
cfg.Sample(&sample, nil, nil)
InitTestMetrics(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckTestMetrics(t, &cfg)
}
Expand All @@ -50,7 +50,7 @@ func TestTracingSample(t *testing.T) {
var cfg env.Tracing
cfg.Sample(&sample, nil, nil)
InitTestTracing(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckTestTracing(t, &cfg)
}
Expand All @@ -60,7 +60,7 @@ func TestSCIONDClientSample(t *testing.T) {
var cfg env.Daemon
cfg.Sample(&sample, nil, nil)
InitTestSCIOND(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
InitTestSCIOND(&cfg)
}
2 changes: 1 addition & 1 deletion private/mgmtapi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ go_test(
deps = [
":go_default_library",
"//private/mgmtapi/mgmtapitest:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
4 changes: 2 additions & 2 deletions private/mgmtapi/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

api "github.com/scionproto/scion/private/mgmtapi"
Expand All @@ -30,7 +30,7 @@ func TestConfigSample(t *testing.T) {
var cfg api.Config
cfg.Sample(&sample, nil, nil)
apitest.InitConfig(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
apitest.CheckConfig(t, &cfg)
}
2 changes: 1 addition & 1 deletion private/service/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go_library(
"//pkg/private/serrors:go_default_library",
"//private/env:go_default_library",
"//private/topology:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promhttp:go_default_library",
],
)
4 changes: 2 additions & 2 deletions private/service/statuspages.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"sort"
"strings"

toml "github.com/pelletier/go-toml"
toml "github.com/pelletier/go-toml/v2"
"github.com/prometheus/client_golang/prometheus/promhttp"

"github.com/scionproto/scion/pkg/log"
Expand Down Expand Up @@ -128,7 +128,7 @@ func (s StatusPages) Register(serveMux *http.ServeMux, elemId string) error {
func NewConfigStatusPage(config interface{}) StatusPage {
handler := func(w http.ResponseWriter, r *http.Request) {
var buf bytes.Buffer
err := toml.NewEncoder(&buf).Order(toml.OrderPreserve).Encode(config)
err := toml.NewEncoder(&buf).Encode(config)
if err != nil {
http.Error(w, "Error encoding toml config", http.StatusInternalServerError)
return
Expand Down
2 changes: 1 addition & 1 deletion private/trust/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (cfg *Cache) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
# Disable caching.
disable = false
# Maximum chache expiration.
# Maximum cache expiration.
expiration = "1m"
`)
}
Expand Down
2 changes: 1 addition & 1 deletion router/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ go_test(
"//pkg/log/logtest:go_default_library",
"//private/env/envtest:go_default_library",
"//private/mgmtapi/mgmtapitest:go_default_library",
"@com_github_pelletier_go_toml//:go_default_library",
"@com_github_pelletier_go_toml_v2//:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
4 changes: 2 additions & 2 deletions router/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"testing"

"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/pkg/log/logtest"
Expand All @@ -33,7 +33,7 @@ func TestConfigSample(t *testing.T) {
cfg.Sample(&sample, nil, nil)

InitTestConfig(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).Strict(true).Decode(&cfg)
err := toml.NewDecoder(bytes.NewReader(sample.Bytes())).DisallowUnknownFields().Decode(&cfg)
assert.NoError(t, err)
CheckTestConfig(t, &cfg, config.IDSample)
}
Expand Down

0 comments on commit 5559981

Please sign in to comment.