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
=== modified file 'Makefile'
--- Makefile 2015-01-05 16:23:48 +0000
+++ Makefile 2015-02-09 15:38:10 +0000
@@ -28,7 +28,7 @@
28setup:28setup:
29 tests/00-setup29 tests/00-setup
30 # Ensure the correct version of pip has been installed30 # Ensure the correct version of pip has been installed
31 tests/.venv/bin/pip --version | grep "pip 1.[4-9]" || exit 131 tests/.venv/bin/pip --version | grep -E '1\.[4-9]\.|6\.[0-9]\.[0-9]' || exit 1
3232
33sysdeps:33sysdeps:
34 sudo apt-get install --yes $(SYSDEPS)34 sudo apt-get install --yes $(SYSDEPS)
3535
=== modified file 'config/config.js.template'
--- config/config.js.template 2014-12-18 16:43:04 +0000
+++ config/config.js.template 2015-02-09 15:38:10 +0000
@@ -28,5 +28,6 @@
28 GA_key: {{ga_key}},28 GA_key: {{ga_key}},
29 login_help: {{login_help}},29 login_help: {{login_help}},
30 hideLoginButton: {{hide_login_button}},30 hideLoginButton: {{hide_login_button}},
31 jujuCoreVersion: {{juju_core_version}}31 jujuCoreVersion: {{juju_core_version}},
32 jujuEnvUUID: {{juju_env_uuid}}
32};33};
3334
=== modified file 'hooks/backend.py'
--- hooks/backend.py 2014-12-18 16:43:04 +0000
+++ hooks/backend.py 2015-02-09 15:38:10 +0000
@@ -133,7 +133,8 @@
133 ga_key=config['ga-key'],133 ga_key=config['ga-key'],
134 hide_login_button=config['hide-login-button'],134 hide_login_button=config['hide-login-button'],
135 juju_core_version=config.get('juju-core-version'),135 juju_core_version=config.get('juju-core-version'),
136 password=config.get('password'))136 password=config.get('password'),
137 juju_env_uuid=os.getenv('JUJU_ENV_UUID', None))
137 # Set up TCP ports.138 # Set up TCP ports.
138 previous_port = backend.prev_config.get('port')139 previous_port = backend.prev_config.get('port')
139 current_port = backend.config.get('port')140 current_port = backend.config.get('port')
140141
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2014-12-18 16:43:04 +0000
+++ hooks/utils.py 2015-02-09 15:38:10 +0000
@@ -348,7 +348,7 @@
348 console_enabled, login_help, readonly, charmworld_url, charmstore_url,348 console_enabled, login_help, readonly, charmworld_url, charmstore_url,
349 build_dir, secure=True, sandbox=False, cached_fonts=False,349 build_dir, secure=True, sandbox=False, cached_fonts=False,
350 hide_login_button=False, config_js_path=None, ga_key='',350 hide_login_button=False, config_js_path=None, ga_key='',
351 juju_core_version=None, password=None):351 juju_core_version=None, password=None, juju_env_uuid=None):
352 """Generate the GUI configuration file."""352 """Generate the GUI configuration file."""
353 log('Generating the Juju GUI configuration file.')353 log('Generating the Juju GUI configuration file.')
354 user = 'user-admin'354 user = 'user-admin'
@@ -414,6 +414,7 @@
414 'ga_key': json.dumps(ga_key),414 'ga_key': json.dumps(ga_key),
415 'hide_login_button': json.dumps(hide_login_button),415 'hide_login_button': json.dumps(hide_login_button),
416 'juju_core_version': json.dumps(juju_core_version),416 'juju_core_version': json.dumps(juju_core_version),
417 'juju_env_uuid': json.dumps(juju_env_uuid),
417 }418 }
418 if config_js_path is None:419 if config_js_path is None:
419 config_js_path = os.path.join(420 config_js_path = os.path.join(
420421
=== modified file 'tests/test_backends.py'
--- tests/test_backends.py 2014-12-18 16:43:04 +0000
+++ tests/test_backends.py 2015-02-09 15:38:10 +0000
@@ -203,7 +203,8 @@
203 secure=config['secure'], sandbox=config['sandbox'],203 secure=config['secure'], sandbox=config['sandbox'],
204 cached_fonts=config['cached-fonts'], ga_key=config['ga-key'],204 cached_fonts=config['cached-fonts'], ga_key=config['ga-key'],
205 juju_core_version=config['juju-core-version'],205 juju_core_version=config['juju-core-version'],
206 hide_login_button=config['hide-login-button'], password=None)206 hide_login_button=config['hide-login-button'],
207 juju_env_uuid=None, password=None)
207208
208 def test_base_dir_created(self):209 def test_base_dir_created(self):
209 # The base Juju GUI directory is correctly created.210 # The base Juju GUI directory is correctly created.
210211
=== modified file 'tests/test_utils.py'
--- tests/test_utils.py 2014-12-18 16:43:04 +0000
+++ tests/test_utils.py 2015-02-09 15:38:10 +0000
@@ -976,6 +976,16 @@
976 'charmstoreURL: "http://charmstore.example.com/"', js_conf)976 'charmstoreURL: "http://charmstore.example.com/"', js_conf)
977 self.assertIn('GA_key: "UA-123456"', js_conf)977 self.assertIn('GA_key: "UA-123456"', js_conf)
978978
979 def test_write_gui_config_uuid(self):
980 # If the environment has the JUJU_ENV_UUID argument then it should
981 # populate the config with the value.
982 with mock.patch('os.environ', {'JUJU_ENV_UUID': 'long-uuid'}):
983 write_gui_config(
984 False, None, True, True, self.charmworld_url,
985 self.charmstore_url, self.build_dir, config_js_path='config',
986 juju_env_uuid=os.getenv('JUJU_ENV_UUID', None))
987 self.assertIn('jujuEnvUUID: "long-uuid"', self.files['config'])
988
979 def test_write_gui_config_insecure(self):989 def test_write_gui_config_insecure(self):
980 write_gui_config(990 write_gui_config(
981 False, 'This is login help.', True, self.charmworld_url,991 False, 'This is login help.', True, self.charmworld_url,

Subscribers

People subscribed via source and target branches

to all changes: