Merge lp:~sidnei/juju-deployer/config-yaml-loader into lp:~gandelman-a/juju-deployer/trunk

Proposed by Sidnei da Silva
Status: Merged
Merged at revision: 71
Proposed branch: lp:~sidnei/juju-deployer/config-yaml-loader
Merge into: lp:~gandelman-a/juju-deployer/trunk
Diff against target: 47 lines (+4/-5)
1 file modified
deployer.py (+4/-5)
To merge this branch: bzr merge lp:~sidnei/juju-deployer/config-yaml-loader
Reviewer Review Type Date Requested Status
Adam Gandelman Pending
Review via email: mp+160481@code.launchpad.net

Commit message

Switch to using yaml to load the config, so it works with either json or yaml.

Description of the change

Switch to using yaml to load the config, so it works with either json or yaml.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer.py'
2--- deployer.py 2013-03-04 18:05:48 +0000
3+++ deployer.py 2013-04-23 19:54:26 +0000
4@@ -5,7 +5,6 @@
5 import time
6 import os
7 import yaml
8-import json
9 import optparse
10 import pprint
11 import signal
12@@ -24,7 +23,7 @@
13
14 parser = optparse.OptionParser()
15 parser.add_option('-c', '--config',
16- help=('File containing deployment(s) json config. This '
17+ help=('File containing deployment(s) config. This '
18 'option can be repeated, with later files overriding '
19 'values in earlier ones.'),
20 dest='configs', action='append')
21@@ -104,7 +103,7 @@
22 rc = find_service(juju_status(opts.juju_env), opts.find_service)
23 exit(rc)
24
25-# load the json configuration for possible deployments.
26+# load the configuration for possible deployments.
27 missing_configs = [c for c in opts.configs if not os.path.exists(c)]
28 if missing_configs:
29 log.error("Configuration not found: {}".format(", ".join(missing_configs)))
30@@ -117,7 +116,7 @@
31 include_dirs.append(dirname(abspath(config)))
32 with open(config, 'r') as f:
33 try:
34- cfg = dict_merge(cfg, json.load(f))
35+ cfg = dict_merge(cfg, yaml.safe_load(f))
36 except ValueError as exc:
37 log.error("Error parsing config: {}".format(config))
38 log.error(exc)
39@@ -205,7 +204,7 @@
40 if os.path.exists("%s/config.yaml" % charm_path):
41 debug_msg("Loading config.yaml from %s/config.yaml" % charm_path)
42 conf = open("%s/config.yaml" % charm_path)
43- CHARMS[k]["config"] = yaml.load(conf)["options"]
44+ CHARMS[k]["config"] = yaml.safe_load(conf)["options"]
45 conf.close()
46 if "units" not in CHARMS[k].keys():
47 CHARMS[k]["units"] = 1

Subscribers

People subscribed via source and target branches