Commit b2ef24fb authored by Brendan Burns's avatar Brendan Burns

Address comments.

parent f7bd5a6f
......@@ -51,7 +51,8 @@ var (
verbose = flag.Bool("verbose", false, "If true, print extra information")
proxy = flag.Bool("proxy", false, "If true, run a proxy to the api server")
www = flag.String("www", "", "If -proxy is true, use this directory to serve static files")
templateFile = flag.String("template", "", "If present load this file as a golang template and us it for output printing")
templateFile = flag.String("template_file", "", "If present load this file as a golang template and us it for output printing")
templateStr = flag.String("template", "", "If present parse this string as a golang template and us it for output printing")
)
func usage() {
......@@ -186,15 +187,22 @@ func executeAPIRequest(method string, s *kube_client.Client) bool {
}
var printer kubecfg.ResourcePrinter
if *json {
switch {
case *json:
printer = &kubecfg.IdentityPrinter{}
} else if *yaml {
case *yaml:
printer = &kubecfg.YAMLPrinter{}
} else if len(*templateFile) > 0 {
data, err := ioutil.ReadFile(*templateFile)
if err != nil {
glog.Fatalf("Error reading template %s, %v\n", *templateFile, err)
return false
case len(*templateFile) > 0 || len(*templateStr) > 0:
var data []byte
if len(*templateFile) > 0 {
var err error
data, err = ioutil.ReadFile(*templateFile)
if err != nil {
glog.Fatalf("Error reading template %s, %v\n", *templateFile, err)
return false
}
} else {
data = []byte(*templateStr)
}
tmpl, err := template.New("output").Parse(string(data))
if err != nil {
......@@ -204,7 +212,7 @@ func executeAPIRequest(method string, s *kube_client.Client) bool {
printer = &kubecfg.TemplatePrinter{
Template: tmpl,
}
} else {
default:
printer = &kubecfg.HumanReadablePrinter{}
}
......
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