refactory to move trim/apply default into schema.go (#33754)

* refactory to move trim/apply default into schema.go

* fix comments

* move schema test outside of load folder
This commit is contained in:
ying-jeanne
2021-05-12 15:38:00 +08:00
committed by GitHub
parent 679001051b
commit a7ea0ca849
12 changed files with 250 additions and 285 deletions
+2 -2
View File
@@ -62,7 +62,7 @@ func (rs *SchemaLoaderService) DashboardApplyDefaults(input *simplejson.Json) (*
val = removeNils(val)
data, _ := json.Marshal(val)
dsSchema := schema.Find(rs.DashFamily, schema.Latest())
result, err := dsSchema.ApplyDefaults(schema.Resource{Value: data})
result, err := schema.ApplyDefaults(schema.Resource{Value: data}, dsSchema.CUE())
if err != nil {
return input, err
}
@@ -83,7 +83,7 @@ func (rs *SchemaLoaderService) DashboardTrimDefaults(input simplejson.Json) (sim
return input, err
}
// spew.Dump(dsSchema)
result, err := dsSchema.TrimDefaults(schema.Resource{Value: data})
result, err := schema.TrimDefaults(schema.Resource{Value: data}, dsSchema.CUE())
if err != nil {
return input, err
}