Skip to content

Commit

Permalink
Added lease
Browse files Browse the repository at this point in the history
  • Loading branch information
Keloran committed Aug 21, 2023
1 parent ad6c51b commit 396e5b7
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import (
"github.com/hashicorp/vault/api"
)

type VaultHelper interface {
GetSecrets(path string) error
GetSecret(key string) (string, error)
Secrets() []KVSecret
LeaseDuration() int
}

type LogicalClient interface {
Read(string) (*api.Secret, error)
}
Expand Down Expand Up @@ -35,11 +42,11 @@ type VaultClient interface {
}

type Vault struct {
Client VaultClient
Address string
Token string
LeaseDuration int
KVSecrets []KVSecret
Client VaultClient
Address string
Token string
Lease int
KVSecrets []KVSecret
}

type KVSecret struct {
Expand Down Expand Up @@ -77,7 +84,7 @@ func (v *Vault) GetSecrets(path string) error {
}

if data.LeaseDuration != 0 {
v.LeaseDuration = data.LeaseDuration
v.Lease = data.LeaseDuration
}

secrets, err := ParseData(data.Data, "data")
Expand Down Expand Up @@ -122,3 +129,7 @@ func ParseData(data map[string]interface{}, filterName string) ([]KVSecret, erro
func (v *Vault) Secrets() []KVSecret {
return v.KVSecrets
}

func (v *Vault) LeaseDuration() int {
return v.Lease
}

0 comments on commit 396e5b7

Please sign in to comment.