generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helm - Add reuse-values when running helm diff
- Loading branch information
Showing
7 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelogs/fragments/20240228-fix-helm-diff-with-reuse-values.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
bugfixes: | ||
- helm - use ``reuse-values`` when running ``helm diff`` command (https://github.com/ansible-collections/kubernetes.core/issues/680). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/integration/targets/helm_diff/files/test-chart-reuse-values/Chart.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: chart-reuse-values | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "1.16.0" |
7 changes: 7 additions & 0 deletions
7
tests/integration/targets/helm_diff/files/test-chart-reuse-values/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: cmap | ||
data: | ||
ansible_version: {{ .Values.ansible_version }} | ||
python_version: {{ .Values.python_version }} |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/helm_diff/files/test-chart-reuse-values/values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ansible_version: 2.16 | ||
python_version: 3.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,3 +299,5 @@ | |
name: "{{ helm_namespace }}" | ||
state: absent | ||
ignore_errors: yes | ||
|
||
- include_tasks: reuse_values.yml |
78 changes: 78 additions & 0 deletions
78
tests/integration/targets/helm_diff/tasks/reuse_values.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
- name: Create temporary directory for helm chart | ||
tempfile: | ||
suffix: .helm | ||
state: directory | ||
register: helm_dir | ||
|
||
- name: Test helm diff functionality | ||
vars: | ||
test_chart_path: "{{ helm_dir.path }}/chart" | ||
helm_namespace: "helm-reuse-values-001" | ||
test_release_name: "myrelease" | ||
|
||
block: | ||
|
||
- name: Install helm diff | ||
helm_plugin: | ||
binary_path: "{{ helm_binary }}" | ||
state: present | ||
plugin_path: https://github.com/databus23/helm-diff | ||
plugin_version: 3.9.4 | ||
|
||
- name: Copy test chart | ||
copy: | ||
src: "test-chart-reuse-values" | ||
dest: "{{ test_chart_path }}" | ||
|
||
- name: Create helm release | ||
kubernetes.core.helm: | ||
state: present | ||
binary_path: "{{ helm_binary }}" | ||
chart_ref: "{{ test_chart_path }}" | ||
release_name: "{{ test_release_name }}" | ||
release_namespace: "{{ helm_namespace }}" | ||
create_namespace: true | ||
release_values: | ||
ansible_version: devel | ||
python_version: 3.11 | ||
wait: true | ||
|
||
- name: Upgrade helm release | ||
kubernetes.core.helm: | ||
binary_path: "{{ helm_binary }}" | ||
chart_ref: "{{ test_chart_path }}" | ||
reset_values: false | ||
reuse_values: true | ||
release_name: "{{ test_release_name }}" | ||
release_namespace: "{{ helm_namespace }}" | ||
values: | ||
ansible_version: devel | ||
register: helm_upgrade | ||
|
||
- name: Ensure task did not reported change | ||
assert: | ||
that: | ||
- helm_upgrade is not changed | ||
|
||
always: | ||
- name: Remove temporary directory | ||
file: | ||
path: "{{ helm_dir.path }}" | ||
state: absent | ||
ignore_errors: true | ||
|
||
- name: Uninstall helm diff | ||
helm_plugin: | ||
binary_path: "{{ helm_binary }}" | ||
state: absent | ||
plugin_name: diff | ||
ignore_errors: true | ||
|
||
- name: Remove helm namespace | ||
k8s: | ||
api_version: v1 | ||
kind: Namespace | ||
name: "{{ helm_namespace }}" | ||
state: absent | ||
ignore_errors: true |