forked from RedHatInsights/clowder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest2template.py
executable file
·38 lines (29 loc) · 1.02 KB
/
manifest2template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import yaml
import sys
import os
import argparse
yamls = yaml.safe_load_all(sys.stdin)
parser = argparse.ArgumentParser(description="Convert kustomize manifest to template")
parser.add_argument('--mutate', dest="mutate", action="store_true",
help="flag to set if we should include the mutatingwebhookconfiguration")
parser.add_argument('--config', dest="config", action="store",
help="supply a config file to use as the clowder-config configmap"
)
args = parser.parse_args()
with open("template.yml") as fp:
template = yaml.safe_load(fp)
template["objects"].extend(yamls)
if not args.mutate:
delete = []
for i, object in enumerate(template["objects"]):
if object["kind"] == "MutatingWebhookConfiguration":
delete.append(i)
for item in delete:
del template["objects"][item]
if args.config:
with open(os.path.realpath(args.config)) as f:
data = f.read()
config = yaml.safe_load(data)
template["objects"].append(config)
print(yaml.dump(template))