Merge lp:~simonklb/charm-helpers/include-empty-config-options into lp:charm-helpers

Proposed by Simon Kollberg
Status: Merged
Merged at revision: 652
Proposed branch: lp:~simonklb/charm-helpers/include-empty-config-options
Merge into: lp:charm-helpers
Diff against target: 26 lines (+4/-1)
2 files modified
charmhelpers/core/hookenv.py (+2/-0)
tests/core/test_hookenv.py (+2/-1)
To merge this branch: bzr merge lp:~simonklb/charm-helpers/include-empty-config-options
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
Casey Marshall (community) Approve
Cory Johns (community) Approve
Review via email: mp+309105@code.launchpad.net

Description of the change

See the issue in the commit message which caused this.

It's possible that this could break some charms if they are expect the config not to include the options with empty defaults which now will exist as None. I'm open to a less intrusive change if necessary.

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

I'm not certain of the impact this has on existing charms which you have called out, but I am +1 to the behavior change proposed here.

I expect the charm-helper config declaration properly translates the None type values to the python None. This should retain all the compatibility required to accept this change, as the inline code expects None's as well in these cases. Typically guarded like so:

if not config('foobar')

or

if config('foobar') is not None:

as two primary examples i've seen historically.

I'll reserve approval pending others perspective on the matter, but as a prelim i'm OK with this change.

Revision history for this message
Cory Johns (johnsca) wrote :

+1 from me. I can't see why this wouldn't have been the intended behavior from the get-go.

review: Approve
Revision history for this message
Casey Marshall (cmars) wrote :

LGTM

review: Approve
Revision history for this message
Charles Butler (lazypower) wrote :

Thanks for the contribution Simon! I've merged this branch into charm-helpers proper as of revision 652.

review: Approve
Revision history for this message
Charles Butler (lazypower) wrote :

Thanks for the contribution Simon! I've merged this branch into charm-helpers proper as of revision 652.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/core/hookenv.py'
2--- charmhelpers/core/hookenv.py 2016-09-07 16:37:01 +0000
3+++ charmhelpers/core/hookenv.py 2016-10-24 11:40:08 +0000
4@@ -332,6 +332,8 @@
5 config_cmd_line = ['config-get']
6 if scope is not None:
7 config_cmd_line.append(scope)
8+ else:
9+ config_cmd_line.append('--all')
10 config_cmd_line.append('--format=json')
11 try:
12 config_data = json.loads(
13
14=== modified file 'tests/core/test_hookenv.py'
15--- tests/core/test_hookenv.py 2016-09-07 00:09:32 +0000
16+++ tests/core/test_hookenv.py 2016-10-24 11:40:08 +0000
17@@ -351,7 +351,8 @@
18
19 self.assertIsInstance(result, hookenv.Config)
20 self.assertEqual(result['foo'], 'bar')
21- check_output.assert_called_with(['config-get', '--format=json'])
22+ check_output.assert_called_with(['config-get', '--all',
23+ '--format=json'])
24
25 @patch('charmhelpers.core.hookenv.os')
26 def test_gets_the_local_unit(self, os_):

Subscribers

People subscribed via source and target branches