Created
July 25, 2021 08:11
-
-
Save aaronjwood/0299ae9a2e5dd43ccc8476dfcea1a219 to your computer and use it in GitHub Desktop.
Decode document into unstructured
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func decode(doc string) (*unstructured.Unstructured, *schema.GroupVersionKind, error) { | |
unstruct := &unstructured.Unstructured{} | |
_, gvk, err := scheme.Codecs.UniversalDeserializer().Decode([]byte(doc), nil, unstruct) | |
if err != nil { | |
return nil, nil, err | |
} | |
return unstruct, gvk, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment