Skip to content

Commit 7c4737b

Browse files
authored
Bump Expected Minimum Go Version to 1.17 (#934)
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) ^ ```
1 parent 5f0086d commit 7c4737b

File tree

7 files changed

+42
-28
lines changed

7 files changed

+42
-28
lines changed

.changelog/934.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:note
2+
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.
3+
```

.github/workflows/ci-go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
runs-on: ubuntu-latest
5757
strategy:
5858
matrix:
59-
go-version: [ '1.17', '1.16' ]
59+
go-version: [ '1.18', '1.17' ]
6060
steps:
6161
- uses: actions/checkout@v3
6262
- uses: actions/setup-go@v3

.go-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.16.7
1+
1.17.8

.golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ linters:
2121
# - paralleltest # Reference: https://github.com/kunwardeep/paralleltest/issues/14
2222
- predeclared
2323
- staticcheck
24-
# - tenv # TODO: Enable when upgrading Go 1.16 to 1.17
24+
- tenv
2525
- unconvert
2626
- unparam
2727
- varcheck

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ When running provider tests, Terraform 0.12.26 or later is needed for version 2.
1414

1515
## Go Compatibility
1616

17-
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.
17+
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.
1818

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

2121
## Getting Started
2222

go.mod

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module github.com/hashicorp/terraform-plugin-sdk/v2
22

3-
go 1.16
3+
go 1.17
44

55
require (
6-
github.com/agext/levenshtein v1.2.2 // indirect
76
github.com/apparentlymart/go-cidr v1.1.0
87
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0
98
github.com/davecgh/go-spew v1.1.1
@@ -21,17 +20,41 @@ require (
2120
github.com/hashicorp/terraform-json v0.13.0
2221
github.com/hashicorp/terraform-plugin-go v0.8.0
2322
github.com/hashicorp/terraform-plugin-log v0.3.0
24-
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
25-
github.com/kylelemons/godebug v1.1.0 // indirect
2623
github.com/mitchellh/copystructure v1.2.0
2724
github.com/mitchellh/go-testing-interface v1.14.1
28-
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
2925
github.com/mitchellh/mapstructure v1.4.3
3026
github.com/mitchellh/reflectwalk v1.0.2
31-
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
3227
github.com/zclconf/go-cty v1.10.0
3328
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
3429
golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed
30+
)
31+
32+
require (
33+
github.com/agext/levenshtein v1.2.2 // indirect
34+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
35+
github.com/fatih/color v1.7.0 // indirect
36+
github.com/golang/protobuf v1.5.2 // indirect
37+
github.com/hashicorp/errwrap v1.0.0 // indirect
38+
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
39+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
40+
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 // indirect
41+
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
42+
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
43+
github.com/kylelemons/godebug v1.1.0 // indirect
44+
github.com/mattn/go-colorable v0.1.4 // indirect
45+
github.com/mattn/go-isatty v0.0.10 // indirect
46+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
47+
github.com/oklog/run v1.0.0 // indirect
48+
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
49+
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
50+
github.com/vmihailenco/tagparser v0.1.1 // indirect
51+
golang.org/x/mod v0.3.0 // indirect
52+
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
53+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
54+
golang.org/x/text v0.3.5 // indirect
55+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
3556
google.golang.org/appengine v1.6.6 // indirect
3657
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
58+
google.golang.org/grpc v1.45.0 // indirect
59+
google.golang.org/protobuf v1.27.1 // indirect
3760
)

helper/schema/schema_test.go

+5-17
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ func TestEnvDefaultFunc(t *testing.T) {
2626
defer os.Unsetenv(key)
2727

2828
f := EnvDefaultFunc(key, "42")
29-
if err := os.Setenv(key, "foo"); err != nil {
30-
t.Fatalf("err: %s", err)
31-
}
29+
t.Setenv(key, "foo")
3230

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

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

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

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

8983
actual, err = f()
9084
if err != nil {
@@ -8474,25 +8468,19 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) {
84748468
}
84758469

84768470
func TestPanicOnErrorDefaultsFalse(t *testing.T) {
8477-
oldEnv := os.Getenv("TF_ACC")
8471+
t.Setenv("TF_ACC", "")
84788472

8479-
os.Setenv("TF_ACC", "")
84808473
if schemaMap(nil).panicOnError() {
84818474
t.Fatalf("panicOnError should be false when TF_ACC is empty")
84828475
}
8483-
8484-
os.Setenv("TF_ACC", oldEnv)
84858476
}
84868477

84878478
func TestPanicOnErrorTF_ACCSet(t *testing.T) {
8488-
oldEnv := os.Getenv("TF_ACC")
8479+
t.Setenv("TF_ACC", "1")
84898480

8490-
os.Setenv("TF_ACC", "1")
84918481
if !schemaMap(nil).panicOnError() {
84928482
t.Fatalf("panicOnError should be true when TF_ACC is not empty")
84938483
}
8494-
8495-
os.Setenv("TF_ACC", oldEnv)
84968484
}
84978485

84988486
func TestValidateRequiredWithAttributes(t *testing.T) {

0 commit comments

Comments
 (0)