-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add parent team id param #724
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
Add parent team id param #724
Conversation
github/orgs_teams.go
Outdated
Name *string `json:"name,omitempty"` | ||
Description *string `json:"description,omitempty"` | ||
Maintainers []*string `json:"maintainers,omitempty"` | ||
RepoNames []*string `json:"repo_names,omitempty"` |
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.
These two fields can be simplified to []string
.
You can look at other structures for example. We use pointers to basic types so it’s possible to tell if the field was missing or zero. Slices are already pointer types and can be nil if missing.
github/orgs_teams.go
Outdated
type NewTeam struct { | ||
ID *int `json:"id,omitempty"` | ||
Name *string `json:"name,omitempty"` | ||
Description *string `json:"description,omitempty"` |
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.
Are any of these fields required rather than optional?
If so, since this struct is used for providing input only, we can use values for mandatory fields.
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.
Yes, the ID
field is required. What you are suggesting makes sense.
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.
Great.
If you want to see some examples, see RequiredStatusChecks
and grep for "Required" and "Optional" in comments.
github/orgs_teams_test.go
Outdated
@@ -73,6 +73,7 @@ func TestOrganizationService_GetTeam_nestedTeams(t *testing.T) { | |||
testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview) | |||
fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", | |||
"parent": {"id":2, "name":"n", "description": "d", "parent": null}}`) | |||
|
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.
Was this line added by accident?
Thanks for providing the rationale for |
Related: #714 Looking forward to having this. I will plan to use it to implement |
I noticed and fixed a mistake I made - |
@@ -139,7 +164,7 @@ func (s *OrganizationsService) CreateTeam(ctx context.Context, org string, team | |||
// EditTeam edits a team. | |||
// | |||
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#edit-team | |||
func (s *OrganizationsService) EditTeam(ctx context.Context, id int, team *Team) (*Team, *Response, error) { | |||
func (s *OrganizationsService) EditTeam(ctx context.Context, id int, team *NewTeam) (*Team, *Response, error) { |
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.
It's odd that the EditTeam
endpoint requires both a name and an id for the team, but that is the documented behavior.
github/orgs_teams.go
Outdated
// TODO: decide whether to delete | ||
// LDAPDN is only available in GitHub Enterprise and when the team | ||
// membership is synchronized with LDAP. | ||
LDAPDN *string `json:"ldap_dn,omitempty"` |
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.
@e-beach I don't think LDAPDN
should be deleted. On GitHub Enterprise, it's allowed to add or update a team with this parameter. We use it in the Terraform GitHub provider too.
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.
Thanks for that feedback! I'll add it back in today, whoops.
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.
Thanks @e-beach!
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.
These are the only minor issues I see.
github/orgs_teams.go
Outdated
type NewTeam struct { | ||
|
||
// The name of the team (Required.) | ||
Name string `json:"name"` |
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.
Since there's no blank line after Name
field, and Description
doesn't have a comment of its own, this reads as if the comment above is for the whole block. You can make it inline to make it more readable. Also, maybe drop the "The" to shorten it.
Name string `json:"name"` // Name of the team. (Required.)
Description *string `json:"description,omitempty"`
...
github/orgs_teams.go
Outdated
@@ -114,10 +114,39 @@ func (s *OrganizationsService) GetTeam(ctx context.Context, team int) (*Team, *R | |||
return t, resp, nil | |||
} | |||
|
|||
// NewTeam represents a team to be created or modified. | |||
type NewTeam struct { | |||
|
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.
Is this blank line helpful? If not, let's remove it.
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
3e35f60
to
d526d52
Compare
LGTM, but 511f540 being in the commit list is a bit odd. Maybe rebased from the wrong spot? |
Yes. Sorry - I was occupied and just got to trying to fix this. I rebased from master, but I think that is actually unnecessary. Not sure why there are conflicting files. |
d526d52
to
94ed0c7
Compare
CLAs look good, thanks! |
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.
Thank you, @e-beach and @shurcooL!
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.
I rebased off of master, realized that was unnecessary and caused conflicts, so rebased off of NestedTeamsPreview and pushed again.
That's the way to go. 👍
Just some really minor comments left.
github/orgs_teams.go
Outdated
// using the new GitHub permission model. It no longer identifies the | ||
// permission a team has on its repos, but only specifies the default | ||
// permission a repo is initially added with. Avoid confusion by | ||
// specifying a permission value when calling AddTeamRepo. |
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.
@e-beach Are you familiar with the convention Go uses for deprecated symbols?
I think it would be nice to use here.
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.
That is copied from Team
so I'll fix it there as well:
go-github/github/orgs_teams.go
Lines 23 to 28 in 511f540
// Permission is deprecated when creating or editing a team in an org | |
// using the new GitHub permission model. It no longer identifies the | |
// permission a team has on its repos, but only specifies the default | |
// permission a repo is initially added with. Avoid confusion by | |
// specifying a permission value when calling AddTeamRepo. | |
Permission *string `json:"permission,omitempty"` |
That instance of Permission
no longer needs the deprecation notice, however, as the deprecation is only for functions where NewTeam
is now used.
github/orgs_teams.go
Outdated
@@ -114,10 +114,37 @@ func (s *OrganizationsService) GetTeam(ctx context.Context, team int) (*Team, *R | |||
return t, resp, nil | |||
} | |||
|
|||
// NewTeam represents a team to be created or modified. | |||
type NewTeam struct { | |||
Name string `json:"name"` // Name of the team (Required.) |
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.
Nitpicky, but I'd add a period at the end of the sentence. "Required" is another sentence inside parenthesis.
// Name of the team. (Required.)
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.
This how it's written elsewhere. See:
Line 552 in 511f540
// Require branches to be up to date before merging. (Required.) |
@shurcooL I believe I addressed your review. |
Thanks! Those adjustments look great. My LGTM from before still applies. Merging this to |
This replaces Team with NewTeam in function that accept a team for creating or editing a team. The NewTeam struct is similar to the existing NewPullRequest for creating pull requests. We need a new struct because the set of parameters for creating or editing a team contains some parameters that are not in the parameter for teams, and most properties of teams cannot be used for editing. The specific change is that Teams are returned with a parent field, but are created/edited with a parent_id field. Helps #714.
* Add support for fetching parent team (for nested teams). (#723) Create mediaTypeNestedTeamsPreview const for https://developer.github.com/changes/2017-08-30-preview-nested-teams/. Add parent field to the Team struct. Set preview API media type in endpoints that return a team, so that the new parent field gets populated. Helps #714. * Add NewTeam struct. (#724) This replaces Team with NewTeam in function that accept a team for creating or editing a team. The NewTeam struct is similar to the existing NewPullRequest for creating pull requests. We need a new struct because the set of parameters for creating or editing a team contains some parameters that are not in the parameter for teams, and most properties of teams cannot be used for editing. The specific change is that Teams are returned with a parent field, but are created/edited with a parent_id field. Helps #714. * Add NestedTeamsPreview header to remaining endpoints Fixes #714. * Change ParentTeamID field to int (from string). (#748) Using the code as written in the `NestedTeamsPreview` branch produces an error when talking to the GitHub API: panic: PATCH https://github.com/api/teams/2514825: 422 Invalid request. For 'properties/parent_team_id', "2514824" is not a number or null. [] The documentation at https://developer.github.com/v3/orgs/teams/#create-team states that this parameter is an id type which appears to mean an integer, not a string. Also, id is an integer in the sample responses for Get team endpoint, etc. * Bump libraryVersion * NestedTeamsPreview: Add the ListChildTeams endpoint (#758)
* Add support for fetching parent team (for nested teams). (google#723) Create mediaTypeNestedTeamsPreview const for https://developer.github.com/changes/2017-08-30-preview-nested-teams/. Add parent field to the Team struct. Set preview API media type in endpoints that return a team, so that the new parent field gets populated. Helps google#714. * Add NewTeam struct. (google#724) This replaces Team with NewTeam in function that accept a team for creating or editing a team. The NewTeam struct is similar to the existing NewPullRequest for creating pull requests. We need a new struct because the set of parameters for creating or editing a team contains some parameters that are not in the parameter for teams, and most properties of teams cannot be used for editing. The specific change is that Teams are returned with a parent field, but are created/edited with a parent_id field. Helps google#714. * Add NestedTeamsPreview header to remaining endpoints Fixes google#714. * Change ParentTeamID field to int (from string). (google#748) Using the code as written in the `NestedTeamsPreview` branch produces an error when talking to the GitHub API: panic: PATCH https://github.com/api/teams/2514825: 422 Invalid request. For 'properties/parent_team_id', "2514824" is not a number or null. [] The documentation at https://developer.github.com/v3/orgs/teams/#create-team states that this parameter is an id type which appears to mean an integer, not a string. Also, id is an integer in the sample responses for Get team endpoint, etc. * Bump libraryVersion * NestedTeamsPreview: Add the ListChildTeams endpoint (google#758)
This replaces
Team
withNewTeam
in function that accept a team for creating or editing a team.The
NewTeam
struct is similar to the existingNewPullRequest
for creating pull requests.We need a new struct because the set of parameters for creating or editing a team contains some parameters that are not in the parameter for teams, and most properties of teams cannot be used for editing.
The specific change is that Teams are returned with a
parent
field, but are created/edited with aparent_id
field.