Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.

Commit afd210e

Browse files
committed
Fix schema location and tolerate loading errors
1 parent 32a7439 commit afd210e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ func readConfiguration(configFile *string, reader fs.FileReader) Configuration {
6262
}
6363

6464
func validateConfiguration(reader fs.FileReader, configFile *string) {
65+
schema := loadSchema()
66+
if schema == nil {
67+
return
68+
}
6569
jsonSchemaValidator := JsonSchemaValidator{
66-
Schema: loadSchema(),
70+
Schema: schema,
6771
FileReader: reader,
6872
}
6973
validationError := jsonSchemaValidator.Validate("file://" + *configFile)
@@ -73,9 +77,10 @@ func validateConfiguration(reader fs.FileReader, configFile *string) {
7377
}
7478

7579
func loadSchema() *jsonsch.Schema {
76-
schema, err := jsonsch.NewSchema(jsonsch.NewReferenceLoader("file://docs/schema.json"))
80+
schema, err := jsonsch.NewSchema(jsonsch.NewReferenceLoader("https://fbiville.github.io/headache/v1.0.0-M01/schema.json"))
7781
if err != nil {
78-
log.Fatalf("headache configuration error, cannot load JSON schema\n\t%v\n", err)
82+
log.Printf("headache configuration warning: cannot load schema, skipping configuration validation. See reason below:\n\t%v\n", err)
83+
return nil
7984
}
8085
return schema
8186
}

0 commit comments

Comments
 (0)