mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add more resid test coverage.
This commit is contained in:
@@ -22,23 +22,30 @@ import (
|
||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||
)
|
||||
|
||||
// ResId conflates GroupVersionKind with a textual name to uniquely identify a kubernetes resource (object).
|
||||
// ResId is an immutable identifier of a k8s resource object.
|
||||
type ResId struct {
|
||||
// Gvk of the resource.
|
||||
gvKind gvk.Gvk
|
||||
// original name of the resource before transformation.
|
||||
|
||||
// name of the resource before transformation.
|
||||
name string
|
||||
// namePrefix of the resource
|
||||
// an untransformed resource has no prefix, fully transformed resource has an arbitrary number of prefixes
|
||||
// concatenated together.
|
||||
|
||||
// namePrefix of the resource.
|
||||
// An untransformed resource has no prefix.
|
||||
// A fully transformed resource has an arbitrary
|
||||
// number of prefixes concatenated together.
|
||||
prefix string
|
||||
// nameSuffix of the resource
|
||||
// an untransformed resource has no suffix, fully transformed resource has an arbitrary number of suffixes
|
||||
// concatenated together.
|
||||
|
||||
// nameSuffix of the resource.
|
||||
// An untransformed resource has no suffix.
|
||||
// A fully transformed resource has an arbitrary
|
||||
// number of suffixes concatenated together.
|
||||
suffix string
|
||||
// namespace the resource belongs to
|
||||
// an untransformed resource has no namespace, fully transformed resource has the namespace from
|
||||
// the top most overlay
|
||||
|
||||
// Namespace the resource belongs to.
|
||||
// An untransformed resource has no namespace.
|
||||
// A fully transformed resource has the namespace
|
||||
// from the top most overlay.
|
||||
namespace string
|
||||
}
|
||||
|
||||
@@ -108,10 +115,16 @@ func (n ResId) GvknString() string {
|
||||
return n.gvKind.String() + separator + n.name
|
||||
}
|
||||
|
||||
// GvknEquals return if two ResId have the same Group/Version/Kind and name
|
||||
// The comparison excludes prefix and suffix
|
||||
// GvknEquals returns true if the other id matches
|
||||
// Group/Version/Kind/name.
|
||||
func (n ResId) GvknEquals(id ResId) bool {
|
||||
return n.gvKind.Equals(id.gvKind) && n.name == id.name
|
||||
return n.name == id.name && n.gvKind.Equals(id.gvKind)
|
||||
}
|
||||
|
||||
// NsGvknEquals returns true if the other id matches
|
||||
// namespace/Group/Version/Kind/name.
|
||||
func (n ResId) NsGvknEquals(id ResId) bool {
|
||||
return n.namespace == id.namespace && n.GvknEquals(id)
|
||||
}
|
||||
|
||||
// Gvk returns Group/Version/Kind of the resource.
|
||||
|
||||
Reference in New Issue
Block a user