github.com/sunilganatra/helm@v3.0.0-beta.3+incompatible/cmd/helm/printer.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "io" 21 "text/template" 22 "time" 23 24 "sigs.k8s.io/yaml" 25 26 "helm.sh/helm/pkg/chartutil" 27 "helm.sh/helm/pkg/release" 28 ) 29 30 var printReleaseTemplate = `REVISION: {{.Release.Version}} 31 RELEASED: {{.ReleaseDate}} 32 CHART: {{.Release.Chart.Metadata.Name}}-{{.Release.Chart.Metadata.Version}} 33 USER-SUPPLIED VALUES: 34 {{.Config}} 35 COMPUTED VALUES: 36 {{.ComputedValues}} 37 HOOKS: 38 {{- range .Release.Hooks }} 39 --- 40 # {{.Name}} 41 {{.Manifest}} 42 {{- end }} 43 MANIFEST: 44 {{.Release.Manifest}} 45 ` 46 47 func printRelease(out io.Writer, rel *release.Release) error { 48 if rel == nil { 49 return nil 50 } 51 52 cfg, err := chartutil.CoalesceValues(rel.Chart, rel.Config) 53 if err != nil { 54 return err 55 } 56 computed, err := cfg.YAML() 57 if err != nil { 58 return err 59 } 60 61 config, err := yaml.Marshal(rel.Config) 62 if err != nil { 63 return err 64 } 65 66 data := map[string]interface{}{ 67 "Release": rel, 68 "Config": string(config), 69 "ComputedValues": computed, 70 "ReleaseDate": rel.Info.LastDeployed.Format(time.ANSIC), 71 } 72 return tpl(printReleaseTemplate, data, out) 73 } 74 75 func tpl(t string, vals map[string]interface{}, out io.Writer) error { 76 tt, err := template.New("_").Parse(t) 77 if err != nil { 78 return err 79 } 80 return tt.Execute(out, vals) 81 }