github.com/shashidharatd/test-infra@v0.0.0-20171006011030-71304e1ca560/gubernator/update_config.py (about) 1 #!/usr/bin/env python 2 3 # Copyright 2017 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 """Updates the Gubernator configuration from the Prow configuration.""" 18 19 import argparse 20 import yaml 21 22 def main(prow_config, gubernator_config): 23 with open(prow_config) as prow_file: 24 prow_data = yaml.load(prow_file) 25 26 default_presubmits = set() 27 for job in prow_data['presubmits']['kubernetes/kubernetes']: 28 if job.get('always_run'): 29 default_presubmits.add(job['name']) 30 31 with open(gubernator_config) as gubernator_file: 32 gubernator_data = yaml.load(gubernator_file) 33 34 gubernator_data['jobs']['kubernetes-jenkins/pr-logs/directory/'] = sorted( 35 default_presubmits) 36 37 with open(gubernator_config, 'w+') as gubernator_file: 38 yaml.dump(gubernator_data, gubernator_file, default_flow_style=False, 39 explicit_start=True) 40 41 if __name__ == '__main__': 42 PARSER = argparse.ArgumentParser() 43 PARSER.add_argument('prow_config', help="Path to Prow configuration YAML.") 44 PARSER.add_argument('gubernator_config', help="Path to Gubernator configuration YAML.") 45 ARGS = PARSER.parse_args() 46 main(ARGS.prow_config, ARGS.gubernator_config)