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

fix(backup): convert odoo regex extensions #424

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion common.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ services:
init: true
environment:
DB_VERSION: "{{ postgres_version or 'latest' }}"
DBS_TO_INCLUDE: "{{ odoo_dbfilter }}"
DBS_TO_INCLUDE: "{{ odoo_dbfilter | replace('$', '$$') | replace('%d', '.*') | replace('%h', '.*') }}"
DST: "{{ backup_dst }}"
{%- if smtp_relay_host %}
EMAIL_FROM: "{{ backup_email_from }}"
Expand Down
2 changes: 1 addition & 1 deletion prod.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- .docker/odoo.env
- .docker/db-access.env
environment:
DB_FILTER: "{{ odoo_dbfilter }}"
DB_FILTER: "{{ odoo_dbfilter | replace('$', '$$') }}"
DOODBA_ENVIRONMENT: "${DOODBA_ENVIRONMENT-prod}"
INITIAL_LANG: "{{ odoo_initial_lang }}"
{%- if smtp_relay_host %}
Expand Down
24 changes: 24 additions & 0 deletions tests/test_settings_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,27 @@ def test_dbfilter_default(
assert "DB_FILTER" not in test.services["odoo"].environment
assert prod.services["odoo"].environment["DB_FILTER"] == "^prod"
assert prod.services["backup"].environment["DBS_TO_INCLUDE"] == "^prod"


def test_dbfilter_custom_odoo_extensions(
cloned_template: Path, supported_odoo_version: float, tmp_path: Path
):
"""Fixes custom Odoo regexp extensions in dbfilter for the backup service."""
with local.cwd(tmp_path):
run_copy(
src_path=str(cloned_template),
dst_path=".",
data={
"odoo_version": supported_odoo_version,
"postgres_version": DBVER_PER_ODOO[supported_odoo_version]["latest"],
"backup_dst": "file:///here",
"odoo_dbfilter": "^%d_%h$",
},
vcs_ref="test",
defaults=True,
overwrite=True,
unsafe=True,
)
prod = DockerClient(compose_files=["prod.yaml"]).compose.config()
assert prod.services["odoo"].environment["DB_FILTER"] == "^%d_%h$$"
assert prod.services["backup"].environment["DBS_TO_INCLUDE"] == "^.*_.*$$"
Loading