Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade provider to go-github v31.0.0 to support new API methods #424

Merged
merged 5 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/url"
"path"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
5 changes: 3 additions & 2 deletions github/data_source_github_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strconv"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down Expand Up @@ -53,14 +53,15 @@ func dataSourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing GitHub Team: %s", slug)

client := meta.(*Organization).v3client
orgId := meta.(*Organization).id
ctx := context.Background()

team, err := getGithubTeamBySlug(ctx, client, meta.(*Organization).name, slug)
if err != nil {
return err
}

member, _, err := client.Teams.ListTeamMembers(ctx, team.GetID(), nil)
member, _, err := client.Teams.ListTeamMembersByID(ctx, orgId, team.GetID(), nil)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_actions_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/base64"
"fmt"
"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"golang.org/x/crypto/nacl/box"
"log"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_issue_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_membership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_organization_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strconv"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_organization_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_organization_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strconv"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_organization_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_project_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_project_column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"regexp"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
7 changes: 5 additions & 2 deletions github/resource_github_repository_collaborator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func resourceGithubRepositoryCollaboratorCreate(d *schema.ResourceData, meta int

log.Printf("[DEBUG] Creating repository collaborator: %s (%s/%s)",
username, orgName, repoName)
_, _, err = client.Repositories.AddCollaborator(ctx,
_, resp, err := client.Repositories.AddCollaborator(ctx,
orgName,
repoName,
username,
Expand All @@ -74,6 +74,9 @@ func resourceGithubRepositoryCollaboratorCreate(d *schema.ResourceData, meta int
if err != nil {
return err
}
if resp.StatusCode == http.StatusNoContent {
return fmt.Errorf("User %s is already a collaborator", username)
}

d.SetId(buildTwoPartID(repoName, username))

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_collaborator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_deploy_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"fmt"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_repository_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strconv"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
15 changes: 9 additions & 6 deletions github/resource_github_team_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strconv"

"github.com/google/go-github/v29/github"
"github.com/google/go-github/v31/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down Expand Up @@ -50,6 +50,7 @@ func resourceGithubTeamMembership() *schema.Resource {

func resourceGithubTeamMembershipCreateOrUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Organization).v3client
orgId := meta.(*Organization).id

teamIdString := d.Get("team_id").(string)
teamId, err := strconv.ParseInt(teamIdString, 10, 64)
Expand All @@ -62,7 +63,8 @@ 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.Teams.AddTeamMembership(ctx,
_, _, err = client.Teams.AddTeamMembershipByID(ctx,
orgId,
teamId,
username,
&github.TeamAddTeamMembershipOptions{
Expand All @@ -80,6 +82,7 @@ func resourceGithubTeamMembershipCreateOrUpdate(d *schema.ResourceData, meta int

func resourceGithubTeamMembershipRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Organization).v3client
orgId := meta.(*Organization).id
teamIdString, username, err := parseTwoPartID(d.Id(), "team_id", "username")
if err != nil {
return err
Expand All @@ -102,8 +105,8 @@ func resourceGithubTeamMembershipRead(d *schema.ResourceData, meta interface{})
}

log.Printf("[DEBUG] Reading team membership: %s/%s", teamIdString, username)
membership, resp, err := client.Teams.GetTeamMembership(ctx,
teamId, username)
membership, resp, err := client.Teams.GetTeamMembershipByID(ctx,
orgId, teamId, username)
if err != nil {
if ghErr, ok := err.(*github.ErrorResponse); ok {
if ghErr.Response.StatusCode == http.StatusNotModified {
Expand All @@ -127,7 +130,7 @@ func resourceGithubTeamMembershipRead(d *schema.ResourceData, meta interface{})

func resourceGithubTeamMembershipDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Organization).v3client

orgId := meta.(*Organization).id
teamIdString := d.Get("team_id").(string)
teamId, err := strconv.ParseInt(teamIdString, 10, 64)
if err != nil {
Expand All @@ -137,7 +140,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.Teams.RemoveTeamMembership(ctx, teamId, username)
_, err = client.Teams.RemoveTeamMembershipByID(ctx, orgId, teamId, username)

return err
}
Loading