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

Return GitHub user suspended status (or some status/state) #978

Closed
mengesb opened this issue Nov 17, 2021 · 0 comments · Fixed by #1070
Closed

Return GitHub user suspended status (or some status/state) #978

mengesb opened this issue Nov 17, 2021 · 0 comments · Fixed by #1070
Labels
github_enterprise r/team_membership Type: Bug Something isn't working as documented

Comments

@mengesb
Copy link

mengesb commented Nov 17, 2021

Greetings,

I've been searching about in both go-github and githubv4 Go modules, and I'm thinking that maybe the GitHub API doesn't provide this information, but thought I'd give it a shot here at least.

When associating a GitHub user with a team and that user is suspended (this is particularly useful with GitHub Enterprise Server situations), Terraform repeatedly tries to (successfully, however always shows a diff to add) continuously add that suspended user to the team. I was thinking that I could potentially use the github_user data source, however in looking at the attributes of the data source, I don't see suspended or some other state related attribute. Perhaps this may be because the GitHub API doesn't transport this information either?

My hope was to iterate through a variable the list of users, and collect their status. If that status resulted in suspended, I would remove them from a local, which is used to build the github_team_membership resource. This would allow for a cleaner, more automatic state of the team, and also allow me to potentially test/warn on the plan - "The following users are potentially suspended: [list of users]". This would tell them to remove the user's membership from the running plan, but still result in a cleaner situation, instead of always showing a diff in resources (repeated attempt to add suspended user to a team). Failure would still occur doing a lookup of a deleted or invalid user, and that's still acceptable.

Unsure if there's another plausible work-around in the github_team_membership resource...

Terraform Version

= 0.12.0

Provider version

~> 4.0

Affected Resource(s)

Please list the resources as a list, for example:

  • data.github_user
  • github_team_membership

Terraform Configuration Files

# Something to the effect of

variable "members" {
  type = map(string)
  description = "Map of username to role in team"
  default = {}
}

data "github_user" "user" {
  for_each = var.members
  username = each.key
}

resource "github_team_membership" "membership" {
  for_each = [for k, v in var.members : { k => v } if data.github_user.user[k].status != "suspended"]
  username = each.key
  role = each.role
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

N/A

Actual Behavior

Suspended users added to a GitHub team are attempted to be re-added (silent failure masked as success)

Steps to Reproduce

  1. Suspend GitHub user
  2. terraform apply

Important Factoids

This is likely most relevent to GitHub Enterprise Server consumers, however there should be some kind of state information about the user - whether they're suspended or not.

References

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_enterprise r/team_membership Type: Bug Something isn't working as documented
Projects
None yet
2 participants