Merge pull request #6493 from bacongobbler/port-5496

feat(cmd): implement `helm get --template`
pull/6400/head
Matthew Fisher 5 years ago committed by GitHub
commit 7817fe2a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -39,6 +39,7 @@ chart, the supplied values, and the generated manifest file.
`
func newGetCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
var template string
client := action.NewGet(cfg)
cmd := &cobra.Command{
@ -51,11 +52,19 @@ func newGetCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
if err != nil {
return err
}
if template != "" {
data := map[string]interface{}{
"Release": res,
}
return tpl(template, data, out)
}
return printRelease(out, res)
},
}
cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision")
f := cmd.Flags()
f.IntVar(&client.Version, "revision", 0, "get the named release with revision")
f.StringVar(&template, "template", "", "go template for formatting the output, eg: {{.Release.Name}}")
cmd.AddCommand(newGetValuesCmd(cfg, out))
cmd.AddCommand(newGetManifestCmd(cfg, out))

@ -28,6 +28,11 @@ func TestGetCmd(t *testing.T) {
cmd: "get thomas-guide",
golden: "output/get-release.txt",
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})},
}, {
name: "get with a formatted release",
cmd: "get elevated-turkey --template {{.Release.Chart.Metadata.Version}}",
golden: "output/get-release-template.txt",
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "elevated-turkey"})},
}, {
name: "get requires release name arg",
cmd: "get",

Loading…
Cancel
Save