ref
This commit is contained in:
1 parent
0d5094cfb5
commit
e3b5e867b1
1 file changed
+5
-7
+5
-7
@@ -102,13 +102,13 @@ func (cs configService) HandleUpsertConfigCommand(upsertConfig cluster.UpsertCon
|
||||
config := upsertConfig.Config
|
||||
module := state.Modules().GetById(config.ModuleId)
|
||||
if module == nil {
|
||||
return cluster.NewResponseErrorf(codes2.InvalidArgument, "invalid moduleId %s", config.ModuleId)
|
||||
return cluster.NewResponseErrorf(codes2.NotFound, "moduleId %s not found", config.ModuleId)
|
||||
}
|
||||
|
||||
if !upsertConfig.Unsafe {
|
||||
schemaStorage := state.Schemas().GetByModuleIds([]string{config.ModuleId})
|
||||
if len(schemaStorage) == 0 {
|
||||
return cluster.NewResponseErrorf(codes2.NotFound, "schema for moduleId %s not found", config.Id)
|
||||
return cluster.NewResponseErrorf(codes2.NotFound, "schema for moduleId %s not found", config.ModuleId)
|
||||
}
|
||||
|
||||
dataForValidate := cs.CompileConfig(config.Data, state, config.CommonConfigs...)
|
||||
@@ -189,16 +189,14 @@ func (configService) validateSchema(schema entity.ConfigSchema, data map[string]
|
||||
documentLoader := gojsonschema.NewGoLoader(data)
|
||||
if result, err := gojsonschema.Validate(schemaLoader, documentLoader); err != nil {
|
||||
return false, err
|
||||
} else if len(result.Errors()) > 0 {
|
||||
} else if result.Valid() {
|
||||
return true, nil
|
||||
} else {
|
||||
desc := make(map[string]string)
|
||||
for _, value := range result.Errors() {
|
||||
desc[value.Field()] = value.Description()
|
||||
}
|
||||
return false, validationSchemaError{Description: desc}
|
||||
} else if result.Valid() {
|
||||
return true, nil
|
||||
} else {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user