Skip to content

Commit

Permalink
Optimise ListRaw for S3-KMS backend (#296)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Irvine <[email protected]>
  • Loading branch information
djrodgerspryor and nickatsegment authored Mar 18, 2021
1 parent b70615e commit 2cf275e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions store/s3storeKMS.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,21 @@ func (s *S3KMSStore) List(service string, includeValues bool) ([]Secret, error)
return secrets, nil
}

// ListRaw returns RawSecrets by extracting them from the index file. It only ever uses the
// index file; it never consults the actual secrets, so if the index file is out of sync, these
// results will reflect that.
func (s *S3KMSStore) ListRaw(service string) ([]RawSecret, error) {

secretList, err := s.List(service, true)
index, err := s.readLatest(service)
if err != nil {
return []RawSecret{}, err
}

// Read raw secrets directly from the index file (which caches the latest values)
secrets := []RawSecret{}
for _, secret := range secretList {
for key := range index.Latest {
s := RawSecret{
Key: fmt.Sprintf("/%s/%s", service, secret.Meta.Key),
Value: *secret.Value,
Key: fmt.Sprintf("/%s/%s", service, key),
Value: index.Latest[key].Value,
}
secrets = append(secrets, s)
}
Expand Down

0 comments on commit 2cf275e

Please sign in to comment.