feat(cmd): implement `helm get --template`

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
pull/6493/head
Matthew Fisher 5 years ago
parent 6419ff6961
commit 05d93b2c7a
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -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