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

Allow using GitHub Team slug instead of name via connector config option #1297

Merged

Conversation

tburko
Copy link
Contributor

@tburko tburko commented Sep 11, 2018

GitHub Team slug is arguably more script-friendly, and less surprising field to use for team names.

Compare acme:Full-time Technical Staff using name, and acme:full-time-technical-staff using slug.

The team slug is already being used by Terraform data module https://www.terraform.io/docs/providers/github/d/team.html for team lookups. Also https://github.com/google/go-github/ refers to teams by slug in a few places.

Our own tooling uses slug across internal systems. Not a strong argument in itself, just suspect that many other organizations are doing the same.

I have considered making the field choice configurable. Could easily add a connector Config property say teamNameField to accept name|slug|both and default to name to keep backwards compatibility. On the other hand, it feels like unnecessary code and flexibility. Hopefully project owners can help to make a call.

@ericchiang
Copy link
Contributor

Could easily add a connector Config property say teamNameField to accept name|slug|both and default to name to keep backwards compatibility.

Yeah we'll need to do that so we don't break existing users :)

@tburko tburko force-pushed the use-github-team-slug-instead-of-name branch from 1b37a0f to a7c998c Compare September 13, 2018 13:55
@tburko tburko changed the title Use GitHub Team slug instead of name Allow using GitHub Team slug instead of name via connector config option Sep 13, 2018
@tburko
Copy link
Contributor Author

tburko commented Sep 13, 2018

Implemented config property

@tburko tburko force-pushed the use-github-team-slug-instead-of-name branch 2 times, most recently from d617ca4 to d5e4c7a Compare September 13, 2018 14:17
@@ -586,7 +594,7 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client,

for _, team := range teams {
if team.Org.Login == orgName {
groups = append(groups, team.Name)
groups = append(groups, c.teamNamesExtractor(team)...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"teamNamesExtractor" is overkill. Just use a switch statement :) It's waaay more readable.

# Acme organization would yield:
# - ['acme:Site Reliability Engineers'] for 'name'
# - ['acme:site-reliability-engineers'] for 'slug'
# - ['acme:Site Reliability Engineers', 'acme:site-reliability-engineers'] for 'both'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a use case for 'both'? I'd rather we drop it if not. If we ever add another field (maybe ID?) 'both' becomes a weird setting.

@tburko tburko force-pushed the use-github-team-slug-instead-of-name branch from c663e8e to ccfa42b Compare September 13, 2018 20:13
Copy link
Contributor

@ericchiang ericchiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, please squash

@tburko tburko force-pushed the use-github-team-slug-instead-of-name branch from ccfa42b to bf39130 Compare September 13, 2018 22:10
@ericchiang ericchiang merged commit 06241ea into dexidp:master Sep 14, 2018
@tburko tburko deleted the use-github-team-slug-instead-of-name branch September 14, 2018 18:17
mmrath pushed a commit to mmrath/dex that referenced this pull request Sep 2, 2019
…ad-of-name

Allow using GitHub Team slug instead of name via connector config option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants