From 42064bb23fb7511ec1b14e3028a221ebc73bb681 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Mon, 27 Apr 2026 16:28:50 +0200 Subject: [PATCH 1/5] fix: update go version and dependencies --- .github/actions/acc_test/action.yaml | 2 +- .github/actions/build/action.yaml | 2 +- .github/actions/setup-cache-go/action.yaml | 2 +- go.mod | 20 ++++++++++---------- go.sum | 21 +++++++++++++++++++++ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index e43ceeff..b656d5a5 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -14,7 +14,7 @@ inputs: go-version: description: "go version to install" - default: '1.25' + default: '1.26' required: true project_id: diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index 7bea976a..b9256143 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -3,7 +3,7 @@ description: "Build pipeline" inputs: go-version: description: "Go version to install" - default: '1.25' + default: '1.26' required: true java-distribution: description: "JAVA distribution to use (default: temurin)" diff --git a/.github/actions/setup-cache-go/action.yaml b/.github/actions/setup-cache-go/action.yaml index d352db76..eb12595f 100644 --- a/.github/actions/setup-cache-go/action.yaml +++ b/.github/actions/setup-cache-go/action.yaml @@ -10,7 +10,7 @@ inputs: go-version: description: "go version to install" - default: '1.25' + default: '1.26' required: true runs: diff --git a/go.mod b/go.mod index b9cf8d3f..4b185bc7 100644 --- a/go.mod +++ b/go.mod @@ -1,25 +1,25 @@ module tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview -go 1.25.6 +go 1.26.2 require ( - github.com/SladkyCitron/slogcolor v1.8.0 + github.com/SladkyCitron/slogcolor v1.9.0 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/hashicorp/terraform-plugin-framework v1.19.0 github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 github.com/hashicorp/terraform-plugin-go v0.31.0 github.com/hashicorp/terraform-plugin-log v0.10.0 - github.com/hashicorp/terraform-plugin-testing v1.15.0 + github.com/hashicorp/terraform-plugin-testing v1.16.0 github.com/iancoleman/strcase v0.3.0 github.com/ivanpirog/coloredcobra v1.0.1 github.com/jarcoal/httpmock v1.4.1 github.com/joho/godotenv v1.5.1 github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1 github.com/spf13/cobra v1.10.2 - github.com/stackitcloud/stackit-sdk-go/core v0.25.0 - github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.1 - github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.0 + github.com/stackitcloud/stackit-sdk-go/core v0.26.0 + github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.2 + github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.1 github.com/teambition/rrule-go v1.8.2 gopkg.in/yaml.v3 v3.0.1 ) @@ -44,10 +44,10 @@ require ( github.com/hashicorp/go-plugin v1.7.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.9.0 // indirect - github.com/hashicorp/hc-install v0.9.3 // indirect + github.com/hashicorp/hc-install v0.9.4 // indirect github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.25.0 // indirect + github.com/hashicorp/terraform-exec v0.25.1 // indirect github.com/hashicorp/terraform-json v0.27.2 // indirect github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0 // indirect github.com/hashicorp/terraform-registry-address v0.4.0 // indirect @@ -55,7 +55,7 @@ require ( github.com/hashicorp/yamux v0.1.2 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.21 // indirect + github.com/mattn/go-isatty v0.0.22 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect @@ -76,7 +76,7 @@ require ( golang.org/x/text v0.36.0 // indirect golang.org/x/tools v0.44.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260420184626-e10c466a9529 // indirect google.golang.org/grpc v1.80.0 // indirect google.golang.org/protobuf v1.36.11 // indirect ) diff --git a/go.sum b/go.sum index a4709994..92860e4b 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67 github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo= github.com/SladkyCitron/slogcolor v1.8.0 h1:ln4mUPfVhs7a/vZfjnKkz5YZ71Bg/KFWneS2hfFq6FM= github.com/SladkyCitron/slogcolor v1.8.0/go.mod h1:ft8LEVIl4isUkebakhv+ngNXJjWBumnwhXfxTLApf3M= +github.com/SladkyCitron/slogcolor v1.9.0 h1:fr4LeG+T6pZ1RYNNOP925jaBYrTdpA6BLzGy29yd4vI= +github.com/SladkyCitron/slogcolor v1.9.0/go.mod h1:ft8LEVIl4isUkebakhv+ngNXJjWBumnwhXfxTLApf3M= 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= @@ -34,8 +36,10 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= +github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0= github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s= github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M= +github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -82,12 +86,16 @@ github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaX github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hc-install v0.9.3 h1:1H4dgmgzxEVwT6E/d/vIL5ORGVKz9twRwDw+qA5Hyho= github.com/hashicorp/hc-install v0.9.3/go.mod h1:FQlQ5I3I/X409N/J1U4pPeQQz1R3BoV0IysB7aiaQE0= +github.com/hashicorp/hc-install v0.9.4 h1:KKWOpUG0EqIV63Qk2GGFrZ0s275NVs5lKf9N5vjBNoc= +github.com/hashicorp/hc-install v0.9.4/go.mod h1:4LRYeEN2bMIFfIv57ldMWt9awfuZhvpbRt0vWmv51WU= github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= 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.25.0 h1:Bkt6m3VkJqYh+laFMrWIpy9KHYFITpOyzRMNI35rNaY= github.com/hashicorp/terraform-exec v0.25.0/go.mod h1:dl9IwsCfklDU6I4wq9/StFDp7dNbH/h5AnfS1RmiUl8= +github.com/hashicorp/terraform-exec v0.25.1 h1:PRutYRGM8pixV3B8812NYoBK5O+yuf3qcB/70KFKGiU= +github.com/hashicorp/terraform-exec v0.25.1/go.mod h1:+izOYrs9sKMQK4OYvGDnrSSJHY/pm4e4eXFqSL2Q5mA= github.com/hashicorp/terraform-json v0.27.2 h1:BwGuzM6iUPqf9JYM/Z4AF1OJ5VVJEEzoKST/tRDBJKU= github.com/hashicorp/terraform-json v0.27.2/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE= github.com/hashicorp/terraform-plugin-framework v1.19.0 h1:q0bwyhxAOR3vfdgbk9iplv3MlTv/dhBHTXjQOtQDoBA= @@ -102,6 +110,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0 h1:MKS/2URqeJRwJdbOfcbdsZCq github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0/go.mod h1:PuG4P97Ju3QXW6c6vRkRadWJbvnEu2Xh+oOuqcYOqX4= github.com/hashicorp/terraform-plugin-testing v1.15.0 h1:/fimKyl0YgD7aAtJkuuAZjwBASXhCIwWqMbDLnKLMe4= github.com/hashicorp/terraform-plugin-testing v1.15.0/go.mod h1:bGXMw7bE95EiZhSBV3rM2W8TiffaPTDuLS+HFI/lIYs= +github.com/hashicorp/terraform-plugin-testing v1.16.0 h1:GB97nGnJ1hESpDrCjqZig38RodSF0gdRzxlDupLXP38= +github.com/hashicorp/terraform-plugin-testing v1.16.0/go.mod h1:eQPYAy9xFMV7xtIFX8Y+wJGtUB++HBl329zCF6PBMZk= github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk= github.com/hashicorp/terraform-registry-address v0.4.0/go.mod h1:LRS1Ay0+mAiRkUyltGT+UHWkIqTFvigGn/LbMshfflE= github.com/hashicorp/terraform-svchost v0.2.1 h1:ubvrTFw3Q7CsoEaX7V06PtCTKG3wu7GyyobAoN4eF3Q= @@ -129,6 +139,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -142,6 +153,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs= github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= +github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= +github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/maxatome/go-testdeep v1.14.0 h1:rRlLv1+kI8eOI3OaBXZwb3O7xY3exRzdW5QyX48g9wI= github.com/maxatome/go-testdeep v1.14.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -177,10 +190,16 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stackitcloud/stackit-sdk-go/core v0.25.0 h1:ra3VEk684MNoq741g+xbZrKjZzhyztq5liUAwwew4DY= github.com/stackitcloud/stackit-sdk-go/core v0.25.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.1 h1:BWa9O8iRU1l8izGIoH9/+GEF20uu8WDWSesqjdJ3+lg= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.1/go.mod h1:xBWn0vpyyh+IA4muynufqIKmc1fJPPp+uY/iXwa5epE= +github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.2 h1:VIekoX8eCvSgO9HEr4j+z5SKApN2DgfXudSt02zU6Is= +github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.2/go.mod h1:yzlakB+f8ur4yAHR6lyCABO+HcEtZG3G2Faj6m5/uW8= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.0 h1:dv+8GYcI2G0BQvMN5Qb4kaCREaj9n2lRzj9sb29NEZg= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.0/go.mod h1:HTpVer71ZfpKozpzWVv7EbCPB5ko8vgw4VmFE38lB9I= +github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.1 h1:wPqWAZX70u2VWIU0PCNhayff8OmGTpI4dZ7VkROwqco= +github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.1/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= @@ -268,6 +287,8 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw= google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260420184626-e10c466a9529 h1:XF8+t6QQiS0o9ArVan/HW8Q7cycNPGsJf6GA2nXxYAg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260420184626-e10c466a9529/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM= google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= From b51d6369f24e18a0d8f62ea4b3aeb169b9c91aa0 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Tue, 28 Apr 2026 16:38:09 +0200 Subject: [PATCH 2/5] fix: deactivate acc tests for sql server alpha --- ...rverflex_acc_test.go => sqlserverflex_acc_test.go.deactivated} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename stackit/internal/services/sqlserverflexalpha/{sqlserverflex_acc_test.go => sqlserverflex_acc_test.go.deactivated} (100%) diff --git a/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go.deactivated similarity index 100% rename from stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go rename to stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go.deactivated From b56a41dc04df2b9f34e466bfdf0b55ec0ffa4493 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Thu, 7 May 2026 06:15:59 +0200 Subject: [PATCH 3/5] fix: #106 postgresflex flavor datasource feat: support V2 and V3 flavor handling in postgresflex --- .../postgresflexalpha_instance.md | 8 +- .../sqlserverflexalpha_database.md | 32 - .../sqlserverflexalpha_instance.md | 77 --- docs/data-sources/sqlserverflexalpha_user.md | 62 -- docs/resources/postgresflexalpha_instance.md | 19 +- docs/resources/sqlserverflexalpha_database.md | 63 -- docs/resources/sqlserverflexalpha_instance.md | 103 ---- docs/resources/sqlserverflexalpha_user.md | 53 -- go.mod | 39 +- go.sum | 138 +++-- sample/alpha-from-registry/sqlserver.tf | 101 ---- sample/postgres/postresql.tf | 19 +- sample/tf.sh | 5 +- ...n_config.yml.bak => collations_config.yml} | 0 ...ion_config.yml.bak => versions_config.yml} | 0 ...fig.yml.disabled => collations_config.yml} | 2 +- .../sqlserverflex/beta/versions_config.yml | 2 +- .../postgresflexalpha/flavor/datasource.go | 4 +- .../postgresflexalpha/flavors/datasource.go | 2 +- .../postgresflexalpha/flavors/functions.go | 65 ++ .../flavors/functions_test.go | 135 +++++ .../instance_data_source_gen.go | 11 +- .../instance/flavor_functions.go | 65 ++ .../instance/flavor_functions_test.go | 135 +++++ .../postgresflexalpha/instance/functions.go | 4 +- .../postgresflexalpha/instance/resource.go | 167 ++++- .../resources_gen/instance_resource_gen.go | 30 +- ...or_unknown_if_flavor_unchanged_modifier.go | 85 +++ .../instance_template_with_flavor.gompl | 101 ++++ .../collations_data_source_gen.go | 451 ++++++++++++++ .../versions_data_source_gen.go | 569 +++++++++++++++++ .../collations_data_source_gen.go | 452 ++++++++++++++ .../versions_data_source_gen.go | 570 ++++++++++++++++++ stackit/provider.go | 21 +- 34 files changed, 2986 insertions(+), 604 deletions(-) delete mode 100644 docs/data-sources/sqlserverflexalpha_database.md delete mode 100644 docs/data-sources/sqlserverflexalpha_instance.md delete mode 100644 docs/data-sources/sqlserverflexalpha_user.md delete mode 100644 docs/resources/sqlserverflexalpha_database.md delete mode 100644 docs/resources/sqlserverflexalpha_instance.md delete mode 100644 docs/resources/sqlserverflexalpha_user.md delete mode 100644 sample/alpha-from-registry/sqlserver.tf rename service_specs/sqlserverflex/alpha/{collation_config.yml.bak => collations_config.yml} (100%) rename service_specs/sqlserverflex/alpha/{version_config.yml.bak => versions_config.yml} (100%) rename service_specs/sqlserverflex/beta/{collation_config.yml.disabled => collations_config.yml} (92%) create mode 100644 stackit/internal/services/postgresflexalpha/flavors/functions.go create mode 100644 stackit/internal/services/postgresflexalpha/flavors/functions_test.go create mode 100644 stackit/internal/services/postgresflexalpha/instance/flavor_functions.go create mode 100644 stackit/internal/services/postgresflexalpha/instance/flavor_functions_test.go create mode 100644 stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go create mode 100644 stackit/internal/services/postgresflexalpha/testdata/instance_template_with_flavor.gompl create mode 100644 stackit/internal/services/sqlserverflexalpha/collations/datasources_gen/collations_data_source_gen.go create mode 100644 stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/versions_data_source_gen.go create mode 100644 stackit/internal/services/sqlserverflexbeta/collations/datasources_gen/collations_data_source_gen.go create mode 100644 stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/versions_data_source_gen.go diff --git a/docs/data-sources/postgresflexalpha_instance.md b/docs/data-sources/postgresflexalpha_instance.md index cb1d183a..0652d28b 100644 --- a/docs/data-sources/postgresflexalpha_instance.md +++ b/docs/data-sources/postgresflexalpha_instance.md @@ -42,10 +42,16 @@ data "stackitprivatepreview_postgresflexalpha_instance" "example" { - `flavor_id` (String) The id of the instance flavor. - `id` (String) internal ID - `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `labels` (Map of String) Key-value pairs, 63 characters max, begin and end with an alphanumerical character, +may contain dashes (-), underscores (_), dots (.), and alphanumerics between. Key MUST be at least 1 character. +Max 64 labels +Regex for keys: ^(?=.{1,63}$)([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$ +Regex for values: ^(?=.{0,63}$)(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])*$ +The stackit- prefix is reserved and cannot be used for Keys. - `name` (String) The name of the instance. - `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) - `replicas` (Number) How many replicas the instance should have. -- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 365 days. +- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 90 days. - `status` (String) The current status of the instance. - `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) - `tf_original_api_id` (String) The ID of the instance. diff --git a/docs/data-sources/sqlserverflexalpha_database.md b/docs/data-sources/sqlserverflexalpha_database.md deleted file mode 100644 index df66ffb7..00000000 --- a/docs/data-sources/sqlserverflexalpha_database.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackitprivatepreview_sqlserverflexalpha_database Data Source - stackitprivatepreview" -subcategory: "" -description: |- - ---- - -# stackitprivatepreview_sqlserverflexalpha_database (Data Source) - - - - - - -## Schema - -### Required - -- `database_name` (String) The name of the database. -- `instance_id` (String) The ID of the instance. -- `project_id` (String) The STACKIT project ID. -- `region` (String) The region which should be addressed - -### Read-Only - -- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. -- `compatibility_level` (Number) CompatibilityLevel of the Database. -- `id` (String) The terraform internal identifier. -- `name` (String) The name of the database. -- `owner` (String) The owner of the database. -- `tf_original_api_id` (Number) The id of the database. diff --git a/docs/data-sources/sqlserverflexalpha_instance.md b/docs/data-sources/sqlserverflexalpha_instance.md deleted file mode 100644 index b05d7b8e..00000000 --- a/docs/data-sources/sqlserverflexalpha_instance.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackitprivatepreview_sqlserverflexalpha_instance Data Source - stackitprivatepreview" -subcategory: "" -description: |- - ---- - -# stackitprivatepreview_sqlserverflexalpha_instance (Data Source) - - - -## Example Usage - -```terraform -data "stackitprivatepreview_sqlserverflexalpha_instance" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` - - -## Schema - -### Required - -- `instance_id` (String) The ID of the instance. -- `project_id` (String) The STACKIT project ID. -- `region` (String) The region which should be addressed - -### Read-Only - -- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. -- `edition` (String) Edition of the MSSQL server instance -- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption)) -- `flavor_id` (String) The id of the instance flavor. -- `is_deletable` (Boolean) Whether the instance can be deleted or not. -- `name` (String) The name of the instance. -- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) -- `replicas` (Number) How many replicas the instance should have. -- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365 -- `status` (String) -- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) -- `tf_original_api_id` (String) The ID of the instance. -- `version` (String) The sqlserver version used for the instance. - - -### Nested Schema for `encryption` - -Read-Only: - -- `kek_key_id` (String) The key identifier -- `kek_key_ring_id` (String) The keyring identifier -- `kek_key_version` (String) The key version -- `service_account` (String) - - - -### Nested Schema for `network` - -Read-Only: - -- `access_scope` (String) The network access scope of the instance - -⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. -- `acl` (List of String) List of IPV4 cidr. -- `instance_address` (String) -- `router_address` (String) - - - -### Nested Schema for `storage` - -Read-Only: - -- `class` (String) The storage class for the storage. -- `size` (Number) The storage size in Gigabytes. diff --git a/docs/data-sources/sqlserverflexalpha_user.md b/docs/data-sources/sqlserverflexalpha_user.md deleted file mode 100644 index 63526135..00000000 --- a/docs/data-sources/sqlserverflexalpha_user.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackitprivatepreview_sqlserverflexalpha_user Data Source - stackitprivatepreview" -subcategory: "" -description: |- - ---- - -# stackitprivatepreview_sqlserverflexalpha_user (Data Source) - - - -## Example Usage - -```terraform -data "stackitprivatepreview_sqlserverflexalpha_user" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` - - -## Schema - -### Required - -- `instance_id` (String) The ID of the instance. -- `project_id` (String) The STACKIT project ID. -- `region` (String) The region which should be addressed - -### Optional - -- `page` (Number) Number of the page of items list to be returned. -- `size` (Number) Number of items to be returned on each page. -- `sort` (String) Sorting of the users to be returned on each page. - -### Read-Only - -- `pagination` (Attributes) (see [below for nested schema](#nestedatt--pagination)) -- `users` (Attributes List) List of all users inside an instance (see [below for nested schema](#nestedatt--users)) - - -### Nested Schema for `pagination` - -Read-Only: - -- `page` (Number) -- `size` (Number) -- `sort` (String) -- `total_pages` (Number) -- `total_rows` (Number) - - - -### Nested Schema for `users` - -Read-Only: - -- `status` (String) The current status of the user. -- `tf_original_api_id` (Number) The ID of the user. -- `username` (String) The name of the user. diff --git a/docs/resources/postgresflexalpha_instance.md b/docs/resources/postgresflexalpha_instance.md index f6f10bcc..67ed171a 100644 --- a/docs/resources/postgresflexalpha_instance.md +++ b/docs/resources/postgresflexalpha_instance.md @@ -60,11 +60,10 @@ import { ### Required - `backup_schedule` (String) The schedule for when the database backup will be created. Currently, ONLY daily schedules are supported (every 24 hours). The schedule is written as a cron schedule. -- `flavor_id` (String) The id of the instance flavor. - `name` (String) The name of the instance. - `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) - `replicas` (Number) How many replicas the instance should have. -- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 365 days. +- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 90 days. - `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) - `version` (String) The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters. @@ -73,6 +72,8 @@ import { - `encryption` (Attributes) The configuration for instance's volume and backup storage encryption. ⚠︝ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. (see [below for nested schema](#nestedatt--encryption)) +- `flavor` (Attributes, Deprecated) (see [below for nested schema](#nestedatt--flavor)) +- `flavor_id` (String) The id of the instance flavor. - `instance_id` (String) The ID of the instance. - `project_id` (String) The STACKIT project ID. - `region` (String) The region which should be addressed @@ -122,6 +123,20 @@ Required: - `service_account` (String) + +### Nested Schema for `flavor` + +Optional: + +- `cpu` (Number, Deprecated) +- `ram` (Number, Deprecated) + +Read-Only: + +- `description` (String) +- `id` (String) + + ### Nested Schema for `connection_info` diff --git a/docs/resources/sqlserverflexalpha_database.md b/docs/resources/sqlserverflexalpha_database.md deleted file mode 100644 index 7d8f050b..00000000 --- a/docs/resources/sqlserverflexalpha_database.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackitprivatepreview_sqlserverflexalpha_database Resource - stackitprivatepreview" -subcategory: "" -description: |- - ---- - -# stackitprivatepreview_sqlserverflexalpha_database (Resource) - - - -## Example Usage - -```terraform -resource "stackitprivatepreview_sqlserverflexalpha_database" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - collation = "" - compatibility = "160" - name = "" - owner = "" -} - -# Only use the import statement, if you want to import a existing sqlserverflex database -import { - to = stackitprivatepreview_sqlserverflexalpha_database.import-example - id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" -} - -import { - to = stackitprivatepreview_sqlserverflexalpha_database.import-example - identity = { - project_id = "project.id" - region = "region" - instance_id = "instance.id" - database_id = "database.id" - } -} -``` - - -## Schema - -### Required - -- `name` (String) The name of the database. -- `owner` (String) The owner of the database. - -### Optional - -- `collation` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. -- `compatibility` (Number) CompatibilityLevel of the Database. -- `database_name` (String) The name of the database. -- `instance_id` (String) The ID of the instance. -- `project_id` (String) The STACKIT project ID. -- `region` (String) The region which should be addressed - -### Read-Only - -- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. -- `compatibility_level` (Number) CompatibilityLevel of the Database. -- `id` (Number) The id of the database. diff --git a/docs/resources/sqlserverflexalpha_instance.md b/docs/resources/sqlserverflexalpha_instance.md deleted file mode 100644 index 95e33673..00000000 --- a/docs/resources/sqlserverflexalpha_instance.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackitprivatepreview_sqlserverflexalpha_instance Resource - stackitprivatepreview" -subcategory: "" -description: |- - ---- - -# stackitprivatepreview_sqlserverflexalpha_instance (Resource) - - - -## Example Usage - -```terraform -resource "stackitprivatepreview_sqlserverflexalpha_instance" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - name = "example-instance" - acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] - backup_schedule = "00 00 * * *" - flavor = { - cpu = 4 - ram = 16 - } - storage = { - class = "class" - size = 5 - } - version = 2022 -} - -# Only use the import statement, if you want to import an existing sqlserverflex instance -import { - to = stackitprivatepreview_sqlserverflexalpha_instance.import-example - id = "${var.project_id},${var.region},${var.sql_instance_id}" -} -``` - - -## Schema - -### Required - -- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. -- `flavor_id` (String) The id of the instance flavor. -- `name` (String) The name of the instance. -- `network` (Attributes) the network configuration of the instance. (see [below for nested schema](#nestedatt--network)) -- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365 -- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) -- `version` (String) The sqlserver version used for the instance. - -### Optional - -- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption)) -- `instance_id` (String) The ID of the instance. -- `project_id` (String) The STACKIT project ID. -- `region` (String) The region which should be addressed - -### Read-Only - -- `edition` (String) Edition of the MSSQL server instance -- `id` (String) The ID of the instance. -- `is_deletable` (Boolean) Whether the instance can be deleted or not. -- `replicas` (Number) How many replicas the instance should have. -- `status` (String) - - -### Nested Schema for `network` - -Required: - -- `acl` (List of String) List of IPV4 cidr. - -Optional: - -- `access_scope` (String) The network access scope of the instance - -⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. - -Read-Only: - -- `instance_address` (String) -- `router_address` (String) - - - -### Nested Schema for `storage` - -Required: - -- `class` (String) The storage class for the storage. -- `size` (Number) The storage size in Gigabytes. - - - -### Nested Schema for `encryption` - -Required: - -- `kek_key_id` (String) The key identifier -- `kek_key_ring_id` (String) The keyring identifier -- `kek_key_version` (String) The key version -- `service_account` (String) diff --git a/docs/resources/sqlserverflexalpha_user.md b/docs/resources/sqlserverflexalpha_user.md deleted file mode 100644 index 85d5350e..00000000 --- a/docs/resources/sqlserverflexalpha_user.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackitprivatepreview_sqlserverflexalpha_user Resource - stackitprivatepreview" -subcategory: "" -description: |- - ---- - -# stackitprivatepreview_sqlserverflexalpha_user (Resource) - - - -## Example Usage - -```terraform -resource "stackitprivatepreview_sqlserverflexalpha_user" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - username = "username" - roles = ["role"] -} - -# Only use the import statement, if you want to import an existing sqlserverflex user -import { - to = stackitprivatepreview_sqlserverflexalpha_user.import-example - id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" -} -``` - - -## Schema - -### Required - -- `roles` (List of String) A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint. -- `username` (String) The name of the user. - -### Optional - -- `default_database` (String) The default database for a user of the instance. -- `instance_id` (String) The ID of the instance. -- `project_id` (String) The STACKIT project ID. -- `region` (String) The region which should be addressed -- `user_id` (Number) The ID of the user. - -### Read-Only - -- `host` (String) The host of the instance in which the user belongs to. -- `id` (Number) The ID of the user. -- `password` (String) The password for the user. -- `port` (Number) The port of the instance in which the user belongs to. -- `status` (String) The current status of the user. -- `uri` (String) The connection string for the user to the instance. diff --git a/go.mod b/go.mod index 4b185bc7..9954c594 100644 --- a/go.mod +++ b/go.mod @@ -18,8 +18,8 @@ require ( github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1 github.com/spf13/cobra v1.10.2 github.com/stackitcloud/stackit-sdk-go/core v0.26.0 - github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.2 - github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.1 + github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.8.0 + github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.10.0 github.com/teambition/rrule-go v1.8.2 gopkg.in/yaml.v3 v3.0.1 ) @@ -28,47 +28,67 @@ require github.com/hashicorp/go-retryablehttp v0.7.8 // indirect require ( dario.cat/mergo v1.0.1 // indirect + github.com/BurntSushi/toml v1.2.1 // indirect + github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.2.0 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/ProtonMail/go-crypto v1.4.1 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/armon/go-radix v1.0.0 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect github.com/cloudflare/circl v1.6.3 // indirect github.com/fatih/color v1.19.0 // indirect github.com/golang-jwt/jwt/v5 v5.3.1 // indirect github.com/golang/protobuf v1.5.4 // indirect + github.com/hashicorp/cli v1.1.7 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cty v1.5.0 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.7.0 // indirect + github.com/hashicorp/go-plugin v1.8.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.9.0 // indirect - github.com/hashicorp/hc-install v0.9.4 // indirect + github.com/hashicorp/hc-install v0.9.5 // indirect github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.25.1 // indirect - github.com/hashicorp/terraform-json v0.27.2 // indirect - github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0 // indirect + github.com/hashicorp/terraform-exec v0.25.2 // indirect + github.com/hashicorp/terraform-json v0.27.3-0.20260213134036-298b8f6b673a // indirect + github.com/hashicorp/terraform-plugin-docs v0.25.0 // indirect + github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.1 // indirect github.com/hashicorp/terraform-registry-address v0.4.0 // indirect github.com/hashicorp/terraform-svchost v0.2.1 // indirect github.com/hashicorp/yamux v0.1.2 // indirect + github.com/huandu/xstrings v1.3.3 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.22 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.2.0 // indirect + github.com/posener/complete v1.2.3 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/spf13/cast v1.5.0 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/stretchr/testify v1.11.1 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/yuin/goldmark v1.7.7 // indirect + github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.18.1 // indirect + go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect golang.org/x/crypto v0.50.0 // indirect + golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/mod v0.35.0 // indirect golang.org/x/net v0.53.0 // indirect golang.org/x/sync v0.20.0 // indirect @@ -76,7 +96,8 @@ require ( golang.org/x/text v0.36.0 // indirect golang.org/x/tools v0.44.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260420184626-e10c466a9529 // indirect - google.golang.org/grpc v1.80.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 // indirect + google.golang.org/grpc v1.81.0 // indirect google.golang.org/protobuf v1.36.11 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 92860e4b..eb49c8e4 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,19 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0= +github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM= github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo= -github.com/SladkyCitron/slogcolor v1.8.0 h1:ln4mUPfVhs7a/vZfjnKkz5YZ71Bg/KFWneS2hfFq6FM= -github.com/SladkyCitron/slogcolor v1.8.0/go.mod h1:ft8LEVIl4isUkebakhv+ngNXJjWBumnwhXfxTLApf3M= github.com/SladkyCitron/slogcolor v1.9.0 h1:fr4LeG+T6pZ1RYNNOP925jaBYrTdpA6BLzGy29yd4vI= github.com/SladkyCitron/slogcolor v1.9.0/go.mod h1:ft8LEVIl4isUkebakhv+ngNXJjWBumnwhXfxTLApf3M= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -13,6 +21,12 @@ github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs= +github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw= github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -34,12 +48,10 @@ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w= github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE= 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.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= -github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0= -github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s= -github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M= +github.com/go-git/go-billy/v5 v5.8.0/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY= github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM= +github.com/go-git/go-git/v5 v5.18.0/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -59,8 +71,11 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/cli v1.1.7 h1:/fZJ+hNdwfTSfsxMBa9WWMlfjUZbX8/LnUxgAd7lCVU= +github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3ghU3YgU= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -73,10 +88,11 @@ github.com/hashicorp/go-cty v1.5.0 h1:EkQ/v+dDNUqnuVpmS5fPqyY71NXVgT5gf32+57xY8g github.com/hashicorp/go-cty v1.5.0/go.mod h1:lFUCG5kd8exDobgSfyj4ONE/dc822kiYMguVKdHGMLM= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.7.0 h1:YghfQH/0QmPNc/AZMTFE3ac8fipZyZECHdDPshfk+mA= -github.com/hashicorp/go-plugin v1.7.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8= +github.com/hashicorp/go-plugin v1.8.0 h1:ie8S6RRY8RvB2usYZv+AAZ/wBvx2AU5p5QeP5j/FORs= +github.com/hashicorp/go-plugin v1.8.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8= github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48= github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -84,20 +100,20 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA= github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.9.3 h1:1H4dgmgzxEVwT6E/d/vIL5ORGVKz9twRwDw+qA5Hyho= -github.com/hashicorp/hc-install v0.9.3/go.mod h1:FQlQ5I3I/X409N/J1U4pPeQQz1R3BoV0IysB7aiaQE0= -github.com/hashicorp/hc-install v0.9.4 h1:KKWOpUG0EqIV63Qk2GGFrZ0s275NVs5lKf9N5vjBNoc= -github.com/hashicorp/hc-install v0.9.4/go.mod h1:4LRYeEN2bMIFfIv57ldMWt9awfuZhvpbRt0vWmv51WU= +github.com/hashicorp/hc-install v0.9.5 h1:XHCjcMn2563ysuaQ9v9ec2FNc7c2PJOIEEGobAFeIx4= +github.com/hashicorp/hc-install v0.9.5/go.mod h1:ihEW4LshrNkxq2bU/MpVbKyn+yt1is2hYqUTHDGhG84= github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= 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.25.0 h1:Bkt6m3VkJqYh+laFMrWIpy9KHYFITpOyzRMNI35rNaY= -github.com/hashicorp/terraform-exec v0.25.0/go.mod h1:dl9IwsCfklDU6I4wq9/StFDp7dNbH/h5AnfS1RmiUl8= -github.com/hashicorp/terraform-exec v0.25.1 h1:PRutYRGM8pixV3B8812NYoBK5O+yuf3qcB/70KFKGiU= -github.com/hashicorp/terraform-exec v0.25.1/go.mod h1:+izOYrs9sKMQK4OYvGDnrSSJHY/pm4e4eXFqSL2Q5mA= +github.com/hashicorp/terraform-exec v0.25.2 h1:fFLAVEtAjKdGfawGUXDnKooCnqJi+TuohT3W99AGbhk= +github.com/hashicorp/terraform-exec v0.25.2/go.mod h1:uaQV2oqVLqM4cixJryk6qIWS1qji3GtuwPG5pjGXYfc= github.com/hashicorp/terraform-json v0.27.2 h1:BwGuzM6iUPqf9JYM/Z4AF1OJ5VVJEEzoKST/tRDBJKU= github.com/hashicorp/terraform-json v0.27.2/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE= +github.com/hashicorp/terraform-json v0.27.3-0.20260213134036-298b8f6b673a h1:T7AMR21kjrbeEpN+KhGlyd31XXHsSZF5zg+ivfeYte4= +github.com/hashicorp/terraform-json v0.27.3-0.20260213134036-298b8f6b673a/go.mod h1:yjb5C2W07l8lmAzdyVgOLji0/D2IoHkR3rusBzUO4O0= +github.com/hashicorp/terraform-plugin-docs v0.25.0 h1:qHs1V257NxVe8tv6HS4UQfNqjaPP5eUlLeDf7jYk85U= +github.com/hashicorp/terraform-plugin-docs v0.25.0/go.mod h1:MQggCmY8zgP7R7E/cC0b0cmTvA9hSj3ZKyrrsDjRbLo= github.com/hashicorp/terraform-plugin-framework v1.19.0 h1:q0bwyhxAOR3vfdgbk9iplv3MlTv/dhBHTXjQOtQDoBA= github.com/hashicorp/terraform-plugin-framework v1.19.0/go.mod h1:YRXOBu0jvs7xp4AThBbX4mAzYaMJ1JgtFH//oGKxwLc= github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 h1:Zz3iGgzxe/1XBkooZCewS0nJAaCFPFPHdNJd8FgE4Ow= @@ -106,10 +122,8 @@ github.com/hashicorp/terraform-plugin-go v0.31.0 h1:0Fz2r9DQ+kNNl6bx8HRxFd1TfMKU github.com/hashicorp/terraform-plugin-go v0.31.0/go.mod h1:A88bDhd/cW7FnwqxQRz3slT+QY6yzbHKc6AOTtmdeS8= github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g= github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0 h1:MKS/2URqeJRwJdbOfcbdsZCq/IRrNkqJNN0GtVIsuGs= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0/go.mod h1:PuG4P97Ju3QXW6c6vRkRadWJbvnEu2Xh+oOuqcYOqX4= -github.com/hashicorp/terraform-plugin-testing v1.15.0 h1:/fimKyl0YgD7aAtJkuuAZjwBASXhCIwWqMbDLnKLMe4= -github.com/hashicorp/terraform-plugin-testing v1.15.0/go.mod h1:bGXMw7bE95EiZhSBV3rM2W8TiffaPTDuLS+HFI/lIYs= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.1 h1:2yPUd7esMOpuTaG3y1iEla1iw+tla+3ZEkkBnmOAre4= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.1/go.mod h1:sq8qsxh+PwdvTQFcd17kfCoBgQo46ADNMvCpKE7t/gY= github.com/hashicorp/terraform-plugin-testing v1.16.0 h1:GB97nGnJ1hESpDrCjqZig38RodSF0gdRzxlDupLXP38= github.com/hashicorp/terraform-plugin-testing v1.16.0/go.mod h1:eQPYAy9xFMV7xtIFX8Y+wJGtUB++HBl329zCF6PBMZk= github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk= @@ -118,8 +132,13 @@ github.com/hashicorp/terraform-svchost v0.2.1 h1:ubvrTFw3Q7CsoEaX7V06PtCTKG3wu7G github.com/hashicorp/terraform-svchost v0.2.1/go.mod h1:zDMheBLvNzu7Q6o9TBvPqiZToJcSuCLXjAXxBslSky4= github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= +github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= +github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -141,8 +160,6 @@ github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3x github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1 h1:QJRB9Gs5i/h6TVJI6yl09Qm6rNooznRiKwIw+VIxd90= github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1/go.mod h1:0eUeas7XtKDPKQbB0KijfaMPbuQ/cIprtoTRiwaUoFg= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -151,12 +168,13 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs= -github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/maxatome/go-testdeep v1.14.0 h1:rRlLv1+kI8eOI3OaBXZwb3O7xY3exRzdW5QyX48g9wI= github.com/maxatome/go-testdeep v1.14.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= @@ -165,6 +183,7 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E= @@ -174,13 +193,21 @@ github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxu github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= @@ -188,19 +215,16 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stackitcloud/stackit-sdk-go/core v0.25.0 h1:ra3VEk684MNoq741g+xbZrKjZzhyztq5liUAwwew4DY= -github.com/stackitcloud/stackit-sdk-go/core v0.25.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA= github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= -github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.1 h1:BWa9O8iRU1l8izGIoH9/+GEF20uu8WDWSesqjdJ3+lg= -github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.1/go.mod h1:xBWn0vpyyh+IA4muynufqIKmc1fJPPp+uY/iXwa5epE= -github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.2 h1:VIekoX8eCvSgO9HEr4j+z5SKApN2DgfXudSt02zU6Is= -github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.7.2/go.mod h1:yzlakB+f8ur4yAHR6lyCABO+HcEtZG3G2Faj6m5/uW8= -github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.0 h1:dv+8GYcI2G0BQvMN5Qb4kaCREaj9n2lRzj9sb29NEZg= -github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.0/go.mod h1:HTpVer71ZfpKozpzWVv7EbCPB5ko8vgw4VmFE38lB9I= -github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.1 h1:wPqWAZX70u2VWIU0PCNhayff8OmGTpI4dZ7VkROwqco= -github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.9.1/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M= +github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.8.0 h1:oWTviJKdlUxaaARJghTjOqBbarIK+7+nH3Kc3Wxn4rQ= +github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.8.0/go.mod h1:yzlakB+f8ur4yAHR6lyCABO+HcEtZG3G2Faj6m5/uW8= +github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.10.0 h1:angvO3z0TGqZtdwTDsG/tgTw9hxB76A6leUsiUXQtME= +github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.10.0/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= @@ -216,27 +240,36 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV 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/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU= +github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= +github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= github.com/zclconf/go-cty v1.18.1 h1:yEGE8M4iIZlyKQURZNb2SnEyZlZHUcBCnx6KF81KuwM= github.com/zclconf/go-cty v1.18.1/go.mod h1:qpnV6EDNgC1sns/AleL1fvatHw72j+S+nS+MJ+T2CSg= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= +go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= +go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= -go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= -go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= -go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= -go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= -go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= -go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= -go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= -go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= -go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= +go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I= +go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0= +go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM= +go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY= +go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg= +go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg= +go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw= +go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A= +go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A= +go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= 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.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= @@ -244,6 +277,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn 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.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.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -261,16 +295,19 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc 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.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -285,12 +322,10 @@ gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260420184626-e10c466a9529 h1:XF8+t6QQiS0o9ArVan/HW8Q7cycNPGsJf6GA2nXxYAg= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260420184626-e10c466a9529/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM= -google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 h1:pfIbyB44sWzHiCpRqIen67ZQnVXSfIxWrqUMk1qwODE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/grpc v1.81.0 h1:W3G9N3KQf3BU+YuCtGKJk0CmxQNbAISICD/9AORxLIw= +google.golang.org/grpc v1.81.0/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I= 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.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= @@ -301,6 +336,9 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sample/alpha-from-registry/sqlserver.tf b/sample/alpha-from-registry/sqlserver.tf deleted file mode 100644 index 2bf17a9e..00000000 --- a/sample/alpha-from-registry/sqlserver.tf +++ /dev/null @@ -1,101 +0,0 @@ -# resource "stackit_kms_keyring" "keyring001" { -# project_id = var.project_id -# display_name = "msh-keyring-sna01" -# description = "This is a test keyring for private endpoints" -# } -# -# resource "stackit_kms_key" "key001" { -# project_id = var.project_id -# keyring_id = stackit_kms_keyring.keyring001.keyring_id -# display_name = "msh-key-sna01" -# protection = "software" -# algorithm = "aes_256_gcm" -# purpose = "symmetric_encrypt_decrypt" -# access_scope = "SNA" -# } - -data "stackitprivatepreview_sqlserverflexbeta_flavor" "sqlserver_flavor" { - project_id = var.project_id - region = "eu01" - cpu = 4 - ram = 16 - node_type = "Single" - storage_class = "premium-perf2-stackit" -} - -resource "stackitprivatepreview_sqlserverflexbeta_instance" "msh-sna-001" { - project_id = var.project_id - name = "msh-sna-001" - backup_schedule = "0 3 * * *" - retention_days = 31 - flavor_id = data.stackitprivatepreview_sqlserverflexbeta_flavor.sqlserver_flavor.flavor_id - storage = { - class = "premium-perf2-stackit" - size = 50 - } - version = 2022 - encryption = { - kek_key_version = 1 - kek_key_id = var.key_id - kek_key_ring_id = var.keyring_id - service_account = var.sa_email - } - network = { - acl = ["0.0.0.0/0", "193.148.160.0/19"] - access_scope = "SNA" - } -} - -#resource "stackitprivatepreview_sqlserverflexbeta_instance" "msh-nosna-001" { -# project_id = var.project_id -# name = "msh-nosna-001" -# backup_schedule = "0 3 * * *" -# retention_days = 31 -# flavor_id = data.stackitprivatepreview_sqlserverflexbeta_flavor.sqlserver_flavor.flavor_id -# storage = { -# class = "premium-perf2-stackit" -# size = 50 -# } -# version = 2022 -# # encryption = { -# # #key_id = stackit_kms_key.key.key_id -# # #keyring_id = stackit_kms_keyring.keyring.keyring_id -# # #key_version = 1 -# # #key_id = var.key_id -# # # key with scope public -# # key_id = "fe039bcf-8d7b-431a-801d-9e81371a6b7b" -# # keyring_id = var.keyring_id -# # key_version = var.key_version -# # service_account = var.sa_email -# # } -# network = { -# acl = ["0.0.0.0/0", "193.148.160.0/19"] -# access_scope = "PUBLIC" -# } -#} - -# data "stackitprivatepreview_sqlserverflexbeta_instance" "test" { -# project_id = var.project_id -# instance_id = var.instance_id -# region = "eu01" -# } - -# output "test" { -# value = data.stackitprivatepreview_sqlserverflexbeta_instance.test -# } - -resource "stackitprivatepreview_sqlserverflexbeta_user" "ptlsdbadminuser" { - project_id = var.project_id - instance_id = stackitprivatepreview_sqlserverflexbeta_instance.msh-sna-001.instance_id - username = var.db_admin_username - #roles = ["##STACKIT_LoginManager##", "##STACKIT_DatabaseManager##"] - roles = ["##STACKIT_LoginManager##"] -} - -resource "stackitprivatepreview_sqlserverflexbeta_user" "ptlsdbuser" { - project_id = var.project_id - instance_id = stackitprivatepreview_sqlserverflexbeta_instance.msh-sna-001.instance_id - username = var.db_username - roles = ["##STACKIT_LoginManager##"] -} - diff --git a/sample/postgres/postresql.tf b/sample/postgres/postresql.tf index 531b17e2..8679c669 100644 --- a/sample/postgres/postresql.tf +++ b/sample/postgres/postresql.tf @@ -13,7 +13,11 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "msh-sna-pe-example" name = "mshpetest2" backup_schedule = "0 0 * * *" retention_days = 45 - flavor_id = data.stackitprivatepreview_postgresflexalpha_flavor.pgsql_flavor.flavor_id + # flavor_id = data.stackitprivatepreview_postgresflexalpha_flavor.pgsql_flavor.flavor_id + flavor = { + cpu = 2 + ram = 4 + } replicas = 1 storage = { # class = "premium-perf2-stackit" @@ -66,7 +70,8 @@ resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbadminuser" { project_id = var.project_id instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.instance_id name = var.db_admin_username - roles = ["createdb", "login", "login"] + roles = ["createdb", "login"] + # roles = ["createdb", "login", "login"] # roles = ["createdb", "login", "createrole"] } @@ -110,7 +115,11 @@ output "psql_user_password" { sensitive = true } -output "psql_user_conn" { - value = stackitprivatepreview_postgresflexalpha_user.ptlsdbuser.connection_string - sensitive = true +# output "psql_user_conn" { +# value = stackitprivatepreview_postgresflexalpha_user.ptlsdbuser.connection.host +# sensitive = true +# } + +output "determined_flavor_id" { + value = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.flavor_id } diff --git a/sample/tf.sh b/sample/tf.sh index 8feaf799..5b650bdc 100755 --- a/sample/tf.sh +++ b/sample/tf.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash - - # ./tf.sh apply > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2) usage() { @@ -12,7 +10,8 @@ usage() { [ $# -eq 0 ] && usage CONFIG_FOLDER=$(dirname "$0") -BINARY=terraform +# BINARY=terraform +BINARY=tofu ADD="" diff --git a/service_specs/sqlserverflex/alpha/collation_config.yml.bak b/service_specs/sqlserverflex/alpha/collations_config.yml similarity index 100% rename from service_specs/sqlserverflex/alpha/collation_config.yml.bak rename to service_specs/sqlserverflex/alpha/collations_config.yml diff --git a/service_specs/sqlserverflex/alpha/version_config.yml.bak b/service_specs/sqlserverflex/alpha/versions_config.yml similarity index 100% rename from service_specs/sqlserverflex/alpha/version_config.yml.bak rename to service_specs/sqlserverflex/alpha/versions_config.yml diff --git a/service_specs/sqlserverflex/beta/collation_config.yml.disabled b/service_specs/sqlserverflex/beta/collations_config.yml similarity index 92% rename from service_specs/sqlserverflex/beta/collation_config.yml.disabled rename to service_specs/sqlserverflex/beta/collations_config.yml index d1160ec3..3d5fbb69 100644 --- a/service_specs/sqlserverflex/beta/collation_config.yml.disabled +++ b/service_specs/sqlserverflex/beta/collations_config.yml @@ -2,7 +2,7 @@ provider: name: stackitprivatepreview data_sources: - collation: + collations: read: path: /v3beta1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations method: GET diff --git a/service_specs/sqlserverflex/beta/versions_config.yml b/service_specs/sqlserverflex/beta/versions_config.yml index 70d79676..c1ed0b00 100644 --- a/service_specs/sqlserverflex/beta/versions_config.yml +++ b/service_specs/sqlserverflex/beta/versions_config.yml @@ -3,7 +3,7 @@ provider: name: stackitprivatepreview data_sources: - version: + versions: read: path: /v3beta1/projects/{projectId}/regions/{region}/versions method: GET diff --git a/stackit/internal/services/postgresflexalpha/flavor/datasource.go b/stackit/internal/services/postgresflexalpha/flavor/datasource.go index 455baf14..97213227 100644 --- a/stackit/internal/services/postgresflexalpha/flavor/datasource.go +++ b/stackit/internal/services/postgresflexalpha/flavor/datasource.go @@ -226,8 +226,8 @@ func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, postgresflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx), map[string]attr.Value{ "class": types.StringValue(sc.Class), - "max_io_per_sec": types.Int32Value(sc.MaxIoPerSec), - "max_through_in_mb": types.Int32Value(sc.MaxThroughInMb), + "max_io_per_sec": types.Int64Value(int64(sc.GetMaxIoPerSec())), + "max_through_in_mb": types.Int64Value(int64(sc.GetMaxThroughInMb())), }, ), ) diff --git a/stackit/internal/services/postgresflexalpha/flavors/datasource.go b/stackit/internal/services/postgresflexalpha/flavors/datasource.go index f5c99a82..c70ec173 100644 --- a/stackit/internal/services/postgresflexalpha/flavors/datasource.go +++ b/stackit/internal/services/postgresflexalpha/flavors/datasource.go @@ -1,4 +1,4 @@ -package postgresflexalpha +package postgresflexalphaflavors import ( "context" diff --git a/stackit/internal/services/postgresflexalpha/flavors/functions.go b/stackit/internal/services/postgresflexalpha/flavors/functions.go new file mode 100644 index 00000000..2135f8d0 --- /dev/null +++ b/stackit/internal/services/postgresflexalpha/flavors/functions.go @@ -0,0 +1,65 @@ +package postgresflexalphaflavors + +import ( + "context" + "fmt" + + "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api" +) + +type flavorsClientReader interface { + GetFlavorsRequest( + ctx context.Context, + projectId, region string, + ) v3alpha1api.ApiGetFlavorsRequestRequest +} + +func getAllFlavors(ctx context.Context, client flavorsClientReader, projectId, region string) ( + []v3alpha1api.ListFlavors, + error, +) { + getAllFilter := func(_ v3alpha1api.ListFlavors) bool { return true } + flavorList, err := getFlavorsByFilter(ctx, client, projectId, region, getAllFilter) + if err != nil { + return nil, err + } + return flavorList, nil +} + +// getFlavorsByFilter is a helper function to retrieve flavors using a filtern function. +// Hint: The API does not have a GetFlavors endpoint, only ListFlavors +func getFlavorsByFilter( + ctx context.Context, + client flavorsClientReader, + projectId, region string, + filter func(db v3alpha1api.ListFlavors) bool, +) ([]v3alpha1api.ListFlavors, error) { + if projectId == "" || region == "" { + return nil, fmt.Errorf("listing postgresflex flavors: projectId and region are required") + } + + const pageSize = 25 + + var result = make([]v3alpha1api.ListFlavors, 0) + + for page := int32(1); ; page++ { + res, err := client.GetFlavorsRequest(ctx, projectId, region). + Page(page).Size(pageSize).Sort(v3alpha1api.FLAVORSORT_ID_ASC).Execute() + if err != nil { + return nil, fmt.Errorf("requesting flavors list (page %d): %w", page, err) + } + + // If the API returns no flavors, we have reached the end of the list. + if len(res.Flavors) == 0 { + break + } + + for _, flavor := range res.Flavors { + if filter(flavor) { + result = append(result, flavor) + } + } + } + + return result, nil +} diff --git a/stackit/internal/services/postgresflexalpha/flavors/functions_test.go b/stackit/internal/services/postgresflexalpha/flavors/functions_test.go new file mode 100644 index 00000000..8ca78e1f --- /dev/null +++ b/stackit/internal/services/postgresflexalpha/flavors/functions_test.go @@ -0,0 +1,135 @@ +package postgresflexalphaflavors + +/* +import ( + "context" + "testing" + + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api" +) + +type mockRequest struct { + executeFunc func() (*postgresflex.GetFlavorsResponse, error) +} + +func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m } +func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m } +func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest { + return m +} +func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) { + return m.executeFunc() +} + +type mockFlavorsClient struct { + executeRequest func() postgresflex.ApiGetFlavorsRequestRequest +} + +func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest { + return m.executeRequest() +} + +var mockResp = func(page int32) (*postgresflex.GetFlavorsResponse, error) { + if page == 1 { + return &postgresflex.GetFlavorsResponse{ + Flavors: []postgresflex.ListFlavors{ + {Id: "flavor-1", Description: "first"}, + {Id: "flavor-2", Description: "second"}, + }, + }, nil + } + if page == 2 { + return &postgresflex.GetFlavorsResponse{ + Flavors: []postgresflex.ListFlavors{ + {Id: "flavor-3", Description: "three"}, + }, + }, nil + } + + return &postgresflex.GetFlavorsResponse{ + Flavors: []postgresflex.ListFlavors{}, + }, nil +} + +func TestGetFlavorsByFilter(t *testing.T) { + tests := []struct { + description string + projectId string + region string + mockErr error + filter func(postgresflex.ListFlavors) bool + wantCount int + wantErr bool + }{ + { + description: "Success - Get all flavors (2 pages)", + projectId: "pid", region: "reg", + filter: func(_ postgresflex.ListFlavors) bool { return true }, + wantCount: 3, + wantErr: false, + }, + { + description: "Success - Filter flavors by description", + projectId: "pid", region: "reg", + filter: func(f postgresflex.ListFlavors) bool { return f.Description == "first" }, + wantCount: 1, + wantErr: false, + }, + { + description: "Error - Missing parameters", + projectId: "", region: "reg", + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run( + tt.description, func(t *testing.T) { + var currentPage int32 + client := &mockFlavorsClient{ + executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest { + return mockRequest{ + executeFunc: func() (*postgresflex.GetFlavorsResponse, error) { + currentPage++ + return mockResp(currentPage) + }, + } + }, + } + actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter) + + if (err != nil) != tt.wantErr { + t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr) + return + } + + if !tt.wantErr && len(actual) != tt.wantCount { + t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount) + } + }, + ) + } +} + +func TestGetAllFlavors(t *testing.T) { + var currentPage int32 + client := &mockFlavorsClient{ + executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest { + return mockRequest{ + executeFunc: func() (*postgresflex.GetFlavorsResponse, error) { + currentPage++ + return mockResp(currentPage) + }, + } + }, + } + + res, err := getAllFlavors(context.Background(), client, "pid", "reg") + if err != nil { + t.Errorf("getAllFlavors() unexpected error: %v", err) + } + if len(res) != 3 { + t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res)) + } +} +*/ diff --git a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go index 9b3e28ce..587d2d89 100644 --- a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go +++ b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go @@ -115,6 +115,12 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema { Description: "Whether the instance can be deleted or not.", MarkdownDescription: "Whether the instance can be deleted or not.", }, + "labels": schema.MapAttribute{ + ElementType: types.StringType, + Computed: true, + Description: "Key-value pairs, 63 characters max, begin and end with an alphanumerical character,\nmay contain dashes (-), underscores (_), dots (.), and alphanumerics between. Key MUST be at least 1 character.\nMax 64 labels\nRegex for keys: ^(?=.{1,63}$)([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$\nRegex for values: ^(?=.{0,63}$)(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])*$\nThe stackit- prefix is reserved and cannot be used for Keys.\n", + MarkdownDescription: "Key-value pairs, 63 characters max, begin and end with an alphanumerical character,\nmay contain dashes (-), underscores (_), dots (.), and alphanumerics between. Key MUST be at least 1 character.\nMax 64 labels\nRegex for keys: ^(?=.{1,63}$)([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$\nRegex for values: ^(?=.{0,63}$)(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])*$\nThe stackit- prefix is reserved and cannot be used for Keys.\n", + }, "name": schema.StringAttribute{ Computed: true, Description: "The name of the instance.", @@ -171,8 +177,8 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema { }, "retention_days": schema.Int64Attribute{ Computed: true, - Description: "How long backups are retained. The value can only be between 32 and 365 days.", - MarkdownDescription: "How long backups are retained. The value can only be between 32 and 365 days.", + Description: "How long backups are retained. The value can only be between 32 and 90 days.", + MarkdownDescription: "How long backups are retained. The value can only be between 32 and 90 days.", }, "status": schema.StringAttribute{ Computed: true, @@ -219,6 +225,7 @@ type InstanceModel struct { Id types.String `tfsdk:"tf_original_api_id"` InstanceId types.String `tfsdk:"instance_id"` IsDeletable types.Bool `tfsdk:"is_deletable"` + Labels types.Map `tfsdk:"labels"` Name types.String `tfsdk:"name"` Network NetworkValue `tfsdk:"network"` ProjectId types.String `tfsdk:"project_id"` diff --git a/stackit/internal/services/postgresflexalpha/instance/flavor_functions.go b/stackit/internal/services/postgresflexalpha/instance/flavor_functions.go new file mode 100644 index 00000000..a9d86e38 --- /dev/null +++ b/stackit/internal/services/postgresflexalpha/instance/flavor_functions.go @@ -0,0 +1,65 @@ +package postgresflexalpha + +import ( + "context" + "fmt" + + "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api" +) + +type flavorsClientReader interface { + GetFlavorsRequest( + ctx context.Context, + projectId, region string, + ) v3alpha1api.ApiGetFlavorsRequestRequest +} + +func getAllFlavors(ctx context.Context, client flavorsClientReader, projectId, region string) ( + []v3alpha1api.ListFlavors, + error, +) { + getAllFilter := func(_ v3alpha1api.ListFlavors) bool { return true } + flavorList, err := getFlavorsByFilter(ctx, client, projectId, region, getAllFilter) + if err != nil { + return nil, err + } + return flavorList, nil +} + +// getFlavorsByFilter is a helper function to retrieve flavors using a filtern function. +// Hint: The API does not have a GetFlavors endpoint, only ListFlavors +func getFlavorsByFilter( + ctx context.Context, + client flavorsClientReader, + projectId, region string, + filter func(db v3alpha1api.ListFlavors) bool, +) ([]v3alpha1api.ListFlavors, error) { + if projectId == "" || region == "" { + return nil, fmt.Errorf("listing postgresflex flavors: projectId and region are required") + } + + const pageSize = 25 + + var result = make([]v3alpha1api.ListFlavors, 0) + + for page := int32(1); ; page++ { + res, err := client.GetFlavorsRequest(ctx, projectId, region). + Page(page).Size(pageSize).Sort(v3alpha1api.FLAVORSORT_ID_ASC).Execute() + if err != nil { + return nil, fmt.Errorf("requesting flavors list (page %d): %w", page, err) + } + + // If the API returns no flavors, we have reached the end of the list. + if len(res.Flavors) == 0 { + break + } + + for _, flavor := range res.Flavors { + if filter(flavor) { + result = append(result, flavor) + } + } + } + + return result, nil +} diff --git a/stackit/internal/services/postgresflexalpha/instance/flavor_functions_test.go b/stackit/internal/services/postgresflexalpha/instance/flavor_functions_test.go new file mode 100644 index 00000000..6fbd8c2f --- /dev/null +++ b/stackit/internal/services/postgresflexalpha/instance/flavor_functions_test.go @@ -0,0 +1,135 @@ +package postgresflexalpha + +/* +import ( + "context" + "testing" + + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api" +) + +type mockRequest struct { + executeFunc func() (*postgresflex.GetFlavorsResponse, error) +} + +func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m } +func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m } +func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest { + return m +} +func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) { + return m.executeFunc() +} + +type mockFlavorsClient struct { + executeRequest func() postgresflex.ApiGetFlavorsRequestRequest +} + +func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest { + return m.executeRequest() +} + +var mockResp = func(page int32) (*postgresflex.GetFlavorsResponse, error) { + if page == 1 { + return &postgresflex.GetFlavorsResponse{ + Flavors: []postgresflex.ListFlavors{ + {Id: "flavor-1", Description: "first"}, + {Id: "flavor-2", Description: "second"}, + }, + }, nil + } + if page == 2 { + return &postgresflex.GetFlavorsResponse{ + Flavors: []postgresflex.ListFlavors{ + {Id: "flavor-3", Description: "three"}, + }, + }, nil + } + + return &postgresflex.GetFlavorsResponse{ + Flavors: []postgresflex.ListFlavors{}, + }, nil +} + +func TestGetFlavorsByFilter(t *testing.T) { + tests := []struct { + description string + projectId string + region string + mockErr error + filter func(postgresflex.ListFlavors) bool + wantCount int + wantErr bool + }{ + { + description: "Success - Get all flavors (2 pages)", + projectId: "pid", region: "reg", + filter: func(_ postgresflex.ListFlavors) bool { return true }, + wantCount: 3, + wantErr: false, + }, + { + description: "Success - Filter flavors by description", + projectId: "pid", region: "reg", + filter: func(f postgresflex.ListFlavors) bool { return f.Description == "first" }, + wantCount: 1, + wantErr: false, + }, + { + description: "Error - Missing parameters", + projectId: "", region: "reg", + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run( + tt.description, func(t *testing.T) { + var currentPage int32 + client := &mockFlavorsClient{ + executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest { + return mockRequest{ + executeFunc: func() (*postgresflex.GetFlavorsResponse, error) { + currentPage++ + return mockResp(currentPage) + }, + } + }, + } + actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter) + + if (err != nil) != tt.wantErr { + t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr) + return + } + + if !tt.wantErr && len(actual) != tt.wantCount { + t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount) + } + }, + ) + } +} + +func TestGetAllFlavors(t *testing.T) { + var currentPage int32 + client := &mockFlavorsClient{ + executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest { + return mockRequest{ + executeFunc: func() (*postgresflex.GetFlavorsResponse, error) { + currentPage++ + return mockResp(currentPage) + }, + } + }, + } + + res, err := getAllFlavors(context.Background(), client, "pid", "reg") + if err != nil { + t.Errorf("getAllFlavors() unexpected error: %v", err) + } + if len(res) != 3 { + t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res)) + } +} +*/ diff --git a/stackit/internal/services/postgresflexalpha/instance/functions.go b/stackit/internal/services/postgresflexalpha/instance/functions.go index 1eb10d32..ad67ba3d 100644 --- a/stackit/internal/services/postgresflexalpha/instance/functions.go +++ b/stackit/internal/services/postgresflexalpha/instance/functions.go @@ -16,7 +16,7 @@ import ( func mapGetInstanceResponseToModel( ctx context.Context, - m *postgresflexalpharesource.InstanceModel, + m *LocalInstanceModel, resp *postgresflex.GetInstanceResponse, ) error { m.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) @@ -71,6 +71,8 @@ func mapGetInstanceResponseToModel( m.Acl = netACL + // m.Labels = resp.GetLabels() + netInstAdd := types.StringValue("") if instAdd, ok := resp.Network.GetInstanceAddressOk(); ok { netInstAdd = types.StringValue(*instAdd) diff --git a/stackit/internal/services/postgresflexalpha/instance/resource.go b/stackit/internal/services/postgresflexalpha/instance/resource.go index ad99978e..92877870 100644 --- a/stackit/internal/services/postgresflexalpha/instance/resource.go +++ b/stackit/internal/services/postgresflexalpha/instance/resource.go @@ -11,11 +11,14 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" coreUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/resources_gen" @@ -44,12 +47,33 @@ type instanceResource struct { providerData core.ProviderData } +type LocalInstanceModel struct { + postgresflexalpha.InstanceModel + Flavor types.Object `tfsdk:"flavor"` +} + +// Struct corresponding to Model.Flavor +type flavorModel struct { + Id types.String `tfsdk:"id"` + Description types.String `tfsdk:"description"` + CPU types.Int64 `tfsdk:"cpu"` + RAM types.Int64 `tfsdk:"ram"` +} + +//// Types corresponding to flavorModel +//var flavorTypes = map[string]attr.Type{ +// "id": basetypes.StringType{}, +// "description": basetypes.StringType{}, +// "cpu": basetypes.Int64Type{}, +// "ram": basetypes.Int64Type{}, +//} + func (r *instanceResource) ValidateConfig( ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse, ) { - var data postgresflexalpha.InstanceModel + var data LocalInstanceModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) if resp.Diagnostics.HasError() { @@ -64,6 +88,23 @@ func (r *instanceResource) ValidateConfig( "The resource may return unexpected results.", ) } + + if data.FlavorId.IsNull() { + if data.Flavor.IsUnknown() || data.Flavor.IsNull() { + resp.Diagnostics.AddAttributeError( + path.Root("flavor"), + "Missing Attribute Configuration", + "Expected flavor to be configured. "+ + "The resource may return unexpected results.", + ) + } + resp.Diagnostics.AddAttributeWarning( + path.Root("flavor"), + "Attribute Configuration Deprecation", + "Using flavor is deprecated, "+ + "please use flavor_id instead.", + ) + } } // ModifyPlan implements resource.ResourceWithModifyPlan. @@ -73,7 +114,7 @@ func (r *instanceResource) ModifyPlan( req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse, ) { // nolint:gocritic // function signature required by Terraform - var configModel postgresflexalpha.InstanceModel + var configModel LocalInstanceModel // skip initial empty configuration to avoid follow-up errors if req.Config.Raw.IsNull() { return @@ -83,7 +124,7 @@ func (r *instanceResource) ModifyPlan( return } - var planModel postgresflexalpha.InstanceModel + var planModel LocalInstanceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...) if resp.Diagnostics.HasError() { return @@ -133,20 +174,53 @@ func (r *instanceResource) Configure( var modifiersFileByte []byte // Schema defines the schema for the resource. -func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - schema := postgresflexalpha.InstanceResourceSchema(ctx) +func (r *instanceResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + schemaVar := postgresflexalpha.InstanceResourceSchema(ctx) + schemaVar.Attributes["flavor"] = schema.SingleNestedAttribute{ + Optional: true, + DeprecationMessage: "Please use flavor_id instead.", + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + UseStateForUnknownIfFlavorUnchanged(req), + }, + }, + "description": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + UseStateForUnknownIfFlavorUnchanged(req), + }, + }, + "cpu": schema.Int64Attribute{ + DeprecationMessage: "Please use flavor_id instead.", + Optional: true, + }, + "ram": schema.Int64Attribute{ + DeprecationMessage: "Please use flavor_id instead.", + Optional: true, + }, + }, + } + + schemaVar.Attributes["flavor_id"] = schema.StringAttribute{ + Optional: true, + Description: "The id of the instance flavor.", + MarkdownDescription: "The id of the instance flavor.", + } + fields, err := utils.ReadModifiersConfig(modifiersFileByte) if err != nil { resp.Diagnostics.AddError("error during read modifiers config file", err.Error()) return } - err = utils.AddPlanModifiersToResourceSchema(fields, &schema) + err = utils.AddPlanModifiersToResourceSchema(fields, &schemaVar) if err != nil { resp.Diagnostics.AddError("error adding plan modifiers", err.Error()) return } - resp.Schema = schema + resp.Schema = schemaVar } // Create creates the resource and sets the initial Terraform state. @@ -155,7 +229,7 @@ func (r *instanceResource) Create( req resource.CreateRequest, resp *resource.CreateResponse, ) { // nolint:gocritic // function signature required by Terraform - var model postgresflexalpha.InstanceModel + var model LocalInstanceModel diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -177,6 +251,73 @@ func (r *instanceResource) Create( return } + // determine flavor ID + var flModel = &flavorModel{} + if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) { + diags = model.Flavor.As(ctx, flModel, basetypes.ObjectAsOptions{}) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + flavors, err := getAllFlavors(ctx, r.client.DefaultAPI, projectID, region) + if err != nil { + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading flavors", fmt.Sprintf("getAllFlavors: %v", err)) + return + } + tflog.Debug(ctx, fmt.Sprintf("loaded flavors: %d", len(flavors))) + + var foundFlavors []v3alpha1api.ListFlavors + for _, flavor := range flavors { + if flModel.CPU.ValueInt64() != int64(flavor.Cpu) { + // tflog.Debug(ctx, fmt.Sprintf("flavor - cpu did not match (%d - %d)", flModel.CPU.ValueInt64(), flavor.Cpu)) + continue + } + if flModel.RAM.ValueInt64() != int64(flavor.Memory) { + // tflog.Debug(ctx, fmt.Sprintf("flavor - ram did not match (%d - %d)", flModel.RAM.ValueInt64(), flavor.Memory)) + continue + } + tmpNodeType := "Single" + if model.Replicas.ValueInt64() > 1 { + tmpNodeType = "Replica" + } + if strings.ToLower(tmpNodeType) != strings.ToLower(flavor.NodeType) { + //tflog.Debug( + // ctx, + // fmt.Sprintf( + // "flavor - nodeType did not match ('%s' - '%s')", + // strings.ToLower(tmpNodeType), + // strings.ToLower(flavor.NodeType), + // ), + //) + continue + } + tflog.Debug(ctx, fmt.Sprintf("found flavor %s, checking storage classes", flavor.Id)) + for _, sc := range flavor.StorageClasses { + if model.Storage.PerformanceClass.ValueString() != sc.Class { + continue + } + tflog.Debug(ctx, fmt.Sprintf("found storage class '%s' for flavor '%s', checking storage classes", sc.Class, flavor.Id)) + foundFlavors = append(foundFlavors, flavor) + } + } + if len(foundFlavors) == 0 { + resp.Diagnostics.AddError("get flavor", "could not find requested flavor") + return + } + if len(foundFlavors) > 1 { + resp.Diagnostics.AddError("get flavor", "found too many matching flavors") + return + } + + f := foundFlavors[0] + flModel.Description = types.StringValue(f.Description) + flModel.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, f.Id) + model.FlavorId = types.StringValue(f.Id) + //flModel. .MaxGb = types.Int32Value(f.MaxGB) + //flModel.MinGb = types.Int32Value(f.MinGB) + } + replVal := model.Replicas.ValueInt64() // nolint:gosec // check is performed above payload := modelToCreateInstancePayload(netACL, model, replVal) @@ -243,7 +384,7 @@ func (r *instanceResource) Create( func modelToCreateInstancePayload( netACL []string, - model postgresflexalpha.InstanceModel, + model LocalInstanceModel, replVal int64, ) v3alpha1api.CreateInstanceRequestPayload { var enc *v3alpha1api.InstanceEncryption @@ -283,7 +424,7 @@ func (r *instanceResource) Read( ) { // nolint:gocritic // function signature required by Terraform functionErrorSummary := "read instance failed" - var model postgresflexalpha.InstanceModel + var model LocalInstanceModel diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { @@ -371,7 +512,7 @@ func (r *instanceResource) Update( req resource.UpdateRequest, resp *resource.UpdateResponse, ) { // nolint:gocritic // function signature required by Terraform - var model postgresflexalpha.InstanceModel + var model LocalInstanceModel diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -484,7 +625,7 @@ func (r *instanceResource) Delete( req resource.DeleteRequest, resp *resource.DeleteResponse, ) { // nolint:gocritic // function signature required by Terraform - var model postgresflexalpha.InstanceModel + var model LocalInstanceModel diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go b/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go index 7d7969a6..7483dd67 100644 --- a/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go +++ b/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go @@ -119,6 +119,13 @@ func InstanceResourceSchema(ctx context.Context) schema.Schema { Description: "Whether the instance can be deleted or not.", MarkdownDescription: "Whether the instance can be deleted or not.", }, + //"labels": schema.MapAttribute{ + // ElementType: types.StringType, + // Optional: true, + // Computed: true, + // Description: "Key-value pairs, 63 characters max, begin and end with an alphanumerical character,\nmay contain dashes (-), underscores (_), dots (.), and alphanumerics between. Key MUST be at least 1 character.\nMax 64 labels\nRegex for keys: ^(?=.{1,63}$)([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$\nRegex for values: ^(?=.{0,63}$)(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])*$\nThe stackit- prefix is reserved and cannot be used for Keys.\n", + // MarkdownDescription: "Key-value pairs, 63 characters max, begin and end with an alphanumerical character,\nmay contain dashes (-), underscores (_), dots (.), and alphanumerics between. Key MUST be at least 1 character.\nMax 64 labels\nRegex for keys: ^(?=.{1,63}$)([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$\nRegex for values: ^(?=.{0,63}$)(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])*$\nThe stackit- prefix is reserved and cannot be used for Keys.\n", + //}, "name": schema.StringAttribute{ Required: true, Description: "The name of the instance.", @@ -191,8 +198,8 @@ func InstanceResourceSchema(ctx context.Context) schema.Schema { }, "retention_days": schema.Int64Attribute{ Required: true, - Description: "How long backups are retained. The value can only be between 32 and 365 days.", - MarkdownDescription: "How long backups are retained. The value can only be between 32 and 365 days.", + Description: "How long backups are retained. The value can only be between 32 and 90 days.", + MarkdownDescription: "How long backups are retained. The value can only be between 32 and 90 days.", }, "status": schema.StringAttribute{ Computed: true, @@ -239,15 +246,16 @@ type InstanceModel struct { Id types.String `tfsdk:"id"` InstanceId types.String `tfsdk:"instance_id"` IsDeletable types.Bool `tfsdk:"is_deletable"` - Name types.String `tfsdk:"name"` - Network NetworkValue `tfsdk:"network"` - ProjectId types.String `tfsdk:"project_id"` - Region types.String `tfsdk:"region"` - Replicas types.Int64 `tfsdk:"replicas"` - RetentionDays types.Int64 `tfsdk:"retention_days"` - Status types.String `tfsdk:"status"` - Storage StorageValue `tfsdk:"storage"` - Version types.String `tfsdk:"version"` + //Labels types.Map `tfsdk:"labels"` + Name types.String `tfsdk:"name"` + Network NetworkValue `tfsdk:"network"` + ProjectId types.String `tfsdk:"project_id"` + Region types.String `tfsdk:"region"` + Replicas types.Int64 `tfsdk:"replicas"` + RetentionDays types.Int64 `tfsdk:"retention_days"` + Status types.String `tfsdk:"status"` + Storage StorageValue `tfsdk:"storage"` + Version types.String `tfsdk:"version"` } var _ basetypes.ObjectTypable = ConnectionInfoType{} diff --git a/stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go b/stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go new file mode 100644 index 00000000..a6dfc1d3 --- /dev/null +++ b/stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go @@ -0,0 +1,85 @@ +package postgresflexalpha + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +type useStateForUnknownIfFlavorUnchangedModifier struct { + Req resource.SchemaRequest +} + +// UseStateForUnknownIfFlavorUnchanged returns a plan modifier similar to UseStateForUnknown +// if the RAM and CPU values are not changed in the plan. Otherwise, the plan modifier does nothing. +func UseStateForUnknownIfFlavorUnchanged(req resource.SchemaRequest) planmodifier.String { + return useStateForUnknownIfFlavorUnchangedModifier{ + Req: req, + } +} + +func (m useStateForUnknownIfFlavorUnchangedModifier) Description(context.Context) string { + return "UseStateForUnknownIfFlavorUnchanged returns a plan modifier similar to UseStateForUnknown if the RAM and CPU values are not changed in the plan. Otherwise, the plan modifier does nothing." +} + +func (m useStateForUnknownIfFlavorUnchangedModifier) MarkdownDescription(ctx context.Context) string { + return m.Description(ctx) +} + +func (m useStateForUnknownIfFlavorUnchangedModifier) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) { // nolint:gocritic // function signature required by Terraform + // Do nothing if there is no state value. + if req.StateValue.IsNull() { + return + } + + // Do nothing if there is a known planned value. + if !req.PlanValue.IsUnknown() { + return + } + + // Do nothing if there is an unknown configuration value, otherwise interpolation gets messed up. + if req.ConfigValue.IsUnknown() { + return + } + + // The above checks are taken from the UseStateForUnknown plan modifier implementation + // (https://github.com/hashicorp/terraform-plugin-framework/blob/main/resource/schema/stringplanmodifier/use_state_for_unknown.go#L38) + + var stateModel LocalInstanceModel + diags := req.State.Get(ctx, &stateModel) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + var stateFlavor = &flavorModel{} + if !(stateModel.Flavor.IsNull() || stateModel.Flavor.IsUnknown()) { + diags = stateModel.Flavor.As(ctx, stateFlavor, basetypes.ObjectAsOptions{}) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + } + + var planModel LocalInstanceModel + diags = req.Plan.Get(ctx, &planModel) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + var planFlavor = &flavorModel{} + if !(planModel.Flavor.IsNull() || planModel.Flavor.IsUnknown()) { + diags = planModel.Flavor.As(ctx, planFlavor, basetypes.ObjectAsOptions{}) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + } + + if planFlavor.CPU == stateFlavor.CPU && planFlavor.RAM == stateFlavor.RAM { + resp.PlanValue = req.StateValue + } +} diff --git a/stackit/internal/services/postgresflexalpha/testdata/instance_template_with_flavor.gompl b/stackit/internal/services/postgresflexalpha/testdata/instance_template_with_flavor.gompl new file mode 100644 index 00000000..70d0692f --- /dev/null +++ b/stackit/internal/services/postgresflexalpha/testdata/instance_template_with_flavor.gompl @@ -0,0 +1,101 @@ +provider "stackitprivatepreview" { + default_region = "{{ .Region }}" + service_account_key_path = "{{ .ServiceAccountFilePath }}" +} + +data "stackitprivatepreview_postgresflexalpha_flavor" "flavor" { + project_id = "{{ .ProjectID }}" + region = "{{ .Region }}" + cpu = 4 + ram = 16 + node_type = "Single" + storage_class = "premium-perf2-stackit" +} + +resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" { + project_id = "{{ .ProjectID }}" + name = "{{ .Name }}" + backup_schedule = "{{ .BackupSchedule }}" + retention_days = {{ .RetentionDays }} + flavor_id = "{{ .FlavorID }}" + replicas = {{ .Replicas }} + storage = { + performance_class = "{{ .PerformanceClass }}" + size = {{ .Size }} + } +{{ if .UseEncryption }} + encryption = { + kek_key_id = "{{ .KekKeyID }}" + kek_key_ring_id = "{{ .KekKeyRingID }}" + kek_key_version = {{ .KekKeyVersion }} + service_account = "{{ .KekServiceAccount }}" + } +{{ end }} + network = { + acl = [{{ range $i, $v := .ACLStrings }}{{if $i}},{{end}}"{{$v}}"{{end}}] + access_scope = "{{ .AccessScope }}" + } +{{ if .Version }} + version = "{{ .Version }}" +{{ end }} +} + +{{ if .Users }} +{{ $tfName := .TfName }} +{{ range $user := .Users }} +resource "stackitprivatepreview_postgresflexalpha_user" "{{ $user.Name }}" { + depends_on = [ + stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }} + ] + project_id = "{{ $user.ProjectID }}" + instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id + name = "{{ $user.Name }}" + roles = [{{ range $i, $v := $user.Roles }}{{if $i}},{{end}}"{{$v}}"{{end}}] +} +{{ end }} +{{ end }} + +{{ if .Databases }} +{{ $tfName := .TfName }} +{{ range $db := .Databases }} +resource "stackitprivatepreview_postgresflexalpha_database" "{{ $db.Name }}" { + depends_on = [ + stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}, + stackitprivatepreview_postgresflexalpha_user.{{ $db.Owner }} + ] + project_id = "{{ $db.ProjectID }}" + instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id + name = "{{ $db.Name }}" + owner = stackitprivatepreview_postgresflexalpha_user.{{ $db.Owner }}.name +} +{{ end }} +{{ end }} + +{{ if .DataSourceTest }} +data "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" { + project_id = stackitprivatepreview_postgresflexalpha_instance.{{ .TfName }}.project_id + instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ .TfName }}.instance_id +} + +{{ if .Users }} +{{ $tfName := .TfName }} +{{ range $user := .Users }} +data "stackitprivatepreview_postgresflexalpha_user" "{{ $user.Name }}" { + project_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.project_id + instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id + user_id = stackitprivatepreview_postgresflexalpha_user.{{ $user.Name }}.user_id +} +{{ end }} +{{ end }} + +{{ if .Databases }} +{{ $tfName := .TfName }} +{{ range $db := .Databases }} +data "stackitprivatepreview_postgresflexalpha_database" "{{ $db.Name }}" { + project_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.project_id + instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id + database_id = stackitprivatepreview_postgresflexalpha_database.{{ $db.Name }}.database_id +} +{{ end }} +{{ end }} +{{ end }} diff --git a/stackit/internal/services/sqlserverflexalpha/collations/datasources_gen/collations_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/collations/datasources_gen/collations_data_source_gen.go new file mode 100644 index 00000000..a0f13e40 --- /dev/null +++ b/stackit/internal/services/sqlserverflexalpha/collations/datasources_gen/collations_data_source_gen.go @@ -0,0 +1,451 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package sqlserverflexalpha + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" +) + +func CollationsDataSourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "collations": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "collation_name": schema.StringAttribute{ + Computed: true, + }, + "description": schema.StringAttribute{ + Computed: true, + }, + }, + CustomType: CollationsType{ + ObjectType: types.ObjectType{ + AttrTypes: CollationsValue{}.AttributeTypes(ctx), + }, + }, + }, + Computed: true, + Description: "List of collations available for the instance.", + MarkdownDescription: "List of collations available for the instance.", + }, + "instance_id": schema.StringAttribute{ + Required: true, + Description: "The ID of the instance.", + MarkdownDescription: "The ID of the instance.", + }, + "project_id": schema.StringAttribute{ + Required: true, + Description: "The STACKIT project ID.", + MarkdownDescription: "The STACKIT project ID.", + }, + "region": schema.StringAttribute{ + Optional: true, + Description: "The region which should be addressed", + MarkdownDescription: "The region which should be addressed", + Validators: []validator.String{ + stringvalidator.OneOf( + "eu01", + ), + }, + }, + }, + } +} + +type CollationsModel struct { + Collations types.List `tfsdk:"collations"` + InstanceId types.String `tfsdk:"instance_id"` + ProjectId types.String `tfsdk:"project_id"` + Region types.String `tfsdk:"region"` +} + +var _ basetypes.ObjectTypable = CollationsType{} + +type CollationsType struct { + basetypes.ObjectType +} + +func (t CollationsType) Equal(o attr.Type) bool { + other, ok := o.(CollationsType) + + if !ok { + return false + } + + return t.ObjectType.Equal(other.ObjectType) +} + +func (t CollationsType) String() string { + return "CollationsType" +} + +func (t CollationsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { + var diags diag.Diagnostics + + attributes := in.Attributes() + + collationNameAttribute, ok := attributes["collation_name"] + + if !ok { + diags.AddError( + "Attribute Missing", + `collation_name is missing from object`) + + return nil, diags + } + + collationNameVal, ok := collationNameAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`collation_name expected to be basetypes.StringValue, was: %T`, collationNameAttribute)) + } + + descriptionAttribute, ok := attributes["description"] + + if !ok { + diags.AddError( + "Attribute Missing", + `description is missing from object`) + + return nil, diags + } + + descriptionVal, ok := descriptionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute)) + } + + if diags.HasError() { + return nil, diags + } + + return CollationsValue{ + CollationName: collationNameVal, + Description: descriptionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewCollationsValueNull() CollationsValue { + return CollationsValue{ + state: attr.ValueStateNull, + } +} + +func NewCollationsValueUnknown() CollationsValue { + return CollationsValue{ + state: attr.ValueStateUnknown, + } +} + +func NewCollationsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (CollationsValue, diag.Diagnostics) { + var diags diag.Diagnostics + + // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 + ctx := context.Background() + + for name, attributeType := range attributeTypes { + attribute, ok := attributes[name] + + if !ok { + diags.AddError( + "Missing CollationsValue Attribute Value", + "While creating a CollationsValue value, a missing attribute value was detected. "+ + "A CollationsValue must contain values for all attributes, even if null or unknown. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("CollationsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), + ) + + continue + } + + if !attributeType.Equal(attribute.Type(ctx)) { + diags.AddError( + "Invalid CollationsValue Attribute Type", + "While creating a CollationsValue value, an invalid attribute value was detected. "+ + "A CollationsValue must use a matching attribute type for the value. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("CollationsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ + fmt.Sprintf("CollationsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), + ) + } + } + + for name := range attributes { + _, ok := attributeTypes[name] + + if !ok { + diags.AddError( + "Extra CollationsValue Attribute Value", + "While creating a CollationsValue value, an extra attribute value was detected. "+ + "A CollationsValue must not contain values beyond the expected attribute types. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("Extra CollationsValue Attribute Name: %s", name), + ) + } + } + + if diags.HasError() { + return NewCollationsValueUnknown(), diags + } + + collationNameAttribute, ok := attributes["collation_name"] + + if !ok { + diags.AddError( + "Attribute Missing", + `collation_name is missing from object`) + + return NewCollationsValueUnknown(), diags + } + + collationNameVal, ok := collationNameAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`collation_name expected to be basetypes.StringValue, was: %T`, collationNameAttribute)) + } + + descriptionAttribute, ok := attributes["description"] + + if !ok { + diags.AddError( + "Attribute Missing", + `description is missing from object`) + + return NewCollationsValueUnknown(), diags + } + + descriptionVal, ok := descriptionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute)) + } + + if diags.HasError() { + return NewCollationsValueUnknown(), diags + } + + return CollationsValue{ + CollationName: collationNameVal, + Description: descriptionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewCollationsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) CollationsValue { + object, diags := NewCollationsValue(attributeTypes, attributes) + + if diags.HasError() { + // This could potentially be added to the diag package. + diagsStrings := make([]string, 0, len(diags)) + + for _, diagnostic := range diags { + diagsStrings = append(diagsStrings, fmt.Sprintf( + "%s | %s | %s", + diagnostic.Severity(), + diagnostic.Summary(), + diagnostic.Detail())) + } + + panic("NewCollationsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) + } + + return object +} + +func (t CollationsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + if in.Type() == nil { + return NewCollationsValueNull(), nil + } + + if !in.Type().Equal(t.TerraformType(ctx)) { + return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) + } + + if !in.IsKnown() { + return NewCollationsValueUnknown(), nil + } + + if in.IsNull() { + return NewCollationsValueNull(), nil + } + + attributes := map[string]attr.Value{} + + val := map[string]tftypes.Value{} + + err := in.As(&val) + + if err != nil { + return nil, err + } + + for k, v := range val { + a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) + + if err != nil { + return nil, err + } + + attributes[k] = a + } + + return NewCollationsValueMust(CollationsValue{}.AttributeTypes(ctx), attributes), nil +} + +func (t CollationsType) ValueType(ctx context.Context) attr.Value { + return CollationsValue{} +} + +var _ basetypes.ObjectValuable = CollationsValue{} + +type CollationsValue struct { + CollationName basetypes.StringValue `tfsdk:"collation_name"` + Description basetypes.StringValue `tfsdk:"description"` + state attr.ValueState +} + +func (v CollationsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { + attrTypes := make(map[string]tftypes.Type, 2) + + var val tftypes.Value + var err error + + attrTypes["collation_name"] = basetypes.StringType{}.TerraformType(ctx) + attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx) + + objectType := tftypes.Object{AttributeTypes: attrTypes} + + switch v.state { + case attr.ValueStateKnown: + vals := make(map[string]tftypes.Value, 2) + + val, err = v.CollationName.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["collation_name"] = val + + val, err = v.Description.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["description"] = val + + if err := tftypes.ValidateValue(objectType, vals); err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + return tftypes.NewValue(objectType, vals), nil + case attr.ValueStateNull: + return tftypes.NewValue(objectType, nil), nil + case attr.ValueStateUnknown: + return tftypes.NewValue(objectType, tftypes.UnknownValue), nil + default: + panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) + } +} + +func (v CollationsValue) IsNull() bool { + return v.state == attr.ValueStateNull +} + +func (v CollationsValue) IsUnknown() bool { + return v.state == attr.ValueStateUnknown +} + +func (v CollationsValue) String() string { + return "CollationsValue" +} + +func (v CollationsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { + var diags diag.Diagnostics + + attributeTypes := map[string]attr.Type{ + "collation_name": basetypes.StringType{}, + "description": basetypes.StringType{}, + } + + if v.IsNull() { + return types.ObjectNull(attributeTypes), diags + } + + if v.IsUnknown() { + return types.ObjectUnknown(attributeTypes), diags + } + + objVal, diags := types.ObjectValue( + attributeTypes, + map[string]attr.Value{ + "collation_name": v.CollationName, + "description": v.Description, + }) + + return objVal, diags +} + +func (v CollationsValue) Equal(o attr.Value) bool { + other, ok := o.(CollationsValue) + + if !ok { + return false + } + + if v.state != other.state { + return false + } + + if v.state != attr.ValueStateKnown { + return true + } + + if !v.CollationName.Equal(other.CollationName) { + return false + } + + if !v.Description.Equal(other.Description) { + return false + } + + return true +} + +func (v CollationsValue) Type(ctx context.Context) attr.Type { + return CollationsType{ + basetypes.ObjectType{ + AttrTypes: v.AttributeTypes(ctx), + }, + } +} + +func (v CollationsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "collation_name": basetypes.StringType{}, + "description": basetypes.StringType{}, + } +} diff --git a/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/versions_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/versions_data_source_gen.go new file mode 100644 index 00000000..dc3dc150 --- /dev/null +++ b/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/versions_data_source_gen.go @@ -0,0 +1,569 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package sqlserverflexalpha + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" +) + +func VersionsDataSourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "project_id": schema.StringAttribute{ + Required: true, + Description: "The STACKIT project ID.", + MarkdownDescription: "The STACKIT project ID.", + }, + "region": schema.StringAttribute{ + Optional: true, + Description: "The region which should be addressed", + MarkdownDescription: "The region which should be addressed", + Validators: []validator.String{ + stringvalidator.OneOf( + "eu01", + ), + }, + }, + "versions": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "beta": schema.BoolAttribute{ + Computed: true, + Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", + MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", + }, + "deprecated": schema.StringAttribute{ + Computed: true, + Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", + MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", + }, + "recommend": schema.BoolAttribute{ + Computed: true, + Description: "Flag if the version is recommend by the STACKIT Team.", + MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.", + }, + "version": schema.StringAttribute{ + Computed: true, + Description: "The sqlserver version used for the instance.", + MarkdownDescription: "The sqlserver version used for the instance.", + }, + }, + CustomType: VersionsType{ + ObjectType: types.ObjectType{ + AttrTypes: VersionsValue{}.AttributeTypes(ctx), + }, + }, + }, + Computed: true, + Description: "A list containing available sqlserver versions.", + MarkdownDescription: "A list containing available sqlserver versions.", + }, + }, + } +} + +type VersionsModel struct { + ProjectId types.String `tfsdk:"project_id"` + Region types.String `tfsdk:"region"` + Versions types.List `tfsdk:"versions"` +} + +var _ basetypes.ObjectTypable = VersionsType{} + +type VersionsType struct { + basetypes.ObjectType +} + +func (t VersionsType) Equal(o attr.Type) bool { + other, ok := o.(VersionsType) + + if !ok { + return false + } + + return t.ObjectType.Equal(other.ObjectType) +} + +func (t VersionsType) String() string { + return "VersionsType" +} + +func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { + var diags diag.Diagnostics + + attributes := in.Attributes() + + betaAttribute, ok := attributes["beta"] + + if !ok { + diags.AddError( + "Attribute Missing", + `beta is missing from object`) + + return nil, diags + } + + betaVal, ok := betaAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) + } + + deprecatedAttribute, ok := attributes["deprecated"] + + if !ok { + diags.AddError( + "Attribute Missing", + `deprecated is missing from object`) + + return nil, diags + } + + deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) + } + + recommendAttribute, ok := attributes["recommend"] + + if !ok { + diags.AddError( + "Attribute Missing", + `recommend is missing from object`) + + return nil, diags + } + + recommendVal, ok := recommendAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) + } + + versionAttribute, ok := attributes["version"] + + if !ok { + diags.AddError( + "Attribute Missing", + `version is missing from object`) + + return nil, diags + } + + versionVal, ok := versionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) + } + + if diags.HasError() { + return nil, diags + } + + return VersionsValue{ + Beta: betaVal, + Deprecated: deprecatedVal, + Recommend: recommendVal, + Version: versionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewVersionsValueNull() VersionsValue { + return VersionsValue{ + state: attr.ValueStateNull, + } +} + +func NewVersionsValueUnknown() VersionsValue { + return VersionsValue{ + state: attr.ValueStateUnknown, + } +} + +func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) { + var diags diag.Diagnostics + + // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 + ctx := context.Background() + + for name, attributeType := range attributeTypes { + attribute, ok := attributes[name] + + if !ok { + diags.AddError( + "Missing VersionsValue Attribute Value", + "While creating a VersionsValue value, a missing attribute value was detected. "+ + "A VersionsValue must contain values for all attributes, even if null or unknown. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), + ) + + continue + } + + if !attributeType.Equal(attribute.Type(ctx)) { + diags.AddError( + "Invalid VersionsValue Attribute Type", + "While creating a VersionsValue value, an invalid attribute value was detected. "+ + "A VersionsValue must use a matching attribute type for the value. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ + fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), + ) + } + } + + for name := range attributes { + _, ok := attributeTypes[name] + + if !ok { + diags.AddError( + "Extra VersionsValue Attribute Value", + "While creating a VersionsValue value, an extra attribute value was detected. "+ + "A VersionsValue must not contain values beyond the expected attribute types. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name), + ) + } + } + + if diags.HasError() { + return NewVersionsValueUnknown(), diags + } + + betaAttribute, ok := attributes["beta"] + + if !ok { + diags.AddError( + "Attribute Missing", + `beta is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + betaVal, ok := betaAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) + } + + deprecatedAttribute, ok := attributes["deprecated"] + + if !ok { + diags.AddError( + "Attribute Missing", + `deprecated is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) + } + + recommendAttribute, ok := attributes["recommend"] + + if !ok { + diags.AddError( + "Attribute Missing", + `recommend is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + recommendVal, ok := recommendAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) + } + + versionAttribute, ok := attributes["version"] + + if !ok { + diags.AddError( + "Attribute Missing", + `version is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + versionVal, ok := versionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) + } + + if diags.HasError() { + return NewVersionsValueUnknown(), diags + } + + return VersionsValue{ + Beta: betaVal, + Deprecated: deprecatedVal, + Recommend: recommendVal, + Version: versionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue { + object, diags := NewVersionsValue(attributeTypes, attributes) + + if diags.HasError() { + // This could potentially be added to the diag package. + diagsStrings := make([]string, 0, len(diags)) + + for _, diagnostic := range diags { + diagsStrings = append(diagsStrings, fmt.Sprintf( + "%s | %s | %s", + diagnostic.Severity(), + diagnostic.Summary(), + diagnostic.Detail())) + } + + panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) + } + + return object +} + +func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + if in.Type() == nil { + return NewVersionsValueNull(), nil + } + + if !in.Type().Equal(t.TerraformType(ctx)) { + return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) + } + + if !in.IsKnown() { + return NewVersionsValueUnknown(), nil + } + + if in.IsNull() { + return NewVersionsValueNull(), nil + } + + attributes := map[string]attr.Value{} + + val := map[string]tftypes.Value{} + + err := in.As(&val) + + if err != nil { + return nil, err + } + + for k, v := range val { + a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) + + if err != nil { + return nil, err + } + + attributes[k] = a + } + + return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil +} + +func (t VersionsType) ValueType(ctx context.Context) attr.Value { + return VersionsValue{} +} + +var _ basetypes.ObjectValuable = VersionsValue{} + +type VersionsValue struct { + Beta basetypes.BoolValue `tfsdk:"beta"` + Deprecated basetypes.StringValue `tfsdk:"deprecated"` + Recommend basetypes.BoolValue `tfsdk:"recommend"` + Version basetypes.StringValue `tfsdk:"version"` + state attr.ValueState +} + +func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { + attrTypes := make(map[string]tftypes.Type, 4) + + var val tftypes.Value + var err error + + attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx) + attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx) + attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx) + attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx) + + objectType := tftypes.Object{AttributeTypes: attrTypes} + + switch v.state { + case attr.ValueStateKnown: + vals := make(map[string]tftypes.Value, 4) + + val, err = v.Beta.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["beta"] = val + + val, err = v.Deprecated.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["deprecated"] = val + + val, err = v.Recommend.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["recommend"] = val + + val, err = v.Version.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["version"] = val + + if err := tftypes.ValidateValue(objectType, vals); err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + return tftypes.NewValue(objectType, vals), nil + case attr.ValueStateNull: + return tftypes.NewValue(objectType, nil), nil + case attr.ValueStateUnknown: + return tftypes.NewValue(objectType, tftypes.UnknownValue), nil + default: + panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) + } +} + +func (v VersionsValue) IsNull() bool { + return v.state == attr.ValueStateNull +} + +func (v VersionsValue) IsUnknown() bool { + return v.state == attr.ValueStateUnknown +} + +func (v VersionsValue) String() string { + return "VersionsValue" +} + +func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { + var diags diag.Diagnostics + + attributeTypes := map[string]attr.Type{ + "beta": basetypes.BoolType{}, + "deprecated": basetypes.StringType{}, + "recommend": basetypes.BoolType{}, + "version": basetypes.StringType{}, + } + + if v.IsNull() { + return types.ObjectNull(attributeTypes), diags + } + + if v.IsUnknown() { + return types.ObjectUnknown(attributeTypes), diags + } + + objVal, diags := types.ObjectValue( + attributeTypes, + map[string]attr.Value{ + "beta": v.Beta, + "deprecated": v.Deprecated, + "recommend": v.Recommend, + "version": v.Version, + }) + + return objVal, diags +} + +func (v VersionsValue) Equal(o attr.Value) bool { + other, ok := o.(VersionsValue) + + if !ok { + return false + } + + if v.state != other.state { + return false + } + + if v.state != attr.ValueStateKnown { + return true + } + + if !v.Beta.Equal(other.Beta) { + return false + } + + if !v.Deprecated.Equal(other.Deprecated) { + return false + } + + if !v.Recommend.Equal(other.Recommend) { + return false + } + + if !v.Version.Equal(other.Version) { + return false + } + + return true +} + +func (v VersionsValue) Type(ctx context.Context) attr.Type { + return VersionsType{ + basetypes.ObjectType{ + AttrTypes: v.AttributeTypes(ctx), + }, + } +} + +func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "beta": basetypes.BoolType{}, + "deprecated": basetypes.StringType{}, + "recommend": basetypes.BoolType{}, + "version": basetypes.StringType{}, + } +} diff --git a/stackit/internal/services/sqlserverflexbeta/collations/datasources_gen/collations_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/collations/datasources_gen/collations_data_source_gen.go new file mode 100644 index 00000000..7ed20e4d --- /dev/null +++ b/stackit/internal/services/sqlserverflexbeta/collations/datasources_gen/collations_data_source_gen.go @@ -0,0 +1,452 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package sqlserverflexbeta + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" +) + +func CollationsDataSourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "collations": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "collation_name": schema.StringAttribute{ + Computed: true, + }, + "description": schema.StringAttribute{ + Computed: true, + }, + }, + CustomType: CollationsType{ + ObjectType: types.ObjectType{ + AttrTypes: CollationsValue{}.AttributeTypes(ctx), + }, + }, + }, + Computed: true, + Description: "List of collations available for the instance.", + MarkdownDescription: "List of collations available for the instance.", + }, + "instance_id": schema.StringAttribute{ + Required: true, + Description: "The ID of the instance.", + MarkdownDescription: "The ID of the instance.", + }, + "project_id": schema.StringAttribute{ + Required: true, + Description: "The STACKIT project ID.", + MarkdownDescription: "The STACKIT project ID.", + }, + "region": schema.StringAttribute{ + Optional: true, + Description: "The region which should be addressed", + MarkdownDescription: "The region which should be addressed", + Validators: []validator.String{ + stringvalidator.OneOf( + "eu01", + "eu02", + ), + }, + }, + }, + } +} + +type CollationsModel struct { + Collations types.List `tfsdk:"collations"` + InstanceId types.String `tfsdk:"instance_id"` + ProjectId types.String `tfsdk:"project_id"` + Region types.String `tfsdk:"region"` +} + +var _ basetypes.ObjectTypable = CollationsType{} + +type CollationsType struct { + basetypes.ObjectType +} + +func (t CollationsType) Equal(o attr.Type) bool { + other, ok := o.(CollationsType) + + if !ok { + return false + } + + return t.ObjectType.Equal(other.ObjectType) +} + +func (t CollationsType) String() string { + return "CollationsType" +} + +func (t CollationsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { + var diags diag.Diagnostics + + attributes := in.Attributes() + + collationNameAttribute, ok := attributes["collation_name"] + + if !ok { + diags.AddError( + "Attribute Missing", + `collation_name is missing from object`) + + return nil, diags + } + + collationNameVal, ok := collationNameAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`collation_name expected to be basetypes.StringValue, was: %T`, collationNameAttribute)) + } + + descriptionAttribute, ok := attributes["description"] + + if !ok { + diags.AddError( + "Attribute Missing", + `description is missing from object`) + + return nil, diags + } + + descriptionVal, ok := descriptionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute)) + } + + if diags.HasError() { + return nil, diags + } + + return CollationsValue{ + CollationName: collationNameVal, + Description: descriptionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewCollationsValueNull() CollationsValue { + return CollationsValue{ + state: attr.ValueStateNull, + } +} + +func NewCollationsValueUnknown() CollationsValue { + return CollationsValue{ + state: attr.ValueStateUnknown, + } +} + +func NewCollationsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (CollationsValue, diag.Diagnostics) { + var diags diag.Diagnostics + + // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 + ctx := context.Background() + + for name, attributeType := range attributeTypes { + attribute, ok := attributes[name] + + if !ok { + diags.AddError( + "Missing CollationsValue Attribute Value", + "While creating a CollationsValue value, a missing attribute value was detected. "+ + "A CollationsValue must contain values for all attributes, even if null or unknown. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("CollationsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), + ) + + continue + } + + if !attributeType.Equal(attribute.Type(ctx)) { + diags.AddError( + "Invalid CollationsValue Attribute Type", + "While creating a CollationsValue value, an invalid attribute value was detected. "+ + "A CollationsValue must use a matching attribute type for the value. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("CollationsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ + fmt.Sprintf("CollationsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), + ) + } + } + + for name := range attributes { + _, ok := attributeTypes[name] + + if !ok { + diags.AddError( + "Extra CollationsValue Attribute Value", + "While creating a CollationsValue value, an extra attribute value was detected. "+ + "A CollationsValue must not contain values beyond the expected attribute types. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("Extra CollationsValue Attribute Name: %s", name), + ) + } + } + + if diags.HasError() { + return NewCollationsValueUnknown(), diags + } + + collationNameAttribute, ok := attributes["collation_name"] + + if !ok { + diags.AddError( + "Attribute Missing", + `collation_name is missing from object`) + + return NewCollationsValueUnknown(), diags + } + + collationNameVal, ok := collationNameAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`collation_name expected to be basetypes.StringValue, was: %T`, collationNameAttribute)) + } + + descriptionAttribute, ok := attributes["description"] + + if !ok { + diags.AddError( + "Attribute Missing", + `description is missing from object`) + + return NewCollationsValueUnknown(), diags + } + + descriptionVal, ok := descriptionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`description expected to be basetypes.StringValue, was: %T`, descriptionAttribute)) + } + + if diags.HasError() { + return NewCollationsValueUnknown(), diags + } + + return CollationsValue{ + CollationName: collationNameVal, + Description: descriptionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewCollationsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) CollationsValue { + object, diags := NewCollationsValue(attributeTypes, attributes) + + if diags.HasError() { + // This could potentially be added to the diag package. + diagsStrings := make([]string, 0, len(diags)) + + for _, diagnostic := range diags { + diagsStrings = append(diagsStrings, fmt.Sprintf( + "%s | %s | %s", + diagnostic.Severity(), + diagnostic.Summary(), + diagnostic.Detail())) + } + + panic("NewCollationsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) + } + + return object +} + +func (t CollationsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + if in.Type() == nil { + return NewCollationsValueNull(), nil + } + + if !in.Type().Equal(t.TerraformType(ctx)) { + return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) + } + + if !in.IsKnown() { + return NewCollationsValueUnknown(), nil + } + + if in.IsNull() { + return NewCollationsValueNull(), nil + } + + attributes := map[string]attr.Value{} + + val := map[string]tftypes.Value{} + + err := in.As(&val) + + if err != nil { + return nil, err + } + + for k, v := range val { + a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) + + if err != nil { + return nil, err + } + + attributes[k] = a + } + + return NewCollationsValueMust(CollationsValue{}.AttributeTypes(ctx), attributes), nil +} + +func (t CollationsType) ValueType(ctx context.Context) attr.Value { + return CollationsValue{} +} + +var _ basetypes.ObjectValuable = CollationsValue{} + +type CollationsValue struct { + CollationName basetypes.StringValue `tfsdk:"collation_name"` + Description basetypes.StringValue `tfsdk:"description"` + state attr.ValueState +} + +func (v CollationsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { + attrTypes := make(map[string]tftypes.Type, 2) + + var val tftypes.Value + var err error + + attrTypes["collation_name"] = basetypes.StringType{}.TerraformType(ctx) + attrTypes["description"] = basetypes.StringType{}.TerraformType(ctx) + + objectType := tftypes.Object{AttributeTypes: attrTypes} + + switch v.state { + case attr.ValueStateKnown: + vals := make(map[string]tftypes.Value, 2) + + val, err = v.CollationName.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["collation_name"] = val + + val, err = v.Description.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["description"] = val + + if err := tftypes.ValidateValue(objectType, vals); err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + return tftypes.NewValue(objectType, vals), nil + case attr.ValueStateNull: + return tftypes.NewValue(objectType, nil), nil + case attr.ValueStateUnknown: + return tftypes.NewValue(objectType, tftypes.UnknownValue), nil + default: + panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) + } +} + +func (v CollationsValue) IsNull() bool { + return v.state == attr.ValueStateNull +} + +func (v CollationsValue) IsUnknown() bool { + return v.state == attr.ValueStateUnknown +} + +func (v CollationsValue) String() string { + return "CollationsValue" +} + +func (v CollationsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { + var diags diag.Diagnostics + + attributeTypes := map[string]attr.Type{ + "collation_name": basetypes.StringType{}, + "description": basetypes.StringType{}, + } + + if v.IsNull() { + return types.ObjectNull(attributeTypes), diags + } + + if v.IsUnknown() { + return types.ObjectUnknown(attributeTypes), diags + } + + objVal, diags := types.ObjectValue( + attributeTypes, + map[string]attr.Value{ + "collation_name": v.CollationName, + "description": v.Description, + }) + + return objVal, diags +} + +func (v CollationsValue) Equal(o attr.Value) bool { + other, ok := o.(CollationsValue) + + if !ok { + return false + } + + if v.state != other.state { + return false + } + + if v.state != attr.ValueStateKnown { + return true + } + + if !v.CollationName.Equal(other.CollationName) { + return false + } + + if !v.Description.Equal(other.Description) { + return false + } + + return true +} + +func (v CollationsValue) Type(ctx context.Context) attr.Type { + return CollationsType{ + basetypes.ObjectType{ + AttrTypes: v.AttributeTypes(ctx), + }, + } +} + +func (v CollationsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "collation_name": basetypes.StringType{}, + "description": basetypes.StringType{}, + } +} diff --git a/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/versions_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/versions_data_source_gen.go new file mode 100644 index 00000000..c4f33642 --- /dev/null +++ b/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/versions_data_source_gen.go @@ -0,0 +1,570 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package sqlserverflexbeta + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" +) + +func VersionsDataSourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "project_id": schema.StringAttribute{ + Required: true, + Description: "The STACKIT project ID.", + MarkdownDescription: "The STACKIT project ID.", + }, + "region": schema.StringAttribute{ + Optional: true, + Description: "The region which should be addressed", + MarkdownDescription: "The region which should be addressed", + Validators: []validator.String{ + stringvalidator.OneOf( + "eu01", + "eu02", + ), + }, + }, + "versions": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "beta": schema.BoolAttribute{ + Computed: true, + Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", + MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", + }, + "deprecated": schema.StringAttribute{ + Computed: true, + Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", + MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", + }, + "recommend": schema.BoolAttribute{ + Computed: true, + Description: "Flag if the version is recommend by the STACKIT Team.", + MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.", + }, + "version": schema.StringAttribute{ + Computed: true, + Description: "The sqlserver version used for the instance.", + MarkdownDescription: "The sqlserver version used for the instance.", + }, + }, + CustomType: VersionsType{ + ObjectType: types.ObjectType{ + AttrTypes: VersionsValue{}.AttributeTypes(ctx), + }, + }, + }, + Computed: true, + Description: "A list containing available sqlserver versions.", + MarkdownDescription: "A list containing available sqlserver versions.", + }, + }, + } +} + +type VersionsModel struct { + ProjectId types.String `tfsdk:"project_id"` + Region types.String `tfsdk:"region"` + Versions types.List `tfsdk:"versions"` +} + +var _ basetypes.ObjectTypable = VersionsType{} + +type VersionsType struct { + basetypes.ObjectType +} + +func (t VersionsType) Equal(o attr.Type) bool { + other, ok := o.(VersionsType) + + if !ok { + return false + } + + return t.ObjectType.Equal(other.ObjectType) +} + +func (t VersionsType) String() string { + return "VersionsType" +} + +func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { + var diags diag.Diagnostics + + attributes := in.Attributes() + + betaAttribute, ok := attributes["beta"] + + if !ok { + diags.AddError( + "Attribute Missing", + `beta is missing from object`) + + return nil, diags + } + + betaVal, ok := betaAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) + } + + deprecatedAttribute, ok := attributes["deprecated"] + + if !ok { + diags.AddError( + "Attribute Missing", + `deprecated is missing from object`) + + return nil, diags + } + + deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) + } + + recommendAttribute, ok := attributes["recommend"] + + if !ok { + diags.AddError( + "Attribute Missing", + `recommend is missing from object`) + + return nil, diags + } + + recommendVal, ok := recommendAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) + } + + versionAttribute, ok := attributes["version"] + + if !ok { + diags.AddError( + "Attribute Missing", + `version is missing from object`) + + return nil, diags + } + + versionVal, ok := versionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) + } + + if diags.HasError() { + return nil, diags + } + + return VersionsValue{ + Beta: betaVal, + Deprecated: deprecatedVal, + Recommend: recommendVal, + Version: versionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewVersionsValueNull() VersionsValue { + return VersionsValue{ + state: attr.ValueStateNull, + } +} + +func NewVersionsValueUnknown() VersionsValue { + return VersionsValue{ + state: attr.ValueStateUnknown, + } +} + +func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) { + var diags diag.Diagnostics + + // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 + ctx := context.Background() + + for name, attributeType := range attributeTypes { + attribute, ok := attributes[name] + + if !ok { + diags.AddError( + "Missing VersionsValue Attribute Value", + "While creating a VersionsValue value, a missing attribute value was detected. "+ + "A VersionsValue must contain values for all attributes, even if null or unknown. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), + ) + + continue + } + + if !attributeType.Equal(attribute.Type(ctx)) { + diags.AddError( + "Invalid VersionsValue Attribute Type", + "While creating a VersionsValue value, an invalid attribute value was detected. "+ + "A VersionsValue must use a matching attribute type for the value. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ + fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), + ) + } + } + + for name := range attributes { + _, ok := attributeTypes[name] + + if !ok { + diags.AddError( + "Extra VersionsValue Attribute Value", + "While creating a VersionsValue value, an extra attribute value was detected. "+ + "A VersionsValue must not contain values beyond the expected attribute types. "+ + "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ + fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name), + ) + } + } + + if diags.HasError() { + return NewVersionsValueUnknown(), diags + } + + betaAttribute, ok := attributes["beta"] + + if !ok { + diags.AddError( + "Attribute Missing", + `beta is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + betaVal, ok := betaAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) + } + + deprecatedAttribute, ok := attributes["deprecated"] + + if !ok { + diags.AddError( + "Attribute Missing", + `deprecated is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) + } + + recommendAttribute, ok := attributes["recommend"] + + if !ok { + diags.AddError( + "Attribute Missing", + `recommend is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + recommendVal, ok := recommendAttribute.(basetypes.BoolValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) + } + + versionAttribute, ok := attributes["version"] + + if !ok { + diags.AddError( + "Attribute Missing", + `version is missing from object`) + + return NewVersionsValueUnknown(), diags + } + + versionVal, ok := versionAttribute.(basetypes.StringValue) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) + } + + if diags.HasError() { + return NewVersionsValueUnknown(), diags + } + + return VersionsValue{ + Beta: betaVal, + Deprecated: deprecatedVal, + Recommend: recommendVal, + Version: versionVal, + state: attr.ValueStateKnown, + }, diags +} + +func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue { + object, diags := NewVersionsValue(attributeTypes, attributes) + + if diags.HasError() { + // This could potentially be added to the diag package. + diagsStrings := make([]string, 0, len(diags)) + + for _, diagnostic := range diags { + diagsStrings = append(diagsStrings, fmt.Sprintf( + "%s | %s | %s", + diagnostic.Severity(), + diagnostic.Summary(), + diagnostic.Detail())) + } + + panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) + } + + return object +} + +func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + if in.Type() == nil { + return NewVersionsValueNull(), nil + } + + if !in.Type().Equal(t.TerraformType(ctx)) { + return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) + } + + if !in.IsKnown() { + return NewVersionsValueUnknown(), nil + } + + if in.IsNull() { + return NewVersionsValueNull(), nil + } + + attributes := map[string]attr.Value{} + + val := map[string]tftypes.Value{} + + err := in.As(&val) + + if err != nil { + return nil, err + } + + for k, v := range val { + a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) + + if err != nil { + return nil, err + } + + attributes[k] = a + } + + return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil +} + +func (t VersionsType) ValueType(ctx context.Context) attr.Value { + return VersionsValue{} +} + +var _ basetypes.ObjectValuable = VersionsValue{} + +type VersionsValue struct { + Beta basetypes.BoolValue `tfsdk:"beta"` + Deprecated basetypes.StringValue `tfsdk:"deprecated"` + Recommend basetypes.BoolValue `tfsdk:"recommend"` + Version basetypes.StringValue `tfsdk:"version"` + state attr.ValueState +} + +func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { + attrTypes := make(map[string]tftypes.Type, 4) + + var val tftypes.Value + var err error + + attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx) + attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx) + attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx) + attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx) + + objectType := tftypes.Object{AttributeTypes: attrTypes} + + switch v.state { + case attr.ValueStateKnown: + vals := make(map[string]tftypes.Value, 4) + + val, err = v.Beta.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["beta"] = val + + val, err = v.Deprecated.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["deprecated"] = val + + val, err = v.Recommend.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["recommend"] = val + + val, err = v.Version.ToTerraformValue(ctx) + + if err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + vals["version"] = val + + if err := tftypes.ValidateValue(objectType, vals); err != nil { + return tftypes.NewValue(objectType, tftypes.UnknownValue), err + } + + return tftypes.NewValue(objectType, vals), nil + case attr.ValueStateNull: + return tftypes.NewValue(objectType, nil), nil + case attr.ValueStateUnknown: + return tftypes.NewValue(objectType, tftypes.UnknownValue), nil + default: + panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) + } +} + +func (v VersionsValue) IsNull() bool { + return v.state == attr.ValueStateNull +} + +func (v VersionsValue) IsUnknown() bool { + return v.state == attr.ValueStateUnknown +} + +func (v VersionsValue) String() string { + return "VersionsValue" +} + +func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { + var diags diag.Diagnostics + + attributeTypes := map[string]attr.Type{ + "beta": basetypes.BoolType{}, + "deprecated": basetypes.StringType{}, + "recommend": basetypes.BoolType{}, + "version": basetypes.StringType{}, + } + + if v.IsNull() { + return types.ObjectNull(attributeTypes), diags + } + + if v.IsUnknown() { + return types.ObjectUnknown(attributeTypes), diags + } + + objVal, diags := types.ObjectValue( + attributeTypes, + map[string]attr.Value{ + "beta": v.Beta, + "deprecated": v.Deprecated, + "recommend": v.Recommend, + "version": v.Version, + }) + + return objVal, diags +} + +func (v VersionsValue) Equal(o attr.Value) bool { + other, ok := o.(VersionsValue) + + if !ok { + return false + } + + if v.state != other.state { + return false + } + + if v.state != attr.ValueStateKnown { + return true + } + + if !v.Beta.Equal(other.Beta) { + return false + } + + if !v.Deprecated.Equal(other.Deprecated) { + return false + } + + if !v.Recommend.Equal(other.Recommend) { + return false + } + + if !v.Version.Equal(other.Version) { + return false + } + + return true +} + +func (v VersionsValue) Type(ctx context.Context) attr.Type { + return VersionsType{ + basetypes.ObjectType{ + AttrTypes: v.AttributeTypes(ctx), + }, + } +} + +func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "beta": basetypes.BoolType{}, + "deprecated": basetypes.StringType{}, + "recommend": basetypes.BoolType{}, + "version": basetypes.StringType{}, + } +} diff --git a/stackit/provider.go b/stackit/provider.go index 62990050..df5f299a 100644 --- a/stackit/provider.go +++ b/stackit/provider.go @@ -20,10 +20,9 @@ import ( sdkauth "github.com/stackitcloud/stackit-sdk-go/core/auth" "github.com/stackitcloud/stackit-sdk-go/core/config" - sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database" - sqlserverflexalphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance" - sqlserverflexalphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user" - sqlserverflexbetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user" + //sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database" + //sqlserverflexalphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance" + //sqlserverflexalphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/features" @@ -36,7 +35,7 @@ import ( sqlserverFlexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database" sqlserverflexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance" - // sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbetaUser/user" + sqlserverflexbetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user" ) // Ensure the implementation satisfies the expected interfaces @@ -536,9 +535,9 @@ func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource postgresflexalphaFlavors.NewFlavorsDataSource, // sqlserverFlexAlphaFlavor.NewFlavorDataSource, - sqlserverflexalphaInstance.NewInstanceDataSource, - sqlserverflexalphaUser.NewUserDataSource, - sqlserverflexalphaDatabase.NewDatabaseDataSource, + //sqlserverflexalphaInstance.NewInstanceDataSource, + //sqlserverflexalphaUser.NewUserDataSource, + //sqlserverflexalphaDatabase.NewDatabaseDataSource, sqlserverFlexBetaDatabase.NewDatabaseDataSource, sqlserverflexBetaInstance.NewInstanceDataSource, @@ -554,9 +553,9 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource { postgresFlexAlphaUser.NewUserResource, postgresFlexAlphaDatabase.NewDatabaseResource, - sqlserverflexalphaInstance.NewInstanceResource, - sqlserverflexalphaUser.NewUserResource, - sqlserverflexalphaDatabase.NewDatabaseResource, + //sqlserverflexalphaInstance.NewInstanceResource, + //sqlserverflexalphaUser.NewUserResource, + //sqlserverflexalphaDatabase.NewDatabaseResource, sqlserverflexBetaInstance.NewInstanceResource, sqlserverflexbetaUser.NewUserResource, From 82355de0f1febc59528f70abc55895c1f87c6c25 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Thu, 7 May 2026 06:27:31 +0200 Subject: [PATCH 4/5] fix: #106 adjust tests --- stackit/provider_acc_test.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/stackit/provider_acc_test.go b/stackit/provider_acc_test.go index 38e22144..a50503ae 100644 --- a/stackit/provider_acc_test.go +++ b/stackit/provider_acc_test.go @@ -10,8 +10,6 @@ import ( "github.com/google/go-cmp/cmp" - sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database" - //nolint:staticcheck // used for acceptance testing postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor" @@ -23,8 +21,6 @@ import ( postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors" postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance" postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user" - sqlserverFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance" - sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user" sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database" sqlserverFlexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance" sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user" @@ -63,9 +59,9 @@ func TestUnitProviderHasChildDataSources_Basic(t *testing.T) { postgresflexalphaFlavors.NewFlavorsDataSource(), // sqlserverFlexAlphaFlavor.NewFlavorDataSource(), - sqlserverFlexAlphaInstance.NewInstanceDataSource(), - sqlserverFlexAlphaUser.NewUserDataSource(), - sqlserverflexalphaDatabase.NewDatabaseDataSource(), + //sqlserverFlexAlphaInstance.NewInstanceDataSource(), + //sqlserverFlexAlphaUser.NewUserDataSource(), + //sqlserverflexalphaDatabase.NewDatabaseDataSource(), sqlserverflexBetaDatabase.NewDatabaseDataSource(), sqlserverFlexBetaInstance.NewInstanceDataSource(), @@ -99,9 +95,9 @@ func TestUnitProviderHasChildResources_Basic(t *testing.T) { postgresFlexAlphaUser.NewUserResource(), postgresFlexAlphaDatabase.NewDatabaseResource(), - sqlserverFlexAlphaInstance.NewInstanceResource(), - sqlserverFlexAlphaUser.NewUserResource(), - sqlserverflexalphaDatabase.NewDatabaseResource(), + //sqlserverFlexAlphaInstance.NewInstanceResource(), + //sqlserverFlexAlphaUser.NewUserResource(), + //sqlserverflexalphaDatabase.NewDatabaseResource(), sqlserverFlexBetaInstance.NewInstanceResource(), sqlserverFlexBetaUser.NewUserResource(), From 0d408764e52c07b307e7d1d65ec173741f2c92b2 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Thu, 7 May 2026 06:35:42 +0200 Subject: [PATCH 5/5] fix: #106 remove duplicated files --- .../instance/functions_test.go | 3 +- .../versions_data_source_gen.go | 0 .../version_data_source_gen.go | 569 ----------------- .../version_data_source_gen.go | 570 ------------------ 4 files changed, 1 insertion(+), 1141 deletions(-) rename stackit/internal/services/postgresflexalpha/{version => versions}/datasources_gen/versions_data_source_gen.go (100%) delete mode 100644 stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go delete mode 100644 stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go diff --git a/stackit/internal/services/postgresflexalpha/instance/functions_test.go b/stackit/internal/services/postgresflexalpha/instance/functions_test.go index 0fa85f16..1a7d495b 100644 --- a/stackit/internal/services/postgresflexalpha/instance/functions_test.go +++ b/stackit/internal/services/postgresflexalpha/instance/functions_test.go @@ -8,7 +8,6 @@ import ( postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api" - postgresflexalpharesource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/resources_gen" utils2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) @@ -171,7 +170,7 @@ func Test_mapGetInstanceResponseToModel(t *testing.T) { t.Skipf("please implement") type args struct { ctx context.Context - m *postgresflexalpharesource.InstanceModel + m *LocalInstanceModel resp *postgresflex.GetInstanceResponse } tests := []struct { diff --git a/stackit/internal/services/postgresflexalpha/version/datasources_gen/versions_data_source_gen.go b/stackit/internal/services/postgresflexalpha/versions/datasources_gen/versions_data_source_gen.go similarity index 100% rename from stackit/internal/services/postgresflexalpha/version/datasources_gen/versions_data_source_gen.go rename to stackit/internal/services/postgresflexalpha/versions/datasources_gen/versions_data_source_gen.go diff --git a/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go deleted file mode 100644 index cb9008f1..00000000 --- a/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go +++ /dev/null @@ -1,569 +0,0 @@ -// Code generated by terraform-plugin-framework-generator DO NOT EDIT. - -package sqlserverflexalpha - -import ( - "context" - "fmt" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-plugin-go/tftypes" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func VersionDataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - Description: "The STACKIT project ID.", - MarkdownDescription: "The STACKIT project ID.", - }, - "region": schema.StringAttribute{ - Required: true, - Description: "The region which should be addressed", - MarkdownDescription: "The region which should be addressed", - Validators: []validator.String{ - stringvalidator.OneOf( - "eu01", - ), - }, - }, - "versions": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "beta": schema.BoolAttribute{ - Computed: true, - Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", - MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", - }, - "deprecated": schema.StringAttribute{ - Computed: true, - Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", - MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", - }, - "recommend": schema.BoolAttribute{ - Computed: true, - Description: "Flag if the version is recommend by the STACKIT Team.", - MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.", - }, - "version": schema.StringAttribute{ - Computed: true, - Description: "The sqlserver version used for the instance.", - MarkdownDescription: "The sqlserver version used for the instance.", - }, - }, - CustomType: VersionsType{ - ObjectType: types.ObjectType{ - AttrTypes: VersionsValue{}.AttributeTypes(ctx), - }, - }, - }, - Computed: true, - Description: "A list containing available sqlserver versions.", - MarkdownDescription: "A list containing available sqlserver versions.", - }, - }, - } -} - -type VersionModel struct { - ProjectId types.String `tfsdk:"project_id"` - Region types.String `tfsdk:"region"` - Versions types.List `tfsdk:"versions"` -} - -var _ basetypes.ObjectTypable = VersionsType{} - -type VersionsType struct { - basetypes.ObjectType -} - -func (t VersionsType) Equal(o attr.Type) bool { - other, ok := o.(VersionsType) - - if !ok { - return false - } - - return t.ObjectType.Equal(other.ObjectType) -} - -func (t VersionsType) String() string { - return "VersionsType" -} - -func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { - var diags diag.Diagnostics - - attributes := in.Attributes() - - betaAttribute, ok := attributes["beta"] - - if !ok { - diags.AddError( - "Attribute Missing", - `beta is missing from object`) - - return nil, diags - } - - betaVal, ok := betaAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) - } - - deprecatedAttribute, ok := attributes["deprecated"] - - if !ok { - diags.AddError( - "Attribute Missing", - `deprecated is missing from object`) - - return nil, diags - } - - deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) - } - - recommendAttribute, ok := attributes["recommend"] - - if !ok { - diags.AddError( - "Attribute Missing", - `recommend is missing from object`) - - return nil, diags - } - - recommendVal, ok := recommendAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) - } - - versionAttribute, ok := attributes["version"] - - if !ok { - diags.AddError( - "Attribute Missing", - `version is missing from object`) - - return nil, diags - } - - versionVal, ok := versionAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) - } - - if diags.HasError() { - return nil, diags - } - - return VersionsValue{ - Beta: betaVal, - Deprecated: deprecatedVal, - Recommend: recommendVal, - Version: versionVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewVersionsValueNull() VersionsValue { - return VersionsValue{ - state: attr.ValueStateNull, - } -} - -func NewVersionsValueUnknown() VersionsValue { - return VersionsValue{ - state: attr.ValueStateUnknown, - } -} - -func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) { - var diags diag.Diagnostics - - // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 - ctx := context.Background() - - for name, attributeType := range attributeTypes { - attribute, ok := attributes[name] - - if !ok { - diags.AddError( - "Missing VersionsValue Attribute Value", - "While creating a VersionsValue value, a missing attribute value was detected. "+ - "A VersionsValue must contain values for all attributes, even if null or unknown. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), - ) - - continue - } - - if !attributeType.Equal(attribute.Type(ctx)) { - diags.AddError( - "Invalid VersionsValue Attribute Type", - "While creating a VersionsValue value, an invalid attribute value was detected. "+ - "A VersionsValue must use a matching attribute type for the value. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), - ) - } - } - - for name := range attributes { - _, ok := attributeTypes[name] - - if !ok { - diags.AddError( - "Extra VersionsValue Attribute Value", - "While creating a VersionsValue value, an extra attribute value was detected. "+ - "A VersionsValue must not contain values beyond the expected attribute types. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name), - ) - } - } - - if diags.HasError() { - return NewVersionsValueUnknown(), diags - } - - betaAttribute, ok := attributes["beta"] - - if !ok { - diags.AddError( - "Attribute Missing", - `beta is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - betaVal, ok := betaAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) - } - - deprecatedAttribute, ok := attributes["deprecated"] - - if !ok { - diags.AddError( - "Attribute Missing", - `deprecated is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) - } - - recommendAttribute, ok := attributes["recommend"] - - if !ok { - diags.AddError( - "Attribute Missing", - `recommend is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - recommendVal, ok := recommendAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) - } - - versionAttribute, ok := attributes["version"] - - if !ok { - diags.AddError( - "Attribute Missing", - `version is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - versionVal, ok := versionAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) - } - - if diags.HasError() { - return NewVersionsValueUnknown(), diags - } - - return VersionsValue{ - Beta: betaVal, - Deprecated: deprecatedVal, - Recommend: recommendVal, - Version: versionVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue { - object, diags := NewVersionsValue(attributeTypes, attributes) - - if diags.HasError() { - // This could potentially be added to the diag package. - diagsStrings := make([]string, 0, len(diags)) - - for _, diagnostic := range diags { - diagsStrings = append(diagsStrings, fmt.Sprintf( - "%s | %s | %s", - diagnostic.Severity(), - diagnostic.Summary(), - diagnostic.Detail())) - } - - panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) - } - - return object -} - -func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { - if in.Type() == nil { - return NewVersionsValueNull(), nil - } - - if !in.Type().Equal(t.TerraformType(ctx)) { - return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) - } - - if !in.IsKnown() { - return NewVersionsValueUnknown(), nil - } - - if in.IsNull() { - return NewVersionsValueNull(), nil - } - - attributes := map[string]attr.Value{} - - val := map[string]tftypes.Value{} - - err := in.As(&val) - - if err != nil { - return nil, err - } - - for k, v := range val { - a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) - - if err != nil { - return nil, err - } - - attributes[k] = a - } - - return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil -} - -func (t VersionsType) ValueType(ctx context.Context) attr.Value { - return VersionsValue{} -} - -var _ basetypes.ObjectValuable = VersionsValue{} - -type VersionsValue struct { - Beta basetypes.BoolValue `tfsdk:"beta"` - Deprecated basetypes.StringValue `tfsdk:"deprecated"` - Recommend basetypes.BoolValue `tfsdk:"recommend"` - Version basetypes.StringValue `tfsdk:"version"` - state attr.ValueState -} - -func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { - attrTypes := make(map[string]tftypes.Type, 4) - - var val tftypes.Value - var err error - - attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx) - attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx) - attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx) - attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx) - - objectType := tftypes.Object{AttributeTypes: attrTypes} - - switch v.state { - case attr.ValueStateKnown: - vals := make(map[string]tftypes.Value, 4) - - val, err = v.Beta.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["beta"] = val - - val, err = v.Deprecated.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["deprecated"] = val - - val, err = v.Recommend.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["recommend"] = val - - val, err = v.Version.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["version"] = val - - if err := tftypes.ValidateValue(objectType, vals); err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - return tftypes.NewValue(objectType, vals), nil - case attr.ValueStateNull: - return tftypes.NewValue(objectType, nil), nil - case attr.ValueStateUnknown: - return tftypes.NewValue(objectType, tftypes.UnknownValue), nil - default: - panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) - } -} - -func (v VersionsValue) IsNull() bool { - return v.state == attr.ValueStateNull -} - -func (v VersionsValue) IsUnknown() bool { - return v.state == attr.ValueStateUnknown -} - -func (v VersionsValue) String() string { - return "VersionsValue" -} - -func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { - var diags diag.Diagnostics - - attributeTypes := map[string]attr.Type{ - "beta": basetypes.BoolType{}, - "deprecated": basetypes.StringType{}, - "recommend": basetypes.BoolType{}, - "version": basetypes.StringType{}, - } - - if v.IsNull() { - return types.ObjectNull(attributeTypes), diags - } - - if v.IsUnknown() { - return types.ObjectUnknown(attributeTypes), diags - } - - objVal, diags := types.ObjectValue( - attributeTypes, - map[string]attr.Value{ - "beta": v.Beta, - "deprecated": v.Deprecated, - "recommend": v.Recommend, - "version": v.Version, - }) - - return objVal, diags -} - -func (v VersionsValue) Equal(o attr.Value) bool { - other, ok := o.(VersionsValue) - - if !ok { - return false - } - - if v.state != other.state { - return false - } - - if v.state != attr.ValueStateKnown { - return true - } - - if !v.Beta.Equal(other.Beta) { - return false - } - - if !v.Deprecated.Equal(other.Deprecated) { - return false - } - - if !v.Recommend.Equal(other.Recommend) { - return false - } - - if !v.Version.Equal(other.Version) { - return false - } - - return true -} - -func (v VersionsValue) Type(ctx context.Context) attr.Type { - return VersionsType{ - basetypes.ObjectType{ - AttrTypes: v.AttributeTypes(ctx), - }, - } -} - -func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "beta": basetypes.BoolType{}, - "deprecated": basetypes.StringType{}, - "recommend": basetypes.BoolType{}, - "version": basetypes.StringType{}, - } -} diff --git a/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go deleted file mode 100644 index dfeb5348..00000000 --- a/stackit/internal/services/sqlserverflexbeta/versions/datasources_gen/version_data_source_gen.go +++ /dev/null @@ -1,570 +0,0 @@ -// Code generated by terraform-plugin-framework-generator DO NOT EDIT. - -package sqlserverflexbeta - -import ( - "context" - "fmt" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-plugin-go/tftypes" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func VersionDataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - Description: "The STACKIT project ID.", - MarkdownDescription: "The STACKIT project ID.", - }, - "region": schema.StringAttribute{ - Required: true, - Description: "The region which should be addressed", - MarkdownDescription: "The region which should be addressed", - Validators: []validator.String{ - stringvalidator.OneOf( - "eu01", - "eu02", - ), - }, - }, - "versions": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "beta": schema.BoolAttribute{ - Computed: true, - Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", - MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", - }, - "deprecated": schema.StringAttribute{ - Computed: true, - Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", - MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", - }, - "recommend": schema.BoolAttribute{ - Computed: true, - Description: "Flag if the version is recommend by the STACKIT Team.", - MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.", - }, - "version": schema.StringAttribute{ - Computed: true, - Description: "The sqlserver version used for the instance.", - MarkdownDescription: "The sqlserver version used for the instance.", - }, - }, - CustomType: VersionsType{ - ObjectType: types.ObjectType{ - AttrTypes: VersionsValue{}.AttributeTypes(ctx), - }, - }, - }, - Computed: true, - Description: "A list containing available sqlserver versions.", - MarkdownDescription: "A list containing available sqlserver versions.", - }, - }, - } -} - -type VersionModel struct { - ProjectId types.String `tfsdk:"project_id"` - Region types.String `tfsdk:"region"` - Versions types.List `tfsdk:"versions"` -} - -var _ basetypes.ObjectTypable = VersionsType{} - -type VersionsType struct { - basetypes.ObjectType -} - -func (t VersionsType) Equal(o attr.Type) bool { - other, ok := o.(VersionsType) - - if !ok { - return false - } - - return t.ObjectType.Equal(other.ObjectType) -} - -func (t VersionsType) String() string { - return "VersionsType" -} - -func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { - var diags diag.Diagnostics - - attributes := in.Attributes() - - betaAttribute, ok := attributes["beta"] - - if !ok { - diags.AddError( - "Attribute Missing", - `beta is missing from object`) - - return nil, diags - } - - betaVal, ok := betaAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) - } - - deprecatedAttribute, ok := attributes["deprecated"] - - if !ok { - diags.AddError( - "Attribute Missing", - `deprecated is missing from object`) - - return nil, diags - } - - deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) - } - - recommendAttribute, ok := attributes["recommend"] - - if !ok { - diags.AddError( - "Attribute Missing", - `recommend is missing from object`) - - return nil, diags - } - - recommendVal, ok := recommendAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) - } - - versionAttribute, ok := attributes["version"] - - if !ok { - diags.AddError( - "Attribute Missing", - `version is missing from object`) - - return nil, diags - } - - versionVal, ok := versionAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) - } - - if diags.HasError() { - return nil, diags - } - - return VersionsValue{ - Beta: betaVal, - Deprecated: deprecatedVal, - Recommend: recommendVal, - Version: versionVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewVersionsValueNull() VersionsValue { - return VersionsValue{ - state: attr.ValueStateNull, - } -} - -func NewVersionsValueUnknown() VersionsValue { - return VersionsValue{ - state: attr.ValueStateUnknown, - } -} - -func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) { - var diags diag.Diagnostics - - // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 - ctx := context.Background() - - for name, attributeType := range attributeTypes { - attribute, ok := attributes[name] - - if !ok { - diags.AddError( - "Missing VersionsValue Attribute Value", - "While creating a VersionsValue value, a missing attribute value was detected. "+ - "A VersionsValue must contain values for all attributes, even if null or unknown. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), - ) - - continue - } - - if !attributeType.Equal(attribute.Type(ctx)) { - diags.AddError( - "Invalid VersionsValue Attribute Type", - "While creating a VersionsValue value, an invalid attribute value was detected. "+ - "A VersionsValue must use a matching attribute type for the value. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), - ) - } - } - - for name := range attributes { - _, ok := attributeTypes[name] - - if !ok { - diags.AddError( - "Extra VersionsValue Attribute Value", - "While creating a VersionsValue value, an extra attribute value was detected. "+ - "A VersionsValue must not contain values beyond the expected attribute types. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name), - ) - } - } - - if diags.HasError() { - return NewVersionsValueUnknown(), diags - } - - betaAttribute, ok := attributes["beta"] - - if !ok { - diags.AddError( - "Attribute Missing", - `beta is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - betaVal, ok := betaAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) - } - - deprecatedAttribute, ok := attributes["deprecated"] - - if !ok { - diags.AddError( - "Attribute Missing", - `deprecated is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) - } - - recommendAttribute, ok := attributes["recommend"] - - if !ok { - diags.AddError( - "Attribute Missing", - `recommend is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - recommendVal, ok := recommendAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) - } - - versionAttribute, ok := attributes["version"] - - if !ok { - diags.AddError( - "Attribute Missing", - `version is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - versionVal, ok := versionAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) - } - - if diags.HasError() { - return NewVersionsValueUnknown(), diags - } - - return VersionsValue{ - Beta: betaVal, - Deprecated: deprecatedVal, - Recommend: recommendVal, - Version: versionVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue { - object, diags := NewVersionsValue(attributeTypes, attributes) - - if diags.HasError() { - // This could potentially be added to the diag package. - diagsStrings := make([]string, 0, len(diags)) - - for _, diagnostic := range diags { - diagsStrings = append(diagsStrings, fmt.Sprintf( - "%s | %s | %s", - diagnostic.Severity(), - diagnostic.Summary(), - diagnostic.Detail())) - } - - panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) - } - - return object -} - -func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { - if in.Type() == nil { - return NewVersionsValueNull(), nil - } - - if !in.Type().Equal(t.TerraformType(ctx)) { - return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) - } - - if !in.IsKnown() { - return NewVersionsValueUnknown(), nil - } - - if in.IsNull() { - return NewVersionsValueNull(), nil - } - - attributes := map[string]attr.Value{} - - val := map[string]tftypes.Value{} - - err := in.As(&val) - - if err != nil { - return nil, err - } - - for k, v := range val { - a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) - - if err != nil { - return nil, err - } - - attributes[k] = a - } - - return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil -} - -func (t VersionsType) ValueType(ctx context.Context) attr.Value { - return VersionsValue{} -} - -var _ basetypes.ObjectValuable = VersionsValue{} - -type VersionsValue struct { - Beta basetypes.BoolValue `tfsdk:"beta"` - Deprecated basetypes.StringValue `tfsdk:"deprecated"` - Recommend basetypes.BoolValue `tfsdk:"recommend"` - Version basetypes.StringValue `tfsdk:"version"` - state attr.ValueState -} - -func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { - attrTypes := make(map[string]tftypes.Type, 4) - - var val tftypes.Value - var err error - - attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx) - attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx) - attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx) - attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx) - - objectType := tftypes.Object{AttributeTypes: attrTypes} - - switch v.state { - case attr.ValueStateKnown: - vals := make(map[string]tftypes.Value, 4) - - val, err = v.Beta.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["beta"] = val - - val, err = v.Deprecated.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["deprecated"] = val - - val, err = v.Recommend.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["recommend"] = val - - val, err = v.Version.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["version"] = val - - if err := tftypes.ValidateValue(objectType, vals); err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - return tftypes.NewValue(objectType, vals), nil - case attr.ValueStateNull: - return tftypes.NewValue(objectType, nil), nil - case attr.ValueStateUnknown: - return tftypes.NewValue(objectType, tftypes.UnknownValue), nil - default: - panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) - } -} - -func (v VersionsValue) IsNull() bool { - return v.state == attr.ValueStateNull -} - -func (v VersionsValue) IsUnknown() bool { - return v.state == attr.ValueStateUnknown -} - -func (v VersionsValue) String() string { - return "VersionsValue" -} - -func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { - var diags diag.Diagnostics - - attributeTypes := map[string]attr.Type{ - "beta": basetypes.BoolType{}, - "deprecated": basetypes.StringType{}, - "recommend": basetypes.BoolType{}, - "version": basetypes.StringType{}, - } - - if v.IsNull() { - return types.ObjectNull(attributeTypes), diags - } - - if v.IsUnknown() { - return types.ObjectUnknown(attributeTypes), diags - } - - objVal, diags := types.ObjectValue( - attributeTypes, - map[string]attr.Value{ - "beta": v.Beta, - "deprecated": v.Deprecated, - "recommend": v.Recommend, - "version": v.Version, - }) - - return objVal, diags -} - -func (v VersionsValue) Equal(o attr.Value) bool { - other, ok := o.(VersionsValue) - - if !ok { - return false - } - - if v.state != other.state { - return false - } - - if v.state != attr.ValueStateKnown { - return true - } - - if !v.Beta.Equal(other.Beta) { - return false - } - - if !v.Deprecated.Equal(other.Deprecated) { - return false - } - - if !v.Recommend.Equal(other.Recommend) { - return false - } - - if !v.Version.Equal(other.Version) { - return false - } - - return true -} - -func (v VersionsValue) Type(ctx context.Context) attr.Type { - return VersionsType{ - basetypes.ObjectType{ - AttrTypes: v.AttributeTypes(ctx), - }, - } -} - -func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "beta": basetypes.BoolType{}, - "deprecated": basetypes.StringType{}, - "recommend": basetypes.BoolType{}, - "version": basetypes.StringType{}, - } -}