浏览代码

use repository["path"] instead of repository

Divyansh Singh 2 年之前
父节点
当前提交
e83ad9e1e4
共有 36 个文件被更改,包括 193 次插入134 次删除
  1. 3 3
      borgmatic/actions/borg.py
  2. 6 2
      borgmatic/actions/break_lock.py
  3. 2 2
      borgmatic/actions/check.py
  4. 5 3
      borgmatic/actions/compact.py
  5. 5 3
      borgmatic/actions/export_tar.py
  6. 5 3
      borgmatic/actions/extract.py
  7. 3 3
      borgmatic/actions/info.py
  8. 4 4
      borgmatic/actions/list.py
  9. 6 4
      borgmatic/actions/mount.py
  10. 2 2
      borgmatic/actions/prune.py
  11. 2 2
      borgmatic/actions/rcreate.py
  12. 20 7
      borgmatic/actions/restore.py
  13. 4 2
      borgmatic/actions/rinfo.py
  14. 2 2
      borgmatic/actions/rlist.py
  15. 4 0
      borgmatic/commands/borgmatic.py
  16. 22 15
      borgmatic/config/normalize.py
  17. 23 13
      borgmatic/config/schema.yaml
  18. 8 6
      borgmatic/config/validate.py
  19. 15 6
      tests/integration/config/test_validate.py
  20. 1 1
      tests/unit/actions/test_borg.py
  21. 1 1
      tests/unit/actions/test_break_lock.py
  22. 3 3
      tests/unit/actions/test_check.py
  23. 3 3
      tests/unit/actions/test_compact.py
  24. 2 2
      tests/unit/actions/test_create.py
  25. 1 1
      tests/unit/actions/test_export_tar.py
  26. 1 1
      tests/unit/actions/test_extract.py
  27. 1 1
      tests/unit/actions/test_info.py
  28. 1 1
      tests/unit/actions/test_list.py
  29. 1 1
      tests/unit/actions/test_mount.py
  30. 2 2
      tests/unit/actions/test_prune.py
  31. 2 2
      tests/unit/actions/test_rcreate.py
  32. 8 8
      tests/unit/actions/test_restore.py
  33. 1 1
      tests/unit/actions/test_rinfo.py
  34. 1 1
      tests/unit/actions/test_rlist.py
  35. 18 18
      tests/unit/commands/test_borgmatic.py
  36. 5 5
      tests/unit/config/test_normalize.py

+ 3 - 3
borgmatic/actions/borg.py

@@ -16,9 +16,9 @@ def run_borg(
     if borg_arguments.repository is None or borgmatic.config.validate.repositories_match(
         repository, borg_arguments.repository
     ):
-        logger.info('{}: Running arbitrary Borg command'.format(repository))
+        logger.info('{}: Running arbitrary Borg command'.format(repository['path']))
         archive_name = borgmatic.borg.rlist.resolve_archive_name(
-            repository,
+            repository['path'],
             borg_arguments.archive,
             storage,
             local_borg_version,
@@ -26,7 +26,7 @@ def run_borg(
             remote_path,
         )
         borgmatic.borg.borg.run_arbitrary_borg(
-            repository,
+            repository['path'],
             storage,
             local_borg_version,
             options=borg_arguments.options,

+ 6 - 2
borgmatic/actions/break_lock.py

@@ -15,7 +15,11 @@ def run_break_lock(
     if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match(
         repository, break_lock_arguments.repository
     ):
-        logger.info(f'{repository}: Breaking repository and cache locks')
+        logger.info(f'{repository["path"]}: Breaking repository and cache locks')
         borgmatic.borg.break_lock.break_lock(
-            repository, storage, local_borg_version, local_path=local_path, remote_path=remote_path,
+            repository['path'],
+            storage,
+            local_borg_version,
+            local_path=local_path,
+            remote_path=remote_path,
         )

+ 2 - 2
borgmatic/actions/check.py

@@ -37,9 +37,9 @@ def run_check(
         global_arguments.dry_run,
         **hook_context,
     )
-    logger.info('{}: Running consistency checks'.format(repository))
+    logger.info('{}: Running consistency checks'.format(repository['path']))
     borgmatic.borg.check.check_archives(
-        repository,
+        repository['path'],
         location,
         storage,
         consistency,

+ 5 - 3
borgmatic/actions/compact.py

@@ -39,10 +39,10 @@ def run_compact(
         **hook_context,
     )
     if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version):
-        logger.info('{}: Compacting segments{}'.format(repository, dry_run_label))
+        logger.info('{}: Compacting segments{}'.format(repository['path'], dry_run_label))
         borgmatic.borg.compact.compact_segments(
             global_arguments.dry_run,
-            repository,
+            repository['path'],
             storage,
             local_borg_version,
             local_path=local_path,
@@ -52,7 +52,9 @@ def run_compact(
             threshold=compact_arguments.threshold,
         )
     else:  # pragma: nocover
-        logger.info('{}: Skipping compact (only available/needed in Borg 1.2+)'.format(repository))
+        logger.info(
+            '{}: Skipping compact (only available/needed in Borg 1.2+)'.format(repository['path'])
+        )
     borgmatic.hooks.command.execute_hook(
         hooks.get('after_compact'),
         hooks.get('umask'),

+ 5 - 3
borgmatic/actions/export_tar.py

@@ -23,13 +23,15 @@ def run_export_tar(
         repository, export_tar_arguments.repository
     ):
         logger.info(
-            '{}: Exporting archive {} as tar file'.format(repository, export_tar_arguments.archive)
+            '{}: Exporting archive {} as tar file'.format(
+                repository['path'], export_tar_arguments.archive
+            )
         )
         borgmatic.borg.export_tar.export_tar_archive(
             global_arguments.dry_run,
-            repository,
+            repository['path'],
             borgmatic.borg.rlist.resolve_archive_name(
-                repository,
+                repository['path'],
                 export_tar_arguments.archive,
                 storage,
                 local_borg_version,

+ 5 - 3
borgmatic/actions/extract.py

@@ -35,12 +35,14 @@ def run_extract(
     if extract_arguments.repository is None or borgmatic.config.validate.repositories_match(
         repository, extract_arguments.repository
     ):
-        logger.info('{}: Extracting archive {}'.format(repository, extract_arguments.archive))
+        logger.info(
+            '{}: Extracting archive {}'.format(repository['path'], extract_arguments.archive)
+        )
         borgmatic.borg.extract.extract_archive(
             global_arguments.dry_run,
-            repository,
+            repository['path'],
             borgmatic.borg.rlist.resolve_archive_name(
-                repository,
+                repository['path'],
                 extract_arguments.archive,
                 storage,
                 local_borg_version,

+ 3 - 3
borgmatic/actions/info.py

@@ -20,9 +20,9 @@ def run_info(
         repository, info_arguments.repository
     ):
         if not info_arguments.json:  # pragma: nocover
-            logger.answer(f'{repository}: Displaying archive summary information')
+            logger.answer(f'{repository["path"]}: Displaying archive summary information')
         info_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
-            repository,
+            repository['path'],
             info_arguments.archive,
             storage,
             local_borg_version,
@@ -30,7 +30,7 @@ def run_info(
             remote_path,
         )
         json_output = borgmatic.borg.info.display_archives_info(
-            repository,
+            repository['path'],
             storage,
             local_borg_version,
             info_arguments=info_arguments,

+ 4 - 4
borgmatic/actions/list.py

@@ -20,11 +20,11 @@ def run_list(
     ):
         if not list_arguments.json:  # pragma: nocover
             if list_arguments.find_paths:
-                logger.answer(f'{repository}: Searching archives')
+                logger.answer(f'{repository["path"]}: Searching archives')
             elif not list_arguments.archive:
-                logger.answer(f'{repository}: Listing archives')
+                logger.answer(f'{repository["path"]}: Listing archives')
         list_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
-            repository,
+            repository['path'],
             list_arguments.archive,
             storage,
             local_borg_version,
@@ -32,7 +32,7 @@ def run_list(
             remote_path,
         )
         json_output = borgmatic.borg.list.list_archive(
-            repository,
+            repository['path'],
             storage,
             local_borg_version,
             list_arguments=list_arguments,

+ 6 - 4
borgmatic/actions/mount.py

@@ -17,14 +17,16 @@ def run_mount(
         repository, mount_arguments.repository
     ):
         if mount_arguments.archive:
-            logger.info('{}: Mounting archive {}'.format(repository, mount_arguments.archive))
+            logger.info(
+                '{}: Mounting archive {}'.format(repository['path'], mount_arguments.archive)
+            )
         else:  # pragma: nocover
-            logger.info('{}: Mounting repository'.format(repository))
+            logger.info('{}: Mounting repository'.format(repository['path']))
 
         borgmatic.borg.mount.mount_archive(
-            repository,
+            repository['path'],
             borgmatic.borg.rlist.resolve_archive_name(
-                repository,
+                repository['path'],
                 mount_arguments.archive,
                 storage,
                 local_borg_version,

+ 2 - 2
borgmatic/actions/prune.py

@@ -37,10 +37,10 @@ def run_prune(
         global_arguments.dry_run,
         **hook_context,
     )
-    logger.info('{}: Pruning archives{}'.format(repository, dry_run_label))
+    logger.info('{}: Pruning archives{}'.format(repository['path'], dry_run_label))
     borgmatic.borg.prune.prune_archives(
         global_arguments.dry_run,
-        repository,
+        repository['path'],
         storage,
         retention,
         local_borg_version,

+ 2 - 2
borgmatic/actions/rcreate.py

@@ -23,10 +23,10 @@ def run_rcreate(
     ):
         return
 
-    logger.info('{}: Creating repository'.format(repository))
+    logger.info('{}: Creating repository'.format(repository['path']))
     borgmatic.borg.rcreate.create_repository(
         global_arguments.dry_run,
-        repository,
+        repository['path'],
         storage,
         local_borg_version,
         rcreate_arguments.encryption_mode,

+ 20 - 7
borgmatic/actions/restore.py

@@ -256,22 +256,35 @@ def run_restore(
         return
 
     logger.info(
-        '{}: Restoring databases from archive {}'.format(repository, restore_arguments.archive)
+        '{}: Restoring databases from archive {}'.format(
+            repository['path'], restore_arguments.archive
+        )
     )
     borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
         'remove_database_dumps',
         hooks,
-        repository,
+        repository['path'],
         borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
         location,
         global_arguments.dry_run,
     )
 
     archive_name = borgmatic.borg.rlist.resolve_archive_name(
-        repository, restore_arguments.archive, storage, local_borg_version, local_path, remote_path,
+        repository['path'],
+        restore_arguments.archive,
+        storage,
+        local_borg_version,
+        local_path,
+        remote_path,
     )
     archive_database_names = collect_archive_database_names(
-        repository, archive_name, location, storage, local_borg_version, local_path, remote_path,
+        repository['path'],
+        archive_name,
+        location,
+        storage,
+        local_borg_version,
+        local_path,
+        remote_path,
     )
     restore_names = find_databases_to_restore(restore_arguments.databases, archive_database_names)
     found_names = set()
@@ -291,7 +304,7 @@ def run_restore(
 
             found_names.add(database_name)
             restore_single_database(
-                repository,
+                repository['path'],
                 location,
                 storage,
                 hooks,
@@ -320,7 +333,7 @@ def run_restore(
             database['name'] = database_name
 
             restore_single_database(
-                repository,
+                repository['path'],
                 location,
                 storage,
                 hooks,
@@ -336,7 +349,7 @@ def run_restore(
     borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
         'remove_database_dumps',
         hooks,
-        repository,
+        repository['path'],
         borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
         location,
         global_arguments.dry_run,

+ 4 - 2
borgmatic/actions/rinfo.py

@@ -19,9 +19,11 @@ def run_rinfo(
         repository, rinfo_arguments.repository
     ):
         if not rinfo_arguments.json:  # pragma: nocover
-            logger.answer('{}: Displaying repository summary information'.format(repository))
+            logger.answer(
+                '{}: Displaying repository summary information'.format(repository['path'])
+            )
         json_output = borgmatic.borg.rinfo.display_repository_info(
-            repository,
+            repository['path'],
             storage,
             local_borg_version,
             rinfo_arguments=rinfo_arguments,

+ 2 - 2
borgmatic/actions/rlist.py

@@ -19,9 +19,9 @@ def run_rlist(
         repository, rlist_arguments.repository
     ):
         if not rlist_arguments.json:  # pragma: nocover
-            logger.answer('{}: Listing repository'.format(repository))
+            logger.answer('{}: Listing repository'.format(repository['path']))
         json_output = borgmatic.borg.rlist.list_repository(
-            repository,
+            repository['path'],
             storage,
             local_borg_version,
             rlist_arguments=rlist_arguments,

+ 4 - 0
borgmatic/commands/borgmatic.py

@@ -109,6 +109,8 @@ def run_configuration(config_filename, config, arguments):
 
         while not repo_queue.empty():
             repository, retry_num = repo_queue.get()
+            if isinstance(repository, str):
+                repository = {'path': repository}
             timeout = retry_num * retry_wait
             if timeout:
                 logger.warning(f'{config_filename}: Sleeping {timeout}s before next retry')
@@ -263,6 +265,8 @@ def run_actions(
     invalid.
     '''
     add_custom_log_levels()
+    if isinstance(repository, str):
+        repository = {'path': repository}
     repository_path = os.path.expanduser(repository['path'])
     global_arguments = arguments['global']
     dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''

+ 22 - 15
borgmatic/config/normalize.py

@@ -56,14 +56,16 @@ def normalize(config_filename, config):
 
     # Upgrade remote repositories to ssh:// syntax, required in Borg 2.
     repositories = location.get('repositories')
-    if isinstance(repositories[0], str):
-        config['location']['repositories'] = [{'path': repository} for repository in repositories]
-        repositories = config['location']['repositories']
     if repositories:
+        if isinstance(repositories[0], str):
+            config['location']['repositories'] = [
+                {'path': repository} for repository in repositories
+            ]
+            repositories = config['location']['repositories']
         config['location']['repositories'] = []
         for repository_dict in repositories:
-            repository = repository_dict['path']
-            if '~' in repository:
+            repository_path = repository_dict['path']
+            if '~' in repository_path:
                 logs.append(
                     logging.makeLogRecord(
                         dict(
@@ -73,37 +75,42 @@ def normalize(config_filename, config):
                         )
                     )
                 )
-            if ':' in repository:
-                if repository.startswith('file://'):
-                    updated_repository_path = os.path.abspath(repository.partition('file://')[-1])
+            if ':' in repository_path:
+                if repository_path.startswith('file://'):
+                    updated_repository_path = os.path.abspath(
+                        repository_path.partition('file://')[-1]
+                    )
 
                     config['location']['repositories'].append(
                         {
                             'path': updated_repository_path,
-                            'label': repository_dict.get('label', None),
+                            'label': repository_dict.get('label', ''),
                         }
                     )
-                elif repository.startswith('ssh://'):
+                elif repository_path.startswith('ssh://'):
                     config['location']['repositories'].append(
-                        {'path': repository, 'label': repository_dict.get('label', None),}
+                        {'path': repository_path, 'label': repository_dict.get('label', '')}
                     )
                 else:
-                    rewritten_repository = f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}"
+                    rewritten_repository_path = f"ssh://{repository_path.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}"
                     logs.append(
                         logging.makeLogRecord(
                             dict(
                                 levelno=logging.WARNING,
                                 levelname='WARNING',
-                                msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated. Interpreting "{repository}" as "{rewritten_repository}"',
+                                msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated. Interpreting "{repository_path}" as "{rewritten_repository_path}"',
                             )
                         )
                     )
                     config['location']['repositories'].append(
-                        {'path': rewritten_repository, 'label': repository_dict.get('label', None),}
+                        {
+                            'path': rewritten_repository_path,
+                            'label': repository_dict.get('label', ''),
+                        }
                     )
             else:
                 config['location']['repositories'].append(
-                    {'path': repository, 'label': repository_dict.get('label', None),}
+                    {'path': repository_path, 'label': repository_dict.get('label', '')}
                 )
 
     return logs

+ 23 - 13
borgmatic/config/schema.yaml

@@ -36,23 +36,33 @@ properties:
                         path:
                             type: string
                             description: |
-                                Path to local or remote repository (required). 
-                                are expanded. Multiple repositories are backed up to
-                                in sequence. Borg placeholders can be used. See the
-                                output of "borg help placeholders" for details. See
-                                ssh_command for SSH options like identity file or
-                                port. If systemd service is used, then add local
-                                repository paths in the systemd service file to the
-                                ReadWritePaths list.                                
-                            example:
-                                - ssh://user@backupserver/./sourcehostname.borg
-                                - ssh://user@backupserver/./{fqdn}
-                                - /var/local/backups/local.borg
+                                Path to local or remote repository
+                                (required). Tildes are expanded.
+                                Multiple repositories are backed up
+                                to in sequence. Borg placeholders
+                                can be used. See the output of
+                                "borg help placeholders" for
+                                details. See ssh_command for SSH
+                                options like identity file or port.
+                                If systemd service is used, then
+                                add local repository paths in the
+                                systemd service file to the
+                                ReadWritePaths list.
+                            example: ssh://user@backupserver/./{fqdn}
                         label:
                             type: string
                             description: |
-                                Optional label for the repository.
+                                Optional label for the repository. This 
+                                can be used with the --repository option 
+                                to select a repository to backup to. 
+                                If not specified, the repository path is 
+                                used as the label.
                             example: backupserver
+                example:
+                    - path: ssh://user@backupserver/./{fqdn}
+                      label: backupserver
+                    - path: /mnt/backup
+                      label: local
             working_directory:
                 type: string
                 description: |

+ 8 - 6
borgmatic/config/validate.py

@@ -141,12 +141,14 @@ def repositories_match(first, second):
     Given two repository dicts with keys 'path' (relative and/or absolute),
     and 'label', return whether they match.
     '''
-    if isinstance(first, str) and isinstance(second, str):
-        return normalize_repository_path(first) == normalize_repository_path(second)
-    elif isinstance(first, dict) and isinstance(second, str):
-        return (second == first.get('label')) or (
-            normalize_repository_path(second) == normalize_repository_path(first.get('path'))
-        )
+    if isinstance(first, str):
+        first = {'path': first, 'label': first}
+    if isinstance(second, str):
+        second = {'path': second, 'label': second}
+    return (first.get('label') == second.get('label')) or (
+        normalize_repository_path(first.get('path'))
+        == normalize_repository_path(second.get('path'))
+    )
 
 
 def guard_configuration_contains_repository(repository, configurations):

+ 15 - 6
tests/integration/config/test_validate.py

@@ -63,7 +63,10 @@ def test_parse_configuration_transforms_file_into_mapping():
     config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
 
     assert config == {
-        'location': {'source_directories': ['/home', '/etc'], 'repositories': ['hostname.borg']},
+        'location': {
+            'source_directories': ['/home', '/etc'],
+            'repositories': [{'path': 'hostname.borg', 'label': ''}],
+        },
         'retention': {'keep_daily': 7, 'keep_hourly': 24, 'keep_minutely': 60},
         'consistency': {'checks': [{'name': 'repository'}, {'name': 'archives'}]},
     }
@@ -89,7 +92,7 @@ def test_parse_configuration_passes_through_quoted_punctuation():
     assert config == {
         'location': {
             'source_directories': [f'/home/{string.punctuation}'],
-            'repositories': ['test.borg'],
+            'repositories': [{'path': 'test.borg', 'label': ''}],
         }
     }
     assert logs == []
@@ -151,7 +154,10 @@ def test_parse_configuration_inlines_include():
     config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
 
     assert config == {
-        'location': {'source_directories': ['/home'], 'repositories': ['hostname.borg']},
+        'location': {
+            'source_directories': ['/home'],
+            'repositories': [{'path': 'hostname.borg', 'label': ''}],
+        },
         'retention': {'keep_daily': 7, 'keep_hourly': 24},
     }
     assert logs == []
@@ -185,7 +191,10 @@ def test_parse_configuration_merges_include():
     config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
 
     assert config == {
-        'location': {'source_directories': ['/home'], 'repositories': ['hostname.borg']},
+        'location': {
+            'source_directories': ['/home'],
+            'repositories': [{'path': 'hostname.borg', 'label': ''}],
+        },
         'retention': {'keep_daily': 1, 'keep_hourly': 24},
     }
     assert logs == []
@@ -247,7 +256,7 @@ def test_parse_configuration_applies_overrides():
     assert config == {
         'location': {
             'source_directories': ['/home'],
-            'repositories': ['hostname.borg'],
+            'repositories': [{'path': 'hostname.borg', 'label': ''}],
             'local_path': 'borg2',
         }
     }
@@ -273,7 +282,7 @@ def test_parse_configuration_applies_normalization():
     assert config == {
         'location': {
             'source_directories': ['/home'],
-            'repositories': ['hostname.borg'],
+            'repositories': [{'path': 'hostname.borg', 'label': ''}],
             'exclude_if_present': ['.nobackup'],
         }
     }

+ 1 - 1
tests/unit/actions/test_borg.py

@@ -13,7 +13,7 @@ def test_run_borg_does_not_raise():
     borg_arguments = flexmock(repository=flexmock(), archive=flexmock(), options=flexmock())
 
     module.run_borg(
-        repository='repo',
+        repository={'path': 'repos'},
         storage={},
         local_borg_version=None,
         borg_arguments=borg_arguments,

+ 1 - 1
tests/unit/actions/test_break_lock.py

@@ -10,7 +10,7 @@ def test_run_break_lock_does_not_raise():
     break_lock_arguments = flexmock(repository=flexmock())
 
     module.run_break_lock(
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         local_borg_version=None,
         break_lock_arguments=break_lock_arguments,

+ 3 - 3
tests/unit/actions/test_check.py

@@ -18,7 +18,7 @@ def test_run_check_calls_hooks_for_configured_repository():
 
     module.run_check(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         location={'repositories': ['repo']},
         storage={},
         consistency={},
@@ -49,7 +49,7 @@ def test_run_check_runs_with_selected_repository():
 
     module.run_check(
         config_filename='test.yaml',
-        repository=flexmock(),
+        repository={'path': 'repo'},
         location={'repositories': ['repo']},
         storage={},
         consistency={},
@@ -80,7 +80,7 @@ def test_run_check_bails_if_repository_does_not_match():
 
     module.run_check(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         location={'repositories': ['repo']},
         storage={},
         consistency={},

+ 3 - 3
tests/unit/actions/test_compact.py

@@ -16,7 +16,7 @@ def test_compact_actions_calls_hooks_for_configured_repository():
 
     module.run_compact(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         retention={},
         hooks={},
@@ -44,7 +44,7 @@ def test_compact_runs_with_selected_repository():
 
     module.run_compact(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         retention={},
         hooks={},
@@ -72,7 +72,7 @@ def test_compact_bails_if_repository_does_not_match():
 
     module.run_compact(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         retention={},
         hooks={},

+ 2 - 2
tests/unit/actions/test_create.py

@@ -24,7 +24,7 @@ def test_run_create_executes_and_calls_hooks_for_configured_repository():
     list(
         module.run_create(
             config_filename='test.yaml',
-            repository='repo',
+            repository={'path': 'repo'},
             location={},
             storage={},
             hooks={},
@@ -57,7 +57,7 @@ def test_run_create_runs_with_selected_repository():
     list(
         module.run_create(
             config_filename='test.yaml',
-            repository='repo',
+            repository={'path': 'repo'},
             location={},
             storage={},
             hooks={},

+ 1 - 1
tests/unit/actions/test_export_tar.py

@@ -19,7 +19,7 @@ def test_run_export_tar_does_not_raise():
     global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
 
     module.run_export_tar(
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         local_borg_version=None,
         export_tar_arguments=export_tar_arguments,

+ 1 - 1
tests/unit/actions/test_extract.py

@@ -20,7 +20,7 @@ def test_run_extract_calls_hooks():
 
     module.run_extract(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         location={'repositories': ['repo']},
         storage={},
         hooks={},

+ 1 - 1
tests/unit/actions/test_info.py

@@ -14,7 +14,7 @@ def test_run_info_does_not_raise():
 
     list(
         module.run_info(
-            repository='repo',
+            repository={'path': 'repo'},
             storage={},
             local_borg_version=None,
             info_arguments=info_arguments,

+ 1 - 1
tests/unit/actions/test_list.py

@@ -14,7 +14,7 @@ def test_run_list_does_not_raise():
 
     list(
         module.run_list(
-            repository='repo',
+            repository={'path': 'repo'},
             storage={},
             local_borg_version=None,
             list_arguments=list_arguments,

+ 1 - 1
tests/unit/actions/test_mount.py

@@ -17,7 +17,7 @@ def test_run_mount_does_not_raise():
     )
 
     module.run_mount(
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         local_borg_version=None,
         mount_arguments=mount_arguments,

+ 2 - 2
tests/unit/actions/test_prune.py

@@ -13,7 +13,7 @@ def test_run_prune_calls_hooks_for_configured_repository():
 
     module.run_prune(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         retention={},
         hooks={},
@@ -38,7 +38,7 @@ def test_run_prune_runs_with_selected_repository():
 
     module.run_prune(
         config_filename='test.yaml',
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         retention={},
         hooks={},

+ 2 - 2
tests/unit/actions/test_rcreate.py

@@ -18,7 +18,7 @@ def test_run_rcreate_does_not_raise():
     )
 
     module.run_rcreate(
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         local_borg_version=None,
         rcreate_arguments=arguments,
@@ -45,7 +45,7 @@ def test_run_rcreate_bails_if_repository_does_not_match():
     )
 
     module.run_rcreate(
-        repository='repo',
+        repository={'path': 'repo'},
         storage={},
         local_borg_version=None,
         rcreate_arguments=arguments,

+ 8 - 8
tests/unit/actions/test_restore.py

@@ -67,7 +67,7 @@ def test_collect_archive_database_names_parses_archive_paths():
     )
 
     archive_database_names = module.collect_archive_database_names(
-        repository='repo',
+        repository={'path': 'repo'},
         archive='archive',
         location={'borgmatic_source_directory': '.borgmatic'},
         storage=flexmock(),
@@ -92,7 +92,7 @@ def test_collect_archive_database_names_parses_directory_format_archive_paths():
     )
 
     archive_database_names = module.collect_archive_database_names(
-        repository='repo',
+        repository={'path': 'repo'},
         archive='archive',
         location={'borgmatic_source_directory': '.borgmatic'},
         storage=flexmock(),
@@ -113,7 +113,7 @@ def test_collect_archive_database_names_skips_bad_archive_paths():
     )
 
     archive_database_names = module.collect_archive_database_names(
-        repository='repo',
+        repository={'path': 'repo'},
         archive='archive',
         location={'borgmatic_source_directory': '.borgmatic'},
         storage=flexmock(),
@@ -251,7 +251,7 @@ def test_run_restore_restores_each_database():
     flexmock(module).should_receive('ensure_databases_found')
 
     module.run_restore(
-        repository='repo',
+        repository={'path': 'repo'},
         location=flexmock(),
         storage=flexmock(),
         hooks=flexmock(),
@@ -273,7 +273,7 @@ def test_run_restore_bails_for_non_matching_repository():
     flexmock(module).should_receive('restore_single_database').never()
 
     module.run_restore(
-        repository='repo',
+        repository={'path': 'repo'},
         location=flexmock(),
         storage=flexmock(),
         hooks=flexmock(),
@@ -345,7 +345,7 @@ def test_run_restore_restores_database_configured_with_all_name():
     flexmock(module).should_receive('ensure_databases_found')
 
     module.run_restore(
-        repository='repo',
+        repository={'path': 'repo'},
         location=flexmock(),
         storage=flexmock(),
         hooks=flexmock(),
@@ -417,7 +417,7 @@ def test_run_restore_skips_missing_database():
     flexmock(module).should_receive('ensure_databases_found')
 
     module.run_restore(
-        repository='repo',
+        repository={'path': 'repo'},
         location=flexmock(),
         storage=flexmock(),
         hooks=flexmock(),
@@ -483,7 +483,7 @@ def test_run_restore_restores_databases_from_different_hooks():
     flexmock(module).should_receive('ensure_databases_found')
 
     module.run_restore(
-        repository='repo',
+        repository={'path': 'repo'},
         location=flexmock(),
         storage=flexmock(),
         hooks=flexmock(),

+ 1 - 1
tests/unit/actions/test_rinfo.py

@@ -11,7 +11,7 @@ def test_run_rinfo_does_not_raise():
 
     list(
         module.run_rinfo(
-            repository='repo',
+            repository={'path': 'repo'},
             storage={},
             local_borg_version=None,
             rinfo_arguments=rinfo_arguments,

+ 1 - 1
tests/unit/actions/test_rlist.py

@@ -11,7 +11,7 @@ def test_run_rlist_does_not_raise():
 
     list(
         module.run_rlist(
-            repository='repo',
+            repository={'path': 'repo'},
             storage={},
             local_borg_version=None,
             rlist_arguments=rlist_arguments,

+ 18 - 18
tests/unit/commands/test_borgmatic.py

@@ -409,7 +409,7 @@ def test_run_actions_runs_rcreate():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -431,7 +431,7 @@ def test_run_actions_runs_transfer():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -454,7 +454,7 @@ def test_run_actions_runs_create():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
     assert result == (expected,)
@@ -477,7 +477,7 @@ def test_run_actions_runs_prune():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -499,7 +499,7 @@ def test_run_actions_runs_compact():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -522,7 +522,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -545,7 +545,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -567,7 +567,7 @@ def test_run_actions_runs_extract():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -589,7 +589,7 @@ def test_run_actions_runs_export_tar():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -611,7 +611,7 @@ def test_run_actions_runs_mount():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -633,7 +633,7 @@ def test_run_actions_runs_restore():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -656,7 +656,7 @@ def test_run_actions_runs_rlist():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
     assert result == (expected,)
@@ -680,7 +680,7 @@ def test_run_actions_runs_list():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
     assert result == (expected,)
@@ -704,7 +704,7 @@ def test_run_actions_runs_rinfo():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
     assert result == (expected,)
@@ -728,7 +728,7 @@ def test_run_actions_runs_info():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
     assert result == (expected,)
@@ -751,7 +751,7 @@ def test_run_actions_runs_break_lock():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -773,7 +773,7 @@ def test_run_actions_runs_borg():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 
@@ -800,7 +800,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
             local_path=flexmock(),
             remote_path=flexmock(),
             local_borg_version=flexmock(),
-            repository_path='repo',
+            repository='repo',
         )
     )
 

+ 5 - 5
tests/unit/config/test_normalize.py

@@ -69,27 +69,27 @@ from borgmatic.config import normalize as module
         ),
         (
             {'location': {'repositories': ['foo@bar:/repo']}},
-            {'location': {'repositories': ['ssh://foo@bar/repo']}},
+            {'location': {'repositories': [{'path': 'ssh://foo@bar/repo', 'label': ''}]}},
             True,
         ),
         (
             {'location': {'repositories': ['foo@bar:repo']}},
-            {'location': {'repositories': ['ssh://foo@bar/./repo']}},
+            {'location': {'repositories': [{'path': 'ssh://foo@bar/./repo', 'label': ''}]}},
             True,
         ),
         (
             {'location': {'repositories': ['foo@bar:~/repo']}},
-            {'location': {'repositories': ['ssh://foo@bar/~/repo']}},
+            {'location': {'repositories': [{'path': 'ssh://foo@bar/~/repo', 'label': ''}]}},
             True,
         ),
         (
             {'location': {'repositories': ['ssh://foo@bar:1234/repo']}},
-            {'location': {'repositories': ['ssh://foo@bar:1234/repo']}},
+            {'location': {'repositories': [{'path': 'ssh://foo@bar:1234/repo', 'label': ''}]}},
             False,
         ),
         (
             {'location': {'repositories': ['file:///repo']}},
-            {'location': {'repositories': ['/repo']}},
+            {'location': {'repositories': [{'path': '/repo', 'label': ''}]}},
             False,
         ),
     ),