Skip to content

Instantly share code, notes, and snippets.

@aaronjwood
Created July 25, 2021 08:11
Show Gist options
  • Save aaronjwood/0299ae9a2e5dd43ccc8476dfcea1a219 to your computer and use it in GitHub Desktop.
Save aaronjwood/0299ae9a2e5dd43ccc8476dfcea1a219 to your computer and use it in GitHub Desktop.
Decode document into unstructured
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