Merge ~hloeung/content-cache-charm:master into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 86b914847ae1c32d1c1617ef144f100a53bad2ba
Merged at revision: 950bb86f185e83c5214bde20c74c14b5099d8c06
Proposed branch: ~hloeung/content-cache-charm:master
Merge into: content-cache-charm:master
Diff against target: 61 lines (+5/-2)
5 files modified
reactive/content_cache.py (+1/-0)
templates/nginx_cfg.tmpl (+1/-1)
tests/unit/files/config_test_config.txt (+1/-0)
tests/unit/files/nginx_config_rendered_test_output-site5.txt (+1/-1)
tests/unit/test_nginx.py (+1/-0)
Reviewer Review Type Date Requested Status
Joel Sing (community) +1 Approve
Review via email: mp+366152@code.launchpad.net

Commit message

Allow overriding Nginx's 'location' modifier

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Joel Sing (jsing) wrote :

LGTM

review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 950bb86f185e83c5214bde20c74c14b5099d8c06

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/content_cache.py b/reactive/content_cache.py
2index d40c75a..7f4f3a3 100644
3--- a/reactive/content_cache.py
4+++ b/reactive/content_cache.py
5@@ -99,6 +99,7 @@ def configure_nginx(conf_path=None):
6 for location, loc_conf in site_conf.get('locations', {}).items():
7 conf['locations'][location] = {}
8 lc = conf['locations'][location]
9+ lc['modifier'] = loc_conf.get('modifier')
10
11 backend_port = loc_conf.get('backend_port')
12 if backend_port:
13diff --git a/templates/nginx_cfg.tmpl b/templates/nginx_cfg.tmpl
14index 25c6805..f84c6cc 100644
15--- a/templates/nginx_cfg.tmpl
16+++ b/templates/nginx_cfg.tmpl
17@@ -6,7 +6,7 @@ server {
18
19 {%- for location, conf in locations.items() %}
20
21- location {{ location }} {
22+ location {% if conf['modifier'] %}{{conf['modifier']}} {% endif %}{{ location }} {
23 {%- if conf['backend'] %}
24 proxy_pass {{conf['backend']}};
25 proxy_set_header Host "{{site}}";
26diff --git a/tests/unit/files/config_test_config.txt b/tests/unit/files/config_test_config.txt
27index 256217c..e074496 100644
28--- a/tests/unit/files/config_test_config.txt
29+++ b/tests/unit/files/config_test_config.txt
30@@ -63,5 +63,6 @@ site5:
31 backends:
32 - 127.0.1.10:80
33 /auth:
34+ modifier: '='
35 backends:
36 - 127.0.1.11:80
37diff --git a/tests/unit/files/nginx_config_rendered_test_output-site5.txt b/tests/unit/files/nginx_config_rendered_test_output-site5.txt
38index 3ff24d3..9425247 100644
39--- a/tests/unit/files/nginx_config_rendered_test_output-site5.txt
40+++ b/tests/unit/files/nginx_config_rendered_test_output-site5.txt
41@@ -17,7 +17,7 @@ server {
42 }
43
44
45- location /auth {
46+ location = /auth {
47 proxy_pass http://localhost:8084;
48 proxy_set_header Host "site5.local";
49 proxy_cache site5-cache;
50diff --git a/tests/unit/test_nginx.py b/tests/unit/test_nginx.py
51index f9ceb23..a58ef7e 100644
52--- a/tests/unit/test_nginx.py
53+++ b/tests/unit/test_nginx.py
54@@ -55,6 +55,7 @@ class TestLibNginx(unittest.TestCase):
55 for location, loc_conf in site_conf.get('locations', {}).items():
56 conf['locations'][location] = {}
57 lc = conf['locations'][location]
58+ lc['modifier'] = loc_conf.get('modifier')
59
60 if loc_conf.get('backends'):
61 backend_port += 1

Subscribers

People subscribed via source and target branches