diff --git a/go.mod b/go.mod index fbd686732..18352ee46 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,14 @@ go 1.21.1 require ( github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 + github.com/hashicorp/go-hclog v1.5.0 github.com/hashicorp/go-multierror v1.1.1 + github.com/hashicorp/terraform-plugin-framework v1.4.0 + github.com/hashicorp/terraform-plugin-go v0.19.0 github.com/hashicorp/terraform-plugin-log v0.9.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0 + github.com/hashicorp/terraform-plugin-mux v0.12.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 + github.com/hashicorp/terraform-plugin-testing v1.5.1 github.com/hetznercloud/hcloud-go v1.49.0 github.com/stretchr/testify v1.8.4 golang.org/x/crypto v0.13.0 @@ -14,9 +19,9 @@ require ( ) require ( - github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudflare/circl v1.3.3 // indirect @@ -27,17 +32,15 @@ require ( 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-hclog v1.5.0 // indirect - github.com/hashicorp/go-plugin v1.4.10 // indirect + github.com/hashicorp/go-plugin v1.5.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.5.2 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/hashicorp/hc-install v0.6.0 // indirect + github.com/hashicorp/hcl/v2 v2.18.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.18.1 // indirect + github.com/hashicorp/terraform-exec v0.19.0 // indirect github.com/hashicorp/terraform-json v0.17.1 // indirect - github.com/hashicorp/terraform-plugin-go v0.18.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.1 // indirect + github.com/hashicorp/terraform-registry-address v0.2.2 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -59,13 +62,14 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - golang.org/x/mod v0.10.0 // indirect + github.com/zclconf/go-cty v1.14.0 // indirect + golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect + google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 9feed683a..12b9ff843 100644 --- a/go.sum +++ b/go.sum @@ -1,20 +1,23 @@ -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -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= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +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 v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 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/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -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/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -24,14 +27,16 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +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.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= -github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= -github.com/go-git/go-git/v5 v5.6.1/go.mod h1:mvyoL6Unz0PiTQrGQfSfiLFhBH1c1e84ylC2MDs4ee8= +github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A= +github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo= 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/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/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= @@ -57,43 +62,47 @@ github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= 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.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= -github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= +github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k= +github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= 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.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -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/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/hashicorp/hc-install v0.6.0 h1:fDHnU7JNFNSQebVKYhHZ0va1bC6SrPQ8fpebsvNr2w4= +github.com/hashicorp/hc-install v0.6.0/go.mod h1:10I912u3nntx9Umo1VAeYPUUuehk0aRQJYpMwbX5wQA= +github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= +github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= 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-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= +github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= 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-plugin-go v0.18.0 h1:IwTkOS9cOW1ehLd/rG0y+u/TGLK9y6fGoBjXVUquzpE= -github.com/hashicorp/terraform-plugin-go v0.18.0/go.mod h1:l7VK+2u5Kf2y+A+742GX0ouLut3gttudmvMgN0PA74Y= +github.com/hashicorp/terraform-plugin-framework v1.4.0 h1:WKbtCRtNrjsh10eA7NZvC/Qyr7zp77j+D21aDO5th9c= +github.com/hashicorp/terraform-plugin-framework v1.4.0/go.mod h1:XC0hPcQbBvlbxwmjxuV/8sn8SbZRg4XwGMs22f+kqV0= +github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU= +github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec= 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-sdk/v2 v2.28.0 h1:gY4SG34ANc6ZSeWEKC9hDTChY0ZiN+Myon17fSA0Xgc= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0/go.mod h1:deXEw/iJXtJxNV9d1c/OVJrvL7Zh0a++v7rzokW6wVY= -github.com/hashicorp/terraform-registry-address v0.2.1 h1:QuTf6oJ1+WSflJw6WYOHhLgwUiQ0FrROpHPYFtwTYWM= -github.com/hashicorp/terraform-registry-address v0.2.1/go.mod h1:BSE9fIFzp0qWsJUUyGquo4ldV9k2n+psif6NYkBRS3Y= +github.com/hashicorp/terraform-plugin-mux v0.12.0 h1:TJlmeslQ11WlQtIFAfth0vXx+gSNgvMEng2Rn9z3WZY= +github.com/hashicorp/terraform-plugin-mux v0.12.0/go.mod h1:8MR0AgmV+Q03DIjyrAKxXyYlq2EUnYBQP8gxAAA0zeM= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8= +github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c= +github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0= +github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= +github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= 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/hetznercloud/hcloud-go v1.49.0 h1:b/dKaptbbahWrkzYilWi42UgyfpiQ0Qh9ZFvyAgAVoo= github.com/hetznercloud/hcloud-go v1.49.0/go.mod h1:VzDWThl47lOnZXY0q5/LPFD+M62pfe/52TV+mOrpp9Q= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= +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/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -142,8 +151,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= -github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag= +github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= +github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= @@ -163,25 +172,36 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh 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/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -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= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= +github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= +golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +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.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/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-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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -189,32 +209,46 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w 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.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= 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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= -google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= 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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= diff --git a/hcloud/plugin_provider.go b/hcloud/plugin_provider.go new file mode 100644 index 000000000..82e6e6cd0 --- /dev/null +++ b/hcloud/plugin_provider.go @@ -0,0 +1,162 @@ +package hcloud + +import ( + "context" + "fmt" + "os" + "time" + + "github.com/hashicorp/go-hclog" + "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/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/terraform-provider-hcloud/internal/util/tflogutil" +) + +type PluginProvider struct{} + +var _ provider.Provider = &PluginProvider{} + +func NewPluginProvider() provider.Provider { + return &PluginProvider{} +} + +// Metadata should return the metadata for the provider, such as +// a type name and version data. +// +// Implementing the MetadataResponse.TypeName will populate the +// datasource.MetadataRequest.ProviderTypeName and +// resource.MetadataRequest.ProviderTypeName fields automatically. +func (p *PluginProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) { + resp.TypeName = "hcloud" + resp.Version = Version +} + +// Schema should return the schema for this provider. +func (p *PluginProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "token": schema.StringAttribute{ + Description: "The Hetzner Cloud API token, can also be specified with the HCLOUD_TOKEN environment variable.", + Optional: true, + Sensitive: true, + }, + "endpoint": schema.StringAttribute{ + Description: "The Hetzner Cloud API endpoint, can be used to override the default API Endpoint https://api.hetzner.cloud/v1.", + Optional: true, + }, + "poll_interval": schema.StringAttribute{ + Description: "The interval at which actions are polled by the client. Default `500ms`. Increase this interval if you run into rate limiting errors.", + Optional: true, + }, + }, + // TODO: Uncomment once we get rid of the SDK v2 Provider + // MarkdownDescription: `The Hetzner Cloud (hcloud) provider is used to interact with the resources supported by + // [Hetzner Cloud](https://www.hetzner.com/cloud). The provider needs to be configured with the proper credentials + // before it can be used.`, + } +} + +// PluginProviderModel describes the provider data model. +type PluginProviderModel struct { + Token types.String `tfsdk:"token"` + Endpoint types.String `tfsdk:"endpoint"` + PollInterval types.String `tfsdk:"poll_interval"` +} + +// Configure is called at the beginning of the provider lifecycle, when +// Terraform sends to the provider the values the user specified in the +// provider configuration block. These are supplied in the +// ConfigureProviderRequest argument. +// Values from provider configuration are often used to initialize an +// API client, which should be stored on the struct to initialize an +// Provider interface. +func (p *PluginProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { + var data PluginProviderModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + opts := []hcloud.ClientOption{ + hcloud.WithApplication("hcloud-terraform", Version), + } + + endpoint := os.Getenv("HCLOUD_ENDPOINT") + if data.Endpoint.ValueString() != "" { + endpoint = data.Endpoint.ValueString() + } + if endpoint != "" { + opts = append(opts, hcloud.WithEndpoint(endpoint)) + } + + token := os.Getenv("HCLOUD_TOKEN") + if data.Token.ValueString() != "" { + token = data.Token.ValueString() + } + if token != "" { + opts = append(opts, hcloud.WithToken(token)) + } else { + resp.Diagnostics.AddAttributeError( + path.Root("token"), + "Missing Hetzner Cloud API token", + "While configuring the provider, the Hetzner Cloud API token was not found in the HCLOUD_TOKEN environment variable or provider configuration block token attribute.", + ) + } + + if data.PollInterval.ValueString() != "" { + pollInterval, err := time.ParseDuration(data.PollInterval.ValueString()) + if err != nil { + resp.Diagnostics.AddAttributeError( + path.Root("poll_interval"), + "Unparsable poll interval value", + fmt.Sprintf("An unexpected error was encountered trying to parse the value.\n\n%s", err.Error()), + ) + } + opts = append(opts, hcloud.WithPollBackoffFunc(hcloud.ExponentialBackoff(2, pollInterval))) + } + + if resp.Diagnostics.HasError() { + return + } + + // Debug writer + opts = append(opts, + hcloud.WithDebugWriter( + tflogutil.NewWriter( + tflog.NewSubsystem(ctx, "hcloud-go", tflog.WithLevel(hclog.Debug)), + ), + ), + ) + + client := hcloud.NewClient(opts...) + resp.DataSourceData = client + resp.ResourceData = client + + tflog.Info(ctx, "terraform-provider-hcloud info", map[string]any{"version": Version, "commit": Commit}) + tflog.Info(ctx, "hcloud-go info", map[string]any{"version": hcloud.Version}) +} + +// DataSources returns a slice of functions to instantiate each DataSource +// implementation. +// +// The data source type name is determined by the DataSource implementing +// the Metadata method. All data sources must have unique names. +func (p *PluginProvider) DataSources(_ context.Context) []func() datasource.DataSource { + return []func() datasource.DataSource{} +} + +// Resources returns a slice of functions to instantiate each Resource +// implementation. +// +// The resource type name is determined by the Resource implementing +// the Metadata method. All resources must have unique names. +func (p *PluginProvider) Resources(_ context.Context) []func() resource.Resource { + return []func() resource.Resource{} +} diff --git a/hcloud/provider.go b/hcloud/provider.go index 492288624..44bf67c79 100644 --- a/hcloud/provider.go +++ b/hcloud/provider.go @@ -47,7 +47,7 @@ func Provider() *schema.Provider { Type: schema.TypeString, Required: true, DefaultFunc: schema.EnvDefaultFunc("HCLOUD_TOKEN", nil), - Description: "The API token to access the Hetzner cloud.", + Description: "The Hetzner Cloud API token, can also be specified with the HCLOUD_TOKEN environment variable.", ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { token := val.(string) if len(token) != 64 { @@ -61,11 +61,13 @@ func Provider() *schema.Provider { Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("HCLOUD_ENDPOINT", nil), + Description: "The Hetzner Cloud API endpoint, can be used to override the default API Endpoint https://api.hetzner.cloud/v1.", }, "poll_interval": { - Type: schema.TypeString, - Optional: true, - Default: "500ms", + Type: schema.TypeString, + Optional: true, + Default: "500ms", + Description: "The interval at which actions are polled by the client. Default `500ms`. Increase this interval if you run into rate limiting errors.", }, }, ResourcesMap: map[string]*schema.Resource{ diff --git a/internal/certificate/testing.go b/internal/certificate/testing.go index d023727d7..1860e8e9d 100644 --- a/internal/certificate/testing.go +++ b/internal/certificate/testing.go @@ -9,7 +9,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "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/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) diff --git a/internal/e2etests/certificate/data_source_test.go b/internal/e2etests/certificate/data_source_test.go index af15165f9..e4e81e4cf 100644 --- a/internal/e2etests/certificate/data_source_test.go +++ b/internal/e2etests/certificate/data_source_test.go @@ -7,7 +7,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/certificate" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -30,9 +30,9 @@ func TestAccHcloudDataSourceCertificateTest(t *testing.T) { certificateBySel.SetRName("certificate_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.ResourceType, certificate.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.ResourceType, certificate.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -78,9 +78,9 @@ func TestAccHcloudDataSourceCertificateListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.ResourceType, certificate.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.ResourceType, certificate.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/certificate/resource_test.go b/internal/e2etests/certificate/resource_test.go index 0aed17447..cd65d3364 100644 --- a/internal/e2etests/certificate/resource_test.go +++ b/internal/e2etests/certificate/resource_test.go @@ -8,8 +8,8 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/certificate" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" - "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" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -30,9 +30,9 @@ func TestCertificateResource_Uploaded_Basic(t *testing.T) { tmplMan := testtemplate.Manager{} // Not parallel because number of certificates per domain is limited resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.UploadedResourceType, certificate.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.UploadedResourceType, certificate.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Certificate using the required values @@ -77,9 +77,9 @@ func TestCertificateResource_Uploaded_ChangeCertRequiresNewResource(t *testing.T tmplMan := testtemplate.Manager{} // Not parallel because number of certificates per domain is limited resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.UploadedResourceType, certificate.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.UploadedResourceType, certificate.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Certificate using the required values @@ -132,9 +132,9 @@ func TestCertificateResource_Managed_Basic(t *testing.T) { tmplMan := testtemplate.Manager{} // Not parallel because number of certificates per domain is limited resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.ManagedResourceType, certificate.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(certificate.ManagedResourceType, certificate.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Certificate using the required values diff --git a/internal/e2etests/datacenter/data_source_test.go b/internal/e2etests/datacenter/data_source_test.go index 47702ee02..af0aadaf4 100644 --- a/internal/e2etests/datacenter/data_source_test.go +++ b/internal/e2etests/datacenter/data_source_test.go @@ -6,7 +6,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/datacenter" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -22,8 +22,8 @@ func TestAccHcloudDataSourceDatacenterTest(t *testing.T) { } dcByID.SetRName("dc_by_id") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -49,8 +49,8 @@ func TestAccHcloudDataSourceDatacentersTest(t *testing.T) { datacentersD := &datacenter.DDataList{} datacentersD.SetRName("ds") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/firewall/attachment_resource_test.go b/internal/e2etests/firewall/attachment_resource_test.go index c70007cdf..bc6294394 100644 --- a/internal/e2etests/firewall/attachment_resource_test.go +++ b/internal/e2etests/firewall/attachment_resource_test.go @@ -3,7 +3,7 @@ package firewall import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/firewall" @@ -31,8 +31,8 @@ func TestAttachmentResource_Servers(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), CheckDestroy: resource.ComposeAggregateTestCheckFunc( testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &fw)), @@ -76,8 +76,8 @@ func TestAttachmentResource_LabelSelectors(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), CheckDestroy: resource.ComposeAggregateTestCheckFunc( testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &fw)), diff --git a/internal/e2etests/firewall/data_source_test.go b/internal/e2etests/firewall/data_source_test.go index d975a4805..e8819e747 100644 --- a/internal/e2etests/firewall/data_source_test.go +++ b/internal/e2etests/firewall/data_source_test.go @@ -7,7 +7,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/firewall" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -32,9 +32,9 @@ func TestAccHcloudDataSourceFirewallTest(t *testing.T) { // TODO: Move to parallel test once API endpoint is fixed resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -78,9 +78,9 @@ func TestAccHcloudDataSourceFirewallListTest(t *testing.T) { tmplMan := testtemplate.Manager{} // TODO: Move to parallel test once API endpoint is fixed resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/firewall/resource_test.go b/internal/e2etests/firewall/resource_test.go index e795f61b3..8aa0c0dd4 100644 --- a/internal/e2etests/firewall/resource_test.go +++ b/internal/e2etests/firewall/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/firewall" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -69,9 +69,9 @@ func TestFirewallResource_Basic(t *testing.T) { tmplMan := testtemplate.Manager{} // TODO: Move to parallel test once API endpoint is fixed resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), Steps: []resource.TestStep{ { // Create a new Firewall using the required values @@ -147,9 +147,9 @@ func TestFirewallResource_ApplyTo(t *testing.T) { tmplMan := testtemplate.Manager{} // TODO: Move to parallel test once API endpoint is fixed resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), Steps: []resource.TestStep{ { // Create a new Firewall using the required values @@ -195,9 +195,9 @@ func TestFirewallResource_SourceIPs_IPv6Comparison(t *testing.T) { // TODO: Move to parallel test once API endpoint is fixed resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, "testdata/r/hcloud_firewall", res), @@ -228,9 +228,9 @@ func TestFirewallResource_DestinationIPs_IPv6Comparison(t *testing.T) { // TODO: Move to parallel test once API endpoint is fixed resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(firewall.ResourceType, firewall.ByID(t, &f)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, "testdata/r/hcloud_firewall", res), diff --git a/internal/e2etests/floatingip/data_source_test.go b/internal/e2etests/floatingip/data_source_test.go index 42a81a460..c4f360a9c 100644 --- a/internal/e2etests/floatingip/data_source_test.go +++ b/internal/e2etests/floatingip/data_source_test.go @@ -5,11 +5,11 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/floatingip" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -40,9 +40,9 @@ func TestAccHcloudDataSourceFloatingIPTest(t *testing.T) { floatingipBySel.SetRName("floatingip_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -96,9 +96,9 @@ func TestAccHcloudDataSourceFloatingIPListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/floatingip/resource_assignment_test.go b/internal/e2etests/floatingip/resource_assignment_test.go index 6dc52affd..984b7b754 100644 --- a/internal/e2etests/floatingip/resource_assignment_test.go +++ b/internal/e2etests/floatingip/resource_assignment_test.go @@ -4,14 +4,14 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" "github.com/hetznercloud/terraform-provider-hcloud/internal/floatingip" "github.com/hetznercloud/terraform-provider-hcloud/internal/server" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -63,9 +63,9 @@ func TestFloatingIPAssignmentResource_Basic(t *testing.T) { ServerID: resServer2.TFID() + ".id", } resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new RDNS using the required values diff --git a/internal/e2etests/floatingip/resource_test.go b/internal/e2etests/floatingip/resource_test.go index db01270e3..49d8d7bf3 100644 --- a/internal/e2etests/floatingip/resource_test.go +++ b/internal/e2etests/floatingip/resource_test.go @@ -10,7 +10,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/floatingip" "github.com/hetznercloud/terraform-provider-hcloud/internal/server" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -29,9 +29,9 @@ func TestFloatingIPResource_Basic(t *testing.T) { resRenamed.SetRName(res.Name) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fip)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fip)), Steps: []resource.TestStep{ { // Create a new Floating IP using the required values @@ -89,9 +89,9 @@ func TestFloatingIPResource_WithServer(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fip)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fip)), Steps: []resource.TestStep{ { // Create a new Floating IP using the required values @@ -137,9 +137,9 @@ func TestFloatingIPResource_Protection(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fip)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fip)), Steps: []resource.TestStep{ { // Create a new Floating IP using the required values diff --git a/internal/e2etests/image/data_source_test.go b/internal/e2etests/image/data_source_test.go index 31b3a24df..25ab9f5e1 100644 --- a/internal/e2etests/image/data_source_test.go +++ b/internal/e2etests/image/data_source_test.go @@ -6,7 +6,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/image" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -28,9 +28,9 @@ func TestAccHcloudDataSourceImageTest(t *testing.T) { imageByID.SetRName("image_by_id") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -63,9 +63,9 @@ func TestAccHcloudDataSourceImageWithFiltersTest(t *testing.T) { imageByName.SetRName("image_by_name") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - ProviderFactories: e2etests.ProviderFactories(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -89,9 +89,9 @@ func TestAccHcloudDataSourceImageListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/loadbalancer/data_source_test.go b/internal/e2etests/loadbalancer/data_source_test.go index 8e47c5a5b..5b4a95d60 100644 --- a/internal/e2etests/loadbalancer/data_source_test.go +++ b/internal/e2etests/loadbalancer/data_source_test.go @@ -5,9 +5,9 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" @@ -38,9 +38,9 @@ func TestAccHcloudDataSourceLoadBalancerTest(t *testing.T) { lbBySel.SetRName("lb_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -98,9 +98,9 @@ func TestAccHcloudDataSourceLoadBalancerListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/loadbalancer/resource_network_test.go b/internal/e2etests/loadbalancer/resource_network_test.go index 7bc323249..026892b04 100644 --- a/internal/e2etests/loadbalancer/resource_network_test.go +++ b/internal/e2etests/loadbalancer/resource_network_test.go @@ -5,9 +5,9 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" @@ -43,9 +43,9 @@ func TestAccHcloudLoadBalancerNetwork_NetworkID(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -127,9 +127,9 @@ func TestAccHcloudLoadBalancerNetwork_SubNetID(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -180,9 +180,9 @@ func TestAccHcloudLoadBalancerNetwork_CannotAttachToTwoNetworks(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/loadbalancer/resource_service_test.go b/internal/e2etests/loadbalancer/resource_service_test.go index 2ca556f06..e867e58eb 100644 --- a/internal/e2etests/loadbalancer/resource_service_test.go +++ b/internal/e2etests/loadbalancer/resource_service_test.go @@ -5,9 +5,9 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/certificate" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" @@ -25,9 +25,9 @@ func TestAccHcloudLoadBalancerService_TCP(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -99,9 +99,9 @@ func TestAccHcloudLoadBalancerService_HTTP(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { // Create a HTTP service using defaults @@ -213,9 +213,9 @@ func TestAccHcloudLoadBalancerService_HTTP_StickySessions(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { // Create a HTTP service using defaults @@ -261,9 +261,9 @@ func TestAccHcloudLoadBalancerService_HTTPS(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -316,9 +316,9 @@ func TestAccHcloudLoadBalancerService_HTTPS_UpdateUnchangedCertificates(t *testi tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { // Create a new Load Balancer using two certificates @@ -341,9 +341,9 @@ func TestAccHcloudLoadBalancerService_CreateDelete_NoListenPort(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ // HTTP { @@ -398,9 +398,9 @@ func TestAccHcloudLoadBalancerService_ChangeListenPort(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/loadbalancer/resource_target_test.go b/internal/e2etests/loadbalancer/resource_target_test.go index 834fe2cf9..11c0acf99 100644 --- a/internal/e2etests/loadbalancer/resource_target_test.go +++ b/internal/e2etests/loadbalancer/resource_target_test.go @@ -8,8 +8,8 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" - "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/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" @@ -35,9 +35,9 @@ func TestAccHcloudLoadBalancerTarget_ServerTarget(t *testing.T) { } resServer.SetRName("lb-server-target") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -105,9 +105,9 @@ func TestAccHcloudLoadBalancerTarget_ServerTarget_UsePrivateIP(t *testing.T) { } resNetwork.SetRName("lb-target-test-network") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -187,9 +187,9 @@ func TestAccHcloudLoadBalancerTarget_LabelSelectorTarget(t *testing.T) { } resServer.SetRName("lb-server-target") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -263,9 +263,9 @@ func TestAccHcloudLoadBalancerTarget_LabelSelectorTarget_UsePrivateIP(t *testing selector := fmt.Sprintf("tf-test=tf-test-%d", tmplMan.RandInt) resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -338,9 +338,9 @@ func TestAccHcloudLoadBalancerTarget_IPTarget(t *testing.T) { ip := "213.239.214.25" tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/loadbalancer/resource_test.go b/internal/e2etests/loadbalancer/resource_test.go index 5ec1f0b3b..ef846a291 100644 --- a/internal/e2etests/loadbalancer/resource_test.go +++ b/internal/e2etests/loadbalancer/resource_test.go @@ -5,8 +5,8 @@ import ( "strconv" "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" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" @@ -31,9 +31,9 @@ func TestLoadBalancerResource_Basic(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), Steps: []resource.TestStep{ { // Create a new Load Balancer using the required values @@ -86,9 +86,9 @@ func TestLoadBalancerResource_Resize(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), Steps: []resource.TestStep{ { // Create a new Load Balancer using the required values @@ -160,8 +160,8 @@ func TestLoadBalancerResource_InlineTarget(t *testing.T) { resWithoutTargets.SetRName(res.RName()) resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), CheckDestroy: resource.ComposeAggregateTestCheckFunc( testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), @@ -214,9 +214,9 @@ func TestLoadBalancerResource_Protection(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), Steps: []resource.TestStep{ { // Create a new Load Balancer using the required values diff --git a/internal/e2etests/location/data_source_test.go b/internal/e2etests/location/data_source_test.go index 84e0efb76..9029a276c 100644 --- a/internal/e2etests/location/data_source_test.go +++ b/internal/e2etests/location/data_source_test.go @@ -6,7 +6,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/location" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -22,8 +22,8 @@ func TestAccHcloudDataSourceLocationTest(t *testing.T) { } lByID.SetRName("l_by_id") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -53,8 +53,8 @@ func TestAccHcloudDataSourceLocationsTest(t *testing.T) { locationsDS := &location.DDataList{} locationsDS.SetRName("ds") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/network/data_source_test.go b/internal/e2etests/network/data_source_test.go index 63eda913c..4a15ed370 100644 --- a/internal/e2etests/network/data_source_test.go +++ b/internal/e2etests/network/data_source_test.go @@ -5,11 +5,11 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -41,9 +41,9 @@ func TestAccHcloudDataSourceNetworkTest(t *testing.T) { networkBySel.SetRName("network_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -99,9 +99,9 @@ func TestAccHcloudDataSourceNetworkListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/network/resource_route_test.go b/internal/e2etests/network/resource_route_test.go index e153d56e5..a8087c008 100644 --- a/internal/e2etests/network/resource_route_test.go +++ b/internal/e2etests/network/resource_route_test.go @@ -4,12 +4,12 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -31,9 +31,9 @@ func TestNetworkRouteResource_Basic(t *testing.T) { res.SetRName("network-route-test") tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &nw)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &nw)), Steps: []resource.TestStep{ { // Create a new Network using the required values diff --git a/internal/e2etests/network/resource_subnet_test.go b/internal/e2etests/network/resource_subnet_test.go index 7e41ddef9..2a7ef9ff1 100644 --- a/internal/e2etests/network/resource_subnet_test.go +++ b/internal/e2etests/network/resource_subnet_test.go @@ -4,12 +4,12 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -33,9 +33,9 @@ func TestNetworkSubnetResource_Basic(t *testing.T) { res.SetRName("network-subnet-test") tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &nw)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &nw)), Steps: []resource.TestStep{ { // Create a new Network using the required values @@ -85,9 +85,9 @@ func TestNetworkSubnetResource_VSwitch(t *testing.T) { res.SetRName("network-subnet-vswitch-test") tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &nw)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &nw)), Steps: []resource.TestStep{ { // Create a new Network using the required values diff --git a/internal/e2etests/network/resource_test.go b/internal/e2etests/network/resource_test.go index a17c7db4b..6022b50d0 100644 --- a/internal/e2etests/network/resource_test.go +++ b/internal/e2etests/network/resource_test.go @@ -7,7 +7,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -25,9 +25,9 @@ func TestNetworkResource_Basic(t *testing.T) { resRenamed.SetRName(res.Name) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Network using the required values @@ -74,9 +74,9 @@ func TestNetworkResource_IncreaseNetwork(t *testing.T) { resResized.SetRName(res.RName()) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Network using the required values @@ -130,9 +130,9 @@ func TestNetworkResource_Protection(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Network using the required values @@ -179,9 +179,9 @@ func TestNetworkResource_ExposeRouteToVSwitch(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(network.ResourceType, network.ByID(t, &cert)), Steps: []resource.TestStep{ { // Create a new Network using the required values only. diff --git a/internal/e2etests/placementgroup/data_source_test.go b/internal/e2etests/placementgroup/data_source_test.go index 60d0aa545..e49466683 100644 --- a/internal/e2etests/placementgroup/data_source_test.go +++ b/internal/e2etests/placementgroup/data_source_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" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/placementgroup" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" @@ -34,9 +34,9 @@ func TestAccHcloudDataSourcePlacementGroupTest(t *testing.T) { placementGroupBySel.SetRName("placement_group_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(placementgroup.ResourceType, placementgroup.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(placementgroup.ResourceType, placementgroup.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -80,9 +80,9 @@ func TestAccHcloudDataSourcePlacementGroupListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(placementgroup.ResourceType, placementgroup.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(placementgroup.ResourceType, placementgroup.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/placementgroup/resource_test.go b/internal/e2etests/placementgroup/resource_test.go index 4922e4071..ca7898769 100644 --- a/internal/e2etests/placementgroup/resource_test.go +++ b/internal/e2etests/placementgroup/resource_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" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/placementgroup" @@ -30,9 +30,9 @@ func TestPlacementGroupResource_Basic(t *testing.T) { updated.SetRName(res.RName()) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(placementgroup.ResourceType, placementgroup.ByID(t, &g)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(placementgroup.ResourceType, placementgroup.ByID(t, &g)), Steps: []resource.TestStep{ { // Create a new Placement Group using the required values diff --git a/internal/e2etests/primaryip/data_source_test.go b/internal/e2etests/primaryip/data_source_test.go index 9336146ea..f5159a2b0 100644 --- a/internal/e2etests/primaryip/data_source_test.go +++ b/internal/e2etests/primaryip/data_source_test.go @@ -5,9 +5,9 @@ import ( "strconv" "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/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" tfhcloud "github.com/hetznercloud/terraform-provider-hcloud/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/primaryip" diff --git a/internal/e2etests/primaryip/resource_test.go b/internal/e2etests/primaryip/resource_test.go index 81b525e6c..dbdff2e23 100644 --- a/internal/e2etests/primaryip/resource_test.go +++ b/internal/e2etests/primaryip/resource_test.go @@ -5,10 +5,10 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" tfhcloud "github.com/hetznercloud/terraform-provider-hcloud/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" diff --git a/internal/e2etests/rdns/resource_test.go b/internal/e2etests/rdns/resource_test.go index f763a0d2b..8f27ffdc1 100644 --- a/internal/e2etests/rdns/resource_test.go +++ b/internal/e2etests/rdns/resource_test.go @@ -2,11 +2,10 @@ package rdns_test 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/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" @@ -65,9 +64,9 @@ func TestRDNSResource_Server(t *testing.T) { // TODO: Debug issues that causes this to fail when running in parallel resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new RDNS using the required values @@ -131,9 +130,9 @@ func TestRDNSResource_PrimaryIP(t *testing.T) { // TODO: Debug issues that causes this to fail when running in parallel resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(primaryip.ResourceType, primaryip.ByID(t, &primaryIP)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(primaryip.ResourceType, primaryip.ByID(t, &primaryIP)), Steps: []resource.TestStep{ { // Create a new SSH Key using the required values @@ -195,9 +194,9 @@ func TestRDNSResource_FloatingIP(t *testing.T) { // TODO: Debug issues that causes this to fail when running in parallel resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fl)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(floatingip.ResourceType, floatingip.ByID(t, &fl)), Steps: []resource.TestStep{ { // Create a new SSH Key using the required values @@ -266,9 +265,9 @@ func TestRDNSResource_LoadBalancer(t *testing.T) { // TODO: Debug issues that causes this to fail when running in parallel resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, &lb)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/server/data_source_test.go b/internal/e2etests/server/data_source_test.go index 5c6c17fa5..b6a75b079 100644 --- a/internal/e2etests/server/data_source_test.go +++ b/internal/e2etests/server/data_source_test.go @@ -5,11 +5,11 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/server" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/loadbalancer" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -41,9 +41,9 @@ func TestAccHcloudDataSourceServerTest(t *testing.T) { } serverBySel.SetRName("server_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(loadbalancer.ResourceType, loadbalancer.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -93,9 +93,9 @@ func TestAccHcloudDataSourceServerListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/server/resource_network_test.go b/internal/e2etests/server/resource_network_test.go index c171ebb38..ac2b37084 100644 --- a/internal/e2etests/server/resource_network_test.go +++ b/internal/e2etests/server/resource_network_test.go @@ -4,11 +4,11 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" "github.com/hetznercloud/terraform-provider-hcloud/internal/server" @@ -53,9 +53,9 @@ func TestAccHcloudServerNetwork_NetworkID(t *testing.T) { } tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -116,9 +116,9 @@ func TestAccHcloudServerNetwork_SubNetID(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/server/resource_test.go b/internal/e2etests/server/resource_test.go index 777cc56a7..468e69240 100644 --- a/internal/e2etests/server/resource_test.go +++ b/internal/e2etests/server/resource_test.go @@ -8,8 +8,8 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" "github.com/hetznercloud/hcloud-go/hcloud" @@ -41,9 +41,9 @@ func TestServerResource_Basic(t *testing.T) { resRenamed.SetRName(res.Name) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -104,9 +104,9 @@ func TestServerResource_ImageID(t *testing.T) { res.SetRName("server-image-id") tmplMan := testtemplate.Manager{} resource.Test(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -139,9 +139,9 @@ func TestServerResource_Resize(t *testing.T) { resResized.SetRName(res.Name) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -192,9 +192,9 @@ func TestServerResource_ChangeUserData(t *testing.T) { resChangedUserdata.SetRName(res.Name) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -248,9 +248,9 @@ func TestServerResource_ISO(t *testing.T) { res.SetRName("server-iso") tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -342,9 +342,9 @@ func TestServerResource_DirectAttachToNetwork(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, nil)), Steps: []resource.TestStep{ { // Create a new server and directly attach it to a network. @@ -772,9 +772,9 @@ func TestServerResource_Firewalls(t *testing.T) { res2.SetRName(res.RName()) tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -832,9 +832,9 @@ func TestServerResource_PlacementGroup(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -882,9 +882,9 @@ func TestServerResource_Protection(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), Steps: []resource.TestStep{ { // Create a new Server using the required values @@ -931,9 +931,9 @@ func TestServerResource_EmptySSHKey(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - ProviderFactories: e2etests.ProviderFactories(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &srv)), Steps: []resource.TestStep{ { // Create a new Server using the required values diff --git a/internal/e2etests/servertype/data_source_test.go b/internal/e2etests/servertype/data_source_test.go index 8685a7f03..bb27ce1ba 100644 --- a/internal/e2etests/servertype/data_source_test.go +++ b/internal/e2etests/servertype/data_source_test.go @@ -6,7 +6,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/servertype" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -22,8 +22,8 @@ func TestAccHcloudDataSourceServerTypeTest(t *testing.T) { } stByID.SetRName("st_by_id") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -59,8 +59,8 @@ func TestAccHcloudDataSourceServerTypesTest(t *testing.T) { servertypesD := &servertype.DDataList{} servertypesD.SetRName("ds") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/snapshot/resource_test.go b/internal/e2etests/snapshot/resource_test.go index dcda50b2b..caf1b18a4 100644 --- a/internal/e2etests/snapshot/resource_test.go +++ b/internal/e2etests/snapshot/resource_test.go @@ -10,7 +10,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/snapshot" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -47,9 +47,9 @@ func TestSnapshotResource_Basic(t *testing.T) { }} resRenamed.SetRName("snapshot-basic") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(snapshot.ResourceType, snapshot.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(snapshot.ResourceType, snapshot.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Snapshot using the required values diff --git a/internal/e2etests/sshkey/data_source_test.go b/internal/e2etests/sshkey/data_source_test.go index 7ab9c5320..c8c3f2ba1 100644 --- a/internal/e2etests/sshkey/data_source_test.go +++ b/internal/e2etests/sshkey/data_source_test.go @@ -7,7 +7,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) @@ -30,9 +30,9 @@ func TestAccHcloudDataSourceSSHKeyTest(t *testing.T) { sshKeyBySel.SetRName("sshkey_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(sshkey.ResourceType, sshkey.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(sshkey.ResourceType, sshkey.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -78,8 +78,8 @@ func TestAccHcloudDataSourceSSHKeysTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/sshkey/resource_test.go b/internal/e2etests/sshkey/resource_test.go index a3f5bd21e..8ac6c6f00 100644 --- a/internal/e2etests/sshkey/resource_test.go +++ b/internal/e2etests/sshkey/resource_test.go @@ -7,7 +7,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -21,9 +21,9 @@ func TestSSHKeyResource_Basic(t *testing.T) { resRenamed := &sshkey.RData{Name: res.Name + "-renamed", PublicKey: res.PublicKey} resRenamed.SetRName(res.Name) resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(sshkey.ResourceType, sshkey.ByID(t, &sk)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(sshkey.ResourceType, sshkey.ByID(t, &sk)), Steps: []resource.TestStep{ { // Create a new SSH Key using the required values diff --git a/internal/e2etests/testing.go b/internal/e2etests/testing.go index 24c532450..1bd285817 100644 --- a/internal/e2etests/testing.go +++ b/internal/e2etests/testing.go @@ -1,10 +1,14 @@ package e2etests import ( + "context" "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" "github.com/hetznercloud/hcloud-go/hcloud" tfhcloud "github.com/hetznercloud/terraform-provider-hcloud/hcloud" ) @@ -29,18 +33,34 @@ const ( TestLocationName = "hel1" ) -// Providers returns all providers used during acceptance testing. -func Providers() map[string]*schema.Provider { - return map[string]*schema.Provider{ - "hcloud": tfhcloud.Provider(), - } -} +func ProtoV6ProviderFactories() map[string]func() (tfprotov6.ProviderServer, error) { + return map[string]func() (tfprotov6.ProviderServer, error){ + "hcloud": func() (tfprotov6.ProviderServer, error) { + ctx := context.Background() + + upgradedSdkServer, err := tf5to6server.UpgradeServer( + ctx, + tfhcloud.Provider().GRPCProvider, + ) + + if err != nil { + return nil, err + } + + providers := []func() tfprotov6.ProviderServer{ + providerserver.NewProtocol6(tfhcloud.NewPluginProvider()), + func() tfprotov6.ProviderServer { + return upgradedSdkServer + }, + } + + muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...) + + if err != nil { + return nil, err + } -func ProviderFactories() map[string]func() (*schema.Provider, error) { - return map[string]func() (*schema.Provider, error){ - //nolint:unparam - "hcloud": func() (*schema.Provider, error) { - return tfhcloud.Provider(), nil + return muxServer.ProviderServer(), nil }, } } diff --git a/internal/e2etests/volume/data_source_test.go b/internal/e2etests/volume/data_source_test.go index c910fdd71..cf1f32747 100644 --- a/internal/e2etests/volume/data_source_test.go +++ b/internal/e2etests/volume/data_source_test.go @@ -5,9 +5,9 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/server" @@ -45,9 +45,9 @@ func TestAccHcloudDataSourceVolumeTest(t *testing.T) { volBySel.SetRName("vol_by_sel") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -123,9 +123,9 @@ func TestAccHcloudDataSourceAttachedVolumeTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, @@ -192,9 +192,9 @@ func TestAccHcloudDataSourceVolumeListTest(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, nil)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, nil)), Steps: []resource.TestStep{ { Config: tmplMan.Render(t, diff --git a/internal/e2etests/volume/resource_attachment_test.go b/internal/e2etests/volume/resource_attachment_test.go index aa00f19a2..d4cd29837 100644 --- a/internal/e2etests/volume/resource_attachment_test.go +++ b/internal/e2etests/volume/resource_attachment_test.go @@ -4,14 +4,14 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests" "github.com/hetznercloud/terraform-provider-hcloud/internal/sshkey" "github.com/hetznercloud/terraform-provider-hcloud/internal/server" "github.com/hetznercloud/terraform-provider-hcloud/internal/volume" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -64,9 +64,9 @@ func TestVolumeAssignmentResource_Basic(t *testing.T) { ServerID: resServer2.TFID() + ".id", } resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(server.ResourceType, server.ByID(t, &s)), Steps: []resource.TestStep{ { // Create a new Volume attachment using the required values diff --git a/internal/e2etests/volume/resource_test.go b/internal/e2etests/volume/resource_test.go index 09e2dcaeb..b89df30db 100644 --- a/internal/e2etests/volume/resource_test.go +++ b/internal/e2etests/volume/resource_test.go @@ -8,7 +8,7 @@ import ( "github.com/hetznercloud/terraform-provider-hcloud/internal/server" "github.com/hetznercloud/terraform-provider-hcloud/internal/volume" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" @@ -31,9 +31,9 @@ func TestVolumeResource_Basic(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), Steps: []resource.TestStep{ { // Create a new Volume using the required values @@ -90,9 +90,9 @@ func TestVolumeResource_Resize(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), Steps: []resource.TestStep{ { // Create a new Volume using the required values @@ -156,9 +156,9 @@ func TestVolumeResource_WithServer(t *testing.T) { resAnotherServer.SetRName(res.RName()) resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), Steps: []resource.TestStep{ { // Create a new Volume using the required values @@ -226,9 +226,9 @@ func TestVolumeResource_WithServerMultipleVolumes(t *testing.T) { resAnotherVolume.SetRName("another-volume") resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), Steps: []resource.TestStep{ { // Create a new Volume using the required values @@ -269,9 +269,9 @@ func TestVolumeResource_Protection(t *testing.T) { tmplMan := testtemplate.Manager{} resource.ParallelTest(t, resource.TestCase{ - PreCheck: e2etests.PreCheck(t), - Providers: e2etests.Providers(), - CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), + PreCheck: e2etests.PreCheck(t), + ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(), + CheckDestroy: testsupport.CheckResourcesDestroyed(volume.ResourceType, volume.ByID(t, &vol)), Steps: []resource.TestStep{ { // Create a new Volume using the required values diff --git a/internal/firewall/testing.go b/internal/firewall/testing.go index e88538c6e..6d6f86418 100644 --- a/internal/firewall/testing.go +++ b/internal/firewall/testing.go @@ -7,7 +7,7 @@ import ( "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/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/floatingip/testing.go b/internal/floatingip/testing.go index 689231163..7b0da877e 100644 --- a/internal/floatingip/testing.go +++ b/internal/floatingip/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/hcclient/error_framework.go b/internal/hcclient/error_framework.go new file mode 100644 index 000000000..b57d349a4 --- /dev/null +++ b/internal/hcclient/error_framework.go @@ -0,0 +1,63 @@ +package hcclient + +import ( + "errors" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/diag" + + "github.com/hetznercloud/hcloud-go/hcloud" +) + +// APIErrorDiagnostics creates diagnostics from the errors that occurred during an API requests. +func APIErrorDiagnostics(err error) diag.Diagnostics { + var diagnostics diag.Diagnostics + var hcloudErr hcloud.Error + + if errors.As(err, &hcloudErr) { + if hcloud.IsError(hcloudErr, hcloud.ErrorCodeInvalidInput) { + invalidInput := hcloudErr.Details.(hcloud.ErrorDetailsInvalidInput) + for _, field := range invalidInput.Fields { + messages := make([]string, 0, len(field.Messages)) + for _, message := range field.Messages { + messages = append(messages, fmt.Sprintf(" - %s", message)) + } + + diagnostics.AddError( + "Invalid field in API request", + fmt.Sprintf( + "An invalid field was encountered during an API request. "+ + "The field might not map 1:1 to your terraform resource.\n\n"+ + "%s\n\n"+ + "Field: %s\n"+ + "Messages:\n%s\n"+ + "Error code: %s\n", + err.Error(), field.Name, strings.Join(messages, "\n"), hcloudErr.Code, + )) + } + return diagnostics + } + + diagnostics.AddError( + "API request failed", + fmt.Sprintf( + "An unexpected error was encountered during an API request.\n\n"+ + "%s\n\n"+ + "Error code: %s\n", + hcloudErr.Message, hcloudErr.Code, + ), + ) + return diagnostics + } + + diagnostics.AddError( + "API request failed", + fmt.Sprintf( + "An unexpected error was encountered during an API request.\n\n"+ + "%s\n", + err.Error(), + ), + ) + return diagnostics +} diff --git a/internal/hcclient/error_framework_test.go b/internal/hcclient/error_framework_test.go new file mode 100644 index 000000000..d372d8862 --- /dev/null +++ b/internal/hcclient/error_framework_test.go @@ -0,0 +1,81 @@ +package hcclient + +import ( + "fmt" + "reflect" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hetznercloud/hcloud-go/hcloud" +) + +func TestAPIErrorDiagnostics(t *testing.T) { + for _, tc := range []struct { + name string + err error + diagnostics diag.Diagnostics + }{ + { + name: "hcloud invalid input error", + err: hcloud.Error{ + Code: hcloud.ErrorCodeInvalidInput, + Message: "something is fishy", + Details: hcloud.ErrorDetailsInvalidInput{ + Fields: []hcloud.ErrorDetailsInvalidInputField{ + {Name: "foobar", Messages: []string{"must be bar", "foo too long"}}, + }, + }, + }, + diagnostics: []diag.Diagnostic{ + diag.NewErrorDiagnostic( + "Invalid field in API request", + `An invalid field was encountered during an API request. The field might not map 1:1 to your terraform resource. + +something is fishy (invalid_input) + +Field: foobar +Messages: + - must be bar + - foo too long +Error code: invalid_input +`), + }, + }, + { + name: "hcloud error", + err: hcloud.Error{ + Code: hcloud.ErrorCodeRateLimitExceeded, + Message: "rate limit exceeded", + }, + diagnostics: []diag.Diagnostic{ + diag.NewErrorDiagnostic( + "API request failed", + `An unexpected error was encountered during an API request. + +rate limit exceeded + +Error code: rate_limit_exceeded +`), + }, + }, + { + name: "generic error", + err: fmt.Errorf("something broke :("), + diagnostics: []diag.Diagnostic{ + diag.NewErrorDiagnostic( + "API request failed", + `An unexpected error was encountered during an API request. + +something broke :( +`), + }, + }, + } { + t.Run(tc.name, func(t *testing.T) { + diags := APIErrorDiagnostics(tc.err) + if !reflect.DeepEqual(diags, tc.diagnostics) { + t.Errorf("expected %+v\n\nfound %+v", tc.diagnostics, diags) + } + }) + } +} diff --git a/internal/hcclient/error.go b/internal/hcclient/error_sdk.go similarity index 100% rename from internal/hcclient/error.go rename to internal/hcclient/error_sdk.go diff --git a/internal/hcclient/error_test.go b/internal/hcclient/error_sdk_test.go similarity index 100% rename from internal/hcclient/error_test.go rename to internal/hcclient/error_sdk_test.go diff --git a/internal/loadbalancer/resource_target.go b/internal/loadbalancer/resource_target.go index 91c7f0a69..f10ef14a1 100644 --- a/internal/loadbalancer/resource_target.go +++ b/internal/loadbalancer/resource_target.go @@ -181,7 +181,7 @@ func resourceLoadBalancerCreateServerTarget( } action, _, err := client.LoadBalancer.AddServerTarget(ctx, lb, opts) if err != nil { - if hcloud.IsError(err, "target_already_defined") { // TODO: use const when hcloud go is released + if hcloud.IsError(err, hcloud.ErrorCodeTargetAlreadyDefined) { return nil, tgt, nil } return nil, tgt, fmt.Errorf("add server target: %v", err) diff --git a/internal/loadbalancer/testing.go b/internal/loadbalancer/testing.go index eeaf7006d..96273359b 100644 --- a/internal/loadbalancer/testing.go +++ b/internal/loadbalancer/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/certificate" "github.com/hetznercloud/terraform-provider-hcloud/internal/network" diff --git a/internal/network/testing.go b/internal/network/testing.go index 8a94d1592..6681b1587 100644 --- a/internal/network/testing.go +++ b/internal/network/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/primaryip/testing.go b/internal/primaryip/testing.go index 4f5cbce85..d67be300d 100644 --- a/internal/primaryip/testing.go +++ b/internal/primaryip/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/rdns/testing.go b/internal/rdns/testing.go index 5519a3a85..63c7d81d6 100644 --- a/internal/rdns/testing.go +++ b/internal/rdns/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" ) diff --git a/internal/server/testing.go b/internal/server/testing.go index b88ba1c67..a15426d70 100644 --- a/internal/server/testing.go +++ b/internal/server/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/snapshot/testing.go b/internal/snapshot/testing.go index 106d7daf1..e122e07c4 100644 --- a/internal/snapshot/testing.go +++ b/internal/snapshot/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/sshkey/testing.go b/internal/sshkey/testing.go index d2b25330d..3e3482c00 100644 --- a/internal/sshkey/testing.go +++ b/internal/sshkey/testing.go @@ -7,7 +7,7 @@ import ( "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/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/internal/testsupport/check.go b/internal/testsupport/check.go index 1d22f3fcf..498651c3a 100644 --- a/internal/testsupport/check.go +++ b/internal/testsupport/check.go @@ -6,8 +6,8 @@ import ( "strconv" "github.com/hashicorp/go-multierror" - "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/hetznercloud/hcloud-go/hcloud" ) diff --git a/internal/util/tflogutil/writer.go b/internal/util/tflogutil/writer.go new file mode 100644 index 000000000..bf13acf36 --- /dev/null +++ b/internal/util/tflogutil/writer.go @@ -0,0 +1,25 @@ +package tflogutil + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Writer wraps the logging interface terraform provides in a [io.Writer] interface +// that hcloud-go expects for its HTTP logs. +type Writer struct { + // Context holds the tflog writer that is used to write the logs to. + ctx context.Context +} + +func (w *Writer) Write(p []byte) (n int, err error) { + tflog.Debug(w.ctx, string(p)) + return len(p), nil +} + +func NewWriter(ctx context.Context) *Writer { + return &Writer{ + ctx: ctx, + } +} diff --git a/internal/volume/testing.go b/internal/volume/testing.go index 6c5cd9bad..75d5a3fb2 100644 --- a/internal/volume/testing.go +++ b/internal/volume/testing.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport" "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate" diff --git a/main.go b/main.go index a37adcc2f..e3919dbf5 100644 --- a/main.go +++ b/main.go @@ -1,25 +1,62 @@ package main import ( + "context" "flag" + "log" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server" + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" - "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" "github.com/hetznercloud/terraform-provider-hcloud/hcloud" ) func main() { - var debugMode bool + ctx := context.Background() + + var debug bool - flag.BoolVar(&debugMode, "debuggable", false, "set to true to run the provider with support for debuggers like delve") + flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") flag.Parse() - if debugMode { - plugin.Serve(&plugin.ServeOpts{ - ProviderAddr: "registry.terraform.io/hetznercloud/hcloud", - ProviderFunc: hcloud.Provider, - }) - } else { - plugin.Serve(&plugin.ServeOpts{ - ProviderFunc: hcloud.Provider}) + upgradedSdkServer, err := tf5to6server.UpgradeServer( + ctx, + hcloud.Provider().GRPCProvider, + ) + + if err != nil { + log.Fatal(err) + } + + providers := []func() tfprotov6.ProviderServer{ + providerserver.NewProtocol6(hcloud.NewPluginProvider()), + func() tfprotov6.ProviderServer { + return upgradedSdkServer + }, + } + + muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...) + + if err != nil { + log.Fatal(err) + } + + var serveOpts []tf6server.ServeOpt + + if debug { + serveOpts = append(serveOpts, tf6server.WithManagedDebug()) + } + + err = tf6server.Serve( + "registry.terraform.io/hetznercloud/hcloud", + muxServer.ProviderServer, + serveOpts..., + ) + + if err != nil { + log.Fatal(err) } }