mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-27 05:49:04 +01:00
Refactor
This commit is contained in:
parent
ba7cc9168e
commit
2502989ca2
@ -28,12 +28,13 @@ const (
|
|||||||
//go:embed schemas/*
|
//go:embed schemas/*
|
||||||
var schemaFiles embed.FS
|
var schemaFiles embed.FS
|
||||||
|
|
||||||
func Validate(k Kind, r io.Reader) (err error) {
|
func Validate(k Kind, r io.Reader) error {
|
||||||
jsonschema.Loaders["embedfs"] = func(s string) (io.ReadCloser, error) {
|
jsonschema.Loaders["embedfs"] = func(s string) (io.ReadCloser, error) {
|
||||||
f := filepath.Join("schemas", strings.Split(s, "//")[1])
|
f := filepath.Join("schemas", strings.Split(s, "//")[1])
|
||||||
return schemaFiles.Open(f)
|
return schemaFiles.Open(f)
|
||||||
}
|
}
|
||||||
var s *jsonschema.Schema
|
var s *jsonschema.Schema
|
||||||
|
var err error
|
||||||
|
|
||||||
switch k {
|
switch k {
|
||||||
case Meta:
|
case Meta:
|
||||||
@ -54,7 +55,7 @@ func Validate(k Kind, r io.Reader) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var v interface{}
|
var v interface{}
|
||||||
if err := json.NewDecoder(r).Decode(&v); err != nil {
|
if err = json.NewDecoder(r).Decode(&v); err != nil {
|
||||||
log.Warnf("Error while decoding raw json schema: %#v", err)
|
log.Warnf("Error while decoding raw json schema: %#v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user