diff --git a/go.mod b/go.mod index 80d81fc..01e6e5d 100644 --- a/go.mod +++ b/go.mod @@ -94,6 +94,7 @@ require ( github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.23.0 // indirect github.com/hashicorp/terraform-json v0.25.0 // indirect + github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 // indirect github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect @@ -110,13 +111,13 @@ require ( require ( github.com/cenkalti/backoff/v5 v5.0.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/formancehq/terraform-provider-cloud/sdk v0.0.0-20250617093736-a5a3abe25511 + github.com/formancehq/terraform-provider-cloud/sdk v0.0.0-20250624122835-08527daf62c5 github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( - github.com/formancehq/terraform-provider-cloud v0.0.5-0.20250617093736-a5a3abe25511 + github.com/formancehq/terraform-provider-cloud v0.0.5-0.20250624122835-08527daf62c5 github.com/go-jose/go-jose/v4 v4.0.5 // indirect github.com/gorilla/securecookie v1.1.2 // indirect github.com/hashicorp/terraform-plugin-testing v1.13.1 diff --git a/go.sum b/go.sum index 9567dd7..b5f3d68 100644 --- a/go.sum +++ b/go.sum @@ -39,10 +39,10 @@ github.com/formancehq/formance-sdk-go/v3 v3.5.0 h1:4qUhPOaF0igfH+cR95bnsteNXoidZ github.com/formancehq/formance-sdk-go/v3 v3.5.0/go.mod h1:6V6/yj6FZDYS3lA7R8d93y/Z4mQbLdGoNOYEMrUKUWM= github.com/formancehq/go-libs/v3 v3.0.0-20250522193102-7361760ee4ef h1:yrhbW231+FUOUrrKGsDhUyqhWFIjFv4TLtoP6L6HJgc= github.com/formancehq/go-libs/v3 v3.0.0-20250522193102-7361760ee4ef/go.mod h1:faThzFZoF/9uEZQgifklAespL+quZ1CnTTF63+mG950= -github.com/formancehq/terraform-provider-cloud v0.0.5-0.20250617093736-a5a3abe25511 h1:yWljUOJPjiYza7f6tEAoxBb5pohcG5auwbaSqwIWR/A= -github.com/formancehq/terraform-provider-cloud v0.0.5-0.20250617093736-a5a3abe25511/go.mod h1:Mho2pUyEDMBa40z1O2hTWND3J7Db8f5smkBdv/URkrU= -github.com/formancehq/terraform-provider-cloud/sdk v0.0.0-20250617093736-a5a3abe25511 h1:TafrTTiry/UcvRr5OG4yKgA2hMtoJjOFoymPLIX2CwM= -github.com/formancehq/terraform-provider-cloud/sdk v0.0.0-20250617093736-a5a3abe25511/go.mod h1:6XkfNbGruADRkgUtfu9+U069EZt+4Ev5sVWUjq1FnOI= +github.com/formancehq/terraform-provider-cloud v0.0.5-0.20250624122835-08527daf62c5 h1:wx4RAoHRP7L3pAmMlgSAO1eQEWwYmaND4bd1dmTtd60= +github.com/formancehq/terraform-provider-cloud v0.0.5-0.20250624122835-08527daf62c5/go.mod h1:ND38nmai7sABUwH97OYaE+IvsPArTdU511Z7y4sSGgs= +github.com/formancehq/terraform-provider-cloud/sdk v0.0.0-20250624122835-08527daf62c5 h1:5nBh+ygIPfw0FFwjyfPORdOpgI+myAd/RVsRqV4bTEg= +github.com/formancehq/terraform-provider-cloud/sdk v0.0.0-20250624122835-08527daf62c5/go.mod h1:6XkfNbGruADRkgUtfu9+U069EZt+4Ev5sVWUjq1FnOI= github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8= github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -115,6 +115,8 @@ github.com/hashicorp/terraform-json v0.25.0 h1:rmNqc/CIfcWawGiwXmRuiXJKEiJu1ntGo github.com/hashicorp/terraform-json v0.25.0/go.mod h1:sMKS8fiRDX4rVlR6EJUMudg1WcanxCMoWwTLkgZP/vc= github.com/hashicorp/terraform-plugin-framework v1.15.0 h1:LQ2rsOfmDLxcn5EeIwdXFtr03FVsNktbbBci8cOKdb4= github.com/hashicorp/terraform-plugin-framework v1.15.0/go.mod h1:hxrNI/GY32KPISpWqlCoTLM9JZsGH3CyYlir09bD/fI= +github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua//rCw+QhBbSqfW3QbwtVrcdWeQN5gI3Hw= +github.com/hashicorp/terraform-plugin-framework-validators v0.18.0/go.mod h1:lZvZvagw5hsJwuY7mAY6KUz45/U6fiDR0CzQAwWD0CA= github.com/hashicorp/terraform-plugin-go v0.27.0 h1:ujykws/fWIdsi6oTUT5Or4ukvEan4aN9lY+LOxVP8EE= github.com/hashicorp/terraform-plugin-go v0.27.0/go.mod h1:FDa2Bb3uumkTGSkTFpWSOwWJDwA7bf3vdP3ltLDTH6o= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= diff --git a/internal/resources/main_test.go b/internal/resources/main_test.go deleted file mode 100644 index 3fb591c..0000000 --- a/internal/resources/main_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package resources_test - -// func test(t *testing.T, fn func(ctx context.Context)) { -// t.Parallel() - -// ctx := logging.TestingContext() - -// fn(ctx) -// } diff --git a/main.go b/main.go index 02125a8..8f606c0 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,14 @@ // Format Terraform code for use in documentation. // If you do not have Terraform installed, you can remove the formatting command, but it is suggested // to ensure the documentation is formatted properly. + +//go:generate rm -rf docs +//go:generate mkdir docs //go:generate terraform fmt -recursive ./examples/ // Generate documentation. -// //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest generate --provider-dir . -provider-name formancestack + package main import "github.com/formancehq/terraform-provider-stack/cmd" diff --git a/tests/e2e/ledger_test.go b/tests/e2e/ledger_test.go index a1d0641..dcb7c20 100644 --- a/tests/e2e/ledger_test.go +++ b/tests/e2e/ledger_test.go @@ -26,11 +26,11 @@ func TestLedger(t *testing.T) { Steps: []resource.TestStep{ newTestStepStack(), { - Config: newStack(OrganizationId, RegionName) + + Config: newStack(RegionName) + ` provider "formancestack" { stack_id = formancecloud_stack.default.id - organization_id = formancecloud_stack.default.organization_id + organization_id = data.formancecloud_current_organization.default.id uri = formancecloud_stack.default.uri } @@ -55,11 +55,11 @@ func TestLedger(t *testing.T) { }, }, { - Config: newStack(OrganizationId, RegionName) + + Config: newStack(RegionName) + ` provider "formancestack" { stack_id = formancecloud_stack.default.id - organization_id = formancecloud_stack.default.organization_id + organization_id = data.formancecloud_current_organization.default.id uri = formancecloud_stack.default.uri } diff --git a/tests/e2e/main_test.go b/tests/e2e/main_test.go index 3d2e7c0..7ca4053 100644 --- a/tests/e2e/main_test.go +++ b/tests/e2e/main_test.go @@ -25,15 +25,14 @@ import ( ) var ( - CloudProvider func() provider.Provider - StackProvider func() provider.Provider - RegionName = "" - OrganizationId = "" + CloudProvider func() provider.Provider + StackProvider func() provider.Provider + RegionName = "" ) func newTestStepStack() resource.TestStep { return resource.TestStep{ - Config: newStack(OrganizationId, RegionName), + Config: newStack(RegionName), ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue("formancecloud_stack.default", tfjsonpath.New("name"), knownvalue.StringExact("test")), statecheck.ExpectKnownValue("formancecloud_stack.default", tfjsonpath.New("id"), knownvalue.StringRegexp(regexp.MustCompile(`.+`))), @@ -50,9 +49,8 @@ func TestMain(m *testing.M) { // TODO: This can be replaced with TF variables in the future RegionName = os.Getenv("FORMANCE_CLOUD_REGION_NAME") - OrganizationId = os.Getenv("FORMANCE_CLOUD_ORGANIZATION_ID") - if RegionName == "" || OrganizationId == "" || endpoint == "" || clientID == "" || clientSecret == "" { - missingVars := []string{RegionName, OrganizationId, endpoint, clientID, clientSecret} + if RegionName == "" || endpoint == "" || clientID == "" || clientSecret == "" { + missingVars := []string{RegionName, endpoint, clientID, clientSecret} missingVars = collectionutils.Filter(missingVars, func(s string) bool { return s == "" }) @@ -89,7 +87,7 @@ func TestMain(m *testing.M) { clientID, clientSecret, transport, - cloudpkg.NewSDK, + cloudpkg.NewCloudSDK(), cloudpkg.NewTokenProvider, ) @@ -98,20 +96,16 @@ func TestMain(m *testing.M) { os.Exit(code) } -func newStack(organizationId, regionName string) string { +func newStack(regionName string) string { return ` - data "formancecloud_organizations" "default" { - id = "` + organizationId + `" - } + data "formancecloud_current_organization" "default" {} data "formancecloud_regions" "default" { name = "` + regionName + `" - organization_id = data.formancecloud_organizations.default.id } resource "formancecloud_stack" "default" { name = "test" - organization_id = data.formancecloud_organizations.default.id region_id = data.formancecloud_regions.default.id force_destroy = true diff --git a/tests/e2e/noop_test.go b/tests/e2e/noop_test.go index 24f2fad..3ae4d9f 100644 --- a/tests/e2e/noop_test.go +++ b/tests/e2e/noop_test.go @@ -23,11 +23,11 @@ func TestNoopResources(t *testing.T) { Steps: []resource.TestStep{ newTestStepStack(), { - Config: newStack(OrganizationId, RegionName) + + Config: newStack(RegionName) + ` provider "formancestack" { stack_id = formancecloud_stack.default.id - organization_id = formancecloud_stack.default.organization_id + organization_id = data.formancecloud_current_organization.default.id uri = formancecloud_stack.default.uri } diff --git a/tests/e2e/stack_test.go b/tests/e2e/stack_test.go index f4c6655..35d87a6 100644 --- a/tests/e2e/stack_test.go +++ b/tests/e2e/stack_test.go @@ -24,7 +24,7 @@ func TestStack(t *testing.T) { }, Steps: []resource.TestStep{ { - Config: newStack(OrganizationId, RegionName), + Config: newStack(RegionName), ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue("formancecloud_stack.default", tfjsonpath.New("name"), knownvalue.StringExact("test")), statecheck.ExpectKnownValue("formancecloud_stack.default", tfjsonpath.New("id"), knownvalue.StringRegexp(regexp.MustCompile(`.+`))), diff --git a/tests/e2e/webhooks_test.go b/tests/e2e/webhooks_test.go index 3edaa50..9f9579b 100644 --- a/tests/e2e/webhooks_test.go +++ b/tests/e2e/webhooks_test.go @@ -27,17 +27,16 @@ func TestWebhooks(t *testing.T) { Steps: []resource.TestStep{ newTestStepStack(), { - Config: newStack(OrganizationId, RegionName) + + Config: newStack(RegionName) + ` resource "formancecloud_stack_module" "webhooks" { name = "webhooks" stack_id = formancecloud_stack.default.id - organization_id = data.formancecloud_organizations.default.id } provider "formancestack" { stack_id = formancecloud_stack.default.id - organization_id = formancecloud_stack.default.organization_id + organization_id = data.formancecloud_current_organization.default.id uri = formancecloud_stack.default.uri } @@ -66,17 +65,16 @@ func TestWebhooks(t *testing.T) { }, }, { - Config: newStack(OrganizationId, RegionName) + + Config: newStack(RegionName) + ` resource "formancecloud_stack_module" "webhooks" { name = "webhooks" stack_id = formancecloud_stack.default.id - organization_id = data.formancecloud_organizations.default.id } provider "formancestack" { stack_id = formancecloud_stack.default.id - organization_id = formancecloud_stack.default.organization_id + organization_id = data.formancecloud_current_organization.default.id uri = formancecloud_stack.default.uri }