From 57aac788e32627257fc9a5c57b33e148ca42ef59 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 3 Oct 2022 13:55:44 +0200 Subject: [PATCH] test_openshift.yaml has for like TAG: TAG_VALUE This fixes bug in case of TAG: \"TAG_VALUE\" is defined Signed-off-by: Petr "Stone" Hracek --- container_workflow_tool/distgit.py | 2 +- setup.py | 2 +- tests/data/test-openshift.yaml | 6 +++--- tests/test_distgit.py | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/container_workflow_tool/distgit.py b/container_workflow_tool/distgit.py index 254d3dc..8dd234a 100644 --- a/container_workflow_tool/distgit.py +++ b/container_workflow_tool/distgit.py @@ -78,7 +78,7 @@ def _update_variable_in_string(self, fdata: str = "", tag: str = "", tag_str: st It replaces OS: OS_VERSION -> OS: " """ self.logger.debug(f"Replaces variable of tag {tag} from {tag_str} to {variable}") - ret = re.sub(rf'{tag}: "{tag_str}"', f"{tag}: \"{variable}\"", fdata) + ret = re.sub(rf"{tag}: {tag_str}", f"{tag}: \"{variable}\"", fdata) return ret def _update_test_openshift_yaml(self, test_openshift_yaml, version: str = "", short_name: str = ""): diff --git a/setup.py b/setup.py index 2e5dddf..248df2e 100755 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ def get_dir(system_path=None, virtual_path=None): setup( name='container-workflow-tool', - version="1.5.0", + version="1.5.1", description='A python3 tool to make rebuilding images easier by automating several steps of the process.', long_description=long_description, long_description_content_type='text/markdown', diff --git a/tests/data/test-openshift.yaml b/tests/data/test-openshift.yaml index 3180488..3e68e5f 100644 --- a/tests/data/test-openshift.yaml +++ b/tests/data/test-openshift.yaml @@ -5,9 +5,9 @@ - openshift environment: - VERSION: "VERSION_NUMBER" - OS: "OS_NUMBER" - SHORT_NAME: "CONTAINER_NAME" + VERSION: VERSION_NUMBER + OS: OS_NUMBER + SHORT_NAME: CONTAINER_NAME IMAGE_FULL_NAME: "{{ image_full_name }}" IMAGE_REGISTRY_URL: "{{ image_registry_url }}" IMAGE_NAMESPACE: "{{ image_namespace }}" diff --git a/tests/test_distgit.py b/tests/test_distgit.py index 04baaa0..8102004 100644 --- a/tests/test_distgit.py +++ b/tests/test_distgit.py @@ -121,12 +121,15 @@ def test_tag_dockerfile(self): [ ("VERSION", "VERSION_NUMBER", "base", True), ("VERSION", "VERSION_NUMBER", "1.14", True), + ("VERSION", "\"VERSION_NUMBER\"", "1.14", False), ("OS", "OS_NUMBER", "rhel8", True), ("VER", "VERSION_NUMBER", "base", False), ("OS", "OS_NUMBER", "rhel9", True), + ("OS", "\"OS_NUMBER\"", "rhel9", False), ("OS", "VERSION_NUMBER", "base", False), ("VERSION", "VERSIONS_NUMBER", "1.14", False), ("SHORT_NAME", "CONTAINER_NAME", "nodejs", True), + ("SHORT_NAME", "\"CONTAINER_NAME\"", "nodejs", False), ("SHORT_NAME", "CONT_NAME", "nodejs", False), ("SHORTNAME", "CONTAINER_NAME", "nodejs", False), ]