mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Upgrade dependencies
This commit is contained in:
31
vendor/github.com/go-openapi/spec/.travis.yml
generated
vendored
31
vendor/github.com/go-openapi/spec/.travis.yml
generated
vendored
@@ -1,31 +0,0 @@
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- 1.16.x
|
||||
- 1.x
|
||||
arch:
|
||||
- amd64
|
||||
jobs:
|
||||
include:
|
||||
# only run fast tests on ppc64le
|
||||
- go: 1.x
|
||||
arch: ppc64le
|
||||
script:
|
||||
- gotestsum -f short-verbose -- ./...
|
||||
|
||||
# include linting job, but only for latest go version and amd64 arch
|
||||
- go: 1.x
|
||||
arch: amd64
|
||||
install:
|
||||
go get github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
script:
|
||||
- golangci-lint run --new-from-rev master
|
||||
|
||||
install:
|
||||
- GO111MODULE=off go get -u gotest.tools/gotestsum
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E=
|
||||
script:
|
||||
- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./...
|
11
vendor/github.com/go-openapi/spec/normalizer.go
generated
vendored
11
vendor/github.com/go-openapi/spec/normalizer.go
generated
vendored
@@ -40,7 +40,7 @@ const fileScheme = "file"
|
||||
//
|
||||
// The base path argument is assumed to be canonicalized (e.g. using normalizeBase()).
|
||||
func normalizeURI(refPath, base string) string {
|
||||
refURL, err := url.Parse(refPath)
|
||||
refURL, err := parseURL(refPath)
|
||||
if err != nil {
|
||||
specLogger.Printf("warning: invalid URI in $ref %q: %v", refPath, err)
|
||||
refURL, refPath = repairURI(refPath)
|
||||
@@ -58,7 +58,7 @@ func normalizeURI(refPath, base string) string {
|
||||
return refURL.String()
|
||||
}
|
||||
|
||||
baseURL, _ := url.Parse(base)
|
||||
baseURL, _ := parseURL(base)
|
||||
if path.IsAbs(refURL.Path) {
|
||||
baseURL.Path = refURL.Path
|
||||
} else if refURL.Path != "" {
|
||||
@@ -84,7 +84,6 @@ func normalizeURI(refPath, base string) string {
|
||||
// There is a special case for schemas that are anchored with an "id":
|
||||
// in that case, the rebasing is performed // against the id only if this is an anchor for the initial root document.
|
||||
// All other intermediate "id"'s found along the way are ignored for the purpose of rebasing.
|
||||
//
|
||||
func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
|
||||
debugLog("denormalizeRef called:\n$ref: %q\noriginal: %s\nroot ID:%s", ref.String(), originalRelativeBase, id)
|
||||
|
||||
@@ -94,7 +93,7 @@ func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
|
||||
}
|
||||
|
||||
if id != "" {
|
||||
idBaseURL, err := url.Parse(id)
|
||||
idBaseURL, err := parseURL(id)
|
||||
if err == nil { // if the schema id is not usable as a URI, ignore it
|
||||
if ref, ok := rebase(ref, idBaseURL, true); ok { // rebase, but keep references to root unchaged (do not want $ref: "")
|
||||
// $ref relative to the ID of the schema in the root document
|
||||
@@ -103,7 +102,7 @@ func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
|
||||
}
|
||||
}
|
||||
|
||||
originalRelativeBaseURL, _ := url.Parse(originalRelativeBase)
|
||||
originalRelativeBaseURL, _ := parseURL(originalRelativeBase)
|
||||
|
||||
r, _ := rebase(ref, originalRelativeBaseURL, false)
|
||||
|
||||
@@ -168,7 +167,7 @@ func normalizeRef(ref *Ref, relativeBase string) *Ref {
|
||||
//
|
||||
// See also: https://en.wikipedia.org/wiki/File_URI_scheme
|
||||
func normalizeBase(in string) string {
|
||||
u, err := url.Parse(in)
|
||||
u, err := parseURL(in)
|
||||
if err != nil {
|
||||
specLogger.Printf("warning: invalid URI in RelativeBase %q: %v", in, err)
|
||||
u, in = repairURI(in)
|
||||
|
3
vendor/github.com/go-openapi/spec/normalizer_nonwindows.go
generated
vendored
3
vendor/github.com/go-openapi/spec/normalizer_nonwindows.go
generated
vendored
@@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
@@ -34,7 +35,7 @@ func absPath(in string) string {
|
||||
}
|
||||
|
||||
func repairURI(in string) (*url.URL, string) {
|
||||
u, _ := url.Parse("")
|
||||
u, _ := parseURL("")
|
||||
debugLog("repaired URI: original: %q, repaired: %q", in, "")
|
||||
return u, ""
|
||||
}
|
||||
|
4
vendor/github.com/go-openapi/spec/normalizer_windows.go
generated
vendored
4
vendor/github.com/go-openapi/spec/normalizer_windows.go
generated
vendored
@@ -60,13 +60,13 @@ func repairURI(in string) (*url.URL, string) {
|
||||
const prefix = fileScheme + "://"
|
||||
if !strings.HasPrefix(in, prefix) {
|
||||
// giving up: resolve to empty path
|
||||
u, _ := url.Parse("")
|
||||
u, _ := parseURL("")
|
||||
|
||||
return u, ""
|
||||
}
|
||||
|
||||
// attempt the repair, stripping the scheme should be sufficient
|
||||
u, _ := url.Parse(strings.TrimPrefix(in, prefix))
|
||||
u, _ := parseURL(strings.TrimPrefix(in, prefix))
|
||||
debugLog("repaired URI: original: %q, repaired: %q", in, u.String())
|
||||
|
||||
return u, u.String()
|
||||
|
3
vendor/github.com/go-openapi/spec/schema.go
generated
vendored
3
vendor/github.com/go-openapi/spec/schema.go
generated
vendored
@@ -17,7 +17,6 @@ package spec
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/jsonpointer"
|
||||
@@ -145,7 +144,7 @@ func (r *SchemaURL) fromMap(v map[string]interface{}) error {
|
||||
}
|
||||
if vv, ok := v["$schema"]; ok {
|
||||
if str, ok := vv.(string); ok {
|
||||
u, err := url.Parse(str)
|
||||
u, err := parseURL(str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
8
vendor/github.com/go-openapi/spec/url_go18.go
generated
vendored
Normal file
8
vendor/github.com/go-openapi/spec/url_go18.go
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build !go1.19
|
||||
// +build !go1.19
|
||||
|
||||
package spec
|
||||
|
||||
import "net/url"
|
||||
|
||||
var parseURL = url.Parse
|
14
vendor/github.com/go-openapi/spec/url_go19.go
generated
vendored
Normal file
14
vendor/github.com/go-openapi/spec/url_go19.go
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//go:build go1.19
|
||||
// +build go1.19
|
||||
|
||||
package spec
|
||||
|
||||
import "net/url"
|
||||
|
||||
func parseURL(s string) (*url.URL, error) {
|
||||
u, err := url.Parse(s)
|
||||
if err == nil {
|
||||
u.OmitHost = false
|
||||
}
|
||||
return u, err
|
||||
}
|
4
vendor/github.com/go-openapi/swag/.golangci.yml
generated
vendored
4
vendor/github.com/go-openapi/swag/.golangci.yml
generated
vendored
@@ -48,3 +48,7 @@ linters:
|
||||
- goimports
|
||||
- tenv
|
||||
- golint
|
||||
- exhaustruct
|
||||
- nilnil
|
||||
- nonamedreturns
|
||||
- nosnakecase
|
||||
|
15
vendor/github.com/go-openapi/swag/doc.go
generated
vendored
15
vendor/github.com/go-openapi/swag/doc.go
generated
vendored
@@ -17,16 +17,15 @@ Package swag contains a bunch of helper functions for go-openapi and go-swagger
|
||||
|
||||
You may also use it standalone for your projects.
|
||||
|
||||
* convert between value and pointers for builtin types
|
||||
* convert from string to builtin types (wraps strconv)
|
||||
* fast json concatenation
|
||||
* search in path
|
||||
* load from file or http
|
||||
* name mangling
|
||||
|
||||
- convert between value and pointers for builtin types
|
||||
- convert from string to builtin types (wraps strconv)
|
||||
- fast json concatenation
|
||||
- search in path
|
||||
- load from file or http
|
||||
- name mangling
|
||||
|
||||
This repo has only few dependencies outside of the standard library:
|
||||
|
||||
* YAML utilities depend on gopkg.in/yaml.v2
|
||||
- YAML utilities depend on gopkg.in/yaml.v2
|
||||
*/
|
||||
package swag
|
||||
|
11
vendor/github.com/go-openapi/swag/loading.go
generated
vendored
11
vendor/github.com/go-openapi/swag/loading.go
generated
vendored
@@ -16,10 +16,11 @@ package swag
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
@@ -40,13 +41,13 @@ var LoadHTTPCustomHeaders = map[string]string{}
|
||||
|
||||
// LoadFromFileOrHTTP loads the bytes from a file or a remote http server based on the path passed in
|
||||
func LoadFromFileOrHTTP(path string) ([]byte, error) {
|
||||
return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(LoadHTTPTimeout))(path)
|
||||
return LoadStrategy(path, os.ReadFile, loadHTTPBytes(LoadHTTPTimeout))(path)
|
||||
}
|
||||
|
||||
// LoadFromFileOrHTTPWithTimeout loads the bytes from a file or a remote http server based on the path passed in
|
||||
// timeout arg allows for per request overriding of the request timeout
|
||||
func LoadFromFileOrHTTPWithTimeout(path string, timeout time.Duration) ([]byte, error) {
|
||||
return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(timeout))(path)
|
||||
return LoadStrategy(path, os.ReadFile, loadHTTPBytes(timeout))(path)
|
||||
}
|
||||
|
||||
// LoadStrategy returns a loader function for a given path or uri
|
||||
@@ -86,7 +87,7 @@ func LoadStrategy(path string, local, remote func(string) ([]byte, error)) func(
|
||||
func loadHTTPBytes(timeout time.Duration) func(path string) ([]byte, error) {
|
||||
return func(path string) ([]byte, error) {
|
||||
client := &http.Client{Timeout: timeout}
|
||||
req, err := http.NewRequest("GET", path, nil) // nolint: noctx
|
||||
req, err := http.NewRequest(http.MethodGet, path, nil) //nolint:noctx
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -115,6 +116,6 @@ func loadHTTPBytes(timeout time.Duration) func(path string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("could not access document at %q [%s] ", path, resp.Status)
|
||||
}
|
||||
|
||||
return ioutil.ReadAll(resp.Body)
|
||||
return io.ReadAll(resp.Body)
|
||||
}
|
||||
}
|
||||
|
17
vendor/github.com/go-openapi/swag/util.go
generated
vendored
17
vendor/github.com/go-openapi/swag/util.go
generated
vendored
@@ -99,10 +99,11 @@ const (
|
||||
)
|
||||
|
||||
// JoinByFormat joins a string array by a known format (e.g. swagger's collectionFormat attribute):
|
||||
// ssv: space separated value
|
||||
// tsv: tab separated value
|
||||
// pipes: pipe (|) separated value
|
||||
// csv: comma separated value (default)
|
||||
//
|
||||
// ssv: space separated value
|
||||
// tsv: tab separated value
|
||||
// pipes: pipe (|) separated value
|
||||
// csv: comma separated value (default)
|
||||
func JoinByFormat(data []string, format string) []string {
|
||||
if len(data) == 0 {
|
||||
return data
|
||||
@@ -124,11 +125,11 @@ func JoinByFormat(data []string, format string) []string {
|
||||
}
|
||||
|
||||
// SplitByFormat splits a string by a known format:
|
||||
// ssv: space separated value
|
||||
// tsv: tab separated value
|
||||
// pipes: pipe (|) separated value
|
||||
// csv: comma separated value (default)
|
||||
//
|
||||
// ssv: space separated value
|
||||
// tsv: tab separated value
|
||||
// pipes: pipe (|) separated value
|
||||
// csv: comma separated value (default)
|
||||
func SplitByFormat(data, format string) []string {
|
||||
if data == "" {
|
||||
return nil
|
||||
|
254
vendor/github.com/go-openapi/swag/yaml.go
generated
vendored
254
vendor/github.com/go-openapi/swag/yaml.go
generated
vendored
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/mailru/easyjson/jlexer"
|
||||
"github.com/mailru/easyjson/jwriter"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// YAMLMatcher matches yaml
|
||||
@@ -43,16 +43,126 @@ func YAMLToJSON(data interface{}) (json.RawMessage, error) {
|
||||
|
||||
// BytesToYAMLDoc converts a byte slice into a YAML document
|
||||
func BytesToYAMLDoc(data []byte) (interface{}, error) {
|
||||
var canary map[interface{}]interface{} // validate this is an object and not a different type
|
||||
if err := yaml.Unmarshal(data, &canary); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var document yaml.MapSlice // preserve order that is present in the document
|
||||
var document yaml.Node // preserve order that is present in the document
|
||||
if err := yaml.Unmarshal(data, &document); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return document, nil
|
||||
if document.Kind != yaml.DocumentNode || len(document.Content) != 1 || document.Content[0].Kind != yaml.MappingNode {
|
||||
return nil, fmt.Errorf("only YAML documents that are objects are supported")
|
||||
}
|
||||
return &document, nil
|
||||
}
|
||||
|
||||
func yamlNode(root *yaml.Node) (interface{}, error) {
|
||||
switch root.Kind {
|
||||
case yaml.DocumentNode:
|
||||
return yamlDocument(root)
|
||||
case yaml.SequenceNode:
|
||||
return yamlSequence(root)
|
||||
case yaml.MappingNode:
|
||||
return yamlMapping(root)
|
||||
case yaml.ScalarNode:
|
||||
return yamlScalar(root)
|
||||
case yaml.AliasNode:
|
||||
return yamlNode(root.Alias)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported YAML node type: %v", root.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
func yamlDocument(node *yaml.Node) (interface{}, error) {
|
||||
if len(node.Content) != 1 {
|
||||
return nil, fmt.Errorf("unexpected YAML Document node content length: %d", len(node.Content))
|
||||
}
|
||||
return yamlNode(node.Content[0])
|
||||
}
|
||||
|
||||
func yamlMapping(node *yaml.Node) (interface{}, error) {
|
||||
m := make(JSONMapSlice, len(node.Content)/2)
|
||||
|
||||
var j int
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
var nmi JSONMapItem
|
||||
k, err := yamlStringScalarC(node.Content[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decode YAML map key: %w", err)
|
||||
}
|
||||
nmi.Key = k
|
||||
v, err := yamlNode(node.Content[i+1])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process YAML map value for key %q: %w", k, err)
|
||||
}
|
||||
nmi.Value = v
|
||||
m[j] = nmi
|
||||
j++
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func yamlSequence(node *yaml.Node) (interface{}, error) {
|
||||
s := make([]interface{}, 0)
|
||||
|
||||
for i := 0; i < len(node.Content); i++ {
|
||||
|
||||
v, err := yamlNode(node.Content[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decode YAML sequence value: %w", err)
|
||||
}
|
||||
s = append(s, v)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
const ( // See https://yaml.org/type/
|
||||
yamlStringScalar = "tag:yaml.org,2002:str"
|
||||
yamlIntScalar = "tag:yaml.org,2002:int"
|
||||
yamlBoolScalar = "tag:yaml.org,2002:bool"
|
||||
yamlFloatScalar = "tag:yaml.org,2002:float"
|
||||
yamlTimestamp = "tag:yaml.org,2002:timestamp"
|
||||
yamlNull = "tag:yaml.org,2002:null"
|
||||
)
|
||||
|
||||
func yamlScalar(node *yaml.Node) (interface{}, error) {
|
||||
switch node.LongTag() {
|
||||
case yamlStringScalar:
|
||||
return node.Value, nil
|
||||
case yamlBoolScalar:
|
||||
b, err := strconv.ParseBool(node.Value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting bool content: %w", node.Value, err)
|
||||
}
|
||||
return b, nil
|
||||
case yamlIntScalar:
|
||||
i, err := strconv.ParseInt(node.Value, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting integer content: %w", node.Value, err)
|
||||
}
|
||||
return i, nil
|
||||
case yamlFloatScalar:
|
||||
f, err := strconv.ParseFloat(node.Value, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting float content: %w", node.Value, err)
|
||||
}
|
||||
return f, nil
|
||||
case yamlTimestamp:
|
||||
return node.Value, nil
|
||||
case yamlNull:
|
||||
return nil, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("YAML tag %q is not supported", node.LongTag())
|
||||
}
|
||||
}
|
||||
|
||||
func yamlStringScalarC(node *yaml.Node) (string, error) {
|
||||
if node.Kind != yaml.ScalarNode {
|
||||
return "", fmt.Errorf("expecting a string scalar but got %q", node.Kind)
|
||||
}
|
||||
switch node.LongTag() {
|
||||
case yamlStringScalar, yamlIntScalar, yamlFloatScalar:
|
||||
return node.Value, nil
|
||||
default:
|
||||
return "", fmt.Errorf("YAML tag %q is not supported as map key", node.LongTag())
|
||||
}
|
||||
}
|
||||
|
||||
// JSONMapSlice represent a JSON object, with the order of keys maintained
|
||||
@@ -105,6 +215,113 @@ func (s *JSONMapSlice) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
*s = result
|
||||
}
|
||||
|
||||
func (s JSONMapSlice) MarshalYAML() (interface{}, error) {
|
||||
var n yaml.Node
|
||||
n.Kind = yaml.DocumentNode
|
||||
var nodes []*yaml.Node
|
||||
for _, item := range s {
|
||||
nn, err := json2yaml(item.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ns := []*yaml.Node{
|
||||
{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlStringScalar,
|
||||
Value: item.Key,
|
||||
},
|
||||
nn,
|
||||
}
|
||||
nodes = append(nodes, ns...)
|
||||
}
|
||||
|
||||
n.Content = []*yaml.Node{
|
||||
{
|
||||
Kind: yaml.MappingNode,
|
||||
Content: nodes,
|
||||
},
|
||||
}
|
||||
|
||||
return yaml.Marshal(&n)
|
||||
}
|
||||
|
||||
func json2yaml(item interface{}) (*yaml.Node, error) {
|
||||
switch val := item.(type) {
|
||||
case JSONMapSlice:
|
||||
var n yaml.Node
|
||||
n.Kind = yaml.MappingNode
|
||||
for i := range val {
|
||||
childNode, err := json2yaml(&val[i].Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n.Content = append(n.Content, &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlStringScalar,
|
||||
Value: val[i].Key,
|
||||
}, childNode)
|
||||
}
|
||||
return &n, nil
|
||||
case map[string]interface{}:
|
||||
var n yaml.Node
|
||||
n.Kind = yaml.MappingNode
|
||||
for k, v := range val {
|
||||
childNode, err := json2yaml(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n.Content = append(n.Content, &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlStringScalar,
|
||||
Value: k,
|
||||
}, childNode)
|
||||
}
|
||||
return &n, nil
|
||||
case []interface{}:
|
||||
var n yaml.Node
|
||||
n.Kind = yaml.SequenceNode
|
||||
for i := range val {
|
||||
childNode, err := json2yaml(val[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n.Content = append(n.Content, childNode)
|
||||
}
|
||||
return &n, nil
|
||||
case string:
|
||||
return &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlStringScalar,
|
||||
Value: val,
|
||||
}, nil
|
||||
case float64:
|
||||
return &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlFloatScalar,
|
||||
Value: strconv.FormatFloat(val, 'f', -1, 64),
|
||||
}, nil
|
||||
case int64:
|
||||
return &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlIntScalar,
|
||||
Value: strconv.FormatInt(val, 10),
|
||||
}, nil
|
||||
case uint64:
|
||||
return &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlIntScalar,
|
||||
Value: strconv.FormatUint(val, 10),
|
||||
}, nil
|
||||
case bool:
|
||||
return &yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: yamlBoolScalar,
|
||||
Value: strconv.FormatBool(val),
|
||||
}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// JSONMapItem represents the value of a key in a JSON object held by JSONMapSlice
|
||||
type JSONMapItem struct {
|
||||
Key string
|
||||
@@ -173,23 +390,10 @@ func transformData(input interface{}) (out interface{}, err error) {
|
||||
}
|
||||
|
||||
switch in := input.(type) {
|
||||
case yaml.MapSlice:
|
||||
|
||||
o := make(JSONMapSlice, len(in))
|
||||
for i, mi := range in {
|
||||
var nmi JSONMapItem
|
||||
if nmi.Key, err = format(mi.Key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v, ert := transformData(mi.Value)
|
||||
if ert != nil {
|
||||
return nil, ert
|
||||
}
|
||||
nmi.Value = v
|
||||
o[i] = nmi
|
||||
}
|
||||
return o, nil
|
||||
case yaml.Node:
|
||||
return yamlNode(&in)
|
||||
case *yaml.Node:
|
||||
return yamlNode(in)
|
||||
case map[interface{}]interface{}:
|
||||
o := make(JSONMapSlice, 0, len(in))
|
||||
for ke, va := range in {
|
||||
|
Reference in New Issue
Block a user