Adds a repository to a team with team_name.

    repo_name
        The name of the repository to add.

    team_name
        The name of the team of which to add the repository.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    permission
        The permission for team members within the repository, can be 'pull',
        'push' or 'admin'. If not specified, the default permission specified on
        the team will be used.

        .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team_repo 'my_repo' 'team_name'

    .. versionadded:: 2016.11.0

def add_team_repo(repo_name, team_name, profile="github", permission=None):
    '''
    Adds a repository to a team with team_name.

    repo_name
        The name of the repository to add.

    team_name
        The name of the team of which to add the repository.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    permission
        The permission for team members within the repository, can be 'pull',
        'push' or 'admin'. If not specified, the default permission specified on
        the team will be used.

        .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team_repo 'my_repo' 'team_name'

    .. versionadded:: 2016.11.0
    '''
    team = get_team(team_name, profile=profile)
    if not team:
        log.error('Team %s does not exist', team_name)
        return False
    try:
        client = _get_client(profile)
        organization = client.get_organization(
            _get_config_value(profile, 'org_name')
        )
        team = organization.get_team(team['id'])
        repo = organization.get_repo(repo_name)
    except UnknownObjectException:
        log.exception('Resource not found: %s', team['id'])
        return False
    params = None
    if permission is not None:
        params = {'permission': permission}

    headers, data = team._requester.requestJsonAndCheck(
        "PUT",
        team.url + "/repos/" + repo._identity,
        input=params
    )
    # Try to refresh cache
    list_team_repos(team_name, profile=profile, ignore_cache=True)
    return True