From b78dc19d9b47f3347a99394ee839c02f5127a986 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Fri, 31 Oct 2014 13:58:39 +0100 Subject: Take plugin params from ENV rather than default The way the argparse options were being structured, if there was a default value set on the option it would use this value as the default and not check the environment variables. This is wrong, we expect the environment variables to be used and the default value to be the final fallback. Change-Id: Ifbd68c9de329c2e0c70824ba873caa579e8e86d0 Closes-Bug: #1388076 --- keystoneclient/auth/base.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'keystoneclient/auth/base.py') diff --git a/keystoneclient/auth/base.py b/keystoneclient/auth/base.py index 1f4ce29..4c743d9 100644 --- a/keystoneclient/auth/base.py +++ b/keystoneclient/auth/base.py @@ -155,14 +155,12 @@ class BaseAuthPlugin(object): args.append('--os-%s' % o.name) envs.append('OS_%s' % o.name.replace('-', '_').upper()) - default = opt.default - if default is None: - # select the first ENV that is not false-y or return None - env_vars = (os.environ.get(e) for e in envs) - default = six.next(six.moves.filter(None, env_vars), None) + # select the first ENV that is not false-y or return None + env_vars = (os.environ.get(e) for e in envs) + default = six.next(six.moves.filter(None, env_vars), None) parser.add_argument(*args, - default=default, + default=default or opt.default, metavar=opt.metavar, help=opt.help, dest='os_%s' % opt.dest) -- cgit v1.2.1