From 396e5b7df4243bef743737d7bb433768e1edcec9 Mon Sep 17 00:00:00 2001 From: Keloran Date: Mon, 21 Aug 2023 21:04:14 +0100 Subject: [PATCH] Added lease --- vault.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/vault.go b/vault.go index a35537b..5cd0b7a 100644 --- a/vault.go +++ b/vault.go @@ -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) } @@ -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 { @@ -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") @@ -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 +}