jobspec: allow artifact headers in HCLv1 (#14637)

* jobspec: allow artifact headers in HCLv1

Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
This commit is contained in:
Jim Razmus II 2022-09-27 11:18:49 -05:00 committed by GitHub
parent 5df5e70542
commit 7da3fd050b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

3
.changelog/14637.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
jobspec: Fixed a bug where an `artifact` with `headers` configuration would fail to parse when using HCLv1
```

View File

@ -370,6 +370,7 @@ func parseArtifacts(result *[]*api.TaskArtifact, list *ast.ObjectList) error {
valid := []string{ valid := []string{
"source", "source",
"options", "options",
"headers",
"mode", "mode",
"destination", "destination",
} }

View File

@ -628,6 +628,13 @@ func TestParse(t *testing.T) {
GetterOptions: nil, GetterOptions: nil,
RelativeDest: stringToPtr("var/foo"), RelativeDest: stringToPtr("var/foo"),
}, },
{
GetterSource: stringToPtr("https://example.com/file.txt"),
GetterHeaders: map[string]string{
"User-Agent": "nomad",
"X-Nomad-Alloc": "alloc",
},
},
}, },
}, },
}, },

View File

@ -20,6 +20,15 @@ job "binstore-storagelocker" {
source = "http://foo.com/bam" source = "http://foo.com/bam"
destination = "var/foo" destination = "var/foo"
} }
artifact {
source = "https://example.com/file.txt"
headers {
User-Agent = "nomad"
X-Nomad-Alloc = "alloc"
}
}
} }
} }
} }