Add json schema validation for config file

This commit is contained in:
Jan Eitzinger
2022-09-19 16:16:05 +02:00
parent 9f9462496a
commit e8d7722c42
4 changed files with 398 additions and 14 deletions

View File

@@ -18,6 +18,7 @@ type Kind int
const (
Meta Kind = iota + 1
Data
Config
ClusterCfg
)
@@ -31,6 +32,8 @@ func Validate(k Kind, r io.Reader) (err error) {
s, err = jsonschema.Compile("https://raw.githubusercontent.com/ClusterCockpit/cc-specifications/master/datastructures/job-data.schema.json")
case ClusterCfg:
s, err = jsonschema.Compile("https://raw.githubusercontent.com/ClusterCockpit/cc-specifications/master/datastructures/cluster.schema.json")
case Config:
s, err = jsonschema.Compile("../../configs/config.schema.json")
default:
return fmt.Errorf("unkown schema kind ")
}