def get_branches_from_config_file(file_dir, filename): """Get all branches defined in a single service configuration file. A branch is defined for an instance if it has a 'branch' key, or the branch name is paasta-{cluster}.{instance}, where cluster is the cluster the marathon or chronos file is defined for (i.e. marathon-hab.yaml is for hab), and instance is the instance name. :param file_dir: The directory that the filename argument is in :param filename: The name of the service configuration file to read from :returns: A set of branch names listed in the configuration file """ valid_branches = set([]) config = service_configuration_lib.read_service_information( os.path.join(file_dir, filename)) for instance in config: target_branch = None if 'branch' in config[instance]: target_branch = config[instance]['branch'] else: try: # cluster may contain dashes (and frequently does) so # reassemble the cluster after stripping the chronos/marathon prefix cluster = '-'.join(filename.split('-')[1:]).split('.')[0] target_branch = get_paasta_branch(cluster, instance) except IndexError: pass if target_branch: valid_branches.add(target_branch) return valid_branches
def get_branches_from_config_file(file_dir, filename): """Get all branches defined in a single service configuration file. A branch is defined for an instance if it has a 'branch' key, or the branch name is paasta-{cluster}.{instance}, where cluster is the cluster the marathon or chronos file is defined for (i.e. marathon-hab.yaml is for hab), and instance is the instance name. :param file_dir: The directory that the filename argument is in :param filename: The name of the service configuration file to read from :returns: A set of branch names listed in the configuration file """ valid_branches = set([]) config = service_configuration_lib.read_service_information(os.path.join(file_dir, filename)) for instance in config: target_branch = None if "branch" in config[instance]: target_branch = config[instance]["branch"] else: try: # cluster may contain dashes (and frequently does) so # reassemble the cluster after stripping the chronos/marathon prefix cluster = "-".join(filename.split("-")[1:]).split(".")[0] target_branch = get_paasta_branch(cluster, instance) except IndexError: pass if target_branch: valid_branches.add(target_branch) return valid_branches
def _load_service_yamls_from_disk(): all_service_yamls = [] for root, dirs, files in os.walk(config.YELPSOA_CONFIG_ROOT): if "service.yaml" in files: all_service_yamls.append( service_configuration_lib.read_service_information( os.path.join(root, "service.yaml"))) return all_service_yamls