don't surface entire node content in error message

This commit is contained in:
natasha41575
2021-12-22 15:41:22 -08:00
parent 233f1a3c2a
commit c659306ee2
7 changed files with 26 additions and 73 deletions

View File

@@ -6,6 +6,8 @@ package resid
import (
"reflect"
"strings"
"sigs.k8s.io/kustomize/kyaml/yaml"
)
// ResId is an identifier of a k8s resource object.
@@ -63,7 +65,7 @@ func FromString(s string) ResId {
gvk := GvkFromString(values[0])
values = strings.Split(values[1], fieldSep)
last := len(values)-1
last := len(values) - 1
ns := values[last]
if ns == noNamespace {
@@ -80,6 +82,13 @@ func FromString(s string) ResId {
}
}
// FromRNode returns the ResId for the RNode
func FromRNode(rn *yaml.RNode) ResId {
group, version := ParseGroupVersion(rn.GetApiVersion())
return NewResIdWithNamespace(
Gvk{Group: group, Version: version, Kind: rn.GetKind()}, rn.GetName(), rn.GetNamespace())
}
// GvknEquals returns true if the other id matches
// Group/Version/Kind/name.
func (id ResId) GvknEquals(o ResId) bool {