@ -41,7 +41,7 @@ type Storage struct {
// if the storage driver failed to fetch the release, or the
// if the storage driver failed to fetch the release, or the
// release identified by the key, version pair does not exist.
// release identified by the key, version pair does not exist.
func ( s * Storage ) Get ( name string , version int32 ) ( * rspb . Release , error ) {
func ( s * Storage ) Get ( name string , version int32 ) ( * rspb . Release , error ) {
s . Log ( " G etting release %q", makeKey ( name , version ) )
s . Log ( " g etting release %q", makeKey ( name , version ) )
return s . Driver . Get ( makeKey ( name , version ) )
return s . Driver . Get ( makeKey ( name , version ) )
}
}
@ -49,7 +49,7 @@ func (s *Storage) Get(name string, version int32) (*rspb.Release, error) {
// error is returned if the storage driver failed to store the
// error is returned if the storage driver failed to store the
// release, or a release with identical an key already exists.
// release, or a release with identical an key already exists.
func ( s * Storage ) Create ( rls * rspb . Release ) error {
func ( s * Storage ) Create ( rls * rspb . Release ) error {
s . Log ( " C reating release %q", makeKey ( rls . Name , rls . Version ) )
s . Log ( " c reating release %q", makeKey ( rls . Name , rls . Version ) )
return s . Driver . Create ( makeKey ( rls . Name , rls . Version ) , rls )
return s . Driver . Create ( makeKey ( rls . Name , rls . Version ) , rls )
}
}
@ -57,7 +57,7 @@ func (s *Storage) Create(rls *rspb.Release) error {
// storage backend fails to update the release or if the release
// storage backend fails to update the release or if the release
// does not exist.
// does not exist.
func ( s * Storage ) Update ( rls * rspb . Release ) error {
func ( s * Storage ) Update ( rls * rspb . Release ) error {
s . Log ( " U pdating release %q", makeKey ( rls . Name , rls . Version ) )
s . Log ( " u pdating release %q", makeKey ( rls . Name , rls . Version ) )
return s . Driver . Update ( makeKey ( rls . Name , rls . Version ) , rls )
return s . Driver . Update ( makeKey ( rls . Name , rls . Version ) , rls )
}
}
@ -65,21 +65,21 @@ func (s *Storage) Update(rls *rspb.Release) error {
// the storage backend fails to delete the release or if the release
// the storage backend fails to delete the release or if the release
// does not exist.
// does not exist.
func ( s * Storage ) Delete ( name string , version int32 ) ( * rspb . Release , error ) {
func ( s * Storage ) Delete ( name string , version int32 ) ( * rspb . Release , error ) {
s . Log ( " D eleting release %q", makeKey ( name , version ) )
s . Log ( " d eleting release %q", makeKey ( name , version ) )
return s . Driver . Delete ( makeKey ( name , version ) )
return s . Driver . Delete ( makeKey ( name , version ) )
}
}
// ListReleases returns all releases from storage. An error is returned if the
// ListReleases returns all releases from storage. An error is returned if the
// storage backend fails to retrieve the releases.
// storage backend fails to retrieve the releases.
func ( s * Storage ) ListReleases ( ) ( [ ] * rspb . Release , error ) {
func ( s * Storage ) ListReleases ( ) ( [ ] * rspb . Release , error ) {
s . Log ( " L isting all releases in storage")
s . Log ( " l isting all releases in storage")
return s . Driver . List ( func ( _ * rspb . Release ) bool { return true } )
return s . Driver . List ( func ( _ * rspb . Release ) bool { return true } )
}
}
// ListDeleted returns all releases with Status == DELETED. An error is returned
// ListDeleted returns all releases with Status == DELETED. An error is returned
// if the storage backend fails to retrieve the releases.
// if the storage backend fails to retrieve the releases.
func ( s * Storage ) ListDeleted ( ) ( [ ] * rspb . Release , error ) {
func ( s * Storage ) ListDeleted ( ) ( [ ] * rspb . Release , error ) {
s . Log ( " L isting deleted releases in storage")
s . Log ( " l isting deleted releases in storage")
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return relutil . StatusFilter ( rspb . Status_DELETED ) . Check ( rls )
return relutil . StatusFilter ( rspb . Status_DELETED ) . Check ( rls )
} )
} )
@ -88,7 +88,7 @@ func (s *Storage) ListDeleted() ([]*rspb.Release, error) {
// ListDeployed returns all releases with Status == DEPLOYED. An error is returned
// ListDeployed returns all releases with Status == DEPLOYED. An error is returned
// if the storage backend fails to retrieve the releases.
// if the storage backend fails to retrieve the releases.
func ( s * Storage ) ListDeployed ( ) ( [ ] * rspb . Release , error ) {
func ( s * Storage ) ListDeployed ( ) ( [ ] * rspb . Release , error ) {
s . Log ( " L isting all deployed releases in storage")
s . Log ( " l isting all deployed releases in storage")
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return relutil . StatusFilter ( rspb . Status_DEPLOYED ) . Check ( rls )
return relutil . StatusFilter ( rspb . Status_DEPLOYED ) . Check ( rls )
} )
} )
@ -98,7 +98,7 @@ func (s *Storage) ListDeployed() ([]*rspb.Release, error) {
// (filter0 && filter1 && ... && filterN), i.e. a Release is included in the results
// (filter0 && filter1 && ... && filterN), i.e. a Release is included in the results
// if and only if all filters return true.
// if and only if all filters return true.
func ( s * Storage ) ListFilterAll ( fns ... relutil . FilterFunc ) ( [ ] * rspb . Release , error ) {
func ( s * Storage ) ListFilterAll ( fns ... relutil . FilterFunc ) ( [ ] * rspb . Release , error ) {
s . Log ( " L isting all releases with filter")
s . Log ( " l isting all releases with filter")
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return relutil . All ( fns ... ) . Check ( rls )
return relutil . All ( fns ... ) . Check ( rls )
} )
} )
@ -108,7 +108,7 @@ func (s *Storage) ListFilterAll(fns ...relutil.FilterFunc) ([]*rspb.Release, err
// (filter0 || filter1 || ... || filterN), i.e. a Release is included in the results
// (filter0 || filter1 || ... || filterN), i.e. a Release is included in the results
// if at least one of the filters returns true.
// if at least one of the filters returns true.
func ( s * Storage ) ListFilterAny ( fns ... relutil . FilterFunc ) ( [ ] * rspb . Release , error ) {
func ( s * Storage ) ListFilterAny ( fns ... relutil . FilterFunc ) ( [ ] * rspb . Release , error ) {
s . Log ( " L isting any releases with filter")
s . Log ( " l isting any releases with filter")
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return s . Driver . List ( func ( rls * rspb . Release ) bool {
return relutil . Any ( fns ... ) . Check ( rls )
return relutil . Any ( fns ... ) . Check ( rls )
} )
} )
@ -117,7 +117,7 @@ func (s *Storage) ListFilterAny(fns ...relutil.FilterFunc) ([]*rspb.Release, err
// Deployed returns the deployed release with the provided release name, or
// Deployed returns the deployed release with the provided release name, or
// returns ErrReleaseNotFound if not found.
// returns ErrReleaseNotFound if not found.
func ( s * Storage ) Deployed ( name string ) ( * rspb . Release , error ) {
func ( s * Storage ) Deployed ( name string ) ( * rspb . Release , error ) {
s . Log ( " G etting deployed release from %q history", name )
s . Log ( " g etting deployed release from %q history", name )
ls , err := s . Driver . Query ( map [ string ] string {
ls , err := s . Driver . Query ( map [ string ] string {
"NAME" : name ,
"NAME" : name ,
@ -137,14 +137,14 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) {
// History returns the revision history for the release with the provided name, or
// History returns the revision history for the release with the provided name, or
// returns ErrReleaseNotFound if no such release name exists.
// returns ErrReleaseNotFound if no such release name exists.
func ( s * Storage ) History ( name string ) ( [ ] * rspb . Release , error ) {
func ( s * Storage ) History ( name string ) ( [ ] * rspb . Release , error ) {
s . Log ( " G etting release history for %q", name )
s . Log ( " g etting release history for %q", name )
return s . Driver . Query ( map [ string ] string { "NAME" : name , "OWNER" : "TILLER" } )
return s . Driver . Query ( map [ string ] string { "NAME" : name , "OWNER" : "TILLER" } )
}
}
// Last fetches the last revision of the named release.
// Last fetches the last revision of the named release.
func ( s * Storage ) Last ( name string ) ( * rspb . Release , error ) {
func ( s * Storage ) Last ( name string ) ( * rspb . Release , error ) {
s . Log ( " G etting last revision of %q", name )
s . Log ( " g etting last revision of %q", name )
h , err := s . History ( name )
h , err := s . History ( name )
if err != nil {
if err != nil {
return nil , err
return nil , err
@ -159,6 +159,7 @@ func (s *Storage) Last(name string) (*rspb.Release, error) {
// LockRelease gains a mutually exclusive access to a release via a mutex.
// LockRelease gains a mutually exclusive access to a release via a mutex.
func ( s * Storage ) LockRelease ( name string ) error {
func ( s * Storage ) LockRelease ( name string ) error {
s . Log ( "locking release %s" , name )
s . releaseLocksLock . Lock ( )
s . releaseLocksLock . Lock ( )
defer s . releaseLocksLock . Unlock ( )
defer s . releaseLocksLock . Unlock ( )
@ -191,6 +192,7 @@ func (s *Storage) LockRelease(name string) error {
// UnlockRelease releases a mutually exclusive access to a release.
// UnlockRelease releases a mutually exclusive access to a release.
// If release doesn't exist or wasn't previously locked - the unlock will pass
// If release doesn't exist or wasn't previously locked - the unlock will pass
func ( s * Storage ) UnlockRelease ( name string ) {
func ( s * Storage ) UnlockRelease ( name string ) {
s . Log ( "unlocking release %s" , name )
s . releaseLocksLock . Lock ( )
s . releaseLocksLock . Lock ( )
defer s . releaseLocksLock . Unlock ( )
defer s . releaseLocksLock . Unlock ( )