Skip to content

Commit

Permalink
Bump Expected Minimum Go Version to 1.17 (#934)
Browse files Browse the repository at this point in the history
Reference: #933

Previously from `tenv` linter:

```
helper/schema/schema_test.go:29:2: os.Setenv() can be replaced by `t.Setenv()` in TestEnvDefaultFunc (tenv)
        if err := os.Setenv(key, "foo"); err != nil {
        ^
helper/schema/schema_test.go:67:2: os.Setenv() can be replaced by `t.Setenv()` in TestMultiEnvDefaultFunc (tenv)
        if err := os.Setenv(keys[0], "foo"); err != nil {
        ^
helper/schema/schema_test.go:85:2: os.Setenv() can be replaced by `t.Setenv()` in TestMultiEnvDefaultFunc (tenv)
        if err := os.Setenv(keys[1], "foo"); err != nil {
        ^
helper/schema/schema_test.go:8479:2: os.Setenv() can be replaced by `t.Setenv()` in TestPanicOnErrorDefaultsFalse (tenv)
        os.Setenv("TF_ACC", "")
        ^
helper/schema/schema_test.go:8484:2: os.Setenv() can be replaced by `t.Setenv()` in TestPanicOnErrorDefaultsFalse (tenv)
        os.Setenv("TF_ACC", oldEnv)
        ^
helper/schema/schema_test.go:8490:2: os.Setenv() can be replaced by `t.Setenv()` in TestPanicOnErrorTF_ACCSet (tenv)
        os.Setenv("TF_ACC", "1")
        ^
helper/schema/schema_test.go:8495:2: os.Setenv() can be replaced by `t.Setenv()` in TestPanicOnErrorTF_ACCSet (tenv)
        os.Setenv("TF_ACC", oldEnv)
        ^
```
  • Loading branch information
bflad committed Apr 12, 2022
1 parent 5f0086d commit 7c4737b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .changelog/934.txt
@@ -0,0 +1,3 @@
```release-note:note
This Go module has been updated to Go 1.17 per the [Go support policy](https://golang.org/doc/devel/release.html#policy). Any consumers building on earlier Go versions may experience errors.
```
2 changes: 1 addition & 1 deletion .github/workflows/ci-go.yml
Expand Up @@ -56,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.17', '1.16' ]
go-version: [ '1.18', '1.17' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
Expand Down
2 changes: 1 addition & 1 deletion .go-version
@@ -1 +1 @@
1.16.7
1.17.8
2 changes: 1 addition & 1 deletion .golangci.yml
Expand Up @@ -21,7 +21,7 @@ linters:
# - paralleltest # Reference: https://github.com/kunwardeep/paralleltest/issues/14
- predeclared
- staticcheck
# - tenv # TODO: Enable when upgrading Go 1.16 to 1.17
- tenv
- unconvert
- unparam
- varcheck
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -14,9 +14,9 @@ When running provider tests, Terraform 0.12.26 or later is needed for version 2.

## Go Compatibility

The Terraform Plugin SDK is built in Go, and uses the [support policy](https://golang.org/doc/devel/release.html#policy) of Go as its support policy. The two latest major releases of Go are supported by the SDK.
This project follows the [support policy](https://golang.org/doc/devel/release.html#policy) of Go as its support policy. The two latest major releases of Go are supported by the project.

Currently, that means Go **1.16** or later must be used when building a provider with the SDK.
Currently, that means Go **1.17** or later must be used when including this project as a dependency.

## Getting Started

Expand Down
35 changes: 29 additions & 6 deletions go.mod
@@ -1,9 +1,8 @@
module github.com/hashicorp/terraform-plugin-sdk/v2

go 1.16
go 1.17

require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.1.0
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0
github.com/davecgh/go-spew v1.1.1
Expand All @@ -21,17 +20,41 @@ require (
github.com/hashicorp/terraform-json v0.13.0
github.com/hashicorp/terraform-plugin-go v0.8.0
github.com/hashicorp/terraform-plugin-log v0.3.0
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mitchellh/copystructure v1.2.0
github.com/mitchellh/go-testing-interface v1.14.1
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3
github.com/mitchellh/reflectwalk v1.0.2
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.10.0
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed
)

require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
22 changes: 5 additions & 17 deletions helper/schema/schema_test.go
Expand Up @@ -26,9 +26,7 @@ func TestEnvDefaultFunc(t *testing.T) {
defer os.Unsetenv(key)

f := EnvDefaultFunc(key, "42")
if err := os.Setenv(key, "foo"); err != nil {
t.Fatalf("err: %s", err)
}
t.Setenv(key, "foo")

actual, err := f()
if err != nil {
Expand Down Expand Up @@ -64,9 +62,7 @@ func TestMultiEnvDefaultFunc(t *testing.T) {

// Test that the first key is returned first
f := MultiEnvDefaultFunc(keys, "42")
if err := os.Setenv(keys[0], "foo"); err != nil {
t.Fatalf("err: %s", err)
}
t.Setenv(keys[0], "foo")

actual, err := f()
if err != nil {
Expand All @@ -82,9 +78,7 @@ func TestMultiEnvDefaultFunc(t *testing.T) {

// Test that the second key is returned if the first one is empty
f = MultiEnvDefaultFunc(keys, "42")
if err := os.Setenv(keys[1], "foo"); err != nil {
t.Fatalf("err: %s", err)
}
t.Setenv(keys[1], "foo")

actual, err = f()
if err != nil {
Expand Down Expand Up @@ -8474,25 +8468,19 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) {
}

func TestPanicOnErrorDefaultsFalse(t *testing.T) {
oldEnv := os.Getenv("TF_ACC")
t.Setenv("TF_ACC", "")

os.Setenv("TF_ACC", "")
if schemaMap(nil).panicOnError() {
t.Fatalf("panicOnError should be false when TF_ACC is empty")
}

os.Setenv("TF_ACC", oldEnv)
}

func TestPanicOnErrorTF_ACCSet(t *testing.T) {
oldEnv := os.Getenv("TF_ACC")
t.Setenv("TF_ACC", "1")

os.Setenv("TF_ACC", "1")
if !schemaMap(nil).panicOnError() {
t.Fatalf("panicOnError should be true when TF_ACC is not empty")
}

os.Setenv("TF_ACC", oldEnv)
}

func TestValidateRequiredWithAttributes(t *testing.T) {
Expand Down

0 comments on commit 7c4737b

Please sign in to comment.