From 466aa3f31dbf65d3f9a356fe3d5a0d53235ee379 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Tue, 27 Sep 2022 12:19:23 -0400 Subject: [PATCH] Backport of jobspec: allow artifact headers in HCLv1 into release/1.2.x (#14724) This pull request was automerged via backport-assistant --- .changelog/14637.txt | 3 +++ jobspec/parse_task.go | 1 + jobspec/parse_test.go | 7 +++++++ jobspec/test-fixtures/artifacts.hcl | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100644 .changelog/14637.txt diff --git a/.changelog/14637.txt b/.changelog/14637.txt new file mode 100644 index 000000000000..7e01d444d33b --- /dev/null +++ b/.changelog/14637.txt @@ -0,0 +1,3 @@ +```release-note:bug +jobspec: Fixed a bug where an `artifact` with `headers` configuration would fail to parse when using HCLv1 +``` diff --git a/jobspec/parse_task.go b/jobspec/parse_task.go index 4bc77c310f27..2bdcac227203 100644 --- a/jobspec/parse_task.go +++ b/jobspec/parse_task.go @@ -370,6 +370,7 @@ func parseArtifacts(result *[]*api.TaskArtifact, list *ast.ObjectList) error { valid := []string{ "source", "options", + "headers", "mode", "destination", } diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 1af37804371d..bbd183abcd15 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -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", + }, + }, }, }, }, diff --git a/jobspec/test-fixtures/artifacts.hcl b/jobspec/test-fixtures/artifacts.hcl index 4631f595bef9..2da722850c8c 100644 --- a/jobspec/test-fixtures/artifacts.hcl +++ b/jobspec/test-fixtures/artifacts.hcl @@ -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" + } + } } } }