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
b2280a64
Commit
b2280a64
authored
Oct 13, 2016
by
AdoHe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update various commands to adapt the new Factory interface
parent
dfae1a27
Hide whitespace changes
Inline
Side-by-side
Showing
53 changed files
with
154 additions
and
200 deletions
+154
-200
cmd.go
cmd/kubeadm/app/cmd/cmd.go
+1
-1
annotate.go
pkg/kubectl/cmd/annotate.go
+4
-4
apiversions.go
pkg/kubectl/cmd/apiversions.go
+2
-2
apply.go
pkg/kubectl/cmd/apply.go
+2
-2
attach.go
pkg/kubectl/cmd/attach.go
+2
-2
autoscale.go
pkg/kubectl/cmd/autoscale.go
+2
-2
clusterinfo.go
pkg/kubectl/cmd/clusterinfo.go
+2
-2
clusterinfo_dump.go
pkg/kubectl/cmd/clusterinfo_dump.go
+2
-2
cmd.go
pkg/kubectl/cmd/cmd.go
+1
-1
completion.go
pkg/kubectl/cmd/completion.go
+2
-2
convert.go
pkg/kubectl/cmd/convert.go
+2
-2
create.go
pkg/kubectl/cmd/create.go
+3
-3
create_configmap.go
pkg/kubectl/cmd/create_configmap.go
+2
-2
create_deployment.go
pkg/kubectl/cmd/create_deployment.go
+2
-2
create_namespace.go
pkg/kubectl/cmd/create_namespace.go
+2
-2
create_quota.go
pkg/kubectl/cmd/create_quota.go
+2
-2
create_secret.go
pkg/kubectl/cmd/create_secret.go
+7
-7
create_service.go
pkg/kubectl/cmd/create_service.go
+7
-7
create_serviceaccount.go
pkg/kubectl/cmd/create_serviceaccount.go
+2
-2
delete.go
pkg/kubectl/cmd/delete.go
+3
-3
describe.go
pkg/kubectl/cmd/describe.go
+3
-3
drain.go
pkg/kubectl/cmd/drain.go
+4
-4
drain_test.go
pkg/kubectl/cmd/drain_test.go
+5
-2
edit.go
pkg/kubectl/cmd/edit.go
+4
-4
exec.go
pkg/kubectl/cmd/exec.go
+8
-26
exec_test.go
pkg/kubectl/cmd/exec_test.go
+21
-52
explain.go
pkg/kubectl/cmd/explain.go
+2
-2
expose.go
pkg/kubectl/cmd/expose.go
+2
-2
get.go
pkg/kubectl/cmd/get.go
+2
-2
help.go
pkg/kubectl/cmd/help.go
+1
-1
label.go
pkg/kubectl/cmd/label.go
+3
-3
logs.go
pkg/kubectl/cmd/logs.go
+2
-2
patch.go
pkg/kubectl/cmd/patch.go
+2
-2
portforward.go
pkg/kubectl/cmd/portforward.go
+2
-2
proxy.go
pkg/kubectl/cmd/proxy.go
+2
-2
replace.go
pkg/kubectl/cmd/replace.go
+3
-3
rollingupdate.go
pkg/kubectl/cmd/rollingupdate.go
+2
-2
rollout.go
pkg/kubectl/cmd/rollout/rollout.go
+1
-1
rollout_history.go
pkg/kubectl/cmd/rollout/rollout_history.go
+2
-2
rollout_pause.go
pkg/kubectl/cmd/rollout/rollout_pause.go
+2
-2
rollout_resume.go
pkg/kubectl/cmd/rollout/rollout_resume.go
+2
-2
rollout_status.go
pkg/kubectl/cmd/rollout/rollout_status.go
+2
-2
rollout_undo.go
pkg/kubectl/cmd/rollout/rollout_undo.go
+2
-2
run.go
pkg/kubectl/cmd/run.go
+5
-5
scale.go
pkg/kubectl/cmd/scale.go
+2
-2
set.go
pkg/kubectl/cmd/set/set.go
+1
-1
set_image.go
pkg/kubectl/cmd/set/set_image.go
+2
-2
stop.go
pkg/kubectl/cmd/stop.go
+2
-2
taint.go
pkg/kubectl/cmd/taint.go
+3
-3
top.go
pkg/kubectl/cmd/top.go
+2
-2
top_node.go
pkg/kubectl/cmd/top_node.go
+2
-2
top_pod.go
pkg/kubectl/cmd/top_pod.go
+2
-2
version.go
pkg/kubectl/cmd/version.go
+2
-2
No files found.
cmd/kubeadm/app/cmd/cmd.go
View file @
b2280a64
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/util/flag"
"k8s.io/kubernetes/pkg/util/flag"
)
)
func
NewKubeadmCommand
(
f
*
cmdutil
.
Factory
,
in
io
.
Reader
,
out
,
err
io
.
Writer
)
*
cobra
.
Command
{
func
NewKubeadmCommand
(
f
cmdutil
.
Factory
,
in
io
.
Reader
,
out
,
err
io
.
Writer
)
*
cobra
.
Command
{
cmds
:=
&
cobra
.
Command
{
cmds
:=
&
cobra
.
Command
{
Use
:
"kubeadm"
,
Use
:
"kubeadm"
,
Short
:
"kubeadm: easily bootstrap a secure Kubernetes cluster."
,
Short
:
"kubeadm: easily bootstrap a secure Kubernetes cluster."
,
...
...
pkg/kubectl/cmd/annotate.go
View file @
b2280a64
...
@@ -54,7 +54,7 @@ type AnnotateOptions struct {
...
@@ -54,7 +54,7 @@ type AnnotateOptions struct {
newAnnotations
map
[
string
]
string
newAnnotations
map
[
string
]
string
removeAnnotations
[]
string
removeAnnotations
[]
string
// Common share
d
fields
// Common share fields
out
io
.
Writer
out
io
.
Writer
}
}
...
@@ -91,7 +91,7 @@ var (
...
@@ -91,7 +91,7 @@ var (
kubectl annotate pods foo description-`
)
kubectl annotate pods foo description-`
)
)
)
func
NewCmdAnnotate
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdAnnotate
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
AnnotateOptions
{}
options
:=
&
AnnotateOptions
{}
// retrieve a list of handled resources from printer as valid args
// retrieve a list of handled resources from printer as valid args
...
@@ -138,7 +138,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -138,7 +138,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
}
// Complete adapts from the command line args and factory to the data required.
// Complete adapts from the command line args and factory to the data required.
func
(
o
*
AnnotateOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
func
(
o
*
AnnotateOptions
)
Complete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
o
.
out
=
out
o
.
out
=
out
o
.
local
=
cmdutil
.
GetFlagBool
(
cmd
,
"local"
)
o
.
local
=
cmdutil
.
GetFlagBool
(
cmd
,
"local"
)
o
.
overwrite
=
cmdutil
.
GetFlagBool
(
cmd
,
"overwrite"
)
o
.
overwrite
=
cmdutil
.
GetFlagBool
(
cmd
,
"overwrite"
)
...
@@ -172,7 +172,7 @@ func (o AnnotateOptions) Validate() error {
...
@@ -172,7 +172,7 @@ func (o AnnotateOptions) Validate() error {
}
}
// RunAnnotate does the work
// RunAnnotate does the work
func
(
o
AnnotateOptions
)
RunAnnotate
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
func
(
o
AnnotateOptions
)
RunAnnotate
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
namespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
namespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/apiversions.go
View file @
b2280a64
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
)
func
NewCmdApiVersions
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdApiVersions
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"api-versions"
,
Use
:
"api-versions"
,
// apiversions is deprecated.
// apiversions is deprecated.
...
@@ -42,7 +42,7 @@ func NewCmdApiVersions(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -42,7 +42,7 @@ func NewCmdApiVersions(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunApiVersions
(
f
*
cmdutil
.
Factory
,
w
io
.
Writer
)
error
{
func
RunApiVersions
(
f
cmdutil
.
Factory
,
w
io
.
Writer
)
error
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"apiversions"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"apiversions"
{
printDeprecationWarning
(
"api-versions"
,
"apiversions"
)
printDeprecationWarning
(
"api-versions"
,
"apiversions"
)
}
}
...
...
pkg/kubectl/cmd/apply.go
View file @
b2280a64
...
@@ -75,7 +75,7 @@ var (
...
@@ -75,7 +75,7 @@ var (
cat pod.json | kubectl apply -f -`
)
cat pod.json | kubectl apply -f -`
)
)
)
func
NewCmdApply
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdApply
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
var
options
ApplyOptions
var
options
ApplyOptions
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -122,7 +122,7 @@ func validatePruneAll(prune, all bool, selector string) error {
...
@@ -122,7 +122,7 @@ func validatePruneAll(prune, all bool, selector string) error {
return
nil
return
nil
}
}
func
RunApply
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
options
*
ApplyOptions
)
error
{
func
RunApply
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
options
*
ApplyOptions
)
error
{
shortOutput
:=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
==
"name"
shortOutput
:=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
==
"name"
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
),
cmdutil
.
GetFlagString
(
cmd
,
"schema-cache-dir"
))
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
),
cmdutil
.
GetFlagString
(
cmd
,
"schema-cache-dir"
))
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kubectl/cmd/attach.go
View file @
b2280a64
...
@@ -48,7 +48,7 @@ var (
...
@@ -48,7 +48,7 @@ var (
kubectl attach 123456-7890 -c ruby-container -i -t`
)
kubectl attach 123456-7890 -c ruby-container -i -t`
)
)
)
func
NewCmdAttach
(
f
*
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdAttach
(
f
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
AttachOptions
{
options
:=
&
AttachOptions
{
StreamOptions
:
StreamOptions
{
StreamOptions
:
StreamOptions
{
In
:
cmdIn
,
In
:
cmdIn
,
...
@@ -113,7 +113,7 @@ type AttachOptions struct {
...
@@ -113,7 +113,7 @@ type AttachOptions struct {
}
}
// Complete verifies command line arguments and loads data from the command environment
// Complete verifies command line arguments and loads data from the command environment
func
(
p
*
AttachOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
argsIn
[]
string
)
error
{
func
(
p
*
AttachOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
argsIn
[]
string
)
error
{
if
len
(
argsIn
)
==
0
{
if
len
(
argsIn
)
==
0
{
return
cmdutil
.
UsageError
(
cmd
,
"POD is required for attach"
)
return
cmdutil
.
UsageError
(
cmd
,
"POD is required for attach"
)
}
}
...
...
pkg/kubectl/cmd/autoscale.go
View file @
b2280a64
...
@@ -45,7 +45,7 @@ var (
...
@@ -45,7 +45,7 @@ var (
kubectl autoscale rc foo --max=5 --cpu-percent=80`
)
kubectl autoscale rc foo --max=5 --cpu-percent=80`
)
)
)
func
NewCmdAutoscale
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdAutoscale
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
validArgs
:=
[]
string
{
"deployment"
,
"replicaset"
,
"replicationcontroller"
}
validArgs
:=
[]
string
{
"deployment"
,
"replicaset"
,
"replicationcontroller"
}
...
@@ -79,7 +79,7 @@ func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -79,7 +79,7 @@ func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunAutoscale
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunAutoscale
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
namespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
namespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/clusterinfo.go
View file @
b2280a64
...
@@ -33,7 +33,7 @@ import (
...
@@ -33,7 +33,7 @@ import (
var
longDescr
=
`Display addresses of the master and services with label kubernetes.io/cluster-service=true
var
longDescr
=
`Display addresses of the master and services with label kubernetes.io/cluster-service=true
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`
func
NewCmdClusterInfo
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdClusterInfo
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"cluster-info"
,
Use
:
"cluster-info"
,
// clusterinfo is deprecated.
// clusterinfo is deprecated.
...
@@ -50,7 +50,7 @@ func NewCmdClusterInfo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -50,7 +50,7 @@ func NewCmdClusterInfo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunClusterInfo
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
)
error
{
func
RunClusterInfo
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
)
error
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"clusterinfo"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"clusterinfo"
{
printDeprecationWarning
(
"cluster-info"
,
"clusterinfo"
)
printDeprecationWarning
(
"cluster-info"
,
"clusterinfo"
)
}
}
...
...
pkg/kubectl/cmd/clusterinfo_dump.go
View file @
b2280a64
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
)
)
// NewCmdCreateSecret groups subcommands to create various types of secrets
// NewCmdCreateSecret groups subcommands to create various types of secrets
func
NewCmdClusterInfoDump
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdClusterInfoDump
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"dump"
,
Use
:
"dump"
,
Short
:
"Dump lots of relevant info for debugging and diagnosis"
,
Short
:
"Dump lots of relevant info for debugging and diagnosis"
,
...
@@ -84,7 +84,7 @@ func setupOutputWriter(cmd *cobra.Command, defaultWriter io.Writer, filename str
...
@@ -84,7 +84,7 @@ func setupOutputWriter(cmd *cobra.Command, defaultWriter io.Writer, filename str
return
file
return
file
}
}
func
dumpClusterInfo
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
func
dumpClusterInfo
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
clientset
,
err
:=
f
.
ClientSet
()
clientset
,
err
:=
f
.
ClientSet
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/cmd.go
View file @
b2280a64
...
@@ -224,7 +224,7 @@ Use "{{.CommandPath}} [command] --help" for more information about a command.{{e
...
@@ -224,7 +224,7 @@ Use "{{.CommandPath}} [command] --help" for more information about a command.{{e
)
)
// NewKubectlCommand creates the `kubectl` command and its nested children.
// NewKubectlCommand creates the `kubectl` command and its nested children.
func
NewKubectlCommand
(
f
*
cmdutil
.
Factory
,
in
io
.
Reader
,
out
,
err
io
.
Writer
)
*
cobra
.
Command
{
func
NewKubectlCommand
(
f
cmdutil
.
Factory
,
in
io
.
Reader
,
out
,
err
io
.
Writer
)
*
cobra
.
Command
{
// Parent command to which all subcommands are added.
// Parent command to which all subcommands are added.
cmds
:=
&
cobra
.
Command
{
cmds
:=
&
cobra
.
Command
{
Use
:
"kubectl"
,
Use
:
"kubectl"
,
...
...
pkg/kubectl/cmd/completion.go
View file @
b2280a64
...
@@ -56,7 +56,7 @@ var (
...
@@ -56,7 +56,7 @@ var (
}
}
)
)
func
NewCmdCompletion
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCompletion
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
shells
:=
[]
string
{}
shells
:=
[]
string
{}
for
s
:=
range
completion_shells
{
for
s
:=
range
completion_shells
{
shells
=
append
(
shells
,
s
)
shells
=
append
(
shells
,
s
)
...
@@ -77,7 +77,7 @@ func NewCmdCompletion(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -77,7 +77,7 @@ func NewCmdCompletion(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunCompletion
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
RunCompletion
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
return
cmdutil
.
UsageError
(
cmd
,
"Shell not specified."
)
return
cmdutil
.
UsageError
(
cmd
,
"Shell not specified."
)
}
}
...
...
pkg/kubectl/cmd/convert.go
View file @
b2280a64
...
@@ -62,7 +62,7 @@ var (
...
@@ -62,7 +62,7 @@ var (
// NewCmdConvert creates a command object for the generic "convert" action, which
// NewCmdConvert creates a command object for the generic "convert" action, which
// translates the config file into a given version.
// translates the config file into a given version.
func
NewCmdConvert
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdConvert
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
ConvertOptions
{}
options
:=
&
ConvertOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -103,7 +103,7 @@ type ConvertOptions struct {
...
@@ -103,7 +103,7 @@ type ConvertOptions struct {
}
}
// Complete collects information required to run Convert command from command line.
// Complete collects information required to run Convert command from command line.
func
(
o
*
ConvertOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
func
(
o
*
ConvertOptions
)
Complete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
o
.
outputVersion
,
err
=
cmdutil
.
OutputVersion
(
cmd
,
&
registered
.
EnabledVersionsForGroup
(
api
.
GroupName
)[
0
])
o
.
outputVersion
,
err
=
cmdutil
.
OutputVersion
(
cmd
,
&
registered
.
EnabledVersionsForGroup
(
api
.
GroupName
)[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create.go
View file @
b2280a64
...
@@ -43,7 +43,7 @@ var (
...
@@ -43,7 +43,7 @@ var (
cat pod.json | kubectl create -f -`
)
cat pod.json | kubectl create -f -`
)
)
)
func
NewCmdCreate
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreate
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -89,7 +89,7 @@ func ValidateArgs(cmd *cobra.Command, args []string) error {
...
@@ -89,7 +89,7 @@ func ValidateArgs(cmd *cobra.Command, args []string) error {
return
nil
return
nil
}
}
func
RunCreate
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunCreate
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
options
*
resource
.
FilenameOptions
)
error
{
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
),
cmdutil
.
GetFlagString
(
cmd
,
"schema-cache-dir"
))
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
),
cmdutil
.
GetFlagString
(
cmd
,
"schema-cache-dir"
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -183,7 +183,7 @@ type CreateSubcommandOptions struct {
...
@@ -183,7 +183,7 @@ type CreateSubcommandOptions struct {
}
}
// RunCreateSubcommand executes a create subcommand using the specified options
// RunCreateSubcommand executes a create subcommand using the specified options
func
RunCreateSubcommand
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
options
*
CreateSubcommandOptions
)
error
{
func
RunCreateSubcommand
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
options
*
CreateSubcommandOptions
)
error
{
namespace
,
_
,
err
:=
f
.
DefaultNamespace
()
namespace
,
_
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_configmap.go
View file @
b2280a64
...
@@ -53,7 +53,7 @@ var (
...
@@ -53,7 +53,7 @@ var (
)
)
// ConfigMap is a command to ease creating ConfigMaps.
// ConfigMap is a command to ease creating ConfigMaps.
func
NewCmdCreateConfigMap
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateConfigMap
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]"
,
Use
:
"configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]"
,
Aliases
:
[]
string
{
"cm"
},
Aliases
:
[]
string
{
"cm"
},
...
@@ -75,7 +75,7 @@ func NewCmdCreateConfigMap(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
...
@@ -75,7 +75,7 @@ func NewCmdCreateConfigMap(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
}
}
// CreateConfigMap is the implementation of the create configmap command.
// CreateConfigMap is the implementation of the create configmap command.
func
CreateConfigMap
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateConfigMap
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_deployment.go
View file @
b2280a64
...
@@ -37,7 +37,7 @@ var (
...
@@ -37,7 +37,7 @@ var (
)
)
// NewCmdCreateDeployment is a macro command to create a new deployment
// NewCmdCreateDeployment is a macro command to create a new deployment
func
NewCmdCreateDeployment
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateDeployment
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"deployment NAME --image=image [--dry-run]"
,
Use
:
"deployment NAME --image=image [--dry-run]"
,
Aliases
:
[]
string
{
"deploy"
},
Aliases
:
[]
string
{
"deploy"
},
...
@@ -59,7 +59,7 @@ func NewCmdCreateDeployment(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
...
@@ -59,7 +59,7 @@ func NewCmdCreateDeployment(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
}
}
// CreateDeployment implements the behavior to run the create deployment command
// CreateDeployment implements the behavior to run the create deployment command
func
CreateDeployment
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateDeployment
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_namespace.go
View file @
b2280a64
...
@@ -37,7 +37,7 @@ var (
...
@@ -37,7 +37,7 @@ var (
)
)
// NewCmdCreateNamespace is a macro command to create a new namespace
// NewCmdCreateNamespace is a macro command to create a new namespace
func
NewCmdCreateNamespace
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateNamespace
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"namespace NAME [--dry-run]"
,
Use
:
"namespace NAME [--dry-run]"
,
Aliases
:
[]
string
{
"ns"
},
Aliases
:
[]
string
{
"ns"
},
...
@@ -58,7 +58,7 @@ func NewCmdCreateNamespace(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
...
@@ -58,7 +58,7 @@ func NewCmdCreateNamespace(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
}
}
// CreateNamespace implements the behavior to run the create namespace command
// CreateNamespace implements the behavior to run the create namespace command
func
CreateNamespace
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateNamespace
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_quota.go
View file @
b2280a64
...
@@ -40,7 +40,7 @@ var (
...
@@ -40,7 +40,7 @@ var (
)
)
// NewCmdCreateQuota is a macro command to create a new quota
// NewCmdCreateQuota is a macro command to create a new quota
func
NewCmdCreateQuota
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateQuota
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=bool]"
,
Use
:
"quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=bool]"
,
Aliases
:
[]
string
{
"resourcequota"
},
Aliases
:
[]
string
{
"resourcequota"
},
...
@@ -63,7 +63,7 @@ func NewCmdCreateQuota(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command {
...
@@ -63,7 +63,7 @@ func NewCmdCreateQuota(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command {
}
}
// CreateQuota implements the behavior to run the create quota command
// CreateQuota implements the behavior to run the create quota command
func
CreateQuota
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateQuota
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_secret.go
View file @
b2280a64
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
)
)
// NewCmdCreateSecret groups subcommands to create various types of secrets
// NewCmdCreateSecret groups subcommands to create various types of secrets
func
NewCmdCreateSecret
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateSecret
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"secret"
,
Use
:
"secret"
,
Short
:
"Create a secret using specified subcommand"
,
Short
:
"Create a secret using specified subcommand"
,
...
@@ -70,7 +70,7 @@ var (
...
@@ -70,7 +70,7 @@ var (
)
)
// NewCmdCreateSecretGeneric is a command to create generic secrets from files, directories, or literal values
// NewCmdCreateSecretGeneric is a command to create generic secrets from files, directories, or literal values
func
NewCmdCreateSecretGeneric
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateSecretGeneric
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]"
,
Use
:
"generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]"
,
Short
:
"Create a secret from a local file, directory or literal value"
,
Short
:
"Create a secret from a local file, directory or literal value"
,
...
@@ -92,7 +92,7 @@ func NewCmdCreateSecretGeneric(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Comm
...
@@ -92,7 +92,7 @@ func NewCmdCreateSecretGeneric(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Comm
}
}
// CreateSecretGeneric is the implementation of the create secret generic command
// CreateSecretGeneric is the implementation of the create secret generic command
func
CreateSecretGeneric
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateSecretGeneric
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -138,7 +138,7 @@ var (
...
@@ -138,7 +138,7 @@ var (
)
)
// NewCmdCreateSecretDockerRegistry is a macro command for creating secrets to work with Docker registries
// NewCmdCreateSecretDockerRegistry is a macro command for creating secrets to work with Docker registries
func
NewCmdCreateSecretDockerRegistry
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateSecretDockerRegistry
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run]"
,
Use
:
"docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run]"
,
Short
:
"Create a secret for use with a Docker registry"
,
Short
:
"Create a secret for use with a Docker registry"
,
...
@@ -165,7 +165,7 @@ func NewCmdCreateSecretDockerRegistry(f *cmdutil.Factory, cmdOut io.Writer) *cob
...
@@ -165,7 +165,7 @@ func NewCmdCreateSecretDockerRegistry(f *cmdutil.Factory, cmdOut io.Writer) *cob
}
}
// CreateSecretDockerRegistry is the implementation of the create secret docker-registry command
// CreateSecretDockerRegistry is the implementation of the create secret docker-registry command
func
CreateSecretDockerRegistry
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateSecretDockerRegistry
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -209,7 +209,7 @@ var (
...
@@ -209,7 +209,7 @@ var (
)
)
// NewCmdCreateSecretTLS is a macro command for creating secrets to work with Docker registries
// NewCmdCreateSecretTLS is a macro command for creating secrets to work with Docker registries
func
NewCmdCreateSecretTLS
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateSecretTLS
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run]"
,
Use
:
"tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run]"
,
Short
:
"Create a TLS secret"
,
Short
:
"Create a TLS secret"
,
...
@@ -230,7 +230,7 @@ func NewCmdCreateSecretTLS(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
...
@@ -230,7 +230,7 @@ func NewCmdCreateSecretTLS(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command
}
}
// CreateSecretTLS is the implementation of the create secret tls command
// CreateSecretTLS is the implementation of the create secret tls command
func
CreateSecretTLS
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateSecretTLS
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_service.go
View file @
b2280a64
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
)
)
// NewCmdCreateService is a macro command to create a new service
// NewCmdCreateService is a macro command to create a new service
func
NewCmdCreateService
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateService
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"service"
,
Use
:
"service"
,
Aliases
:
[]
string
{
"svc"
},
Aliases
:
[]
string
{
"svc"
},
...
@@ -63,7 +63,7 @@ func addPortFlags(cmd *cobra.Command) {
...
@@ -63,7 +63,7 @@ func addPortFlags(cmd *cobra.Command) {
}
}
// NewCmdCreateServiceClusterIP is a command to create a clusterIP service
// NewCmdCreateServiceClusterIP is a command to create a clusterIP service
func
NewCmdCreateServiceClusterIP
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateServiceClusterIP
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run]"
,
Use
:
"clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run]"
,
Short
:
"Create a clusterIP service."
,
Short
:
"Create a clusterIP service."
,
...
@@ -84,7 +84,7 @@ func NewCmdCreateServiceClusterIP(f *cmdutil.Factory, cmdOut io.Writer) *cobra.C
...
@@ -84,7 +84,7 @@ func NewCmdCreateServiceClusterIP(f *cmdutil.Factory, cmdOut io.Writer) *cobra.C
}
}
// CreateServiceClusterIP implements the behavior to run the create service clusterIP command
// CreateServiceClusterIP implements the behavior to run the create service clusterIP command
func
CreateServiceClusterIP
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateServiceClusterIP
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -119,7 +119,7 @@ var (
...
@@ -119,7 +119,7 @@ var (
)
)
// NewCmdCreateServiceNodePort is a macro command for creating a NodePort service
// NewCmdCreateServiceNodePort is a macro command for creating a NodePort service
func
NewCmdCreateServiceNodePort
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateServiceNodePort
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"nodeport NAME [--tcp=port:targetPort] [--dry-run]"
,
Use
:
"nodeport NAME [--tcp=port:targetPort] [--dry-run]"
,
Short
:
"Create a NodePort service."
,
Short
:
"Create a NodePort service."
,
...
@@ -140,7 +140,7 @@ func NewCmdCreateServiceNodePort(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Co
...
@@ -140,7 +140,7 @@ func NewCmdCreateServiceNodePort(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Co
}
}
// CreateServiceNodePort is the implementation of the create service nodeport command
// CreateServiceNodePort is the implementation of the create service nodeport command
func
CreateServiceNodePort
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateServiceNodePort
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -176,7 +176,7 @@ var (
...
@@ -176,7 +176,7 @@ var (
)
)
// NewCmdCreateServiceLoadBalancer is a macro command for creating a LoadBalancer service
// NewCmdCreateServiceLoadBalancer is a macro command for creating a LoadBalancer service
func
NewCmdCreateServiceLoadBalancer
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateServiceLoadBalancer
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"loadbalancer NAME [--tcp=port:targetPort] [--dry-run]"
,
Use
:
"loadbalancer NAME [--tcp=port:targetPort] [--dry-run]"
,
Short
:
"Create a LoadBalancer service."
,
Short
:
"Create a LoadBalancer service."
,
...
@@ -196,7 +196,7 @@ func NewCmdCreateServiceLoadBalancer(f *cmdutil.Factory, cmdOut io.Writer) *cobr
...
@@ -196,7 +196,7 @@ func NewCmdCreateServiceLoadBalancer(f *cmdutil.Factory, cmdOut io.Writer) *cobr
}
}
// CreateServiceLoadBalancer is the implementation of the service loadbalancer command
// CreateServiceLoadBalancer is the implementation of the service loadbalancer command
func
CreateServiceLoadBalancer
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateServiceLoadBalancer
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/create_serviceaccount.go
View file @
b2280a64
...
@@ -37,7 +37,7 @@ var (
...
@@ -37,7 +37,7 @@ var (
)
)
// NewCmdCreateServiceAccount is a macro command to create a new service account
// NewCmdCreateServiceAccount is a macro command to create a new service account
func
NewCmdCreateServiceAccount
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCreateServiceAccount
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"serviceaccount NAME [--dry-run]"
,
Use
:
"serviceaccount NAME [--dry-run]"
,
Aliases
:
[]
string
{
"sa"
},
Aliases
:
[]
string
{
"sa"
},
...
@@ -58,7 +58,7 @@ func NewCmdCreateServiceAccount(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Com
...
@@ -58,7 +58,7 @@ func NewCmdCreateServiceAccount(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Com
}
}
// CreateServiceAccount implements the behavior to run the create service account command
// CreateServiceAccount implements the behavior to run the create service account command
func
CreateServiceAccount
(
f
*
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
CreateServiceAccount
(
f
cmdutil
.
Factory
,
cmdOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/delete.go
View file @
b2280a64
...
@@ -66,7 +66,7 @@ var (
...
@@ -66,7 +66,7 @@ var (
kubectl delete pods --all`
)
kubectl delete pods --all`
)
)
)
func
NewCmdDelete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdDelete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
// retrieve a list of handled resources from printer as valid args
// retrieve a list of handled resources from printer as valid args
...
@@ -108,7 +108,7 @@ func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -108,7 +108,7 @@ func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunDelete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunDelete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -158,7 +158,7 @@ func RunDelete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
...
@@ -158,7 +158,7 @@ func RunDelete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
return
DeleteResult
(
r
,
out
,
ignoreNotFound
,
shortOutput
,
mapper
)
return
DeleteResult
(
r
,
out
,
ignoreNotFound
,
shortOutput
,
mapper
)
}
}
func
ReapResult
(
r
*
resource
.
Result
,
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
isDefaultDelete
,
ignoreNotFound
bool
,
timeout
time
.
Duration
,
gracePeriod
int
,
shortOutput
bool
,
mapper
meta
.
RESTMapper
,
quiet
bool
)
error
{
func
ReapResult
(
r
*
resource
.
Result
,
f
cmdutil
.
Factory
,
out
io
.
Writer
,
isDefaultDelete
,
ignoreNotFound
bool
,
timeout
time
.
Duration
,
gracePeriod
int
,
shortOutput
bool
,
mapper
meta
.
RESTMapper
,
quiet
bool
)
error
{
found
:=
0
found
:=
0
if
ignoreNotFound
{
if
ignoreNotFound
{
r
=
r
.
IgnoreErrors
(
errors
.
IsNotFound
)
r
=
r
.
IgnoreErrors
(
errors
.
IsNotFound
)
...
...
pkg/kubectl/cmd/describe.go
View file @
b2280a64
...
@@ -67,7 +67,7 @@ var (
...
@@ -67,7 +67,7 @@ var (
kubectl describe pods frontend`
)
kubectl describe pods frontend`
)
)
)
func
NewCmdDescribe
(
f
*
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdDescribe
(
f
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
describerSettings
:=
&
kubectl
.
DescriberSettings
{}
describerSettings
:=
&
kubectl
.
DescriberSettings
{}
...
@@ -95,7 +95,7 @@ func NewCmdDescribe(f *cmdutil.Factory, out, cmdErr io.Writer) *cobra.Command {
...
@@ -95,7 +95,7 @@ func NewCmdDescribe(f *cmdutil.Factory, out, cmdErr io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunDescribe
(
f
*
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
,
describerSettings
*
kubectl
.
DescriberSettings
)
error
{
func
RunDescribe
(
f
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
,
describerSettings
*
kubectl
.
DescriberSettings
)
error
{
selector
:=
cmdutil
.
GetFlagString
(
cmd
,
"selector"
)
selector
:=
cmdutil
.
GetFlagString
(
cmd
,
"selector"
)
allNamespaces
:=
cmdutil
.
GetFlagBool
(
cmd
,
"all-namespaces"
)
allNamespaces
:=
cmdutil
.
GetFlagBool
(
cmd
,
"all-namespaces"
)
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
...
@@ -157,7 +157,7 @@ func RunDescribe(f *cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command,
...
@@ -157,7 +157,7 @@ func RunDescribe(f *cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command,
return
utilerrors
.
NewAggregate
(
allErrs
)
return
utilerrors
.
NewAggregate
(
allErrs
)
}
}
func
DescribeMatchingResources
(
mapper
meta
.
RESTMapper
,
typer
runtime
.
ObjectTyper
,
f
*
cmdutil
.
Factory
,
namespace
,
rsrc
,
prefix
string
,
describerSettings
*
kubectl
.
DescriberSettings
,
out
io
.
Writer
,
originalError
error
)
error
{
func
DescribeMatchingResources
(
mapper
meta
.
RESTMapper
,
typer
runtime
.
ObjectTyper
,
f
cmdutil
.
Factory
,
namespace
,
rsrc
,
prefix
string
,
describerSettings
*
kubectl
.
DescriberSettings
,
out
io
.
Writer
,
originalError
error
)
error
{
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
resource
.
ClientMapperFunc
(
f
.
ClientForMapping
),
f
.
Decoder
(
true
))
.
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
resource
.
ClientMapperFunc
(
f
.
ClientForMapping
),
f
.
Decoder
(
true
))
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
ResourceTypeOrNameArgs
(
true
,
rsrc
)
.
ResourceTypeOrNameArgs
(
true
,
rsrc
)
.
...
...
pkg/kubectl/cmd/drain.go
View file @
b2280a64
...
@@ -40,7 +40,7 @@ import (
...
@@ -40,7 +40,7 @@ import (
type
DrainOptions
struct
{
type
DrainOptions
struct
{
client
*
internalclientset
.
Clientset
client
*
internalclientset
.
Clientset
restClient
*
restclient
.
RESTClient
restClient
*
restclient
.
RESTClient
factory
*
cmdutil
.
Factory
factory
cmdutil
.
Factory
Force
bool
Force
bool
GracePeriodSeconds
int
GracePeriodSeconds
int
IgnoreDaemonsets
bool
IgnoreDaemonsets
bool
...
@@ -80,7 +80,7 @@ var (
...
@@ -80,7 +80,7 @@ var (
`
)
`
)
)
)
func
NewCmdCordon
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCordon
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
DrainOptions
{
factory
:
f
,
out
:
out
}
options
:=
&
DrainOptions
{
factory
:
f
,
out
:
out
}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -106,7 +106,7 @@ var (
...
@@ -106,7 +106,7 @@ var (
`
)
`
)
)
)
func
NewCmdUncordon
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdUncordon
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
DrainOptions
{
factory
:
f
,
out
:
out
}
options
:=
&
DrainOptions
{
factory
:
f
,
out
:
out
}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -151,7 +151,7 @@ var (
...
@@ -151,7 +151,7 @@ var (
`
)
`
)
)
)
func
NewCmdDrain
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdDrain
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
DrainOptions
{
factory
:
f
,
out
:
out
}
options
:=
&
DrainOptions
{
factory
:
f
,
out
:
out
}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
...
pkg/kubectl/cmd/drain_test.go
View file @
b2280a64
...
@@ -69,7 +69,7 @@ func TestCordon(t *testing.T) {
...
@@ -69,7 +69,7 @@ func TestCordon(t *testing.T) {
description
string
description
string
node
*
api
.
Node
node
*
api
.
Node
expected
*
api
.
Node
expected
*
api
.
Node
cmd
func
(
*
cmdutil
.
Factory
,
io
.
Writer
)
*
cobra
.
Command
cmd
func
(
cmdutil
.
Factory
,
io
.
Writer
)
*
cobra
.
Command
arg
string
arg
string
expectFatal
bool
expectFatal
bool
}{
}{
...
@@ -177,7 +177,10 @@ func TestCordon(t *testing.T) {
...
@@ -177,7 +177,10 @@ func TestCordon(t *testing.T) {
// Restore cmdutil behavior
// Restore cmdutil behavior
cmdutil
.
DefaultBehaviorOnFatal
()
cmdutil
.
DefaultBehaviorOnFatal
()
}()
}()
cmdutil
.
BehaviorOnFatal
(
func
(
e
string
,
code
int
)
{
saw_fatal
=
true
;
panic
(
e
)
})
cmdutil
.
BehaviorOnFatal
(
func
(
e
string
,
code
int
)
{
saw_fatal
=
true
panic
(
e
)
})
cmd
.
SetArgs
([]
string
{
test
.
arg
})
cmd
.
SetArgs
([]
string
{
test
.
arg
})
cmd
.
Execute
()
cmd
.
Execute
()
}()
}()
...
...
pkg/kubectl/cmd/edit.go
View file @
b2280a64
...
@@ -80,7 +80,7 @@ var (
...
@@ -80,7 +80,7 @@ var (
var
errExit
=
fmt
.
Errorf
(
"exit directly"
)
var
errExit
=
fmt
.
Errorf
(
"exit directly"
)
func
NewCmdEdit
(
f
*
cmdutil
.
Factory
,
out
,
errOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdEdit
(
f
cmdutil
.
Factory
,
out
,
errOut
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
// retrieve a list of handled resources from printer as valid args
// retrieve a list of handled resources from printer as valid args
...
@@ -121,7 +121,7 @@ func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
...
@@ -121,7 +121,7 @@ func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunEdit
(
f
*
cmdutil
.
Factory
,
out
,
errOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunEdit
(
f
cmdutil
.
Factory
,
out
,
errOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
o
,
err
:=
getPrinter
(
cmd
)
o
,
err
:=
getPrinter
(
cmd
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -321,7 +321,7 @@ func getPrinter(cmd *cobra.Command) (*editPrinterOptions, error) {
...
@@ -321,7 +321,7 @@ func getPrinter(cmd *cobra.Command) (*editPrinterOptions, error) {
}
}
}
}
func
getMapperAndResult
(
f
*
cmdutil
.
Factory
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
(
meta
.
RESTMapper
,
*
resource
.
Mapper
,
*
resource
.
Result
,
string
,
error
)
{
func
getMapperAndResult
(
f
cmdutil
.
Factory
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
(
meta
.
RESTMapper
,
*
resource
.
Mapper
,
*
resource
.
Result
,
string
,
error
)
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
""
,
err
return
nil
,
nil
,
nil
,
""
,
err
...
@@ -441,7 +441,7 @@ func visitToPatch(originalObj runtime.Object, updates *resource.Info, mapper met
...
@@ -441,7 +441,7 @@ func visitToPatch(originalObj runtime.Object, updates *resource.Info, mapper met
return
err
return
err
}
}
func
visitAnnotation
(
cmd
*
cobra
.
Command
,
f
*
cmdutil
.
Factory
,
updates
*
resource
.
Info
,
resourceMapper
*
resource
.
Mapper
,
encoder
runtime
.
Encoder
)
([]
runtime
.
Object
,
error
)
{
func
visitAnnotation
(
cmd
*
cobra
.
Command
,
f
cmdutil
.
Factory
,
updates
*
resource
.
Info
,
resourceMapper
*
resource
.
Mapper
,
encoder
runtime
.
Encoder
)
([]
runtime
.
Object
,
error
)
{
mutatedObjects
:=
[]
runtime
.
Object
{}
mutatedObjects
:=
[]
runtime
.
Object
{}
annotationVisitor
:=
resource
.
NewFlattenListVisitor
(
updates
,
resourceMapper
)
annotationVisitor
:=
resource
.
NewFlattenListVisitor
(
updates
,
resourceMapper
)
// iterate through all items to apply annotations
// iterate through all items to apply annotations
...
...
pkg/kubectl/cmd/exec.go
View file @
b2280a64
...
@@ -30,7 +30,6 @@ import (
...
@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned/remotecommand"
"k8s.io/kubernetes/pkg/client/unversioned/remotecommand"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
remotecommandserver
"k8s.io/kubernetes/pkg/kubelet/server/remotecommand"
remotecommandserver
"k8s.io/kubernetes/pkg/kubelet/server/remotecommand"
"k8s.io/kubernetes/pkg/util/interrupt"
"k8s.io/kubernetes/pkg/util/interrupt"
"k8s.io/kubernetes/pkg/util/term"
"k8s.io/kubernetes/pkg/util/term"
...
@@ -53,7 +52,7 @@ const (
...
@@ -53,7 +52,7 @@ const (
execUsageStr
=
"expected 'exec POD_NAME COMMAND [ARG1] [ARG2] ... [ARGN]'.
\n
POD_NAME and COMMAND are required arguments for the exec command"
execUsageStr
=
"expected 'exec POD_NAME COMMAND [ARG1] [ARG2] ... [ARGN]'.
\n
POD_NAME and COMMAND are required arguments for the exec command"
)
)
func
NewCmdExec
(
f
*
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdExec
(
f
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
ExecOptions
{
options
:=
&
ExecOptions
{
StreamOptions
:
StreamOptions
{
StreamOptions
:
StreamOptions
{
In
:
cmdIn
,
In
:
cmdIn
,
...
@@ -140,7 +139,7 @@ type ExecOptions struct {
...
@@ -140,7 +139,7 @@ type ExecOptions struct {
}
}
// Complete verifies command line arguments and loads data from the command environment
// Complete verifies command line arguments and loads data from the command environment
func
(
p
*
ExecOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
argsIn
[]
string
,
argsLenAtDash
int
)
error
{
func
(
p
*
ExecOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
argsIn
[]
string
,
argsLenAtDash
int
)
error
{
// Let kubectl exec follow rules for `--`, see #13004 issue
// Let kubectl exec follow rules for `--`, see #13004 issue
if
len
(
p
.
PodName
)
==
0
&&
(
len
(
argsIn
)
==
0
||
argsLenAtDash
==
0
)
{
if
len
(
p
.
PodName
)
==
0
&&
(
len
(
argsIn
)
==
0
||
argsLenAtDash
==
0
)
{
return
cmdutil
.
UsageError
(
cmd
,
execUsageStr
)
return
cmdutil
.
UsageError
(
cmd
,
execUsageStr
)
...
@@ -158,29 +157,6 @@ func (p *ExecOptions) Complete(f *cmdutil.Factory, cmd *cobra.Command, argsIn []
...
@@ -158,29 +157,6 @@ func (p *ExecOptions) Complete(f *cmdutil.Factory, cmd *cobra.Command, argsIn []
return
cmdutil
.
UsageError
(
cmd
,
execUsageStr
)
return
cmdutil
.
UsageError
(
cmd
,
execUsageStr
)
}
}
}
}
namespace
,
_
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
return
err
}
p
.
Namespace
=
namespace
clientMapper
:=
resource
.
ClientMapperFunc
(
f
.
ClientForMapping
)
mapper
,
typer
:=
f
.
Object
()
decoder
:=
f
.
Decoder
(
true
)
infos
,
err
:=
resource
.
NewBuilder
(
mapper
,
typer
,
clientMapper
,
decoder
)
.
NamespaceParam
(
p
.
Namespace
)
.
DefaultNamespace
()
.
ResourceNames
(
"pods"
,
p
.
PodName
)
.
SingleResourceType
()
.
Do
()
.
Infos
()
if
err
!=
nil
{
return
err
}
if
len
(
infos
)
!=
1
{
return
cmdutil
.
UsageError
(
cmd
,
execUsageStr
)
}
p
.
PodName
=
infos
[
0
]
.
Name
cmdParent
:=
cmd
.
Parent
()
cmdParent
:=
cmd
.
Parent
()
if
cmdParent
!=
nil
{
if
cmdParent
!=
nil
{
...
@@ -190,6 +166,12 @@ func (p *ExecOptions) Complete(f *cmdutil.Factory, cmd *cobra.Command, argsIn []
...
@@ -190,6 +166,12 @@ func (p *ExecOptions) Complete(f *cmdutil.Factory, cmd *cobra.Command, argsIn []
p
.
SuggestedCmdUsage
=
fmt
.
Sprintf
(
"Use '%s describe pod/%s' to see all of the containers in this pod."
,
p
.
FullCmdName
,
p
.
PodName
)
p
.
SuggestedCmdUsage
=
fmt
.
Sprintf
(
"Use '%s describe pod/%s' to see all of the containers in this pod."
,
p
.
FullCmdName
,
p
.
PodName
)
}
}
namespace
,
_
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
return
err
}
p
.
Namespace
=
namespace
config
,
err
:=
f
.
ClientConfig
()
config
,
err
:=
f
.
ClientConfig
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/exec_test.go
View file @
b2280a64
...
@@ -55,7 +55,7 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -55,7 +55,7 @@ func TestPodAndContainer(t *testing.T) {
p
*
ExecOptions
p
*
ExecOptions
name
string
name
string
expectError
bool
expectError
bool
expectedPod
*
api
.
Pod
expectedPod
string
expectedContainer
string
expectedContainer
string
expectedArgs
[]
string
expectedArgs
[]
string
}{
}{
...
@@ -81,19 +81,11 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -81,19 +81,11 @@ func TestPodAndContainer(t *testing.T) {
p
:
&
ExecOptions
{
StreamOptions
:
StreamOptions
{
PodName
:
"foo"
}},
p
:
&
ExecOptions
{
StreamOptions
:
StreamOptions
{
PodName
:
"foo"
}},
args
:
[]
string
{
"cmd"
},
args
:
[]
string
{
"cmd"
},
argsLenAtDash
:
-
1
,
argsLenAtDash
:
-
1
,
expectedPod
:
execPod
()
,
expectedPod
:
"foo"
,
expectedArgs
:
[]
string
{
"cmd"
},
expectedArgs
:
[]
string
{
"cmd"
},
name
:
"pod in flags"
,
name
:
"pod in flags"
,
},
},
{
{
p
:
&
ExecOptions
{
StreamOptions
:
StreamOptions
{
PodName
:
"pod/foo"
}},
args
:
[]
string
{
"cmd"
},
argsLenAtDash
:
-
1
,
expectedPod
:
execPod
(),
expectedArgs
:
[]
string
{
"cmd"
},
name
:
"pod with 'pod/' prefix in flags"
,
},
{
p
:
&
ExecOptions
{},
p
:
&
ExecOptions
{},
args
:
[]
string
{
"foo"
,
"cmd"
},
args
:
[]
string
{
"foo"
,
"cmd"
},
argsLenAtDash
:
0
,
argsLenAtDash
:
0
,
...
@@ -111,23 +103,15 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -111,23 +103,15 @@ func TestPodAndContainer(t *testing.T) {
p
:
&
ExecOptions
{},
p
:
&
ExecOptions
{},
args
:
[]
string
{
"foo"
,
"cmd"
},
args
:
[]
string
{
"foo"
,
"cmd"
},
argsLenAtDash
:
-
1
,
argsLenAtDash
:
-
1
,
expectedPod
:
execPod
()
,
expectedPod
:
"foo"
,
expectedArgs
:
[]
string
{
"cmd"
},
expectedArgs
:
[]
string
{
"cmd"
},
name
:
"cmd, w/o flags"
,
name
:
"cmd, w/o flags"
,
},
},
{
{
p
:
&
ExecOptions
{},
p
:
&
ExecOptions
{},
args
:
[]
string
{
"pod/foo"
,
"cmd"
},
argsLenAtDash
:
-
1
,
expectedPod
:
execPod
(),
expectedArgs
:
[]
string
{
"cmd"
},
name
:
"pod with 'pod/' prefix, cmd, w/o flags"
,
},
{
p
:
&
ExecOptions
{},
args
:
[]
string
{
"foo"
,
"cmd"
},
args
:
[]
string
{
"foo"
,
"cmd"
},
argsLenAtDash
:
1
,
argsLenAtDash
:
1
,
expectedPod
:
execPod
()
,
expectedPod
:
"foo"
,
expectedArgs
:
[]
string
{
"cmd"
},
expectedArgs
:
[]
string
{
"cmd"
},
name
:
"cmd, cmd is behind dash"
,
name
:
"cmd, cmd is behind dash"
,
},
},
...
@@ -135,27 +119,17 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -135,27 +119,17 @@ func TestPodAndContainer(t *testing.T) {
p
:
&
ExecOptions
{
StreamOptions
:
StreamOptions
{
ContainerName
:
"bar"
}},
p
:
&
ExecOptions
{
StreamOptions
:
StreamOptions
{
ContainerName
:
"bar"
}},
args
:
[]
string
{
"foo"
,
"cmd"
},
args
:
[]
string
{
"foo"
,
"cmd"
},
argsLenAtDash
:
-
1
,
argsLenAtDash
:
-
1
,
expectedPod
:
execPod
()
,
expectedPod
:
"foo"
,
expectedContainer
:
"bar"
,
expectedContainer
:
"bar"
,
expectedArgs
:
[]
string
{
"cmd"
},
expectedArgs
:
[]
string
{
"cmd"
},
name
:
"cmd, container in flag"
,
name
:
"cmd, container in flag"
,
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
f
,
tf
,
codec
,
ns
:=
NewAPIFactory
()
f
,
tf
,
_
,
ns
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
NegotiatedSerializer
:
ns
,
NegotiatedSerializer
:
ns
,
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
switch
m
:=
req
.
Method
;
{
case
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
expectedPod
)
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
body
},
nil
default
:
//Ensures no GET is performed when deleting by name
t
.
Errorf
(
"%s: unexpected request: %s %#v
\n
%#v"
,
test
.
name
,
req
.
Method
,
req
.
URL
,
req
)
return
nil
,
fmt
.
Errorf
(
"unexpected request"
)
}
}),
}
}
tf
.
Namespace
=
"test"
tf
.
Namespace
=
"test"
tf
.
ClientConfig
=
defaultClientConfig
()
tf
.
ClientConfig
=
defaultClientConfig
()
...
@@ -172,8 +146,8 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -172,8 +146,8 @@ func TestPodAndContainer(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
continue
continue
}
}
if
options
.
PodName
!=
test
.
expectedPod
.
Name
{
if
options
.
PodName
!=
test
.
expectedPod
{
t
.
Errorf
(
"expected: %s, got: %s (%s)"
,
test
.
expectedPod
.
Name
,
options
.
PodName
,
test
.
name
)
t
.
Errorf
(
"expected: %s, got: %s (%s)"
,
test
.
expectedPod
,
options
.
PodName
,
test
.
name
)
}
}
if
options
.
ContainerName
!=
test
.
expectedContainer
{
if
options
.
ContainerName
!=
test
.
expectedContainer
{
t
.
Errorf
(
"expected: %s, got: %s (%s)"
,
test
.
expectedContainer
,
options
.
ContainerName
,
test
.
name
)
t
.
Errorf
(
"expected: %s, got: %s (%s)"
,
test
.
expectedContainer
,
options
.
ContainerName
,
test
.
name
)
...
@@ -187,24 +161,22 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -187,24 +161,22 @@ func TestPodAndContainer(t *testing.T) {
func
TestExec
(
t
*
testing
.
T
)
{
func
TestExec
(
t
*
testing
.
T
)
{
version
:=
registered
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
.
Version
version
:=
registered
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
.
Version
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
,
shortPodPath
,
podPath
,
execPath
,
container
string
name
,
podPath
,
execPath
,
container
string
pod
*
api
.
Pod
pod
*
api
.
Pod
execErr
bool
execErr
bool
}{
}{
{
{
name
:
"pod exec"
,
name
:
"pod exec"
,
shortPodPath
:
"/namespaces/test/pods/foo"
,
podPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo"
,
podPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo"
,
execPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo/exec"
,
execPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo/exec"
,
pod
:
execPod
(),
pod
:
execPod
(),
},
},
{
{
name
:
"pod exec error"
,
name
:
"pod exec error"
,
shortPodPath
:
"/namespaces/test/pods/foo"
,
podPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo"
,
podPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo"
,
execPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo/exec"
,
execPath
:
"/api/"
+
version
+
"/namespaces/test/pods/foo/exec"
,
pod
:
execPod
(),
pod
:
execPod
(),
execErr
:
true
,
execErr
:
true
,
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
@@ -216,9 +188,6 @@ func TestExec(t *testing.T) {
...
@@ -216,9 +188,6 @@ func TestExec(t *testing.T) {
case
p
==
test
.
podPath
&&
m
==
"GET"
:
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
body
:=
objBody
(
codec
,
test
.
pod
)
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
body
},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
body
},
nil
case
p
==
test
.
shortPodPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
body
},
nil
default
:
default
:
// Ensures no GET is performed when deleting by name
// Ensures no GET is performed when deleting by name
t
.
Errorf
(
"%s: unexpected request: %s %#v
\n
%#v"
,
test
.
name
,
req
.
Method
,
req
.
URL
,
req
)
t
.
Errorf
(
"%s: unexpected request: %s %#v
\n
%#v"
,
test
.
name
,
req
.
Method
,
req
.
URL
,
req
)
...
...
pkg/kubectl/cmd/explain.go
View file @
b2280a64
...
@@ -44,7 +44,7 @@ var (
...
@@ -44,7 +44,7 @@ var (
)
)
// NewCmdExplain returns a cobra command for swagger docs
// NewCmdExplain returns a cobra command for swagger docs
func
NewCmdExplain
(
f
*
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdExplain
(
f
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"explain RESOURCE"
,
Use
:
"explain RESOURCE"
,
Short
:
"Documentation of resources"
,
Short
:
"Documentation of resources"
,
...
@@ -61,7 +61,7 @@ func NewCmdExplain(f *cmdutil.Factory, out, cmdErr io.Writer) *cobra.Command {
...
@@ -61,7 +61,7 @@ func NewCmdExplain(f *cmdutil.Factory, out, cmdErr io.Writer) *cobra.Command {
}
}
// RunExplain executes the appropriate steps to print a model's documentation
// RunExplain executes the appropriate steps to print a model's documentation
func
RunExplain
(
f
*
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
RunExplain
(
f
cmdutil
.
Factory
,
out
,
cmdErr
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
fmt
.
Fprint
(
cmdErr
,
"You must specify the type of resource to explain. "
,
valid_resources
)
fmt
.
Fprint
(
cmdErr
,
"You must specify the type of resource to explain. "
,
valid_resources
)
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
...
...
pkg/kubectl/cmd/expose.go
View file @
b2280a64
...
@@ -73,7 +73,7 @@ var (
...
@@ -73,7 +73,7 @@ var (
kubectl expose deployment nginx --port=80 --target-port=8000`
)
kubectl expose deployment nginx --port=80 --target-port=8000`
)
)
)
func
NewCmdExposeService
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdExposeService
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
validArgs
,
argAliases
:=
[]
string
{},
[]
string
{}
validArgs
,
argAliases
:=
[]
string
{},
[]
string
{}
...
@@ -123,7 +123,7 @@ func NewCmdExposeService(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -123,7 +123,7 @@ func NewCmdExposeService(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunExpose
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunExpose
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
namespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
namespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/get.go
View file @
b2280a64
...
@@ -81,7 +81,7 @@ var (
...
@@ -81,7 +81,7 @@ var (
// NewCmdGet creates a command object for the generic "get" action, which
// NewCmdGet creates a command object for the generic "get" action, which
// retrieves one or more resources from a server.
// retrieves one or more resources from a server.
func
NewCmdGet
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
errOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdGet
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
errOut
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
GetOptions
{}
options
:=
&
GetOptions
{}
// retrieve a list of handled resources from printer as valid args
// retrieve a list of handled resources from printer as valid args
...
@@ -125,7 +125,7 @@ func NewCmdGet(f *cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Comma
...
@@ -125,7 +125,7 @@ func NewCmdGet(f *cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Comma
// RunGet implements the generic Get command
// RunGet implements the generic Get command
// TODO: convert all direct flag accessors to a struct and pass that instead of cmd
// TODO: convert all direct flag accessors to a struct and pass that instead of cmd
func
RunGet
(
f
*
cmdutil
.
Factory
,
out
,
errOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
GetOptions
)
error
{
func
RunGet
(
f
cmdutil
.
Factory
,
out
,
errOut
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
GetOptions
)
error
{
if
len
(
options
.
Raw
)
>
0
{
if
len
(
options
.
Raw
)
>
0
{
restClient
,
err
:=
f
.
RESTClient
()
restClient
,
err
:=
f
.
RESTClient
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kubectl/cmd/help.go
View file @
b2280a64
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
const
help_long
=
`Help provides help for any command in the application.
const
help_long
=
`Help provides help for any command in the application.
Simply type kubectl help [path to command] for full details.`
Simply type kubectl help [path to command] for full details.`
func
NewCmdHelp
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdHelp
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"help [command] | STRING_TO_SEARCH"
,
Use
:
"help [command] | STRING_TO_SEARCH"
,
Short
:
"Help about any command"
,
Short
:
"Help about any command"
,
...
...
pkg/kubectl/cmd/label.go
View file @
b2280a64
...
@@ -88,7 +88,7 @@ var (
...
@@ -88,7 +88,7 @@ var (
kubectl label pods foo bar-`
)
kubectl label pods foo bar-`
)
)
)
func
NewCmdLabel
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdLabel
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
LabelOptions
{}
options
:=
&
LabelOptions
{}
// retrieve a list of handled resources from printer as valid args
// retrieve a list of handled resources from printer as valid args
...
@@ -135,7 +135,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -135,7 +135,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
}
// Complete adapts from the command line args and factory to the data required.
// Complete adapts from the command line args and factory to the data required.
func
(
o
*
LabelOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
func
(
o
*
LabelOptions
)
Complete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
o
.
out
=
out
o
.
out
=
out
o
.
local
=
cmdutil
.
GetFlagBool
(
cmd
,
"local"
)
o
.
local
=
cmdutil
.
GetFlagBool
(
cmd
,
"local"
)
o
.
overwrite
=
cmdutil
.
GetFlagBool
(
cmd
,
"overwrite"
)
o
.
overwrite
=
cmdutil
.
GetFlagBool
(
cmd
,
"overwrite"
)
...
@@ -166,7 +166,7 @@ func (o *LabelOptions) Validate() error {
...
@@ -166,7 +166,7 @@ func (o *LabelOptions) Validate() error {
}
}
// RunLabel does the work
// RunLabel does the work
func
(
o
*
LabelOptions
)
RunLabel
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
func
(
o
*
LabelOptions
)
RunLabel
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/logs.go
View file @
b2280a64
...
@@ -74,7 +74,7 @@ type LogsOptions struct {
...
@@ -74,7 +74,7 @@ type LogsOptions struct {
}
}
// NewCmdLog creates a new pod logs command
// NewCmdLog creates a new pod logs command
func
NewCmdLogs
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdLogs
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
o
:=
&
LogsOptions
{}
o
:=
&
LogsOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"logs [-f] [-p] POD [-c CONTAINER]"
,
Use
:
"logs [-f] [-p] POD [-c CONTAINER]"
,
...
@@ -111,7 +111,7 @@ func NewCmdLogs(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -111,7 +111,7 @@ func NewCmdLogs(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
LogsOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
LogsOptions
)
Complete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
containerName
:=
cmdutil
.
GetFlagString
(
cmd
,
"container"
)
containerName
:=
cmdutil
.
GetFlagString
(
cmd
,
"container"
)
switch
len
(
args
)
{
switch
len
(
args
)
{
case
0
:
case
0
:
...
...
pkg/kubectl/cmd/patch.go
View file @
b2280a64
...
@@ -69,7 +69,7 @@ var (
...
@@ -69,7 +69,7 @@ var (
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'`
)
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'`
)
)
)
func
NewCmdPatch
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdPatch
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
PatchOptions
{}
options
:=
&
PatchOptions
{}
// retrieve a list of handled resources from printer as valid args
// retrieve a list of handled resources from printer as valid args
...
@@ -111,7 +111,7 @@ func NewCmdPatch(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -111,7 +111,7 @@ func NewCmdPatch(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunPatch
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
PatchOptions
)
error
{
func
RunPatch
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
PatchOptions
)
error
{
switch
{
switch
{
case
options
.
Local
&&
len
(
args
)
!=
0
:
case
options
.
Local
&&
len
(
args
)
!=
0
:
return
fmt
.
Errorf
(
"cannot specify --local and server resources"
)
return
fmt
.
Errorf
(
"cannot specify --local and server resources"
)
...
...
pkg/kubectl/cmd/portforward.go
View file @
b2280a64
...
@@ -62,7 +62,7 @@ var (
...
@@ -62,7 +62,7 @@ var (
kubectl port-forward mypod 0:5000`
)
kubectl port-forward mypod 0:5000`
)
)
)
func
NewCmdPortForward
(
f
*
cmdutil
.
Factory
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdPortForward
(
f
cmdutil
.
Factory
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
opts
:=
&
PortForwardOptions
{
opts
:=
&
PortForwardOptions
{
PortForwarder
:
&
defaultPortForwarder
{
PortForwarder
:
&
defaultPortForwarder
{
cmdOut
:
cmdOut
,
cmdOut
:
cmdOut
,
...
@@ -112,7 +112,7 @@ func (f *defaultPortForwarder) ForwardPorts(method string, url *url.URL, opts Po
...
@@ -112,7 +112,7 @@ func (f *defaultPortForwarder) ForwardPorts(method string, url *url.URL, opts Po
}
}
// Complete completes all the required options for port-forward cmd.
// Complete completes all the required options for port-forward cmd.
func
(
o
*
PortForwardOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
cmdOut
io
.
Writer
,
cmdErr
io
.
Writer
)
error
{
func
(
o
*
PortForwardOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
cmdOut
io
.
Writer
,
cmdErr
io
.
Writer
)
error
{
var
err
error
var
err
error
o
.
PodName
=
cmdutil
.
GetFlagString
(
cmd
,
"pod"
)
o
.
PodName
=
cmdutil
.
GetFlagString
(
cmd
,
"pod"
)
if
len
(
o
.
PodName
)
==
0
&&
len
(
args
)
==
0
{
if
len
(
o
.
PodName
)
==
0
&&
len
(
args
)
==
0
{
...
...
pkg/kubectl/cmd/proxy.go
View file @
b2280a64
...
@@ -45,7 +45,7 @@ var (
...
@@ -45,7 +45,7 @@ var (
kubectl proxy --api-prefix=/k8s-api`
)
kubectl proxy --api-prefix=/k8s-api`
)
)
)
func
NewCmdProxy
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdProxy
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]"
,
Use
:
"proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]"
,
Short
:
"Run a proxy to the Kubernetes API server"
,
Short
:
"Run a proxy to the Kubernetes API server"
,
...
@@ -86,7 +86,7 @@ func NewCmdProxy(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -86,7 +86,7 @@ func NewCmdProxy(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunProxy
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
)
error
{
func
RunProxy
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
)
error
{
path
:=
cmdutil
.
GetFlagString
(
cmd
,
"unix-socket"
)
path
:=
cmdutil
.
GetFlagString
(
cmd
,
"unix-socket"
)
port
:=
cmdutil
.
GetFlagInt
(
cmd
,
"port"
)
port
:=
cmdutil
.
GetFlagInt
(
cmd
,
"port"
)
address
:=
cmdutil
.
GetFlagString
(
cmd
,
"address"
)
address
:=
cmdutil
.
GetFlagString
(
cmd
,
"address"
)
...
...
pkg/kubectl/cmd/replace.go
View file @
b2280a64
...
@@ -58,7 +58,7 @@ var (
...
@@ -58,7 +58,7 @@ var (
kubectl replace --force -f ./pod.json`
)
kubectl replace --force -f ./pod.json`
)
)
)
func
NewCmdReplace
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdReplace
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -90,7 +90,7 @@ func NewCmdReplace(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -90,7 +90,7 @@ func NewCmdReplace(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunReplace
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunReplace
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"update"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"update"
{
printDeprecationWarning
(
"replace"
,
"update"
)
printDeprecationWarning
(
"replace"
,
"update"
)
}
}
...
@@ -163,7 +163,7 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
...
@@ -163,7 +163,7 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
})
})
}
}
func
forceReplace
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
shortOutput
bool
,
options
*
resource
.
FilenameOptions
)
error
{
func
forceReplace
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
shortOutput
bool
,
options
*
resource
.
FilenameOptions
)
error
{
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
),
cmdutil
.
GetFlagString
(
cmd
,
"schema-cache-dir"
))
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
),
cmdutil
.
GetFlagString
(
cmd
,
"schema-cache-dir"
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/rollingupdate.go
View file @
b2280a64
...
@@ -74,7 +74,7 @@ var (
...
@@ -74,7 +74,7 @@ var (
pollInterval
,
_
=
time
.
ParseDuration
(
"3s"
)
pollInterval
,
_
=
time
.
ParseDuration
(
"3s"
)
)
)
func
NewCmdRollingUpdate
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRollingUpdate
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -141,7 +141,7 @@ func validateArguments(cmd *cobra.Command, filenames, args []string) error {
...
@@ -141,7 +141,7 @@ func validateArguments(cmd *cobra.Command, filenames, args []string) error {
return
utilerrors
.
NewAggregate
(
errors
)
return
utilerrors
.
NewAggregate
(
errors
)
}
}
func
RunRollingUpdate
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunRollingUpdate
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"rollingupdate"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"rollingupdate"
{
printDeprecationWarning
(
"rolling-update"
,
"rollingupdate"
)
printDeprecationWarning
(
"rolling-update"
,
"rollingupdate"
)
}
}
...
...
pkg/kubectl/cmd/rollout/rollout.go
View file @
b2280a64
...
@@ -36,7 +36,7 @@ var (
...
@@ -36,7 +36,7 @@ var (
`
)
`
)
)
)
func
NewCmdRollout
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRollout
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"rollout SUBCOMMAND"
,
Use
:
"rollout SUBCOMMAND"
,
...
...
pkg/kubectl/cmd/rollout/rollout_history.go
View file @
b2280a64
...
@@ -39,7 +39,7 @@ var (
...
@@ -39,7 +39,7 @@ var (
kubectl rollout history deployment/abc --revision=3`
)
kubectl rollout history deployment/abc --revision=3`
)
)
)
func
NewCmdRolloutHistory
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRolloutHistory
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
validArgs
:=
[]
string
{
"deployment"
}
validArgs
:=
[]
string
{
"deployment"
}
...
@@ -63,7 +63,7 @@ func NewCmdRolloutHistory(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -63,7 +63,7 @@ func NewCmdRolloutHistory(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunHistory
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunHistory
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
options
.
Filenames
)
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
options
.
Filenames
)
{
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_pause.go
View file @
b2280a64
...
@@ -58,7 +58,7 @@ var (
...
@@ -58,7 +58,7 @@ var (
kubectl rollout pause deployment/nginx`
)
kubectl rollout pause deployment/nginx`
)
)
)
func
NewCmdRolloutPause
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRolloutPause
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
PauseConfig
{}
options
:=
&
PauseConfig
{}
validArgs
:=
[]
string
{
"deployment"
}
validArgs
:=
[]
string
{
"deployment"
}
...
@@ -90,7 +90,7 @@ func NewCmdRolloutPause(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -90,7 +90,7 @@ func NewCmdRolloutPause(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
PauseConfig
)
CompletePause
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
)
error
{
func
(
o
*
PauseConfig
)
CompletePause
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
o
.
Filenames
)
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
o
.
Filenames
)
{
return
cmdutil
.
UsageError
(
cmd
,
cmd
.
Use
)
return
cmdutil
.
UsageError
(
cmd
,
cmd
.
Use
)
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_resume.go
View file @
b2280a64
...
@@ -56,7 +56,7 @@ var (
...
@@ -56,7 +56,7 @@ var (
kubectl rollout resume deployment/nginx`
)
kubectl rollout resume deployment/nginx`
)
)
)
func
NewCmdRolloutResume
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRolloutResume
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
ResumeConfig
{}
options
:=
&
ResumeConfig
{}
validArgs
:=
[]
string
{
"deployment"
}
validArgs
:=
[]
string
{
"deployment"
}
...
@@ -88,7 +88,7 @@ func NewCmdRolloutResume(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -88,7 +88,7 @@ func NewCmdRolloutResume(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
ResumeConfig
)
CompleteResume
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
)
error
{
func
(
o
*
ResumeConfig
)
CompleteResume
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
o
.
Filenames
)
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
o
.
Filenames
)
{
return
cmdutil
.
UsageError
(
cmd
,
cmd
.
Use
)
return
cmdutil
.
UsageError
(
cmd
,
cmd
.
Use
)
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_status.go
View file @
b2280a64
...
@@ -45,7 +45,7 @@ var (
...
@@ -45,7 +45,7 @@ var (
kubectl rollout status deployment/nginx`
)
kubectl rollout status deployment/nginx`
)
)
)
func
NewCmdRolloutStatus
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRolloutStatus
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
validArgs
:=
[]
string
{
"deployment"
}
validArgs
:=
[]
string
{
"deployment"
}
...
@@ -70,7 +70,7 @@ func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -70,7 +70,7 @@ func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunStatus
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunStatus
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
,
options
*
resource
.
FilenameOptions
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
options
.
Filenames
)
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
options
.
Filenames
)
{
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_undo.go
View file @
b2280a64
...
@@ -59,7 +59,7 @@ var (
...
@@ -59,7 +59,7 @@ var (
kubectl rollout undo --dry-run=true deployment/abc`
)
kubectl rollout undo --dry-run=true deployment/abc`
)
)
)
func
NewCmdRolloutUndo
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRolloutUndo
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
UndoOptions
{}
options
:=
&
UndoOptions
{}
validArgs
:=
[]
string
{
"deployment"
}
validArgs
:=
[]
string
{
"deployment"
}
...
@@ -93,7 +93,7 @@ func NewCmdRolloutUndo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -93,7 +93,7 @@ func NewCmdRolloutUndo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
UndoOptions
)
CompleteUndo
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
)
error
{
func
(
o
*
UndoOptions
)
CompleteUndo
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
out
io
.
Writer
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
o
.
Filenames
)
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameEmpty
(
o
.
Filenames
)
{
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
return
cmdutil
.
UsageError
(
cmd
,
"Required resource not specified."
)
}
}
...
...
pkg/kubectl/cmd/run.go
View file @
b2280a64
...
@@ -83,7 +83,7 @@ var (
...
@@ -83,7 +83,7 @@ var (
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'`
)
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'`
)
)
)
func
NewCmdRun
(
f
*
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdRun
(
f
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"run NAME --image=image [--env=
\"
key=value
\"
] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...]"
,
Use
:
"run NAME --image=image [--env=
\"
key=value
\"
] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...]"
,
// run-container is deprecated
// run-container is deprecated
...
@@ -133,7 +133,7 @@ func addRunFlags(cmd *cobra.Command) {
...
@@ -133,7 +133,7 @@ func addRunFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
String
(
"schedule"
,
""
,
"A schedule in the Cron format the job should be run with."
)
cmd
.
Flags
()
.
String
(
"schedule"
,
""
,
"A schedule in the Cron format the job should be run with."
)
}
}
func
Run
(
f
*
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
argsLenAtDash
int
)
error
{
func
Run
(
f
cmdutil
.
Factory
,
cmdIn
io
.
Reader
,
cmdOut
,
cmdErr
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
argsLenAtDash
int
)
error
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"run-container"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"run-container"
{
printDeprecationWarning
(
"run"
,
"run-container"
)
printDeprecationWarning
(
"run"
,
"run-container"
)
}
}
...
@@ -456,7 +456,7 @@ func waitForPodTerminated(podClient coreclient.PodsGetter, ns, name string, out
...
@@ -456,7 +456,7 @@ func waitForPodTerminated(podClient coreclient.PodsGetter, ns, name string, out
return
pod
,
err
return
pod
,
err
}
}
func
handleAttachPod
(
f
*
cmdutil
.
Factory
,
podClient
coreclient
.
PodsGetter
,
ns
,
name
string
,
opts
*
AttachOptions
,
quiet
bool
)
error
{
func
handleAttachPod
(
f
cmdutil
.
Factory
,
podClient
coreclient
.
PodsGetter
,
ns
,
name
string
,
opts
*
AttachOptions
,
quiet
bool
)
error
{
pod
,
err
:=
waitForPodRunning
(
podClient
,
ns
,
name
,
opts
.
Out
,
quiet
)
pod
,
err
:=
waitForPodRunning
(
podClient
,
ns
,
name
,
opts
.
Out
,
quiet
)
if
err
!=
nil
&&
err
!=
conditions
.
ErrPodCompleted
{
if
err
!=
nil
&&
err
!=
conditions
.
ErrPodCompleted
{
return
err
return
err
...
@@ -535,7 +535,7 @@ func verifyImagePullPolicy(cmd *cobra.Command) error {
...
@@ -535,7 +535,7 @@ func verifyImagePullPolicy(cmd *cobra.Command) error {
}
}
}
}
func
generateService
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
serviceGenerator
string
,
paramsIn
map
[
string
]
interface
{},
namespace
string
,
out
io
.
Writer
)
error
{
func
generateService
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
serviceGenerator
string
,
paramsIn
map
[
string
]
interface
{},
namespace
string
,
out
io
.
Writer
)
error
{
generators
:=
f
.
Generators
(
"expose"
)
generators
:=
f
.
Generators
(
"expose"
)
generator
,
found
:=
generators
[
serviceGenerator
]
generator
,
found
:=
generators
[
serviceGenerator
]
if
!
found
{
if
!
found
{
...
@@ -583,7 +583,7 @@ func generateService(f *cmdutil.Factory, cmd *cobra.Command, args []string, serv
...
@@ -583,7 +583,7 @@ func generateService(f *cmdutil.Factory, cmd *cobra.Command, args []string, serv
return
nil
return
nil
}
}
func
createGeneratedObject
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
generator
kubectl
.
Generator
,
names
[]
kubectl
.
GeneratorParam
,
params
map
[
string
]
interface
{},
overrides
,
namespace
string
)
(
runtime
.
Object
,
string
,
meta
.
RESTMapper
,
*
meta
.
RESTMapping
,
error
)
{
func
createGeneratedObject
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
generator
kubectl
.
Generator
,
names
[]
kubectl
.
GeneratorParam
,
params
map
[
string
]
interface
{},
overrides
,
namespace
string
)
(
runtime
.
Object
,
string
,
meta
.
RESTMapper
,
*
meta
.
RESTMapping
,
error
)
{
err
:=
kubectl
.
ValidateParams
(
names
,
params
)
err
:=
kubectl
.
ValidateParams
(
names
,
params
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
""
,
nil
,
nil
,
err
return
nil
,
""
,
nil
,
nil
,
err
...
...
pkg/kubectl/cmd/scale.go
View file @
b2280a64
...
@@ -56,7 +56,7 @@ var (
...
@@ -56,7 +56,7 @@ var (
)
)
// NewCmdScale returns a cobra command with the appropriate configuration and flags to run scale
// NewCmdScale returns a cobra command with the appropriate configuration and flags to run scale
func
NewCmdScale
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdScale
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
validArgs
:=
[]
string
{
"deployment"
,
"replicaset"
,
"replicationcontroller"
,
"job"
}
validArgs
:=
[]
string
{
"deployment"
,
"replicaset"
,
"replicationcontroller"
,
"job"
}
...
@@ -93,7 +93,7 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -93,7 +93,7 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
}
// RunScale executes the scaling
// RunScale executes the scaling
func
RunScale
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
shortOutput
bool
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunScale
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
shortOutput
bool
,
options
*
resource
.
FilenameOptions
)
error
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"resize"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"resize"
{
printDeprecationWarning
(
"scale"
,
"resize"
)
printDeprecationWarning
(
"scale"
,
"resize"
)
}
}
...
...
pkg/kubectl/cmd/set/set.go
View file @
b2280a64
...
@@ -32,7 +32,7 @@ var (
...
@@ -32,7 +32,7 @@ var (
set_example
=
dedent
.
Dedent
(
``
)
set_example
=
dedent
.
Dedent
(
``
)
)
)
func
NewCmdSet
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdSet
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"set SUBCOMMAND"
,
Use
:
"set SUBCOMMAND"
,
...
...
pkg/kubectl/cmd/set/set_image.go
View file @
b2280a64
...
@@ -78,7 +78,7 @@ var (
...
@@ -78,7 +78,7 @@ var (
kubectl set image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml`
)
kubectl set image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml`
)
)
)
func
NewCmdImage
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdImage
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
ImageOptions
{
options
:=
&
ImageOptions
{
Out
:
out
,
Out
:
out
,
}
}
...
@@ -105,7 +105,7 @@ func NewCmdImage(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -105,7 +105,7 @@ func NewCmdImage(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
ImageOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ImageOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
o
.
Mapper
,
o
.
Typer
=
f
.
Object
()
o
.
Mapper
,
o
.
Typer
=
f
.
Object
()
o
.
UpdatePodSpecForObject
=
f
.
UpdatePodSpecForObject
o
.
UpdatePodSpecForObject
=
f
.
UpdatePodSpecForObject
o
.
Encoder
=
f
.
JSONEncoder
()
o
.
Encoder
=
f
.
JSONEncoder
()
...
...
pkg/kubectl/cmd/stop.go
View file @
b2280a64
...
@@ -49,7 +49,7 @@ var (
...
@@ -49,7 +49,7 @@ var (
kubectl stop -f path/to/resources`
)
kubectl stop -f path/to/resources`
)
)
)
func
NewCmdStop
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdStop
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
resource
.
FilenameOptions
{}
options
:=
&
resource
.
FilenameOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -75,7 +75,7 @@ func NewCmdStop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -75,7 +75,7 @@ func NewCmdStop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunStop
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
,
options
*
resource
.
FilenameOptions
)
error
{
func
RunStop
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
,
options
*
resource
.
FilenameOptions
)
error
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/taint.go
View file @
b2280a64
...
@@ -47,7 +47,7 @@ type TaintOptions struct {
...
@@ -47,7 +47,7 @@ type TaintOptions struct {
selector
string
selector
string
overwrite
bool
overwrite
bool
all
bool
all
bool
f
*
cmdutil
.
Factory
f
cmdutil
.
Factory
out
io
.
Writer
out
io
.
Writer
cmd
*
cobra
.
Command
cmd
*
cobra
.
Command
}
}
...
@@ -73,7 +73,7 @@ var (
...
@@ -73,7 +73,7 @@ var (
kubectl taint nodes foo dedicated-`
)
kubectl taint nodes foo dedicated-`
)
)
)
func
NewCmdTaint
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdTaint
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
TaintOptions
{}
options
:=
&
TaintOptions
{}
validArgs
:=
[]
string
{
"node"
}
validArgs
:=
[]
string
{
"node"
}
...
@@ -220,7 +220,7 @@ func parseTaints(spec []string) ([]api.Taint, []api.Taint, error) {
...
@@ -220,7 +220,7 @@ func parseTaints(spec []string) ([]api.Taint, []api.Taint, error) {
}
}
// Complete adapts from the command line args and factory to the data required.
// Complete adapts from the command line args and factory to the data required.
func
(
o
*
TaintOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
func
(
o
*
TaintOptions
)
Complete
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
namespace
,
_
,
err
:=
f
.
DefaultNamespace
()
namespace
,
_
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubectl/cmd/top.go
View file @
b2280a64
...
@@ -35,7 +35,7 @@ var (
...
@@ -35,7 +35,7 @@ var (
The top command allows you to see the resource consumption for nodes or pods.`
)
The top command allows you to see the resource consumption for nodes or pods.`
)
)
)
func
NewCmdTop
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdTop
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
TopOptions
{}
options
:=
&
TopOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -55,6 +55,6 @@ func NewCmdTop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -55,6 +55,6 @@ func NewCmdTop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
TopOptions
)
RunTop
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
func
(
o
TopOptions
)
RunTop
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
return
cmd
.
Help
()
return
cmd
.
Help
()
}
}
pkg/kubectl/cmd/top_node.go
View file @
b2280a64
...
@@ -53,7 +53,7 @@ var (
...
@@ -53,7 +53,7 @@ var (
kubectl top node NODE_NAME`
)
kubectl top node NODE_NAME`
)
)
)
func
NewCmdTopNode
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdTopNode
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
TopNodeOptions
{}
options
:=
&
TopNodeOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -78,7 +78,7 @@ func NewCmdTopNode(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -78,7 +78,7 @@ func NewCmdTopNode(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
TopNodeOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
func
(
o
*
TopNodeOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
var
err
error
var
err
error
if
len
(
args
)
==
1
{
if
len
(
args
)
==
1
{
o
.
ResourceName
=
args
[
0
]
o
.
ResourceName
=
args
[
0
]
...
...
pkg/kubectl/cmd/top_pod.go
View file @
b2280a64
...
@@ -69,7 +69,7 @@ var (
...
@@ -69,7 +69,7 @@ var (
kubectl top pod -l name=myLabel`
)
kubectl top pod -l name=myLabel`
)
)
)
func
NewCmdTopPod
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdTopPod
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
options
:=
&
TopPodOptions
{}
options
:=
&
TopPodOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -96,7 +96,7 @@ func NewCmdTopPod(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -96,7 +96,7 @@ func NewCmdTopPod(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
(
o
*
TopPodOptions
)
Complete
(
f
*
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
func
(
o
*
TopPodOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
out
io
.
Writer
)
error
{
var
err
error
var
err
error
if
len
(
args
)
==
1
{
if
len
(
args
)
==
1
{
o
.
ResourceName
=
args
[
0
]
o
.
ResourceName
=
args
[
0
]
...
...
pkg/kubectl/cmd/version.go
View file @
b2280a64
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
)
func
NewCmdVersion
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdVersion
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"version"
,
Use
:
"version"
,
Short
:
"Print the client and server version information"
,
Short
:
"Print the client and server version information"
,
...
@@ -40,7 +40,7 @@ func NewCmdVersion(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -40,7 +40,7 @@ func NewCmdVersion(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
RunVersion
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
)
error
{
func
RunVersion
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
cmd
*
cobra
.
Command
)
error
{
kubectl
.
GetClientVersion
(
out
)
kubectl
.
GetClientVersion
(
out
)
if
cmdutil
.
GetFlagBool
(
cmd
,
"client"
)
{
if
cmdutil
.
GetFlagBool
(
cmd
,
"client"
)
{
return
nil
return
nil
...
...
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