ref(pkg/storage): Refactor Deployed and DeployedAll (#7374)

The error returned from DeployedAll will never contain "not found".

The error returned at the end of Deployed is already known to be nil,
and we never want to return ls[0] together with a non-nil error anyway.

Signed-off-by: Simon Alling <alling.simon@gmail.com>
This commit is contained in:
Simon Alling
2020-01-15 16:51:04 +01:00
committed by Martin Hickey
parent e84b61b2db
commit e868cb23c0

View File

@@ -112,9 +112,6 @@ func (s *Storage) ListDeployed() ([]*rspb.Release, error) {
func (s *Storage) Deployed(name string) (*rspb.Release, error) {
ls, err := s.DeployedAll(name)
if err != nil {
if strings.Contains(err.Error(), "not found") {
return nil, errors.Errorf("%q has no deployed releases", name)
}
return nil, err
}
@@ -122,7 +119,7 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) {
return nil, errors.Errorf("%q has no deployed releases", name)
}
return ls[0], err
return ls[0], nil
}
// DeployedAll returns all deployed releases with the provided name, or