Remove the wrappy layer.

This commit is contained in:
monopole
2021-03-10 05:38:39 -08:00
parent e4bbd04a43
commit 123a5d6e56
37 changed files with 1537 additions and 1750 deletions

View File

@@ -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())

View File

@@ -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