Add FEATURE_SIGNING flag and refactor nginx_conf_create.sh

This commit is contained in:
Evan Cordell 2017-02-16 16:30:31 -05:00
parent 16ec19d356
commit eac9927414
2 changed files with 20 additions and 22 deletions

View file

@ -6,21 +6,22 @@ import yaml
import jinja2 import jinja2
def write_config(filename, **kwargs):
with open(filename + ".jnj") as f:
template = jinja2.Template(f.read())
rendered = template.render(kwargs)
with open(filename, 'w') as f:
f.write(rendered)
def generate_nginx_config(): def generate_nginx_config():
""" """
Generates nginx config from the app config Generates nginx config from the app config
""" """
use_https = os.path.exists('conf/stack/ssl.key') use_https = os.path.exists('conf/stack/ssl.key')
write_config('conf/nginx/nginx.conf',
with open("conf/nginx/nginx.conf.jnj") as f: use_https=use_https)
template = jinja2.Template(f.read())
rendered = template.render(
use_https=use_https,
)
with open('conf/nginx/nginx.conf', 'w') as f:
f.write(rendered)
def generate_server_config(config): def generate_server_config(config):
@ -28,21 +29,15 @@ def generate_server_config(config):
Generates server config from the app config Generates server config from the app config
""" """
tuf_server = config.get('TUF_SERVER', None) tuf_server = config.get('TUF_SERVER', None)
signing_enabled = tuf_server is not None signing_enabled = config.get('FEATURE_SIGNING', False)
with open("conf/nginx/server-base.conf.jnj") as f: write_config('conf/nginx/server-base.conf',
template = jinja2.Template(f.read()) tuf_server=tuf_server,
rendered = template.render( signing_enabled=signing_enabled)
signing_enabled=signing_enabled,
tuf_server=tuf_server,
)
with open('conf/nginx/server-base.conf', 'w') as f:
f.write(rendered)
if __name__ == "__main__": if __name__ == "__main__":
with open('conf/stack/config.yaml', 'r') as f: with open('conf/stack/config.yaml', 'r') as f:
config = yaml.load(f) config = yaml.load(f)
generate_server_config(config) generate_server_config(config)
generate_nginx_config() generate_nginx_config()

View file

@ -168,7 +168,7 @@ class DefaultConfig(object):
# Feature Flag: Whether Dex login is supported. # Feature Flag: Whether Dex login is supported.
FEATURE_DEX_LOGIN = False FEATURE_DEX_LOGIN = False
# Feature flag: whether to enable support chat # Feature Flag: whether to enable support chat
FEATURE_SUPPORT_CHAT = False FEATURE_SUPPORT_CHAT = False
# Feature Flag: Whether to support GitHub build triggers. # Feature Flag: Whether to support GitHub build triggers.
@ -228,6 +228,9 @@ class DefaultConfig(object):
# Feature Flag: Whether to collect and support user metadata. # Feature Flag: Whether to collect and support user metadata.
FEATURE_USER_METADATA = False FEATURE_USER_METADATA = False
# Feature Flag: Whether to support signing
FEATURE_SIGNING = False
# The namespace to use for library repositories. # The namespace to use for library repositories.
# Note: This must remain 'library' until Docker removes their hard-coded namespace for libraries. # Note: This must remain 'library' until Docker removes their hard-coded namespace for libraries.
# See: https://github.com/docker/docker/blob/master/registry/session.go#L320 # See: https://github.com/docker/docker/blob/master/registry/session.go#L320