ref(pkg/storage): Refactor Deployed and DeployedAll

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>
pull/7374/head
Simon Alling 6 years ago
parent f35719a62a
commit 157bc207d5

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

Loading…
Cancel
Save