Ejemplo n.º 1
0
def create_teams_for_data(databag):
    client = set_up_github_client()
    organization = get_cc_organization(client)

    print("Creating and populating teams...")
    projects = databag["projects"]
    for project in projects:
        project_name = project["name"]
        print(
            f"    Creating and populating teams for project {project_name}...")
        roles = project["roles"]
        for role, members in roles.items():
            if PERMISSIONS[role] is None:
                print(f"    Skipping {role} as it has no privileges.")
                continue

            print(f"        Finding team for role {role}...")
            team = map_role_to_team(organization, project_name, role)
            print("        Done.")

            print(f"        Populating repos for team {team.name}...")
            repos = project["repos"]
            map_team_to_repos(organization, team, repos, True)
            set_team_repo_permissions(team, PERMISSIONS[role])
            print("        Done.")

            print(f"        Populating members for team {team.name}...")
            members = [member["github"] for member in members]
            map_team_to_members(client, team, members, True)
            print("        Done.")
        print("    Done.")
    print("Done.")
Ejemplo n.º 2
0
def set_labels(standard_labels, repo_specific_labels):
    """
    Set labels on all repos for the organisation. This is the main entrypoint of
    the module.
    """

    logger.log(logging.INFO, "Setting up...")
    client = set_up_github_client()
    organization = get_cc_organization(client)
    logger.log(log.SUCCESS, "done.")

    logger.log(logging.INFO, "Fetching repos...")
    repos = list(organization.get_repos())
    logger.log(log.SUCCESS, f"done. Found {len(repos)} repos.")

    for repo in repos:
        logger.log(logging.INFO, f"Getting labels for repo '{repo.name}'...")
        labels = standard_labels + repo_specific_labels.get(repo.name, [])
        logger.log(log.SUCCESS, f"done. Found {len(labels)} labels.")
        logger.log(logging.INFO, f"Syncing labels for repo '{repo.name}'...")
        map_repo_to_labels(repo, labels)
        logger.log(log.SUCCESS, "done.")
Ejemplo n.º 3
0
def create_codeowners_for_data(databag):
    set_up_git_user()

    client = set_up_github_client()
    organization = get_cc_organization(client)

    print("Identifying and fixing CODEOWNER issues...")
    projects = databag["projects"]
    for project in projects:
        project_name = project["name"]
        print("    Identifying and fixing CODEOWNER issues for project"
              f" {project_name}...")

        print("        Finding all teams...")
        roles = project["roles"]
        teams = get_teams(organization, project_name, roles)
        print(f"        Found {len(teams)} teams for project {project_name}.")

        print("        Checking all projects...")
        repos = project["repos"]
        for repo in repos:
            check_and_fix_repo(organization, repo, teams)
    print("Done")
Ejemplo n.º 4
0
def get_cc_repos(github):
    cc = get_cc_organization(github)
    return cc.get_repos()