Fix VaultPolicies returning non-empty map when there are no policies
This commit is contained in:
parent
50efdb00e9
commit
5a9919bfbf
|
@ -1844,7 +1844,7 @@ func TestClientEndpoint_DeriveVaultToken_Bad(t *testing.T) {
|
|||
|
||||
// Now we should get an error about the job not needing any Vault secrets
|
||||
err = msgpackrpc.CallWithCodec(codec, "Node.DeriveVaultToken", req, &resp)
|
||||
if err == nil || !strings.Contains(err.Error(), "without defined Vault") {
|
||||
if err == nil || !strings.Contains(err.Error(), "does not require") {
|
||||
t.Fatalf("Expected no policies error: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -1277,7 +1277,6 @@ func (j *Job) VaultPolicies() map[string]map[string]*Vault {
|
|||
|
||||
for _, tg := range j.TaskGroups {
|
||||
tgPolicies := make(map[string]*Vault, len(tg.Tasks))
|
||||
policies[tg.Name] = tgPolicies
|
||||
|
||||
for _, task := range tg.Tasks {
|
||||
if task.Vault == nil {
|
||||
|
@ -1286,6 +1285,10 @@ func (j *Job) VaultPolicies() map[string]map[string]*Vault {
|
|||
|
||||
tgPolicies[task.Name] = task.Vault
|
||||
}
|
||||
|
||||
if len(tgPolicies) != 0 {
|
||||
policies[tg.Name] = tgPolicies
|
||||
}
|
||||
}
|
||||
|
||||
return policies
|
||||
|
|
Loading…
Reference in a new issue