display path on error
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
c625d497d4
commit
2f287b4b80
7
vault.go
7
vault.go
@ -3,7 +3,7 @@ package vault
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
@ -14,7 +14,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultStructTag = "vault"
|
DefaultStructTag = "vault"
|
||||||
ErrPathNotExist = errors.New("path is not exist")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type vaultConfig struct {
|
type vaultConfig struct {
|
||||||
@ -109,7 +108,7 @@ func (c *vaultConfig) Load(ctx context.Context, opts ...config.LoadOption) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.cli == nil && !c.opts.AllowFail {
|
if c.cli == nil && !c.opts.AllowFail {
|
||||||
return ErrPathNotExist
|
return fmt.Errorf("vault client not created")
|
||||||
} else if c.cli == nil && c.opts.AllowFail {
|
} else if c.cli == nil && c.opts.AllowFail {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -118,7 +117,7 @@ func (c *vaultConfig) Load(ctx context.Context, opts ...config.LoadOption) error
|
|||||||
if err != nil && !c.opts.AllowFail {
|
if err != nil && !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
} else if (pair == nil || pair.Data == nil) && !c.opts.AllowFail {
|
} else if (pair == nil || pair.Data == nil) && !c.opts.AllowFail {
|
||||||
return ErrPathNotExist
|
return fmt.Errorf("vault path %s not found", c.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil && pair != nil && pair.Data != nil {
|
if err == nil && pair != nil && pair.Data != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user