-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: #41 Signed-off-by: Neil Armstrong <[email protected]>
- Loading branch information
1 parent
5e3bdca
commit 6dbac57
Showing
2 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
"$schema": https://json-schema.org/draft/2020-12/schema# | ||
title: CDBA Configuration Schema | ||
type: object | ||
properties: | ||
devices: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
board: | ||
type: string | ||
|
||
name: | ||
type: string | ||
|
||
description: | ||
type: string | ||
|
||
console: | ||
type: string | ||
pattern: "^/dev/.*$" | ||
|
||
fastboot: | ||
type: string | ||
pattern: "^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$" | ||
|
||
fastboot_set_active: | ||
type: boolean | ||
|
||
broken_fastboot_boot: | ||
type: boolean | ||
|
||
usb_always_on: | ||
type: boolean | ||
|
||
fastboot_key_timeout: | ||
type: integer | ||
minimum: 1 | ||
|
||
cdba: | ||
type: string | ||
pattern: "^/dev/.*$" | ||
|
||
conmux: | ||
type: string | ||
pattern: "^/dev/.*$" | ||
|
||
external: | ||
type: string | ||
|
||
ppps_path: | ||
type: string | ||
|
||
ppps3_path: | ||
type: string | ||
|
||
qcomlt_debug_board: | ||
type: string | ||
pattern: "^/dev/.*$" | ||
|
||
voltage: | ||
type: integer | ||
|
||
alpaca: | ||
type: string | ||
pattern: "^/dev/.*$" | ||
|
||
users: | ||
type: array | ||
uniqueItems: true | ||
minItems: 1 | ||
items: | ||
type: string | ||
|
||
ftdi_gpio: | ||
oneOf: | ||
- type: string | ||
pattern: "^s:0x[0-9A-f][0-9a-f][0-9a-f][0-9a-f]:0x[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:FT[0-9a-zA-Z]{6};[A-D](;(POWER|FASTBOOT_KEY|POWER_KEY|USB_DISCONNECT),[0-7],(ACTIVE_HIGH|ACTIVE_LOW)){1,4}$" | ||
|
||
- type: object | ||
properties: | ||
description: | ||
type: string | ||
pattern: "^s:0x[0-9A-f][0-9a-f][0-9a-f][0-9a-f]:0x[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:FT[0-9a-zA-Z]{6}$" | ||
interface: | ||
enum: | ||
- A | ||
- B | ||
- C | ||
- D | ||
gpios: | ||
type: array | ||
unevaluatedItems: false | ||
minItems: 1 | ||
prefixItems: | ||
- type: object | ||
properties: | ||
power: | ||
type: object | ||
properties: | ||
line: | ||
type: integer | ||
minimum: 0 | ||
maximum: 7 | ||
active_low: | ||
type: boolean | ||
required: | ||
- line | ||
- type: object | ||
properties: | ||
fastboot_key: | ||
type: object | ||
properties: | ||
line: | ||
type: integer | ||
minimum: 0 | ||
maximum: 7 | ||
active_low: | ||
type: boolean | ||
required: | ||
- line | ||
- type: object | ||
properties: | ||
power_key: | ||
type: object | ||
properties: | ||
line: | ||
type: integer | ||
minimum: 0 | ||
maximum: 7 | ||
active_low: | ||
type: boolean | ||
required: | ||
- line | ||
- type: object | ||
properties: | ||
usb_disconnect: | ||
type: object | ||
properties: | ||
line: | ||
type: integer | ||
minimum: 0 | ||
maximum: 7 | ||
active_low: | ||
type: boolean | ||
required: | ||
- line | ||
- type: object | ||
properties: | ||
output_enable: | ||
type: object | ||
properties: | ||
line: | ||
type: integer | ||
minimum: 0 | ||
maximum: 7 | ||
active_low: | ||
type: boolean | ||
required: | ||
- line | ||
required: | ||
- description | ||
- interface | ||
- gpios | ||
|
||
local_gpio: | ||
type: array | ||
unevaluatedItems: false | ||
minItems: 1 | ||
prefixItems: | ||
- type: object | ||
properties: | ||
power: | ||
type: object | ||
properties: | ||
chip: | ||
type: string | ||
pattern: "^gpiochip[0-9]+$" | ||
line: | ||
type: integer | ||
minimum: 0 | ||
active_low: | ||
type: boolean | ||
required: | ||
- chip | ||
- line | ||
- type: object | ||
properties: | ||
fastboot_key: | ||
type: object | ||
properties: | ||
chip: | ||
type: string | ||
pattern: "^gpiochip[0-9]+$" | ||
line: | ||
type: integer | ||
minimum: 0 | ||
active_low: | ||
type: boolean | ||
required: | ||
- chip | ||
- line | ||
- type: object | ||
properties: | ||
power_key: | ||
type: object | ||
properties: | ||
chip: | ||
type: string | ||
pattern: "^gpiochip[0-9]+$" | ||
line: | ||
type: integer | ||
minimum: 0 | ||
active_low: | ||
type: boolean | ||
required: | ||
- chip | ||
- line | ||
- type: object | ||
properties: | ||
usb_disconnect: | ||
type: object | ||
properties: | ||
chip: | ||
type: string | ||
pattern: "^gpiochip[0-9]+$" | ||
line: | ||
type: integer | ||
minimum: 0 | ||
active_low: | ||
type: boolean | ||
required: | ||
- chip | ||
- line | ||
required: | ||
- board | ||
- name | ||
|
||
additionalProperties: false | ||
|
||
required: | ||
- devices | ||
|
||
additionalProperties: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
import sys | ||
import argparse | ||
import json | ||
import jsonschema | ||
import ruamel.yaml | ||
|
||
if __name__ == "__main__": | ||
ap = argparse.ArgumentParser() | ||
ap.add_argument("cfg", help="Filename YAML input file") | ||
ap.add_argument('-s', '--schema', help="schema file") | ||
args = ap.parse_args() | ||
|
||
yaml = ruamel.yaml.YAML(typ='safe') | ||
yaml.allow_duplicate_keys = False | ||
|
||
with open(args.schema, 'r', encoding='utf-8') as f: | ||
schema = yaml.load(f.read()) | ||
|
||
with open(args.cfg, 'r', encoding='utf-8') as f: | ||
cfg = yaml.load(f.read()) | ||
|
||
jsonschema.validate(cfg, schema=schema) |