Skip to content

Commit

Permalink
Employ DeriveVaultToken API and flesh-up DeriveToken
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnayak committed Aug 24, 2016
1 parent 6b83d07 commit 04fab3b
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 112 deletions.
18 changes: 16 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ func NewClient(cfg *config.Config, consulSyncer *consul.Syncer, logger *log.Logg
go c.rpcProxy.Run()

// Start renewing tokens and secrets
go c.vaultClient.Start()
if c.vaultClient != nil {
go c.vaultClient.Start()
}

return c, nil
}
Expand Down Expand Up @@ -1298,15 +1300,27 @@ func (c *Client) setupVaultClient() error {
if c.config.VaultConfig == nil {
return fmt.Errorf("nil vault config")
}

if !c.config.VaultConfig.Enabled {
return nil
}

if c.config.VaultConfig.Token == "" {
return fmt.Errorf("vault token not set")
}

var err error
if c.vaultClient, err = vaultclient.NewVaultClient(c.config.VaultConfig, c.logger); err != nil {
if c.vaultClient, err = vaultclient.NewVaultClient(c.Node(), c.Region(),
c.config.VaultConfig, c.logger, c.config.RPCHandler, c.connPool,
c.rpcProxy); err != nil {
return err
}

if c.vaultClient == nil {
c.logger.Printf("[ERR] client: failed to create vault client")
return fmt.Errorf("failed to create vault client")
}

return nil
}

Expand Down
1 change: 0 additions & 1 deletion client/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/armon/go-metrics"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver"
Expand Down
Loading

0 comments on commit 04fab3b

Please sign in to comment.