Pārlūkot izejas kodu

Remove the error when "archive_name_format" is specified but a retention prefix isn't (#402).

Dan Helfman 3 gadi atpakaļ
vecāks
revīzija
32a1043468

+ 1 - 0
NEWS

@@ -1,4 +1,5 @@
 1.6.1.dev0
 1.6.1.dev0
+ * #402: Remove the error when "archive_name_format" is specified but a retention prefix isn't. 
  * #420: Warn when an unsupported variable is used in a hook command.
  * #420: Warn when an unsupported variable is used in a hook command.
  * #528: Improve the error message when a configuration override contains an invalid value.
  * #528: Improve the error message when a configuration override contains an invalid value.
  * #531: BREAKING: When deep merging common configuration, merge colliding list values by appending
  * #531: BREAKING: When deep merging common configuration, merge colliding list values by appending

+ 4 - 4
borgmatic/config/schema.yaml

@@ -332,10 +332,10 @@ properties:
                     Name of the archive. Borg placeholders can be used. See the
                     Name of the archive. Borg placeholders can be used. See the
                     output of "borg help placeholders" for details. Defaults to
                     output of "borg help placeholders" for details. Defaults to
                     "{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}". If you specify this
                     "{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}". If you specify this
-                    option, you must also specify a prefix in the retention
-                    section to avoid accidental pruning of archives with a
-                    different archive name format. And you should also specify a
-                    prefix in the consistency section as well.
+                    option, consider also specifying a prefix in the retention
+                    and consistency sections to avoid accidental
+                    pruning/checking of archives with different archive name
+                    formats.
                 example: "{hostname}-documents-{now}"
                 example: "{hostname}-documents-{now}"
             relocated_repo_access_is_ok:
             relocated_repo_access_is_ok:
                 type: boolean
                 type: boolean

+ 0 - 9
borgmatic/config/validate.py

@@ -65,15 +65,6 @@ def apply_logical_validation(config_filename, parsed_configuration):
     below), run through any additional logical validation checks. If there are any such validation
     below), run through any additional logical validation checks. If there are any such validation
     problems, raise a Validation_error.
     problems, raise a Validation_error.
     '''
     '''
-    archive_name_format = parsed_configuration.get('storage', {}).get('archive_name_format')
-    prefix = parsed_configuration.get('retention', {}).get('prefix')
-
-    if archive_name_format and not prefix:
-        raise Validation_error(
-            config_filename,
-            ('If you provide an archive_name_format, you must also specify a retention prefix.',),
-        )
-
     location_repositories = parsed_configuration.get('location', {}).get('repositories')
     location_repositories = parsed_configuration.get('location', {}).get('repositories')
     check_repositories = parsed_configuration.get('consistency', {}).get('check_repositories', [])
     check_repositories = parsed_configuration.get('consistency', {}).get('check_repositories', [])
     for repository in check_repositories:
     for repository in check_repositories:

+ 0 - 27
tests/unit/config/test_validate.py

@@ -37,33 +37,6 @@ def test_validation_error_string_contains_errors():
     assert 'uh oh' in result
     assert 'uh oh' in result
 
 
 
 
-def test_apply_logical_validation_raises_if_archive_name_format_present_without_prefix():
-    flexmock(module).format_json_error = lambda error: error.message
-
-    with pytest.raises(module.Validation_error):
-        module.apply_logical_validation(
-            'config.yaml',
-            {
-                'storage': {'archive_name_format': '{hostname}-{now}'},
-                'retention': {'keep_daily': 7},
-            },
-        )
-
-
-def test_apply_logical_validation_raises_if_archive_name_format_present_without_retention_prefix():
-    flexmock(module).format_json_error = lambda error: error.message
-
-    with pytest.raises(module.Validation_error):
-        module.apply_logical_validation(
-            'config.yaml',
-            {
-                'storage': {'archive_name_format': '{hostname}-{now}'},
-                'retention': {'keep_daily': 7},
-                'consistency': {'prefix': '{hostname}-'},
-            },
-        )
-
-
 def test_apply_locical_validation_raises_if_unknown_repository_in_check_repositories():
 def test_apply_locical_validation_raises_if_unknown_repository_in_check_repositories():
     flexmock(module).format_json_error = lambda error: error.message
     flexmock(module).format_json_error = lambda error: error.message