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

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: af0a56f7e0d36242ce9aa1d2c8059c3d9e5e9539
Merged at revision: 043986307ab2aa9e5a9f1690cdde4ae7aaee8926
Proposed branch: ~hloeung/content-cache-charm:yaml
Merge into: content-cache-charm:master
Diff against target: 84 lines (+15/-9)
4 files modified
reactive/content_cache.py (+2/-0)
tests/unit/files/config_test_config.txt (+7/-9)
tests/unit/test_haproxy.py (+2/-0)
tests/unit/test_nginx.py (+4/-0)
Reviewer Review Type Date Requested Status
Paul Collins lgtm Approve
Canonical IS Reviewers Pending
Review via email: mp+390875@code.launchpad.net

Commit message

Allow specifying configs for use with YAML anchors and references - LP:1895614

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
Paul Collins (pjdc) :
review: Approve (lgtm)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 043986307ab2aa9e5a9f1690cdde4ae7aaee8926

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 97ce35f..5b15f8a 100644
3--- a/reactive/content_cache.py
4+++ b/reactive/content_cache.py
5@@ -541,6 +541,8 @@ def ports_map_lookup(ports_map, site, base_port, blacklist_ports=None, key=None)
6
7 def sites_from_config(sites_yaml, sites_secrets=None, blacklist_ports=None):
8 conf = yaml.safe_load(sites_yaml)
9+ # 'configs' is special and used to host YAML anchors so let's remove it
10+ conf.pop('configs', '')
11 sites = interpolate_secrets(conf, sites_secrets)
12 cache_port = 0
13 backend_port = 0
14diff --git a/tests/unit/files/config_test_config.txt b/tests/unit/files/config_test_config.txt
15index 25d69c9..bae4473 100644
16--- a/tests/unit/files/config_test_config.txt
17+++ b/tests/unit/files/config_test_config.txt
18@@ -1,13 +1,14 @@
19+configs:
20+ backends: &BACKENDS ['127.0.1.10:80', '127.0.1.11:80', '127.0.1.12:80']
21+ hmac_key: &HMAC_KEY SrRorTsImr92B6FfSKBFrSIiR5NYGS+gdjd8oGoVH44=
22+
23 # Test 1: The basic port and backends (HTTP)
24 site1.local:
25 port: 80
26 locations:
27 /:
28- backends:
29- - 127.0.1.10:80
30- - 127.0.1.11:80
31- - 127.0.1.12:80
32- signed-url-hmac-key: SrRorTsImr92B6FfSKBFrSIiR5NYGS+gdjd8oGoVH44=
33+ backends: *BACKENDS
34+ signed-url-hmac-key: *HMAC_KEY
35 origin-headers:
36 - X-Origin-Key: Sae6oob2aethuosh
37 - X-Some-Header-1: something one two three
38@@ -43,10 +44,7 @@ site3.local:
39 default: True
40 locations:
41 /:
42- backends:
43- - 127.0.1.10:80
44- - 127.0.1.11:80
45- - 127.0.1.12:80
46+ backends: *BACKENDS
47 backend-options:
48 - forwardfor except 127.0.0.1
49 - forceclose
50diff --git a/tests/unit/test_haproxy.py b/tests/unit/test_haproxy.py
51index 198879d..22e07d6 100644
52--- a/tests/unit/test_haproxy.py
53+++ b/tests/unit/test_haproxy.py
54@@ -20,6 +20,8 @@ class TestLibHAProxy(unittest.TestCase):
55 self.charm_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
56 with open('tests/unit/files/config_test_config.txt', 'r', encoding='utf-8') as f:
57 self.site_config = yaml.safe_load(f.read())
58+ # 'configs' is special and used to host YAML anchors so let's remove it
59+ self.site_config.pop('configs', '')
60
61 patcher = mock.patch('multiprocessing.cpu_count')
62 self.mock_cpu_count = patcher.start()
63diff --git a/tests/unit/test_nginx.py b/tests/unit/test_nginx.py
64index c7bcfe3..5ec7fbe 100644
65--- a/tests/unit/test_nginx.py
66+++ b/tests/unit/test_nginx.py
67@@ -44,6 +44,8 @@ class TestLibNginx(unittest.TestCase):
68
69 with open('tests/unit/files/config_test_config.txt', 'r', encoding='utf-8') as f:
70 sites = yaml.safe_load(f.read())
71+ # 'configs' is special and used to host YAML anchors so let's remove it
72+ sites.pop('configs', '')
73
74 conf = {}
75 conf['cache_inactive_time'] = '2h'
76@@ -128,6 +130,8 @@ class TestLibNginx(unittest.TestCase):
77
78 with open('tests/unit/files/config_test_basic_config.txt', 'r', encoding='utf-8') as f:
79 sites = yaml.safe_load(f.read())
80+ # 'configs' is special and used to host YAML anchors so let's remove it
81+ sites.pop('configs', '')
82
83 conf = {
84 'cache_inactive_time': '2h',

Subscribers

People subscribed via source and target branches