Skip to content

Commit 753557e

Browse files
authored
Merge pull request #3 from Southclaws/vault-secret-path
add vault path prefix
2 parents e267ae8 + f10fa5d commit 753557e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ this repository has new commits, Wadsworth will automatically reconfigure.`,
6363
cli.DurationFlag{Name: "check-interval", EnvVar: "CHECK_INTERVAL", Value: time.Second * 10},
6464
cli.StringFlag{Name: "vault-addr", EnvVar: "VAULT_ADDR"},
6565
cli.StringFlag{Name: "vault-token", EnvVar: "VAULT_TOKEN"},
66+
cli.StringFlag{Name: "vault-path", EnvVar: "VAULT_PATH"},
6667
},
6768
Action: func(c *cli.Context) (err error) {
6869
if !c.Args().Present() {
@@ -79,6 +80,7 @@ this repository has new commits, Wadsworth will automatically reconfigure.`,
7980
CheckInterval: c.Duration("check-interval"),
8081
VaultAddress: c.String("vault-addr"),
8182
VaultToken: c.String("vault-token"),
83+
VaultPath: c.String("vault-path"),
8284
})
8385
if err != nil {
8486
return errors.Wrap(err, "failed to initialise")

service/secrets.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package service
22

3-
import "github.com/pkg/errors"
3+
import (
4+
"path/filepath"
5+
6+
"github.com/pkg/errors"
7+
)
48

59
func (app *App) getSecretsForTarget(name string) (env map[string]string, err error) {
610
if app.vault != nil {
@@ -10,7 +14,7 @@ func (app *App) getSecretsForTarget(name string) (env map[string]string, err err
1014
}
1115

1216
func (app *App) secretsFromVault(name string) (env map[string]string, err error) {
13-
path := "/secret/" + name
17+
path := filepath.Join("/secret", app.config.VaultPath, name)
1418
secret, err := app.vault.Logical().Read(path)
1519
if err != nil {
1620
return nil, errors.Wrap(err, "failed to read secret")

service/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Config struct {
3636
CheckInterval time.Duration
3737
VaultAddress string
3838
VaultToken string
39+
VaultPath string
3940
}
4041

4142
// Initialise prepares an instance of the app to run

0 commit comments

Comments
 (0)