1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-15 06:44:31 +00:00

For ByID if transformer returns nil and nil that means 404

This commit is contained in:
Darren Shepherd
2018-06-19 11:25:17 -07:00
parent 0e3bc2dfca
commit 938de659af

View File

@@ -1,6 +1,9 @@
package transform
import (
"fmt"
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
)
@@ -30,11 +33,15 @@ func (s *Store) ByID(apiContext *types.APIContext, schema *types.Schema, id stri
if s.Transformer == nil {
return data, nil
}
return s.Transformer(apiContext, schema, data, &types.QueryOptions{
obj, err := s.Transformer(apiContext, schema, data, &types.QueryOptions{
Options: map[string]string{
"ByID": "true",
},
})
if obj == nil && err == nil {
return obj, httperror.NewAPIError(httperror.NotFound, fmt.Sprintf("%s not found", id))
}
return obj, err
}
func (s *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *types.QueryOptions) (chan map[string]interface{}, error) {