Skip to content

Commit

Permalink
Merge pull request #35 from oholiab/enable_description_field_for_mounts
Browse files Browse the repository at this point in the history
Enable "description" field for mounts
  • Loading branch information
jippi authored Aug 12, 2019
2 parents 90c1d31 + 0219f95 commit 8eb9087
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion config/vault_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Config) parseVaultMountStanza(list *ast.ObjectList, environment *Enviro
for _, mountAST := range list.Items {
x := mountAST.Val.(*ast.ObjectType).List

valid := []string{"config", "role", "type", "path", "max_lease_ttl", "default_lease_ttl", "force_no_cache"}
valid := []string{"config", "role", "type", "path", "max_lease_ttl", "default_lease_ttl", "force_no_cache", "description"}
if err := c.checkHCLKeys(x, valid); err != nil {
return err
}
Expand Down Expand Up @@ -148,6 +148,19 @@ func (c *Config) parseVaultMountStanza(list *ast.ObjectList, environment *Enviro
} else if len(forceNoCacheAST.Items) > 1 {
return fmt.Errorf("You can only specify force_no_cache once per mount in %s -> %s", environment.Name, mountName)
}
description := ""
descriptionAST := x.Filter("description")
if len(descriptionAST.Items) == 1 {
v := descriptionAST.Items[0].Val.(*ast.LiteralType).Token.Value()
switch t := v.(type) {
default:
return fmt.Errorf("unexpected type %T for %s -> %s -> description", environment.Name, mountName, t)
case string:
description = v.(string)
}
} else if len(descriptionAST.Items) > 1 {
return fmt.Errorf("You can only specify description once per mount in %s -> %s", environment.Name, mountName)
}

mount = &Mount{
Name: mountName,
Expand All @@ -156,6 +169,7 @@ func (c *Config) parseVaultMountStanza(list *ast.ObjectList, environment *Enviro
MaxLeaseTTL: mountMaxLeaseTTL,
DefaultLeaseTTL: mountDefaultLeaseTTL,
ForceNoCache: mountForceNoCache,
Description: description,
}
}

Expand Down

0 comments on commit 8eb9087

Please sign in to comment.