Merge lp:~bloodearnest/charms/trusty/gunicorn/fix-envs into lp:~bloodearnest/charms/trusty/gunicorn/trunk

Proposed by Simon Davy
Status: Merged
Merged at revision: 42
Proposed branch: lp:~bloodearnest/charms/trusty/gunicorn/fix-envs
Merge into: lp:~bloodearnest/charms/trusty/gunicorn/trunk
Diff against target: 103 lines (+19/-15)
4 files modified
hooks/tests/test_template.py (+7/-8)
templates/config.tmpl (+0/-7)
templates/runner.tmpl (+6/-0)
templates/upstart.tmpl (+6/-0)
To merge this branch: bzr merge lp:~bloodearnest/charms/trusty/gunicorn/fix-envs
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini (community) Approve
Simon Davy Pending
Review via email: mp+320635@code.launchpad.net

Commit message

Move env vars to upstart/runner templates rather than raw_env

Description of the change

Move env vars to upstart/runner templates rather than raw_env

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

LGTM! Thanks,

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/tests/test_template.py'
2--- hooks/tests/test_template.py 2016-10-10 13:07:21 +0000
3+++ hooks/tests/test_template.py 2017-03-22 13:59:43 +0000
4@@ -78,11 +78,14 @@
5 setgid WSGI_GROUP
6 chdir WORKING_DIR
7
8+ env A="1"
9+ env B="2 3"
10 exec GUNICORN_PATH WSGI_CLI --config WSGI_CONFIG_FILE WSGI_WSGI_FILE
11 """).strip()
12
13 def test_upstart_template(self):
14 ctx = self.get_test_context()
15+ ctx['env_extra'] = [['A', '1'], ['B', '2 3']]
16 hooks.process_template('upstart.tmpl', ctx, 'path')
17 output = self.file.write.call_args[0][0]
18 self.assertMultiLineEqual(self.UPSTART_EXPECTED, output)
19@@ -94,12 +97,16 @@
20 #--------------------------------------------------------------
21 # This file is managed by Juju; ANY CHANGES WILL BE OVERWRITTEN
22 #--------------------------------------------------------------
23+ export A="1"
24+ export B="2 3"
25 cd WORKING_DIR
26 GUNICORN_PATH WSGI_CLI --config WSGI_CONFIG_FILE $@ WSGI_WSGI_FILE
27 """).strip()
28
29 def test_runner_template(self):
30 ctx = self.get_test_context()
31+ ctx['env_extra'] = [['A', '1'], ['B', '2 3']]
32+ hooks.process_template('upstart.tmpl', ctx, 'path')
33 hooks.process_template('runner.tmpl', ctx, 'path')
34 output = self.file.write.call_args[0][0]
35 self.assertMultiLineEqual(self.RUNNER_EXPECTED, output)
36@@ -136,7 +143,6 @@
37 self.assertFalse(hasattr(mod, 'accesslog'))
38 self.assertFalse(hasattr(mod, 'access_log_format'))
39 self.assertFalse(hasattr(mod, 'pythonpath'))
40- self.assertFalse(hasattr(mod, 'raw_env'))
41
42 def test_access_logfile(self):
43 ctx = self.get_test_context()
44@@ -170,13 +176,6 @@
45 self.assert_basic(mod)
46 self.assertEqual(mod.pythonpath, 'PYTHONPATH')
47
48- def test_env_extra(self):
49- ctx = self.get_test_context()
50- ctx['env_extra'] = [['A', '1'], ['B', '2 3']]
51- mod = self.get_module(ctx)
52- self.assert_basic(mod)
53- self.assertEqual(mod.raw_env, ['A=1', 'B=2 3'])
54-
55 def test_config_extra(self):
56 ctx = self.get_test_context()
57 ctx['wsgi_extra_config_lines'] = ["x=1", "y=2"]
58
59=== modified file 'templates/config.tmpl'
60--- templates/config.tmpl 2016-10-10 13:07:21 +0000
61+++ templates/config.tmpl 2017-03-22 13:59:43 +0000
62@@ -31,10 +31,3 @@
63 {% for line in wsgi_extra_config_lines %}
64 {{ line }}
65 {% endfor %}
66-{% if env_extra %}
67-raw_env = [
68- {% for k,v in env_extra -%}
69- '{{k }}={{ v }}',
70- {% endfor -%}
71-]
72-{% endif %}
73
74=== modified file 'templates/runner.tmpl'
75--- templates/runner.tmpl 2015-09-25 13:59:18 +0000
76+++ templates/runner.tmpl 2017-03-22 13:59:43 +0000
77@@ -2,5 +2,11 @@
78 #--------------------------------------------------------------
79 # This file is managed by Juju; ANY CHANGES WILL BE OVERWRITTEN
80 #--------------------------------------------------------------
81+{% if env_extra -%}
82+{% for k, v in env_extra -%}
83+export {{ k }}="{{ v }}"
84+{% endfor -%}
85+{% endif -%}
86+
87 cd {{ working_dir }}
88 {{ gunicorn_path }} {{ wsgi_cli }} --config {{ wsgi_config_file }} $@ {{ wsgi_wsgi_file }}
89
90=== modified file 'templates/upstart.tmpl'
91--- templates/upstart.tmpl 2015-09-25 13:59:18 +0000
92+++ templates/upstart.tmpl 2017-03-22 13:59:43 +0000
93@@ -15,4 +15,10 @@
94 setgid {{ wsgi_group }}
95 chdir {{ working_dir }}
96
97+{% if env_extra -%}
98+{% for k, v in env_extra -%}
99+env {{ k }}="{{ v }}"
100+{% endfor -%}
101+{% endif -%}
102+
103 exec {{ gunicorn_path }} {{ wsgi_cli }} --config {{ wsgi_config_file }} {{ wsgi_wsgi_file }}

Subscribers

People subscribed via source and target branches

to all changes: