diff options
author | Jason Song <i@wolfogre.com> | 2022-11-21 16:36:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-21 16:36:59 +0800 |
commit | e4eaa68a2b2355c7333406fdcbb8b118677b95df (patch) | |
tree | a4027ec3b2efc7bf4d2f22f51676f3dc26e829e3 /modules | |
parent | b4802b9b2eae044e35f022dc7116986e4762a944 (diff) | |
download | gitea-e4eaa68a2b2355c7333406fdcbb8b118677b95df.tar.gz gitea-e4eaa68a2b2355c7333406fdcbb8b118677b95df.zip |
Replace yaml.v2 with yaml.v3 (#21832)
I don't see why we have to use two versions of yaml. The difference
between the two versions has nothing to do with our usage.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/migration/file_format.go | 11 | ||||
-rw-r--r-- | modules/packages/helm/metadata.go | 2 | ||||
-rw-r--r-- | modules/packages/pub/metadata.go | 2 | ||||
-rw-r--r-- | modules/packages/rubygems/metadata.go | 4 |
4 files changed, 9 insertions, 10 deletions
diff --git a/modules/migration/file_format.go b/modules/migration/file_format.go index 30e1d256cd..92cf71407d 100644 --- a/modules/migration/file_format.go +++ b/modules/migration/file_format.go @@ -8,12 +8,13 @@ import ( "fmt" "os" "strings" + "time" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" "github.com/santhosh-tekuri/jsonschema/v5" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) // Load project data from file, with optional validation @@ -84,13 +85,9 @@ func validate(bs []byte, datatype interface{}, isJSON bool) error { func toStringKeys(val interface{}) (interface{}, error) { var err error switch val := val.(type) { - case map[interface{}]interface{}: + case map[string]interface{}: m := make(map[string]interface{}) for k, v := range val { - k, ok := k.(string) - if !ok { - return nil, fmt.Errorf("found non-string key %T %s", k, k) - } m[k], err = toStringKeys(v) if err != nil { return nil, err @@ -106,6 +103,8 @@ func toStringKeys(val interface{}) (interface{}, error) { } } return l, nil + case time.Time: + return val.Format(time.RFC3339), nil default: return val, nil } diff --git a/modules/packages/helm/metadata.go b/modules/packages/helm/metadata.go index 9517448ca6..fb5e51d0c5 100644 --- a/modules/packages/helm/metadata.go +++ b/modules/packages/helm/metadata.go @@ -14,7 +14,7 @@ import ( "code.gitea.io/gitea/modules/validation" "github.com/hashicorp/go-version" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) var ( diff --git a/modules/packages/pub/metadata.go b/modules/packages/pub/metadata.go index 1fc4908b91..f3e9bf20bc 100644 --- a/modules/packages/pub/metadata.go +++ b/modules/packages/pub/metadata.go @@ -15,7 +15,7 @@ import ( "code.gitea.io/gitea/modules/validation" "github.com/hashicorp/go-version" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) var ( diff --git a/modules/packages/rubygems/metadata.go b/modules/packages/rubygems/metadata.go index 05c1a8a719..f1fc399918 100644 --- a/modules/packages/rubygems/metadata.go +++ b/modules/packages/rubygems/metadata.go @@ -14,7 +14,7 @@ import ( "code.gitea.io/gitea/modules/validation" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) var ( @@ -120,7 +120,7 @@ func (r requirement) AsVersionRequirement() []VersionRequirement { if !ok { continue } - vm, ok := req[1].(map[interface{}]interface{}) + vm, ok := req[1].(map[string]interface{}) if !ok { continue } |