Skip to content

Commit

Permalink
always set purgeFunc
Browse files Browse the repository at this point in the history
purgeFunc cannot be nil, so ensure it's set to a no-op function in
tests.
  • Loading branch information
Mahmood Ali committed May 22, 2020
1 parent c781608 commit abda1a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nomad/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ type consulACLsAPI struct {
}

func NewConsulACLsAPI(aclClient consul.ACLsAPI, logger hclog.Logger, purgeFunc PurgeSITokenAccessorFunc) *consulACLsAPI {
if purgeFunc == nil {
purgeFunc = func([]*structs.SITokenAccessor) error { return nil }
}

c := &consulACLsAPI{
aclClient: aclClient,
limiter: rate.NewLimiter(siTokenRequestRateLimit, int(siTokenRequestRateLimit)),
Expand Down
3 changes: 3 additions & 0 deletions nomad/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ func NewVaultClient(c *config.VaultConfig, logger log.Logger, purgeFn PurgeVault
if logger == nil {
return nil, fmt.Errorf("must pass valid logger")
}
if purgeFn == nil {
purgeFn = func(accessors []*structs.VaultAccessor) error { return nil }
}

v := &vaultClient{
config: c,
Expand Down

0 comments on commit abda1a1

Please sign in to comment.