1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-01 23:36:58 +00:00

Many enhancements

This commit is contained in:
Darren Shepherd
2017-12-11 20:58:43 -07:00
parent eef2c6ee6e
commit 406c0d9999
12 changed files with 63 additions and 47 deletions

View File

@@ -6,7 +6,7 @@ import (
"github.com/rancher/norman/types"
)
func ParseAndValidateBody(apiContext *types.APIContext) (map[string]interface{}, error) {
func ParseAndValidateBody(apiContext *types.APIContext, create bool) (map[string]interface{}, error) {
data, err := parse.Body(apiContext.Request)
if err != nil {
return nil, err
@@ -14,7 +14,11 @@ func ParseAndValidateBody(apiContext *types.APIContext) (map[string]interface{},
b := builder.NewBuilder(apiContext)
data, err = b.Construct(apiContext.Schema, data, builder.Create)
op := builder.Create
if !create {
op = builder.Update
}
data, err = b.Construct(apiContext.Schema, data, op)
if err != nil {
return nil, err
}