Skip to content

Commit 6379b52

Browse files
committed
feat: Add description_markdown property to rich parameter
1 parent 22f160d commit 6379b52

File tree

3 files changed

+49
-30
lines changed

3 files changed

+49
-30
lines changed

examples/resources/coder_parameter/resource.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ data "coder_parameter" "example" {
1717

1818
data "coder_parameter" "ami" {
1919
name = "Machine Image"
20+
description = "Provide the machine image."
21+
description_markdown = <<EOT
22+
# Select the machine image
23+
See the [registry](https://container.registry.blah/namespace) for options.
24+
EOT
2025
option {
2126
value = "ami-xxxxxxxx"
2227
name = "Ubuntu"
@@ -26,14 +31,15 @@ data "coder_parameter" "ami" {
2631

2732
data "coder_parameter" "is_public_instance" {
2833
name = "Is public instance?"
29-
icon = "/icon/docker.svg"
3034
type = "bool"
35+
icon = "/icon/docker.svg"
3136
default = false
3237
}
3338

3439
data "coder_parameter" "cores" {
3540
name = "CPU Cores"
36-
icon = "/icon/"
41+
type = "number"
42+
icon = "/icon/cpu.svg"
3743
default = 3
3844
}
3945

@@ -50,7 +56,7 @@ data "coder_parameter" "disk_size" {
5056
}
5157

5258
data "coder_parameter" "cat_lives" {
53-
name = "Cat Live"
59+
name = "Cat Lives"
5460
type = "number"
5561
default = "9"
5662
validation {

provider/parameter.go

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ const (
3939
)
4040

4141
type Parameter struct {
42-
Value string
43-
Name string
44-
Description string
45-
Type string
46-
Mutable bool
47-
Default string
48-
Icon string
49-
Option []Option
50-
Validation []Validation
42+
Value string
43+
Name string
44+
Description string
45+
DescriptionMarkdown string
46+
Type string
47+
Mutable bool
48+
Default string
49+
Icon string
50+
Option []Option
51+
Validation []Validation
5152
}
5253

5354
func parameterDataSource() *schema.Resource {
@@ -58,25 +59,27 @@ func parameterDataSource() *schema.Resource {
5859

5960
var parameter Parameter
6061
err := mapstructure.Decode(struct {
61-
Value interface{}
62-
Name interface{}
63-
Description interface{}
64-
Type interface{}
65-
Mutable interface{}
66-
Default interface{}
67-
Icon interface{}
68-
Option interface{}
69-
Validation interface{}
62+
Value interface{}
63+
Name interface{}
64+
Description interface{}
65+
DescriptionMarkdown interface{}
66+
Type interface{}
67+
Mutable interface{}
68+
Default interface{}
69+
Icon interface{}
70+
Option interface{}
71+
Validation interface{}
7072
}{
71-
Value: rd.Get("value"),
72-
Name: rd.Get("name"),
73-
Description: rd.Get("description"),
74-
Type: rd.Get("type"),
75-
Mutable: rd.Get("mutable"),
76-
Default: rd.Get("default"),
77-
Icon: rd.Get("icon"),
78-
Option: rd.Get("option"),
79-
Validation: rd.Get("validation"),
73+
Value: rd.Get("value"),
74+
Name: rd.Get("name"),
75+
Description: rd.Get("description"),
76+
DescriptionMarkdown: rd.Get("description_markdown"),
77+
Type: rd.Get("type"),
78+
Mutable: rd.Get("mutable"),
79+
Default: rd.Get("default"),
80+
Icon: rd.Get("icon"),
81+
Option: rd.Get("option"),
82+
Validation: rd.Get("validation"),
8083
}, &parameter)
8184
if err != nil {
8285
return diag.Errorf("decode parameter: %s", err)
@@ -142,6 +145,11 @@ func parameterDataSource() *schema.Resource {
142145
Optional: true,
143146
Description: "Describe what this parameter does.",
144147
},
148+
"description_markdown": {
149+
Type: schema.TypeString,
150+
Optional: true,
151+
Description: "Alternative description with Markdown tags.",
152+
},
145153
"type": {
146154
Type: schema.TypeString,
147155
Default: "string",

provider/parameter_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ data "coder_parameter" "region" {
2525
name = "Region"
2626
type = "string"
2727
description = "Some option!"
28+
description_markdown = <<EOT
29+
# Select the machine image
30+
See the [registry](https://container.registry.blah/namespace) for options.
31+
EOT
2832
mutable = true
2933
icon = "/icon/region.svg"
3034
option {
@@ -47,6 +51,7 @@ data "coder_parameter" "region" {
4751
"name": "Region",
4852
"type": "string",
4953
"description": "Some option!",
54+
"description_markdown": "# Select the machine image\nSee the [registry](https://container.registry.blah/namespace) for options.\n",
5055
"mutable": "true",
5156
"icon": "/icon/region.svg",
5257
"option.0.name": "US Central",

0 commit comments

Comments
 (0)