diff options
author | ewolinetz <ewolinet@redhat.com> | 2017-07-17 16:40:25 -0500 |
---|---|---|
committer | ewolinetz <ewolinet@redhat.com> | 2017-07-17 17:27:29 -0500 |
commit | 4c5554f1b84e00f110fbecab740df028916cfb64 (patch) | |
tree | 556de8b1a6866d2e6b9a1c55df48eb166f0d1222 /filter_plugins | |
parent | 9d041fddeed79b3af9eb2a76a93598c902eebbda (diff) | |
download | openshift-4c5554f1b84e00f110fbecab740df028916cfb64.tar.gz openshift-4c5554f1b84e00f110fbecab740df028916cfb64.tar.bz2 openshift-4c5554f1b84e00f110fbecab740df028916cfb64.tar.xz openshift-4c5554f1b84e00f110fbecab740df028916cfb64.zip |
Updating to compare sets instead of sorted lists
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/oo_filters.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 399e83bec..c6d0e69eb 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -1008,20 +1008,22 @@ def oo_random_word(length, source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS """ return ''.join(random.choice(source) for i in range(length)) + def oo_contains_rule(source, apiGroups, resources, verbs): '''Return true if the specified rule is contained within the provided source''' - rules=source['rules'] + rules = source['rules'] if rules: for rule in rules: - if rule['apiGroups'].sort() == apiGroups.sort(): - if rule['resources'].sort() == resources.sort(): - if rule['verbs'].sort() == verbs.sort(): + if set(rule['apiGroups']) == set(apiGroups): + if set(rule['resources']) == set(resources): + if set(rule['verbs']) == set(verbs): return True return False + class FilterModule(object): """ Custom ansible filter mapping """ |