mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-21 12:50:02 +02:00
feat: Add ConditionTemplate support in releaseSpec (#2669)
* feat: Add ConditionTemplate support in releaseSpec Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> * feat: improve testing, clarify doc Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> * feat: update CHANGELOG for ConditionTemplate support and fix test cases for ID generation Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> * Update pkg/state/state_exec_tmpl.go Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> * Update pkg/state/state_exec_tmpl.go Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> * Update docs/configuration.md Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> * refactor: improve comments for condition checks and clean up whitespace Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> --------- Signed-off-by: Arthur Garreau <arthur.garreau98@gmail.com> Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
This commit is contained in:
co-authored by
yxxhero
parent
afdb2487a6
commit
cc85562625
@@ -173,7 +173,7 @@ releases:
|
||||
foo: bar
|
||||
chart: roboll/vault-secret-manager # the chart being installed to create this release, referenced by `repository/chart` syntax
|
||||
version: ~1.24.1 # the semver of the chart. range constraint is supported
|
||||
condition: vault.enabled # The values lookup key for filtering releases. Corresponds to the boolean value of `vault.enabled`, where `vault` is an arbitrary value
|
||||
condition: vault.enabled # Filters releases by the boolean value at `vault.enabled`. Can also be set directly to true or false.
|
||||
missingFileHandler: Warn # set to either "Error" or "Warn". "Error" instructs helmfile to fail when unable to find a values or secrets file. When "Warn", it prints the file and continues.
|
||||
missingFileHandlerConfig:
|
||||
# Ignores missing git branch error so that the Debug/Info/Warn handler can treat a missing branch as non-error.
|
||||
@@ -445,6 +445,12 @@ The following `helmDefaults` fields are also available but not shown in the exam
|
||||
|
||||
### Additional release fields
|
||||
|
||||
#### Condition
|
||||
|
||||
`condition` controls whether a release is enabled. An empty condition enables the release. A direct `true` or `false` value is treated as a literal boolean and bypasses values lookup. Any other condition must be a values lookup path ending in `.enabled`, such as `vault.enabled`.
|
||||
|
||||
`conditionTemplate` is evaluated before `condition` is checked. It must render to a boolean value; when both `condition` and `conditionTemplate` are set, the rendered `conditionTemplate` value replaces `condition`. Like other `*Template` fields, `conditionTemplate` is not evaluated by the `list` command.
|
||||
|
||||
The following per-release fields are also available:
|
||||
|
||||
| Field | Type | Default | Description |
|
||||
@@ -457,6 +463,7 @@ The following per-release fields are also available:
|
||||
| `verifyTemplate` | string | | Templated verify flag (e.g., `{{ .Values.verify \| default "false" }}`) |
|
||||
| `waitTemplate` | string | | Templated wait flag |
|
||||
| `installedTemplate` | string | | Templated installed flag |
|
||||
| `conditionTemplate` | string | | Templated condition flag. Must render to a boolean. When set with `condition`, the rendered value replaces `condition` |
|
||||
| `adopt` | list | | List of resources to adopt (passes `--adopt` to Helm) |
|
||||
| `forceGoGetter` | bool | false | Force go-getter URL parsing for the chart field. Useful when go-getter URL parsing fails unexpectedly |
|
||||
| `forceNamespace` | string | | Force namespace on all K8s resources rendered by the chart, even when the template doesn't use `{{ .Namespace }}`. Use with caution |
|
||||
|
||||
@@ -118,12 +118,15 @@ Release Templating supports the following parts of release definition:
|
||||
|
||||
- basic fields: `name`, `namespace`, `chart`, `version`
|
||||
|
||||
- boolean fields: `installed`, `wait`, `waitForJobs`, `verify` by the means of additional text
|
||||
fields designed for templating only: `installedTemplate`, `waitTemplate`, `verifyTemplate`
|
||||
- boolean fields: `installed`, `wait`, `waitForJobs`, `verify`, `condition` by the means of additional text
|
||||
fields designed for templating only: `installedTemplate`, `waitTemplate`, `verifyTemplate`, `conditionTemplate`.
|
||||
`conditionTemplate` must render to a boolean. When set with `condition`, the rendered value replaces `condition`.
|
||||
`condition` accepts direct `true`/`false` values or a values lookup path ending in `.enabled`, for example `condition: vault.enabled`.
|
||||
|
||||
# ...
|
||||
installedTemplate: '{{`{{ eq .Release.Namespace "kube-system" }}`}}'
|
||||
waitTemplate: '{{`{{ eq .Release.Labels.tag "safe" | not }}`}}'
|
||||
conditionTemplate: '{{`{{ eq .Release.Namespace "kube-system" }}`}}'
|
||||
# ...
|
||||
|
||||
- `set` block values:
|
||||
|
||||
Reference in New Issue
Block a user