forked from replicatedhq/troubleshoot-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
concat.py
30 lines (25 loc) · 847 Bytes
/
concat.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
import yaml
# Open Collector yaml and convert it to dict
with open('./collectors.yaml') as collector:
data_collector = yaml.safe_load(collector)
# Open Analyzer yaml and convert it to dict
with open('./analyzers.yaml') as analyzer:
data_analyzer = yaml.safe_load(analyzer)
# Dict with the final spec
spec_final = {
"apiVersion": "troubleshoot.sh/v1beta2",
"kind": "SupportBundle",
"metadata": {
"name": "concat-spec",
},
"spec": {
"collectors": {},
"analyzers": {},
},
}
# Concat the Collectors and Analyzers specs
spec_final["spec"]["collectors"] = data_collector["spec"]["collectors"]
spec_final["spec"]["analyzers"] = data_analyzer["spec"]["analyzers"]
# Write final spec file
with open(r'support-bundle.yaml', 'w') as support_bundle_file:
spec_final_doc = yaml.dump(spec_final, support_bundle_file)