This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/boot.py

58 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2016-04-27 18:39:01 +00:00
from datetime import datetime, timedelta
from urlparse import urlunparse
2016-04-27 18:39:01 +00:00
import json
2016-04-27 18:39:01 +00:00
from jwkest.jwk import RSAKey
from jinja2 import Template
2016-04-27 18:39:01 +00:00
import release
from app import app
2016-04-27 18:39:01 +00:00
from data.database import ServiceKeyApprovalType
from data.model.release import set_region_release
2016-04-27 18:39:01 +00:00
from data.model.service_keys import generate_service_key, approve_service_key
from util.config.database import sync_database_with_config
2016-04-27 19:37:48 +00:00
from util.generatepresharedkey import generate_key
2016-04-28 14:04:04 +00:00
def create_quay_service_key():
2016-04-27 19:37:48 +00:00
quay_key, key_id = generate_key(None, 'quay', 'quay')
2016-04-27 18:39:01 +00:00
2016-04-27 19:37:48 +00:00
with open('/conf/quay.pem', mode='w') as f:
2016-04-27 18:39:01 +00:00
f.truncate(0)
2016-04-27 19:37:48 +00:00
f.write(quay_key.exportKey())
2016-04-27 18:39:01 +00:00
2016-04-27 19:37:48 +00:00
return key_id
2016-04-27 18:39:01 +00:00
2016-04-27 19:37:48 +00:00
def create_jwtproxy_conf(quay_key_id):
2016-04-28 19:29:21 +00:00
audience = app.config.get('JWTPROXY_AUDIENCE')
registry = audience + '/keys'
with open("/conf/jwtproxy_conf.yaml.jnj") as f:
template = Template(f.read())
rendered = template.render(
audience=audience,
2016-04-27 19:37:48 +00:00
registry=registry,
key_id=quay_key_id
)
with open('/conf/jwtproxy_conf.yaml', 'w') as f:
f.write(rendered)
def main():
if app.config.get('SETUP_COMPLETE', False):
sync_database_with_config(app.config)
2016-04-28 14:04:04 +00:00
quay_key_id = create_quay_service_key()
2016-04-27 19:37:48 +00:00
create_jwtproxy_conf(quay_key_id)
# Record deploy
if release.REGION and release.GIT_HEAD:
set_region_release(release.SERVICE, release.REGION, release.GIT_HEAD)
if __name__ == '__main__':
main()