diff --git a/docs/chart_template_guide/builtin_objects.md b/docs/chart_template_guide/builtin_objects.md index 98f091eb019844940cecfc65a9cf6d7b4737d812..077b2fc304c3edff27f3f0f22d6e8e143f3152bd 100644 --- a/docs/chart_template_guide/builtin_objects.md +++ b/docs/chart_template_guide/builtin_objects.md @@ -7,12 +7,13 @@ Objects can be simple, and have just one value. Or they can contain other object In the previous section, we use `{{.Release.Name}}` to insert the name of a release into a template. `Release` is one of four top-level objects that you can access in your templates. - `Release`: This object describes the release itself. It has several objects inside of it: - - `Release.Name`: The release name - - `Release.Time`: The time of the release - - `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.Name`: The release name + - `Release.Time`: The time of the release + - `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.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. - `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) diff --git a/docs/charts.md b/docs/charts.md index dd4a12253a5590fbd096b919b2ada0ee7ac3e3e2..d6ccc151232114b83e8495e39f7fb2a47483b6c6 100644 --- a/docs/charts.md +++ b/docs/charts.md @@ -292,8 +292,9 @@ sensitive_. - `Release.Namespace`: The namespace the chart was released to. - `Release.Service`: The service that conducted the release. Usually this is `Tiller`. -- `Release.IsUpgrade`: This is set to true if the current operation is an upgrade. - It is false for install. +- `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. - `Release.Revision`: The revision number. It begins at 1, and increments with each `helm upgrade`. - `Chart`: The contents of the `Chart.yaml`. Thus, the chart version is diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index 7c3cb21fbf3365de61e702d58d6f6cd1a990ebbd..16e1ae9b4dd9f95f8f9b95b0208f389387a0e9f7 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -305,6 +305,7 @@ type ReleaseOptions struct { Time *timestamp.Timestamp Namespace string IsUpgrade bool + IsInstall bool Revision int } @@ -317,6 +318,7 @@ func ToRenderValues(chrt *chart.Chart, chrtVals *chart.Config, options ReleaseOp "Time": options.Time, "Namespace": options.Namespace, "IsUpgrade": options.IsUpgrade, + "IsInstall": options.IsInstall, "Revision": options.Revision, "Service": "Tiller", }, diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index 41da8efe78d3d7787cae897b58e9de99d0d3dd26..0cb86e6efbd138e629c4bd576b4a37d099d2a112 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -104,6 +104,7 @@ where: Name: "Seven Voyages", Time: timeconv.Now(), Namespace: "al Basrah", + IsInstall: true, Revision: 5, } @@ -126,6 +127,9 @@ where: if relmap["IsUpgrade"].(bool) { 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" { t.Errorf("Expected file '1,001 Nights', got %q", string(data)) } diff --git a/pkg/tiller/release_server.go b/pkg/tiller/release_server.go index c3fecc456f350b8a80dfa1e89dc1bd3c1d90e772..51570a9a1926846bab001025c15a15edbbe627b5 100644 --- a/pkg/tiller/release_server.go +++ b/pkg/tiller/release_server.go @@ -659,6 +659,7 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re Time: ts, Namespace: req.Namespace, Revision: revision, + IsInstall: true, } valuesToRender, err := chartutil.ToRenderValues(req.Chart, req.Values, options) if err != nil {