Skip to content

Commit 2ad918d

Browse files
authored
feature - timeout seconds data source (#89)
1 parent bc30051 commit 2ad918d

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/data-sources/dbt_cloud_job.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ description: |-
2727
- `id` (String) The ID of this resource.
2828
- `name` (String) Given name for the job
2929
- `self_deferring` (Boolean) Whether this job defers on a previous run of itself (overrides value in deferring_job_id)
30+
- `timeout_seconds` (Number) Number of seconds before the job times out
3031
- `triggers` (Map of Boolean) Flags for which types of triggers to use, keys of github_webhook, git_provider_webhook, schedule, custom_branch_only
3132

3233

pkg/data_sources/job.go

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ var jobSchema = map[string]*schema.Schema{
5151
},
5252
Description: "Flags for which types of triggers to use, keys of github_webhook, git_provider_webhook, schedule, custom_branch_only",
5353
},
54+
"timeout_seconds": &schema.Schema{
55+
Type: schema.TypeInt,
56+
Computed: true,
57+
Description: "Number of seconds before the job times out",
58+
},
5459
}
5560

5661
func DatasourceJob() *schema.Resource {
@@ -93,6 +98,9 @@ func datasourceJobRead(ctx context.Context, d *schema.ResourceData, m interface{
9398
if err := d.Set("self_deferring", selfDeferring); err != nil {
9499
return diag.FromErr(err)
95100
}
101+
if err := d.Set("timeout_seconds", job.Execution.Timeout_Seconds); err != nil {
102+
return diag.FromErr(err)
103+
}
96104
var triggers map[string]interface{}
97105
triggersInput, _ := json.Marshal(job.Triggers)
98106
json.Unmarshal(triggersInput, &triggers)

pkg/data_sources/job_acceptance_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestDbtCloudJobDataSource(t *testing.T) {
1919
resource.TestCheckResourceAttrSet("data.dbt_cloud_job.test", "project_id"),
2020
resource.TestCheckResourceAttrSet("data.dbt_cloud_job.test", "environment_id"),
2121
resource.TestCheckResourceAttr("data.dbt_cloud_job.test", "name", randomJobName),
22+
resource.TestCheckResourceAttr("data.dbt_cloud_job.test", "timeout_seconds", "180"),
2223
)
2324

2425
resource.ParallelTest(t, resource.TestCase{
@@ -58,6 +59,7 @@ func jobs(jobName string) string {
5859
"schedule" : false,
5960
"git_provider_webhook": false
6061
}
62+
timeout_seconds = 180
6163
}
6264
6365
data "dbt_cloud_job" "test" {

0 commit comments

Comments
 (0)