Commit 1412a88c authored by Matt Butcher's avatar Matt Butcher

fix(tiller): stop returning deleted releases for list

parent e3967e57
...@@ -70,15 +70,15 @@ func (m *Memory) Delete(name string) (*release.Release, error) { ...@@ -70,15 +70,15 @@ func (m *Memory) Delete(name string) (*release.Release, error) {
return rel, nil return rel, nil
} }
// List returns all releases. // List returns all releases whose status is not Status_DELETED.
func (m *Memory) List() ([]*release.Release, error) { func (m *Memory) List() ([]*release.Release, error) {
m.RLock() m.RLock()
defer m.RUnlock() defer m.RUnlock()
buf := make([]*release.Release, len(m.releases)) buf := []*release.Release{}
i := 0
for _, v := range m.releases { for _, v := range m.releases {
buf[i] = v if v.Info.Status.Code != release.Status_DELETED {
i++ buf = append(buf, v)
}
} }
return buf, nil return buf, nil
} }
......
...@@ -72,7 +72,18 @@ func TestList(t *testing.T) { ...@@ -72,7 +72,18 @@ func TestList(t *testing.T) {
rels := []string{"a", "b", "c"} rels := []string{"a", "b", "c"}
for _, k := range rels { for _, k := range rels {
ms.Create(&release.Release{Name: k}) ms.Create(&release.Release{
Name: k,
Info: &release.Info{
Status: &release.Status{Code: release.Status_UNKNOWN},
},
})
ms.Create(&release.Release{
Name: "deleted-should-not-show-up",
Info: &release.Info{
Status: &release.Status{Code: release.Status_DELETED},
},
})
} }
l, err := ms.List() l, err := ms.List()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment