getCompiledAWFConfigSchema returns the compiled AWF config schema, compiling once and caching.
()
| 93 | |
| 94 | // getCompiledAWFConfigSchema returns the compiled AWF config schema, compiling once and caching. |
| 95 | func getCompiledAWFConfigSchema() (*jsonschema.Schema, error) { |
| 96 | compiledAWFConfigSchemaOnce.Do(func() { |
| 97 | awfConfigLog.Print("Compiling AWF config schema (first time)") |
| 98 | schemaURL := fmt.Sprintf("https://github.com/github/gh-aw-firewall/releases/download/%s/awf-config.schema.json", constants.DefaultFirewallVersion) |
| 99 | compiledAWFConfigSchema, awfConfigSchemaCompileError = compileSchema(awfConfigSchema, schemaURL) |
| 100 | if awfConfigSchemaCompileError == nil { |
| 101 | awfConfigLog.Print("AWF config schema compiled successfully") |
| 102 | } |
| 103 | }) |
| 104 | return compiledAWFConfigSchema, awfConfigSchemaCompileError |
| 105 | } |
| 106 | |
| 107 | // validateAWFConfigJSON validates the provided AWF config JSON string against the |
| 108 | // embedded AWF config schema. Returns nil if validation passes. |
no test coverage detected