Skip to content

Add missing apps methods #733

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

Merged
merged 1 commit into from
Oct 30, 2017

Conversation

mandrean
Copy link
Contributor

@mandrean mandrean commented Sep 29, 2017

This pull request provides the missing apps methods and tests.

Fixes #734.

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Sep 29, 2017
@mandrean mandrean force-pushed the feat/add-missing-apps-methods branch from 3d78587 to 7136f17 Compare September 29, 2017 13:29
@googlebot googlebot added cla: no and removed cla: yes Indication that the PR author has signed a Google Contributor License Agreement. labels Sep 29, 2017
@mandrean mandrean force-pushed the feat/add-missing-apps-methods branch 2 times, most recently from 73cc038 to 56b2ed1 Compare September 29, 2017 13:37
@mandrean
Copy link
Contributor Author

Note: I accidentally pushed an incorrect squash, but fixed it. However, that caused googlebot to remove the cla: yes label. But I have signed the cla. Just FYI.

@google google deleted a comment from googlebot Sep 29, 2017
@googlebot googlebot added cla: yes Indication that the PR author has signed a Google Contributor License Agreement. and removed cla: no labels Sep 29, 2017
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @mandrean!
Just a few minor comments to address, and some advice requested from other reviewers.

github/apps.go Outdated
// the authenticated GitHub App.
//
// GitHub API docs: https://developer.github.com/v3/apps/#get-a-single-github-app
func (s *AppsService) Get(ctx context.Context, slug string) (*App, *Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please change slug to appSlug to match the docs and also add the following comment so that people don't have to follow the link to figure out what an appSlug is?

// Note: appSlug is just the URL-friendly name of your GitHub App.
// You can find this on the settings page for your GitHub App
// (e.g., https://github.com/settings/apps/:app_slug).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


// AppsService provides access to the installation related functions
// in the GitHub API.
//
// GitHub API docs: https://developer.github.com/v3/apps/
type AppsService service

// App represents a GitHub App.
type App struct {
ID *int `json:"id,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is actually more of a question for @shurcooL or @willnorris...

In the light of #597, do you think we should start using int64 for numeric IDs for new APIs in order to make the implementation of #597 easier (by providing an example and reducing the number of changes needed)?

Or do you think that we should remain internally consistent and just change everything all at once when #597 is addressed?

Copy link
Member

Choose a reason for hiding this comment

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

IMO it's unclear what the state of #597 is right now. The issue has been opened a while ago, but I haven't seen any reports of issues from production use. I'm not convinced that we should act right away, or how we should act. I think that we need to collect more data in that issue (or, wait until there's a concrete need to act).

Because of that, I think we should not try to incorporate that issue into this one. So, I suggest we stay consistent, and deal with int -> int64 changes (or another solution), if at all, later and separately from this PR.

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeIntegrationPreview)

var i struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@shurcooL - what do you think about making this a new type ... struct and include the TotalCount field, then returning a pointer to the struct in the return value of this method?

I'm asking because it seems more consistent with the rest of the package and also allows GitHub to add/tweak their response and we could more flexibly support it however they decide to tweak it.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, I think we should have this method return a pointer to a struct that corresponds to the JSON response in the documentation.

Returning []*Installation would've made sense if the GitHub response was a JSON array of installation objects, but it's a JSON object containing installations field with the array.

The only question is what to name it, if we make it exported (I think we have to, don't we?). Perhaps ListUserInstallationsResponse?

Copy link
Member

Choose a reason for hiding this comment

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

Then again, it's unfortunate it's quite different from the existing ListInstallations method (https://developer.github.com/v3/apps/#find-installations) which does return a JSON array of installations...

I can't help but think GitHub might've made the API inconsistent unintentionally and might want to change it while it's still in preview, so it'd be worth shooting them an email about it.

Copy link
Contributor Author

@mandrean mandrean Oct 3, 2017

Choose a reason for hiding this comment

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

@gmlewis @shurcooL I did this in my original contribution, but later removed it because I didn't see this pattern being used in other places in go-github where the same type of JSON structure was being handled.

I tried to stay "idiomatic" to your library. But personally I would have mimicked their JSON response as closely as possible.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't see this pattern being used in other places in go-github where the same type of JSON structure was being handled.

Mind sharing examples of that? It would be helpful.

Copy link
Contributor Author

@mandrean mandrean Oct 3, 2017

Choose a reason for hiding this comment

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

@shurcooL: This is currently in master: https://github.com/google/go-github/blob/master/github/apps_installation.go#L40

But as you can see in the GitHub API docs, the response actually has the total_count field: https://developer.github.com/v3/apps/installations/#list-repositories

So I just reused that same pattern for my ListUserRepos and ListUserInstallations contribution.

Copy link
Member

@dmitshur dmitshur Oct 3, 2017

Choose a reason for hiding this comment

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

Thanks!

@gmlewis What do you think about this finding?

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, looks like we do this elsewhere... I suppose that if the GitHub API starts expanding these return values to more than just total_count that we can then revisit making a named structure.
So I'm fine with proceeding as written.
Thanks, @mandrean and @shurcooL!

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeIntegrationPreview)

var r struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@shurcooL - Same for this one... make a new type ... struct and return it?

}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeIntegrationPreview)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this needed for this endpoint? I didn't see it in the link on line 57.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed!

@gmlewis gmlewis requested a review from dmitshur September 29, 2017 20:57
@mandrean mandrean force-pushed the feat/add-missing-apps-methods branch from 1580d77 to 0142ac9 Compare October 5, 2017 11:27
@itay
Copy link

itay commented Oct 23, 2017

Is there any update on this PR in terms of reviewing the updates from @mandrean ? It would be great to have those missing APIs, and it's hard to add them outside the library.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you, @mandrean.
Awaiting second LGTM before merging. @shurcooL may not be available currently, so I will request a review from @elliott-beach if he can.

@gmlewis gmlewis requested review from elliott-beach and removed request for dmitshur October 23, 2017 16:29
@gmlewis
Copy link
Collaborator

gmlewis commented Oct 23, 2017

@mandrean - would you mind resolving the merge conflicts?

@itay itay mentioned this pull request Oct 29, 2017
@dmitshur
Copy link
Member

dmitshur commented Oct 30, 2017

With the help of @itay and PR #769, I'll take care of the merge conflicts here by force pushing the squashed and rebased commit 15ad131 (with merge conflicts resolved) to the PR branch. I've confirmed that it's good and doesn't differ from the contents of this PR (aside from conflict resolution).

Edit: Done.

(For reference, the previous head commit of this PR was 0142ac9.)

@dmitshur dmitshur force-pushed the feat/add-missing-apps-methods branch from 0142ac9 to 15ad131 Compare October 30, 2017 06:43
Copy link
Member

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

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

I've reviewed at a high-level and didn't spot any major issues. Since this is new functionality, instead of spending an exorbitant amount of time reviewing it for low-level issues prior to merging, I'd prefer we merge it sooner and let people who want to use this API (e.g., @itay) test it out. If any issues or deviations from actual GitHub API are discovered through real-world use, they'll be easy to prioritize and address then. That seems like a more efficient way to move forward.

So, LGTM. It already has @gmlewis's LGTM, so I'll merge. Please let us know if any issues come up.

Thanks @mandrean and @itay (also @gmlewis for reviewing)!

@mandrean
Copy link
Contributor Author

mandrean commented Nov 2, 2017

Thanks everyone (and @shurcooL for fixing the merge conflicts - I totally missed @gmlewis question)

❤️

@mandrean mandrean deleted the feat/add-missing-apps-methods branch November 2, 2017 09:42
@dmitshur dmitshur mentioned this pull request Nov 7, 2017
nbareil pushed a commit to nbareil/go-github that referenced this pull request May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants