Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To ease transition, handle legacy format with kinto-wizard 4.0 #64

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 namespace.")
Natim marked this conversation as resolved.
Show resolved Hide resolved
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 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