summaryrefslogtreecommitdiffstats
path: root/filter_plugins
diff options
context:
space:
mode:
authorewolinetz <ewolinet@redhat.com>2017-07-17 10:02:32 -0500
committerewolinetz <ewolinet@redhat.com>2017-07-17 15:27:12 -0500
commit650149e1fa1e631775aac5ced9b22e03b3090f33 (patch)
treeb151f5c5f3e9b3f5988a8dc2145410643e38071a /filter_plugins
parentda7551b82fc37a77181a8c9aa9b82060b7101c5f (diff)
downloadopenshift-650149e1fa1e631775aac5ced9b22e03b3090f33.tar.gz
openshift-650149e1fa1e631775aac5ced9b22e03b3090f33.tar.bz2
openshift-650149e1fa1e631775aac5ced9b22e03b3090f33.tar.xz
openshift-650149e1fa1e631775aac5ced9b22e03b3090f33.zip
Updating to use oc replace and conditionally update edit and admin roles
Diffstat (limited to 'filter_plugins')
-rw-r--r--filter_plugins/oo_filters.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index cff9f8a60..399e83bec 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -1008,6 +1008,19 @@ 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']
+
+ if rules:
+ for rule in rules:
+ if rule['apiGroups'].sort() == apiGroups.sort():
+ if rule['resources'].sort() == resources.sort():
+ if rule['verbs'].sort() == verbs.sort():
+ return True
+
+ return False
class FilterModule(object):
""" Custom ansible filter mapping """
@@ -1049,5 +1062,6 @@ class FilterModule(object):
"oo_openshift_loadbalancer_frontends": oo_openshift_loadbalancer_frontends,
"oo_openshift_loadbalancer_backends": oo_openshift_loadbalancer_backends,
"to_padded_yaml": to_padded_yaml,
- "oo_random_word": oo_random_word
+ "oo_random_word": oo_random_word,
+ "oo_contains_rule": oo_contains_rule
}