-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-metadata.py
More file actions
29 lines (21 loc) · 1.24 KB
/
Copy pathcheck-metadata.py
File metadata and controls
29 lines (21 loc) · 1.24 KB
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
import json
with open('/tmp/service-catalog-payload.json') as fp:
payload = json.load(fp)
catalog = payload['catalog.json']
messages = []
# Esnure that everyone has a GitHub URL specified.
github_url = catalog['meta'].get('github_url', None)
if not github_url:
messages.append["No `github_url` specified in the `meta` section of the file."]
if github_url and not github_url.startswith("https://github.com"):
messages.append("The `github_url` specified in the `meta` section of the file, doesn't seem to point to GitHub.")
# Ensure that priority 1 services have a pager_duty_url.
if catalog['priority'] < 2:
pager_duty_url = catalog['meta'].get('pager_duty_url', None)
if not pager_duty_url:
messages.append("No `pager_duty_url` specified in the `meta` section of the file. This is required for priority 1 services.")
if pager_duty_url and not pager_duty_url.startswith("https://pagerduty.com"):
messages.append("The `pager_duty_url` specified in the `meta` section of the file, doesn't seem to point to PagerDuty. This is required for priority 1 services.")
result = "fail" if len(messages) > 0 else "pass"
with open('/tmp/service-catalog-result.json', 'w') as fp:
json.dump({'result': result, 'message': "\n\n".join(messages)}, fp)