summaryrefslogtreecommitdiffstats
path: root/roles/openshift_sanitize_inventory/filter_plugins/openshift_sanitize_inventory.py
blob: 14f1f72c26ce5fb73ee69928e5f49fa25a851a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
 Openshift Sanitize inventory class that provides useful filters used in Logging.
'''


import re


def vars_with_pattern(source, pattern=""):
    ''' Returns a list of variables whose name matches the given pattern '''
    if source == '':
        return list()

    var_list = list()

    var_pattern = re.compile(pattern)

    for item in source:
        if var_pattern.match(item):
            var_list.append(item)

    return var_list


# pylint: disable=too-few-public-methods
class FilterModule(object):
    ''' OpenShift Logging Filters '''

    # pylint: disable=no-self-use, too-few-public-methods
    def filters(self):
        ''' Returns the names of the filters provided by this class '''
        return {
            'vars_with_pattern': vars_with_pattern
        }