Skip to content

Commit 81904fc

Browse files
authored
chore: update generated schema when updating ecosystems (#376)
This should help with keeping the generated schema in sync and not require people to have Go setup to run `go generate` Signed-off-by: Gareth Jones <[email protected]>
1 parent 2994c84 commit 81904fc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/update-ecosystems-lists.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
open('ecosystems.json', 'w').write(json.dumps(ecosystems, indent=2) + '\n')
1818

1919

20-
def update_json_schema():
20+
def update_json_schema(filename: str):
2121
"""
2222
Updates references to ecosystems defined in the OSV JSON schema
2323
:return:
2424
"""
25-
schema = json.loads(open('validation/schema.json').read())
25+
schema = json.loads(open(filename).read())
2626

2727
names = ecosystems.keys()
2828
pattern = ''
@@ -37,7 +37,7 @@ def update_json_schema():
3737
schema['$defs']['ecosystemName']['enum'] = list(names)
3838
schema['$defs']['ecosystemWithSuffix']['pattern'] = f'^({pattern})(:.+)?$'
3939

40-
open('validation/schema.json', 'w').write(json.dumps(schema, indent=2) + '\n')
40+
open(filename, 'w').write(json.dumps(schema, indent=2) + '\n')
4141

4242

4343
def generate_ecosystems_markdown_table() -> str:
@@ -140,5 +140,6 @@ def update_go_constants():
140140

141141

142142
update_go_constants()
143-
update_json_schema()
143+
update_json_schema('validation/schema.json')
144+
update_json_schema('tools/osv-linter/internal/checks/schema_generated.json')
144145
update_schema_md()

0 commit comments

Comments
 (0)