1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

Migrate gopkg.in/yaml.v3 usages to go.yaml.in/yaml/v4 (#6651)

This commit is contained in:
6543
2026-05-28 15:08:09 +02:00
committed by GitHub
parent 80561d51cd
commit c61d7403b2
25 changed files with 53 additions and 32 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ import (
"slices"
"strings"
"codeberg.org/6543/xyaml"
"codeberg.org/6543/xyaml/v2"
"github.com/oklog/ulid/v2"
"github.com/urfave/cli/v3"
"go.uber.org/multierr"
+4 -2
View File
@@ -6,8 +6,8 @@ require (
al.essio.dev/pkg/shellescape v1.6.0
charm.land/huh/v2 v2.0.3
code.gitea.io/sdk/gitea v0.25.1
codeberg.org/6543/go-yaml2json v1.0.0
codeberg.org/6543/xyaml v1.1.0
codeberg.org/6543/go-yaml2json/v2 v2.0.0
codeberg.org/6543/xyaml/v2 v2.0.1
codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v3 v3.0.0
github.com/6543/logfile-open v1.2.1
github.com/adrg/xdg v0.5.3
@@ -57,6 +57,7 @@ require (
github.com/zalando/go-keyring v0.2.8
gitlab.com/gitlab-org/api/client-go/v2 v2.34.0
go.uber.org/multierr v1.11.0
go.yaml.in/yaml/v4 v4.0.0-rc.4
golang.org/x/crypto v0.52.0
golang.org/x/image v0.41.0
golang.org/x/net v0.55.0
@@ -80,6 +81,7 @@ require (
charm.land/bubbles/v2 v2.0.0 // indirect
charm.land/bubbletea/v2 v2.0.2 // indirect
charm.land/lipgloss/v2 v2.0.1 // indirect
codeberg.org/6543/xyaml v1.1.0 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/42wim/httpsig v1.2.4 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
+6 -2
View File
@@ -10,10 +10,12 @@ charm.land/lipgloss/v2 v2.0.1 h1:6Xzrn49+Py1Um5q/wZG1gWgER2+7dUyZ9XMEufqPSys=
charm.land/lipgloss/v2 v2.0.1/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM=
code.gitea.io/sdk/gitea v0.25.1 h1:yywxWwoV+SdjHtbC6unBiXojWdZOtoHuGhEazEXeWuE=
code.gitea.io/sdk/gitea v0.25.1/go.mod h1:uDFWYBU8dgZsgOHwe6C/6olxvf8FHguNB3wW1i83fgg=
codeberg.org/6543/go-yaml2json v1.0.0 h1:heGqo9VEi7gY2yNqjj7X4ADs5nzlFIbGsJtgYDLrnig=
codeberg.org/6543/go-yaml2json v1.0.0/go.mod h1:mz61q14LWF4ZABrgMEDMmk3t9dPi6zgR1uBh2VKV2RQ=
codeberg.org/6543/go-yaml2json/v2 v2.0.0 h1:S2c643uPhlNlURQWjnnOyOGmiAcCewINBzpGRcfwaVg=
codeberg.org/6543/go-yaml2json/v2 v2.0.0/go.mod h1:a0LIJUJKeRvfGJMQC0aDdywyqgQQzaAT2zzi7OPDeOE=
codeberg.org/6543/xyaml v1.1.0 h1:0PWTy8OUqshshjrrnAXFWXSPUEa8R49DIh2ah07SxFc=
codeberg.org/6543/xyaml v1.1.0/go.mod h1:jI7afXLZUxeL4rNNsG1SlHh78L+gma9lK1bIebyFZwA=
codeberg.org/6543/xyaml/v2 v2.0.1 h1:GIkCLqf8TeUHjRqTbhCOGAmc8pzCuAFr4lWgLV+HgPc=
codeberg.org/6543/xyaml/v2 v2.0.1/go.mod h1:OiVkoPEUSJK4xUub8OuQvdnJM9SpM74oGxpGB045JVI=
codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v3 v3.0.0 h1:s2fK+FBwvcYsmKDjNhmoe7B8q9zsgs0UrSlYe9r4XjM=
codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v3 v3.0.0/go.mod h1:Is2jTpS1dizeXm4skQv/ES3QVqnzcNhn2GzZXpiw9f8=
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
@@ -655,6 +657,8 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U=
go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -20,8 +20,8 @@ import (
"strconv"
"strings"
"codeberg.org/6543/go-yaml2json"
"gopkg.in/yaml.v3"
"codeberg.org/6543/go-yaml2json/v2"
"go.yaml.in/yaml/v4"
)
// ParamsToEnv uses reflection to convert a map[string]interface to a list
@@ -97,7 +97,7 @@ func sanitizeParamValue(v any, getSecretValue func(name string) (string, error))
case reflect.Map:
switch v := v.(type) {
// gopkg.in/yaml.v3 only emits this map interface
// go.yaml.in/yaml/v4 only emits this map interface
case map[string]any:
// check if it's a secret and return value if it's the case
value, isSecret, err := injectSecret(v, getSecretValue)
@@ -204,7 +204,7 @@ func injectSecretRecursive(v any, getSecretValue func(name string) (string, erro
switch t.Kind() {
case reflect.Map:
switch v := v.(type) {
// gopkg.in/yaml.v3 only emits this map interface
// go.yaml.in/yaml/v4 only emits this map interface
case map[string]any:
// handle secrets
value, isSecret, err := injectSecret(v, getSecretValue)
@@ -20,7 +20,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func TestParamsToEnv(t *testing.T) {
@@ -21,7 +21,7 @@ import (
"slices"
"github.com/expr-lang/expr"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/metadata"
yaml_base_types "go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/types/base"
@@ -123,6 +123,9 @@ func (when *When) IsLocal() bool {
}
func (when *When) UnmarshalYAML(value *yaml.Node) error {
if value.Kind == yaml.DocumentNode && len(value.Content) == 1 {
value = value.Content[0]
}
switch value.Kind {
case yaml.SequenceNode:
if err := value.Decode(&when.Constraints); err != nil {
@@ -19,7 +19,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/metadata"
)
+4 -1
View File
@@ -19,7 +19,7 @@ import (
"github.com/bmatcuk/doublestar/v4"
"go.uber.org/multierr"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
yaml_base_types "go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/types/base"
)
@@ -75,6 +75,9 @@ func (c *List) Excludes(v string) bool {
// UnmarshalYAML unmarshal the constraint.
func (c *List) UnmarshalYAML(value *yaml.Node) error {
if value.Kind == yaml.DocumentNode && len(value.Content) == 1 {
value = value.Content[0]
}
out1 := struct {
Include yaml_base_types.StringOrSlice
Exclude yaml_base_types.StringOrSlice
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func TestConstraintList(t *testing.T) {
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func TestConstraintMap(t *testing.T) {
+4 -1
View File
@@ -19,7 +19,7 @@ import (
"strings"
"github.com/bmatcuk/doublestar/v4"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
yaml_base_types "go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/types/base"
"go.woodpecker-ci.org/woodpecker/v3/shared/optional"
@@ -35,6 +35,9 @@ type Path struct {
// UnmarshalYAML unmarshal the constraint.
func (c *Path) UnmarshalYAML(value *yaml.Node) error {
if value.Kind == yaml.DocumentNode && len(value.Content) == 1 {
value = value.Content[0]
}
out1 := struct {
Include yaml_base_types.StringOrSlice `yaml:"include"`
Exclude yaml_base_types.StringOrSlice `yaml:"exclude"`
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func TestConstraintPath(t *testing.T) {
+1 -1
View File
@@ -18,7 +18,7 @@ import (
"fmt"
"slices"
"codeberg.org/6543/xyaml"
"codeberg.org/6543/xyaml/v2"
"go.uber.org/multierr"
pipeline_errors "go.woodpecker-ci.org/woodpecker/v3/pipeline/errors"
@@ -21,10 +21,10 @@ import (
"io"
"strings"
"codeberg.org/6543/go-yaml2json"
"codeberg.org/6543/xyaml"
"codeberg.org/6543/go-yaml2json/v2"
"codeberg.org/6543/xyaml/v2"
"github.com/xeipuuv/gojsonschema"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
//go:embed schema.json
+1 -1
View File
@@ -17,7 +17,7 @@ package matrix
import (
"strings"
"codeberg.org/6543/xyaml"
"codeberg.org/6543/xyaml/v2"
pipeline_errors "go.woodpecker-ci.org/woodpecker/v3/pipeline/errors"
)
+1 -1
View File
@@ -15,7 +15,7 @@
package yaml
import (
"codeberg.org/6543/xyaml"
"codeberg.org/6543/xyaml/v2"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/types"
)
+1 -1
View File
@@ -19,7 +19,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/metadata"
yaml_base_types "go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/types/base"
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
type StructStringOrInt struct {
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
type StructStringOrSlice struct {
@@ -17,7 +17,7 @@ package types
import (
"fmt"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
// ContainerList contains ordered collection of containers.
@@ -27,6 +27,9 @@ type ContainerList struct {
// UnmarshalYAML implements the Unmarshaler interface.
func (c *ContainerList) UnmarshalYAML(value *yaml.Node) error {
if value.Kind == yaml.DocumentNode && len(value.Content) == 1 {
value = value.Content[0]
}
switch value.Kind {
// We support maps ...
case yaml.MappingNode:
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/constraint"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/yaml/types/base"
+1 -1
View File
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func TestMarshalNetworks(t *testing.T) {
+1 -1
View File
@@ -18,7 +18,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func TestMarshalVolumes(t *testing.T) {
+4 -1
View File
@@ -8,7 +8,7 @@ package optional
import (
"encoding/json"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
)
func (o *Option[T]) UnmarshalJSON(data []byte) error {
@@ -29,6 +29,9 @@ func (o Option[T]) MarshalJSON() ([]byte, error) {
}
func (o *Option[T]) UnmarshalYAML(value *yaml.Node) error {
if value.Kind == yaml.DocumentNode && len(value.Content) == 1 {
value = value.Content[0]
}
var v *T
if err := value.Decode(&v); err != nil {
return err
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"go.yaml.in/yaml/v4"
"go.woodpecker-ci.org/woodpecker/v3/shared/optional"
)