From 56e30258bab0255f8fa364c2d9852e480b6389b8 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Fri, 22 Mar 2024 11:42:23 +0100 Subject: [PATCH] feat(chart): set `helm.sh/resource-policy: keep` Signed-off-by: Hidde Beydals --- charts/kargo/README.md | 7 ++++--- charts/kargo/templates/crds.yaml | 8 +++++++- charts/kargo/values.yaml | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/charts/kargo/README.md b/charts/kargo/README.md index ef9a5ae25..21481842b 100644 --- a/charts/kargo/README.md +++ b/charts/kargo/README.md @@ -21,9 +21,10 @@ ### CRDs -| Name | Description | Value | -| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -| `crds.install` | Indicates if CRDs should be managed as part of the Helm release. If set to `false`, the CRDs are only installed if they do not already exist. | `true` | +| Name | Description | Value | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | +| `crds.install` | Indicates if Custom Resource Definitions should be installed and upgraded as part of the release. If set to `false`, the CRDs will only be installed if they do not already exist. | `true` | +| `crds.keep` | Indicates if Custom Resource Definitions should be kept when a release is uninstalled. | `true` | ### KubeConfigs diff --git a/charts/kargo/templates/crds.yaml b/charts/kargo/templates/crds.yaml index 5f8f577e8..7271ef541 100644 --- a/charts/kargo/templates/crds.yaml +++ b/charts/kargo/templates/crds.yaml @@ -1,5 +1,11 @@ {{- if .Values.crds.install -}} {{- range $path, $bytes := .Files.Glob "crds/*.yaml" }} -{{ $.Files.Get $path }} +{{- $manifest := $.Files.Get $path | fromYaml }} +{{- if $.Values.crds.keep }} +{{- $newAnnotations := dict "helm.sh/resource-policy" "keep" | merge $manifest.metadata.annotations }} +{{- $_ := set $manifest.metadata "annotations" $newAnnotations }} +{{- end }} +{{- $manifest | toYaml }} +{{- print "\n---\n" }} {{- end }} {{- end }} diff --git a/charts/kargo/values.yaml b/charts/kargo/values.yaml index 74793162c..cec59ef4c 100755 --- a/charts/kargo/values.yaml +++ b/charts/kargo/values.yaml @@ -24,8 +24,10 @@ rbac: ## @section CRDs crds: - ## @param crds.install Indicates if CRDs should be managed as part of the Helm release. If set to `false`, the CRDs are only installed if they do not already exist. + ## @param crds.install Indicates if Custom Resource Definitions should be installed and upgraded as part of the release. If set to `false`, the CRDs will only be installed if they do not already exist. install: true + ## @param crds.keep Indicates if Custom Resource Definitions should be kept when a release is uninstalled. + keep: true ## @section KubeConfigs ## @descriptionStart