mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-07 13:32:37 +00:00
helm - fix issue for helm command when chart contains space into its name (#657)
* fix issue for helm command when chart contains space into its name
This commit is contained in:
@@ -25,3 +25,4 @@ test_namespace:
|
||||
- "helm-from-repository"
|
||||
- "helm-from-url"
|
||||
- "helm-reuse-values"
|
||||
- "helm-chart-with-space-into-name"
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
- name: Test helm uninstall
|
||||
include_tasks: test_helm_uninstall.yml
|
||||
|
||||
- name: Test helm install with chart name containing space
|
||||
include_tasks: test_helm_with_space_into_chart_name.yml
|
||||
|
||||
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
||||
- name: Test Skip CRDS feature in helm chart install
|
||||
include_tasks: test_crds.yml
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
- name: Create test directory
|
||||
ansible.builtin.tempfile:
|
||||
state: directory
|
||||
suffix: .helm
|
||||
register: test_dir
|
||||
|
||||
- name: Test helm using directory with space
|
||||
vars:
|
||||
helm_dir: "{{ test_dir.path }}/Deploy Chart"
|
||||
helm_namespace: "{{ test_namespace[10] }}"
|
||||
chart_release_name: "deploy-chart-with-space-into-name"
|
||||
helm_local_src: "test-chart"
|
||||
block:
|
||||
- name: Copy helm file into destination
|
||||
ansible.builtin.copy:
|
||||
src: "{{ helm_local_src }}"
|
||||
dest: "{{ helm_dir }}"
|
||||
|
||||
- name: Install chart from local source with Space into name
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: "{{ chart_release_name }}"
|
||||
chart_ref: "{{ helm_dir }}/{{ helm_local_src | basename }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
register: install_chart
|
||||
|
||||
- name: Assert that chart is installed
|
||||
assert:
|
||||
that:
|
||||
- install_chart is changed
|
||||
- install_chart.status.status | lower == 'deployed'
|
||||
|
||||
- name: Check helm_info content
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: "{{ chart_release_name }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
register: chart_info
|
||||
|
||||
- name: Assert that Chart is installed (using helm_info)
|
||||
assert:
|
||||
that:
|
||||
- chart_info.status.status | lower == 'deployed'
|
||||
|
||||
always:
|
||||
- name: Delete temporary directory
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
name: "{{ test_dir.path }}"
|
||||
|
||||
- name: Remove helm namespace
|
||||
k8s:
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
@@ -86,12 +86,12 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
||||
helm.main()
|
||||
helm.run_dep_update.assert_not_called()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm upgrade -i --reset-values test /tmp/path",
|
||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
|
||||
== "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_false(self):
|
||||
@@ -116,12 +116,12 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
||||
helm.main()
|
||||
helm.run_dep_update.assert_not_called()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm upgrade -i --reset-values test /tmp/path",
|
||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
|
||||
== "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_true(self):
|
||||
@@ -145,14 +145,14 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
||||
mock_run_command.assert_has_calls(
|
||||
[
|
||||
call(
|
||||
"/usr/bin/helm upgrade -i --reset-values test /tmp/path",
|
||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
]
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
|
||||
== "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_true_without_dependencies_block(self):
|
||||
@@ -179,14 +179,14 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
|
||||
mock_run_command.assert_has_calls(
|
||||
[
|
||||
call(
|
||||
"/usr/bin/helm upgrade -i --reset-values test /tmp/path",
|
||||
"/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
]
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
|
||||
== "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
|
||||
)
|
||||
|
||||
|
||||
@@ -249,12 +249,12 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
helm.main()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1",
|
||||
"/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1"
|
||||
== "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_False(self):
|
||||
@@ -278,12 +278,12 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
helm.main()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1",
|
||||
"/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1"
|
||||
== "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_True_and_replace_option_disabled(self):
|
||||
@@ -336,12 +336,12 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
helm.main()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test chart1",
|
||||
"/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test 'chart1'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test chart1"
|
||||
== "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test 'chart1'"
|
||||
)
|
||||
|
||||
|
||||
@@ -403,12 +403,12 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
helm.main()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz",
|
||||
"/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz"
|
||||
== "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_False(self):
|
||||
@@ -431,12 +431,12 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
helm.main()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz",
|
||||
"/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz"
|
||||
== "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'"
|
||||
)
|
||||
|
||||
def test_dependency_update_option_True_and_replace_option_disabled(self):
|
||||
@@ -487,10 +487,10 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
helm.main()
|
||||
mock_run_command.assert_called_once_with(
|
||||
"/usr/bin/helm install --dependency-update --replace test http://repo.example/charts/application.tgz",
|
||||
"/usr/bin/helm install --dependency-update --replace test 'http://repo.example/charts/application.tgz'",
|
||||
environ_update={"HELM_NAMESPACE": "test"},
|
||||
)
|
||||
assert (
|
||||
result.exception.args[0]["command"]
|
||||
== "/usr/bin/helm install --dependency-update --replace test http://repo.example/charts/application.tgz"
|
||||
== "/usr/bin/helm install --dependency-update --replace test 'http://repo.example/charts/application.tgz'"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user