Make storage NotFoundError available

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-01 20:29:54 -03:00
parent 954c52471b
commit d8ec0eb754
2 changed files with 8 additions and 8 deletions

View File

@@ -31,7 +31,7 @@ func (store *storage) SessionGet(id string) (*types.Session, error) {
s, found := store.db.Sessions[id]
if !found {
return nil, notFound
return nil, NotFoundError
}
return s, nil
@@ -98,7 +98,7 @@ func (store *storage) InstanceGet(name string) (*types.Instance, error) {
i := store.db.Instances[name]
if i == nil {
return nil, notFound
return nil, NotFoundError
}
return i, nil
}
@@ -109,7 +109,7 @@ func (store *storage) InstancePut(instance *types.Instance) error {
_, found := store.db.Sessions[string(instance.SessionId)]
if !found {
return notFound
return NotFoundError
}
store.db.Instances[instance.Name] = instance
@@ -188,7 +188,7 @@ func (store *storage) WindowsInstancePut(instance *types.WindowsInstance) error
_, found := store.db.Sessions[string(instance.SessionId)]
if !found {
return notFound
return NotFoundError
}
store.db.WindowsInstances[instance.Id] = instance
found = false
@@ -233,7 +233,7 @@ func (store *storage) ClientGet(id string) (*types.Client, error) {
i := store.db.Clients[id]
if i == nil {
return nil, notFound
return nil, NotFoundError
}
return i, nil
}
@@ -243,7 +243,7 @@ func (store *storage) ClientPut(client *types.Client) error {
_, found := store.db.Sessions[string(client.SessionId)]
if !found {
return notFound
return NotFoundError
}
store.db.Clients[client.Id] = client

View File

@@ -6,10 +6,10 @@ import (
"github.com/play-with-docker/play-with-docker/pwd/types"
)
var notFound = errors.New("NotFound")
var NotFoundError = errors.New("NotFound")
func NotFound(e error) bool {
return e == notFound
return e == NotFoundError
}
type StorageApi interface {