Skip to content

Commit e45f822

Browse files
committed
Refactor adobe_only_user_list checks together
Also improve logic such that NO combo of users and adobe_only_user_list is allowed (previously certain combos between invocation defaults and command line were accepted)
1 parent 4118a79 commit e45f822

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

user_sync/config.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ def load_invocation_options(self):
173173

174174
# --users and --adobe-only-user-list conflict with each other, so we need to disambiguate.
175175
# Argument specifications override configuration options, so you must have one or the other
176-
# either as an argument or as a configured default.
177-
if self.args['users'] and (self.args['adobe_only_user_list'] or options['adobe_only_user_list']):
176+
# either as an argument or as a configured default. For a complete check, we need to compare against
177+
# BOTH the args values AND the options values (in order to catch the invocation defaults).
178+
if (self.args['users'] or (options['users'] and options['users'] != self.invocation_defaults['users'])) \
179+
and (self.args['adobe_only_user_list'] or options['adobe_only_user_list']):
178180
# specifying both --users and --adobe-only-user-list is an error
179181
raise AssertionException('You cannot specify both a --users arg and an --adobe-only-user-list arg')
180182
elif self.args['users']:
@@ -188,14 +190,6 @@ def load_invocation_options(self):
188190
raise AssertionException('You cannot specify --adobe-only-user-list when using "push" strategy')
189191
users_spec = None
190192
stray_list_input_path = self.args['adobe_only_user_list']
191-
192-
# Check both that options['users'] exists, AND that it is not the default value before checking against
193-
# the adobe_only_user_list parameter - otherwise, defaults cause exception to be thrown unconditionally when
194-
# the user list option is specified
195-
elif (options['users'] and options['users'] != self.invocation_defaults['users']) and options['adobe_only_user_list']:
196-
raise AssertionException('You cannot configure both a default "users" option (%s) '
197-
'and a default "adobe-only-user-list" option (%s)' %
198-
(' '.join(options['users']), options['adobe_only_user_list']))
199193
elif options['adobe_only_user_list']:
200194
users_spec = None
201195
stray_list_input_path = options['adobe_only_user_list']

0 commit comments

Comments
 (0)