Merge lp:~hatch/charms/trusty/juju-gui/add-uuid-configjs into lp:~juju-gui/charms/trusty/juju-gui/trunk

Proposed by Jeff Pihach
Status: Merged
Approved by: Jeff Pihach
Approved revision: 233
Merged at revision: 231
Proposed branch: lp:~hatch/charms/trusty/juju-gui/add-uuid-configjs
Merge into: lp:~juju-gui/charms/trusty/juju-gui/trunk
Diff against target: 94 lines (+19/-5)
6 files modified
Makefile (+1/-1)
config/config.js.template (+2/-1)
hooks/backend.py (+2/-1)
hooks/utils.py (+2/-1)
tests/test_backends.py (+2/-1)
tests/test_utils.py (+10/-0)
To merge this branch: bzr merge lp:~hatch/charms/trusty/juju-gui/add-uuid-configjs
Reviewer Review Type Date Requested Status
Madison Scott-Clary (community) Approve
Francesco Banconi Approve
Review via email: mp+248826@code.launchpad.net

Description of the change

Supply the config.js file with the value from the JUJU_ENV_UUID value in supported versions of Juju.

To QA:
Deploy this charm and check that the config.js file sent to the gui has a key juju_env_uuid with a populated uuid value.

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :

This branch looks good Jeff, thank you!
I have some minor comments, and I'd add a test for write_gui_config in test_utils.py:TestStartImprovAgentGui,
similar to test_write_gui_config_with_version_from_jujud, but exercising the juju_env_uuid value.

QA ok.

review: Approve
233. By Jeff Pihach

Added additional test for the write_gui_config method around the uuid support

Revision history for this message
Madison Scott-Clary (makyo) wrote :

This LGTM, thanks Jeff! No QA.

review: Approve
Revision history for this message
Jeff Pihach (hatch) wrote :

Thanks for the reviews!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-01-05 16:23:48 +0000
3+++ Makefile 2015-02-09 15:38:10 +0000
4@@ -28,7 +28,7 @@
5 setup:
6 tests/00-setup
7 # Ensure the correct version of pip has been installed
8- tests/.venv/bin/pip --version | grep "pip 1.[4-9]" || exit 1
9+ tests/.venv/bin/pip --version | grep -E '1\.[4-9]\.|6\.[0-9]\.[0-9]' || exit 1
10
11 sysdeps:
12 sudo apt-get install --yes $(SYSDEPS)
13
14=== modified file 'config/config.js.template'
15--- config/config.js.template 2014-12-18 16:43:04 +0000
16+++ config/config.js.template 2015-02-09 15:38:10 +0000
17@@ -28,5 +28,6 @@
18 GA_key: {{ga_key}},
19 login_help: {{login_help}},
20 hideLoginButton: {{hide_login_button}},
21- jujuCoreVersion: {{juju_core_version}}
22+ jujuCoreVersion: {{juju_core_version}},
23+ jujuEnvUUID: {{juju_env_uuid}}
24 };
25
26=== modified file 'hooks/backend.py'
27--- hooks/backend.py 2014-12-18 16:43:04 +0000
28+++ hooks/backend.py 2015-02-09 15:38:10 +0000
29@@ -133,7 +133,8 @@
30 ga_key=config['ga-key'],
31 hide_login_button=config['hide-login-button'],
32 juju_core_version=config.get('juju-core-version'),
33- password=config.get('password'))
34+ password=config.get('password'),
35+ juju_env_uuid=os.getenv('JUJU_ENV_UUID', None))
36 # Set up TCP ports.
37 previous_port = backend.prev_config.get('port')
38 current_port = backend.config.get('port')
39
40=== modified file 'hooks/utils.py'
41--- hooks/utils.py 2014-12-18 16:43:04 +0000
42+++ hooks/utils.py 2015-02-09 15:38:10 +0000
43@@ -348,7 +348,7 @@
44 console_enabled, login_help, readonly, charmworld_url, charmstore_url,
45 build_dir, secure=True, sandbox=False, cached_fonts=False,
46 hide_login_button=False, config_js_path=None, ga_key='',
47- juju_core_version=None, password=None):
48+ juju_core_version=None, password=None, juju_env_uuid=None):
49 """Generate the GUI configuration file."""
50 log('Generating the Juju GUI configuration file.')
51 user = 'user-admin'
52@@ -414,6 +414,7 @@
53 'ga_key': json.dumps(ga_key),
54 'hide_login_button': json.dumps(hide_login_button),
55 'juju_core_version': json.dumps(juju_core_version),
56+ 'juju_env_uuid': json.dumps(juju_env_uuid),
57 }
58 if config_js_path is None:
59 config_js_path = os.path.join(
60
61=== modified file 'tests/test_backends.py'
62--- tests/test_backends.py 2014-12-18 16:43:04 +0000
63+++ tests/test_backends.py 2015-02-09 15:38:10 +0000
64@@ -203,7 +203,8 @@
65 secure=config['secure'], sandbox=config['sandbox'],
66 cached_fonts=config['cached-fonts'], ga_key=config['ga-key'],
67 juju_core_version=config['juju-core-version'],
68- hide_login_button=config['hide-login-button'], password=None)
69+ hide_login_button=config['hide-login-button'],
70+ juju_env_uuid=None, password=None)
71
72 def test_base_dir_created(self):
73 # The base Juju GUI directory is correctly created.
74
75=== modified file 'tests/test_utils.py'
76--- tests/test_utils.py 2014-12-18 16:43:04 +0000
77+++ tests/test_utils.py 2015-02-09 15:38:10 +0000
78@@ -976,6 +976,16 @@
79 'charmstoreURL: "http://charmstore.example.com/"', js_conf)
80 self.assertIn('GA_key: "UA-123456"', js_conf)
81
82+ def test_write_gui_config_uuid(self):
83+ # If the environment has the JUJU_ENV_UUID argument then it should
84+ # populate the config with the value.
85+ with mock.patch('os.environ', {'JUJU_ENV_UUID': 'long-uuid'}):
86+ write_gui_config(
87+ False, None, True, True, self.charmworld_url,
88+ self.charmstore_url, self.build_dir, config_js_path='config',
89+ juju_env_uuid=os.getenv('JUJU_ENV_UUID', None))
90+ self.assertIn('jujuEnvUUID: "long-uuid"', self.files['config'])
91+
92 def test_write_gui_config_insecure(self):
93 write_gui_config(
94 False, 'This is login help.', True, self.charmworld_url,

Subscribers

People subscribed via source and target branches

to all changes: