From 201663dd571d91f79f713f1b090fdf7ec99d71ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Thu, 6 Dec 2018 16:35:13 +0100 Subject: [PATCH 1/3] To ease transition, handle legacy format with kinto-wizard 4.0 --- kinto_wizard/validate.py | 8 +++++++- kinto_wizard/yaml2kinto.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/kinto_wizard/validate.py b/kinto_wizard/validate.py index e5bcba8..4cb7db3 100644 --- a/kinto_wizard/validate.py +++ b/kinto_wizard/validate.py @@ -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.") + buckets = config for bid, bucket in buckets.items(): logger.info(f"- Bucket {bid}") bucket_collections = bucket.get('collections', {}) diff --git a/kinto_wizard/yaml2kinto.py b/kinto_wizard/yaml2kinto.py index 8d580e2..6033ba0 100644 --- a/kinto_wizard/yaml2kinto.py +++ b/kinto_wizard/yaml2kinto.py @@ -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. From 9c7b803440fdf935e69399ef9be3b9b960cc0f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Thu, 6 Dec 2018 16:37:24 +0100 Subject: [PATCH 2/3] Update CHANGELOG. --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 684a9bd..d21783e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) ------------------ From 814ff54a31a3942f3e0b621082774265c10693f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Thu, 6 Dec 2018 17:43:31 +0100 Subject: [PATCH 3/3] @leplatrem review. --- kinto_wizard/validate.py | 2 +- kinto_wizard/yaml2kinto.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kinto_wizard/validate.py b/kinto_wizard/validate.py index 4cb7db3..b08249e 100644 --- a/kinto_wizard/validate.py +++ b/kinto_wizard/validate.py @@ -47,7 +47,7 @@ def validate_export(config): 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.") + "Please add a `buckets:` root level.") buckets = config for bid, bucket in buckets.items(): logger.info(f"- Bucket {bid}") diff --git a/kinto_wizard/yaml2kinto.py b/kinto_wizard/yaml2kinto.py index 6033ba0..08e3998 100644 --- a/kinto_wizard/yaml2kinto.py +++ b/kinto_wizard/yaml2kinto.py @@ -26,7 +26,7 @@ async def initialize_server(async_client, config, bucket=None, collection=None, 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.") + "Please add a `buckets:` root level.") buckets = config with async_client.batch() as batch: for bucket_id, bucket in buckets.items():