cmd: switch to gopkg.in/yaml.v3 for YAML parsing

This commit is contained in:
Vincent Bernat
2023-01-29 13:09:22 +01:00
parent 6d660e0887
commit 9884844adf
7 changed files with 23 additions and 23 deletions

View File

@@ -19,7 +19,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"github.com/mitchellh/mapstructure"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"akvorado/common/helpers"
)

View File

@@ -16,7 +16,7 @@ import (
"time"
"github.com/gin-gonic/gin"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"akvorado/cmd"
"akvorado/common/helpers"

View File

@@ -15,7 +15,7 @@ import (
"akvorado/common/helpers"
"akvorado/common/reporter"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)
func TestOrchestratorStart(t *testing.T) {

View File

@@ -9,7 +9,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/mitchellh/mapstructure"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"akvorado/common/helpers"
)

View File

@@ -10,7 +10,7 @@ import (
"testing"
"github.com/mitchellh/mapstructure"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)
// ConfigurationDecodeCases describes a test case for configuration

6
go.mod
View File

@@ -29,6 +29,7 @@ require (
github.com/mattn/go-isatty v0.0.17
github.com/mitchellh/mapstructure v1.5.0
github.com/netsampler/goflow2 v1.1.1-0.20221008154147-57fad2e0c837
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
github.com/oschwald/maxminddb-golang v1.10.0
github.com/osrg/gobgp/v3 v3.10.0
github.com/prometheus/client_golang v1.14.0
@@ -46,7 +47,7 @@ require (
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
google.golang.org/protobuf v1.28.1
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/gorm v1.24.3
zgo.at/zcache/v2 v2.1.0
)
@@ -98,7 +99,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/paulmach/orb v0.8.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
@@ -127,7 +127,7 @@ require (
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.3.0 // indirect
modernc.org/libc v1.21.5 // indirect
modernc.org/mathutil v1.5.0 // indirect

View File

@@ -8,7 +8,7 @@ import (
"testing"
"github.com/gin-gonic/gin"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"akvorado/common/helpers"
"akvorado/inlet/flow/input/file"
@@ -218,20 +218,20 @@ func TestMarshalYAML(t *testing.T) {
t.Fatalf("Marshal() error:\n%+v", err)
}
expected := `inputs:
- decoder: netflow
listen: 192.0.2.11:2055
queuesize: 1000
receivebuffer: 0
type: udp
usesrcaddrforexporteraddr: false
workers: 3
- decoder: sflow
listen: 192.0.2.11:6343
queuesize: 1000
receivebuffer: 0
type: udp
usesrcaddrforexporteraddr: true
workers: 3
- decoder: netflow
listen: 192.0.2.11:2055
queuesize: 1000
receivebuffer: 0
type: udp
usesrcaddrforexporteraddr: false
workers: 3
- decoder: sflow
listen: 192.0.2.11:6343
queuesize: 1000
receivebuffer: 0
type: udp
usesrcaddrforexporteraddr: true
workers: 3
ratelimit: 0
`
if diff := helpers.Diff(strings.Split(string(got), "\n"), strings.Split(expected, "\n")); diff != "" {