1
0
mirror of https://github.com/cmur2/kube-stale-resources.git synced 2024-12-22 12:54:25 +01:00

module: add formatting and linting configuration

- apply formatting
This commit is contained in:
Christian Nicolai 2019-12-16 12:09:56 +01:00 committed by Christian Nicolai
parent d5bb54cc8e
commit 79779b6377
3 changed files with 35 additions and 22 deletions

5
.pylintrc Normal file
View File

@ -0,0 +1,5 @@
[FORMAT]
max-line-length=121
[MESSAGES CONTROL]
disable=invalid-name,missing-module-docstring,missing-function-docstring

3
.style.yapf Normal file
View File

@ -0,0 +1,3 @@
[style]
based_on_style = pep8
column_limit = 120

View File

@ -4,10 +4,11 @@ import argparse
import re import re
import sys import sys
from typing import (List, Tuple, IO)
import requests import requests
import yaml import yaml
from typing import (List, Any, Dict, Tuple, IO)
K8sResourceIdentifier = Tuple[str, str, str, str] K8sResourceIdentifier = Tuple[str, str, str, str]
HEADERS = {"Content-Type": "application/json"} HEADERS = {"Content-Type": "application/json"}
@ -98,7 +99,7 @@ def get_compact_resource_identifiers(tuples: List[K8sResourceIdentifier]) -> Lis
return [namespace + ':' + apiVersion + ':' + kind + ':' + name for namespace, apiVersion, kind, name in tuples] return [namespace + ':' + apiVersion + ':' + kind + ':' + name for namespace, apiVersion, kind, name in tuples]
if __name__ == "__main__": def main():
parser = argparse.ArgumentParser(description='Utility to detect k8s configuration drift.') parser = argparse.ArgumentParser(description='Utility to detect k8s configuration drift.')
parser.add_argument('-f', parser.add_argument('-f',
@ -121,7 +122,7 @@ if __name__ == "__main__":
if args.blacklist_file: if args.blacklist_file:
print(f'Reading blacklist file {args.blacklist_file}...') print(f'Reading blacklist file {args.blacklist_file}...')
with open(args.blacklist_file, 'r') as f: with open(args.blacklist_file, 'r') as f:
blacklist_regexs += filter(lambda x: not re.match(r'^\s*$', x), f.read().split('\n')) blacklist_regexs += list(filter(lambda x: not re.match(r'^\s*$', x), f.read().split('\n')))
print('Retrieving target state...') print('Retrieving target state...')
if args.target_manifests_file == '-': if args.target_manifests_file == '-':
@ -154,3 +155,7 @@ if __name__ == "__main__":
counter += 1 counter += 1
print(' ' + x) print(' ' + x)
print("..", counter, "entries") print("..", counter, "entries")
if __name__ == "__main__":
main()