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/genproto v0.0.0-20211027162914-98a5263abeca // indirect
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
google.golang.org/protobuf v1.27.1
|
google.golang.org/protobuf v1.27.1
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
xorm.io/builder v0.3.9
|
xorm.io/builder v0.3.9
|
||||||
xorm.io/xorm v1.2.5
|
xorm.io/xorm v1.2.5
|
||||||
|
|
|
@ -72,16 +72,12 @@ func handleNetwork(name string, value interface{}) (*Network, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case map[interface{}]interface{}:
|
case map[string]interface{}:
|
||||||
network := &Network{
|
network := &Network{
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
for mapKey, mapValue := range v {
|
for mapKey, mapValue := range v {
|
||||||
name, ok := mapKey.(string)
|
switch mapKey {
|
||||||
if !ok {
|
|
||||||
return &Network{}, fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", name, name)
|
|
||||||
}
|
|
||||||
switch name {
|
|
||||||
case "aliases":
|
case "aliases":
|
||||||
aliases, ok := mapValue.([]interface{})
|
aliases, ok := mapValue.([]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package types
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
todo_yaml "gopkg.in/yaml.v2"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -16,8 +15,7 @@ func TestMarshalNetworks(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
networks: Networks{},
|
networks: Networks{},
|
||||||
expected: `{}
|
expected: "{}\n",
|
||||||
`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
networks: Networks{
|
networks: Networks{
|
||||||
|
@ -158,8 +156,8 @@ func TestUnmarshalNetworks(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, network := range networks {
|
for _, network := range networks {
|
||||||
actual := &Networks{}
|
actual := &Networks{}
|
||||||
err := todo_yaml.Unmarshal([]byte(network.yaml), actual)
|
err := yaml.Unmarshal([]byte(network.yaml), actual)
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, network.expected, actual, "should be equal")
|
assert.EqualValues(t, network.expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (u *Ulimits) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
case int:
|
case int:
|
||||||
soft = int64(mv)
|
soft = int64(mv)
|
||||||
hard = int64(mv)
|
hard = int64(mv)
|
||||||
case map[interface{}]interface{}:
|
case map[string]interface{}:
|
||||||
if len(mv) != 2 {
|
if len(mv) != 2 {
|
||||||
return fmt.Errorf("Failed to unmarshal Ulimit: %#v", mapValue)
|
return fmt.Errorf("Failed to unmarshal Ulimit: %#v", mapValue)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package types
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
todo_yaml "gopkg.in/yaml.v2"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -119,7 +118,7 @@ nofile:
|
||||||
|
|
||||||
for _, ulimit := range ulimits {
|
for _, ulimit := range ulimits {
|
||||||
actual := &Ulimits{}
|
actual := &Ulimits{}
|
||||||
err := todo_yaml.Unmarshal([]byte(ulimit.yaml), actual)
|
err := yaml.Unmarshal([]byte(ulimit.yaml), actual)
|
||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, ulimit.expected, actual, "should be equal")
|
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 v1.63.2
|
||||||
gopkg.in/ini.v1
|
gopkg.in/ini.v1
|
||||||
# gopkg.in/yaml.v2 v2.4.0
|
# gopkg.in/yaml.v2 v2.4.0
|
||||||
## explicit
|
|
||||||
gopkg.in/yaml.v2
|
gopkg.in/yaml.v2
|
||||||
# gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
# gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
## explicit
|
## explicit
|
||||||
|
|
Loading…
Reference in a new issue