Add helm_repository module and fix review suggestion

This commit is contained in:
LucasBoisserie
2020-04-25 12:20:12 +02:00
parent e89aa1c692
commit 1a23994448
6 changed files with 293 additions and 12 deletions

View File

@@ -12,6 +12,9 @@
- name: "Install {{ helm_version }}"
include_tasks: install.yml
- name: tests_repository
include_tasks: tests_repository.yml
- name: Deploy charts
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
loop_control:

View File

@@ -1,11 +1,19 @@
---
- name: Add chart repo
shell: "helm repo add stable {{ chart_test_repo }}"
helm_repository:
name: test_helm
repo_url: "{{ chart_test_repo }}"
- name: Install Chart from repository
include_tasks: "../tests_chart.yml"
vars:
source: repository
chart_source: "stable/{{ chart_test }}"
chart_source: "test_helm/{{ chart_test }}"
chart_source_version: "{{ chart_test_version }}"
chart_source_version_upgrade: "{{ chart_test_version_upgrade }}"
- name: Add chart repo
helm_repository:
name: test_helm
repo_url: "{{ chart_test_repo }}"
state: absent

View File

@@ -0,0 +1,61 @@
---
- name: "Ensure test_helm_repo doesn't exist"
helm_repository:
name: test_helm_repo
state: absent
- name: Add test_helm_repo chart repository
helm_repository:
name: test_helm_repo
repo_url: "{{ chart_test_repo }}"
register: repository
- name: Assert that test_helm_repo repository is added
assert:
that:
- repository is changed
- name: Check idempotency
helm_repository:
name: test_helm_repo
repo_url: "{{ chart_test_repo }}"
register: repository
- name: Assert idempotency
assert:
that:
- repository is not changed
- name: Failed to add repository with the same name
helm_repository:
name: test_helm_repo
repo_url: "https://other-charts.url"
register: repository_errors
ignore_errors: yes
- name: Assert that adding repository with the same name failed
assert:
that:
- repository_errors is failed
- name: Remove test_helm_repo chart repository
helm_repository:
name: test_helm_repo
state: absent
register: repository
- name: Assert that test_helm_repo repository is removed
assert:
that:
- repository is changed
- name: Check idempotency after remove
helm_repository:
name: test_helm_repo
state: absent
register: repository
- name: Assert idempotency
assert:
that:
- repository is not changed