Skip to content

Commit

Permalink
Merge pull request #64 from Kinto/handle-legacy
Browse files Browse the repository at this point in the history
To ease transition, handle legacy format with kinto-wizard 4.0
  • Loading branch information
Natim authored Dec 6, 2018
2 parents 88e23c3 + 814ff54 commit 4546420
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ This document describes changes between each past release.
- Add a ``validate`` command to run JSON schema validation on the records
locally. (fixes #61)

**Internal changes**

- To ease the transition between kinto-wizard 3 and kinto-wizard 4,
handle both for a couple of releases. (#64)


3.0.0 (2018-10-17)
------------------
Expand Down
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 4.0
logger.warning("Your file seems to be in legacy format. "
"Please add a `buckets:` root level.")
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 4.0
logger.warning("Your file seems to be in legacy format. "
"Please add a `buckets:` root level.")
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 4546420

Please sign in to comment.