Skip to content

Instantly share code, notes, and snippets.

@srfrnk
Created July 26, 2019 12:38
Show Gist options
  • Select an option

  • Save srfrnk/385f2c1a0be392ac007c147126b3816f to your computer and use it in GitHub Desktop.

Select an option

Save srfrnk/385f2c1a0be392ac007c147126b3816f to your computer and use it in GitHub Desktop.
if filepath.Ext(mf.path) == ".json" {
// Unmarshal the YAML instead of directly marshaling to JSON to support future changes of kustomizationFile::marshal method:
k := make(map[string]interface{})
err := yaml.Unmarshal(data, &k)
if err != nil {
return err
}
// Remove `kind` and `apiVersion` so as make minimal changes to original source file:
delete(k, "kind")
delete(k, "apiVersion")
data, err = json.MarshalIndent(k, "", " ")
if err != nil {
return err
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment