From 8f9469c9ac2391925b982bf387978756da578e40 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Tue, 13 Aug 2019 11:33:49 +1000 Subject: [PATCH] DCD-545: Move seraph logic into the template and generally clean-up. --- config/seraph-config.xml.j2 | 12 +++++++----- entrypoint.py | 33 +++++++++++---------------------- tests/test_image.py | 4 +--- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/config/seraph-config.xml.j2 b/config/seraph-config.xml.j2 index 8b16d54..1fd05e7 100644 --- a/config/seraph-config.xml.j2 +++ b/config/seraph-config.xml.j2 @@ -16,11 +16,13 @@ login.cookie.key seraph.confluence - - - autologin.cookie.age - {{ atl_autologin_cookie_age }} - + + {% if atl_autologin_cookie_age is defined %} + + autologin.cookie.age + {{ atl_autologin_cookie_age }} + + {% endif %} diff --git a/entrypoint.py b/entrypoint.py index 0456687..948f90b 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -10,6 +10,8 @@ import jinja2 as j2 ###################################################################### # Utils +logging.basicConfig(level=logging.DEBUG) + def set_perms(path, user, group, mode): shutil.chown(path, user=user, group=group) os.chmod(path, mode) @@ -26,8 +28,6 @@ def gen_cfg(tmpl, target, env, user='root', group='root', mode=0o644): fd.write(cfg) set_perms(target, user, group, mode) -logging.basicConfig(level=logging.DEBUG) - ###################################################################### # Setup inputs and outputs @@ -46,30 +46,19 @@ env['atl_product_home_shared'] = env.get('confluence_shared_home') ###################################################################### -# Generate server.xml for Tomcat. +# Generate all configuration files for Confluence -gen_cfg('server.xml.j2', env['confluence_install_dir']+'/conf/server.xml', env) +gen_cfg('server.xml.j2', + env['confluence_install_dir']+'/conf/server.xml', env) +gen_cfg('seraph-config.xml.j2', + env['confluence_install_dir']+'/confluence/WEB-INF/classes/seraph-config.xml', env) -###################################################################### -# Configure seraph login handling. +gen_cfg('confluence-init.properties.j2', + env['confluence_install_dir']+'/confluence/WEB-INF/classes/confluence-init.properties', env) -# The default is two weeks, in seconds, same as the seraph default. -env['atl_autologin_cookie_age'] = env.get('atl_autologin_cookie_age', "1209600") - -gen_cfg('seraph-config.xml.j2', env['confluence_install_dir']+'/confluence/WEB-INF/classes/seraph-config.xml', env) - - -###################################################################### -# Configure confluence-init.properties - - -gen_cfg('confluence-init.properties.j2', env['confluence_install_dir']+'/confluence/WEB-INF/classes/confluence-init.properties', env) - -###################################################################### -# Configure confluence.cfg.xml - -gen_cfg('confluence.cfg.xml.j2', env['confluence_home']+'/confluence.cfg.xml', env, +gen_cfg('confluence.cfg.xml.j2', + env['confluence_home']+'/confluence.cfg.xml', env, user=env['run_user'], group=env['run_group'], mode=0o640) diff --git a/tests/test_image.py b/tests/test_image.py index edacca4..f0b65a5 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -174,9 +174,7 @@ def test_seraph_defaults(docker_cli, image): wait_for_file(container, "/opt/atlassian/confluence/confluence/WEB-INF/classes/seraph-config.xml") xml = etree.fromstring(container.file('/opt/atlassian/confluence/confluence/WEB-INF/classes/seraph-config.xml').content) - param = xml.xpath('//param-name[text()="autologin.cookie.age"]')[0].getnext() - assert param.text == "1209600" - + param = xml.xpath('//param-name[text()="autologin.cookie.age"]') == [] def test_seraph_login_set(docker_cli, image): container = run_image(docker_cli, image, environment={"ATL_AUTOLOGIN_COOKIE_AGE": "TEST_VAL"})