mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 01:39:06 +00:00
Remove the wrappy layer.
This commit is contained in:
@@ -36,6 +36,14 @@ func ParseGroupVersion(apiVersion string) (group, version string) {
|
||||
// GvkFromString makes a Gvk from the output of Gvk.String().
|
||||
func GvkFromString(s string) Gvk {
|
||||
values := strings.Split(s, fieldSep)
|
||||
if len(values) != 3 {
|
||||
// ...then the string didn't come from Gvk.String().
|
||||
return Gvk{
|
||||
Group: noGroup,
|
||||
Version: noVersion,
|
||||
Kind: noKind,
|
||||
}
|
||||
}
|
||||
g := values[0]
|
||||
if g == noGroup {
|
||||
g = ""
|
||||
@@ -213,7 +221,10 @@ func (x Gvk) toKyamlTypeMeta() yaml.TypeMeta {
|
||||
}
|
||||
}
|
||||
|
||||
// IsNamespaceableKind returns true if x is a namespaceable Gvk
|
||||
// IsNamespaceableKind returns true if x is a namespaceable Gvk,
|
||||
// e.g. instances of Pod and Deployment are namespaceable,
|
||||
// but instances of Node and Namespace are not namespaceable.
|
||||
// Alternative name for this method: IsNotClusterScoped.
|
||||
// Implements https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#not-all-objects-are-in-a-namespace
|
||||
func (x Gvk) IsNamespaceableKind() bool {
|
||||
isNamespaceScoped, found := openapi.IsNamespaceScoped(x.toKyamlTypeMeta())
|
||||
|
||||
@@ -103,6 +103,12 @@ func TestString(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGvkFromString(t *testing.T) {
|
||||
for _, hey := range stringTests {
|
||||
assert.Equal(t, hey.x, GvkFromString(hey.s))
|
||||
}
|
||||
}
|
||||
|
||||
func TestApiVersion(t *testing.T) {
|
||||
for _, hey := range []struct {
|
||||
x Gvk
|
||||
|
||||
Reference in New Issue
Block a user