Skip to content
Open
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:

BUG FIXES:
* cli: Fix panic when calling status command with namespace wildcard [[GH-827](https://github.com/hashicorp/nomad-pack/pull/854)]
* pack: Preserve pack metadata injection for job templates with top-level HCL blocks such as `locals`
* renderer: Fixed output template rendering to respect --parser-v1 flag [[GH-875](https://github.com/hashicorp/nomad-pack/pull/875)]

## 0.4.2 (March 16, 2026)
Expand Down
2 changes: 1 addition & 1 deletion internal/runner/job/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (r *Runner) setHCLMeta(job string) string {
if diags.HasErrors() {
return job
}
content, diags := file.Body.Content(&hcl.BodySchema{
content, _, diags := file.Body.PartialContent(&hcl.BodySchema{
Blocks: []hcl.BlockHeaderSchema{
{Type: "job", LabelNames: []string{""}},
},
Expand Down
22 changes: 22 additions & 0 deletions internal/runner/job/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ func TestDeployer_setHCLMeta(t *testing.T) {
"pack.version" = "123456"
thing = "baz"
}
}`,
},
{
desc: "top-level locals are preserved while job meta is merged",
inputRunner: &Runner{
runnerCfg: defaultConfig,
},
inputJob: "locals {\n thing = \"baz\"\n}\n\njob \"foobar\" {\n meta {\n other = \"foobar\" \n}\n }",
expectedJob: `locals {
thing = "baz"
}

job "foobar" {
meta = {
other = "foobar"
"pack.deployment_name" = "foobar@123456"
"pack.job" = "foobar"
"pack.name" = "foobar"
"pack.path" = "/opt/src/foobar"
"pack.registry" = "default"
"pack.version" = "123456"
}
}`,
},
{
Expand Down