mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
drop 'go-spew' dependencies and update dependencies (#6134)
* drop 'go-spew' dependencies * update dependencies * fix: change install method of golangci-lint
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
yaml "go.yaml.in/yaml/v3"
|
||||
"sigs.k8s.io/kustomize/kyaml/errors"
|
||||
)
|
||||
@@ -850,14 +849,33 @@ func ErrorIfInvalid(rn *RNode, kind yaml.Kind) error {
|
||||
|
||||
if kind == yaml.MappingNode {
|
||||
if len(rn.YNode().Content)%2 != 0 {
|
||||
content := rn.YNode().Content
|
||||
return errors.Errorf(
|
||||
"yaml MappingNodes must have even length contents: %v", spew.Sdump(rn))
|
||||
"yaml MappingNodes must have even length contents: content length %d, content summary: %s",
|
||||
len(content), mappingNodeContentSummary(content))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func mappingNodeContentSummary(content []*yaml.Node) string {
|
||||
if len(content) == 0 {
|
||||
return "[]"
|
||||
}
|
||||
summary := make([]string, 0, len(content))
|
||||
for i, node := range content {
|
||||
if node == nil {
|
||||
summary = append(summary, fmt.Sprintf("%d:<nil>", i))
|
||||
continue
|
||||
}
|
||||
summary = append(summary, fmt.Sprintf(
|
||||
"%d:{kind:%s tag:%q value:%q}",
|
||||
i, nodeKindString(node.Kind), node.Tag, node.Value))
|
||||
}
|
||||
return "[" + strings.Join(summary, ", ") + "]"
|
||||
}
|
||||
|
||||
// IsListIndex returns true if p is an index into a Val.
|
||||
// e.g. [fieldName=fieldValue]
|
||||
// e.g. [=primitiveValue]
|
||||
|
||||
@@ -1057,10 +1057,12 @@ func TestErrorIfInvalid(t *testing.T) {
|
||||
|
||||
err = ErrorIfInvalid(NewRNode(&yaml.Node{
|
||||
Kind: yaml.MappingNode,
|
||||
Content: []*yaml.Node{{}},
|
||||
Content: []*yaml.Node{{Kind: yaml.ScalarNode, Tag: NodeTagString, Value: "orphan"}},
|
||||
}), yaml.MappingNode)
|
||||
if assert.Error(t, err) {
|
||||
assert.Contains(t, err.Error(), "even length")
|
||||
assert.Contains(t, err.Error(), "content length 1")
|
||||
assert.Contains(t, err.Error(), `0:{kind:ScalarNode tag:"!!str" value:"orphan"}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user