feat(tiller): add .Release.IsInstall

pull/1687/head
Matt Butcher 9 years ago
parent de7c5e5a38
commit b2d762af48
No known key found for this signature in database
GPG Key ID: DCD5F5E5EF32C345

@ -12,7 +12,8 @@ In the previous section, we use `{{.Release.Name}}` to insert the name of a rele
- `Release.Namespace`: The namespace to be released into (if the manifest doesn't override) - `Release.Namespace`: The namespace to be released into (if the manifest doesn't override)
- `Release.Service`: The name of the releasing service (always `Tiller`). - `Release.Service`: The name of the releasing service (always `Tiller`).
- `Release.Revision`: The revision number of this release. It begins at 1 and is incremented for each `helm upgrade`. - `Release.Revision`: The revision number of this release. It begins at 1 and is incremented for each `helm upgrade`.
- `Release.IsUpgrade`: This is set to `true` if the current operation is an upgrade. - `Release.IsUpgrade`: This is set to `true` if the current operation is an upgrade or rollback.
- `Release.IsInstall`: This is set to `true` if the current operation is an install.
- `Values`: Values passed into the template from the `values.yaml` file and from user-supplied files. By default, `Values` is empty. - `Values`: Values passed into the template from the `values.yaml` file and from user-supplied files. By default, `Values` is empty.
- `Chart`: The contents of the `Chart.yaml` file. Any data in `Chart.yaml` will be accessible here. For example `{{.Chart.Name}}-{{.Chart.Version}}` will print out the `mychart-0.1.0`. - `Chart`: The contents of the `Chart.yaml` file. Any data in `Chart.yaml` will be accessible here. For example `{{.Chart.Name}}-{{.Chart.Version}}` will print out the `mychart-0.1.0`.
- The available fields are listed in the [Charts Guide](charts.md) - The available fields are listed in the [Charts Guide](charts.md)

@ -292,8 +292,9 @@ sensitive_.
- `Release.Namespace`: The namespace the chart was released to. - `Release.Namespace`: The namespace the chart was released to.
- `Release.Service`: The service that conducted the release. Usually - `Release.Service`: The service that conducted the release. Usually
this is `Tiller`. this is `Tiller`.
- `Release.IsUpgrade`: This is set to true if the current operation is an upgrade. - `Release.IsUpgrade`: This is set to true if the current operation is an upgrade or rollback.
It is false for install. - `Release.IsInstall`: This is set to true if the current operation is an
install.
- `Release.Revision`: The revision number. It begins at 1, and increments with - `Release.Revision`: The revision number. It begins at 1, and increments with
each `helm upgrade`. each `helm upgrade`.
- `Chart`: The contents of the `Chart.yaml`. Thus, the chart version is - `Chart`: The contents of the `Chart.yaml`. Thus, the chart version is

@ -305,6 +305,7 @@ type ReleaseOptions struct {
Time *timestamp.Timestamp Time *timestamp.Timestamp
Namespace string Namespace string
IsUpgrade bool IsUpgrade bool
IsInstall bool
Revision int Revision int
} }
@ -317,6 +318,7 @@ func ToRenderValues(chrt *chart.Chart, chrtVals *chart.Config, options ReleaseOp
"Time": options.Time, "Time": options.Time,
"Namespace": options.Namespace, "Namespace": options.Namespace,
"IsUpgrade": options.IsUpgrade, "IsUpgrade": options.IsUpgrade,
"IsInstall": options.IsInstall,
"Revision": options.Revision, "Revision": options.Revision,
"Service": "Tiller", "Service": "Tiller",
}, },

@ -104,6 +104,7 @@ where:
Name: "Seven Voyages", Name: "Seven Voyages",
Time: timeconv.Now(), Time: timeconv.Now(),
Namespace: "al Basrah", Namespace: "al Basrah",
IsInstall: true,
Revision: 5, Revision: 5,
} }
@ -126,6 +127,9 @@ where:
if relmap["IsUpgrade"].(bool) { if relmap["IsUpgrade"].(bool) {
t.Errorf("Expected upgrade to be false.") t.Errorf("Expected upgrade to be false.")
} }
if !relmap["IsInstall"].(bool) {
t.Errorf("Expected install to be true.")
}
if data := res["Files"].(Files)["scheherazade/shahryar.txt"]; string(data) != "1,001 Nights" { if data := res["Files"].(Files)["scheherazade/shahryar.txt"]; string(data) != "1,001 Nights" {
t.Errorf("Expected file '1,001 Nights', got %q", string(data)) t.Errorf("Expected file '1,001 Nights', got %q", string(data))
} }

@ -659,6 +659,7 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
Time: ts, Time: ts,
Namespace: req.Namespace, Namespace: req.Namespace,
Revision: revision, Revision: revision,
IsInstall: true,
} }
valuesToRender, err := chartutil.ToRenderValues(req.Chart, req.Values, options) valuesToRender, err := chartutil.ToRenderValues(req.Chart, req.Values, options)
if err != nil { if err != nil {

Loading…
Cancel
Save