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
This HIP proposes exposing metadata from the currently deployed chart version during template rendering. Currently, Helm templates have access to `.Chart` for the chart being installed but no equivalent access to the currently deployed release. This forces chart authors to use complex workarounds like post-renderers, pre-upgrade hooks, or manual values conventions to implement version-aware upgrade logic.
12
+
This HIP proposes exposing metadata from currently deployed chart versions during template rendering. Currently, Helm templates have access to `.Chart` for the chart being installed but no equivalent access to deployed releases. This forces chart authors to use complex workarounds like post-renderers, pre-upgrade hooks, or manual values conventions to implement version-aware upgrade logic.
13
13
14
-
The proposal introduces a new `.DeployedChart` object available in all template contexts, populated with the deployed chart's metadata during `helm upgrade` and `helm rollback` operations. When no deployed release exists, `.DeployedChart` is nil, allowing safe checks with `{{ if .DeployedChart }}`. An optional `--disable-deployed-chart` flag provides opt-out capability.
14
+
The proposal introduces `.DeployedChart` (singular, latest deployed) and `.DeployedCharts` (array, multiple versions) objects available in all template contexts, populated during `helm upgrade` and `helm rollback` operations. The `--deployed-depth` flag controls how many deployed versions to retrieve (default: 1), with `--deployed-depth 0` disabling the feature.
### Naming: `.DeployedChart` and `.DeployedCharts`
42
+
43
+
`.DeployedChart` (singular) provides ergonomic access to the most recent deployed version. `.DeployedCharts` (array) provides access to historical deployed versions in reverse chronological order (index 0 is most recent). `.DeployedChart` is syntactic sugar for `.DeployedCharts[0]`.
42
44
43
45
Alternatives considered and rejected:
46
+
44
47
-`.PreviousChart` - Ambiguous during rollbacks
45
48
-`.InstalledChart` - Confusing with current installation
46
49
-`.CurrentChart` - Ambiguous which is "current"
47
50
-`.Release.Deployed.Chart` - Unnecessarily nested
48
51
49
-
`.DeployedChart` unambiguously means "what is currently running in the cluster" and maintains consistency with Helm terminology.
52
+
### Always Available as Template Objects
50
53
51
-
### Always Available as Template Object
52
-
53
-
`.DeployedChart` is always present (though possibly nil) to ensure consistent template behavior, prevent undefined variable errors, and enable testing with `helm template`.
54
+
`.DeployedChart` (nil or chart metadata) and `.DeployedCharts` (empty array or populated) are always present to ensure consistent template behavior, prevent undefined variable errors, and enable testing with `helm template`.
54
55
55
56
### Populated Only During Upgrades/Rollbacks
56
57
57
-
`.DeployedChart` contains chart metadata only during `helm upgrade` and `helm rollback` when a deployed release exists. It's nil for:
58
+
`.DeployedChart`/`.DeployedCharts` contain chart metadata only during `helm upgrade` and `helm rollback` when deployed releases exist. During rollback, they reflect the currently deployed version (being rolled back _from_). They're nil/empty for:
59
+
58
60
-`helm install` - No deployed release
59
61
-`helm template` / dry-runs - No cluster context
60
-
- When `--disable-deployed-chart` is used
62
+
- When `--deployed-depth 0` is used
61
63
62
64
### Chart Metadata Only
63
65
64
66
This proposal exposes only Chart.yaml metadata (same structure as `.Chart`), not values, manifests, or release metadata. This maintains security (values may contain secrets), performance (manifests can be large), and simplicity while solving 90% of use cases. Future HIPs could extend this if needed.
65
67
66
-
### Opt-Out Flag
68
+
### Depth Control Flag
67
69
68
-
The `--disable-deployed-chart` flag allows organizations to disable the feature for security or determinism requirements. A CLI flag was chosen over environment variables for explicitness and consistency with Helm's patterns.
70
+
The `--deployed-depth` flag controls how many deployed chart versions to retrieve (default: 1). Setting `--deployed-depth 0` disables the feature for security or determinism requirements. Higher depths may impact performance and should only be used for specific multi-version migration scenarios.
69
71
70
72
### Design Decisions
71
73
@@ -75,17 +77,20 @@ The `--disable-deployed-chart` flag allows organizations to disable the feature
75
77
76
78
## Specification
77
79
78
-
### New Template Object: `.DeployedChart`
80
+
### New Template Objects
79
81
80
-
A top-level template object available in all contexts. Populated with deployed chart metadata during upgrade/rollback; nil otherwise.
82
+
**`.DeployedChart`**: Singular object containing the most recent deployed chart metadata (nil if none exists). Syntactic sugar for `.DeployedCharts[0]`.
81
83
82
-
**Metadata Structure:** Identical to `.Chart`, including `Name`, `Version`, `AppVersion`, and other [Chart.yaml fields](https://helm.sh/docs/topics/charts/#the-chartyaml-file).
84
+
**`.DeployedCharts`**: Array of deployed chart metadata objects in reverse chronological order (most recent first). Empty array if no deployed releases exist.
85
+
86
+
**Metadata Structure:** Each chart object is identical to `.Chart`, including `Name`, `Version`, `AppVersion`, and other [Chart.yaml fields](https://helm.sh/docs/topics/charts/#the-chartyaml-file).
87
+
88
+
**Usage Examples:**
83
89
84
-
**Usage Example:**
85
90
```yaml
91
+
# Simple case: check latest deployed version
86
92
{{- if .DeployedChart }}
87
93
{{- if and (semverCompare ">=2.0.0" .Chart.Version) (semverCompare "<2.0.0" .DeployedChart.Version) }}
|`--deployed-depth N`| Up to N most recent deployed versions |
122
144
123
145
## Backwards Compatibility
124
146
125
-
Fully backwards compatible. The `.DeployedChart`object is purely additive—existing charts work unchanged. Go templates handle nil safely; the recommended `{{ if .DeployedChart }}` pattern works in all scenarios.
147
+
Fully backwards compatible. The `.DeployedChart`and `.DeployedCharts` objects are purely additive—existing charts work unchanged. Go templates handle nil and empty arrays safely; the recommended `{{ if .DeployedChart }}` pattern works in all scenarios.
126
148
127
149
## Security Implications
128
150
129
151
**Not Exposed:** Previous values (may contain secrets) or previous manifest (may contain sensitive data). Only Chart.yaml metadata is exposed.
130
152
131
-
**Considerations:** Chart authors should not store sensitive data in Chart.yaml. The `--disable-deployed-chart` flag provides opt-out for security-sensitive environments.
153
+
**Considerations:** Chart authors should not store sensitive data in Chart.yaml. The `--deployed-depth 0` flag provides opt-out for security-sensitive environments. Higher depth values increase data exposure; use the minimum required.
132
154
133
155
## How to Teach This
134
156
135
157
### Documentation Additions
136
158
137
-
1.**Template Objects Reference:** Add `.DeployedChart` to built-in objects with availability details
138
-
2.**Upgrade Guide:** "Implementing Version-Aware Upgrades" covering nil checks, version comparisons, and best practices
139
-
3.**Migration Examples:** Show replacement of post-renderers and pre-upgrade hooks with `.DeployedChart`
140
-
4.**Chart Linting:** Update `helm lint` to warn on `.DeployedChart` usage without nil checks
159
+
1.**Template Objects Reference:** Add `.DeployedChart` and `.DeployedCharts` to built-in objects with availability details
160
+
2.**Upgrade Guide:** "Implementing Version-Aware Upgrades" covering nil/empty checks, version comparisons, and best practices
161
+
3.**Migration Examples:** Show replacement of post-renderers and pre-upgrade hooks
162
+
4.**Performance Note:** Document that `--deployed-depth` should be kept minimal; default of 1 is recommended
163
+
5.**Chart Linting:** Update `helm lint` to warn on usage without nil/empty checks
141
164
142
165
### Key Example Pattern
143
166
@@ -150,22 +173,27 @@ Fully backwards compatible. The `.DeployedChart` object is purely additive—exi
150
173
## Reference Implementation
151
174
152
175
A future pull request will:
153
-
1. Extend template rendering context to include `.DeployedChart`
154
-
2. Populate from release records during upgrade/rollback
155
-
3. Add `--disable-deployed-chart` flag
156
-
4. Include comprehensive unit and integration tests
176
+
177
+
1. Extend template rendering context to include `.DeployedChart` and `.DeployedCharts`
178
+
2. Populate from release records during upgrade/rollback (reverse chronological order)
179
+
3. Add `--deployed-depth` flag (default: 1)
180
+
4. Implement `.DeployedChart` as alias to `.DeployedCharts[0]`
181
+
5. Include comprehensive unit and integration tests covering depth behavior
0 commit comments