Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions github/activity_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
payload = &ForkEvent{}
case "GollumEvent":
payload = &GollumEvent{}
case "IntegrationInstallationEvent":
payload = &IntegrationInstallationEvent{}
case "IntegrationInstallationRepositoriesEvent":
payload = &IntegrationInstallationRepositoriesEvent{}
case "InstallationEvent":
payload = &InstallationEvent{}
case "InstallationRepositoriesEvent":
payload = &InstallationRepositoriesEvent{}
case "IssueCommentEvent":
payload = &IssueCommentEvent{}
case "IssuesEvent":
Expand Down
14 changes: 7 additions & 7 deletions github/integration.go → github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ package github

import "context"

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

// ListInstallations lists the installations that the current integration has.
// ListInstallations lists the installations that the current GitHub App has.
//
// GitHub API docs: https://developer.github.com/v3/integrations/#find-installations
func (s *IntegrationsService) ListInstallations(ctx context.Context, opt *ListOptions) ([]*Installation, *Response, error) {
u, err := addOptions("integration/installations", opt)
// GitHub API docs: https://developer.github.com/v3/apps/#find-installations
func (s *AppsService) ListInstallations(ctx context.Context, opt *ListOptions) ([]*Installation, *Response, error) {
u, err := addOptions("app/installations", opt)
if err != nil {
return nil, nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package github

import "context"

// Installation represents a GitHub integration installation.
// Installation represents a GitHub Apps installation.
type Installation struct {
ID *int `json:"id,omitempty"`
Account *User `json:"account,omitempty"`
Expand All @@ -20,10 +20,10 @@ func (i Installation) String() string {
return Stringify(i)
}

// ListRepos lists the repositories that the current installation has access to.
// ListRepos lists the repositories that are accessible to the authenticated installation.
//
// GitHub API docs: https://developer.github.com/v3/integrations/installations/#list-repositories
func (s *IntegrationsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repository, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/apps/installations/#list-repositories
func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repository, *Response, error) {
u, err := addOptions("installation/repositories", opt)
if err != nil {
return nil, nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"testing"
)

func TestIntegrationService_ListRepos(t *testing.T) {
func TestAppsService_ListRepos(t *testing.T) {
setup()
defer teardown()

Expand All @@ -28,13 +28,13 @@ func TestIntegrationService_ListRepos(t *testing.T) {
})

opt := &ListOptions{Page: 1, PerPage: 2}
repositories, _, err := client.Integrations.ListRepos(context.Background(), opt)
repositories, _, err := client.Apps.ListRepos(context.Background(), opt)
if err != nil {
t.Errorf("Integration.ListRepos returned error: %v", err)
t.Errorf("Apps.ListRepos returned error: %v", err)
}

want := []*Repository{{ID: Int(1)}}
if !reflect.DeepEqual(repositories, want) {
t.Errorf("Integration.ListRepos returned %+v, want %+v", repositories, want)
t.Errorf("Apps.ListRepos returned %+v, want %+v", repositories, want)
}
}
10 changes: 5 additions & 5 deletions github/integration_test.go → github/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"testing"
)

func TestIntegrationService_ListInstallations(t *testing.T) {
func TestAppsService_ListInstallations(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/integration/installations", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/app/installations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
testFormValues(t, r, values{
Expand All @@ -28,13 +28,13 @@ func TestIntegrationService_ListInstallations(t *testing.T) {
})

opt := &ListOptions{Page: 1, PerPage: 2}
installations, _, err := client.Integrations.ListInstallations(context.Background(), opt)
installations, _, err := client.Apps.ListInstallations(context.Background(), opt)
if err != nil {
t.Errorf("Integration.ListInstallations returned error: %v", err)
t.Errorf("Apps.ListInstallations returned error: %v", err)
}

want := []*Installation{{ID: Int(1)}}
if !reflect.DeepEqual(installations, want) {
t.Errorf("Integration.ListInstallations returned %+v, want %+v", installations, want)
t.Errorf("Apps.ListInstallations returned %+v, want %+v", installations, want)
}
}
23 changes: 11 additions & 12 deletions github/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,28 +187,27 @@ type TeamChange struct {
} `json:"repository,omitempty"`
}

// IntegrationInstallationEvent is triggered when an integration is created or deleted.
// The Webhook event name is "integration_installation".
// InstallationEvent is triggered when a GitHub App has been installed or uninstalled.
// The Webhook event name is "installation".
//
// GitHub API docs: https://developer.github.com/early-access/integrations/webhooks/#integrationinstallationevent
type IntegrationInstallationEvent struct {
// The action that was performed. Possible values for an "integration_installation"
// event are: "created", "deleted".
// GitHub API docs: https://developer.github.com/v3/activity/events/types/#installationevent
type InstallationEvent struct {
// The action that was performed. Can be either "created" or "deleted".

@bradleyfalzon bradleyfalzon Jun 3, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shurcooL do you want me to remove these field comments? They duplicate the GitHub API and it's only a comment for a single field, yet the GitHub API have docs for other fields. So either these should be removed or all of the fields should have the docs duplicated IMHO - is there another reason they are there?

Just the field comments, not the struct comments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, keep them, they're helpful and appreciated (as long as they're accurate, and I've checked, they are).

Action *string `json:"action,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}

// IntegrationInstallationRepositoriesEvent is triggered when an integration repository
// is added or removed. The Webhook event name is "integration_installation_repositories".
// InstallationRepositoriesEvent is triggered when a repository is added or
// removed from an installation. The Webhook event name is "installation_repositories".
//
// GitHub API docs: https://developer.github.com/early-access/integrations/webhooks/#integrationinstallationrepositoriesevent
type IntegrationInstallationRepositoriesEvent struct {
// The action that was performed. Possible values for an "integration_installation_repositories"
// event are: "added", "removed".
// GitHub API docs: https://developer.github.com/v3/activity/events/types/#installationrepositoriesevent
type InstallationRepositoriesEvent struct {
// The action that was performed. Can be either "added" or "removed".
Action *string `json:"action,omitempty"`
RepositoriesAdded []*Repository `json:"repositories_added,omitempty"`
RepositoriesRemoved []*Repository `json:"repositories_removed,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This struct is missing repository_selection field from https://developer.github.com/v3/activity/events/types/#installationrepositoriesevent. Is it in scope of this PR too add it?

RepositorySelection *string `json:"repository_selection,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}
Expand Down
12 changes: 10 additions & 2 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
libraryVersion = "7"
libraryVersion = "8"
defaultBaseURL = "https://api.github.com/"
uploadBaseURL = "https://uploads.github.com/"
userAgent = "go-github/" + libraryVersion
Expand Down Expand Up @@ -123,11 +123,11 @@ type Client struct {
// Services used for talking to different parts of the GitHub API.
Activity *ActivityService
Admin *AdminService
Apps *AppsService
Authorizations *AuthorizationsService
Gists *GistsService
Git *GitService
Gitignores *GitignoresService
Integrations *IntegrationsService
Issues *IssuesService
Organizations *OrganizationsService
Projects *ProjectsService
Expand Down Expand Up @@ -212,11 +212,11 @@ func NewClient(httpClient *http.Client) *Client {
c.common.client = c
c.Activity = (*ActivityService)(&c.common)
c.Admin = (*AdminService)(&c.common)
c.Apps = (*AppsService)(&c.common)
c.Authorizations = (*AuthorizationsService)(&c.common)
c.Gists = (*GistsService)(&c.common)
c.Git = (*GitService)(&c.common)
c.Gitignores = (*GitignoresService)(&c.common)
c.Integrations = (*IntegrationsService)(&c.common)
c.Issues = (*IssuesService)(&c.common)
c.Licenses = (*LicensesService)(&c.common)
c.Migrations = (*MigrationService)(&c.common)
Expand Down
66 changes: 33 additions & 33 deletions github/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,39 @@ const (
var (
// eventTypeMapping maps webhooks types to their corresponding go-github struct types.
eventTypeMapping = map[string]string{
"commit_comment": "CommitCommentEvent",
"create": "CreateEvent",
"delete": "DeleteEvent",
"deployment": "DeploymentEvent",
"deployment_status": "DeploymentStatusEvent",
"fork": "ForkEvent",
"gollum": "GollumEvent",
"integration_installation": "IntegrationInstallationEvent",
"integration_installation_repositories": "IntegrationInstallationRepositoriesEvent",
"issue_comment": "IssueCommentEvent",
"issues": "IssuesEvent",
"label": "LabelEvent",
"member": "MemberEvent",
"membership": "MembershipEvent",
"milestone": "MilestoneEvent",
"organization": "OrganizationEvent",
"org_block": "OrgBlockEvent",
"page_build": "PageBuildEvent",
"ping": "PingEvent",
"project": "ProjectEvent",
"project_card": "ProjectCardEvent",
"project_column": "ProjectColumnEvent",
"public": "PublicEvent",
"pull_request_review": "PullRequestReviewEvent",
"pull_request_review_comment": "PullRequestReviewCommentEvent",
"pull_request": "PullRequestEvent",
"push": "PushEvent",
"repository": "RepositoryEvent",
"release": "ReleaseEvent",
"status": "StatusEvent",
"team": "TeamEvent",
"team_add": "TeamAddEvent",
"watch": "WatchEvent",
"commit_comment": "CommitCommentEvent",
"create": "CreateEvent",
"delete": "DeleteEvent",
"deployment": "DeploymentEvent",
"deployment_status": "DeploymentStatusEvent",
"fork": "ForkEvent",
"gollum": "GollumEvent",
"installation": "InstallationEvent",
"installation_repositories": "InstallationRepositoriesEvent",
"issue_comment": "IssueCommentEvent",
"issues": "IssuesEvent",
"label": "LabelEvent",
"member": "MemberEvent",
"membership": "MembershipEvent",
"milestone": "MilestoneEvent",
"organization": "OrganizationEvent",
"org_block": "OrgBlockEvent",
"page_build": "PageBuildEvent",
"ping": "PingEvent",
"project": "ProjectEvent",
"project_card": "ProjectCardEvent",
"project_column": "ProjectColumnEvent",
"public": "PublicEvent",
"pull_request_review": "PullRequestReviewEvent",
"pull_request_review_comment": "PullRequestReviewCommentEvent",
"pull_request": "PullRequestEvent",
"push": "PushEvent",
"repository": "RepositoryEvent",
"release": "ReleaseEvent",
"status": "StatusEvent",
"team": "TeamEvent",
"team_add": "TeamAddEvent",
"watch": "WatchEvent",
}
)

Expand Down
8 changes: 8 additions & 0 deletions github/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ func TestParseWebHook(t *testing.T) {
payload: &GollumEvent{},
messageType: "gollum",
},
{
payload: &InstallationEvent{},
messageType: "installation",
},
{
payload: &InstallationRepositoriesEvent{},
messageType: "installation_repositories",
},
{
payload: &IssueCommentEvent{},
messageType: "issue_comment",
Expand Down