From a34a4e93a3fb1015b6a8872c0e6da515a574f3cf Mon Sep 17 00:00:00 2001 From: Kamil Páral Date: Jul 10 2018 08:44:40 +0000 Subject: critpath: make config value optional This allows administrators to disable critpath checking by simply not pointing trigger to any critpath file (the default behavior after this patch). The job triggers will receive an empty critpath list set in this case. If a critpath file is set in the config file, the file has to exist and be valid. This improves reliability over the previous change in e67e56745ac. Fixes #54 --- diff --git a/README.rst b/README.rst index 0e3d63e..3df8591 100644 --- a/README.rst +++ b/README.rst @@ -102,7 +102,7 @@ Edit ``conf/trigger.cfg`` and set: * ``joblog_file`` and ``git_cache_dir`` to a path where you have write access * ``rules_template`` to a file with your trigger rules, you can use ``conf/trigger_rules.yml.example`` as a starting point - * ``critpath_filepath`` to a critpath definition, you can use + * ``critpath_filepath`` to a critpath definition (optional), you can use ``docker_data/critpath_whitelist.example`` as a starting point Once this is all done, you can run fedmsg-hub (while still having the diff --git a/conf/trigger.cfg.example b/conf/trigger.cfg.example index fa28a55..2ab6ef8 100644 --- a/conf/trigger.cfg.example +++ b/conf/trigger.cfg.example @@ -15,4 +15,5 @@ rules_template = /etc/taskotron/trigger_rules.yml deployment_type = prod ; possible values are: [prod,stg,dev] [koji_build_completed] -critpath_filepath = /var/lib/taskotron-trigger/critpath_whitelist +; critpath_filepath = /var/lib/taskotron-trigger/critpath_whitelist +critpath_filepath = diff --git a/jobtriggers/config.py b/jobtriggers/config.py index 929731e..9a5dfe6 100644 --- a/jobtriggers/config.py +++ b/jobtriggers/config.py @@ -19,7 +19,7 @@ rules_template = ./conf/trigger_rules.yml.example deployment_type = prod [koji_build_completed] -critpath_filepath = /var/lib/taskotron-trigger/critpath_whitelist +critpath_filepath = """ config = ConfigParser.ConfigParser() diff --git a/jobtriggers/utils.py b/jobtriggers/utils.py index cbbfb82..171693d 100644 --- a/jobtriggers/utils.py +++ b/jobtriggers/utils.py @@ -153,12 +153,11 @@ def git_repo_exists(repo): def get_critpath_pkgs(release): '''Parse critpath definition file and return a list of critpath packages - for a given release. If the file doesn't exist, return an empty list.''' - if not os.path.exists(config.critpath_filepath): + for a given release. If critpath_filepath config option is empty, return + an empty list.''' + if not config.critpath_filepath: return [] critpath = parse_yaml_from_file(config.critpath_filepath) - if not critpath: # file is empty - return [] distgit_branch = get_distgit_branch(release) critpath_pkgs = critpath['pkgs'].get(distgit_branch, critpath['pkgs']['master']) return critpath_pkgs