From 70bffdf9d5f884dba209cb4f4050780c9feaed00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Armando=20Garc=C3=ADa=20Sancio?= Date: Mon, 27 Apr 2015 22:33:26 -0700 Subject: [PATCH] We should always merge option with the default If the user doesn't provide any options file then we should just use the generated default. If the user provides an options file then we should merge it with the generated defaults. --- cli/dcoscli/package/main.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cli/dcoscli/package/main.py b/cli/dcoscli/package/main.py index 594174e..0f9de96 100644 --- a/cli/dcoscli/package/main.py +++ b/cli/dcoscli/package/main.py @@ -298,18 +298,22 @@ def _install(package_name, options_path, app_id, cli, app): return 1 if options_path is None: - options = {} + user_options = {} else: - try: - with open(options_path) as options_file: - user_options = json.load(options_file) - options, err = pkg.options(pkg_version, user_options) - if err is not None: - emitter.publish(err) - return 1 - except Exception as e: - emitter.publish(errors.DefaultError(e.message)) + with open(options_path) as options_file: + user_options, err = util.load_json(options_file) + if err is not None: + emitter.publish(err) + return 1 + + try: + options, err = pkg.options(pkg_version, user_options) + if err is not None: + emitter.publish(err) return 1 + except Exception as e: + emitter.publish(errors.DefaultError(e.message)) + return 1 if app: # Install in Marathon