From fb7db1143c5e1c305999549f4767303f07dc4adf Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Thu, 11 Aug 2016 18:37:53 -0400 Subject: [PATCH] Update jobspec parsing to contain vault_token at job level and not task level --- jobspec/parse.go | 2 +- jobspec/parse_test.go | 1 - jobspec/test-fixtures/bad-ports.hcl | 1 + jobspec/test-fixtures/basic.hcl | 2 +- jobspec/test-fixtures/basic_wrong_key.hcl | 1 + jobspec/test-fixtures/incorrect-service-def.hcl | 1 + jobspec/test-fixtures/multi-vault.hcl | 2 -- jobspec/test-fixtures/overlapping-ports.hcl | 1 + 8 files changed, 6 insertions(+), 5 deletions(-) diff --git a/jobspec/parse.go b/jobspec/parse.go index 7966c5864..b2d8eb8f7 100644 --- a/jobspec/parse.go +++ b/jobspec/parse.go @@ -139,6 +139,7 @@ func parseJob(result *structs.Job, list *ast.ObjectList) error { "meta", "task", "group", + "vault_token", } if err := checkHCLKeys(listVal, valid); err != nil { return multierror.Prefix(err, "job:") @@ -1047,7 +1048,6 @@ func parseVault(result *structs.Vault, list *ast.ObjectList) error { // Check for invalid keys valid := []string{ "policies", - "token", } if err := checkHCLKeys(listVal, valid); err != nil { return multierror.Prefix(err, "vault ->") diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 028e289b7..5231abcc7 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -155,7 +155,6 @@ func TestParse(t *testing.T) { }, Vault: &structs.Vault{ Policies: []string{"foo", "bar"}, - Token: "baz", }, }, &structs.Task{ diff --git a/jobspec/test-fixtures/bad-ports.hcl b/jobspec/test-fixtures/bad-ports.hcl index dbc990b12..309205479 100644 --- a/jobspec/test-fixtures/bad-ports.hcl +++ b/jobspec/test-fixtures/bad-ports.hcl @@ -4,6 +4,7 @@ job "binstore-storagelocker" { priority = 50 all_at_once = true datacenters = ["us2", "eu1"] + vault_token = "foo" meta { foo = "bar" diff --git a/jobspec/test-fixtures/basic.hcl b/jobspec/test-fixtures/basic.hcl index 2e9bb5beb..ed52a6a29 100644 --- a/jobspec/test-fixtures/basic.hcl +++ b/jobspec/test-fixtures/basic.hcl @@ -4,6 +4,7 @@ job "binstore-storagelocker" { priority = 50 all_at_once = true datacenters = ["us2", "eu1"] + vault_token = "foo" meta { foo = "bar" @@ -126,7 +127,6 @@ job "binstore-storagelocker" { vault { policies = ["foo", "bar"] - token = "baz" } } diff --git a/jobspec/test-fixtures/basic_wrong_key.hcl b/jobspec/test-fixtures/basic_wrong_key.hcl index 50244ae45..e717edbb9 100644 --- a/jobspec/test-fixtures/basic_wrong_key.hcl +++ b/jobspec/test-fixtures/basic_wrong_key.hcl @@ -4,6 +4,7 @@ job "binstore-storagelocker" { priority = 50 all_at_once = true datacenters = ["us2", "eu1"] + vault_token = "foo" meta { foo = "bar" diff --git a/jobspec/test-fixtures/incorrect-service-def.hcl b/jobspec/test-fixtures/incorrect-service-def.hcl index dae8bbd60..fa832a216 100644 --- a/jobspec/test-fixtures/incorrect-service-def.hcl +++ b/jobspec/test-fixtures/incorrect-service-def.hcl @@ -4,6 +4,7 @@ job "binstore-storagelocker" { priority = 50 all_at_once = true datacenters = ["us2", "eu1"] + vault_token = "foo" meta { foo = "bar" diff --git a/jobspec/test-fixtures/multi-vault.hcl b/jobspec/test-fixtures/multi-vault.hcl index e01bc68c0..c5266548c 100644 --- a/jobspec/test-fixtures/multi-vault.hcl +++ b/jobspec/test-fixtures/multi-vault.hcl @@ -17,11 +17,9 @@ job "binstore-storagelocker" { vault { policies = ["foo", "bar"] - token = "baz" } vault { policies = ["1", "2"] - token = "3" } } } diff --git a/jobspec/test-fixtures/overlapping-ports.hcl b/jobspec/test-fixtures/overlapping-ports.hcl index daa9b60ee..a07ef2262 100644 --- a/jobspec/test-fixtures/overlapping-ports.hcl +++ b/jobspec/test-fixtures/overlapping-ports.hcl @@ -4,6 +4,7 @@ job "binstore-storagelocker" { priority = 50 all_at_once = true datacenters = ["us2", "eu1"] + vault_token = "foo" meta { foo = "bar"