Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b2ef24fb
Commit
b2ef24fb
authored
Jul 14, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address comments.
parent
f7bd5a6f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
kubecfg.go
cmd/kubecfg/kubecfg.go
+17
-9
No files found.
cmd/kubecfg/kubecfg.go
View file @
b2ef24fb
...
@@ -51,7 +51,8 @@ var (
...
@@ -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 {
...
@@ -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 {
...
@@ -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
{}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment