Skip to content

Commit a27420c

Browse files
committed
rename datasource coder_ai_task_prompt -> coder_task
1 parent 51684f4 commit a27420c

File tree

9 files changed

+32
-33
lines changed

9 files changed

+32
-33
lines changed

docs/data-sources/ai_task_prompt.md renamed to docs/data-sources/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
# generated by https://github.com/hashicorp/terraform-plugin-docs
3-
page_title: "coder_ai_task_prompt Data Source - terraform-provider-coder"
3+
page_title: "coder_task Data Source - terraform-provider-coder"
44
subcategory: ""
55
description: |-
66
Use this data source to read information about Coder tasks.
77
---
88

9-
# coder_ai_task_prompt (Data Source)
9+
# coder_task (Data Source)
1010

1111
Use this data source to read information about Coder tasks.
1212

@@ -21,6 +21,6 @@ Use this data source to read information about Coder tasks.
2121

2222
->This field is only populated in Coder v2.28 and later.
2323
- `id` (String) The UUID of the task, if executing in a Coder Task context. Empty in a Coder Workspace context.
24-
- `value` (String) The prompt text provided to the task by Coder, if executing in a Coder Task context. Empty in a Coder Workspace context.
24+
- `prompt` (String) The prompt text provided to the task by Coder, if executing in a Coder Task context. Empty in a Coder Workspace context.
2525

2626
->This field is only populated in Coder v2.28 and later.

integration/coder-ai-task/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ data "coder_parameter" "ai_prompt" {
3232
mutable = true
3333
}
3434

35-
data "coder_ai_task_prompt" "me" {}
35+
data "coder_task" "me" {}
3636

3737
resource "coder_ai_task" "task" {
3838
sidebar_app {
@@ -49,9 +49,9 @@ locals {
4949
"ai_task.enabled" = tostring(coder_ai_task.task.enabled)
5050
"app.id" = coder_app.ai_interface.id
5151

52-
"ai_task_prompt.id" = data.coder_ai_task_prompt.me.id
53-
"ai_task_prompt.value" = data.coder_ai_task_prompt.me.value
54-
"ai_task_prompt.enabled" = tostring(data.coder_ai_task_prompt.me.enabled)
52+
"task.id" = data.coder_task.me.id
53+
"task.prompt" = data.coder_task.me.prompt
54+
"task.enabled" = tostring(data.coder_task.me.enabled)
5555
}
5656
}
5757

integration/integration_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ func TestIntegration(t *testing.T) {
215215
name: "coder-ai-task",
216216
minVersion: "v2.26.0",
217217
expectedOutput: map[string]string{
218-
"ai_task.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
219-
"ai_task.prompt": "",
220-
"ai_task.app_id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
221-
"ai_task.enabled": "false",
222-
"app.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
223-
"ai_task_prompt.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
224-
"ai_task_prompt.value": "",
225-
"ai_task_prompt.enabled": "false",
218+
"ai_task.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
219+
"ai_task.prompt": "",
220+
"ai_task.app_id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
221+
"ai_task.enabled": "false",
222+
"app.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
223+
"task.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
224+
"task.prompt": "",
225+
"task.enabled": "false",
226226
},
227227
},
228228
} {

provider/ai_task.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func aiTaskResource() *schema.Resource {
116116
}
117117
}
118118

119-
func aiTaskPromptDatasource() *schema.Resource {
119+
func aiTaskDatasource() *schema.Resource {
120120
return &schema.Resource{
121121
Description: "Use this data source to read information about Coder tasks.",
122122
ReadContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
@@ -133,8 +133,7 @@ func aiTaskPromptDatasource() *schema.Resource {
133133
diags = append(diags, errorAsDiagnostics(err)...)
134134
}
135135

136-
prompt := os.Getenv("CODER_TASK_PROMPT")
137-
_ = rd.Set("value", prompt)
136+
_ = rd.Set("prompt", os.Getenv("CODER_TASK_PROMPT"))
138137
return diags
139138
},
140139
Schema: map[string]*schema.Schema{
@@ -143,7 +142,7 @@ func aiTaskPromptDatasource() *schema.Resource {
143142
Computed: true,
144143
Description: "The UUID of the task, if executing in a Coder Task context. Empty in a Coder Workspace context.",
145144
},
146-
"value": {
145+
"prompt": {
147146
Type: schema.TypeString,
148147
Computed: true,
149148
Description: "The prompt text provided to the task by Coder, if executing in a Coder Task context. Empty in a Coder Workspace context.\n\n->This field is only populated in Coder v2.28 and later.",

provider/ai_task_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,18 @@ func TestAITaskPromptDatasource(t *testing.T) {
226226
Steps: []resource.TestStep{{
227227
Config: `
228228
provider "coder" {}
229-
data "coder_ai_task_prompt" "me" {}
229+
data "coder_task" "me" {}
230230
`,
231231
Check: func(s *terraform.State) error {
232232
require.Len(t, s.Modules, 1)
233233
require.Len(t, s.Modules[0].Resources, 1)
234-
resource := s.Modules[0].Resources["data.coder_ai_task_prompt.me"]
234+
resource := s.Modules[0].Resources["data.coder_task.me"]
235235
require.NotNil(t, resource)
236236

237237
taskID := resource.Primary.Attributes["id"]
238238
require.Equal(t, "7d8d4c2e-fb57-44f9-a183-22509819c2e7", taskID)
239239

240-
taskPromptValue := resource.Primary.Attributes["value"]
240+
taskPromptValue := resource.Primary.Attributes["prompt"]
241241
require.Equal(t, "some task prompt", taskPromptValue)
242242

243243
enabledValue := resource.Primary.Attributes["enabled"]
@@ -255,12 +255,12 @@ func TestAITaskPromptDatasource(t *testing.T) {
255255
Steps: []resource.TestStep{{
256256
Config: `
257257
provider "coder" {}
258-
data "coder_ai_task_prompt" "me" {}
258+
data "coder_task" "me" {}
259259
`,
260260
Check: func(s *terraform.State) error {
261261
require.Len(t, s.Modules, 1)
262262
require.Len(t, s.Modules[0].Resources, 1)
263-
resource := s.Modules[0].Resources["data.coder_ai_task_prompt.me"]
263+
resource := s.Modules[0].Resources["data.coder_task.me"]
264264
require.NotNil(t, resource)
265265

266266
taskID := resource.Primary.Attributes["id"]
@@ -269,7 +269,7 @@ func TestAITaskPromptDatasource(t *testing.T) {
269269
_, err := uuid.Parse(taskID)
270270
require.NoError(t, err)
271271

272-
taskPromptValue := resource.Primary.Attributes["value"]
272+
taskPromptValue := resource.Primary.Attributes["prompt"]
273273
require.Empty(t, taskPromptValue)
274274

275275
enabledValue := resource.Primary.Attributes["enabled"]
@@ -288,7 +288,7 @@ func TestAITaskPromptDatasource(t *testing.T) {
288288
Steps: []resource.TestStep{{
289289
Config: `
290290
provider "coder" {}
291-
data "coder_ai_task_prompt" "me" {}
291+
data "coder_task" "me" {}
292292
`,
293293
ExpectError: regexp.MustCompile(`invalid UUID`),
294294
}},

provider/helpers/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ func ValidateURL(value any, label string) ([]string, []error) {
1717
if _, err := url.Parse(val); err != nil {
1818
return nil, []error{err}
1919
}
20-
20+
2121
return nil, nil
2222
}

provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func New() *schema.Provider {
6464
"coder_external_auth": externalAuthDataSource(),
6565
"coder_workspace_owner": workspaceOwnerDataSource(),
6666
"coder_workspace_preset": workspacePresetDataSource(),
67-
"coder_ai_task_prompt": aiTaskPromptDatasource(),
67+
"coder_task": aiTaskDatasource(),
6868
},
6969
ResourcesMap: map[string]*schema.Resource{
7070
"coder_agent": agentResource(),

provider/provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestProviderEmpty(t *testing.T) {
3838
data "coder_parameter" "param" {
3939
name = "hey"
4040
}
41-
data "coder_ai_task_prompt" "me" {}`,
41+
data "coder_task" "me" {}`,
4242
Check: func(state *terraform.State) error {
4343
return nil
4444
},

provider/script_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ func TestValidateCronExpression(t *testing.T) {
131131
t.Parallel()
132132

133133
tests := []struct {
134-
name string
135-
cronExpr string
136-
expectWarnings bool
137-
expectErrors bool
134+
name string
135+
cronExpr string
136+
expectWarnings bool
137+
expectErrors bool
138138
warningContains string
139139
}{
140140
{

0 commit comments

Comments
 (0)