From 6379b52e4aa08042cfe2bcd23fd11d6781065a22 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 7 Feb 2023 14:33:03 +0100 Subject: [PATCH 1/3] feat: Add description_markdown property to rich parameter --- .../resources/coder_parameter/resource.tf | 12 +++- provider/parameter.go | 62 +++++++++++-------- provider/parameter_test.go | 5 ++ 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/examples/resources/coder_parameter/resource.tf b/examples/resources/coder_parameter/resource.tf index d23afc5f..3bcb939d 100644 --- a/examples/resources/coder_parameter/resource.tf +++ b/examples/resources/coder_parameter/resource.tf @@ -17,6 +17,11 @@ data "coder_parameter" "example" { data "coder_parameter" "ami" { name = "Machine Image" + description = "Provide the machine image." + description_markdown = < Date: Tue, 7 Feb 2023 14:55:01 +0100 Subject: [PATCH 2/3] EOT --- examples/resources/coder_parameter/resource.tf | 8 ++++---- provider/parameter_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/resources/coder_parameter/resource.tf b/examples/resources/coder_parameter/resource.tf index 3bcb939d..820f34fd 100644 --- a/examples/resources/coder_parameter/resource.tf +++ b/examples/resources/coder_parameter/resource.tf @@ -18,10 +18,10 @@ data "coder_parameter" "example" { data "coder_parameter" "ami" { name = "Machine Image" description = "Provide the machine image." - description_markdown = < Date: Tue, 7 Feb 2023 15:35:49 +0100 Subject: [PATCH 3/3] test: parameter description contains Markdown --- .../resources/coder_parameter/resource.tf | 5 +- provider/parameter.go | 62 ++++++++----------- provider/parameter_test.go | 6 +- 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/examples/resources/coder_parameter/resource.tf b/examples/resources/coder_parameter/resource.tf index 820f34fd..ea2a3e47 100644 --- a/examples/resources/coder_parameter/resource.tf +++ b/examples/resources/coder_parameter/resource.tf @@ -17,9 +17,8 @@ data "coder_parameter" "example" { data "coder_parameter" "ami" { name = "Machine Image" - description = "Provide the machine image." - description_markdown = <<-EOT - # Select the machine image + description = <<-EOT + # Provide the machine image See the [registry](https://container.registry.blah/namespace) for options. EOT option { diff --git a/provider/parameter.go b/provider/parameter.go index a080d0e5..615a3da3 100644 --- a/provider/parameter.go +++ b/provider/parameter.go @@ -39,16 +39,15 @@ const ( ) type Parameter struct { - Value string - Name string - Description string - DescriptionMarkdown string - Type string - Mutable bool - Default string - Icon string - Option []Option - Validation []Validation + Value string + Name string + Description string + Type string + Mutable bool + Default string + Icon string + Option []Option + Validation []Validation } func parameterDataSource() *schema.Resource { @@ -59,27 +58,25 @@ func parameterDataSource() *schema.Resource { var parameter Parameter err := mapstructure.Decode(struct { - Value interface{} - Name interface{} - Description interface{} - DescriptionMarkdown interface{} - Type interface{} - Mutable interface{} - Default interface{} - Icon interface{} - Option interface{} - Validation interface{} + Value interface{} + Name interface{} + Description interface{} + Type interface{} + Mutable interface{} + Default interface{} + Icon interface{} + Option interface{} + Validation interface{} }{ - Value: rd.Get("value"), - Name: rd.Get("name"), - Description: rd.Get("description"), - DescriptionMarkdown: rd.Get("description_markdown"), - Type: rd.Get("type"), - Mutable: rd.Get("mutable"), - Default: rd.Get("default"), - Icon: rd.Get("icon"), - Option: rd.Get("option"), - Validation: rd.Get("validation"), + Value: rd.Get("value"), + Name: rd.Get("name"), + Description: rd.Get("description"), + Type: rd.Get("type"), + Mutable: rd.Get("mutable"), + Default: rd.Get("default"), + Icon: rd.Get("icon"), + Option: rd.Get("option"), + Validation: rd.Get("validation"), }, ¶meter) if err != nil { return diag.Errorf("decode parameter: %s", err) @@ -145,11 +142,6 @@ func parameterDataSource() *schema.Resource { Optional: true, Description: "Describe what this parameter does.", }, - "description_markdown": { - Type: schema.TypeString, - Optional: true, - Description: "Alternative description with Markdown tags.", - }, "type": { Type: schema.TypeString, Default: "string", diff --git a/provider/parameter_test.go b/provider/parameter_test.go index fc4f26a4..788e0832 100644 --- a/provider/parameter_test.go +++ b/provider/parameter_test.go @@ -24,8 +24,7 @@ func TestParameter(t *testing.T) { data "coder_parameter" "region" { name = "Region" type = "string" - description = "Some option!" - description_markdown = <<-EOT + description = <<-EOT # Select the machine image See the [registry](https://container.registry.blah/namespace) for options. EOT @@ -50,8 +49,7 @@ data "coder_parameter" "region" { for key, value := range map[string]interface{}{ "name": "Region", "type": "string", - "description": "Some option!", - "description_markdown": "# Select the machine image\nSee the [registry](https://container.registry.blah/namespace) for options.\n", + "description": "# Select the machine image\nSee the [registry](https://container.registry.blah/namespace) for options.\n", "mutable": "true", "icon": "/icon/region.svg", "option.0.name": "US Central",