mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fix datastore error for inexistent app (#493)
* fix datastore error inexistent app * fix get route error handling * fix API errors handling and tests
This commit is contained in:
committed by
Travis Reeder
parent
5a91710dbf
commit
a80fe9c897
@@ -229,6 +229,8 @@ func (ds *BoltDatastore) GetApp(ctx context.Context, name string) (*models.App,
|
||||
return err
|
||||
}
|
||||
res = app
|
||||
} else {
|
||||
return models.ErrAppsNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -239,15 +241,11 @@ func (ds *BoltDatastore) GetApp(ctx context.Context, name string) (*models.App,
|
||||
}
|
||||
|
||||
func (ds *BoltDatastore) getRouteBucketForApp(tx *bolt.Tx, appName string) (*bolt.Bucket, error) {
|
||||
var err error
|
||||
// todo: should this be reversed? Make a bucket for each app that contains sub buckets for routes, etc
|
||||
bp := tx.Bucket(ds.routesBucket)
|
||||
b := bp.Bucket([]byte(appName))
|
||||
if b == nil {
|
||||
b, err = bp.CreateBucket([]byte(appName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, models.ErrAppsNotFound
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
@@ -418,6 +416,10 @@ func (ds *BoltDatastore) GetRoute(ctx context.Context, appName, routePath string
|
||||
}
|
||||
|
||||
v := b.Get([]byte(routePath))
|
||||
if v == nil {
|
||||
return models.ErrRoutesNotFound
|
||||
}
|
||||
|
||||
if v != nil {
|
||||
err = json.Unmarshal(v, &route)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user