diff --git a/changelogs/fragments/20240611-helm-rc-version.yaml b/changelogs/fragments/20240611-helm-rc-version.yaml new file mode 100644 index 0000000000..28c4dcd4b3 --- /dev/null +++ b/changelogs/fragments/20240611-helm-rc-version.yaml @@ -0,0 +1,2 @@ +bugfixes: + - helm - Helm version checks did not support RC versions. They now accept any version tags. (https://github.com/ansible-collections/kubernetes.core/pull/745). diff --git a/plugins/module_utils/helm.py b/plugins/module_utils/helm.py index faa12c03ad..edc48f6b0c 100644 --- a/plugins/module_utils/helm.py +++ b/plugins/module_utils/helm.py @@ -184,10 +184,10 @@ def get_helm_binary(self): def get_helm_version(self): command = self.get_helm_binary() + " version" rc, out, err = self.run_command(command) - m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out) + m = re.match(r'version.BuildInfo{Version:"v(.*?)",', out) if m: return m.group(1) - m = re.match(r'Client: &version.Version{SemVer:"v([0-9\.]*)", ', out) + m = re.match(r'Client: &version.Version{SemVer:"v(.*?)", ', out) if m: return m.group(1) return None diff --git a/tests/unit/module_utils/test_helm.py b/tests/unit/module_utils/test_helm.py index 5db0a017c8..c4b09e4083 100644 --- a/tests/unit/module_utils/test_helm.py +++ b/tests/unit/module_utils/test_helm.py @@ -200,6 +200,10 @@ def test_module_get_values(_ansible_helm_module, no_values, get_all): 'version.BuildInfo{Version:"v3.10.3", GitCommit:7870ab3ed4135f136eec, GoVersion:"go1.18.9"}', "3.10.3", ), + ( + 'version.BuildInfo{Version:"v3.15.0-rc.1", GitCommit:"d7afa3b6b432c09a02cd07342e908ba5bed34940", GitTreeState:"clean", GoVersion:"go1.22.4"}', + "3.15.0-rc.1", + ), ('Client: &version.Version{SemVer:"v3.12.3", ', "3.12.3"), ('Client: &version.Version{SemVer:"v3.12.3"', None), ],