Skip to content

Commit

Permalink
feat(chart): set helm.sh/resource-policy: keep
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
  • Loading branch information
hiddeco committed Mar 22, 2024
1 parent 1d03432 commit 56e3025
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions charts/kargo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion charts/kargo/templates/crds.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 3 additions & 1 deletion charts/kargo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56e3025

Please sign in to comment.