Add list_options setting (#306).
Reviewed-on: https://projects.torsion.org/borgmatic-collective/borgmatic/pulls/464
This commit is contained in:
commit
bcc820d646
3 changed files with 27 additions and 0 deletions
|
@ -749,6 +749,14 @@ properties:
|
||||||
configured to trust the configured username
|
configured to trust the configured username
|
||||||
without a password.
|
without a password.
|
||||||
example: trustsome1
|
example: trustsome1
|
||||||
|
list_options:
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
Additional mysql options to pass directly to
|
||||||
|
the mysql command that lists available
|
||||||
|
databases, without performing any validation on
|
||||||
|
them. See mysql documentation for details.
|
||||||
|
example: --defaults-extra-file=my.cnf
|
||||||
options:
|
options:
|
||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -31,6 +31,7 @@ def database_names_to_dump(database, extra_environment, log_prefix, dry_run_labe
|
||||||
|
|
||||||
show_command = (
|
show_command = (
|
||||||
('mysql',)
|
('mysql',)
|
||||||
|
+ (tuple(database['list_options'].split(' ')) if 'list_options' in database else ())
|
||||||
+ (('--host', database['hostname']) if 'hostname' in database else ())
|
+ (('--host', database['hostname']) if 'hostname' in database else ())
|
||||||
+ (('--port', str(database['port'])) if 'port' in database else ())
|
+ (('--port', str(database['port'])) if 'port' in database else ())
|
||||||
+ (('--protocol', 'tcp') if 'hostname' in database or 'port' in database else ())
|
+ (('--protocol', 'tcp') if 'hostname' in database or 'port' in database else ())
|
||||||
|
|
|
@ -198,6 +198,24 @@ def test_dump_databases_runs_mysqldump_for_all_databases():
|
||||||
assert module.dump_databases(databases, 'test.yaml', {}, dry_run=False) == [process]
|
assert module.dump_databases(databases, 'test.yaml', {}, dry_run=False) == [process]
|
||||||
|
|
||||||
|
|
||||||
|
def test_database_names_to_dump_runs_mysql_with_list_options():
|
||||||
|
database = {'name': 'all', 'list_options': '--defaults-extra-file=my.cnf'}
|
||||||
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
|
(
|
||||||
|
'mysql',
|
||||||
|
'--defaults-extra-file=my.cnf',
|
||||||
|
'--skip-column-names',
|
||||||
|
'--batch',
|
||||||
|
'--execute',
|
||||||
|
'show schemas',
|
||||||
|
),
|
||||||
|
output_log_level=None,
|
||||||
|
extra_environment=None,
|
||||||
|
).and_return(('foo\nbar')).once()
|
||||||
|
|
||||||
|
assert module.database_names_to_dump(database, None, 'test.yaml', '') == ('foo', 'bar')
|
||||||
|
|
||||||
|
|
||||||
def test_dump_databases_errors_for_missing_all_databases():
|
def test_dump_databases_errors_for_missing_all_databases():
|
||||||
databases = [{'name': 'all'}]
|
databases = [{'name': 'all'}]
|
||||||
process = flexmock()
|
process = flexmock()
|
||||||
|
|
Loading…
Reference in a new issue