forked from helm/helm-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.go
45 lines (37 loc) · 991 Bytes
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package action
import (
"text/template"
"github.com/helm/helm/chart"
"github.com/helm/helm/log"
helm "github.com/helm/helm/util"
)
const defaultInfoFormat = `Name: {{.Name}}
Home: {{.Home}}
Version: {{.Version}}
Description: {{.Description}}
Details: {{.Details}}
`
// Info prints information about a chart.
//
// - chartName to display
// - homeDir is the helm home directory for the user
// - format is a optional Go template
func Info(chartName, homedir, format string) {
r := mustConfig(homedir).Repos
table, chartLocal := r.RepoChart(chartName)
chartPath := helm.CacheDirectory(homedir, table, chartLocal, Chartfile)
if format == "" {
format = defaultInfoFormat
}
chart, err := chart.LoadChartfile(chartPath)
if err != nil {
log.Die("Could not find chart %s: %s", chartName, err.Error())
}
tmpl, err := template.New("info").Parse(format)
if err != nil {
log.Die("%s", err)
}
if err = tmpl.Execute(log.Stdout, chart); err != nil {
log.Die("%s", err)
}
}