Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Ensures listing secrets excludes deleted secrets without content.
Browse files Browse the repository at this point in the history
  • Loading branch information
alokmenghrajani committed Jul 12, 2016
1 parent 7afb609 commit 75ad4ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cache_test.go
Expand Up @@ -333,6 +333,7 @@ func TestCacheSecretListUsesClientOverCache(t *testing.T) {
list := cache.SecretList()
assert.Len(list, 2)
assert.Contains(list, *fixture1)
assert.Contains(list, *fixture2)
assert.Equal(2, cache.Len())

// Advance clock, cache should now have only 1 element
Expand Down
7 changes: 5 additions & 2 deletions secretmap.go
Expand Up @@ -113,10 +113,13 @@ func (m *SecretMap) Replace(m2 *SecretMap) {
// Delete existing entries
expire := m.getNow().Add(m.timeouts.DeletionDelay)
for k, v := range m.m {
if v.ttl.IsZero() {
// Only hold on to secrets which actually have data.
if len(v.Secret.Content) == 0 {
delete(m.m, k)
} else if v.ttl.IsZero() {
v.ttl = expire
m.m[k] = v
}
m.m[k] = v
}

// Replace values with data from m2
Expand Down

0 comments on commit 75ad4ae

Please sign in to comment.