Created
August 25, 2020 20:16
-
-
Save lnattrass/1886b28bcfe85484fc88bfc7892cb6a8 to your computer and use it in GitHub Desktop.
Split Kubernetes Manifests to Directory
This file contains 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
#!/usr/bin/env python3 | |
import sys | |
import os | |
from ruamel.yaml import YAML | |
yaml = YAML() | |
infilename = sys.argv[1] | |
outfolder = sys.argv[2] | |
doc_counter=0 | |
with open(infilename) as infile: | |
docs = yaml.load_all(infile) | |
for doc in docs: | |
if not doc: | |
continue | |
outpath = f"{outfolder}/{doc['kind']}-{doc['metadata']['name']}.yaml" | |
print(f"Writing {outpath}") | |
with open(f"{outpath}", 'w') as outfile: | |
yaml.dump(doc, outfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment