Skip to content

Commit

Permalink
Backport of jobspec: allow artifact headers in HCLv1 into release/1.2…
Browse files Browse the repository at this point in the history
….x (#14724)

This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core committed Sep 27, 2022
1 parent 0735ed3 commit 466aa3f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/14637.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
jobspec: Fixed a bug where an `artifact` with `headers` configuration would fail to parse when using HCLv1
```
1 change: 1 addition & 0 deletions jobspec/parse_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ func parseArtifacts(result *[]*api.TaskArtifact, list *ast.ObjectList) error {
valid := []string{
"source",
"options",
"headers",
"mode",
"destination",
}
Expand Down
7 changes: 7 additions & 0 deletions jobspec/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ func TestParse(t *testing.T) {
GetterOptions: nil,
RelativeDest: stringToPtr("var/foo"),
},
{
GetterSource: stringToPtr("https://example.com/file.txt"),
GetterHeaders: map[string]string{
"User-Agent": "nomad",
"X-Nomad-Alloc": "alloc",
},
},
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions jobspec/test-fixtures/artifacts.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ job "binstore-storagelocker" {
source = "http://foo.com/bam"
destination = "var/foo"
}

artifact {
source = "https://example.com/file.txt"

headers {
User-Agent = "nomad"
X-Nomad-Alloc = "alloc"
}
}
}
}
}

0 comments on commit 466aa3f

Please sign in to comment.