Skip to content
Snippets Groups Projects
Commit 575dbda5 authored by Nathaniel Kofalt's avatar Nathaniel Kofalt
Browse files

Add support for bootstraping projects and project-gear-rules

parent d5373588
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,25 @@ def users(filepath, api_url, http_headers, insecure):
role.setdefault('site', site_id)
r = _upsert_role(request_session=rs, api_url=api_url, role_doc=role, group_id=g['_id'])
r.raise_for_status()
log.info('bootstrapping projects...')
for p in input_data.get('projects', []):
r = rs.post(api_url + '/projects?inherit=true' , json=p)
r.raise_for_status()
project_id = r.json()['_id']
project_name = p['label']
for stanza in input_data.get('gear_rules', []):
desired_projects = stanza.get('projects', [])
rule = stanza.get('rule', None)
if project_name in desired_projects and rule:
log.info('Adding rule...')
r = rs.post(api_url + '/projects/' + project_id + '/rules', json=rule)
r.raise_for_status()
log.info('bootstrapping complete')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment