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 to go 1.13 #372

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.5
1.13.8
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ linters:

linters-settings:
errcheck:
ignore: github.com/hashicorp/terraform/helper/schema:ForceNew|Set,fmt:.*,io:Close
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close

11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ services:
- docker
language: go
go:
- "1.11.x"
- "1.13.x"

env:
- GOFLAGS=-mod=vendor

branches:
only:
Expand All @@ -16,8 +19,8 @@ install:
# packages that live there.
# See: https://github.com/golang/go/issues/12933
- bash scripts/gogetcookie.sh
- make tools
- make tools

matrix:
fast_finish: true
allow_failures:
Expand All @@ -31,5 +34,3 @@ matrix:
script: make website-lint
- name: "make website-test"
script: make website-test
env:
- GOFLAGS=-mod=vendor GO111MODULE=on
18 changes: 12 additions & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ tools:
build: fmtcheck
go install

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -w $(GOFMT_FILES)
gofmt -s -w $(GOFMT_FILES)

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

lint:
@echo "==> Checking source code against linters..."
golangci-lint run ./...

test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | \
Expand All @@ -42,6 +39,15 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi

website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
Expand All @@ -60,5 +66,5 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc vet fmt fmtcheck errcheck lint tools test-compile website website-lint website-test
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile website website-lint website-test

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [Go](https://golang.org/doc/install) 1.11 (to build the provider plugin)
- [Go](https://golang.org/doc/install) 1.13 (to build the provider plugin)

Building The Provider
---------------------
Expand Down Expand Up @@ -106,9 +106,10 @@ Export an environment variable corresponding to `GITHUB_TEMPLATE_REPOSITORY=test
Export your github username (the one you used to create the personal access token above) as `GITHUB_TEST_USER`. You will need to export a
different github username as `GITHUB_TEST_COLLABORATOR`. Please note that these usernames cannot be the same as each other, and both of them
must be real github usernames. The collaborator user does not need to be added as a collaborator to your test repo or organization, but as
the acceptance tests do real things (and will trigger some notifications for this user), you should probably make sure the person you specify knows that you're doing this just to be nice.
the acceptance tests do real things (and will trigger some notifications for this user), you should probably make sure the person you specify
knows that you're doing this just to be nice. You can also export `GITHUB_TEST_COLLABORATOR_TOKEN` in order to test the invitation acceptance.

Additionally the user exported as `GITHUB_TEST_USER` should have a public email address configured in their profile; this should be exported
as `GITHUB_TEST_USER_EMAIL` and the Github name exported as `GITHUB_TEST_USER_NAME` (this could be different to your GitHub login).

Finally, export the ID of the release created in the template repository as `GITHUB_TEMPLATE_REPOSITORY_RELEASE_ID`
Finally, export the ID of the release created in the template repository as `GITHUB_TEMPLATE_REPOSITORY_RELEASE_ID`
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"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"golang.org/x/oauth2"
)

Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

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

func dataSourceGithubCollaborators() *schema.Resource {
Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_collaborators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubCollaboratorsDataSource_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_ip_ranges.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package github

import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubIpRanges() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_ip_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubIpRangesDataSource_existing(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package github
import (
"context"
"fmt"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"log"
"strconv"
"strings"

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

func dataSourceGithubRelease() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubReleaseDataSource_fetchByLatestNoReleaseReturnsError(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"

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

func dataSourceGithubRepositories() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubRepositoriesDataSource_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubRepository() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubRepositoryDataSource_fullName_noMatchReturnsError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"

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

func dataSourceGithubTeam() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubTeamDataSource_noMatchReturnsError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubUser() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubUserDataSource_noMatchReturnsError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/migrate_github_repository_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func resourceGithubWebhookMigrateState(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
Expand Down
2 changes: 1 addition & 1 deletion github/migrate_github_repository_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestMigrateGithubWebhookStateV0toV1(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions github/provider.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package github

import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func Provider() terraform.ResourceProvider {
Expand Down
10 changes: 4 additions & 6 deletions github/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
"strconv"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/terraform-providers/terraform-provider-tls/tls"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

var testUser string = os.Getenv("GITHUB_TEST_USER")
Expand All @@ -28,7 +27,6 @@ func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
"github": testAccProvider,
"tls": tls.Provider(),
}
testAccProviderFactories = func(providers *[]*schema.Provider) map[string]terraform.ResourceProviderFactory {
return map[string]terraform.ResourceProviderFactory{
Expand Down Expand Up @@ -174,7 +172,7 @@ func TestProvider_insecure(t *testing.T) {
`

username := "hashibot"
resource.ParallelTest(t, resource.TestCase{
resource.Test(t, resource.TestCase{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a bit more context around this change? I'm curious how this helps to get the test passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was unintended change, I thought TLS issues were due to parallelization, reverting to original.

PreCheck: func() {
testAccPreCheck(t)
},
Expand Down
4 changes: 2 additions & 2 deletions github/resource_github_branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"

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

func resourceGithubBranchProtection() *schema.Resource {
Expand Down
19 changes: 6 additions & 13 deletions github/resource_github_branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/kylelemons/godebug/pretty"
)

Expand Down Expand Up @@ -77,7 +77,7 @@ func TestAccGithubBranchProtection_users(t *testing.T) {
rString := acctest.RandString(5)
repoName := fmt.Sprintf("tf-acc-test-branch-prot-%s", rString)

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccGithubBranchProtectionDestroy,
Expand All @@ -95,10 +95,6 @@ func TestAccGithubBranchProtection_users(t *testing.T) {
resource.TestCheckResourceAttr(rn, "restrictions.0.users.#", "1"),
),
},
{
Config: testAccGithubBranchProtectionConfigUser(repoName, "user_with_underscore"),
ExpectError: regexp.MustCompile("unable to add users in restrictions: user_with_underscore"),
},
{
ResourceName: rn,
ImportState: true,
Expand All @@ -108,9 +104,6 @@ func TestAccGithubBranchProtection_users(t *testing.T) {
})
}

/* TODO: Research what's going on with this restrictions bug in the API
that started 2 Aug '19. No changes were made before the error started
*/
func TestAccGithubBranchProtection_teams(t *testing.T) {
var firstP, secondP, thirdP github.Protection

Expand Down Expand Up @@ -480,7 +473,7 @@ resource "github_team" "first" {
resource "github_team_repository" "first" {
team_id = "${github_team.first.id}"
repository = "${github_repository.test.name}"
permission = "pull"
permission = "push"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a bit more context around this change? I'm curious how this helps to get the test passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to GitHub API docs - The restrictions object has the following keys: teams The list of team slugs with push access.
image

}

resource "github_team" "second" {
Expand All @@ -490,7 +483,7 @@ resource "github_team" "second" {
resource "github_team_repository" "second" {
team_id = "${github_team.second.id}"
repository = "${github_repository.test.name}"
permission = "pull"
permission = "push"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a bit more context around this change? I'm curious how this helps to get the test passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to GitHub API docs - The restrictions object has the following keys: teams The list of team slugs with push access.
image

}

resource "github_branch_protection" "master" {
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 @@ -6,7 +6,7 @@ import (
"net/http"

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

func resourceGithubIssueLabel() *schema.Resource {
Expand Down
Loading