From 717cfd2d37584b88d1fc92c637223fcd99508459 Mon Sep 17 00:00:00 2001 From: "Kim B. Heino" Date: Sat, 23 Oct 2021 15:04:07 +0300 Subject: [PATCH] validate: add support for both jsonschema v3 and old v2 RHEL8 and RHEL7 have old jsonschema v2. Try v3 (Draft7) first but fallback to v2 (Draft4) if needed. --- borgmatic/config/validate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/borgmatic/config/validate.py b/borgmatic/config/validate.py index 5658c1b..7d41151 100644 --- a/borgmatic/config/validate.py +++ b/borgmatic/config/validate.py @@ -110,7 +110,10 @@ def parse_configuration(config_filename, schema_filename, overrides=None): override.apply_overrides(config, overrides) normalize.normalize(config) - validator = jsonschema.Draft7Validator(schema) + try: + validator = jsonschema.Draft7Validator(schema) + except AttributeError: + validator = jsonschema.Draft4Validator(schema) validation_errors = tuple(validator.iter_errors(config)) if validation_errors: