validateRepoConfigJSON validates raw JSON bytes against the repo config schema.
(data []byte, filePath string)
| 251 | |
| 252 | // validateRepoConfigJSON validates raw JSON bytes against the repo config schema. |
| 253 | func validateRepoConfigJSON(data []byte, filePath string) error { |
| 254 | repoConfigLog.Printf("Validating repo config JSON schema: %s (%d bytes)", filePath, len(data)) |
| 255 | schema, err := parser.GetCompiledRepoConfigSchema() |
| 256 | if err != nil { |
| 257 | return fmt.Errorf("failed to compile repo config schema: %w", err) |
| 258 | } |
| 259 | |
| 260 | var doc any |
| 261 | if err := json.Unmarshal(data, &doc); err != nil { |
| 262 | return fmt.Errorf("failed to parse %s as JSON: %w", filePath, err) |
| 263 | } |
| 264 | |
| 265 | if err := schema.Validate(doc); err != nil { |
| 266 | repoConfigLog.Printf("Repo config schema validation failed: %v", err) |
| 267 | return fmt.Errorf("invalid %s: %w", RepoConfigFileName, err) |
| 268 | } |
| 269 | |
| 270 | repoConfigLog.Print("Repo config JSON schema validation passed") |
| 271 | return nil |
| 272 | } |
| 273 | |
| 274 | func validateRepoConfigValues(cfg *RepoConfig) error { |
| 275 | if cfg == nil { |
no test coverage detected