mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 06:08:42 +00:00
Remove gopkg.in/yaml.v2 (#583)
* rm "gopkg.in/yaml.v2" * fix UnmarshalYAML for Networks & Ulimits
This commit is contained in:
parent
e7cfa902a6
commit
0061edcbe2
6 changed files with 8 additions and 17 deletions
1
go.mod
1
go.mod
|
@ -54,7 +54,6 @@ require (
|
|||
google.golang.org/genproto v0.0.0-20211027162914-98a5263abeca // indirect
|
||||
google.golang.org/grpc v1.41.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
xorm.io/builder v0.3.9
|
||||
xorm.io/xorm v1.2.5
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
|
@ -812,7 +812,6 @@ google.golang.org/protobuf/types/known/timestamppb
|
|||
# gopkg.in/ini.v1 v1.63.2
|
||||
gopkg.in/ini.v1
|
||||
# gopkg.in/yaml.v2 v2.4.0
|
||||
## explicit
|
||||
gopkg.in/yaml.v2
|
||||
# gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
## explicit
|
||||
|
|
Loading…
Reference in a new issue