From fae929b151e1f321f4e88149ee67c2f9a8cd6b22 Mon Sep 17 00:00:00 2001 From: Mitchell Nielsen Date: Thu, 19 Sep 2024 11:16:37 -0500 Subject: [PATCH 1/2] Block "data" argument: Clarify expected data format Clarifies the expected data format for the "data" argument in the Block resource. The specific type is `schema.stringAttribute`, but we also set a CustomType of `jsontypes.NormalizedType`, which is an RFC 7159 JSON string. The Terraform Documentation tooling does not consider the CustomType field, so in the generated markdown it only say `String, Sensitive`. This can be confusing for users who expect to just pass any string here. So this change: - Clarifies the format expectations in the `data` argument description - Updates the examples to ensure we use `jsonencode` consistently Related to https://github.com/PrefectHQ/terraform-provider-prefect/issues/255 --- docs/resources/block.md | 4 ++-- examples/resources/prefect_block/resource.tf | 2 +- internal/provider/resources/block.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/resources/block.md b/docs/resources/block.md index 39f3f3b..30e5fc5 100644 --- a/docs/resources/block.md +++ b/docs/resources/block.md @@ -45,7 +45,7 @@ resource "prefect_block" "aws_credentials_from_file" { type_slug = "aws-credentials" # prefect block type inspect aws-credentials - data = file("./aws-credentials.json") + data = jsonencode(file("./aws-credentials.json")) } # example: @@ -111,7 +111,7 @@ For more information on the `$ref` syntax definition, see the ### Required -- `data` (String, Sensitive) The user-inputted Block payload, as a JSON string. The value's schema will depend on the selected `type` slug. Use `prefect block type inspect ` to view the data schema for a given Block type. +- `data` (String, Sensitive) The user-inputted Block payload, as a JSON string. Use `jsonencode` on the provided value to satisfy the underlying JSON type. The value's schema will depend on the selected `type` slug. Use `prefect block type inspect ` to view the data schema for a given Block type. - `name` (String) Unique name of the Block - `type_slug` (String) Block Type slug, which determines the schema of the `data` JSON attribute. Use `prefect block type ls` to view all available Block type slugs. diff --git a/examples/resources/prefect_block/resource.tf b/examples/resources/prefect_block/resource.tf index ec37a4b..83b0201 100644 --- a/examples/resources/prefect_block/resource.tf +++ b/examples/resources/prefect_block/resource.tf @@ -22,7 +22,7 @@ resource "prefect_block" "aws_credentials_from_file" { type_slug = "aws-credentials" # prefect block type inspect aws-credentials - data = file("./aws-credentials.json") + data = jsonencode(file("./aws-credentials.json")) } # example: diff --git a/internal/provider/resources/block.go b/internal/provider/resources/block.go index 51add2d..5e77493 100644 --- a/internal/provider/resources/block.go +++ b/internal/provider/resources/block.go @@ -116,7 +116,7 @@ func (r *BlockResource) Schema(_ context.Context, _ resource.SchemaRequest, resp Required: true, Sensitive: true, CustomType: jsontypes.NormalizedType{}, - Description: "The user-inputted Block payload, as a JSON string. The value's schema will depend on the selected `type` slug. Use `prefect block type inspect ` to view the data schema for a given Block type.", + Description: "The user-inputted Block payload, as a JSON string. Use `jsonencode` on the provided value to satisfy the underlying JSON type. The value's schema will depend on the selected `type` slug. Use `prefect block type inspect ` to view the data schema for a given Block type.", }, "account_id": schema.StringAttribute{ Optional: true, From ba784320387a0a02ac5e7915a9c2a04a1a7bba44 Mon Sep 17 00:00:00 2001 From: Mitchell Nielsen Date: Fri, 20 Sep 2024 13:26:56 -0500 Subject: [PATCH 2/2] Fix Marvin account email --- internal/provider/datasources/account_member_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/provider/datasources/account_member_test.go b/internal/provider/datasources/account_member_test.go index 8b7733c..54dfd3b 100644 --- a/internal/provider/datasources/account_member_test.go +++ b/internal/provider/datasources/account_member_test.go @@ -25,9 +25,9 @@ func TestAccDatasource_account_member(t *testing.T) { PreCheck: func() { testutils.AccTestPreCheck(t) }, Steps: []resource.TestStep{ { - Config: fixtureAccAccountMember("marvin+tf-acceptance-tester@prefect.io"), + Config: fixtureAccAccountMember("marvin@prefect.io"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "email", "marvin+tf-acceptance-tester@prefect.io"), + resource.TestCheckResourceAttr(dataSourceName, "email", "marvin@prefect.io"), resource.TestCheckResourceAttrSet(dataSourceName, "id"), resource.TestCheckResourceAttrSet(dataSourceName, "account_role_id"), resource.TestCheckResourceAttrSet(dataSourceName, "account_role_name"),