Skip to content

Commit 9a25472

Browse files
committed
Merge v2.17.0
2 parents a9dc436 + ab57299 commit 9a25472

23 files changed

+2136
-282
lines changed

.changelog/972.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```release-note:note
2+
helper/resource: Provider references or external installation can now be handled at either the `TestCase` or `TestStep` level. Using the `TestStep` handling, advanced use cases are now enabled such as state upgrade acceptance testing.
3+
```
4+
5+
```release-note:enhancement
6+
helper/resource: Added `TestStep` type `ExternalProviders`, `ProtoV5ProviderFactories`, `ProtoV6ProviderFactories`, and `ProviderFactories` fields
7+
```
8+
9+
```release-note:bug
10+
helper/resource: Removed extraneous `terraform state show` command when not using the `TestStep` type `Taint` field
11+
```

.github/workflows/ci-go.yml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,30 @@ jobs:
2525
with:
2626
go-version: ${{ steps.go-version.outputs.version }}
2727
- run: go mod download
28-
- uses: golangci/golangci-lint-action@v3.1.0
28+
- uses: golangci/golangci-lint-action@v3.2.0
29+
terraform-provider-corner:
30+
defaults:
31+
run:
32+
working-directory: terraform-provider-corner
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v3
37+
with:
38+
path: terraform-provider-corner
39+
repository: hashicorp/terraform-provider-corner
40+
- id: go-version
41+
# Reference: https://github.com/actions/setup-go/issues/23
42+
run: echo "::set-output name=version::$(cat ./.go-version)"
43+
working-directory: .
44+
- uses: actions/setup-go@v3
2945
with:
30-
skip-go-installation: true
31-
# FORK: we've disabled the corner test because it uses features (UseJSONNumber) that we do not support in our fork.
32-
# terraform-provider-corner:
33-
# defaults:
34-
# run:
35-
# working-directory: terraform-provider-corner
36-
# runs-on: ubuntu-latest
37-
# steps:
38-
# - uses: actions/checkout@v3
39-
# - uses: actions/checkout@v3
40-
# with:
41-
# path: terraform-provider-corner
42-
# repository: hashicorp/terraform-provider-corner
43-
# - id: go-version
44-
# # Reference: https://github.com/actions/setup-go/issues/23
45-
# run: echo "::set-output name=version::$(cat ./.go-version)"
46-
# working-directory: .
47-
# - uses: actions/setup-go@v3
48-
# with:
49-
# go-version: ${{ steps.go-version.outputs.version }}
50-
# - run: go mod edit -replace=github.com/hashicorp/terraform-plugin-sdk/v2=../
51-
# - run: go mod tidy
52-
# - run: go test -v ./...
53-
# env:
54-
# TF_ACC: '1'
46+
go-version: ${{ steps.go-version.outputs.version }}
47+
- run: go mod edit -replace=github.com/hashicorp/terraform-plugin-sdk/v2=../
48+
- run: go mod tidy
49+
- run: go test -v ./...
50+
env:
51+
TF_ACC: '1'
5552
test:
5653
name: test (Go v${{ matrix.go-version }})
5754
runs-on: ubuntu-latest

.github/workflows/ci-goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
- uses: actions/setup-go@v3
2121
with:
2222
go-version: ${{ steps.go-version.outputs.version }}
23-
- uses: goreleaser/goreleaser-action@v2
23+
- uses: goreleaser/goreleaser-action@v3
2424
with:
2525
args: check

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Generate Release Notes
2929
# Fetch CHANGELOG.md contents up to Git tag prior to this release, skipping top two lines
3030
run: sed -n -e "1{/# /d;}" -e "2{/^$/d;}" -e "/# $(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)/q;p" CHANGELOG.md > /tmp/release-notes.txt
31-
- uses: goreleaser/goreleaser-action@v2
31+
- uses: goreleaser/goreleaser-action@v3
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434
with:

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# 2.17.0 (May 31, 2022)
2+
3+
NOTES:
4+
5+
* helper/resource: Provider references or external installation can now be handled at either the `TestCase` or `TestStep` level. Using the `TestStep` handling, advanced use cases are now enabled such as state upgrade acceptance testing. ([#972](https://github.com/hashicorp/terraform-plugin-sdk/issues/972))
6+
7+
ENHANCEMENTS:
8+
9+
* helper/resource: Added `TestStep` type `ExternalProviders`, `ProtoV5ProviderFactories`, `ProtoV6ProviderFactories`, and `ProviderFactories` fields ([#972](https://github.com/hashicorp/terraform-plugin-sdk/issues/972))
10+
11+
BUG FIXES:
12+
13+
* helper/resource: Removed extraneous `terraform state show` command when not using the `TestStep` type `Taint` field ([#972](https://github.com/hashicorp/terraform-plugin-sdk/issues/972))
14+
115
# 2.16.0 (May 10, 2022)
216

317
ENHANCEMENTS:

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ require (
1010
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1111
github.com/hashicorp/go-hclog v1.2.0
1212
github.com/hashicorp/go-multierror v1.1.1
13-
github.com/hashicorp/go-plugin v1.4.3
13+
github.com/hashicorp/go-plugin v1.4.4
1414
github.com/hashicorp/go-uuid v1.0.3
15-
github.com/hashicorp/go-version v1.4.0
15+
github.com/hashicorp/go-version v1.5.0
1616
github.com/hashicorp/hc-install v0.3.2
1717
github.com/hashicorp/hcl/v2 v2.12.0
1818
github.com/hashicorp/logutils v1.0.0
1919
github.com/hashicorp/terraform-exec v0.16.1
20-
github.com/hashicorp/terraform-json v0.13.0
21-
github.com/hashicorp/terraform-plugin-go v0.9.0
20+
github.com/hashicorp/terraform-json v0.14.0
21+
github.com/hashicorp/terraform-plugin-go v0.9.1
2222
github.com/hashicorp/terraform-plugin-log v0.4.0
2323
github.com/mitchellh/copystructure v1.2.0
2424
github.com/mitchellh/go-testing-interface v1.14.1
@@ -55,6 +55,6 @@ require (
5555
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
5656
google.golang.org/appengine v1.6.6 // indirect
5757
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
58-
google.golang.org/grpc v1.45.0 // indirect
58+
google.golang.org/grpc v1.46.0 // indirect
5959
google.golang.org/protobuf v1.28.0 // indirect
6060
)

go.sum

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
3030
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
3131
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
3232
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
33-
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
3433
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
34+
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
3535
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
3636
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
3737
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -43,7 +43,7 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
4343
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
4444
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
4545
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
46-
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
46+
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
4747
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
4848
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
4949
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
@@ -106,15 +106,16 @@ github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXc
106106
github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
107107
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
108108
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
109-
github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM=
110-
github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ=
109+
github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ=
110+
github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
111111
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
112112
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
113113
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
114114
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
115115
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
116-
github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4=
117116
github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
117+
github.com/hashicorp/go-version v1.5.0 h1:O293SZ2Eg+AAYijkVK3jR786Am1bhDEh2GHT0tIVE5E=
118+
github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
118119
github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak=
119120
github.com/hashicorp/hc-install v0.3.2 h1:oiQdJZvXmkNcRcEOOfM5n+VTsvNjWQeOjfAoO6dKSH8=
120121
github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs=
@@ -124,11 +125,11 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
124125
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
125126
github.com/hashicorp/terraform-exec v0.16.1 h1:NAwZFJW2L2SaCBVZoVaH8LPImLOGbPLkSHy0IYbs2uE=
126127
github.com/hashicorp/terraform-exec v0.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M=
127-
github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY=
128128
github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk=
129-
github.com/hashicorp/terraform-plugin-go v0.9.0 h1:FvLY/3z4SNVatPZdoFcyrlNbCar+WyyOTv5X4Tp+WZc=
130-
github.com/hashicorp/terraform-plugin-go v0.9.0/go.mod h1:EawBkgjBWNf7jiKnVoyDyF39OSV+u6KUX+Y73EPj3oM=
131-
github.com/hashicorp/terraform-plugin-log v0.3.0/go.mod h1:EjueSP/HjlyFAsDqt+okpCPjkT4NDynAe32AeDC4vps=
129+
github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s=
130+
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
131+
github.com/hashicorp/terraform-plugin-go v0.9.1 h1:vXdHaQ6aqL+OF076nMSBV+JKPdmXlzG5mzVDD04WyPs=
132+
github.com/hashicorp/terraform-plugin-go v0.9.1/go.mod h1:ItjVSlQs70otlzcCwlPcU8FRXLdO973oYFRZwAOxy8M=
132133
github.com/hashicorp/terraform-plugin-log v0.4.0 h1:F3eVnm8r2EfQCe2k9blPIiF/r2TT01SHijXnS7bujvc=
133134
github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg=
134135
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw=
@@ -251,6 +252,7 @@ golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLL
251252
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
252253
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
253254
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
255+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
254256
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
255257
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
256258
golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs=
@@ -274,7 +276,9 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w
274276
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
275277
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
276278
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
279+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
277280
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
281+
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
278282
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
279283
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
280284
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -320,8 +324,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
320324
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
321325
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
322326
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
323-
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
324-
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
327+
google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8=
328+
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
325329
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY=
326330
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
327331
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=

helper/resource/plugin.go

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,108 @@ import (
1919
testing "github.com/mitchellh/go-testing-interface"
2020
)
2121

22+
// protov5ProviderFactory is a function which is called to start a protocol
23+
// version 5 provider server.
24+
type protov5ProviderFactory func() (tfprotov5.ProviderServer, error)
25+
26+
// protov5ProviderFactories is a mapping of provider addresses to provider
27+
// factory for protocol version 5 provider servers.
28+
type protov5ProviderFactories map[string]func() (tfprotov5.ProviderServer, error)
29+
30+
// merge combines provider factories.
31+
//
32+
// In case of an overlapping entry, the later entry will overwrite the previous
33+
// value.
34+
func (pf protov5ProviderFactories) merge(otherPfs ...protov5ProviderFactories) protov5ProviderFactories {
35+
result := make(protov5ProviderFactories)
36+
37+
for name, providerFactory := range pf {
38+
result[name] = providerFactory
39+
}
40+
41+
for _, otherPf := range otherPfs {
42+
for name, providerFactory := range otherPf {
43+
result[name] = providerFactory
44+
}
45+
}
46+
47+
return result
48+
}
49+
50+
// protov6ProviderFactory is a function which is called to start a protocol
51+
// version 6 provider server.
52+
type protov6ProviderFactory func() (tfprotov6.ProviderServer, error)
53+
54+
// protov6ProviderFactories is a mapping of provider addresses to provider
55+
// factory for protocol version 6 provider servers.
56+
type protov6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error)
57+
58+
// merge combines provider factories.
59+
//
60+
// In case of an overlapping entry, the later entry will overwrite the previous
61+
// value.
62+
func (pf protov6ProviderFactories) merge(otherPfs ...protov6ProviderFactories) protov6ProviderFactories {
63+
result := make(protov6ProviderFactories)
64+
65+
for name, providerFactory := range pf {
66+
result[name] = providerFactory
67+
}
68+
69+
for _, otherPf := range otherPfs {
70+
for name, providerFactory := range otherPf {
71+
result[name] = providerFactory
72+
}
73+
}
74+
75+
return result
76+
}
77+
78+
// sdkProviderFactory is a function which is called to start a SDK provider
79+
// server.
80+
type sdkProviderFactory func() (*schema.Provider, error)
81+
82+
// protov6ProviderFactories is a mapping of provider addresses to provider
83+
// factory for protocol version 6 provider servers.
84+
type sdkProviderFactories map[string]func() (*schema.Provider, error)
85+
86+
// merge combines provider factories.
87+
//
88+
// In case of an overlapping entry, the later entry will overwrite the previous
89+
// value.
90+
func (pf sdkProviderFactories) merge(otherPfs ...sdkProviderFactories) sdkProviderFactories {
91+
result := make(sdkProviderFactories)
92+
93+
for name, providerFactory := range pf {
94+
result[name] = providerFactory
95+
}
96+
97+
for _, otherPf := range otherPfs {
98+
for name, providerFactory := range otherPf {
99+
result[name] = providerFactory
100+
}
101+
}
102+
103+
return result
104+
}
105+
22106
type providerFactories struct {
23-
legacy map[string]func() (*schema.Provider, error)
24-
protov5 map[string]func() (tfprotov5.ProviderServer, error)
25-
protov6 map[string]func() (tfprotov6.ProviderServer, error)
107+
legacy sdkProviderFactories
108+
protov5 protov5ProviderFactories
109+
protov6 protov6ProviderFactories
26110
}
27111

28-
func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *plugintest.WorkingDir, factories providerFactories) error {
112+
func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *plugintest.WorkingDir, factories *providerFactories) error {
29113
// don't point to this as a test failure location
30114
// point to whatever called it
31115
t.Helper()
32116

117+
// This should not happen, but prevent panics just in case.
118+
if factories == nil {
119+
err := fmt.Errorf("Provider factories are missing to run Terraform command. Please report this bug in the testing framework.")
120+
logging.HelperResourceError(ctx, err.Error())
121+
return err
122+
}
123+
33124
// Run the providers in the same process as the test runner using the
34125
// reattach behavior in Terraform. This ensures we get test coverage
35126
// and enables the use of delve as a debugger.

0 commit comments

Comments
 (0)