Merge pull request #55 from hashicorp/f-hcl-job

jobspec: default job ID also comes from key
This commit is contained in:
Ryan Uber 2015-09-16 22:25:26 -07:00
commit 173a84fb2e
3 changed files with 20 additions and 1 deletions

View File

@ -77,7 +77,8 @@ func parseJob(result *structs.Job, obj *hclobj.Object) error {
delete(m, "constraint")
delete(m, "meta")
// Set the name to the object key
// Set the ID and name to the object key
result.ID = obj.Key
result.Name = obj.Key
// Defaults

View File

@ -17,6 +17,7 @@ func TestParse(t *testing.T) {
{
"basic.hcl",
&structs.Job{
ID: "binstore-storagelocker",
Name: "binstore-storagelocker",
Type: "service",
Priority: 50,
@ -128,6 +129,7 @@ func TestParse(t *testing.T) {
{
"default-job.hcl",
&structs.Job{
ID: "foo",
Name: "foo",
Priority: 50,
Region: "global",
@ -135,6 +137,18 @@ func TestParse(t *testing.T) {
},
false,
},
{
"specify-job.hcl",
&structs.Job{
ID: "job1",
Name: "My Job",
Priority: 50,
Region: "global",
Type: "service",
},
false,
},
}
for _, tc := range cases {

View File

@ -0,0 +1,4 @@
job "default" {
id = "job1"
name = "My Job"
}