Skip to content

Commit e26351c

Browse files
committed
add some debug logging related to secret lookups
1 parent 04fea66 commit e26351c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

service/secret/vault/vault.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/hashicorp/go-cleanhttp"
99
"github.com/hashicorp/vault/api"
1010
"github.com/pkg/errors"
11+
"go.uber.org/zap"
1112

1213
"github.com/picostack/pico/service/secret"
1314
)
@@ -46,18 +47,31 @@ func New(addr, path, token string, renewal time.Duration) (*VaultSecrets, error)
4647
// GetSecretsForTarget implements secret.Store
4748
func (v *VaultSecrets) GetSecretsForTarget(name string) (map[string]string, error) {
4849
path := filepath.Join(v.path, name)
50+
51+
zap.L().Debug("looking for secrets in vault",
52+
zap.String("name", name),
53+
zap.String("path", path))
54+
4955
secret, err := v.client.Logical().Read(path)
5056
if err != nil {
5157
return nil, errors.Wrap(err, "failed to read secret")
5258
}
5359
if secret == nil {
60+
zap.L().Debug("did not find secrets in vault",
61+
zap.String("name", name),
62+
zap.String("path", path))
5463
return nil, nil
5564
}
5665

5766
env := make(map[string]string)
5867
for k, v := range secret.Data {
5968
env[k] = v.(string)
6069
}
70+
71+
zap.L().Debug("found secrets in vault",
72+
zap.Any("secrets", env),
73+
zap.Int("count", len(env)))
74+
6175
return env, nil
6276
}
6377

service/service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ func Initialise(c Config) (app *App, err error) {
5353

5454
var secretStore secret.Store
5555
if c.VaultAddress != "" {
56+
zap.L().Debug("connecting to vault",
57+
zap.String("address", c.VaultAddress),
58+
zap.String("path", c.VaultPath),
59+
zap.String("token", c.VaultToken),
60+
zap.Duration("renewal", c.VaultRenewal))
61+
5662
secretStore, err = vault.New(c.VaultAddress, c.VaultPath, c.VaultToken, c.VaultRenewal)
5763
if err != nil {
5864
return nil, err

0 commit comments

Comments
 (0)