Merge ~nick-moffitt/content-cache-charm:snapstore-cache-bug into content-cache-charm:master

Proposed by Nick Moffitt
Status: Merged
Approved by: Tom Haddon
Approved revision: 98df4d85093e192a8ca6708bb40f0eae2aa9deb4
Merged at revision: 6fa85fc947dbeddda6aff4d705481925af50130e
Proposed branch: ~nick-moffitt/content-cache-charm:snapstore-cache-bug
Merge into: content-cache-charm:master
Diff against target: 96 lines (+28/-19)
4 files modified
config.yaml (+5/-3)
reactive/content_cache.py (+1/-1)
tests/unit/files/config_test_secrets.txt (+5/-4)
tests/unit/test_content_cache.py (+17/-11)
Reviewer Review Type Date Requested Status
Tom Haddon (community) Approve
Nick Moffitt (community) Needs Resubmitting
Review via email: mp+367629@code.launchpad.net

Commit message

Make secrets yaml layout match config layout

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
Tom Haddon (mthaddon) wrote :

The config.yaml entry for site_secrets will need udpating too.

Revision history for this message
Nick Moffitt (nick-moffitt) :
review: Needs Resubmitting
Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM

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

Change successfully merged at revision 6fa85fc947dbeddda6aff4d705481925af50130e

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 7a2e6ee..cbd0b29 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -23,6 +23,8 @@ options:
6 description: |
7 YAML-formatted dictionary of secrets/keys. e.g.
8 site1.local:
9- origin-headers:
10- X-Origin-Key: my-origin-secret-key
11- signed-url-hmac-key: my-signed-url-secret-key
12+ locations:
13+ "/":
14+ origin-headers:
15+ X-Origin-Key: my-origin-secret-key
16+ signed-url-hmac-key: my-signed-url-secret-key
17diff --git a/reactive/content_cache.py b/reactive/content_cache.py
18index be5663a..a648087 100644
19--- a/reactive/content_cache.py
20+++ b/reactive/content_cache.py
21@@ -396,7 +396,7 @@ def interpolate_secrets(sites, secrets):
22 if not secrets or not secrets.get(site):
23 continue
24 for location, loc_conf in site_conf.get('locations', {}).items():
25- location_secrets = secrets.get(site).get(location)
26+ location_secrets = secrets.get(site).get('locations').get(location)
27
28 signed_url_hmac_key = loc_conf.get('signed-url-hmac-key')
29 if signed_url_hmac_key == '${secret}':
30diff --git a/tests/unit/files/config_test_secrets.txt b/tests/unit/files/config_test_secrets.txt
31index d28f0f8..ac0fb2b 100644
32--- a/tests/unit/files/config_test_secrets.txt
33+++ b/tests/unit/files/config_test_secrets.txt
34@@ -1,5 +1,6 @@
35 site1.local:
36- /:
37- origin-headers:
38- X-Origin-Key: Sae6oob2aethuosh
39- signed-url-hmac-key: xooBaLemenae6voopooz
40+ locations:
41+ /:
42+ origin-headers:
43+ X-Origin-Key: Sae6oob2aethuosh
44+ signed-url-hmac-key: xooBaLemenae6voopooz
45diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
46index d937c4b..00df816 100644
47--- a/tests/unit/test_content_cache.py
48+++ b/tests/unit/test_content_cache.py
49@@ -454,15 +454,18 @@ site5.local:
50 def test_secrets_from_config(self):
51 secrets_yaml = '''
52 site1.local:
53- /:
54- origin-headers:
55- X-Some-Header: myvalue
56+ locations:
57+ /:
58+ origin-headers:
59+ X-Some-Header: myvalue
60 '''
61 want = {
62 'site1.local': {
63- '/': {
64- 'origin-headers': {
65- 'X-Some-Header': 'myvalue',
66+ 'locations': {
67+ '/': {
68+ 'origin-headers': {
69+ 'X-Some-Header': 'myvalue',
70+ }
71 }
72 }
73 }
74@@ -475,14 +478,17 @@ site1.local:
75 def test_interpolate_secrets(self):
76 secrets = {
77 'site1.local': {
78- '/': {
79- 'origin-headers': {
80- 'X-Origin-Key': 'Sae6oob2aethuosh'
81- },
82- 'signed-url-hmac-key': 'Maiqu7ohmeiSh6ooroa0'
83+ 'locations': {
84+ '/': {
85+ 'origin-headers': {
86+ 'X-Origin-Key': 'Sae6oob2aethuosh'
87+ },
88+ 'signed-url-hmac-key': 'Maiqu7ohmeiSh6ooroa0'
89+ }
90 }
91 }
92 }
93+
94 config = {
95 'site1.local': {
96 'locations': {

Subscribers

People subscribed via source and target branches