Skip to content

Commit

Permalink
jobspec: allow artifact headers in HCLv1 (#14637)
Browse files Browse the repository at this point in the history
* jobspec: allow artifact headers in HCLv1

Co-authored-by: Luiz Aoqui <[email protected]>
  • Loading branch information
jimrazmus and lgfa29 authored Sep 27, 2022
1 parent 1e5f618 commit cc8e624
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 @@ -628,6 +628,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 cc8e624

Please sign in to comment.