mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Address comments.
This commit is contained in:
parent
f7bd5a6f0f
commit
b2ef24fb48
@ -51,7 +51,8 @@ var (
|
|||||||
verbose = flag.Bool("verbose", false, "If true, print extra information")
|
verbose = flag.Bool("verbose", false, "If true, print extra information")
|
||||||
proxy = flag.Bool("proxy", false, "If true, run a proxy to the api server")
|
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")
|
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() {
|
func usage() {
|
||||||
@ -186,15 +187,22 @@ func executeAPIRequest(method string, s *kube_client.Client) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var printer kubecfg.ResourcePrinter
|
var printer kubecfg.ResourcePrinter
|
||||||
if *json {
|
switch {
|
||||||
|
case *json:
|
||||||
printer = &kubecfg.IdentityPrinter{}
|
printer = &kubecfg.IdentityPrinter{}
|
||||||
} else if *yaml {
|
case *yaml:
|
||||||
printer = &kubecfg.YAMLPrinter{}
|
printer = &kubecfg.YAMLPrinter{}
|
||||||
} else if len(*templateFile) > 0 {
|
case len(*templateFile) > 0 || len(*templateStr) > 0:
|
||||||
data, err := ioutil.ReadFile(*templateFile)
|
var data []byte
|
||||||
if err != nil {
|
if len(*templateFile) > 0 {
|
||||||
glog.Fatalf("Error reading template %s, %v\n", *templateFile, err)
|
var err error
|
||||||
return false
|
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))
|
tmpl, err := template.New("output").Parse(string(data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -204,7 +212,7 @@ func executeAPIRequest(method string, s *kube_client.Client) bool {
|
|||||||
printer = &kubecfg.TemplatePrinter{
|
printer = &kubecfg.TemplatePrinter{
|
||||||
Template: tmpl,
|
Template: tmpl,
|
||||||
}
|
}
|
||||||
} else {
|
default:
|
||||||
printer = &kubecfg.HumanReadablePrinter{}
|
printer = &kubecfg.HumanReadablePrinter{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user