@@ -17,6 +17,13 @@ import (
1717 vault "github.com/hashicorp/vault/api"
1818)
1919
20+ const (
21+ MountTypeKVv1 = "kvv1"
22+ MountTypeKVv2 = "kvv2"
23+ MountTypeDatabase = "database"
24+ MountTypeLogical = "logical"
25+ )
26+
2027var UnsupportedMountType = errors .New ("Unsupported HashiCorp Vault mount type" )
2128var RequiredKeyMissing = errors .New ("Required key missing from HashiCorp Vault secret" )
2229
@@ -77,11 +84,11 @@ func (c HashicorpVaultClient) getVaultSecret(mountType string, mount string, pat
7784 result := map [string ]string {}
7885 var err error
7986 var secretData map [string ]interface {}
80- if mountType == "kvv2" || mountType == "kvv1" {
87+ if mountType == MountTypeKVv1 || mountType == MountTypeKVv2 {
8188 // Handle simple key-value secrets
8289 var secret * vault.KVSecret
8390 c .logger .Info ("Making call to HashiCorp Vault" , "mountType" , mountType , "mountName" , mount , "secretPath" , path , "expectedKeys" , requiredKeys )
84- if mountType == "kvv2" {
91+ if mountType == MountTypeKVv2 {
8592 secret , err = c .client .KVv2 (mount ).Get (context .TODO (), path )
8693 } else {
8794 secret , err = c .client .KVv1 (mount ).Get (context .TODO (), path )
@@ -91,11 +98,11 @@ func (c HashicorpVaultClient) getVaultSecret(mountType string, mount string, pat
9198 return result , err
9299 }
93100 secretData = secret .Data
94- } else if mountType == "database" || mountType == "logical" {
101+ } else if mountType == MountTypeDatabase || mountType == MountTypeLogical {
95102 // Handle other types of secrets, for example database roles, just using the Logical() backend
96103 var secret * vault.Secret
97104 var secretPath string
98- if mountType == "database" {
105+ if mountType == MountTypeDatabase {
99106 secretPath = fmt .Sprintf ("%s/creds/%s" , mount , path )
100107 } else {
101108 secretPath = fmt .Sprintf ("%s/%s" , mount , path )
0 commit comments