Skip to content

Commit

Permalink
Apply review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff committed Mar 3, 2020
1 parent 19cc57b commit 9300f40
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions builtin/credential/approle/path_tidy_user_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (b *backend) tidySecretID(ctx context.Context, req *logical.Request) (*logi
return resp, nil
}

go b.tidySecretIDbackground(req.Storage)
go b.tidySecretIDinternal(req.Storage)

resp := &logical.Response{}
resp.AddWarning("Tidy operation successfully started. Any information from the operation will be printed to Vault's server logs.")
Expand All @@ -53,7 +53,7 @@ type tidyHelperSecretIDAccessor struct {
saltedSecretIDAccessor string
}

func (b *backend) tidySecretIDbackground(s logical.Storage) {
func (b *backend) tidySecretIDinternal(s logical.Storage) {
defer atomic.StoreUint32(b.tidySecretIDCASGuard, 0)

logger := b.Logger().Named("tidy")
Expand All @@ -74,13 +74,6 @@ func (b *backend) tidySecretIDbackground(s logical.Storage) {
}

tidyFunc := func(secretIDPrefixToUse, accessorIDPrefixToUse string) error {
logger.Trace("listing role HMACs", "prefix", secretIDPrefixToUse)

roleNameHMACs, err := s.List(ctx, secretIDPrefixToUse)
if err != nil {
return err
}

logger.Trace("listing accessors", "prefix", accessorIDPrefixToUse)

// List all the accessors and add them all to a map
Expand Down Expand Up @@ -176,6 +169,13 @@ func (b *backend) tidySecretIDbackground(s logical.Storage) {
return nil
}

logger.Trace("listing role HMACs", "prefix", secretIDPrefixToUse)

roleNameHMACs, err := s.List(ctx, secretIDPrefixToUse)
if err != nil {
return err
}

for _, roleNameHMAC := range roleNameHMACs {
logger.Trace("listing secret ID HMACs", "role_hmac", roleNameHMAC)
secretIDHMACs, err := s.List(ctx, fmt.Sprintf("%s%s", secretIDPrefixToUse, roleNameHMAC))
Expand Down

0 comments on commit 9300f40

Please sign in to comment.