Skip to content

Commit 1eedbdd

Browse files
committedDec 14, 2019
implement vault token auto renew
1 parent e9e8978 commit 1eedbdd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎service/service.go

+11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func Initialise(ctx context.Context, c Config) (app *App, err error) {
7979

8080
// Start launches the app and blocks until fatal error
8181
func (app *App) Start() (final error) {
82+
// Renew vault token daily
83+
renew := time.NewTicker(time.Hour * 24)
84+
defer renew.Stop()
85+
8286
f := func() (err error) {
8387
select {
8488
case <-app.configWatcher.Events:
@@ -95,6 +99,13 @@ func (app *App) Start() (final error) {
9599
case e := <-errorMultiplex(app.configWatcher.Errors, app.targetsWatcher.Errors):
96100
zap.L().Error("git error",
97101
zap.Error(e))
102+
103+
case <-renew.C:
104+
_, e := app.vault.Auth().Token().RenewSelf(86400)
105+
if e != nil {
106+
zap.L().Error("failed to renew vault token",
107+
zap.Error(e))
108+
}
98109
}
99110
return
100111
}

0 commit comments

Comments
 (0)
Please sign in to comment.