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

View file

@ -1,3 +1,4 @@
import os
import ldap
import subprocess
@ -5,6 +6,7 @@ from app import app, config_provider
from data.users import LDAP_CERT_FILENAME
from data.users.externalldap import LDAPConnection, LDAPUsers
from util.config.validators import BaseValidator, ConfigValidationException
from _init import CONF_DIR
class LDAPValidator(BaseValidator):
name = "ldap"
@ -17,7 +19,7 @@ class LDAPValidator(BaseValidator):
# If there is a custom LDAP certificate, then reinstall the certificates for the container.
if config_provider.volume_file_exists(LDAP_CERT_FILENAME):
subprocess.check_call(['/conf/init/certs_install.sh'])
subprocess.check_call([os.path.join(CONF_DIR, 'init/certs_install.sh')])
# Note: raises ldap.INVALID_CREDENTIALS on failure
admin_dn = config.get('LDAP_ADMIN_DN')

View file

@ -3,6 +3,7 @@ from data import model
from util.names import parse_robot_username
from jinja2 import Environment, FileSystemLoader
def icon_path(icon_name):
return '%s/static/img/icons/%s.png' % (get_app_url(), icon_name)

View file

@ -1,4 +1,5 @@
import os
from _init import CONF_DIR
def logfile_path(jsonfmt=False, debug=False):
@ -19,7 +20,7 @@ def logfile_path(jsonfmt=False, debug=False):
if debug or os.getenv('DEBUGLOG', 'false').lower() == 'true':
_debug = "_debug"
return 'conf/logging%s%s.conf' % (_debug, _json)
return os.path.join(CONF_DIR, "logging%s%s.conf" % (_debug, _json))
def filter_logs(values, filtered_fields):

View file

@ -1,3 +1,4 @@
import os
import logging
from abc import ABCMeta, abstractmethod
@ -18,12 +19,13 @@ from util.secscan.validator import SecurityConfigValidator
from util.security.instancekeys import InstanceKeys
from util.security.registry_jwt import generate_bearer_token, build_context_and_subject
from _init import CONF_DIR
TOKEN_VALIDITY_LIFETIME_S = 60 # Amount of time the security scanner has to call the layer URL
UNKNOWN_PARENT_LAYER_ERROR_MSG = 'worker: parent layer is unknown, it must be processed first'
MITM_CERT_PATH = '/conf/mitm.cert'
MITM_CERT_PATH = os.path.join(CONF_DIR, '/mitm.cert')
DEFAULT_HTTP_HEADERS = {'Connection': 'close'}
logger = logging.getLogger(__name__)

View file

@ -1,7 +1,8 @@
import pytest
import os
from util.log import logfile_path, filter_logs
from app import FILTERED_VALUES
from _init import CONF_DIR
def test_filter_logs():
values = {
@ -16,20 +17,20 @@ def test_filter_logs():
@pytest.mark.parametrize('debug,jsonfmt,expected', [
(False, False, "conf/logging.conf"),
(False, True, "conf/logging_json.conf"),
(True, False, "conf/logging_debug.conf"),
(True, True, "conf/logging_debug_json.conf"),
(False, False, os.path.join(CONF_DIR, "logging.conf")),
(False, True, os.path.join(CONF_DIR, "logging_json.conf")),
(True, False, os.path.join(CONF_DIR, "logging_debug.conf")),
(True, True, os.path.join(CONF_DIR, "logging_debug_json.conf"))
])
def test_logfile_path(debug, jsonfmt, expected, monkeypatch):
assert logfile_path(jsonfmt=jsonfmt, debug=debug) == expected
@pytest.mark.parametrize('debug,jsonfmt,expected', [
("false", "false", "conf/logging.conf"),
("false", "true", "conf/logging_json.conf"),
("true", "false", "conf/logging_debug.conf"),
("true", "true", "conf/logging_debug_json.conf"),
("false", "false", os.path.join(CONF_DIR, "logging.conf")),
("false", "true", os.path.join(CONF_DIR, "logging_json.conf")),
("true", "false", os.path.join(CONF_DIR, "logging_debug.conf")),
("true", "true", os.path.join(CONF_DIR, "logging_debug_json.conf"))
])
def test_logfile_path_env(debug, jsonfmt, expected, monkeypatch):
monkeypatch.setenv("DEBUGLOG", debug)
@ -38,4 +39,4 @@ def test_logfile_path_env(debug, jsonfmt, expected, monkeypatch):
def test_logfile_path_default():
assert logfile_path() == "conf/logging.conf"
assert logfile_path() == os.path.join(CONF_DIR, "logging.conf")

View file

@ -1,3 +1,4 @@
import os
import json
import logging
@ -5,12 +6,14 @@ from flask_mail import Message
import features
from _init import ROOT_DIR
from app import mail, app, get_app_url
from util.jinjautil import get_template_env
logger = logging.getLogger(__name__)
template_env = get_template_env("emails")
template_env = get_template_env(os.path.join(ROOT_DIR, "emails"))
class CannotSendEmailException(Exception):