Commit 8f43b059 authored by Adam Reese's avatar Adam Reese

feat(cli): use template for deployment format

parent 9506757a
...@@ -18,12 +18,26 @@ package main ...@@ -18,12 +18,26 @@ package main
import ( import (
"errors" "errors"
"os"
"regexp" "regexp"
"text/template"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/format" "github.com/kubernetes/helm/pkg/format"
) )
var errMissingDeploymentArg = errors.New("First argument, deployment name, is required. Try 'helm get --help'")
const defaultShowFormat = `Name: {{.Name}}
Status: {{.State.Status}}
{{- with .State.Errors}}
Errors:
{{- range .}}
{{.}}
{{- end}}
{{- end}}
`
func init() { func init() {
addCommands(deploymentCommands()) addCommands(deploymentCommands())
} }
...@@ -103,7 +117,7 @@ func listDeployments(c *cli.Context) error { ...@@ -103,7 +117,7 @@ func listDeployments(c *cli.Context) error {
func deleteDeployment(c *cli.Context) error { func deleteDeployment(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) < 1 { if len(args) < 1 {
return errors.New("First argument, deployment name, is required. Try 'helm get --help'") return errMissingDeploymentArg
} }
for _, name := range args { for _, name := range args {
deployment, err := NewClient(c).DeleteDeployment(name) deployment, err := NewClient(c).DeleteDeployment(name)
...@@ -118,12 +132,13 @@ func deleteDeployment(c *cli.Context) error { ...@@ -118,12 +132,13 @@ func deleteDeployment(c *cli.Context) error {
func showDeployment(c *cli.Context) error { func showDeployment(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) < 1 { if len(args) < 1 {
return errors.New("First argument, deployment name, is required. Try 'helm get --help'") return errMissingDeploymentArg
} }
name := args[0] name := args[0]
deployment, err := NewClient(c).GetDeployment(name) deployment, err := NewClient(c).GetDeployment(name)
if err != nil { if err != nil {
return err return err
} }
return format.YAML(deployment) tmpl := template.Must(template.New("show").Parse(defaultShowFormat))
return tmpl.Execute(os.Stdout, deployment)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment