aboutsummaryrefslogtreecommitdiffstats
path: root/anteater
diff options
context:
space:
mode:
authorJulien <zhang.jun3g@zte.com.cn>2017-06-15 11:24:57 +0800
committerJulien <zhang.jun3g@zte.com.cn>2017-06-18 00:49:41 +0800
commita211f19382a75d4322f7dd6f74ee694222735ff9 (patch)
tree0f17f655e87c4ff7be84a5be882ae7324d2a16d3 /anteater
parent9111f5ec7a6fbcec824d3c8d4018a7a6e109c466 (diff)
seperate exception rules for releng project
add optional project exception configuration file. for one project: configuration in project exception file and in gatechecks.yaml will be merged together for one project JIRA:RELENG-234 Change-Id: I7fff3082e837a478f155769fadd75533583543cd Signed-off-by: Julien <zhang.jun3g@zte.com.cn>
Diffstat (limited to 'anteater')
-rw-r--r--anteater/src/get_lists.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/anteater/src/get_lists.py b/anteater/src/get_lists.py
index 8941510..7d6d3f1 100644
--- a/anteater/src/get_lists.py
+++ b/anteater/src/get_lists.py
@@ -16,6 +16,8 @@
import anteater.utils.anteater_logger as antlog
import ConfigParser
+import copy
+import os
import yaml
import re
@@ -27,14 +29,45 @@ gate_checks = config.get('config', 'gate_checks')
with open(gate_checks, 'r') as f:
yl = yaml.safe_load(f)
+def _remove_nullvalue(contents):
+ if contents and len(contents) > 2 and 'nullvalue' in contents:
+ contents.remove('nullvalue')
+
+def _merge(org, ded):
+ ret = copy.deepcopy(org)
+ for key in list(set([k for k in org] + [k for k in ded])):
+ if key in org and key in ded:
+ ret[key] = list(set(ret[key] + ded[key]))
+ _remove_nullvalue(ret[key])
+ elif key in ded:
+ ret[key] = ded[key]
+ return ret
class GetLists(object):
def __init__(self, *args):
# Placeholder for future args if more filters are needed
self.args = args
+ self.loaded = False
+
+ def load_project_exception_file(self, project_config, project):
+ if self.loaded:
+ return
+ exception_file = None
+ for item in project_config:
+ if project in item:
+ exception_file = item.get(project)
+ if exception_file is not None:
+ with open(exception_file, 'r') as f:
+ ex = yaml.safe_load(f)
+ for key in ex:
+ if key in yl:
+ yl[key][project] = _merge(yl[key][project], ex.get(key, None)) \
+ if project in yl[key] else ex.get(key, None)
+ self.loaded = True
def binary_list(self, project):
project_list = False
+ self.load_project_exception_file(yl.get('project_config'), project)
try:
default_list = (yl['binaries']['binary_ignore'])
except KeyError:
@@ -58,6 +91,7 @@ class GetLists(object):
def file_audit_list(self, project):
project_list = False
+ self.load_project_exception_file(yl.get('project_config'), project)
try:
default_list = set((yl['file_audits']['file_names']))
except KeyError:
@@ -83,6 +117,7 @@ class GetLists(object):
def file_content_list(self, project):
project_list = False
+ self.load_project_exception_file(yl.get('project_config'), project)
try:
default_list = set((yl['file_audits']['file_contents']))
except KeyError: