mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
Limit compatibility to Helm =>v3.0.0,<4.0.0 (#1039)
SUMMARY Helm v4 is a major version with backward-incompatible changes, including to the flags and output of the Helm CLI and to the SDK. This version is currently not supported in the kubernetes.core. This PR is related to #1038 and is a short-term solution to mark compatibility explicitly ISSUE TYPE Bugfix Pull Request Docs Pull Request COMPONENT NAME helm helm_template helm_info helm_repository helm_pull helm_registry_auth helm_plugin helm_plugin_info ADDITIONAL INFORMATION Added `validate_helm_version()`` method to AnsibleHelmModule that enforces version constraint >=3.0.0,<4.0.0. Fails fast with clear error message: "Helm version must be >=3.0.0,<4.0.0, current version is {version}" Some modules (i.e. helm_registry_auth) technically is compatible with Helm v4, but validation was added to all helm modules. Partially coauthored by GitHub Copilot with Claude Sonnet 4 model. Addresses issue #1038 Reviewed-by: GomathiselviS <gomathiselvi@gmail.com> Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua> Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: Alina Buzachis Reviewed-by: Bianca Henderson <beeankha@gmail.com>
This commit is contained in:
committed by
GitHub
parent
452fb3d7cb
commit
13791ec7bf
@@ -30,6 +30,10 @@ A collection may contain metadata that identifies these versions.
|
|||||||
PEP440 is the schema used to describe the versions of Ansible.
|
PEP440 is the schema used to describe the versions of Ansible.
|
||||||
<!--end requires_ansible-->
|
<!--end requires_ansible-->
|
||||||
|
|
||||||
|
### Helm Version Compatibility
|
||||||
|
|
||||||
|
Helm modules in this collection are compatible with Helm v3.x and are not yet compatible with Helm v4. Individual modules and their parameters may support a more specific range of Helm versions.
|
||||||
|
|
||||||
### Python Support
|
### Python Support
|
||||||
|
|
||||||
* Collection supports 3.9+
|
* Collection supports 3.9+
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- Limit supported versions of Helm to <4.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/1039).
|
||||||
@@ -27,7 +27,7 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- helm >= 3.0 (https://github.com/helm/helm/releases)
|
- helm >= 3.0, <4.0.0 (https://github.com/helm/helm/releases)
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -401,7 +401,7 @@ Examples
|
|||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
-------------
|
-------------
|
||||||
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
||||||
|
|
||||||
.. raw:: html
|
.. raw:: html
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases) => 3.8.0
|
- helm (https://github.com/helm/helm/releases) >= 3.8.0, <4.0.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -215,7 +215,7 @@ Examples
|
|||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
-------------
|
-------------
|
||||||
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
||||||
|
|
||||||
.. raw:: html
|
.. raw:: html
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,24 @@ class AnsibleHelmModule(object):
|
|||||||
return m.group(1)
|
return m.group(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def validate_helm_version(self):
|
||||||
|
"""
|
||||||
|
Validate that Helm version is >=3.0.0 and <4.0.0.
|
||||||
|
Helm 4 is not yet supported.
|
||||||
|
"""
|
||||||
|
helm_version = self.get_helm_version()
|
||||||
|
if helm_version is None:
|
||||||
|
self.fail_json(msg="Unable to determine Helm version")
|
||||||
|
|
||||||
|
if (LooseVersion(helm_version) < LooseVersion("3.0.0")) or (
|
||||||
|
LooseVersion(helm_version) >= LooseVersion("4.0.0")
|
||||||
|
):
|
||||||
|
self.fail_json(
|
||||||
|
msg="Helm version must be >=3.0.0,<4.0.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def get_values(self, release_name, get_all=False):
|
def get_values(self, release_name, get_all=False):
|
||||||
"""
|
"""
|
||||||
Get Values from deployed release
|
Get Values from deployed release
|
||||||
|
|||||||
@@ -928,6 +928,9 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
chart_ref = module.params.get("chart_ref")
|
chart_ref = module.params.get("chart_ref")
|
||||||
|
|||||||
@@ -245,6 +245,9 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
release_name = module.params.get("release_name")
|
release_name = module.params.get("release_name")
|
||||||
release_state = module.params.get("release_state")
|
release_state = module.params.get("release_state")
|
||||||
get_all_values = module.params.get("get_all_values")
|
get_all_values = module.params.get("get_all_values")
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ def main():
|
|||||||
mutually_exclusive=mutually_exclusive(),
|
mutually_exclusive=mutually_exclusive(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
state = module.params.get("state")
|
state = module.params.get("state")
|
||||||
|
|
||||||
helm_cmd_common = module.get_helm_binary() + " plugin"
|
helm_cmd_common = module.get_helm_binary() + " plugin"
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ def main():
|
|||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
plugin_name = module.params.get("plugin_name")
|
plugin_name = module.params.get("plugin_name")
|
||||||
|
|
||||||
plugin_list = []
|
plugin_list = []
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ description:
|
|||||||
- There are options for unpacking the chart after download.
|
- There are options for unpacking the chart after download.
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm >= 3.0 (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0, <4.0.0 (https://github.com/helm/helm/releases)"
|
||||||
|
|
||||||
options:
|
options:
|
||||||
chart_ref:
|
chart_ref:
|
||||||
@@ -220,13 +220,10 @@ def main():
|
|||||||
mutually_exclusive=[("chart_version", "chart_devel")],
|
mutually_exclusive=[("chart_version", "chart_devel")],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
helm_version = module.get_helm_version()
|
helm_version = module.get_helm_version()
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.0.0"):
|
|
||||||
module.fail_json(
|
|
||||||
msg="This module requires helm >= 3.0.0, current version is {0}".format(
|
|
||||||
helm_version
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
helm_pull_opt_versionning = dict(
|
helm_pull_opt_versionning = dict(
|
||||||
skip_tls_certs_check="3.3.0",
|
skip_tls_certs_check="3.3.0",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ author:
|
|||||||
- Yuriy Novostavskiy (@yurnov)
|
- Yuriy Novostavskiy (@yurnov)
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases) => 3.8.0"
|
- "helm (https://github.com/helm/helm/releases) >= 3.8.0, <4.0.0"
|
||||||
|
|
||||||
description:
|
description:
|
||||||
- Helm registry authentication module allows you to login C(helm registry login) and logout C(helm registry logout) from a Helm registry.
|
- Helm registry authentication module allows you to login C(helm registry login) and logout C(helm registry logout) from a Helm registry.
|
||||||
@@ -194,6 +194,9 @@ def main():
|
|||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
host = module.params.get("host")
|
host = module.params.get("host")
|
||||||
|
|||||||
@@ -295,6 +295,9 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
repo_name = module.params.get("repo_name")
|
repo_name = module.params.get("repo_name")
|
||||||
|
|||||||
@@ -347,6 +347,9 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
|
# Validate Helm version >=3.0.0,<4.0.0
|
||||||
|
module.validate_helm_version()
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
helm_cmd = module.get_helm_binary()
|
||||||
|
|
||||||
if plain_http:
|
if plain_http:
|
||||||
|
|||||||
@@ -7,3 +7,4 @@
|
|||||||
- "v3.15.4"
|
- "v3.15.4"
|
||||||
- "v3.16.0"
|
- "v3.16.0"
|
||||||
- "v3.17.0"
|
- "v3.17.0"
|
||||||
|
- "v4.0.0"
|
||||||
|
|||||||
@@ -13,10 +13,15 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: install_helm
|
name: install_helm
|
||||||
|
|
||||||
- name: "Ensure we honor the environment variables"
|
- name: Main helm tests with Helm v3
|
||||||
include_tasks: test_read_envvars.yml
|
when: helm_version != "v4.0.0"
|
||||||
|
block:
|
||||||
|
|
||||||
- name: Deploy charts
|
- name: "Ensure we honor the environment variables"
|
||||||
|
include_tasks: test_read_envvars.yml
|
||||||
|
when: helm_version != "v4.0.0"
|
||||||
|
|
||||||
|
- name: Deploy charts
|
||||||
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_chart_type
|
loop_var: test_chart_type
|
||||||
@@ -25,34 +30,37 @@
|
|||||||
- from_repository
|
- from_repository
|
||||||
- from_url
|
- from_url
|
||||||
|
|
||||||
- name: test helm upgrade with reuse_values
|
- name: test helm upgrade with reuse_values
|
||||||
include_tasks: test_helm_reuse_values.yml
|
include_tasks: test_helm_reuse_values.yml
|
||||||
|
|
||||||
- name: test helm upgrade with reset_then_reuse_values
|
- name: test helm upgrade with reset_then_reuse_values
|
||||||
include_tasks: test_helm_reset_then_reuse_values.yml
|
include_tasks: test_helm_reset_then_reuse_values.yml
|
||||||
|
|
||||||
- name: test helm dependency update
|
- name: test helm dependency update
|
||||||
include_tasks: test_up_dep.yml
|
include_tasks: test_up_dep.yml
|
||||||
|
|
||||||
- name: Test helm uninstall
|
- name: Test helm uninstall
|
||||||
include_tasks: test_helm_uninstall.yml
|
include_tasks: test_helm_uninstall.yml
|
||||||
|
|
||||||
- name: Test helm install with chart name containing space
|
- name: Test helm install with chart name containing space
|
||||||
include_tasks: test_helm_with_space_into_chart_name.yml
|
include_tasks: test_helm_with_space_into_chart_name.yml
|
||||||
|
|
||||||
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
||||||
- name: Test Skip CRDS feature in helm chart install
|
- name: Test Skip CRDS feature in helm chart install
|
||||||
include_tasks: test_crds.yml
|
include_tasks: test_crds.yml
|
||||||
|
|
||||||
- name: Test insecure registry flag feature
|
- name: Test insecure registry flag feature
|
||||||
include_tasks: test_helm_insecure.yml
|
include_tasks: test_helm_insecure.yml
|
||||||
|
|
||||||
- name: Test take ownership flag feature
|
- name: Test take ownership flag feature
|
||||||
include_tasks: test_helm_take_ownership.yml
|
include_tasks: test_helm_take_ownership.yml
|
||||||
|
|
||||||
- name: Test helm skip_schema_validation
|
- name: Test helm skip_schema_validation
|
||||||
include_tasks: test_skip_schema_validation.yml
|
include_tasks: test_skip_schema_validation.yml
|
||||||
|
|
||||||
|
- name: Test helm version
|
||||||
|
include_tasks: test_helm_version.yml
|
||||||
|
|
||||||
- name: Clean helm install
|
- name: Clean helm install
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
|
|||||||
47
tests/integration/targets/helm/tasks/test_helm_version.yml
Normal file
47
tests/integration/targets/helm/tasks/test_helm_version.yml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
- name: Test helm reuse_values
|
||||||
|
vars:
|
||||||
|
helm_namespace: "{{ test_namespace[14] }}"
|
||||||
|
chart_release_values:
|
||||||
|
replica:
|
||||||
|
replicaCount: 3
|
||||||
|
master:
|
||||||
|
count: 1
|
||||||
|
kind: Deployment
|
||||||
|
chart_reuse_values:
|
||||||
|
replica:
|
||||||
|
replicaCount: 1
|
||||||
|
master:
|
||||||
|
count: 3
|
||||||
|
block:
|
||||||
|
- name: Initial chart installation
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
|
||||||
|
release_name: test-redis
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
create_namespace: true
|
||||||
|
release_values: "{{ chart_release_values }}"
|
||||||
|
register: install
|
||||||
|
ignore_errors: true
|
||||||
|
when: helm_version == "v4.0.0"
|
||||||
|
|
||||||
|
- name: Debug install result
|
||||||
|
debug:
|
||||||
|
var: install
|
||||||
|
when: helm_version == "v4.0.0"
|
||||||
|
|
||||||
|
- name: Ensure helm installation was failed for v4.0.0
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install is failed
|
||||||
|
- "'Helm version must be >=3.0.0,<4.0.0' in install.msg"
|
||||||
|
when: helm_version == "v4.0.0"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove helm namespace
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: "{{ helm_namespace }}"
|
||||||
|
state: absent
|
||||||
@@ -443,3 +443,46 @@ def test_module_get_helm_set_values_args(set_values, expected):
|
|||||||
|
|
||||||
result = helm_module.get_helm_set_values_args(set_values)
|
result = helm_module.get_helm_set_values_args(set_values)
|
||||||
assert " ".join(expected) == result
|
assert " ".join(expected) == result
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"helm_version,should_fail",
|
||||||
|
[
|
||||||
|
("3.0.0", False),
|
||||||
|
("3.5.0", False),
|
||||||
|
("3.10.3", False),
|
||||||
|
("3.15.0", False),
|
||||||
|
("3.17.0", False),
|
||||||
|
("2.9.0", True),
|
||||||
|
("2.17.0", True),
|
||||||
|
("4.0.0", True),
|
||||||
|
("4.1.0", True),
|
||||||
|
("5.0.0", True),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_module_validate_helm_version(_ansible_helm_module, helm_version, should_fail):
|
||||||
|
_ansible_helm_module.get_helm_version = MagicMock()
|
||||||
|
_ansible_helm_module.get_helm_version.return_value = helm_version
|
||||||
|
|
||||||
|
if should_fail:
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
_ansible_helm_module.validate_helm_version()
|
||||||
|
_ansible_helm_module.fail_json.assert_called_once()
|
||||||
|
call_args = _ansible_helm_module.fail_json.call_args
|
||||||
|
assert "Helm version must be >=3.0.0,<4.0.0" in call_args[1]["msg"]
|
||||||
|
assert helm_version in call_args[1]["msg"]
|
||||||
|
else:
|
||||||
|
_ansible_helm_module.validate_helm_version()
|
||||||
|
_ansible_helm_module.fail_json.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
def test_module_validate_helm_version_none(_ansible_helm_module):
|
||||||
|
_ansible_helm_module.get_helm_version = MagicMock()
|
||||||
|
_ansible_helm_module.get_helm_version.return_value = None
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
_ansible_helm_module.validate_helm_version()
|
||||||
|
|
||||||
|
_ansible_helm_module.fail_json.assert_called_once_with(
|
||||||
|
msg="Unable to determine Helm version"
|
||||||
|
)
|
||||||
|
|||||||
@@ -43,15 +43,21 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
def test_dependency_update_option_not_defined(self):
|
def test_dependency_update_option_not_defined(self):
|
||||||
set_module_args({"chart_ref": "/tmp/path"})
|
set_module_args({"chart_ref": "/tmp/path"})
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm_template.main()
|
helm_template.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call was the actual helm template command
|
||||||
"/usr/bin/helm template /tmp/path", environ_update={}, data=None
|
assert (
|
||||||
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
|
== "/usr/bin/helm template /tmp/path"
|
||||||
)
|
)
|
||||||
assert result.exception.args[0]["command"] == "/usr/bin/helm template /tmp/path"
|
assert result.exception.args[0]["command"] == "/usr/bin/helm template /tmp/path"
|
||||||
|
|
||||||
@@ -64,17 +70,21 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm_template.main()
|
helm_template.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call was the actual helm template command
|
||||||
"/usr/bin/helm template test --repo=https://charts.com/test",
|
assert (
|
||||||
environ_update={},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm template test --repo=https://charts.com/test"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -86,17 +96,21 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
{"chart_ref": "https://charts/example.tgz", "dependency_update": True}
|
{"chart_ref": "https://charts/example.tgz", "dependency_update": True}
|
||||||
)
|
)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm_template.main()
|
helm_template.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call was the actual helm template command
|
||||||
"/usr/bin/helm template https://charts/example.tgz --dependency-update",
|
assert (
|
||||||
environ_update={},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm template https://charts/example.tgz --dependency-update"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import MagicMock, call, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from ansible.module_utils import basic
|
from ansible.module_utils import basic
|
||||||
from ansible_collections.kubernetes.core.plugins.modules import helm
|
from ansible_collections.kubernetes.core.plugins.modules import helm
|
||||||
@@ -77,18 +77,22 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
helm.run_dep_update = MagicMock()
|
helm.run_dep_update = MagicMock()
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
helm.run_dep_update.assert_not_called()
|
helm.run_dep_update.assert_not_called()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -108,18 +112,22 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
helm.run_dep_update = MagicMock()
|
helm.run_dep_update = MagicMock()
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
helm.run_dep_update.assert_not_called()
|
helm.run_dep_update.assert_not_called()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -139,19 +147,23 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_with_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_with_dep)
|
||||||
|
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = 0, "configuration updated", ""
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
|
"",
|
||||||
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with patch.object(basic.AnsibleModule, "warn") as mock_warn:
|
with patch.object(basic.AnsibleModule, "warn") as mock_warn:
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_warn.assert_not_called()
|
mock_warn.assert_not_called()
|
||||||
mock_run_command.assert_has_calls(
|
# Check calls include the actual helm command (after version check)
|
||||||
[
|
assert any(
|
||||||
call(
|
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'" in str(call)
|
||||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
for call in mock_run_command.call_args_list
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
|
||||||
data=None,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -170,23 +182,23 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with patch.object(basic.AnsibleModule, "warn") as mock_warn:
|
with patch.object(basic.AnsibleModule, "warn") as mock_warn:
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_warn.assert_called_once()
|
mock_warn.assert_called_once()
|
||||||
mock_run_command.assert_has_calls(
|
# Check calls include the actual helm command (after version check)
|
||||||
[
|
assert any(
|
||||||
call(
|
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'" in str(call)
|
||||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
for call in mock_run_command.call_args_list
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
|
||||||
data=None,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -245,17 +257,21 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -275,17 +291,21 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -305,11 +325,15 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_with_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_with_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleFailJson) as result:
|
with self.assertRaises(AnsibleFailJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
# mock_run_command.assert_called_once_with('/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1',
|
# mock_run_command.assert_called_once_with('/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1',
|
||||||
@@ -334,17 +358,21 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test 'chart1'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test 'chart1'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -402,17 +430,21 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -431,17 +463,21 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
@@ -460,11 +496,15 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_with_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_with_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleFailJson) as result:
|
with self.assertRaises(AnsibleFailJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
# mock_run_command.assert_called_once_with('/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1',
|
# mock_run_command.assert_called_once_with('/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1',
|
||||||
@@ -488,17 +528,21 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
|||||||
helm.get_release_status = MagicMock(return_value=None)
|
helm.get_release_status = MagicMock(return_value=None)
|
||||||
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
helm.fetch_chart_info = MagicMock(return_value=self.chart_info_without_dep)
|
||||||
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
with patch.object(basic.AnsibleModule, "run_command") as mock_run_command:
|
||||||
mock_run_command.return_value = (
|
# Mock responses: first call is helm version, second is the actual command
|
||||||
|
mock_run_command.side_effect = [
|
||||||
|
(
|
||||||
0,
|
0,
|
||||||
"configuration updated",
|
'version.BuildInfo{Version:"v3.10.0", GitCommit:"", GoVersion:"go1.18"}',
|
||||||
"",
|
"",
|
||||||
) # successful execution
|
),
|
||||||
|
(0, "configuration updated", ""),
|
||||||
|
]
|
||||||
with self.assertRaises(AnsibleExitJson) as result:
|
with self.assertRaises(AnsibleExitJson) as result:
|
||||||
helm.main()
|
helm.main()
|
||||||
mock_run_command.assert_called_once_with(
|
# Check the last call (actual helm command, after version check)
|
||||||
"/usr/bin/helm install --dependency-update --replace test 'http://repo.example/charts/application.tgz'",
|
assert (
|
||||||
environ_update={"HELM_NAMESPACE": "test"},
|
mock_run_command.call_args_list[-1][0][0]
|
||||||
data=None,
|
== "/usr/bin/helm install --dependency-update --replace test 'http://repo.example/charts/application.tgz'"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result.exception.args[0]["command"]
|
result.exception.args[0]["command"]
|
||||||
|
|||||||
Reference in New Issue
Block a user