Skip to content

Commit 3ca8f2f

Browse files
authored
Don't use computed for pause_status in databricks_job resource (#2696)
Right now, the `pause_status` in `schedule`, `continuous` and `trigger` blocks is marked as `computed` because it could be omitted, and backend will provide a default value. This leads to following problems: - it's not changed to default `UNPAUSED` if you remove it from TF code (same behaviour would be with `suppress_diff`) - so you can't unpause the job after you paused it until you explicitly set `pause_status` to `UNPAUSED` - this field isn't exported by TF exporter (issue #2695) The solution for these problems is to set default in the provider's source code. Also added validators for `pause_status` in `continuous` & `trigger` blocks. This fixes #2695
1 parent 0ba6039 commit 3ca8f2f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

jobs/resource_job.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type Webhook struct {
158158
type CronSchedule struct {
159159
QuartzCronExpression string `json:"quartz_cron_expression"`
160160
TimezoneID string `json:"timezone_id"`
161-
PauseStatus string `json:"pause_status,omitempty" tf:"computed"`
161+
PauseStatus string `json:"pause_status,omitempty" tf:"default:UNPAUSED"`
162162
}
163163

164164
// BEGIN Jobs + Repo integration preview
@@ -228,7 +228,7 @@ type JobCompute struct {
228228
}
229229

230230
type ContinuousConf struct {
231-
PauseStatus string `json:"pause_status,omitempty" tf:"computed"`
231+
PauseStatus string `json:"pause_status,omitempty" tf:"default:UNPAUSED"`
232232
}
233233

234234
type Queue struct {
@@ -247,7 +247,7 @@ type FileArrival struct {
247247

248248
type Trigger struct {
249249
FileArrival *FileArrival `json:"file_arrival"`
250-
PauseStatus string `json:"pause_status,omitempty" tf:"computed"`
250+
PauseStatus string `json:"pause_status,omitempty" tf:"default:UNPAUSED"`
251251
}
252252

253253
// JobSettings contains the information for configuring a job on databricks
@@ -665,6 +665,12 @@ var jobSchema = common.StructToSchema(JobSettings{},
665665
if p, err := common.SchemaPath(s, "schedule", "pause_status"); err == nil {
666666
p.ValidateFunc = validation.StringInSlice([]string{"PAUSED", "UNPAUSED"}, false)
667667
}
668+
if p, err := common.SchemaPath(s, "trigger", "pause_status"); err == nil {
669+
p.ValidateFunc = validation.StringInSlice([]string{"PAUSED", "UNPAUSED"}, false)
670+
}
671+
if p, err := common.SchemaPath(s, "continuous", "pause_status"); err == nil {
672+
p.ValidateFunc = validation.StringInSlice([]string{"PAUSED", "UNPAUSED"}, false)
673+
}
668674
s["max_concurrent_runs"].ValidateDiagFunc = validation.ToDiagFunc(validation.IntAtLeast(0))
669675
s["max_concurrent_runs"].Default = 1
670676
s["url"] = &schema.Schema{

0 commit comments

Comments
 (0)