Skip to content

Commit

Permalink
Allow --gh-team-allowlist to work with team names and slugs (runatl…
Browse files Browse the repository at this point in the history
…antis#2719)

* Add team slugs

* Expand test to include both names and slugs

* docs: add version document of flag before/after

* docs: this will be merged for next release
  • Loading branch information
nitrocode authored and krrrr38 committed Dec 16, 2022
1 parent a1e4799 commit 412eea6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion runatlantis.io/docs/server-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,13 @@ Values are chosen in this order:
# or
ATLANTIS_GH_TEAM_ALLOWLIST="myteam:plan, secteam:apply, DevOps Team:apply"
```
Comma-separated list of GitHub team name (not a slug) and permission pairs. By default, any team can plan and apply.
In versions v0.21.0 and later, the GitHub team name can be a name or a slug.

In versions v0.20.1 and below, the Github team name required the case sensitive team name.

Comma-separated list of GitHub teams and permission pairs.

By default, any team can plan and apply.

::: warning NOTE
You should use the Team name as the variable, not the slug, even if it has spaces or special characters.
Expand Down
3 changes: 2 additions & 1 deletion server/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ func (g *GithubClient) GetTeamNamesForUser(repo models.Repo, user models.User) (
Edges []struct {
Node struct {
Name string
Slug string
}
}
PageInfo struct {
Expand All @@ -551,7 +552,7 @@ func (g *GithubClient) GetTeamNamesForUser(repo models.Repo, user models.User) (
return nil, err
}
for _, edge := range q.Organization.Teams.Edges {
teamNames = append(teamNames, edge.Node.Name)
teamNames = append(teamNames, edge.Node.Name, edge.Node.Slug)
}
if !q.Organization.Teams.PageInfo.HasNextPage {
break
Expand Down
6 changes: 3 additions & 3 deletions server/events/vcs/github_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,8 @@ func TestGithubClient_GetTeamNamesForUser(t *testing.T) {
"organization": {
"teams":{
"edges":[
{"node":{"name":"frontend-developers"}},
{"node":{"name":"employees"}}
{"node":{"name": "Frontend Developers", "slug":"frontend-developers"}},
{"node":{"name": "Employees", "slug":"employees"}}
],
"pageInfo":{
"endCursor":"Y3Vyc29yOnYyOpHOAFMoLQ==",
Expand Down Expand Up @@ -1168,5 +1168,5 @@ func TestGithubClient_GetTeamNamesForUser(t *testing.T) {
Username: "testuser",
})
Ok(t, err)
Equals(t, []string{"frontend-developers", "employees"}, teams)
Equals(t, []string{"Frontend Developers", "frontend-developers", "Employees", "employees"}, teams)
}

0 comments on commit 412eea6

Please sign in to comment.