Skip to content

Commit

Permalink
resource/job: set namespace on register (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
FourLeafTec authored Dec 16, 2023
1 parent a81b5f7 commit 8f20175
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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:
BUG FIXES:
* resource/nomad_acl_policy: fixed a bug where the namespace would be incorrectly calculated from a job identity ([#396](https://github.com/hashicorp/terraform-provider-nomad/pull/396))
* resource/nomad_csi_volume_registration: fixed a bug that cause an import operation to not load all of the volume attributes ([#402](https://github.com/hashicorp/terraform-provider-nomad/pull/402))
* resource/nomad_job: fixed a bug that could cause jobs to be registered in the incorrect namespace if the `NOMAD_NAMESPACE` environment variable is set ([#386](https://github.com/hashicorp/terraform-provider-nomad/pull/386))
* resource/nomad_volume: fixed a bug that cause an import operation to not load all of the volume attributes ([#402](https://github.com/hashicorp/terraform-provider-nomad/pull/402))

## 2.0.0 (August 28th, 2023)
Expand Down
9 changes: 6 additions & 3 deletions nomad/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,12 @@ func resourceJobRegister(d *schema.ResourceData, meta interface{}) error {
if err != nil {
wantModifyIndex = 0
}

resp, _, err := client.Jobs().RegisterOpts(job, &api.RegisterOptions{
PolicyOverride: d.Get("policy_override").(bool),
ModifyIndex: wantModifyIndex,
}, nil)
}, &api.WriteOptions{
Namespace: *job.Namespace,
})
if err != nil {
return fmt.Errorf("error applying jobspec: %s", err)
}
Expand Down Expand Up @@ -695,7 +696,9 @@ func resourceJobCustomizeDiff(_ context.Context, d *schema.ResourceDiff, meta in
resp, _, err := client.Jobs().PlanOpts(job, &api.PlanOptions{
Diff: false,
PolicyOverride: d.Get("policy_override").(bool),
}, nil)
}, &api.WriteOptions{
Namespace: *job.Namespace,
})
if err != nil {
log.Printf("[WARN] failed to validate Nomad plan: %s", err)
}
Expand Down

0 comments on commit 8f20175

Please sign in to comment.