diff options
author | Eric Wolinetz <ewolinet@redhat.com> | 2017-10-25 20:45:34 -0500 |
---|---|---|
committer | Eric Wolinetz <ewolinet@redhat.com> | 2018-01-02 11:16:04 -0600 |
commit | 8cb27ae800df71ee816852df56cd2c861a0f0a0a (patch) | |
tree | 9a3f000d6bb886296912df6de0ececdfe7783a53 /roles/openshift_logging/filter_plugins | |
parent | 332764e4541d8c922f2589a533bb56b2a2419ac1 (diff) | |
download | openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.tar.gz openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.tar.bz2 openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.tar.xz openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.zip |
Updating logging_facts to be able to pull values from config maps yaml files, use diffs to keep custom changes, white list certain settings when creating diffs
Diffstat (limited to 'roles/openshift_logging/filter_plugins')
-rw-r--r-- | roles/openshift_logging/filter_plugins/openshift_logging.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/roles/openshift_logging/filter_plugins/openshift_logging.py b/roles/openshift_logging/filter_plugins/openshift_logging.py index e1a5ea726..ba412b5a6 100644 --- a/roles/openshift_logging/filter_plugins/openshift_logging.py +++ b/roles/openshift_logging/filter_plugins/openshift_logging.py @@ -102,6 +102,28 @@ def serviceaccount_namespace(qualified_sa, default=None): return seg[-1] +def flatten_dict(data, parent_key=None): + """ This filter plugin will flatten a dict and its sublists into a single dict + """ + if not isinstance(data, dict): + raise RuntimeError("flatten_dict failed, expects to flatten a dict") + + merged = dict() + + for key in data: + if parent_key is not None: + insert_key = '.'.join((parent_key, key)) + else: + insert_key = key + + if isinstance(data[key], dict): + merged.update(flatten_dict(data[key], insert_key)) + else: + merged[insert_key] = data[key] + + return merged + + # pylint: disable=too-few-public-methods class FilterModule(object): ''' OpenShift Logging Filters ''' @@ -117,5 +139,6 @@ class FilterModule(object): 'es_storage': es_storage, 'serviceaccount_name': serviceaccount_name, 'serviceaccount_namespace': serviceaccount_namespace, - 'walk': walk + 'walk': walk, + "flatten_dict": flatten_dict } |