Remove gopkg.in/yaml.v2 (#583)

* rm "gopkg.in/yaml.v2"

* fix UnmarshalYAML for Networks & Ulimits
This commit is contained in:
6543
2021-12-08 23:35:51 +01:00
committed by GitHub
parent e7cfa902a6
commit 0061edcbe2
6 changed files with 8 additions and 17 deletions

View File

@@ -72,16 +72,12 @@ func handleNetwork(name string, value interface{}) (*Network, error) {
}, nil
}
switch v := value.(type) {
case map[interface{}]interface{}:
case map[string]interface{}:
network := &Network{
Name: name,
}
for mapKey, mapValue := range v {
name, ok := mapKey.(string)
if !ok {
return &Network{}, fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", name, name)
}
switch name {
switch mapKey {
case "aliases":
aliases, ok := mapValue.([]interface{})
if !ok {

View File

@@ -3,7 +3,6 @@ package types
import (
"testing"
todo_yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"github.com/stretchr/testify/assert"
@@ -16,8 +15,7 @@ func TestMarshalNetworks(t *testing.T) {
}{
{
networks: Networks{},
expected: `{}
`,
expected: "{}\n",
},
{
networks: Networks{
@@ -158,8 +156,8 @@ func TestUnmarshalNetworks(t *testing.T) {
}
for _, network := range networks {
actual := &Networks{}
err := todo_yaml.Unmarshal([]byte(network.yaml), actual)
assert.Nil(t, err)
assert.Equal(t, network.expected, actual, "should be equal")
err := yaml.Unmarshal([]byte(network.yaml), actual)
assert.NoError(t, err)
assert.EqualValues(t, network.expected, actual)
}
}

View File

@@ -37,7 +37,7 @@ func (u *Ulimits) UnmarshalYAML(unmarshal func(interface{}) error) error {
case int:
soft = int64(mv)
hard = int64(mv)
case map[interface{}]interface{}:
case map[string]interface{}:
if len(mv) != 2 {
return fmt.Errorf("Failed to unmarshal Ulimit: %#v", mapValue)
}

View File

@@ -3,7 +3,6 @@ package types
import (
"testing"
todo_yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
"github.com/stretchr/testify/assert"
@@ -119,7 +118,7 @@ nofile:
for _, ulimit := range ulimits {
actual := &Ulimits{}
err := todo_yaml.Unmarshal([]byte(ulimit.yaml), actual)
err := yaml.Unmarshal([]byte(ulimit.yaml), actual)
assert.Nil(t, err)
assert.Equal(t, ulimit.expected, actual, "should be equal")