Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ IMPROVEMENTS:
* data source/nomad_node_pool: Added the `node_identity_ttl` argument ([#569](https://github.com/hashicorp/terraform-provider-nomad/pull/569))
* resource/nomad_node_pool: Added the `node_identity_ttl` argument to configure the node identity TTL for nodes in the pool ([#569](https://github.com/hashicorp/terraform-provider-nomad/pull/569))
* resource/nomad_quota_specification: add support for all `QuotaResources` fields including `secrets_mb`, `devices`, `numa`, and `storage` ([#584](https://github.com/hashicorp/terraform-provider-nomad/pull/584))
* resource/nomad_job, data source/nomad_job: Added and aligned computed job and task group attributes, including periodic and update strategy fields, to match the `nomad_job` implementation and documentation ([#585](https://github.com/hashicorp/terraform-provider-nomad/pull/585))

## 2.5.2 (November 13, 2025)

Expand Down
23 changes: 4 additions & 19 deletions nomad/datasource_nomad_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func dataSourceJob() *schema.Resource {
},
},
},
"update_strategy": updateStrategySchema(),
"periodic_config": {
Description: "Job Periodic Configuration",
Computed: true,
Expand Down Expand Up @@ -204,29 +205,13 @@ func dataSourceJobRead(d *schema.ResourceData, meta interface{}) error {
d.Set("stop", job.Stop)
d.Set("priority", job.Priority)
d.Set("parent_id", job.ParentID)

d.Set("task_groups", jobTaskGroupsRaw(job.TaskGroups))
d.Set("stable", job.Stable)
d.Set("all_at_once", job.AllAtOnce)
d.Set("constraints", job.Constraints)
if job.Periodic != nil {
periodic := map[string]interface{}{}
if job.Periodic.Enabled != nil {
periodic["enabled"] = *job.Periodic.Enabled
}
if job.Periodic.Spec != nil {
periodic["spec"] = *job.Periodic.Spec
}
if job.Periodic.SpecType != nil {
periodic["spec_type"] = *job.Periodic.SpecType
}
if job.Periodic.ProhibitOverlap != nil {
periodic["prohibit_overlap"] = *job.Periodic.ProhibitOverlap
}
if job.Periodic.TimeZone != nil {
periodic["timezone"] = *job.Periodic.TimeZone
}
d.Set("periodic_config", []map[string]interface{}{periodic})
}
d.Set("update_strategy", flattenUpdateStrategy(job.Update))
d.Set("periodic_config", flattenPeriodicConfig(job.Periodic))

return nil
}
16 changes: 16 additions & 0 deletions nomad/datasource_nomad_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ func TestAccDataSourceNomadJob_Basic(t *testing.T) {
"data.nomad_job.test-job", "priority", "50"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "namespace", "default"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "update_strategy.#", "1"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "update_strategy.0.max_parallel", "2"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "task_groups.0.update_strategy.#", "1"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "task_groups.0.update_strategy.0.max_parallel", "2"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "task_groups.0.update_strategy.0.min_healthy_time", "11s"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "task_groups.0.update_strategy.0.healthy_deadline", "6m0s"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "task_groups.0.update_strategy.0.auto_revert", "true"),
resource.TestCheckResourceAttr(
"data.nomad_job.test-job", "task_groups.0.update_strategy.0.canary", "1"),
),
},
},
Expand Down
Loading
Loading