From abf1413aa9de6d1fae3784eb49fc5fd69d388ec8 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 11:49:53 +0200
Subject: [PATCH 01/26] SCALRCORE-26653 Introduce internal packages
---
{scalr => internal/client}/client_mock.go | 2 +-
{scalr => internal/client}/config_unix.go | 2 +-
{scalr => internal/client}/config_windows.go | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename {scalr => internal/client}/client_mock.go (99%)
rename {scalr => internal/client}/config_unix.go (98%)
rename {scalr => internal/client}/config_windows.go (98%)
diff --git a/scalr/client_mock.go b/internal/client/client_mock.go
similarity index 99%
rename from scalr/client_mock.go
rename to internal/client/client_mock.go
index 678c9423..515222a9 100644
--- a/scalr/client_mock.go
+++ b/internal/client/client_mock.go
@@ -1,4 +1,4 @@
-package scalr
+package client
import (
"context"
diff --git a/scalr/config_unix.go b/internal/client/config_unix.go
similarity index 98%
rename from scalr/config_unix.go
rename to internal/client/config_unix.go
index 2246b56b..137deca8 100644
--- a/scalr/config_unix.go
+++ b/internal/client/config_unix.go
@@ -1,6 +1,6 @@
//go:build !windows
-package scalr
+package client
import (
"errors"
diff --git a/scalr/config_windows.go b/internal/client/config_windows.go
similarity index 98%
rename from scalr/config_windows.go
rename to internal/client/config_windows.go
index 655f114b..54267285 100644
--- a/scalr/config_windows.go
+++ b/internal/client/config_windows.go
@@ -1,6 +1,6 @@
//go:build windows
-package scalr
+package client
import (
"path/filepath"
From 9e6bcc4e66ea1921a981cbca6cbc2229f627210c Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 11:59:10 +0200
Subject: [PATCH 02/26] SCALRCORE-26653 Implement provider server muxing
---
.go-version | 2 +-
go.mod | 88 +--
go.sum | 513 +++++-------------
internal/client/client.go | 117 ++++
internal/client/client_mock.go | 38 +-
internal/client/config.go | 138 +++++
internal/provider/provider.go | 156 ++++++
main.go | 42 +-
scalr/provider.go | 367 +------------
scalr/provider_test.go | 65 +--
...ource_scalr_provider_configuration_test.go | 9 +-
scalr/testing.go | 12 +-
12 files changed, 680 insertions(+), 867 deletions(-)
create mode 100644 internal/client/client.go
create mode 100644 internal/client/config.go
create mode 100644 internal/provider/provider.go
diff --git a/.go-version b/.go-version
index c4729c87..ac1df3fc 100644
--- a/.go-version
+++ b/.go-version
@@ -1 +1 @@
-1.19.13
+1.23.3
diff --git a/go.mod b/go.mod
index e76d9688..322cd0de 100644
--- a/go.mod
+++ b/go.mod
@@ -1,53 +1,55 @@
+go 1.23
+
module github.com/scalr/terraform-provider-scalr
require (
- github.com/hashicorp/go-version v1.6.0
+ github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
github.com/hashicorp/terraform-plugin-docs v0.16.0
- github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
- github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
+ github.com/hashicorp/terraform-plugin-framework v1.13.0
+ github.com/hashicorp/terraform-plugin-go v0.25.0
+ github.com/hashicorp/terraform-plugin-log v0.9.0
+ github.com/hashicorp/terraform-plugin-mux v0.17.0
+ github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
+ github.com/hashicorp/terraform-svchost v0.1.1
github.com/scalr/go-scalr v0.0.0-20240929210950-4e55784195ad
)
require (
github.com/Masterminds/goutils v1.1.1 // indirect
- github.com/Masterminds/semver/v3 v3.1.1 // indirect
- github.com/Masterminds/sprig/v3 v3.2.2 // indirect
- github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
+ github.com/Masterminds/semver/v3 v3.2.0 // indirect
+ github.com/Masterminds/sprig/v3 v3.2.3 // indirect
+ github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
- github.com/apparentlymart/go-cidr v1.1.0 // indirect
- github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
+ github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
- github.com/cloudflare/circl v1.3.3 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/fatih/color v1.13.0 // indirect
- github.com/golang/protobuf v1.5.2 // indirect
- github.com/google/go-cmp v0.5.9 // indirect
+ github.com/cloudflare/circl v1.3.7 // indirect
+ github.com/fatih/color v1.16.0 // indirect
+ github.com/golang/protobuf v1.5.4 // indirect
+ github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
- github.com/google/uuid v1.3.0 // indirect
+ github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
- github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
- github.com/hashicorp/go-hclog v1.2.1 // indirect
+ github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
- github.com/hashicorp/go-plugin v1.4.6 // indirect
- github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
+ github.com/hashicorp/go-plugin v1.6.2 // indirect
+ github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
- github.com/hashicorp/hc-install v0.5.2 // indirect
- github.com/hashicorp/hcl/v2 v2.15.0 // indirect
+ github.com/hashicorp/go-version v1.7.0 // indirect
+ github.com/hashicorp/hc-install v0.9.0 // indirect
+ github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
- github.com/hashicorp/terraform-exec v0.18.1 // indirect
- github.com/hashicorp/terraform-json v0.17.1 // indirect
- github.com/hashicorp/terraform-plugin-go v0.14.1 // indirect
- github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
- github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
- github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
- github.com/huandu/xstrings v1.3.2 // indirect
- github.com/imdario/mergo v0.3.13 // indirect
+ github.com/hashicorp/terraform-exec v0.21.0 // indirect
+ github.com/hashicorp/terraform-json v0.23.0 // indirect
+ github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
+ github.com/hashicorp/yamux v0.1.1 // indirect
+ github.com/huandu/xstrings v1.3.3 // indirect
+ github.com/imdario/mergo v0.3.15 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
- github.com/mattn/go-isatty v0.0.16 // indirect
+ github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
@@ -61,20 +63,20 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d // 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
- github.com/zclconf/go-cty v1.13.2 // indirect
- golang.org/x/crypto v0.8.0 // indirect
+ github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
+ github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
+ github.com/zclconf/go-cty v1.15.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
- golang.org/x/mod v0.11.0 // indirect
- golang.org/x/net v0.9.0 // indirect
- golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
- golang.org/x/sys v0.7.0 // indirect
- golang.org/x/text v0.11.0 // indirect
- google.golang.org/appengine v1.6.6 // indirect
+ golang.org/x/mod v0.21.0 // indirect
+ golang.org/x/net v0.28.0 // indirect
+ golang.org/x/oauth2 v0.22.0 // indirect
+ golang.org/x/sync v0.8.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
+ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
+ google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
- google.golang.org/grpc v1.50.1 // indirect
- google.golang.org/protobuf v1.28.1 // indirect
+ google.golang.org/grpc v1.67.1 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
)
-
-go 1.19
diff --git a/go.sum b/go.sum
index b90d5127..0f7a7b6f 100644
--- a/go.sum
+++ b/go.sum
@@ -1,227 +1,163 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
-cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
-cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
-cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
-cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
-cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
-cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
-cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
-cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
-cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
-cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
-cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
-cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
-cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
-cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
-cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
-cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
-cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
-cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
-cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
-cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
-cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
-cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
-cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
-cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
-cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
-cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
-cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
-cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
-cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
-dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
+dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
-github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
+github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
+github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
-github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8=
-github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
-github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
-github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
-github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
-github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
+github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
+github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
+github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
+github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
+github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
+github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
-github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
-github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
-github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
-github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
-github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
-github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
+github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
+github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
-github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
+github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
+github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
-github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
-github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
-github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
-github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
-github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
-github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
-github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
+github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
+github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
+github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
+github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
-github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
-github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
-github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
+github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
+github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
-github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
-github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
-github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk=
-github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
+github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
+github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
+github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
+github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
+github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
+github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
+github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
-github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
-github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
-github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
+github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
-github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
-github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
-github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
-github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
-github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
-github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
-github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
-github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
-github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
-github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
-github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
+github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
-github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
-github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
-github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
-github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
-github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
-github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
-github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
-github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
-github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
-github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw=
-github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
+github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
+github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
-github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA=
-github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
-github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4=
-github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
+github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog=
+github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q=
+github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
+github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
-github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
-github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
-github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/hc-install v0.5.2 h1:SfwMFnEXVVirpwkDuSF5kymUOhrUxrTq3udEseZdOD0=
-github.com/hashicorp/hc-install v0.5.2/go.mod h1:9QISwe6newMWIfEiXpzuu1k9HAGtQYgnSH8H9T8wmoI=
+github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
+github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/hashicorp/hc-install v0.9.0 h1:2dIk8LcvANwtv3QZLckxcjyF5w8KVtiMxu6G6eLhghE=
+github.com/hashicorp/hc-install v0.9.0/go.mod h1:+6vOP+mf3tuGgMApVYtmsnDoKWMDcFXeTxCACYZ8SFg=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce h1:xdsDDbiBDQTKASoGEZ+pEmF1OnWuu8AQ9I8iNbHNeno=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
-github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8=
-github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
+github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M=
+github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
-github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4=
-github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980=
-github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA=
-github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
+github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ=
+github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg=
+github.com/hashicorp/terraform-json v0.23.0 h1:sniCkExU4iKtTADReHzACkk8fnpQXrdD2xoR+lppBkI=
+github.com/hashicorp/terraform-json v0.23.0/go.mod h1:MHdXbBAbSg0GvzuWazEGKAn/cyNfIB7mN6y7KJN6y2c=
github.com/hashicorp/terraform-plugin-docs v0.16.0 h1:UmxFr3AScl6Wged84jndJIfFccGyBZn52KtMNsS12dI=
github.com/hashicorp/terraform-plugin-docs v0.16.0/go.mod h1:M3ZrlKBJAbPMtNOPwHicGi1c+hZUh7/g0ifT/z7TVfA=
-github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek=
-github.com/hashicorp/terraform-plugin-go v0.14.1/go.mod h1:Bc/K6K26BQ2FHqIELPbpKtt2CzzbQou+0UQF3/0NsCQ=
-github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs=
-github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
-github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM=
-github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw=
-github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
-github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
-github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
-github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
-github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
-github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
+github.com/hashicorp/terraform-plugin-framework v1.13.0 h1:8OTG4+oZUfKgnfTdPTJwZ532Bh2BobF4H+yBiYJ/scw=
+github.com/hashicorp/terraform-plugin-framework v1.13.0/go.mod h1:j64rwMGpgM3NYXTKuxrCnyubQb/4VKldEKlcG8cvmjU=
+github.com/hashicorp/terraform-plugin-go v0.25.0 h1:oi13cx7xXA6QciMcpcFi/rwA974rdTxjqEhXJjbAyks=
+github.com/hashicorp/terraform-plugin-go v0.25.0/go.mod h1:+SYagMYadJP86Kvn+TGeV+ofr/R3g4/If0O5sO96MVw=
+github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
+github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
+github.com/hashicorp/terraform-plugin-mux v0.17.0 h1:/J3vv3Ps2ISkbLPiZOLspFcIZ0v5ycUXCEQScudGCCw=
+github.com/hashicorp/terraform-plugin-mux v0.17.0/go.mod h1:yWuM9U1Jg8DryNfvCp+lH70WcYv6D8aooQxxxIzFDsE=
+github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 h1:wyKCCtn6pBBL46c1uIIBNUOWlNfYXfXpVo16iDyLp8Y=
+github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0/go.mod h1:B0Al8NyYVr8Mp/KLwssKXG1RqnTk7FySqSn4fRuLNgw=
+github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
+github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
+github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
+github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
+github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
+github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
-github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
-github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
+github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
-github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
-github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
+github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
+github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
-github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
-github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
-github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
+github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
+github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
-github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
+github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
-github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
-github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -230,8 +166,9 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
-github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng=
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
@@ -246,27 +183,29 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
-github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
+github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
-github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
+github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/scalr/go-scalr v0.0.0-20240929210950-4e55784195ad h1:G+GZ3pm22r748k05/FBnBPKBmjG8xf7UMq1cEOkPG5Y=
github.com/scalr/go-scalr v0.0.0-20240929210950-4e55784195ad/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
-github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
+github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
+github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
-github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0=
+github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
+github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
@@ -275,311 +214,137 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
+github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
+github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d h1:Z4EH+5EffvBEhh37F0C0DnpklTMh00JOkjW5zK3ofBI=
github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d/go.mod h1:BSTlc8jOjh0niykqEGVXOLXdi9o0r0kR8tCYiMvjFgw=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
-github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
-github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
-github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
-github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
+github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
+github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
+github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
+github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
-github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
-github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0=
-github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
-go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
-go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
-go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
-go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
-go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
+github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
+github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
+github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
-golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
+golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
-golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
-golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
-golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
-golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
-golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
-golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
-golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
-golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
-golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
-golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
-golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
-golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
-golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
-golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
-golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
-golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
-golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
-golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
-golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
-golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
-golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
-golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
+golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
-golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
+golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
+golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
-golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 h1:ld7aEMNHoBnnDAX15v1T6z31v8HwR2A9FYOuAhWqkwc=
-golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
+golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
+golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
-golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
-golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
-golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
-golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
+golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
-golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
-golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
-golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
+golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
-google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
-google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
-google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
-google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
-google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
-google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
-google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
-google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
-google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
-google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
-google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
-google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
+google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
-google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
-google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
-google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
-google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
-google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
-google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d h1:92D1fum1bJLKSdr11OJ+54YeCMCGYIygTA7R/YZxH5M=
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
-google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
-google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
-google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
-google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
-google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
-google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
-google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
-google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
-google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY=
-google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
+google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
+google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
-google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
-google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
-google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
+gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
-honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
-rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
-rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/internal/client/client.go b/internal/client/client.go
new file mode 100644
index 00000000..4b978797
--- /dev/null
+++ b/internal/client/client.go
@@ -0,0 +1,117 @@
+package client
+
+import (
+ "errors"
+ "fmt"
+ "log"
+ "net/http"
+ "net/url"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
+ svchost "github.com/hashicorp/terraform-svchost"
+ "github.com/hashicorp/terraform-svchost/disco"
+ "github.com/scalr/go-scalr"
+)
+
+var scalrServiceIDs = []string{"iacp.v3"}
+
+func Configure(h, t, v string) (*scalr.Client, error) {
+ // Parse the hostname for comparison,
+ hostname, err := svchost.ForComparison(h)
+ if err != nil {
+ return nil, err
+ }
+
+ providerUaString := fmt.Sprintf("terraform-provider-scalr/%s", v)
+
+ // Get the Terraform CLI configuration.
+ config := cliConfig()
+
+ // Create a new credential source and service discovery object.
+ credsSrc := credentialsSource(config)
+ services := disco.NewWithCredentialsSource(credsSrc)
+ services.SetUserAgent(providerUaString)
+ services.Transport = logging.NewLoggingHTTPTransport(services.Transport)
+
+ // Add any static host configurations service discovery object.
+ for userHost, hostConfig := range config.Hosts {
+ host, err := svchost.ForComparison(userHost)
+ if err != nil {
+ // ignore invalid hostnames.
+ continue
+ }
+ services.ForceHostServices(host, hostConfig.Services)
+ }
+
+ // Discover the address.
+ host, err := services.Discover(hostname)
+ if err != nil {
+ return nil, err
+ }
+
+ // Get the full service address.
+ var address *url.URL
+ var discoErr error
+ for _, scalrServiceID := range scalrServiceIDs {
+ service, err := host.ServiceURL(scalrServiceID)
+ if _, ok := err.(*disco.ErrVersionNotSupported); !ok && err != nil {
+ return nil, err
+ }
+ // If discoErr is nil we save the first error. When multiple services
+ // are checked, and we found one that didn't give an error we need to
+ // reset the discoErr. So if err is nil, we assign it as well.
+ if discoErr == nil || err == nil {
+ discoErr = err
+ }
+ if service != nil {
+ address = service
+ break
+ }
+ }
+
+ // When we don't have any constraints errors, also check for discovery
+ // errors before we continue.
+ if discoErr != nil {
+ return nil, discoErr
+ }
+
+ // Only try to get to the token from the credentials source if no token
+ // was explicitly set in the provider configuration.
+ if t == "" {
+ creds, err := services.CredentialsForHost(hostname)
+ if err != nil {
+ log.Printf("[DEBUG] Failed to get credentials for %s: %s (ignoring)", hostname, err)
+ }
+ if creds != nil {
+ t = creds.Token()
+ }
+ }
+
+ // If we still don't have a token at this point, we return an error.
+ if t == "" {
+ return nil, errors.New("required token could not be found")
+ }
+
+ httpClient := scalr.DefaultConfig().HTTPClient
+ httpClient.Transport = logging.NewLoggingHTTPTransport(httpClient.Transport)
+
+ headers := make(http.Header)
+ headers.Add("User-Agent", providerUaString)
+
+ // Create a new Scalr client config
+ cfg := &scalr.Config{
+ Address: address.String(),
+ Token: t,
+ HTTPClient: httpClient,
+ Headers: headers,
+ }
+
+ // Create a new Scalr client.
+ scalrClient, err := scalr.NewClient(cfg)
+ if err != nil {
+ return nil, err
+ }
+
+ scalrClient.RetryServerErrors(true)
+ return scalrClient, nil
+}
diff --git a/internal/client/client_mock.go b/internal/client/client_mock.go
index 515222a9..1f7b3859 100644
--- a/internal/client/client_mock.go
+++ b/internal/client/client_mock.go
@@ -10,31 +10,31 @@ type workspaceNamesKey struct {
environment, workspace string
}
-type mockWorkspaces struct {
+type MockWorkspaces struct {
workspaceNames map[workspaceNamesKey]*scalr.Workspace
}
-type mockVariables struct {
+type MockVariables struct {
ids map[string]*scalr.Variable
}
-func newMockWorkspaces() *mockWorkspaces {
- return &mockWorkspaces{
+func NewMockWorkspaces() *MockWorkspaces {
+ return &MockWorkspaces{
workspaceNames: make(map[workspaceNamesKey]*scalr.Workspace),
}
}
-func newMockVariables() *mockVariables {
- return &mockVariables{
+func NewMockVariables() *MockVariables {
+ return &MockVariables{
ids: make(map[string]*scalr.Variable),
}
}
-func (m *mockWorkspaces) List(_ context.Context, _ scalr.WorkspaceListOptions) (*scalr.WorkspaceList, error) {
+func (m *MockWorkspaces) List(_ context.Context, _ scalr.WorkspaceListOptions) (*scalr.WorkspaceList, error) {
panic("not implemented")
}
-func (m *mockWorkspaces) Create(_ context.Context, options scalr.WorkspaceCreateOptions) (*scalr.Workspace, error) {
+func (m *MockWorkspaces) Create(_ context.Context, options scalr.WorkspaceCreateOptions) (*scalr.Workspace, error) {
ws := &scalr.Workspace{
ID: options.ID,
Name: *options.Name,
@@ -48,7 +48,7 @@ func (m *mockWorkspaces) Create(_ context.Context, options scalr.WorkspaceCreate
return ws, nil
}
-func (m *mockVariables) Create(_ context.Context, options scalr.VariableCreateOptions) (*scalr.Variable, error) {
+func (m *MockVariables) Create(_ context.Context, options scalr.VariableCreateOptions) (*scalr.Variable, error) {
variable := &scalr.Variable{
ID: options.ID,
}
@@ -58,7 +58,7 @@ func (m *mockVariables) Create(_ context.Context, options scalr.VariableCreateOp
return variable, nil
}
-func (m *mockVariables) Read(_ context.Context, varID string) (*scalr.Variable, error) {
+func (m *MockVariables) Read(_ context.Context, varID string) (*scalr.Variable, error) {
v := m.ids[varID]
if v == nil {
@@ -68,11 +68,11 @@ func (m *mockVariables) Read(_ context.Context, varID string) (*scalr.Variable,
return v, nil
}
-func (m *mockVariables) List(_ context.Context, _ scalr.VariableListOptions) (*scalr.VariableList, error) {
+func (m *MockVariables) List(_ context.Context, _ scalr.VariableListOptions) (*scalr.VariableList, error) {
panic("not implemented")
}
-func (m *mockWorkspaces) Read(_ context.Context, environment string, workspace string) (*scalr.Workspace, error) {
+func (m *MockWorkspaces) Read(_ context.Context, environment string, workspace string) (*scalr.Workspace, error) {
w := m.workspaceNames[workspaceNamesKey{environment, workspace}]
if w == nil {
return nil, scalr.ErrResourceNotFound
@@ -81,29 +81,29 @@ func (m *mockWorkspaces) Read(_ context.Context, environment string, workspace s
return w, nil
}
-func (m *mockWorkspaces) ReadByID(_ context.Context, _ string) (*scalr.Workspace, error) {
+func (m *MockWorkspaces) ReadByID(_ context.Context, _ string) (*scalr.Workspace, error) {
panic("not implemented")
}
-func (m *mockWorkspaces) Update(_ context.Context, _ string, _ scalr.WorkspaceUpdateOptions) (*scalr.Workspace, error) {
+func (m *MockWorkspaces) Update(_ context.Context, _ string, _ scalr.WorkspaceUpdateOptions) (*scalr.Workspace, error) {
panic("not implemented")
}
-func (m *mockWorkspaces) Delete(_ context.Context, _ string) error {
+func (m *MockWorkspaces) Delete(_ context.Context, _ string) error {
panic("not implemented")
}
-func (m *mockWorkspaces) ReadOutputs(_ context.Context, _ string) ([]*scalr.Output, error) {
+func (m *MockWorkspaces) ReadOutputs(_ context.Context, _ string) ([]*scalr.Output, error) {
panic("not implemented")
}
-func (m *mockWorkspaces) SetSchedule(_ context.Context, _ string, _ scalr.WorkspaceRunScheduleOptions) (*scalr.Workspace, error) {
+func (m *MockWorkspaces) SetSchedule(_ context.Context, _ string, _ scalr.WorkspaceRunScheduleOptions) (*scalr.Workspace, error) {
panic("not implemented")
}
-func (m *mockVariables) Update(_ context.Context, _ string, _ scalr.VariableUpdateOptions) (*scalr.Variable, error) {
+func (m *MockVariables) Update(_ context.Context, _ string, _ scalr.VariableUpdateOptions) (*scalr.Variable, error) {
panic("not implemented")
}
-func (m *mockVariables) Delete(_ context.Context, _ string) error {
+func (m *MockVariables) Delete(_ context.Context, _ string) error {
panic("not implemented")
}
diff --git a/internal/client/config.go b/internal/client/config.go
new file mode 100644
index 00000000..0a36c29c
--- /dev/null
+++ b/internal/client/config.go
@@ -0,0 +1,138 @@
+package client
+
+import (
+ "log"
+ "os"
+
+ "github.com/hashicorp/hcl"
+ svchost "github.com/hashicorp/terraform-svchost"
+ "github.com/hashicorp/terraform-svchost/auth"
+)
+
+const (
+ DefaultHostname = "scalr.io"
+ HostnameEnvVar = "SCALR_HOSTNAME"
+ TokenEnvVar = "SCALR_TOKEN"
+)
+
+// config is the structure of the configuration for the Terraform CLI.
+type config struct {
+ Hosts map[string]*configHost `hcl:"host"`
+ Credentials map[string]map[string]interface{} `hcl:"credentials"`
+}
+
+// configHost is the structure of the "host" nested block within the CLI
+// configuration, which can be used to override the default service host
+// discovery behavior for a particular hostname.
+type configHost struct {
+ Services map[string]interface{} `hcl:"services"`
+}
+
+// CliConfig tries to find and parse the configuration of the Terraform CLI.
+// This is an optional step, so any errors are ignored.
+func cliConfig() *config {
+ combinedConfig := &config{}
+
+ // Main CLI config file; might contain manually-entered credentials, and/or
+ // some host service discovery objects. Location is configurable via
+ // environment variables.
+ mainConfig := readCliConfigFile(locateConfigFile())
+
+ // Credentials file; might contain credentials auto-configured by terraform
+ // login. Location isn't configurable.
+ var credentialsConfig *config
+ credentialsFilePath, err := credentialsFile()
+ if err != nil {
+ log.Printf("[ERROR] Error detecting default credentials file path: %s", err)
+ credentialsConfig = &config{}
+ } else {
+ credentialsConfig = readCliConfigFile(credentialsFilePath)
+ }
+
+ // Use host service discovery configs from main config file.
+ combinedConfig.Hosts = mainConfig.Hosts
+
+ // Combine both sets of credentials. Per Terraform's own behavior, the main
+ // config file overrides the credentials file if they have any overlapping
+ // hostnames.
+ combinedConfig.Credentials = credentialsConfig.Credentials
+ if combinedConfig.Credentials == nil {
+ combinedConfig.Credentials = make(map[string]map[string]interface{})
+ }
+ for host, creds := range mainConfig.Credentials {
+ combinedConfig.Credentials[host] = creds
+ }
+
+ return combinedConfig
+}
+
+func credentialsSource(config *config) auth.CredentialsSource {
+ creds := auth.NoCredentials
+
+ // Add all configured credentials to the credentials source.
+ if len(config.Credentials) > 0 {
+ staticTable := map[svchost.Hostname]map[string]interface{}{}
+ for userHost, creds := range config.Credentials {
+ host, err := svchost.ForComparison(userHost)
+ if err != nil {
+ // We expect the config was already validated by the time we get
+ // here, so we'll just ignore invalid hostnames.
+ continue
+ }
+ staticTable[host] = creds
+ }
+ creds = auth.StaticCredentialsSource(staticTable)
+ }
+
+ return creds
+}
+
+func readCliConfigFile(configFilePath string) *config {
+ config := &config{}
+
+ if configFilePath == "" {
+ return config
+ }
+
+ // Read the CLI config file content.
+ content, err := os.ReadFile(configFilePath)
+ if err != nil {
+ log.Printf("[ERROR] Error reading CLI config or credentials file %s: %v", configFilePath, err)
+ return config
+ }
+
+ // Parse the CLI config file content.
+ obj, err := hcl.Parse(string(content))
+ if err != nil {
+ log.Printf("[ERROR] Error parsing CLI config or credentials file %s: %v", configFilePath, err)
+ return config
+ }
+
+ // Decode the CLI config file content.
+ if err := hcl.DecodeObject(config, obj); err != nil {
+ log.Printf("[ERROR] Error decoding CLI config or credentials file %s: %v", configFilePath, err)
+ }
+
+ return config
+}
+
+func locateConfigFile() string {
+ // To find the main CLI config file, follow Terraform's own logic: try
+ // TF_CLI_CONFIG_FILE, then try TERRAFORM_CONFIG, then try the default
+ // location.
+
+ if os.Getenv("TF_CLI_CONFIG_FILE") != "" {
+ return os.Getenv("TF_CLI_CONFIG_FILE")
+ }
+
+ if os.Getenv("TERRAFORM_CONFIG") != "" {
+ return os.Getenv("TERRAFORM_CONFIG")
+ }
+ filePath, err := configFile()
+ if err != nil {
+ log.Printf("[ERROR] Error detecting default CLI config file path: %s", err)
+ return ""
+ }
+
+ return filePath
+}
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
new file mode 100644
index 00000000..bf6e39db
--- /dev/null
+++ b/internal/provider/provider.go
@@ -0,0 +1,156 @@
+package provider
+
+import (
+ "context"
+ "fmt"
+ "os"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/provider"
+ "github.com/hashicorp/terraform-plugin-framework/provider/schema"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+
+ "github.com/scalr/terraform-provider-scalr/internal/client"
+)
+
+// Compile-time interface check
+var _ provider.Provider = &scalrProvider{}
+
+// New returns a function that creates a Scalr provider instance with version v.
+func New(v string) func() provider.Provider {
+ return func() provider.Provider {
+ return &scalrProvider{
+ version: v,
+ }
+ }
+}
+
+// scalrProviderModel describes the provider data model.
+type scalrProviderModel struct {
+ Hostname types.String `tfsdk:"hostname"`
+ Token types.String `tfsdk:"token"`
+}
+
+// scalrProvider implements the Terraform plugin framework Provider interface.
+type scalrProvider struct {
+ version string
+}
+
+func (p *scalrProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) {
+ resp.TypeName = "scalr"
+ resp.Version = p.version
+}
+
+func (p *scalrProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ Attributes: map[string]schema.Attribute{
+ "hostname": schema.StringAttribute{
+ Description: fmt.Sprintf("The Scalr hostname to connect to. Defaults to %q."+
+ " Can be overridden by setting the %s environment variable.",
+ client.DefaultHostname, client.HostnameEnvVar),
+ MarkdownDescription: fmt.Sprintf("The Scalr hostname to connect to. Defaults to %q."+
+ " Can be overridden by setting the `%s` environment variable.",
+ client.DefaultHostname, client.HostnameEnvVar),
+ Optional: true,
+ },
+ "token": schema.StringAttribute{
+ Description: fmt.Sprintf("The token used to authenticate with Scalr."+
+ " Can be overridden by setting the %s environment variable."+
+ " See Scalr provider configuration at https://docs.scalr.io/docs/scalr"+
+ " for information on generating a token.",
+ client.TokenEnvVar),
+ MarkdownDescription: fmt.Sprintf("The token used to authenticate with Scalr."+
+ " Can be overridden by setting the `%s` environment variable."+
+ " See [Scalr provider configuration](https://docs.scalr.io/docs/scalr)"+
+ " for information on generating a token.",
+ client.TokenEnvVar),
+ Optional: true,
+ },
+ },
+ }
+}
+
+func (p *scalrProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
+ tflog.Info(ctx, "Configuring Scalr provider...")
+
+ var cfg scalrProviderModel
+ diags := req.Config.Get(ctx, &cfg)
+ resp.Diagnostics.Append(diags...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ if cfg.Hostname.IsUnknown() {
+ resp.Diagnostics.AddAttributeError(
+ path.Root("hostname"),
+ "Unknown Scalr instance hostname",
+ fmt.Sprintf(
+ "The provider cannot create the Scalr API client as there is an unknown configuration value"+
+ " for the Scalr instance hostname. Either target apply the source of the value first,"+
+ " set the value statically in the configuration, or use the %s environment variable.",
+ client.HostnameEnvVar,
+ ),
+ )
+ }
+ if cfg.Token.IsUnknown() {
+ resp.Diagnostics.AddAttributeError(
+ path.Root("token"),
+ "Unknown Scalr API token",
+ fmt.Sprintf(
+ "The provider cannot create the Scalr API client as there is an unknown configuration value"+
+ " for the Scalr API token. Either target apply the source of the value first,"+
+ " set the value statically in the configuration, or use the %s environment variable.",
+ client.TokenEnvVar,
+ ),
+ )
+ }
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ hostname := os.Getenv(client.HostnameEnvVar)
+ token := os.Getenv(client.TokenEnvVar)
+
+ if !cfg.Hostname.IsNull() {
+ hostname = cfg.Hostname.ValueString()
+ }
+ if hostname == "" {
+ hostname = client.DefaultHostname
+ }
+
+ if !cfg.Token.IsNull() {
+ token = cfg.Token.ValueString()
+ }
+
+ ctx = tflog.SetField(ctx, "scalr_hostname", hostname)
+
+ tflog.Debug(ctx, "Creating Scalr client...")
+
+ scalrClient, err := client.Configure(hostname, token, p.version)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create Scalr API client",
+ "An unexpected error occurred when creating the Scalr API client. "+
+ "If the error is not clear, please contact the provider developers.\n\n"+
+ "Scalr client error: "+err.Error(),
+ )
+ return
+ }
+
+ // Make the Scalr client available during DataSource and Resource Configure methods.
+ resp.DataSourceData = scalrClient
+ resp.ResourceData = scalrClient
+
+ tflog.Info(ctx, "Scalr provider configured.")
+}
+
+func (p *scalrProvider) Resources(_ context.Context) []func() resource.Resource {
+ return []func() resource.Resource{}
+}
+
+func (p *scalrProvider) DataSources(_ context.Context) []func() datasource.DataSource {
+ return []func() datasource.DataSource{}
+}
diff --git a/main.go b/main.go
index 241b42f9..03f30665 100644
--- a/main.go
+++ b/main.go
@@ -1,13 +1,19 @@
package main
import (
+ "context"
"flag"
"log"
+ "github.com/hashicorp/terraform-plugin-framework/providerserver"
+ "github.com/hashicorp/terraform-plugin-go/tfprotov5"
+ "github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server"
+ "github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- "github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
+ "github.com/scalr/terraform-provider-scalr/internal/provider"
"github.com/scalr/terraform-provider-scalr/scalr"
+ "github.com/scalr/terraform-provider-scalr/version"
)
// Commands to prepare auto-generated documentation.
@@ -24,6 +30,8 @@ const (
)
func main() {
+ ctx := context.Background()
+
var isDebug bool
flag.BoolVar(&isDebug, "debug", false, "Start provider in debug mode.")
flag.Parse()
@@ -34,9 +42,31 @@ func main() {
schema.DescriptionKind = schema.StringMarkdown
- plugin.Serve(&plugin.ServeOpts{
- ProviderFunc: scalr.Provider,
- ProviderAddr: scalrProviderAddr,
- Debug: isDebug,
- })
+ providers := []func() tfprotov5.ProviderServer{
+ // New provider implementation with Terraform Plugin Framework
+ providerserver.NewProtocol5(provider.New(version.ProviderVersion)()),
+ // Classic provider implementation with Terraform Plugin SDK
+ scalr.Provider().GRPCProvider,
+ }
+
+ muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ var serveOpts []tf5server.ServeOpt
+ if isDebug {
+ serveOpts = append(serveOpts, tf5server.WithManagedDebug())
+ }
+
+ // Serve both the classic and the new provider
+ err = tf5server.Serve(
+ scalrProviderAddr,
+ muxServer.ProviderServer,
+ serveOpts...,
+ )
+
+ if err != nil {
+ log.Fatal(err)
+ }
}
diff --git a/scalr/provider.go b/scalr/provider.go
index 0d6a927e..e028f57e 100644
--- a/scalr/provider.go
+++ b/scalr/provider.go
@@ -3,41 +3,13 @@ package scalr
import (
"context"
"fmt"
- "log"
- "net/http"
- "net/url"
- "os"
- "sort"
- "strings"
- "github.com/hashicorp/go-version"
- "github.com/hashicorp/hcl"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- svchost "github.com/hashicorp/terraform-svchost"
- "github.com/hashicorp/terraform-svchost/auth"
- "github.com/hashicorp/terraform-svchost/disco"
- "github.com/scalr/go-scalr"
- providerVersion "github.com/scalr/terraform-provider-scalr/version"
-)
-
-const defaultHostname = "scalr.io"
-var scalrServiceIDs = []string{"iacp.v3"}
-
-// Config is the structure of the configuration for the Terraform CLI.
-type Config struct {
- Hosts map[string]*ConfigHost `hcl:"host"`
- Credentials map[string]map[string]interface{} `hcl:"credentials"`
-}
-
-// ConfigHost is the structure of the "host" nested block within the CLI
-// configuration, which can be used to override the default service host
-// discovery behavior for a particular hostname.
-type ConfigHost struct {
- Services map[string]interface{} `hcl:"services"`
-}
+ "github.com/scalr/terraform-provider-scalr/internal/client"
+ "github.com/scalr/terraform-provider-scalr/version"
+)
// Provider returns a terraform.ResourceProvider.
func Provider() *schema.Provider {
@@ -46,20 +18,21 @@ func Provider() *schema.Provider {
"hostname": {
Type: schema.TypeString,
Optional: true,
- Description: fmt.Sprintf("The Scalr hostname to connect to. Defaults to `%s`."+
- " Can be overridden by setting the `SCALR_HOSTNAME` environment variable.",
- defaultHostname),
- DefaultFunc: schema.EnvDefaultFunc("SCALR_HOSTNAME", defaultHostname),
+ Description: fmt.Sprintf("The Scalr hostname to connect to. Defaults to %q."+
+ " Can be overridden by setting the `%s` environment variable.",
+ client.DefaultHostname, client.HostnameEnvVar),
+ DefaultFunc: schema.EnvDefaultFunc(client.HostnameEnvVar, client.DefaultHostname),
},
"token": {
Type: schema.TypeString,
Optional: true,
- Description: "The token used to authenticate with Scalr." +
- " Can be overridden by setting the `SCALR_TOKEN` environment variable." +
- " See [Scalr provider configuration](https://docs.scalr.io/docs/scalr)" +
+ Description: fmt.Sprintf("The token used to authenticate with Scalr."+
+ " Can be overridden by setting the `%s` environment variable."+
+ " See [Scalr provider configuration](https://docs.scalr.io/docs/scalr)"+
" for information on generating a token.",
- DefaultFunc: schema.EnvDefaultFunc("SCALR_TOKEN", nil),
+ client.TokenEnvVar),
+ DefaultFunc: schema.EnvDefaultFunc(client.TokenEnvVar, nil),
},
},
@@ -122,321 +95,13 @@ func Provider() *schema.Provider {
}
func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
- // Parse the hostname for comparison,
- hostname, err := svchost.ForComparison(d.Get("hostname").(string))
- if err != nil {
- return nil, diag.FromErr(err)
- }
-
- providerUaString := fmt.Sprintf("terraform-provider-scalr/%s", providerVersion.ProviderVersion)
-
- // Get the Terraform CLI configuration.
- config := cliConfig()
-
- // Create a new credential source and service discovery object.
- credsSrc := credentialsSource(config)
- services := disco.NewWithCredentialsSource(credsSrc)
- services.SetUserAgent(providerUaString)
- services.Transport = logging.NewLoggingHTTPTransport(services.Transport)
+ h := d.Get("hostname").(string)
+ t := d.Get("token").(string)
- // Add any static host configurations service discovery object.
- for userHost, hostConfig := range config.Hosts {
- host, err := svchost.ForComparison(userHost)
- if err != nil {
- // ignore invalid hostnames.
- continue
- }
- services.ForceHostServices(host, hostConfig.Services)
- }
-
- // Discover the address.
- host, err := services.Discover(hostname)
+ scalrClient, err := client.Configure(h, t, version.ProviderVersion)
if err != nil {
return nil, diag.FromErr(err)
}
- // Get the full service address.
- var address *url.URL
- var discoErr error
- for _, scalrServiceID := range scalrServiceIDs {
- service, err := host.ServiceURL(scalrServiceID)
- if _, ok := err.(*disco.ErrVersionNotSupported); !ok && err != nil {
- return nil, diag.FromErr(err)
- }
- // If discoErr is nil we save the first error. When multiple services
- // are checked, and we found one that didn't give an error we need to
- // reset the discoErr. So if err is nil, we assign it as well.
- if discoErr == nil || err == nil {
- discoErr = err
- }
- if service != nil {
- address = service
- break
- }
- }
-
- // When we don't have any constraints errors, also check for discovery
- // errors before we continue.
- if discoErr != nil {
- return nil, diag.FromErr(discoErr)
- }
-
- // Get the token from the config.
- token := d.Get("token").(string)
-
- // Only try to get to the token from the credentials source if no token
- // was explicitly set in the provider configuration.
- if token == "" {
- creds, err := services.CredentialsForHost(hostname)
- if err != nil {
- log.Printf("[DEBUG] Failed to get credentials for %s: %s (ignoring)", hostname, err)
- }
- if creds != nil {
- token = creds.Token()
- }
- }
-
- // If we still don't have a token at this point, we return an error.
- if token == "" {
- return nil, diag.Errorf("required token could not be found")
- }
-
- httpClient := scalr.DefaultConfig().HTTPClient
- httpClient.Transport = logging.NewLoggingHTTPTransport(httpClient.Transport)
-
- headers := make(http.Header)
- headers.Add("User-Agent", providerUaString)
-
- // Create a new Scalr client config
- cfg := &scalr.Config{
- Address: address.String(),
- Token: token,
- HTTPClient: httpClient,
- Headers: headers,
- }
-
- // Create a new Scalr client.
- client, err := scalr.NewClient(cfg)
- if err != nil {
- return nil, diag.FromErr(err)
- }
-
- client.RetryServerErrors(true)
- return client, nil
-}
-
-// cliConfig tries to find and parse the configuration of the Terraform CLI.
-// This is an optional step, so any errors are ignored.
-func cliConfig() *Config {
- combinedConfig := &Config{}
-
- // Main CLI config file; might contain manually-entered credentials, and/or
- // some host service discovery objects. Location is configurable via
- // environment variables.
- mainConfig := readCliConfigFile(locateConfigFile())
-
- // Credentials file; might contain credentials auto-configured by terraform
- // login. Location isn't configurable.
- var credentialsConfig *Config
- credentialsFilePath, err := credentialsFile()
- if err != nil {
- log.Printf("[ERROR] Error detecting default credentials file path: %s", err)
- credentialsConfig = &Config{}
- } else {
- credentialsConfig = readCliConfigFile(credentialsFilePath)
- }
-
- // Use host service discovery configs from main config file.
- combinedConfig.Hosts = mainConfig.Hosts
-
- // Combine both sets of credentials. Per Terraform's own behavior, the main
- // config file overrides the credentials file if they have any overlapping
- // hostnames.
- combinedConfig.Credentials = credentialsConfig.Credentials
- if combinedConfig.Credentials == nil {
- combinedConfig.Credentials = make(map[string]map[string]interface{})
- }
- for host, creds := range mainConfig.Credentials {
- combinedConfig.Credentials[host] = creds
- }
-
- return combinedConfig
-}
-
-func locateConfigFile() string {
- // To find the main CLI config file, follow Terraform's own logic: try
- // TF_CLI_CONFIG_FILE, then try TERRAFORM_CONFIG, then try the default
- // location.
-
- if os.Getenv("TF_CLI_CONFIG_FILE") != "" {
- return os.Getenv("TF_CLI_CONFIG_FILE")
- }
-
- if os.Getenv("TERRAFORM_CONFIG") != "" {
- return os.Getenv("TERRAFORM_CONFIG")
- }
- filePath, err := configFile()
- if err != nil {
- log.Printf("[ERROR] Error detecting default CLI config file path: %s", err)
- return ""
- }
-
- return filePath
-}
-
-func readCliConfigFile(configFilePath string) *Config {
- config := &Config{}
-
- if configFilePath == "" {
- return config
- }
-
- // Read the CLI config file content.
- content, err := os.ReadFile(configFilePath)
- if err != nil {
- log.Printf("[ERROR] Error reading CLI config or credentials file %s: %v", configFilePath, err)
- return config
- }
-
- // Parse the CLI config file content.
- obj, err := hcl.Parse(string(content))
- if err != nil {
- log.Printf("[ERROR] Error parsing CLI config or credentials file %s: %v", configFilePath, err)
- return config
- }
-
- // Decode the CLI config file content.
- if err := hcl.DecodeObject(config, obj); err != nil {
- log.Printf("[ERROR] Error decoding CLI config or credentials file %s: %v", configFilePath, err)
- }
-
- return config
-}
-
-func credentialsSource(config *Config) auth.CredentialsSource {
- creds := auth.NoCredentials
-
- // Add all configured credentials to the credentials source.
- if len(config.Credentials) > 0 {
- staticTable := map[svchost.Hostname]map[string]interface{}{}
- for userHost, creds := range config.Credentials {
- host, err := svchost.ForComparison(userHost)
- if err != nil {
- // We expect the config was already validated by the time we get
- // here, so we'll just ignore invalid hostnames.
- continue
- }
- staticTable[host] = creds
- }
- creds = auth.StaticCredentialsSource(staticTable)
- }
-
- return creds
-}
-
-// checkConstraints checks service version constrains against our own
-// version and returns rich and informational diagnostics in case any
-// incompatibilities are detected.
-// nolint:deadcode,unused
-func checkConstraints(c *disco.Constraints) error {
- if c == nil || c.Minimum == "" || c.Maximum == "" {
- return nil
- }
-
- // Generate a parsable constraints string.
- excluding := ""
- if len(c.Excluding) > 0 {
- excluding = fmt.Sprintf(", != %s", strings.Join(c.Excluding, ", != "))
- }
- constStr := fmt.Sprintf(">= %s%s, <= %s", c.Minimum, excluding, c.Maximum)
-
- // Create the constraints to check against.
- constraints, err := version.NewConstraint(constStr)
- if err != nil {
- return checkConstraintsWarning(err)
- }
-
- // Create the version to check.
- v, err := version.NewVersion(providerVersion.ProviderVersion)
- if err != nil {
- return checkConstraintsWarning(err)
- }
-
- // Return if we satisfy all constraints.
- if constraints.Check(v) {
- return nil
- }
-
- // Find out what action (upgrade/downgrade) we should advise.
- minimum, err := version.NewVersion(c.Minimum)
- if err != nil {
- return checkConstraintsWarning(err)
- }
-
- maximum, err := version.NewVersion(c.Maximum)
- if err != nil {
- return checkConstraintsWarning(err)
- }
-
- var excludes []*version.Version
- for _, exclude := range c.Excluding {
- v, err := version.NewVersion(exclude)
- if err != nil {
- return checkConstraintsWarning(err)
- }
- excludes = append(excludes, v)
- }
-
- // Sort all the excludes.
- sort.Sort(version.Collection(excludes))
-
- var action, toVersion string
- switch {
- case minimum.GreaterThan(v):
- action = "upgrade"
- toVersion = ">= " + minimum.String()
- case maximum.LessThan(v):
- action = "downgrade"
- toVersion = "<= " + maximum.String()
- case len(excludes) > 0:
- // Get the latest excluded version.
- action = "upgrade"
- toVersion = "> " + excludes[len(excludes)-1].String()
- }
-
- switch {
- case len(excludes) == 1:
- excluding = fmt.Sprintf(", excluding version %s", excludes[0].String())
- case len(excludes) > 1:
- var vs []string
- for _, v := range excludes {
- vs = append(vs, v.String())
- }
- excluding = fmt.Sprintf(", excluding versions %s", strings.Join(vs, ", "))
- default:
- excluding = ""
- }
-
- summary := fmt.Sprintf("Incompatible Scalr provider version v%s", v.String())
- details := fmt.Sprintf(
- "The configured Scalr installation is compatible with Scalr provider\n"+
- "versions >= %s, <= %s%s.", c.Minimum, c.Maximum, excluding,
- )
-
- if action != "" && toVersion != "" {
- summary = fmt.Sprintf("Please %s the Scalr provider to %s", action, toVersion)
- }
-
- // Return the customized and informational error message.
- return fmt.Errorf("%s\n\n%s", summary, details)
-}
-
-// nolint:unused
-func checkConstraintsWarning(err error) error {
- return fmt.Errorf(
- "Failed to check version constraints: %v\n\n"+
- "Checking version constraints is considered optional, but this is an\n"+
- "unexpected error which should be reported.",
- err,
- )
+ return scalrClient, nil
}
diff --git a/scalr/provider_test.go b/scalr/provider_test.go
index 3f24a6ff..971b8d70 100644
--- a/scalr/provider_test.go
+++ b/scalr/provider_test.go
@@ -3,15 +3,12 @@ package scalr
import (
"context"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"os"
- "strings"
"testing"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
- "github.com/hashicorp/terraform-svchost/disco"
- "github.com/scalr/terraform-provider-scalr/version"
)
var testAccProvider *schema.Provider
@@ -41,66 +38,6 @@ func TestProvider_impl(t *testing.T) {
var _ = Provider()
}
-func TestProvider_versionConstraints(t *testing.T) {
- cases := map[string]struct {
- constraints *disco.Constraints
- version string
- result string
- }{
- "compatible version": {
- constraints: &disco.Constraints{
- Service: "tfe.v2.1",
- Product: "scalr-provider",
- Minimum: "0.4.0",
- Maximum: "0.7.0",
- },
- version: "0.6.0",
- },
- "version too old": {
- constraints: &disco.Constraints{
- Service: "tfe.v2.1",
- Product: "scalr-provider",
- Minimum: "0.4.0",
- Maximum: "0.7.0",
- },
- version: "0.3.0",
- result: "upgrade the Scalr provider to >= 0.4.0",
- },
- "version too new": {
- constraints: &disco.Constraints{
- Service: "tfe.v2.1",
- Product: "scalr-provider",
- Minimum: "0.4.0",
- Maximum: "0.7.0",
- },
- version: "0.8.0",
- result: "downgrade the Scalr provider to <= 0.7.0",
- },
- }
-
- // Save and restore the actual version.
- v := version.ProviderVersion
- defer func() {
- version.ProviderVersion = v
- }()
-
- for name, tc := range cases {
- // Set the version for this test.
- version.ProviderVersion = tc.version
-
- err := checkConstraints(tc.constraints)
- if err == nil && tc.result != "" {
- t.Fatalf("%s: expected error to contain %q, but got no error", name, tc.result)
- }
- if err != nil && tc.result == "" {
- t.Fatalf("%s: unexpected error: %v", name, err)
- }
- if err != nil && !strings.Contains(err.Error(), tc.result) {
- t.Fatalf("%s: expected error to contain %q, got: %v", name, tc.result, err)
- }
- }
-}
-
func testAccPreCheck(t *testing.T) {
// The credentials must be provided by the CLI config file for testing.
if diags := Provider().Configure(context.Background(), &terraform.ResourceConfig{}); diags.HasError() {
diff --git a/scalr/resource_scalr_provider_configuration_test.go b/scalr/resource_scalr_provider_configuration_test.go
index 9dfdb033..068416e0 100644
--- a/scalr/resource_scalr_provider_configuration_test.go
+++ b/scalr/resource_scalr_provider_configuration_test.go
@@ -10,8 +10,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
-
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/client"
)
func TestAccProviderConfiguration_import(t *testing.T) {
@@ -228,7 +229,7 @@ func TestAccProviderConfiguration_aws(t *testing.T) {
func TestAccProviderConfiguration_scalr(t *testing.T) {
var providerConfiguration scalr.ProviderConfiguration
- scalrHostname := os.Getenv("SCALR_HOSTNAME")
+ scalrHostname := os.Getenv(client.HostnameEnvVar)
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
@@ -1070,7 +1071,7 @@ resource "scalr_provider_configuration" "scalr" {
token = "%s"
}
}
-`, name, defaultAccount, os.Getenv("SCALR_HOSTNAME"), os.Getenv("SCALR_TOKEN"))
+`, name, defaultAccount, os.Getenv(client.HostnameEnvVar), os.Getenv(client.TokenEnvVar))
}
func testAccScalrProviderConfigurationScalrUpdatedConfig(name string) string {
@@ -1084,5 +1085,5 @@ resource "scalr_provider_configuration" "scalr" {
token = "%s"
}
}
-`, name, defaultAccount, os.Getenv("SCALR_HOSTNAME")+"/", os.Getenv("SCALR_TOKEN"))
+`, name, defaultAccount, os.Getenv(client.HostnameEnvVar)+"/", os.Getenv(client.TokenEnvVar))
}
diff --git a/scalr/testing.go b/scalr/testing.go
index 6d9ecb87..172c710c 100644
--- a/scalr/testing.go
+++ b/scalr/testing.go
@@ -7,6 +7,8 @@ import (
"testing"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/client"
)
const defaultAccount = "acc-svrcncgh453bi8g"
@@ -20,15 +22,15 @@ func testScalrClient(t *testing.T) *scalr.Client {
Token: "not-a-token",
}
- client, err := scalr.NewClient(config)
+ scalrClient, err := scalr.NewClient(config)
if err != nil {
t.Fatalf("error creating Scalr client: %v", err)
}
- client.Workspaces = newMockWorkspaces()
- client.Variables = newMockVariables()
+ scalrClient.Workspaces = client.NewMockWorkspaces()
+ scalrClient.Variables = client.NewMockVariables()
- return client
+ return scalrClient
}
func assertCorrectState(t *testing.T, err error, actual, expected map[string]interface{}) {
@@ -49,7 +51,7 @@ func isAccTest() bool {
func createScalrClient() (*scalr.Client, error) {
config := scalr.DefaultConfig()
- config.Address = fmt.Sprintf("https://%s", os.Getenv("SCALR_HOSTNAME"))
+ config.Address = fmt.Sprintf("https://%s", os.Getenv(client.HostnameEnvVar))
scalrClient, err := scalr.NewClient(config)
return scalrClient, err
}
From 2306d54378d04b0c3da3743f105cc3c50b092006 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 12:07:04 +0200
Subject: [PATCH 03/26] SCALRCORE-26653 Resolve conflicts
---
go.mod | 2 +-
go.sum | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/go.mod b/go.mod
index 322cd0de..90852689 100644
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,7 @@ require (
github.com/hashicorp/terraform-plugin-mux v0.17.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/hashicorp/terraform-svchost v0.1.1
- github.com/scalr/go-scalr v0.0.0-20240929210950-4e55784195ad
+ github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e
)
require (
diff --git a/go.sum b/go.sum
index 0f7a7b6f..df258143 100644
--- a/go.sum
+++ b/go.sum
@@ -197,8 +197,8 @@ github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBO
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
-github.com/scalr/go-scalr v0.0.0-20240929210950-4e55784195ad h1:G+GZ3pm22r748k05/FBnBPKBmjG8xf7UMq1cEOkPG5Y=
-github.com/scalr/go-scalr v0.0.0-20240929210950-4e55784195ad/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
+github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e h1:dRpwrWotOKjMEmUJQEavyoM/20QTXshBeY7bAmg+84s=
+github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
From e1b7bd73db4010649e0c8fcc753df16e005a9005 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 12:12:31 +0200
Subject: [PATCH 04/26] SCALRCORE-26653 CI: bump Go to 1.23
---
.github/workflows/default.yml | 8 ++++----
.github/workflows/default_release.yml | 2 +-
.github/workflows/release.yml | 2 +-
.github/workflows/upstream.yml | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml
index ff20d6f7..81533bf5 100644
--- a/.github/workflows/default.yml
+++ b/.github/workflows/default.yml
@@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
cache: false
- name: Lint
uses: golangci/golangci-lint-action@v4
@@ -53,7 +53,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
- name: Run unit tests
run: make test
@@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
- name: Check if Same Branch Exists in Fatmouse Repo
id: check-branch
uses: actions/github-script@v7
@@ -278,7 +278,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
diff --git a/.github/workflows/default_release.yml b/.github/workflows/default_release.yml
index f2177904..6553d9a4 100644
--- a/.github/workflows/default_release.yml
+++ b/.github/workflows/default_release.yml
@@ -33,7 +33,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 266ae010..49c2725b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -33,7 +33,7 @@ jobs:
- name: Set Up Go
uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml
index 905668e8..00a4582c 100644
--- a/.github/workflows/upstream.yml
+++ b/.github/workflows/upstream.yml
@@ -51,7 +51,7 @@ jobs:
run: make notify-upstream org_admin_token=${{steps.generate_token.outputs.token}} upstream_sha=${{ github.event.inputs.upstream-sha }} state=pending run_id=${{ github.run_id }}
- uses: actions/setup-go@v5
with:
- go-version: "1.19"
+ go-version: "1.23"
- name: Clone Fatmouse Repo
uses: actions/checkout@v4
with:
From 5967df4501de8d3b3723704875238cd3cc151937 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 12:21:52 +0200
Subject: [PATCH 05/26] SCALRCORE-26653 CI: bump golangci-lint
---
.github/workflows/default.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml
index 81533bf5..a1b496a4 100644
--- a/.github/workflows/default.yml
+++ b/.github/workflows/default.yml
@@ -32,9 +32,9 @@ jobs:
go-version: "1.23"
cache: false
- name: Lint
- uses: golangci/golangci-lint-action@v4
+ uses: golangci/golangci-lint-action@v6
with:
- version: v1.56.1
+ version: v1.62.0
args: --timeout 2m
- name: Validate Generated Code
run: |
From d67774e5b6662220748f49a55d5350324425cd01 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 12:27:01 +0200
Subject: [PATCH 06/26] SCALRCORE-26653 Remove deprecated rand.Seed calls
---
scalr/data_source_scalr_webhook_test.go | 2 --
scalr/helpers.go | 5 -----
2 files changed, 7 deletions(-)
diff --git a/scalr/data_source_scalr_webhook_test.go b/scalr/data_source_scalr_webhook_test.go
index adc2422b..b3d42628 100644
--- a/scalr/data_source_scalr_webhook_test.go
+++ b/scalr/data_source_scalr_webhook_test.go
@@ -6,13 +6,11 @@ import (
"regexp"
"strconv"
"testing"
- "time"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccWebhookDataSource_basic(t *testing.T) {
- rand.Seed(time.Now().UnixNano())
rInt := rand.Intn(100)
cutRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
diff --git a/scalr/helpers.go b/scalr/helpers.go
index e05a0eba..25d02b14 100644
--- a/scalr/helpers.go
+++ b/scalr/helpers.go
@@ -6,7 +6,6 @@ import (
"fmt"
"math/rand"
"os"
- "time"
"github.com/scalr/go-scalr"
)
@@ -16,10 +15,6 @@ const (
dummyIdentifier = "-"
)
-func init() {
- rand.Seed(time.Now().UnixNano())
-}
-
type GetEnvironmentByNameOptions struct {
Name *string
Account *string
From 8fbf26bd4d8d2f008d0f54bc78e9e46e4880b412 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 12:35:08 +0200
Subject: [PATCH 07/26] SCALRCORE-26653 Doc formatting
---
internal/provider/provider.go | 2 +-
scalr/provider.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
index bf6e39db..b302737a 100644
--- a/internal/provider/provider.go
+++ b/internal/provider/provider.go
@@ -51,7 +51,7 @@ func (p *scalrProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp
Description: fmt.Sprintf("The Scalr hostname to connect to. Defaults to %q."+
" Can be overridden by setting the %s environment variable.",
client.DefaultHostname, client.HostnameEnvVar),
- MarkdownDescription: fmt.Sprintf("The Scalr hostname to connect to. Defaults to %q."+
+ MarkdownDescription: fmt.Sprintf("The Scalr hostname to connect to. Defaults to `%s`."+
" Can be overridden by setting the `%s` environment variable.",
client.DefaultHostname, client.HostnameEnvVar),
Optional: true,
diff --git a/scalr/provider.go b/scalr/provider.go
index 0b34adda..a865aabb 100644
--- a/scalr/provider.go
+++ b/scalr/provider.go
@@ -18,7 +18,7 @@ func Provider() *schema.Provider {
"hostname": {
Type: schema.TypeString,
Optional: true,
- Description: fmt.Sprintf("The Scalr hostname to connect to. Defaults to %q."+
+ Description: fmt.Sprintf("The Scalr hostname to connect to. Defaults to `%s`."+
" Can be overridden by setting the `%s` environment variable.",
client.DefaultHostname, client.HostnameEnvVar),
DefaultFunc: schema.EnvDefaultFunc(client.HostnameEnvVar, client.DefaultHostname),
From f5660f71ea74777be364680d2c75966e95cc3b6b Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Mon, 18 Nov 2024 13:03:24 +0200
Subject: [PATCH 08/26] SCALRCORE-26653 Fix goveralls CI step
---
.github/workflows/default.yml | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml
index a1b496a4..62b3e428 100644
--- a/.github/workflows/default.yml
+++ b/.github/workflows/default.yml
@@ -190,9 +190,7 @@ jobs:
TEST_ARM_SUBSCRIPTION_ID: ${{ secrets.TEST_ARM_SUBSCRIPTION_ID }}
run: make testacc
- name: Install Goveralls
- env:
- GO111MODULE: off
- run: go get github.com/mattn/goveralls
+ run: go install github.com/mattn/goveralls@latest
- name: Send Coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
From 2225edd355931e005caffd907156c7e30c3aa95d Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 21 Nov 2024 17:01:03 +0200
Subject: [PATCH 09/26] SCALRCORE-26654 Move existing provider modules to
internal/provider package
---
.../data_source_scalr_access_policy.go | 2 +-
.../data_source_scalr_access_policy_test.go | 14 ++--
.../provider}/data_source_scalr_agent_pool.go | 5 +-
.../data_source_scalr_agent_pool_test.go | 28 ++++----
.../data_source_scalr_current_account.go | 5 +-
.../data_source_scalr_current_account_test.go | 12 ++--
.../data_source_scalr_current_run.go | 2 +-
.../data_source_scalr_current_run_test.go | 20 +++---
.../data_source_scalr_environment.go | 5 +-
.../data_source_scalr_environment_test.go | 22 ++++---
.../data_source_scalr_environments.go | 5 +-
.../data_source_scalr_environments_test.go | 8 ++-
...a_source_scalr_event_bridge_integration.go | 5 +-
...rce_scalr_event_bridge_integration_test.go | 8 ++-
.../provider}/data_source_scalr_iam_team.go | 3 +-
.../data_source_scalr_iam_team_test.go | 18 +++---
.../provider}/data_source_scalr_iam_user.go | 5 +-
.../data_source_scalr_iam_user_test.go | 28 ++++----
.../data_source_scalr_module_version.go | 2 +-
.../data_source_scalr_module_version_test.go | 18 +++---
.../data_source_scalr_module_versions.go | 2 +-
.../data_source_scalr_module_versions_test.go | 10 +--
.../data_source_scalr_policy_group.go | 5 +-
.../data_source_scalr_policy_group_test.go | 37 ++++++-----
...ata_source_scalr_provider_configuration.go | 2 +-
...ource_scalr_provider_configuration_test.go | 14 ++--
...ta_source_scalr_provider_configurations.go | 2 +-
...urce_scalr_provider_configurations_test.go | 10 +--
.../provider}/data_source_scalr_role.go | 5 +-
.../provider}/data_source_scalr_role_test.go | 18 +++---
.../data_source_scalr_service_account.go | 2 +-
.../data_source_scalr_service_account_test.go | 14 ++--
.../provider}/data_source_scalr_ssh_key.go | 2 +-
.../data_source_scalr_ssh_key_test.go | 21 +++---
.../provider}/data_source_scalr_tag.go | 5 +-
.../provider}/data_source_scalr_tag_test.go | 23 ++++---
.../provider}/data_source_scalr_variable.go | 2 +-
.../data_source_scalr_variable_test.go | 18 +++---
.../provider}/data_source_scalr_variables.go | 2 +-
.../data_source_scalr_variables_test.go | 18 +++---
.../data_source_scalr_vcs_provider.go | 3 +-
.../data_source_scalr_vcs_provider_test.go | 20 +++---
.../provider}/data_source_scalr_webhook.go | 5 +-
.../data_source_scalr_webhook_test.go | 16 +++--
.../provider}/data_source_scalr_workspace.go | 2 +-
.../data_source_scalr_workspace_ids.go | 3 +-
.../data_source_scalr_workspace_ids_test.go | 16 +++--
.../data_source_scalr_workspace_test.go | 14 ++--
.../provider}/data_source_scalr_workspaces.go | 5 +-
.../data_source_scalr_workspaces_test.go | 8 ++-
{scalr => internal/provider}/helpers.go | 2 +-
.../provider/provider_sdk.go | 2 +-
.../provider/provider_sdk_test.go | 2 +-
.../provider}/resource_scalr_access_policy.go | 2 +-
.../resource_scalr_access_policy_test.go | 40 ++++++------
.../resource_scalr_account_allowed_ips.go | 2 +-
...resource_scalr_account_allowed_ips_test.go | 24 +++----
.../provider}/resource_scalr_agent_pool.go | 5 +-
.../resource_scalr_agent_pool_test.go | 32 +++++-----
.../resource_scalr_agent_pool_token.go | 5 +-
.../resource_scalr_agent_pool_token_test.go | 30 +++++----
.../provider}/resource_scalr_environment.go | 5 +-
.../resource_scalr_environment_test.go | 32 +++++-----
...resource_scalr_event_bridge_integration.go | 2 +-
...rce_scalr_event_bridge_integration_test.go | 8 ++-
.../provider}/resource_scalr_iam_team.go | 5 +-
.../provider}/resource_scalr_iam_team_test.go | 32 +++++-----
.../provider}/resource_scalr_module.go | 5 +-
.../provider}/resource_scalr_module_test.go | 24 +++----
.../provider}/resource_scalr_policy_group.go | 5 +-
.../resource_scalr_policy_group_linkage.go | 5 +-
...esource_scalr_policy_group_linkage_test.go | 22 ++++---
.../resource_scalr_policy_group_test.go | 36 ++++++-----
.../resource_scalr_provider_configuration.go | 2 +-
...ce_scalr_provider_configuration_default.go | 5 +-
...alr_provider_configuration_default_test.go | 20 +++---
...ource_scalr_provider_configuration_test.go | 47 +++++++-------
.../provider}/resource_scalr_role.go | 5 +-
.../provider}/resource_scalr_role_migrate.go | 2 +-
.../resource_scalr_role_migrate_test.go | 10 +--
.../provider}/resource_scalr_role_test.go | 32 +++++-----
.../resource_scalr_run_schedule_rule.go | 5 +-
.../resource_scalr_run_schedule_rule_test.go | 24 +++----
.../provider}/resource_scalr_run_triggers.go | 5 +-
.../resource_scalr_run_triggers_test.go | 22 ++++---
.../resource_scalr_service_account.go | 2 +-
.../resource_scalr_service_account_test.go | 20 +++---
.../resource_scalr_service_account_token.go | 5 +-
...source_scalr_service_account_token_test.go | 16 +++--
.../resource_scalr_slack_integration.go | 2 +-
.../resource_scalr_slack_integration_test.go | 10 +--
.../provider}/resource_scalr_ssh_key.go | 3 +-
.../provider}/resource_scalr_ssh_key_test.go | 20 +++---
.../provider}/resource_scalr_tag.go | 5 +-
.../provider}/resource_scalr_tag_test.go | 37 ++++++-----
.../provider}/resource_scalr_variable.go | 5 +-
.../resource_scalr_variable_migrate.go | 2 +-
.../resource_scalr_variable_migrate_test.go | 10 +--
.../provider}/resource_scalr_variable_test.go | 32 +++++-----
.../provider}/resource_scalr_vcs_provider.go | 5 +-
.../resource_scalr_vcs_provider_migrate.go | 2 +-
...esource_scalr_vcs_provider_migrate_test.go | 6 +-
.../resource_scalr_vcs_provider_test.go | 36 ++++++-----
.../provider}/resource_scalr_webhook.go | 2 +-
.../resource_scalr_webhook_migrate.go | 2 +-
.../provider}/resource_scalr_webhook_test.go | 12 ++--
.../provider}/resource_scalr_workspace.go | 2 +-
.../resource_scalr_workspace_migrate.go | 2 +-
.../resource_scalr_workspace_migrate_test.go | 17 +++--
.../resource_scalr_workspace_run_schedule.go | 5 +-
...ource_scalr_workspace_run_schedule_test.go | 15 +++--
.../resource_scalr_workspace_test.go | 64 ++++++++++---------
{scalr => internal/provider}/testing.go | 2 +-
.../provider}/workspace_helpers.go | 2 +-
.../provider}/workspace_helpers_test.go | 6 +-
main.go | 3 +-
116 files changed, 760 insertions(+), 617 deletions(-)
rename {scalr => internal/provider}/data_source_scalr_access_policy.go (99%)
rename {scalr => internal/provider}/data_source_scalr_access_policy_test.go (84%)
rename {scalr => internal/provider}/data_source_scalr_agent_pool.go (99%)
rename {scalr => internal/provider}/data_source_scalr_agent_pool_test.go (87%)
rename {scalr => internal/provider}/data_source_scalr_current_account.go (98%)
rename {scalr => internal/provider}/data_source_scalr_current_account_test.go (73%)
rename {scalr => internal/provider}/data_source_scalr_current_run.go (99%)
rename {scalr => internal/provider}/data_source_scalr_current_run_test.go (77%)
rename {scalr => internal/provider}/data_source_scalr_environment.go (99%)
rename {scalr => internal/provider}/data_source_scalr_environment_test.go (92%)
rename {scalr => internal/provider}/data_source_scalr_environments.go (99%)
rename {scalr => internal/provider}/data_source_scalr_environments_test.go (91%)
rename {scalr => internal/provider}/data_source_scalr_event_bridge_integration.go (99%)
rename {scalr => internal/provider}/data_source_scalr_event_bridge_integration_test.go (95%)
rename {scalr => internal/provider}/data_source_scalr_iam_team.go (99%)
rename {scalr => internal/provider}/data_source_scalr_iam_team_test.go (88%)
rename {scalr => internal/provider}/data_source_scalr_iam_user.go (99%)
rename {scalr => internal/provider}/data_source_scalr_iam_user_test.go (82%)
rename {scalr => internal/provider}/data_source_scalr_module_version.go (99%)
rename {scalr => internal/provider}/data_source_scalr_module_version_test.go (85%)
rename {scalr => internal/provider}/data_source_scalr_module_versions.go (99%)
rename {scalr => internal/provider}/data_source_scalr_module_versions_test.go (96%)
rename {scalr => internal/provider}/data_source_scalr_policy_group.go (99%)
rename {scalr => internal/provider}/data_source_scalr_policy_group_test.go (82%)
rename {scalr => internal/provider}/data_source_scalr_provider_configuration.go (99%)
rename {scalr => internal/provider}/data_source_scalr_provider_configuration_test.go (90%)
rename {scalr => internal/provider}/data_source_scalr_provider_configurations.go (99%)
rename {scalr => internal/provider}/data_source_scalr_provider_configurations_test.go (95%)
rename {scalr => internal/provider}/data_source_scalr_role.go (99%)
rename {scalr => internal/provider}/data_source_scalr_role_test.go (93%)
rename {scalr => internal/provider}/data_source_scalr_service_account.go (99%)
rename {scalr => internal/provider}/data_source_scalr_service_account_test.go (91%)
rename {scalr => internal/provider}/data_source_scalr_ssh_key.go (99%)
rename {scalr => internal/provider}/data_source_scalr_ssh_key_test.go (89%)
rename {scalr => internal/provider}/data_source_scalr_tag.go (99%)
rename {scalr => internal/provider}/data_source_scalr_tag_test.go (87%)
rename {scalr => internal/provider}/data_source_scalr_variable.go (99%)
rename {scalr => internal/provider}/data_source_scalr_variable_test.go (94%)
rename {scalr => internal/provider}/data_source_scalr_variables.go (99%)
rename {scalr => internal/provider}/data_source_scalr_variables_test.go (92%)
rename {scalr => internal/provider}/data_source_scalr_vcs_provider.go (99%)
rename {scalr => internal/provider}/data_source_scalr_vcs_provider_test.go (87%)
rename {scalr => internal/provider}/data_source_scalr_webhook.go (99%)
rename {scalr => internal/provider}/data_source_scalr_webhook_test.go (93%)
rename {scalr => internal/provider}/data_source_scalr_workspace.go (99%)
rename {scalr => internal/provider}/data_source_scalr_workspace_ids.go (99%)
rename {scalr => internal/provider}/data_source_scalr_workspace_ids_test.go (91%)
rename {scalr => internal/provider}/data_source_scalr_workspace_test.go (95%)
rename {scalr => internal/provider}/data_source_scalr_workspaces.go (99%)
rename {scalr => internal/provider}/data_source_scalr_workspaces_test.go (92%)
rename {scalr => internal/provider}/helpers.go (99%)
rename scalr/provider.go => internal/provider/provider_sdk.go (99%)
rename scalr/provider_test.go => internal/provider/provider_sdk_test.go (98%)
rename {scalr => internal/provider}/resource_scalr_access_policy.go (99%)
rename {scalr => internal/provider}/resource_scalr_access_policy_test.go (88%)
rename {scalr => internal/provider}/resource_scalr_account_allowed_ips.go (99%)
rename {scalr => internal/provider}/resource_scalr_account_allowed_ips_test.go (83%)
rename {scalr => internal/provider}/resource_scalr_agent_pool.go (99%)
rename {scalr => internal/provider}/resource_scalr_agent_pool_test.go (85%)
rename {scalr => internal/provider}/resource_scalr_agent_pool_token.go (99%)
rename {scalr => internal/provider}/resource_scalr_agent_pool_token_test.go (86%)
rename {scalr => internal/provider}/resource_scalr_environment.go (99%)
rename {scalr => internal/provider}/resource_scalr_environment_test.go (91%)
rename {scalr => internal/provider}/resource_scalr_event_bridge_integration.go (99%)
rename {scalr => internal/provider}/resource_scalr_event_bridge_integration_test.go (89%)
rename {scalr => internal/provider}/resource_scalr_iam_team.go (99%)
rename {scalr => internal/provider}/resource_scalr_iam_team_test.go (87%)
rename {scalr => internal/provider}/resource_scalr_module.go (99%)
rename {scalr => internal/provider}/resource_scalr_module_test.go (87%)
rename {scalr => internal/provider}/resource_scalr_policy_group.go (99%)
rename {scalr => internal/provider}/resource_scalr_policy_group_linkage.go (99%)
rename {scalr => internal/provider}/resource_scalr_policy_group_linkage_test.go (83%)
rename {scalr => internal/provider}/resource_scalr_policy_group_test.go (90%)
rename {scalr => internal/provider}/resource_scalr_provider_configuration.go (99%)
rename {scalr => internal/provider}/resource_scalr_provider_configuration_default.go (99%)
rename {scalr => internal/provider}/resource_scalr_provider_configuration_default_test.go (85%)
rename {scalr => internal/provider}/resource_scalr_provider_configuration_test.go (97%)
rename {scalr => internal/provider}/resource_scalr_role.go (99%)
rename {scalr => internal/provider}/resource_scalr_role_migrate.go (98%)
rename {scalr => internal/provider}/resource_scalr_role_migrate_test.go (81%)
rename {scalr => internal/provider}/resource_scalr_role_test.go (88%)
rename {scalr => internal/provider}/resource_scalr_run_schedule_rule.go (99%)
rename {scalr => internal/provider}/resource_scalr_run_schedule_rule_test.go (85%)
rename {scalr => internal/provider}/resource_scalr_run_triggers.go (99%)
rename {scalr => internal/provider}/resource_scalr_run_triggers_test.go (80%)
rename {scalr => internal/provider}/resource_scalr_service_account.go (99%)
rename {scalr => internal/provider}/resource_scalr_service_account_test.go (87%)
rename {scalr => internal/provider}/resource_scalr_service_account_token.go (99%)
rename {scalr => internal/provider}/resource_scalr_service_account_token_test.go (85%)
rename {scalr => internal/provider}/resource_scalr_slack_integration.go (99%)
rename {scalr => internal/provider}/resource_scalr_slack_integration_test.go (94%)
rename {scalr => internal/provider}/resource_scalr_ssh_key.go (99%)
rename {scalr => internal/provider}/resource_scalr_ssh_key_test.go (87%)
rename {scalr => internal/provider}/resource_scalr_tag.go (99%)
rename {scalr => internal/provider}/resource_scalr_tag_test.go (83%)
rename {scalr => internal/provider}/resource_scalr_variable.go (99%)
rename {scalr => internal/provider}/resource_scalr_variable_migrate.go (99%)
rename {scalr => internal/provider}/resource_scalr_variable_migrate_test.go (80%)
rename {scalr => internal/provider}/resource_scalr_variable_test.go (93%)
rename {scalr => internal/provider}/resource_scalr_vcs_provider.go (99%)
rename {scalr => internal/provider}/resource_scalr_vcs_provider_migrate.go (98%)
rename {scalr => internal/provider}/resource_scalr_vcs_provider_migrate_test.go (76%)
rename {scalr => internal/provider}/resource_scalr_vcs_provider_test.go (81%)
rename {scalr => internal/provider}/resource_scalr_webhook.go (99%)
rename {scalr => internal/provider}/resource_scalr_webhook_migrate.go (99%)
rename {scalr => internal/provider}/resource_scalr_webhook_test.go (90%)
rename {scalr => internal/provider}/resource_scalr_workspace.go (99%)
rename {scalr => internal/provider}/resource_scalr_workspace_migrate.go (99%)
rename {scalr => internal/provider}/resource_scalr_workspace_migrate_test.go (81%)
rename {scalr => internal/provider}/resource_scalr_workspace_run_schedule.go (99%)
rename {scalr => internal/provider}/resource_scalr_workspace_run_schedule_test.go (88%)
rename {scalr => internal/provider}/resource_scalr_workspace_test.go (94%)
rename {scalr => internal/provider}/testing.go (98%)
rename {scalr => internal/provider}/workspace_helpers.go (98%)
rename {scalr => internal/provider}/workspace_helpers_test.go (92%)
diff --git a/scalr/data_source_scalr_access_policy.go b/internal/provider/data_source_scalr_access_policy.go
similarity index 99%
rename from scalr/data_source_scalr_access_policy.go
rename to internal/provider/data_source_scalr_access_policy.go
index bc16fd44..c90ebe5b 100644
--- a/scalr/data_source_scalr_access_policy.go
+++ b/internal/provider/data_source_scalr_access_policy.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_access_policy_test.go b/internal/provider/data_source_scalr_access_policy_test.go
similarity index 84%
rename from scalr/data_source_scalr_access_policy_test.go
rename to internal/provider/data_source_scalr_access_policy_test.go
index f088bf8c..183d7e9c 100644
--- a/scalr/data_source_scalr_access_policy_test.go
+++ b/internal/provider/data_source_scalr_access_policy_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,22 +6,24 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAccessPolicyDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyDataSourceConfig(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_access_policy.test", "id"),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "subject.0.type", "user"),
- resource.TestCheckResourceAttr("data.scalr_access_policy.test", "subject.0.id", testUser),
+ resource.TestCheckResourceAttr("data.scalr_access_policy.test", "subject.0.id", scalr.testUser),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "is_system", "false"),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "scope.0.type", "environment"),
- resource.TestCheckResourceAttr("data.scalr_access_policy.test", "role_ids.0", readOnlyRole),
+ resource.TestCheckResourceAttr("data.scalr_access_policy.test", "role_ids.0", scalr.readOnlyRole),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "role_ids.#", "1"),
),
},
@@ -57,7 +59,7 @@ resource "scalr_access_policy" "test" {
data "scalr_access_policy" "test" {
id = scalr_access_policy.test.id
-}`, defaultAccount, testUser, readOnlyRole)
+}`, scalr.defaultAccount, scalr.testUser, scalr.readOnlyRole)
}
func testAccAccessPolicyDataSourceNotFoundConfig() string {
diff --git a/scalr/data_source_scalr_agent_pool.go b/internal/provider/data_source_scalr_agent_pool.go
similarity index 99%
rename from scalr/data_source_scalr_agent_pool.go
rename to internal/provider/data_source_scalr_agent_pool.go
index e1f8cbaa..6960b45d 100644
--- a/scalr/data_source_scalr_agent_pool.go
+++ b/internal/provider/data_source_scalr_agent_pool.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_agent_pool_test.go b/internal/provider/data_source_scalr_agent_pool_test.go
similarity index 87%
rename from scalr/data_source_scalr_agent_pool_test.go
rename to internal/provider/data_source_scalr_agent_pool_test.go
index 532e9d3e..e1e8ca9b 100644
--- a/scalr/data_source_scalr_agent_pool_test.go
+++ b/internal/provider/data_source_scalr_agent_pool_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,12 +6,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_agent_pool test {}`,
@@ -34,7 +36,7 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "ds-agent_pool-test-acc"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
),
},
{
@@ -43,7 +45,7 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "ds-agent_pool-test-acc"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
),
},
{
@@ -52,7 +54,7 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "ds-agent_pool-test-acc"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
),
},
},
@@ -60,8 +62,8 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
}
func TestAccScalrAgentPoolDataSource_basic_env(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolEnvDataSourceConfig(),
@@ -69,7 +71,7 @@ func TestAccScalrAgentPoolDataSource_basic_env(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "agent_pool-test-env-ds"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
),
},
},
@@ -85,7 +87,7 @@ resource "scalr_agent_pool" "test" {
data "scalr_agent_pool" "test" {
id = scalr_agent_pool.test.id
account_id = scalr_agent_pool.test.account_id
-}`, defaultAccount)
+}`, scalr.defaultAccount)
var testAccScalrAgentPoolAccountDataSourceByNameConfig = fmt.Sprintf(`
resource "scalr_agent_pool" "test" {
@@ -96,7 +98,7 @@ resource "scalr_agent_pool" "test" {
data "scalr_agent_pool" "test" {
name = scalr_agent_pool.test.name
account_id = scalr_agent_pool.test.account_id
-}`, defaultAccount)
+}`, scalr.defaultAccount)
var testAccScalrAgentPoolAccountDataSourceByIDAndNameConfig = fmt.Sprintf(`
resource "scalr_agent_pool" "test" {
@@ -108,7 +110,7 @@ data "scalr_agent_pool" "test" {
id = scalr_agent_pool.test.id
name = scalr_agent_pool.test.name
account_id = scalr_agent_pool.test.account_id
-}`, defaultAccount)
+}`, scalr.defaultAccount)
func testAccScalrAgentPoolEnvDataSourceConfig() string {
return fmt.Sprintf(`
@@ -127,5 +129,5 @@ data "scalr_agent_pool" "test" {
name = scalr_agent_pool.test.name
account_id = scalr_agent_pool.test.account_id
environment_id = scalr_environment.test.id
-}`, defaultAccount, defaultAccount)
+}`, scalr.defaultAccount, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_current_account.go b/internal/provider/data_source_scalr_current_account.go
similarity index 98%
rename from scalr/data_source_scalr_current_account.go
rename to internal/provider/data_source_scalr_current_account.go
index 604e8b0f..fdf2f28b 100644
--- a/scalr/data_source_scalr_current_account.go
+++ b/internal/provider/data_source_scalr_current_account.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"errors"
+ "log"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
- "log"
)
func dataSourceScalrCurrentAccount() *schema.Resource {
diff --git a/scalr/data_source_scalr_current_account_test.go b/internal/provider/data_source_scalr_current_account_test.go
similarity index 73%
rename from scalr/data_source_scalr_current_account_test.go
rename to internal/provider/data_source_scalr_current_account_test.go
index 04fb4a88..1f607cee 100644
--- a/scalr/data_source_scalr_current_account_test.go
+++ b/internal/provider/data_source_scalr_current_account_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"os"
@@ -6,12 +6,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccCurrentAccount_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{
{
@@ -24,13 +26,13 @@ func TestAccCurrentAccount_basic(t *testing.T) {
},
{
PreConfig: func() {
- _ = os.Setenv(currentAccountIDEnvVar, defaultAccount)
+ _ = os.Setenv(currentAccountIDEnvVar, scalr.defaultAccount)
},
Config: testAccCurrentAccountDataSourceConfig(),
PlanOnly: true,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(
- "data.scalr_current_account.test", "id", defaultAccount),
+ "data.scalr_current_account.test", "id", scalr.defaultAccount),
resource.TestCheckResourceAttr(
"data.scalr_current_account.test", "name", "mainiacp"),
),
diff --git a/scalr/data_source_scalr_current_run.go b/internal/provider/data_source_scalr_current_run.go
similarity index 99%
rename from scalr/data_source_scalr_current_run.go
rename to internal/provider/data_source_scalr_current_run.go
index 31ae7a5c..127f820a 100644
--- a/scalr/data_source_scalr_current_run.go
+++ b/internal/provider/data_source_scalr_current_run.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_current_run_test.go b/internal/provider/data_source_scalr_current_run_test.go
similarity index 77%
rename from scalr/data_source_scalr_current_run_test.go
rename to internal/provider/data_source_scalr_current_run_test.go
index 08ad365b..a3b17179 100644
--- a/scalr/data_source_scalr_current_run_test.go
+++ b/internal/provider/data_source_scalr_current_run_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -8,14 +8,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccCurrentRun_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{
{
@@ -46,23 +48,23 @@ func TestAccCurrentRun_basic(t *testing.T) {
func launchRun(environmentName, workspaceName string) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
options := GetEnvironmentByNameOptions{
Name: &environmentName,
}
- env, err := GetEnvironmentByName(ctx, options, scalrClient)
+ env, err := GetEnvironmentByName(scalr2.ctx, options, scalrClient)
if err != nil {
log.Fatalf("Got error during environment fetching: %v", err)
return
}
- ws, err := scalrClient.Workspaces.Read(ctx, env.ID, workspaceName)
+ ws, err := scalrClient.Workspaces.Read(scalr2.ctx, env.ID, workspaceName)
if err != nil {
log.Fatalf("Error retrieving workspace: %v", err)
}
- cv, err := scalrClient.ConfigurationVersions.Create(ctx, scalr.ConfigurationVersionCreateOptions{
+ cv, err := scalrClient.ConfigurationVersions.Create(scalr2.ctx, scalr.ConfigurationVersionCreateOptions{
Workspace: &scalr.Workspace{
ID: ws.ID,
},
@@ -72,7 +74,7 @@ func launchRun(environmentName, workspaceName string) func() {
log.Fatalf("Error creating cv: %v", cv)
}
- run, err := scalrClient.Runs.Create(ctx, scalr.RunCreateOptions{
+ run, err := scalrClient.Runs.Create(scalr2.ctx, scalr.RunCreateOptions{
Workspace: &scalr.Workspace{
ID: ws.ID,
},
@@ -100,7 +102,7 @@ resource scalr_workspace test {
name = "test-ws-%[1]d"
environment_id = scalr_environment.test.id
}
-`, rInt, defaultAccount)
+`, rInt, scalr2.defaultAccount)
}
func testAccCurrentRunDataSourceConfig(rInt int) string {
diff --git a/scalr/data_source_scalr_environment.go b/internal/provider/data_source_scalr_environment.go
similarity index 99%
rename from scalr/data_source_scalr_environment.go
rename to internal/provider/data_source_scalr_environment.go
index 67e5252c..2074d150 100644
--- a/scalr/data_source_scalr_environment.go
+++ b/internal/provider/data_source_scalr_environment.go
@@ -1,10 +1,11 @@
-package scalr
+package provider
import (
"context"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_environment_test.go b/internal/provider/data_source_scalr_environment_test.go
similarity index 92%
rename from scalr/data_source_scalr_environment_test.go
rename to internal/provider/data_source_scalr_environment_test.go
index 77fe60c7..789a1357 100644
--- a/scalr/data_source_scalr_environment_test.go
+++ b/internal/provider/data_source_scalr_environment_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccEnvironmentDataSource_basic(t *testing.T) {
@@ -21,8 +23,8 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
cuttedRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_environment test {}`,
@@ -45,7 +47,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
- resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttr("data.scalr_environment.test", "tags.#", "0"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
@@ -59,7 +61,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
- resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.username"),
@@ -71,7 +73,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
- resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.username"),
@@ -105,7 +107,7 @@ resource "scalr_environment" "test" {
data "scalr_environment" "test" {
id = scalr_environment.test.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccEnvironmentDataSourceAccessByNameConfig(rInt int) string {
@@ -118,7 +120,7 @@ resource "scalr_environment" "test" {
data "scalr_environment" "test" {
name = scalr_environment.test.name
account_id = "%s"
-}`, rInt, defaultAccount, defaultAccount)
+}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
}
func testAccEnvironmentDataSourceAccessByIDAndNameConfig(rInt int) string {
@@ -132,7 +134,7 @@ data "scalr_environment" "test" {
id = scalr_environment.test.id
name = scalr_environment.test.name
account_id = "%s"
-}`, rInt, defaultAccount, defaultAccount)
+}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
}
func testAccEnvironmentDataSourceNotFoundConfig() string {
@@ -158,5 +160,5 @@ resource "scalr_environment" "test" {
data "scalr_environment" "test" {
name = "test-env-%s"
-}`, rInt, defaultAccount, cuttedRInt)
+}`, rInt, scalr.defaultAccount, cuttedRInt)
}
diff --git a/scalr/data_source_scalr_environments.go b/internal/provider/data_source_scalr_environments.go
similarity index 99%
rename from scalr/data_source_scalr_environments.go
rename to internal/provider/data_source_scalr_environments.go
index e34a2f59..e8707c51 100644
--- a/scalr/data_source_scalr_environments.go
+++ b/internal/provider/data_source_scalr_environments.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"fmt"
+ "strings"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
- "strings"
)
func dataSourceScalrEnvironments() *schema.Resource {
diff --git a/scalr/data_source_scalr_environments_test.go b/internal/provider/data_source_scalr_environments_test.go
similarity index 91%
rename from scalr/data_source_scalr_environments_test.go
rename to internal/provider/data_source_scalr_environments_test.go
index 7bb24520..4a627f23 100644
--- a/scalr/data_source_scalr_environments_test.go
+++ b/internal/provider/data_source_scalr_environments_test.go
@@ -1,18 +1,20 @@
-package scalr
+package provider
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrEnvironmentsDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrEnvironmentsDataSourceConfigBasic(rInt),
diff --git a/scalr/data_source_scalr_event_bridge_integration.go b/internal/provider/data_source_scalr_event_bridge_integration.go
similarity index 99%
rename from scalr/data_source_scalr_event_bridge_integration.go
rename to internal/provider/data_source_scalr_event_bridge_integration.go
index 8e40e3f6..b049c0ec 100644
--- a/scalr/data_source_scalr_event_bridge_integration.go
+++ b/internal/provider/data_source_scalr_event_bridge_integration.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_event_bridge_integration_test.go b/internal/provider/data_source_scalr_event_bridge_integration_test.go
similarity index 95%
rename from scalr/data_source_scalr_event_bridge_integration_test.go
rename to internal/provider/data_source_scalr_event_bridge_integration_test.go
index 728e7ece..8f6aa280 100644
--- a/scalr/data_source_scalr_event_bridge_integration_test.go
+++ b/internal/provider/data_source_scalr_event_bridge_integration_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrEventBridgeIntegrationDataSource_basic(t *testing.T) {
@@ -16,8 +18,8 @@ func TestAccScalrEventBridgeIntegrationDataSource_basic(t *testing.T) {
t.Skip("Please set AWS_EVENT_BRIDGE_ACCOUNT_ID, AWS_EVENT_BRIDGE_REGION env variables to run this test.")
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_event_bridge test {}`,
diff --git a/scalr/data_source_scalr_iam_team.go b/internal/provider/data_source_scalr_iam_team.go
similarity index 99%
rename from scalr/data_source_scalr_iam_team.go
rename to internal/provider/data_source_scalr_iam_team.go
index 7823e823..20e1537a 100644
--- a/scalr/data_source_scalr_iam_team.go
+++ b/internal/provider/data_source_scalr_iam_team.go
@@ -1,7 +1,8 @@
-package scalr
+package provider
import (
"context"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
diff --git a/scalr/data_source_scalr_iam_team_test.go b/internal/provider/data_source_scalr_iam_team_test.go
similarity index 88%
rename from scalr/data_source_scalr_iam_team_test.go
rename to internal/provider/data_source_scalr_iam_team_test.go
index c25e7711..a2dc2c96 100644
--- a/scalr/data_source_scalr_iam_team_test.go
+++ b/internal/provider/data_source_scalr_iam_team_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,14 +6,16 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrIamTeamDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_iam_team test {}`,
@@ -40,9 +42,9 @@ func TestAccScalrIamTeamDataSource_basic(t *testing.T) {
fmt.Sprintf("test-team-%d", rInt),
),
resource.TestCheckResourceAttr("data.scalr_iam_team.test", "description", ""),
- resource.TestCheckResourceAttr("data.scalr_iam_team.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_iam_team.test", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_iam_team.test", "identity_provider_id"),
- resource.TestCheckResourceAttr("data.scalr_iam_team.test", "users.0", testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_team.test", "users.0", scalr.testUser),
),
},
{
@@ -82,7 +84,7 @@ resource "scalr_iam_team" "test" {
data "scalr_iam_team" "test" {
id = scalr_iam_team.test.id
account_id = scalr_iam_team.test.account_id
-}`, rInt, defaultAccount, testUser)
+}`, rInt, scalr.defaultAccount, scalr.testUser)
}
func testAccScalrIamTeamDataSourceByNameConfig(rInt int) string {
@@ -96,7 +98,7 @@ resource "scalr_iam_team" "test" {
data "scalr_iam_team" "test" {
name = scalr_iam_team.test.name
account_id = scalr_iam_team.test.account_id
-}`, rInt, defaultAccount, testUser)
+}`, rInt, scalr.defaultAccount, scalr.testUser)
}
func testAccScalrIamTeamDataSourceByIDAndNameConfig(rInt int) string {
@@ -111,5 +113,5 @@ data "scalr_iam_team" "test" {
id = scalr_iam_team.test.id
name = scalr_iam_team.test.name
account_id = scalr_iam_team.test.account_id
-}`, rInt, defaultAccount, testUser)
+}`, rInt, scalr.defaultAccount, scalr.testUser)
}
diff --git a/scalr/data_source_scalr_iam_user.go b/internal/provider/data_source_scalr_iam_user.go
similarity index 99%
rename from scalr/data_source_scalr_iam_user.go
rename to internal/provider/data_source_scalr_iam_user.go
index 61c69509..e86b5471 100644
--- a/scalr/data_source_scalr_iam_user.go
+++ b/internal/provider/data_source_scalr_iam_user.go
@@ -1,10 +1,11 @@
-package scalr
+package provider
import (
"context"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_iam_user_test.go b/internal/provider/data_source_scalr_iam_user_test.go
similarity index 82%
rename from scalr/data_source_scalr_iam_user_test.go
rename to internal/provider/data_source_scalr_iam_user_test.go
index 509eb218..14af9f9c 100644
--- a/scalr/data_source_scalr_iam_user_test.go
+++ b/internal/provider/data_source_scalr_iam_user_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,12 +7,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrIamUserDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_iam_user test {}`,
@@ -32,14 +34,14 @@ func TestAccScalrIamUserDataSource_basic(t *testing.T) {
{
Config: testAccScalrIamUserDataSourceByIDConfig,
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", scalr2.testUser),
resource.TestCheckResourceAttr(
"data.scalr_iam_user.test",
"status",
string(scalr.UserStatusActive),
),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", testUserEmail),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "username", testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", scalr2.testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "username", scalr2.testUserEmail),
resource.TestCheckResourceAttrSet("data.scalr_iam_user.test", "full_name"),
resource.TestCheckResourceAttrSet("data.scalr_iam_user.test", "teams.0"),
),
@@ -47,15 +49,15 @@ func TestAccScalrIamUserDataSource_basic(t *testing.T) {
{
Config: testAccScalrIamUserDataSourceByEmailConfig,
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", testUser),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", scalr2.testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", scalr2.testUserEmail),
),
},
{
Config: testAccScalrIamUserDataSourceByIDAndEmailConfig,
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", testUser),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", scalr2.testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", scalr2.testUserEmail),
),
},
},
@@ -65,15 +67,15 @@ func TestAccScalrIamUserDataSource_basic(t *testing.T) {
var testAccScalrIamUserDataSourceByIDConfig = fmt.Sprintf(`
data "scalr_iam_user" "test" {
id = "%s"
-}`, testUser)
+}`, scalr2.testUser)
var testAccScalrIamUserDataSourceByEmailConfig = fmt.Sprintf(`
data "scalr_iam_user" "test" {
email = "%s"
-}`, testUserEmail)
+}`, scalr2.testUserEmail)
var testAccScalrIamUserDataSourceByIDAndEmailConfig = fmt.Sprintf(`
data "scalr_iam_user" "test" {
id = "%s"
email = "%s"
-}`, testUser, testUserEmail)
+}`, scalr2.testUser, scalr2.testUserEmail)
diff --git a/scalr/data_source_scalr_module_version.go b/internal/provider/data_source_scalr_module_version.go
similarity index 99%
rename from scalr/data_source_scalr_module_version.go
rename to internal/provider/data_source_scalr_module_version.go
index bc5c7cd3..0e3a95f3 100644
--- a/scalr/data_source_scalr_module_version.go
+++ b/internal/provider/data_source_scalr_module_version.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_module_version_test.go b/internal/provider/data_source_scalr_module_version_test.go
similarity index 85%
rename from scalr/data_source_scalr_module_version_test.go
rename to internal/provider/data_source_scalr_module_version_test.go
index d6857663..f6453616 100644
--- a/scalr/data_source_scalr_module_version_test.go
+++ b/internal/provider/data_source_scalr_module_version_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -8,6 +8,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccModuleVersionDataSource_basic(t *testing.T) {
@@ -15,9 +17,9 @@ func TestAccModuleVersionDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountModule(rInt),
@@ -55,19 +57,19 @@ func TestAccModuleVersionDataSource_basic(t *testing.T) {
func waitForModuleVersions(environmentName string) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
options := GetEnvironmentByNameOptions{
Name: &environmentName,
}
- env, err := GetEnvironmentByName(ctx, options, scalrClient)
+ env, err := GetEnvironmentByName(scalr2.ctx, options, scalrClient)
if err != nil {
log.Fatalf("Got error during environment fetching: %v", err)
return
}
- ml, err := scalrClient.Modules.List(ctx, scalr.ModuleListOptions{Environment: &env.ID})
+ ml, err := scalrClient.Modules.List(scalr2.ctx, scalr.ModuleListOptions{Environment: &env.ID})
if len(ml.Items) == 0 {
log.Fatalf("The test module for environment with name %s was not created: %v", environmentName, err)
@@ -75,7 +77,7 @@ func waitForModuleVersions(environmentName string) func() {
var mID = ml.Items[0].ID
for i := 0; i < 60; i++ {
- m, err := scalrClient.Modules.Read(ctx, mID)
+ m, err := scalrClient.Modules.Read(scalr2.ctx, mID)
if err != nil {
log.Fatalf("Error polling module %s: %v", mID, err)
}
@@ -116,7 +118,7 @@ func testAccScalrAccountModule(rInt int) string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, defaultAccount, rInt, string(scalr.Github), githubToken)
+`, scalr2.defaultAccount, rInt, string(scalr.Github), scalr2.githubToken)
}
func testAccModuleVersionDataSourceConfig(rInt int) string {
diff --git a/scalr/data_source_scalr_module_versions.go b/internal/provider/data_source_scalr_module_versions.go
similarity index 99%
rename from scalr/data_source_scalr_module_versions.go
rename to internal/provider/data_source_scalr_module_versions.go
index 1a279631..5d5b8d97 100644
--- a/scalr/data_source_scalr_module_versions.go
+++ b/internal/provider/data_source_scalr_module_versions.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_module_versions_test.go b/internal/provider/data_source_scalr_module_versions_test.go
similarity index 96%
rename from scalr/data_source_scalr_module_versions_test.go
rename to internal/provider/data_source_scalr_module_versions_test.go
index ba418c84..a2ef3714 100644
--- a/scalr/data_source_scalr_module_versions_test.go
+++ b/internal/provider/data_source_scalr_module_versions_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccModuleVersionsDataSource_basic(t *testing.T) {
@@ -14,9 +16,9 @@ func TestAccModuleVersionsDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_module_versions all_by_none {}`,
@@ -125,7 +127,7 @@ func testAccModuleVersionsReourceConfig(rInt int) string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, defaultAccount, rInt, string(scalr.Github), githubToken)
+`, scalr2.defaultAccount, rInt, string(scalr.Github), scalr2.githubToken)
}
func testAccModuleVersionsDataSourceConfig(rInt int) string {
diff --git a/scalr/data_source_scalr_policy_group.go b/internal/provider/data_source_scalr_policy_group.go
similarity index 99%
rename from scalr/data_source_scalr_policy_group.go
rename to internal/provider/data_source_scalr_policy_group.go
index ee157e36..02c9c67f 100644
--- a/scalr/data_source_scalr_policy_group.go
+++ b/internal/provider/data_source_scalr_policy_group.go
@@ -1,10 +1,11 @@
-package scalr
+package provider
import (
"context"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_policy_group_test.go b/internal/provider/data_source_scalr_policy_group_test.go
similarity index 82%
rename from scalr/data_source_scalr_policy_group_test.go
rename to internal/provider/data_source_scalr_policy_group_test.go
index aa671f21..383e6d0f 100644
--- a/scalr/data_source_scalr_policy_group_test.go
+++ b/internal/provider/data_source_scalr_policy_group_test.go
@@ -1,13 +1,16 @@
-package scalr
+package provider
import (
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/scalr/go-scalr"
"log"
"regexp"
"testing"
"time"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccPolicyGroupDataSource_basic(t *testing.T) {
@@ -17,9 +20,9 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupConfig(rInt),
@@ -66,18 +69,18 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_policy_group.test",
"account_id",
- defaultAccount,
+ scalr2.defaultAccount,
),
resource.TestCheckResourceAttrSet("data.scalr_policy_group.test", "vcs_provider_id"),
resource.TestCheckResourceAttr(
"data.scalr_policy_group.test",
"vcs_repo.0.identifier",
- policyGroupVcsRepoID,
+ scalr2.policyGroupVcsRepoID,
),
resource.TestCheckResourceAttr(
"data.scalr_policy_group.test",
"vcs_repo.0.path",
- policyGroupVcsRepoPath,
+ scalr2.policyGroupVcsRepoPath,
),
resource.TestCheckResourceAttrSet("data.scalr_policy_group.test", "vcs_repo.0.branch"),
resource.TestCheckResourceAttrSet("data.scalr_policy_group.test", "policies.#"),
@@ -90,9 +93,9 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
name = "not-exists"
account_id = "%s"
}
- `, defaultAccount),
+ `, scalr2.defaultAccount),
ExpectError: regexp.MustCompile(fmt.Sprintf(
- "policy group %s/%s not found", defaultAccount, "not-exists",
+ "policy group %s/%s not found", scalr2.defaultAccount, "not-exists",
)),
PlanOnly: true,
},
@@ -102,20 +105,20 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
func waitForPolicyGroupFetch(name string) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- pgl, err := scalrClient.PolicyGroups.List(ctx, scalr.PolicyGroupListOptions{
- Account: defaultAccount,
+ pgl, err := scalrClient.PolicyGroups.List(scalr2.ctx, scalr.PolicyGroupListOptions{
+ Account: scalr2.defaultAccount,
Name: name,
})
if err != nil || len(pgl.Items) == 0 {
- log.Fatalf("The test policy group on account %s was not created: %v", defaultAccount, err)
+ log.Fatalf("The test policy group on account %s was not created: %v", scalr2.defaultAccount, err)
}
var pgID = pgl.Items[0].ID
for i := 0; i < 60; i++ {
- pg, err := scalrClient.PolicyGroups.Read(ctx, pgID)
+ pg, err := scalrClient.PolicyGroups.Read(scalr2.ctx, pgID)
if err != nil {
log.Fatalf("Error polling policy group %s: %v", pgID, err)
}
@@ -148,7 +151,7 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), scalr2.githubToken, scalr2.defaultAccount, scalr2.policyGroupVcsRepoID, scalr2.policyGroupVcsRepoPath)
}
func testAccPolicyGroupDataSourceConfig(rInt int) string {
@@ -160,5 +163,5 @@ data "scalr_policy_group" "test" {
name = scalr_policy_group.test.name
account_id = "%s"
}
-`, testAccPolicyGroupConfig(rInt), defaultAccount)
+`, testAccPolicyGroupConfig(rInt), scalr2.defaultAccount)
}
diff --git a/scalr/data_source_scalr_provider_configuration.go b/internal/provider/data_source_scalr_provider_configuration.go
similarity index 99%
rename from scalr/data_source_scalr_provider_configuration.go
rename to internal/provider/data_source_scalr_provider_configuration.go
index 7df2e95b..beb637cc 100644
--- a/scalr/data_source_scalr_provider_configuration.go
+++ b/internal/provider/data_source_scalr_provider_configuration.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_provider_configuration_test.go b/internal/provider/data_source_scalr_provider_configuration_test.go
similarity index 90%
rename from scalr/data_source_scalr_provider_configuration_test.go
rename to internal/provider/data_source_scalr_provider_configuration_test.go
index 557ac59a..89491dd9 100644
--- a/scalr/data_source_scalr_provider_configuration_test.go
+++ b/internal/provider/data_source_scalr_provider_configuration_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -8,12 +8,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationDataSourceInitConfig, // depends_on works improperly with data sources
@@ -45,7 +47,7 @@ func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckEqualID("data.scalr_provider_configuration.scalr", "scalr_provider_configuration.scalr"),
resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "name", rName),
- resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "provider_name", "scalr"),
),
},
@@ -58,7 +60,7 @@ func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
var rName = acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
-var testAccScalrProviderConfigurationDataSourceScalrConfig = testAccScalrProviderConfigurationScalrConfig(rName) + `
+var testAccScalrProviderConfigurationDataSourceScalrConfig = scalr.testAccScalrProviderConfigurationScalrConfig(rName) + `
data "scalr_provider_configuration" "scalr" {
name = scalr_provider_configuration.scalr.name
}`
@@ -102,7 +104,7 @@ resource "scalr_provider_configuration" "consul" {
}
}
}
-`, defaultAccount)
+`, scalr.defaultAccount)
var testAccScalrProviderConfigurationDataSourceConfig = testAccScalrProviderConfigurationDataSourceInitConfig + `
data "scalr_provider_configuration" "kubernetes" {
diff --git a/scalr/data_source_scalr_provider_configurations.go b/internal/provider/data_source_scalr_provider_configurations.go
similarity index 99%
rename from scalr/data_source_scalr_provider_configurations.go
rename to internal/provider/data_source_scalr_provider_configurations.go
index 1dd4951b..b2bea8b8 100644
--- a/scalr/data_source_scalr_provider_configurations.go
+++ b/internal/provider/data_source_scalr_provider_configurations.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_provider_configurations_test.go b/internal/provider/data_source_scalr_provider_configurations_test.go
similarity index 95%
rename from scalr/data_source_scalr_provider_configurations_test.go
rename to internal/provider/data_source_scalr_provider_configurations_test.go
index 346d4bc5..dd031bb0 100644
--- a/scalr/data_source_scalr_provider_configurations_test.go
+++ b/internal/provider/data_source_scalr_provider_configurations_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,12 +6,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrProviderConfigurationsDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationsDataSourceInitConfig, // depends_on works improperly with data sources
@@ -152,7 +154,7 @@ resource "scalr_provider_configuration" "consul" {
value = "nyc1"
}
}
-}`, defaultAccount)
+}`, scalr.defaultAccount)
var testAccScalrProviderConfigurationsDataSourceConfig = testAccScalrProviderConfigurationsDataSourceInitConfig + `
data "scalr_provider_configurations" "kubernetes2consul" {
diff --git a/scalr/data_source_scalr_role.go b/internal/provider/data_source_scalr_role.go
similarity index 99%
rename from scalr/data_source_scalr_role.go
rename to internal/provider/data_source_scalr_role.go
index 28f175c2..c25e3346 100644
--- a/scalr/data_source_scalr_role.go
+++ b/internal/provider/data_source_scalr_role.go
@@ -1,10 +1,11 @@
-package scalr
+package provider
import (
"context"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_role_test.go b/internal/provider/data_source_scalr_role_test.go
similarity index 93%
rename from scalr/data_source_scalr_role_test.go
rename to internal/provider/data_source_scalr_role_test.go
index 79748919..384e899a 100644
--- a/scalr/data_source_scalr_role_test.go
+++ b/internal/provider/data_source_scalr_role_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,12 +7,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRoleDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_role test_role {}`,
@@ -37,7 +39,7 @@ func TestAccScalrRoleDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_role.test", "name", "role-test"),
resource.TestCheckResourceAttr("data.scalr_role.test", "description", ""),
resource.TestCheckResourceAttr("data.scalr_role.test", "is_system", "false"),
- resource.TestCheckResourceAttr("data.scalr_role.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_role.test", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttr("data.scalr_role.test", "permissions.0", "*:read"),
resource.TestCheckResourceAttr("data.scalr_role.test", "permissions.1", "roles:update"),
),
@@ -61,7 +63,7 @@ func TestAccScalrRoleDataSource_basic(t *testing.T) {
{
Config: testAccScalrRoleDataSourceUserConfig(),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_role.user", "id", userRole),
+ resource.TestCheckResourceAttr("data.scalr_role.user", "id", scalr.userRole),
resource.TestCheckResourceAttr("data.scalr_role.user", "name", "user"),
resource.TestCheckResourceAttrSet("data.scalr_role.user", "description"),
resource.TestCheckResourceAttr("data.scalr_role.user", "is_system", "true"),
@@ -106,7 +108,7 @@ data "scalr_role" "test" {
id = scalr_role.test.id
account_id = scalr_role.test.account_id
}
-`, defaultAccount)
+`, scalr.defaultAccount)
var testAccScalrRoleDataSourceByNameConfig = fmt.Sprintf(`
resource "scalr_role" "test" {
@@ -122,7 +124,7 @@ data "scalr_role" "test" {
name = scalr_role.test.name
account_id = scalr_role.test.account_id
}
-`, defaultAccount)
+`, scalr.defaultAccount)
var testAccScalrRoleDataSourceByIDAndNameConfig = fmt.Sprintf(`
resource "scalr_role" "test" {
@@ -139,7 +141,7 @@ data "scalr_role" "test" {
name = scalr_role.test.name
account_id = scalr_role.test.account_id
}
-`, defaultAccount)
+`, scalr.defaultAccount)
func testAccScalrRoleDataSourceUserConfig() string {
return `
diff --git a/scalr/data_source_scalr_service_account.go b/internal/provider/data_source_scalr_service_account.go
similarity index 99%
rename from scalr/data_source_scalr_service_account.go
rename to internal/provider/data_source_scalr_service_account.go
index 08d5edc6..ea0a9da2 100644
--- a/scalr/data_source_scalr_service_account.go
+++ b/internal/provider/data_source_scalr_service_account.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_service_account_test.go b/internal/provider/data_source_scalr_service_account_test.go
similarity index 91%
rename from scalr/data_source_scalr_service_account_test.go
rename to internal/provider/data_source_scalr_service_account_test.go
index 4739b8e9..9426a4e9 100644
--- a/scalr/data_source_scalr_service_account_test.go
+++ b/internal/provider/data_source_scalr_service_account_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,14 +7,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_service_account test {}`,
@@ -46,7 +48,7 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
"data.scalr_service_account.test", "description", fmt.Sprintf("desc-%d", rInt),
),
resource.TestCheckResourceAttr(
- "data.scalr_service_account.test", "account_id", defaultAccount,
+ "data.scalr_service_account.test", "account_id", scalr2.defaultAccount,
),
resource.TestCheckResourceAttr(
"data.scalr_service_account.test", "created_by.#", "1",
@@ -75,7 +77,7 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
"data.scalr_service_account.test", "description", fmt.Sprintf("desc-%d", rInt),
),
resource.TestCheckResourceAttr(
- "data.scalr_service_account.test", "account_id", defaultAccount,
+ "data.scalr_service_account.test", "account_id", scalr2.defaultAccount,
),
resource.TestCheckResourceAttr(
"data.scalr_service_account.test", "created_by.#", "1",
@@ -100,7 +102,7 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
"data.scalr_service_account.test", "description", fmt.Sprintf("desc-%d", rInt),
),
resource.TestCheckResourceAttr(
- "data.scalr_service_account.test", "account_id", defaultAccount,
+ "data.scalr_service_account.test", "account_id", scalr2.defaultAccount,
),
resource.TestCheckResourceAttr(
"data.scalr_service_account.test", "created_by.#", "1",
diff --git a/scalr/data_source_scalr_ssh_key.go b/internal/provider/data_source_scalr_ssh_key.go
similarity index 99%
rename from scalr/data_source_scalr_ssh_key.go
rename to internal/provider/data_source_scalr_ssh_key.go
index 599bbc9d..eaa05b63 100644
--- a/scalr/data_source_scalr_ssh_key.go
+++ b/internal/provider/data_source_scalr_ssh_key.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_ssh_key_test.go b/internal/provider/data_source_scalr_ssh_key_test.go
similarity index 89%
rename from scalr/data_source_scalr_ssh_key_test.go
rename to internal/provider/data_source_scalr_ssh_key_test.go
index 9e7cad3c..c74bfde2 100644
--- a/scalr/data_source_scalr_ssh_key_test.go
+++ b/internal/provider/data_source_scalr_ssh_key_test.go
@@ -1,20 +1,23 @@
-package scalr
+package provider
import (
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"regexp"
"testing"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
rInt := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_ssh_key test {}`,
@@ -39,7 +42,7 @@ func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(
"data.scalr_ssh_key.test", "environments.#"),
resource.TestCheckResourceAttr(
- "data.scalr_ssh_key.test", "account_id", defaultAccount),
+ "data.scalr_ssh_key.test", "account_id", scalr.defaultAccount),
),
},
{
@@ -48,7 +51,7 @@ func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_ssh_key.test_by_name", "name", fmt.Sprintf("ssh-key-test-%s", rInt)),
resource.TestCheckResourceAttr(
- "data.scalr_ssh_key.test_by_name", "account_id", defaultAccount),
+ "data.scalr_ssh_key.test_by_name", "account_id", scalr.defaultAccount),
),
},
{
@@ -83,7 +86,7 @@ EOF
data "scalr_ssh_key" "test" {
id = scalr_ssh_key.test.id
account_id = scalr_ssh_key.test.account_id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccScalrSSHKeyDataSourceAccessByNameConfig(rInt string) string {
@@ -102,7 +105,7 @@ EOF
data "scalr_ssh_key" "test_by_name" {
name = scalr_ssh_key.test.name
account_id = scalr_ssh_key.test.account_id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccScalrSSHKeyDataSourceNotFoundByNameConfig() string {
@@ -130,5 +133,5 @@ data "scalr_ssh_key" "test_mismatch" {
id = scalr_ssh_key.test.id
name = "incorrect-name"
account_id = scalr_ssh_key.test.account_id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_tag.go b/internal/provider/data_source_scalr_tag.go
similarity index 99%
rename from scalr/data_source_scalr_tag.go
rename to internal/provider/data_source_scalr_tag.go
index ee214c21..b7c97224 100644
--- a/scalr/data_source_scalr_tag.go
+++ b/internal/provider/data_source_scalr_tag.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
+ "log"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/scalr/go-scalr"
- "log"
)
func dataSourceScalrTag() *schema.Resource {
diff --git a/scalr/data_source_scalr_tag_test.go b/internal/provider/data_source_scalr_tag_test.go
similarity index 87%
rename from scalr/data_source_scalr_tag_test.go
rename to internal/provider/data_source_scalr_tag_test.go
index 0ba93c07..57c18858 100644
--- a/scalr/data_source_scalr_tag_test.go
+++ b/internal/provider/data_source_scalr_tag_test.go
@@ -1,18 +1,21 @@
-package scalr
+package provider
import (
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
"testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrTagDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_tag test {}`,
@@ -34,7 +37,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", scalr.defaultAccount),
),
},
{
@@ -42,7 +45,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", scalr.defaultAccount),
),
},
{
@@ -50,7 +53,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", scalr.defaultAccount),
),
},
},
@@ -67,7 +70,7 @@ resource scalr_tag test {
data scalr_tag test {
id = scalr_tag.test.id
account_id = "%[2]s"
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccScalrTagDataSourceByNameConfig(rInt int) string {
@@ -80,7 +83,7 @@ resource scalr_tag test {
data scalr_tag test {
name = scalr_tag.test.name
account_id = "%[2]s"
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccScalrTagDataSourceByIDAndNameConfig(rInt int) string {
@@ -94,5 +97,5 @@ data scalr_tag test {
id = scalr_tag.test.id
name = scalr_tag.test.name
account_id = "%[2]s"
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_variable.go b/internal/provider/data_source_scalr_variable.go
similarity index 99%
rename from scalr/data_source_scalr_variable.go
rename to internal/provider/data_source_scalr_variable.go
index cb75444d..62f74ee8 100644
--- a/scalr/data_source_scalr_variable.go
+++ b/internal/provider/data_source_scalr_variable.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_variable_test.go b/internal/provider/data_source_scalr_variable_test.go
similarity index 94%
rename from scalr/data_source_scalr_variable_test.go
rename to internal/provider/data_source_scalr_variable_test.go
index 78191924..b136048d 100644
--- a/scalr/data_source_scalr_variable_test.go
+++ b/internal/provider/data_source_scalr_variable_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,13 +6,15 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrVariableDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_variable test {}`,
@@ -56,7 +58,7 @@ func TestAccScalrVariableDataSource(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "sensitive", "false"),
resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "description", "The hostname of scalr workspace."),
resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "final", "false"),
- resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "account_id", defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "account_id", scalr.defaultAccount),
testAccCheckEqualID("data.scalr_variable.secret", "scalr_variable.secret"),
resource.TestCheckResourceAttr("data.scalr_variable.secret", "hcl", "false"),
resource.TestCheckResourceAttr("data.scalr_variable.secret", "sensitive", "true"),
@@ -120,14 +122,14 @@ resource "scalr_variable" "secret" {
final = true
account_id = "%[1]s"
}
-`, defaultAccount)
+`, scalr.defaultAccount)
var testAccScalrVariableDataSourceByIDConfig = testAccScalrVariableDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variable" "secret" {
id = scalr_variable.secret.id
account_id = "%s"
}
-`, defaultAccount)
+`, scalr.defaultAccount)
var testAccScalrVariableDataSourceByKeyConfig = testAccScalrVariableDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variable" "secret" {
@@ -141,7 +143,7 @@ data "scalr_variable" "workspace_hostname" {
category = "shell"
account_id = "%[1]s"
workspace_id = scalr_workspace.test.id
-}`, defaultAccount)
+}`, scalr.defaultAccount)
var testAccScalrVariableDataSourceByIDAndKeyConfig = testAccScalrVariableDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variable" "secret" {
@@ -149,4 +151,4 @@ data "scalr_variable" "secret" {
key = "secret"
account_id = "%s"
}
-`, defaultAccount)
+`, scalr.defaultAccount)
diff --git a/scalr/data_source_scalr_variables.go b/internal/provider/data_source_scalr_variables.go
similarity index 99%
rename from scalr/data_source_scalr_variables.go
rename to internal/provider/data_source_scalr_variables.go
index aae9d610..0024bc87 100644
--- a/scalr/data_source_scalr_variables.go
+++ b/internal/provider/data_source_scalr_variables.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_variables_test.go b/internal/provider/data_source_scalr_variables_test.go
similarity index 92%
rename from scalr/data_source_scalr_variables_test.go
rename to internal/provider/data_source_scalr_variables_test.go
index 35e8a50f..4b42d213 100644
--- a/scalr/data_source_scalr_variables_test.go
+++ b/internal/provider/data_source_scalr_variables_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -9,13 +9,15 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrVariablesDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrVariablesDataSourceInitConfig, // depends_on works improperly with data sources
@@ -65,18 +67,18 @@ func TestAccScalrVariablesDataSource(t *testing.T) {
}
func deleteAllVariables() {
- scalrClient, err := createScalrClient()
+ scalrClient, err := scalr2.createScalrClient()
if err != nil {
log.Fatalf("Cant remove default variables before test: %s", err)
return
}
- variables, err := scalrClient.Variables.List(ctx, scalr.VariableListOptions{})
+ variables, err := scalrClient.Variables.List(scalr2.ctx, scalr.VariableListOptions{})
if err != nil {
log.Fatalf("Cant remove default variables before test: %s", err)
return
}
for _, variable := range variables.Items {
- err = scalrClient.Variables.Delete(ctx, variable.ID)
+ err = scalrClient.Variables.Delete(scalr2.ctx, variable.ID)
if err != nil {
log.Fatalf("Cant remove default variables before test: %s", err)
return
@@ -181,7 +183,7 @@ resource "scalr_variable" "secret" {
final = true
account_id = "%[1]s"
}
-`, defaultAccount)
+`, scalr2.defaultAccount)
var testAccScalrVariablesDataSourceConfig = testAccScalrVariablesDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variables" "shell" {
@@ -203,4 +205,4 @@ data "scalr_variables" "workspace_and_null" {
data "scalr_variables" "account" {
account_id = "%[1]s"
}
-`, defaultAccount)
+`, scalr2.defaultAccount)
diff --git a/scalr/data_source_scalr_vcs_provider.go b/internal/provider/data_source_scalr_vcs_provider.go
similarity index 99%
rename from scalr/data_source_scalr_vcs_provider.go
rename to internal/provider/data_source_scalr_vcs_provider.go
index f22594de..279a3371 100644
--- a/scalr/data_source_scalr_vcs_provider.go
+++ b/internal/provider/data_source_scalr_vcs_provider.go
@@ -1,7 +1,8 @@
-package scalr
+package provider
import (
"context"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
diff --git a/scalr/data_source_scalr_vcs_provider_test.go b/internal/provider/data_source_scalr_vcs_provider_test.go
similarity index 87%
rename from scalr/data_source_scalr_vcs_provider_test.go
rename to internal/provider/data_source_scalr_vcs_provider_test.go
index 6e0fe54e..a27a6bdc 100644
--- a/scalr/data_source_scalr_vcs_provider_test.go
+++ b/internal/provider/data_source_scalr_vcs_provider_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,17 +6,19 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
- Config: testAccScalrVcsProviderDataSourceConfigAllFilters(rInt, githubToken),
+ Config: testAccScalrVcsProviderDataSourceConfigAllFilters(rInt, scalr.githubToken),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_vcs_provider.test", "id"),
resource.TestCheckResourceAttr(
@@ -26,13 +28,13 @@ func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_vcs_provider.test", "url", "https://github.com"),
resource.TestCheckResourceAttr(
- "data.scalr_vcs_provider.test", "account_id", defaultAccount),
+ "data.scalr_vcs_provider.test", "account_id", scalr.defaultAccount),
resource.TestCheckResourceAttr(
"data.scalr_vcs_provider.test", "draft_pr_runs_enabled", "false"),
),
},
{
- Config: testAccScalrVcsProviderDataSourceConfigFilterByName(rInt, githubToken),
+ Config: testAccScalrVcsProviderDataSourceConfigFilterByName(rInt, scalr.githubToken),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_vcs_provider.test", "id"),
resource.TestCheckResourceAttr(
@@ -42,7 +44,7 @@ func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_vcs_provider.test", "url", "https://github.com"),
resource.TestCheckResourceAttr(
- "data.scalr_vcs_provider.test", "account_id", defaultAccount),
+ "data.scalr_vcs_provider.test", "account_id", scalr.defaultAccount),
),
},
{
@@ -89,7 +91,7 @@ data scalr_vcs_provider test {
name = scalr_vcs_provider.test.name
vcs_type = scalr_vcs_provider.test.vcs_type
account_id = scalr_vcs_provider.test.account_id
-}`, rInt, token, defaultAccount)
+}`, rInt, token, scalr.defaultAccount)
}
func testAccScalrVcsProviderDataSourceConfigFilterByName(rInt int, token string) string {
@@ -103,5 +105,5 @@ resource scalr_vcs_provider test {
data scalr_vcs_provider test {
name = scalr_vcs_provider.test.name
-}`, rInt, token, defaultAccount)
+}`, rInt, token, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_webhook.go b/internal/provider/data_source_scalr_webhook.go
similarity index 99%
rename from scalr/data_source_scalr_webhook.go
rename to internal/provider/data_source_scalr_webhook.go
index 72fc7e25..257d59fe 100644
--- a/scalr/data_source_scalr_webhook.go
+++ b/internal/provider/data_source_scalr_webhook.go
@@ -1,10 +1,11 @@
-package scalr
+package provider
import (
"context"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/data_source_scalr_webhook_test.go b/internal/provider/data_source_scalr_webhook_test.go
similarity index 93%
rename from scalr/data_source_scalr_webhook_test.go
rename to internal/provider/data_source_scalr_webhook_test.go
index b3d42628..e32a82b9 100644
--- a/scalr/data_source_scalr_webhook_test.go
+++ b/internal/provider/data_source_scalr_webhook_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -8,6 +8,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccWebhookDataSource_basic(t *testing.T) {
@@ -16,8 +18,8 @@ func TestAccWebhookDataSource_basic(t *testing.T) {
cutRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_webhook test {}`,
@@ -119,7 +121,7 @@ resource scalr_webhook test-new {
data scalr_webhook test-new {
id = scalr_webhook.test-new.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccWebhookDataSourceAccessByNameConfig(rInt int) string {
@@ -135,7 +137,7 @@ resource scalr_webhook test {
data scalr_webhook test {
name = scalr_webhook.test.name
account_id = "%s"
-}`, rInt, defaultAccount, defaultAccount)
+}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
}
func testAccWebhookDataSourceAccessByIDAndNameConfig(rInt int) string {
@@ -152,7 +154,7 @@ data scalr_webhook test {
id = scalr_webhook.test.id
name = scalr_webhook.test.name
account_id = "%s"
-}`, rInt, defaultAccount, defaultAccount)
+}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
}
func testAccWebhookDataSourceNotFoundByNameConfig() string {
@@ -176,5 +178,5 @@ resource scalr_webhook test {
data scalr_webhook test {
name = "test webhook-%[3]s"
account_id = "%s"
-}`, rInt, defaultAccount, cutRInt, defaultAccount)
+}`, rInt, scalr.defaultAccount, cutRInt, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_workspace.go b/internal/provider/data_source_scalr_workspace.go
similarity index 99%
rename from scalr/data_source_scalr_workspace.go
rename to internal/provider/data_source_scalr_workspace.go
index 1ef0a58f..60689a80 100644
--- a/scalr/data_source_scalr_workspace.go
+++ b/internal/provider/data_source_scalr_workspace.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/data_source_scalr_workspace_ids.go b/internal/provider/data_source_scalr_workspace_ids.go
similarity index 99%
rename from scalr/data_source_scalr_workspace_ids.go
rename to internal/provider/data_source_scalr_workspace_ids.go
index 957cb34d..d45cdb48 100644
--- a/scalr/data_source_scalr_workspace_ids.go
+++ b/internal/provider/data_source_scalr_workspace_ids.go
@@ -1,8 +1,9 @@
-package scalr
+package provider
import (
"context"
"fmt"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
diff --git a/scalr/data_source_scalr_workspace_ids_test.go b/internal/provider/data_source_scalr_workspace_ids_test.go
similarity index 91%
rename from scalr/data_source_scalr_workspace_ids_test.go
rename to internal/provider/data_source_scalr_workspace_ids_test.go
index 90c6b5af..08fb3b5e 100644
--- a/scalr/data_source_scalr_workspace_ids_test.go
+++ b/internal/provider/data_source_scalr_workspace_ids_test.go
@@ -1,18 +1,20 @@
-package scalr
+package provider
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspaceIDsDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceIDsDataSourceConfigBasic(rInt),
@@ -43,8 +45,8 @@ func TestAccScalrWorkspaceIDsDataSource_wildcard(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceIDsDataSourceConfigWildcard(rInt),
@@ -94,7 +96,7 @@ resource scalr_workspace dummy {
data scalr_workspace_ids foobar {
names = [scalr_workspace.foo.name, scalr_workspace.bar.name]
environment_id = scalr_environment.test.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
// nolint:unused
@@ -123,5 +125,5 @@ resource scalr_workspace dummy {
data scalr_workspace_ids foobar {
names = ["*"]
environment_id = scalr_environment.test.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_workspace_test.go b/internal/provider/data_source_scalr_workspace_test.go
similarity index 95%
rename from scalr/data_source_scalr_workspace_test.go
rename to internal/provider/data_source_scalr_workspace_test.go
index 4bcc5b72..4c06d0cc 100644
--- a/scalr/data_source_scalr_workspace_test.go
+++ b/internal/provider/data_source_scalr_workspace_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,14 +6,16 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspaceDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceDataSourceMissingRequiredConfig,
@@ -134,7 +136,7 @@ resource scalr_workspace test {
data scalr_workspace test {
id = scalr_workspace.test.id
environment_id = scalr_environment.test.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccScalrWorkspaceDataSourceByNameConfig(rInt int) string {
@@ -152,7 +154,7 @@ resource scalr_workspace test {
data scalr_workspace test {
name = scalr_workspace.test.name
environment_id = scalr_environment.test.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
func testAccScalrWorkspaceDataSourceByIDAndNameConfig(rInt int) string {
@@ -171,5 +173,5 @@ data scalr_workspace test {
id = scalr_workspace.test.id
name = scalr_workspace.test.name
environment_id = scalr_environment.test.id
-}`, rInt, defaultAccount)
+}`, rInt, scalr.defaultAccount)
}
diff --git a/scalr/data_source_scalr_workspaces.go b/internal/provider/data_source_scalr_workspaces.go
similarity index 99%
rename from scalr/data_source_scalr_workspaces.go
rename to internal/provider/data_source_scalr_workspaces.go
index a5888e8c..f0d9e0d5 100644
--- a/scalr/data_source_scalr_workspaces.go
+++ b/internal/provider/data_source_scalr_workspaces.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"fmt"
+ "strings"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
- "strings"
)
func dataSourceScalrWorkspaces() *schema.Resource {
diff --git a/scalr/data_source_scalr_workspaces_test.go b/internal/provider/data_source_scalr_workspaces_test.go
similarity index 92%
rename from scalr/data_source_scalr_workspaces_test.go
rename to internal/provider/data_source_scalr_workspaces_test.go
index e53b15b7..06277d84 100644
--- a/scalr/data_source_scalr_workspaces_test.go
+++ b/internal/provider/data_source_scalr_workspaces_test.go
@@ -1,18 +1,20 @@
-package scalr
+package provider
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspacesDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspacesDataSourceConfigBasic(rInt),
diff --git a/scalr/helpers.go b/internal/provider/helpers.go
similarity index 99%
rename from scalr/helpers.go
rename to internal/provider/helpers.go
index 25d02b14..86dbdb9a 100644
--- a/scalr/helpers.go
+++ b/internal/provider/helpers.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/provider.go b/internal/provider/provider_sdk.go
similarity index 99%
rename from scalr/provider.go
rename to internal/provider/provider_sdk.go
index a865aabb..a36a8a6d 100644
--- a/scalr/provider.go
+++ b/internal/provider/provider_sdk.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/provider_test.go b/internal/provider/provider_sdk_test.go
similarity index 98%
rename from scalr/provider_test.go
rename to internal/provider/provider_sdk_test.go
index 971b8d70..5c24b2c1 100644
--- a/scalr/provider_test.go
+++ b/internal/provider/provider_sdk_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_access_policy.go b/internal/provider/resource_scalr_access_policy.go
similarity index 99%
rename from scalr/resource_scalr_access_policy.go
rename to internal/provider/resource_scalr_access_policy.go
index ec135208..0fb45819 100644
--- a/scalr/resource_scalr_access_policy.go
+++ b/internal/provider/resource_scalr_access_policy.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_access_policy_test.go b/internal/provider/resource_scalr_access_policy_test.go
similarity index 88%
rename from scalr/resource_scalr_access_policy_test.go
rename to internal/provider/resource_scalr_access_policy_test.go
index 787a8d07..583fe4d5 100644
--- a/scalr/resource_scalr_access_policy_test.go
+++ b/internal/provider/resource_scalr_access_policy_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -12,6 +12,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAccessPolicy_basic(t *testing.T) {
@@ -19,8 +21,8 @@ func TestAccScalrAccessPolicy_basic(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -44,8 +46,8 @@ func TestAccScalrAccessPolicy_bad_scope(t *testing.T) {
rg, _ := regexp.Compile(`scope.0.type must be one of \[workspace, environment, account], got: universe`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBadScope(),
@@ -59,8 +61,8 @@ func TestAccScalrAccessPolicy_bad_subject(t *testing.T) {
rg, _ := regexp.Compile(`subject.0.type must be one of \[user, team, service_account], got: grandpa`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBadSubject(),
@@ -75,8 +77,8 @@ func TestAccScalrAccessPolicy_changed_outside(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -114,8 +116,8 @@ func TestAccScalrAccessPolicy_update(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -158,8 +160,8 @@ func TestAccScalrAccessPolicy_import(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -177,7 +179,7 @@ func TestAccScalrAccessPolicy_import(t *testing.T) {
func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -189,7 +191,7 @@ func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) r
}
// Get the ap
- r, err := scalrClient.AccessPolicies.Read(ctx, rs.Primary.ID)
+ r, err := scalrClient.AccessPolicies.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -202,9 +204,9 @@ func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) r
func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.AccessPolicies.Read(ctx, ap.ID)
+ r, err := scalrClient.AccessPolicies.Read(scalr2.ctx, ap.ID)
if err != nil {
log.Fatalf("Error retrieving access policy: %v", err)
@@ -226,7 +228,7 @@ func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func()
}
func testAccCheckScalrAccessPolicyDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_access_policy" {
@@ -237,7 +239,7 @@ func testAccCheckScalrAccessPolicyDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.AccessPolicies.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.AccessPolicies.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("AccessPolicy %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_account_allowed_ips.go b/internal/provider/resource_scalr_account_allowed_ips.go
similarity index 99%
rename from scalr/resource_scalr_account_allowed_ips.go
rename to internal/provider/resource_scalr_account_allowed_ips.go
index 8027e404..35536ccf 100644
--- a/scalr/resource_scalr_account_allowed_ips.go
+++ b/internal/provider/resource_scalr_account_allowed_ips.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_account_allowed_ips_test.go b/internal/provider/resource_scalr_account_allowed_ips_test.go
similarity index 83%
rename from scalr/resource_scalr_account_allowed_ips_test.go
rename to internal/provider/resource_scalr_account_allowed_ips_test.go
index ad271184..6cda7e8c 100644
--- a/scalr/resource_scalr_account_allowed_ips_test.go
+++ b/internal/provider/resource_scalr_account_allowed_ips_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"encoding/json"
@@ -7,12 +7,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0", "192.168.0.0/32"}),
@@ -30,8 +32,8 @@ func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
func TestAccScalrAccountAllowedIps_update(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0"}),
@@ -56,8 +58,8 @@ func TestAccScalrAccountAllowedIps_update(t *testing.T) {
func TestAccScalrAccountAllowedIps_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0"}),
@@ -75,8 +77,8 @@ func TestAccScalrAccountAllowedIps_import(t *testing.T) {
func TestAccScalrAccountAllowedIps_empty(t *testing.T) {
rg, _ := regexp.Compile(`Attribute allowed_ips requires 1 item minimum, but config has only 0`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{}),
@@ -89,8 +91,8 @@ func TestAccScalrAccountAllowedIps_empty(t *testing.T) {
func TestAccScalrAccountAllowedIps_invalid_CIDR(t *testing.T) {
rg, _ := regexp.Compile(`value is not a valid IPv4 network`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12/24"}),
diff --git a/scalr/resource_scalr_agent_pool.go b/internal/provider/resource_scalr_agent_pool.go
similarity index 99%
rename from scalr/resource_scalr_agent_pool.go
rename to internal/provider/resource_scalr_agent_pool.go
index d4e93f01..d79d56a9 100644
--- a/scalr/resource_scalr_agent_pool.go
+++ b/internal/provider/resource_scalr_agent_pool.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_agent_pool_test.go b/internal/provider/resource_scalr_agent_pool_test.go
similarity index 85%
rename from scalr/resource_scalr_agent_pool_test.go
rename to internal/provider/resource_scalr_agent_pool_test.go
index 8ed30ecd..6b8173b7 100644
--- a/scalr/resource_scalr_agent_pool_test.go
+++ b/internal/provider/resource_scalr_agent_pool_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -9,6 +9,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAgentPool_basic(t *testing.T) {
@@ -16,8 +18,8 @@ func TestAccScalrAgentPool_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -39,8 +41,8 @@ func TestAccScalrAgentPool_renamed(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -71,8 +73,8 @@ func TestAccScalrAgentPool_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -100,8 +102,8 @@ func TestAccScalrAgentPool_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -119,7 +121,7 @@ func TestAccScalrAgentPool_import(t *testing.T) {
func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -131,7 +133,7 @@ func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resou
}
// Get the agent_pool
- r, err := scalrClient.AgentPools.Read(ctx, rs.Primary.ID)
+ r, err := scalrClient.AgentPools.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -144,9 +146,9 @@ func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resou
func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.AgentPools.Read(ctx, pool.ID)
+ r, err := scalrClient.AgentPools.Read(scalr2.ctx, pool.ID)
if err != nil {
log.Fatalf("Error retrieving agent pool: %v", err)
@@ -168,7 +170,7 @@ func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
}
func testAccCheckScalrAgentPoolDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_agent_pool" {
@@ -179,7 +181,7 @@ func testAccCheckScalrAgentPoolDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.AgentPools.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.AgentPools.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("AgentPool %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_agent_pool_token.go b/internal/provider/resource_scalr_agent_pool_token.go
similarity index 99%
rename from scalr/resource_scalr_agent_pool_token.go
rename to internal/provider/resource_scalr_agent_pool_token.go
index 27becff1..93e261c8 100644
--- a/scalr/resource_scalr_agent_pool_token.go
+++ b/internal/provider/resource_scalr_agent_pool_token.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_agent_pool_token_test.go b/internal/provider/resource_scalr_agent_pool_token_test.go
similarity index 86%
rename from scalr/resource_scalr_agent_pool_token_test.go
rename to internal/provider/resource_scalr_agent_pool_token_test.go
index a4c12f65..9eb865f7 100644
--- a/scalr/resource_scalr_agent_pool_token_test.go
+++ b/internal/provider/resource_scalr_agent_pool_token_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -9,6 +9,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAgentPoolToken_basic(t *testing.T) {
@@ -21,8 +23,8 @@ func TestAccScalrAgentPoolToken_basic(t *testing.T) {
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
@@ -47,8 +49,8 @@ func TestAccScalrAgentPoolToken_changed_outside(t *testing.T) {
token := &scalr.AccessToken{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
@@ -81,8 +83,8 @@ func TestAccScalrAgentPoolToken_update(t *testing.T) {
token := &scalr.AccessToken{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
@@ -106,7 +108,7 @@ func TestAccScalrAgentPoolToken_update(t *testing.T) {
func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, token *scalr.AccessToken) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -118,7 +120,7 @@ func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, t
}
// Get the token
- l, err := scalrClient.AgentPoolTokens.List(ctx, pool.ID, scalr.AccessTokenListOptions{})
+ l, err := scalrClient.AgentPoolTokens.List(scalr2.ctx, pool.ID, scalr.AccessTokenListOptions{})
if err != nil {
return err
}
@@ -138,7 +140,7 @@ func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, t
func testAccCheckScalrAgentPoolTokenChangedOutside(token *scalr.AccessToken) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
r, err := scalrClient.AccessTokens.Update(
context.Background(),
@@ -161,7 +163,7 @@ func deletePool(t *testing.T, pool scalr.AgentPool) {
t.Fatalf("Unable to create a Scalr client: %s", err)
}
- err = scalrClient.AgentPools.Delete(ctx, pool.ID)
+ err = scalrClient.AgentPools.Delete(scalr2.ctx, pool.ID)
if err != nil {
t.Fatalf("Unable to delete an agent pool: %s", err)
}
@@ -175,7 +177,7 @@ func createPool(t *testing.T) scalr.AgentPool {
t.Fatalf("Unable to create a Scalr client: %s", err)
}
- r, err := scalrClient.AgentPools.Create(ctx, scalr.AgentPoolCreateOptions{
+ r, err := scalrClient.AgentPools.Create(scalr2.ctx, scalr.AgentPoolCreateOptions{
Name: scalr.String(name),
Account: &scalr.Account{ID: defaultAccount},
})
@@ -187,7 +189,7 @@ func createPool(t *testing.T) scalr.AgentPool {
}
func testAccCheckScalrAgentPoolTokenDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_agent_pool_token" {
@@ -197,7 +199,7 @@ func testAccCheckScalrAgentPoolTokenDestroy(s *terraform.State) error {
poolID := rs.Primary.Attributes["agent_pool_id"]
// the agent pool must be deleted along with token
- l, _ := scalrClient.AgentPoolTokens.List(ctx, poolID, scalr.AccessTokenListOptions{})
+ l, _ := scalrClient.AgentPoolTokens.List(scalr2.ctx, poolID, scalr.AccessTokenListOptions{})
if len(l.Items) > 0 {
return fmt.Errorf("AgentPoolToken %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_environment.go b/internal/provider/resource_scalr_environment.go
similarity index 99%
rename from scalr/resource_scalr_environment.go
rename to internal/provider/resource_scalr_environment.go
index 7eee66b5..4d953880 100644
--- a/scalr/resource_scalr_environment.go
+++ b/internal/provider/resource_scalr_environment.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"errors"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_environment_test.go b/internal/provider/resource_scalr_environment_test.go
similarity index 91%
rename from scalr/resource_scalr_environment_test.go
rename to internal/provider/resource_scalr_environment_test.go
index 7643e17e..5d7e0dc3 100644
--- a/scalr/resource_scalr_environment_test.go
+++ b/internal/provider/resource_scalr_environment_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccEnvironment_basic(t *testing.T) {
@@ -14,8 +16,8 @@ func TestAccEnvironment_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
@@ -42,8 +44,8 @@ func TestAccEnvironment_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
@@ -79,8 +81,8 @@ func TestAccEnvironmentWithProviderConfigurations_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
@@ -109,7 +111,7 @@ func TestAccEnvironmentWithProviderConfigurations_update(t *testing.T) {
}
func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_environment" {
@@ -120,7 +122,7 @@ func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Environments.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.Environments.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Environment %s still exists", rs.Primary.ID)
}
@@ -131,7 +133,7 @@ func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
func testAccCheckScalrEnvironmentExists(n string, environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -141,7 +143,7 @@ func testAccCheckScalrEnvironmentExists(n string, environment *scalr.Environment
if rs.Primary.ID == "" {
return fmt.Errorf("No instance ID is set")
}
- env, err := scalrClient.Environments.Read(ctx, rs.Primary.ID)
+ env, err := scalrClient.Environments.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -185,12 +187,12 @@ func testAccCheckScalrEnvironmentAttributesUpdate(environment *scalr.Environment
func testAccCheckScalrEnvironmentProviderConfigurations(environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
if len(environment.DefaultProviderConfigurations) != 1 {
return fmt.Errorf("Bad default provider configurations: %v", environment.DefaultProviderConfigurations)
}
- providerConfiguration, err := scalrClient.ProviderConfigurations.Read(ctx, environment.DefaultProviderConfigurations[0].ID)
+ providerConfiguration, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, environment.DefaultProviderConfigurations[0].ID)
if err != nil {
return err
}
@@ -202,12 +204,12 @@ func testAccCheckScalrEnvironmentProviderConfigurations(environment *scalr.Envir
}
func testAccCheckScalrEnvironmentProviderConfigurationsUpdate(environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
if len(environment.DefaultProviderConfigurations) != 1 {
return fmt.Errorf("Bad default provider configurations: %v", environment.DefaultProviderConfigurations)
}
- providerConfiguration, err := scalrClient.ProviderConfigurations.Read(ctx, environment.DefaultProviderConfigurations[0].ID)
+ providerConfiguration, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, environment.DefaultProviderConfigurations[0].ID)
if err != nil {
return err
}
diff --git a/scalr/resource_scalr_event_bridge_integration.go b/internal/provider/resource_scalr_event_bridge_integration.go
similarity index 99%
rename from scalr/resource_scalr_event_bridge_integration.go
rename to internal/provider/resource_scalr_event_bridge_integration.go
index 65a73014..5a1982f7 100644
--- a/scalr/resource_scalr_event_bridge_integration.go
+++ b/internal/provider/resource_scalr_event_bridge_integration.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_event_bridge_integration_test.go b/internal/provider/resource_scalr_event_bridge_integration_test.go
similarity index 89%
rename from scalr/resource_scalr_event_bridge_integration_test.go
rename to internal/provider/resource_scalr_event_bridge_integration_test.go
index 11152287..98756ed7 100644
--- a/scalr/resource_scalr_event_bridge_integration_test.go
+++ b/internal/provider/resource_scalr_event_bridge_integration_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,6 +6,8 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccEventBridgeIntegration_basic(t *testing.T) {
@@ -15,8 +17,8 @@ func TestAccEventBridgeIntegration_basic(t *testing.T) {
t.Skip("Please set AWS_EVENT_BRIDGE_ACCOUNT_ID, AWS_EVENT_BRIDGE_REGION env variables to run this test.")
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrEventBridgeIntegrationConfig(AWSAccountId, region),
diff --git a/scalr/resource_scalr_iam_team.go b/internal/provider/resource_scalr_iam_team.go
similarity index 99%
rename from scalr/resource_scalr_iam_team.go
rename to internal/provider/resource_scalr_iam_team.go
index ae4e6b60..b3479773 100644
--- a/scalr/resource_scalr_iam_team.go
+++ b/internal/provider/resource_scalr_iam_team.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"errors"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_iam_team_test.go b/internal/provider/resource_scalr_iam_team_test.go
similarity index 87%
rename from scalr/resource_scalr_iam_team_test.go
rename to internal/provider/resource_scalr_iam_team_test.go
index bab8602c..2230f244 100644
--- a/scalr/resource_scalr_iam_team_test.go
+++ b/internal/provider/resource_scalr_iam_team_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrIamTeam_basic(t *testing.T) {
@@ -17,8 +19,8 @@ func TestAccScalrIamTeam_basic(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -44,8 +46,8 @@ func TestAccScalrIamTeam_renamed(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -82,8 +84,8 @@ func TestAccScalrIamTeam_update(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -122,8 +124,8 @@ func TestAccScalrIamTeam_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -140,7 +142,7 @@ func TestAccScalrIamTeam_import(t *testing.T) {
func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -151,7 +153,7 @@ func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.Tes
return fmt.Errorf("No instance ID is set")
}
- t, err := scalrClient.Teams.Read(ctx, rs.Primary.ID)
+ t, err := scalrClient.Teams.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -164,9 +166,9 @@ func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.Tes
func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- t, err := scalrClient.Teams.Read(ctx, team.ID)
+ t, err := scalrClient.Teams.Read(scalr2.ctx, team.ID)
if err != nil {
log.Fatalf("Error retrieving team: %v", err)
}
@@ -189,7 +191,7 @@ func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
}
func testAccCheckScalrIamTeamDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_iam_team" {
@@ -200,7 +202,7 @@ func testAccCheckScalrIamTeamDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Teams.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.Teams.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Team %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_module.go b/internal/provider/resource_scalr_module.go
similarity index 99%
rename from scalr/resource_scalr_module.go
rename to internal/provider/resource_scalr_module.go
index 6f607ddf..52ec6793 100644
--- a/scalr/resource_scalr_module.go
+++ b/internal/provider/resource_scalr_module.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_module_test.go b/internal/provider/resource_scalr_module_test.go
similarity index 87%
rename from scalr/resource_scalr_module_test.go
rename to internal/provider/resource_scalr_module_test.go
index 23d3fa5b..e14b3507 100644
--- a/scalr/resource_scalr_module_test.go
+++ b/internal/provider/resource_scalr_module_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -8,6 +8,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrModule_basic(t *testing.T) {
@@ -15,9 +17,9 @@ func TestAccScalrModule_basic(t *testing.T) {
PreCheck: func() {
//TODO:ape delete skip after SCALRCORE-19891
t.Skip("Working on personal token but not working with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrModuleDestroy,
Steps: []resource.TestStep{
{
@@ -66,9 +68,9 @@ func TestAccScalrModule_basic(t *testing.T) {
func TestAccScalrModule_import(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrModuleDestroy,
Steps: []resource.TestStep{
{
@@ -85,7 +87,7 @@ func TestAccScalrModule_import(t *testing.T) {
func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[moduleId]
if !ok {
@@ -97,7 +99,7 @@ func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resour
}
// Get the module
- m, err := scalrClient.Modules.Read(ctx, rs.Primary.ID)
+ m, err := scalrClient.Modules.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -109,7 +111,7 @@ func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resour
}
func testAccCheckScalrModuleDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_module" {
@@ -120,7 +122,7 @@ func testAccCheckScalrModuleDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Modules.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.Modules.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Module %s still exists", rs.Primary.ID)
}
@@ -143,7 +145,7 @@ func testAccScalrModule() string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, string(scalr.Github), githubToken)
+`, string(scalr.Github), scalr2.githubToken)
}
func testAccScalrModulesOnAllScopes() string {
@@ -188,5 +190,5 @@ func testAccScalrModulesOnAllScopes() string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, rInd, string(scalr.Github), githubToken, defaultAccount)
+`, rInd, string(scalr.Github), scalr2.githubToken, defaultAccount)
}
diff --git a/scalr/resource_scalr_policy_group.go b/internal/provider/resource_scalr_policy_group.go
similarity index 99%
rename from scalr/resource_scalr_policy_group.go
rename to internal/provider/resource_scalr_policy_group.go
index 01d88ae4..6e491909 100644
--- a/scalr/resource_scalr_policy_group.go
+++ b/internal/provider/resource_scalr_policy_group.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"errors"
+ "log"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
- "log"
)
func resourceScalrPolicyGroup() *schema.Resource {
diff --git a/scalr/resource_scalr_policy_group_linkage.go b/internal/provider/resource_scalr_policy_group_linkage.go
similarity index 99%
rename from scalr/resource_scalr_policy_group_linkage.go
rename to internal/provider/resource_scalr_policy_group_linkage.go
index 3d2de885..d0cea965 100644
--- a/scalr/resource_scalr_policy_group_linkage.go
+++ b/internal/provider/resource_scalr_policy_group_linkage.go
@@ -1,13 +1,14 @@
-package scalr
+package provider
import (
"context"
"errors"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
"strings"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_policy_group_linkage_test.go b/internal/provider/resource_scalr_policy_group_linkage_test.go
similarity index 83%
rename from scalr/resource_scalr_policy_group_linkage_test.go
rename to internal/provider/resource_scalr_policy_group_linkage_test.go
index 14038dc1..3dfe6382 100644
--- a/scalr/resource_scalr_policy_group_linkage_test.go
+++ b/internal/provider/resource_scalr_policy_group_linkage_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccPolicyGroupLinkage_basic(t *testing.T) {
@@ -18,9 +20,9 @@ func TestAccPolicyGroupLinkage_basic(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
Steps: []resource.TestStep{
{
@@ -54,9 +56,9 @@ func TestAccPolicyGroupLinkage_import(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
Steps: []resource.TestStep{
{
@@ -77,7 +79,7 @@ func testAccCheckPolicyGroupLinkageExists(
environment *scalr.Environment,
) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resID]
if !ok {
@@ -88,7 +90,7 @@ func testAccCheckPolicyGroupLinkageExists(
return fmt.Errorf("no instance ID is set")
}
- pg, env, err := getLinkedResources(ctx, rs.Primary.ID, scalrClient)
+ pg, env, err := getLinkedResources(scalr2.ctx, rs.Primary.ID, scalrClient)
if err != nil {
return err
}
@@ -101,7 +103,7 @@ func testAccCheckPolicyGroupLinkageExists(
}
func testAccCheckPolicyGroupLinkageDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_policy_group_linkage" {
@@ -112,7 +114,7 @@ func testAccCheckPolicyGroupLinkageDestroy(s *terraform.State) error {
return fmt.Errorf("no instance ID is set")
}
- _, _, err := getLinkedResources(ctx, rs.Primary.ID, scalrClient)
+ _, _, err := getLinkedResources(scalr2.ctx, rs.Primary.ID, scalrClient)
if err == nil {
return fmt.Errorf("policy group linkage %s still exists", rs.Primary.ID)
}
@@ -152,5 +154,5 @@ resource "scalr_policy_group_linkage" "test" {
policy_group_id = scalr_policy_group.test.id
environment_id = scalr_environment.test.id
}
-`, defaultAccount, rInt, string(scalr.Github), githubToken, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, defaultAccount, rInt, string(scalr.Github), scalr2.githubToken, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
diff --git a/scalr/resource_scalr_policy_group_test.go b/internal/provider/resource_scalr_policy_group_test.go
similarity index 90%
rename from scalr/resource_scalr_policy_group_test.go
rename to internal/provider/resource_scalr_policy_group_test.go
index 5b2ab247..4ed4a628 100644
--- a/scalr/resource_scalr_policy_group_test.go
+++ b/internal/provider/resource_scalr_policy_group_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -9,6 +9,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
const (
@@ -23,9 +25,9 @@ func TestAccPolicyGroup_basic(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -76,9 +78,9 @@ func TestAccPolicyGroup_update(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -167,9 +169,9 @@ func TestAccPolicyGroup_renamed(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -258,9 +260,9 @@ func TestAccPolicyGroup_import(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- testVcsAccGithubTokenPreCheck(t)
+ scalr2.testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -277,7 +279,7 @@ func TestAccPolicyGroup_import(t *testing.T) {
func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resID]
if !ok {
@@ -288,7 +290,7 @@ func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup)
return fmt.Errorf("no instance ID is set")
}
- pg, err := scalrClient.PolicyGroups.Read(ctx, rs.Primary.ID)
+ pg, err := scalrClient.PolicyGroups.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -299,7 +301,7 @@ func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup)
}
func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_policy_group" {
@@ -310,7 +312,7 @@ func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
return fmt.Errorf("no instance ID is set")
}
- _, err := scalrClient.PolicyGroups.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.PolicyGroups.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("policy group %s still exists", rs.Primary.ID)
}
@@ -321,7 +323,7 @@ func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
func testAccCheckPolicyGroupRename(policyGroup *scalr.PolicyGroup) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
_, err := scalrClient.PolicyGroups.Update(
context.Background(),
@@ -351,7 +353,7 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), scalr2.githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
func testAccPolicyGroupUpdateConfig(rInt int) string {
@@ -371,7 +373,7 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), scalr2.githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
func testAccPolicyGroupRenamedConfig(rInt int) string {
@@ -391,5 +393,5 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), scalr2.githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
diff --git a/scalr/resource_scalr_provider_configuration.go b/internal/provider/resource_scalr_provider_configuration.go
similarity index 99%
rename from scalr/resource_scalr_provider_configuration.go
rename to internal/provider/resource_scalr_provider_configuration.go
index dbebe7e9..b233b3d0 100644
--- a/scalr/resource_scalr_provider_configuration.go
+++ b/internal/provider/resource_scalr_provider_configuration.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_provider_configuration_default.go b/internal/provider/resource_scalr_provider_configuration_default.go
similarity index 99%
rename from scalr/resource_scalr_provider_configuration_default.go
rename to internal/provider/resource_scalr_provider_configuration_default.go
index b36f4bc1..105d1b3a 100644
--- a/scalr/resource_scalr_provider_configuration_default.go
+++ b/internal/provider/resource_scalr_provider_configuration_default.go
@@ -1,13 +1,14 @@
-package scalr
+package provider
import (
"context"
"errors"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"strings"
"sync"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_provider_configuration_default_test.go b/internal/provider/resource_scalr_provider_configuration_default_test.go
similarity index 85%
rename from scalr/resource_scalr_provider_configuration_default_test.go
rename to internal/provider/resource_scalr_provider_configuration_default_test.go
index 8454c4c1..bc8e8aa7 100644
--- a/scalr/resource_scalr_provider_configuration_default_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_default_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccProviderConfigurationDefault_basic(t *testing.T) {
@@ -14,9 +16,9 @@ func TestAccProviderConfigurationDefault_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testAccPreCheck(t)
+ scalr2.testAccPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
Steps: []resource.TestStep{
{
@@ -36,9 +38,9 @@ func TestAccProviderConfigurationDefault_import(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testAccPreCheck(t)
+ scalr2.testAccPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
Steps: []resource.TestStep{
{
@@ -62,12 +64,12 @@ func testAccCheckProviderConfigurationDefaultExists(
return fmt.Errorf("Not found: %s", rn)
}
- client := testAccProvider.Meta().(*scalr.Client)
+ client := scalr2.testAccProvider.Meta().(*scalr.Client)
providerConfigurationID := rs.Primary.Attributes["provider_configuration_id"]
environmentID := rs.Primary.Attributes["environment_id"]
- environment, err := client.Environments.Read(ctx, environmentID)
+ environment, err := client.Environments.Read(scalr2.ctx, environmentID)
if err != nil {
return err
}
@@ -83,7 +85,7 @@ func testAccCheckProviderConfigurationDefaultExists(
}
func testAccCheckProviderConfigurationDefaultDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_provider_configuration_default" {
@@ -94,7 +96,7 @@ func testAccCheckProviderConfigurationDefaultDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- environment, err := scalrClient.Environments.Read(ctx, rs.Primary.Attributes["environment_id"])
+ environment, err := scalrClient.Environments.Read(scalr2.ctx, rs.Primary.Attributes["environment_id"])
if err == nil {
for _, defaultProviderConfiguration := range environment.DefaultProviderConfigurations {
if defaultProviderConfiguration.ID == rs.Primary.Attributes["provider_configuration_id"] {
diff --git a/scalr/resource_scalr_provider_configuration_test.go b/internal/provider/resource_scalr_provider_configuration_test.go
similarity index 97%
rename from scalr/resource_scalr_provider_configuration_test.go
rename to internal/provider/resource_scalr_provider_configuration_test.go
index 068416e0..185b6b31 100644
--- a/scalr/resource_scalr_provider_configuration_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -13,6 +13,7 @@ import (
"github.com/scalr/go-scalr"
"github.com/scalr/terraform-provider-scalr/internal/client"
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccProviderConfiguration_import(t *testing.T) {
@@ -20,9 +21,9 @@ func TestAccProviderConfiguration_import(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testAccPreCheck(t)
+ scalr2.testAccPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -43,8 +44,8 @@ func TestAccProviderConfiguration_custom(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -165,8 +166,8 @@ func TestAccProviderConfiguration_aws_custom(t *testing.T) {
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -187,8 +188,8 @@ func TestAccProviderConfiguration_aws(t *testing.T) {
accessKeyId, secretAccessKey, roleArn, externalId := getAwsTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -234,8 +235,8 @@ func TestAccProviderConfiguration_scalr(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -279,8 +280,8 @@ func TestAccProviderConfiguration_google(t *testing.T) {
credentials, project := getGoogleTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -325,8 +326,8 @@ func TestAccProviderConfiguration_google_oidc(t *testing.T) {
_, project := getGoogleTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -372,8 +373,8 @@ func TestAccProviderConfiguration_aws_oidc(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -414,8 +415,8 @@ func TestAccProviderConfiguration_azurerm(t *testing.T) {
armClientId, armClientSecret, armSubscription, armTenantId := getAzureTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -694,9 +695,9 @@ func testAccCheckProviderConfigurationExists(n string, providerConfiguration *sc
return fmt.Errorf("Not found: %s", n)
}
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- providerConfigurationResource, err := scalrClient.ProviderConfigurations.Read(ctx, rs.Primary.ID)
+ providerConfigurationResource, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
@@ -709,14 +710,14 @@ func testAccCheckProviderConfigurationExists(n string, providerConfiguration *sc
}
func testAccCheckProviderConfigurationResourceDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_provider_configuration" {
continue
}
- _, err := scalrClient.ProviderConfigurations.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Provider configuraiton (%s) still exists.", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_role.go b/internal/provider/resource_scalr_role.go
similarity index 99%
rename from scalr/resource_scalr_role.go
rename to internal/provider/resource_scalr_role.go
index c633d81f..0b79e4b1 100644
--- a/scalr/resource_scalr_role.go
+++ b/internal/provider/resource_scalr_role.go
@@ -1,14 +1,15 @@
-package scalr
+package provider
import (
"context"
"errors"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
"reflect"
"sort"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_role_migrate.go b/internal/provider/resource_scalr_role_migrate.go
similarity index 98%
rename from scalr/resource_scalr_role_migrate.go
rename to internal/provider/resource_scalr_role_migrate.go
index 3c21725a..8057b6ec 100644
--- a/scalr/resource_scalr_role_migrate.go
+++ b/internal/provider/resource_scalr_role_migrate.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_role_migrate_test.go b/internal/provider/resource_scalr_role_migrate_test.go
similarity index 81%
rename from scalr/resource_scalr_role_migrate_test.go
rename to internal/provider/resource_scalr_role_migrate_test.go
index f19db4cc..9787e53c 100644
--- a/scalr/resource_scalr_role_migrate_test.go
+++ b/internal/provider/resource_scalr_role_migrate_test.go
@@ -1,7 +1,9 @@
-package scalr
+package provider
import (
"testing"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrRoleStateDataV0() map[string]interface{} {
@@ -48,18 +50,18 @@ func testResourceScalrRoleStateDataV1ExistingPerm() map[string]interface{} {
func TestResourceScalrRoleStateUpgradeV0(t *testing.T) {
expected := testResourceScalrRoleStateDataV1()
- actual, err := resourceScalrRoleStateUpgradeV0(ctx, testResourceScalrRoleStateDataV0(), nil)
+ actual, err := resourceScalrRoleStateUpgradeV0(scalr.ctx, testResourceScalrRoleStateDataV0(), nil)
assertCorrectState(t, err, actual, expected)
}
func TestResourceScalrRoleStateUpgradeV0NoGlobalScope(t *testing.T) {
expected := testResourceScalrRoleStateDataV1NoGlobalScope()
- actual, err := resourceScalrRoleStateUpgradeV0(ctx, testResourceScalrRoleStateDataV0NoGlobalScope(), nil)
+ actual, err := resourceScalrRoleStateUpgradeV0(scalr.ctx, testResourceScalrRoleStateDataV0NoGlobalScope(), nil)
assertCorrectState(t, err, actual, expected)
}
func TestResourceScalrRoleStateUpgradeV0ExistingPermission(t *testing.T) {
expected := testResourceScalrRoleStateDataV1ExistingPerm()
- actual, err := resourceScalrRoleStateUpgradeV0(ctx, testResourceScalrRoleStateDataV0ExistingPerm(), nil)
+ actual, err := resourceScalrRoleStateUpgradeV0(scalr.ctx, testResourceScalrRoleStateDataV0ExistingPerm(), nil)
assertCorrectState(t, err, actual, expected)
}
diff --git a/scalr/resource_scalr_role_test.go b/internal/provider/resource_scalr_role_test.go
similarity index 88%
rename from scalr/resource_scalr_role_test.go
rename to internal/provider/resource_scalr_role_test.go
index 0f2fc3e3..3a6695c3 100644
--- a/scalr/resource_scalr_role_test.go
+++ b/internal/provider/resource_scalr_role_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -10,14 +10,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRole_basic(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -40,8 +42,8 @@ func TestAccScalrRole_renamed(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -77,8 +79,8 @@ func TestAccScalrRole_update(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -117,8 +119,8 @@ func TestAccScalrRole_update(t *testing.T) {
func TestAccScalrRole_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -136,7 +138,7 @@ func TestAccScalrRole_import(t *testing.T) {
func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -148,7 +150,7 @@ func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCh
}
// Get the role
- r, err := scalrClient.Roles.Read(ctx, rs.Primary.ID)
+ r, err := scalrClient.Roles.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -161,9 +163,9 @@ func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCh
func testAccCheckScalrRoleRename(role *scalr.Role) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.Roles.Read(ctx, role.ID)
+ r, err := scalrClient.Roles.Read(scalr2.ctx, role.ID)
if err != nil {
log.Fatalf("Error retrieving role: %v", err)
@@ -185,7 +187,7 @@ func testAccCheckScalrRoleRename(role *scalr.Role) func() {
}
func testAccCheckScalrRoleDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_role" {
@@ -196,7 +198,7 @@ func testAccCheckScalrRoleDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Roles.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.Roles.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Role %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_run_schedule_rule.go b/internal/provider/resource_scalr_run_schedule_rule.go
similarity index 99%
rename from scalr/resource_scalr_run_schedule_rule.go
rename to internal/provider/resource_scalr_run_schedule_rule.go
index 01989924..14ddaf93 100644
--- a/scalr/resource_scalr_run_schedule_rule.go
+++ b/internal/provider/resource_scalr_run_schedule_rule.go
@@ -1,13 +1,14 @@
-package scalr
+package provider
import (
"context"
"errors"
+ "log"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/scalr/go-scalr"
- "log"
)
func resourceScalrRunScheduleRule() *schema.Resource {
diff --git a/scalr/resource_scalr_run_schedule_rule_test.go b/internal/provider/resource_scalr_run_schedule_rule_test.go
similarity index 85%
rename from scalr/resource_scalr_run_schedule_rule_test.go
rename to internal/provider/resource_scalr_run_schedule_rule_test.go
index 323896cf..8a5f9c2d 100644
--- a/scalr/resource_scalr_run_schedule_rule_test.go
+++ b/internal/provider/resource_scalr_run_schedule_rule_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,14 +7,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRunScheduleRule_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
@@ -37,8 +39,8 @@ func TestAccScalrRunScheduleRule_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
@@ -69,8 +71,8 @@ func TestAccScalrRunScheduleRule_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
@@ -96,8 +98,8 @@ func testAccCheckScalrRunScheduleRuleExists(resId string, rule *scalr.RunSchedul
return fmt.Errorf("No Run Schedule Rule ID is set")
}
- scalrClient := testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.RunScheduleRules.Read(ctx, rs.Primary.ID)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ r, err := scalrClient.RunScheduleRules.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return fmt.Errorf("Error reading run schedule rule: %v", err)
}
@@ -109,7 +111,7 @@ func testAccCheckScalrRunScheduleRuleExists(resId string, rule *scalr.RunSchedul
}
func testAccCheckScalrRunScheduleRuleDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_run_schedule_rule" {
@@ -120,7 +122,7 @@ func testAccCheckScalrRunScheduleRuleDestroy(s *terraform.State) error {
return fmt.Errorf("No Run Schedule Rule ID is set")
}
- _, err := scalrClient.RunScheduleRules.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.RunScheduleRules.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Run Schedule Rule %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_run_triggers.go b/internal/provider/resource_scalr_run_triggers.go
similarity index 99%
rename from scalr/resource_scalr_run_triggers.go
rename to internal/provider/resource_scalr_run_triggers.go
index 258b90b3..b9588f8c 100644
--- a/scalr/resource_scalr_run_triggers.go
+++ b/internal/provider/resource_scalr_run_triggers.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_run_triggers_test.go b/internal/provider/resource_scalr_run_triggers_test.go
similarity index 80%
rename from scalr/resource_scalr_run_triggers_test.go
rename to internal/provider/resource_scalr_run_triggers_test.go
index 513a85be..44469790 100644
--- a/scalr/resource_scalr_run_triggers_test.go
+++ b/internal/provider/resource_scalr_run_triggers_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
@@ -14,8 +16,8 @@ func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckRunTriggerDestroy,
Steps: []resource.TestStep{
{
@@ -30,7 +32,7 @@ func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
}
func testAccCheckRunTriggerDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_run_trigger" {
@@ -41,7 +43,7 @@ func testAccCheckRunTriggerDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.RunTriggers.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.RunTriggers.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("RunTrigger %s still exists", rs.Primary.ID)
}
@@ -77,7 +79,7 @@ resource "scalr_run_trigger" "foobar" {
func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -88,7 +90,7 @@ func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resour
return fmt.Errorf("No instance ID is set")
}
- rt, err := scalrClient.RunTriggers.Read(ctx, rs.Primary.ID)
+ rt, err := scalrClient.RunTriggers.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -101,7 +103,7 @@ func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resour
func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
environment, ok := s.RootModule().Resources[environmentName]
if !ok {
@@ -109,7 +111,7 @@ func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentN
}
downstreamID := runTrigger.Downstream.ID
- downstream, err := scalrClient.Workspaces.Read(ctx, environment.Primary.ID, "downstream-test")
+ downstream, err := scalrClient.Workspaces.Read(scalr2.ctx, environment.Primary.ID, "downstream-test")
if err != nil {
return fmt.Errorf("Error retreiving workspace downstream-test for environment %s, %v", environmentName, err)
}
@@ -119,7 +121,7 @@ func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentN
}
upstreamID := runTrigger.Upstream.ID
- upstream, err := scalrClient.Workspaces.Read(ctx, environment.Primary.ID, "upstream-test")
+ upstream, err := scalrClient.Workspaces.Read(scalr2.ctx, environment.Primary.ID, "upstream-test")
if err != nil {
return fmt.Errorf("Error retreiving workspace upstream-test for environment %s, %v", environmentName, err)
}
diff --git a/scalr/resource_scalr_service_account.go b/internal/provider/resource_scalr_service_account.go
similarity index 99%
rename from scalr/resource_scalr_service_account.go
rename to internal/provider/resource_scalr_service_account.go
index e17a5d89..b266a8de 100644
--- a/scalr/resource_scalr_service_account.go
+++ b/internal/provider/resource_scalr_service_account.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_service_account_test.go b/internal/provider/resource_scalr_service_account_test.go
similarity index 87%
rename from scalr/resource_scalr_service_account_test.go
rename to internal/provider/resource_scalr_service_account_test.go
index 9755e911..a7b5ef24 100644
--- a/scalr/resource_scalr_service_account_test.go
+++ b/internal/provider/resource_scalr_service_account_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,14 +7,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrServiceAccount_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
@@ -50,8 +52,8 @@ func TestAccScalrServiceAccount_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
@@ -70,8 +72,8 @@ func TestAccScalrServiceAccount_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
@@ -127,7 +129,7 @@ resource scalr_service_account test {
}
func testAccCheckScalrServiceAccountDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_service_account" {
@@ -138,7 +140,7 @@ func testAccCheckScalrServiceAccountDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.ServiceAccounts.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.ServiceAccounts.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Service account %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_service_account_token.go b/internal/provider/resource_scalr_service_account_token.go
similarity index 99%
rename from scalr/resource_scalr_service_account_token.go
rename to internal/provider/resource_scalr_service_account_token.go
index 7a85b82c..f2fdf0f4 100644
--- a/scalr/resource_scalr_service_account_token.go
+++ b/internal/provider/resource_scalr_service_account_token.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
)
diff --git a/scalr/resource_scalr_service_account_token_test.go b/internal/provider/resource_scalr_service_account_token_test.go
similarity index 85%
rename from scalr/resource_scalr_service_account_token_test.go
rename to internal/provider/resource_scalr_service_account_token_test.go
index 3daceec2..3718c9e8 100644
--- a/scalr/resource_scalr_service_account_token_test.go
+++ b/internal/provider/resource_scalr_service_account_token_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,14 +7,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrServiceAccountToken_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
Steps: []resource.TestStep{
{
@@ -38,8 +40,8 @@ func TestAccScalrServiceAccountToken_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
Steps: []resource.TestStep{
{
@@ -59,7 +61,7 @@ func TestAccScalrServiceAccountToken_update(t *testing.T) {
}
func testAccCheckScalrServiceAccountTokenDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_service_account_token" {
@@ -69,7 +71,7 @@ func testAccCheckScalrServiceAccountTokenDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.AccessTokens.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.AccessTokens.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Service account token %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_slack_integration.go b/internal/provider/resource_scalr_slack_integration.go
similarity index 99%
rename from scalr/resource_scalr_slack_integration.go
rename to internal/provider/resource_scalr_slack_integration.go
index cb23b9cf..7348cbd5 100644
--- a/scalr/resource_scalr_slack_integration.go
+++ b/internal/provider/resource_scalr_slack_integration.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_slack_integration_test.go b/internal/provider/resource_scalr_slack_integration_test.go
similarity index 94%
rename from scalr/resource_scalr_slack_integration_test.go
rename to internal/provider/resource_scalr_slack_integration_test.go
index 85658ea0..6f2d8445 100644
--- a/scalr/resource_scalr_slack_integration_test.go
+++ b/internal/provider/resource_scalr_slack_integration_test.go
@@ -1,20 +1,22 @@
-package scalr
+package provider
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccSlackIntegration_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- testAccPreCheck(t)
+ scalr.testAccPreCheck(t)
scalrClient, _ := createScalrClient()
- slackConnection, err := scalrClient.SlackIntegrations.GetConnection(ctx, defaultAccount)
+ slackConnection, err := scalrClient.SlackIntegrations.GetConnection(scalr.ctx, defaultAccount)
if err != nil {
t.Fatalf("Error fetching Slack connection: %v", err)
return
@@ -23,7 +25,7 @@ func TestAccSlackIntegration_basic(t *testing.T) {
t.Skip("Scalr instance doesn't have working slack connection.")
}
},
- ProviderFactories: testAccProviderFactories,
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrSlackIntegrationConfig(),
diff --git a/scalr/resource_scalr_ssh_key.go b/internal/provider/resource_scalr_ssh_key.go
similarity index 99%
rename from scalr/resource_scalr_ssh_key.go
rename to internal/provider/resource_scalr_ssh_key.go
index d6e50d69..c6f908f3 100644
--- a/scalr/resource_scalr_ssh_key.go
+++ b/internal/provider/resource_scalr_ssh_key.go
@@ -1,8 +1,9 @@
-package scalr
+package provider
import (
"context"
"errors"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
diff --git a/scalr/resource_scalr_ssh_key_test.go b/internal/provider/resource_scalr_ssh_key_test.go
similarity index 87%
rename from scalr/resource_scalr_ssh_key_test.go
rename to internal/provider/resource_scalr_ssh_key_test.go
index 6d3385c7..41c43e43 100644
--- a/scalr/resource_scalr_ssh_key_test.go
+++ b/internal/provider/resource_scalr_ssh_key_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrSSHKey_basic(t *testing.T) {
@@ -17,8 +19,8 @@ func TestAccScalrSSHKey_basic(t *testing.T) {
var sshKey scalr.SSHKey
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
@@ -38,8 +40,8 @@ func TestAccScalrSSHKey_update(t *testing.T) {
var sshKey scalr.SSHKey
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
@@ -64,8 +66,8 @@ func TestAccScalrSSHKey_import(t *testing.T) {
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
@@ -112,7 +114,7 @@ EOF
}
func testAccCheckSSHKeyDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_ssh_key" {
@@ -139,7 +141,7 @@ func testAccCheckSSHKeyIsShared(resourceName string, expectedIsShared bool, sshK
return fmt.Errorf("Not found: %s", resourceName)
}
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
readKey, err := scalrClient.SSHKeys.Read(context.Background(), rs.Primary.ID)
if err != nil {
return fmt.Errorf("Error reading SSH key: %s", err)
diff --git a/scalr/resource_scalr_tag.go b/internal/provider/resource_scalr_tag.go
similarity index 99%
rename from scalr/resource_scalr_tag.go
rename to internal/provider/resource_scalr_tag.go
index 487272ba..4ceab8a3 100644
--- a/scalr/resource_scalr_tag.go
+++ b/internal/provider/resource_scalr_tag.go
@@ -1,12 +1,13 @@
-package scalr
+package provider
import (
"context"
"errors"
+ "log"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
- "log"
)
func resourceScalrTag() *schema.Resource {
diff --git a/scalr/resource_scalr_tag_test.go b/internal/provider/resource_scalr_tag_test.go
similarity index 83%
rename from scalr/resource_scalr_tag_test.go
rename to internal/provider/resource_scalr_tag_test.go
index 00fd3b16..88e84ef5 100644
--- a/scalr/resource_scalr_tag_test.go
+++ b/internal/provider/resource_scalr_tag_test.go
@@ -1,21 +1,24 @@
-package scalr
+package provider
import (
"context"
"fmt"
+ "log"
+ "testing"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
- "log"
- "testing"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrTag_basic(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -33,8 +36,8 @@ func TestAccScalrTag_basic(t *testing.T) {
func TestAccScalrTag_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -54,8 +57,8 @@ func TestAccScalrTag_update(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -83,8 +86,8 @@ func TestAccScalrTag_renamed(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -135,9 +138,9 @@ resource scalr_tag test {
func testAccCheckScalrTagRename(tag *scalr.Tag) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- t, err := scalrClient.Tags.Read(ctx, tag.ID)
+ t, err := scalrClient.Tags.Read(scalr2.ctx, tag.ID)
if err != nil {
log.Fatalf("Error retrieving tag: %v", err)
@@ -161,7 +164,7 @@ func testAccCheckScalrTagRename(tag *scalr.Tag) func() {
func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -173,7 +176,7 @@ func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheck
}
// Get the tag
- t, err := scalrClient.Tags.Read(ctx, rs.Primary.ID)
+ t, err := scalrClient.Tags.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -185,7 +188,7 @@ func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheck
}
func testAccCheckScalrTagDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_tag" {
@@ -196,7 +199,7 @@ func testAccCheckScalrTagDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Tags.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.Tags.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Tag %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_variable.go b/internal/provider/resource_scalr_variable.go
similarity index 99%
rename from scalr/resource_scalr_variable.go
rename to internal/provider/resource_scalr_variable.go
index dc7bdae2..946c5939 100644
--- a/scalr/resource_scalr_variable.go
+++ b/internal/provider/resource_scalr_variable.go
@@ -1,8 +1,9 @@
-package scalr
+package provider
import (
"context"
"errors"
+ "log"
"time"
"github.com/hashicorp/go-cty/cty"
@@ -11,8 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/scalr/go-scalr"
-
- "log"
)
func resourceScalrVariable() *schema.Resource {
diff --git a/scalr/resource_scalr_variable_migrate.go b/internal/provider/resource_scalr_variable_migrate.go
similarity index 99%
rename from scalr/resource_scalr_variable_migrate.go
rename to internal/provider/resource_scalr_variable_migrate.go
index f690f9c2..183bcd79 100644
--- a/scalr/resource_scalr_variable_migrate.go
+++ b/internal/provider/resource_scalr_variable_migrate.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_variable_migrate_test.go b/internal/provider/resource_scalr_variable_migrate_test.go
similarity index 80%
rename from scalr/resource_scalr_variable_migrate_test.go
rename to internal/provider/resource_scalr_variable_migrate_test.go
index fdf99178..d0b2e5a0 100644
--- a/scalr/resource_scalr_variable_migrate_test.go
+++ b/internal/provider/resource_scalr_variable_migrate_test.go
@@ -1,10 +1,12 @@
-package scalr
+package provider
import (
"context"
"testing"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrVariableStateDataV0() map[string]interface{} {
@@ -29,7 +31,7 @@ func TestResourceScalrVariableStateUpgradeV0(t *testing.T) {
})
expected := testResourceScalrVariableStateDataV1()
- actual, err := resourceScalrVariableStateUpgradeV0(ctx, testResourceScalrVariableStateDataV0(), client)
+ actual, err := resourceScalrVariableStateUpgradeV0(scalr2.ctx, testResourceScalrVariableStateDataV0(), client)
assertCorrectState(t, err, actual, expected)
}
@@ -47,7 +49,7 @@ func testResourceScalrVariableStateDataCategoryV1() map[string]interface{} {
func TestResourceScalrVariableStateUpgradeV1(t *testing.T) {
expected := testResourceScalrVariableStateDataCategoryV1()
- actual, err := resourceScalrVariableStateUpgradeV1(ctx, testResourceScalrVariableStateDataCategoryV0(), nil)
+ actual, err := resourceScalrVariableStateUpgradeV1(scalr2.ctx, testResourceScalrVariableStateDataCategoryV0(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -68,7 +70,7 @@ func TestResourceScalrVariableStateUpgradeV2(t *testing.T) {
client := testScalrClient(t)
variable, _ := client.Variables.Create(context.Background(), scalr.VariableCreateOptions{ID: "var-123"})
expected := testResourceScalrVariableStateDataDescriptionV2(variable.ID)
- actual, err := resourceScalrVariableStateUpgradeV2(ctx, testResourceScalrVariableStateDataDescriptionV1(variable.ID), client)
+ actual, err := resourceScalrVariableStateUpgradeV2(scalr2.ctx, testResourceScalrVariableStateDataDescriptionV1(variable.ID), client)
assertCorrectState(t, err, actual, expected)
}
diff --git a/scalr/resource_scalr_variable_test.go b/internal/provider/resource_scalr_variable_test.go
similarity index 93%
rename from scalr/resource_scalr_variable_test.go
rename to internal/provider/resource_scalr_variable_test.go
index 98d0b2b5..80cd5b9f 100644
--- a/scalr/resource_scalr_variable_test.go
+++ b/internal/provider/resource_scalr_variable_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
const baseForUpdate = `
@@ -26,8 +28,8 @@ func TestAccScalrVariable_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -84,8 +86,8 @@ func TestAccScalrVariable_basic(t *testing.T) {
func TestAccScalrVariable_defaults(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -111,8 +113,8 @@ func TestAccScalrVariable_scopes(t *testing.T) {
variable := &scalr.Variable{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -128,8 +130,8 @@ func TestAccScalrVariable_update(t *testing.T) {
variable := &scalr.Variable{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -188,8 +190,8 @@ func TestAccScalrVariable_update(t *testing.T) {
func TestAccScalrVariable_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -205,7 +207,7 @@ func TestAccScalrVariable_import(t *testing.T) {
}
func variableFromState(s *terraform.State, n string, v *scalr.Variable) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -216,7 +218,7 @@ func variableFromState(s *terraform.State, n string, v *scalr.Variable) error {
return fmt.Errorf("No instance ID is set")
}
- variable, err := scalrClient.Variables.Read(ctx, rs.Primary.ID)
+ variable, err := scalrClient.Variables.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -333,7 +335,7 @@ func testAccCheckScalrVariableAttributesUpdate(
}
func testAccCheckScalrVariableDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_variable" {
@@ -344,7 +346,7 @@ func testAccCheckScalrVariableDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Variables.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.Variables.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Variable %s still exists", rs.Primary.ID)
}
diff --git a/scalr/resource_scalr_vcs_provider.go b/internal/provider/resource_scalr_vcs_provider.go
similarity index 99%
rename from scalr/resource_scalr_vcs_provider.go
rename to internal/provider/resource_scalr_vcs_provider.go
index d38eca27..1778d589 100644
--- a/scalr/resource_scalr_vcs_provider.go
+++ b/internal/provider/resource_scalr_vcs_provider.go
@@ -1,11 +1,12 @@
-package scalr
+package provider
import (
"context"
"errors"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/scalr/go-scalr"
diff --git a/scalr/resource_scalr_vcs_provider_migrate.go b/internal/provider/resource_scalr_vcs_provider_migrate.go
similarity index 98%
rename from scalr/resource_scalr_vcs_provider_migrate.go
rename to internal/provider/resource_scalr_vcs_provider_migrate.go
index 3ffd3c86..3554408e 100644
--- a/scalr/resource_scalr_vcs_provider_migrate.go
+++ b/internal/provider/resource_scalr_vcs_provider_migrate.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_vcs_provider_migrate_test.go b/internal/provider/resource_scalr_vcs_provider_migrate_test.go
similarity index 76%
rename from scalr/resource_scalr_vcs_provider_migrate_test.go
rename to internal/provider/resource_scalr_vcs_provider_migrate_test.go
index 79731445..b9d419a9 100644
--- a/scalr/resource_scalr_vcs_provider_migrate_test.go
+++ b/internal/provider/resource_scalr_vcs_provider_migrate_test.go
@@ -1,7 +1,9 @@
-package scalr
+package provider
import (
"testing"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrVcsProviderStateDataV0() map[string]interface{} {
@@ -22,6 +24,6 @@ func testResourceScalrVcsProviderStateDataV1() map[string]interface{} {
func TestResourceScalrVcsProviderStateUpgradeV0(t *testing.T) {
expected := testResourceScalrVcsProviderStateDataV1()
- actual, err := resourceScalrVcsProviderStateUpgradeV0(ctx, testResourceScalrVcsProviderStateDataV0(), nil)
+ actual, err := resourceScalrVcsProviderStateUpgradeV0(scalr.ctx, testResourceScalrVcsProviderStateDataV0(), nil)
assertCorrectState(t, err, actual, expected)
}
diff --git a/scalr/resource_scalr_vcs_provider_test.go b/internal/provider/resource_scalr_vcs_provider_test.go
similarity index 81%
rename from scalr/resource_scalr_vcs_provider_test.go
rename to internal/provider/resource_scalr_vcs_provider_test.go
index 7ad75623..8f3c5a49 100644
--- a/scalr/resource_scalr_vcs_provider_test.go
+++ b/internal/provider/resource_scalr_vcs_provider_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -8,14 +8,16 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccVcsProvider_basic(t *testing.T) {
provider := &scalr.VcsProvider{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrVcsProviderConfig(),
@@ -30,7 +32,7 @@ func TestAccVcsProvider_basic(t *testing.T) {
),
},
{
- Config: testAccScalrVcsProviderUpdate(githubToken, scalr.Github),
+ Config: testAccScalrVcsProviderUpdate(scalr2.githubToken, scalr.Github),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrVcsProviderExists("scalr_vcs_provider.test", provider),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "name", "updated-github-vcs-provider"),
@@ -45,7 +47,7 @@ func TestAccVcsProvider_basic(t *testing.T) {
ExpectError: regexp.MustCompile("Invalid access token"),
},
{
- Config: testAccScalrVcsProviderUpdate(githubToken, scalr.Gitlab),
+ Config: testAccScalrVcsProviderUpdate(scalr2.githubToken, scalr.Gitlab),
ExpectError: regexp.MustCompile("Invalid access token"),
},
},
@@ -55,8 +57,8 @@ func TestAccVcsProvider_basic(t *testing.T) {
func TestAccVcsProvider_globalScope(t *testing.T) {
provider := &scalr.VcsProvider{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVcsProviderDestroy,
Steps: []resource.TestStep{
{
@@ -66,7 +68,7 @@ func TestAccVcsProvider_globalScope(t *testing.T) {
vcs_type="github"
token="%s"
}
- `, githubToken),
+ `, scalr2.githubToken),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrVcsProviderExists("scalr_vcs_provider.test", provider),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "name", "global-github-vcs-provider"),
@@ -80,8 +82,8 @@ func TestAccVcsProvider_globalScope(t *testing.T) {
func TestAccScalrVcsProvider_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrVcsProviderDestroy,
Steps: []resource.TestStep{
{
@@ -99,7 +101,7 @@ func TestAccScalrVcsProvider_import(t *testing.T) {
func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProvider) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -107,11 +109,11 @@ func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProv
}
if rs.Primary.ID == "" {
- return noInstanceIdErr
+ return scalr2.noInstanceIdErr
}
// Get the role
- p, err := scalrClient.VcsProviders.Read(ctx, rs.Primary.ID)
+ p, err := scalrClient.VcsProviders.Read(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -123,7 +125,7 @@ func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProv
}
func testAccCheckScalrVcsProviderDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_vcs_provider" {
@@ -131,10 +133,10 @@ func testAccCheckScalrVcsProviderDestroy(s *terraform.State) error {
}
if rs.Primary.ID == "" {
- return noInstanceIdErr
+ return scalr2.noInstanceIdErr
}
- _, err := scalrClient.VcsProviders.Read(ctx, rs.Primary.ID)
+ _, err := scalrClient.VcsProviders.Read(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Role %s still exists", rs.Primary.ID)
}
@@ -150,7 +152,7 @@ resource "scalr_vcs_provider" "test" {
account_id = "%s"
vcs_type="github"
token = "%s"
-}`, defaultAccount, githubToken)
+}`, defaultAccount, scalr2.githubToken)
}
func testAccScalrVcsProviderUpdate(token string, vcsType scalr.VcsType) string {
diff --git a/scalr/resource_scalr_webhook.go b/internal/provider/resource_scalr_webhook.go
similarity index 99%
rename from scalr/resource_scalr_webhook.go
rename to internal/provider/resource_scalr_webhook.go
index d8b37b98..cf6e5457 100644
--- a/scalr/resource_scalr_webhook.go
+++ b/internal/provider/resource_scalr_webhook.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_webhook_migrate.go b/internal/provider/resource_scalr_webhook_migrate.go
similarity index 99%
rename from scalr/resource_scalr_webhook_migrate.go
rename to internal/provider/resource_scalr_webhook_migrate.go
index 661f459c..45eacde1 100644
--- a/scalr/resource_scalr_webhook_migrate.go
+++ b/internal/provider/resource_scalr_webhook_migrate.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_webhook_test.go b/internal/provider/resource_scalr_webhook_test.go
similarity index 90%
rename from scalr/resource_scalr_webhook_test.go
rename to internal/provider/resource_scalr_webhook_test.go
index 79cc76b2..f31c36a5 100644
--- a/scalr/resource_scalr_webhook_test.go
+++ b/internal/provider/resource_scalr_webhook_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
@@ -6,14 +6,16 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccWebhook_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccWebhookConfig(rInt),
@@ -32,8 +34,8 @@ func TestAccWebhook_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccWebhookConfigUpdateEmptyEvent(rInt),
diff --git a/scalr/resource_scalr_workspace.go b/internal/provider/resource_scalr_workspace.go
similarity index 99%
rename from scalr/resource_scalr_workspace.go
rename to internal/provider/resource_scalr_workspace.go
index de66e9b8..46da0d79 100644
--- a/scalr/resource_scalr_workspace.go
+++ b/internal/provider/resource_scalr_workspace.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_workspace_migrate.go b/internal/provider/resource_scalr_workspace_migrate.go
similarity index 99%
rename from scalr/resource_scalr_workspace_migrate.go
rename to internal/provider/resource_scalr_workspace_migrate.go
index 8a91f338..4fb5f741 100644
--- a/scalr/resource_scalr_workspace_migrate.go
+++ b/internal/provider/resource_scalr_workspace_migrate.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/resource_scalr_workspace_migrate_test.go b/internal/provider/resource_scalr_workspace_migrate_test.go
similarity index 81%
rename from scalr/resource_scalr_workspace_migrate_test.go
rename to internal/provider/resource_scalr_workspace_migrate_test.go
index 6b63ce9c..eabf50de 100644
--- a/scalr/resource_scalr_workspace_migrate_test.go
+++ b/internal/provider/resource_scalr_workspace_migrate_test.go
@@ -1,8 +1,11 @@
-package scalr
+package provider
import (
- "github.com/scalr/go-scalr"
"testing"
+
+ "github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrWorkspaceStateDataV0() map[string]interface{} {
@@ -21,7 +24,7 @@ func testResourceScalrWorkspaceStateDataV1() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV0(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV1()
- actual, err := resourceScalrWorkspaceStateUpgradeV0(ctx, testResourceScalrWorkspaceStateDataV0(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV0(scalr2.ctx, testResourceScalrWorkspaceStateDataV0(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -60,13 +63,13 @@ func testResourceScalrWorkspaceStateDataV2NoVcs() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV1(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV2()
- actual, err := resourceScalrWorkspaceStateUpgradeV1(ctx, testResourceScalrWorkspaceStateDataV1VcsRepo(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV1(scalr2.ctx, testResourceScalrWorkspaceStateDataV1VcsRepo(), nil)
assertCorrectState(t, err, actual, expected)
}
func TestResourceScalrWorkspaceStateUpgradeV1NoVcs(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV2NoVcs()
- actual, err := resourceScalrWorkspaceStateUpgradeV1(ctx, testResourceScalrWorkspaceStateDataV1(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV1(scalr2.ctx, testResourceScalrWorkspaceStateDataV1(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -78,7 +81,7 @@ func testResourceScalrWorkspaceStateDataV3() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV2(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV3()
- actual, err := resourceScalrWorkspaceStateUpgradeV2(ctx, testResourceScalrWorkspaceStateDataV2(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV2(scalr2.ctx, testResourceScalrWorkspaceStateDataV2(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -106,6 +109,6 @@ func testResourceScalrWorkspaceStateDataV4Operations() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV3(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV4Operations()
- actual, err := resourceScalrWorkspaceStateUpgradeV3(ctx, testResourceScalrWorkspaceStateDataV3Operations(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV3(scalr2.ctx, testResourceScalrWorkspaceStateDataV3Operations(), nil)
assertCorrectState(t, err, actual, expected)
}
diff --git a/scalr/resource_scalr_workspace_run_schedule.go b/internal/provider/resource_scalr_workspace_run_schedule.go
similarity index 99%
rename from scalr/resource_scalr_workspace_run_schedule.go
rename to internal/provider/resource_scalr_workspace_run_schedule.go
index e80e2ace..0e8d48e2 100644
--- a/scalr/resource_scalr_workspace_run_schedule.go
+++ b/internal/provider/resource_scalr_workspace_run_schedule.go
@@ -1,13 +1,14 @@
-package scalr
+package provider
import (
"context"
"errors"
"fmt"
+ "log"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
- "log"
)
func resourceScalrWorkspaceRunSchedule() *schema.Resource {
diff --git a/scalr/resource_scalr_workspace_run_schedule_test.go b/internal/provider/resource_scalr_workspace_run_schedule_test.go
similarity index 88%
rename from scalr/resource_scalr_workspace_run_schedule_test.go
rename to internal/provider/resource_scalr_workspace_run_schedule_test.go
index 4ab6a583..3bc63be8 100644
--- a/scalr/resource_scalr_workspace_run_schedule_test.go
+++ b/internal/provider/resource_scalr_workspace_run_schedule_test.go
@@ -1,17 +1,20 @@
-package scalr
+package provider
import (
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestScalrWorkspaceRunSchedule_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -31,8 +34,8 @@ func TestScalrWorkspaceRunSchedule_default(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr.testAccPreCheck(t) },
+ ProviderFactories: scalr.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
diff --git a/scalr/resource_scalr_workspace_test.go b/internal/provider/resource_scalr_workspace_test.go
similarity index 94%
rename from scalr/resource_scalr_workspace_test.go
rename to internal/provider/resource_scalr_workspace_test.go
index 121d5f90..e7642e14 100644
--- a/scalr/resource_scalr_workspace_test.go
+++ b/internal/provider/resource_scalr_workspace_test.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
@@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspace_basic(t *testing.T) {
@@ -17,8 +19,8 @@ func TestAccScalrWorkspace_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -72,8 +74,8 @@ func TestAccScalrWorkspace_create_missed_vcs_attr(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceMissedVcsProvider(rInt),
@@ -92,8 +94,8 @@ func TestAccScalrWorkspace_monorepo(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -124,8 +126,8 @@ func TestAccScalrWorkspace_renamed(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -199,8 +201,8 @@ func TestAccScalrWorkspace_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -320,8 +322,8 @@ func TestAccScalrWorkspace_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -342,8 +344,8 @@ func TestAccScalrWorkspace_providerConfiguration(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -377,8 +379,8 @@ func TestAccScalrWorkspaceSSHKey(t *testing.T) {
sshKeyName := fmt.Sprintf("ssh-key-test-%d", rInt)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -397,7 +399,7 @@ func TestAccScalrWorkspaceSSHKey(t *testing.T) {
func testAccCheckScalrSSHKeyExists(n string, sshKey *scalr.SSHKey) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -422,8 +424,8 @@ func TestAccScalrWorkspace_emptyHooks(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { scalr2.testAccPreCheck(t) },
+ ProviderFactories: scalr2.testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -436,7 +438,7 @@ func TestAccScalrWorkspace_emptyHooks(t *testing.T) {
func testAccCheckScalrWorkspaceExists(
n string, workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -448,7 +450,7 @@ func testAccCheckScalrWorkspaceExists(
}
// Get the workspace
- w, err := scalrClient.Workspaces.ReadByID(ctx, rs.Primary.ID)
+ w, err := scalrClient.Workspaces.ReadByID(scalr2.ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -500,10 +502,10 @@ func testAccCheckScalrWorkspaceMonorepoAttributes(
func testAccCheckScalrWorkspaceRename(environmentName, workspaceName string) func() {
return func() {
var environmentID *string
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
listOptions := scalr.EnvironmentListOptions{}
- envl, err := scalrClient.Environments.List(ctx, listOptions)
+ envl, err := scalrClient.Environments.List(scalr2.ctx, listOptions)
if err != nil {
log.Fatalf("Error retrieving environments: %v", err)
}
@@ -519,7 +521,7 @@ func testAccCheckScalrWorkspaceRename(environmentName, workspaceName string) fun
return
}
- ws, err := scalrClient.Workspaces.Read(ctx, *environmentID, workspaceName)
+ ws, err := scalrClient.Workspaces.Read(scalr2.ctx, *environmentID, workspaceName)
if err != nil {
log.Fatalf("Error retrieving workspace: %v", err)
@@ -570,9 +572,9 @@ func testAccCheckScalrWorkspaceAttributesUpdated(
func testAccCheckScalrWorkspaceProviderConfigurations(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- links, err := getProviderConfigurationWorkspaceLinks(ctx, scalrClient, workspace.ID)
+ links, err := getProviderConfigurationWorkspaceLinks(scalr2.ctx, scalrClient, workspace.ID)
if err != nil {
return fmt.Errorf("Error retrieving provider configuration links: %v", err)
}
@@ -624,9 +626,9 @@ func testAccCheckScalrWorkspaceProviderConfigurations(
func testAccCheckScalrWorkspaceProviderConfigurationsUpdated(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- links, err := getProviderConfigurationWorkspaceLinks(ctx, scalrClient, workspace.ID)
+ links, err := getProviderConfigurationWorkspaceLinks(scalr2.ctx, scalrClient, workspace.ID)
if err != nil {
return fmt.Errorf("Error retrieving provider configuration links: %v", err)
}
@@ -677,7 +679,7 @@ func testAccCheckScalrWorkspaceProviderConfigurationsUpdated(
}
func testAccCheckScalrWorkspaceDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_workspace" {
@@ -688,7 +690,7 @@ func testAccCheckScalrWorkspaceDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Workspaces.ReadByID(ctx, rs.Primary.ID)
+ _, err := scalrClient.Workspaces.ReadByID(scalr2.ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Workspace %s still exists", rs.Primary.ID)
}
diff --git a/scalr/testing.go b/internal/provider/testing.go
similarity index 98%
rename from scalr/testing.go
rename to internal/provider/testing.go
index 172c710c..1d5bc515 100644
--- a/scalr/testing.go
+++ b/internal/provider/testing.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"fmt"
diff --git a/scalr/workspace_helpers.go b/internal/provider/workspace_helpers.go
similarity index 98%
rename from scalr/workspace_helpers.go
rename to internal/provider/workspace_helpers.go
index 878122d6..3efef315 100644
--- a/scalr/workspace_helpers.go
+++ b/internal/provider/workspace_helpers.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
diff --git a/scalr/workspace_helpers_test.go b/internal/provider/workspace_helpers_test.go
similarity index 92%
rename from scalr/workspace_helpers_test.go
rename to internal/provider/workspace_helpers_test.go
index 3d69b80c..b29ed08d 100644
--- a/scalr/workspace_helpers_test.go
+++ b/internal/provider/workspace_helpers_test.go
@@ -1,10 +1,12 @@
-package scalr
+package provider
import (
"context"
"testing"
"github.com/scalr/go-scalr"
+
+ scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestFetchWorkspaceID(t *testing.T) {
@@ -40,7 +42,7 @@ func TestFetchWorkspaceID(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
- got, err := fetchWorkspaceID(ctx, test.def, client)
+ got, err := fetchWorkspaceID(scalr2.ctx, test.def, client)
if (err != nil) != test.err {
t.Fatalf("expected error is %t, got %v", test.err, err)
diff --git a/main.go b/main.go
index 03f30665..94fba414 100644
--- a/main.go
+++ b/main.go
@@ -12,7 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/terraform-provider-scalr/internal/provider"
- "github.com/scalr/terraform-provider-scalr/scalr"
"github.com/scalr/terraform-provider-scalr/version"
)
@@ -46,7 +45,7 @@ func main() {
// New provider implementation with Terraform Plugin Framework
providerserver.NewProtocol5(provider.New(version.ProviderVersion)()),
// Classic provider implementation with Terraform Plugin SDK
- scalr.Provider().GRPCProvider,
+ provider.Provider().GRPCProvider,
}
muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
From d98d9bbb4934cd5d9967d08f830626f62bccef55 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Fri, 22 Nov 2024 09:43:40 +0200
Subject: [PATCH 10/26] SCALRCORE-26654 Move existing provider modules to
internal/provider package
---
.../data_source_scalr_access_policy_test.go | 12 ++--
.../data_source_scalr_agent_pool_test.go | 26 ++++----
.../data_source_scalr_current_account_test.go | 10 ++-
.../data_source_scalr_current_run_test.go | 18 +++---
.../data_source_scalr_environment_test.go | 20 +++---
.../data_source_scalr_environments_test.go | 6 +-
...rce_scalr_event_bridge_integration_test.go | 6 +-
.../data_source_scalr_iam_team_test.go | 16 +++--
.../data_source_scalr_iam_user_test.go | 26 ++++----
.../data_source_scalr_module_version_test.go | 16 +++--
.../data_source_scalr_module_versions_test.go | 8 +--
.../data_source_scalr_policy_group_test.go | 30 +++++----
...ource_scalr_provider_configuration_test.go | 13 ++--
...urce_scalr_provider_configurations_test.go | 8 +--
.../provider/data_source_scalr_role_test.go | 16 +++--
.../data_source_scalr_service_account_test.go | 12 ++--
.../data_source_scalr_ssh_key_test.go | 17 +++--
.../provider/data_source_scalr_tag_test.go | 18 +++---
.../data_source_scalr_variable_test.go | 22 +++----
.../data_source_scalr_variables_test.go | 16 +++--
.../data_source_scalr_vcs_provider_test.go | 18 +++---
.../data_source_scalr_webhook_test.go | 14 ++---
.../data_source_scalr_workspace_ids_test.go | 14 ++---
.../data_source_scalr_workspace_test.go | 12 ++--
.../data_source_scalr_workspaces_test.go | 6 +-
.../resource_scalr_access_policy_test.go | 38 ++++++------
...resource_scalr_account_allowed_ips_test.go | 22 +++----
.../resource_scalr_agent_pool_test.go | 30 +++++----
.../resource_scalr_agent_pool_token_test.go | 28 ++++-----
.../resource_scalr_environment_test.go | 30 +++++----
...rce_scalr_event_bridge_integration_test.go | 6 +-
.../provider/resource_scalr_iam_team_test.go | 30 +++++----
.../provider/resource_scalr_module_test.go | 22 +++----
...esource_scalr_policy_group_linkage_test.go | 20 +++---
.../resource_scalr_policy_group_test.go | 34 +++++-----
...alr_provider_configuration_default_test.go | 18 +++---
...ource_scalr_provider_configuration_test.go | 45 +++++++-------
.../resource_scalr_role_migrate_test.go | 8 +--
internal/provider/resource_scalr_role_test.go | 30 +++++----
.../resource_scalr_run_schedule_rule_test.go | 22 +++----
.../resource_scalr_run_triggers_test.go | 20 +++---
.../resource_scalr_service_account_test.go | 18 +++---
...source_scalr_service_account_token_test.go | 14 ++---
.../resource_scalr_slack_integration_test.go | 8 +--
.../provider/resource_scalr_ssh_key_test.go | 18 +++---
internal/provider/resource_scalr_tag_test.go | 30 +++++----
.../resource_scalr_variable_migrate_test.go | 8 +--
.../provider/resource_scalr_variable_test.go | 30 +++++----
...esource_scalr_vcs_provider_migrate_test.go | 4 +-
.../resource_scalr_vcs_provider_test.go | 34 +++++-----
.../provider/resource_scalr_webhook_test.go | 10 ++-
.../resource_scalr_workspace_migrate_test.go | 12 ++--
...ource_scalr_workspace_run_schedule_test.go | 10 ++-
.../provider/resource_scalr_workspace_test.go | 62 +++++++++----------
internal/provider/workspace_helpers_test.go | 4 +-
55 files changed, 467 insertions(+), 578 deletions(-)
diff --git a/internal/provider/data_source_scalr_access_policy_test.go b/internal/provider/data_source_scalr_access_policy_test.go
index 183d7e9c..968958f2 100644
--- a/internal/provider/data_source_scalr_access_policy_test.go
+++ b/internal/provider/data_source_scalr_access_policy_test.go
@@ -6,24 +6,22 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAccessPolicyDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyDataSourceConfig(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_access_policy.test", "id"),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "subject.0.type", "user"),
- resource.TestCheckResourceAttr("data.scalr_access_policy.test", "subject.0.id", scalr.testUser),
+ resource.TestCheckResourceAttr("data.scalr_access_policy.test", "subject.0.id", testUser),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "is_system", "false"),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "scope.0.type", "environment"),
- resource.TestCheckResourceAttr("data.scalr_access_policy.test", "role_ids.0", scalr.readOnlyRole),
+ resource.TestCheckResourceAttr("data.scalr_access_policy.test", "role_ids.0", readOnlyRole),
resource.TestCheckResourceAttr("data.scalr_access_policy.test", "role_ids.#", "1"),
),
},
@@ -59,7 +57,7 @@ resource "scalr_access_policy" "test" {
data "scalr_access_policy" "test" {
id = scalr_access_policy.test.id
-}`, scalr.defaultAccount, scalr.testUser, scalr.readOnlyRole)
+}`, defaultAccount, testUser, readOnlyRole)
}
func testAccAccessPolicyDataSourceNotFoundConfig() string {
diff --git a/internal/provider/data_source_scalr_agent_pool_test.go b/internal/provider/data_source_scalr_agent_pool_test.go
index e1e8ca9b..ddf13458 100644
--- a/internal/provider/data_source_scalr_agent_pool_test.go
+++ b/internal/provider/data_source_scalr_agent_pool_test.go
@@ -6,14 +6,12 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_agent_pool test {}`,
@@ -36,7 +34,7 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "ds-agent_pool-test-acc"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
),
},
{
@@ -45,7 +43,7 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "ds-agent_pool-test-acc"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
),
},
{
@@ -54,7 +52,7 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "ds-agent_pool-test-acc"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
),
},
},
@@ -62,8 +60,8 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
}
func TestAccScalrAgentPoolDataSource_basic_env(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolEnvDataSourceConfig(),
@@ -71,7 +69,7 @@ func TestAccScalrAgentPoolDataSource_basic_env(t *testing.T) {
testAccCheckEqualID("data.scalr_agent_pool.test", "scalr_agent_pool.test"),
resource.TestCheckResourceAttrSet("data.scalr_agent_pool.test", "id"),
resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "name", "agent_pool-test-env-ds"),
- resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_agent_pool.test", "account_id", defaultAccount),
),
},
},
@@ -87,7 +85,7 @@ resource "scalr_agent_pool" "test" {
data "scalr_agent_pool" "test" {
id = scalr_agent_pool.test.id
account_id = scalr_agent_pool.test.account_id
-}`, scalr.defaultAccount)
+}`, defaultAccount)
var testAccScalrAgentPoolAccountDataSourceByNameConfig = fmt.Sprintf(`
resource "scalr_agent_pool" "test" {
@@ -98,7 +96,7 @@ resource "scalr_agent_pool" "test" {
data "scalr_agent_pool" "test" {
name = scalr_agent_pool.test.name
account_id = scalr_agent_pool.test.account_id
-}`, scalr.defaultAccount)
+}`, defaultAccount)
var testAccScalrAgentPoolAccountDataSourceByIDAndNameConfig = fmt.Sprintf(`
resource "scalr_agent_pool" "test" {
@@ -110,7 +108,7 @@ data "scalr_agent_pool" "test" {
id = scalr_agent_pool.test.id
name = scalr_agent_pool.test.name
account_id = scalr_agent_pool.test.account_id
-}`, scalr.defaultAccount)
+}`, defaultAccount)
func testAccScalrAgentPoolEnvDataSourceConfig() string {
return fmt.Sprintf(`
@@ -129,5 +127,5 @@ data "scalr_agent_pool" "test" {
name = scalr_agent_pool.test.name
account_id = scalr_agent_pool.test.account_id
environment_id = scalr_environment.test.id
-}`, scalr.defaultAccount, scalr.defaultAccount)
+}`, defaultAccount, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_current_account_test.go b/internal/provider/data_source_scalr_current_account_test.go
index 1f607cee..25ab964d 100644
--- a/internal/provider/data_source_scalr_current_account_test.go
+++ b/internal/provider/data_source_scalr_current_account_test.go
@@ -6,14 +6,12 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccCurrentAccount_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{
{
@@ -26,13 +24,13 @@ func TestAccCurrentAccount_basic(t *testing.T) {
},
{
PreConfig: func() {
- _ = os.Setenv(currentAccountIDEnvVar, scalr.defaultAccount)
+ _ = os.Setenv(currentAccountIDEnvVar, defaultAccount)
},
Config: testAccCurrentAccountDataSourceConfig(),
PlanOnly: true,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(
- "data.scalr_current_account.test", "id", scalr.defaultAccount),
+ "data.scalr_current_account.test", "id", defaultAccount),
resource.TestCheckResourceAttr(
"data.scalr_current_account.test", "name", "mainiacp"),
),
diff --git a/internal/provider/data_source_scalr_current_run_test.go b/internal/provider/data_source_scalr_current_run_test.go
index a3b17179..e8e588f5 100644
--- a/internal/provider/data_source_scalr_current_run_test.go
+++ b/internal/provider/data_source_scalr_current_run_test.go
@@ -8,16 +8,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccCurrentRun_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{
{
@@ -48,23 +46,23 @@ func TestAccCurrentRun_basic(t *testing.T) {
func launchRun(environmentName, workspaceName string) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
options := GetEnvironmentByNameOptions{
Name: &environmentName,
}
- env, err := GetEnvironmentByName(scalr2.ctx, options, scalrClient)
+ env, err := GetEnvironmentByName(ctx, options, scalrClient)
if err != nil {
log.Fatalf("Got error during environment fetching: %v", err)
return
}
- ws, err := scalrClient.Workspaces.Read(scalr2.ctx, env.ID, workspaceName)
+ ws, err := scalrClient.Workspaces.Read(ctx, env.ID, workspaceName)
if err != nil {
log.Fatalf("Error retrieving workspace: %v", err)
}
- cv, err := scalrClient.ConfigurationVersions.Create(scalr2.ctx, scalr.ConfigurationVersionCreateOptions{
+ cv, err := scalrClient.ConfigurationVersions.Create(ctx, scalr.ConfigurationVersionCreateOptions{
Workspace: &scalr.Workspace{
ID: ws.ID,
},
@@ -74,7 +72,7 @@ func launchRun(environmentName, workspaceName string) func() {
log.Fatalf("Error creating cv: %v", cv)
}
- run, err := scalrClient.Runs.Create(scalr2.ctx, scalr.RunCreateOptions{
+ run, err := scalrClient.Runs.Create(ctx, scalr.RunCreateOptions{
Workspace: &scalr.Workspace{
ID: ws.ID,
},
@@ -102,7 +100,7 @@ resource scalr_workspace test {
name = "test-ws-%[1]d"
environment_id = scalr_environment.test.id
}
-`, rInt, scalr2.defaultAccount)
+`, rInt, defaultAccount)
}
func testAccCurrentRunDataSourceConfig(rInt int) string {
diff --git a/internal/provider/data_source_scalr_environment_test.go b/internal/provider/data_source_scalr_environment_test.go
index 789a1357..2c0edb27 100644
--- a/internal/provider/data_source_scalr_environment_test.go
+++ b/internal/provider/data_source_scalr_environment_test.go
@@ -7,8 +7,6 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccEnvironmentDataSource_basic(t *testing.T) {
@@ -23,8 +21,8 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
cuttedRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_environment test {}`,
@@ -47,7 +45,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
- resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
resource.TestCheckResourceAttr("data.scalr_environment.test", "tags.#", "0"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
@@ -61,7 +59,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
- resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.username"),
@@ -73,7 +71,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
- resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.username"),
@@ -107,7 +105,7 @@ resource "scalr_environment" "test" {
data "scalr_environment" "test" {
id = scalr_environment.test.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccEnvironmentDataSourceAccessByNameConfig(rInt int) string {
@@ -120,7 +118,7 @@ resource "scalr_environment" "test" {
data "scalr_environment" "test" {
name = scalr_environment.test.name
account_id = "%s"
-}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
+}`, rInt, defaultAccount, defaultAccount)
}
func testAccEnvironmentDataSourceAccessByIDAndNameConfig(rInt int) string {
@@ -134,7 +132,7 @@ data "scalr_environment" "test" {
id = scalr_environment.test.id
name = scalr_environment.test.name
account_id = "%s"
-}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
+}`, rInt, defaultAccount, defaultAccount)
}
func testAccEnvironmentDataSourceNotFoundConfig() string {
@@ -160,5 +158,5 @@ resource "scalr_environment" "test" {
data "scalr_environment" "test" {
name = "test-env-%s"
-}`, rInt, scalr.defaultAccount, cuttedRInt)
+}`, rInt, defaultAccount, cuttedRInt)
}
diff --git a/internal/provider/data_source_scalr_environments_test.go b/internal/provider/data_source_scalr_environments_test.go
index 4a627f23..bf71e9ed 100644
--- a/internal/provider/data_source_scalr_environments_test.go
+++ b/internal/provider/data_source_scalr_environments_test.go
@@ -5,16 +5,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrEnvironmentsDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrEnvironmentsDataSourceConfigBasic(rInt),
diff --git a/internal/provider/data_source_scalr_event_bridge_integration_test.go b/internal/provider/data_source_scalr_event_bridge_integration_test.go
index 8f6aa280..76747194 100644
--- a/internal/provider/data_source_scalr_event_bridge_integration_test.go
+++ b/internal/provider/data_source_scalr_event_bridge_integration_test.go
@@ -7,8 +7,6 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrEventBridgeIntegrationDataSource_basic(t *testing.T) {
@@ -18,8 +16,8 @@ func TestAccScalrEventBridgeIntegrationDataSource_basic(t *testing.T) {
t.Skip("Please set AWS_EVENT_BRIDGE_ACCOUNT_ID, AWS_EVENT_BRIDGE_REGION env variables to run this test.")
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_event_bridge test {}`,
diff --git a/internal/provider/data_source_scalr_iam_team_test.go b/internal/provider/data_source_scalr_iam_team_test.go
index a2dc2c96..b38191fb 100644
--- a/internal/provider/data_source_scalr_iam_team_test.go
+++ b/internal/provider/data_source_scalr_iam_team_test.go
@@ -6,16 +6,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrIamTeamDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_iam_team test {}`,
@@ -42,9 +40,9 @@ func TestAccScalrIamTeamDataSource_basic(t *testing.T) {
fmt.Sprintf("test-team-%d", rInt),
),
resource.TestCheckResourceAttr("data.scalr_iam_team.test", "description", ""),
- resource.TestCheckResourceAttr("data.scalr_iam_team.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_iam_team.test", "account_id", defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_iam_team.test", "identity_provider_id"),
- resource.TestCheckResourceAttr("data.scalr_iam_team.test", "users.0", scalr.testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_team.test", "users.0", testUser),
),
},
{
@@ -84,7 +82,7 @@ resource "scalr_iam_team" "test" {
data "scalr_iam_team" "test" {
id = scalr_iam_team.test.id
account_id = scalr_iam_team.test.account_id
-}`, rInt, scalr.defaultAccount, scalr.testUser)
+}`, rInt, defaultAccount, testUser)
}
func testAccScalrIamTeamDataSourceByNameConfig(rInt int) string {
@@ -98,7 +96,7 @@ resource "scalr_iam_team" "test" {
data "scalr_iam_team" "test" {
name = scalr_iam_team.test.name
account_id = scalr_iam_team.test.account_id
-}`, rInt, scalr.defaultAccount, scalr.testUser)
+}`, rInt, defaultAccount, testUser)
}
func testAccScalrIamTeamDataSourceByIDAndNameConfig(rInt int) string {
@@ -113,5 +111,5 @@ data "scalr_iam_team" "test" {
id = scalr_iam_team.test.id
name = scalr_iam_team.test.name
account_id = scalr_iam_team.test.account_id
-}`, rInt, scalr.defaultAccount, scalr.testUser)
+}`, rInt, defaultAccount, testUser)
}
diff --git a/internal/provider/data_source_scalr_iam_user_test.go b/internal/provider/data_source_scalr_iam_user_test.go
index 14af9f9c..52da6aff 100644
--- a/internal/provider/data_source_scalr_iam_user_test.go
+++ b/internal/provider/data_source_scalr_iam_user_test.go
@@ -7,14 +7,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrIamUserDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_iam_user test {}`,
@@ -34,14 +32,14 @@ func TestAccScalrIamUserDataSource_basic(t *testing.T) {
{
Config: testAccScalrIamUserDataSourceByIDConfig,
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", scalr2.testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", testUser),
resource.TestCheckResourceAttr(
"data.scalr_iam_user.test",
"status",
string(scalr.UserStatusActive),
),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", scalr2.testUserEmail),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "username", scalr2.testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "username", testUserEmail),
resource.TestCheckResourceAttrSet("data.scalr_iam_user.test", "full_name"),
resource.TestCheckResourceAttrSet("data.scalr_iam_user.test", "teams.0"),
),
@@ -49,15 +47,15 @@ func TestAccScalrIamUserDataSource_basic(t *testing.T) {
{
Config: testAccScalrIamUserDataSourceByEmailConfig,
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", scalr2.testUser),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", scalr2.testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", testUserEmail),
),
},
{
Config: testAccScalrIamUserDataSourceByIDAndEmailConfig,
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", scalr2.testUser),
- resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", scalr2.testUserEmail),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "id", testUser),
+ resource.TestCheckResourceAttr("data.scalr_iam_user.test", "email", testUserEmail),
),
},
},
@@ -67,15 +65,15 @@ func TestAccScalrIamUserDataSource_basic(t *testing.T) {
var testAccScalrIamUserDataSourceByIDConfig = fmt.Sprintf(`
data "scalr_iam_user" "test" {
id = "%s"
-}`, scalr2.testUser)
+}`, testUser)
var testAccScalrIamUserDataSourceByEmailConfig = fmt.Sprintf(`
data "scalr_iam_user" "test" {
email = "%s"
-}`, scalr2.testUserEmail)
+}`, testUserEmail)
var testAccScalrIamUserDataSourceByIDAndEmailConfig = fmt.Sprintf(`
data "scalr_iam_user" "test" {
id = "%s"
email = "%s"
-}`, scalr2.testUser, scalr2.testUserEmail)
+}`, testUser, testUserEmail)
diff --git a/internal/provider/data_source_scalr_module_version_test.go b/internal/provider/data_source_scalr_module_version_test.go
index f6453616..d076c952 100644
--- a/internal/provider/data_source_scalr_module_version_test.go
+++ b/internal/provider/data_source_scalr_module_version_test.go
@@ -8,8 +8,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccModuleVersionDataSource_basic(t *testing.T) {
@@ -17,9 +15,9 @@ func TestAccModuleVersionDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountModule(rInt),
@@ -57,19 +55,19 @@ func TestAccModuleVersionDataSource_basic(t *testing.T) {
func waitForModuleVersions(environmentName string) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
options := GetEnvironmentByNameOptions{
Name: &environmentName,
}
- env, err := GetEnvironmentByName(scalr2.ctx, options, scalrClient)
+ env, err := GetEnvironmentByName(ctx, options, scalrClient)
if err != nil {
log.Fatalf("Got error during environment fetching: %v", err)
return
}
- ml, err := scalrClient.Modules.List(scalr2.ctx, scalr.ModuleListOptions{Environment: &env.ID})
+ ml, err := scalrClient.Modules.List(ctx, scalr.ModuleListOptions{Environment: &env.ID})
if len(ml.Items) == 0 {
log.Fatalf("The test module for environment with name %s was not created: %v", environmentName, err)
@@ -77,7 +75,7 @@ func waitForModuleVersions(environmentName string) func() {
var mID = ml.Items[0].ID
for i := 0; i < 60; i++ {
- m, err := scalrClient.Modules.Read(scalr2.ctx, mID)
+ m, err := scalrClient.Modules.Read(ctx, mID)
if err != nil {
log.Fatalf("Error polling module %s: %v", mID, err)
}
@@ -118,7 +116,7 @@ func testAccScalrAccountModule(rInt int) string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, scalr2.defaultAccount, rInt, string(scalr.Github), scalr2.githubToken)
+`, defaultAccount, rInt, string(scalr.Github), githubToken)
}
func testAccModuleVersionDataSourceConfig(rInt int) string {
diff --git a/internal/provider/data_source_scalr_module_versions_test.go b/internal/provider/data_source_scalr_module_versions_test.go
index a2ef3714..a09f2e2b 100644
--- a/internal/provider/data_source_scalr_module_versions_test.go
+++ b/internal/provider/data_source_scalr_module_versions_test.go
@@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccModuleVersionsDataSource_basic(t *testing.T) {
@@ -16,9 +14,9 @@ func TestAccModuleVersionsDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_module_versions all_by_none {}`,
@@ -127,7 +125,7 @@ func testAccModuleVersionsReourceConfig(rInt int) string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, scalr2.defaultAccount, rInt, string(scalr.Github), scalr2.githubToken)
+`, defaultAccount, rInt, string(scalr.Github), githubToken)
}
func testAccModuleVersionsDataSourceConfig(rInt int) string {
diff --git a/internal/provider/data_source_scalr_policy_group_test.go b/internal/provider/data_source_scalr_policy_group_test.go
index 383e6d0f..850de9ca 100644
--- a/internal/provider/data_source_scalr_policy_group_test.go
+++ b/internal/provider/data_source_scalr_policy_group_test.go
@@ -9,8 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccPolicyGroupDataSource_basic(t *testing.T) {
@@ -20,9 +18,9 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupConfig(rInt),
@@ -69,18 +67,18 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_policy_group.test",
"account_id",
- scalr2.defaultAccount,
+ defaultAccount,
),
resource.TestCheckResourceAttrSet("data.scalr_policy_group.test", "vcs_provider_id"),
resource.TestCheckResourceAttr(
"data.scalr_policy_group.test",
"vcs_repo.0.identifier",
- scalr2.policyGroupVcsRepoID,
+ policyGroupVcsRepoID,
),
resource.TestCheckResourceAttr(
"data.scalr_policy_group.test",
"vcs_repo.0.path",
- scalr2.policyGroupVcsRepoPath,
+ policyGroupVcsRepoPath,
),
resource.TestCheckResourceAttrSet("data.scalr_policy_group.test", "vcs_repo.0.branch"),
resource.TestCheckResourceAttrSet("data.scalr_policy_group.test", "policies.#"),
@@ -93,9 +91,9 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
name = "not-exists"
account_id = "%s"
}
- `, scalr2.defaultAccount),
+ `, defaultAccount),
ExpectError: regexp.MustCompile(fmt.Sprintf(
- "policy group %s/%s not found", scalr2.defaultAccount, "not-exists",
+ "policy group %s/%s not found", defaultAccount, "not-exists",
)),
PlanOnly: true,
},
@@ -105,20 +103,20 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
func waitForPolicyGroupFetch(name string) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- pgl, err := scalrClient.PolicyGroups.List(scalr2.ctx, scalr.PolicyGroupListOptions{
- Account: scalr2.defaultAccount,
+ pgl, err := scalrClient.PolicyGroups.List(ctx, scalr.PolicyGroupListOptions{
+ Account: defaultAccount,
Name: name,
})
if err != nil || len(pgl.Items) == 0 {
- log.Fatalf("The test policy group on account %s was not created: %v", scalr2.defaultAccount, err)
+ log.Fatalf("The test policy group on account %s was not created: %v", defaultAccount, err)
}
var pgID = pgl.Items[0].ID
for i := 0; i < 60; i++ {
- pg, err := scalrClient.PolicyGroups.Read(scalr2.ctx, pgID)
+ pg, err := scalrClient.PolicyGroups.Read(ctx, pgID)
if err != nil {
log.Fatalf("Error polling policy group %s: %v", pgID, err)
}
@@ -151,7 +149,7 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), scalr2.githubToken, scalr2.defaultAccount, scalr2.policyGroupVcsRepoID, scalr2.policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
func testAccPolicyGroupDataSourceConfig(rInt int) string {
@@ -163,5 +161,5 @@ data "scalr_policy_group" "test" {
name = scalr_policy_group.test.name
account_id = "%s"
}
-`, testAccPolicyGroupConfig(rInt), scalr2.defaultAccount)
+`, testAccPolicyGroupConfig(rInt), defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_provider_configuration_test.go b/internal/provider/data_source_scalr_provider_configuration_test.go
index 89491dd9..53888653 100644
--- a/internal/provider/data_source_scalr_provider_configuration_test.go
+++ b/internal/provider/data_source_scalr_provider_configuration_test.go
@@ -6,16 +6,13 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationDataSourceInitConfig, // depends_on works improperly with data sources
@@ -47,7 +44,7 @@ func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckEqualID("data.scalr_provider_configuration.scalr", "scalr_provider_configuration.scalr"),
resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "name", rName),
- resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "account_id", defaultAccount),
resource.TestCheckResourceAttr("data.scalr_provider_configuration.scalr", "provider_name", "scalr"),
),
},
@@ -60,7 +57,7 @@ func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
var rName = acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
-var testAccScalrProviderConfigurationDataSourceScalrConfig = scalr.testAccScalrProviderConfigurationScalrConfig(rName) + `
+var testAccScalrProviderConfigurationDataSourceScalrConfig = testAccScalrProviderConfigurationScalrConfig(rName) + `
data "scalr_provider_configuration" "scalr" {
name = scalr_provider_configuration.scalr.name
}`
@@ -104,7 +101,7 @@ resource "scalr_provider_configuration" "consul" {
}
}
}
-`, scalr.defaultAccount)
+`, defaultAccount)
var testAccScalrProviderConfigurationDataSourceConfig = testAccScalrProviderConfigurationDataSourceInitConfig + `
data "scalr_provider_configuration" "kubernetes" {
diff --git a/internal/provider/data_source_scalr_provider_configurations_test.go b/internal/provider/data_source_scalr_provider_configurations_test.go
index dd031bb0..e208816d 100644
--- a/internal/provider/data_source_scalr_provider_configurations_test.go
+++ b/internal/provider/data_source_scalr_provider_configurations_test.go
@@ -6,14 +6,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrProviderConfigurationsDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationsDataSourceInitConfig, // depends_on works improperly with data sources
@@ -154,7 +152,7 @@ resource "scalr_provider_configuration" "consul" {
value = "nyc1"
}
}
-}`, scalr.defaultAccount)
+}`, defaultAccount)
var testAccScalrProviderConfigurationsDataSourceConfig = testAccScalrProviderConfigurationsDataSourceInitConfig + `
data "scalr_provider_configurations" "kubernetes2consul" {
diff --git a/internal/provider/data_source_scalr_role_test.go b/internal/provider/data_source_scalr_role_test.go
index 384e899a..ff7d4fd7 100644
--- a/internal/provider/data_source_scalr_role_test.go
+++ b/internal/provider/data_source_scalr_role_test.go
@@ -7,14 +7,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRoleDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_role test_role {}`,
@@ -39,7 +37,7 @@ func TestAccScalrRoleDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_role.test", "name", "role-test"),
resource.TestCheckResourceAttr("data.scalr_role.test", "description", ""),
resource.TestCheckResourceAttr("data.scalr_role.test", "is_system", "false"),
- resource.TestCheckResourceAttr("data.scalr_role.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_role.test", "account_id", defaultAccount),
resource.TestCheckResourceAttr("data.scalr_role.test", "permissions.0", "*:read"),
resource.TestCheckResourceAttr("data.scalr_role.test", "permissions.1", "roles:update"),
),
@@ -63,7 +61,7 @@ func TestAccScalrRoleDataSource_basic(t *testing.T) {
{
Config: testAccScalrRoleDataSourceUserConfig(),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("data.scalr_role.user", "id", scalr.userRole),
+ resource.TestCheckResourceAttr("data.scalr_role.user", "id", userRole),
resource.TestCheckResourceAttr("data.scalr_role.user", "name", "user"),
resource.TestCheckResourceAttrSet("data.scalr_role.user", "description"),
resource.TestCheckResourceAttr("data.scalr_role.user", "is_system", "true"),
@@ -108,7 +106,7 @@ data "scalr_role" "test" {
id = scalr_role.test.id
account_id = scalr_role.test.account_id
}
-`, scalr.defaultAccount)
+`, defaultAccount)
var testAccScalrRoleDataSourceByNameConfig = fmt.Sprintf(`
resource "scalr_role" "test" {
@@ -124,7 +122,7 @@ data "scalr_role" "test" {
name = scalr_role.test.name
account_id = scalr_role.test.account_id
}
-`, scalr.defaultAccount)
+`, defaultAccount)
var testAccScalrRoleDataSourceByIDAndNameConfig = fmt.Sprintf(`
resource "scalr_role" "test" {
@@ -141,7 +139,7 @@ data "scalr_role" "test" {
name = scalr_role.test.name
account_id = scalr_role.test.account_id
}
-`, scalr.defaultAccount)
+`, defaultAccount)
func testAccScalrRoleDataSourceUserConfig() string {
return `
diff --git a/internal/provider/data_source_scalr_service_account_test.go b/internal/provider/data_source_scalr_service_account_test.go
index 9426a4e9..a8b668f7 100644
--- a/internal/provider/data_source_scalr_service_account_test.go
+++ b/internal/provider/data_source_scalr_service_account_test.go
@@ -7,16 +7,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_service_account test {}`,
@@ -48,7 +46,7 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
"data.scalr_service_account.test", "description", fmt.Sprintf("desc-%d", rInt),
),
resource.TestCheckResourceAttr(
- "data.scalr_service_account.test", "account_id", scalr2.defaultAccount,
+ "data.scalr_service_account.test", "account_id", defaultAccount,
),
resource.TestCheckResourceAttr(
"data.scalr_service_account.test", "created_by.#", "1",
@@ -77,7 +75,7 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
"data.scalr_service_account.test", "description", fmt.Sprintf("desc-%d", rInt),
),
resource.TestCheckResourceAttr(
- "data.scalr_service_account.test", "account_id", scalr2.defaultAccount,
+ "data.scalr_service_account.test", "account_id", defaultAccount,
),
resource.TestCheckResourceAttr(
"data.scalr_service_account.test", "created_by.#", "1",
@@ -102,7 +100,7 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
"data.scalr_service_account.test", "description", fmt.Sprintf("desc-%d", rInt),
),
resource.TestCheckResourceAttr(
- "data.scalr_service_account.test", "account_id", scalr2.defaultAccount,
+ "data.scalr_service_account.test", "account_id", defaultAccount,
),
resource.TestCheckResourceAttr(
"data.scalr_service_account.test", "created_by.#", "1",
diff --git a/internal/provider/data_source_scalr_ssh_key_test.go b/internal/provider/data_source_scalr_ssh_key_test.go
index c74bfde2..a1b1ac71 100644
--- a/internal/provider/data_source_scalr_ssh_key_test.go
+++ b/internal/provider/data_source_scalr_ssh_key_test.go
@@ -6,18 +6,15 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
rInt := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_ssh_key test {}`,
@@ -42,7 +39,7 @@ func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(
"data.scalr_ssh_key.test", "environments.#"),
resource.TestCheckResourceAttr(
- "data.scalr_ssh_key.test", "account_id", scalr.defaultAccount),
+ "data.scalr_ssh_key.test", "account_id", defaultAccount),
),
},
{
@@ -51,7 +48,7 @@ func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_ssh_key.test_by_name", "name", fmt.Sprintf("ssh-key-test-%s", rInt)),
resource.TestCheckResourceAttr(
- "data.scalr_ssh_key.test_by_name", "account_id", scalr.defaultAccount),
+ "data.scalr_ssh_key.test_by_name", "account_id", defaultAccount),
),
},
{
@@ -86,7 +83,7 @@ EOF
data "scalr_ssh_key" "test" {
id = scalr_ssh_key.test.id
account_id = scalr_ssh_key.test.account_id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccScalrSSHKeyDataSourceAccessByNameConfig(rInt string) string {
@@ -105,7 +102,7 @@ EOF
data "scalr_ssh_key" "test_by_name" {
name = scalr_ssh_key.test.name
account_id = scalr_ssh_key.test.account_id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccScalrSSHKeyDataSourceNotFoundByNameConfig() string {
@@ -133,5 +130,5 @@ data "scalr_ssh_key" "test_mismatch" {
id = scalr_ssh_key.test.id
name = "incorrect-name"
account_id = scalr_ssh_key.test.account_id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_tag_test.go b/internal/provider/data_source_scalr_tag_test.go
index 57c18858..b3b719ed 100644
--- a/internal/provider/data_source_scalr_tag_test.go
+++ b/internal/provider/data_source_scalr_tag_test.go
@@ -6,16 +6,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrTagDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_tag test {}`,
@@ -37,7 +35,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
{
@@ -45,7 +43,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
{
@@ -53,7 +51,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
},
@@ -70,7 +68,7 @@ resource scalr_tag test {
data scalr_tag test {
id = scalr_tag.test.id
account_id = "%[2]s"
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccScalrTagDataSourceByNameConfig(rInt int) string {
@@ -83,7 +81,7 @@ resource scalr_tag test {
data scalr_tag test {
name = scalr_tag.test.name
account_id = "%[2]s"
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccScalrTagDataSourceByIDAndNameConfig(rInt int) string {
@@ -97,5 +95,5 @@ data scalr_tag test {
id = scalr_tag.test.id
name = scalr_tag.test.name
account_id = "%[2]s"
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_variable_test.go b/internal/provider/data_source_scalr_variable_test.go
index b136048d..2b19c40a 100644
--- a/internal/provider/data_source_scalr_variable_test.go
+++ b/internal/provider/data_source_scalr_variable_test.go
@@ -6,15 +6,13 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrVariableDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_variable test {}`,
@@ -58,7 +56,7 @@ func TestAccScalrVariableDataSource(t *testing.T) {
resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "sensitive", "false"),
resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "description", "The hostname of scalr workspace."),
resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "final", "false"),
- resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "account_id", scalr.defaultAccount),
+ resource.TestCheckResourceAttr("data.scalr_variable.workspace_hostname", "account_id", defaultAccount),
testAccCheckEqualID("data.scalr_variable.secret", "scalr_variable.secret"),
resource.TestCheckResourceAttr("data.scalr_variable.secret", "hcl", "false"),
resource.TestCheckResourceAttr("data.scalr_variable.secret", "sensitive", "true"),
@@ -92,7 +90,7 @@ resource scalr_workspace test {
resource "scalr_variable" "workspace_hostname" {
key = "hostname"
- value = "workspace.scalr.com"
+ value = "workspace.com"
category = "shell"
hcl = false
sensitive = false
@@ -103,11 +101,11 @@ resource "scalr_variable" "workspace_hostname" {
resource "scalr_variable" "hostname" {
key = "hostname"
- value = "scalr.com"
+ value = "com"
category = "shell"
hcl = false
sensitive = false
- description = "The hostname of scalr."
+ description = "The hostname of "
final = false
account_id = "%[1]s"
}
@@ -122,14 +120,14 @@ resource "scalr_variable" "secret" {
final = true
account_id = "%[1]s"
}
-`, scalr.defaultAccount)
+`, defaultAccount)
var testAccScalrVariableDataSourceByIDConfig = testAccScalrVariableDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variable" "secret" {
id = scalr_variable.secret.id
account_id = "%s"
}
-`, scalr.defaultAccount)
+`, defaultAccount)
var testAccScalrVariableDataSourceByKeyConfig = testAccScalrVariableDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variable" "secret" {
@@ -143,7 +141,7 @@ data "scalr_variable" "workspace_hostname" {
category = "shell"
account_id = "%[1]s"
workspace_id = scalr_workspace.test.id
-}`, scalr.defaultAccount)
+}`, defaultAccount)
var testAccScalrVariableDataSourceByIDAndKeyConfig = testAccScalrVariableDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variable" "secret" {
@@ -151,4 +149,4 @@ data "scalr_variable" "secret" {
key = "secret"
account_id = "%s"
}
-`, scalr.defaultAccount)
+`, defaultAccount)
diff --git a/internal/provider/data_source_scalr_variables_test.go b/internal/provider/data_source_scalr_variables_test.go
index 4b42d213..7aebb2c3 100644
--- a/internal/provider/data_source_scalr_variables_test.go
+++ b/internal/provider/data_source_scalr_variables_test.go
@@ -9,15 +9,13 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrVariablesDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrVariablesDataSourceInitConfig, // depends_on works improperly with data sources
@@ -67,18 +65,18 @@ func TestAccScalrVariablesDataSource(t *testing.T) {
}
func deleteAllVariables() {
- scalrClient, err := scalr2.createScalrClient()
+ scalrClient, err := createScalrClient()
if err != nil {
log.Fatalf("Cant remove default variables before test: %s", err)
return
}
- variables, err := scalrClient.Variables.List(scalr2.ctx, scalr.VariableListOptions{})
+ variables, err := scalrClient.Variables.List(ctx, scalr.VariableListOptions{})
if err != nil {
log.Fatalf("Cant remove default variables before test: %s", err)
return
}
for _, variable := range variables.Items {
- err = scalrClient.Variables.Delete(scalr2.ctx, variable.ID)
+ err = scalrClient.Variables.Delete(ctx, variable.ID)
if err != nil {
log.Fatalf("Cant remove default variables before test: %s", err)
return
@@ -183,7 +181,7 @@ resource "scalr_variable" "secret" {
final = true
account_id = "%[1]s"
}
-`, scalr2.defaultAccount)
+`, defaultAccount)
var testAccScalrVariablesDataSourceConfig = testAccScalrVariablesDataSourceInitConfig + fmt.Sprintf(`
data "scalr_variables" "shell" {
@@ -205,4 +203,4 @@ data "scalr_variables" "workspace_and_null" {
data "scalr_variables" "account" {
account_id = "%[1]s"
}
-`, scalr2.defaultAccount)
+`, defaultAccount)
diff --git a/internal/provider/data_source_scalr_vcs_provider_test.go b/internal/provider/data_source_scalr_vcs_provider_test.go
index a27a6bdc..48fc1241 100644
--- a/internal/provider/data_source_scalr_vcs_provider_test.go
+++ b/internal/provider/data_source_scalr_vcs_provider_test.go
@@ -6,19 +6,17 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
- Config: testAccScalrVcsProviderDataSourceConfigAllFilters(rInt, scalr.githubToken),
+ Config: testAccScalrVcsProviderDataSourceConfigAllFilters(rInt, githubToken),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_vcs_provider.test", "id"),
resource.TestCheckResourceAttr(
@@ -28,13 +26,13 @@ func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_vcs_provider.test", "url", "https://github.com"),
resource.TestCheckResourceAttr(
- "data.scalr_vcs_provider.test", "account_id", scalr.defaultAccount),
+ "data.scalr_vcs_provider.test", "account_id", defaultAccount),
resource.TestCheckResourceAttr(
"data.scalr_vcs_provider.test", "draft_pr_runs_enabled", "false"),
),
},
{
- Config: testAccScalrVcsProviderDataSourceConfigFilterByName(rInt, scalr.githubToken),
+ Config: testAccScalrVcsProviderDataSourceConfigFilterByName(rInt, githubToken),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_vcs_provider.test", "id"),
resource.TestCheckResourceAttr(
@@ -44,7 +42,7 @@ func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"data.scalr_vcs_provider.test", "url", "https://github.com"),
resource.TestCheckResourceAttr(
- "data.scalr_vcs_provider.test", "account_id", scalr.defaultAccount),
+ "data.scalr_vcs_provider.test", "account_id", defaultAccount),
),
},
{
@@ -91,7 +89,7 @@ data scalr_vcs_provider test {
name = scalr_vcs_provider.test.name
vcs_type = scalr_vcs_provider.test.vcs_type
account_id = scalr_vcs_provider.test.account_id
-}`, rInt, token, scalr.defaultAccount)
+}`, rInt, token, defaultAccount)
}
func testAccScalrVcsProviderDataSourceConfigFilterByName(rInt int, token string) string {
@@ -105,5 +103,5 @@ resource scalr_vcs_provider test {
data scalr_vcs_provider test {
name = scalr_vcs_provider.test.name
-}`, rInt, token, scalr.defaultAccount)
+}`, rInt, token, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_webhook_test.go b/internal/provider/data_source_scalr_webhook_test.go
index e32a82b9..613a8b31 100644
--- a/internal/provider/data_source_scalr_webhook_test.go
+++ b/internal/provider/data_source_scalr_webhook_test.go
@@ -8,8 +8,6 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccWebhookDataSource_basic(t *testing.T) {
@@ -18,8 +16,8 @@ func TestAccWebhookDataSource_basic(t *testing.T) {
cutRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: `data scalr_webhook test {}`,
@@ -121,7 +119,7 @@ resource scalr_webhook test-new {
data scalr_webhook test-new {
id = scalr_webhook.test-new.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccWebhookDataSourceAccessByNameConfig(rInt int) string {
@@ -137,7 +135,7 @@ resource scalr_webhook test {
data scalr_webhook test {
name = scalr_webhook.test.name
account_id = "%s"
-}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
+}`, rInt, defaultAccount, defaultAccount)
}
func testAccWebhookDataSourceAccessByIDAndNameConfig(rInt int) string {
@@ -154,7 +152,7 @@ data scalr_webhook test {
id = scalr_webhook.test.id
name = scalr_webhook.test.name
account_id = "%s"
-}`, rInt, scalr.defaultAccount, scalr.defaultAccount)
+}`, rInt, defaultAccount, defaultAccount)
}
func testAccWebhookDataSourceNotFoundByNameConfig() string {
@@ -178,5 +176,5 @@ resource scalr_webhook test {
data scalr_webhook test {
name = "test webhook-%[3]s"
account_id = "%s"
-}`, rInt, scalr.defaultAccount, cutRInt, scalr.defaultAccount)
+}`, rInt, defaultAccount, cutRInt, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_workspace_ids_test.go b/internal/provider/data_source_scalr_workspace_ids_test.go
index 08fb3b5e..0e552b6e 100644
--- a/internal/provider/data_source_scalr_workspace_ids_test.go
+++ b/internal/provider/data_source_scalr_workspace_ids_test.go
@@ -5,16 +5,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspaceIDsDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceIDsDataSourceConfigBasic(rInt),
@@ -45,8 +43,8 @@ func TestAccScalrWorkspaceIDsDataSource_wildcard(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceIDsDataSourceConfigWildcard(rInt),
@@ -96,7 +94,7 @@ resource scalr_workspace dummy {
data scalr_workspace_ids foobar {
names = [scalr_workspace.foo.name, scalr_workspace.bar.name]
environment_id = scalr_environment.test.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
// nolint:unused
@@ -125,5 +123,5 @@ resource scalr_workspace dummy {
data scalr_workspace_ids foobar {
names = ["*"]
environment_id = scalr_environment.test.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_workspace_test.go b/internal/provider/data_source_scalr_workspace_test.go
index 4c06d0cc..1a3d302c 100644
--- a/internal/provider/data_source_scalr_workspace_test.go
+++ b/internal/provider/data_source_scalr_workspace_test.go
@@ -6,16 +6,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspaceDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceDataSourceMissingRequiredConfig,
@@ -136,7 +134,7 @@ resource scalr_workspace test {
data scalr_workspace test {
id = scalr_workspace.test.id
environment_id = scalr_environment.test.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccScalrWorkspaceDataSourceByNameConfig(rInt int) string {
@@ -154,7 +152,7 @@ resource scalr_workspace test {
data scalr_workspace test {
name = scalr_workspace.test.name
environment_id = scalr_environment.test.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
func testAccScalrWorkspaceDataSourceByIDAndNameConfig(rInt int) string {
@@ -173,5 +171,5 @@ data scalr_workspace test {
id = scalr_workspace.test.id
name = scalr_workspace.test.name
environment_id = scalr_environment.test.id
-}`, rInt, scalr.defaultAccount)
+}`, rInt, defaultAccount)
}
diff --git a/internal/provider/data_source_scalr_workspaces_test.go b/internal/provider/data_source_scalr_workspaces_test.go
index 06277d84..235d1af8 100644
--- a/internal/provider/data_source_scalr_workspaces_test.go
+++ b/internal/provider/data_source_scalr_workspaces_test.go
@@ -5,16 +5,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspacesDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspacesDataSourceConfigBasic(rInt),
diff --git a/internal/provider/resource_scalr_access_policy_test.go b/internal/provider/resource_scalr_access_policy_test.go
index 583fe4d5..525c4e52 100644
--- a/internal/provider/resource_scalr_access_policy_test.go
+++ b/internal/provider/resource_scalr_access_policy_test.go
@@ -12,8 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAccessPolicy_basic(t *testing.T) {
@@ -21,8 +19,8 @@ func TestAccScalrAccessPolicy_basic(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -46,8 +44,8 @@ func TestAccScalrAccessPolicy_bad_scope(t *testing.T) {
rg, _ := regexp.Compile(`scope.0.type must be one of \[workspace, environment, account], got: universe`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBadScope(),
@@ -61,8 +59,8 @@ func TestAccScalrAccessPolicy_bad_subject(t *testing.T) {
rg, _ := regexp.Compile(`subject.0.type must be one of \[user, team, service_account], got: grandpa`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBadSubject(),
@@ -77,8 +75,8 @@ func TestAccScalrAccessPolicy_changed_outside(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -116,8 +114,8 @@ func TestAccScalrAccessPolicy_update(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -160,8 +158,8 @@ func TestAccScalrAccessPolicy_import(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
@@ -179,7 +177,7 @@ func TestAccScalrAccessPolicy_import(t *testing.T) {
func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -191,7 +189,7 @@ func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) r
}
// Get the ap
- r, err := scalrClient.AccessPolicies.Read(scalr2.ctx, rs.Primary.ID)
+ r, err := scalrClient.AccessPolicies.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -204,9 +202,9 @@ func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) r
func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.AccessPolicies.Read(scalr2.ctx, ap.ID)
+ r, err := scalrClient.AccessPolicies.Read(ctx, ap.ID)
if err != nil {
log.Fatalf("Error retrieving access policy: %v", err)
@@ -228,7 +226,7 @@ func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func()
}
func testAccCheckScalrAccessPolicyDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_access_policy" {
@@ -239,7 +237,7 @@ func testAccCheckScalrAccessPolicyDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.AccessPolicies.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.AccessPolicies.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("AccessPolicy %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_account_allowed_ips_test.go b/internal/provider/resource_scalr_account_allowed_ips_test.go
index 6cda7e8c..ab163329 100644
--- a/internal/provider/resource_scalr_account_allowed_ips_test.go
+++ b/internal/provider/resource_scalr_account_allowed_ips_test.go
@@ -7,14 +7,12 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0", "192.168.0.0/32"}),
@@ -32,8 +30,8 @@ func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
func TestAccScalrAccountAllowedIps_update(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0"}),
@@ -58,8 +56,8 @@ func TestAccScalrAccountAllowedIps_update(t *testing.T) {
func TestAccScalrAccountAllowedIps_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0"}),
@@ -77,8 +75,8 @@ func TestAccScalrAccountAllowedIps_import(t *testing.T) {
func TestAccScalrAccountAllowedIps_empty(t *testing.T) {
rg, _ := regexp.Compile(`Attribute allowed_ips requires 1 item minimum, but config has only 0`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{}),
@@ -91,8 +89,8 @@ func TestAccScalrAccountAllowedIps_empty(t *testing.T) {
func TestAccScalrAccountAllowedIps_invalid_CIDR(t *testing.T) {
rg, _ := regexp.Compile(`value is not a valid IPv4 network`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12/24"}),
diff --git a/internal/provider/resource_scalr_agent_pool_test.go b/internal/provider/resource_scalr_agent_pool_test.go
index 6b8173b7..83a225a0 100644
--- a/internal/provider/resource_scalr_agent_pool_test.go
+++ b/internal/provider/resource_scalr_agent_pool_test.go
@@ -9,8 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAgentPool_basic(t *testing.T) {
@@ -18,8 +16,8 @@ func TestAccScalrAgentPool_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -41,8 +39,8 @@ func TestAccScalrAgentPool_renamed(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -73,8 +71,8 @@ func TestAccScalrAgentPool_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -102,8 +100,8 @@ func TestAccScalrAgentPool_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
@@ -121,7 +119,7 @@ func TestAccScalrAgentPool_import(t *testing.T) {
func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -133,7 +131,7 @@ func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resou
}
// Get the agent_pool
- r, err := scalrClient.AgentPools.Read(scalr2.ctx, rs.Primary.ID)
+ r, err := scalrClient.AgentPools.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -146,9 +144,9 @@ func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resou
func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.AgentPools.Read(scalr2.ctx, pool.ID)
+ r, err := scalrClient.AgentPools.Read(ctx, pool.ID)
if err != nil {
log.Fatalf("Error retrieving agent pool: %v", err)
@@ -170,7 +168,7 @@ func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
}
func testAccCheckScalrAgentPoolDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_agent_pool" {
@@ -181,7 +179,7 @@ func testAccCheckScalrAgentPoolDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.AgentPools.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.AgentPools.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("AgentPool %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_agent_pool_token_test.go b/internal/provider/resource_scalr_agent_pool_token_test.go
index 9eb865f7..b2fccc52 100644
--- a/internal/provider/resource_scalr_agent_pool_token_test.go
+++ b/internal/provider/resource_scalr_agent_pool_token_test.go
@@ -9,8 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrAgentPoolToken_basic(t *testing.T) {
@@ -23,8 +21,8 @@ func TestAccScalrAgentPoolToken_basic(t *testing.T) {
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
@@ -49,8 +47,8 @@ func TestAccScalrAgentPoolToken_changed_outside(t *testing.T) {
token := &scalr.AccessToken{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
@@ -83,8 +81,8 @@ func TestAccScalrAgentPoolToken_update(t *testing.T) {
token := &scalr.AccessToken{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
@@ -108,7 +106,7 @@ func TestAccScalrAgentPoolToken_update(t *testing.T) {
func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, token *scalr.AccessToken) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -120,7 +118,7 @@ func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, t
}
// Get the token
- l, err := scalrClient.AgentPoolTokens.List(scalr2.ctx, pool.ID, scalr.AccessTokenListOptions{})
+ l, err := scalrClient.AgentPoolTokens.List(ctx, pool.ID, scalr.AccessTokenListOptions{})
if err != nil {
return err
}
@@ -140,7 +138,7 @@ func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, t
func testAccCheckScalrAgentPoolTokenChangedOutside(token *scalr.AccessToken) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
r, err := scalrClient.AccessTokens.Update(
context.Background(),
@@ -163,7 +161,7 @@ func deletePool(t *testing.T, pool scalr.AgentPool) {
t.Fatalf("Unable to create a Scalr client: %s", err)
}
- err = scalrClient.AgentPools.Delete(scalr2.ctx, pool.ID)
+ err = scalrClient.AgentPools.Delete(ctx, pool.ID)
if err != nil {
t.Fatalf("Unable to delete an agent pool: %s", err)
}
@@ -177,7 +175,7 @@ func createPool(t *testing.T) scalr.AgentPool {
t.Fatalf("Unable to create a Scalr client: %s", err)
}
- r, err := scalrClient.AgentPools.Create(scalr2.ctx, scalr.AgentPoolCreateOptions{
+ r, err := scalrClient.AgentPools.Create(ctx, scalr.AgentPoolCreateOptions{
Name: scalr.String(name),
Account: &scalr.Account{ID: defaultAccount},
})
@@ -189,7 +187,7 @@ func createPool(t *testing.T) scalr.AgentPool {
}
func testAccCheckScalrAgentPoolTokenDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_agent_pool_token" {
@@ -199,7 +197,7 @@ func testAccCheckScalrAgentPoolTokenDestroy(s *terraform.State) error {
poolID := rs.Primary.Attributes["agent_pool_id"]
// the agent pool must be deleted along with token
- l, _ := scalrClient.AgentPoolTokens.List(scalr2.ctx, poolID, scalr.AccessTokenListOptions{})
+ l, _ := scalrClient.AgentPoolTokens.List(ctx, poolID, scalr.AccessTokenListOptions{})
if len(l.Items) > 0 {
return fmt.Errorf("AgentPoolToken %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_environment_test.go b/internal/provider/resource_scalr_environment_test.go
index 5d7e0dc3..f51d201f 100644
--- a/internal/provider/resource_scalr_environment_test.go
+++ b/internal/provider/resource_scalr_environment_test.go
@@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccEnvironment_basic(t *testing.T) {
@@ -16,8 +14,8 @@ func TestAccEnvironment_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
@@ -44,8 +42,8 @@ func TestAccEnvironment_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
@@ -81,8 +79,8 @@ func TestAccEnvironmentWithProviderConfigurations_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
@@ -111,7 +109,7 @@ func TestAccEnvironmentWithProviderConfigurations_update(t *testing.T) {
}
func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_environment" {
@@ -122,7 +120,7 @@ func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Environments.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Environments.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Environment %s still exists", rs.Primary.ID)
}
@@ -133,7 +131,7 @@ func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
func testAccCheckScalrEnvironmentExists(n string, environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -143,7 +141,7 @@ func testAccCheckScalrEnvironmentExists(n string, environment *scalr.Environment
if rs.Primary.ID == "" {
return fmt.Errorf("No instance ID is set")
}
- env, err := scalrClient.Environments.Read(scalr2.ctx, rs.Primary.ID)
+ env, err := scalrClient.Environments.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -187,12 +185,12 @@ func testAccCheckScalrEnvironmentAttributesUpdate(environment *scalr.Environment
func testAccCheckScalrEnvironmentProviderConfigurations(environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
if len(environment.DefaultProviderConfigurations) != 1 {
return fmt.Errorf("Bad default provider configurations: %v", environment.DefaultProviderConfigurations)
}
- providerConfiguration, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, environment.DefaultProviderConfigurations[0].ID)
+ providerConfiguration, err := scalrClient.ProviderConfigurations.Read(ctx, environment.DefaultProviderConfigurations[0].ID)
if err != nil {
return err
}
@@ -204,12 +202,12 @@ func testAccCheckScalrEnvironmentProviderConfigurations(environment *scalr.Envir
}
func testAccCheckScalrEnvironmentProviderConfigurationsUpdate(environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
if len(environment.DefaultProviderConfigurations) != 1 {
return fmt.Errorf("Bad default provider configurations: %v", environment.DefaultProviderConfigurations)
}
- providerConfiguration, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, environment.DefaultProviderConfigurations[0].ID)
+ providerConfiguration, err := scalrClient.ProviderConfigurations.Read(ctx, environment.DefaultProviderConfigurations[0].ID)
if err != nil {
return err
}
diff --git a/internal/provider/resource_scalr_event_bridge_integration_test.go b/internal/provider/resource_scalr_event_bridge_integration_test.go
index 98756ed7..15d753de 100644
--- a/internal/provider/resource_scalr_event_bridge_integration_test.go
+++ b/internal/provider/resource_scalr_event_bridge_integration_test.go
@@ -6,8 +6,6 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccEventBridgeIntegration_basic(t *testing.T) {
@@ -17,8 +15,8 @@ func TestAccEventBridgeIntegration_basic(t *testing.T) {
t.Skip("Please set AWS_EVENT_BRIDGE_ACCOUNT_ID, AWS_EVENT_BRIDGE_REGION env variables to run this test.")
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrEventBridgeIntegrationConfig(AWSAccountId, region),
diff --git a/internal/provider/resource_scalr_iam_team_test.go b/internal/provider/resource_scalr_iam_team_test.go
index 2230f244..b6b5e1d6 100644
--- a/internal/provider/resource_scalr_iam_team_test.go
+++ b/internal/provider/resource_scalr_iam_team_test.go
@@ -10,8 +10,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrIamTeam_basic(t *testing.T) {
@@ -19,8 +17,8 @@ func TestAccScalrIamTeam_basic(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -46,8 +44,8 @@ func TestAccScalrIamTeam_renamed(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -84,8 +82,8 @@ func TestAccScalrIamTeam_update(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -124,8 +122,8 @@ func TestAccScalrIamTeam_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
@@ -142,7 +140,7 @@ func TestAccScalrIamTeam_import(t *testing.T) {
func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -153,7 +151,7 @@ func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.Tes
return fmt.Errorf("No instance ID is set")
}
- t, err := scalrClient.Teams.Read(scalr2.ctx, rs.Primary.ID)
+ t, err := scalrClient.Teams.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -166,9 +164,9 @@ func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.Tes
func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- t, err := scalrClient.Teams.Read(scalr2.ctx, team.ID)
+ t, err := scalrClient.Teams.Read(ctx, team.ID)
if err != nil {
log.Fatalf("Error retrieving team: %v", err)
}
@@ -191,7 +189,7 @@ func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
}
func testAccCheckScalrIamTeamDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_iam_team" {
@@ -202,7 +200,7 @@ func testAccCheckScalrIamTeamDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Teams.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Teams.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Team %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_module_test.go b/internal/provider/resource_scalr_module_test.go
index e14b3507..f5e9ca08 100644
--- a/internal/provider/resource_scalr_module_test.go
+++ b/internal/provider/resource_scalr_module_test.go
@@ -8,8 +8,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrModule_basic(t *testing.T) {
@@ -17,9 +15,9 @@ func TestAccScalrModule_basic(t *testing.T) {
PreCheck: func() {
//TODO:ape delete skip after SCALRCORE-19891
t.Skip("Working on personal token but not working with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrModuleDestroy,
Steps: []resource.TestStep{
{
@@ -68,9 +66,9 @@ func TestAccScalrModule_basic(t *testing.T) {
func TestAccScalrModule_import(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrModuleDestroy,
Steps: []resource.TestStep{
{
@@ -87,7 +85,7 @@ func TestAccScalrModule_import(t *testing.T) {
func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[moduleId]
if !ok {
@@ -99,7 +97,7 @@ func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resour
}
// Get the module
- m, err := scalrClient.Modules.Read(scalr2.ctx, rs.Primary.ID)
+ m, err := scalrClient.Modules.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -111,7 +109,7 @@ func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resour
}
func testAccCheckScalrModuleDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_module" {
@@ -122,7 +120,7 @@ func testAccCheckScalrModuleDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Modules.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Modules.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Module %s still exists", rs.Primary.ID)
}
@@ -145,7 +143,7 @@ func testAccScalrModule() string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, string(scalr.Github), scalr2.githubToken)
+`, string(scalr.Github), githubToken)
}
func testAccScalrModulesOnAllScopes() string {
@@ -190,5 +188,5 @@ func testAccScalrModulesOnAllScopes() string {
}
vcs_provider_id = scalr_vcs_provider.test.id
}
-`, rInd, string(scalr.Github), scalr2.githubToken, defaultAccount)
+`, rInd, string(scalr.Github), githubToken, defaultAccount)
}
diff --git a/internal/provider/resource_scalr_policy_group_linkage_test.go b/internal/provider/resource_scalr_policy_group_linkage_test.go
index 3dfe6382..f0681a93 100644
--- a/internal/provider/resource_scalr_policy_group_linkage_test.go
+++ b/internal/provider/resource_scalr_policy_group_linkage_test.go
@@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccPolicyGroupLinkage_basic(t *testing.T) {
@@ -20,9 +18,9 @@ func TestAccPolicyGroupLinkage_basic(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
Steps: []resource.TestStep{
{
@@ -56,9 +54,9 @@ func TestAccPolicyGroupLinkage_import(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
Steps: []resource.TestStep{
{
@@ -79,7 +77,7 @@ func testAccCheckPolicyGroupLinkageExists(
environment *scalr.Environment,
) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resID]
if !ok {
@@ -90,7 +88,7 @@ func testAccCheckPolicyGroupLinkageExists(
return fmt.Errorf("no instance ID is set")
}
- pg, env, err := getLinkedResources(scalr2.ctx, rs.Primary.ID, scalrClient)
+ pg, env, err := getLinkedResources(ctx, rs.Primary.ID, scalrClient)
if err != nil {
return err
}
@@ -103,7 +101,7 @@ func testAccCheckPolicyGroupLinkageExists(
}
func testAccCheckPolicyGroupLinkageDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_policy_group_linkage" {
@@ -114,7 +112,7 @@ func testAccCheckPolicyGroupLinkageDestroy(s *terraform.State) error {
return fmt.Errorf("no instance ID is set")
}
- _, _, err := getLinkedResources(scalr2.ctx, rs.Primary.ID, scalrClient)
+ _, _, err := getLinkedResources(ctx, rs.Primary.ID, scalrClient)
if err == nil {
return fmt.Errorf("policy group linkage %s still exists", rs.Primary.ID)
}
@@ -154,5 +152,5 @@ resource "scalr_policy_group_linkage" "test" {
policy_group_id = scalr_policy_group.test.id
environment_id = scalr_environment.test.id
}
-`, defaultAccount, rInt, string(scalr.Github), scalr2.githubToken, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, defaultAccount, rInt, string(scalr.Github), githubToken, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
diff --git a/internal/provider/resource_scalr_policy_group_test.go b/internal/provider/resource_scalr_policy_group_test.go
index 4ed4a628..c86e25cd 100644
--- a/internal/provider/resource_scalr_policy_group_test.go
+++ b/internal/provider/resource_scalr_policy_group_test.go
@@ -9,8 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
const (
@@ -25,9 +23,9 @@ func TestAccPolicyGroup_basic(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -78,9 +76,9 @@ func TestAccPolicyGroup_update(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -169,9 +167,9 @@ func TestAccPolicyGroup_renamed(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -260,9 +258,9 @@ func TestAccPolicyGroup_import(t *testing.T) {
PreCheck: func() {
// TODO: delete skip after SCALRCORE-19891
t.Skip("Works with personal token but does not work with github action token.")
- scalr2.testVcsAccGithubTokenPreCheck(t)
+ testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
@@ -279,7 +277,7 @@ func TestAccPolicyGroup_import(t *testing.T) {
func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resID]
if !ok {
@@ -290,7 +288,7 @@ func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup)
return fmt.Errorf("no instance ID is set")
}
- pg, err := scalrClient.PolicyGroups.Read(scalr2.ctx, rs.Primary.ID)
+ pg, err := scalrClient.PolicyGroups.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -301,7 +299,7 @@ func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup)
}
func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_policy_group" {
@@ -312,7 +310,7 @@ func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
return fmt.Errorf("no instance ID is set")
}
- _, err := scalrClient.PolicyGroups.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.PolicyGroups.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("policy group %s still exists", rs.Primary.ID)
}
@@ -323,7 +321,7 @@ func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
func testAccCheckPolicyGroupRename(policyGroup *scalr.PolicyGroup) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
_, err := scalrClient.PolicyGroups.Update(
context.Background(),
@@ -353,7 +351,7 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), scalr2.githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
func testAccPolicyGroupUpdateConfig(rInt int) string {
@@ -373,7 +371,7 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), scalr2.githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
func testAccPolicyGroupRenamedConfig(rInt int) string {
@@ -393,5 +391,5 @@ resource "scalr_policy_group" "test" {
path = "%s"
}
}
-`, rInt, string(scalr.Github), scalr2.githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
+`, rInt, string(scalr.Github), githubToken, defaultAccount, policyGroupVcsRepoID, policyGroupVcsRepoPath)
}
diff --git a/internal/provider/resource_scalr_provider_configuration_default_test.go b/internal/provider/resource_scalr_provider_configuration_default_test.go
index bc8e8aa7..c5937164 100644
--- a/internal/provider/resource_scalr_provider_configuration_default_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_default_test.go
@@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccProviderConfigurationDefault_basic(t *testing.T) {
@@ -16,9 +14,9 @@ func TestAccProviderConfigurationDefault_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr2.testAccPreCheck(t)
+ testAccPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
Steps: []resource.TestStep{
{
@@ -38,9 +36,9 @@ func TestAccProviderConfigurationDefault_import(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr2.testAccPreCheck(t)
+ testAccPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
Steps: []resource.TestStep{
{
@@ -64,12 +62,12 @@ func testAccCheckProviderConfigurationDefaultExists(
return fmt.Errorf("Not found: %s", rn)
}
- client := scalr2.testAccProvider.Meta().(*scalr.Client)
+ client := testAccProvider.Meta().(*scalr.Client)
providerConfigurationID := rs.Primary.Attributes["provider_configuration_id"]
environmentID := rs.Primary.Attributes["environment_id"]
- environment, err := client.Environments.Read(scalr2.ctx, environmentID)
+ environment, err := client.Environments.Read(ctx, environmentID)
if err != nil {
return err
}
@@ -85,7 +83,7 @@ func testAccCheckProviderConfigurationDefaultExists(
}
func testAccCheckProviderConfigurationDefaultDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_provider_configuration_default" {
@@ -96,7 +94,7 @@ func testAccCheckProviderConfigurationDefaultDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- environment, err := scalrClient.Environments.Read(scalr2.ctx, rs.Primary.Attributes["environment_id"])
+ environment, err := scalrClient.Environments.Read(ctx, rs.Primary.Attributes["environment_id"])
if err == nil {
for _, defaultProviderConfiguration := range environment.DefaultProviderConfigurations {
if defaultProviderConfiguration.ID == rs.Primary.Attributes["provider_configuration_id"] {
diff --git a/internal/provider/resource_scalr_provider_configuration_test.go b/internal/provider/resource_scalr_provider_configuration_test.go
index 185b6b31..413e4cd1 100644
--- a/internal/provider/resource_scalr_provider_configuration_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_test.go
@@ -13,7 +13,6 @@ import (
"github.com/scalr/go-scalr"
"github.com/scalr/terraform-provider-scalr/internal/client"
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccProviderConfiguration_import(t *testing.T) {
@@ -21,9 +20,9 @@ func TestAccProviderConfiguration_import(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr2.testAccPreCheck(t)
+ testAccPreCheck(t)
},
- ProviderFactories: scalr2.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -44,8 +43,8 @@ func TestAccProviderConfiguration_custom(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -166,8 +165,8 @@ func TestAccProviderConfiguration_aws_custom(t *testing.T) {
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -188,8 +187,8 @@ func TestAccProviderConfiguration_aws(t *testing.T) {
accessKeyId, secretAccessKey, roleArn, externalId := getAwsTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -235,8 +234,8 @@ func TestAccProviderConfiguration_scalr(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -280,8 +279,8 @@ func TestAccProviderConfiguration_google(t *testing.T) {
credentials, project := getGoogleTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -326,8 +325,8 @@ func TestAccProviderConfiguration_google_oidc(t *testing.T) {
_, project := getGoogleTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -373,8 +372,8 @@ func TestAccProviderConfiguration_aws_oidc(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -415,8 +414,8 @@ func TestAccProviderConfiguration_azurerm(t *testing.T) {
armClientId, armClientSecret, armSubscription, armTenantId := getAzureTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
@@ -695,9 +694,9 @@ func testAccCheckProviderConfigurationExists(n string, providerConfiguration *sc
return fmt.Errorf("Not found: %s", n)
}
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- providerConfigurationResource, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, rs.Primary.ID)
+ providerConfigurationResource, err := scalrClient.ProviderConfigurations.Read(ctx, rs.Primary.ID)
if err != nil {
return err
@@ -710,14 +709,14 @@ func testAccCheckProviderConfigurationExists(n string, providerConfiguration *sc
}
func testAccCheckProviderConfigurationResourceDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_provider_configuration" {
continue
}
- _, err := scalrClient.ProviderConfigurations.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.ProviderConfigurations.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Provider configuraiton (%s) still exists.", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_role_migrate_test.go b/internal/provider/resource_scalr_role_migrate_test.go
index 9787e53c..1f8a2f93 100644
--- a/internal/provider/resource_scalr_role_migrate_test.go
+++ b/internal/provider/resource_scalr_role_migrate_test.go
@@ -2,8 +2,6 @@ package provider
import (
"testing"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrRoleStateDataV0() map[string]interface{} {
@@ -50,18 +48,18 @@ func testResourceScalrRoleStateDataV1ExistingPerm() map[string]interface{} {
func TestResourceScalrRoleStateUpgradeV0(t *testing.T) {
expected := testResourceScalrRoleStateDataV1()
- actual, err := resourceScalrRoleStateUpgradeV0(scalr.ctx, testResourceScalrRoleStateDataV0(), nil)
+ actual, err := resourceScalrRoleStateUpgradeV0(ctx, testResourceScalrRoleStateDataV0(), nil)
assertCorrectState(t, err, actual, expected)
}
func TestResourceScalrRoleStateUpgradeV0NoGlobalScope(t *testing.T) {
expected := testResourceScalrRoleStateDataV1NoGlobalScope()
- actual, err := resourceScalrRoleStateUpgradeV0(scalr.ctx, testResourceScalrRoleStateDataV0NoGlobalScope(), nil)
+ actual, err := resourceScalrRoleStateUpgradeV0(ctx, testResourceScalrRoleStateDataV0NoGlobalScope(), nil)
assertCorrectState(t, err, actual, expected)
}
func TestResourceScalrRoleStateUpgradeV0ExistingPermission(t *testing.T) {
expected := testResourceScalrRoleStateDataV1ExistingPerm()
- actual, err := resourceScalrRoleStateUpgradeV0(scalr.ctx, testResourceScalrRoleStateDataV0ExistingPerm(), nil)
+ actual, err := resourceScalrRoleStateUpgradeV0(ctx, testResourceScalrRoleStateDataV0ExistingPerm(), nil)
assertCorrectState(t, err, actual, expected)
}
diff --git a/internal/provider/resource_scalr_role_test.go b/internal/provider/resource_scalr_role_test.go
index 3a6695c3..5c336384 100644
--- a/internal/provider/resource_scalr_role_test.go
+++ b/internal/provider/resource_scalr_role_test.go
@@ -10,16 +10,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRole_basic(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -42,8 +40,8 @@ func TestAccScalrRole_renamed(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -79,8 +77,8 @@ func TestAccScalrRole_update(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -119,8 +117,8 @@ func TestAccScalrRole_update(t *testing.T) {
func TestAccScalrRole_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
@@ -138,7 +136,7 @@ func TestAccScalrRole_import(t *testing.T) {
func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -150,7 +148,7 @@ func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCh
}
// Get the role
- r, err := scalrClient.Roles.Read(scalr2.ctx, rs.Primary.ID)
+ r, err := scalrClient.Roles.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -163,9 +161,9 @@ func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCh
func testAccCheckScalrRoleRename(role *scalr.Role) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.Roles.Read(scalr2.ctx, role.ID)
+ r, err := scalrClient.Roles.Read(ctx, role.ID)
if err != nil {
log.Fatalf("Error retrieving role: %v", err)
@@ -187,7 +185,7 @@ func testAccCheckScalrRoleRename(role *scalr.Role) func() {
}
func testAccCheckScalrRoleDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_role" {
@@ -198,7 +196,7 @@ func testAccCheckScalrRoleDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Roles.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Roles.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Role %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_run_schedule_rule_test.go b/internal/provider/resource_scalr_run_schedule_rule_test.go
index 8a5f9c2d..db7c4516 100644
--- a/internal/provider/resource_scalr_run_schedule_rule_test.go
+++ b/internal/provider/resource_scalr_run_schedule_rule_test.go
@@ -7,16 +7,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRunScheduleRule_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
@@ -39,8 +37,8 @@ func TestAccScalrRunScheduleRule_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
@@ -71,8 +69,8 @@ func TestAccScalrRunScheduleRule_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
@@ -98,8 +96,8 @@ func testAccCheckScalrRunScheduleRuleExists(resId string, rule *scalr.RunSchedul
return fmt.Errorf("No Run Schedule Rule ID is set")
}
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
- r, err := scalrClient.RunScheduleRules.Read(scalr2.ctx, rs.Primary.ID)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
+ r, err := scalrClient.RunScheduleRules.Read(ctx, rs.Primary.ID)
if err != nil {
return fmt.Errorf("Error reading run schedule rule: %v", err)
}
@@ -111,7 +109,7 @@ func testAccCheckScalrRunScheduleRuleExists(resId string, rule *scalr.RunSchedul
}
func testAccCheckScalrRunScheduleRuleDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_run_schedule_rule" {
@@ -122,7 +120,7 @@ func testAccCheckScalrRunScheduleRuleDestroy(s *terraform.State) error {
return fmt.Errorf("No Run Schedule Rule ID is set")
}
- _, err := scalrClient.RunScheduleRules.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.RunScheduleRules.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Run Schedule Rule %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_run_triggers_test.go b/internal/provider/resource_scalr_run_triggers_test.go
index 44469790..8bb43a2a 100644
--- a/internal/provider/resource_scalr_run_triggers_test.go
+++ b/internal/provider/resource_scalr_run_triggers_test.go
@@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
@@ -16,8 +14,8 @@ func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckRunTriggerDestroy,
Steps: []resource.TestStep{
{
@@ -32,7 +30,7 @@ func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
}
func testAccCheckRunTriggerDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_run_trigger" {
@@ -43,7 +41,7 @@ func testAccCheckRunTriggerDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.RunTriggers.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.RunTriggers.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("RunTrigger %s still exists", rs.Primary.ID)
}
@@ -79,7 +77,7 @@ resource "scalr_run_trigger" "foobar" {
func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -90,7 +88,7 @@ func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resour
return fmt.Errorf("No instance ID is set")
}
- rt, err := scalrClient.RunTriggers.Read(scalr2.ctx, rs.Primary.ID)
+ rt, err := scalrClient.RunTriggers.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -103,7 +101,7 @@ func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resour
func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
environment, ok := s.RootModule().Resources[environmentName]
if !ok {
@@ -111,7 +109,7 @@ func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentN
}
downstreamID := runTrigger.Downstream.ID
- downstream, err := scalrClient.Workspaces.Read(scalr2.ctx, environment.Primary.ID, "downstream-test")
+ downstream, err := scalrClient.Workspaces.Read(ctx, environment.Primary.ID, "downstream-test")
if err != nil {
return fmt.Errorf("Error retreiving workspace downstream-test for environment %s, %v", environmentName, err)
}
@@ -121,7 +119,7 @@ func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentN
}
upstreamID := runTrigger.Upstream.ID
- upstream, err := scalrClient.Workspaces.Read(scalr2.ctx, environment.Primary.ID, "upstream-test")
+ upstream, err := scalrClient.Workspaces.Read(ctx, environment.Primary.ID, "upstream-test")
if err != nil {
return fmt.Errorf("Error retreiving workspace upstream-test for environment %s, %v", environmentName, err)
}
diff --git a/internal/provider/resource_scalr_service_account_test.go b/internal/provider/resource_scalr_service_account_test.go
index a7b5ef24..ad88b6f4 100644
--- a/internal/provider/resource_scalr_service_account_test.go
+++ b/internal/provider/resource_scalr_service_account_test.go
@@ -7,16 +7,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrServiceAccount_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
@@ -52,8 +50,8 @@ func TestAccScalrServiceAccount_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
@@ -72,8 +70,8 @@ func TestAccScalrServiceAccount_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
@@ -129,7 +127,7 @@ resource scalr_service_account test {
}
func testAccCheckScalrServiceAccountDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_service_account" {
@@ -140,7 +138,7 @@ func testAccCheckScalrServiceAccountDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.ServiceAccounts.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.ServiceAccounts.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Service account %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_service_account_token_test.go b/internal/provider/resource_scalr_service_account_token_test.go
index 3718c9e8..153719a6 100644
--- a/internal/provider/resource_scalr_service_account_token_test.go
+++ b/internal/provider/resource_scalr_service_account_token_test.go
@@ -7,16 +7,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrServiceAccountToken_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
Steps: []resource.TestStep{
{
@@ -40,8 +38,8 @@ func TestAccScalrServiceAccountToken_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
Steps: []resource.TestStep{
{
@@ -61,7 +59,7 @@ func TestAccScalrServiceAccountToken_update(t *testing.T) {
}
func testAccCheckScalrServiceAccountTokenDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_service_account_token" {
@@ -71,7 +69,7 @@ func testAccCheckScalrServiceAccountTokenDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.AccessTokens.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.AccessTokens.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Service account token %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_slack_integration_test.go b/internal/provider/resource_scalr_slack_integration_test.go
index 6f2d8445..31518eea 100644
--- a/internal/provider/resource_scalr_slack_integration_test.go
+++ b/internal/provider/resource_scalr_slack_integration_test.go
@@ -5,18 +5,16 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccSlackIntegration_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
- scalr.testAccPreCheck(t)
+ testAccPreCheck(t)
scalrClient, _ := createScalrClient()
- slackConnection, err := scalrClient.SlackIntegrations.GetConnection(scalr.ctx, defaultAccount)
+ slackConnection, err := scalrClient.SlackIntegrations.GetConnection(ctx, defaultAccount)
if err != nil {
t.Fatalf("Error fetching Slack connection: %v", err)
return
@@ -25,7 +23,7 @@ func TestAccSlackIntegration_basic(t *testing.T) {
t.Skip("Scalr instance doesn't have working slack connection.")
}
},
- ProviderFactories: scalr.testAccProviderFactories,
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrSlackIntegrationConfig(),
diff --git a/internal/provider/resource_scalr_ssh_key_test.go b/internal/provider/resource_scalr_ssh_key_test.go
index 41c43e43..1695d4f7 100644
--- a/internal/provider/resource_scalr_ssh_key_test.go
+++ b/internal/provider/resource_scalr_ssh_key_test.go
@@ -10,8 +10,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrSSHKey_basic(t *testing.T) {
@@ -19,8 +17,8 @@ func TestAccScalrSSHKey_basic(t *testing.T) {
var sshKey scalr.SSHKey
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
@@ -40,8 +38,8 @@ func TestAccScalrSSHKey_update(t *testing.T) {
var sshKey scalr.SSHKey
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
@@ -66,8 +64,8 @@ func TestAccScalrSSHKey_import(t *testing.T) {
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
@@ -114,7 +112,7 @@ EOF
}
func testAccCheckSSHKeyDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_ssh_key" {
@@ -141,7 +139,7 @@ func testAccCheckSSHKeyIsShared(resourceName string, expectedIsShared bool, sshK
return fmt.Errorf("Not found: %s", resourceName)
}
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
readKey, err := scalrClient.SSHKeys.Read(context.Background(), rs.Primary.ID)
if err != nil {
return fmt.Errorf("Error reading SSH key: %s", err)
diff --git a/internal/provider/resource_scalr_tag_test.go b/internal/provider/resource_scalr_tag_test.go
index 88e84ef5..b1d13e25 100644
--- a/internal/provider/resource_scalr_tag_test.go
+++ b/internal/provider/resource_scalr_tag_test.go
@@ -9,16 +9,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrTag_basic(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -36,8 +34,8 @@ func TestAccScalrTag_basic(t *testing.T) {
func TestAccScalrTag_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -57,8 +55,8 @@ func TestAccScalrTag_update(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -86,8 +84,8 @@ func TestAccScalrTag_renamed(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
@@ -138,9 +136,9 @@ resource scalr_tag test {
func testAccCheckScalrTagRename(tag *scalr.Tag) func() {
return func() {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- t, err := scalrClient.Tags.Read(scalr2.ctx, tag.ID)
+ t, err := scalrClient.Tags.Read(ctx, tag.ID)
if err != nil {
log.Fatalf("Error retrieving tag: %v", err)
@@ -164,7 +162,7 @@ func testAccCheckScalrTagRename(tag *scalr.Tag) func() {
func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -176,7 +174,7 @@ func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheck
}
// Get the tag
- t, err := scalrClient.Tags.Read(scalr2.ctx, rs.Primary.ID)
+ t, err := scalrClient.Tags.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -188,7 +186,7 @@ func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheck
}
func testAccCheckScalrTagDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_tag" {
@@ -199,7 +197,7 @@ func testAccCheckScalrTagDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Tags.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Tags.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Tag %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_variable_migrate_test.go b/internal/provider/resource_scalr_variable_migrate_test.go
index d0b2e5a0..297fbb2c 100644
--- a/internal/provider/resource_scalr_variable_migrate_test.go
+++ b/internal/provider/resource_scalr_variable_migrate_test.go
@@ -5,8 +5,6 @@ import (
"testing"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrVariableStateDataV0() map[string]interface{} {
@@ -31,7 +29,7 @@ func TestResourceScalrVariableStateUpgradeV0(t *testing.T) {
})
expected := testResourceScalrVariableStateDataV1()
- actual, err := resourceScalrVariableStateUpgradeV0(scalr2.ctx, testResourceScalrVariableStateDataV0(), client)
+ actual, err := resourceScalrVariableStateUpgradeV0(ctx, testResourceScalrVariableStateDataV0(), client)
assertCorrectState(t, err, actual, expected)
}
@@ -49,7 +47,7 @@ func testResourceScalrVariableStateDataCategoryV1() map[string]interface{} {
func TestResourceScalrVariableStateUpgradeV1(t *testing.T) {
expected := testResourceScalrVariableStateDataCategoryV1()
- actual, err := resourceScalrVariableStateUpgradeV1(scalr2.ctx, testResourceScalrVariableStateDataCategoryV0(), nil)
+ actual, err := resourceScalrVariableStateUpgradeV1(ctx, testResourceScalrVariableStateDataCategoryV0(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -70,7 +68,7 @@ func TestResourceScalrVariableStateUpgradeV2(t *testing.T) {
client := testScalrClient(t)
variable, _ := client.Variables.Create(context.Background(), scalr.VariableCreateOptions{ID: "var-123"})
expected := testResourceScalrVariableStateDataDescriptionV2(variable.ID)
- actual, err := resourceScalrVariableStateUpgradeV2(scalr2.ctx, testResourceScalrVariableStateDataDescriptionV1(variable.ID), client)
+ actual, err := resourceScalrVariableStateUpgradeV2(ctx, testResourceScalrVariableStateDataDescriptionV1(variable.ID), client)
assertCorrectState(t, err, actual, expected)
}
diff --git a/internal/provider/resource_scalr_variable_test.go b/internal/provider/resource_scalr_variable_test.go
index 80cd5b9f..8f4eb731 100644
--- a/internal/provider/resource_scalr_variable_test.go
+++ b/internal/provider/resource_scalr_variable_test.go
@@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
const baseForUpdate = `
@@ -28,8 +26,8 @@ func TestAccScalrVariable_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -86,8 +84,8 @@ func TestAccScalrVariable_basic(t *testing.T) {
func TestAccScalrVariable_defaults(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -113,8 +111,8 @@ func TestAccScalrVariable_scopes(t *testing.T) {
variable := &scalr.Variable{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -130,8 +128,8 @@ func TestAccScalrVariable_update(t *testing.T) {
variable := &scalr.Variable{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -190,8 +188,8 @@ func TestAccScalrVariable_update(t *testing.T) {
func TestAccScalrVariable_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
@@ -207,7 +205,7 @@ func TestAccScalrVariable_import(t *testing.T) {
}
func variableFromState(s *terraform.State, n string, v *scalr.Variable) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -218,7 +216,7 @@ func variableFromState(s *terraform.State, n string, v *scalr.Variable) error {
return fmt.Errorf("No instance ID is set")
}
- variable, err := scalrClient.Variables.Read(scalr2.ctx, rs.Primary.ID)
+ variable, err := scalrClient.Variables.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -335,7 +333,7 @@ func testAccCheckScalrVariableAttributesUpdate(
}
func testAccCheckScalrVariableDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_variable" {
@@ -346,7 +344,7 @@ func testAccCheckScalrVariableDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Variables.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Variables.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Variable %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/resource_scalr_vcs_provider_migrate_test.go b/internal/provider/resource_scalr_vcs_provider_migrate_test.go
index b9d419a9..7970ec46 100644
--- a/internal/provider/resource_scalr_vcs_provider_migrate_test.go
+++ b/internal/provider/resource_scalr_vcs_provider_migrate_test.go
@@ -2,8 +2,6 @@ package provider
import (
"testing"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrVcsProviderStateDataV0() map[string]interface{} {
@@ -24,6 +22,6 @@ func testResourceScalrVcsProviderStateDataV1() map[string]interface{} {
func TestResourceScalrVcsProviderStateUpgradeV0(t *testing.T) {
expected := testResourceScalrVcsProviderStateDataV1()
- actual, err := resourceScalrVcsProviderStateUpgradeV0(scalr.ctx, testResourceScalrVcsProviderStateDataV0(), nil)
+ actual, err := resourceScalrVcsProviderStateUpgradeV0(ctx, testResourceScalrVcsProviderStateDataV0(), nil)
assertCorrectState(t, err, actual, expected)
}
diff --git a/internal/provider/resource_scalr_vcs_provider_test.go b/internal/provider/resource_scalr_vcs_provider_test.go
index 8f3c5a49..ecfaef7e 100644
--- a/internal/provider/resource_scalr_vcs_provider_test.go
+++ b/internal/provider/resource_scalr_vcs_provider_test.go
@@ -8,16 +8,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccVcsProvider_basic(t *testing.T) {
provider := &scalr.VcsProvider{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrVcsProviderConfig(),
@@ -32,7 +30,7 @@ func TestAccVcsProvider_basic(t *testing.T) {
),
},
{
- Config: testAccScalrVcsProviderUpdate(scalr2.githubToken, scalr.Github),
+ Config: testAccScalrVcsProviderUpdate(githubToken, scalr.Github),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrVcsProviderExists("scalr_vcs_provider.test", provider),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "name", "updated-github-vcs-provider"),
@@ -47,7 +45,7 @@ func TestAccVcsProvider_basic(t *testing.T) {
ExpectError: regexp.MustCompile("Invalid access token"),
},
{
- Config: testAccScalrVcsProviderUpdate(scalr2.githubToken, scalr.Gitlab),
+ Config: testAccScalrVcsProviderUpdate(githubToken, scalr.Gitlab),
ExpectError: regexp.MustCompile("Invalid access token"),
},
},
@@ -57,8 +55,8 @@ func TestAccVcsProvider_basic(t *testing.T) {
func TestAccVcsProvider_globalScope(t *testing.T) {
provider := &scalr.VcsProvider{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVcsProviderDestroy,
Steps: []resource.TestStep{
{
@@ -68,7 +66,7 @@ func TestAccVcsProvider_globalScope(t *testing.T) {
vcs_type="github"
token="%s"
}
- `, scalr2.githubToken),
+ `, githubToken),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrVcsProviderExists("scalr_vcs_provider.test", provider),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "name", "global-github-vcs-provider"),
@@ -82,8 +80,8 @@ func TestAccVcsProvider_globalScope(t *testing.T) {
func TestAccScalrVcsProvider_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrVcsProviderDestroy,
Steps: []resource.TestStep{
{
@@ -101,7 +99,7 @@ func TestAccScalrVcsProvider_import(t *testing.T) {
func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProvider) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -109,11 +107,11 @@ func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProv
}
if rs.Primary.ID == "" {
- return scalr2.noInstanceIdErr
+ return noInstanceIdErr
}
// Get the role
- p, err := scalrClient.VcsProviders.Read(scalr2.ctx, rs.Primary.ID)
+ p, err := scalrClient.VcsProviders.Read(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -125,7 +123,7 @@ func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProv
}
func testAccCheckScalrVcsProviderDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_vcs_provider" {
@@ -133,10 +131,10 @@ func testAccCheckScalrVcsProviderDestroy(s *terraform.State) error {
}
if rs.Primary.ID == "" {
- return scalr2.noInstanceIdErr
+ return noInstanceIdErr
}
- _, err := scalrClient.VcsProviders.Read(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.VcsProviders.Read(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Role %s still exists", rs.Primary.ID)
}
@@ -152,7 +150,7 @@ resource "scalr_vcs_provider" "test" {
account_id = "%s"
vcs_type="github"
token = "%s"
-}`, defaultAccount, scalr2.githubToken)
+}`, defaultAccount, githubToken)
}
func testAccScalrVcsProviderUpdate(token string, vcsType scalr.VcsType) string {
diff --git a/internal/provider/resource_scalr_webhook_test.go b/internal/provider/resource_scalr_webhook_test.go
index f31c36a5..79f2b99c 100644
--- a/internal/provider/resource_scalr_webhook_test.go
+++ b/internal/provider/resource_scalr_webhook_test.go
@@ -6,16 +6,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccWebhook_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccWebhookConfig(rInt),
@@ -34,8 +32,8 @@ func TestAccWebhook_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccWebhookConfigUpdateEmptyEvent(rInt),
diff --git a/internal/provider/resource_scalr_workspace_migrate_test.go b/internal/provider/resource_scalr_workspace_migrate_test.go
index eabf50de..c93f17bc 100644
--- a/internal/provider/resource_scalr_workspace_migrate_test.go
+++ b/internal/provider/resource_scalr_workspace_migrate_test.go
@@ -4,8 +4,6 @@ import (
"testing"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func testResourceScalrWorkspaceStateDataV0() map[string]interface{} {
@@ -24,7 +22,7 @@ func testResourceScalrWorkspaceStateDataV1() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV0(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV1()
- actual, err := resourceScalrWorkspaceStateUpgradeV0(scalr2.ctx, testResourceScalrWorkspaceStateDataV0(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV0(ctx, testResourceScalrWorkspaceStateDataV0(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -63,13 +61,13 @@ func testResourceScalrWorkspaceStateDataV2NoVcs() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV1(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV2()
- actual, err := resourceScalrWorkspaceStateUpgradeV1(scalr2.ctx, testResourceScalrWorkspaceStateDataV1VcsRepo(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV1(ctx, testResourceScalrWorkspaceStateDataV1VcsRepo(), nil)
assertCorrectState(t, err, actual, expected)
}
func TestResourceScalrWorkspaceStateUpgradeV1NoVcs(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV2NoVcs()
- actual, err := resourceScalrWorkspaceStateUpgradeV1(scalr2.ctx, testResourceScalrWorkspaceStateDataV1(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV1(ctx, testResourceScalrWorkspaceStateDataV1(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -81,7 +79,7 @@ func testResourceScalrWorkspaceStateDataV3() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV2(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV3()
- actual, err := resourceScalrWorkspaceStateUpgradeV2(scalr2.ctx, testResourceScalrWorkspaceStateDataV2(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV2(ctx, testResourceScalrWorkspaceStateDataV2(), nil)
assertCorrectState(t, err, actual, expected)
}
@@ -109,6 +107,6 @@ func testResourceScalrWorkspaceStateDataV4Operations() map[string]interface{} {
func TestResourceScalrWorkspaceStateUpgradeV3(t *testing.T) {
expected := testResourceScalrWorkspaceStateDataV4Operations()
- actual, err := resourceScalrWorkspaceStateUpgradeV3(scalr2.ctx, testResourceScalrWorkspaceStateDataV3Operations(), nil)
+ actual, err := resourceScalrWorkspaceStateUpgradeV3(ctx, testResourceScalrWorkspaceStateDataV3Operations(), nil)
assertCorrectState(t, err, actual, expected)
}
diff --git a/internal/provider/resource_scalr_workspace_run_schedule_test.go b/internal/provider/resource_scalr_workspace_run_schedule_test.go
index 3bc63be8..d33b244f 100644
--- a/internal/provider/resource_scalr_workspace_run_schedule_test.go
+++ b/internal/provider/resource_scalr_workspace_run_schedule_test.go
@@ -5,16 +5,14 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
-
- "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestScalrWorkspaceRunSchedule_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -34,8 +32,8 @@ func TestScalrWorkspaceRunSchedule_default(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr.testAccPreCheck(t) },
- ProviderFactories: scalr.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
diff --git a/internal/provider/resource_scalr_workspace_test.go b/internal/provider/resource_scalr_workspace_test.go
index e7642e14..15060702 100644
--- a/internal/provider/resource_scalr_workspace_test.go
+++ b/internal/provider/resource_scalr_workspace_test.go
@@ -10,8 +10,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestAccScalrWorkspace_basic(t *testing.T) {
@@ -19,8 +17,8 @@ func TestAccScalrWorkspace_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -74,8 +72,8 @@ func TestAccScalrWorkspace_create_missed_vcs_attr(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceMissedVcsProvider(rInt),
@@ -94,8 +92,8 @@ func TestAccScalrWorkspace_monorepo(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -126,8 +124,8 @@ func TestAccScalrWorkspace_renamed(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -201,8 +199,8 @@ func TestAccScalrWorkspace_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -322,8 +320,8 @@ func TestAccScalrWorkspace_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -344,8 +342,8 @@ func TestAccScalrWorkspace_providerConfiguration(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -379,8 +377,8 @@ func TestAccScalrWorkspaceSSHKey(t *testing.T) {
sshKeyName := fmt.Sprintf("ssh-key-test-%d", rInt)
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -399,7 +397,7 @@ func TestAccScalrWorkspaceSSHKey(t *testing.T) {
func testAccCheckScalrSSHKeyExists(n string, sshKey *scalr.SSHKey) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -424,8 +422,8 @@ func TestAccScalrWorkspace_emptyHooks(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { scalr2.testAccPreCheck(t) },
- ProviderFactories: scalr2.testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
@@ -438,7 +436,7 @@ func TestAccScalrWorkspace_emptyHooks(t *testing.T) {
func testAccCheckScalrWorkspaceExists(
n string, workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -450,7 +448,7 @@ func testAccCheckScalrWorkspaceExists(
}
// Get the workspace
- w, err := scalrClient.Workspaces.ReadByID(scalr2.ctx, rs.Primary.ID)
+ w, err := scalrClient.Workspaces.ReadByID(ctx, rs.Primary.ID)
if err != nil {
return err
}
@@ -502,10 +500,10 @@ func testAccCheckScalrWorkspaceMonorepoAttributes(
func testAccCheckScalrWorkspaceRename(environmentName, workspaceName string) func() {
return func() {
var environmentID *string
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
listOptions := scalr.EnvironmentListOptions{}
- envl, err := scalrClient.Environments.List(scalr2.ctx, listOptions)
+ envl, err := scalrClient.Environments.List(ctx, listOptions)
if err != nil {
log.Fatalf("Error retrieving environments: %v", err)
}
@@ -521,7 +519,7 @@ func testAccCheckScalrWorkspaceRename(environmentName, workspaceName string) fun
return
}
- ws, err := scalrClient.Workspaces.Read(scalr2.ctx, *environmentID, workspaceName)
+ ws, err := scalrClient.Workspaces.Read(ctx, *environmentID, workspaceName)
if err != nil {
log.Fatalf("Error retrieving workspace: %v", err)
@@ -572,9 +570,9 @@ func testAccCheckScalrWorkspaceAttributesUpdated(
func testAccCheckScalrWorkspaceProviderConfigurations(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- links, err := getProviderConfigurationWorkspaceLinks(scalr2.ctx, scalrClient, workspace.ID)
+ links, err := getProviderConfigurationWorkspaceLinks(ctx, scalrClient, workspace.ID)
if err != nil {
return fmt.Errorf("Error retrieving provider configuration links: %v", err)
}
@@ -626,9 +624,9 @@ func testAccCheckScalrWorkspaceProviderConfigurations(
func testAccCheckScalrWorkspaceProviderConfigurationsUpdated(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
- links, err := getProviderConfigurationWorkspaceLinks(scalr2.ctx, scalrClient, workspace.ID)
+ links, err := getProviderConfigurationWorkspaceLinks(ctx, scalrClient, workspace.ID)
if err != nil {
return fmt.Errorf("Error retrieving provider configuration links: %v", err)
}
@@ -679,7 +677,7 @@ func testAccCheckScalrWorkspaceProviderConfigurationsUpdated(
}
func testAccCheckScalrWorkspaceDestroy(s *terraform.State) error {
- scalrClient := scalr2.testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProvider.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_workspace" {
@@ -690,7 +688,7 @@ func testAccCheckScalrWorkspaceDestroy(s *terraform.State) error {
return fmt.Errorf("No instance ID is set")
}
- _, err := scalrClient.Workspaces.ReadByID(scalr2.ctx, rs.Primary.ID)
+ _, err := scalrClient.Workspaces.ReadByID(ctx, rs.Primary.ID)
if err == nil {
return fmt.Errorf("Workspace %s still exists", rs.Primary.ID)
}
diff --git a/internal/provider/workspace_helpers_test.go b/internal/provider/workspace_helpers_test.go
index b29ed08d..5cf18a3c 100644
--- a/internal/provider/workspace_helpers_test.go
+++ b/internal/provider/workspace_helpers_test.go
@@ -5,8 +5,6 @@ import (
"testing"
"github.com/scalr/go-scalr"
-
- scalr2 "github.com/scalr/terraform-provider-scalr/scalr"
)
func TestFetchWorkspaceID(t *testing.T) {
@@ -42,7 +40,7 @@ func TestFetchWorkspaceID(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
- got, err := fetchWorkspaceID(scalr2.ctx, test.def, client)
+ got, err := fetchWorkspaceID(ctx, test.def, client)
if (err != nil) != test.err {
t.Fatalf("expected error is %t, got %v", test.err, err)
From 849fb919f7de16c6556bc4a3d88ca531bfe9240f Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Fri, 22 Nov 2024 10:06:59 +0200
Subject: [PATCH 11/26] SCALRCORE-26654 Inject version in SDK provider
---
internal/provider/provider_sdk.go | 25 +++++++++++++------------
internal/provider/provider_sdk_test.go | 8 ++++----
internal/provider/provider_test.go | 3 +++
main.go | 2 +-
4 files changed, 21 insertions(+), 17 deletions(-)
create mode 100644 internal/provider/provider_test.go
diff --git a/internal/provider/provider_sdk.go b/internal/provider/provider_sdk.go
index a36a8a6d..7077aeef 100644
--- a/internal/provider/provider_sdk.go
+++ b/internal/provider/provider_sdk.go
@@ -8,11 +8,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/terraform-provider-scalr/internal/client"
- "github.com/scalr/terraform-provider-scalr/version"
)
-// Provider returns a terraform.ResourceProvider.
-func Provider() *schema.Provider {
+// Provider returns a terraform.ResourceProvider with version v.
+func Provider(v string) *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"hostname": {
@@ -92,18 +91,20 @@ func Provider() *schema.Provider {
"scalr_ssh_key": resourceScalrSSHKey(),
},
- ConfigureContextFunc: providerConfigure,
+ ConfigureContextFunc: providerConfigure(v),
}
}
-func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
- h := d.Get("hostname").(string)
- t := d.Get("token").(string)
+func providerConfigure(v string) func(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
+ return func(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
+ h := d.Get("hostname").(string)
+ t := d.Get("token").(string)
- scalrClient, err := client.Configure(h, t, version.ProviderVersion)
- if err != nil {
- return nil, diag.FromErr(err)
- }
+ scalrClient, err := client.Configure(h, t, v)
+ if err != nil {
+ return nil, diag.FromErr(err)
+ }
- return scalrClient, nil
+ return scalrClient, nil
+ }
}
diff --git a/internal/provider/provider_sdk_test.go b/internal/provider/provider_sdk_test.go
index 5c24b2c1..4e36c2d0 100644
--- a/internal/provider/provider_sdk_test.go
+++ b/internal/provider/provider_sdk_test.go
@@ -20,7 +20,7 @@ var githubToken = os.Getenv("githubToken")
var ctx = context.Background()
func init() {
- testAccProvider = Provider()
+ testAccProvider = Provider(testProviderVersion)
testAccProviderFactories = map[string]func() (*schema.Provider, error){
"scalr": func() (*schema.Provider, error) {
return testAccProvider, nil
@@ -29,18 +29,18 @@ func init() {
}
func TestProvider(t *testing.T) {
- if err := Provider().InternalValidate(); err != nil {
+ if err := Provider(testProviderVersion).InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}
func TestProvider_impl(t *testing.T) {
- var _ = Provider()
+ var _ = Provider(testProviderVersion)
}
func testAccPreCheck(t *testing.T) {
// The credentials must be provided by the CLI config file for testing.
- if diags := Provider().Configure(context.Background(), &terraform.ResourceConfig{}); diags.HasError() {
+ if diags := Provider(testProviderVersion).Configure(context.Background(), &terraform.ResourceConfig{}); diags.HasError() {
for _, d := range diags {
if d.Severity == diag.Error {
t.Fatalf("err: %s", d.Summary)
diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go
new file mode 100644
index 00000000..3b3b860a
--- /dev/null
+++ b/internal/provider/provider_test.go
@@ -0,0 +1,3 @@
+package provider
+
+const testProviderVersion = "test"
diff --git a/main.go b/main.go
index 94fba414..94979324 100644
--- a/main.go
+++ b/main.go
@@ -45,7 +45,7 @@ func main() {
// New provider implementation with Terraform Plugin Framework
providerserver.NewProtocol5(provider.New(version.ProviderVersion)()),
// Classic provider implementation with Terraform Plugin SDK
- provider.Provider().GRPCProvider,
+ provider.Provider(version.ProviderVersion).GRPCProvider,
}
muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
From 027eb6ba6539d2706dc2aaf501a331668eed7431 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Fri, 22 Nov 2024 10:18:47 +0200
Subject: [PATCH 12/26] SCALRCORE-26654 Fix refactoring typos
---
internal/provider/data_source_scalr_variable_test.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/internal/provider/data_source_scalr_variable_test.go b/internal/provider/data_source_scalr_variable_test.go
index 2b19c40a..3be0a714 100644
--- a/internal/provider/data_source_scalr_variable_test.go
+++ b/internal/provider/data_source_scalr_variable_test.go
@@ -90,7 +90,7 @@ resource scalr_workspace test {
resource "scalr_variable" "workspace_hostname" {
key = "hostname"
- value = "workspace.com"
+ value = "workspace.scalr.com"
category = "shell"
hcl = false
sensitive = false
@@ -101,11 +101,11 @@ resource "scalr_variable" "workspace_hostname" {
resource "scalr_variable" "hostname" {
key = "hostname"
- value = "com"
+ value = "scalr.com"
category = "shell"
hcl = false
sensitive = false
- description = "The hostname of "
+ description = "The hostname of scalr."
final = false
account_id = "%[1]s"
}
From 5fc4491fcfd8358ede5fa37dcf1a2ec5a1978378 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Fri, 22 Nov 2024 19:23:33 +0200
Subject: [PATCH 13/26] SCALRCORE-26654 Get rid of terraform-plugin-sdk logging
package in http client
---
internal/client/client.go | 7 +-
internal/logging/http.go | 144 ++++++++++++++++++++++++++++++
internal/provider/provider_sdk.go | 2 +-
3 files changed, 149 insertions(+), 4 deletions(-)
create mode 100644 internal/logging/http.go
diff --git a/internal/client/client.go b/internal/client/client.go
index 4b978797..73e8778d 100644
--- a/internal/client/client.go
+++ b/internal/client/client.go
@@ -7,10 +7,11 @@ import (
"net/http"
"net/url"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
svchost "github.com/hashicorp/terraform-svchost"
"github.com/hashicorp/terraform-svchost/disco"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/logging"
)
var scalrServiceIDs = []string{"iacp.v3"}
@@ -31,7 +32,7 @@ func Configure(h, t, v string) (*scalr.Client, error) {
credsSrc := credentialsSource(config)
services := disco.NewWithCredentialsSource(credsSrc)
services.SetUserAgent(providerUaString)
- services.Transport = logging.NewLoggingHTTPTransport(services.Transport)
+ services.Transport = logging.NewLoggingTransport(services.Transport)
// Add any static host configurations service discovery object.
for userHost, hostConfig := range config.Hosts {
@@ -93,7 +94,7 @@ func Configure(h, t, v string) (*scalr.Client, error) {
}
httpClient := scalr.DefaultConfig().HTTPClient
- httpClient.Transport = logging.NewLoggingHTTPTransport(httpClient.Transport)
+ httpClient.Transport = logging.NewLoggingTransport(httpClient.Transport)
headers := make(http.Header)
headers.Add("User-Agent", providerUaString)
diff --git a/internal/logging/http.go b/internal/logging/http.go
new file mode 100644
index 00000000..d5ec38b5
--- /dev/null
+++ b/internal/logging/http.go
@@ -0,0 +1,144 @@
+package logging
+
+import (
+ "bytes"
+ "io"
+ "net/http"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+)
+
+// NewLoggingTransport returns a wrapper around http.RoundTripper
+// that logs HTTP requests and responses using the `tflog` package.
+// The context.Context of the underlying http.Request is passed to the logger.
+func NewLoggingTransport(transport http.RoundTripper) http.RoundTripper {
+ return &loggingTransport{transport: transport}
+}
+
+// loggingTransport is a http.RoundTripper that logs HTTP requests and responses.
+type loggingTransport struct {
+ transport http.RoundTripper
+}
+
+func (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ ctx := req.Context()
+
+ fields, err := collectRequestFields(req)
+ if err != nil {
+ tflog.Error(ctx, "Failed to parse request for logging", map[string]interface{}{
+ "error": err,
+ })
+ } else {
+ tflog.Debug(ctx, "Sending HTTP Request", fields)
+ }
+
+ resp, err := t.transport.RoundTrip(req)
+ if err != nil {
+ return resp, err
+ }
+
+ fields, err = collectResponseFields(resp)
+ if err != nil {
+ tflog.Error(ctx, "Failed to parse response for logging", map[string]interface{}{
+ "error": err,
+ })
+ } else {
+ tflog.Debug(ctx, "Received HTTP Response", fields)
+ }
+ return resp, nil
+}
+
+func collectRequestFields(req *http.Request) (map[string]interface{}, error) {
+ fields := make(map[string]interface{})
+
+ fields["http_op"] = "request"
+ fields["http_url"] = req.URL.String()
+ fields["http_method"] = req.Method
+
+ // Collect request headers
+ for name, values := range req.Header {
+ if len(values) == 1 {
+ fields[name] = values[0]
+ } else {
+ fields[name] = values
+ }
+ }
+
+ // Collect the request body
+ body, err := bodyFromRequest(req)
+ if err != nil {
+ return nil, err
+ }
+ fields["http_req_body"] = body
+
+ return fields, nil
+}
+
+func bodyFromRequest(req *http.Request) (string, error) {
+ if req.Body == nil {
+ return "", nil
+ }
+
+ // Read and log the body without consuming it
+ var buf bytes.Buffer
+ tee := io.TeeReader(req.Body, &buf)
+
+ // Read the body into a byte slice
+ bodyBytes, err := io.ReadAll(tee)
+ if err != nil {
+ return "", err
+ }
+
+ // Restore the original request body for the actual request
+ req.Body = io.NopCloser(&buf)
+
+ return string(bodyBytes), nil
+}
+
+func collectResponseFields(resp *http.Response) (map[string]interface{}, error) {
+ fields := make(map[string]interface{})
+
+ fields["http_op"] = "response"
+ fields["http_status"] = resp.StatusCode
+
+ // Collect response headers
+ for name, values := range resp.Header {
+ if len(values) == 1 {
+ fields[name] = values[0]
+ } else {
+ fields[name] = values
+ }
+ }
+
+ // Collect the response body
+ body, err := bodyFromResponse(resp)
+ if err != nil {
+ return nil, err
+ }
+ fields["http_resp_body"] = body
+
+ return fields, nil
+}
+
+func bodyFromResponse(resp *http.Response) (string, error) {
+ if resp.Body == nil {
+ return "", nil
+ }
+
+ // Read the response body
+ bodyBytes, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return "", err
+ }
+
+ // Close the original response body
+ err = resp.Body.Close()
+ if err != nil {
+ return "", err
+ }
+
+ // Restore the response body for the client
+ resp.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
+
+ return string(bodyBytes), nil
+}
diff --git a/internal/provider/provider_sdk.go b/internal/provider/provider_sdk.go
index 7077aeef..4964b098 100644
--- a/internal/provider/provider_sdk.go
+++ b/internal/provider/provider_sdk.go
@@ -95,7 +95,7 @@ func Provider(v string) *schema.Provider {
}
}
-func providerConfigure(v string) func(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
+func providerConfigure(v string) func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
return func(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
h := d.Get("hostname").(string)
t := d.Get("token").(string)
From 06bc06a7e4a2c0148c08ddc0d2b1df89e872909b Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Fri, 22 Nov 2024 19:51:50 +0200
Subject: [PATCH 14/26] SCALRCORE-26654 Rename datasource files
---
.../provider/{data_source_scalr_tag.go => tag_data_source.go} | 0
...{data_source_scalr_tag_test.go => tag_data_source_test.go} | 4 ++--
2 files changed, 2 insertions(+), 2 deletions(-)
rename internal/provider/{data_source_scalr_tag.go => tag_data_source.go} (100%)
rename internal/provider/{data_source_scalr_tag_test.go => tag_data_source_test.go} (96%)
diff --git a/internal/provider/data_source_scalr_tag.go b/internal/provider/tag_data_source.go
similarity index 100%
rename from internal/provider/data_source_scalr_tag.go
rename to internal/provider/tag_data_source.go
diff --git a/internal/provider/data_source_scalr_tag_test.go b/internal/provider/tag_data_source_test.go
similarity index 96%
rename from internal/provider/data_source_scalr_tag_test.go
rename to internal/provider/tag_data_source_test.go
index b3b719ed..c9c9a4ca 100644
--- a/internal/provider/data_source_scalr_tag_test.go
+++ b/internal/provider/tag_data_source_test.go
@@ -12,8 +12,8 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_tag test {}`,
From a44346bb9fcf65e8affd5bb3745538045deaf56d Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 12:25:07 +0200
Subject: [PATCH 15/26] SCALRCORE-26654 Add tag datasource; replace SDK imports
in test modules with framework substitutes
---
go.mod | 12 +-
go.sum | 28 ++--
internal/client/client.go | 5 +-
internal/client/config.go | 12 +-
internal/framework/datasource.go | 32 ++++
.../validation/string_not_whitespace.go | 45 ++++++
.../data_source_scalr_access_policy_test.go | 2 +-
.../data_source_scalr_agent_pool_test.go | 2 +-
.../data_source_scalr_current_account_test.go | 2 +-
.../data_source_scalr_current_run_test.go | 2 +-
.../data_source_scalr_environment_test.go | 2 +-
.../data_source_scalr_environments_test.go | 2 +-
...rce_scalr_event_bridge_integration_test.go | 2 +-
.../data_source_scalr_iam_team_test.go | 2 +-
.../data_source_scalr_iam_user_test.go | 2 +-
.../data_source_scalr_module_version_test.go | 2 +-
.../data_source_scalr_module_versions_test.go | 2 +-
.../data_source_scalr_policy_group_test.go | 2 +-
...ource_scalr_provider_configuration_test.go | 4 +-
...urce_scalr_provider_configurations_test.go | 4 +-
.../provider/data_source_scalr_role_test.go | 4 +-
.../data_source_scalr_service_account_test.go | 2 +-
.../data_source_scalr_ssh_key_test.go | 4 +-
.../data_source_scalr_variable_test.go | 2 +-
.../data_source_scalr_variables_test.go | 4 +-
.../data_source_scalr_vcs_provider_test.go | 2 +-
.../data_source_scalr_webhook_test.go | 2 +-
.../data_source_scalr_workspace_ids_test.go | 2 +-
.../data_source_scalr_workspace_test.go | 2 +-
.../data_source_scalr_workspaces_test.go | 2 +-
internal/provider/helpers.go | 5 +
internal/provider/provider.go | 4 +-
internal/provider/provider_sdk.go | 1 -
internal/provider/provider_test.go | 32 ++++
.../resource_scalr_access_policy_test.go | 47 +-----
...resource_scalr_account_allowed_ips_test.go | 2 +-
.../resource_scalr_agent_pool_test.go | 50 +-----
.../resource_scalr_agent_pool_token_test.go | 47 +-----
.../resource_scalr_environment_test.go | 4 +-
...rce_scalr_event_bridge_integration_test.go | 2 +-
.../provider/resource_scalr_iam_team_test.go | 52 +------
.../provider/resource_scalr_module_test.go | 4 +-
...esource_scalr_policy_group_linkage_test.go | 4 +-
.../resource_scalr_policy_group_test.go | 4 +-
...alr_provider_configuration_default_test.go | 4 +-
...ource_scalr_provider_configuration_test.go | 6 +-
internal/provider/resource_scalr_role_test.go | 54 +------
.../resource_scalr_run_schedule_rule_test.go | 4 +-
.../resource_scalr_run_triggers_test.go | 4 +-
.../resource_scalr_service_account_test.go | 4 +-
...source_scalr_service_account_token_test.go | 4 +-
.../resource_scalr_slack_integration_test.go | 2 +-
.../provider/resource_scalr_ssh_key_test.go | 6 +-
internal/provider/resource_scalr_tag_test.go | 62 +-------
.../provider/resource_scalr_variable_test.go | 4 +-
.../resource_scalr_vcs_provider_test.go | 4 +-
.../provider/resource_scalr_webhook_test.go | 2 +-
...ource_scalr_workspace_run_schedule_test.go | 2 +-
.../provider/resource_scalr_workspace_test.go | 142 +----------------
internal/provider/tag_data_source.go | 144 ++++++++++++------
internal/provider/tag_data_source_test.go | 8 +-
61 files changed, 325 insertions(+), 581 deletions(-)
create mode 100644 internal/framework/datasource.go
create mode 100644 internal/framework/validation/string_not_whitespace.go
diff --git a/go.mod b/go.mod
index 90852689..70eb3bfe 100644
--- a/go.mod
+++ b/go.mod
@@ -7,10 +7,12 @@ require (
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.13.0
+ github.com/hashicorp/terraform-plugin-framework-validators v0.15.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.17.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
+ github.com/hashicorp/terraform-plugin-testing v1.11.0
github.com/hashicorp/terraform-svchost v0.1.1
github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e
)
@@ -40,7 +42,7 @@ require (
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.9.0 // indirect
- github.com/hashicorp/hcl/v2 v2.22.0 // indirect
+ github.com/hashicorp/hcl/v2 v2.23.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
@@ -66,14 +68,14 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
- golang.org/x/crypto v0.28.0 // indirect
+ golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
- golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.26.0 // indirect
- golang.org/x/text v0.19.0 // indirect
+ golang.org/x/sync v0.9.0 // indirect
+ golang.org/x/sys v0.27.0 // indirect
+ golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
diff --git a/go.sum b/go.sum
index df258143..a222cf50 100644
--- a/go.sum
+++ b/go.sum
@@ -112,8 +112,8 @@ github.com/hashicorp/hc-install v0.9.0 h1:2dIk8LcvANwtv3QZLckxcjyF5w8KVtiMxu6G6e
github.com/hashicorp/hc-install v0.9.0/go.mod h1:+6vOP+mf3tuGgMApVYtmsnDoKWMDcFXeTxCACYZ8SFg=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce h1:xdsDDbiBDQTKASoGEZ+pEmF1OnWuu8AQ9I8iNbHNeno=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
-github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M=
-github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
+github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos=
+github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ=
@@ -124,6 +124,8 @@ github.com/hashicorp/terraform-plugin-docs v0.16.0 h1:UmxFr3AScl6Wged84jndJIfFcc
github.com/hashicorp/terraform-plugin-docs v0.16.0/go.mod h1:M3ZrlKBJAbPMtNOPwHicGi1c+hZUh7/g0ifT/z7TVfA=
github.com/hashicorp/terraform-plugin-framework v1.13.0 h1:8OTG4+oZUfKgnfTdPTJwZ532Bh2BobF4H+yBiYJ/scw=
github.com/hashicorp/terraform-plugin-framework v1.13.0/go.mod h1:j64rwMGpgM3NYXTKuxrCnyubQb/4VKldEKlcG8cvmjU=
+github.com/hashicorp/terraform-plugin-framework-validators v0.15.0 h1:RXMmu7JgpFjnI1a5QjMCBb11usrW2OtAG+iOTIj5c9Y=
+github.com/hashicorp/terraform-plugin-framework-validators v0.15.0/go.mod h1:Bh89/hNmqsEWug4/XWKYBwtnw3tbz5BAy1L1OgvbIaY=
github.com/hashicorp/terraform-plugin-go v0.25.0 h1:oi13cx7xXA6QciMcpcFi/rwA974rdTxjqEhXJjbAyks=
github.com/hashicorp/terraform-plugin-go v0.25.0/go.mod h1:+SYagMYadJP86Kvn+TGeV+ofr/R3g4/If0O5sO96MVw=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
@@ -132,6 +134,8 @@ github.com/hashicorp/terraform-plugin-mux v0.17.0 h1:/J3vv3Ps2ISkbLPiZOLspFcIZ0v
github.com/hashicorp/terraform-plugin-mux v0.17.0/go.mod h1:yWuM9U1Jg8DryNfvCp+lH70WcYv6D8aooQxxxIzFDsE=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 h1:wyKCCtn6pBBL46c1uIIBNUOWlNfYXfXpVo16iDyLp8Y=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0/go.mod h1:B0Al8NyYVr8Mp/KLwssKXG1RqnTk7FySqSn4fRuLNgw=
+github.com/hashicorp/terraform-plugin-testing v1.11.0 h1:MeDT5W3YHbONJt2aPQyaBsgQeAIckwPX41EUHXEn29A=
+github.com/hashicorp/terraform-plugin-testing v1.11.0/go.mod h1:WNAHQ3DcgV/0J+B15WTE6hDvxcUdkPPpnB1FR3M910U=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
@@ -238,8 +242,8 @@ golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
-golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
-golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
+golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
+golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
@@ -267,8 +271,8 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
-golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
+golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -284,21 +288,21 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
-golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
+golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
-golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
-golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
+golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
+golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
-golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
+golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
diff --git a/internal/client/client.go b/internal/client/client.go
index 73e8778d..eead14d6 100644
--- a/internal/client/client.go
+++ b/internal/client/client.go
@@ -7,7 +7,7 @@ import (
"net/http"
"net/url"
- svchost "github.com/hashicorp/terraform-svchost"
+ "github.com/hashicorp/terraform-svchost"
"github.com/hashicorp/terraform-svchost/disco"
"github.com/scalr/go-scalr"
@@ -16,8 +16,9 @@ import (
var scalrServiceIDs = []string{"iacp.v3"}
+// Configure configures and returns a new Scalr client.
func Configure(h, t, v string) (*scalr.Client, error) {
- // Parse the hostname for comparison,
+ // Parse the hostname for comparison
hostname, err := svchost.ForComparison(h)
if err != nil {
return nil, err
diff --git a/internal/client/config.go b/internal/client/config.go
index 0a36c29c..f05b6194 100644
--- a/internal/client/config.go
+++ b/internal/client/config.go
@@ -5,7 +5,7 @@ import (
"os"
"github.com/hashicorp/hcl"
- svchost "github.com/hashicorp/terraform-svchost"
+ "github.com/hashicorp/terraform-svchost"
"github.com/hashicorp/terraform-svchost/auth"
)
@@ -17,15 +17,15 @@ const (
// config is the structure of the configuration for the Terraform CLI.
type config struct {
- Hosts map[string]*configHost `hcl:"host"`
- Credentials map[string]map[string]interface{} `hcl:"credentials"`
+ Hosts map[string]*configHost `hcl:"host"`
+ Credentials map[string]map[string]any `hcl:"credentials"`
}
// configHost is the structure of the "host" nested block within the CLI
// configuration, which can be used to override the default service host
// discovery behavior for a particular hostname.
type configHost struct {
- Services map[string]interface{} `hcl:"services"`
+ Services map[string]any `hcl:"services"`
}
// CliConfig tries to find and parse the configuration of the Terraform CLI.
@@ -57,7 +57,7 @@ func cliConfig() *config {
// hostnames.
combinedConfig.Credentials = credentialsConfig.Credentials
if combinedConfig.Credentials == nil {
- combinedConfig.Credentials = make(map[string]map[string]interface{})
+ combinedConfig.Credentials = make(map[string]map[string]any)
}
for host, creds := range mainConfig.Credentials {
combinedConfig.Credentials[host] = creds
@@ -71,7 +71,7 @@ func credentialsSource(config *config) auth.CredentialsSource {
// Add all configured credentials to the credentials source.
if len(config.Credentials) > 0 {
- staticTable := map[svchost.Hostname]map[string]interface{}{}
+ staticTable := map[svchost.Hostname]map[string]any{}
for userHost, creds := range config.Credentials {
host, err := svchost.ForComparison(userHost)
if err != nil {
diff --git a/internal/framework/datasource.go b/internal/framework/datasource.go
new file mode 100644
index 00000000..e8fb8c97
--- /dev/null
+++ b/internal/framework/datasource.go
@@ -0,0 +1,32 @@
+package framework
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+
+ "github.com/scalr/go-scalr"
+)
+
+type DataSourceWithScalrClient struct {
+ Client *scalr.Client
+}
+
+func (d *DataSourceWithScalrClient) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
+ if req.ProviderData == nil {
+ return
+ }
+
+ c, ok := req.ProviderData.(*scalr.Client)
+ if !ok {
+ resp.Diagnostics.AddError(
+ "Unexpected Data Source Configure Type",
+ fmt.Sprintf("Expected *scalr.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
+ )
+
+ return
+ }
+
+ d.Client = c
+}
diff --git a/internal/framework/validation/string_not_whitespace.go b/internal/framework/validation/string_not_whitespace.go
new file mode 100644
index 00000000..4c1df9c1
--- /dev/null
+++ b/internal/framework/validation/string_not_whitespace.go
@@ -0,0 +1,45 @@
+package validation
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ "github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+)
+
+// Compile-time interface check
+var _ validator.String = stringIsNotWhiteSpaceValidator{}
+
+type stringIsNotWhiteSpaceValidator struct{}
+
+func (v stringIsNotWhiteSpaceValidator) Description(_ context.Context) string {
+ return "must not be empty or consisting entirely of whitespace characters"
+}
+
+func (v stringIsNotWhiteSpaceValidator) MarkdownDescription(ctx context.Context) string {
+ return v.Description(ctx)
+}
+
+func (v stringIsNotWhiteSpaceValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
+ if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() {
+ return
+ }
+
+ value := req.ConfigValue.ValueString()
+
+ if strings.TrimSpace(value) == "" {
+ resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
+ req.Path,
+ v.Description(ctx),
+ fmt.Sprintf("%q", value),
+ ))
+
+ return
+ }
+}
+
+func StringIsNotWhiteSpace() validator.String {
+ return stringIsNotWhiteSpaceValidator{}
+}
diff --git a/internal/provider/data_source_scalr_access_policy_test.go b/internal/provider/data_source_scalr_access_policy_test.go
index 968958f2..fab63809 100644
--- a/internal/provider/data_source_scalr_access_policy_test.go
+++ b/internal/provider/data_source_scalr_access_policy_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrAccessPolicyDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_agent_pool_test.go b/internal/provider/data_source_scalr_agent_pool_test.go
index ddf13458..6e7816c1 100644
--- a/internal/provider/data_source_scalr_agent_pool_test.go
+++ b/internal/provider/data_source_scalr_agent_pool_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_current_account_test.go b/internal/provider/data_source_scalr_current_account_test.go
index 25ab964d..be603aec 100644
--- a/internal/provider/data_source_scalr_current_account_test.go
+++ b/internal/provider/data_source_scalr_current_account_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccCurrentAccount_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_current_run_test.go b/internal/provider/data_source_scalr_current_run_test.go
index e8e588f5..d3ba187c 100644
--- a/internal/provider/data_source_scalr_current_run_test.go
+++ b/internal/provider/data_source_scalr_current_run_test.go
@@ -6,7 +6,7 @@ import (
"os"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_environment_test.go b/internal/provider/data_source_scalr_environment_test.go
index 2c0edb27..87f6556f 100644
--- a/internal/provider/data_source_scalr_environment_test.go
+++ b/internal/provider/data_source_scalr_environment_test.go
@@ -6,7 +6,7 @@ import (
"strconv"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccEnvironmentDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_environments_test.go b/internal/provider/data_source_scalr_environments_test.go
index bf71e9ed..f0d28cda 100644
--- a/internal/provider/data_source_scalr_environments_test.go
+++ b/internal/provider/data_source_scalr_environments_test.go
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrEnvironmentsDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_event_bridge_integration_test.go b/internal/provider/data_source_scalr_event_bridge_integration_test.go
index 76747194..9ef6ac13 100644
--- a/internal/provider/data_source_scalr_event_bridge_integration_test.go
+++ b/internal/provider/data_source_scalr_event_bridge_integration_test.go
@@ -6,7 +6,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrEventBridgeIntegrationDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_iam_team_test.go b/internal/provider/data_source_scalr_iam_team_test.go
index b38191fb..56cd450a 100644
--- a/internal/provider/data_source_scalr_iam_team_test.go
+++ b/internal/provider/data_source_scalr_iam_team_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrIamTeamDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_iam_user_test.go b/internal/provider/data_source_scalr_iam_user_test.go
index 52da6aff..429e01ba 100644
--- a/internal/provider/data_source_scalr_iam_user_test.go
+++ b/internal/provider/data_source_scalr_iam_user_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_module_version_test.go b/internal/provider/data_source_scalr_module_version_test.go
index d076c952..772cc48e 100644
--- a/internal/provider/data_source_scalr_module_version_test.go
+++ b/internal/provider/data_source_scalr_module_version_test.go
@@ -6,7 +6,7 @@ import (
"testing"
"time"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_module_versions_test.go b/internal/provider/data_source_scalr_module_versions_test.go
index a09f2e2b..1a0cb859 100644
--- a/internal/provider/data_source_scalr_module_versions_test.go
+++ b/internal/provider/data_source_scalr_module_versions_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_policy_group_test.go b/internal/provider/data_source_scalr_policy_group_test.go
index 850de9ca..63dd06fc 100644
--- a/internal/provider/data_source_scalr_policy_group_test.go
+++ b/internal/provider/data_source_scalr_policy_group_test.go
@@ -7,7 +7,7 @@ import (
"testing"
"time"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_provider_configuration_test.go b/internal/provider/data_source_scalr_provider_configuration_test.go
index 53888653..2a9a8421 100644
--- a/internal/provider/data_source_scalr_provider_configuration_test.go
+++ b/internal/provider/data_source_scalr_provider_configuration_test.go
@@ -5,8 +5,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_provider_configurations_test.go b/internal/provider/data_source_scalr_provider_configurations_test.go
index e208816d..5c43c28c 100644
--- a/internal/provider/data_source_scalr_provider_configurations_test.go
+++ b/internal/provider/data_source_scalr_provider_configurations_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
)
func TestAccScalrProviderConfigurationsDataSource(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_role_test.go b/internal/provider/data_source_scalr_role_test.go
index ff7d4fd7..a2680d85 100644
--- a/internal/provider/data_source_scalr_role_test.go
+++ b/internal/provider/data_source_scalr_role_test.go
@@ -5,8 +5,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
)
func TestAccScalrRoleDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_service_account_test.go b/internal/provider/data_source_scalr_service_account_test.go
index a8b668f7..4d0e48c5 100644
--- a/internal/provider/data_source_scalr_service_account_test.go
+++ b/internal/provider/data_source_scalr_service_account_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_ssh_key_test.go b/internal/provider/data_source_scalr_ssh_key_test.go
index a1b1ac71..ebd56a69 100644
--- a/internal/provider/data_source_scalr_ssh_key_test.go
+++ b/internal/provider/data_source_scalr_ssh_key_test.go
@@ -5,8 +5,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_variable_test.go b/internal/provider/data_source_scalr_variable_test.go
index 3be0a714..aab87727 100644
--- a/internal/provider/data_source_scalr_variable_test.go
+++ b/internal/provider/data_source_scalr_variable_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrVariableDataSource(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_variables_test.go b/internal/provider/data_source_scalr_variables_test.go
index 7aebb2c3..7e835c2e 100644
--- a/internal/provider/data_source_scalr_variables_test.go
+++ b/internal/provider/data_source_scalr_variables_test.go
@@ -6,8 +6,8 @@ import (
"strconv"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/data_source_scalr_vcs_provider_test.go b/internal/provider/data_source_scalr_vcs_provider_test.go
index 48fc1241..7a02c122 100644
--- a/internal/provider/data_source_scalr_vcs_provider_test.go
+++ b/internal/provider/data_source_scalr_vcs_provider_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_webhook_test.go b/internal/provider/data_source_scalr_webhook_test.go
index 613a8b31..beba20cb 100644
--- a/internal/provider/data_source_scalr_webhook_test.go
+++ b/internal/provider/data_source_scalr_webhook_test.go
@@ -7,7 +7,7 @@ import (
"strconv"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccWebhookDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_workspace_ids_test.go b/internal/provider/data_source_scalr_workspace_ids_test.go
index 0e552b6e..3ab9ce20 100644
--- a/internal/provider/data_source_scalr_workspace_ids_test.go
+++ b/internal/provider/data_source_scalr_workspace_ids_test.go
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrWorkspaceIDsDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_workspace_test.go b/internal/provider/data_source_scalr_workspace_test.go
index 1a3d302c..0ef8bd4b 100644
--- a/internal/provider/data_source_scalr_workspace_test.go
+++ b/internal/provider/data_source_scalr_workspace_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrWorkspaceDataSource_basic(t *testing.T) {
diff --git a/internal/provider/data_source_scalr_workspaces_test.go b/internal/provider/data_source_scalr_workspaces_test.go
index 235d1af8..8800d9e5 100644
--- a/internal/provider/data_source_scalr_workspaces_test.go
+++ b/internal/provider/data_source_scalr_workspaces_test.go
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrWorkspacesDataSource_basic(t *testing.T) {
diff --git a/internal/provider/helpers.go b/internal/provider/helpers.go
index 86dbdb9a..a04b9658 100644
--- a/internal/provider/helpers.go
+++ b/internal/provider/helpers.go
@@ -132,3 +132,8 @@ func scalrAccountIDOptionalDefaultFunc() (interface{}, error) {
accID, _ := getDefaultScalrAccountID()
return accID, nil
}
+
+// ptr returns a pointer to the value passed.
+func ptr[T any](v T) *T {
+ return &v
+}
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
index b302737a..36a07e08 100644
--- a/internal/provider/provider.go
+++ b/internal/provider/provider.go
@@ -152,5 +152,7 @@ func (p *scalrProvider) Resources(_ context.Context) []func() resource.Resource
}
func (p *scalrProvider) DataSources(_ context.Context) []func() datasource.DataSource {
- return []func() datasource.DataSource{}
+ return []func() datasource.DataSource{
+ newTagDataSource,
+ }
}
diff --git a/internal/provider/provider_sdk.go b/internal/provider/provider_sdk.go
index 4964b098..03ebb332 100644
--- a/internal/provider/provider_sdk.go
+++ b/internal/provider/provider_sdk.go
@@ -51,7 +51,6 @@ func Provider(v string) *schema.Provider {
"scalr_provider_configurations": dataSourceScalrProviderConfigurations(),
"scalr_role": dataSourceScalrRole(),
"scalr_service_account": dataSourceScalrServiceAccount(),
- "scalr_tag": dataSourceScalrTag(),
"scalr_variable": dataSourceScalrVariable(),
"scalr_variables": dataSourceScalrVariables(),
"scalr_vcs_provider": dataSourceScalrVcsProvider(),
diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go
index 3b3b860a..34683811 100644
--- a/internal/provider/provider_test.go
+++ b/internal/provider/provider_test.go
@@ -1,3 +1,35 @@
package provider
+import (
+ "context"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-framework/providerserver"
+ "github.com/hashicorp/terraform-plugin-go/tfprotov5"
+ "github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+)
+
const testProviderVersion = "test"
+
+func init() {
+ schema.DescriptionKind = schema.StringMarkdown
+}
+
+func protoV5ProviderFactories(t *testing.T) map[string]func() (tfprotov5.ProviderServer, error) {
+ ctx := context.Background()
+
+ providers := []func() tfprotov5.ProviderServer{
+ providerserver.NewProtocol5(New(testProviderVersion)()),
+ Provider(testProviderVersion).GRPCProvider,
+ }
+
+ muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+
+ return map[string]func() (tfprotov5.ProviderServer, error){
+ "scalr": func() (tfprotov5.ProviderServer, error) { return muxServer.ProviderServer(), nil },
+ }
+}
diff --git a/internal/provider/resource_scalr_access_policy_test.go b/internal/provider/resource_scalr_access_policy_test.go
index 525c4e52..8f628607 100644
--- a/internal/provider/resource_scalr_access_policy_test.go
+++ b/internal/provider/resource_scalr_access_policy_test.go
@@ -9,8 +9,8 @@ import (
"testing"
"time"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -70,45 +70,6 @@ func TestAccScalrAccessPolicy_bad_subject(t *testing.T) {
})
}
-func TestAccScalrAccessPolicy_changed_outside(t *testing.T) {
- ap := &scalr.AccessPolicy{}
- rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrAccessPolicyBasic(rInt),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrAccessPolicyExists("scalr_access_policy.test", ap),
- resource.TestCheckResourceAttrSet("scalr_access_policy.test", "id"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "subject.0.type", "user"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "subject.0.id", testUser),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "is_system", "false"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "scope.0.type", "environment"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "role_ids.0", readOnlyRole),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "role_ids.#", "1"),
- ),
- },
- {
- PreConfig: testAccCheckScalrAccessPolicyChangedOutside(ap),
- Config: testAccScalrAccessPolicyChangedOutside(rInt),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("scalr_access_policy.test", "id"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "subject.0.type", "user"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "subject.0.id", testUser),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "is_system", "false"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "scope.0.type", "environment"),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "role_ids.0", userRole),
- resource.TestCheckResourceAttr("scalr_access_policy.test", "role_ids.#", "1"),
- ),
- },
- },
- })
-}
func TestAccScalrAccessPolicy_update(t *testing.T) {
ap := &scalr.AccessPolicy{}
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
@@ -313,10 +274,6 @@ func testAccScalrAccessPolicyEmptyRoleId(rInt int) string {
return fmt.Sprintf(iamPolicyTemplate, rInt, defaultAccount, testUser, "")
}
-func testAccScalrAccessPolicyChangedOutside(rInt int) string {
- return fmt.Sprintf(iamPolicyTemplate, rInt, defaultAccount, testUser, userRole)
-}
-
func testAccScalrAccessPolicyUpdate(rInt int) string {
return fmt.Sprintf(iamPolicyTemplate, rInt, defaultAccount, testUser, fmt.Sprintf("%s\", \"%s", readOnlyRole, userRole))
}
diff --git a/internal/provider/resource_scalr_account_allowed_ips_test.go b/internal/provider/resource_scalr_account_allowed_ips_test.go
index ab163329..42e9b079 100644
--- a/internal/provider/resource_scalr_account_allowed_ips_test.go
+++ b/internal/provider/resource_scalr_account_allowed_ips_test.go
@@ -6,7 +6,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
diff --git a/internal/provider/resource_scalr_agent_pool_test.go b/internal/provider/resource_scalr_agent_pool_test.go
index 83a225a0..69f5d195 100644
--- a/internal/provider/resource_scalr_agent_pool_test.go
+++ b/internal/provider/resource_scalr_agent_pool_test.go
@@ -6,8 +6,8 @@ import (
"log"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -34,38 +34,6 @@ func TestAccScalrAgentPool_basic(t *testing.T) {
})
}
-func TestAccScalrAgentPool_renamed(t *testing.T) {
- pool := &scalr.AgentPool{}
- rInt := GetRandomInteger()
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrAgentPoolBasic(rInt),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrAgentPoolExists("scalr_agent_pool.test", pool),
- resource.TestCheckResourceAttr(
- "scalr_agent_pool.test", "name", fmt.Sprintf("agent_pool-test-%d", rInt),
- ),
- resource.TestCheckResourceAttr("scalr_agent_pool.test", "account_id", defaultAccount),
- ),
- },
-
- {
- PreConfig: testAccCheckScalrAgentPoolRename(pool),
- Config: testAccScalrAgentPoolRenamed(rInt),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("scalr_agent_pool.test", "name", "renamed-outside-of-terraform"),
- resource.TestCheckResourceAttr("scalr_agent_pool.test", "account_id", defaultAccount),
- ),
- },
- },
- })
-}
func TestAccScalrAgentPool_update(t *testing.T) {
pool := &scalr.AgentPool{}
rInt := GetRandomInteger()
@@ -203,20 +171,6 @@ resource "scalr_agent_pool" "test" {
}`, rInt, defaultAccount, rInt, defaultAccount)
}
-func testAccScalrAgentPoolRenamed(rInt int) string {
- return fmt.Sprintf(`
-resource "scalr_environment" "test" {
- name = "agent_pool-test-%d"
- account_id = "%s"
-
-}
-resource "scalr_agent_pool" "test" {
- name = "renamed-outside-of-terraform"
- account_id = "%s"
- environment_id = scalr_environment.test.id
-}`, rInt, defaultAccount, defaultAccount)
-}
-
func testAccScalrAgentPoolUpdate() string {
return fmt.Sprintf(`
resource "scalr_agent_pool" "test" {
diff --git a/internal/provider/resource_scalr_agent_pool_token_test.go b/internal/provider/resource_scalr_agent_pool_token_test.go
index b2fccc52..1042ae7b 100644
--- a/internal/provider/resource_scalr_agent_pool_token_test.go
+++ b/internal/provider/resource_scalr_agent_pool_token_test.go
@@ -6,8 +6,8 @@ import (
"log"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -37,41 +37,6 @@ func TestAccScalrAgentPoolToken_basic(t *testing.T) {
})
}
-func TestAccScalrAgentPoolToken_changed_outside(t *testing.T) {
-
- var pool scalr.AgentPool
- if isAccTest() {
- pool = createPool(t)
- defer deletePool(t, pool)
- }
- token := &scalr.AccessToken{}
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrAgentPoolTokenBasic(pool),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrAgentPoolTokenExists("scalr_agent_pool_token.test", pool, token),
- resource.TestCheckResourceAttr("scalr_agent_pool_token.test", "description", "agent_pool_token-test"),
- resource.TestCheckResourceAttr("scalr_agent_pool_token.test", "agent_pool_id", pool.ID),
- ),
- },
-
- {
- PreConfig: testAccCheckScalrAgentPoolTokenChangedOutside(token),
- Config: testAccScalrAgentPoolTokenChangedOutside(pool),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("scalr_agent_pool_token.test", "description", "changed-outside-of-terraform"),
- resource.TestCheckResourceAttr("scalr_agent_pool_token.test", "agent_pool_id", pool.ID),
- ),
- },
- },
- })
-}
func TestAccScalrAgentPoolToken_update(t *testing.T) {
var pool scalr.AgentPool
if isAccTest() {
@@ -215,14 +180,6 @@ resource "scalr_agent_pool_token" "test" {
}`, pool.ID)
}
-func testAccScalrAgentPoolTokenChangedOutside(pool scalr.AgentPool) string {
- return fmt.Sprintf(`
-resource "scalr_agent_pool_token" "test" {
- description = "changed-outside-of-terraform"
- agent_pool_id = "%s"
-}`, pool.ID)
-}
-
func testAccScalrAgentPoolTokenUpdate(pool scalr.AgentPool) string {
return fmt.Sprintf(`
resource "scalr_agent_pool_token" "test" {
diff --git a/internal/provider/resource_scalr_environment_test.go b/internal/provider/resource_scalr_environment_test.go
index f51d201f..545ca36e 100644
--- a/internal/provider/resource_scalr_environment_test.go
+++ b/internal/provider/resource_scalr_environment_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_event_bridge_integration_test.go b/internal/provider/resource_scalr_event_bridge_integration_test.go
index 15d753de..35de4f69 100644
--- a/internal/provider/resource_scalr_event_bridge_integration_test.go
+++ b/internal/provider/resource_scalr_event_bridge_integration_test.go
@@ -5,7 +5,7 @@ import (
"os"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccEventBridgeIntegration_basic(t *testing.T) {
diff --git a/internal/provider/resource_scalr_iam_team_test.go b/internal/provider/resource_scalr_iam_team_test.go
index b6b5e1d6..e2017ae6 100644
--- a/internal/provider/resource_scalr_iam_team_test.go
+++ b/internal/provider/resource_scalr_iam_team_test.go
@@ -7,8 +7,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -39,44 +39,6 @@ func TestAccScalrIamTeam_basic(t *testing.T) {
})
}
-func TestAccScalrIamTeam_renamed(t *testing.T) {
- rInt := GetRandomInteger()
- team := &scalr.Team{}
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrIamTeamDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrIamTeamBasic(rInt),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrIamTeamExists("scalr_iam_team.test", team),
- resource.TestCheckResourceAttr(
- "scalr_iam_team.test",
- "name",
- fmt.Sprintf("test-team-%d", rInt),
- ),
- resource.TestCheckResourceAttr("scalr_iam_team.test", "description", "Test team"),
- resource.TestCheckResourceAttr("scalr_iam_team.test", "account_id", defaultAccount),
- resource.TestCheckResourceAttr("scalr_iam_team.test", "users.0", testUser),
- ),
- },
- {
- PreConfig: testAccCheckScalrIamTeamRename(team),
- Config: testAccScalrIamTeamRenamed(),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("scalr_iam_team.test", "name", "renamed-outside-of-terraform"),
- resource.TestCheckResourceAttr("scalr_iam_team.test", "description", "Test team"),
- resource.TestCheckResourceAttr("scalr_iam_team.test", "account_id", defaultAccount),
- resource.TestCheckResourceAttr("scalr_iam_team.test", "users.0", testUser),
- ),
- },
- },
- })
-}
-
func TestAccScalrIamTeam_update(t *testing.T) {
rInt := GetRandomInteger()
team := &scalr.Team{}
@@ -219,16 +181,6 @@ resource "scalr_iam_team" "test" {
}`, rInt, defaultAccount, testUser)
}
-func testAccScalrIamTeamRenamed() string {
- return fmt.Sprintf(`
-resource "scalr_iam_team" "test" {
- name = "renamed-outside-of-terraform"
- description = "Test team"
- account_id = "%s"
- users = ["%s"]
-}`, defaultAccount, testUser)
-}
-
func testAccScalrIamTeamUpdate() string {
return fmt.Sprintf(`
resource "scalr_iam_team" "test" {
diff --git a/internal/provider/resource_scalr_module_test.go b/internal/provider/resource_scalr_module_test.go
index f5e9ca08..0caf036b 100644
--- a/internal/provider/resource_scalr_module_test.go
+++ b/internal/provider/resource_scalr_module_test.go
@@ -5,8 +5,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_policy_group_linkage_test.go b/internal/provider/resource_scalr_policy_group_linkage_test.go
index f0681a93..df8dc0f2 100644
--- a/internal/provider/resource_scalr_policy_group_linkage_test.go
+++ b/internal/provider/resource_scalr_policy_group_linkage_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_policy_group_test.go b/internal/provider/resource_scalr_policy_group_test.go
index c86e25cd..946b67de 100644
--- a/internal/provider/resource_scalr_policy_group_test.go
+++ b/internal/provider/resource_scalr_policy_group_test.go
@@ -6,8 +6,8 @@ import (
"log"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_provider_configuration_default_test.go b/internal/provider/resource_scalr_provider_configuration_default_test.go
index c5937164..6150f11c 100644
--- a/internal/provider/resource_scalr_provider_configuration_default_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_default_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_provider_configuration_test.go b/internal/provider/resource_scalr_provider_configuration_test.go
index 413e4cd1..055bb688 100644
--- a/internal/provider/resource_scalr_provider_configuration_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_test.go
@@ -7,9 +7,9 @@ import (
"strings"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
"github.com/scalr/terraform-provider-scalr/internal/client"
diff --git a/internal/provider/resource_scalr_role_test.go b/internal/provider/resource_scalr_role_test.go
index 5c336384..669ce0f2 100644
--- a/internal/provider/resource_scalr_role_test.go
+++ b/internal/provider/resource_scalr_role_test.go
@@ -7,8 +7,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -36,43 +36,6 @@ func TestAccScalrRole_basic(t *testing.T) {
})
}
-func TestAccScalrRole_renamed(t *testing.T) {
- role := &scalr.Role{}
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRoleDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrRoleBasic(),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrRoleExists("scalr_role.test", role),
- resource.TestCheckResourceAttr("scalr_role.test", "name", "role-test"),
- resource.TestCheckResourceAttr("scalr_role.test", "description", "test basic"),
- resource.TestCheckResourceAttr("scalr_role.test", "is_system", "false"),
- resource.TestCheckResourceAttr("scalr_role.test", "account_id", defaultAccount),
- resource.TestCheckResourceAttr("scalr_role.test", "permissions.0", "*:read"),
- resource.TestCheckResourceAttr("scalr_role.test", "permissions.1", "*:update"),
- ),
- },
-
- {
- PreConfig: testAccCheckScalrRoleRename(role),
- Config: testAccScalrRoleRenamed(),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("scalr_role.test", "name", "renamed-outside-of-terraform"),
- resource.TestCheckResourceAttr("scalr_role.test", "description", "test basic"),
- resource.TestCheckResourceAttr("scalr_role.test", "is_system", "false"),
- resource.TestCheckResourceAttr("scalr_role.test", "account_id", defaultAccount),
- resource.TestCheckResourceAttr("scalr_role.test", "permissions.0", "*:read"),
- resource.TestCheckResourceAttr("scalr_role.test", "permissions.1", "*:update"),
- ),
- },
- },
- })
-}
func TestAccScalrRole_update(t *testing.T) {
role := &scalr.Role{}
@@ -218,19 +181,6 @@ resource "scalr_role" "test" {
}`, defaultAccount)
}
-func testAccScalrRoleRenamed() string {
- return fmt.Sprintf(`
-resource "scalr_role" "test" {
- name = "renamed-outside-of-terraform"
- description = "test basic"
- account_id = "%s"
- permissions = [
- "*:read",
- "*:update"
- ]
-}`, defaultAccount)
-}
-
func testAccScalrRoleUpdate() string {
return fmt.Sprintf(`
resource "scalr_role" "test" {
diff --git a/internal/provider/resource_scalr_run_schedule_rule_test.go b/internal/provider/resource_scalr_run_schedule_rule_test.go
index db7c4516..2a443875 100644
--- a/internal/provider/resource_scalr_run_schedule_rule_test.go
+++ b/internal/provider/resource_scalr_run_schedule_rule_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_run_triggers_test.go b/internal/provider/resource_scalr_run_triggers_test.go
index 8bb43a2a..13fb47f9 100644
--- a/internal/provider/resource_scalr_run_triggers_test.go
+++ b/internal/provider/resource_scalr_run_triggers_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_service_account_test.go b/internal/provider/resource_scalr_service_account_test.go
index ad88b6f4..857b5350 100644
--- a/internal/provider/resource_scalr_service_account_test.go
+++ b/internal/provider/resource_scalr_service_account_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_service_account_token_test.go b/internal/provider/resource_scalr_service_account_token_test.go
index 153719a6..ded5c4a8 100644
--- a/internal/provider/resource_scalr_service_account_token_test.go
+++ b/internal/provider/resource_scalr_service_account_token_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_slack_integration_test.go b/internal/provider/resource_scalr_slack_integration_test.go
index 31518eea..aed6918e 100644
--- a/internal/provider/resource_scalr_slack_integration_test.go
+++ b/internal/provider/resource_scalr_slack_integration_test.go
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccSlackIntegration_basic(t *testing.T) {
diff --git a/internal/provider/resource_scalr_ssh_key_test.go b/internal/provider/resource_scalr_ssh_key_test.go
index 1695d4f7..ef276219 100644
--- a/internal/provider/resource_scalr_ssh_key_test.go
+++ b/internal/provider/resource_scalr_ssh_key_test.go
@@ -6,9 +6,9 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_tag_test.go b/internal/provider/resource_scalr_tag_test.go
index b1d13e25..c12942cc 100644
--- a/internal/provider/resource_scalr_tag_test.go
+++ b/internal/provider/resource_scalr_tag_test.go
@@ -1,13 +1,11 @@
package provider
import (
- "context"
"fmt"
- "log"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -80,36 +78,6 @@ func TestAccScalrTag_update(t *testing.T) {
})
}
-func TestAccScalrTag_renamed(t *testing.T) {
- tag := &scalr.Tag{}
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrTagDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrTagBasic(),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrTagExists("scalr_tag.test", tag),
- resource.TestCheckResourceAttr("scalr_tag.test", "name", "test-tag-name"),
- resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
- ),
- },
-
- {
- PreConfig: testAccCheckScalrTagRename(tag),
- Config: testAccScalrTagRenamed(),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("scalr_tag.test", "name", "renamed-outside-terraform"),
- resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
- ),
- },
- },
- })
-}
-
func testAccScalrTagBasic() string {
return fmt.Sprintf(`
resource scalr_tag test {
@@ -134,32 +102,6 @@ resource scalr_tag test {
}`, defaultAccount)
}
-func testAccCheckScalrTagRename(tag *scalr.Tag) func() {
- return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
-
- t, err := scalrClient.Tags.Read(ctx, tag.ID)
-
- if err != nil {
- log.Fatalf("Error retrieving tag: %v", err)
- }
-
- t, err = scalrClient.Tags.Update(
- context.Background(),
- t.ID,
- scalr.TagUpdateOptions{Name: scalr.String("renamed-outside-terraform")},
- )
-
- if err != nil {
- log.Fatalf("Could not rename the tag outside of terraform: %v", err)
- }
-
- if t.Name != "renamed-outside-terraform" {
- log.Fatalf("Failed to rename the tag outside of terraform: %v", err)
- }
- }
-}
-
func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheckFunc {
return func(s *terraform.State) error {
scalrClient := testAccProvider.Meta().(*scalr.Client)
diff --git a/internal/provider/resource_scalr_variable_test.go b/internal/provider/resource_scalr_variable_test.go
index 8f4eb731..c2e84440 100644
--- a/internal/provider/resource_scalr_variable_test.go
+++ b/internal/provider/resource_scalr_variable_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_vcs_provider_test.go b/internal/provider/resource_scalr_vcs_provider_test.go
index ecfaef7e..93e8aa2c 100644
--- a/internal/provider/resource_scalr_vcs_provider_test.go
+++ b/internal/provider/resource_scalr_vcs_provider_test.go
@@ -5,8 +5,8 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
diff --git a/internal/provider/resource_scalr_webhook_test.go b/internal/provider/resource_scalr_webhook_test.go
index 79f2b99c..ba7aa53b 100644
--- a/internal/provider/resource_scalr_webhook_test.go
+++ b/internal/provider/resource_scalr_webhook_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccWebhook_basic(t *testing.T) {
diff --git a/internal/provider/resource_scalr_workspace_run_schedule_test.go b/internal/provider/resource_scalr_workspace_run_schedule_test.go
index d33b244f..69eeb679 100644
--- a/internal/provider/resource_scalr_workspace_run_schedule_test.go
+++ b/internal/provider/resource_scalr_workspace_run_schedule_test.go
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestScalrWorkspaceRunSchedule_basic(t *testing.T) {
diff --git a/internal/provider/resource_scalr_workspace_test.go b/internal/provider/resource_scalr_workspace_test.go
index 15060702..64617968 100644
--- a/internal/provider/resource_scalr_workspace_test.go
+++ b/internal/provider/resource_scalr_workspace_test.go
@@ -3,12 +3,11 @@ package provider
import (
"context"
"fmt"
- "log"
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -119,81 +118,6 @@ func TestAccScalrWorkspace_monorepo(t *testing.T) {
})
}
-func TestAccScalrWorkspace_renamed(t *testing.T) {
- workspace := &scalr.Workspace{}
- rInt := GetRandomInteger()
-
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccScalrWorkspaceBasic(rInt),
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrWorkspaceExists(
- "scalr_workspace.test", workspace),
- testAccCheckScalrWorkspaceAttributes(workspace),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "name", "workspace-test"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "auto_apply", "true"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "operations", "true"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "execution_mode", string(scalr.WorkspaceExecutionModeRemote)),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "auto_queue_runs", string(scalr.AutoQueueRunsModeAlways)),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "working_directory", ""),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.pre_init", "./scripts/pre-init.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.post_plan", "./scripts/post-plan.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.pre_apply", "./scripts/pre-apply.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.post_apply", "./scripts/post-apply.sh"),
- ),
- },
-
- {
- PreConfig: testAccCheckScalrWorkspaceRename(fmt.Sprintf("test-env-%d", rInt), "workspace-test"),
- Config: testAccScalrWorkspaceRenamed(rInt),
- PlanOnly: true,
- Check: resource.ComposeTestCheckFunc(
- testAccCheckScalrWorkspaceExists(
- "scalr_workspace.test", workspace),
- testAccCheckScalrWorkspaceAttributes(workspace),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "name", "workspace-test"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "auto_apply", "true"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "operations", "true"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "execution_mode", string(scalr.WorkspaceExecutionModeRemote)),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "auto_queue_runs", string(scalr.AutoQueueRunsModeAlways)),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "working_directory", ""),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.pre_init", "./scripts/pre-init.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.post_plan", "./scripts/post-plan.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.pre_apply", "./scripts/pre-apply.sh"),
- resource.TestCheckResourceAttr(
- "scalr_workspace.test", "hooks.0.post_apply", "./scripts/post-apply.sh"),
- ),
- },
- },
- })
-}
func TestAccScalrWorkspace_update(t *testing.T) {
workspace := &scalr.Workspace{}
rInt := GetRandomInteger()
@@ -497,49 +421,6 @@ func testAccCheckScalrWorkspaceMonorepoAttributes(
}
}
-func testAccCheckScalrWorkspaceRename(environmentName, workspaceName string) func() {
- return func() {
- var environmentID *string
- scalrClient := testAccProvider.Meta().(*scalr.Client)
-
- listOptions := scalr.EnvironmentListOptions{}
- envl, err := scalrClient.Environments.List(ctx, listOptions)
- if err != nil {
- log.Fatalf("Error retrieving environments: %v", err)
- }
-
- for _, env := range envl.Items {
- if env.Name == environmentName {
- environmentID = &env.ID
- break
- }
- }
- if environmentID == nil {
- log.Fatalf("Could not find environment with name: %s", environmentName)
- return
- }
-
- ws, err := scalrClient.Workspaces.Read(ctx, *environmentID, workspaceName)
-
- if err != nil {
- log.Fatalf("Error retrieving workspace: %v", err)
- }
-
- w, err := scalrClient.Workspaces.Update(
- context.Background(),
- ws.ID,
- scalr.WorkspaceUpdateOptions{Name: scalr.String("renamed-out-of-band")},
- )
- if err != nil {
- log.Fatalf("Could not rename the workspace out of band: %v", err)
- }
-
- if w.Name != "renamed-out-of-band" {
- log.Fatalf("Failed to rename the workspace out of band: %v", err)
- }
- }
-}
-
func testAccCheckScalrWorkspaceAttributesUpdated(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
@@ -751,25 +632,6 @@ resource "scalr_workspace" "test" {
}`)
}
-func testAccScalrWorkspaceRenamed(rInt int) string {
- return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, `
-resource "scalr_workspace" "test" {
- name = "renamed-out-of-band"
- environment_id = scalr_environment.test.id
- auto_apply = true
- run_operation_timeout = 18
- auto_queue_runs = "always"
- deletion_protection_enabled = false
- hooks {
- pre_init = "./scripts/pre-init.sh"
- pre_plan = "./scripts/pre-plan.sh"
- post_plan = "./scripts/post-plan.sh"
- pre_apply = "./scripts/pre-apply.sh"
- post_apply = "./scripts/post-apply.sh"
- }
-}`)
-}
-
func testAccScalrWorkspaceUpdate(rInt int) string {
return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount,
fmt.Sprintf(`
diff --git a/internal/provider/tag_data_source.go b/internal/provider/tag_data_source.go
index b7c97224..179a9f31 100644
--- a/internal/provider/tag_data_source.go
+++ b/internal/provider/tag_data_source.go
@@ -2,83 +2,131 @@ package provider
import (
"context"
- "log"
+ "fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+ "github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/validation"
+)
+
+// Ensure provider defined types fully satisfy framework interfaces.
+var (
+ _ datasource.DataSource = &tagDataSource{}
+ _ datasource.DataSourceWithConfigure = &tagDataSource{}
+ _ datasource.DataSourceWithConfigValidators = &tagDataSource{}
)
-func dataSourceScalrTag() *schema.Resource {
- return &schema.Resource{
- Description: "Retrieves information about a tag.",
- ReadContext: dataSourceScalrTagRead,
- Schema: map[string]*schema.Schema{
- "id": {
- Description: "The identifier of the tag in the format `tag-`.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- ValidateFunc: validation.StringIsNotWhiteSpace,
- AtLeastOneOf: []string{"name"},
+func newTagDataSource() datasource.DataSource {
+ return &tagDataSource{}
+}
+
+// tagDataSource defines the data source implementation.
+type tagDataSource struct {
+ framework.DataSourceWithScalrClient
+}
+
+// TagDataSourceModel describes the data source data model.
+type TagDataSourceModel struct {
+ Id types.String `tfsdk:"id"`
+ Name types.String `tfsdk:"name"`
+ AccountID types.String `tfsdk:"account_id"`
+}
+
+func (d *tagDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_tag"
+}
+
+func (d *tagDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ MarkdownDescription: "Retrieves information about a tag.",
+
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ MarkdownDescription: "The identifier of the tag in the format `tag-`.",
+ Optional: true,
+ Computed: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
},
- "name": {
- Description: "The name of the tag.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- ValidateFunc: validation.StringIsNotWhiteSpace,
+ "name": schema.StringAttribute{
+ MarkdownDescription: "The name of the tag.",
+ Optional: true,
+ Computed: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
},
- "account_id": {
- Description: "The ID of the Scalr account, in the format `acc-`.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- DefaultFunc: scalrAccountIDDefaultFunc,
+ "account_id": schema.StringAttribute{
+ MarkdownDescription: "The ID of the Scalr account, in the format `acc-`.",
+ Optional: true,
+ Computed: true,
},
},
}
}
-func dataSourceScalrTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
- scalrClient := meta.(*scalr.Client)
+func (d *tagDataSource) ConfigValidators(_ context.Context) []datasource.ConfigValidator {
+ return []datasource.ConfigValidator{
+ datasourcevalidator.AtLeastOneOf(
+ path.MatchRoot("id"),
+ path.MatchRoot("name"),
+ ),
+ }
+}
- tagID := d.Get("id").(string)
- name := d.Get("name").(string)
- accountID := d.Get("account_id").(string)
+func (d *tagDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var cfg TagDataSourceModel
- options := scalr.TagListOptions{
- Account: scalr.String(accountID),
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &cfg)...)
+ if resp.Diagnostics.HasError() {
+ return
}
- if tagID != "" {
- options.Tag = scalr.String(tagID)
+ opts := scalr.TagListOptions{}
+ if !cfg.Id.IsNull() {
+ opts.Tag = ptr(cfg.Id.ValueString())
}
-
- if name != "" {
- options.Name = scalr.String(name)
+ if !cfg.Name.IsNull() {
+ opts.Name = ptr(cfg.Name.ValueString())
}
- log.Printf("[DEBUG] Read tag with ID '%s', name '%s', and account_id '%s'", tagID, name, accountID)
- tags, err := scalrClient.Tags.List(ctx, options)
+ tags, err := d.Client.Tags.List(ctx, opts)
if err != nil {
- return diag.Errorf("Error retrieving tag: %v", err)
+ resp.Diagnostics.AddError("Error retrieving tag", err.Error())
+ return
}
// Unlikely
if tags.TotalCount > 1 {
- return diag.Errorf("Your query returned more than one result. Please try a more specific search criteria.")
+ resp.Diagnostics.AddError(
+ "Error retrieving tag",
+ "Your query returned more than one result. Please try a more specific search criteria.",
+ )
+ return
}
if tags.TotalCount == 0 {
- return diag.Errorf("Could not find tag with ID '%s', name '%s', and account_id '%s'", tagID, name, accountID)
+ resp.Diagnostics.AddError(
+ "Error retrieving tag",
+ fmt.Sprintf("Could not find tag with ID '%s', name '%s'.", cfg.Id.ValueString(), cfg.Name.ValueString()),
+ )
+ return
}
tag := tags.Items[0]
- _ = d.Set("name", tag.Name)
- d.SetId(tag.ID)
+ cfg.Id = types.StringValue(tag.ID)
+ cfg.Name = types.StringValue(tag.Name)
+ cfg.AccountID = types.StringValue(tag.Account.ID)
- return nil
+ resp.Diagnostics.Append(resp.State.Set(ctx, &cfg)...)
}
diff --git a/internal/provider/tag_data_source_test.go b/internal/provider/tag_data_source_test.go
index c9c9a4ca..fc330038 100644
--- a/internal/provider/tag_data_source_test.go
+++ b/internal/provider/tag_data_source_test.go
@@ -5,7 +5,7 @@ import (
"regexp"
"testing"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrTagDataSource_basic(t *testing.T) {
@@ -17,17 +17,17 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: `data scalr_tag test {}`,
- ExpectError: regexp.MustCompile("\"id\": one of `id,name` must be specified"),
+ ExpectError: regexp.MustCompile("At least one of these attributes must be configured: \\[id,name]"),
PlanOnly: true,
},
{
Config: `data scalr_tag test {id = ""}`,
- ExpectError: regexp.MustCompile("expected \"id\" to not be an empty string or whitespace"),
+ ExpectError: regexp.MustCompile("Attribute id must not be empty"),
PlanOnly: true,
},
{
Config: `data scalr_tag test {name = ""}`,
- ExpectError: regexp.MustCompile("expected \"name\" to not be an empty string or whitespace"),
+ ExpectError: regexp.MustCompile("Attribute name must not be empty"),
PlanOnly: true,
},
{
From 80d7eb9ef47df7c7f56e0adc4f1d033238bdcf36 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 12:39:43 +0200
Subject: [PATCH 16/26] SCALRCORE-26654 * wip
---
internal/provider/tag_data_source.go | 132 ---------------------------
scalr/data_source_scalr_tag.go | 84 +++++++++++++++++
2 files changed, 84 insertions(+), 132 deletions(-)
delete mode 100644 internal/provider/tag_data_source.go
create mode 100644 scalr/data_source_scalr_tag.go
diff --git a/internal/provider/tag_data_source.go b/internal/provider/tag_data_source.go
deleted file mode 100644
index 179a9f31..00000000
--- a/internal/provider/tag_data_source.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package provider
-
-import (
- "context"
- "fmt"
-
- "github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
- "github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
- "github.com/hashicorp/terraform-plugin-framework/path"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/scalr/go-scalr"
-
- "github.com/scalr/terraform-provider-scalr/internal/framework"
- "github.com/scalr/terraform-provider-scalr/internal/framework/validation"
-)
-
-// Ensure provider defined types fully satisfy framework interfaces.
-var (
- _ datasource.DataSource = &tagDataSource{}
- _ datasource.DataSourceWithConfigure = &tagDataSource{}
- _ datasource.DataSourceWithConfigValidators = &tagDataSource{}
-)
-
-func newTagDataSource() datasource.DataSource {
- return &tagDataSource{}
-}
-
-// tagDataSource defines the data source implementation.
-type tagDataSource struct {
- framework.DataSourceWithScalrClient
-}
-
-// TagDataSourceModel describes the data source data model.
-type TagDataSourceModel struct {
- Id types.String `tfsdk:"id"`
- Name types.String `tfsdk:"name"`
- AccountID types.String `tfsdk:"account_id"`
-}
-
-func (d *tagDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_tag"
-}
-
-func (d *tagDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- resp.Schema = schema.Schema{
- MarkdownDescription: "Retrieves information about a tag.",
-
- Attributes: map[string]schema.Attribute{
- "id": schema.StringAttribute{
- MarkdownDescription: "The identifier of the tag in the format `tag-`.",
- Optional: true,
- Computed: true,
- Validators: []validator.String{
- validation.StringIsNotWhiteSpace(),
- },
- },
- "name": schema.StringAttribute{
- MarkdownDescription: "The name of the tag.",
- Optional: true,
- Computed: true,
- Validators: []validator.String{
- validation.StringIsNotWhiteSpace(),
- },
- },
- "account_id": schema.StringAttribute{
- MarkdownDescription: "The ID of the Scalr account, in the format `acc-`.",
- Optional: true,
- Computed: true,
- },
- },
- }
-}
-
-func (d *tagDataSource) ConfigValidators(_ context.Context) []datasource.ConfigValidator {
- return []datasource.ConfigValidator{
- datasourcevalidator.AtLeastOneOf(
- path.MatchRoot("id"),
- path.MatchRoot("name"),
- ),
- }
-}
-
-func (d *tagDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
- var cfg TagDataSourceModel
-
- // Read Terraform configuration data into the model
- resp.Diagnostics.Append(req.Config.Get(ctx, &cfg)...)
- if resp.Diagnostics.HasError() {
- return
- }
-
- opts := scalr.TagListOptions{}
- if !cfg.Id.IsNull() {
- opts.Tag = ptr(cfg.Id.ValueString())
- }
- if !cfg.Name.IsNull() {
- opts.Name = ptr(cfg.Name.ValueString())
- }
-
- tags, err := d.Client.Tags.List(ctx, opts)
- if err != nil {
- resp.Diagnostics.AddError("Error retrieving tag", err.Error())
- return
- }
-
- // Unlikely
- if tags.TotalCount > 1 {
- resp.Diagnostics.AddError(
- "Error retrieving tag",
- "Your query returned more than one result. Please try a more specific search criteria.",
- )
- return
- }
-
- if tags.TotalCount == 0 {
- resp.Diagnostics.AddError(
- "Error retrieving tag",
- fmt.Sprintf("Could not find tag with ID '%s', name '%s'.", cfg.Id.ValueString(), cfg.Name.ValueString()),
- )
- return
- }
-
- tag := tags.Items[0]
-
- cfg.Id = types.StringValue(tag.ID)
- cfg.Name = types.StringValue(tag.Name)
- cfg.AccountID = types.StringValue(tag.Account.ID)
-
- resp.Diagnostics.Append(resp.State.Set(ctx, &cfg)...)
-}
diff --git a/scalr/data_source_scalr_tag.go b/scalr/data_source_scalr_tag.go
new file mode 100644
index 00000000..a6111dee
--- /dev/null
+++ b/scalr/data_source_scalr_tag.go
@@ -0,0 +1,84 @@
+package scalr
+
+import (
+ "context"
+ "log"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+ "github.com/scalr/go-scalr"
+)
+
+func dataSourceScalrTag() *schema.Resource {
+ return &schema.Resource{
+ Description: "Retrieves information about a tag.",
+ ReadContext: dataSourceScalrTagRead,
+ Schema: map[string]*schema.Schema{
+ "id": {
+ Description: "The identifier of the tag in the format `tag-`.",
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ValidateFunc: validation.StringIsNotWhiteSpace,
+ AtLeastOneOf: []string{"name"},
+ },
+ "name": {
+ Description: "The name of the tag.",
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ValidateFunc: validation.StringIsNotWhiteSpace,
+ },
+ "account_id": {
+ Description: "The ID of the Scalr account, in the format `acc-`.",
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ DefaultFunc: scalrAccountIDDefaultFunc,
+ },
+ },
+ }
+}
+
+func dataSourceScalrTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
+ scalrClient := meta.(*scalr.Client)
+
+ tagID := d.Get("id").(string)
+ name := d.Get("name").(string)
+ accountID := d.Get("account_id").(string)
+
+ options := scalr.TagListOptions{
+ Account: scalr.String(accountID),
+ }
+
+ if tagID != "" {
+ options.Tag = scalr.String(tagID)
+ }
+
+ if name != "" {
+ options.Name = scalr.String(name)
+ }
+
+ log.Printf("[DEBUG] Read tag with ID '%s', name '%s', and account_id '%s'", tagID, name, accountID)
+ tags, err := scalrClient.Tags.List(ctx, options)
+ if err != nil {
+ return diag.Errorf("Error retrieving tag: %v", err)
+ }
+
+ // Unlikely
+ if tags.TotalCount > 1 {
+ return diag.Errorf("Your query returned more than one result. Please try a more specific search criteria.")
+ }
+
+ if tags.TotalCount == 0 {
+ return diag.Errorf("Could not find tag with ID '%s', name '%s', and account_id '%s'", tagID, name, accountID)
+ }
+
+ tag := tags.Items[0]
+
+ _ = d.Set("name", tag.Name)
+ d.SetId(tag.ID)
+
+ return nil
+}
From c798ae8b3d96f84fb50f16de24ac24afbce008da Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 12:40:24 +0200
Subject: [PATCH 17/26] SCALRCORE-26654 * wip
---
{scalr => internal/provider}/data_source_scalr_tag.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename {scalr => internal/provider}/data_source_scalr_tag.go (99%)
diff --git a/scalr/data_source_scalr_tag.go b/internal/provider/data_source_scalr_tag.go
similarity index 99%
rename from scalr/data_source_scalr_tag.go
rename to internal/provider/data_source_scalr_tag.go
index a6111dee..b7c97224 100644
--- a/scalr/data_source_scalr_tag.go
+++ b/internal/provider/data_source_scalr_tag.go
@@ -1,4 +1,4 @@
-package scalr
+package provider
import (
"context"
From 297d10b419be79081eac63ffe56d27ac7ddd2fc4 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 12:41:02 +0200
Subject: [PATCH 18/26] SCALRCORE-26654 * wip
---
.../provider/{data_source_scalr_tag.go => tag_data_source.go} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename internal/provider/{data_source_scalr_tag.go => tag_data_source.go} (100%)
diff --git a/internal/provider/data_source_scalr_tag.go b/internal/provider/tag_data_source.go
similarity index 100%
rename from internal/provider/data_source_scalr_tag.go
rename to internal/provider/tag_data_source.go
From 2d82946d844d0eed2c189ac3498acf32e7115ff3 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 12:41:43 +0200
Subject: [PATCH 19/26] SCALRCORE-26654 * wip - preserve file move history
---
internal/provider/tag_data_source.go | 144 ++++++++++++++++++---------
1 file changed, 96 insertions(+), 48 deletions(-)
diff --git a/internal/provider/tag_data_source.go b/internal/provider/tag_data_source.go
index b7c97224..179a9f31 100644
--- a/internal/provider/tag_data_source.go
+++ b/internal/provider/tag_data_source.go
@@ -2,83 +2,131 @@ package provider
import (
"context"
- "log"
+ "fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+ "github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/validation"
+)
+
+// Ensure provider defined types fully satisfy framework interfaces.
+var (
+ _ datasource.DataSource = &tagDataSource{}
+ _ datasource.DataSourceWithConfigure = &tagDataSource{}
+ _ datasource.DataSourceWithConfigValidators = &tagDataSource{}
)
-func dataSourceScalrTag() *schema.Resource {
- return &schema.Resource{
- Description: "Retrieves information about a tag.",
- ReadContext: dataSourceScalrTagRead,
- Schema: map[string]*schema.Schema{
- "id": {
- Description: "The identifier of the tag in the format `tag-`.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- ValidateFunc: validation.StringIsNotWhiteSpace,
- AtLeastOneOf: []string{"name"},
+func newTagDataSource() datasource.DataSource {
+ return &tagDataSource{}
+}
+
+// tagDataSource defines the data source implementation.
+type tagDataSource struct {
+ framework.DataSourceWithScalrClient
+}
+
+// TagDataSourceModel describes the data source data model.
+type TagDataSourceModel struct {
+ Id types.String `tfsdk:"id"`
+ Name types.String `tfsdk:"name"`
+ AccountID types.String `tfsdk:"account_id"`
+}
+
+func (d *tagDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_tag"
+}
+
+func (d *tagDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ MarkdownDescription: "Retrieves information about a tag.",
+
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ MarkdownDescription: "The identifier of the tag in the format `tag-`.",
+ Optional: true,
+ Computed: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
},
- "name": {
- Description: "The name of the tag.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- ValidateFunc: validation.StringIsNotWhiteSpace,
+ "name": schema.StringAttribute{
+ MarkdownDescription: "The name of the tag.",
+ Optional: true,
+ Computed: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
},
- "account_id": {
- Description: "The ID of the Scalr account, in the format `acc-`.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- DefaultFunc: scalrAccountIDDefaultFunc,
+ "account_id": schema.StringAttribute{
+ MarkdownDescription: "The ID of the Scalr account, in the format `acc-`.",
+ Optional: true,
+ Computed: true,
},
},
}
}
-func dataSourceScalrTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
- scalrClient := meta.(*scalr.Client)
+func (d *tagDataSource) ConfigValidators(_ context.Context) []datasource.ConfigValidator {
+ return []datasource.ConfigValidator{
+ datasourcevalidator.AtLeastOneOf(
+ path.MatchRoot("id"),
+ path.MatchRoot("name"),
+ ),
+ }
+}
- tagID := d.Get("id").(string)
- name := d.Get("name").(string)
- accountID := d.Get("account_id").(string)
+func (d *tagDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var cfg TagDataSourceModel
- options := scalr.TagListOptions{
- Account: scalr.String(accountID),
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &cfg)...)
+ if resp.Diagnostics.HasError() {
+ return
}
- if tagID != "" {
- options.Tag = scalr.String(tagID)
+ opts := scalr.TagListOptions{}
+ if !cfg.Id.IsNull() {
+ opts.Tag = ptr(cfg.Id.ValueString())
}
-
- if name != "" {
- options.Name = scalr.String(name)
+ if !cfg.Name.IsNull() {
+ opts.Name = ptr(cfg.Name.ValueString())
}
- log.Printf("[DEBUG] Read tag with ID '%s', name '%s', and account_id '%s'", tagID, name, accountID)
- tags, err := scalrClient.Tags.List(ctx, options)
+ tags, err := d.Client.Tags.List(ctx, opts)
if err != nil {
- return diag.Errorf("Error retrieving tag: %v", err)
+ resp.Diagnostics.AddError("Error retrieving tag", err.Error())
+ return
}
// Unlikely
if tags.TotalCount > 1 {
- return diag.Errorf("Your query returned more than one result. Please try a more specific search criteria.")
+ resp.Diagnostics.AddError(
+ "Error retrieving tag",
+ "Your query returned more than one result. Please try a more specific search criteria.",
+ )
+ return
}
if tags.TotalCount == 0 {
- return diag.Errorf("Could not find tag with ID '%s', name '%s', and account_id '%s'", tagID, name, accountID)
+ resp.Diagnostics.AddError(
+ "Error retrieving tag",
+ fmt.Sprintf("Could not find tag with ID '%s', name '%s'.", cfg.Id.ValueString(), cfg.Name.ValueString()),
+ )
+ return
}
tag := tags.Items[0]
- _ = d.Set("name", tag.Name)
- d.SetId(tag.ID)
+ cfg.Id = types.StringValue(tag.ID)
+ cfg.Name = types.StringValue(tag.Name)
+ cfg.AccountID = types.StringValue(tag.Account.ID)
- return nil
+ resp.Diagnostics.Append(resp.State.Set(ctx, &cfg)...)
}
From 18d027bba3c4ccb886634280c8b1985e3964dc12 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 13:18:15 +0200
Subject: [PATCH 20/26] SCALRCORE-26654 Replace legacy pointer fns with generic
ptr()
---
.../provider/data_source_scalr_agent_pool.go | 6 +-
.../provider/data_source_scalr_environment.go | 2 +-
.../data_source_scalr_environments.go | 4 +-
.../provider/data_source_scalr_iam_team.go | 6 +-
.../provider/data_source_scalr_iam_user.go | 4 +-
internal/provider/data_source_scalr_role.go | 2 +-
.../data_source_scalr_service_account.go | 8 +-
.../provider/data_source_scalr_variable.go | 14 +-
.../provider/data_source_scalr_variables.go | 12 +-
.../data_source_scalr_vcs_provider.go | 10 +-
.../provider/data_source_scalr_workspace.go | 6 +-
.../provider/data_source_scalr_workspaces.go | 6 +-
.../provider/resource_scalr_agent_pool.go | 6 +-
.../resource_scalr_agent_pool_test.go | 2 +-
.../resource_scalr_agent_pool_token.go | 4 +-
.../resource_scalr_agent_pool_token_test.go | 4 +-
.../provider/resource_scalr_environment.go | 8 +-
internal/provider/resource_scalr_iam_team.go | 6 +-
.../provider/resource_scalr_iam_team_test.go | 2 +-
internal/provider/resource_scalr_module.go | 6 +-
.../provider/resource_scalr_policy_group.go | 28 ++--
.../resource_scalr_policy_group_test.go | 2 +-
.../resource_scalr_provider_configuration.go | 140 +++++++++---------
internal/provider/resource_scalr_role.go | 8 +-
internal/provider/resource_scalr_role_test.go | 2 +-
.../resource_scalr_run_schedule_rule.go | 2 +-
.../resource_scalr_service_account.go | 10 +-
.../resource_scalr_service_account_token.go | 4 +-
.../resource_scalr_slack_integration.go | 10 +-
internal/provider/resource_scalr_ssh_key.go | 16 +-
internal/provider/resource_scalr_tag.go | 4 +-
internal/provider/resource_scalr_variable.go | 30 ++--
.../provider/resource_scalr_vcs_provider.go | 26 ++--
internal/provider/resource_scalr_webhook.go | 30 ++--
internal/provider/resource_scalr_workspace.go | 106 ++++++-------
.../resource_scalr_workspace_run_schedule.go | 8 +-
36 files changed, 272 insertions(+), 272 deletions(-)
diff --git a/internal/provider/data_source_scalr_agent_pool.go b/internal/provider/data_source_scalr_agent_pool.go
index 6960b45d..aef98c71 100644
--- a/internal/provider/data_source_scalr_agent_pool.go
+++ b/internal/provider/data_source_scalr_agent_pool.go
@@ -72,7 +72,7 @@ func dataSourceScalrAgentPoolRead(ctx context.Context, d *schema.ResourceData, m
envID := d.Get("environment_id").(string)
options := scalr.AgentPoolListOptions{
- Account: scalr.String(accountID),
+ Account: ptr(accountID),
}
if agentPoolID != "" {
@@ -84,11 +84,11 @@ func dataSourceScalrAgentPoolRead(ctx context.Context, d *schema.ResourceData, m
}
if envID != "" {
- options.Environment = scalr.String(envID)
+ options.Environment = ptr(envID)
}
if vcsEnabled, ok := d.GetOkExists("vcs_enabled"); ok { //nolint:staticcheck
- options.VcsEnabled = scalr.Bool(vcsEnabled.(bool))
+ options.VcsEnabled = ptr(vcsEnabled.(bool))
}
agentPoolsList, err := scalrClient.AgentPools.List(ctx, options)
diff --git a/internal/provider/data_source_scalr_environment.go b/internal/provider/data_source_scalr_environment.go
index 2074d150..c69719be 100644
--- a/internal/provider/data_source_scalr_environment.go
+++ b/internal/provider/data_source_scalr_environment.go
@@ -116,7 +116,7 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta
options := GetEnvironmentByNameOptions{
Name: &envName,
Account: &accountID,
- Include: scalr.String("created-by"),
+ Include: ptr("created-by"),
}
environment, err = GetEnvironmentByName(ctx, options, scalrClient)
if err != nil {
diff --git a/internal/provider/data_source_scalr_environments.go b/internal/provider/data_source_scalr_environments.go
index e8707c51..c04bcfc5 100644
--- a/internal/provider/data_source_scalr_environments.go
+++ b/internal/provider/data_source_scalr_environments.go
@@ -59,7 +59,7 @@ func dataSourceScalrEnvironmentsRead(ctx context.Context, d *schema.ResourceData
if name, ok := d.GetOk("name"); ok {
id.WriteString(name.(string))
- options.Filter.Name = scalr.String(name.(string))
+ options.Filter.Name = ptr(name.(string))
}
if tagIDsI, ok := d.GetOk("tag_ids"); ok {
@@ -69,7 +69,7 @@ func dataSourceScalrEnvironmentsRead(ctx context.Context, d *schema.ResourceData
tagIDs = append(tagIDs, t.(string))
}
if len(tagIDs) > 0 {
- options.Filter.Tag = scalr.String("in:" + strings.Join(tagIDs, ","))
+ options.Filter.Tag = ptr("in:" + strings.Join(tagIDs, ","))
}
}
diff --git a/internal/provider/data_source_scalr_iam_team.go b/internal/provider/data_source_scalr_iam_team.go
index 20e1537a..1322bef4 100644
--- a/internal/provider/data_source_scalr_iam_team.go
+++ b/internal/provider/data_source_scalr_iam_team.go
@@ -66,15 +66,15 @@ func dataSourceScalrIamTeamRead(ctx context.Context, d *schema.ResourceData, met
accountID := d.Get("account_id").(string)
options := scalr.TeamListOptions{
- Account: scalr.String("in:null," + accountID),
+ Account: ptr("in:null," + accountID),
}
if teamID != "" {
- options.Team = scalr.String(teamID)
+ options.Team = ptr(teamID)
}
if name != "" {
- options.Name = scalr.String(name)
+ options.Name = ptr(name)
}
teams, err := scalrClient.Teams.List(ctx, options)
diff --git a/internal/provider/data_source_scalr_iam_user.go b/internal/provider/data_source_scalr_iam_user.go
index e86b5471..207fc394 100644
--- a/internal/provider/data_source_scalr_iam_user.go
+++ b/internal/provider/data_source_scalr_iam_user.go
@@ -73,10 +73,10 @@ func dataSourceScalrIamUserRead(ctx context.Context, d *schema.ResourceData, met
options := scalr.UserListOptions{}
if uID != "" {
- options.User = scalr.String(uID)
+ options.User = ptr(uID)
}
if email != "" {
- options.Email = scalr.String(email)
+ options.Email = ptr(email)
}
log.Printf("[DEBUG] Read configuration of iam user: email '%s', ID '%s'", email, uID)
diff --git a/internal/provider/data_source_scalr_role.go b/internal/provider/data_source_scalr_role.go
index c25e3346..23455fe5 100644
--- a/internal/provider/data_source_scalr_role.go
+++ b/internal/provider/data_source_scalr_role.go
@@ -71,7 +71,7 @@ func dataSourceScalrRoleRead(ctx context.Context, d *schema.ResourceData, meta i
accountID := d.Get("account_id").(string)
options := scalr.RoleListOptions{
- Account: scalr.String("in:null," + accountID),
+ Account: ptr("in:null," + accountID),
}
if roleID != "" {
diff --git a/internal/provider/data_source_scalr_service_account.go b/internal/provider/data_source_scalr_service_account.go
index ea0a9da2..2fca9108 100644
--- a/internal/provider/data_source_scalr_service_account.go
+++ b/internal/provider/data_source_scalr_service_account.go
@@ -94,16 +94,16 @@ func dataSourceScalrServiceAccountRead(ctx context.Context, d *schema.ResourceDa
accountID := d.Get("account_id").(string)
options := scalr.ServiceAccountListOptions{
- Account: scalr.String(accountID),
- Include: scalr.String("created-by"),
+ Account: ptr(accountID),
+ Include: ptr("created-by"),
}
if saID != "" {
- options.ServiceAccount = scalr.String(saID)
+ options.ServiceAccount = ptr(saID)
}
if email != "" {
- options.Email = scalr.String(email)
+ options.Email = ptr(email)
}
log.Printf("[DEBUG] Read service account with ID '%s', email '%s', and account_id '%s'", saID, email, accountID)
diff --git a/internal/provider/data_source_scalr_variable.go b/internal/provider/data_source_scalr_variable.go
index 62f74ee8..14e96d1a 100644
--- a/internal/provider/data_source_scalr_variable.go
+++ b/internal/provider/data_source_scalr_variable.go
@@ -121,27 +121,27 @@ func dataSourceScalrVariable() *schema.Resource {
func dataSourceScalrVariableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
scalrClient := meta.(*scalr.Client)
filters := scalr.VariableFilter{}
- options := scalr.VariableListOptions{Filter: &filters, Include: scalr.String("updated-by")}
+ options := scalr.VariableListOptions{Filter: &filters, Include: ptr("updated-by")}
variableID := d.Get("id").(string)
key := d.Get("key").(string)
- filters.Account = scalr.String(d.Get("account_id").(string))
+ filters.Account = ptr(d.Get("account_id").(string))
if variableID != "" {
- filters.Var = scalr.String(variableID)
+ filters.Var = ptr(variableID)
}
if key != "" {
- filters.Key = scalr.String(key)
+ filters.Key = ptr(key)
}
if categoryI, ok := d.GetOk("category"); ok {
- filters.Category = scalr.String(categoryI.(string))
+ filters.Category = ptr(categoryI.(string))
}
if envIdI, ok := d.GetOk("environment_id"); ok {
- filters.Environment = scalr.String(envIdI.(string))
+ filters.Environment = ptr(envIdI.(string))
}
if workspaceIDI, ok := d.GetOk("workspace_id"); ok {
- filters.Workspace = scalr.String(workspaceIDI.(string))
+ filters.Workspace = ptr(workspaceIDI.(string))
}
variables, err := scalrClient.Variables.List(ctx, options)
diff --git a/internal/provider/data_source_scalr_variables.go b/internal/provider/data_source_scalr_variables.go
index 0024bc87..7c67bd16 100644
--- a/internal/provider/data_source_scalr_variables.go
+++ b/internal/provider/data_source_scalr_variables.go
@@ -155,9 +155,9 @@ func dataSourceScalrVariables() *schema.Resource {
func dataSourceScalrVariablesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
scalrClient := meta.(*scalr.Client)
filters := scalr.VariableFilter{}
- options := scalr.VariableListOptions{Filter: &filters, Include: scalr.String("updated-by")}
+ options := scalr.VariableListOptions{Filter: &filters, Include: ptr("updated-by")}
- filters.Account = scalr.String(d.Get("account_id").(string))
+ filters.Account = ptr(d.Get("account_id").(string))
if keysI, ok := d.GetOk("keys"); ok {
keys := make([]string, 0)
@@ -165,11 +165,11 @@ func dataSourceScalrVariablesRead(ctx context.Context, d *schema.ResourceData, m
keys = append(keys, keyI.(string))
}
if len(keys) > 0 {
- filters.Key = scalr.String("in:" + strings.Join(keys, ","))
+ filters.Key = ptr("in:" + strings.Join(keys, ","))
}
}
if categoryI, ok := d.GetOk("category"); ok {
- filters.Category = scalr.String(categoryI.(string))
+ filters.Category = ptr(categoryI.(string))
}
if envIdsI, ok := d.GetOk("environment_ids"); ok {
envIds := make([]string, 0)
@@ -177,7 +177,7 @@ func dataSourceScalrVariablesRead(ctx context.Context, d *schema.ResourceData, m
envIds = append(envIds, envIdI.(string))
}
if len(envIds) > 0 {
- filters.Environment = scalr.String("in:" + strings.Join(envIds, ","))
+ filters.Environment = ptr("in:" + strings.Join(envIds, ","))
}
}
if wsIdsI, ok := d.GetOk("workspace_ids"); ok {
@@ -186,7 +186,7 @@ func dataSourceScalrVariablesRead(ctx context.Context, d *schema.ResourceData, m
wsIds = append(wsIds, wsIdI.(string))
}
if len(wsIds) > 0 {
- filters.Workspace = scalr.String("in:" + strings.Join(wsIds, ","))
+ filters.Workspace = ptr("in:" + strings.Join(wsIds, ","))
}
}
diff --git a/internal/provider/data_source_scalr_vcs_provider.go b/internal/provider/data_source_scalr_vcs_provider.go
index 279a3371..984452c8 100644
--- a/internal/provider/data_source_scalr_vcs_provider.go
+++ b/internal/provider/data_source_scalr_vcs_provider.go
@@ -74,23 +74,23 @@ func dataSourceScalrVcsProvider() *schema.Resource {
func dataSourceScalrVcsProviderRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
scalrClient := meta.(*scalr.Client)
options := scalr.VcsProvidersListOptions{
- Account: scalr.String(d.Get("account_id").(string)),
+ Account: ptr(d.Get("account_id").(string)),
}
if vcsProviderID, ok := d.GetOk("id"); ok {
- options.ID = scalr.String(vcsProviderID.(string))
+ options.ID = ptr(vcsProviderID.(string))
}
if name, ok := d.GetOk("name"); ok {
- options.Query = scalr.String(name.(string))
+ options.Query = ptr(name.(string))
}
if envId, ok := d.GetOk("environment_id"); ok {
- options.Environment = scalr.String(envId.(string))
+ options.Environment = ptr(envId.(string))
}
if agentPoolID, ok := d.GetOk("agent_pool_id"); ok {
- options.AgentPool = scalr.String(agentPoolID.(string))
+ options.AgentPool = ptr(agentPoolID.(string))
}
if vcsType, ok := d.GetOk("vcs_type"); ok {
diff --git a/internal/provider/data_source_scalr_workspace.go b/internal/provider/data_source_scalr_workspace.go
index 60689a80..3866ca0d 100644
--- a/internal/provider/data_source_scalr_workspace.go
+++ b/internal/provider/data_source_scalr_workspace.go
@@ -241,15 +241,15 @@ func dataSourceScalrWorkspaceRead(ctx context.Context, d *schema.ResourceData, m
options := scalr.WorkspaceListOptions{
Include: "created-by",
- Filter: &scalr.WorkspaceFilter{Environment: scalr.String(environmentID)},
+ Filter: &scalr.WorkspaceFilter{Environment: ptr(environmentID)},
}
if workspaceID != "" {
- options.Filter.Id = scalr.String(workspaceID)
+ options.Filter.Id = ptr(workspaceID)
}
if name != "" {
- options.Filter.Name = scalr.String(name)
+ options.Filter.Name = ptr(name)
}
log.Printf("[DEBUG] Read configuration of workspace with ID '%s', name '%s', and environment_id '%s'", workspaceID, name, environmentID)
diff --git a/internal/provider/data_source_scalr_workspaces.go b/internal/provider/data_source_scalr_workspaces.go
index f0d9e0d5..a9095c6b 100644
--- a/internal/provider/data_source_scalr_workspaces.go
+++ b/internal/provider/data_source_scalr_workspaces.go
@@ -64,12 +64,12 @@ func dataSourceScalrWorkspacesRead(ctx context.Context, d *schema.ResourceData,
if env, ok := d.GetOk("environment_id"); ok {
id.WriteString(env.(string))
- options.Filter.Environment = scalr.String(env.(string))
+ options.Filter.Environment = ptr(env.(string))
}
if name, ok := d.GetOk("name"); ok {
id.WriteString(name.(string))
- options.Filter.Name = scalr.String(name.(string))
+ options.Filter.Name = ptr(name.(string))
}
if tagIDsI, ok := d.GetOk("tag_ids"); ok {
@@ -79,7 +79,7 @@ func dataSourceScalrWorkspacesRead(ctx context.Context, d *schema.ResourceData,
tagIDs = append(tagIDs, t.(string))
}
if len(tagIDs) > 0 {
- options.Filter.Tag = scalr.String("in:" + strings.Join(tagIDs, ","))
+ options.Filter.Tag = ptr("in:" + strings.Join(tagIDs, ","))
}
}
diff --git a/internal/provider/resource_scalr_agent_pool.go b/internal/provider/resource_scalr_agent_pool.go
index d79d56a9..c5a8efef 100644
--- a/internal/provider/resource_scalr_agent_pool.go
+++ b/internal/provider/resource_scalr_agent_pool.go
@@ -64,9 +64,9 @@ func resourceScalrAgentPoolCreate(ctx context.Context, d *schema.ResourceData, m
// Create a new options struct
options := scalr.AgentPoolCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
Account: &scalr.Account{ID: accountID},
- VcsEnabled: scalr.Bool(vcsEnabled),
+ VcsEnabled: ptr(vcsEnabled),
}
if envID, ok := d.GetOk("environment_id"); ok {
@@ -124,7 +124,7 @@ func resourceScalrAgentPoolUpdate(ctx context.Context, d *schema.ResourceData, m
if d.HasChange("name") {
// Create a new options struct
options := scalr.AgentPoolUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
+ Name: ptr(d.Get("name").(string)),
}
log.Printf("[DEBUG] Update agent pool %s", id)
diff --git a/internal/provider/resource_scalr_agent_pool_test.go b/internal/provider/resource_scalr_agent_pool_test.go
index 69f5d195..be81737d 100644
--- a/internal/provider/resource_scalr_agent_pool_test.go
+++ b/internal/provider/resource_scalr_agent_pool_test.go
@@ -123,7 +123,7 @@ func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
r, err = scalrClient.AgentPools.Update(
context.Background(),
r.ID,
- scalr.AgentPoolUpdateOptions{Name: scalr.String("renamed-outside-of-terraform")},
+ scalr.AgentPoolUpdateOptions{Name: ptr("renamed-outside-of-terraform")},
)
if err != nil {
log.Fatalf("Could not rename the agent pool outside of terraform: %v", err)
diff --git a/internal/provider/resource_scalr_agent_pool_token.go b/internal/provider/resource_scalr_agent_pool_token.go
index 93e261c8..974c7b3b 100644
--- a/internal/provider/resource_scalr_agent_pool_token.go
+++ b/internal/provider/resource_scalr_agent_pool_token.go
@@ -51,7 +51,7 @@ func resourceScalrAgentPoolTokenCreate(ctx context.Context, d *schema.ResourceDa
options := scalr.AccessTokenCreateOptions{}
if desc, ok := d.GetOk("description"); ok {
- options.Description = scalr.String(desc.(string))
+ options.Description = ptr(desc.(string))
}
log.Printf("[DEBUG] Create token for agent pool: %s", poolID)
@@ -123,7 +123,7 @@ func resourceScalrAgentPoolTokenUpdate(ctx context.Context, d *schema.ResourceDa
desc := d.Get("description").(string)
// Create a new options struct
options := scalr.AccessTokenUpdateOptions{
- Description: scalr.String(desc),
+ Description: ptr(desc),
}
log.Printf("[DEBUG] Update agent pool token %s", id)
diff --git a/internal/provider/resource_scalr_agent_pool_token_test.go b/internal/provider/resource_scalr_agent_pool_token_test.go
index 1042ae7b..e364f7f6 100644
--- a/internal/provider/resource_scalr_agent_pool_token_test.go
+++ b/internal/provider/resource_scalr_agent_pool_token_test.go
@@ -108,7 +108,7 @@ func testAccCheckScalrAgentPoolTokenChangedOutside(token *scalr.AccessToken) fun
r, err := scalrClient.AccessTokens.Update(
context.Background(),
token.ID,
- scalr.AccessTokenUpdateOptions{Description: scalr.String("changed-outside-of-terraform")},
+ scalr.AccessTokenUpdateOptions{Description: ptr("changed-outside-of-terraform")},
)
if err != nil {
log.Fatalf("Could not update the agent pool outside of terraform: %v", err)
@@ -141,7 +141,7 @@ func createPool(t *testing.T) scalr.AgentPool {
}
r, err := scalrClient.AgentPools.Create(ctx, scalr.AgentPoolCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
Account: &scalr.Account{ID: defaultAccount},
})
diff --git a/internal/provider/resource_scalr_environment.go b/internal/provider/resource_scalr_environment.go
index 4d953880..e39278c6 100644
--- a/internal/provider/resource_scalr_environment.go
+++ b/internal/provider/resource_scalr_environment.go
@@ -127,8 +127,8 @@ func resourceScalrEnvironmentCreate(ctx context.Context, d *schema.ResourceData,
}
options := scalr.EnvironmentCreateOptions{
- Name: scalr.String(name),
- CostEstimationEnabled: scalr.Bool(d.Get("cost_estimation_enabled").(bool)),
+ Name: ptr(name),
+ CostEstimationEnabled: ptr(d.Get("cost_estimation_enabled").(bool)),
Account: &scalr.Account{ID: accountID},
PolicyGroups: policyGroups,
}
@@ -229,8 +229,8 @@ func resourceScalrEnvironmentUpdate(ctx context.Context, d *schema.ResourceData,
// Create a new options struct.
options := scalr.EnvironmentUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
- CostEstimationEnabled: scalr.Bool(d.Get("cost_estimation_enabled").(bool)),
+ Name: ptr(d.Get("name").(string)),
+ CostEstimationEnabled: ptr(d.Get("cost_estimation_enabled").(bool)),
PolicyGroups: policyGroups,
}
diff --git a/internal/provider/resource_scalr_iam_team.go b/internal/provider/resource_scalr_iam_team.go
index b3479773..c88ef362 100644
--- a/internal/provider/resource_scalr_iam_team.go
+++ b/internal/provider/resource_scalr_iam_team.go
@@ -95,7 +95,7 @@ func resourceScalrIamTeamCreate(ctx context.Context, d *schema.ResourceData, met
// Optional attributes
if desc, ok := d.GetOk("description"); ok {
- opts.Description = scalr.String(desc.(string))
+ opts.Description = ptr(desc.(string))
}
if idpID, ok := d.GetOk("identity_provider_id"); ok {
opts.IdentityProvider = &scalr.IdentityProvider{ID: idpID.(string)}
@@ -159,8 +159,8 @@ func resourceScalrIamTeamUpdate(ctx context.Context, d *schema.ResourceData, met
}
opts := scalr.TeamUpdateOptions{
- Name: scalr.String(name),
- Description: scalr.String(desc),
+ Name: ptr(name),
+ Description: ptr(desc),
Users: users,
}
diff --git a/internal/provider/resource_scalr_iam_team_test.go b/internal/provider/resource_scalr_iam_team_test.go
index e2017ae6..ce8deb87 100644
--- a/internal/provider/resource_scalr_iam_team_test.go
+++ b/internal/provider/resource_scalr_iam_team_test.go
@@ -137,7 +137,7 @@ func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
context.Background(),
team.ID,
scalr.TeamUpdateOptions{
- Name: scalr.String("renamed-outside-of-terraform"),
+ Name: ptr("renamed-outside-of-terraform"),
Users: t.Users,
},
)
diff --git a/internal/provider/resource_scalr_module.go b/internal/provider/resource_scalr_module.go
index 52ec6793..df602eed 100644
--- a/internal/provider/resource_scalr_module.go
+++ b/internal/provider/resource_scalr_module.go
@@ -100,13 +100,13 @@ func resourceScalrModuleCreate(ctx context.Context, d *schema.ResourceData, meta
vcsRepo := d.Get("vcs_repo").([]interface{})[0].(map[string]interface{})
vcsOpt := &scalr.ModuleVCSRepo{
- Identifier: *scalr.String(vcsRepo["identifier"].(string)),
+ Identifier: vcsRepo["identifier"].(string),
}
if path, ok := vcsRepo["path"].(string); ok && path != "" {
- vcsOpt.Path = scalr.String(path)
+ vcsOpt.Path = ptr(path)
}
if prefix, ok := vcsRepo["tag_prefix"].(string); ok && prefix != "" {
- vcsOpt.TagPrefix = scalr.String(prefix)
+ vcsOpt.TagPrefix = ptr(prefix)
}
opt := scalr.ModuleCreateOptions{
diff --git a/internal/provider/resource_scalr_policy_group.go b/internal/provider/resource_scalr_policy_group.go
index 6e491909..19823163 100644
--- a/internal/provider/resource_scalr_policy_group.go
+++ b/internal/provider/resource_scalr_policy_group.go
@@ -129,28 +129,28 @@ func resourceScalrPolicyGroupCreate(ctx context.Context, d *schema.ResourceData,
vcsRepo := d.Get("vcs_repo").([]interface{})[0].(map[string]interface{})
vcsOpt := &scalr.PolicyGroupVCSRepoOptions{
- Identifier: scalr.String(vcsRepo["identifier"].(string)),
+ Identifier: ptr(vcsRepo["identifier"].(string)),
}
if branch, ok := vcsRepo["branch"].(string); ok && branch != "" {
- vcsOpt.Branch = scalr.String(branch)
+ vcsOpt.Branch = ptr(branch)
}
if path, ok := vcsRepo["path"].(string); ok && path != "" {
- vcsOpt.Path = scalr.String(path)
+ vcsOpt.Path = ptr(path)
}
opts := scalr.PolicyGroupCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
VCSRepo: vcsOpt,
Account: &scalr.Account{ID: accountID},
VcsProvider: &scalr.VcsProvider{ID: vcsProviderID},
- IsEnforced: scalr.Bool(false),
+ IsEnforced: ptr(false),
}
environments := make([]*scalr.Environment, 0)
if environmentsI, ok := d.GetOk("environments"); ok {
environmentsIDs := environmentsI.([]interface{})
if (len(environmentsIDs) == 1) && environmentsIDs[0].(string) == "*" {
- opts.IsEnforced = scalr.Bool(true)
+ opts.IsEnforced = ptr(true)
} else if len(environmentsIDs) > 0 {
for _, env := range environmentsIDs {
if env.(string) == "*" {
@@ -165,7 +165,7 @@ func resourceScalrPolicyGroupCreate(ctx context.Context, d *schema.ResourceData,
// Optional attributes
if opaVersion, ok := d.GetOk("opa_version"); ok {
- opts.OpaVersion = scalr.String(opaVersion.(string))
+ opts.OpaVersion = ptr(opaVersion.(string))
}
pg, err := scalrClient.PolicyGroups.Create(ctx, opts)
@@ -264,30 +264,30 @@ func resourceScalrPolicyGroupUpdate(ctx context.Context, d *schema.ResourceData,
vcsRepo := d.Get("vcs_repo").([]interface{})[0].(map[string]interface{})
vcsOpt := &scalr.PolicyGroupVCSRepoOptions{
- Identifier: scalr.String(vcsRepo["identifier"].(string)),
+ Identifier: ptr(vcsRepo["identifier"].(string)),
}
if branch, ok := vcsRepo["branch"].(string); ok && branch != "" {
- vcsOpt.Branch = scalr.String(branch)
+ vcsOpt.Branch = ptr(branch)
}
if path, ok := vcsRepo["path"].(string); ok && path != "" {
- vcsOpt.Path = scalr.String(path)
+ vcsOpt.Path = ptr(path)
}
opts := scalr.PolicyGroupUpdateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
VCSRepo: vcsOpt,
VcsProvider: &scalr.VcsProvider{ID: vcsProviderID},
- IsEnforced: scalr.Bool(false),
+ IsEnforced: ptr(false),
}
if opaVersion, ok := d.GetOk("opa_version"); ok {
- opts.OpaVersion = scalr.String(opaVersion.(string))
+ opts.OpaVersion = ptr(opaVersion.(string))
}
environments := make([]*scalr.Environment, 0)
if environmentsI, ok := d.GetOk("environments"); ok {
environmentsIDs := environmentsI.([]interface{})
if (len(environmentsIDs) == 1) && environmentsIDs[0].(string) == "*" {
- opts.IsEnforced = scalr.Bool(true)
+ opts.IsEnforced = ptr(true)
} else if len(environmentsIDs) > 0 {
for _, env := range environmentsIDs {
if env.(string) == "*" {
diff --git a/internal/provider/resource_scalr_policy_group_test.go b/internal/provider/resource_scalr_policy_group_test.go
index 946b67de..126fe44b 100644
--- a/internal/provider/resource_scalr_policy_group_test.go
+++ b/internal/provider/resource_scalr_policy_group_test.go
@@ -326,7 +326,7 @@ func testAccCheckPolicyGroupRename(policyGroup *scalr.PolicyGroup) func() {
_, err := scalrClient.PolicyGroups.Update(
context.Background(),
policyGroup.ID,
- scalr.PolicyGroupUpdateOptions{Name: scalr.String("renamed-outside-of-terraform")},
+ scalr.PolicyGroupUpdateOptions{Name: ptr("renamed-outside-of-terraform")},
)
if err != nil {
log.Fatalf("Could not rename policy group outside of terraform: %v", err)
diff --git a/internal/provider/resource_scalr_provider_configuration.go b/internal/provider/resource_scalr_provider_configuration.go
index b233b3d0..47962a7b 100644
--- a/internal/provider/resource_scalr_provider_configuration.go
+++ b/internal/provider/resource_scalr_provider_configuration.go
@@ -299,9 +299,9 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
accountID := d.Get("account_id").(string)
configurationOptions := scalr.ProviderConfigurationCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
Account: &scalr.Account{ID: accountID},
- ExportShellVariables: scalr.Bool(d.Get("export_shell_variables").(bool)),
+ ExportShellVariables: ptr(d.Get("export_shell_variables").(bool)),
}
if owners, ok := d.GetOk("owners"); ok {
@@ -315,7 +315,7 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- configurationOptions.IsShared = scalr.Bool(true)
+ configurationOptions.IsShared = ptr(true)
} else if len(environments) > 0 {
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
@@ -328,10 +328,10 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
var createArgumentOptions []scalr.ProviderConfigurationParameterCreateOptions
if _, ok := d.GetOk("aws"); ok {
- configurationOptions.ProviderName = scalr.String("aws")
+ configurationOptions.ProviderName = ptr("aws")
- configurationOptions.AwsAccountType = scalr.String(d.Get("aws.0.account_type").(string))
- configurationOptions.AwsCredentialsType = scalr.String(d.Get("aws.0.credentials_type").(string))
+ configurationOptions.AwsAccountType = ptr(d.Get("aws.0.account_type").(string))
+ configurationOptions.AwsCredentialsType = ptr(d.Get("aws.0.credentials_type").(string))
accessKeyIdI, accessKeyIdExists := d.GetOk("aws.0.access_key")
accessKeyIdExists = accessKeyIdExists && len(accessKeyIdI.(string)) > 0
@@ -339,18 +339,18 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
accessSecretKeyExists = accessSecretKeyExists && len(accessSecretKeyI.(string)) > 0
if accessKeyIdExists && accessSecretKeyExists {
- configurationOptions.AwsAccessKey = scalr.String(accessKeyIdI.(string))
- configurationOptions.AwsSecretKey = scalr.String(accessSecretKeyI.(string))
+ configurationOptions.AwsAccessKey = ptr(accessKeyIdI.(string))
+ configurationOptions.AwsSecretKey = ptr(accessSecretKeyI.(string))
} else if accessKeyIdExists || accessSecretKeyExists {
return diag.Errorf("'access_key' and 'secret_key' fields can be used only together")
}
if *configurationOptions.AwsCredentialsType == "role_delegation" {
- configurationOptions.AwsTrustedEntityType = scalr.String(d.Get("aws.0.trusted_entity_type").(string))
- configurationOptions.AwsRoleArn = scalr.String(d.Get("aws.0.role_arn").(string))
+ configurationOptions.AwsTrustedEntityType = ptr(d.Get("aws.0.trusted_entity_type").(string))
+ configurationOptions.AwsRoleArn = ptr(d.Get("aws.0.role_arn").(string))
externalIdI, externalIdExists := d.GetOk("aws.0.external_id")
if externalIdExists {
- configurationOptions.AwsExternalId = scalr.String(externalIdI.(string))
+ configurationOptions.AwsExternalId = ptr(externalIdI.(string))
}
if len(*configurationOptions.AwsTrustedEntityType) == 0 {
return diag.Errorf("'trusted_entity_type' field is required for 'role_delegation' credentials type of aws provider configuration")
@@ -362,8 +362,8 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
return diag.Errorf("'external_id' field is required for 'role_delegation' credentials type with 'aws_account' trusted entity type of aws provider configuration")
}
} else if *configurationOptions.AwsCredentialsType == "oidc" {
- configurationOptions.AwsRoleArn = scalr.String(d.Get("aws.0.role_arn").(string))
- configurationOptions.AwsAudience = scalr.String(d.Get("aws.0.audience").(string))
+ configurationOptions.AwsRoleArn = ptr(d.Get("aws.0.role_arn").(string))
+ configurationOptions.AwsAudience = ptr(d.Get("aws.0.audience").(string))
if len(*configurationOptions.AwsRoleArn) == 0 {
return diag.Errorf("'role_arn' field is required for 'oidc' credentials type of aws provider configuration")
}
@@ -377,9 +377,9 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
}
} else if _, ok := d.GetOk("google"); ok {
- configurationOptions.ProviderName = scalr.String("google")
- configurationOptions.GoogleAuthType = scalr.String(d.Get("google.0.auth_type").(string))
- configurationOptions.GoogleUseDefaultProject = scalr.Bool(d.Get("google.0.use_default_project").(bool))
+ configurationOptions.ProviderName = ptr("google")
+ configurationOptions.GoogleAuthType = ptr(d.Get("google.0.auth_type").(string))
+ configurationOptions.GoogleUseDefaultProject = ptr(d.Get("google.0.use_default_project").(bool))
googleCredentials, googleCredentialsExists := d.GetOk("google.0.credentials")
googleCredentialsExists = googleCredentialsExists && len(googleCredentials.(string)) > 0
@@ -395,7 +395,7 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
if serviceAccountEmailExists || workloadProviderNameExists {
return diag.Errorf("'service_account_email' and 'workload_provider_name' fields of google provider configuration can be used only with 'oidc' auth type")
}
- configurationOptions.GoogleCredentials = scalr.String(googleCredentials.(string))
+ configurationOptions.GoogleCredentials = ptr(googleCredentials.(string))
} else if *configurationOptions.GoogleAuthType == "oidc" {
if !serviceAccountEmailExists || !workloadProviderNameExists {
return diag.Errorf("'service_account_email' and 'workload_provider_name' fields are required for 'oidc' auth type of google provider configuration")
@@ -403,21 +403,21 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
if googleCredentialsExists {
return diag.Errorf("'credentials' field of google provider configuration can be used only with 'service-account-key' auth type")
}
- configurationOptions.GoogleServiceAccountEmail = scalr.String(serviceAccountEmail.(string))
- configurationOptions.GoogleWorkloadProviderName = scalr.String(workloadProviderName.(string))
+ configurationOptions.GoogleServiceAccountEmail = ptr(serviceAccountEmail.(string))
+ configurationOptions.GoogleWorkloadProviderName = ptr(workloadProviderName.(string))
} else {
return diag.Errorf("unknown google provider configuration auth type: '%s', allowed: 'service-account-key', 'oidc'", *configurationOptions.GoogleAuthType)
}
if v, ok := d.GetOk("google.0.project"); ok {
- configurationOptions.GoogleProject = scalr.String(v.(string))
+ configurationOptions.GoogleProject = ptr(v.(string))
}
} else if _, ok := d.GetOk("azurerm"); ok {
- configurationOptions.ProviderName = scalr.String("azurerm")
- configurationOptions.AzurermClientId = scalr.String(d.Get("azurerm.0.client_id").(string))
- configurationOptions.AzurermSubscriptionId = scalr.String(d.Get("azurerm.0.subscription_id").(string))
- configurationOptions.AzurermTenantId = scalr.String(d.Get("azurerm.0.tenant_id").(string))
+ configurationOptions.ProviderName = ptr("azurerm")
+ configurationOptions.AzurermClientId = ptr(d.Get("azurerm.0.client_id").(string))
+ configurationOptions.AzurermSubscriptionId = ptr(d.Get("azurerm.0.subscription_id").(string))
+ configurationOptions.AzurermTenantId = ptr(d.Get("azurerm.0.tenant_id").(string))
authType := d.Get("azurerm.0.auth_type").(string)
if authType == "oidc" {
@@ -425,43 +425,43 @@ func resourceScalrProviderConfigurationCreate(ctx context.Context, d *schema.Res
if !audienceExists {
return diag.Errorf("'audience' field is required for 'oidc' auth type of azurerm provider configuration")
}
- configurationOptions.AzurermAudience = scalr.String(audience.(string))
- configurationOptions.AzurermAuthType = scalr.String("oidc")
+ configurationOptions.AzurermAudience = ptr(audience.(string))
+ configurationOptions.AzurermAuthType = ptr("oidc")
} else if authType == "client-secrets" {
client_secret, secretExists := d.GetOk("azurerm.0.client_secret")
if !secretExists {
return diag.Errorf("'client_secret' field is required for 'client-secrets' auth type of azurerm provider configuration")
}
- configurationOptions.AzurermClientSecret = scalr.String(client_secret.(string))
- configurationOptions.AzurermAuthType = scalr.String("client-secrets")
+ configurationOptions.AzurermClientSecret = ptr(client_secret.(string))
+ configurationOptions.AzurermAuthType = ptr("client-secrets")
} else {
return diag.Errorf("unknown azurerm provider configuration auth type: '%s', allowed: 'client-secrets', 'oidc'", authType)
}
} else if _, ok := d.GetOk("scalr"); ok {
- configurationOptions.ProviderName = scalr.String("scalr")
- configurationOptions.ScalrHostname = scalr.String(d.Get("scalr.0.hostname").(string))
- configurationOptions.ScalrToken = scalr.String(d.Get("scalr.0.token").(string))
+ configurationOptions.ProviderName = ptr("scalr")
+ configurationOptions.ScalrHostname = ptr(d.Get("scalr.0.hostname").(string))
+ configurationOptions.ScalrToken = ptr(d.Get("scalr.0.token").(string))
} else if v, ok := d.GetOk("custom"); ok {
custom := v.([]interface{})[0].(map[string]interface{})
- configurationOptions.ProviderName = scalr.String(custom["provider_name"].(string))
- configurationOptions.IsCustom = scalr.Bool(true)
+ configurationOptions.ProviderName = ptr(custom["provider_name"].(string))
+ configurationOptions.IsCustom = ptr(true)
for _, v := range custom["argument"].(*schema.Set).List() {
argument := v.(map[string]interface{})
createArgumentOption := scalr.ProviderConfigurationParameterCreateOptions{
- Key: scalr.String(argument["name"].(string)),
+ Key: ptr(argument["name"].(string)),
}
if v, ok := argument["value"]; ok {
- createArgumentOption.Value = scalr.String(v.(string))
+ createArgumentOption.Value = ptr(v.(string))
}
if v, ok := argument["description"]; ok {
- createArgumentOption.Description = scalr.String(v.(string))
+ createArgumentOption.Description = ptr(v.(string))
}
if v, ok := argument["sensitive"]; ok {
- createArgumentOption.Sensitive = scalr.Bool(v.(bool))
+ createArgumentOption.Sensitive = ptr(v.(bool))
}
createArgumentOptions = append(createArgumentOptions, createArgumentOption)
@@ -686,16 +686,16 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
d.HasChange("environments") ||
d.HasChange("owners") {
configurationOptions := scalr.ProviderConfigurationUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
- ExportShellVariables: scalr.Bool(d.Get("export_shell_variables").(bool)),
+ Name: ptr(d.Get("name").(string)),
+ ExportShellVariables: ptr(d.Get("export_shell_variables").(bool)),
}
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- configurationOptions.IsShared = scalr.Bool(true)
+ configurationOptions.IsShared = ptr(true)
configurationOptions.Environments = make([]*scalr.Environment, 0)
} else {
- configurationOptions.IsShared = scalr.Bool(false)
+ configurationOptions.IsShared = ptr(false)
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
environmentValues = append(environmentValues, &scalr.Environment{ID: env.(string)})
@@ -703,13 +703,13 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
configurationOptions.Environments = environmentValues
}
} else {
- configurationOptions.IsShared = scalr.Bool(false)
+ configurationOptions.IsShared = ptr(false)
configurationOptions.Environments = make([]*scalr.Environment, 0)
}
if _, ok := d.GetOk("aws"); ok {
- configurationOptions.AwsAccountType = scalr.String(d.Get("aws.0.account_type").(string))
- configurationOptions.AwsCredentialsType = scalr.String(d.Get("aws.0.credentials_type").(string))
+ configurationOptions.AwsAccountType = ptr(d.Get("aws.0.account_type").(string))
+ configurationOptions.AwsCredentialsType = ptr(d.Get("aws.0.credentials_type").(string))
accessKeyIdI, accessKeyIdExists := d.GetOk("aws.0.access_key")
accessKeyIdExists = accessKeyIdExists && len(accessKeyIdI.(string)) > 0
@@ -717,18 +717,18 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
accessSecretKeyExists = accessSecretKeyExists && len(accessSecretKeyI.(string)) > 0
if accessKeyIdExists && accessSecretKeyExists {
- configurationOptions.AwsAccessKey = scalr.String(accessKeyIdI.(string))
- configurationOptions.AwsSecretKey = scalr.String(accessSecretKeyI.(string))
+ configurationOptions.AwsAccessKey = ptr(accessKeyIdI.(string))
+ configurationOptions.AwsSecretKey = ptr(accessSecretKeyI.(string))
} else if accessKeyIdExists || accessSecretKeyExists {
return diag.Errorf("'access_key' and 'secret_key' fields can be used only together")
}
if *configurationOptions.AwsCredentialsType == "role_delegation" {
- configurationOptions.AwsTrustedEntityType = scalr.String(d.Get("aws.0.trusted_entity_type").(string))
- configurationOptions.AwsRoleArn = scalr.String(d.Get("aws.0.role_arn").(string))
+ configurationOptions.AwsTrustedEntityType = ptr(d.Get("aws.0.trusted_entity_type").(string))
+ configurationOptions.AwsRoleArn = ptr(d.Get("aws.0.role_arn").(string))
externalIdI, externalIdExists := d.GetOk("aws.0.external_id")
if externalIdExists {
- configurationOptions.AwsExternalId = scalr.String(externalIdI.(string))
+ configurationOptions.AwsExternalId = ptr(externalIdI.(string))
}
if len(*configurationOptions.AwsTrustedEntityType) == 0 {
return diag.Errorf("'trusted_entity_type' field is required for 'role_delegation' credentials type of aws provider configuration")
@@ -740,8 +740,8 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
return diag.Errorf("'external_id' field is required for 'role_delegation' credentials type with 'aws_account' entity type of aws provider configuration")
}
} else if *configurationOptions.AwsCredentialsType == "oidc" {
- configurationOptions.AwsRoleArn = scalr.String(d.Get("aws.0.role_arn").(string))
- configurationOptions.AwsAudience = scalr.String(d.Get("aws.0.audience").(string))
+ configurationOptions.AwsRoleArn = ptr(d.Get("aws.0.role_arn").(string))
+ configurationOptions.AwsAudience = ptr(d.Get("aws.0.audience").(string))
if len(*configurationOptions.AwsRoleArn) == 0 {
return diag.Errorf("'role_arn' field is required for 'oidc' credentials type of aws provider configuration")
}
@@ -754,9 +754,9 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
return diag.Errorf("'access_key' and 'secret_key' fields are required for 'access_keys' credentials type of aws provider configuration")
}
} else if _, ok := d.GetOk("google"); ok {
- configurationOptions.GoogleAuthType = scalr.String(d.Get("google.0.auth_type").(string))
+ configurationOptions.GoogleAuthType = ptr(d.Get("google.0.auth_type").(string))
- configurationOptions.GoogleUseDefaultProject = scalr.Bool(d.Get("google.0.use_default_project").(bool))
+ configurationOptions.GoogleUseDefaultProject = ptr(d.Get("google.0.use_default_project").(bool))
googleCredentials, googleCredentialsExists := d.GetOk("google.0.credentials")
googleCredentialsExists = googleCredentialsExists && len(googleCredentials.(string)) > 0
serviceAccountEmail, serviceAccountEmailExists := d.GetOk("google.0.service_account_email")
@@ -771,7 +771,7 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
if serviceAccountEmailExists || workloadProviderNameExists {
return diag.Errorf("'service_account_email' and 'workload_provider_name' fields of google provider configuration can be used only with 'oidc' auth type")
}
- configurationOptions.GoogleCredentials = scalr.String(googleCredentials.(string))
+ configurationOptions.GoogleCredentials = ptr(googleCredentials.(string))
} else if *configurationOptions.GoogleAuthType == "oidc" {
if !serviceAccountEmailExists || !workloadProviderNameExists {
return diag.Errorf("'service_account_email' and 'workload_provider_name' fields are required for 'oidc' auth type of google provider configuration")
@@ -779,22 +779,22 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
if googleCredentialsExists {
return diag.Errorf("'credentials' field of google provider configuration can be used only with 'service-account-key' auth type")
}
- configurationOptions.GoogleServiceAccountEmail = scalr.String(serviceAccountEmail.(string))
- configurationOptions.GoogleWorkloadProviderName = scalr.String(workloadProviderName.(string))
+ configurationOptions.GoogleServiceAccountEmail = ptr(serviceAccountEmail.(string))
+ configurationOptions.GoogleWorkloadProviderName = ptr(workloadProviderName.(string))
} else {
return diag.Errorf("unknown google provider configuration auth type: '%s', allowed: 'service-account-key', 'oidc'", *configurationOptions.GoogleAuthType)
}
if v, ok := d.GetOk("google.0.project"); ok {
- configurationOptions.GoogleProject = scalr.String(v.(string))
+ configurationOptions.GoogleProject = ptr(v.(string))
}
} else if _, ok := d.GetOk("scalr"); ok {
- configurationOptions.ScalrHostname = scalr.String(d.Get("scalr.0.hostname").(string))
- configurationOptions.ScalrToken = scalr.String(d.Get("scalr.0.token").(string))
+ configurationOptions.ScalrHostname = ptr(d.Get("scalr.0.hostname").(string))
+ configurationOptions.ScalrToken = ptr(d.Get("scalr.0.token").(string))
} else if _, ok := d.GetOk("azurerm"); ok {
- configurationOptions.AzurermClientId = scalr.String(d.Get("azurerm.0.client_id").(string))
- configurationOptions.AzurermSubscriptionId = scalr.String(d.Get("azurerm.0.subscription_id").(string))
- configurationOptions.AzurermTenantId = scalr.String(d.Get("azurerm.0.tenant_id").(string))
+ configurationOptions.AzurermClientId = ptr(d.Get("azurerm.0.client_id").(string))
+ configurationOptions.AzurermSubscriptionId = ptr(d.Get("azurerm.0.subscription_id").(string))
+ configurationOptions.AzurermTenantId = ptr(d.Get("azurerm.0.tenant_id").(string))
authType := d.Get("azurerm.0.auth_type").(string)
if authType == "oidc" {
@@ -802,15 +802,15 @@ func resourceScalrProviderConfigurationUpdate(ctx context.Context, d *schema.Res
if !audienceExists {
return diag.Errorf("'audience' field is required for 'oidc' auth type of azurerm provider configuration")
}
- configurationOptions.AzurermAudience = scalr.String(audience.(string))
- configurationOptions.AzurermAuthType = scalr.String("oidc")
+ configurationOptions.AzurermAudience = ptr(audience.(string))
+ configurationOptions.AzurermAuthType = ptr("oidc")
} else if authType == "client-secrets" {
client_secret, secretExists := d.GetOk("azurerm.0.client_secret")
if !secretExists {
return diag.Errorf("'client_secret' field is required for 'client-secrets' auth type of azurerm provider configuration")
}
- configurationOptions.AzurermClientSecret = scalr.String(client_secret.(string))
- configurationOptions.AzurermAuthType = scalr.String("client-secrets")
+ configurationOptions.AzurermClientSecret = ptr(client_secret.(string))
+ configurationOptions.AzurermAuthType = ptr("client-secrets")
} else {
return diag.Errorf("unknown azurerm provider configuration auth type: '%s', allowed: 'client-secrets', 'oidc'", authType)
}
@@ -852,16 +852,16 @@ func syncArguments(ctx context.Context, providerConfigurationId string, custom m
configArgument := v.(map[string]interface{})
name := configArgument["name"].(string)
parameterCreateOption := scalr.ProviderConfigurationParameterCreateOptions{
- Key: scalr.String(name),
+ Key: ptr(name),
}
if v, ok := configArgument["value"]; ok {
- parameterCreateOption.Value = scalr.String(v.(string))
+ parameterCreateOption.Value = ptr(v.(string))
}
if v, ok := configArgument["sensitive"]; ok {
- parameterCreateOption.Sensitive = scalr.Bool(v.(bool))
+ parameterCreateOption.Sensitive = ptr(v.(bool))
}
if v, ok := configArgument["description"]; ok {
- parameterCreateOption.Description = scalr.String(v.(string))
+ parameterCreateOption.Description = ptr(v.(string))
}
configArgumentsCreateOptions[name] = parameterCreateOption
}
diff --git a/internal/provider/resource_scalr_role.go b/internal/provider/resource_scalr_role.go
index 0b79e4b1..051f2d61 100644
--- a/internal/provider/resource_scalr_role.go
+++ b/internal/provider/resource_scalr_role.go
@@ -103,9 +103,9 @@ func resourceScalrRoleCreate(ctx context.Context, d *schema.ResourceData, meta i
// Create a new options struct
options := scalr.RoleCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
Account: &scalr.Account{ID: accountID},
- Description: scalr.String(description),
+ Description: ptr(description),
Permissions: permissions,
}
@@ -182,8 +182,8 @@ func resourceScalrRoleUpdate(ctx context.Context, d *schema.ResourceData, meta i
// Create a new options struct
options := scalr.RoleUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
- Description: scalr.String(d.Get("description").(string)),
+ Name: ptr(d.Get("name").(string)),
+ Description: ptr(d.Get("description").(string)),
Permissions: permissions,
}
diff --git a/internal/provider/resource_scalr_role_test.go b/internal/provider/resource_scalr_role_test.go
index 669ce0f2..dbc6f437 100644
--- a/internal/provider/resource_scalr_role_test.go
+++ b/internal/provider/resource_scalr_role_test.go
@@ -135,7 +135,7 @@ func testAccCheckScalrRoleRename(role *scalr.Role) func() {
r, err = scalrClient.Roles.Update(
context.Background(),
r.ID,
- scalr.RoleUpdateOptions{Name: scalr.String("renamed-outside-of-terraform")},
+ scalr.RoleUpdateOptions{Name: ptr("renamed-outside-of-terraform")},
)
if err != nil {
log.Fatalf("Could not rename the role outside of terraform: %v", err)
diff --git a/internal/provider/resource_scalr_run_schedule_rule.go b/internal/provider/resource_scalr_run_schedule_rule.go
index 14ddaf93..b4b24112 100644
--- a/internal/provider/resource_scalr_run_schedule_rule.go
+++ b/internal/provider/resource_scalr_run_schedule_rule.go
@@ -100,7 +100,7 @@ func resourceScalrRunScheduleRuleUpdate(ctx context.Context, d *schema.ResourceD
opts := scalr.RunScheduleRuleUpdateOptions{}
if v, ok := d.GetOk("schedule"); ok {
- opts.Schedule = scalr.String(v.(string))
+ opts.Schedule = ptr(v.(string))
}
if v, ok := d.GetOk("schedule_mode"); ok {
diff --git a/internal/provider/resource_scalr_service_account.go b/internal/provider/resource_scalr_service_account.go
index b266a8de..adf6601d 100644
--- a/internal/provider/resource_scalr_service_account.go
+++ b/internal/provider/resource_scalr_service_account.go
@@ -143,17 +143,17 @@ func resourceScalrServiceAccountCreate(ctx context.Context, d *schema.ResourceDa
accountID := d.Get("account_id").(string)
options := scalr.ServiceAccountCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
Account: &scalr.Account{ID: accountID},
}
if desc, ok := d.GetOk("description"); ok {
- options.Description = scalr.String(desc.(string))
+ options.Description = ptr(desc.(string))
}
if status, ok := d.GetOk("status"); ok {
saStatus := scalr.ServiceAccountStatus(status.(string))
- options.Status = scalr.ServiceAccountStatusPtr(saStatus)
+ options.Status = ptr(saStatus)
}
if owners, ok := d.GetOk("owners"); ok {
@@ -184,12 +184,12 @@ func resourceScalrServiceAccountUpdate(ctx context.Context, d *schema.ResourceDa
if d.HasChange("description") {
desc := d.Get("description").(string)
- options.Description = scalr.String(desc)
+ options.Description = ptr(desc)
}
if d.HasChange("status") {
status := scalr.ServiceAccountStatus(d.Get("status").(string))
- options.Status = scalr.ServiceAccountStatusPtr(status)
+ options.Status = ptr(status)
}
if d.HasChange("owners") {
diff --git a/internal/provider/resource_scalr_service_account_token.go b/internal/provider/resource_scalr_service_account_token.go
index f2fdf0f4..da2bbf3b 100644
--- a/internal/provider/resource_scalr_service_account_token.go
+++ b/internal/provider/resource_scalr_service_account_token.go
@@ -47,7 +47,7 @@ func resourceScalrServiceAccountTokenCreate(ctx context.Context, d *schema.Resou
options := scalr.AccessTokenCreateOptions{}
if desc, ok := d.GetOk("description"); ok {
- options.Description = scalr.String(desc.(string))
+ options.Description = ptr(desc.(string))
}
log.Printf("[DEBUG] Create access token for service account: %s", saID)
@@ -119,7 +119,7 @@ func resourceScalrServiceAccountTokenUpdate(ctx context.Context, d *schema.Resou
desc := d.Get("description").(string)
options := scalr.AccessTokenUpdateOptions{
- Description: scalr.String(desc),
+ Description: ptr(desc),
}
log.Printf("[DEBUG] Update service account access token %s", id)
diff --git a/internal/provider/resource_scalr_slack_integration.go b/internal/provider/resource_scalr_slack_integration.go
index 7348cbd5..54857f0a 100644
--- a/internal/provider/resource_scalr_slack_integration.go
+++ b/internal/provider/resource_scalr_slack_integration.go
@@ -143,9 +143,9 @@ func resourceScalrSlackIntegrationCreate(ctx context.Context, d *schema.Resource
options := scalr.SlackIntegrationCreateOptions{
Name: &name,
- ChannelId: scalr.String(d.Get("channel_id").(string)),
+ ChannelId: ptr(d.Get("channel_id").(string)),
Events: parseEvents(d),
- RunMode: scalr.String(d.Get("run_mode").(string)),
+ RunMode: ptr(d.Get("run_mode").(string)),
Account: &scalr.Account{ID: accountID},
Environments: parseEnvironments(d),
}
@@ -217,11 +217,11 @@ func resourceScalrSlackIntegrationUpdate(ctx context.Context, d *schema.Resource
options := scalr.SlackIntegrationUpdateOptions{}
if d.HasChange("name") {
- options.Name = scalr.String(d.Get("name").(string))
+ options.Name = ptr(d.Get("name").(string))
}
if d.HasChange("channel_id") {
- options.ChannelId = scalr.String(d.Get("channel_id").(string))
+ options.ChannelId = ptr(d.Get("channel_id").(string))
}
if d.HasChange("events") {
@@ -230,7 +230,7 @@ func resourceScalrSlackIntegrationUpdate(ctx context.Context, d *schema.Resource
}
if d.HasChange("run_mode") {
- options.RunMode = scalr.String(d.Get("run_mode").(string))
+ options.RunMode = ptr(d.Get("run_mode").(string))
}
if d.HasChange("environments") {
diff --git a/internal/provider/resource_scalr_ssh_key.go b/internal/provider/resource_scalr_ssh_key.go
index c6f908f3..70469733 100644
--- a/internal/provider/resource_scalr_ssh_key.go
+++ b/internal/provider/resource_scalr_ssh_key.go
@@ -59,14 +59,14 @@ func resourceScalrSSHKeyCreate(ctx context.Context, d *schema.ResourceData, meta
sshKeyOptions := scalr.SSHKeyCreateOptions{
Account: &scalr.Account{ID: accountID},
- Name: scalr.String(name),
- PrivateKey: scalr.String(privateKey),
+ Name: ptr(name),
+ PrivateKey: ptr(privateKey),
}
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- sshKeyOptions.IsShared = scalr.Bool(true)
+ sshKeyOptions.IsShared = ptr(true)
} else if len(environments) > 0 {
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
@@ -121,17 +121,17 @@ func resourceScalrSSHKeyUpdate(ctx context.Context, d *schema.ResourceData, meta
if d.HasChange("name") || d.HasChange("private_key") || d.HasChange("environments") {
sshKeyUpdateOptions := scalr.SSHKeyUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
- PrivateKey: scalr.String(d.Get("private_key").(string)),
+ Name: ptr(d.Get("name").(string)),
+ PrivateKey: ptr(d.Get("private_key").(string)),
}
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- sshKeyUpdateOptions.IsShared = scalr.Bool(true)
+ sshKeyUpdateOptions.IsShared = ptr(true)
sshKeyUpdateOptions.Environments = make([]*scalr.Environment, 0)
} else {
- sshKeyUpdateOptions.IsShared = scalr.Bool(false)
+ sshKeyUpdateOptions.IsShared = ptr(false)
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
environmentValues = append(environmentValues, &scalr.Environment{ID: env.(string)})
@@ -139,7 +139,7 @@ func resourceScalrSSHKeyUpdate(ctx context.Context, d *schema.ResourceData, meta
sshKeyUpdateOptions.Environments = environmentValues
}
} else {
- sshKeyUpdateOptions.IsShared = scalr.Bool(false)
+ sshKeyUpdateOptions.IsShared = ptr(false)
sshKeyUpdateOptions.Environments = make([]*scalr.Environment, 0)
}
diff --git a/internal/provider/resource_scalr_tag.go b/internal/provider/resource_scalr_tag.go
index 4ceab8a3..21263372 100644
--- a/internal/provider/resource_scalr_tag.go
+++ b/internal/provider/resource_scalr_tag.go
@@ -69,7 +69,7 @@ func resourceScalrTagCreate(ctx context.Context, d *schema.ResourceData, meta in
accountID := d.Get("account_id").(string)
options := scalr.TagCreateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
Account: &scalr.Account{ID: accountID},
}
@@ -91,7 +91,7 @@ func resourceScalrTagUpdate(ctx context.Context, d *schema.ResourceData, meta in
if d.HasChange("name") {
name := d.Get("name").(string)
opts := scalr.TagUpdateOptions{
- Name: scalr.String(name),
+ Name: ptr(name),
}
log.Printf("[DEBUG] Update tag %s", id)
_, err := scalrClient.Tags.Update(ctx, id, opts)
diff --git a/internal/provider/resource_scalr_variable.go b/internal/provider/resource_scalr_variable.go
index 946c5939..1790b9b3 100644
--- a/internal/provider/resource_scalr_variable.go
+++ b/internal/provider/resource_scalr_variable.go
@@ -204,14 +204,14 @@ func resourceScalrVariableCreate(ctx context.Context, d *schema.ResourceData, me
// Create a new options struct.
options := scalr.VariableCreateOptions{
- Key: scalr.String(key),
- Value: scalr.String(d.Get("value").(string)),
- Description: scalr.String(d.Get("description").(string)),
- Category: scalr.Category(category),
- HCL: scalr.Bool(hcl),
- Sensitive: scalr.Bool(d.Get("sensitive").(bool)),
- Final: scalr.Bool(d.Get("final").(bool)),
- QueryOptions: &scalr.VariableWriteQueryOptions{Force: scalr.Bool(d.Get("force").(bool))},
+ Key: ptr(key),
+ Value: ptr(d.Get("value").(string)),
+ Description: ptr(d.Get("description").(string)),
+ Category: ptr(category),
+ HCL: ptr(hcl),
+ Sensitive: ptr(d.Get("sensitive").(bool)),
+ Final: ptr(d.Get("final").(bool)),
+ QueryOptions: &scalr.VariableWriteQueryOptions{Force: ptr(d.Get("force").(bool))},
Account: &scalr.Account{ID: d.Get("account_id").(string)},
}
@@ -319,13 +319,13 @@ func resourceScalrVariableUpdate(ctx context.Context, d *schema.ResourceData, me
// Create a new options struct.
options := scalr.VariableUpdateOptions{
- Key: scalr.String(d.Get("key").(string)),
- Value: scalr.String(d.Get("value").(string)),
- HCL: scalr.Bool(hcl),
- Sensitive: scalr.Bool(d.Get("sensitive").(bool)),
- Description: scalr.String(d.Get("description").(string)),
- Final: scalr.Bool(d.Get("final").(bool)),
- QueryOptions: &scalr.VariableWriteQueryOptions{Force: scalr.Bool(d.Get("force").(bool))},
+ Key: ptr(d.Get("key").(string)),
+ Value: ptr(d.Get("value").(string)),
+ HCL: ptr(hcl),
+ Sensitive: ptr(d.Get("sensitive").(bool)),
+ Description: ptr(d.Get("description").(string)),
+ Final: ptr(d.Get("final").(bool)),
+ QueryOptions: &scalr.VariableWriteQueryOptions{Force: ptr(d.Get("force").(bool))},
}
log.Printf("[DEBUG] Update variable: %s", d.Id())
diff --git a/internal/provider/resource_scalr_vcs_provider.go b/internal/provider/resource_scalr_vcs_provider.go
index 1778d589..ee4c4460 100644
--- a/internal/provider/resource_scalr_vcs_provider.go
+++ b/internal/provider/resource_scalr_vcs_provider.go
@@ -117,12 +117,12 @@ func resourceScalrVcsProviderCreate(ctx context.Context, d *schema.ResourceData,
// Get the url
if url, ok := d.GetOk("url"); ok {
- options.Url = scalr.String(url.(string))
+ options.Url = ptr(url.(string))
}
// Get the username
if username, ok := d.GetOk("username"); ok {
- options.Username = scalr.String(username.(string))
+ options.Username = ptr(username.(string))
}
if agentPoolID, ok := d.GetOk("agent_pool_id"); ok {
@@ -132,15 +132,15 @@ func resourceScalrVcsProviderCreate(ctx context.Context, d *schema.ResourceData,
}
if draftPRsRunEnabled, ok := d.GetOk("draft_pr_runs_enabled"); ok {
- options.DraftPrRunsEnabled = scalr.Bool(draftPRsRunEnabled.(bool))
+ options.DraftPrRunsEnabled = ptr(draftPRsRunEnabled.(bool))
}
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- options.IsShared = scalr.Bool(true)
+ options.IsShared = ptr(true)
} else if len(environments) > 0 {
- options.IsShared = scalr.Bool(false)
+ options.IsShared = ptr(false)
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
if env.(string) == "*" {
@@ -206,17 +206,17 @@ func resourceScalrVcsProviderUpdate(ctx context.Context, d *schema.ResourceData,
scalrClient := meta.(*scalr.Client)
// Create a new options' struct.
options := scalr.VcsProviderUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
- Token: scalr.String(d.Get("token").(string)),
+ Name: ptr(d.Get("name").(string)),
+ Token: ptr(d.Get("token").(string)),
}
if url, ok := d.GetOk("url"); ok {
- options.Url = scalr.String(url.(string))
+ options.Url = ptr(url.(string))
}
// Get the username
if username, ok := d.GetOk("username"); ok {
- options.Username = scalr.String(username.(string))
+ options.Username = ptr(username.(string))
}
if agentPoolID, ok := d.GetOk("agent_pool_id"); ok {
@@ -226,16 +226,16 @@ func resourceScalrVcsProviderUpdate(ctx context.Context, d *schema.ResourceData,
}
if d.HasChange("draft_pr_runs_enabled") {
- options.DraftPrRunsEnabled = scalr.Bool(d.Get("draft_pr_runs_enabled").(bool))
+ options.DraftPrRunsEnabled = ptr(d.Get("draft_pr_runs_enabled").(bool))
}
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- options.IsShared = scalr.Bool(true)
+ options.IsShared = ptr(true)
options.Environments = make([]*scalr.Environment, 0)
} else {
- options.IsShared = scalr.Bool(false)
+ options.IsShared = ptr(false)
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
if env.(string) == "*" {
@@ -248,7 +248,7 @@ func resourceScalrVcsProviderUpdate(ctx context.Context, d *schema.ResourceData,
options.Environments = environmentValues
}
} else {
- options.IsShared = scalr.Bool(true)
+ options.IsShared = ptr(true)
options.Environments = make([]*scalr.Environment, 0)
}
diff --git a/internal/provider/resource_scalr_webhook.go b/internal/provider/resource_scalr_webhook.go
index cf6e5457..c914db29 100644
--- a/internal/provider/resource_scalr_webhook.go
+++ b/internal/provider/resource_scalr_webhook.go
@@ -185,22 +185,22 @@ func createWebhook(ctx context.Context, d *schema.ResourceData, scalrClient *sca
options := scalr.WebhookIntegrationCreateOptions{
Name: &name,
- Url: scalr.String(d.Get("url").(string)),
+ Url: ptr(d.Get("url").(string)),
Account: &scalr.Account{ID: accountId},
Events: eventDefinitions,
- Enabled: scalr.Bool(d.Get("enabled").(bool)),
- Timeout: scalr.Int(d.Get("timeout").(int)),
- MaxAttempts: scalr.Int(d.Get("max_attempts").(int)),
+ Enabled: ptr(d.Get("enabled").(bool)),
+ Timeout: ptr(d.Get("timeout").(int)),
+ MaxAttempts: ptr(d.Get("max_attempts").(int)),
}
if secretKey, ok := d.GetOk("secret_key"); ok {
- options.SecretKey = scalr.String(secretKey.(string))
+ options.SecretKey = ptr(secretKey.(string))
}
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- options.IsShared = scalr.Bool(true)
+ options.IsShared = ptr(true)
} else if len(environments) > 0 {
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
@@ -309,27 +309,27 @@ func updateWebhook(ctx context.Context, d *schema.ResourceData, scalrClient *sca
options := scalr.WebhookIntegrationUpdateOptions{}
if d.HasChange("name") {
- options.Name = scalr.String(d.Get("name").(string))
+ options.Name = ptr(d.Get("name").(string))
}
if d.HasChange("url") {
- options.Url = scalr.String(d.Get("url").(string))
+ options.Url = ptr(d.Get("url").(string))
}
if d.HasChange("enabled") {
- options.Enabled = scalr.Bool(d.Get("enabled").(bool))
+ options.Enabled = ptr(d.Get("enabled").(bool))
}
if d.HasChange("secret_key") {
- options.SecretKey = scalr.String(d.Get("secret_key").(string))
+ options.SecretKey = ptr(d.Get("secret_key").(string))
}
if d.HasChange("timeout") {
- options.Timeout = scalr.Int(d.Get("timeout").(int))
+ options.Timeout = ptr(d.Get("timeout").(int))
}
if d.HasChange("max_attempts") {
- options.MaxAttempts = scalr.Int(d.Get("max_attempts").(int))
+ options.MaxAttempts = ptr(d.Get("max_attempts").(int))
}
if d.HasChange("header") {
@@ -345,10 +345,10 @@ func updateWebhook(ctx context.Context, d *schema.ResourceData, scalrClient *sca
if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
- options.IsShared = scalr.Bool(true)
+ options.IsShared = ptr(true)
options.Environments = make([]*scalr.Environment, 0)
} else {
- options.IsShared = scalr.Bool(false)
+ options.IsShared = ptr(false)
environmentValues := make([]*scalr.Environment, 0)
for _, env := range environments {
if env.(string) == "*" {
@@ -361,7 +361,7 @@ func updateWebhook(ctx context.Context, d *schema.ResourceData, scalrClient *sca
options.Environments = environmentValues
}
} else {
- options.IsShared = scalr.Bool(false)
+ options.IsShared = ptr(false)
options.Environments = make([]*scalr.Environment, 0)
}
diff --git a/internal/provider/resource_scalr_workspace.go b/internal/provider/resource_scalr_workspace.go
index 46da0d79..3e5cf486 100644
--- a/internal/provider/resource_scalr_workspace.go
+++ b/internal/provider/resource_scalr_workspace.go
@@ -400,51 +400,51 @@ func resourceScalrWorkspaceCreate(ctx context.Context, d *schema.ResourceData, m
// Create a new options struct.
options := scalr.WorkspaceCreateOptions{
- Name: scalr.String(name),
- AutoApply: scalr.Bool(d.Get("auto_apply").(bool)),
- ForceLatestRun: scalr.Bool(d.Get("force_latest_run").(bool)),
- DeletionProtectionEnabled: scalr.Bool(d.Get("deletion_protection_enabled").(bool)),
+ Name: ptr(name),
+ AutoApply: ptr(d.Get("auto_apply").(bool)),
+ ForceLatestRun: ptr(d.Get("force_latest_run").(bool)),
+ DeletionProtectionEnabled: ptr(d.Get("deletion_protection_enabled").(bool)),
Environment: &scalr.Environment{ID: environmentID},
Hooks: &scalr.HooksOptions{},
}
// Process all configured options.
if operations, ok := d.GetOk("operations"); ok {
- options.Operations = scalr.Bool(operations.(bool))
+ options.Operations = ptr(operations.(bool))
}
if executionMode, ok := d.GetOk("execution_mode"); ok {
- options.ExecutionMode = scalr.WorkspaceExecutionModePtr(
+ options.ExecutionMode = ptr(
scalr.WorkspaceExecutionMode(executionMode.(string)),
)
}
if autoQueueRunsI, ok := d.GetOk("auto_queue_runs"); ok {
- options.AutoQueueRuns = scalr.AutoQueueRunsModePtr(
+ options.AutoQueueRuns = ptr(
scalr.WorkspaceAutoQueueRuns(autoQueueRunsI.(string)),
)
}
if workspaceEnvironmentTypeI, ok := d.GetOk("type"); ok {
- options.EnvironmentType = scalr.WorkspaceEnvironmentTypePtr(
+ options.EnvironmentType = ptr(
scalr.WorkspaceEnvironmentType(workspaceEnvironmentTypeI.(string)),
)
}
if tfVersion, ok := d.GetOk("terraform_version"); ok {
- options.TerraformVersion = scalr.String(tfVersion.(string))
+ options.TerraformVersion = ptr(tfVersion.(string))
}
if iacPlatform, ok := d.GetOk("iac_platform"); ok {
- options.IacPlatform = scalr.WorkspaceIaCPlatformPtr(scalr.WorkspaceIaCPlatform(iacPlatform.(string)))
+ options.IacPlatform = ptr(scalr.WorkspaceIaCPlatform(iacPlatform.(string)))
}
if workingDir, ok := d.GetOk("working_directory"); ok {
- options.WorkingDirectory = scalr.String(workingDir.(string))
+ options.WorkingDirectory = ptr(workingDir.(string))
}
if runOperationTimeout, ok := d.GetOk("run_operation_timeout"); ok {
- options.RunOperationTimeout = scalr.Int(runOperationTimeout.(int))
+ options.RunOperationTimeout = ptr(runOperationTimeout.(int))
}
if v, ok := d.GetOk("module_version_id"); ok {
@@ -472,17 +472,17 @@ func resourceScalrWorkspaceCreate(ctx context.Context, d *schema.ResourceData, m
}
options.VCSRepo = &scalr.WorkspaceVCSRepoOptions{
- Identifier: scalr.String(vcsRepo["identifier"].(string)),
- Path: scalr.String(vcsRepo["path"].(string)),
+ Identifier: ptr(vcsRepo["identifier"].(string)),
+ Path: ptr(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
- TriggerPatterns: scalr.String(vcsRepo["trigger_patterns"].(string)),
- DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
- IngressSubmodules: scalr.Bool(vcsRepo["ingress_submodules"].(bool)),
+ TriggerPatterns: ptr(vcsRepo["trigger_patterns"].(string)),
+ DryRunsEnabled: ptr(vcsRepo["dry_runs_enabled"].(bool)),
+ IngressSubmodules: ptr(vcsRepo["ingress_submodules"].(bool)),
}
// Only set the branch if one is configured.
if branch, ok := vcsRepo["branch"].(string); ok && branch != "" {
- options.VCSRepo.Branch = scalr.String(branch)
+ options.VCSRepo.Branch = ptr(branch)
}
}
@@ -492,11 +492,11 @@ func resourceScalrWorkspaceCreate(ctx context.Context, d *schema.ResourceData, m
hooks := v.([]interface{})[0].(map[string]interface{})
options.Hooks = &scalr.HooksOptions{
- PreInit: scalr.String(hooks["pre_init"].(string)),
- PrePlan: scalr.String(hooks["pre_plan"].(string)),
- PostPlan: scalr.String(hooks["post_plan"].(string)),
- PreApply: scalr.String(hooks["pre_apply"].(string)),
- PostApply: scalr.String(hooks["post_apply"].(string)),
+ PreInit: ptr(hooks["pre_init"].(string)),
+ PrePlan: ptr(hooks["pre_plan"].(string)),
+ PostPlan: ptr(hooks["post_plan"].(string)),
+ PreApply: ptr(hooks["pre_apply"].(string)),
+ PostApply: ptr(hooks["post_apply"].(string)),
}
}
}
@@ -534,7 +534,7 @@ func resourceScalrWorkspaceCreate(ctx context.Context, d *schema.ResourceData, m
ProviderConfiguration: &scalr.ProviderConfiguration{ID: pcfg["id"].(string)},
}
if alias, ok := pcfg["alias"]; ok && len(alias.(string)) > 0 {
- createLinkOption.Alias = scalr.String(alias.(string))
+ createLinkOption.Alias = ptr(alias.(string))
}
_, err := scalrClient.ProviderConfigurationLinks.Create(
ctx, workspace.ID, createLinkOption,
@@ -692,48 +692,48 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m
d.HasChange("type") {
// Create a new options struct.
options := scalr.WorkspaceUpdateOptions{
- Name: scalr.String(d.Get("name").(string)),
- AutoApply: scalr.Bool(d.Get("auto_apply").(bool)),
- ForceLatestRun: scalr.Bool(d.Get("force_latest_run").(bool)),
- DeletionProtectionEnabled: scalr.Bool(d.Get("deletion_protection_enabled").(bool)),
+ Name: ptr(d.Get("name").(string)),
+ AutoApply: ptr(d.Get("auto_apply").(bool)),
+ ForceLatestRun: ptr(d.Get("force_latest_run").(bool)),
+ DeletionProtectionEnabled: ptr(d.Get("deletion_protection_enabled").(bool)),
Hooks: &scalr.HooksOptions{
- PreInit: scalr.String(""),
- PrePlan: scalr.String(""),
- PostPlan: scalr.String(""),
- PreApply: scalr.String(""),
- PostApply: scalr.String(""),
+ PreInit: ptr(""),
+ PrePlan: ptr(""),
+ PostPlan: ptr(""),
+ PreApply: ptr(""),
+ PostApply: ptr(""),
},
}
// Process all configured options.
if operations, ok := d.GetOk("operations"); ok {
- options.Operations = scalr.Bool(operations.(bool))
+ options.Operations = ptr(operations.(bool))
}
if executionMode, ok := d.GetOk("execution_mode"); ok {
- options.ExecutionMode = scalr.WorkspaceExecutionModePtr(
+ options.ExecutionMode = ptr(
scalr.WorkspaceExecutionMode(executionMode.(string)),
)
}
if autoQueueRunsI, ok := d.GetOk("auto_queue_runs"); ok {
- options.AutoQueueRuns = scalr.AutoQueueRunsModePtr(
+ options.AutoQueueRuns = ptr(
scalr.WorkspaceAutoQueueRuns(autoQueueRunsI.(string)),
)
}
if workspaceEnvironmentTypeI, ok := d.GetOk("type"); ok {
- options.EnvironmentType = scalr.WorkspaceEnvironmentTypePtr(
+ options.EnvironmentType = ptr(
scalr.WorkspaceEnvironmentType(workspaceEnvironmentTypeI.(string)),
)
}
if tfVersion, ok := d.GetOk("terraform_version"); ok {
- options.TerraformVersion = scalr.String(tfVersion.(string))
+ options.TerraformVersion = ptr(tfVersion.(string))
}
if iacPlatform, ok := d.GetOk("iac_platform"); ok {
- options.IacPlatform = scalr.WorkspaceIaCPlatformPtr(scalr.WorkspaceIaCPlatform(iacPlatform.(string)))
+ options.IacPlatform = ptr(scalr.WorkspaceIaCPlatform(iacPlatform.(string)))
}
if v, ok := d.Get("var_files").([]interface{}); ok {
@@ -744,10 +744,10 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m
options.VarFiles = varFiles
}
- options.WorkingDirectory = scalr.String(d.Get("working_directory").(string))
+ options.WorkingDirectory = ptr(d.Get("working_directory").(string))
if runOperationTimeout, ok := d.GetOk("run_operation_timeout"); ok {
- options.RunOperationTimeout = scalr.Int(runOperationTimeout.(int))
+ options.RunOperationTimeout = ptr(runOperationTimeout.(int))
}
if vcsProviderId, ok := d.GetOk("vcs_provider_id"); ok {
@@ -771,13 +771,13 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m
}
options.VCSRepo = &scalr.WorkspaceVCSRepoOptions{
- Identifier: scalr.String(vcsRepo["identifier"].(string)),
- Branch: scalr.String(vcsRepo["branch"].(string)),
- Path: scalr.String(vcsRepo["path"].(string)),
+ Identifier: ptr(vcsRepo["identifier"].(string)),
+ Branch: ptr(vcsRepo["branch"].(string)),
+ Path: ptr(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
- TriggerPatterns: scalr.String(vcsRepo["trigger_patterns"].(string)),
- DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
- IngressSubmodules: scalr.Bool(vcsRepo["ingress_submodules"].(bool)),
+ TriggerPatterns: ptr(vcsRepo["trigger_patterns"].(string)),
+ DryRunsEnabled: ptr(vcsRepo["dry_runs_enabled"].(bool)),
+ IngressSubmodules: ptr(vcsRepo["ingress_submodules"].(bool)),
}
}
@@ -787,11 +787,11 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m
hooks := v.([]interface{})[0].(map[string]interface{})
options.Hooks = &scalr.HooksOptions{
- PreInit: scalr.String(hooks["pre_init"].(string)),
- PrePlan: scalr.String(hooks["pre_plan"].(string)),
- PostPlan: scalr.String(hooks["post_plan"].(string)),
- PreApply: scalr.String(hooks["pre_apply"].(string)),
- PostApply: scalr.String(hooks["post_apply"].(string)),
+ PreInit: ptr(hooks["pre_init"].(string)),
+ PrePlan: ptr(hooks["pre_plan"].(string)),
+ PostPlan: ptr(hooks["post_plan"].(string)),
+ PreApply: ptr(hooks["pre_apply"].(string)),
+ PostApply: ptr(hooks["post_apply"].(string)),
}
}
}
@@ -838,7 +838,7 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m
ProviderConfiguration: &scalr.ProviderConfiguration{ID: configLink["id"].(string)},
}
if v, ok := configLink["alias"]; ok && len(v.(string)) > 0 {
- linkCreateOption.Alias = scalr.String(v.(string))
+ linkCreateOption.Alias = ptr(v.(string))
mapID = mapID + v.(string)
}
expectedLinks[mapID] = linkCreateOption
diff --git a/internal/provider/resource_scalr_workspace_run_schedule.go b/internal/provider/resource_scalr_workspace_run_schedule.go
index 0e8d48e2..311f3d69 100644
--- a/internal/provider/resource_scalr_workspace_run_schedule.go
+++ b/internal/provider/resource_scalr_workspace_run_schedule.go
@@ -58,10 +58,10 @@ func resourceScalrWorkspaceRunScheduleCreate(ctx context.Context, d *schema.Reso
options := scalr.WorkspaceRunScheduleOptions{}
if applySchedule, ok := d.GetOk("apply_schedule"); ok {
- options.ApplySchedule = scalr.String(applySchedule.(string))
+ options.ApplySchedule = ptr(applySchedule.(string))
}
if destroySchedule, ok := d.GetOk("destroy_schedule"); ok {
- options.DestroySchedule = scalr.String(destroySchedule.(string))
+ options.DestroySchedule = ptr(destroySchedule.(string))
}
applySchedule := ""
@@ -124,10 +124,10 @@ func resourceScalrWorkspaceRunScheduleUpdate(ctx context.Context, d *schema.Reso
options := scalr.WorkspaceRunScheduleOptions{}
if applySchedule, ok := d.GetOk("apply_schedule"); ok {
- options.ApplySchedule = scalr.String(applySchedule.(string))
+ options.ApplySchedule = ptr(applySchedule.(string))
}
if destroySchedule, ok := d.GetOk("destroy_schedule"); ok {
- options.DestroySchedule = scalr.String(destroySchedule.(string))
+ options.DestroySchedule = ptr(destroySchedule.(string))
}
applySchedule := ""
From ad39c2ac908a2e9f362cfb0e6ac4f71be24dcc81 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Thu, 28 Nov 2024 15:18:01 +0200
Subject: [PATCH 21/26] SCALRCORE-26654 Add tag resource
---
internal/provider/{resource_scalr_tag.go => tag_resource.go} | 0
.../provider/{resource_scalr_tag_test.go => tag_resource_test.go} | 0
2 files changed, 0 insertions(+), 0 deletions(-)
rename internal/provider/{resource_scalr_tag.go => tag_resource.go} (100%)
rename internal/provider/{resource_scalr_tag_test.go => tag_resource_test.go} (100%)
diff --git a/internal/provider/resource_scalr_tag.go b/internal/provider/tag_resource.go
similarity index 100%
rename from internal/provider/resource_scalr_tag.go
rename to internal/provider/tag_resource.go
diff --git a/internal/provider/resource_scalr_tag_test.go b/internal/provider/tag_resource_test.go
similarity index 100%
rename from internal/provider/resource_scalr_tag_test.go
rename to internal/provider/tag_resource_test.go
From 10ef9f8a911fa8239b2885dff8f018a02339814b Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Sun, 1 Dec 2024 12:44:20 +0200
Subject: [PATCH 22/26] SCALRCORE-26654 Add tag resource
---
internal/framework/defaults/account.go | 54 ++++
internal/framework/resource.go | 32 +++
.../data_source_scalr_access_policy_test.go | 4 +-
.../data_source_scalr_agent_pool_test.go | 8 +-
.../data_source_scalr_current_account.go | 4 +-
.../data_source_scalr_current_account_test.go | 8 +-
.../data_source_scalr_current_run_test.go | 4 +-
.../data_source_scalr_environment_test.go | 4 +-
.../data_source_scalr_environments_test.go | 4 +-
...rce_scalr_event_bridge_integration_test.go | 4 +-
.../data_source_scalr_iam_team_test.go | 4 +-
.../data_source_scalr_iam_user_test.go | 4 +-
.../data_source_scalr_module_version_test.go | 4 +-
.../data_source_scalr_module_versions_test.go | 2 +-
.../data_source_scalr_policy_group_test.go | 4 +-
...ource_scalr_provider_configuration_test.go | 4 +-
...urce_scalr_provider_configurations_test.go | 4 +-
.../provider/data_source_scalr_role_test.go | 4 +-
.../data_source_scalr_service_account_test.go | 4 +-
.../data_source_scalr_ssh_key_test.go | 4 +-
.../data_source_scalr_variable_test.go | 4 +-
.../data_source_scalr_variables_test.go | 4 +-
.../data_source_scalr_vcs_provider_test.go | 4 +-
.../data_source_scalr_webhook_test.go | 4 +-
.../data_source_scalr_workspace_ids_test.go | 8 +-
.../data_source_scalr_workspace_test.go | 4 +-
.../data_source_scalr_workspaces_test.go | 4 +-
internal/provider/helpers.go | 7 +-
internal/provider/provider.go | 4 +-
internal/provider/provider_sdk.go | 1 -
internal/provider/provider_sdk_test.go | 14 +-
internal/provider/provider_test.go | 8 +-
.../resource_scalr_access_policy_test.go | 32 +--
...resource_scalr_account_allowed_ips_test.go | 20 +-
.../resource_scalr_agent_pool_test.go | 24 +-
.../resource_scalr_agent_pool_token_test.go | 18 +-
.../resource_scalr_environment_test.go | 26 +-
...rce_scalr_event_bridge_integration_test.go | 4 +-
.../provider/resource_scalr_iam_team_test.go | 24 +-
.../provider/resource_scalr_module_test.go | 12 +-
...esource_scalr_policy_group_linkage_test.go | 12 +-
.../resource_scalr_policy_group_test.go | 22 +-
...alr_provider_configuration_default_test.go | 12 +-
...ource_scalr_provider_configuration_test.go | 56 ++---
internal/provider/resource_scalr_role_test.go | 24 +-
.../resource_scalr_run_schedule_rule_test.go | 22 +-
.../resource_scalr_run_triggers_test.go | 12 +-
.../resource_scalr_service_account_test.go | 20 +-
...source_scalr_service_account_token_test.go | 14 +-
.../resource_scalr_slack_integration_test.go | 2 +-
.../provider/resource_scalr_ssh_key_test.go | 22 +-
.../provider/resource_scalr_variable_test.go | 34 +--
.../resource_scalr_vcs_provider_test.go | 20 +-
.../provider/resource_scalr_webhook_test.go | 8 +-
...ource_scalr_workspace_run_schedule_test.go | 12 +-
.../provider/resource_scalr_workspace_test.go | 56 ++---
internal/provider/tag_data_source.go | 10 +-
internal/provider/tag_resource.go | 234 ++++++++++++------
internal/provider/tag_resource_test.go | 22 +-
59 files changed, 584 insertions(+), 420 deletions(-)
create mode 100644 internal/framework/defaults/account.go
create mode 100644 internal/framework/resource.go
diff --git a/internal/framework/defaults/account.go b/internal/framework/defaults/account.go
new file mode 100644
index 00000000..c981899d
--- /dev/null
+++ b/internal/framework/defaults/account.go
@@ -0,0 +1,54 @@
+package defaults
+
+import (
+ "context"
+ "fmt"
+ "os"
+
+ "github.com/hashicorp/terraform-plugin-framework/diag"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+)
+
+const CurrentAccountIDEnvVar = "SCALR_ACCOUNT_ID"
+
+func GetDefaultScalrAccountID() (string, diag.Diagnostics) {
+ var diags diag.Diagnostics
+ v := os.Getenv(CurrentAccountIDEnvVar)
+ if v == "" {
+ diags.AddError(
+ "Cannot infer current account",
+ fmt.Sprintf(
+ "Default value for `account_id` could not be computed."+
+ "\nIf you are using Scalr Provider for local runs, please set the attribute in resources explicitly,"+
+ "\nor export `%s` environment variable prior the run.",
+ CurrentAccountIDEnvVar,
+ ),
+ )
+ }
+ return v, diags
+}
+
+// AccountIDRequired returns a default account id value handler.
+//
+// Use AccountIDRequired when a default value for account id must be set.
+func AccountIDRequired() defaults.String {
+ return accountIDRequiredDefault{}
+}
+
+// accountIDRequiredDefault implements defaults.String
+type accountIDRequiredDefault struct{}
+
+func (r accountIDRequiredDefault) Description(_ context.Context) string {
+ return "value defaults to current Scalr account id"
+}
+
+func (r accountIDRequiredDefault) MarkdownDescription(ctx context.Context) string {
+ return r.Description(ctx)
+}
+
+func (r accountIDRequiredDefault) DefaultString(_ context.Context, _ defaults.StringRequest, resp *defaults.StringResponse) {
+ s, diags := GetDefaultScalrAccountID()
+ resp.Diagnostics.Append(diags...)
+ resp.PlanValue = types.StringValue(s)
+}
diff --git a/internal/framework/resource.go b/internal/framework/resource.go
new file mode 100644
index 00000000..f186eebc
--- /dev/null
+++ b/internal/framework/resource.go
@@ -0,0 +1,32 @@
+package framework
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+
+ "github.com/scalr/go-scalr"
+)
+
+type ResourceWithScalrClient struct {
+ Client *scalr.Client
+}
+
+func (r *ResourceWithScalrClient) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
+ if req.ProviderData == nil {
+ return
+ }
+
+ c, ok := req.ProviderData.(*scalr.Client)
+ if !ok {
+ resp.Diagnostics.AddError(
+ "Unexpected Resource Configure Type",
+ fmt.Sprintf("Expected *scalr.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
+ )
+
+ return
+ }
+
+ r.Client = c
+}
diff --git a/internal/provider/data_source_scalr_access_policy_test.go b/internal/provider/data_source_scalr_access_policy_test.go
index fab63809..8ef037f4 100644
--- a/internal/provider/data_source_scalr_access_policy_test.go
+++ b/internal/provider/data_source_scalr_access_policy_test.go
@@ -10,8 +10,8 @@ import (
func TestAccScalrAccessPolicyDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyDataSourceConfig(),
diff --git a/internal/provider/data_source_scalr_agent_pool_test.go b/internal/provider/data_source_scalr_agent_pool_test.go
index 6e7816c1..ced121fe 100644
--- a/internal/provider/data_source_scalr_agent_pool_test.go
+++ b/internal/provider/data_source_scalr_agent_pool_test.go
@@ -10,8 +10,8 @@ import (
func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_agent_pool test {}`,
@@ -60,8 +60,8 @@ func TestAccScalrAgentPoolDataSource_basic(t *testing.T) {
}
func TestAccScalrAgentPoolDataSource_basic_env(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolEnvDataSourceConfig(),
diff --git a/internal/provider/data_source_scalr_current_account.go b/internal/provider/data_source_scalr_current_account.go
index fdf2f28b..6fd865d5 100644
--- a/internal/provider/data_source_scalr_current_account.go
+++ b/internal/provider/data_source_scalr_current_account.go
@@ -8,6 +8,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework/defaults"
)
func dataSourceScalrCurrentAccount() *schema.Resource {
@@ -36,7 +38,7 @@ func dataSourceScalrCurrentAccountRead(ctx context.Context, d *schema.ResourceDa
accID, ok := getDefaultScalrAccountID()
if !ok {
- log.Printf("[DEBUG] %s is not set", currentAccountIDEnvVar)
+ log.Printf("[DEBUG] %s is not set", defaults.CurrentAccountIDEnvVar)
return diag.Errorf("Current account is not set")
}
diff --git a/internal/provider/data_source_scalr_current_account_test.go b/internal/provider/data_source_scalr_current_account_test.go
index be603aec..73ce7f9b 100644
--- a/internal/provider/data_source_scalr_current_account_test.go
+++ b/internal/provider/data_source_scalr_current_account_test.go
@@ -6,17 +6,19 @@ import (
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework/defaults"
)
func TestAccCurrentAccount_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{
{
PreConfig: func() {
- _ = os.Unsetenv(currentAccountIDEnvVar)
+ _ = os.Unsetenv(defaults.CurrentAccountIDEnvVar)
},
Config: testAccCurrentAccountDataSourceConfig(),
PlanOnly: true,
@@ -24,7 +26,7 @@ func TestAccCurrentAccount_basic(t *testing.T) {
},
{
PreConfig: func() {
- _ = os.Setenv(currentAccountIDEnvVar, defaultAccount)
+ _ = os.Setenv(defaults.CurrentAccountIDEnvVar, defaultAccount)
},
Config: testAccCurrentAccountDataSourceConfig(),
PlanOnly: true,
diff --git a/internal/provider/data_source_scalr_current_run_test.go b/internal/provider/data_source_scalr_current_run_test.go
index d3ba187c..1061c0f9 100644
--- a/internal/provider/data_source_scalr_current_run_test.go
+++ b/internal/provider/data_source_scalr_current_run_test.go
@@ -15,7 +15,7 @@ func TestAccCurrentRun_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{
{
@@ -46,7 +46,7 @@ func TestAccCurrentRun_basic(t *testing.T) {
func launchRun(environmentName, workspaceName string) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
options := GetEnvironmentByNameOptions{
Name: &environmentName,
diff --git a/internal/provider/data_source_scalr_environment_test.go b/internal/provider/data_source_scalr_environment_test.go
index 87f6556f..2c703bcf 100644
--- a/internal/provider/data_source_scalr_environment_test.go
+++ b/internal/provider/data_source_scalr_environment_test.go
@@ -21,8 +21,8 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
cuttedRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_environment test {}`,
diff --git a/internal/provider/data_source_scalr_environments_test.go b/internal/provider/data_source_scalr_environments_test.go
index f0d28cda..aae3965c 100644
--- a/internal/provider/data_source_scalr_environments_test.go
+++ b/internal/provider/data_source_scalr_environments_test.go
@@ -11,8 +11,8 @@ func TestAccScalrEnvironmentsDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrEnvironmentsDataSourceConfigBasic(rInt),
diff --git a/internal/provider/data_source_scalr_event_bridge_integration_test.go b/internal/provider/data_source_scalr_event_bridge_integration_test.go
index 9ef6ac13..210562be 100644
--- a/internal/provider/data_source_scalr_event_bridge_integration_test.go
+++ b/internal/provider/data_source_scalr_event_bridge_integration_test.go
@@ -16,8 +16,8 @@ func TestAccScalrEventBridgeIntegrationDataSource_basic(t *testing.T) {
t.Skip("Please set AWS_EVENT_BRIDGE_ACCOUNT_ID, AWS_EVENT_BRIDGE_REGION env variables to run this test.")
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_event_bridge test {}`,
diff --git a/internal/provider/data_source_scalr_iam_team_test.go b/internal/provider/data_source_scalr_iam_team_test.go
index 56cd450a..160e11f8 100644
--- a/internal/provider/data_source_scalr_iam_team_test.go
+++ b/internal/provider/data_source_scalr_iam_team_test.go
@@ -12,8 +12,8 @@ func TestAccScalrIamTeamDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_iam_team test {}`,
diff --git a/internal/provider/data_source_scalr_iam_user_test.go b/internal/provider/data_source_scalr_iam_user_test.go
index 429e01ba..2f956a6a 100644
--- a/internal/provider/data_source_scalr_iam_user_test.go
+++ b/internal/provider/data_source_scalr_iam_user_test.go
@@ -11,8 +11,8 @@ import (
func TestAccScalrIamUserDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_iam_user test {}`,
diff --git a/internal/provider/data_source_scalr_module_version_test.go b/internal/provider/data_source_scalr_module_version_test.go
index 772cc48e..e482d824 100644
--- a/internal/provider/data_source_scalr_module_version_test.go
+++ b/internal/provider/data_source_scalr_module_version_test.go
@@ -17,7 +17,7 @@ func TestAccModuleVersionDataSource_basic(t *testing.T) {
PreCheck: func() {
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccountModule(rInt),
@@ -55,7 +55,7 @@ func TestAccModuleVersionDataSource_basic(t *testing.T) {
func waitForModuleVersions(environmentName string) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
options := GetEnvironmentByNameOptions{
Name: &environmentName,
diff --git a/internal/provider/data_source_scalr_module_versions_test.go b/internal/provider/data_source_scalr_module_versions_test.go
index 1a0cb859..e3d4070a 100644
--- a/internal/provider/data_source_scalr_module_versions_test.go
+++ b/internal/provider/data_source_scalr_module_versions_test.go
@@ -16,7 +16,7 @@ func TestAccModuleVersionsDataSource_basic(t *testing.T) {
PreCheck: func() {
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_module_versions all_by_none {}`,
diff --git a/internal/provider/data_source_scalr_policy_group_test.go b/internal/provider/data_source_scalr_policy_group_test.go
index 63dd06fc..7101e961 100644
--- a/internal/provider/data_source_scalr_policy_group_test.go
+++ b/internal/provider/data_source_scalr_policy_group_test.go
@@ -20,7 +20,7 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupConfig(rInt),
@@ -103,7 +103,7 @@ func TestAccPolicyGroupDataSource_basic(t *testing.T) {
func waitForPolicyGroupFetch(name string) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
pgl, err := scalrClient.PolicyGroups.List(ctx, scalr.PolicyGroupListOptions{
Account: defaultAccount,
diff --git a/internal/provider/data_source_scalr_provider_configuration_test.go b/internal/provider/data_source_scalr_provider_configuration_test.go
index 2a9a8421..a1c6ecb9 100644
--- a/internal/provider/data_source_scalr_provider_configuration_test.go
+++ b/internal/provider/data_source_scalr_provider_configuration_test.go
@@ -11,8 +11,8 @@ import (
func TestAccScalrProviderConfigurationDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationDataSourceInitConfig, // depends_on works improperly with data sources
diff --git a/internal/provider/data_source_scalr_provider_configurations_test.go b/internal/provider/data_source_scalr_provider_configurations_test.go
index 5c43c28c..f5428453 100644
--- a/internal/provider/data_source_scalr_provider_configurations_test.go
+++ b/internal/provider/data_source_scalr_provider_configurations_test.go
@@ -10,8 +10,8 @@ import (
func TestAccScalrProviderConfigurationsDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationsDataSourceInitConfig, // depends_on works improperly with data sources
diff --git a/internal/provider/data_source_scalr_role_test.go b/internal/provider/data_source_scalr_role_test.go
index a2680d85..5c92eb0e 100644
--- a/internal/provider/data_source_scalr_role_test.go
+++ b/internal/provider/data_source_scalr_role_test.go
@@ -11,8 +11,8 @@ import (
func TestAccScalrRoleDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_role test_role {}`,
diff --git a/internal/provider/data_source_scalr_service_account_test.go b/internal/provider/data_source_scalr_service_account_test.go
index 4d0e48c5..6a2d30b4 100644
--- a/internal/provider/data_source_scalr_service_account_test.go
+++ b/internal/provider/data_source_scalr_service_account_test.go
@@ -13,8 +13,8 @@ func TestAccScalrServiceAccountDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_service_account test {}`,
diff --git a/internal/provider/data_source_scalr_ssh_key_test.go b/internal/provider/data_source_scalr_ssh_key_test.go
index ebd56a69..974b94f4 100644
--- a/internal/provider/data_source_scalr_ssh_key_test.go
+++ b/internal/provider/data_source_scalr_ssh_key_test.go
@@ -13,8 +13,8 @@ func TestAccScalrSSHKeyDataSource_basic(t *testing.T) {
rInt := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_ssh_key test {}`,
diff --git a/internal/provider/data_source_scalr_variable_test.go b/internal/provider/data_source_scalr_variable_test.go
index aab87727..08c30edd 100644
--- a/internal/provider/data_source_scalr_variable_test.go
+++ b/internal/provider/data_source_scalr_variable_test.go
@@ -11,8 +11,8 @@ import (
func TestAccScalrVariableDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_variable test {}`,
diff --git a/internal/provider/data_source_scalr_variables_test.go b/internal/provider/data_source_scalr_variables_test.go
index 7e835c2e..bb256918 100644
--- a/internal/provider/data_source_scalr_variables_test.go
+++ b/internal/provider/data_source_scalr_variables_test.go
@@ -14,8 +14,8 @@ import (
func TestAccScalrVariablesDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrVariablesDataSourceInitConfig, // depends_on works improperly with data sources
diff --git a/internal/provider/data_source_scalr_vcs_provider_test.go b/internal/provider/data_source_scalr_vcs_provider_test.go
index 7a02c122..c662452a 100644
--- a/internal/provider/data_source_scalr_vcs_provider_test.go
+++ b/internal/provider/data_source_scalr_vcs_provider_test.go
@@ -12,8 +12,8 @@ func TestAccScalrVcsProviderDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrVcsProviderDataSourceConfigAllFilters(rInt, githubToken),
diff --git a/internal/provider/data_source_scalr_webhook_test.go b/internal/provider/data_source_scalr_webhook_test.go
index beba20cb..4710e56f 100644
--- a/internal/provider/data_source_scalr_webhook_test.go
+++ b/internal/provider/data_source_scalr_webhook_test.go
@@ -16,8 +16,8 @@ func TestAccWebhookDataSource_basic(t *testing.T) {
cutRInt := strconv.Itoa(rInt)[:len(strconv.Itoa(rInt))-1]
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: `data scalr_webhook test {}`,
diff --git a/internal/provider/data_source_scalr_workspace_ids_test.go b/internal/provider/data_source_scalr_workspace_ids_test.go
index 3ab9ce20..b4af7440 100644
--- a/internal/provider/data_source_scalr_workspace_ids_test.go
+++ b/internal/provider/data_source_scalr_workspace_ids_test.go
@@ -11,8 +11,8 @@ func TestAccScalrWorkspaceIDsDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceIDsDataSourceConfigBasic(rInt),
@@ -43,8 +43,8 @@ func TestAccScalrWorkspaceIDsDataSource_wildcard(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceIDsDataSourceConfigWildcard(rInt),
diff --git a/internal/provider/data_source_scalr_workspace_test.go b/internal/provider/data_source_scalr_workspace_test.go
index 0ef8bd4b..1697bf20 100644
--- a/internal/provider/data_source_scalr_workspace_test.go
+++ b/internal/provider/data_source_scalr_workspace_test.go
@@ -12,8 +12,8 @@ func TestAccScalrWorkspaceDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceDataSourceMissingRequiredConfig,
diff --git a/internal/provider/data_source_scalr_workspaces_test.go b/internal/provider/data_source_scalr_workspaces_test.go
index 8800d9e5..b432d37a 100644
--- a/internal/provider/data_source_scalr_workspaces_test.go
+++ b/internal/provider/data_source_scalr_workspaces_test.go
@@ -11,8 +11,8 @@ func TestAccScalrWorkspacesDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspacesDataSourceConfigBasic(rInt),
diff --git a/internal/provider/helpers.go b/internal/provider/helpers.go
index a04b9658..a10d3916 100644
--- a/internal/provider/helpers.go
+++ b/internal/provider/helpers.go
@@ -8,11 +8,12 @@ import (
"os"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework/defaults"
)
const (
- currentAccountIDEnvVar = "SCALR_ACCOUNT_ID"
- dummyIdentifier = "-"
+ dummyIdentifier = "-"
)
type GetEnvironmentByNameOptions struct {
@@ -108,7 +109,7 @@ func InterfaceArrToTagRelationArr(arr []interface{}) []*scalr.TagRelation {
}
func getDefaultScalrAccountID() (string, bool) {
- if v := os.Getenv(currentAccountIDEnvVar); v != "" {
+ if v := os.Getenv(defaults.CurrentAccountIDEnvVar); v != "" {
return v, true
}
return "", false
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
index 36a07e08..596ca6cc 100644
--- a/internal/provider/provider.go
+++ b/internal/provider/provider.go
@@ -148,7 +148,9 @@ func (p *scalrProvider) Configure(ctx context.Context, req provider.ConfigureReq
}
func (p *scalrProvider) Resources(_ context.Context) []func() resource.Resource {
- return []func() resource.Resource{}
+ return []func() resource.Resource{
+ newTagResource,
+ }
}
func (p *scalrProvider) DataSources(_ context.Context) []func() datasource.DataSource {
diff --git a/internal/provider/provider_sdk.go b/internal/provider/provider_sdk.go
index 03ebb332..f0574d44 100644
--- a/internal/provider/provider_sdk.go
+++ b/internal/provider/provider_sdk.go
@@ -79,7 +79,6 @@ func Provider(v string) *schema.Provider {
"scalr_service_account": resourceScalrServiceAccount(),
"scalr_service_account_token": resourceScalrServiceAccountToken(),
"scalr_slack_integration": resourceScalrSlackIntegration(),
- "scalr_tag": resourceScalrTag(),
"scalr_variable": resourceScalrVariable(),
"scalr_vcs_provider": resourceScalrVcsProvider(),
"scalr_webhook": resourceScalrWebhook(),
diff --git a/internal/provider/provider_sdk_test.go b/internal/provider/provider_sdk_test.go
index 4e36c2d0..e52a28f5 100644
--- a/internal/provider/provider_sdk_test.go
+++ b/internal/provider/provider_sdk_test.go
@@ -9,10 +9,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework/defaults"
)
-var testAccProvider *schema.Provider
-var testAccProviderFactories map[string]func() (*schema.Provider, error)
+var testAccProviderSDK *schema.Provider
var noInstanceIdErr = fmt.Errorf("No instance ID is set")
var githubToken = os.Getenv("githubToken")
@@ -20,12 +21,7 @@ var githubToken = os.Getenv("githubToken")
var ctx = context.Background()
func init() {
- testAccProvider = Provider(testProviderVersion)
- testAccProviderFactories = map[string]func() (*schema.Provider, error){
- "scalr": func() (*schema.Provider, error) {
- return testAccProvider, nil
- },
- }
+ testAccProviderSDK = Provider(testProviderVersion)
}
func TestProvider(t *testing.T) {
@@ -48,7 +44,7 @@ func testAccPreCheck(t *testing.T) {
}
}
// Set env variable to allow `account_id` compute the default value
- _ = os.Setenv(currentAccountIDEnvVar, defaultAccount)
+ _ = os.Setenv(defaults.CurrentAccountIDEnvVar, defaultAccount)
}
func testVcsAccGithubTokenPreCheck(t *testing.T) {
diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go
index 34683811..d799553c 100644
--- a/internal/provider/provider_test.go
+++ b/internal/provider/provider_test.go
@@ -4,6 +4,7 @@ import (
"context"
"testing"
+ "github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
@@ -12,16 +13,19 @@ import (
const testProviderVersion = "test"
+var testAccProvider provider.Provider
+
func init() {
schema.DescriptionKind = schema.StringMarkdown
+ testAccProvider = New(testProviderVersion)()
}
func protoV5ProviderFactories(t *testing.T) map[string]func() (tfprotov5.ProviderServer, error) {
ctx := context.Background()
providers := []func() tfprotov5.ProviderServer{
- providerserver.NewProtocol5(New(testProviderVersion)()),
- Provider(testProviderVersion).GRPCProvider,
+ providerserver.NewProtocol5(testAccProvider),
+ testAccProviderSDK.GRPCProvider,
}
muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
diff --git a/internal/provider/resource_scalr_access_policy_test.go b/internal/provider/resource_scalr_access_policy_test.go
index 8f628607..6ddd6994 100644
--- a/internal/provider/resource_scalr_access_policy_test.go
+++ b/internal/provider/resource_scalr_access_policy_test.go
@@ -19,9 +19,9 @@ func TestAccScalrAccessPolicy_basic(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBasic(rInt),
@@ -44,8 +44,8 @@ func TestAccScalrAccessPolicy_bad_scope(t *testing.T) {
rg, _ := regexp.Compile(`scope.0.type must be one of \[workspace, environment, account], got: universe`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBadScope(),
@@ -59,8 +59,8 @@ func TestAccScalrAccessPolicy_bad_subject(t *testing.T) {
rg, _ := regexp.Compile(`subject.0.type must be one of \[user, team, service_account], got: grandpa`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBadSubject(),
@@ -75,9 +75,9 @@ func TestAccScalrAccessPolicy_update(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBasic(rInt),
@@ -119,9 +119,9 @@ func TestAccScalrAccessPolicy_import(t *testing.T) {
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAccessPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAccessPolicyBasic(rInt),
@@ -138,7 +138,7 @@ func TestAccScalrAccessPolicy_import(t *testing.T) {
func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -163,7 +163,7 @@ func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) r
func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
r, err := scalrClient.AccessPolicies.Read(ctx, ap.ID)
@@ -187,7 +187,7 @@ func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func()
}
func testAccCheckScalrAccessPolicyDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_access_policy" {
diff --git a/internal/provider/resource_scalr_account_allowed_ips_test.go b/internal/provider/resource_scalr_account_allowed_ips_test.go
index 42e9b079..f060414f 100644
--- a/internal/provider/resource_scalr_account_allowed_ips_test.go
+++ b/internal/provider/resource_scalr_account_allowed_ips_test.go
@@ -11,8 +11,8 @@ import (
func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0", "192.168.0.0/32"}),
@@ -30,8 +30,8 @@ func TestAccScalrAccountAllowedIps_basic(t *testing.T) {
func TestAccScalrAccountAllowedIps_update(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0"}),
@@ -56,8 +56,8 @@ func TestAccScalrAccountAllowedIps_update(t *testing.T) {
func TestAccScalrAccountAllowedIps_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12", "0.0.0.0/0"}),
@@ -75,8 +75,8 @@ func TestAccScalrAccountAllowedIps_import(t *testing.T) {
func TestAccScalrAccountAllowedIps_empty(t *testing.T) {
rg, _ := regexp.Compile(`Attribute allowed_ips requires 1 item minimum, but config has only 0`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{}),
@@ -89,8 +89,8 @@ func TestAccScalrAccountAllowedIps_empty(t *testing.T) {
func TestAccScalrAccountAllowedIps_invalid_CIDR(t *testing.T) {
rg, _ := regexp.Compile(`value is not a valid IPv4 network`)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrAccountAllowedIps([]string{"192.168.0.12/24"}),
diff --git a/internal/provider/resource_scalr_agent_pool_test.go b/internal/provider/resource_scalr_agent_pool_test.go
index be81737d..d713b734 100644
--- a/internal/provider/resource_scalr_agent_pool_test.go
+++ b/internal/provider/resource_scalr_agent_pool_test.go
@@ -16,9 +16,9 @@ func TestAccScalrAgentPool_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolBasic(rInt),
@@ -39,9 +39,9 @@ func TestAccScalrAgentPool_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolBasic(rInt),
@@ -68,9 +68,9 @@ func TestAccScalrAgentPool_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAgentPoolDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolBasic(rInt),
@@ -87,7 +87,7 @@ func TestAccScalrAgentPool_import(t *testing.T) {
func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -112,7 +112,7 @@ func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resou
func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
r, err := scalrClient.AgentPools.Read(ctx, pool.ID)
@@ -136,7 +136,7 @@ func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
}
func testAccCheckScalrAgentPoolDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_agent_pool" {
diff --git a/internal/provider/resource_scalr_agent_pool_token_test.go b/internal/provider/resource_scalr_agent_pool_token_test.go
index e364f7f6..d2e31097 100644
--- a/internal/provider/resource_scalr_agent_pool_token_test.go
+++ b/internal/provider/resource_scalr_agent_pool_token_test.go
@@ -21,9 +21,9 @@ func TestAccScalrAgentPoolToken_basic(t *testing.T) {
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolTokenBasic(pool),
@@ -46,9 +46,9 @@ func TestAccScalrAgentPoolToken_update(t *testing.T) {
token := &scalr.AccessToken{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrAgentPoolTokenDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrAgentPoolTokenBasic(pool),
@@ -71,7 +71,7 @@ func TestAccScalrAgentPoolToken_update(t *testing.T) {
func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, token *scalr.AccessToken) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -103,7 +103,7 @@ func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, t
func testAccCheckScalrAgentPoolTokenChangedOutside(token *scalr.AccessToken) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
r, err := scalrClient.AccessTokens.Update(
context.Background(),
@@ -152,7 +152,7 @@ func createPool(t *testing.T) scalr.AgentPool {
}
func testAccCheckScalrAgentPoolTokenDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_agent_pool_token" {
diff --git a/internal/provider/resource_scalr_environment_test.go b/internal/provider/resource_scalr_environment_test.go
index 545ca36e..962db8bf 100644
--- a/internal/provider/resource_scalr_environment_test.go
+++ b/internal/provider/resource_scalr_environment_test.go
@@ -14,9 +14,9 @@ func TestAccEnvironment_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrEnvironmentDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
Config: testAccEnvironmentConfig(rInt),
@@ -42,9 +42,9 @@ func TestAccEnvironment_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrEnvironmentDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
Config: testAccEnvironmentConfig(rInt),
@@ -79,9 +79,9 @@ func TestAccEnvironmentWithProviderConfigurations_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrEnvironmentDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrEnvironmentDestroy,
Steps: []resource.TestStep{
{
Config: testAccEnvironmentWithProviderConfigurationsConfig(rInt),
@@ -109,7 +109,7 @@ func TestAccEnvironmentWithProviderConfigurations_update(t *testing.T) {
}
func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_environment" {
@@ -131,7 +131,7 @@ func testAccCheckScalrEnvironmentDestroy(s *terraform.State) error {
func testAccCheckScalrEnvironmentExists(n string, environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -185,7 +185,7 @@ func testAccCheckScalrEnvironmentAttributesUpdate(environment *scalr.Environment
func testAccCheckScalrEnvironmentProviderConfigurations(environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
if len(environment.DefaultProviderConfigurations) != 1 {
return fmt.Errorf("Bad default provider configurations: %v", environment.DefaultProviderConfigurations)
@@ -202,7 +202,7 @@ func testAccCheckScalrEnvironmentProviderConfigurations(environment *scalr.Envir
}
func testAccCheckScalrEnvironmentProviderConfigurationsUpdate(environment *scalr.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
if len(environment.DefaultProviderConfigurations) != 1 {
return fmt.Errorf("Bad default provider configurations: %v", environment.DefaultProviderConfigurations)
diff --git a/internal/provider/resource_scalr_event_bridge_integration_test.go b/internal/provider/resource_scalr_event_bridge_integration_test.go
index 35de4f69..bd78640c 100644
--- a/internal/provider/resource_scalr_event_bridge_integration_test.go
+++ b/internal/provider/resource_scalr_event_bridge_integration_test.go
@@ -15,8 +15,8 @@ func TestAccEventBridgeIntegration_basic(t *testing.T) {
t.Skip("Please set AWS_EVENT_BRIDGE_ACCOUNT_ID, AWS_EVENT_BRIDGE_REGION env variables to run this test.")
}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrEventBridgeIntegrationConfig(AWSAccountId, region),
diff --git a/internal/provider/resource_scalr_iam_team_test.go b/internal/provider/resource_scalr_iam_team_test.go
index ce8deb87..f9726002 100644
--- a/internal/provider/resource_scalr_iam_team_test.go
+++ b/internal/provider/resource_scalr_iam_team_test.go
@@ -17,9 +17,9 @@ func TestAccScalrIamTeam_basic(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrIamTeamDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrIamTeamBasic(rInt),
@@ -44,9 +44,9 @@ func TestAccScalrIamTeam_update(t *testing.T) {
team := &scalr.Team{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrIamTeamDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrIamTeamBasic(rInt),
@@ -84,9 +84,9 @@ func TestAccScalrIamTeam_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrIamTeamDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrIamTeamDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrIamTeamBasic(rInt),
@@ -102,7 +102,7 @@ func TestAccScalrIamTeam_import(t *testing.T) {
func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -126,7 +126,7 @@ func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.Tes
func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
t, err := scalrClient.Teams.Read(ctx, team.ID)
if err != nil {
@@ -151,7 +151,7 @@ func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
}
func testAccCheckScalrIamTeamDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_iam_team" {
diff --git a/internal/provider/resource_scalr_module_test.go b/internal/provider/resource_scalr_module_test.go
index 0caf036b..6bcddc36 100644
--- a/internal/provider/resource_scalr_module_test.go
+++ b/internal/provider/resource_scalr_module_test.go
@@ -17,8 +17,8 @@ func TestAccScalrModule_basic(t *testing.T) {
t.Skip("Working on personal token but not working with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrModuleDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrModuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrModulesOnAllScopes(),
@@ -68,8 +68,8 @@ func TestAccScalrModule_import(t *testing.T) {
PreCheck: func() {
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrModuleDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrModuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrModule(),
@@ -85,7 +85,7 @@ func TestAccScalrModule_import(t *testing.T) {
func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[moduleId]
if !ok {
@@ -109,7 +109,7 @@ func testAccCheckScalrModuleExists(moduleId string, module *scalr.Module) resour
}
func testAccCheckScalrModuleDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_module" {
diff --git a/internal/provider/resource_scalr_policy_group_linkage_test.go b/internal/provider/resource_scalr_policy_group_linkage_test.go
index df8dc0f2..6aacb36f 100644
--- a/internal/provider/resource_scalr_policy_group_linkage_test.go
+++ b/internal/provider/resource_scalr_policy_group_linkage_test.go
@@ -20,8 +20,8 @@ func TestAccPolicyGroupLinkage_basic(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupLinkageBasicConfig(rInt),
@@ -56,8 +56,8 @@ func TestAccPolicyGroupLinkage_import(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckPolicyGroupLinkageDestroy,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupLinkageBasicConfig(rInt),
@@ -77,7 +77,7 @@ func testAccCheckPolicyGroupLinkageExists(
environment *scalr.Environment,
) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resID]
if !ok {
@@ -101,7 +101,7 @@ func testAccCheckPolicyGroupLinkageExists(
}
func testAccCheckPolicyGroupLinkageDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_policy_group_linkage" {
diff --git a/internal/provider/resource_scalr_policy_group_test.go b/internal/provider/resource_scalr_policy_group_test.go
index 126fe44b..c81f81b9 100644
--- a/internal/provider/resource_scalr_policy_group_test.go
+++ b/internal/provider/resource_scalr_policy_group_test.go
@@ -25,8 +25,8 @@ func TestAccPolicyGroup_basic(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckPolicyGroupDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupBasicConfig(rInt),
@@ -78,8 +78,8 @@ func TestAccPolicyGroup_update(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckPolicyGroupDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupBasicConfig(rInt),
@@ -169,8 +169,8 @@ func TestAccPolicyGroup_renamed(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckPolicyGroupDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupBasicConfig(rInt),
@@ -260,8 +260,8 @@ func TestAccPolicyGroup_import(t *testing.T) {
t.Skip("Works with personal token but does not work with github action token.")
testVcsAccGithubTokenPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckPolicyGroupDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckPolicyGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccPolicyGroupBasicConfig(rInt),
@@ -277,7 +277,7 @@ func TestAccPolicyGroup_import(t *testing.T) {
func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resID]
if !ok {
@@ -299,7 +299,7 @@ func testAccCheckPolicyGroupExists(resID string, policyGroup *scalr.PolicyGroup)
}
func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_policy_group" {
@@ -321,7 +321,7 @@ func testAccCheckPolicyGroupDestroy(s *terraform.State) error {
func testAccCheckPolicyGroupRename(policyGroup *scalr.PolicyGroup) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
_, err := scalrClient.PolicyGroups.Update(
context.Background(),
diff --git a/internal/provider/resource_scalr_provider_configuration_default_test.go b/internal/provider/resource_scalr_provider_configuration_default_test.go
index 6150f11c..45432f41 100644
--- a/internal/provider/resource_scalr_provider_configuration_default_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_default_test.go
@@ -16,8 +16,8 @@ func TestAccProviderConfigurationDefault_basic(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
Steps: []resource.TestStep{
{
Config: testAccProviderConfigurationDefaultBasicConfig(rInt),
@@ -38,8 +38,8 @@ func TestAccProviderConfigurationDefault_import(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationDefaultDestroy,
Steps: []resource.TestStep{
{
Config: testAccProviderConfigurationDefaultBasicConfig(rInt),
@@ -62,7 +62,7 @@ func testAccCheckProviderConfigurationDefaultExists(
return fmt.Errorf("Not found: %s", rn)
}
- client := testAccProvider.Meta().(*scalr.Client)
+ client := testAccProviderSDK.Meta().(*scalr.Client)
providerConfigurationID := rs.Primary.Attributes["provider_configuration_id"]
environmentID := rs.Primary.Attributes["environment_id"]
@@ -83,7 +83,7 @@ func testAccCheckProviderConfigurationDefaultExists(
}
func testAccCheckProviderConfigurationDefaultDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_provider_configuration_default" {
diff --git a/internal/provider/resource_scalr_provider_configuration_test.go b/internal/provider/resource_scalr_provider_configuration_test.go
index 055bb688..a7fb9b2a 100644
--- a/internal/provider/resource_scalr_provider_configuration_test.go
+++ b/internal/provider/resource_scalr_provider_configuration_test.go
@@ -22,8 +22,8 @@ func TestAccProviderConfiguration_import(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
},
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationCustomImportConfig(rName),
@@ -43,9 +43,9 @@ func TestAccProviderConfiguration_custom(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationCustomConfig(rName),
@@ -165,9 +165,9 @@ func TestAccProviderConfiguration_aws_custom(t *testing.T) {
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationCustomConfigAws(rName),
@@ -187,9 +187,9 @@ func TestAccProviderConfiguration_aws(t *testing.T) {
accessKeyId, secretAccessKey, roleArn, externalId := getAwsTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationAwsConfig(rName, accessKeyId, secretAccessKey, roleArn, externalId),
@@ -234,9 +234,9 @@ func TestAccProviderConfiguration_scalr(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationScalrConfig(rName),
@@ -279,9 +279,9 @@ func TestAccProviderConfiguration_google(t *testing.T) {
credentials, project := getGoogleTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationGoogleConfig(rName, credentials, project),
@@ -325,9 +325,9 @@ func TestAccProviderConfiguration_google_oidc(t *testing.T) {
_, project := getGoogleTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationGoogleOidcConfig(rName, project),
@@ -372,9 +372,9 @@ func TestAccProviderConfiguration_aws_oidc(t *testing.T) {
rNewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationAWSOidcConfig(rName),
@@ -414,9 +414,9 @@ func TestAccProviderConfiguration_azurerm(t *testing.T) {
armClientId, armClientSecret, armSubscription, armTenantId := getAzureTestingCreds(t)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckProviderConfigurationResourceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrProviderConfigurationAzurermConfig(rName, armClientId, armClientSecret, armSubscription, armTenantId),
@@ -694,7 +694,7 @@ func testAccCheckProviderConfigurationExists(n string, providerConfiguration *sc
return fmt.Errorf("Not found: %s", n)
}
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
providerConfigurationResource, err := scalrClient.ProviderConfigurations.Read(ctx, rs.Primary.ID)
@@ -709,7 +709,7 @@ func testAccCheckProviderConfigurationExists(n string, providerConfiguration *sc
}
func testAccCheckProviderConfigurationResourceDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_provider_configuration" {
diff --git a/internal/provider/resource_scalr_role_test.go b/internal/provider/resource_scalr_role_test.go
index dbc6f437..1605ce53 100644
--- a/internal/provider/resource_scalr_role_test.go
+++ b/internal/provider/resource_scalr_role_test.go
@@ -16,9 +16,9 @@ func TestAccScalrRole_basic(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRoleDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrRoleBasic(),
@@ -40,9 +40,9 @@ func TestAccScalrRole_update(t *testing.T) {
role := &scalr.Role{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRoleDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrRoleBasic(),
@@ -80,9 +80,9 @@ func TestAccScalrRole_update(t *testing.T) {
func TestAccScalrRole_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRoleDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrRoleBasic(),
@@ -99,7 +99,7 @@ func TestAccScalrRole_import(t *testing.T) {
func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -124,7 +124,7 @@ func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCh
func testAccCheckScalrRoleRename(role *scalr.Role) func() {
return func() {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
r, err := scalrClient.Roles.Read(ctx, role.ID)
@@ -148,7 +148,7 @@ func testAccCheckScalrRoleRename(role *scalr.Role) func() {
}
func testAccCheckScalrRoleDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_role" {
diff --git a/internal/provider/resource_scalr_run_schedule_rule_test.go b/internal/provider/resource_scalr_run_schedule_rule_test.go
index 2a443875..7092eb83 100644
--- a/internal/provider/resource_scalr_run_schedule_rule_test.go
+++ b/internal/provider/resource_scalr_run_schedule_rule_test.go
@@ -13,9 +13,9 @@ func TestAccScalrRunScheduleRule_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrRunScheduleRuleBasic(rInt),
@@ -37,9 +37,9 @@ func TestAccScalrRunScheduleRule_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrRunScheduleRuleBasic(rInt),
@@ -69,9 +69,9 @@ func TestAccScalrRunScheduleRule_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrRunScheduleRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrRunScheduleRuleBasic(rInt),
@@ -96,7 +96,7 @@ func testAccCheckScalrRunScheduleRuleExists(resId string, rule *scalr.RunSchedul
return fmt.Errorf("No Run Schedule Rule ID is set")
}
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
r, err := scalrClient.RunScheduleRules.Read(ctx, rs.Primary.ID)
if err != nil {
return fmt.Errorf("Error reading run schedule rule: %v", err)
@@ -109,7 +109,7 @@ func testAccCheckScalrRunScheduleRuleExists(resId string, rule *scalr.RunSchedul
}
func testAccCheckScalrRunScheduleRuleDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_run_schedule_rule" {
diff --git a/internal/provider/resource_scalr_run_triggers_test.go b/internal/provider/resource_scalr_run_triggers_test.go
index 13fb47f9..a32916b7 100644
--- a/internal/provider/resource_scalr_run_triggers_test.go
+++ b/internal/provider/resource_scalr_run_triggers_test.go
@@ -14,9 +14,9 @@ func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckRunTriggerDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckRunTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccRunTriggerConfig(rInt),
@@ -30,7 +30,7 @@ func TestAccScalrRunTriggersDataSource_basic(t *testing.T) {
}
func testAccCheckRunTriggerDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_run_trigger" {
@@ -77,7 +77,7 @@ resource "scalr_run_trigger" "foobar" {
func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -101,7 +101,7 @@ func testAccCheckRunTriggerExists(n string, runTrigger *scalr.RunTrigger) resour
func testAccCheckRunTriggerAttributes(runTrigger *scalr.RunTrigger, environmentName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
environment, ok := s.RootModule().Resources[environmentName]
if !ok {
diff --git a/internal/provider/resource_scalr_service_account_test.go b/internal/provider/resource_scalr_service_account_test.go
index 857b5350..75bfb888 100644
--- a/internal/provider/resource_scalr_service_account_test.go
+++ b/internal/provider/resource_scalr_service_account_test.go
@@ -13,9 +13,9 @@ func TestAccScalrServiceAccount_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrServiceAccountDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrServiceAccountBasic(rInt),
@@ -50,9 +50,9 @@ func TestAccScalrServiceAccount_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrServiceAccountDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrServiceAccountBasic(rInt),
@@ -70,9 +70,9 @@ func TestAccScalrServiceAccount_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrServiceAccountDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrServiceAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrServiceAccountBasic(rInt),
@@ -127,7 +127,7 @@ resource scalr_service_account test {
}
func testAccCheckScalrServiceAccountDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_service_account" {
diff --git a/internal/provider/resource_scalr_service_account_token_test.go b/internal/provider/resource_scalr_service_account_token_test.go
index ded5c4a8..99a6b4bc 100644
--- a/internal/provider/resource_scalr_service_account_token_test.go
+++ b/internal/provider/resource_scalr_service_account_token_test.go
@@ -13,9 +13,9 @@ func TestAccScalrServiceAccountToken_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrServiceAccountTokenBasicConfig(rInt),
@@ -38,9 +38,9 @@ func TestAccScalrServiceAccountToken_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrServiceAccountTokenDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrServiceAccountTokenBasicConfig(rInt),
@@ -59,7 +59,7 @@ func TestAccScalrServiceAccountToken_update(t *testing.T) {
}
func testAccCheckScalrServiceAccountTokenDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_service_account_token" {
diff --git a/internal/provider/resource_scalr_slack_integration_test.go b/internal/provider/resource_scalr_slack_integration_test.go
index aed6918e..4732625a 100644
--- a/internal/provider/resource_scalr_slack_integration_test.go
+++ b/internal/provider/resource_scalr_slack_integration_test.go
@@ -23,7 +23,7 @@ func TestAccSlackIntegration_basic(t *testing.T) {
t.Skip("Scalr instance doesn't have working slack connection.")
}
},
- ProviderFactories: testAccProviderFactories,
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrSlackIntegrationConfig(),
diff --git a/internal/provider/resource_scalr_ssh_key_test.go b/internal/provider/resource_scalr_ssh_key_test.go
index ef276219..8a88a3ba 100644
--- a/internal/provider/resource_scalr_ssh_key_test.go
+++ b/internal/provider/resource_scalr_ssh_key_test.go
@@ -17,9 +17,9 @@ func TestAccScalrSSHKey_basic(t *testing.T) {
var sshKey scalr.SSHKey
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckSSHKeyDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrSSHKeyConfig(rName),
@@ -38,9 +38,9 @@ func TestAccScalrSSHKey_update(t *testing.T) {
var sshKey scalr.SSHKey
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckSSHKeyDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrSSHKeyConfig(rName),
@@ -64,9 +64,9 @@ func TestAccScalrSSHKey_import(t *testing.T) {
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckSSHKeyDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckSSHKeyDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrSSHKeyConfig(rName),
@@ -112,7 +112,7 @@ EOF
}
func testAccCheckSSHKeyDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_ssh_key" {
@@ -139,7 +139,7 @@ func testAccCheckSSHKeyIsShared(resourceName string, expectedIsShared bool, sshK
return fmt.Errorf("Not found: %s", resourceName)
}
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
readKey, err := scalrClient.SSHKeys.Read(context.Background(), rs.Primary.ID)
if err != nil {
return fmt.Errorf("Error reading SSH key: %s", err)
diff --git a/internal/provider/resource_scalr_variable_test.go b/internal/provider/resource_scalr_variable_test.go
index c2e84440..8fc6dee7 100644
--- a/internal/provider/resource_scalr_variable_test.go
+++ b/internal/provider/resource_scalr_variable_test.go
@@ -26,9 +26,9 @@ func TestAccScalrVariable_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVariableDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrVariableOnAccountScopeImplicit(rInt),
@@ -84,9 +84,9 @@ func TestAccScalrVariable_basic(t *testing.T) {
func TestAccScalrVariable_defaults(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVariableDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrVariableOnAccountScopeImplicit(rInt),
@@ -111,9 +111,9 @@ func TestAccScalrVariable_scopes(t *testing.T) {
variable := &scalr.Variable{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVariableDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrVariableOnAllScopes(rInt),
@@ -128,9 +128,9 @@ func TestAccScalrVariable_update(t *testing.T) {
variable := &scalr.Variable{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVariableDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrVariableOnWorkspaceScope(rInt),
@@ -188,9 +188,9 @@ func TestAccScalrVariable_update(t *testing.T) {
func TestAccScalrVariable_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVariableDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVariableDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrVariableOnWorkspaceScope(rInt),
@@ -205,7 +205,7 @@ func TestAccScalrVariable_import(t *testing.T) {
}
func variableFromState(s *terraform.State, n string, v *scalr.Variable) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -333,7 +333,7 @@ func testAccCheckScalrVariableAttributesUpdate(
}
func testAccCheckScalrVariableDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_variable" {
diff --git a/internal/provider/resource_scalr_vcs_provider_test.go b/internal/provider/resource_scalr_vcs_provider_test.go
index 93e8aa2c..522b1d6c 100644
--- a/internal/provider/resource_scalr_vcs_provider_test.go
+++ b/internal/provider/resource_scalr_vcs_provider_test.go
@@ -14,8 +14,8 @@ func TestAccVcsProvider_basic(t *testing.T) {
provider := &scalr.VcsProvider{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrVcsProviderConfig(),
@@ -55,9 +55,9 @@ func TestAccVcsProvider_basic(t *testing.T) {
func TestAccVcsProvider_globalScope(t *testing.T) {
provider := &scalr.VcsProvider{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVcsProviderDestroy,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVcsProviderDestroy,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
@@ -80,9 +80,9 @@ func TestAccVcsProvider_globalScope(t *testing.T) {
func TestAccScalrVcsProvider_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrVcsProviderDestroy,
+ PreCheck: func() { testVcsAccGithubTokenPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrVcsProviderDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrVcsProviderConfig(),
@@ -99,7 +99,7 @@ func TestAccScalrVcsProvider_import(t *testing.T) {
func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProvider) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -123,7 +123,7 @@ func testAccCheckScalrVcsProviderExists(resId string, vcsProvider *scalr.VcsProv
}
func testAccCheckScalrVcsProviderDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_vcs_provider" {
diff --git a/internal/provider/resource_scalr_webhook_test.go b/internal/provider/resource_scalr_webhook_test.go
index ba7aa53b..e0ff3da5 100644
--- a/internal/provider/resource_scalr_webhook_test.go
+++ b/internal/provider/resource_scalr_webhook_test.go
@@ -12,8 +12,8 @@ func TestAccWebhook_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccWebhookConfig(rInt),
@@ -32,8 +32,8 @@ func TestAccWebhook_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccWebhookConfigUpdateEmptyEvent(rInt),
diff --git a/internal/provider/resource_scalr_workspace_run_schedule_test.go b/internal/provider/resource_scalr_workspace_run_schedule_test.go
index 69eeb679..9449c758 100644
--- a/internal/provider/resource_scalr_workspace_run_schedule_test.go
+++ b/internal/provider/resource_scalr_workspace_run_schedule_test.go
@@ -11,9 +11,9 @@ func TestScalrWorkspaceRunSchedule_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceRunSchedule(rInt),
@@ -32,9 +32,9 @@ func TestScalrWorkspaceRunSchedule_default(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceRunScheduleDefaultValue(rInt),
diff --git a/internal/provider/resource_scalr_workspace_test.go b/internal/provider/resource_scalr_workspace_test.go
index 64617968..c8df2227 100644
--- a/internal/provider/resource_scalr_workspace_test.go
+++ b/internal/provider/resource_scalr_workspace_test.go
@@ -16,9 +16,9 @@ func TestAccScalrWorkspace_basic(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceBasic(rInt),
@@ -71,8 +71,8 @@ func TestAccScalrWorkspace_create_missed_vcs_attr(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceMissedVcsProvider(rInt),
@@ -91,9 +91,9 @@ func TestAccScalrWorkspace_monorepo(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceMonorepo(rInt),
@@ -123,9 +123,9 @@ func TestAccScalrWorkspace_update(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceBasic(rInt),
@@ -244,9 +244,9 @@ func TestAccScalrWorkspace_import(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceBasic(rInt),
@@ -266,9 +266,9 @@ func TestAccScalrWorkspace_providerConfiguration(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceProviderConfiguration(rInt),
@@ -301,9 +301,9 @@ func TestAccScalrWorkspaceSSHKey(t *testing.T) {
sshKeyName := fmt.Sprintf("ssh-key-test-%d", rInt)
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceWithSSHKeyConfig(rInt, sshKeyName),
@@ -321,7 +321,7 @@ func TestAccScalrWorkspaceSSHKey(t *testing.T) {
func testAccCheckScalrSSHKeyExists(n string, sshKey *scalr.SSHKey) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -346,9 +346,9 @@ func TestAccScalrWorkspace_emptyHooks(t *testing.T) {
rInt := GetRandomInteger()
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrWorkspaceDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrWorkspaceEmptyHooks(rInt),
@@ -360,7 +360,7 @@ func TestAccScalrWorkspace_emptyHooks(t *testing.T) {
func testAccCheckScalrWorkspaceExists(
n string, workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[n]
if !ok {
@@ -451,7 +451,7 @@ func testAccCheckScalrWorkspaceAttributesUpdated(
func testAccCheckScalrWorkspaceProviderConfigurations(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
links, err := getProviderConfigurationWorkspaceLinks(ctx, scalrClient, workspace.ID)
if err != nil {
@@ -505,7 +505,7 @@ func testAccCheckScalrWorkspaceProviderConfigurations(
func testAccCheckScalrWorkspaceProviderConfigurationsUpdated(
workspace *scalr.Workspace) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
links, err := getProviderConfigurationWorkspaceLinks(ctx, scalrClient, workspace.ID)
if err != nil {
@@ -558,7 +558,7 @@ func testAccCheckScalrWorkspaceProviderConfigurationsUpdated(
}
func testAccCheckScalrWorkspaceDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_workspace" {
diff --git a/internal/provider/tag_data_source.go b/internal/provider/tag_data_source.go
index 179a9f31..b3c2ed57 100644
--- a/internal/provider/tag_data_source.go
+++ b/internal/provider/tag_data_source.go
@@ -32,8 +32,8 @@ type tagDataSource struct {
framework.DataSourceWithScalrClient
}
-// TagDataSourceModel describes the data source data model.
-type TagDataSourceModel struct {
+// tagDataSourceModel describes the data source data model.
+type tagDataSourceModel struct {
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
AccountID types.String `tfsdk:"account_id"`
@@ -83,7 +83,7 @@ func (d *tagDataSource) ConfigValidators(_ context.Context) []datasource.ConfigV
}
func (d *tagDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
- var cfg TagDataSourceModel
+ var cfg tagDataSourceModel
// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &cfg)...)
@@ -93,10 +93,10 @@ func (d *tagDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
opts := scalr.TagListOptions{}
if !cfg.Id.IsNull() {
- opts.Tag = ptr(cfg.Id.ValueString())
+ opts.Tag = cfg.Id.ValueStringPointer()
}
if !cfg.Name.IsNull() {
- opts.Name = ptr(cfg.Name.ValueString())
+ opts.Name = cfg.Name.ValueStringPointer()
}
tags, err := d.Client.Tags.List(ctx, opts)
diff --git a/internal/provider/tag_resource.go b/internal/provider/tag_resource.go
index 21263372..56b3bd23 100644
--- a/internal/provider/tag_resource.go
+++ b/internal/provider/tag_resource.go
@@ -3,118 +3,190 @@ package provider
import (
"context"
"errors"
- "log"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/defaults"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/validation"
)
-func resourceScalrTag() *schema.Resource {
- return &schema.Resource{
- Description: "Manages the state of tags in Scalr.",
- CreateContext: resourceScalrTagCreate,
- ReadContext: resourceScalrTagRead,
- UpdateContext: resourceScalrTagUpdate,
- DeleteContext: resourceScalrTagDelete,
- Importer: &schema.ResourceImporter{
- StateContext: schema.ImportStatePassthroughContext,
- },
+// Ensure provider defined types fully satisfy framework interfaces.
+var (
+ _ resource.Resource = &tagResource{}
+ _ resource.ResourceWithConfigure = &tagResource{}
+ _ resource.ResourceWithConfigValidators = &tagResource{}
+ _ resource.ResourceWithImportState = &tagResource{}
+)
+
+func newTagResource() resource.Resource {
+ return &tagResource{}
+}
+
+// tagResource defines the resource implementation.
+type tagResource struct {
+ framework.ResourceWithScalrClient
+}
+
+// tagResourceModel describes the resource data model.
+type tagResourceModel struct {
+ Id types.String `tfsdk:"id"`
+ Name types.String `tfsdk:"name"`
+ AccountID types.String `tfsdk:"account_id"`
+}
+
+func (r *tagResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_tag"
+}
- Schema: map[string]*schema.Schema{
- "name": {
- Description: "Name of the tag.",
- Type: schema.TypeString,
- Required: true,
+func (r *tagResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ MarkdownDescription: "Manages the state of tags in Scalr.",
+
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ MarkdownDescription: "The ID of this resource.",
+ Computed: true,
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.UseStateForUnknown(),
+ },
+ },
+ "name": schema.StringAttribute{
+ MarkdownDescription: "Name of the tag.",
+ Required: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
},
- "account_id": {
- Description: "ID of the account, in the format `acc-`.",
- Type: schema.TypeString,
- Optional: true,
- Computed: true,
- DefaultFunc: scalrAccountIDDefaultFunc,
- ForceNew: true,
+ "account_id": schema.StringAttribute{
+ MarkdownDescription: "ID of the account, in the format `acc-`.",
+ Optional: true,
+ Computed: true,
+ Default: defaults.AccountIDRequired(),
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.RequiresReplace(),
+ },
},
},
}
}
-func resourceScalrTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
- scalrClient := meta.(*scalr.Client)
- id := d.Id()
+func (r *tagResource) ConfigValidators(_ context.Context) []resource.ConfigValidator {
+ return []resource.ConfigValidator{}
+}
+
+func (r *tagResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var plan tagResourceModel
+
+ // Read plan data
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
- log.Printf("[DEBUG] Read tag: %s", id)
- tag, err := scalrClient.Tags.Read(ctx, id)
+ opts := scalr.TagCreateOptions{
+ Name: plan.Name.ValueStringPointer(),
+ Account: &scalr.Account{ID: plan.AccountID.ValueString()},
+ }
+ tag, err := r.Client.Tags.Create(ctx, opts)
if err != nil {
- if errors.Is(err, scalr.ErrResourceNotFound) {
- log.Printf("[DEBUG] Tag %s not found", id)
- d.SetId("")
- return nil
- }
- return diag.Errorf("Error reading tag %s: %v", id, err)
+ resp.Diagnostics.AddError("Error creating tag", err.Error())
+ return
}
- // Update config.
- _ = d.Set("name", tag.Name)
- _ = d.Set("account_id", tag.Account.ID)
+ plan.Id = types.StringValue(tag.ID)
+ plan.Name = types.StringValue(tag.Name)
+ plan.AccountID = types.StringValue(tag.Account.ID)
- return nil
+ // Set state to fully populated data
+ resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
}
-func resourceScalrTagCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
- scalrClient := meta.(*scalr.Client)
-
- // Get the name and account_id.
- name := d.Get("name").(string)
- accountID := d.Get("account_id").(string)
-
- options := scalr.TagCreateOptions{
- Name: ptr(name),
- Account: &scalr.Account{ID: accountID},
+func (r *tagResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ // Get current state
+ var state tagResourceModel
+ resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
+ if resp.Diagnostics.HasError() {
+ return
}
- log.Printf("[DEBUG] Create tag %s for account %s", name, accountID)
- tag, err := scalrClient.Tags.Create(ctx, options)
+ // Get refreshed resource state from API
+ tag, err := r.Client.Tags.Read(ctx, state.Id.ValueString())
if err != nil {
- return diag.Errorf(
- "Error creating tag %s for account %s: %v", name, accountID, err)
+ if errors.Is(err, scalr.ErrResourceNotFound) {
+ resp.State.RemoveResource(ctx)
+ return
+ }
+ resp.Diagnostics.AddError("Error retrieving tag", err.Error())
+ return
}
- d.SetId(tag.ID)
- return resourceScalrTagRead(ctx, d, meta)
+ // Overwrite attributes with refreshed values
+ state.Name = types.StringValue(tag.Name)
+ state.AccountID = types.StringValue(tag.Account.ID)
+
+ // Set refreshed state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
}
-func resourceScalrTagUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
- scalrClient := meta.(*scalr.Client)
+func (r *tagResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
+ // Read plan data
+ var plan tagResourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
- id := d.Id()
- if d.HasChange("name") {
- name := d.Get("name").(string)
- opts := scalr.TagUpdateOptions{
- Name: ptr(name),
- }
- log.Printf("[DEBUG] Update tag %s", id)
- _, err := scalrClient.Tags.Update(ctx, id, opts)
- if err != nil {
- return diag.Errorf("error updating tag %s: %v", id, err)
- }
+ opts := scalr.TagUpdateOptions{
+ Name: plan.Name.ValueStringPointer(),
}
- return resourceScalrTagRead(ctx, d, meta)
+ // Update existing resource
+ tag, err := r.Client.Tags.Update(ctx, plan.Id.ValueString(), opts)
+ if err != nil {
+ resp.Diagnostics.AddError("Error updating tag", err.Error())
+ return
+ }
+
+ // Overwrite attributes with refreshed values
+ plan.Name = types.StringValue(tag.Name)
+ plan.AccountID = types.StringValue(tag.Account.ID)
+
+ // Set refreshed state
+ resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
}
-func resourceScalrTagDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
- scalrClient := meta.(*scalr.Client)
- id := d.Id()
+func (r *tagResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ // Get current state
+ var state tagResourceModel
+ resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
- log.Printf("[DEBUG] Delete tag %s", id)
- err := scalrClient.Tags.Delete(ctx, id)
- if err != nil {
- if errors.Is(err, scalr.ErrResourceNotFound) {
- return nil
- }
- return diag.Errorf("Error deleting tag %s: %v", id, err)
+ err := r.Client.Tags.Delete(ctx, state.Id.ValueString())
+ if err != nil && !errors.Is(err, scalr.ErrResourceNotFound) {
+ resp.Diagnostics.AddError("Error deleting tag", err.Error())
+ return
}
+}
- return nil
+func (r *tagResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
+ resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
}
diff --git a/internal/provider/tag_resource_test.go b/internal/provider/tag_resource_test.go
index c12942cc..068337e9 100644
--- a/internal/provider/tag_resource_test.go
+++ b/internal/provider/tag_resource_test.go
@@ -13,9 +13,9 @@ func TestAccScalrTag_basic(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrTagDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrTagBasic(),
@@ -32,9 +32,9 @@ func TestAccScalrTag_basic(t *testing.T) {
func TestAccScalrTag_import(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrTagDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrTagBasic(),
@@ -53,9 +53,9 @@ func TestAccScalrTag_update(t *testing.T) {
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProviderFactories: testAccProviderFactories,
- CheckDestroy: testAccCheckScalrTagDestroy,
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
Config: testAccScalrTagBasic(),
@@ -104,7 +104,7 @@ resource scalr_tag test {
func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheckFunc {
return func(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
rs, ok := s.RootModule().Resources[resId]
if !ok {
@@ -128,7 +128,7 @@ func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheck
}
func testAccCheckScalrTagDestroy(s *terraform.State) error {
- scalrClient := testAccProvider.Meta().(*scalr.Client)
+ scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "scalr_tag" {
From 9c474473595be38d34bab99d4a197a3703e18d5d Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Sun, 1 Dec 2024 12:59:04 +0200
Subject: [PATCH 23/26] SCALRCORE-26654 Fix linter
---
.../resource_scalr_access_policy_test.go | 27 ------------------
.../resource_scalr_agent_pool_test.go | 27 ------------------
.../resource_scalr_agent_pool_token_test.go | 21 --------------
.../provider/resource_scalr_iam_team_test.go | 28 -------------------
internal/provider/resource_scalr_role_test.go | 27 ------------------
internal/provider/tag_data_source_test.go | 2 +-
internal/provider/tag_resource_test.go | 8 ------
7 files changed, 1 insertion(+), 139 deletions(-)
diff --git a/internal/provider/resource_scalr_access_policy_test.go b/internal/provider/resource_scalr_access_policy_test.go
index 6ddd6994..dadcd0ff 100644
--- a/internal/provider/resource_scalr_access_policy_test.go
+++ b/internal/provider/resource_scalr_access_policy_test.go
@@ -1,9 +1,7 @@
package provider
import (
- "context"
"fmt"
- "log"
"math/rand"
"regexp"
"testing"
@@ -161,31 +159,6 @@ func testAccCheckScalrAccessPolicyExists(resId string, ap *scalr.AccessPolicy) r
}
}
-func testAccCheckScalrAccessPolicyChangedOutside(ap *scalr.AccessPolicy) func() {
- return func() {
- scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
-
- r, err := scalrClient.AccessPolicies.Read(ctx, ap.ID)
-
- if err != nil {
- log.Fatalf("Error retrieving access policy: %v", err)
- }
-
- r, err = scalrClient.AccessPolicies.Update(
- context.Background(),
- r.ID,
- scalr.AccessPolicyUpdateOptions{Roles: []*scalr.Role{{ID: userRole}}},
- )
- if err != nil {
- log.Fatalf("Could not change the access policy outside of terraform: %v", err)
- }
-
- if r.Roles[0].ID != userRole {
- log.Fatalf("Failed to change the access policy outside of terraform: %v", err)
- }
- }
-}
-
func testAccCheckScalrAccessPolicyDestroy(s *terraform.State) error {
scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
diff --git a/internal/provider/resource_scalr_agent_pool_test.go b/internal/provider/resource_scalr_agent_pool_test.go
index d713b734..b13460bd 100644
--- a/internal/provider/resource_scalr_agent_pool_test.go
+++ b/internal/provider/resource_scalr_agent_pool_test.go
@@ -1,9 +1,7 @@
package provider
import (
- "context"
"fmt"
- "log"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -110,31 +108,6 @@ func testAccCheckScalrAgentPoolExists(resId string, pool *scalr.AgentPool) resou
}
}
-func testAccCheckScalrAgentPoolRename(pool *scalr.AgentPool) func() {
- return func() {
- scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
-
- r, err := scalrClient.AgentPools.Read(ctx, pool.ID)
-
- if err != nil {
- log.Fatalf("Error retrieving agent pool: %v", err)
- }
-
- r, err = scalrClient.AgentPools.Update(
- context.Background(),
- r.ID,
- scalr.AgentPoolUpdateOptions{Name: ptr("renamed-outside-of-terraform")},
- )
- if err != nil {
- log.Fatalf("Could not rename the agent pool outside of terraform: %v", err)
- }
-
- if r.Name != "renamed-outside-of-terraform" {
- log.Fatalf("Failed to rename the agent pool outside of terraform: %v", err)
- }
- }
-}
-
func testAccCheckScalrAgentPoolDestroy(s *terraform.State) error {
scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
diff --git a/internal/provider/resource_scalr_agent_pool_token_test.go b/internal/provider/resource_scalr_agent_pool_token_test.go
index d2e31097..db3dcf9f 100644
--- a/internal/provider/resource_scalr_agent_pool_token_test.go
+++ b/internal/provider/resource_scalr_agent_pool_token_test.go
@@ -1,9 +1,7 @@
package provider
import (
- "context"
"fmt"
- "log"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -101,25 +99,6 @@ func testAccCheckScalrAgentPoolTokenExists(resId string, pool scalr.AgentPool, t
}
}
-func testAccCheckScalrAgentPoolTokenChangedOutside(token *scalr.AccessToken) func() {
- return func() {
- scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
-
- r, err := scalrClient.AccessTokens.Update(
- context.Background(),
- token.ID,
- scalr.AccessTokenUpdateOptions{Description: ptr("changed-outside-of-terraform")},
- )
- if err != nil {
- log.Fatalf("Could not update the agent pool outside of terraform: %v", err)
- }
-
- if r.Description != "changed-outside-of-terraform" {
- log.Fatalf("Failed to update the agent pool outside of terraform: %v", err)
- }
- }
-}
-
func deletePool(t *testing.T, pool scalr.AgentPool) {
scalrClient, err := createScalrClient()
if err != nil {
diff --git a/internal/provider/resource_scalr_iam_team_test.go b/internal/provider/resource_scalr_iam_team_test.go
index f9726002..535f2ee5 100644
--- a/internal/provider/resource_scalr_iam_team_test.go
+++ b/internal/provider/resource_scalr_iam_team_test.go
@@ -1,9 +1,7 @@
package provider
import (
- "context"
"fmt"
- "log"
"regexp"
"testing"
@@ -124,32 +122,6 @@ func testAccCheckScalrIamTeamExists(resId string, team *scalr.Team) resource.Tes
}
}
-func testAccCheckScalrIamTeamRename(team *scalr.Team) func() {
- return func() {
- scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
-
- t, err := scalrClient.Teams.Read(ctx, team.ID)
- if err != nil {
- log.Fatalf("Error retrieving team: %v", err)
- }
-
- t, err = scalrClient.Teams.Update(
- context.Background(),
- team.ID,
- scalr.TeamUpdateOptions{
- Name: ptr("renamed-outside-of-terraform"),
- Users: t.Users,
- },
- )
- if err != nil {
- log.Fatalf("Could not rename team outside of terraform: %v", err)
- }
- if t.Name != "renamed-outside-of-terraform" {
- log.Fatalf("Failed to rename the team outside of terraform: %v", err)
- }
- }
-}
-
func testAccCheckScalrIamTeamDestroy(s *terraform.State) error {
scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
diff --git a/internal/provider/resource_scalr_role_test.go b/internal/provider/resource_scalr_role_test.go
index 1605ce53..2e56e3ec 100644
--- a/internal/provider/resource_scalr_role_test.go
+++ b/internal/provider/resource_scalr_role_test.go
@@ -1,9 +1,7 @@
package provider
import (
- "context"
"fmt"
- "log"
"regexp"
"testing"
@@ -122,31 +120,6 @@ func testAccCheckScalrRoleExists(resId string, role *scalr.Role) resource.TestCh
}
}
-func testAccCheckScalrRoleRename(role *scalr.Role) func() {
- return func() {
- scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
-
- r, err := scalrClient.Roles.Read(ctx, role.ID)
-
- if err != nil {
- log.Fatalf("Error retrieving role: %v", err)
- }
-
- r, err = scalrClient.Roles.Update(
- context.Background(),
- r.ID,
- scalr.RoleUpdateOptions{Name: ptr("renamed-outside-of-terraform")},
- )
- if err != nil {
- log.Fatalf("Could not rename the role outside of terraform: %v", err)
- }
-
- if r.Name != "renamed-outside-of-terraform" {
- log.Fatalf("Failed to rename the role outside of terraform: %v", err)
- }
- }
-}
-
func testAccCheckScalrRoleDestroy(s *terraform.State) error {
scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
diff --git a/internal/provider/tag_data_source_test.go b/internal/provider/tag_data_source_test.go
index fc330038..994c3c4a 100644
--- a/internal/provider/tag_data_source_test.go
+++ b/internal/provider/tag_data_source_test.go
@@ -17,7 +17,7 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: `data scalr_tag test {}`,
- ExpectError: regexp.MustCompile("At least one of these attributes must be configured: \\[id,name]"),
+ ExpectError: regexp.MustCompile(`At least one of these attributes must be configured: \[id,name]`),
PlanOnly: true,
},
{
diff --git a/internal/provider/tag_resource_test.go b/internal/provider/tag_resource_test.go
index 068337e9..1d9c3e25 100644
--- a/internal/provider/tag_resource_test.go
+++ b/internal/provider/tag_resource_test.go
@@ -94,14 +94,6 @@ resource scalr_tag test {
}`, defaultAccount)
}
-func testAccScalrTagRenamed() string {
- return fmt.Sprintf(`
-resource scalr_tag test {
- name = "renamed-outside-terraform"
- account_id = "%s"
-}`, defaultAccount)
-}
-
func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheckFunc {
return func(s *terraform.State) error {
scalrClient := testAccProviderSDK.Meta().(*scalr.Client)
From 6ea549cd4d37c67915d16635733bb5b8371c24d8 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Sun, 1 Dec 2024 22:40:50 +0200
Subject: [PATCH 24/26] SCALRCORE-26654 Implement skaffolding generator
---
GNUmakefile | 10 +-
internal/provider/tag_data_source_test.go | 36 ++--
internal/provider/tag_resource_test.go | 35 ++--
skaff/cmd/main.go | 21 +++
skaff/generator.go | 73 ++++++++
skaff/go.mod | 5 +
skaff/go.sum | 2 +
skaff/templates/data_source.tmpl | 132 +++++++++++++++
skaff/templates/data_source_test.tmpl | 97 +++++++++++
skaff/templates/resource.tmpl | 194 ++++++++++++++++++++++
skaff/templates/resource_test.tmpl | 5 +
11 files changed, 575 insertions(+), 35 deletions(-)
create mode 100644 skaff/cmd/main.go
create mode 100644 skaff/generator.go
create mode 100644 skaff/go.mod
create mode 100644 skaff/go.sum
create mode 100644 skaff/templates/data_source.tmpl
create mode 100644 skaff/templates/data_source_test.tmpl
create mode 100644 skaff/templates/resource.tmpl
create mode 100644 skaff/templates/resource_test.tmpl
diff --git a/GNUmakefile b/GNUmakefile
index 56eaa5ca..680e5c46 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -53,4 +53,12 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)
-.PHONY: build test testacc vet fmt test-compile notify-upstream
+resource:
+ @echo "Skaffolding resource $(name)..."
+ @cd skaff && go run cmd/main.go -type=resource -name=$(name)
+
+datasource:
+ @echo "Skaffolding datasource $(name)..."
+ @cd skaff && go run cmd/main.go -type=data_source -name=$(name)
+
+.PHONY: build test testacc vet fmt test-compile notify-upstream resource datasource
diff --git a/internal/provider/tag_data_source_test.go b/internal/provider/tag_data_source_test.go
index 994c3c4a..118cc846 100644
--- a/internal/provider/tag_data_source_test.go
+++ b/internal/provider/tag_data_source_test.go
@@ -5,11 +5,12 @@ import (
"regexp"
"testing"
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccScalrTagDataSource_basic(t *testing.T) {
- rInt := GetRandomInteger()
+ tagName := acctest.RandomWithPrefix("test-tag")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@@ -18,39 +19,36 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
{
Config: `data scalr_tag test {}`,
ExpectError: regexp.MustCompile(`At least one of these attributes must be configured: \[id,name]`),
- PlanOnly: true,
},
{
Config: `data scalr_tag test {id = ""}`,
ExpectError: regexp.MustCompile("Attribute id must not be empty"),
- PlanOnly: true,
},
{
Config: `data scalr_tag test {name = ""}`,
ExpectError: regexp.MustCompile("Attribute name must not be empty"),
- PlanOnly: true,
},
{
- Config: testAccScalrTagDataSourceByIDConfig(rInt),
+ Config: testAccScalrTagDataSourceByIDConfig(tagName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
{
- Config: testAccScalrTagDataSourceByNameConfig(rInt),
+ Config: testAccScalrTagDataSourceByNameConfig(tagName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
{
- Config: testAccScalrTagDataSourceByIDAndNameConfig(rInt),
+ Config: testAccScalrTagDataSourceByIDAndNameConfig(tagName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
- resource.TestCheckResourceAttr("data.scalr_tag.test", "name", fmt.Sprintf("test-tag-%d", rInt)),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
@@ -58,36 +56,36 @@ func TestAccScalrTagDataSource_basic(t *testing.T) {
})
}
-func testAccScalrTagDataSourceByIDConfig(rInt int) string {
+func testAccScalrTagDataSourceByIDConfig(name string) string {
return fmt.Sprintf(`
resource scalr_tag test {
- name = "test-tag-%[1]d"
+ name = "%[1]s"
account_id = "%[2]s"
}
data scalr_tag test {
id = scalr_tag.test.id
account_id = "%[2]s"
-}`, rInt, defaultAccount)
+}`, name, defaultAccount)
}
-func testAccScalrTagDataSourceByNameConfig(rInt int) string {
+func testAccScalrTagDataSourceByNameConfig(name string) string {
return fmt.Sprintf(`
resource scalr_tag test {
- name = "test-tag-%[1]d"
+ name = "%[1]s"
account_id = "%[2]s"
}
data scalr_tag test {
name = scalr_tag.test.name
account_id = "%[2]s"
-}`, rInt, defaultAccount)
+}`, name, defaultAccount)
}
-func testAccScalrTagDataSourceByIDAndNameConfig(rInt int) string {
+func testAccScalrTagDataSourceByIDAndNameConfig(name string) string {
return fmt.Sprintf(`
resource scalr_tag test {
- name = "test-tag-%[1]d"
+ name = "%[1]s"
account_id = "%[2]s"
}
@@ -95,5 +93,5 @@ data scalr_tag test {
id = scalr_tag.test.id
name = scalr_tag.test.name
account_id = "%[2]s"
-}`, rInt, defaultAccount)
+}`, name, defaultAccount)
}
diff --git a/internal/provider/tag_resource_test.go b/internal/provider/tag_resource_test.go
index 1d9c3e25..4ea00532 100644
--- a/internal/provider/tag_resource_test.go
+++ b/internal/provider/tag_resource_test.go
@@ -4,12 +4,14 @@ import (
"fmt"
"testing"
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
func TestAccScalrTag_basic(t *testing.T) {
+ tagName := acctest.RandomWithPrefix("test-tag")
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
@@ -18,10 +20,10 @@ func TestAccScalrTag_basic(t *testing.T) {
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
- Config: testAccScalrTagBasic(),
+ Config: testAccScalrTagBasic(tagName),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrTagExists("scalr_tag.test", tag),
- resource.TestCheckResourceAttr("scalr_tag.test", "name", "test-tag-name"),
+ resource.TestCheckResourceAttr("scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
),
},
@@ -30,6 +32,7 @@ func TestAccScalrTag_basic(t *testing.T) {
}
func TestAccScalrTag_import(t *testing.T) {
+ tagName := acctest.RandomWithPrefix("test-tag")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@@ -37,7 +40,7 @@ func TestAccScalrTag_import(t *testing.T) {
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
- Config: testAccScalrTagBasic(),
+ Config: testAccScalrTagBasic(tagName),
},
{
@@ -50,6 +53,8 @@ func TestAccScalrTag_import(t *testing.T) {
}
func TestAccScalrTag_update(t *testing.T) {
+ tagName := acctest.RandomWithPrefix("test-tag")
+ tagNameUpdated := acctest.RandomWithPrefix("test-tag")
tag := &scalr.Tag{}
resource.Test(t, resource.TestCase{
@@ -58,19 +63,19 @@ func TestAccScalrTag_update(t *testing.T) {
CheckDestroy: testAccCheckScalrTagDestroy,
Steps: []resource.TestStep{
{
- Config: testAccScalrTagBasic(),
+ Config: testAccScalrTagBasic(tagName),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrTagExists("scalr_tag.test", tag),
- resource.TestCheckResourceAttr("scalr_tag.test", "name", "test-tag-name"),
+ resource.TestCheckResourceAttr("scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
),
},
{
- Config: testAccScalrTagUpdate(),
+ Config: testAccScalrTagUpdate(tagNameUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalrTagExists("scalr_tag.test", tag),
- resource.TestCheckResourceAttr("scalr_tag.test", "name", "test-tag-name-updated"),
+ resource.TestCheckResourceAttr("scalr_tag.test", "name", tagNameUpdated),
resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
),
},
@@ -78,20 +83,20 @@ func TestAccScalrTag_update(t *testing.T) {
})
}
-func testAccScalrTagBasic() string {
+func testAccScalrTagBasic(name string) string {
return fmt.Sprintf(`
resource scalr_tag test {
- name = "test-tag-name"
- account_id = "%s"
-}`, defaultAccount)
+ name = "%[1]s"
+ account_id = "%[2]s"
+}`, name, defaultAccount)
}
-func testAccScalrTagUpdate() string {
+func testAccScalrTagUpdate(name string) string {
return fmt.Sprintf(`
resource scalr_tag test {
- name = "test-tag-name-updated"
- account_id = "%s"
-}`, defaultAccount)
+ name = "%[1]s"
+ account_id = "%[2]s"
+}`, name, defaultAccount)
}
func testAccCheckScalrTagExists(resId string, tag *scalr.Tag) resource.TestCheckFunc {
diff --git a/skaff/cmd/main.go b/skaff/cmd/main.go
new file mode 100644
index 00000000..80e55d6c
--- /dev/null
+++ b/skaff/cmd/main.go
@@ -0,0 +1,21 @@
+package main
+
+import (
+ "flag"
+ "log"
+
+ "github.com/scalr/terraform-provider-scalr/skaff"
+)
+
+func main() {
+ t := flag.String("type", "", "Type of scaffolding to create.")
+ n := flag.String(
+ "name", "", "A name in snake case as it will appear in configuration (e.g., agent_pool).",
+ )
+ flag.Parse()
+
+ err := skaff.Generate(*t, *n)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/skaff/generator.go b/skaff/generator.go
new file mode 100644
index 00000000..34270015
--- /dev/null
+++ b/skaff/generator.go
@@ -0,0 +1,73 @@
+package skaff
+
+import (
+ "errors"
+ "fmt"
+ "log"
+ "os"
+ "path/filepath"
+ "strings"
+ "text/template"
+
+ "github.com/iancoleman/strcase"
+)
+
+const (
+ typeResource = "resource"
+ typeDatasource = "data_source"
+)
+
+var funcMap = template.FuncMap{
+ "camel": strcase.ToCamel,
+ "lowerCamel": strcase.ToLowerCamel,
+ "kebab": strcase.ToKebab,
+}
+
+func Generate(t, n string) error {
+ if t != typeResource && t != typeDatasource {
+ return fmt.Errorf("invalid type. Must be one of: %s, %s", typeResource, typeDatasource)
+ }
+
+ if n == "" {
+ return errors.New("name cannot be empty")
+ }
+
+ if strings.ToLower(strcase.ToSnake(n)) != n {
+ return errors.New("name must be in snake_case lowercase")
+ }
+
+ data := struct {
+ Name string
+ }{
+ Name: n,
+ }
+
+ err := writeTemplate(t+".tmpl", fmt.Sprintf("%s_%s.go", n, t), data)
+ if err != nil {
+ return err
+ }
+
+ return writeTemplate(t+"_test.tmpl", fmt.Sprintf("%s_%s_test.go", n, t), data)
+}
+
+func writeTemplate(tmplName, fileName string, data any) error {
+ tmpl, err := template.New(tmplName).Funcs(funcMap).ParseFiles("templates/" + tmplName)
+ if err != nil {
+ return err
+ }
+
+ out := filepath.Join("../internal/provider", fileName)
+ f, err := os.Create(out)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ err = tmpl.Execute(f, data)
+ if err != nil {
+ return err
+ }
+
+ log.Println("Created", fileName)
+ return nil
+}
diff --git a/skaff/go.mod b/skaff/go.mod
new file mode 100644
index 00000000..7d65362c
--- /dev/null
+++ b/skaff/go.mod
@@ -0,0 +1,5 @@
+go 1.23.3
+
+module github.com/scalr/terraform-provider-scalr/skaff
+
+require github.com/iancoleman/strcase v0.3.0
diff --git a/skaff/go.sum b/skaff/go.sum
new file mode 100644
index 00000000..6261b6ac
--- /dev/null
+++ b/skaff/go.sum
@@ -0,0 +1,2 @@
+github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
+github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
diff --git a/skaff/templates/data_source.tmpl b/skaff/templates/data_source.tmpl
new file mode 100644
index 00000000..63964875
--- /dev/null
+++ b/skaff/templates/data_source.tmpl
@@ -0,0 +1,132 @@
+package provider
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/validation"
+)
+
+// Ensure provider defined types fully satisfy framework interfaces.
+var (
+ _ datasource.DataSource = &{{ .Name | lowerCamel }}DataSource{}
+ _ datasource.DataSourceWithConfigure = &{{ .Name | lowerCamel }}DataSource{}
+ _ datasource.DataSourceWithConfigValidators = &{{ .Name | lowerCamel }}DataSource{}
+)
+
+func new{{ .Name | camel }}DataSource() datasource.DataSource {
+ return &{{ .Name | lowerCamel }}DataSource{}
+}
+
+// {{ .Name | lowerCamel }}DataSource defines the data source implementation.
+type {{ .Name | lowerCamel }}DataSource struct {
+ framework.DataSourceWithScalrClient
+}
+
+// {{ .Name | lowerCamel }}DataSourceModel describes the data source data model.
+type {{ .Name | lowerCamel }}DataSourceModel struct {
+ Id types.String `tfsdk:"id"`
+ Name types.String `tfsdk:"name"`
+ AccountID types.String `tfsdk:"account_id"`
+}
+
+func (d *{{ .Name | lowerCamel }}DataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_{{ .Name }}"
+}
+
+func (d *{{ .Name | lowerCamel }}DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ MarkdownDescription: "Retrieves information about {{ .Name }}.",
+
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ MarkdownDescription: "The identifier of the {{ .Name }}.",
+ Optional: true,
+ Computed: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
+ },
+ "name": schema.StringAttribute{
+ MarkdownDescription: "The name of the {{ .Name }}.",
+ Optional: true,
+ Computed: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
+ },
+ "account_id": schema.StringAttribute{
+ MarkdownDescription: "The ID of the Scalr account, in the format `acc-`.",
+ Optional: true,
+ Computed: true,
+ },
+ },
+ }
+}
+
+func (d *{{ .Name | lowerCamel }}DataSource) ConfigValidators(_ context.Context) []datasource.ConfigValidator {
+ return []datasource.ConfigValidator{
+ datasourcevalidator.AtLeastOneOf(
+ path.MatchRoot("id"),
+ path.MatchRoot("name"),
+ ),
+ }
+}
+
+func (d *{{ .Name | lowerCamel }}DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var cfg {{ .Name | lowerCamel }}DataSourceModel
+
+ // Read Terraform configuration data into the model
+ resp.Diagnostics.Append(req.Config.Get(ctx, &cfg)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ opts := scalr.{{ .Name | camel }}ListOptions{}
+ if !cfg.Id.IsNull() {
+ opts.{{ .Name | camel }} = cfg.Id.ValueStringPointer()
+ }
+ if !cfg.Name.IsNull() {
+ opts.Name = cfg.Name.ValueStringPointer()
+ }
+
+ {{ .Name | lowerCamel }}s, err := d.Client.{{ .Name | camel }}s.List(ctx, opts)
+ if err != nil {
+ resp.Diagnostics.AddError("Error retrieving {{ .Name }}", err.Error())
+ return
+ }
+
+ // Unlikely
+ if {{ .Name | lowerCamel }}s.TotalCount > 1 {
+ resp.Diagnostics.AddError(
+ "Error retrieving {{ .Name }}",
+ "Your query returned more than one result. Please try a more specific search criteria.",
+ )
+ return
+ }
+
+ if {{ .Name | lowerCamel }}s.TotalCount == 0 {
+ resp.Diagnostics.AddError(
+ "Error retrieving {{ .Name }}",
+ fmt.Sprintf("Could not find {{ .Name }} with ID '%s', name '%s'.", cfg.Id.ValueString(), cfg.Name.ValueString()),
+ )
+ return
+ }
+
+ {{ .Name | lowerCamel }} := {{ .Name | lowerCamel }}s.Items[0]
+
+ cfg.Id = types.StringValue({{ .Name | lowerCamel }}.ID)
+ cfg.Name = types.StringValue({{ .Name | lowerCamel }}.Name)
+ cfg.AccountID = types.StringValue({{ .Name | lowerCamel }}.Account.ID)
+
+ resp.Diagnostics.Append(resp.State.Set(ctx, &cfg)...)
+}
diff --git a/skaff/templates/data_source_test.tmpl b/skaff/templates/data_source_test.tmpl
new file mode 100644
index 00000000..d331f081
--- /dev/null
+++ b/skaff/templates/data_source_test.tmpl
@@ -0,0 +1,97 @@
+package provider
+
+import (
+ "fmt"
+ "regexp"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+)
+
+func TestAccScalr{{ .Name | camel }}DataSource_basic(t *testing.T) {
+ {{ .Name | lowerCamel }}Name := acctest.RandomWithPrefix("test-{{ .Name | kebab }}")
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ Steps: []resource.TestStep{
+ {
+ Config: `data scalr_{{ .Name }} test {}`,
+ ExpectError: regexp.MustCompile(`At least one of these attributes must be configured: \[id,name]`),
+ },
+ {
+ Config: `data scalr_{{ .Name }} test {id = ""}`,
+ ExpectError: regexp.MustCompile("Attribute id must not be empty"),
+ },
+ {
+ Config: `data scalr_{{ .Name }} test {name = ""}`,
+ ExpectError: regexp.MustCompile("Attribute name must not be empty"),
+ },
+ {
+ Config: testAccScalr{{ .Name | camel }}DataSourceByIDConfig({{ .Name | lowerCamel }}Name),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttrSet("data.scalr_{{ .Name }}.test", "id"),
+ resource.TestCheckResourceAttr("data.scalr_{{ .Name }}.test", "name", {{ .Name | lowerCamel }}Name),
+ resource.TestCheckResourceAttr("data.scalr_{{ .Name }}.test", "account_id", defaultAccount),
+ ),
+ },
+ {
+ Config: testAccScalr{{ .Name | camel }}DataSourceByNameConfig({{ .Name | lowerCamel }}Name),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttrSet("data.scalr_{{ .Name }}.test", "id"),
+ resource.TestCheckResourceAttr("data.scalr_{{ .Name }}.test", "name", {{ .Name | lowerCamel }}Name),
+ resource.TestCheckResourceAttr("data.scalr_{{ .Name }}.test", "account_id", defaultAccount),
+ ),
+ },
+ {
+ Config: testAccScalr{{ .Name | camel }}DataSourceByIDAndNameConfig({{ .Name | lowerCamel }}Name),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttrSet("data.scalr_{{ .Name }}.test", "id"),
+ resource.TestCheckResourceAttr("data.scalr_{{ .Name }}.test", "name", {{ .Name | lowerCamel }}Name),
+ resource.TestCheckResourceAttr("data.scalr_{{ .Name }}.test", "account_id", defaultAccount),
+ ),
+ },
+ },
+ })
+}
+
+func testAccScalr{{ .Name | camel }}DataSourceByIDConfig(name string) string {
+ return fmt.Sprintf(`
+resource scalr_{{ .Name }} test {
+ name = "%[1]s"
+ account_id = "%[2]s"
+}
+
+data scalr_{{ .Name }} test {
+ id = scalr_{{ .Name }}.test.id
+ account_id = "%[2]s"
+}`, name, defaultAccount)
+}
+
+func testAccScalr{{ .Name | camel }}DataSourceByNameConfig(name string) string {
+ return fmt.Sprintf(`
+resource scalr_{{ .Name }} test {
+ name = "%[1]s"
+ account_id = "%[2]s"
+}
+
+data scalr_{{ .Name }} test {
+ name = scalr_{{ .Name }}.test.name
+ account_id = "%[2]s"
+}`, name, defaultAccount)
+}
+
+func testAccScalr{{ .Name | camel }}DataSourceByIDAndNameConfig(name string) string {
+ return fmt.Sprintf(`
+resource scalr_{{ .Name }} test {
+ name = "%[1]s"
+ account_id = "%[2]s"
+}
+
+data scalr_{{ .Name }} test {
+ id = scalr_{{ .Name }}.test.id
+ name = scalr_{{ .Name }}.test.name
+ account_id = "%[2]s"
+}`, name, defaultAccount)
+}
diff --git a/skaff/templates/resource.tmpl b/skaff/templates/resource.tmpl
new file mode 100644
index 00000000..43ba997a
--- /dev/null
+++ b/skaff/templates/resource.tmpl
@@ -0,0 +1,194 @@
+package provider
+
+import (
+ "context"
+ "errors"
+
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/resource"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/scalr/go-scalr"
+
+ "github.com/scalr/terraform-provider-scalr/internal/framework"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/defaults"
+ "github.com/scalr/terraform-provider-scalr/internal/framework/validation"
+)
+
+// Ensure provider defined types fully satisfy framework interfaces.
+var (
+ _ resource.Resource = &{{ .Name | lowerCamel }}Resource{}
+ _ resource.ResourceWithConfigure = &{{ .Name | lowerCamel }}Resource{}
+ _ resource.ResourceWithConfigValidators = &{{ .Name | lowerCamel }}Resource{}
+ _ resource.ResourceWithImportState = &{{ .Name | lowerCamel }}Resource{}
+)
+
+func new{{ .Name | camel }}Resource() resource.Resource {
+ return &{{ .Name | lowerCamel }}Resource{}
+}
+
+// {{ .Name | lowerCamel }}Resource defines the resource implementation.
+type {{ .Name | lowerCamel }}Resource struct {
+ framework.ResourceWithScalrClient
+}
+
+// {{ .Name | lowerCamel }}ResourceModel describes the resource data model.
+type {{ .Name | lowerCamel }}ResourceModel struct {
+ Id types.String `tfsdk:"id"`
+ Name types.String `tfsdk:"name"`
+ AccountID types.String `tfsdk:"account_id"`
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_{{ .Name }}"
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
+ resp.Schema = schema.Schema{
+ MarkdownDescription: "Manages the state of {{ .Name }}s in Scalr.",
+
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ MarkdownDescription: "The ID of this resource.",
+ Computed: true,
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.UseStateForUnknown(),
+ },
+ },
+ "name": schema.StringAttribute{
+ MarkdownDescription: "Name of the {{ .Name }}.",
+ Required: true,
+ Validators: []validator.String{
+ validation.StringIsNotWhiteSpace(),
+ },
+ },
+ "account_id": schema.StringAttribute{
+ MarkdownDescription: "ID of the account, in the format `acc-`.",
+ Optional: true,
+ Computed: true,
+ Default: defaults.AccountIDRequired(),
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.RequiresReplace(),
+ },
+ },
+ },
+ }
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) ConfigValidators(_ context.Context) []resource.ConfigValidator {
+ // If needed, add config validation logic here,
+ // or remove this method if no additional validation is needed.
+ return []resource.ConfigValidator{}
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var plan {{ .Name | lowerCamel }}ResourceModel
+
+ // Read plan data
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ opts := scalr.{{ .Name | camel }}CreateOptions{
+ Name: plan.Name.ValueStringPointer(),
+ Account: &scalr.Account{ID: plan.AccountID.ValueString()},
+ }
+ {{ .Name | lowerCamel }}, err := r.Client.{{ .Name | camel }}s.Create(ctx, opts)
+ if err != nil {
+ resp.Diagnostics.AddError("Error creating {{ .Name }}", err.Error())
+ return
+ }
+
+ plan.Id = types.StringValue({{ .Name | lowerCamel }}.ID)
+ plan.Name = types.StringValue({{ .Name | lowerCamel }}.Name)
+ plan.AccountID = types.StringValue({{ .Name | lowerCamel }}.Account.ID)
+
+ // Set state to fully populated data
+ resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ // Get current state
+ var state {{ .Name | lowerCamel }}ResourceModel
+ resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ // Get refreshed resource state from API
+ {{ .Name | lowerCamel }}, err := r.Client.{{ .Name | camel }}s.Read(ctx, state.Id.ValueString())
+ if err != nil {
+ if errors.Is(err, scalr.ErrResourceNotFound) {
+ resp.State.RemoveResource(ctx)
+ return
+ }
+ resp.Diagnostics.AddError("Error retrieving {{ .Name }}", err.Error())
+ return
+ }
+
+ // Overwrite attributes with refreshed values
+ state.Name = types.StringValue({{ .Name | lowerCamel }}.Name)
+ state.AccountID = types.StringValue({{ .Name | lowerCamel }}.Account.ID)
+
+ // Set refreshed state
+ resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
+ // Read plan data
+ var plan {{ .Name | lowerCamel }}ResourceModel
+ resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ opts := scalr.{{ .Name | camel }}UpdateOptions{
+ Name: plan.Name.ValueStringPointer(),
+ }
+
+ // Update existing resource
+ {{ .Name | lowerCamel }}, err := r.Client.{{ .Name | camel }}s.Update(ctx, plan.Id.ValueString(), opts)
+ if err != nil {
+ resp.Diagnostics.AddError("Error updating {{ .Name }}", err.Error())
+ return
+ }
+
+ // Overwrite attributes with refreshed values
+ plan.Name = types.StringValue({{ .Name | lowerCamel }}.Name)
+ plan.AccountID = types.StringValue({{ .Name | lowerCamel }}.Account.ID)
+
+ // Set refreshed state
+ resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ // Get current state
+ var state {{ .Name | lowerCamel }}ResourceModel
+ resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
+ if resp.Diagnostics.HasError() {
+ return
+ }
+
+ err := r.Client.{{ .Name | camel }}s.Delete(ctx, state.Id.ValueString())
+ if err != nil && !errors.Is(err, scalr.ErrResourceNotFound) {
+ resp.Diagnostics.AddError("Error deleting {{ .Name }}", err.Error())
+ return
+ }
+}
+
+func (r *{{ .Name | lowerCamel }}Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
+ resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
+}
diff --git a/skaff/templates/resource_test.tmpl b/skaff/templates/resource_test.tmpl
new file mode 100644
index 00000000..d9c3db30
--- /dev/null
+++ b/skaff/templates/resource_test.tmpl
@@ -0,0 +1,5 @@
+package provider
+
+// Please write the tests for the resource manually, as typical tests set is yet to be established later.
+// While migrating to the new framework, the existing tests will be reviewed and updated,
+// and the skaffolded examples will be added here.
From 192362f6c15aeb6a2b9a342bb9a5b050e05eea4c Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Sun, 1 Dec 2024 23:11:46 +0200
Subject: [PATCH 25/26] SCALRCORE-26654 Add skaff readme
---
internal/provider/tag_data_source.go | 2 +-
internal/provider/tag_resource.go | 2 +-
skaff/README.md | 46 ++++++++++++++++++++++++++++
skaff/templates/data_source.tmpl | 2 +-
skaff/templates/resource.tmpl | 2 +-
5 files changed, 50 insertions(+), 4 deletions(-)
create mode 100644 skaff/README.md
diff --git a/internal/provider/tag_data_source.go b/internal/provider/tag_data_source.go
index b3c2ed57..d5767b3b 100644
--- a/internal/provider/tag_data_source.go
+++ b/internal/provider/tag_data_source.go
@@ -16,7 +16,7 @@ import (
"github.com/scalr/terraform-provider-scalr/internal/framework/validation"
)
-// Ensure provider defined types fully satisfy framework interfaces.
+// Compile-time interface checks
var (
_ datasource.DataSource = &tagDataSource{}
_ datasource.DataSourceWithConfigure = &tagDataSource{}
diff --git a/internal/provider/tag_resource.go b/internal/provider/tag_resource.go
index 56b3bd23..93dce349 100644
--- a/internal/provider/tag_resource.go
+++ b/internal/provider/tag_resource.go
@@ -18,7 +18,7 @@ import (
"github.com/scalr/terraform-provider-scalr/internal/framework/validation"
)
-// Ensure provider defined types fully satisfy framework interfaces.
+// Compile-time interface checks
var (
_ resource.Resource = &tagResource{}
_ resource.ResourceWithConfigure = &tagResource{}
diff --git a/skaff/README.md b/skaff/README.md
new file mode 100644
index 00000000..931f6e0e
--- /dev/null
+++ b/skaff/README.md
@@ -0,0 +1,46 @@
+# skaff
+
+A tool that helps to add new resources and data sources to the provider.
+Generates the necessary boilerplate code from templates.
+
+## Usage
+
+The name for new resource or data source should be given in snake_case, lowercase,
+as it will appear in Terraform configuration (without 'scalr_' provider prefix).
+
+For example: `agent_pool`.
+
+### From project's makefile
+
+Makefile contains convenient targets to skaff:
+
+```bash
+make resource name=agent_pool
+```
+
+```bash
+make datasource name=agent_pool
+```
+
+### Run the tool directly
+
+```bash
+cd skaff
+go run cmd/main.go -type=resource -name=agent_pool
+```
+
+```bash
+cd skaff
+go run cmd/main.go -type=data_source -name=agent_pool
+```
+
+## What's next
+
+Review the generated code carefully and make necessary adjustments.
+The tool gives a minimal, simple but full-featured code to start with.
+Templates may be updated and improved in the future.
+
+Please note that the generated code is based on the terraform-provider-framework library only,
+no SDKv2 imports should be used.
+
+Don't forget to add new resource or data source to the provider's `Resources` or `DataSources` functions respectively.
diff --git a/skaff/templates/data_source.tmpl b/skaff/templates/data_source.tmpl
index 63964875..a6ca8d98 100644
--- a/skaff/templates/data_source.tmpl
+++ b/skaff/templates/data_source.tmpl
@@ -16,7 +16,7 @@ import (
"github.com/scalr/terraform-provider-scalr/internal/framework/validation"
)
-// Ensure provider defined types fully satisfy framework interfaces.
+// Compile-time interface checks
var (
_ datasource.DataSource = &{{ .Name | lowerCamel }}DataSource{}
_ datasource.DataSourceWithConfigure = &{{ .Name | lowerCamel }}DataSource{}
diff --git a/skaff/templates/resource.tmpl b/skaff/templates/resource.tmpl
index 43ba997a..1a8bc0d9 100644
--- a/skaff/templates/resource.tmpl
+++ b/skaff/templates/resource.tmpl
@@ -18,7 +18,7 @@ import (
"github.com/scalr/terraform-provider-scalr/internal/framework/validation"
)
-// Ensure provider defined types fully satisfy framework interfaces.
+// Compile-time interface checks
var (
_ resource.Resource = &{{ .Name | lowerCamel }}Resource{}
_ resource.ResourceWithConfigure = &{{ .Name | lowerCamel }}Resource{}
From bac29e013311c0c7bfe02c090295b50ced8e19f8 Mon Sep 17 00:00:00 2001
From: Petro Protsakh
Date: Sun, 1 Dec 2024 23:50:41 +0200
Subject: [PATCH 26/26] SCALRCORE-26654 Add sdk->framework upgrade tests
---
internal/provider/tag_data_source_test.go | 32 ++++++++++++++++++++++
internal/provider/tag_resource_test.go | 33 +++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/internal/provider/tag_data_source_test.go b/internal/provider/tag_data_source_test.go
index 118cc846..84177355 100644
--- a/internal/provider/tag_data_source_test.go
+++ b/internal/provider/tag_data_source_test.go
@@ -95,3 +95,35 @@ data scalr_tag test {
account_id = "%[2]s"
}`, name, defaultAccount)
}
+
+func TestAccScalrTagDataSource_UpgradeFromSDK(t *testing.T) {
+ tagName := acctest.RandomWithPrefix("test-tag")
+
+ resource.Test(t, resource.TestCase{
+ Steps: []resource.TestStep{
+ {
+ ExternalProviders: map[string]resource.ExternalProvider{
+ "scalr": {
+ Source: "registry.scalr.io/scalr/scalr",
+ VersionConstraint: "<=2.2.0",
+ },
+ },
+ Config: testAccScalrTagDataSourceByIDConfig(tagName),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
+ ),
+ },
+ {
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ Config: testAccScalrTagDataSourceByIDConfig(tagName),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
+ resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
+ ),
+ },
+ },
+ })
+}
diff --git a/internal/provider/tag_resource_test.go b/internal/provider/tag_resource_test.go
index 4ea00532..ee3b30e5 100644
--- a/internal/provider/tag_resource_test.go
+++ b/internal/provider/tag_resource_test.go
@@ -6,6 +6,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
@@ -144,3 +145,35 @@ func testAccCheckScalrTagDestroy(s *terraform.State) error {
return nil
}
+
+func TestAccScalrTag_UpgradeFromSDK(t *testing.T) {
+ tagName := acctest.RandomWithPrefix("test-tag")
+
+ resource.Test(t, resource.TestCase{
+ Steps: []resource.TestStep{
+ {
+ ExternalProviders: map[string]resource.ExternalProvider{
+ "scalr": {
+ Source: "registry.scalr.io/scalr/scalr",
+ VersionConstraint: "<=2.2.0",
+ },
+ },
+ Config: testAccScalrTagBasic(tagName),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttrSet("scalr_tag.test", "id"),
+ resource.TestCheckResourceAttr("scalr_tag.test", "name", tagName),
+ resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
+ ),
+ },
+ {
+ ProtoV5ProviderFactories: protoV5ProviderFactories(t),
+ Config: testAccScalrTagBasic(tagName),
+ ConfigPlanChecks: resource.ConfigPlanChecks{
+ PreApply: []plancheck.PlanCheck{
+ plancheck.ExpectEmptyPlan(),
+ },
+ },
+ },
+ },
+ })
+}