Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql_db: added zstd support #696

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
mysql_db: added zstd support
  • Loading branch information
Sergio-IME committed Jan 15, 2025
commit fc610bf6ce8c39eee1d762db5759a0a2eb69155b
3 changes: 3 additions & 0 deletions changelogs/fragments/696-mysql-db-add-zstd-support.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- mysql_db - added ``zstd`` (de)compression support for ``import``/``dump`` states
(https://github.com/ansible-collections/community.mysql/issues/696).
8 changes: 6 additions & 2 deletions plugins/modules/mysql_db.py
Original file line number Diff line number Diff line change
@@ -46,8 +46,8 @@
target:
description:
- Location, on the remote host, of the dump file to read from or write to.
- Uncompressed SQL files (C(.sql)) as well as bzip2 (C(.bz2)), gzip (C(.gz)) and
xz (Added in 2.0) compressed files are supported.
- Uncompressed SQL files (C(.sql)) as well as bzip2 (C(.bz2)), gzip (C(.gz)),
xz (Added in 2.0) and zstd (C(.zst)) (Added in 3.12.0) compressed files are supported.
type: path
single_transaction:
description:
@@ -455,6 +455,8 @@
path = module.get_bin_path('bzip2', True)
elif os.path.splitext(target)[-1] == '.xz':
path = module.get_bin_path('xz', True)
elif os.path.splitext(target)[-1] == '.zst':
path = module.get_bin_path('zstd', True)

Check warning on line 459 in plugins/modules/mysql_db.py

Codecov / codecov/patch

plugins/modules/mysql_db.py#L459

Added line #L459 was not covered by tests

if path:
cmd = '%s | %s > %s' % (cmd, path, shlex_quote(target))
@@ -526,6 +528,8 @@
comp_prog_path = module.get_bin_path('bzip2', required=True)
elif os.path.splitext(target)[-1] == '.xz':
comp_prog_path = module.get_bin_path('xz', required=True)
elif os.path.splitext(target)[-1] == '.zst':
comp_prog_path = module.get_bin_path('zstd', required=True)

Check warning on line 532 in plugins/modules/mysql_db.py

Codecov / codecov/patch

plugins/modules/mysql_db.py#L532

Added line #L532 was not covered by tests
if comp_prog_path:
# The line below is for returned data only:
executed_commands.append('%s -dc %s | %s' % (comp_prog_path, target, cmd))