-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow using GitHub Team slug instead of name via connector config option #1297
Conversation
Yeah we'll need to do that so we don't break existing users :) |
1b37a0f
to
a7c998c
Compare
Implemented config property |
d617ca4
to
d5e4c7a
Compare
connector/github/github.go
Outdated
@@ -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)...) |
There was a problem hiding this comment.
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.
Documentation/connectors/github.md
Outdated
# 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' |
There was a problem hiding this comment.
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.
c663e8e
to
ccfa42b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, please squash
ccfa42b
to
bf39130
Compare
…ad-of-name Allow using GitHub Team slug instead of name via connector config option
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, andacme: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 acceptname|slug|both
and default toname
to keep backwards compatibility. On the other hand, it feels like unnecessary code and flexibility. Hopefully project owners can help to make a call.