Skip to content

Commit

Permalink
To ease transition, handle legacy format with kinto-wizard 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Dec 6, 2018
1 parent 88e23c3 commit ac13226
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion kinto_wizard/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ def validate_schema(data, schema, ignore_fields=[]):

def validate_export(config):
everything_is_fine = True
buckets = config.get("buckets", {})
if 'buckets' in config:
buckets = config.get("buckets", {})
else: # pragma: no cover
# Legacy for file before kinto-wizard 3.0
logger.warning("Your file seems to be in legacy format. "
"Please add a `buckets:` root namespace.")
buckets = config
for bid, bucket in buckets.items():
logger.info(f"- Bucket {bid}")
bucket_collections = bucket.get('collections', {})
Expand Down
8 changes: 7 additions & 1 deletion kinto_wizard/yaml2kinto.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ async def initialize_server(async_client, config, bucket=None, collection=None,
# We don't need to load it because we will override it nevertheless.
current_server_buckets = {}
# 2. For each bucket
buckets = config.get("buckets", {})
if 'buckets' in config:
buckets = config.get("buckets", {})
else: # pragma: no cover
# Legacy for file before kinto-wizard 3.0
logger.warning("Your file seems to be in legacy format. "
"Please add a `buckets:` root namespace.")
buckets = config
with async_client.batch() as batch:
for bucket_id, bucket in buckets.items():
# Skip buckets that we don't want to import.
Expand Down

0 comments on commit ac13226

Please sign in to comment.