mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
don't surface entire node content in error message
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -60,7 +60,6 @@ var resIdStringTests = []struct {
|
||||
ResId{},
|
||||
"[noKind].[noVer].[noGrp]/[noName].[noNs]",
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
func TestResIdString(t *testing.T) {
|
||||
@@ -271,18 +270,18 @@ var ids = []ResId{
|
||||
},
|
||||
{
|
||||
Gvk: Gvk{
|
||||
Group: "rbac.authorization.k8s.io",
|
||||
Version: "v1",
|
||||
Kind: "ClusterRole",
|
||||
Group: "rbac.authorization.k8s.io",
|
||||
Version: "v1",
|
||||
Kind: "ClusterRole",
|
||||
isClusterScoped: true,
|
||||
},
|
||||
Name: "nm",
|
||||
},
|
||||
{
|
||||
Gvk: Gvk{
|
||||
Group: "rbac.authorization.k8s.io",
|
||||
Version: "v1",
|
||||
Kind: "ClusterRole",
|
||||
Group: "rbac.authorization.k8s.io",
|
||||
Version: "v1",
|
||||
Kind: "ClusterRole",
|
||||
isClusterScoped: true,
|
||||
},
|
||||
Name: "my.name",
|
||||
|
||||
Reference in New Issue
Block a user