From a90bb25b644551e2d31b84a5889000c0ad498c53 Mon Sep 17 00:00:00 2001 From: Heidi Berry Date: Wed, 14 May 2025 21:14:38 +0100 Subject: [PATCH] Pluralise collection types --- .../generate/null_provider_success.txtar | 18 +++++++++--------- ..._provider_success_all_framework_types.txtar | 18 +++++++++--------- .../generate/null_provider_success.txtar | 18 +++++++++--------- .../functionmd/testdata/example_arguments.md | 4 ++-- .../schemamd/testdata/aws_acm_certificate.md | 10 +++++----- internal/schemamd/testdata/framework_types.md | 12 ++++++------ internal/schemamd/write_type.go | 6 ++++++ internal/schemamd/write_type_test.go | 10 +++++----- 8 files changed, 51 insertions(+), 45 deletions(-) diff --git a/cmd/tfplugindocs/testdata/scripts/provider-build/generate/null_provider_success.txtar b/cmd/tfplugindocs/testdata/scripts/provider-build/generate/null_provider_success.txtar index 263e85c4..64cb03be 100644 --- a/cmd/tfplugindocs/testdata/scripts/provider-build/generate/null_provider_success.txtar +++ b/cmd/tfplugindocs/testdata/scripts/provider-build/generate/null_provider_success.txtar @@ -232,12 +232,12 @@ class MyConvertedCode(TerraformStack): ### Optional - `has_computed_default` (String) If set, its literal value will be stored and returned. If not, its value defaults to `"default"`. This argument exists primarily for testing and has little practical use. -- `inputs` (Map of String) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. +- `inputs` (Map of Strings) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. ### Read-Only - `id` (String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version. -- `outputs` (Map of String) After the data source is "read", a copy of the `inputs` map. +- `outputs` (Map of Strings) After the data source is "read", a copy of the `inputs` map. - `random` (String) A random value. This is primarily for testing and has little practical use; prefer the [hashicorp/random provider](https://registry.terraform.io/providers/hashicorp/random) for more practical random number use-cases. @@ -342,7 +342,7 @@ class MyConvertedCode(TerraformStack): ### Optional -- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. +- `triggers` (Map of Strings) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. ### Read-Only @@ -460,12 +460,12 @@ class MyConvertedCode extends TerraformStack { ### Optional - `hasComputedDefault` (String) If set, its literal value will be stored and returned. If not, its value defaults to `"default"`. This argument exists primarily for testing and has little practical use. -- `inputs` (Map of String) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. +- `inputs` (Map of Strings) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. ### Read-Only - `id` (String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version. -- `outputs` (Map of String) After the data source is "read", a copy of the `inputs` map. +- `outputs` (Map of Strings) After the data source is "read", a copy of the `inputs` map. - `random` (String) A random value. This is primarily for testing and has little practical use; prefer the [hashicorp/random provider](https://registry.terraform.io/providers/hashicorp/random) for more practical random number use-cases. @@ -580,7 +580,7 @@ class MyConvertedCode extends TerraformStack { ### Optional -- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. +- `triggers` (Map of Strings) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. ### Read-Only @@ -667,12 +667,12 @@ output "all_server_ips" { ### Optional - `has_computed_default` (String) If set, its literal value will be stored and returned. If not, its value defaults to `"default"`. This argument exists primarily for testing and has little practical use. -- `inputs` (Map of String) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. +- `inputs` (Map of Strings) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. ### Read-Only - `id` (String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version. -- `outputs` (Map of String) After the data source is "read", a copy of the `inputs` map. +- `outputs` (Map of Strings) After the data source is "read", a copy of the `inputs` map. - `random` (String) A random value. This is primarily for testing and has little practical use; prefer the [hashicorp/random provider](https://registry.terraform.io/providers/hashicorp/random) for more practical random number use-cases. -- docs/index.md -- @@ -761,7 +761,7 @@ resource "null_resource" "cluster" { ### Optional -- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. +- `triggers` (Map of Strings) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. ### Read-Only diff --git a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar index 813b5c6f..e51e2f63 100644 --- a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar +++ b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar @@ -80,23 +80,23 @@ example resource - `bool_attribute` (Boolean) example bool attribute - `float64_attribute` (Number) example float64 attribute - `int64_attribute` (Number) example int64 attribute -- `list_attribute` (List of String) example list attribute +- `list_attribute` (List of Strings) example list attribute - `list_nested_block` (Block List) example list nested block (see [below for nested schema](#nestedblock--list_nested_block)) - `list_nested_block_sensitive_nested_attribute` (Block List) (see [below for nested schema](#nestedblock--list_nested_block_sensitive_nested_attribute)) -- `map_attribute` (Map of String) example map attribute +- `map_attribute` (Map of Strings) example map attribute - `number_attribute` (Number) example number attribute - `object_attribute` (Object) example object attribute (see [below for nested schema](#nestedatt--object_attribute)) - `object_attribute_with_nested_object_attribute` (Object) example object attribute with nested object attribute (see [below for nested schema](#nestedatt--object_attribute_with_nested_object_attribute)) - `sensitive_bool_attribute` (Boolean, Sensitive) example sensitive bool attribute - `sensitive_float64_attribute` (Number, Sensitive) example sensitive float64 attribute - `sensitive_int64_attribute` (Number, Sensitive) example sensitive int64 attribute -- `sensitive_list_attribute` (List of String, Sensitive) example sensitive list attribute -- `sensitive_map_attribute` (Map of String, Sensitive) example sensitive map attribute +- `sensitive_list_attribute` (List of Strings, Sensitive) example sensitive list attribute +- `sensitive_map_attribute` (Map of Strings, Sensitive) example sensitive map attribute - `sensitive_number_attribute` (Number, Sensitive) example sensitive number attribute - `sensitive_object_attribute` (Object, Sensitive) example sensitive object attribute (see [below for nested schema](#nestedatt--sensitive_object_attribute)) -- `sensitive_set_attribute` (Set of String, Sensitive) example sensitive set attribute +- `sensitive_set_attribute` (Set of Strings, Sensitive) example sensitive set attribute - `sensitive_string_attribute` (String, Sensitive) example sensitive string attribute -- `set_attribute` (Set of String) example set attribute +- `set_attribute` (Set of Strings) example set attribute - `set_nested_block` (Block Set) example set nested block (see [below for nested schema](#nestedblock--set_nested_block)) - `single_nested_block` (Block, Optional) example single nested block (see [below for nested schema](#nestedblock--single_nested_block)) - `single_nested_block_sensitive_nested_attribute` (Block, Optional) example sensitive single nested block (see [below for nested schema](#nestedblock--single_nested_block_sensitive_nested_attribute)) @@ -229,11 +229,11 @@ scaffolding(stringInput string, boolInput bool, float64Input number, int64Input 1. `boolInput` (Boolean) Value to echo testing 1. `float64Input` (Number) Float64 Value to echo 1. `int64Input` (Number) Int64 Value to echo -1. `listStringInput` (List of String) List of strings to echo -1. `mapStringInput` (Map of String) Map of strings to echo +1. `listStringInput` (List of Strings) List of strings to echo +1. `mapStringInput` (Map of Strings) Map of strings to echo 1. `numberInput` (Number) Number to echo 1. `objectInput` (Object) Object to echo -1. `setStringInput` (Set of String) Set of strings to echo +1. `setStringInput` (Set of Strings) Set of strings to echo 1. `variadicParam` (Variadic, String) Value to echo -- schema.json -- diff --git a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/null_provider_success.txtar b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/null_provider_success.txtar index e05ef443..cdb0c561 100644 --- a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/null_provider_success.txtar +++ b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/null_provider_success.txtar @@ -207,12 +207,12 @@ class MyConvertedCode(TerraformStack): ### Optional - `has_computed_default` (String) If set, its literal value will be stored and returned. If not, its value defaults to `"default"`. This argument exists primarily for testing and has little practical use. -- `inputs` (Map of String) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. +- `inputs` (Map of Strings) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. ### Read-Only - `id` (String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version. -- `outputs` (Map of String) After the data source is "read", a copy of the `inputs` map. +- `outputs` (Map of Strings) After the data source is "read", a copy of the `inputs` map. - `random` (String) A random value. This is primarily for testing and has little practical use; prefer the [hashicorp/random provider](https://registry.terraform.io/providers/hashicorp/random) for more practical random number use-cases. @@ -317,7 +317,7 @@ class MyConvertedCode(TerraformStack): ### Optional -- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. +- `triggers` (Map of Strings) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. ### Read-Only @@ -435,12 +435,12 @@ class MyConvertedCode extends TerraformStack { ### Optional - `hasComputedDefault` (String) If set, its literal value will be stored and returned. If not, its value defaults to `"default"`. This argument exists primarily for testing and has little practical use. -- `inputs` (Map of String) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. +- `inputs` (Map of Strings) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. ### Read-Only - `id` (String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version. -- `outputs` (Map of String) After the data source is "read", a copy of the `inputs` map. +- `outputs` (Map of Strings) After the data source is "read", a copy of the `inputs` map. - `random` (String) A random value. This is primarily for testing and has little practical use; prefer the [hashicorp/random provider](https://registry.terraform.io/providers/hashicorp/random) for more practical random number use-cases. @@ -555,7 +555,7 @@ class MyConvertedCode extends TerraformStack { ### Optional -- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. +- `triggers` (Map of Strings) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. ### Read-Only @@ -642,12 +642,12 @@ output "all_server_ips" { ### Optional - `has_computed_default` (String) If set, its literal value will be stored and returned. If not, its value defaults to `"default"`. This argument exists primarily for testing and has little practical use. -- `inputs` (Map of String) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. +- `inputs` (Map of Strings) A map of arbitrary strings that is copied into the `outputs` attribute, and accessible directly for interpolation. ### Read-Only - `id` (String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version. -- `outputs` (Map of String) After the data source is "read", a copy of the `inputs` map. +- `outputs` (Map of Strings) After the data source is "read", a copy of the `inputs` map. - `random` (String) A random value. This is primarily for testing and has little practical use; prefer the [hashicorp/random provider](https://registry.terraform.io/providers/hashicorp/random) for more practical random number use-cases. -- docs/index.md -- @@ -736,7 +736,7 @@ resource "null_resource" "cluster" { ### Optional -- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. +- `triggers` (Map of Strings) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. ### Read-Only diff --git a/internal/functionmd/testdata/example_arguments.md b/internal/functionmd/testdata/example_arguments.md index 643eb579..c0c5fa16 100644 --- a/internal/functionmd/testdata/example_arguments.md +++ b/internal/functionmd/testdata/example_arguments.md @@ -1,5 +1,5 @@ 1. `input` (String) Value to echo. 1. `int64Input` (Number) Int64 Value to echo. -1. `listStringInput` (List of String) List of strings to echo. -1. `mapStringInput` (Map of String) Map of strings to echo. +1. `listStringInput` (List of Strings) List of strings to echo. +1. `mapStringInput` (Map of Strings) Map of strings to echo. 1. `objectInput` (Object) Object to echo. \ No newline at end of file diff --git a/internal/schemamd/testdata/aws_acm_certificate.md b/internal/schemamd/testdata/aws_acm_certificate.md index 7ead0c69..f7f019ee 100644 --- a/internal/schemamd/testdata/aws_acm_certificate.md +++ b/internal/schemamd/testdata/aws_acm_certificate.md @@ -8,18 +8,18 @@ - `domain_name` (String) - `options` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options)) - `private_key` (String, Sensitive) -- `subject_alternative_names` (Set of String) -- `tags` (Map of String) -- `tags_all` (Map of String) +- `subject_alternative_names` (Set of Strings) +- `tags` (Map of Strings) +- `tags_all` (Map of Strings) - `validation_method` (String) ### Read-Only - `arn` (String) -- `domain_validation_options` (Set of Object) (see [below for nested schema](#nestedatt--domain_validation_options)) +- `domain_validation_options` (Set of Objects) (see [below for nested schema](#nestedatt--domain_validation_options)) - `id` (String) The ID of this resource. - `status` (String) -- `validation_emails` (List of String) +- `validation_emails` (List of Strings) ### Nested Schema for `options` diff --git a/internal/schemamd/testdata/framework_types.md b/internal/schemamd/testdata/framework_types.md index 8607a931..f8bcf019 100644 --- a/internal/schemamd/testdata/framework_types.md +++ b/internal/schemamd/testdata/framework_types.md @@ -13,23 +13,23 @@ - `bool_attribute` (Boolean) example bool attribute - `float64_attribute` (Number) example float64 attribute - `int64_attribute` (Number) example int64 attribute -- `list_attribute` (List of String) example list attribute +- `list_attribute` (List of Strings) example list attribute - `list_nested_block` (Block List) example list nested block (see [below for nested schema](#nestedblock--list_nested_block)) - `list_nested_block_sensitive_nested_attribute` (Block List) (see [below for nested schema](#nestedblock--list_nested_block_sensitive_nested_attribute)) -- `map_attribute` (Map of String) example map attribute +- `map_attribute` (Map of Strings) example map attribute - `number_attribute` (Number) example number attribute - `object_attribute` (Object) example object attribute (see [below for nested schema](#nestedatt--object_attribute)) - `object_attribute_with_nested_object_attribute` (Object) example object attribute with nested object attribute (see [below for nested schema](#nestedatt--object_attribute_with_nested_object_attribute)) - `sensitive_bool_attribute` (Boolean, Sensitive) example sensitive bool attribute - `sensitive_float64_attribute` (Number, Sensitive) example sensitive float64 attribute - `sensitive_int64_attribute` (Number, Sensitive) example sensitive int64 attribute -- `sensitive_list_attribute` (List of String, Sensitive) example sensitive list attribute -- `sensitive_map_attribute` (Map of String, Sensitive) example sensitive map attribute +- `sensitive_list_attribute` (List of Strings, Sensitive) example sensitive list attribute +- `sensitive_map_attribute` (Map of Strings, Sensitive) example sensitive map attribute - `sensitive_number_attribute` (Number, Sensitive) example sensitive number attribute - `sensitive_object_attribute` (Object, Sensitive) example sensitive object attribute (see [below for nested schema](#nestedatt--sensitive_object_attribute)) -- `sensitive_set_attribute` (Set of String, Sensitive) example sensitive set attribute +- `sensitive_set_attribute` (Set of Strings, Sensitive) example sensitive set attribute - `sensitive_string_attribute` (String, Sensitive) example sensitive string attribute -- `set_attribute` (Set of String) example set attribute +- `set_attribute` (Set of Strings) example set attribute - `set_nested_block` (Block Set) example set nested block (see [below for nested schema](#nestedblock--set_nested_block)) - `single_nested_block` (Block, Optional) example single nested block (see [below for nested schema](#nestedblock--single_nested_block)) - `single_nested_block_sensitive_nested_attribute` (Block, Optional) example sensitive single nested block (see [below for nested schema](#nestedblock--single_nested_block_sensitive_nested_attribute)) diff --git a/internal/schemamd/write_type.go b/internal/schemamd/write_type.go index d44a9eb4..068c19f0 100644 --- a/internal/schemamd/write_type.go +++ b/internal/schemamd/write_type.go @@ -52,6 +52,12 @@ func WriteType(w io.Writer, ty cty.Type) error { if err != nil { return fmt.Errorf("unable to write element type for %q: %w", ty.FriendlyName(), err) } + if !ty.ElementType().IsCollectionType() { + _, err = io.WriteString(w, "s") + if err != nil { + return err + } + } return nil case ty.IsTupleType(): // TODO: write additional type info? diff --git a/internal/schemamd/write_type_test.go b/internal/schemamd/write_type_test.go index 62340ad3..931e95e2 100644 --- a/internal/schemamd/write_type_test.go +++ b/internal/schemamd/write_type_test.go @@ -30,22 +30,22 @@ func TestWriteType(t *testing.T) { // {"Number", cty.NilType}, // {"Number", cty.Capsule("foo", reflect.TypeOf(1))}, - {"List of Boolean", cty.List(cty.Bool)}, - {"List of Dynamic", cty.List(cty.DynamicPseudoType)}, + {"List of Booleans", cty.List(cty.Bool)}, + {"List of Dynamics", cty.List(cty.DynamicPseudoType)}, - {"Map of Boolean", cty.Map(cty.Bool)}, + {"Map of Booleans", cty.Map(cty.Bool)}, {"Object", cty.EmptyObject}, {"Object", cty.Object(map[string]cty.Type{ "bool": cty.Bool, })}, - {"Set of Boolean", cty.Set(cty.Bool)}, + {"Set of Booleans", cty.Set(cty.Bool)}, {"Tuple", cty.EmptyTuple}, {"Tuple", cty.Tuple([]cty.Type{cty.Bool})}, - {"List of Map of Set of Object", cty.List(cty.Map(cty.Set(cty.Object(map[string]cty.Type{ + {"List of Map of Set of Objects", cty.List(cty.Map(cty.Set(cty.Object(map[string]cty.Type{ "bool": cty.Bool, }))))}, } {