From e7e6cce2321fd8c17c3c8c2c6a0b81f97d02adf1 Mon Sep 17 00:00:00 2001 From: Andy Gertjejansen Date: Mon, 8 Oct 2018 18:03:59 -0500 Subject: [PATCH 1/5] Update go-github v0.18.2 and add required_approving_review_count Fixes #89 --- github/data_source_github_team.go | 4 +- github/resource_github_branch_protection.go | 27 +- .../resource_github_branch_protection_test.go | 7 +- .../resource_github_organization_project.go | 10 +- github/resource_github_repository_project.go | 11 +- github/resource_github_team.go | 12 +- github/resource_github_team_membership.go | 8 +- .../resource_github_team_membership_test.go | 6 +- github/resource_github_team_repository.go | 12 +- .../resource_github_team_repository_test.go | 4 +- github/resource_github_team_test.go | 4 +- .../go-github/github/activity_events.go | 2 + .../google/go-github/github/activity_star.go | 6 +- .../google/go-github/github/apps.go | 10 +- .../google/go-github/github/checks.go | 35 +- .../google/go-github/github/event_types.go | 91 ++-- .../google/go-github/github/gists.go | 30 - .../google/go-github/github/git_blobs.go | 6 - .../google/go-github/github/git_commits.go | 7 +- .../google/go-github/github/git_refs.go | 15 - .../google/go-github/github/git_tags.go | 7 +- .../go-github/github/github-accessors.go | 368 ++++++++++++- .../google/go-github/github/github.go | 46 +- .../google/go-github/github/issues.go | 33 +- .../go-github/github/issues_comments.go | 1 + .../google/go-github/github/issues_events.go | 21 +- .../google/go-github/github/issues_labels.go | 25 +- .../go-github/github/issues_milestones.go | 12 - .../google/go-github/github/messages.go | 79 +-- .../google/go-github/github/orgs.go | 76 ++- .../google/go-github/github/orgs_hooks.go | 13 +- .../google/go-github/github/orgs_members.go | 2 +- .../google/go-github/github/orgs_teams.go | 514 ------------------ .../google/go-github/github/projects.go | 69 +-- .../google/go-github/github/pulls.go | 39 +- .../google/go-github/github/reactions.go | 126 ++++- .../google/go-github/github/repos.go | 89 ++- .../go-github/github/repos_deployments.go | 19 +- .../google/go-github/github/repos_forks.go | 13 +- .../google/go-github/github/repos_hooks.go | 46 +- .../google/go-github/github/repos_projects.go | 7 +- .../google/go-github/github/repos_releases.go | 105 ++-- .../google/go-github/github/search.go | 10 +- .../google/go-github/github/teams.go | 350 ++++++++++++ .../github/teams_discussion_comments.go | 3 +- .../go-github/github/teams_discussions.go | 5 +- .../google/go-github/github/teams_members.go | 174 ++++++ .../google/go-github/github/users.go | 51 ++ vendor/vendor.json | 10 +- 49 files changed, 1628 insertions(+), 992 deletions(-) delete mode 100644 vendor/github.com/google/go-github/github/orgs_teams.go create mode 100644 vendor/github.com/google/go-github/github/teams_members.go diff --git a/github/data_source_github_team.go b/github/data_source_github_team.go index bb22de7620..ee4d677e4a 100644 --- a/github/data_source_github_team.go +++ b/github/data_source_github_team.go @@ -56,7 +56,7 @@ func dataSourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { return err } - member, _, err := client.Organizations.ListTeamMembers(ctx, team.GetID(), nil) + member, _, err := client.Teams.ListTeamMembers(ctx, team.GetID(), nil) if err != nil { return err } @@ -79,7 +79,7 @@ func dataSourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { func getGithubTeamBySlug(client *github.Client, org string, slug string) (team *github.Team, err error) { opt := &github.ListOptions{PerPage: 10} for { - teams, resp, err := client.Organizations.ListTeams(context.TODO(), org, opt) + teams, resp, err := client.Teams.ListTeams(context.TODO(), org, opt) if err != nil { return team, err } diff --git a/github/resource_github_branch_protection.go b/github/resource_github_branch_protection.go index 59018c6dab..3720324765 100644 --- a/github/resource_github_branch_protection.go +++ b/github/resource_github_branch_protection.go @@ -96,6 +96,21 @@ func resourceGithubBranchProtection() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + "required_approving_review_count": { + Type: schema.TypeInt, + Optional: true, + Description: "Number of approvals required to merge a pull request", + Default: 1, + // Old version of terraform, could not utilize validation.IntBetween + ValidateFunc: func(i interface{}, k string) (s []string, es []error) { + v := i.(int) + if v < 1 || v > 6 { + es = append(es, errors.New("required_pull_request_reviews.required_approving_review_count must be an integer between 1 - 6")) + } + + return + }, + }, }, }, }, @@ -205,7 +220,7 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{} } if err := flattenAndSetRequiredPullRequestReviews(d, githubProtection); err != nil { - return fmt.Errorf("Error setting required_pull_request_reviews: %v", err) + return fmt.Errorf("Error setting required_pull_reuest_reviews: %v", err) } if err := flattenAndSetRestrictions(d, githubProtection); err != nil { @@ -338,10 +353,11 @@ func flattenAndSetRequiredPullRequestReviews(d *schema.ResourceData, protection return d.Set("required_pull_request_reviews", []interface{}{ map[string]interface{}{ - "dismiss_stale_reviews": rprr.DismissStaleReviews, - "dismissal_users": schema.NewSet(schema.HashString, users), - "dismissal_teams": schema.NewSet(schema.HashString, teams), - "require_code_owner_reviews": rprr.RequireCodeOwnerReviews, + "dismiss_stale_reviews": rprr.DismissStaleReviews, + "dismissal_users": schema.NewSet(schema.HashString, users), + "dismissal_teams": schema.NewSet(schema.HashString, teams), + "require_code_owner_reviews": rprr.RequireCodeOwnerReviews, + "required_approving_review_count": rprr.RequiredApprovingReviewCount, }, }) } @@ -427,6 +443,7 @@ func expandRequiredPullRequestReviews(d *schema.ResourceData) (*github.PullReque rprr.DismissalRestrictionsRequest = drr rprr.DismissStaleReviews = m["dismiss_stale_reviews"].(bool) rprr.RequireCodeOwnerReviews = m["require_code_owner_reviews"].(bool) + rprr.RequiredApprovingReviewCount = m["required_approving_review_count"].(int) } return rprr, nil diff --git a/github/resource_github_branch_protection_test.go b/github/resource_github_branch_protection_test.go index c2dabc1128..a0ed041d7f 100644 --- a/github/resource_github_branch_protection_test.go +++ b/github/resource_github_branch_protection_test.go @@ -40,6 +40,7 @@ func TestAccGithubBranchProtection_basic(t *testing.T) { resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.dismissal_users.#", "1"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.dismissal_teams.#", "0"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.require_code_owner_reviews", "true"), + resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.required_approving_review_count", "1"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.0.users.#", "1"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.0.teams.#", "0"), ), @@ -94,6 +95,7 @@ func TestAccGithubBranchProtection_teams(t *testing.T) { resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.dismissal_users.#", "0"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.dismissal_teams.#", "2"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.require_code_owner_reviews", "false"), + resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.required_approving_review_count", "2"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.0.users.#", "0"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.0.teams.#", "2"), ), @@ -108,6 +110,7 @@ func TestAccGithubBranchProtection_teams(t *testing.T) { resource.TestCheckResourceAttr("github_branch_protection.master", "enforce_admins", "true"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.#", "1"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.#", "1"), + resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.required_approving_review_count", "1"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.#", "1"), ), }, @@ -127,6 +130,7 @@ func TestAccGithubBranchProtection_teams(t *testing.T) { resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.dismissal_users.#", "0"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.dismissal_teams.#", "2"), resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.require_code_owner_reviews", "false"), + resource.TestCheckResourceAttr("github_branch_protection.master", "required_pull_request_reviews.0.required_approving_review_count", "2"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.0.users.#", "0"), resource.TestCheckResourceAttr("github_branch_protection.master", "restrictions.0.teams.#", "2"), ), @@ -461,7 +465,8 @@ resource "github_branch_protection" "master" { required_pull_request_reviews { dismiss_stale_reviews = true - dismissal_teams = ["${github_team.first.slug}", "${github_team.second.slug}"] + dismissal_teams = ["${github_team.first.slug}", "${github_team.second.slug}"] + required_approving_review_count = 2 } restrictions { diff --git a/github/resource_github_organization_project.go b/github/resource_github_organization_project.go index 5df7f23df2..ef03faf506 100644 --- a/github/resource_github_organization_project.go +++ b/github/resource_github_organization_project.go @@ -46,14 +46,15 @@ func resourceGithubOrganizationProjectCreate(d *schema.ResourceData, meta interf client := meta.(*Organization).client orgName := meta.(*Organization).name name := d.Get("name").(string) + body := d.Get("body").(string) ctx := context.Background() log.Printf("[DEBUG] Creating organization project: %s (%s)", name, orgName) project, _, err := client.Organizations.CreateProject(ctx, orgName, &github.ProjectOptions{ - Name: name, - Body: d.Get("body").(string), + Name: &name, + Body: &body, }, ) if err != nil { @@ -108,9 +109,10 @@ func resourceGithubOrganizationProjectUpdate(d *schema.ResourceData, meta interf orgName := meta.(*Organization).name name := d.Get("name").(string) + body := d.Get("body").(string) options := github.ProjectOptions{ - Name: name, - Body: d.Get("body").(string), + Name: &name, + Body: &body, } projectID, err := strconv.ParseInt(d.Id(), 10, 64) diff --git a/github/resource_github_repository_project.go b/github/resource_github_repository_project.go index dd2a50133a..11ece1b43f 100644 --- a/github/resource_github_repository_project.go +++ b/github/resource_github_repository_project.go @@ -62,9 +62,10 @@ func resourceGithubRepositoryProjectCreate(d *schema.ResourceData, meta interfac orgName := meta.(*Organization).name repoName := d.Get("repository").(string) name := d.Get("name").(string) + body := d.Get("body").(string) options := github.ProjectOptions{ - Name: name, - Body: d.Get("body").(string), + Name: &name, + Body: &body, } ctx := context.Background() @@ -120,10 +121,12 @@ func resourceGithubRepositoryProjectRead(d *schema.ResourceData, meta interface{ func resourceGithubRepositoryProjectUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*Organization).client + name := d.Get("name").(string) + body := d.Get("body").(string) options := github.ProjectOptions{ - Name: d.Get("name").(string), - Body: d.Get("body").(string), + Name: &name, + Body: &body, } projectID, err := strconv.ParseInt(d.Id(), 10, 64) diff --git a/github/resource_github_team.go b/github/resource_github_team.go index b18a74a3d1..4b26c41801 100644 --- a/github/resource_github_team.go +++ b/github/resource_github_team.go @@ -60,7 +60,7 @@ func resourceGithubTeamCreate(d *schema.ResourceData, meta interface{}) error { orgName := meta.(*Organization).name name := d.Get("name").(string) - newTeam := &github.NewTeam{ + newTeam := github.NewTeam{ Name: name, Description: github.String(d.Get("description").(string)), Privacy: github.String(d.Get("privacy").(string)), @@ -72,7 +72,7 @@ func resourceGithubTeamCreate(d *schema.ResourceData, meta interface{}) error { ctx := context.Background() log.Printf("[DEBUG] Creating team: %s (%s)", name, orgName) - githubTeam, _, err := client.Organizations.CreateTeam(ctx, + githubTeam, _, err := client.Teams.CreateTeam(ctx, orgName, newTeam) if err != nil { return err @@ -105,7 +105,7 @@ func resourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { } log.Printf("[DEBUG] Reading team: %s", d.Id()) - team, resp, err := client.Organizations.GetTeam(ctx, id) + team, resp, err := client.Teams.GetTeam(ctx, id) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { if ghErr.Response.StatusCode == http.StatusNotModified { @@ -139,7 +139,7 @@ func resourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { func resourceGithubTeamUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*Organization).client - editedTeam := &github.NewTeam{ + editedTeam := github.NewTeam{ Name: d.Get("name").(string), Description: github.String(d.Get("description").(string)), Privacy: github.String(d.Get("privacy").(string)), @@ -156,7 +156,7 @@ func resourceGithubTeamUpdate(d *schema.ResourceData, meta interface{}) error { ctx := context.WithValue(context.Background(), ctxId, d.Id()) log.Printf("[DEBUG] Updating team: %s", d.Id()) - team, _, err := client.Organizations.EditTeam(ctx, teamId, editedTeam) + team, _, err := client.Teams.EditTeam(ctx, teamId, editedTeam) if err != nil { return err } @@ -186,6 +186,6 @@ func resourceGithubTeamDelete(d *schema.ResourceData, meta interface{}) error { ctx := context.WithValue(context.Background(), ctxId, d.Id()) log.Printf("[DEBUG] Deleting team: %s", d.Id()) - _, err = client.Organizations.DeleteTeam(ctx, id) + _, err = client.Teams.DeleteTeam(ctx, id) return err } diff --git a/github/resource_github_team_membership.go b/github/resource_github_team_membership.go index 15593c950f..2d2620a270 100644 --- a/github/resource_github_team_membership.go +++ b/github/resource_github_team_membership.go @@ -61,10 +61,10 @@ func resourceGithubTeamMembershipCreateOrUpdate(d *schema.ResourceData, meta int role := d.Get("role").(string) log.Printf("[DEBUG] Creating team membership: %s/%s (%s)", teamIdString, username, role) - _, _, err = client.Organizations.AddTeamMembership(ctx, + _, _, err = client.Teams.AddTeamMembership(ctx, teamId, username, - &github.OrganizationAddTeamMembershipOptions{ + &github.TeamAddTeamMembershipOptions{ Role: role, }, ) @@ -94,7 +94,7 @@ func resourceGithubTeamMembershipRead(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Reading team membership: %s/%s", teamIdString, username) - membership, resp, err := client.Organizations.GetTeamMembership(ctx, + membership, resp, err := client.Teams.GetTeamMembership(ctx, teamId, username) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -133,7 +133,7 @@ func resourceGithubTeamMembershipDelete(d *schema.ResourceData, meta interface{} ctx := context.WithValue(context.Background(), ctxId, d.Id()) log.Printf("[DEBUG] Deleting team membership: %s/%s", teamIdString, username) - _, err = client.Organizations.RemoveTeamMembership(ctx, teamId, username) + _, err = client.Teams.RemoveTeamMembership(ctx, teamId, username) return err } diff --git a/github/resource_github_team_membership_test.go b/github/resource_github_team_membership_test.go index bd32767e10..b72a1968d3 100644 --- a/github/resource_github_team_membership_test.go +++ b/github/resource_github_team_membership_test.go @@ -77,7 +77,7 @@ func testAccCheckGithubTeamMembershipDestroy(s *terraform.State) error { return unconvertibleIdErr(teamIdString, err) } - membership, resp, err := conn.Organizations.GetTeamMembership(context.TODO(), + membership, resp, err := conn.Teams.GetTeamMembership(context.TODO(), teamId, username) if err == nil { if membership != nil { @@ -114,7 +114,7 @@ func testAccCheckGithubTeamMembershipExists(n string, membership *github.Members return unconvertibleIdErr(teamIdString, err) } - teamMembership, _, err := conn.Organizations.GetTeamMembership(context.TODO(), teamId, username) + teamMembership, _, err := conn.Teams.GetTeamMembership(context.TODO(), teamId, username) if err != nil { return err @@ -145,7 +145,7 @@ func testAccCheckGithubTeamMembershipRoleState(n, expected string, membership *g return unconvertibleIdErr(teamIdString, err) } - teamMembership, _, err := conn.Organizations.GetTeamMembership(context.TODO(), + teamMembership, _, err := conn.Teams.GetTeamMembership(context.TODO(), teamId, username) if err != nil { return err diff --git a/github/resource_github_team_repository.go b/github/resource_github_team_repository.go index 48634ea010..3624159a34 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -60,11 +60,11 @@ func resourceGithubTeamRepositoryCreate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Creating team repository association: %s:%s (%s/%s)", teamIdString, permission, orgName, repoName) - _, err = client.Organizations.AddTeamRepo(ctx, + _, err = client.Teams.AddTeamRepo(ctx, teamId, orgName, repoName, - &github.OrganizationAddTeamRepoOptions{ + &github.TeamAddTeamRepoOptions{ Permission: permission, }, ) @@ -98,7 +98,7 @@ func resourceGithubTeamRepositoryRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Reading team repository association: %s (%s/%s)", teamIdString, orgName, repoName) - repo, resp, repoErr := client.Organizations.IsTeamRepo(ctx, + repo, resp, repoErr := client.Teams.IsTeamRepo(ctx, teamId, orgName, repoName) if repoErr != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -145,11 +145,11 @@ func resourceGithubTeamRepositoryUpdate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Updating team repository association: %s:%s (%s/%s)", teamIdString, permission, orgName, repoName) // the go-github library's AddTeamRepo method uses the add/update endpoint from Github API - _, err = client.Organizations.AddTeamRepo(ctx, + _, err = client.Teams.AddTeamRepo(ctx, teamId, orgName, repoName, - &github.OrganizationAddTeamRepoOptions{ + &github.TeamAddTeamRepoOptions{ Permission: permission, }, ) @@ -177,7 +177,7 @@ func resourceGithubTeamRepositoryDelete(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Deleting team repository association: %s (%s/%s)", teamIdString, orgName, repoName) - _, err = client.Organizations.RemoveTeamRepo(ctx, + _, err = client.Teams.RemoveTeamRepo(ctx, teamId, orgName, repoName) return err } diff --git a/github/resource_github_team_repository_test.go b/github/resource_github_team_repository_test.go index ef48ba0bcc..efa7ad6430 100644 --- a/github/resource_github_team_repository_test.go +++ b/github/resource_github_team_repository_test.go @@ -125,7 +125,7 @@ func testAccCheckGithubTeamRepositoryExists(n string, repository *github.Reposit return unconvertibleIdErr(teamIdString, err) } - repo, _, err := conn.Organizations.IsTeamRepo(context.TODO(), + repo, _, err := conn.Teams.IsTeamRepo(context.TODO(), teamId, testAccProvider.Meta().(*Organization).name, repoName) @@ -155,7 +155,7 @@ func testAccCheckGithubTeamRepositoryDestroy(s *terraform.State) error { return unconvertibleIdErr(teamIdString, err) } - repo, resp, err := conn.Organizations.IsTeamRepo(context.TODO(), + repo, resp, err := conn.Teams.IsTeamRepo(context.TODO(), teamId, testAccProvider.Meta().(*Organization).name, repoName) diff --git a/github/resource_github_team_test.go b/github/resource_github_team_test.go index e485389d05..fe24d79247 100644 --- a/github/resource_github_team_test.go +++ b/github/resource_github_team_test.go @@ -146,7 +146,7 @@ func testAccCheckGithubTeamExists(n string, team *github.Team) resource.TestChec return unconvertibleIdErr(rs.Primary.ID, err) } - githubTeam, _, err := conn.Organizations.GetTeam(context.TODO(), id) + githubTeam, _, err := conn.Teams.GetTeam(context.TODO(), id) if err != nil { return err } @@ -190,7 +190,7 @@ func testAccCheckGithubTeamDestroy(s *terraform.State) error { return unconvertibleIdErr(rs.Primary.ID, err) } - team, resp, err := conn.Organizations.GetTeam(context.TODO(), id) + team, resp, err := conn.Teams.GetTeam(context.TODO(), id) if err == nil { teamId := strconv.FormatInt(*team.ID, 10) if team != nil && teamId == rs.Primary.ID { diff --git a/vendor/github.com/google/go-github/github/activity_events.go b/vendor/github.com/google/go-github/github/activity_events.go index a919b11c5d..47f0c735bd 100644 --- a/vendor/github.com/google/go-github/github/activity_events.go +++ b/vendor/github.com/google/go-github/github/activity_events.go @@ -96,6 +96,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &ReleaseEvent{} case "RepositoryEvent": payload = &RepositoryEvent{} + case "RepositoryVulnerabilityAlertEvent": + payload = &RepositoryVulnerabilityAlertEvent{} case "StatusEvent": payload = &StatusEvent{} case "TeamEvent": diff --git a/vendor/github.com/google/go-github/github/activity_star.go b/vendor/github.com/google/go-github/github/activity_star.go index d5b067127c..5ae5c10165 100644 --- a/vendor/github.com/google/go-github/github/activity_star.go +++ b/vendor/github.com/google/go-github/github/activity_star.go @@ -8,6 +8,7 @@ package github import ( "context" "fmt" + "strings" ) // StarredRepository is returned by ListStarred. @@ -84,8 +85,9 @@ func (s *ActivityService) ListStarred(ctx context.Context, user string, opt *Act return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeStarringPreview) + // TODO: remove custom Accept header when APIs fully launch + acceptHeaders := []string{mediaTypeStarringPreview, mediaTypeTopicsPreview} + req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) var repos []*StarredRepository resp, err := s.client.Do(ctx, req, &repos) diff --git a/vendor/github.com/google/go-github/github/apps.go b/vendor/github.com/google/go-github/github/apps.go index c076704663..ae3aabda31 100644 --- a/vendor/github.com/google/go-github/github/apps.go +++ b/vendor/github.com/google/go-github/github/apps.go @@ -20,6 +20,7 @@ type AppsService service // App represents a GitHub App. type App struct { ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` Owner *User `json:"owner,omitempty"` Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` @@ -163,7 +164,7 @@ func (s *AppsService) ListUserInstallations(ctx context.Context, opt *ListOption // // GitHub API docs: https://developer.github.com/v3/apps/#create-a-new-installation-token func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64) (*InstallationToken, *Response, error) { - u := fmt.Sprintf("installations/%v/access_tokens", id) + u := fmt.Sprintf("app/installations/%v/access_tokens", id) req, err := s.client.NewRequest("POST", u, nil) if err != nil { @@ -196,6 +197,13 @@ func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, rep return s.getInstallation(ctx, fmt.Sprintf("repos/%v/%v/installation", owner, repo)) } +// FindRepositoryInstallationByID finds the repository's installation information. +// +// Note: FindRepositoryInstallationByID uses the undocumented GitHub API endpoint /repositories/:id/installation. +func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) { + return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id)) +} + // FindUserInstallation finds the user's installation information. // // GitHub API docs: https://developer.github.com/v3/apps/#find-repository-installation diff --git a/vendor/github.com/google/go-github/github/checks.go b/vendor/github.com/google/go-github/github/checks.go index 3549089982..2a6ce4193c 100644 --- a/vendor/github.com/google/go-github/github/checks.go +++ b/vendor/github.com/google/go-github/github/checks.go @@ -19,6 +19,7 @@ type ChecksService service // CheckRun represents a GitHub check run on a repository associated with a GitHub app. type CheckRun struct { ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` HeadSHA *string `json:"head_sha,omitempty"` ExternalID *string `json:"external_id,omitempty"` URL *string `json:"url,omitempty"` @@ -47,14 +48,14 @@ type CheckRunOutput struct { // CheckRunAnnotation represents an annotation object for a CheckRun output. type CheckRunAnnotation struct { - FileName *string `json:"filename,omitempty"` - BlobHRef *string `json:"blob_href,omitempty"` - StartLine *int `json:"start_line,omitempty"` - EndLine *int `json:"end_line,omitempty"` - WarningLevel *string `json:"warning_level,omitempty"` - Message *string `json:"message,omitempty"` - Title *string `json:"title,omitempty"` - RawDetails *string `json:"raw_details,omitempty"` + Path *string `json:"path,omitempty"` + BlobHRef *string `json:"blob_href,omitempty"` + StartLine *int `json:"start_line,omitempty"` + EndLine *int `json:"end_line,omitempty"` + AnnotationLevel *string `json:"annotation_level,omitempty"` + Message *string `json:"message,omitempty"` + Title *string `json:"title,omitempty"` + RawDetails *string `json:"raw_details,omitempty"` } // CheckRunImage represents an image object for a CheckRun output. @@ -67,6 +68,7 @@ type CheckRunImage struct { // CheckSuite represents a suite of check runs. type CheckSuite struct { ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` HeadBranch *string `json:"head_branch,omitempty"` HeadSHA *string `json:"head_sha,omitempty"` URL *string `json:"url,omitempty"` @@ -401,20 +403,11 @@ func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string return checkSuite, resp, nil } -// RequestCheckSuiteOptions sets up the parameters for a request check suite endpoint. -type RequestCheckSuiteOptions struct { - HeadSHA string `json:"head_sha"` // The sha of the head commit. (Required.) -} - -// RequestCheckSuite triggers GitHub to create a new check suite, without pushing new code to a repository. +// ReRequestCheckSuite triggers GitHub to rerequest an existing check suite, without pushing new code to a repository. // -// GitHub API docs: https://developer.github.com/v3/checks/suites/#request-check-suites -func (s *ChecksService) RequestCheckSuite(ctx context.Context, owner, repo string, opt RequestCheckSuiteOptions) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/check-suite-requests", owner, repo) - u, err := addOptions(u, opt) - if err != nil { - return nil, err - } +// GitHub API docs: https://developer.github.com/v3/checks/suites/#rerequest-check-suite +func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/check-suites/%v/rerequest", owner, repo, checkSuiteID) req, err := s.client.NewRequest("POST", u, nil) if err != nil { diff --git a/vendor/github.com/google/go-github/github/event_types.go b/vendor/github.com/google/go-github/github/event_types.go index cfc9290b12..1792f43c73 100644 --- a/vendor/github.com/google/go-github/github/event_types.go +++ b/vendor/github.com/google/go-github/github/event_types.go @@ -519,6 +519,7 @@ type PullRequestEvent struct { // the pull request was closed with unmerged commits. If the action is "closed" // and the merged key is true, the pull request was merged. Action *string `json:"action,omitempty"` + Assignee *User `json:"assignee,omitempty"` Number *int `json:"number,omitempty"` PullRequest *PullRequest `json:"pull_request,omitempty"` @@ -532,6 +533,10 @@ type PullRequestEvent struct { Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` Label *Label `json:"label,omitempty"` // Populated in "labeled" event deliveries. + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Organization *Organization `json:"organization,omitempty"` } // PullRequestReviewEvent is triggered when a review is submitted on a pull @@ -630,38 +635,39 @@ func (p PushEventCommit) String() string { // PushEventRepository represents the repo object in a PushEvent payload. type PushEventRepository struct { - ID *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - FullName *string `json:"full_name,omitempty"` - Owner *PushEventRepoOwner `json:"owner,omitempty"` - Private *bool `json:"private,omitempty"` - Description *string `json:"description,omitempty"` - Fork *bool `json:"fork,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - PushedAt *Timestamp `json:"pushed_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - Homepage *string `json:"homepage,omitempty"` - Size *int `json:"size,omitempty"` - StargazersCount *int `json:"stargazers_count,omitempty"` - WatchersCount *int `json:"watchers_count,omitempty"` - Language *string `json:"language,omitempty"` - HasIssues *bool `json:"has_issues,omitempty"` - HasDownloads *bool `json:"has_downloads,omitempty"` - HasWiki *bool `json:"has_wiki,omitempty"` - HasPages *bool `json:"has_pages,omitempty"` - ForksCount *int `json:"forks_count,omitempty"` - OpenIssuesCount *int `json:"open_issues_count,omitempty"` - DefaultBranch *string `json:"default_branch,omitempty"` - MasterBranch *string `json:"master_branch,omitempty"` - Organization *string `json:"organization,omitempty"` - URL *string `json:"url,omitempty"` - ArchiveURL *string `json:"archive_url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - StatusesURL *string `json:"statuses_url,omitempty"` - GitURL *string `json:"git_url,omitempty"` - SSHURL *string `json:"ssh_url,omitempty"` - CloneURL *string `json:"clone_url,omitempty"` - SVNURL *string `json:"svn_url,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Name *string `json:"name,omitempty"` + FullName *string `json:"full_name,omitempty"` + Owner *User `json:"owner,omitempty"` + Private *bool `json:"private,omitempty"` + Description *string `json:"description,omitempty"` + Fork *bool `json:"fork,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + PushedAt *Timestamp `json:"pushed_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + Homepage *string `json:"homepage,omitempty"` + Size *int `json:"size,omitempty"` + StargazersCount *int `json:"stargazers_count,omitempty"` + WatchersCount *int `json:"watchers_count,omitempty"` + Language *string `json:"language,omitempty"` + HasIssues *bool `json:"has_issues,omitempty"` + HasDownloads *bool `json:"has_downloads,omitempty"` + HasWiki *bool `json:"has_wiki,omitempty"` + HasPages *bool `json:"has_pages,omitempty"` + ForksCount *int `json:"forks_count,omitempty"` + OpenIssuesCount *int `json:"open_issues_count,omitempty"` + DefaultBranch *string `json:"default_branch,omitempty"` + MasterBranch *string `json:"master_branch,omitempty"` + Organization *string `json:"organization,omitempty"` + URL *string `json:"url,omitempty"` + ArchiveURL *string `json:"archive_url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + StatusesURL *string `json:"statuses_url,omitempty"` + GitURL *string `json:"git_url,omitempty"` + SSHURL *string `json:"ssh_url,omitempty"` + CloneURL *string `json:"clone_url,omitempty"` + SVNURL *string `json:"svn_url,omitempty"` } // PushEventRepoOwner is a basic representation of user/org in a PushEvent payload. @@ -704,6 +710,27 @@ type RepositoryEvent struct { Installation *Installation `json:"installation,omitempty"` } +// RepositoryVulnerabilityAlertEvent is triggered when a security alert is created, dismissed, or resolved. +// +// GitHub API docs: https://developer.github.com/v3/activity/events/types/#repositoryvulnerabilityalertevent +type RepositoryVulnerabilityAlertEvent struct { + // Action is the action that was performed. This can be: "create", "dismiss", "resolve". + Action *string `json:"action,omitempty"` + + //The security alert of the vulnerable dependency. + Alert *struct { + ID *int64 `json:"id,omitempty"` + AffectedRange *string `json:"affected_range,omitempty"` + AffectedPackageName *string `json:"affected_package_name,omitempty"` + ExternalReference *string `json:"external_reference,omitempty"` + ExternalIdentifier *string `json:"external_identifier,omitempty"` + FixedIn *string `json:"fixed_in,omitempty"` + Dismisser *User `json:"dismisser,omitempty"` + DismissReason *string `json:"dismiss_reason,omitempty"` + DismissedAt *Timestamp `json:"dismissed_at,omitempty"` + } `json:"alert,omitempty"` +} + // StatusEvent is triggered when the status of a Git commit changes. // The Webhook event name is "status". // diff --git a/vendor/github.com/google/go-github/github/gists.go b/vendor/github.com/google/go-github/github/gists.go index 9108b64244..15e0bc2cd9 100644 --- a/vendor/github.com/google/go-github/github/gists.go +++ b/vendor/github.com/google/go-github/github/gists.go @@ -114,9 +114,6 @@ func (s *GistsService) List(ctx context.Context, user string, opt *GistListOptio return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var gists []*Gist resp, err := s.client.Do(ctx, req, &gists) if err != nil { @@ -140,9 +137,6 @@ func (s *GistsService) ListAll(ctx context.Context, opt *GistListOptions) ([]*Gi return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var gists []*Gist resp, err := s.client.Do(ctx, req, &gists) if err != nil { @@ -166,9 +160,6 @@ func (s *GistsService) ListStarred(ctx context.Context, opt *GistListOptions) ([ return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var gists []*Gist resp, err := s.client.Do(ctx, req, &gists) if err != nil { @@ -188,9 +179,6 @@ func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, er return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - gist := new(Gist) resp, err := s.client.Do(ctx, req, gist) if err != nil { @@ -210,9 +198,6 @@ func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - gist := new(Gist) resp, err := s.client.Do(ctx, req, gist) if err != nil { @@ -232,9 +217,6 @@ func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - g := new(Gist) resp, err := s.client.Do(ctx, req, g) if err != nil { @@ -254,9 +236,6 @@ func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - g := new(Gist) resp, err := s.client.Do(ctx, req, g) if err != nil { @@ -281,9 +260,6 @@ func (s *GistsService) ListCommits(ctx context.Context, id string, opt *ListOpti return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var gistCommits []*GistCommit resp, err := s.client.Do(ctx, req, &gistCommits) if err != nil { @@ -353,9 +329,6 @@ func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, e return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - g := new(Gist) resp, err := s.client.Do(ctx, req, g) if err != nil { @@ -375,9 +348,6 @@ func (s *GistsService) ListForks(ctx context.Context, id string) ([]*GistFork, * return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var gistForks []*GistFork resp, err := s.client.Do(ctx, req, &gistForks) if err != nil { diff --git a/vendor/github.com/google/go-github/github/git_blobs.go b/vendor/github.com/google/go-github/github/git_blobs.go index 5290c5538a..70aee14a7a 100644 --- a/vendor/github.com/google/go-github/github/git_blobs.go +++ b/vendor/github.com/google/go-github/github/git_blobs.go @@ -31,9 +31,6 @@ func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - blob := new(Blob) resp, err := s.client.Do(ctx, req, blob) return blob, resp, err @@ -66,9 +63,6 @@ func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - t := new(Blob) resp, err := s.client.Do(ctx, req, t) return t, resp, err diff --git a/vendor/github.com/google/go-github/github/git_commits.go b/vendor/github.com/google/go-github/github/git_commits.go index 29882569c9..1eb48a8e2c 100644 --- a/vendor/github.com/google/go-github/github/git_commits.go +++ b/vendor/github.com/google/go-github/github/git_commits.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" "time" ) @@ -70,8 +69,7 @@ func (s *GitService) GetCommit(ctx context.Context, owner string, repo string, s } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeGitSigningPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeGitSigningPreview) c := new(Commit) resp, err := s.client.Do(ctx, req, c) @@ -126,9 +124,6 @@ func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - c := new(Commit) resp, err := s.client.Do(ctx, req, c) if err != nil { diff --git a/vendor/github.com/google/go-github/github/git_refs.go b/vendor/github.com/google/go-github/github/git_refs.go index 0947d866ab..3b2ced2333 100644 --- a/vendor/github.com/google/go-github/github/git_refs.go +++ b/vendor/github.com/google/go-github/github/git_refs.go @@ -63,9 +63,6 @@ func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - r := new(Reference) resp, err := s.client.Do(ctx, req, r) if _, ok := err.(*json.UnmarshalTypeError); ok { @@ -97,9 +94,6 @@ func (s *GitService) GetRefs(ctx context.Context, owner string, repo string, ref return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var rawJSON json.RawMessage resp, err := s.client.Do(ctx, req, &rawJSON) if err != nil { @@ -154,9 +148,6 @@ func (s *GitService) ListRefs(ctx context.Context, owner, repo string, opt *Refe return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var rs []*Reference resp, err := s.client.Do(ctx, req, &rs) if err != nil { @@ -180,9 +171,6 @@ func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, r return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - r := new(Reference) resp, err := s.client.Do(ctx, req, r) if err != nil { @@ -206,9 +194,6 @@ func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, r return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - r := new(Reference) resp, err := s.client.Do(ctx, req, r) if err != nil { diff --git a/vendor/github.com/google/go-github/github/git_tags.go b/vendor/github.com/google/go-github/github/git_tags.go index f3822ffacc..90398b3806 100644 --- a/vendor/github.com/google/go-github/github/git_tags.go +++ b/vendor/github.com/google/go-github/github/git_tags.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" ) // Tag represents a tag object. @@ -45,8 +44,7 @@ func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeGitSigningPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeGitSigningPreview) tag := new(Tag) resp, err := s.client.Do(ctx, req, tag) @@ -75,9 +73,6 @@ func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, t return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - t := new(Tag) resp, err := s.client.Do(ctx, req, t) return t, resp, err diff --git a/vendor/github.com/google/go-github/github/github-accessors.go b/vendor/github.com/google/go-github/github/github-accessors.go index 0086998c44..f66d3b09e3 100644 --- a/vendor/github.com/google/go-github/github/github-accessors.go +++ b/vendor/github.com/google/go-github/github/github-accessors.go @@ -164,6 +164,14 @@ func (a *App) GetName() string { return *a.Name } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (a *App) GetNodeID() string { + if a == nil || a.NodeID == nil { + return "" + } + return *a.NodeID +} + // GetOwner returns the Owner field. func (a *App) GetOwner() *User { if a == nil { @@ -524,6 +532,14 @@ func (c *CheckRun) GetName() string { return *c.Name } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (c *CheckRun) GetNodeID() string { + if c == nil || c.NodeID == nil { + return "" + } + return *c.NodeID +} + // GetOutput returns the Output field. func (c *CheckRun) GetOutput() *CheckRunOutput { if c == nil { @@ -556,6 +572,14 @@ func (c *CheckRun) GetURL() string { return *c.URL } +// GetAnnotationLevel returns the AnnotationLevel field if it's non-nil, zero value otherwise. +func (c *CheckRunAnnotation) GetAnnotationLevel() string { + if c == nil || c.AnnotationLevel == nil { + return "" + } + return *c.AnnotationLevel +} + // GetBlobHRef returns the BlobHRef field if it's non-nil, zero value otherwise. func (c *CheckRunAnnotation) GetBlobHRef() string { if c == nil || c.BlobHRef == nil { @@ -572,14 +596,6 @@ func (c *CheckRunAnnotation) GetEndLine() int { return *c.EndLine } -// GetFileName returns the FileName field if it's non-nil, zero value otherwise. -func (c *CheckRunAnnotation) GetFileName() string { - if c == nil || c.FileName == nil { - return "" - } - return *c.FileName -} - // GetMessage returns the Message field if it's non-nil, zero value otherwise. func (c *CheckRunAnnotation) GetMessage() string { if c == nil || c.Message == nil { @@ -588,6 +604,14 @@ func (c *CheckRunAnnotation) GetMessage() string { return *c.Message } +// GetPath returns the Path field if it's non-nil, zero value otherwise. +func (c *CheckRunAnnotation) GetPath() string { + if c == nil || c.Path == nil { + return "" + } + return *c.Path +} + // GetRawDetails returns the RawDetails field if it's non-nil, zero value otherwise. func (c *CheckRunAnnotation) GetRawDetails() string { if c == nil || c.RawDetails == nil { @@ -612,14 +636,6 @@ func (c *CheckRunAnnotation) GetTitle() string { return *c.Title } -// GetWarningLevel returns the WarningLevel field if it's non-nil, zero value otherwise. -func (c *CheckRunAnnotation) GetWarningLevel() string { - if c == nil || c.WarningLevel == nil { - return "" - } - return *c.WarningLevel -} - // GetAction returns the Action field if it's non-nil, zero value otherwise. func (c *CheckRunEvent) GetAction() string { if c == nil || c.Action == nil { @@ -788,6 +804,14 @@ func (c *CheckSuite) GetID() int64 { return *c.ID } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (c *CheckSuite) GetNodeID() string { + if c == nil || c.NodeID == nil { + return "" + } + return *c.NodeID +} + // GetRepository returns the Repository field. func (c *CheckSuite) GetRepository() *Repository { if c == nil { @@ -2365,13 +2389,21 @@ func (d *DiscussionComment) GetNodeID() string { } // GetNumber returns the Number field if it's non-nil, zero value otherwise. -func (d *DiscussionComment) GetNumber() int64 { +func (d *DiscussionComment) GetNumber() int { if d == nil || d.Number == nil { return 0 } return *d.Number } +// GetReactions returns the Reactions field. +func (d *DiscussionComment) GetReactions() *Reactions { + if d == nil { + return nil + } + return d.Reactions +} + // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. func (d *DiscussionComment) GetUpdatedAt() Timestamp { if d == nil || d.UpdatedAt == nil { @@ -3604,6 +3636,14 @@ func (i *Invitation) GetTeamCount() int { return *i.TeamCount } +// GetActiveLockReason returns the ActiveLockReason field if it's non-nil, zero value otherwise. +func (i *Issue) GetActiveLockReason() string { + if i == nil || i.ActiveLockReason == nil { + return "" + } + return *i.ActiveLockReason +} + // GetAssignee returns the Assignee field. func (i *Issue) GetAssignee() *User { if i == nil { @@ -3844,6 +3884,14 @@ func (i *IssueComment) GetIssueURL() string { return *i.IssueURL } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (i *IssueComment) GetNodeID() string { + if i == nil || i.NodeID == nil { + return "" + } + return *i.NodeID +} + // GetReactions returns the Reactions field. func (i *IssueComment) GetReactions() *Reactions { if i == nil { @@ -4004,6 +4052,14 @@ func (i *IssueEvent) GetLabel() *Label { return i.Label } +// GetLockReason returns the LockReason field if it's non-nil, zero value otherwise. +func (i *IssueEvent) GetLockReason() string { + if i == nil || i.LockReason == nil { + return "" + } + return *i.LockReason +} + // GetMilestone returns the Milestone field. func (i *IssueEvent) GetMilestone() *Milestone { if i == nil { @@ -5500,6 +5556,22 @@ func (o *Organization) GetCreatedAt() time.Time { return *o.CreatedAt } +// GetDefaultRepoPermission returns the DefaultRepoPermission field if it's non-nil, zero value otherwise. +func (o *Organization) GetDefaultRepoPermission() string { + if o == nil || o.DefaultRepoPermission == nil { + return "" + } + return *o.DefaultRepoPermission +} + +// GetDefaultRepoSettings returns the DefaultRepoSettings field if it's non-nil, zero value otherwise. +func (o *Organization) GetDefaultRepoSettings() string { + if o == nil || o.DefaultRepoSettings == nil { + return "" + } + return *o.DefaultRepoSettings +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (o *Organization) GetDescription() string { if o == nil || o.Description == nil { @@ -5596,6 +5668,14 @@ func (o *Organization) GetLogin() string { return *o.Login } +// GetMembersCanCreateRepos returns the MembersCanCreateRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetMembersCanCreateRepos() bool { + if o == nil || o.MembersCanCreateRepos == nil { + return false + } + return *o.MembersCanCreateRepos +} + // GetMembersURL returns the MembersURL field if it's non-nil, zero value otherwise. func (o *Organization) GetMembersURL() string { if o == nil || o.MembersURL == nil { @@ -5684,6 +5764,14 @@ func (o *Organization) GetTotalPrivateRepos() int { return *o.TotalPrivateRepos } +// GetTwoFactorRequirementEnabled returns the TwoFactorRequirementEnabled field if it's non-nil, zero value otherwise. +func (o *Organization) GetTwoFactorRequirementEnabled() bool { + if o == nil || o.TwoFactorRequirementEnabled == nil { + return false + } + return *o.TwoFactorRequirementEnabled +} + // GetType returns the Type field if it's non-nil, zero value otherwise. func (o *Organization) GetType() string { if o == nil || o.Type == nil { @@ -6132,6 +6220,78 @@ func (p *PreReceiveHook) GetName() string { return *p.Name } +// GetHRef returns the HRef field if it's non-nil, zero value otherwise. +func (p *PRLink) GetHRef() string { + if p == nil || p.HRef == nil { + return "" + } + return *p.HRef +} + +// GetComments returns the Comments field. +func (p *PRLinks) GetComments() *PRLink { + if p == nil { + return nil + } + return p.Comments +} + +// GetCommits returns the Commits field. +func (p *PRLinks) GetCommits() *PRLink { + if p == nil { + return nil + } + return p.Commits +} + +// GetHTML returns the HTML field. +func (p *PRLinks) GetHTML() *PRLink { + if p == nil { + return nil + } + return p.HTML +} + +// GetIssue returns the Issue field. +func (p *PRLinks) GetIssue() *PRLink { + if p == nil { + return nil + } + return p.Issue +} + +// GetReviewComment returns the ReviewComment field. +func (p *PRLinks) GetReviewComment() *PRLink { + if p == nil { + return nil + } + return p.ReviewComment +} + +// GetReviewComments returns the ReviewComments field. +func (p *PRLinks) GetReviewComments() *PRLink { + if p == nil { + return nil + } + return p.ReviewComments +} + +// GetSelf returns the Self field. +func (p *PRLinks) GetSelf() *PRLink { + if p == nil { + return nil + } + return p.Self +} + +// GetStatuses returns the Statuses field. +func (p *PRLinks) GetStatuses() *PRLink { + if p == nil { + return nil + } + return p.Statuses +} + // GetBody returns the Body field if it's non-nil, zero value otherwise. func (p *Project) GetBody() string { if p == nil || p.Body == nil { @@ -6140,6 +6300,14 @@ func (p *Project) GetBody() string { return *p.Body } +// GetColumnsURL returns the ColumnsURL field if it's non-nil, zero value otherwise. +func (p *Project) GetColumnsURL() string { + if p == nil || p.ColumnsURL == nil { + return "" + } + return *p.ColumnsURL +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (p *Project) GetCreatedAt() Timestamp { if p == nil || p.CreatedAt == nil { @@ -6156,6 +6324,14 @@ func (p *Project) GetCreator() *User { return p.Creator } +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (p *Project) GetHTMLURL() string { + if p == nil || p.HTMLURL == nil { + return "" + } + return *p.HTMLURL +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (p *Project) GetID() int64 { if p == nil || p.ID == nil { @@ -6196,6 +6372,14 @@ func (p *Project) GetOwnerURL() string { return *p.OwnerURL } +// GetState returns the State field if it's non-nil, zero value otherwise. +func (p *Project) GetState() string { + if p == nil || p.State == nil { + return "" + } + return *p.State +} + // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. func (p *Project) GetUpdatedAt() Timestamp { if p == nil || p.UpdatedAt == nil { @@ -6380,6 +6564,14 @@ func (p *ProjectCardOptions) GetArchived() bool { return *p.Archived } +// GetCardsURL returns the CardsURL field if it's non-nil, zero value otherwise. +func (p *ProjectColumn) GetCardsURL() string { + if p == nil || p.CardsURL == nil { + return "" + } + return *p.CardsURL +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (p *ProjectColumn) GetCreatedAt() Timestamp { if p == nil || p.CreatedAt == nil { @@ -6428,6 +6620,14 @@ func (p *ProjectColumn) GetUpdatedAt() Timestamp { return *p.UpdatedAt } +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (p *ProjectColumn) GetURL() string { + if p == nil || p.URL == nil { + return "" + } + return *p.URL +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (p *ProjectColumnEvent) GetAction() string { if p == nil || p.Action == nil { @@ -6548,6 +6748,46 @@ func (p *ProjectEvent) GetSender() *User { return p.Sender } +// GetBody returns the Body field if it's non-nil, zero value otherwise. +func (p *ProjectOptions) GetBody() string { + if p == nil || p.Body == nil { + return "" + } + return *p.Body +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (p *ProjectOptions) GetName() string { + if p == nil || p.Name == nil { + return "" + } + return *p.Name +} + +// GetOrganizationPermission returns the OrganizationPermission field if it's non-nil, zero value otherwise. +func (p *ProjectOptions) GetOrganizationPermission() string { + if p == nil || p.OrganizationPermission == nil { + return "" + } + return *p.OrganizationPermission +} + +// GetPublic returns the Public field if it's non-nil, zero value otherwise. +func (p *ProjectOptions) GetPublic() bool { + if p == nil || p.Public == nil { + return false + } + return *p.Public +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (p *ProjectOptions) GetState() string { + if p == nil || p.State == nil { + return "" + } + return *p.State +} + // GetEnforceAdmins returns the EnforceAdmins field. func (p *Protection) GetEnforceAdmins() *AdminEnforcement { if p == nil { @@ -6628,6 +6868,14 @@ func (p *PublicEvent) GetSender() *User { return p.Sender } +// GetActiveLockReason returns the ActiveLockReason field if it's non-nil, zero value otherwise. +func (p *PullRequest) GetActiveLockReason() string { + if p == nil || p.ActiveLockReason == nil { + return "" + } + return *p.ActiveLockReason +} + // GetAdditions returns the Additions field if it's non-nil, zero value otherwise. func (p *PullRequest) GetAdditions() int { if p == nil || p.Additions == nil { @@ -6772,6 +7020,14 @@ func (p *PullRequest) GetIssueURL() string { return *p.IssueURL } +// GetLinks returns the Links field. +func (p *PullRequest) GetLinks() *PRLinks { + if p == nil { + return nil + } + return p.Links +} + // GetMaintainerCanModify returns the MaintainerCanModify field if it's non-nil, zero value otherwise. func (p *PullRequest) GetMaintainerCanModify() bool { if p == nil || p.MaintainerCanModify == nil { @@ -7116,6 +7372,14 @@ func (p *PullRequestEvent) GetAction() string { return *p.Action } +// GetAssignee returns the Assignee field. +func (p *PullRequestEvent) GetAssignee() *User { + if p == nil { + return nil + } + return p.Assignee +} + // GetChanges returns the Changes field. func (p *PullRequestEvent) GetChanges() *EditChange { if p == nil { @@ -7148,6 +7412,14 @@ func (p *PullRequestEvent) GetNumber() int { return *p.Number } +// GetOrganization returns the Organization field. +func (p *PullRequestEvent) GetOrganization() *Organization { + if p == nil { + return nil + } + return p.Organization +} + // GetPullRequest returns the PullRequest field. func (p *PullRequestEvent) GetPullRequest() *PullRequest { if p == nil { @@ -7900,6 +8172,14 @@ func (p *PushEventRepository) GetName() string { return *p.Name } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (p *PushEventRepository) GetNodeID() string { + if p == nil || p.NodeID == nil { + return "" + } + return *p.NodeID +} + // GetOpenIssuesCount returns the OpenIssuesCount field if it's non-nil, zero value otherwise. func (p *PushEventRepository) GetOpenIssuesCount() int { if p == nil || p.OpenIssuesCount == nil { @@ -7917,7 +8197,7 @@ func (p *PushEventRepository) GetOrganization() string { } // GetOwner returns the Owner field. -func (p *PushEventRepository) GetOwner() *PushEventRepoOwner { +func (p *PushEventRepository) GetOwner() *User { if p == nil { return nil } @@ -8772,6 +9052,14 @@ func (r *Repository) GetNetworkCount() int { return *r.NetworkCount } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (r *Repository) GetNodeID() string { + if r == nil || r.NodeID == nil { + return "" + } + return *r.NodeID +} + // GetNotificationsURL returns the NotificationsURL field if it's non-nil, zero value otherwise. func (r *Repository) GetNotificationsURL() string { if r == nil || r.NotificationsURL == nil { @@ -9676,6 +9964,14 @@ func (r *RepositoryTag) GetZipballURL() string { return *r.ZipballURL } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (r *RepositoryVulnerabilityAlertEvent) GetAction() string { + if r == nil || r.Action == nil { + return "" + } + return *r.Action +} + // GetForkRepos returns the ForkRepos field if it's non-nil, zero value otherwise. func (r *RepoStats) GetForkRepos() int { if r == nil || r.ForkRepos == nil { @@ -10365,7 +10661,7 @@ func (t *TeamDiscussion) GetBodyVersion() string { } // GetCommentsCount returns the CommentsCount field if it's non-nil, zero value otherwise. -func (t *TeamDiscussion) GetCommentsCount() int64 { +func (t *TeamDiscussion) GetCommentsCount() int { if t == nil || t.CommentsCount == nil { return 0 } @@ -10413,7 +10709,7 @@ func (t *TeamDiscussion) GetNodeID() string { } // GetNumber returns the Number field if it's non-nil, zero value otherwise. -func (t *TeamDiscussion) GetNumber() int64 { +func (t *TeamDiscussion) GetNumber() int { if t == nil || t.Number == nil { return 0 } @@ -10436,6 +10732,14 @@ func (t *TeamDiscussion) GetPrivate() bool { return *t.Private } +// GetReactions returns the Reactions field. +func (t *TeamDiscussion) GetReactions() *Reactions { + if t == nil { + return nil + } + return t.Reactions +} + // GetTeamURL returns the TeamURL field if it's non-nil, zero value otherwise. func (t *TeamDiscussion) GetTeamURL() string { if t == nil || t.TeamURL == nil { @@ -11148,6 +11452,14 @@ func (u *User) GetName() string { return *u.Name } +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (u *User) GetNodeID() string { + if u == nil || u.NodeID == nil { + return "" + } + return *u.NodeID +} + // GetOrganizationsURL returns the OrganizationsURL field if it's non-nil, zero value otherwise. func (u *User) GetOrganizationsURL() string { if u == nil || u.OrganizationsURL == nil { @@ -11284,6 +11596,22 @@ func (u *User) GetURL() string { return *u.URL } +// GetMessage returns the Message field if it's non-nil, zero value otherwise. +func (u *UserContext) GetMessage() string { + if u == nil || u.Message == nil { + return "" + } + return *u.Message +} + +// GetOcticon returns the Octicon field if it's non-nil, zero value otherwise. +func (u *UserContext) GetOcticon() string { + if u == nil || u.Octicon == nil { + return "" + } + return *u.Octicon +} + // GetEmail returns the Email field if it's non-nil, zero value otherwise. func (u *UserEmail) GetEmail() string { if u == nil || u.Email == nil { diff --git a/vendor/github.com/google/go-github/github/github.go b/vendor/github.com/google/go-github/github/github.go index e10b9dde00..320b8104b6 100644 --- a/vendor/github.com/google/go-github/github/github.go +++ b/vendor/github.com/google/go-github/github/github.go @@ -48,9 +48,6 @@ const ( // https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/ mediaTypeStarringPreview = "application/vnd.github.v3.star+json" - // https://developer.github.com/changes/2015-11-11-protected-branches-api/ - mediaTypeProtectedBranchesPreview = "application/vnd.github.loki-preview+json" - // https://help.github.com/enterprise/2.4/admin/guides/migrations/exporting-the-github-com-organization-s-repositories/ mediaTypeMigrationsPreview = "application/vnd.github.wyandotte-preview+json" @@ -102,18 +99,24 @@ const ( // https://developer.github.com/changes/2017-11-09-repository-transfer-api-preview/ mediaTypeRepositoryTransferPreview = "application/vnd.github.nightshade-preview+json" - // https://developer.github.com/changes/2017-12-19-graphql-node-id/ - mediaTypeGraphQLNodeIDPreview = "application/vnd.github.jean-grey-preview+json" - // https://developer.github.com/changes/2018-01-25-organization-invitation-api-preview/ mediaTypeOrganizationInvitationPreview = "application/vnd.github.dazzler-preview+json" + // https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/ + mediaTypeRequiredApprovingReviewsPreview = "application/vnd.github.luke-cage-preview+json" + // https://developer.github.com/changes/2018-02-22-label-description-search-preview/ mediaTypeLabelDescriptionSearchPreview = "application/vnd.github.symmetra-preview+json" // https://developer.github.com/changes/2018-02-07-team-discussions-api/ mediaTypeTeamDiscussionsPreview = "application/vnd.github.echo-preview+json" + // https://developer.github.com/changes/2018-03-21-hovercard-api-preview/ + mediaTypeHovercardPreview = "application/vnd.github.hagar-preview+json" + + // https://developer.github.com/changes/2018-01-10-lock-reason-api-preview/ + mediaTypeLockReasonPreview = "application/vnd.github.sailor-v-preview+json" + // https://developer.github.com/changes/2018-05-07-new-checks-api-public-beta/ mediaTypeCheckRunsPreview = "application/vnd.github.antiope-preview+json" @@ -372,7 +375,9 @@ type Response struct { FirstPage int LastPage int - Rate + // Explicitly specify the Rate type so Rate's String() receiver doesn't + // propagate to Response. + Rate Rate } // newResponse creates a new Response for the provided http.Response. @@ -497,13 +502,23 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res err = CheckResponse(resp) if err != nil { - // Even though there was an error, we still return the response - // in case the caller wants to inspect it further. - // However, if the error is AcceptedError, decode it below before - // returning from this function and closing the response body. - if _, ok := err.(*AcceptedError); !ok { - return response, err + // Special case for AcceptedErrors. If an AcceptedError + // has been encountered, the response's payload will be + // added to the AcceptedError and returned. + // + // Issue #1022 + aerr, ok := err.(*AcceptedError) + if ok { + b, readErr := ioutil.ReadAll(resp.Body) + if readErr != nil { + return response, readErr + } + + aerr.Raw = b + return response, aerr } + + return response, err } if v != nil { @@ -605,7 +620,10 @@ func (r *RateLimitError) Error() string { // Technically, 202 Accepted is not a real error, it's just used to // indicate that results are not ready yet, but should be available soon. // The request can be repeated after some time. -type AcceptedError struct{} +type AcceptedError struct { + // Raw contains the response body. + Raw []byte +} func (*AcceptedError) Error() string { return "job scheduled on GitHub side; try again later" diff --git a/vendor/github.com/google/go-github/github/issues.go b/vendor/github.com/google/go-github/github/issues.go index ded07f0aae..1e0991ce4f 100644 --- a/vendor/github.com/google/go-github/github/issues.go +++ b/vendor/github.com/google/go-github/github/issues.go @@ -56,6 +56,10 @@ type Issue struct { // TextMatches is only populated from search results that request text matches // See: search.go and https://developer.github.com/v3/search/#text-match-metadata TextMatches []TextMatch `json:"text_matches,omitempty"` + + // ActiveLockReason is populated only when LockReason is provided while locking the issue. + // Possible values are: "off-topic", "too heated", "resolved", and "spam". + ActiveLockReason *string `json:"active_lock_reason,omitempty"` } func (i Issue) String() string { @@ -156,7 +160,7 @@ func (s *IssuesService) listIssues(ctx context.Context, u string, opt *IssueList } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} + acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) var issues []*Issue @@ -224,7 +228,7 @@ func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo strin } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} + acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeLabelDescriptionSearchPreview, mediaTypeIntegrationPreview} req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) var issues []*Issue @@ -247,7 +251,7 @@ func (s *IssuesService) Get(ctx context.Context, owner string, repo string, numb } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} + acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) issue := new(Issue) @@ -270,8 +274,7 @@ func (s *IssuesService) Create(ctx context.Context, owner string, repo string, i } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) i := new(Issue) resp, err := s.client.Do(ctx, req, i) @@ -293,8 +296,7 @@ func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, num } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) i := new(Issue) resp, err := s.client.Do(ctx, req, i) @@ -305,16 +307,29 @@ func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, num return i, resp, nil } +// LockIssueOptions specifies the optional parameters to the +// IssuesService.Lock method. +type LockIssueOptions struct { + // LockReason specifies the reason to lock this issue. + // Providing a lock reason can help make it clearer to contributors why an issue + // was locked. Possible values are: "off-topic", "too heated", "resolved", and "spam". + LockReason string `json:"lock_reason,omitempty"` +} + // Lock an issue's conversation. // // GitHub API docs: https://developer.github.com/v3/issues/#lock-an-issue -func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, number int) (*Response, error) { +func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, number int, opt *LockIssueOptions) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number) - req, err := s.client.NewRequest("PUT", u, nil) + req, err := s.client.NewRequest("PUT", u, opt) if err != nil { return nil, err } + if opt != nil { + req.Header.Set("Accept", mediaTypeLockReasonPreview) + } + return s.client.Do(ctx, req, nil) } diff --git a/vendor/github.com/google/go-github/github/issues_comments.go b/vendor/github.com/google/go-github/github/issues_comments.go index e6f6f21909..ab68afe2fa 100644 --- a/vendor/github.com/google/go-github/github/issues_comments.go +++ b/vendor/github.com/google/go-github/github/issues_comments.go @@ -14,6 +14,7 @@ import ( // IssueComment represents a comment left on an issue. type IssueComment struct { ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` Body *string `json:"body,omitempty"` User *User `json:"user,omitempty"` Reactions *Reactions `json:"reactions,omitempty"` diff --git a/vendor/github.com/google/go-github/github/issues_events.go b/vendor/github.com/google/go-github/github/issues_events.go index 55e6d431b3..f71e46361c 100644 --- a/vendor/github.com/google/go-github/github/issues_events.go +++ b/vendor/github.com/google/go-github/github/issues_events.go @@ -34,9 +34,13 @@ type IssueEvent struct { // The Actor committed to master a commit mentioning the issue in its commit message. // CommitID holds the SHA1 of the commit. // - // reopened, locked, unlocked + // reopened, unlocked // The Actor did that to the issue. // + // locked + // The Actor locked the issue. + // LockReason holds the reason of locking the issue (if provided while locking). + // // renamed // The Actor changed the issue title from Rename.From to Rename.To. // @@ -64,12 +68,13 @@ type IssueEvent struct { Issue *Issue `json:"issue,omitempty"` // Only present on certain events; see above. - Assignee *User `json:"assignee,omitempty"` - Assigner *User `json:"assigner,omitempty"` - CommitID *string `json:"commit_id,omitempty"` - Milestone *Milestone `json:"milestone,omitempty"` - Label *Label `json:"label,omitempty"` - Rename *Rename `json:"rename,omitempty"` + Assignee *User `json:"assignee,omitempty"` + Assigner *User `json:"assigner,omitempty"` + CommitID *string `json:"commit_id,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + Label *Label `json:"label,omitempty"` + Rename *Rename `json:"rename,omitempty"` + LockReason *string `json:"lock_reason,omitempty"` } // ListIssueEvents lists events for the specified issue. @@ -87,6 +92,8 @@ func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string, return nil, nil, err } + req.Header.Set("Accept", mediaTypeLockReasonPreview) + var events []*IssueEvent resp, err := s.client.Do(ctx, req, &events) if err != nil { diff --git a/vendor/github.com/google/go-github/github/issues_labels.go b/vendor/github.com/google/go-github/github/issues_labels.go index 4328997bbd..adcbe06834 100644 --- a/vendor/github.com/google/go-github/github/issues_labels.go +++ b/vendor/github.com/google/go-github/github/issues_labels.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" ) // Label represents a GitHub label on an Issue @@ -42,8 +41,7 @@ func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo strin } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) var labels []*Label resp, err := s.client.Do(ctx, req, &labels) @@ -65,8 +63,7 @@ func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string, } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) label := new(Label) resp, err := s.client.Do(ctx, req, label) @@ -88,8 +85,7 @@ func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo stri } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) l := new(Label) resp, err := s.client.Do(ctx, req, l) @@ -111,8 +107,7 @@ func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) l := new(Label) resp, err := s.client.Do(ctx, req, l) @@ -151,8 +146,7 @@ func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, rep } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) var labels []*Label resp, err := s.client.Do(ctx, req, &labels) @@ -174,8 +168,7 @@ func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) var l []*Label resp, err := s.client.Do(ctx, req, &l) @@ -213,8 +206,7 @@ func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string, } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) var l []*Label resp, err := s.client.Do(ctx, req, &l) @@ -257,8 +249,7 @@ func (s *IssuesService) ListLabelsForMilestone(ctx context.Context, owner string } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) var labels []*Label resp, err := s.client.Do(ctx, req, &labels) diff --git a/vendor/github.com/google/go-github/github/issues_milestones.go b/vendor/github.com/google/go-github/github/issues_milestones.go index 6af1cc03c4..ffe9aae14c 100644 --- a/vendor/github.com/google/go-github/github/issues_milestones.go +++ b/vendor/github.com/google/go-github/github/issues_milestones.go @@ -68,9 +68,6 @@ func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo s return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var milestones []*Milestone resp, err := s.client.Do(ctx, req, &milestones) if err != nil { @@ -90,9 +87,6 @@ func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo str return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - milestone := new(Milestone) resp, err := s.client.Do(ctx, req, milestone) if err != nil { @@ -112,9 +106,6 @@ func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - m := new(Milestone) resp, err := s.client.Do(ctx, req, m) if err != nil { @@ -134,9 +125,6 @@ func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo st return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - m := new(Milestone) resp, err := s.client.Do(ctx, req, m) if err != nil { diff --git a/vendor/github.com/google/go-github/github/messages.go b/vendor/github.com/google/go-github/github/messages.go index b8d3380e7a..75bc770512 100644 --- a/vendor/github.com/google/go-github/github/messages.go +++ b/vendor/github.com/google/go-github/github/messages.go @@ -41,42 +41,43 @@ const ( var ( // eventTypeMapping maps webhooks types to their corresponding go-github struct types. eventTypeMapping = map[string]string{ - "check_run": "CheckRunEvent", - "check_suite": "CheckSuiteEvent", - "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", - "marketplace_purchase": "MarketplacePurchaseEvent", - "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", + "check_run": "CheckRunEvent", + "check_suite": "CheckSuiteEvent", + "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", + "marketplace_purchase": "MarketplacePurchaseEvent", + "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", + "repository_vulnerability_alert": "RepositoryVulnerabilityAlertEvent", + "release": "ReleaseEvent", + "status": "StatusEvent", + "team": "TeamEvent", + "team_add": "TeamAddEvent", + "watch": "WatchEvent", } ) @@ -175,19 +176,19 @@ func ValidatePayload(r *http.Request, secretKey []byte) (payload []byte, err err } sig := r.Header.Get(signatureHeader) - if err := validateSignature(sig, body, secretKey); err != nil { + if err := ValidateSignature(sig, body, secretKey); err != nil { return nil, err } return payload, nil } -// validateSignature validates the signature for the given payload. +// ValidateSignature validates the signature for the given payload. // signature is the GitHub hash signature delivered in the X-Hub-Signature header. // payload is the JSON payload sent by GitHub Webhooks. // secretKey is the GitHub Webhook secret message. // // GitHub API docs: https://developer.github.com/webhooks/securing/#validating-payloads-from-github -func validateSignature(signature string, payload, secretKey []byte) error { +func ValidateSignature(signature string, payload, secretKey []byte) error { messageMAC, hashFunc, err := messageMAC(signature) if err != nil { return err diff --git a/vendor/github.com/google/go-github/github/orgs.go b/vendor/github.com/google/go-github/github/orgs.go index 7832053582..c70039ba08 100644 --- a/vendor/github.com/google/go-github/github/orgs.go +++ b/vendor/github.com/google/go-github/github/orgs.go @@ -19,31 +19,42 @@ type OrganizationsService service // Organization represents a GitHub organization account. type Organization struct { - Login *string `json:"login,omitempty"` - ID *int64 `json:"id,omitempty"` - AvatarURL *string `json:"avatar_url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - Name *string `json:"name,omitempty"` - Company *string `json:"company,omitempty"` - Blog *string `json:"blog,omitempty"` - Location *string `json:"location,omitempty"` - Email *string `json:"email,omitempty"` - Description *string `json:"description,omitempty"` - PublicRepos *int `json:"public_repos,omitempty"` - PublicGists *int `json:"public_gists,omitempty"` - Followers *int `json:"followers,omitempty"` - Following *int `json:"following,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - TotalPrivateRepos *int `json:"total_private_repos,omitempty"` - OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"` - PrivateGists *int `json:"private_gists,omitempty"` - DiskUsage *int `json:"disk_usage,omitempty"` - Collaborators *int `json:"collaborators,omitempty"` - BillingEmail *string `json:"billing_email,omitempty"` - Type *string `json:"type,omitempty"` - Plan *Plan `json:"plan,omitempty"` - NodeID *string `json:"node_id,omitempty"` + Login *string `json:"login,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + AvatarURL *string `json:"avatar_url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + Name *string `json:"name,omitempty"` + Company *string `json:"company,omitempty"` + Blog *string `json:"blog,omitempty"` + Location *string `json:"location,omitempty"` + Email *string `json:"email,omitempty"` + Description *string `json:"description,omitempty"` + PublicRepos *int `json:"public_repos,omitempty"` + PublicGists *int `json:"public_gists,omitempty"` + Followers *int `json:"followers,omitempty"` + Following *int `json:"following,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + TotalPrivateRepos *int `json:"total_private_repos,omitempty"` + OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"` + PrivateGists *int `json:"private_gists,omitempty"` + DiskUsage *int `json:"disk_usage,omitempty"` + Collaborators *int `json:"collaborators,omitempty"` + BillingEmail *string `json:"billing_email,omitempty"` + Type *string `json:"type,omitempty"` + Plan *Plan `json:"plan,omitempty"` + TwoFactorRequirementEnabled *bool `json:"two_factor_requirement_enabled,omitempty"` + + // DefaultRepoPermission can be one of: "read", "write", "admin", or "none". (Default: "read"). + // It is only used in OrganizationsService.Edit. + DefaultRepoPermission *string `json:"default_repository_permission,omitempty"` + // DefaultRepoSettings can be one of: "read", "write", "admin", or "none". (Default: "read"). + // It is only used in OrganizationsService.Get. + DefaultRepoSettings *string `json:"default_repository_settings,omitempty"` + + // MembersCanCreateRepos default value is true and is only used in Organizations.Edit. + MembersCanCreateRepos *bool `json:"members_can_create_repositories,omitempty"` // API URLs URL *string `json:"url,omitempty"` @@ -101,9 +112,6 @@ func (s *OrganizationsService) ListAll(ctx context.Context, opt *OrganizationsLi return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - orgs := []*Organization{} resp, err := s.client.Do(ctx, req, &orgs) if err != nil { @@ -133,9 +141,6 @@ func (s *OrganizationsService) List(ctx context.Context, user string, opt *ListO return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var orgs []*Organization resp, err := s.client.Do(ctx, req, &orgs) if err != nil { @@ -155,9 +160,6 @@ func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organizati return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - organization := new(Organization) resp, err := s.client.Do(ctx, req, organization) if err != nil { @@ -177,9 +179,6 @@ func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organiza return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - organization := new(Organization) resp, err := s.client.Do(ctx, req, organization) if err != nil { @@ -199,9 +198,6 @@ func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organ return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - o := new(Organization) resp, err := s.client.Do(ctx, req, o) if err != nil { diff --git a/vendor/github.com/google/go-github/github/orgs_hooks.go b/vendor/github.com/google/go-github/github/orgs_hooks.go index ab1d02da7f..c4dc134c4e 100644 --- a/vendor/github.com/google/go-github/github/orgs_hooks.go +++ b/vendor/github.com/google/go-github/github/orgs_hooks.go @@ -51,10 +51,21 @@ func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64 // CreateHook creates a Hook for the specified org. // Name and Config are required fields. // +// Note that only a subset of the hook fields are used and hook must +// not be nil. +// // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#create-a-hook func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks", org) - req, err := s.client.NewRequest("POST", u, hook) + + hookReq := &createHookRequest{ + Name: hook.Name, + Events: hook.Events, + Active: hook.Active, + Config: hook.Config, + } + + req, err := s.client.NewRequest("POST", u, hookReq) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/google/go-github/github/orgs_members.go b/vendor/github.com/google/go-github/github/orgs_members.go index 98e138e7e8..d18435999c 100644 --- a/vendor/github.com/google/go-github/github/orgs_members.go +++ b/vendor/github.com/google/go-github/github/orgs_members.go @@ -59,7 +59,7 @@ type ListMembersOptions struct { // Possible values are: // all - all members of the organization, regardless of role // admin - organization owners - // member - non-organization members + // member - non-owner organization members // // Default is "all". Role string `url:"role,omitempty"` diff --git a/vendor/github.com/google/go-github/github/orgs_teams.go b/vendor/github.com/google/go-github/github/orgs_teams.go deleted file mode 100644 index b3cc9f07da..0000000000 --- a/vendor/github.com/google/go-github/github/orgs_teams.go +++ /dev/null @@ -1,514 +0,0 @@ -// Copyright 2013 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" - "strings" - "time" -) - -// Team represents a team within a GitHub organization. Teams are used to -// manage access to an organization's repositories. -type Team struct { - ID *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Description *string `json:"description,omitempty"` - URL *string `json:"url,omitempty"` - Slug *string `json:"slug,omitempty"` - - // Permission specifies the default permission for repositories owned by the team. - Permission *string `json:"permission,omitempty"` - - // Privacy identifies the level of privacy this team should have. - // Possible values are: - // secret - only visible to organization owners and members of this team - // closed - visible to all members of this organization - // Default is "secret". - Privacy *string `json:"privacy,omitempty"` - - MembersCount *int `json:"members_count,omitempty"` - ReposCount *int `json:"repos_count,omitempty"` - Organization *Organization `json:"organization,omitempty"` - MembersURL *string `json:"members_url,omitempty"` - RepositoriesURL *string `json:"repositories_url,omitempty"` - Parent *Team `json:"parent,omitempty"` - - // LDAPDN is only available in GitHub Enterprise and when the team - // membership is synchronized with LDAP. - LDAPDN *string `json:"ldap_dn,omitempty"` -} - -func (t Team) String() string { - return Stringify(t) -} - -// Invitation represents a team member's invitation status. -type Invitation struct { - ID *int64 `json:"id,omitempty"` - Login *string `json:"login,omitempty"` - Email *string `json:"email,omitempty"` - // Role can be one of the values - 'direct_member', 'admin', 'billing_manager', 'hiring_manager', or 'reinstate'. - Role *string `json:"role,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - Inviter *User `json:"inviter,omitempty"` - TeamCount *int `json:"team_count,omitempty"` - InvitationTeamURL *string `json:"invitation_team_url,omitempty"` -} - -func (i Invitation) String() string { - return Stringify(i) -} - -// ListTeams lists all of the teams for an organization. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-teams -func (s *OrganizationsService) ListTeams(ctx context.Context, org string, opt *ListOptions) ([]*Team, *Response, error) { - u := fmt.Sprintf("orgs/%v/teams", org) - u, err := addOptions(u, opt) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - var teams []*Team - resp, err := s.client.Do(ctx, req, &teams) - if err != nil { - return nil, resp, err - } - - return teams, resp, nil -} - -// GetTeam fetches a team by ID. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team -func (s *OrganizationsService) GetTeam(ctx context.Context, team int64) (*Team, *Response, error) { - u := fmt.Sprintf("teams/%v", team) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - t := new(Team) - resp, err := s.client.Do(ctx, req, t) - if err != nil { - return nil, resp, err - } - - 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.) - Description *string `json:"description,omitempty"` - Maintainers []string `json:"maintainers,omitempty"` - RepoNames []string `json:"repo_names,omitempty"` - ParentTeamID *int64 `json:"parent_team_id,omitempty"` - - // Deprecated: 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"` - - // Privacy identifies the level of privacy this team should have. - // Possible values are: - // secret - only visible to organization owners and members of this team - // closed - visible to all members of this organization - // Default is "secret". - Privacy *string `json:"privacy,omitempty"` - - // LDAPDN may be used in GitHub Enterprise when the team membership - // is synchronized with LDAP. - LDAPDN *string `json:"ldap_dn,omitempty"` -} - -func (s NewTeam) String() string { - return Stringify(s) -} - -// CreateTeam creates a new team within an organization. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#create-team -func (s *OrganizationsService) CreateTeam(ctx context.Context, org string, team *NewTeam) (*Team, *Response, error) { - u := fmt.Sprintf("orgs/%v/teams", org) - req, err := s.client.NewRequest("POST", u, team) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - t := new(Team) - resp, err := s.client.Do(ctx, req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil -} - -// EditTeam edits a team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#edit-team -func (s *OrganizationsService) EditTeam(ctx context.Context, id int64, team *NewTeam) (*Team, *Response, error) { - u := fmt.Sprintf("teams/%v", id) - req, err := s.client.NewRequest("PATCH", u, team) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - t := new(Team) - resp, err := s.client.Do(ctx, req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil -} - -// DeleteTeam deletes a team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#delete-team -func (s *OrganizationsService) DeleteTeam(ctx context.Context, team int64) (*Response, error) { - u := fmt.Sprintf("teams/%v", team) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - return s.client.Do(ctx, req, nil) -} - -// OrganizationListTeamMembersOptions specifies the optional parameters to the -// OrganizationsService.ListTeamMembers method. -type OrganizationListTeamMembersOptions struct { - // Role filters members returned by their role in the team. Possible - // values are "all", "member", "maintainer". Default is "all". - Role string `url:"role,omitempty"` - - ListOptions -} - -// ListChildTeams lists child teams for a team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-child-teams -func (s *OrganizationsService) ListChildTeams(ctx context.Context, teamID int64, opt *ListOptions) ([]*Team, *Response, error) { - u := fmt.Sprintf("teams/%v/teams", teamID) - u, err := addOptions(u, opt) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - var teams []*Team - resp, err := s.client.Do(ctx, req, &teams) - if err != nil { - return nil, resp, err - } - - return teams, resp, nil -} - -// ListTeamMembers lists all of the users who are members of the specified -// team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-team-members -func (s *OrganizationsService) ListTeamMembers(ctx context.Context, team int64, opt *OrganizationListTeamMembersOptions) ([]*User, *Response, error) { - u := fmt.Sprintf("teams/%v/members", team) - u, err := addOptions(u, opt) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - var members []*User - resp, err := s.client.Do(ctx, req, &members) - if err != nil { - return nil, resp, err - } - - return members, resp, nil -} - -// IsTeamMember checks if a user is a member of the specified team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team-member -// -// Deprecated: This API has been marked as deprecated in the Github API docs, -// OrganizationsService.GetTeamMembership method should be used instead. -func (s *OrganizationsService) IsTeamMember(ctx context.Context, team int64, user string) (bool, *Response, error) { - u := fmt.Sprintf("teams/%v/members/%v", team, user) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return false, nil, err - } - - resp, err := s.client.Do(ctx, req, nil) - member, err := parseBoolResponse(err) - return member, resp, err -} - -// ListTeamRepos lists the repositories that the specified team has access to. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-team-repos -func (s *OrganizationsService) ListTeamRepos(ctx context.Context, team int64, opt *ListOptions) ([]*Repository, *Response, error) { - u := fmt.Sprintf("teams/%v/repos", team) - u, err := addOptions(u, opt) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when topics API fully launches. - headers := []string{mediaTypeTopicsPreview, mediaTypeNestedTeamsPreview} - req.Header.Set("Accept", strings.Join(headers, ", ")) - - var repos []*Repository - resp, err := s.client.Do(ctx, req, &repos) - if err != nil { - return nil, resp, err - } - - return repos, resp, nil -} - -// IsTeamRepo checks if a team manages the specified repository. If the -// repository is managed by team, a Repository is returned which includes the -// permissions team has for that repo. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#check-if-a-team-manages-a-repository -func (s *OrganizationsService) IsTeamRepo(ctx context.Context, team int64, owner string, repo string) (*Repository, *Response, error) { - u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - headers := []string{mediaTypeOrgPermissionRepo, mediaTypeNestedTeamsPreview} - req.Header.Set("Accept", strings.Join(headers, ", ")) - - repository := new(Repository) - resp, err := s.client.Do(ctx, req, repository) - if err != nil { - return nil, resp, err - } - - return repository, resp, nil -} - -// OrganizationAddTeamRepoOptions specifies the optional parameters to the -// OrganizationsService.AddTeamRepo method. -type OrganizationAddTeamRepoOptions struct { - // Permission specifies the permission to grant the team on this repository. - // Possible values are: - // pull - team members can pull, but not push to or administer this repository - // push - team members can pull and push, but not administer this repository - // admin - team members can pull, push and administer this repository - // - // If not specified, the team's permission attribute will be used. - Permission string `json:"permission,omitempty"` -} - -// AddTeamRepo adds a repository to be managed by the specified team. The -// specified repository must be owned by the organization to which the team -// belongs, or a direct fork of a repository owned by the organization. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-repo -func (s *OrganizationsService) AddTeamRepo(ctx context.Context, team int64, owner string, repo string, opt *OrganizationAddTeamRepoOptions) (*Response, error) { - u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) - req, err := s.client.NewRequest("PUT", u, opt) - if err != nil { - return nil, err - } - - return s.client.Do(ctx, req, nil) -} - -// RemoveTeamRepo removes a repository from being managed by the specified -// team. Note that this does not delete the repository, it just removes it -// from the team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#remove-team-repo -func (s *OrganizationsService) RemoveTeamRepo(ctx context.Context, team int64, owner string, repo string) (*Response, error) { - u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - return s.client.Do(ctx, req, nil) -} - -// ListUserTeams lists a user's teams -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-user-teams -func (s *OrganizationsService) ListUserTeams(ctx context.Context, opt *ListOptions) ([]*Team, *Response, error) { - u := "user/teams" - u, err := addOptions(u, opt) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - var teams []*Team - resp, err := s.client.Do(ctx, req, &teams) - if err != nil { - return nil, resp, err - } - - return teams, resp, nil -} - -// GetTeamMembership returns the membership status for a user in a team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team-membership -func (s *OrganizationsService) GetTeamMembership(ctx context.Context, team int64, user string) (*Membership, *Response, error) { - u := fmt.Sprintf("teams/%v/memberships/%v", team, user) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - req.Header.Set("Accept", mediaTypeNestedTeamsPreview) - - t := new(Membership) - resp, err := s.client.Do(ctx, req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil -} - -// OrganizationAddTeamMembershipOptions does stuff specifies the optional -// parameters to the OrganizationsService.AddTeamMembership method. -type OrganizationAddTeamMembershipOptions struct { - // Role specifies the role the user should have in the team. Possible - // values are: - // member - a normal member of the team - // maintainer - a team maintainer. Able to add/remove other team - // members, promote other team members to team - // maintainer, and edit the team’s name and description - // - // Default value is "member". - Role string `json:"role,omitempty"` -} - -// AddTeamMembership adds or invites a user to a team. -// -// In order to add a membership between a user and a team, the authenticated -// user must have 'admin' permissions to the team or be an owner of the -// organization that the team is associated with. -// -// If the user is already a part of the team's organization (meaning they're on -// at least one other team in the organization), this endpoint will add the -// user to the team. -// -// If the user is completely unaffiliated with the team's organization (meaning -// they're on none of the organization's teams), this endpoint will send an -// invitation to the user via email. This newly-created membership will be in -// the "pending" state until the user accepts the invitation, at which point -// the membership will transition to the "active" state and the user will be -// added as a member of the team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-membership -func (s *OrganizationsService) AddTeamMembership(ctx context.Context, team int64, user string, opt *OrganizationAddTeamMembershipOptions) (*Membership, *Response, error) { - u := fmt.Sprintf("teams/%v/memberships/%v", team, user) - req, err := s.client.NewRequest("PUT", u, opt) - if err != nil { - return nil, nil, err - } - - t := new(Membership) - resp, err := s.client.Do(ctx, req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil -} - -// RemoveTeamMembership removes a user from a team. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#remove-team-membership -func (s *OrganizationsService) RemoveTeamMembership(ctx context.Context, team int64, user string) (*Response, error) { - u := fmt.Sprintf("teams/%v/memberships/%v", team, user) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - return s.client.Do(ctx, req, nil) -} - -// ListPendingTeamInvitations get pending invitaion list in team. -// Warning: The API may change without advance notice during the preview period. -// Preview features are not supported for production use. -// -// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations -func (s *OrganizationsService) ListPendingTeamInvitations(ctx context.Context, team int64, opt *ListOptions) ([]*Invitation, *Response, error) { - u := fmt.Sprintf("teams/%v/invitations", team) - u, err := addOptions(u, opt) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - var pendingInvitations []*Invitation - resp, err := s.client.Do(ctx, req, &pendingInvitations) - if err != nil { - return nil, resp, err - } - - return pendingInvitations, resp, nil -} diff --git a/vendor/github.com/google/go-github/github/projects.go b/vendor/github.com/google/go-github/github/projects.go index 4df8a49e5c..76ef1e0a3b 100644 --- a/vendor/github.com/google/go-github/github/projects.go +++ b/vendor/github.com/google/go-github/github/projects.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" ) // ProjectsService provides access to the projects functions in the @@ -19,15 +18,18 @@ type ProjectsService service // Project represents a GitHub Project. type Project struct { - ID *int64 `json:"id,omitempty"` - URL *string `json:"url,omitempty"` - OwnerURL *string `json:"owner_url,omitempty"` - Name *string `json:"name,omitempty"` - Body *string `json:"body,omitempty"` - Number *int `json:"number,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - NodeID *string `json:"node_id,omitempty"` + ID *int64 `json:"id,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + ColumnsURL *string `json:"columns_url,omitempty"` + OwnerURL *string `json:"owner_url,omitempty"` + Name *string `json:"name,omitempty"` + Body *string `json:"body,omitempty"` + Number *int `json:"number,omitempty"` + State *string `json:"state,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + NodeID *string `json:"node_id,omitempty"` // The User object that generated the project. Creator *User `json:"creator,omitempty"` @@ -48,8 +50,7 @@ func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, * } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) project := &Project{} resp, err := s.client.Do(ctx, req, project) @@ -65,15 +66,24 @@ func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, * // ProjectsService.UpdateProject methods. type ProjectOptions struct { // The name of the project. (Required for creation; optional for update.) - Name string `json:"name,omitempty"` + Name *string `json:"name,omitempty"` // The body of the project. (Optional.) - Body string `json:"body,omitempty"` + Body *string `json:"body,omitempty"` // The following field(s) are only applicable for update. // They should be left with zero values for creation. // State of the project. Either "open" or "closed". (Optional.) - State string `json:"state,omitempty"` + State *string `json:"state,omitempty"` + // The permission level that all members of the project's organization + // will have on this project. + // Setting the organization permission is only available + // for organization projects. (Optional.) + OrganizationPermission *string `json:"organization_permission,omitempty"` + // Sets visibility of the project within the organization. + // Setting visibility is only available + // for organization projects.(Optional.) + Public *bool `json:"public,omitempty"` } // UpdateProject updates a repository project. @@ -87,8 +97,7 @@ func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opt *Proj } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) project := &Project{} resp, err := s.client.Do(ctx, req, project) @@ -121,7 +130,9 @@ func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Respons type ProjectColumn struct { ID *int64 `json:"id,omitempty"` Name *string `json:"name,omitempty"` + URL *string `json:"url,omitempty"` ProjectURL *string `json:"project_url,omitempty"` + CardsURL *string `json:"cards_url,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` NodeID *string `json:"node_id,omitempty"` @@ -143,8 +154,7 @@ func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int6 } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) columns := []*ProjectColumn{} resp, err := s.client.Do(ctx, req, &columns) @@ -166,8 +176,7 @@ func (s *ProjectsService) GetProjectColumn(ctx context.Context, id int64) (*Proj } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) column := &ProjectColumn{} resp, err := s.client.Do(ctx, req, column) @@ -197,8 +206,7 @@ func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) column := &ProjectColumn{} resp, err := s.client.Do(ctx, req, column) @@ -220,8 +228,7 @@ func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int6 } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) column := &ProjectColumn{} resp, err := s.client.Do(ctx, req, column) @@ -317,8 +324,7 @@ func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) cards := []*ProjectCard{} resp, err := s.client.Do(ctx, req, &cards) @@ -340,8 +346,7 @@ func (s *ProjectsService) GetProjectCard(ctx context.Context, columnID int64) (* } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) card := &ProjectCard{} resp, err := s.client.Do(ctx, req, card) @@ -379,8 +384,7 @@ func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) card := &ProjectCard{} resp, err := s.client.Do(ctx, req, card) @@ -402,8 +406,7 @@ func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, o } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) card := &ProjectCard{} resp, err := s.client.Do(ctx, req, card) diff --git a/vendor/github.com/google/go-github/github/pulls.go b/vendor/github.com/google/go-github/github/pulls.go index 1f344690bc..a0c3c041ca 100644 --- a/vendor/github.com/google/go-github/github/pulls.go +++ b/vendor/github.com/google/go-github/github/pulls.go @@ -60,14 +60,40 @@ type PullRequest struct { NodeID *string `json:"node_id,omitempty"` RequestedReviewers []*User `json:"requested_reviewers,omitempty"` - Head *PullRequestBranch `json:"head,omitempty"` - Base *PullRequestBranch `json:"base,omitempty"` + // RequestedTeams is populated as part of the PullRequestEvent. + // See, https://developer.github.com/v3/activity/events/types/#pullrequestevent for an example. + RequestedTeams []*Team `json:"requested_teams,omitempty"` + + Links *PRLinks `json:"_links,omitempty"` + Head *PullRequestBranch `json:"head,omitempty"` + Base *PullRequestBranch `json:"base,omitempty"` + + // ActiveLockReason is populated only when LockReason is provided while locking the pull request. + // Possible values are: "off-topic", "too heated", "resolved", and "spam". + ActiveLockReason *string `json:"active_lock_reason,omitempty"` } func (p PullRequest) String() string { return Stringify(p) } +// PRLink represents a single link object from Github pull request _links. +type PRLink struct { + HRef *string `json:"href,omitempty"` +} + +// PRLinks represents the "_links" object in a Github pull request. +type PRLinks struct { + Self *PRLink `json:"self,omitempty"` + HTML *PRLink `json:"html,omitempty"` + Issue *PRLink `json:"issue,omitempty"` + Comments *PRLink `json:"comments,omitempty"` + ReviewComments *PRLink `json:"review_comments,omitempty"` + ReviewComment *PRLink `json:"review_comment,omitempty"` + Commits *PRLink `json:"commits,omitempty"` + Statuses *PRLink `json:"statuses,omitempty"` +} + // PullRequestBranch represents a base or head branch in a GitHub pull request. type PullRequestBranch struct { Label *string `json:"label,omitempty"` @@ -119,7 +145,7 @@ func (s *PullRequestsService) List(ctx context.Context, owner string, repo strin } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} + acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) var pulls []*PullRequest @@ -142,7 +168,7 @@ func (s *PullRequestsService) Get(ctx context.Context, owner string, repo string } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} + acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) pull := new(PullRequest) @@ -201,8 +227,7 @@ func (s *PullRequestsService) Create(ctx context.Context, owner string, repo str } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeLabelDescriptionSearchPreview) p := new(PullRequest) resp, err := s.client.Do(ctx, req, p) @@ -251,7 +276,7 @@ func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo strin } // TODO: remove custom Accept header when this API fully launches. - acceptHeaders := []string{mediaTypeGraphQLNodeIDPreview, mediaTypeLabelDescriptionSearchPreview} + acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) p := new(PullRequest) diff --git a/vendor/github.com/google/go-github/github/reactions.go b/vendor/github.com/google/go-github/github/reactions.go index 19b533f39f..ddc055cb1b 100644 --- a/vendor/github.com/google/go-github/github/reactions.go +++ b/vendor/github.com/google/go-github/github/reactions.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" ) // ReactionsService provides access to the reactions-related functions in the @@ -61,8 +60,7 @@ func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) var m []*Reaction resp, err := s.client.Do(ctx, req, &m) @@ -76,6 +74,7 @@ func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo // CreateCommentReaction creates a reaction for a commit comment. // Note that if you have already created a reaction of type content, the // previously created reaction will be returned with Status: 200 OK. +// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray". // // GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment func (s ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { @@ -88,8 +87,7 @@ func (s ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) m := &Reaction{} resp, err := s.client.Do(ctx, req, m) @@ -116,8 +114,7 @@ func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo s } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) var m []*Reaction resp, err := s.client.Do(ctx, req, &m) @@ -131,6 +128,7 @@ func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo s // CreateIssueReaction creates a reaction for an issue. // Note that if you have already created a reaction of type content, the // previously created reaction will be returned with Status: 200 OK. +// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray". // // GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-an-issue func (s ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) { @@ -143,8 +141,7 @@ func (s ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo s } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) m := &Reaction{} resp, err := s.client.Do(ctx, req, m) @@ -171,8 +168,7 @@ func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) var m []*Reaction resp, err := s.client.Do(ctx, req, &m) @@ -186,6 +182,7 @@ func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner, // CreateIssueCommentReaction creates a reaction for an issue comment. // Note that if you have already created a reaction of type content, the // previously created reaction will be returned with Status: 200 OK. +// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray". // // GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment func (s ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { @@ -198,8 +195,7 @@ func (s ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) m := &Reaction{} resp, err := s.client.Do(ctx, req, m) @@ -226,8 +222,7 @@ func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) var m []*Reaction resp, err := s.client.Do(ctx, req, &m) @@ -241,6 +236,7 @@ func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context, // CreatePullRequestCommentReaction creates a reaction for a pull request review comment. // Note that if you have already created a reaction of type content, the // previously created reaction will be returned with Status: 200 OK. +// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray". // // GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment func (s ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { @@ -253,8 +249,104 @@ func (s ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeReactionsPreview) + + m := &Reaction{} + resp, err := s.client.Do(ctx, req, m) + if err != nil { + return nil, resp, err + } + + return m, resp, nil +} + +// ListTeamDiscussionReactions lists the reactions for a team discussion. +// +// GitHub API docs: https://developer.github.com/v3/reactions/#list-reactions-for-a-team-discussion +func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, teamID int64, discussionNumber int, opt *ListOptions) ([]*Reaction, *Response, error) { + u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeReactionsPreview) + + var m []*Reaction + resp, err := s.client.Do(ctx, req, &m) + if err != nil { + return nil, resp, err + } + + return m, resp, nil +} + +// CreateTeamDiscussionReaction creates a reaction for a team discussion. +// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray". +// +// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-a-team-discussion +func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) { + u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber) + + body := &Reaction{Content: String(content)} + req, err := s.client.NewRequest("POST", u, body) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeReactionsPreview) + + m := &Reaction{} + resp, err := s.client.Do(ctx, req, m) + if err != nil { + return nil, resp, err + } + + return m, resp, nil +} + +// ListTeamDiscussionCommentReactions lists the reactions for a team discussion comment. +// +// GitHub API docs: https://developer.github.com/v3/reactions/#list-reactions-for-a-team-discussion-comment +func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Context, teamID int64, discussionNumber, commentNumber int, opt *ListOptions) ([]*Reaction, *Response, error) { + u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeReactionsPreview) + + var m []*Reaction + resp, err := s.client.Do(ctx, req, &m) + + return m, resp, nil +} + +// CreateTeamDiscussionCommentReaction creates a reaction for a team discussion comment. +// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray". +// +// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-a-team-discussion-comment +func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) { + u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber) + + body := &Reaction{Content: String(content)} + req, err := s.client.NewRequest("POST", u, body) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeReactionsPreview) m := &Reaction{} resp, err := s.client.Do(ctx, req, m) diff --git a/vendor/github.com/google/go-github/github/repos.go b/vendor/github.com/google/go-github/github/repos.go index fbc059c6b2..e783ccbea0 100644 --- a/vendor/github.com/google/go-github/github/repos.go +++ b/vendor/github.com/google/go-github/github/repos.go @@ -20,6 +20,7 @@ type RepositoriesService service // Repository represents a GitHub repository. type Repository struct { ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` Owner *User `json:"owner,omitempty"` Name *string `json:"name,omitempty"` FullName *string `json:"full_name,omitempty"` @@ -55,6 +56,7 @@ type Repository struct { AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` Topics []string `json:"topics,omitempty"` + Archived *bool `json:"archived,omitempty"` // Only provided when using RepositoriesService.Get while in preview License *License `json:"license,omitempty"` @@ -68,7 +70,6 @@ type Repository struct { HasDownloads *bool `json:"has_downloads,omitempty"` LicenseTemplate *string `json:"license_template,omitempty"` GitignoreTemplate *string `json:"gitignore_template,omitempty"` - Archived *bool `json:"archived,omitempty"` // Creating an organization repository. Required for non-owners. TeamID *int64 `json:"team_id,omitempty"` @@ -258,10 +259,40 @@ func (s *RepositoriesService) ListAll(ctx context.Context, opt *RepositoryListAl return repos, resp, nil } +// createRepoRequest is a subset of Repository and is used internally +// by Create to pass only the known fields for the endpoint. +// +// See https://github.com/google/go-github/issues/1014 for more +// information. +type createRepoRequest struct { + // Name is required when creating a repo. + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Homepage *string `json:"homepage,omitempty"` + + Private *bool `json:"private,omitempty"` + HasIssues *bool `json:"has_issues,omitempty"` + HasProjects *bool `json:"has_projects,omitempty"` + HasWiki *bool `json:"has_wiki,omitempty"` + + // Creating an organization repository. Required for non-owners. + TeamID *int64 `json:"team_id,omitempty"` + + AutoInit *bool `json:"auto_init,omitempty"` + GitignoreTemplate *string `json:"gitignore_template,omitempty"` + LicenseTemplate *string `json:"license_template,omitempty"` + AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` + AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` + AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` +} + // Create a new repository. If an organization is specified, the new // repository will be created under that org. If the empty string is // specified, it will be created for the authenticated user. // +// Note that only a subset of the repo fields are used and repo must +// not be nil. +// // GitHub API docs: https://developer.github.com/v3/repos/#create func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error) { var u string @@ -271,7 +302,24 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo u = "user/repos" } - req, err := s.client.NewRequest("POST", u, repo) + repoReq := &createRepoRequest{ + Name: repo.Name, + Description: repo.Description, + Homepage: repo.Homepage, + Private: repo.Private, + HasIssues: repo.HasIssues, + HasProjects: repo.HasProjects, + HasWiki: repo.HasWiki, + TeamID: repo.TeamID, + AutoInit: repo.AutoInit, + GitignoreTemplate: repo.GitignoreTemplate, + LicenseTemplate: repo.LicenseTemplate, + AllowSquashMerge: repo.AllowSquashMerge, + AllowMergeCommit: repo.AllowMergeCommit, + AllowRebaseMerge: repo.AllowRebaseMerge, + } + + req, err := s.client.NewRequest("POST", u, repoReq) if err != nil { return nil, nil, err } @@ -567,6 +615,9 @@ type PullRequestReviewsEnforcement struct { DismissStaleReviews bool `json:"dismiss_stale_reviews"` // RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner. RequireCodeOwnerReviews bool `json:"require_code_owner_reviews"` + // RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged. + // Valid values are 1-6. + RequiredApprovingReviewCount int `json:"required_approving_review_count"` } // PullRequestReviewsEnforcementRequest represents request to set the pull request review @@ -581,6 +632,9 @@ type PullRequestReviewsEnforcementRequest struct { DismissStaleReviews bool `json:"dismiss_stale_reviews"` // RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner. RequireCodeOwnerReviews bool `json:"require_code_owner_reviews"` + // RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged. + // Valid values are 1-6. + RequiredApprovingReviewCount int `json:"required_approving_review_count"` } // PullRequestReviewsEnforcementUpdate represents request to patch the pull request review @@ -593,6 +647,9 @@ type PullRequestReviewsEnforcementUpdate struct { DismissStaleReviews *bool `json:"dismiss_stale_reviews,omitempty"` // RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner. RequireCodeOwnerReviews bool `json:"require_code_owner_reviews,omitempty"` + // RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged. + // Valid values are 1 - 6. + RequiredApprovingReviewCount int `json:"required_approving_review_count"` } // AdminEnforcement represents the configuration to enforce required status checks for repository administrators. @@ -657,7 +714,7 @@ func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, re } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) var branches []*Branch resp, err := s.client.Do(ctx, req, &branches) @@ -679,7 +736,7 @@ func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) b := new(Branch) resp, err := s.client.Do(ctx, req, b) @@ -701,7 +758,7 @@ func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, re } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) p := new(Protection) resp, err := s.client.Do(ctx, req, p) @@ -723,7 +780,7 @@ func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) p := new(RequiredStatusChecks) resp, err := s.client.Do(ctx, req, p) @@ -745,7 +802,7 @@ func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Conte } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) resp, err = s.client.Do(ctx, req, &contexts) if err != nil { @@ -766,7 +823,7 @@ func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner, } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) p := new(Protection) resp, err := s.client.Do(ctx, req, p) @@ -788,7 +845,7 @@ func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner, } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) return s.client.Do(ctx, req, nil) } @@ -842,7 +899,7 @@ func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Contex } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) r := new(PullRequestReviewsEnforcement) resp, err := s.client.Do(ctx, req, r) @@ -865,7 +922,7 @@ func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Con } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) r := new(PullRequestReviewsEnforcement) resp, err := s.client.Do(ctx, req, r) @@ -893,7 +950,7 @@ func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context, } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) r := new(PullRequestReviewsEnforcement) resp, err := s.client.Do(ctx, req, r) @@ -915,7 +972,7 @@ func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Con } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) return s.client.Do(ctx, req, nil) } @@ -931,7 +988,7 @@ func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, re } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) r := new(AdminEnforcement) resp, err := s.client.Do(ctx, req, r) @@ -954,7 +1011,7 @@ func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, re } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) r := new(AdminEnforcement) resp, err := s.client.Do(ctx, req, r) @@ -976,7 +1033,7 @@ func (s *RepositoriesService) RemoveAdminEnforcement(ctx context.Context, owner, } // TODO: remove custom Accept header when this API fully launches - req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) + req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) return s.client.Do(ctx, req, nil) } diff --git a/vendor/github.com/google/go-github/github/repos_deployments.go b/vendor/github.com/google/go-github/github/repos_deployments.go index 1300f05ee2..794c3232ed 100644 --- a/vendor/github.com/google/go-github/github/repos_deployments.go +++ b/vendor/github.com/google/go-github/github/repos_deployments.go @@ -9,7 +9,6 @@ import ( "context" "encoding/json" "fmt" - "strings" ) // Deployment represents a deployment in a repo @@ -76,9 +75,6 @@ func (s *RepositoriesService) ListDeployments(ctx context.Context, owner, repo s return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var deployments []*Deployment resp, err := s.client.Do(ctx, req, &deployments) if err != nil { @@ -99,9 +95,6 @@ func (s *RepositoriesService) GetDeployment(ctx context.Context, owner, repo str return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - deployment := new(Deployment) resp, err := s.client.Do(ctx, req, deployment) if err != nil { @@ -123,8 +116,7 @@ func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeDeploymentStatusPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeDeploymentStatusPreview) d := new(Deployment) resp, err := s.client.Do(ctx, req, d) @@ -176,9 +168,6 @@ func (s *RepositoriesService) ListDeploymentStatuses(ctx context.Context, owner, return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var statuses []*DeploymentStatus resp, err := s.client.Do(ctx, req, &statuses) if err != nil { @@ -200,8 +189,7 @@ func (s *RepositoriesService) GetDeploymentStatus(ctx context.Context, owner, re } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeDeploymentStatusPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeDeploymentStatusPreview) d := new(DeploymentStatus) resp, err := s.client.Do(ctx, req, d) @@ -224,8 +212,7 @@ func (s *RepositoriesService) CreateDeploymentStatus(ctx context.Context, owner, } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeDeploymentStatusPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeDeploymentStatusPreview) d := new(DeploymentStatus) resp, err := s.client.Do(ctx, req, d) diff --git a/vendor/github.com/google/go-github/github/repos_forks.go b/vendor/github.com/google/go-github/github/repos_forks.go index d0bff54470..bfff27bb95 100644 --- a/vendor/github.com/google/go-github/github/repos_forks.go +++ b/vendor/github.com/google/go-github/github/repos_forks.go @@ -8,6 +8,8 @@ package github import ( "context" "fmt" + + "encoding/json" ) // RepositoryListForksOptions specifies the optional parameters to the @@ -78,10 +80,15 @@ func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string fork := new(Repository) resp, err := s.client.Do(ctx, req, fork) - if _, ok := err.(*AcceptedError); ok { - return fork, resp, err - } if err != nil { + // Persist AcceptedError's metadata to the Repository object. + if aerr, ok := err.(*AcceptedError); ok { + if err := json.Unmarshal(aerr.Raw, fork); err != nil { + return fork, resp, err + } + + return fork, resp, err + } return nil, resp, err } diff --git a/vendor/github.com/google/go-github/github/repos_hooks.go b/vendor/github.com/google/go-github/github/repos_hooks.go index 1e9e884801..564f5e576f 100644 --- a/vendor/github.com/google/go-github/github/repos_hooks.go +++ b/vendor/github.com/google/go-github/github/repos_hooks.go @@ -69,27 +69,55 @@ func (w WebHookAuthor) String() string { // Hook represents a GitHub (web and service) hook for a repository. type Hook struct { - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - Name *string `json:"name,omitempty"` - URL *string `json:"url,omitempty"` - Events []string `json:"events,omitempty"` - Active *bool `json:"active,omitempty"` - Config map[string]interface{} `json:"config,omitempty"` - ID *int64 `json:"id,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + URL *string `json:"url,omitempty"` + ID *int64 `json:"id,omitempty"` + + // Only the following fields are used when creating a hook. + // Name and Config are required. + Name *string `json:"name,omitempty"` + Config map[string]interface{} `json:"config,omitempty"` + Events []string `json:"events,omitempty"` + Active *bool `json:"active,omitempty"` } func (h Hook) String() string { return Stringify(h) } +// createHookRequest is a subset of Hook and is used internally +// by CreateHook to pass only the known fields for the endpoint. +// +// See https://github.com/google/go-github/issues/1015 for more +// information. +type createHookRequest struct { + // Name and Config are required. + // Name must be passed as "web". + Name *string `json:"name,omitempty"` + Config map[string]interface{} `json:"config,omitempty"` + Events []string `json:"events,omitempty"` + Active *bool `json:"active,omitempty"` +} + // CreateHook creates a Hook for the specified repository. // Name and Config are required fields. // +// Note that only a subset of the hook fields are used and hook must +// not be nil. +// // GitHub API docs: https://developer.github.com/v3/repos/hooks/#create-a-hook func (s *RepositoriesService) CreateHook(ctx context.Context, owner, repo string, hook *Hook) (*Hook, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo) - req, err := s.client.NewRequest("POST", u, hook) + + hookReq := &createHookRequest{ + Name: hook.Name, + Events: hook.Events, + Active: hook.Active, + Config: hook.Config, + } + + req, err := s.client.NewRequest("POST", u, hookReq) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/google/go-github/github/repos_projects.go b/vendor/github.com/google/go-github/github/repos_projects.go index 97a045f6dd..d6486d293c 100644 --- a/vendor/github.com/google/go-github/github/repos_projects.go +++ b/vendor/github.com/google/go-github/github/repos_projects.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" ) // ProjectListOptions specifies the optional parameters to the @@ -36,8 +35,7 @@ func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo stri } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) var projects []*Project resp, err := s.client.Do(ctx, req, &projects) @@ -59,8 +57,7 @@ func (s *RepositoriesService) CreateProject(ctx context.Context, owner, repo str } // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{mediaTypeProjectsPreview, mediaTypeGraphQLNodeIDPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept", mediaTypeProjectsPreview) project := &Project{} resp, err := s.client.Do(ctx, req, project) diff --git a/vendor/github.com/google/go-github/github/repos_releases.go b/vendor/github.com/google/go-github/github/repos_releases.go index d5dfc702f2..bf58743ebd 100644 --- a/vendor/github.com/google/go-github/github/repos_releases.go +++ b/vendor/github.com/google/go-github/github/repos_releases.go @@ -19,24 +19,26 @@ import ( // RepositoryRelease represents a GitHub release in a repository. type RepositoryRelease struct { - ID *int64 `json:"id,omitempty"` - TagName *string `json:"tag_name,omitempty"` - TargetCommitish *string `json:"target_commitish,omitempty"` - Name *string `json:"name,omitempty"` - Body *string `json:"body,omitempty"` - Draft *bool `json:"draft,omitempty"` - Prerelease *bool `json:"prerelease,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - PublishedAt *Timestamp `json:"published_at,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - AssetsURL *string `json:"assets_url,omitempty"` - Assets []ReleaseAsset `json:"assets,omitempty"` - UploadURL *string `json:"upload_url,omitempty"` - ZipballURL *string `json:"zipball_url,omitempty"` - TarballURL *string `json:"tarball_url,omitempty"` - Author *User `json:"author,omitempty"` - NodeID *string `json:"node_id,omitempty"` + TagName *string `json:"tag_name,omitempty"` + TargetCommitish *string `json:"target_commitish,omitempty"` + Name *string `json:"name,omitempty"` + Body *string `json:"body,omitempty"` + Draft *bool `json:"draft,omitempty"` + Prerelease *bool `json:"prerelease,omitempty"` + + // The following fields are not used in CreateRelease or EditRelease: + ID *int64 `json:"id,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + PublishedAt *Timestamp `json:"published_at,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + AssetsURL *string `json:"assets_url,omitempty"` + Assets []ReleaseAsset `json:"assets,omitempty"` + UploadURL *string `json:"upload_url,omitempty"` + ZipballURL *string `json:"zipball_url,omitempty"` + TarballURL *string `json:"tarball_url,omitempty"` + Author *User `json:"author,omitempty"` + NodeID *string `json:"node_id,omitempty"` } func (r RepositoryRelease) String() string { @@ -79,9 +81,6 @@ func (s *RepositoriesService) ListReleases(ctx context.Context, owner, repo stri return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var releases []*RepositoryRelease resp, err := s.client.Do(ctx, req, &releases) if err != nil { @@ -120,9 +119,6 @@ func (s *RepositoriesService) getSingleRelease(ctx context.Context, url string) return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - release := new(RepositoryRelease) resp, err := s.client.Do(ctx, req, release) if err != nil { @@ -131,20 +127,44 @@ func (s *RepositoriesService) getSingleRelease(ctx context.Context, url string) return release, resp, nil } +// repositoryReleaseRequest is a subset of RepositoryRelease and +// is used internally by CreateRelease and EditRelease to pass +// only the known fields for these endpoints. +// +// See https://github.com/google/go-github/issues/992 for more +// information. +type repositoryReleaseRequest struct { + TagName *string `json:"tag_name,omitempty"` + TargetCommitish *string `json:"target_commitish,omitempty"` + Name *string `json:"name,omitempty"` + Body *string `json:"body,omitempty"` + Draft *bool `json:"draft,omitempty"` + Prerelease *bool `json:"prerelease,omitempty"` +} + // CreateRelease adds a new release for a repository. // +// Note that only a subset of the release fields are used. +// See RepositoryRelease for more information. +// // GitHub API docs: https://developer.github.com/v3/repos/releases/#create-a-release func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, release *RepositoryRelease) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases", owner, repo) - req, err := s.client.NewRequest("POST", u, release) + releaseReq := &repositoryReleaseRequest{ + TagName: release.TagName, + TargetCommitish: release.TargetCommitish, + Name: release.Name, + Body: release.Body, + Draft: release.Draft, + Prerelease: release.Prerelease, + } + + req, err := s.client.NewRequest("POST", u, releaseReq) if err != nil { return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - r := new(RepositoryRelease) resp, err := s.client.Do(ctx, req, r) if err != nil { @@ -155,18 +175,27 @@ func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo str // EditRelease edits a repository release. // +// Note that only a subset of the release fields are used. +// See RepositoryRelease for more information. +// // GitHub API docs: https://developer.github.com/v3/repos/releases/#edit-a-release func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo string, id int64, release *RepositoryRelease) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) - req, err := s.client.NewRequest("PATCH", u, release) + releaseReq := &repositoryReleaseRequest{ + TagName: release.TagName, + TargetCommitish: release.TargetCommitish, + Name: release.Name, + Body: release.Body, + Draft: release.Draft, + Prerelease: release.Prerelease, + } + + req, err := s.client.NewRequest("PATCH", u, releaseReq) if err != nil { return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - r := new(RepositoryRelease) resp, err := s.client.Do(ctx, req, r) if err != nil { @@ -203,9 +232,6 @@ func (s *RepositoriesService) ListReleaseAssets(ctx context.Context, owner, repo return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - var assets []*ReleaseAsset resp, err := s.client.Do(ctx, req, &assets) if err != nil { @@ -225,9 +251,6 @@ func (s *RepositoriesService) GetReleaseAsset(ctx context.Context, owner, repo s return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - asset := new(ReleaseAsset) resp, err := s.client.Do(ctx, req, asset) if err != nil { @@ -292,9 +315,6 @@ func (s *RepositoriesService) EditReleaseAsset(ctx context.Context, owner, repo return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - asset := new(ReleaseAsset) resp, err := s.client.Do(ctx, req, asset) if err != nil { @@ -341,9 +361,6 @@ func (s *RepositoriesService) UploadReleaseAsset(ctx context.Context, owner, rep return nil, nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview) - asset := new(ReleaseAsset) resp, err := s.client.Do(ctx, req, asset) if err != nil { diff --git a/vendor/github.com/google/go-github/github/search.go b/vendor/github.com/google/go-github/github/search.go index 6e0000df88..abaf5e1f0b 100644 --- a/vendor/github.com/google/go-github/github/search.go +++ b/vendor/github.com/google/go-github/github/search.go @@ -8,7 +8,9 @@ package github import ( "context" "fmt" + "net/url" "strconv" + "strings" qs "github.com/google/go-querystring/query" ) @@ -221,11 +223,15 @@ func (s *SearchService) search(ctx context.Context, searchType string, parameter if err != nil { return nil, err } - params.Set("q", parameters.Query) + q := strings.Replace(parameters.Query, " ", "+", -1) if parameters.RepositoryID != nil { params.Set("repository_id", strconv.FormatInt(*parameters.RepositoryID, 10)) } - u := fmt.Sprintf("search/%s?%s", searchType, params.Encode()) + query := "q=" + url.PathEscape(q) + if v := params.Encode(); v != "" { + query = query + "&" + v + } + u := fmt.Sprintf("search/%s?%s", searchType, query) req, err := s.client.NewRequest("GET", u, nil) if err != nil { diff --git a/vendor/github.com/google/go-github/github/teams.go b/vendor/github.com/google/go-github/github/teams.go index 1021d538fd..c3773e00e3 100644 --- a/vendor/github.com/google/go-github/github/teams.go +++ b/vendor/github.com/google/go-github/github/teams.go @@ -1,7 +1,357 @@ +// Copyright 2018 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package github +import ( + "context" + "fmt" + "strings" + "time" +) + // TeamsService provides access to the team-related functions // in the GitHub API. // // GitHub API docs: https://developer.github.com/v3/teams/ type TeamsService service + +// Team represents a team within a GitHub organization. Teams are used to +// manage access to an organization's repositories. +type Team struct { + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + URL *string `json:"url,omitempty"` + Slug *string `json:"slug,omitempty"` + + // Permission specifies the default permission for repositories owned by the team. + Permission *string `json:"permission,omitempty"` + + // Privacy identifies the level of privacy this team should have. + // Possible values are: + // secret - only visible to organization owners and members of this team + // closed - visible to all members of this organization + // Default is "secret". + Privacy *string `json:"privacy,omitempty"` + + MembersCount *int `json:"members_count,omitempty"` + ReposCount *int `json:"repos_count,omitempty"` + Organization *Organization `json:"organization,omitempty"` + MembersURL *string `json:"members_url,omitempty"` + RepositoriesURL *string `json:"repositories_url,omitempty"` + Parent *Team `json:"parent,omitempty"` + + // LDAPDN is only available in GitHub Enterprise and when the team + // membership is synchronized with LDAP. + LDAPDN *string `json:"ldap_dn,omitempty"` +} + +func (t Team) String() string { + return Stringify(t) +} + +// Invitation represents a team member's invitation status. +type Invitation struct { + ID *int64 `json:"id,omitempty"` + Login *string `json:"login,omitempty"` + Email *string `json:"email,omitempty"` + // Role can be one of the values - 'direct_member', 'admin', 'billing_manager', 'hiring_manager', or 'reinstate'. + Role *string `json:"role,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + Inviter *User `json:"inviter,omitempty"` + TeamCount *int `json:"team_count,omitempty"` + InvitationTeamURL *string `json:"invitation_team_url,omitempty"` +} + +func (i Invitation) String() string { + return Stringify(i) +} + +// ListTeams lists all of the teams for an organization. +// +// GitHub API docs: https://developer.github.com/v3/teams/#list-teams +func (s *TeamsService) ListTeams(ctx context.Context, org string, opt *ListOptions) ([]*Team, *Response, error) { + u := fmt.Sprintf("orgs/%v/teams", org) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + var teams []*Team + resp, err := s.client.Do(ctx, req, &teams) + if err != nil { + return nil, resp, err + } + + return teams, resp, nil +} + +// GetTeam fetches a team by ID. +// +// GitHub API docs: https://developer.github.com/v3/teams/#get-team +func (s *TeamsService) GetTeam(ctx context.Context, team int64) (*Team, *Response, error) { + u := fmt.Sprintf("teams/%v", team) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + t := new(Team) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + 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.) + Description *string `json:"description,omitempty"` + Maintainers []string `json:"maintainers,omitempty"` + RepoNames []string `json:"repo_names,omitempty"` + ParentTeamID *int64 `json:"parent_team_id,omitempty"` + + // Deprecated: 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"` + + // Privacy identifies the level of privacy this team should have. + // Possible values are: + // secret - only visible to organization owners and members of this team + // closed - visible to all members of this organization + // Default is "secret". + Privacy *string `json:"privacy,omitempty"` + + // LDAPDN may be used in GitHub Enterprise when the team membership + // is synchronized with LDAP. + LDAPDN *string `json:"ldap_dn,omitempty"` +} + +func (s NewTeam) String() string { + return Stringify(s) +} + +// CreateTeam creates a new team within an organization. +// +// GitHub API docs: https://developer.github.com/v3/teams/#create-team +func (s *TeamsService) CreateTeam(ctx context.Context, org string, team NewTeam) (*Team, *Response, error) { + u := fmt.Sprintf("orgs/%v/teams", org) + req, err := s.client.NewRequest("POST", u, team) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + t := new(Team) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + return t, resp, nil +} + +// EditTeam edits a team. +// +// GitHub API docs: https://developer.github.com/v3/teams/#edit-team +func (s *TeamsService) EditTeam(ctx context.Context, id int64, team NewTeam) (*Team, *Response, error) { + u := fmt.Sprintf("teams/%v", id) + req, err := s.client.NewRequest("PATCH", u, team) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + t := new(Team) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + return t, resp, nil +} + +// DeleteTeam deletes a team. +// +// GitHub API docs: https://developer.github.com/v3/teams/#delete-team +func (s *TeamsService) DeleteTeam(ctx context.Context, team int64) (*Response, error) { + u := fmt.Sprintf("teams/%v", team) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + return s.client.Do(ctx, req, nil) +} + +// ListChildTeams lists child teams for a team. +// +// GitHub API docs: https://developer.github.com/v3/teams/#list-child-teams +func (s *TeamsService) ListChildTeams(ctx context.Context, teamID int64, opt *ListOptions) ([]*Team, *Response, error) { + u := fmt.Sprintf("teams/%v/teams", teamID) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + var teams []*Team + resp, err := s.client.Do(ctx, req, &teams) + if err != nil { + return nil, resp, err + } + + return teams, resp, nil +} + +// ListTeamRepos lists the repositories that the specified team has access to. +// +// GitHub API docs: https://developer.github.com/v3/teams/#list-team-repos +func (s *TeamsService) ListTeamRepos(ctx context.Context, team int64, opt *ListOptions) ([]*Repository, *Response, error) { + u := fmt.Sprintf("teams/%v/repos", team) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when topics API fully launches. + headers := []string{mediaTypeTopicsPreview, mediaTypeNestedTeamsPreview} + req.Header.Set("Accept", strings.Join(headers, ", ")) + + var repos []*Repository + resp, err := s.client.Do(ctx, req, &repos) + if err != nil { + return nil, resp, err + } + + return repos, resp, nil +} + +// IsTeamRepo checks if a team manages the specified repository. If the +// repository is managed by team, a Repository is returned which includes the +// permissions team has for that repo. +// +// GitHub API docs: https://developer.github.com/v3/teams/#check-if-a-team-manages-a-repository +func (s *TeamsService) IsTeamRepo(ctx context.Context, team int64, owner string, repo string) (*Repository, *Response, error) { + u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + headers := []string{mediaTypeOrgPermissionRepo, mediaTypeNestedTeamsPreview} + req.Header.Set("Accept", strings.Join(headers, ", ")) + + repository := new(Repository) + resp, err := s.client.Do(ctx, req, repository) + if err != nil { + return nil, resp, err + } + + return repository, resp, nil +} + +// TeamAddTeamRepoOptions specifies the optional parameters to the +// TeamsService.AddTeamRepo method. +type TeamAddTeamRepoOptions struct { + // Permission specifies the permission to grant the team on this repository. + // Possible values are: + // pull - team members can pull, but not push to or administer this repository + // push - team members can pull and push, but not administer this repository + // admin - team members can pull, push and administer this repository + // + // If not specified, the team's permission attribute will be used. + Permission string `json:"permission,omitempty"` +} + +// AddTeamRepo adds a repository to be managed by the specified team. The +// specified repository must be owned by the organization to which the team +// belongs, or a direct fork of a repository owned by the organization. +// +// GitHub API docs: https://developer.github.com/v3/teams/#add-team-repo +func (s *TeamsService) AddTeamRepo(ctx context.Context, team int64, owner string, repo string, opt *TeamAddTeamRepoOptions) (*Response, error) { + u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) + req, err := s.client.NewRequest("PUT", u, opt) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + +// RemoveTeamRepo removes a repository from being managed by the specified +// team. Note that this does not delete the repository, it just removes it +// from the team. +// +// GitHub API docs: https://developer.github.com/v3/teams/#remove-team-repo +func (s *TeamsService) RemoveTeamRepo(ctx context.Context, team int64, owner string, repo string) (*Response, error) { + u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + +// ListUserTeams lists a user's teams +// GitHub API docs: https://developer.github.com/v3/teams/#list-user-teams +func (s *TeamsService) ListUserTeams(ctx context.Context, opt *ListOptions) ([]*Team, *Response, error) { + u := "user/teams" + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + var teams []*Team + resp, err := s.client.Do(ctx, req, &teams) + if err != nil { + return nil, resp, err + } + + return teams, resp, nil +} diff --git a/vendor/github.com/google/go-github/github/teams_discussion_comments.go b/vendor/github.com/google/go-github/github/teams_discussion_comments.go index 26d0e8c506..a0206b9c92 100644 --- a/vendor/github.com/google/go-github/github/teams_discussion_comments.go +++ b/vendor/github.com/google/go-github/github/teams_discussion_comments.go @@ -21,9 +21,10 @@ type DiscussionComment struct { DiscussionURL *string `json:"discussion_url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` NodeID *string `json:"node_id,omitempty"` - Number *int64 `json:"number,omitempty"` + Number *int `json:"number,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` URL *string `json:"url,omitempty"` + Reactions *Reactions `json:"reactions,omitempty"` } func (c DiscussionComment) String() string { diff --git a/vendor/github.com/google/go-github/github/teams_discussions.go b/vendor/github.com/google/go-github/github/teams_discussions.go index fc9b25a58d..f491c9d1d6 100644 --- a/vendor/github.com/google/go-github/github/teams_discussions.go +++ b/vendor/github.com/google/go-github/github/teams_discussions.go @@ -16,19 +16,20 @@ type TeamDiscussion struct { Body *string `json:"body,omitempty"` BodyHTML *string `json:"body_html,omitempty"` BodyVersion *string `json:"body_version,omitempty"` - CommentsCount *int64 `json:"comments_count,omitempty"` + CommentsCount *int `json:"comments_count,omitempty"` CommentsURL *string `json:"comments_url,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` LastEditedAt *Timestamp `json:"last_edited_at,omitempty"` HTMLURL *string `json:"html_url,omitempty"` NodeID *string `json:"node_id,omitempty"` - Number *int64 `json:"number,omitempty"` + Number *int `json:"number,omitempty"` Pinned *bool `json:"pinned,omitempty"` Private *bool `json:"private,omitempty"` TeamURL *string `json:"team_url,omitempty"` Title *string `json:"title,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` URL *string `json:"url,omitempty"` + Reactions *Reactions `json:"reactions,omitempty"` } func (d TeamDiscussion) String() string { diff --git a/vendor/github.com/google/go-github/github/teams_members.go b/vendor/github.com/google/go-github/github/teams_members.go new file mode 100644 index 0000000000..d5cfa0dc7d --- /dev/null +++ b/vendor/github.com/google/go-github/github/teams_members.go @@ -0,0 +1,174 @@ +// Copyright 2018 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// TeamListTeamMembersOptions specifies the optional parameters to the +// TeamsService.ListTeamMembers method. +type TeamListTeamMembersOptions struct { + // Role filters members returned by their role in the team. Possible + // values are "all", "member", "maintainer". Default is "all". + Role string `url:"role,omitempty"` + + ListOptions +} + +// ListTeamMembers lists all of the users who are members of the specified +// team. +// +// GitHub API docs: https://developer.github.com/v3/teams/members/#list-team-members +func (s *TeamsService) ListTeamMembers(ctx context.Context, team int64, opt *TeamListTeamMembersOptions) ([]*User, *Response, error) { + u := fmt.Sprintf("teams/%v/members", team) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + var members []*User + resp, err := s.client.Do(ctx, req, &members) + if err != nil { + return nil, resp, err + } + + return members, resp, nil +} + +// IsTeamMember checks if a user is a member of the specified team. +// +// GitHub API docs: https://developer.github.com/v3/teams/members/#get-team-member +// +// Deprecated: This API has been marked as deprecated in the Github API docs, +// TeamsService.GetTeamMembership method should be used instead. +func (s *TeamsService) IsTeamMember(ctx context.Context, team int64, user string) (bool, *Response, error) { + u := fmt.Sprintf("teams/%v/members/%v", team, user) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return false, nil, err + } + + resp, err := s.client.Do(ctx, req, nil) + member, err := parseBoolResponse(err) + return member, resp, err +} + +// GetTeamMembership returns the membership status for a user in a team. +// +// GitHub API docs: https://developer.github.com/v3/teams/members/#get-team-membership +func (s *TeamsService) GetTeamMembership(ctx context.Context, team int64, user string) (*Membership, *Response, error) { + u := fmt.Sprintf("teams/%v/memberships/%v", team, user) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + req.Header.Set("Accept", mediaTypeNestedTeamsPreview) + + t := new(Membership) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + return t, resp, nil +} + +// TeamAddTeamMembershipOptions specifies the optional +// parameters to the TeamsService.AddTeamMembership method. +type TeamAddTeamMembershipOptions struct { + // Role specifies the role the user should have in the team. Possible + // values are: + // member - a normal member of the team + // maintainer - a team maintainer. Able to add/remove other team + // members, promote other team members to team + // maintainer, and edit the team’s name and description + // + // Default value is "member". + Role string `json:"role,omitempty"` +} + +// AddTeamMembership adds or invites a user to a team. +// +// In order to add a membership between a user and a team, the authenticated +// user must have 'admin' permissions to the team or be an owner of the +// organization that the team is associated with. +// +// If the user is already a part of the team's organization (meaning they're on +// at least one other team in the organization), this endpoint will add the +// user to the team. +// +// If the user is completely unaffiliated with the team's organization (meaning +// they're on none of the organization's teams), this endpoint will send an +// invitation to the user via email. This newly-created membership will be in +// the "pending" state until the user accepts the invitation, at which point +// the membership will transition to the "active" state and the user will be +// added as a member of the team. +// +// GitHub API docs: https://developer.github.com/v3/teams/members/#add-or-update-team-membership +func (s *TeamsService) AddTeamMembership(ctx context.Context, team int64, user string, opt *TeamAddTeamMembershipOptions) (*Membership, *Response, error) { + u := fmt.Sprintf("teams/%v/memberships/%v", team, user) + req, err := s.client.NewRequest("PUT", u, opt) + if err != nil { + return nil, nil, err + } + + t := new(Membership) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + return t, resp, nil +} + +// RemoveTeamMembership removes a user from a team. +// +// GitHub API docs: https://developer.github.com/v3/teams/members/#remove-team-membership +func (s *TeamsService) RemoveTeamMembership(ctx context.Context, team int64, user string) (*Response, error) { + u := fmt.Sprintf("teams/%v/memberships/%v", team, user) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + +// ListPendingTeamInvitations get pending invitaion list in team. +// Warning: The API may change without advance notice during the preview period. +// Preview features are not supported for production use. +// +// GitHub API docs: https://developer.github.com/v3/teams/members/#list-pending-team-invitations +func (s *TeamsService) ListPendingTeamInvitations(ctx context.Context, team int64, opt *ListOptions) ([]*Invitation, *Response, error) { + u := fmt.Sprintf("teams/%v/invitations", team) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var pendingInvitations []*Invitation + resp, err := s.client.Do(ctx, req, &pendingInvitations) + if err != nil { + return nil, resp, err + } + + return pendingInvitations, resp, nil +} diff --git a/vendor/github.com/google/go-github/github/users.go b/vendor/github.com/google/go-github/github/users.go index 8c4efe1d9b..f164d559ed 100644 --- a/vendor/github.com/google/go-github/github/users.go +++ b/vendor/github.com/google/go-github/github/users.go @@ -20,6 +20,7 @@ type UsersService service type User struct { Login *string `json:"login,omitempty"` ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` GravatarID *string `json:"gravatar_id,omitempty"` @@ -134,6 +135,56 @@ func (s *UsersService) Edit(ctx context.Context, user *User) (*User, *Response, return uResp, resp, nil } +// HovercardOptions specifies optional parameters to the UsersService.GetHovercard +// method. +type HovercardOptions struct { + // SubjectType specifies the additional information to be received about the hovercard. + // Possible values are: organization, repository, issue, pull_request. (Required when using subject_id.) + SubjectType string `url:"subject_type"` + + // SubjectID specifies the ID for the SubjectType. (Required when using subject_type.) + SubjectID string `url:"subject_id"` +} + +// Hovercard represents hovercard information about a user. +type Hovercard struct { + Contexts []*UserContext `json:"contexts,omitempty"` +} + +// UserContext represents the contextual information about user. +type UserContext struct { + Message *string `json:"message,omitempty"` + Octicon *string `json:"octicon,omitempty"` +} + +// GetHovercard fetches contextual information about user. It requires authentication +// via Basic Auth or via OAuth with the repo scope. +// +// GitHub API docs: https://developer.github.com/v3/users/#get-contextual-information-about-a-user +func (s *UsersService) GetHovercard(ctx context.Context, user string, opt *HovercardOptions) (*Hovercard, *Response, error) { + u := fmt.Sprintf("users/%v/hovercard", user) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeHovercardPreview) + + hc := new(Hovercard) + resp, err := s.client.Do(ctx, req, hc) + if err != nil { + return nil, resp, err + } + + return hc, resp, nil +} + // UserListOptions specifies optional parameters to the UsersService.ListAll // method. type UserListOptions struct { diff --git a/vendor/vendor.json b/vendor/vendor.json index 935ba41c63..c86faadc3f 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -280,12 +280,12 @@ "versionExact": "v1.1.0" }, { - "checksumSHA1": "DbyiSm4rmoHQeaND4KeMxoZ/ny8=", + "checksumSHA1": "33XMwPqXxqI8wYc1VgiFCURxjnQ=", "path": "github.com/google/go-github/github", - "revision": "2f5e75efdabb0580de63d34eb414bb2905492d2a", - "revisionTime": "2018-08-06T15:27:19Z", - "version": "v16.0.0", - "versionExact": "v16.0.0" + "revision": "902ef4c51cabd60fa6e10422eb06a6ebaef6ad5e", + "revisionTime": "2018-10-08T11:55:33Z", + "version": "v18.2.0", + "versionExact": "v18.2.0" }, { "checksumSHA1": "p3IB18uJRs4dL2K5yx24MrLYE9A=", From 96803823fb5504ffe293504b88c8fa3c98b3fd78 Mon Sep 17 00:00:00 2001 From: Andy Gertjejansen Date: Mon, 8 Oct 2018 18:10:30 -0500 Subject: [PATCH 2/5] Correct error message --- github/resource_github_branch_protection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/resource_github_branch_protection.go b/github/resource_github_branch_protection.go index 3720324765..d92f193ae3 100644 --- a/github/resource_github_branch_protection.go +++ b/github/resource_github_branch_protection.go @@ -220,7 +220,7 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{} } if err := flattenAndSetRequiredPullRequestReviews(d, githubProtection); err != nil { - return fmt.Errorf("Error setting required_pull_reuest_reviews: %v", err) + return fmt.Errorf("Error setting required_pull_request_reviews: %v", err) } if err := flattenAndSetRestrictions(d, githubProtection); err != nil { From 90d250897ec31ecbf9f5a312fd70749ae6c3836b Mon Sep 17 00:00:00 2001 From: Andy Gertjejansen Date: Fri, 26 Oct 2018 10:33:38 -0500 Subject: [PATCH 3/5] Add validation package to allow the use of IntBetween. --- github/resource_github_branch_protection.go | 19 +- .../terraform/helper/validation/validation.go | 268 ++++++++++++++++++ vendor/vendor.json | 6 + 3 files changed, 280 insertions(+), 13 deletions(-) create mode 100644 vendor/github.com/hashicorp/terraform/helper/validation/validation.go diff --git a/github/resource_github_branch_protection.go b/github/resource_github_branch_protection.go index d92f193ae3..3bcdf82cd4 100644 --- a/github/resource_github_branch_protection.go +++ b/github/resource_github_branch_protection.go @@ -9,6 +9,7 @@ import ( "github.com/google/go-github/github" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" ) func resourceGithubBranchProtection() *schema.Resource { @@ -97,19 +98,11 @@ func resourceGithubBranchProtection() *schema.Resource { Optional: true, }, "required_approving_review_count": { - Type: schema.TypeInt, - Optional: true, - Description: "Number of approvals required to merge a pull request", - Default: 1, - // Old version of terraform, could not utilize validation.IntBetween - ValidateFunc: func(i interface{}, k string) (s []string, es []error) { - v := i.(int) - if v < 1 || v > 6 { - es = append(es, errors.New("required_pull_request_reviews.required_approving_review_count must be an integer between 1 - 6")) - } - - return - }, + Type: schema.TypeInt, + Optional: true, + Description: "Number of approvals required to merge a pull request", + Default: 1, + ValidateFunc: validation.IntBetween(1, 6), }, }, }, diff --git a/vendor/github.com/hashicorp/terraform/helper/validation/validation.go b/vendor/github.com/hashicorp/terraform/helper/validation/validation.go new file mode 100644 index 0000000000..e9edcd3338 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/helper/validation/validation.go @@ -0,0 +1,268 @@ +package validation + +import ( + "bytes" + "fmt" + "net" + "reflect" + "regexp" + "strings" + "time" + + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/structure" +) + +// IntBetween returns a SchemaValidateFunc which tests if the provided value +// is of type int and is between min and max (inclusive) +func IntBetween(min, max int) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(int) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be int", k)) + return + } + + if v < min || v > max { + es = append(es, fmt.Errorf("expected %s to be in the range (%d - %d), got %d", k, min, max, v)) + return + } + + return + } +} + +// IntAtLeast returns a SchemaValidateFunc which tests if the provided value +// is of type int and is at least min (inclusive) +func IntAtLeast(min int) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(int) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be int", k)) + return + } + + if v < min { + es = append(es, fmt.Errorf("expected %s to be at least (%d), got %d", k, min, v)) + return + } + + return + } +} + +// IntAtMost returns a SchemaValidateFunc which tests if the provided value +// is of type int and is at most max (inclusive) +func IntAtMost(max int) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(int) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be int", k)) + return + } + + if v > max { + es = append(es, fmt.Errorf("expected %s to be at most (%d), got %d", k, max, v)) + return + } + + return + } +} + +// StringInSlice returns a SchemaValidateFunc which tests if the provided value +// is of type string and matches the value of an element in the valid slice +// will test with in lower case if ignoreCase is true +func StringInSlice(valid []string, ignoreCase bool) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be string", k)) + return + } + + for _, str := range valid { + if v == str || (ignoreCase && strings.ToLower(v) == strings.ToLower(str)) { + return + } + } + + es = append(es, fmt.Errorf("expected %s to be one of %v, got %s", k, valid, v)) + return + } +} + +// StringLenBetween returns a SchemaValidateFunc which tests if the provided value +// is of type string and has length between min and max (inclusive) +func StringLenBetween(min, max int) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be string", k)) + return + } + if len(v) < min || len(v) > max { + es = append(es, fmt.Errorf("expected length of %s to be in the range (%d - %d), got %s", k, min, max, v)) + } + return + } +} + +// StringMatch returns a SchemaValidateFunc which tests if the provided value +// matches a given regexp. Optionally an error message can be provided to +// return something friendlier than "must match some globby regexp". +func StringMatch(r *regexp.Regexp, message string) schema.SchemaValidateFunc { + return func(i interface{}, k string) ([]string, []error) { + v, ok := i.(string) + if !ok { + return nil, []error{fmt.Errorf("expected type of %s to be string", k)} + } + + if ok := r.MatchString(v); !ok { + if message != "" { + return nil, []error{fmt.Errorf("invalid value for %s (%s)", k, message)} + + } + return nil, []error{fmt.Errorf("expected value of %s to match regular expression %q", k, r)} + } + return nil, nil + } +} + +// NoZeroValues is a SchemaValidateFunc which tests if the provided value is +// not a zero value. It's useful in situations where you want to catch +// explicit zero values on things like required fields during validation. +func NoZeroValues(i interface{}, k string) (s []string, es []error) { + if reflect.ValueOf(i).Interface() == reflect.Zero(reflect.TypeOf(i)).Interface() { + switch reflect.TypeOf(i).Kind() { + case reflect.String: + es = append(es, fmt.Errorf("%s must not be empty", k)) + case reflect.Int, reflect.Float64: + es = append(es, fmt.Errorf("%s must not be zero", k)) + default: + // this validator should only ever be applied to TypeString, TypeInt and TypeFloat + panic(fmt.Errorf("can't use NoZeroValues with %T attribute %s", i, k)) + } + } + return +} + +// CIDRNetwork returns a SchemaValidateFunc which tests if the provided value +// is of type string, is in valid CIDR network notation, and has significant bits between min and max (inclusive) +func CIDRNetwork(min, max int) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be string", k)) + return + } + + _, ipnet, err := net.ParseCIDR(v) + if err != nil { + es = append(es, fmt.Errorf( + "expected %s to contain a valid CIDR, got: %s with err: %s", k, v, err)) + return + } + + if ipnet == nil || v != ipnet.String() { + es = append(es, fmt.Errorf( + "expected %s to contain a valid network CIDR, expected %s, got %s", + k, ipnet, v)) + } + + sigbits, _ := ipnet.Mask.Size() + if sigbits < min || sigbits > max { + es = append(es, fmt.Errorf( + "expected %q to contain a network CIDR with between %d and %d significant bits, got: %d", + k, min, max, sigbits)) + } + + return + } +} + +// SingleIP returns a SchemaValidateFunc which tests if the provided value +// is of type string, and in valid single IP notation +func SingleIP() schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be string", k)) + return + } + + ip := net.ParseIP(v) + if ip == nil { + es = append(es, fmt.Errorf( + "expected %s to contain a valid IP, got: %s", k, v)) + } + return + } +} + +// IPRange returns a SchemaValidateFunc which tests if the provided value +// is of type string, and in valid IP range notation +func IPRange() schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be string", k)) + return + } + + ips := strings.Split(v, "-") + if len(ips) != 2 { + es = append(es, fmt.Errorf( + "expected %s to contain a valid IP range, got: %s", k, v)) + return + } + ip1 := net.ParseIP(ips[0]) + ip2 := net.ParseIP(ips[1]) + if ip1 == nil || ip2 == nil || bytes.Compare(ip1, ip2) > 0 { + es = append(es, fmt.Errorf( + "expected %s to contain a valid IP range, got: %s", k, v)) + } + return + } +} + +// ValidateJsonString is a SchemaValidateFunc which tests to make sure the +// supplied string is valid JSON. +func ValidateJsonString(v interface{}, k string) (ws []string, errors []error) { + if _, err := structure.NormalizeJsonString(v); err != nil { + errors = append(errors, fmt.Errorf("%q contains an invalid JSON: %s", k, err)) + } + return +} + +// ValidateListUniqueStrings is a ValidateFunc that ensures a list has no +// duplicate items in it. It's useful for when a list is needed over a set +// because order matters, yet the items still need to be unique. +func ValidateListUniqueStrings(v interface{}, k string) (ws []string, errors []error) { + for n1, v1 := range v.([]interface{}) { + for n2, v2 := range v.([]interface{}) { + if v1.(string) == v2.(string) && n1 != n2 { + errors = append(errors, fmt.Errorf("%q: duplicate entry - %s", k, v1.(string))) + } + } + } + return +} + +// ValidateRegexp returns a SchemaValidateFunc which tests to make sure the +// supplied string is a valid regular expression. +func ValidateRegexp(v interface{}, k string) (ws []string, errors []error) { + if _, err := regexp.Compile(v.(string)); err != nil { + errors = append(errors, fmt.Errorf("%q: %s", k, err)) + } + return +} + +// ValidateRFC3339TimeString is a ValidateFunc that ensures a string parses +// as time.RFC3339 format +func ValidateRFC3339TimeString(v interface{}, k string) (ws []string, errors []error) { + if _, err := time.Parse(time.RFC3339, v.(string)); err != nil { + errors = append(errors, fmt.Errorf("%q: invalid RFC3339 timestamp", k)) + } + return +} diff --git a/vendor/vendor.json b/vendor/vendor.json index c86faadc3f..4e5cbf7e28 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -533,6 +533,12 @@ "version": "v0.11.7", "versionExact": "v0.11.7" }, + { + "checksumSHA1": "nEC56vB6M60BJtGPe+N9rziHqLg=", + "path": "github.com/hashicorp/terraform/helper/validation", + "revision": "c64d8bdf354eb27125416de89ee199a740ff8d35", + "revisionTime": "2018-09-10T19:16:45Z" + }, { "checksumSHA1": "kD1ayilNruf2cES1LDfNZjYRscQ=", "path": "github.com/hashicorp/terraform/httpclient", From 63dcaf45d27069e169c2757e81cd0d18e5e91e3d Mon Sep 17 00:00:00 2001 From: Andy Gertjejansen Date: Fri, 26 Oct 2018 10:40:03 -0500 Subject: [PATCH 4/5] Add missing terrafrom structure helper module --- .../terraform/helper/structure/expand_json.go | 11 +++++++++ .../helper/structure/flatten_json.go | 16 +++++++++++++ .../helper/structure/normalize_json.go | 24 +++++++++++++++++++ .../helper/structure/suppress_json_diff.go | 21 ++++++++++++++++ vendor/vendor.json | 6 +++++ 5 files changed, 78 insertions(+) create mode 100644 vendor/github.com/hashicorp/terraform/helper/structure/expand_json.go create mode 100644 vendor/github.com/hashicorp/terraform/helper/structure/flatten_json.go create mode 100644 vendor/github.com/hashicorp/terraform/helper/structure/normalize_json.go create mode 100644 vendor/github.com/hashicorp/terraform/helper/structure/suppress_json_diff.go diff --git a/vendor/github.com/hashicorp/terraform/helper/structure/expand_json.go b/vendor/github.com/hashicorp/terraform/helper/structure/expand_json.go new file mode 100644 index 0000000000..b3eb90fdff --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/helper/structure/expand_json.go @@ -0,0 +1,11 @@ +package structure + +import "encoding/json" + +func ExpandJsonFromString(jsonString string) (map[string]interface{}, error) { + var result map[string]interface{} + + err := json.Unmarshal([]byte(jsonString), &result) + + return result, err +} diff --git a/vendor/github.com/hashicorp/terraform/helper/structure/flatten_json.go b/vendor/github.com/hashicorp/terraform/helper/structure/flatten_json.go new file mode 100644 index 0000000000..578ad2eade --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/helper/structure/flatten_json.go @@ -0,0 +1,16 @@ +package structure + +import "encoding/json" + +func FlattenJsonToString(input map[string]interface{}) (string, error) { + if len(input) == 0 { + return "", nil + } + + result, err := json.Marshal(input) + if err != nil { + return "", err + } + + return string(result), nil +} diff --git a/vendor/github.com/hashicorp/terraform/helper/structure/normalize_json.go b/vendor/github.com/hashicorp/terraform/helper/structure/normalize_json.go new file mode 100644 index 0000000000..3256b476dd --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/helper/structure/normalize_json.go @@ -0,0 +1,24 @@ +package structure + +import "encoding/json" + +// Takes a value containing JSON string and passes it through +// the JSON parser to normalize it, returns either a parsing +// error or normalized JSON string. +func NormalizeJsonString(jsonString interface{}) (string, error) { + var j interface{} + + if jsonString == nil || jsonString.(string) == "" { + return "", nil + } + + s := jsonString.(string) + + err := json.Unmarshal([]byte(s), &j) + if err != nil { + return s, err + } + + bytes, _ := json.Marshal(j) + return string(bytes[:]), nil +} diff --git a/vendor/github.com/hashicorp/terraform/helper/structure/suppress_json_diff.go b/vendor/github.com/hashicorp/terraform/helper/structure/suppress_json_diff.go new file mode 100644 index 0000000000..46f794a71b --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/helper/structure/suppress_json_diff.go @@ -0,0 +1,21 @@ +package structure + +import ( + "reflect" + + "github.com/hashicorp/terraform/helper/schema" +) + +func SuppressJsonDiff(k, old, new string, d *schema.ResourceData) bool { + oldMap, err := ExpandJsonFromString(old) + if err != nil { + return false + } + + newMap, err := ExpandJsonFromString(new) + if err != nil { + return false + } + + return reflect.DeepEqual(oldMap, newMap) +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 4e5cbf7e28..10ec7b0dfd 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -533,6 +533,12 @@ "version": "v0.11.7", "versionExact": "v0.11.7" }, + { + "checksumSHA1": "Fzbv+N7hFXOtrR6E7ZcHT3jEE9s=", + "path": "github.com/hashicorp/terraform/helper/structure", + "revision": "c64d8bdf354eb27125416de89ee199a740ff8d35", + "revisionTime": "2018-09-10T19:16:45Z" + }, { "checksumSHA1": "nEC56vB6M60BJtGPe+N9rziHqLg=", "path": "github.com/hashicorp/terraform/helper/validation", From 84bae39cac955cb02b14bf488232ef53039ea3a2 Mon Sep 17 00:00:00 2001 From: Andy Gertjejansen Date: Fri, 26 Oct 2018 10:46:48 -0500 Subject: [PATCH 5/5] Fix version of two new packages to v0.11.7 Still new to govendor, they now match other terraform packages. --- vendor/vendor.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vendor/vendor.json b/vendor/vendor.json index 10ec7b0dfd..9f9db6addd 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -536,14 +536,18 @@ { "checksumSHA1": "Fzbv+N7hFXOtrR6E7ZcHT3jEE9s=", "path": "github.com/hashicorp/terraform/helper/structure", - "revision": "c64d8bdf354eb27125416de89ee199a740ff8d35", - "revisionTime": "2018-09-10T19:16:45Z" + "revision": "41e50bd32a8825a84535e353c3674af8ce799161", + "revisionTime": "2018-04-10T16:50:42Z", + "version": "v0.11.7", + "versionExact": "v0.11.7" }, { "checksumSHA1": "nEC56vB6M60BJtGPe+N9rziHqLg=", "path": "github.com/hashicorp/terraform/helper/validation", - "revision": "c64d8bdf354eb27125416de89ee199a740ff8d35", - "revisionTime": "2018-09-10T19:16:45Z" + "revision": "41e50bd32a8825a84535e353c3674af8ce799161", + "revisionTime": "2018-04-10T16:50:42Z", + "version": "v0.11.7", + "versionExact": "v0.11.7" }, { "checksumSHA1": "kD1ayilNruf2cES1LDfNZjYRscQ=",