diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2020-10-12 15:24:49 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2020-10-12 15:24:49 +0300 |
commit | dfd9c3e1a79f6a222b742b1978e45785b06a9440 (patch) | |
tree | b5640c37923025bb0e95227f53b4a3171add4a96 | |
parent | 72b1b557837c5d944557cba7f4462abdeb64c369 (diff) | |
parent | 3c66412ba595b62aca6655f4b4252065388ad144 (diff) |
Merge branch 'sluongngoc/replace-toml' into 'master'
Remove usage of 'github.com/BurntSushi/toml'
Closes #3182
See merge request gitlab-org/gitaly!2638
-rw-r--r-- | NOTICE | 48 | ||||
-rw-r--r-- | cmd/gitaly-hooks/hooks.go | 4 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 3 | ||||
-rw-r--r-- | internal/blackbox/config.go | 4 | ||||
-rw-r--r-- | internal/gitaly/config/config.go | 4 | ||||
-rw-r--r-- | internal/gitaly/config/config_test.go | 2 | ||||
-rw-r--r-- | internal/praefect/config/config.go | 10 | ||||
-rw-r--r-- | internal/testhelper/testserver.go | 2 |
9 files changed, 44 insertions, 35 deletions
@@ -260,30 +260,6 @@ LICENSE - cloud.google.com/go limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -COPYING - github.com/BurntSushi/toml -The MIT License (MIT) - -Copyright (c) 2013 TOML authors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LICENSE - github.com/beorn7/perks/quantile Copyright (C) 2013 Blake Mizerany @@ -1631,6 +1607,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LICENSE - github.com/pelletier/go-toml +The MIT License (MIT) + +Copyright (c) 2013 - 2017 Thomas Pelletier, Eric Anderton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LICENSE - github.com/pkg/errors Copyright (c) 2015, Dave Cheney <dave@cheney.net> All rights reserved. diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go index dda50710c..f4b849dde 100644 --- a/cmd/gitaly-hooks/hooks.go +++ b/cmd/gitaly-hooks/hooks.go @@ -12,8 +12,8 @@ import ( "strconv" "strings" - "github.com/BurntSushi/toml" "github.com/golang/protobuf/jsonpb" + "github.com/pelletier/go-toml" gitalyauth "gitlab.com/gitlab-org/gitaly/auth" "gitlab.com/gitlab-org/gitaly/client" "gitlab.com/gitlab-org/gitaly/internal/command" @@ -329,7 +329,7 @@ func check(configPath string) (int, error) { var c config.Cfg - if _, err := toml.DecodeReader(cfgFile, &c); err != nil { + if err := toml.NewDecoder(cfgFile).Decode(&c); err != nil { return 1, fmt.Errorf("failed to decode toml: %w", err) } @@ -1,7 +1,6 @@ module gitlab.com/gitlab-org/gitaly require ( - github.com/BurntSushi/toml v0.3.1 github.com/beorn7/perks v1.0.1 // indirect github.com/cloudflare/tableflip v1.2.1-0.20200514155827-4baec9811f2b github.com/getsentry/sentry-go v0.5.1 @@ -14,6 +13,7 @@ require ( github.com/libgit2/git2go/v30 v30.0.5 github.com/olekukonko/tablewriter v0.0.2 github.com/opentracing/opentracing-go v1.0.2 + github.com/pelletier/go-toml v1.8.1 github.com/prometheus/client_golang v1.0.0 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 github.com/prometheus/procfs v0.0.3 // indirect @@ -260,7 +260,10 @@ github.com/otiai10/mint v1.2.3/go.mod h1:YnfyPNhBvnY8bW4SGQHCs/aAFhkgySlMZbrF5U0 github.com/otiai10/mint v1.2.3/go.mod h1:YnfyPNhBvnY8bW4SGQHCs/aAFhkgySlMZbrF5U0bOVw= github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= +github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= diff --git a/internal/blackbox/config.go b/internal/blackbox/config.go index 7d4bb9c24..704d9bd62 100644 --- a/internal/blackbox/config.go +++ b/internal/blackbox/config.go @@ -5,7 +5,7 @@ import ( "net/url" "time" - "github.com/BurntSushi/toml" + "github.com/pelletier/go-toml" logconfig "gitlab.com/gitlab-org/gitaly/internal/gitaly/config/log" ) @@ -26,7 +26,7 @@ type Probe struct { func ParseConfig(raw string) (*Config, error) { config := &Config{} - if _, err := toml.Decode(raw, config); err != nil { + if err := toml.Unmarshal([]byte(raw), config); err != nil { return nil, err } diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go index 993e095dd..dc0bb3914 100644 --- a/internal/gitaly/config/config.go +++ b/internal/gitaly/config/config.go @@ -12,8 +12,8 @@ import ( "sync" "time" - "github.com/BurntSushi/toml" "github.com/kelseyhightower/envconfig" + "github.com/pelletier/go-toml" log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config/auth" internallog "gitlab.com/gitlab-org/gitaly/internal/gitaly/config/log" @@ -128,7 +128,7 @@ type Concurrency struct { func Load(file io.Reader) error { Config = Cfg{} - if _, err := toml.DecodeReader(file, &Config); err != nil { + if err := toml.NewDecoder(file).Decode(&Config); err != nil { return fmt.Errorf("load toml: %v", err) } diff --git a/internal/gitaly/config/config_test.go b/internal/gitaly/config/config_test.go index 926b6812f..89beac74e 100644 --- a/internal/gitaly/config/config_test.go +++ b/internal/gitaly/config/config_test.go @@ -831,7 +831,7 @@ storages = ["default"] rawCfg: `[daily_maintenance] duration = "meow"`, expect: DailyJob{}, - loadErr: errors.New("load toml: time: invalid duration meow"), + loadErr: errors.New("load toml: (2, 4): unmarshal text: time: invalid duration meow"), }, { rawCfg: `[daily_maintenance] storages = ["default"]`, diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go index a06acf914..ca03b7831 100644 --- a/internal/praefect/config/config.go +++ b/internal/praefect/config/config.go @@ -3,10 +3,11 @@ package config import ( "errors" "fmt" + "io/ioutil" "strings" "time" - "github.com/BurntSushi/toml" + "github.com/pelletier/go-toml" promclient "github.com/prometheus/client_golang/prometheus" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config/auth" @@ -112,13 +113,18 @@ type VirtualStorage struct { // FromFile loads the config for the passed file path func FromFile(filePath string) (Config, error) { + b, err := ioutil.ReadFile(filePath) + if err != nil { + return Config{}, err + } + conf := &Config{ Reconciliation: DefaultReconciliationConfig(), Replication: DefaultReplicationConfig(), // Sets the default Failover, to be overwritten when deserializing the TOML Failover: Failover{Enabled: true, ElectionStrategy: sqlFailoverValue}, } - if _, err := toml.DecodeFile(filePath, conf); err != nil { + if err := toml.Unmarshal(b, conf); err != nil { return Config{}, err } diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go index dcbab20a5..17934c05b 100644 --- a/internal/testhelper/testserver.go +++ b/internal/testhelper/testserver.go @@ -19,11 +19,11 @@ import ( "testing" "time" - "github.com/BurntSushi/toml" "github.com/golang/protobuf/jsonpb" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" + "github.com/pelletier/go-toml" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" gitalyauth "gitlab.com/gitlab-org/gitaly/auth" |