Пример #1
0
environ_config = json.loads(os.environ.get(OVERRIDE_CONFIG_KEY, "{}"))
app.config.update(environ_config)

# Fix remote address handling for Flask.
if app.config.get("PROXY_COUNT", 1):
    app.wsgi_app = ProxyFix(app.wsgi_app, num_proxies=app.config.get("PROXY_COUNT", 1))

# Allow user to define a custom storage preference for the local instance.
_distributed_storage_preference = os.environ.get("QUAY_DISTRIBUTED_STORAGE_PREFERENCE", "").split()
if _distributed_storage_preference:
    app.config["DISTRIBUTED_STORAGE_PREFERENCE"] = _distributed_storage_preference

# Generate a secret key if none was specified.
if app.config["SECRET_KEY"] is None:
    logger.debug("Generating in-memory secret key")
    app.config["SECRET_KEY"] = generate_secret_key()

# If the "preferred" scheme is https, then http is not allowed. Therefore, ensure we have a secure
# session cookie.
if app.config["PREFERRED_URL_SCHEME"] == "https" and not app.config.get(
    "FORCE_NONSECURE_SESSION_COOKIE", False
):
    app.config["SESSION_COOKIE_SECURE"] = True

# Load features from config.
features.import_features(app.config)

CONFIG_DIGEST = hashlib.sha256(json.dumps(app.config, default=str)).hexdigest()[0:8]

logger.debug("Loaded config", extra={"config": app.config})
Пример #2
0
    app.config.get('OCI_NAMESPACE_PROPORTION') or 0,
    app.config.get('OCI_NAMESPACE_WHITELIST') or set(),
    app.config.get('V22_NAMESPACE_WHITELIST') or set(),
    app.config.get('V3_UPGRADE_MODE'))

# Allow user to define a custom storage preference for the local instance.
_distributed_storage_preference = os.environ.get(
    'QUAY_DISTRIBUTED_STORAGE_PREFERENCE', '').split()
if _distributed_storage_preference:
    app.config[
        'DISTRIBUTED_STORAGE_PREFERENCE'] = _distributed_storage_preference

# Generate a secret key if none was specified.
if app.config['SECRET_KEY'] is None:
    logger.debug('Generating in-memory secret key')
    app.config['SECRET_KEY'] = generate_secret_key()

# If the "preferred" scheme is https, then http is not allowed. Therefore, ensure we have a secure
# session cookie.
if (app.config['PREFERRED_URL_SCHEME'] == 'https'
        and not app.config.get('FORCE_NONSECURE_SESSION_COOKIE', False)):
    app.config['SESSION_COOKIE_SECURE'] = True

# Load features from config.
features.import_features(app.config)

CONFIG_DIGEST = hashlib.sha256(json.dumps(app.config,
                                          default=str)).hexdigest()[0:8]

logger.debug("Loaded config", extra={"config": app.config})