|
|
|
@ -18,7 +18,6 @@ package storage // import "helm.sh/helm/v3/pkg/storage"
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
|
|
|
|
@ -115,10 +114,6 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(ls) == 0 {
|
|
|
|
|
return nil, errors.Errorf("%q has no deployed releases", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If executed concurrently, Helm's database gets corrupted
|
|
|
|
|
// and multiple releases are DEPLOYED. Take the latest.
|
|
|
|
|
relutil.Reverse(ls, relutil.SortByRevision)
|
|
|
|
@ -136,13 +131,13 @@ func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) {
|
|
|
|
|
"owner": "helm",
|
|
|
|
|
"status": "deployed",
|
|
|
|
|
})
|
|
|
|
|
if err == nil {
|
|
|
|
|
return ls, nil
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if strings.Contains(err.Error(), "not found") {
|
|
|
|
|
return nil, errors.Errorf("%q has no deployed releases", name)
|
|
|
|
|
if len(ls) == 0 {
|
|
|
|
|
return nil, driver.ErrReleaseNotFound
|
|
|
|
|
}
|
|
|
|
|
return nil, err
|
|
|
|
|
return ls, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// History returns the revision history for the release with the provided name, or
|
|
|
|
@ -150,7 +145,17 @@ func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) {
|
|
|
|
|
func (s *Storage) History(name string) ([]*rspb.Release, error) {
|
|
|
|
|
s.Log("getting release history for %q", name)
|
|
|
|
|
|
|
|
|
|
return s.Driver.Query(map[string]string{"name": name, "owner": "helm"})
|
|
|
|
|
ls, err := s.Driver.Query(map[string]string{
|
|
|
|
|
"name": name,
|
|
|
|
|
"owner": "helm",
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if len(ls) == 0 {
|
|
|
|
|
return nil, driver.ErrReleaseNotFound
|
|
|
|
|
}
|
|
|
|
|
return ls, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// removeLeastRecent removes items from history until the lengh number of releases
|
|
|
|
@ -231,9 +236,6 @@ func (s *Storage) Last(name string) (*rspb.Release, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if len(h) == 0 {
|
|
|
|
|
return nil, errors.Errorf("no revision for release %q", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relutil.Reverse(h, relutil.SortByRevision)
|
|
|
|
|
return h[0], nil
|
|
|
|
|