Skip to content

Commit

Permalink
schemas: add config fixture, update serializer
Browse files Browse the repository at this point in the history
* closes cernanalysispreservation#2215

Signed-off-by: Ilias Koutsakis <ilias.koutsakis@cern.ch>
  • Loading branch information
Lilykos authored and pamfilos committed Jan 18, 2023
1 parent ab2787d commit 06a76b0
Show file tree
Hide file tree
Showing 8 changed files with 881 additions and 3 deletions.
12 changes: 11 additions & 1 deletion cap/modules/schemas/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from cap.modules.schemas.models import Schema
from cap.modules.schemas.resolvers import resolve_schema_by_url,\
resolve_schema_by_name_and_version, schema_name_to_url
from cap.modules.schemas.utils import is_later_version
from cap.modules.schemas.utils import is_later_version, validate_schema_config

DEPOSIT_REQUIRED_FIELDS = [
'_buckets',
Expand Down Expand Up @@ -296,6 +296,16 @@ def add_schema_from_json(data, replace=None, force_version=None):
allow_all = data.pop("allow_all", False)
version = data['version']
name = data['name']
config = data.get('config')

if config:
errors = validate_schema_config(config)
if errors:
click.secho(errors, fg='red')
click.secho(
f'Configuration is invalid. '
f'Aborting update for schema {name}.', fg='red')
return

try:
with db.session.begin_nested():
Expand Down
16 changes: 16 additions & 0 deletions cap/modules/schemas/configs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "object",
"title": "General Configuration",
"additionalProperties":false,
"properties": {
"notifications": {
"$ref": "/cap/modules/schemas/configs/configs/notifications.json"
},
"reviewable": {
"$ref": "/cap/modules/schemas/configs/reviewable.json"
},
"repositories": {
"$ref": "/cap/modules/schemas/configs/repositories.json"
}
}
}
Loading

0 comments on commit 06a76b0

Please sign in to comment.