Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Add data.github_team summary_only flag #1377

Closed
1 task done
alexlo03 opened this issue Nov 21, 2022 · 0 comments · Fixed by #1379
Closed
1 task done

[FEAT]: Add data.github_team summary_only flag #1377

alexlo03 opened this issue Nov 21, 2022 · 0 comments · Fixed by #1379
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@alexlo03
Copy link

alexlo03 commented Nov 21, 2022

Describe the need

The data source "github_team" should support summary_only flag similar to data source "organization_teams"
https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/organization_teams#summary_only

The github_team source downloads all the members and repos associated with the team, which makes it take O(minutes) whereas getting github_organization_teams takes O(seconds)

Here is where github_team source downloads all the members and repos:

if d.Get("membership_type").(string) == "all" {

Example:

# Define a repo, give a bunch of teams access by name (teams defined by IDP)

resource "github_repository" "default" {
# ...
}

locals = {
  # team slugs
  teams = ["team-one", "team-two", ...]
}

data "github_team" "the_team" {
  for_each = local.teams
  slug     = each.key
}

resource "github_team_repository" "team_repo" {
  for_each = local.teams

  team_id    = data.github_team.team[each.key].id

  repository = github_repository.default.name
  permission = ...
}

If you are struggling with this, we are working around by doing

# Define a repo, give a bunch of teams access by name (teams defined by IDP)

resource "github_repository" "default" {
# ...
}

locals = {
  # team slugs
  teams = ["team-one", "team-two", ...]
}

# Rather than download the teams needed, download all teams in summary_only view
data "github_organization_teams" "all" {
  summary_only = "true"
}

resource "github_team_repository" "team_repo" {
  for_each = {
    for team in data.github_organization_teams.all.teams
  : team.slug => team.id if contains(keys(local.teams), team.slug) }

  team_id    = data.github_team.team[each.key].id

  repository = github_repository.default.name
  permission = ...
}

SDK Version

5.8.0 (latest)

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@alexlo03 alexlo03 added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Nov 21, 2022
@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone Priority: Normal and removed Status: Triage This is being looked at and prioritized labels Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants