You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hips/hip-0027.md
+70-78Lines changed: 70 additions & 78 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ status: "draft"
11
11
12
12
This HIP proposes exposing metadata from the currently deployed chart version during template rendering for upgrade and rollback operations. Currently, Helm templates have access to `.Chart` which provides metadata about the chart being installed (name, version, appVersion, etc.), but no equivalent access to information about the release currently deployed in the cluster. This limitation prevents chart authors from implementing upgrade-aware logic, forcing them to rely on complex workarounds such as post-renderers, pre-upgrade hooks, or manual values file conventions.
13
13
14
-
The proposal introduces a new `.DeployedChart` object available in the template context during `helm upgrade` and `helm rollback`operations. This object contains the same metadata structure as `.Chart` but is populated with values from the chart version currently running in the cluster. When no deployed release exists (such as during initial installation), `.DeployedChart` is nil, allowing templates to safely check for its existence with `{{ if .DeployedChart }}`.
14
+
The proposal introduces a new `.DeployedChart` object available in the template context during all Helm operations. This object contains the same metadata structure as `.Chart` but is populated with values from the chart version currently running in the cluster during upgrade and rollback operations. When no deployed release exists (such as during initial installation, dry-run operations, or when explicitly disabled), `.DeployedChart` is nil, allowing templates to safely check for its existence with `{{ if .DeployedChart }}`.
15
15
16
16
This enhancement enables chart maintainers to build intelligent upgrade paths that can detect version transitions, implement breaking change migrations, conditionally apply resources based on version deltas, and provide seamless user experiences during chart lifecycle operations—all within the chart itself without requiring external tooling. An optional `--disable-deployed-chart` flag allows users to opt out of this feature for security or determinism requirements.
17
17
@@ -93,16 +93,27 @@ This decision provides:
93
93
94
94
### Available During Upgrade and Rollback Operations
95
95
96
-
`.DeployedChart` is populated during both `helm upgrade` and `helm rollback` operations because both scenarios involve transitioning from one deployed state to another. In both cases:
96
+
`.DeployedChart` is always available as a template object but is populated with chart metadata only during `helm upgrade` and `helm rollback` operations when a deployed release exists in the cluster. In all other scenarios, `.DeployedChart` is nil.
97
97
98
-
- There is a currently deployed release that templates may need to reason about
99
-
-Version-aware logic is valuable (e.g., handling migrations, conditional resources)
100
-
-The semantics of "deployed chart" remain clear and unambiguous
98
+
**Populated with chart metadata:**
99
+
-`helm upgrade` (when upgrading an existing release)
100
+
-`helm rollback` (when rolling back to a previous revision)
101
101
102
-
`.DeployedChart` is explicitly **not** available (always nil) during:
103
-
-`helm install`: No deployed chart exists
104
-
-`helm template`: See "Dry-Run and Template Operations" below
105
-
-`helm install --dry-run`: See "Dry-Run and Template Operations" below
102
+
**Always nil:**
103
+
-`helm install` - No deployed release exists yet
104
+
-`helm upgrade` (first install) - Treated as install, no prior release
105
+
-`helm template` - No cluster context available
106
+
-`helm install --dry-run` - No cluster context available
107
+
-`helm upgrade --dry-run` - No cluster access during dry-run
108
+
- When `--disable-deployed-chart` flag is used - Explicitly disabled
109
+
110
+
The object is always present in the template context to ensure templates can be written consistently across all operations. Chart authors can rely on `.DeployedChart` being a valid object reference (though it may be nil) without worrying about undefined variable errors.
111
+
112
+
**Why always available but sometimes nil:**
113
+
- Consistent template behavior - templates don't need to conditional logic to check if the object exists vs. if it has data
114
+
- Follows Go template conventions - nil is the idiomatic way to represent absence of data
115
+
- Simplifies template code - `{{ if .DeployedChart }}` works in all scenarios
116
+
- Enables testing - templates using `.DeployedChart` can be tested with `helm template` without errors
106
117
107
118
### Chart Metadata Only (Not Full Release Data)
108
119
@@ -167,7 +178,9 @@ Chart authors who need to inspect actual cluster state should use the `lookup()`
167
178
168
179
### Dry-Run and Template Operations
169
180
170
-
`.DeployedChart` is **not** available during `helm template` or `helm install --dry-run` operations because these commands are intentionally cluster-agnostic and should remain deterministic without cluster context.
181
+
`.DeployedChart` is always available as a template object but is always nil during `helm template` and dry-run operations (`helm install --dry-run`, `helm upgrade --dry-run`) because these commands are intentionally cluster-agnostic and should remain deterministic without cluster context.
182
+
183
+
The object is present (but nil) to ensure templates that reference `.DeployedChart` don't fail with undefined variable errors during templating and dry-run operations.
171
184
172
185
However, we recognize that chart authors may want to test templates that use `.DeployedChart`. To support this use case:
173
186
@@ -201,13 +214,23 @@ The following outlines the syntax and semantics of the proposed changes.
201
214
202
215
### New Template Object: `.DeployedChart`
203
216
204
-
A new top-level template object `.DeployedChart` will be available during `helm upgrade` and `helm rollback` operations.
217
+
A new top-level template object `.DeployedChart` will be available in all template contexts. The object is populated with chart metadata during `helm upgrade` and `helm rollback` operations when a deployed release exists. In all other scenarios, the object is nil.
218
+
219
+
**Always available:** The `.DeployedChart` object is present in the template context for all Helm operations to ensure consistent template behavior and prevent undefined variable errors.
205
220
206
-
**Availability:**
207
-
-**Available**: `helm upgrade`, `helm rollback`
208
-
-**Not available (nil)**: `helm install`, `helm template`, `helm install --dry-run`, or when `--disable-deployed-chart` flag is used
221
+
**Populated with data:**
222
+
-`helm upgrade` (when upgrading an existing release)
223
+
-`helm rollback` (when rolling back to a previous revision)
209
224
210
-
**Populated from:** The metadata of the chart version currently deployed in the cluster, retrieved from Helm's release record.
225
+
**Always nil:**
226
+
-`helm install` - No deployed release exists
227
+
-`helm upgrade` (first install) - No deployed release exists
228
+
-`helm template` - No cluster context
229
+
-`helm install --dry-run` - No cluster context
230
+
-`helm upgrade --dry-run` - No cluster context during dry-run
231
+
- When `--disable-deployed-chart` flag is used
232
+
233
+
**Populated from:** When not nil, the metadata of the chart version currently deployed in the cluster, retrieved from Helm's release record.
211
234
212
235
### Metadata Fields
213
236
@@ -314,15 +337,18 @@ When this flag is set, `.DeployedChart` will be nil regardless of whether a depl
314
337
315
338
### Behavior During Different Operations
316
339
317
-
| Operation |`.DeployedChart` Value |
318
-
|-----------|----------------------|
319
-
|`helm install`| Always `nil` (no deployed release) |
320
-
|`helm upgrade` (first install) |`nil` (no deployed release) |
0 commit comments