From a11d137eedda596bc856781bef2a8ba2d7300e92 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 22 Mar 2024 17:52:58 +0100 Subject: [PATCH] [IMP] oow init : new option --postgresql-version --- newsfragments/option-postgresql-version.feature | 2 ++ odoo_openupgrade_wizard/cli/cli_init.py | 17 ++++++++++++++++- odoo_openupgrade_wizard/templates/config.yml.j2 | 6 +++--- tests/cli_01_init_test.py | 1 + tests/data/output_expected/config.yml | 4 ++-- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 newsfragments/option-postgresql-version.feature diff --git a/newsfragments/option-postgresql-version.feature b/newsfragments/option-postgresql-version.feature new file mode 100644 index 0000000..9a155c4 --- /dev/null +++ b/newsfragments/option-postgresql-version.feature @@ -0,0 +1,2 @@ +Add a new option ``--postgresql-version`` in ``oow init`` command to +define the version of the postgresql image to be used for the project. diff --git a/odoo_openupgrade_wizard/cli/cli_init.py b/odoo_openupgrade_wizard/cli/cli_init.py index cbf532e..1188ffa 100644 --- a/odoo_openupgrade_wizard/cli/cli_init.py +++ b/odoo_openupgrade_wizard/cli/cli_init.py @@ -36,6 +36,15 @@ from odoo_openupgrade_wizard.tools.tools_system import ( prompt=True, type=click.Choice(get_version_options("final")), ) +@click.option( + "--postgresql-version", + required=True, + help="The version of postgresql that will be used" + " to create the postgresql container.Ex : '9.1', '16', ..." + " The version should be available in docker hub." + " (https://hub.docker.com/_/postgres)" + " avoid the 'latest' version if you want a deterministic installation.", +) @click.option( "--extra-repository", "extra_repository_list", @@ -45,7 +54,12 @@ from odoo_openupgrade_wizard.tools.tools_system import ( ) @click.pass_context def init( - ctx, project_name, initial_version, final_version, extra_repository_list + ctx, + project_name, + initial_version, + final_version, + postgresql_version, + extra_repository_list, ): """Initialize OOW Environment based on the initial and the final version of Odoo you want to migrate. @@ -112,6 +126,7 @@ def init( ctx.obj["config_file_path"], "config.yml.j2", project_name=project_name, + postgresql_version=postgresql_version, steps=steps, odoo_versions=odoo_versions, ) diff --git a/odoo_openupgrade_wizard/templates/config.yml.j2 b/odoo_openupgrade_wizard/templates/config.yml.j2 index d435171..6b6ca36 100644 --- a/odoo_openupgrade_wizard/templates/config.yml.j2 +++ b/odoo_openupgrade_wizard/templates/config.yml.j2 @@ -1,9 +1,9 @@ project_name: {{ project_name }} -postgres_image_name: postgres:13 -postgres_container_name: {{project_name}}-container-postgres -postgres_volume_name: {{project_name}}-volume-postgres +postgres_image_name: postgres:{{postgresql_version}} +postgres_container_name: {{project_name}}-container-postgres-{{postgresql_version}} +postgres_volume_name: {{project_name}}-volume-postgres-{{postgresql_version}} postgres_extra_settings: diff --git a/tests/cli_01_init_test.py b/tests/cli_01_init_test.py index 01e1b0c..4456971 100644 --- a/tests/cli_01_init_test.py +++ b/tests/cli_01_init_test.py @@ -16,6 +16,7 @@ def test_cli_init(): "--project-name=test-cli", "--initial-version=14.0", "--final-version=15.0", + "--postgresql-version=13", "--extra-repository=" "OCA/web,OCA/server-tools,OCA/bank-statement-import", ], diff --git a/tests/data/output_expected/config.yml b/tests/data/output_expected/config.yml index c9784ed..03627e8 100644 --- a/tests/data/output_expected/config.yml +++ b/tests/data/output_expected/config.yml @@ -2,8 +2,8 @@ project_name: test-cli postgres_image_name: postgres:13 -postgres_container_name: test-cli-container-postgres -postgres_volume_name: test-cli-volume-postgres +postgres_container_name: test-cli-container-postgres-13 +postgres_volume_name: test-cli-volume-postgres-13 postgres_extra_settings: