Skip to content

Commit 2133e73

Browse files
committed
add vault-renew-interval flag/var for changing the interval between vault token renewals
1 parent 0736871 commit 2133e73

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ this repository has new commits, Picobot will automatically reconfigure.`,
6666
cli.StringFlag{Name: "vault-addr", EnvVar: "VAULT_ADDR"},
6767
cli.StringFlag{Name: "vault-token", EnvVar: "VAULT_TOKEN"},
6868
cli.StringFlag{Name: "vault-path", EnvVar: "VAULT_PATH"},
69+
cli.DurationFlag{Name: "vault-renew-interval", EnvVar: "VAULT_RENEW_INTERVAL", Value: time.Hour * 24},
6970
},
7071
Action: func(c *cli.Context) (err error) {
7172
if !c.Args().Present() {
@@ -96,6 +97,7 @@ this repository has new commits, Picobot will automatically reconfigure.`,
9697
VaultAddress: c.String("vault-addr"),
9798
VaultToken: c.String("vault-token"),
9899
VaultPath: c.String("vault-path"),
100+
VaultRenewal: c.Duration("vault-renew-interval"),
99101
})
100102
if err != nil {
101103
return errors.Wrap(err, "failed to initialise")

service/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Config struct {
4141
VaultAddress string
4242
VaultToken string
4343
VaultPath string
44+
VaultRenewal time.Duration
4445
}
4546

4647
// Initialise prepares an instance of the app to run
@@ -85,8 +86,7 @@ func Initialise(ctx context.Context, c Config) (app *App, err error) {
8586

8687
// Start launches the app and blocks until fatal error
8788
func (app *App) Start() (final error) {
88-
// Renew vault token daily
89-
renew := time.NewTicker(time.Hour * 24)
89+
renew := time.NewTicker(app.config.VaultRenewal)
9090
defer renew.Stop()
9191

9292
f := func() (err error) {

0 commit comments

Comments
 (0)