Use $QUAYPATH and $QUAYDIR in conf and init files

This commit is contained in:
Antoine Legrand 2017-02-02 00:17:25 +01:00 committed by Antoine Legrand
parent 334a08d90b
commit cdb3722c17
59 changed files with 341 additions and 225 deletions

8
boot.py Normal file → Executable file
View file

@ -13,6 +13,7 @@ from app import app
from data.model.release import set_region_release
from util.config.database import sync_database_with_config
from util.generatepresharedkey import generate_key
from _init import CONF_DIR
@lru_cache(maxsize=1)
@ -42,7 +43,7 @@ def setup_jwt_proxy():
"""
Creates a service key for quay to use in the jwtproxy and generates the JWT proxy configuration.
"""
if os.path.exists('conf/jwtproxy_conf.yaml'):
if os.path.exists(os.path.join(CONF_DIR, 'jwtproxy_conf.yaml')):
# Proxy is already setup.
return
@ -65,16 +66,17 @@ def setup_jwt_proxy():
registry = audience + '/keys'
security_issuer = app.config.get('SECURITY_SCANNER_ISSUER_NAME', 'security_scanner')
with open("conf/jwtproxy_conf.yaml.jnj") as f:
with open(os.path.join(CONF_DIR, 'jwtproxy_conf.yaml.jnj')) as f:
template = Template(f.read())
rendered = template.render(
conf_dir=CONF_DIR,
audience=audience,
registry=registry,
key_id=quay_key_id,
security_issuer=security_issuer,
)
with open('conf/jwtproxy_conf.yaml', 'w') as f:
with open(os.path.join(CONF_DIR, 'jwtproxy_conf.yaml'), 'w') as f:
f.write(rendered)