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>
(cherry picked from commit e868cb23c0)
release-3.0
Simon Alling 6 years ago committed by Matt Farina
parent b63f1900f9
commit d2c8c71d50
No known key found for this signature in database
GPG Key ID: 9436E80BFBA46909

@ -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

Loading…
Cancel
Save