Skip to content

Commit

Permalink
helm: Accept release candidate versions for compatibility checks (#745)…
Browse files Browse the repository at this point in the history
… (#753)

This is a backport of PR #745 as merged into main (6a04f42).
SUMMARY

If the helm CLI version includes -rc.1 for example, the version checks fails due to an incomplete regex.
The error can be triggered if you use helm v3.15.0-rc.1 for example, and apply a helm chart with wait: true 
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
helm
helm_pull
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
  • Loading branch information
patchback[bot] authored Jun 18, 2024
1 parent 615d3d8 commit 1c29556
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/20240611-helm-rc-version.yaml
Original file line number Diff line number Diff line change
@@ -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).
4 changes: 2 additions & 2 deletions plugins/module_utils/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/module_utils/test_helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
Expand Down

0 comments on commit 1c29556

Please sign in to comment.