Make storage NotFoundError available
This commit is contained in:
@@ -31,7 +31,7 @@ func (store *storage) SessionGet(id string) (*types.Session, error) {
|
|||||||
|
|
||||||
s, found := store.db.Sessions[id]
|
s, found := store.db.Sessions[id]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, notFound
|
return nil, NotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
@@ -98,7 +98,7 @@ func (store *storage) InstanceGet(name string) (*types.Instance, error) {
|
|||||||
|
|
||||||
i := store.db.Instances[name]
|
i := store.db.Instances[name]
|
||||||
if i == nil {
|
if i == nil {
|
||||||
return nil, notFound
|
return nil, NotFoundError
|
||||||
}
|
}
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ func (store *storage) InstancePut(instance *types.Instance) error {
|
|||||||
|
|
||||||
_, found := store.db.Sessions[string(instance.SessionId)]
|
_, found := store.db.Sessions[string(instance.SessionId)]
|
||||||
if !found {
|
if !found {
|
||||||
return notFound
|
return NotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
store.db.Instances[instance.Name] = instance
|
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)]
|
_, found := store.db.Sessions[string(instance.SessionId)]
|
||||||
if !found {
|
if !found {
|
||||||
return notFound
|
return NotFoundError
|
||||||
}
|
}
|
||||||
store.db.WindowsInstances[instance.Id] = instance
|
store.db.WindowsInstances[instance.Id] = instance
|
||||||
found = false
|
found = false
|
||||||
@@ -233,7 +233,7 @@ func (store *storage) ClientGet(id string) (*types.Client, error) {
|
|||||||
|
|
||||||
i := store.db.Clients[id]
|
i := store.db.Clients[id]
|
||||||
if i == nil {
|
if i == nil {
|
||||||
return nil, notFound
|
return nil, NotFoundError
|
||||||
}
|
}
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ func (store *storage) ClientPut(client *types.Client) error {
|
|||||||
|
|
||||||
_, found := store.db.Sessions[string(client.SessionId)]
|
_, found := store.db.Sessions[string(client.SessionId)]
|
||||||
if !found {
|
if !found {
|
||||||
return notFound
|
return NotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
store.db.Clients[client.Id] = client
|
store.db.Clients[client.Id] = client
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import (
|
|||||||
"github.com/play-with-docker/play-with-docker/pwd/types"
|
"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 {
|
func NotFound(e error) bool {
|
||||||
return e == notFound
|
return e == NotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
type StorageApi interface {
|
type StorageApi interface {
|
||||||
|
|||||||
Reference in New Issue
Block a user