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
c85e69ae
Unverified
Commit
c85e69ae
authored
May 24, 2018
by
David Eads
Committed by
Maciej Szulik
May 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unnecessary factory delegation for RESTClientGetter method
parent
4da73a5f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
89 changed files
with
205 additions
and
314 deletions
+205
-314
annotate.go
pkg/kubectl/cmd/annotate.go
+1
-1
annotate_test.go
pkg/kubectl/cmd/annotate_test.go
+5
-10
apply.go
pkg/kubectl/cmd/apply.go
+1
-1
apply_set_last_applied.go
pkg/kubectl/cmd/apply_set_last_applied.go
+1
-1
apply_test.go
pkg/kubectl/cmd/apply_test.go
+14
-28
apply_view_last_applied.go
pkg/kubectl/cmd/apply_view_last_applied.go
+1
-1
attach.go
pkg/kubectl/cmd/attach.go
+1
-1
attach_test.go
pkg/kubectl/cmd/attach_test.go
+3
-6
cani.go
pkg/kubectl/cmd/auth/cani.go
+1
-1
cani_test.go
pkg/kubectl/cmd/auth/cani_test.go
+1
-2
reconcile.go
pkg/kubectl/cmd/auth/reconcile.go
+1
-1
autoscale.go
pkg/kubectl/cmd/autoscale.go
+1
-1
clusterinfo_dump.go
pkg/kubectl/cmd/clusterinfo_dump.go
+1
-1
convert.go
pkg/kubectl/cmd/convert.go
+1
-1
convert_test.go
pkg/kubectl/cmd/convert_test.go
+1
-2
cp.go
pkg/kubectl/cmd/cp.go
+1
-1
cp_test.go
pkg/kubectl/cmd/cp_test.go
+1
-2
create.go
pkg/kubectl/cmd/create/create.go
+2
-2
create_clusterrole_test.go
pkg/kubectl/cmd/create/create_clusterrole_test.go
+2
-5
create_clusterrolebinding_test.go
pkg/kubectl/cmd/create/create_clusterrolebinding_test.go
+1
-2
create_configmap_test.go
pkg/kubectl/cmd/create/create_configmap_test.go
+1
-2
create_deployment_test.go
pkg/kubectl/cmd/create/create_deployment_test.go
+2
-4
create_job.go
pkg/kubectl/cmd/create/create_job.go
+1
-1
create_pdb_test.go
pkg/kubectl/cmd/create/create_pdb_test.go
+1
-2
create_quota_test.go
pkg/kubectl/cmd/create/create_quota_test.go
+1
-3
create_role.go
pkg/kubectl/cmd/create/create_role.go
+1
-1
create_role_test.go
pkg/kubectl/cmd/create/create_role_test.go
+3
-7
create_rolebinding_test.go
pkg/kubectl/cmd/create/create_rolebinding_test.go
+1
-2
create_secret_test.go
pkg/kubectl/cmd/create/create_secret_test.go
+2
-4
create_service_test.go
pkg/kubectl/cmd/create/create_service_test.go
+3
-6
create_serviceaccount_test.go
pkg/kubectl/cmd/create/create_serviceaccount_test.go
+1
-2
create_test.go
pkg/kubectl/cmd/create/create_test.go
+3
-6
delete.go
pkg/kubectl/cmd/delete.go
+1
-1
delete_test.go
pkg/kubectl/cmd/delete_test.go
+15
-30
describe.go
pkg/kubectl/cmd/describe.go
+1
-1
describe_test.go
pkg/kubectl/cmd/describe_test.go
+6
-11
diff.go
pkg/kubectl/cmd/diff.go
+2
-2
drain.go
pkg/kubectl/cmd/drain.go
+1
-1
edit_test.go
pkg/kubectl/cmd/edit_test.go
+1
-5
exec.go
pkg/kubectl/cmd/exec.go
+1
-1
exec_test.go
pkg/kubectl/cmd/exec_test.go
+2
-4
expose.go
pkg/kubectl/cmd/expose.go
+1
-1
expose_test.go
pkg/kubectl/cmd/expose_test.go
+1
-2
get.go
pkg/kubectl/cmd/get/get.go
+1
-1
get_test.go
pkg/kubectl/cmd/get/get_test.go
+0
-0
label.go
pkg/kubectl/cmd/label.go
+1
-1
label_test.go
pkg/kubectl/cmd/label_test.go
+4
-8
logs.go
pkg/kubectl/cmd/logs.go
+1
-1
logs_test.go
pkg/kubectl/cmd/logs_test.go
+2
-2
patch.go
pkg/kubectl/cmd/patch.go
+1
-1
patch_test.go
pkg/kubectl/cmd/patch_test.go
+4
-8
plugin.go
pkg/kubectl/cmd/plugin.go
+1
-1
portforward.go
pkg/kubectl/cmd/portforward.go
+1
-1
portforward_test.go
pkg/kubectl/cmd/portforward_test.go
+1
-2
replace.go
pkg/kubectl/cmd/replace.go
+1
-1
replace_test.go
pkg/kubectl/cmd/replace_test.go
+4
-8
rollingupdate.go
pkg/kubectl/cmd/rollingupdate.go
+1
-1
rollout_history.go
pkg/kubectl/cmd/rollout/rollout_history.go
+1
-1
rollout_pause.go
pkg/kubectl/cmd/rollout/rollout_pause.go
+1
-1
rollout_pause_test.go
pkg/kubectl/cmd/rollout/rollout_pause_test.go
+1
-2
rollout_resume.go
pkg/kubectl/cmd/rollout/rollout_resume.go
+1
-1
rollout_status.go
pkg/kubectl/cmd/rollout/rollout_status.go
+1
-1
rollout_undo.go
pkg/kubectl/cmd/rollout/rollout_undo.go
+1
-1
run.go
pkg/kubectl/cmd/run.go
+1
-1
run_test.go
pkg/kubectl/cmd/run_test.go
+2
-4
scale.go
pkg/kubectl/cmd/scale.go
+1
-1
set_env.go
pkg/kubectl/cmd/set/set_env.go
+1
-1
set_env_test.go
pkg/kubectl/cmd/set/set_env_test.go
+5
-9
set_image.go
pkg/kubectl/cmd/set/set_image.go
+1
-1
set_image_test.go
pkg/kubectl/cmd/set/set_image_test.go
+4
-7
set_resources.go
pkg/kubectl/cmd/set/set_resources.go
+1
-1
set_resources_test.go
pkg/kubectl/cmd/set/set_resources_test.go
+4
-7
set_selector.go
pkg/kubectl/cmd/set/set_selector.go
+1
-1
set_selector_test.go
pkg/kubectl/cmd/set/set_selector_test.go
+1
-2
set_serviceaccount.go
pkg/kubectl/cmd/set/set_serviceaccount.go
+1
-1
set_serviceaccount_test.go
pkg/kubectl/cmd/set/set_serviceaccount_test.go
+5
-9
set_subject.go
pkg/kubectl/cmd/set/set_subject.go
+1
-1
set_subject_test.go
pkg/kubectl/cmd/set/set_subject_test.go
+1
-3
taint.go
pkg/kubectl/cmd/taint.go
+1
-1
BUILD
pkg/kubectl/cmd/testing/BUILD
+0
-1
fake.go
pkg/kubectl/cmd/testing/fake.go
+8
-20
top_node_test.go
pkg/kubectl/cmd/top_node_test.go
+7
-14
top_pod.go
pkg/kubectl/cmd/top_pod.go
+1
-1
top_pod_test.go
pkg/kubectl/cmd/top_pod_test.go
+3
-6
editoptions.go
pkg/kubectl/cmd/util/editor/editoptions.go
+1
-1
factory.go
pkg/kubectl/cmd/util/factory.go
+0
-5
factory_client_access.go
pkg/kubectl/cmd/util/factory_client_access.go
+0
-4
BUILD
pkg/kubectl/genericclioptions/BUILD
+1
-0
config_flags_fake.go
pkg/kubectl/genericclioptions/config_flags_fake.go
+31
-0
No files found.
pkg/kubectl/cmd/annotate.go
View file @
c85e69ae
...
@@ -177,7 +177,7 @@ func (o *AnnotateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
...
@@ -177,7 +177,7 @@ func (o *AnnotateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
return
printer
.
PrintObj
(
obj
,
out
)
return
printer
.
PrintObj
(
obj
,
out
)
}
}
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/annotate_test.go
View file @
c85e69ae
...
@@ -418,10 +418,9 @@ func TestAnnotateErrors(t *testing.T) {
...
@@ -418,10 +418,9 @@ func TestAnnotateErrors(t *testing.T) {
for
k
,
testCase
:=
range
testCases
{
for
k
,
testCase
:=
range
testCases
{
t
.
Run
(
k
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
k
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
iostreams
,
_
,
bufOut
,
bufErr
:=
genericclioptions
.
NewTestIOStreams
()
iostreams
,
_
,
bufOut
,
bufErr
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -453,7 +452,7 @@ func TestAnnotateErrors(t *testing.T) {
...
@@ -453,7 +452,7 @@ func TestAnnotateErrors(t *testing.T) {
func
TestAnnotateObject
(
t
*
testing
.
T
)
{
func
TestAnnotateObject
(
t
*
testing
.
T
)
{
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -485,7 +484,6 @@ func TestAnnotateObject(t *testing.T) {
...
@@ -485,7 +484,6 @@ func TestAnnotateObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
iostreams
,
_
,
bufOut
,
_
:=
genericclioptions
.
NewTestIOStreams
()
iostreams
,
_
,
bufOut
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -507,7 +505,7 @@ func TestAnnotateObject(t *testing.T) {
...
@@ -507,7 +505,7 @@ func TestAnnotateObject(t *testing.T) {
func
TestAnnotateObjectFromFile
(
t
*
testing
.
T
)
{
func
TestAnnotateObjectFromFile
(
t
*
testing
.
T
)
{
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -539,7 +537,6 @@ func TestAnnotateObjectFromFile(t *testing.T) {
...
@@ -539,7 +537,6 @@ func TestAnnotateObjectFromFile(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
iostreams
,
_
,
bufOut
,
_
:=
genericclioptions
.
NewTestIOStreams
()
iostreams
,
_
,
bufOut
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -560,7 +557,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
...
@@ -560,7 +557,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
}
}
func
TestAnnotateLocal
(
t
*
testing
.
T
)
{
func
TestAnnotateLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -571,7 +568,6 @@ func TestAnnotateLocal(t *testing.T) {
...
@@ -571,7 +568,6 @@ func TestAnnotateLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
iostreams
,
_
,
_
,
_
:=
genericclioptions
.
NewTestIOStreams
()
iostreams
,
_
,
_
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -594,7 +590,7 @@ func TestAnnotateLocal(t *testing.T) {
...
@@ -594,7 +590,7 @@ func TestAnnotateLocal(t *testing.T) {
func
TestAnnotateMultipleObjects
(
t
*
testing
.
T
)
{
func
TestAnnotateMultipleObjects
(
t
*
testing
.
T
)
{
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -627,7 +623,6 @@ func TestAnnotateMultipleObjects(t *testing.T) {
...
@@ -627,7 +623,6 @@ func TestAnnotateMultipleObjects(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
iostreams
,
_
,
_
,
_
:=
genericclioptions
.
NewTestIOStreams
()
iostreams
,
_
,
_
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/apply.go
View file @
c85e69ae
...
@@ -230,7 +230,7 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -230,7 +230,7 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
return
err
return
err
}
}
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/apply_set_last_applied.go
View file @
c85e69ae
...
@@ -118,7 +118,7 @@ func (o *SetLastAppliedOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
...
@@ -118,7 +118,7 @@ func (o *SetLastAppliedOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
o
.
shortOutput
=
o
.
output
==
"name"
o
.
shortOutput
=
o
.
output
==
"name"
var
err
error
var
err
error
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/apply_test.go
View file @
c85e69ae
...
@@ -273,7 +273,7 @@ func TestRunApplyPrintsValidObjectList(t *testing.T) {
...
@@ -273,7 +273,7 @@ func TestRunApplyPrintsValidObjectList(t *testing.T) {
cmBytes
:=
readConfigMapList
(
t
,
filenameCM
)
cmBytes
:=
readConfigMapList
(
t
,
filenameCM
)
pathCM
:=
"/namespaces/test/configmaps"
pathCM
:=
"/namespaces/test/configmaps"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -292,7 +292,6 @@ func TestRunApplyPrintsValidObjectList(t *testing.T) {
...
@@ -292,7 +292,6 @@ func TestRunApplyPrintsValidObjectList(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -393,7 +392,7 @@ func TestRunApplyViewLastApplied(t *testing.T) {
...
@@ -393,7 +392,7 @@ func TestRunApplyViewLastApplied(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -419,7 +418,6 @@ func TestRunApplyViewLastApplied(t *testing.T) {
...
@@ -419,7 +418,6 @@ func TestRunApplyViewLastApplied(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
cmdutil
.
BehaviorOnFatal
(
func
(
str
string
,
code
int
)
{
cmdutil
.
BehaviorOnFatal
(
func
(
str
string
,
code
int
)
{
...
@@ -453,7 +451,7 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) {
...
@@ -453,7 +451,7 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) {
nameRC
,
rcBytes
:=
readReplicationController
(
t
,
filenameRC
)
nameRC
,
rcBytes
:=
readReplicationController
(
t
,
filenameRC
)
pathRC
:=
"/namespaces/test/replicationcontrollers/"
+
nameRC
pathRC
:=
"/namespaces/test/replicationcontrollers/"
+
nameRC
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -472,7 +470,6 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) {
...
@@ -472,7 +470,6 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -499,7 +496,7 @@ func TestApplyObject(t *testing.T) {
...
@@ -499,7 +496,7 @@ func TestApplyObject(t *testing.T) {
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
t
.
Run
(
"test apply when a local object is specified"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test apply when a local object is specified"
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -520,7 +517,6 @@ func TestApplyObject(t *testing.T) {
...
@@ -520,7 +517,6 @@ func TestApplyObject(t *testing.T) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -564,7 +560,7 @@ func TestApplyObjectOutput(t *testing.T) {
...
@@ -564,7 +560,7 @@ func TestApplyObjectOutput(t *testing.T) {
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
t
.
Run
(
"test apply returns correct output"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test apply returns correct output"
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -585,7 +581,6 @@ func TestApplyObjectOutput(t *testing.T) {
...
@@ -585,7 +581,6 @@ func TestApplyObjectOutput(t *testing.T) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -617,7 +612,7 @@ func TestApplyRetry(t *testing.T) {
...
@@ -617,7 +612,7 @@ func TestApplyRetry(t *testing.T) {
firstPatch
:=
true
firstPatch
:=
true
retry
:=
false
retry
:=
false
getCount
:=
0
getCount
:=
0
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -647,7 +642,6 @@ func TestApplyRetry(t *testing.T) {
...
@@ -647,7 +642,6 @@ func TestApplyRetry(t *testing.T) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -677,7 +671,7 @@ func TestApplyNonExistObject(t *testing.T) {
...
@@ -677,7 +671,7 @@ func TestApplyNonExistObject(t *testing.T) {
pathRC
:=
"/namespaces/test/replicationcontrollers"
pathRC
:=
"/namespaces/test/replicationcontrollers"
pathNameRC
:=
pathRC
+
"/"
+
nameRC
pathNameRC
:=
pathRC
+
"/"
+
nameRC
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -697,7 +691,6 @@ func TestApplyNonExistObject(t *testing.T) {
...
@@ -697,7 +691,6 @@ func TestApplyNonExistObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -723,7 +716,7 @@ func TestApplyEmptyPatch(t *testing.T) {
...
@@ -723,7 +716,7 @@ func TestApplyEmptyPatch(t *testing.T) {
var
body
[]
byte
var
body
[]
byte
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -750,7 +743,6 @@ func TestApplyEmptyPatch(t *testing.T) {
...
@@ -750,7 +743,6 @@ func TestApplyEmptyPatch(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
// 1. apply non exist object
// 1. apply non exist object
...
@@ -797,7 +789,7 @@ func testApplyMultipleObjects(t *testing.T, asList bool) {
...
@@ -797,7 +789,7 @@ func testApplyMultipleObjects(t *testing.T, asList bool) {
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
t
.
Run
(
"test apply on multiple objects"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test apply on multiple objects"
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -825,7 +817,6 @@ func testApplyMultipleObjects(t *testing.T, asList bool) {
...
@@ -825,7 +817,6 @@ func testApplyMultipleObjects(t *testing.T, asList bool) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -884,7 +875,7 @@ func TestApplyNULLPreservation(t *testing.T) {
...
@@ -884,7 +875,7 @@ func TestApplyNULLPreservation(t *testing.T) {
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
t
.
Run
(
"test apply preserves NULL fields"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test apply preserves NULL fields"
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -926,7 +917,6 @@ func TestApplyNULLPreservation(t *testing.T) {
...
@@ -926,7 +917,6 @@ func TestApplyNULLPreservation(t *testing.T) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -960,7 +950,7 @@ func TestUnstructuredApply(t *testing.T) {
...
@@ -960,7 +950,7 @@ func TestUnstructuredApply(t *testing.T) {
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
t
.
Run
(
"test apply works correctly with unstructured objects"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test apply works correctly with unstructured objects"
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -993,7 +983,6 @@ func TestUnstructuredApply(t *testing.T) {
...
@@ -993,7 +983,6 @@ func TestUnstructuredApply(t *testing.T) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -1029,7 +1018,7 @@ func TestUnstructuredIdempotentApply(t *testing.T) {
...
@@ -1029,7 +1018,7 @@ func TestUnstructuredIdempotentApply(t *testing.T) {
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
for
_
,
fn
:=
range
testingOpenAPISchemaFns
{
t
.
Run
(
"test repeated apply operations on an unstructured object"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test repeated apply operations on an unstructured object"
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -1059,7 +1048,6 @@ func TestUnstructuredIdempotentApply(t *testing.T) {
...
@@ -1059,7 +1048,6 @@ func TestUnstructuredIdempotentApply(t *testing.T) {
}),
}),
}
}
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -1131,7 +1119,7 @@ func TestRunApplySetLastApplied(t *testing.T) {
...
@@ -1131,7 +1119,7 @@ func TestRunApplySetLastApplied(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -1161,7 +1149,6 @@ func TestRunApplySetLastApplied(t *testing.T) {
...
@@ -1161,7 +1149,6 @@ func TestRunApplySetLastApplied(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
cmdutil
.
BehaviorOnFatal
(
func
(
str
string
,
code
int
)
{
cmdutil
.
BehaviorOnFatal
(
func
(
str
string
,
code
int
)
{
...
@@ -1227,7 +1214,7 @@ func TestForceApply(t *testing.T) {
...
@@ -1227,7 +1214,7 @@ func TestForceApply(t *testing.T) {
deleted
:=
false
deleted
:=
false
isScaledDownToZero
:=
false
isScaledDownToZero
:=
false
counts
:=
map
[
string
]
int
{}
counts
:=
map
[
string
]
int
{}
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
...
@@ -1312,7 +1299,6 @@ func TestForceApply(t *testing.T) {
...
@@ -1312,7 +1299,6 @@ func TestForceApply(t *testing.T) {
tf
.
OpenAPISchemaFunc
=
fn
tf
.
OpenAPISchemaFunc
=
fn
tf
.
Client
=
tf
.
UnstructuredClient
tf
.
Client
=
tf
.
UnstructuredClient
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdApply
(
"kubectl"
,
tf
,
ioStreams
)
cmd
:=
NewCmdApply
(
"kubectl"
,
tf
,
ioStreams
)
...
...
pkg/kubectl/cmd/apply_view_last_applied.go
View file @
c85e69ae
...
@@ -91,7 +91,7 @@ func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericclioptions.I
...
@@ -91,7 +91,7 @@ func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericclioptions.I
}
}
func
(
o
*
ViewLastAppliedOptions
)
Complete
(
cmd
*
cobra
.
Command
,
f
cmdutil
.
Factory
,
args
[]
string
)
error
{
func
(
o
*
ViewLastAppliedOptions
)
Complete
(
cmd
*
cobra
.
Command
,
f
cmdutil
.
Factory
,
args
[]
string
)
error
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/attach.go
View file @
c85e69ae
...
@@ -135,7 +135,7 @@ func (p *AttachOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn [
...
@@ -135,7 +135,7 @@ func (p *AttachOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn [
return
cmdutil
.
UsageErrorf
(
cmd
,
"expected POD, TYPE/NAME, or TYPE NAME, (at most 2 arguments) saw %d: %v"
,
len
(
argsIn
),
argsIn
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"expected POD, TYPE/NAME, or TYPE NAME, (at most 2 arguments) saw %d: %v"
,
len
(
argsIn
),
argsIn
)
}
}
namespace
,
_
,
err
:=
f
.
Default
Namespace
()
namespace
,
_
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/attach_test.go
View file @
c85e69ae
...
@@ -140,7 +140,7 @@ func TestPodAndContainerAttach(t *testing.T) {
...
@@ -140,7 +140,7 @@ func TestPodAndContainerAttach(t *testing.T) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -156,7 +156,6 @@ func TestPodAndContainerAttach(t *testing.T) {
...
@@ -156,7 +156,6 @@ func TestPodAndContainerAttach(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
cmd
:=
&
cobra
.
Command
{}
cmd
:=
&
cobra
.
Command
{}
...
@@ -224,7 +223,7 @@ func TestAttach(t *testing.T) {
...
@@ -224,7 +223,7 @@ func TestAttach(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -247,7 +246,6 @@ func TestAttach(t *testing.T) {
...
@@ -247,7 +246,6 @@ func TestAttach(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
APIPath
:
"/api"
,
ContentConfig
:
restclient
.
ContentConfig
{
NegotiatedSerializer
:
legacyscheme
.
Codecs
,
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
test
.
version
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
APIPath
:
"/api"
,
ContentConfig
:
restclient
.
ContentConfig
{
NegotiatedSerializer
:
legacyscheme
.
Codecs
,
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
test
.
version
}}}
remoteAttach
:=
&
fakeRemoteAttach
{}
remoteAttach
:=
&
fakeRemoteAttach
{}
if
test
.
remoteAttachErr
{
if
test
.
remoteAttachErr
{
...
@@ -312,7 +310,7 @@ func TestAttachWarnings(t *testing.T) {
...
@@ -312,7 +310,7 @@ func TestAttachWarnings(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -335,7 +333,6 @@ func TestAttachWarnings(t *testing.T) {
...
@@ -335,7 +333,6 @@ func TestAttachWarnings(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
APIPath
:
"/api"
,
ContentConfig
:
restclient
.
ContentConfig
{
NegotiatedSerializer
:
legacyscheme
.
Codecs
,
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
test
.
version
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
APIPath
:
"/api"
,
ContentConfig
:
restclient
.
ContentConfig
{
NegotiatedSerializer
:
legacyscheme
.
Codecs
,
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
test
.
version
}}}
streams
,
_
,
_
,
bufErr
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
_
,
bufErr
:=
genericclioptions
.
NewTestIOStreams
()
ex
:=
&
fakeRemoteAttach
{}
ex
:=
&
fakeRemoteAttach
{}
...
...
pkg/kubectl/cmd/auth/cani.go
View file @
c85e69ae
...
@@ -146,7 +146,7 @@ func (o *CanIOptions) Complete(f cmdutil.Factory, args []string) error {
...
@@ -146,7 +146,7 @@ func (o *CanIOptions) Complete(f cmdutil.Factory, args []string) error {
o
.
Namespace
=
""
o
.
Namespace
=
""
if
!
o
.
AllNamespaces
{
if
!
o
.
AllNamespaces
{
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/auth/cani_test.go
View file @
c85e69ae
...
@@ -121,7 +121,7 @@ func TestRunAccessCheck(t *testing.T) {
...
@@ -121,7 +121,7 @@ func TestRunAccessCheck(t *testing.T) {
test
.
o
.
Out
=
ioutil
.
Discard
test
.
o
.
Out
=
ioutil
.
Discard
test
.
o
.
ErrOut
=
ioutil
.
Discard
test
.
o
.
ErrOut
=
ioutil
.
Discard
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -157,7 +157,6 @@ func TestRunAccessCheck(t *testing.T) {
...
@@ -157,7 +157,6 @@ func TestRunAccessCheck(t *testing.T) {
test
.
serverErr
test
.
serverErr
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
}}}
if
err
:=
test
.
o
.
Complete
(
tf
,
test
.
args
);
err
!=
nil
{
if
err
:=
test
.
o
.
Complete
(
tf
,
test
.
args
);
err
!=
nil
{
...
...
pkg/kubectl/cmd/auth/reconcile.go
View file @
c85e69ae
...
@@ -97,7 +97,7 @@ func (o *ReconcileOptions) Complete(cmd *cobra.Command, f cmdutil.Factory, args
...
@@ -97,7 +97,7 @@ func (o *ReconcileOptions) Complete(cmd *cobra.Command, f cmdutil.Factory, args
return
errors
.
New
(
"no arguments are allowed"
)
return
errors
.
New
(
"no arguments are allowed"
)
}
}
namespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
namespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/autoscale.go
View file @
c85e69ae
...
@@ -165,7 +165,7 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
...
@@ -165,7 +165,7 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
}
}
}
}
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/clusterinfo_dump.go
View file @
c85e69ae
...
@@ -134,7 +134,7 @@ func (o *ClusterInfoDumpOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
...
@@ -134,7 +134,7 @@ func (o *ClusterInfoDumpOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/convert.go
View file @
c85e69ae
...
@@ -139,7 +139,7 @@ func (o *ConvertOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) (err er
...
@@ -139,7 +139,7 @@ func (o *ConvertOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) (err er
o
.
builder
.
Schema
(
schema
)
o
.
builder
.
Schema
(
schema
)
}
}
cmdNamespace
,
_
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
_
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/convert_test.go
View file @
c85e69ae
...
@@ -95,7 +95,7 @@ func TestConvertObject(t *testing.T) {
...
@@ -95,7 +95,7 @@ func TestConvertObject(t *testing.T) {
for
_
,
tc
:=
range
testcases
{
for
_
,
tc
:=
range
testcases
{
for
_
,
field
:=
range
tc
.
fields
{
for
_
,
field
:=
range
tc
.
fields
{
t
.
Run
(
fmt
.
Sprintf
(
"%s %s"
,
tc
.
name
,
field
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"%s %s"
,
tc
.
name
,
field
),
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -104,7 +104,6 @@ func TestConvertObject(t *testing.T) {
...
@@ -104,7 +104,6 @@ func TestConvertObject(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
NewCmdConvert
(
tf
,
genericclioptions
.
IOStreams
{
Out
:
buf
,
ErrOut
:
buf
})
cmd
:=
NewCmdConvert
(
tf
,
genericclioptions
.
IOStreams
{
Out
:
buf
,
ErrOut
:
buf
})
...
...
pkg/kubectl/cmd/cp.go
View file @
c85e69ae
...
@@ -144,7 +144,7 @@ func extractFileSpec(arg string) (fileSpec, error) {
...
@@ -144,7 +144,7 @@ func extractFileSpec(arg string) (fileSpec, error) {
func
(
o
*
CopyOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
func
(
o
*
CopyOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
var
err
error
var
err
error
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/cp_test.go
View file @
c85e69ae
...
@@ -514,8 +514,7 @@ func TestClean(t *testing.T) {
...
@@ -514,8 +514,7 @@ func TestClean(t *testing.T) {
}
}
func
TestCopyToPod
(
t
*
testing
.
T
)
{
func
TestCopyToPod
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
tf
.
Namespace
=
"test"
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
...
pkg/kubectl/cmd/create/create.go
View file @
c85e69ae
...
@@ -216,7 +216,7 @@ func (o *CreateOptions) RunCreate(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -216,7 +216,7 @@ func (o *CreateOptions) RunCreate(f cmdutil.Factory, cmd *cobra.Command) error {
return
err
return
err
}
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -386,7 +386,7 @@ func (o *CreateSubcommandOptions) Complete(f cmdutil.Factory, cmd *cobra.Command
...
@@ -386,7 +386,7 @@ func (o *CreateSubcommandOptions) Complete(f cmdutil.Factory, cmd *cobra.Command
return
printer
.
PrintObj
(
obj
,
out
)
return
printer
.
PrintObj
(
obj
,
out
)
}
}
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/create/create_clusterrole_test.go
View file @
c85e69ae
...
@@ -36,10 +36,9 @@ import (
...
@@ -36,10 +36,9 @@ import (
func
TestCreateClusterRole
(
t
*
testing
.
T
)
{
func
TestCreateClusterRole
(
t
*
testing
.
T
)
{
clusterRoleName
:=
"my-cluster-role"
clusterRoleName
:=
"my-cluster-role"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{}
tf
.
Client
=
&
fake
.
RESTClient
{}
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
...
@@ -178,11 +177,9 @@ func TestCreateClusterRole(t *testing.T) {
...
@@ -178,11 +177,9 @@ func TestCreateClusterRole(t *testing.T) {
}
}
func
TestClusterRoleValidate
(
t
*
testing
.
T
)
{
func
TestClusterRoleValidate
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tests
:=
map
[
string
]
struct
{
tests
:=
map
[
string
]
struct
{
clusterRoleOptions
*
CreateClusterRoleOptions
clusterRoleOptions
*
CreateClusterRoleOptions
expectErr
bool
expectErr
bool
...
...
pkg/kubectl/cmd/create/create_clusterrolebinding_test.go
View file @
c85e69ae
...
@@ -68,7 +68,7 @@ func TestCreateClusterRoleBinding(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestCreateClusterRoleBinding(t *testing.T) {
},
},
}
}
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -77,7 +77,6 @@ func TestCreateClusterRoleBinding(t *testing.T) {
...
@@ -77,7 +77,6 @@ func TestCreateClusterRoleBinding(t *testing.T) {
encoder
:=
ns
.
EncoderForVersion
(
info
.
Serializer
,
groupVersion
)
encoder
:=
ns
.
EncoderForVersion
(
info
.
Serializer
,
groupVersion
)
decoder
:=
ns
.
DecoderToVersion
(
info
.
Serializer
,
groupVersion
)
decoder
:=
ns
.
DecoderToVersion
(
info
.
Serializer
,
groupVersion
)
tf
.
Namespace
=
"test"
tf
.
Client
=
&
ClusterRoleBindingRESTClient
{
tf
.
Client
=
&
ClusterRoleBindingRESTClient
{
RESTClient
:
&
fake
.
RESTClient
{
RESTClient
:
&
fake
.
RESTClient
{
NegotiatedSerializer
:
ns
,
NegotiatedSerializer
:
ns
,
...
...
pkg/kubectl/cmd/create/create_configmap_test.go
View file @
c85e69ae
...
@@ -36,7 +36,7 @@ import (
...
@@ -36,7 +36,7 @@ import (
func
TestCreateConfigMap
(
t
*
testing
.
T
)
{
func
TestCreateConfigMap
(
t
*
testing
.
T
)
{
configMap
:=
&
v1
.
ConfigMap
{}
configMap
:=
&
v1
.
ConfigMap
{}
configMap
.
Name
=
"my-configmap"
configMap
.
Name
=
"my-configmap"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -55,7 +55,6 @@ func TestCreateConfigMap(t *testing.T) {
...
@@ -55,7 +55,6 @@ func TestCreateConfigMap(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateConfigMap
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateConfigMap
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
...
...
pkg/kubectl/cmd/create/create_deployment_test.go
View file @
c85e69ae
...
@@ -89,7 +89,7 @@ func Test_generatorFromName(t *testing.T) {
...
@@ -89,7 +89,7 @@ func Test_generatorFromName(t *testing.T) {
func
TestCreateDeployment
(
t
*
testing
.
T
)
{
func
TestCreateDeployment
(
t
*
testing
.
T
)
{
depName
:=
"jonny-dep"
depName
:=
"jonny-dep"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -104,7 +104,6 @@ func TestCreateDeployment(t *testing.T) {
...
@@ -104,7 +104,6 @@ func TestCreateDeployment(t *testing.T) {
}),
}),
}
}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateDeployment
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateDeployment
(
tf
,
ioStreams
)
...
@@ -120,7 +119,7 @@ func TestCreateDeployment(t *testing.T) {
...
@@ -120,7 +119,7 @@ func TestCreateDeployment(t *testing.T) {
func
TestCreateDeploymentNoImage
(
t
*
testing
.
T
)
{
func
TestCreateDeploymentNoImage
(
t
*
testing
.
T
)
{
depName
:=
"jonny-dep"
depName
:=
"jonny-dep"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -135,7 +134,6 @@ func TestCreateDeploymentNoImage(t *testing.T) {
...
@@ -135,7 +134,6 @@ func TestCreateDeploymentNoImage(t *testing.T) {
}),
}),
}
}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
Namespace
=
"test"
ioStreams
:=
genericclioptions
.
NewTestIOStreamsDiscard
()
ioStreams
:=
genericclioptions
.
NewTestIOStreamsDiscard
()
cmd
:=
NewCmdCreateDeployment
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateDeployment
(
tf
,
ioStreams
)
...
...
pkg/kubectl/cmd/create/create_job.go
View file @
c85e69ae
...
@@ -100,7 +100,7 @@ func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
...
@@ -100,7 +100,7 @@ func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
}
}
o
.
Name
=
args
[
0
]
o
.
Name
=
args
[
0
]
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/create/create_pdb_test.go
View file @
c85e69ae
...
@@ -32,7 +32,7 @@ import (
...
@@ -32,7 +32,7 @@ import (
func
TestCreatePdb
(
t
*
testing
.
T
)
{
func
TestCreatePdb
(
t
*
testing
.
T
)
{
pdbName
:=
"my-pdb"
pdbName
:=
"my-pdb"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -48,7 +48,6 @@ func TestCreatePdb(t *testing.T) {
...
@@ -48,7 +48,6 @@ func TestCreatePdb(t *testing.T) {
}),
}),
}
}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
Namespace
=
"test"
outputFormat
:=
"name"
outputFormat
:=
"name"
...
...
pkg/kubectl/cmd/create/create_quota_test.go
View file @
c85e69ae
...
@@ -51,11 +51,9 @@ func TestCreateQuota(t *testing.T) {
...
@@ -51,11 +51,9 @@ func TestCreateQuota(t *testing.T) {
}
}
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateQuota
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateQuota
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Parse
(
test
.
flags
)
cmd
.
Flags
()
.
Parse
(
test
.
flags
)
...
...
pkg/kubectl/cmd/create/create_role.go
View file @
c85e69ae
...
@@ -226,7 +226,7 @@ func (o *CreateRoleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
...
@@ -226,7 +226,7 @@ func (o *CreateRoleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
}
}
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/create/create_role_test.go
View file @
c85e69ae
...
@@ -34,10 +34,9 @@ import (
...
@@ -34,10 +34,9 @@ import (
func
TestCreateRole
(
t
*
testing
.
T
)
{
func
TestCreateRole
(
t
*
testing
.
T
)
{
roleName
:=
"my-role"
roleName
:=
"my-role"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{}
tf
.
Client
=
&
fake
.
RESTClient
{}
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
...
@@ -152,11 +151,9 @@ func TestCreateRole(t *testing.T) {
...
@@ -152,11 +151,9 @@ func TestCreateRole(t *testing.T) {
}
}
func
TestValidate
(
t
*
testing
.
T
)
{
func
TestValidate
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tests
:=
map
[
string
]
struct
{
tests
:=
map
[
string
]
struct
{
roleOptions
*
CreateRoleOptions
roleOptions
*
CreateRoleOptions
expectErr
bool
expectErr
bool
...
@@ -357,10 +354,9 @@ func TestValidate(t *testing.T) {
...
@@ -357,10 +354,9 @@ func TestValidate(t *testing.T) {
func
TestComplete
(
t
*
testing
.
T
)
{
func
TestComplete
(
t
*
testing
.
T
)
{
roleName
:=
"my-role"
roleName
:=
"my-role"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{}
tf
.
Client
=
&
fake
.
RESTClient
{}
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
...
...
pkg/kubectl/cmd/create/create_rolebinding_test.go
View file @
c85e69ae
...
@@ -70,7 +70,7 @@ func TestCreateRoleBinding(t *testing.T) {
...
@@ -70,7 +70,7 @@ func TestCreateRoleBinding(t *testing.T) {
},
},
}
}
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -79,7 +79,6 @@ func TestCreateRoleBinding(t *testing.T) {
...
@@ -79,7 +79,6 @@ func TestCreateRoleBinding(t *testing.T) {
encoder
:=
ns
.
EncoderForVersion
(
info
.
Serializer
,
groupVersion
)
encoder
:=
ns
.
EncoderForVersion
(
info
.
Serializer
,
groupVersion
)
decoder
:=
ns
.
DecoderToVersion
(
info
.
Serializer
,
groupVersion
)
decoder
:=
ns
.
DecoderToVersion
(
info
.
Serializer
,
groupVersion
)
tf
.
Namespace
=
"test"
tf
.
Client
=
&
RoleBindingRESTClient
{
tf
.
Client
=
&
RoleBindingRESTClient
{
RESTClient
:
&
fake
.
RESTClient
{
RESTClient
:
&
fake
.
RESTClient
{
NegotiatedSerializer
:
ns
,
NegotiatedSerializer
:
ns
,
...
...
pkg/kubectl/cmd/create/create_secret_test.go
View file @
c85e69ae
...
@@ -37,7 +37,7 @@ func TestCreateSecretGeneric(t *testing.T) {
...
@@ -37,7 +37,7 @@ func TestCreateSecretGeneric(t *testing.T) {
},
},
}
}
secretObject
.
Name
=
"my-secret"
secretObject
.
Name
=
"my-secret"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -56,7 +56,6 @@ func TestCreateSecretGeneric(t *testing.T) {
...
@@ -56,7 +56,6 @@ func TestCreateSecretGeneric(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateSecretGeneric
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateSecretGeneric
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
...
@@ -72,7 +71,7 @@ func TestCreateSecretGeneric(t *testing.T) {
...
@@ -72,7 +71,7 @@ func TestCreateSecretGeneric(t *testing.T) {
func
TestCreateSecretDockerRegistry
(
t
*
testing
.
T
)
{
func
TestCreateSecretDockerRegistry
(
t
*
testing
.
T
)
{
secretObject
:=
&
v1
.
Secret
{}
secretObject
:=
&
v1
.
Secret
{}
secretObject
.
Name
=
"my-secret"
secretObject
.
Name
=
"my-secret"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -89,7 +88,6 @@ func TestCreateSecretDockerRegistry(t *testing.T) {
...
@@ -89,7 +88,6 @@ func TestCreateSecretDockerRegistry(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateSecretDockerRegistry
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateSecretDockerRegistry
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"docker-username"
,
"test-user"
)
cmd
.
Flags
()
.
Set
(
"docker-username"
,
"test-user"
)
...
...
pkg/kubectl/cmd/create/create_service_test.go
View file @
c85e69ae
...
@@ -32,7 +32,7 @@ import (
...
@@ -32,7 +32,7 @@ import (
func
TestCreateService
(
t
*
testing
.
T
)
{
func
TestCreateService
(
t
*
testing
.
T
)
{
service
:=
&
v1
.
Service
{}
service
:=
&
v1
.
Service
{}
service
.
Name
=
"my-service"
service
.
Name
=
"my-service"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -51,7 +51,6 @@ func TestCreateService(t *testing.T) {
...
@@ -51,7 +51,6 @@ func TestCreateService(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateServiceClusterIP
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateServiceClusterIP
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
...
@@ -66,7 +65,7 @@ func TestCreateService(t *testing.T) {
...
@@ -66,7 +65,7 @@ func TestCreateService(t *testing.T) {
func
TestCreateServiceNodePort
(
t
*
testing
.
T
)
{
func
TestCreateServiceNodePort
(
t
*
testing
.
T
)
{
service
:=
&
v1
.
Service
{}
service
:=
&
v1
.
Service
{}
service
.
Name
=
"my-node-port-service"
service
.
Name
=
"my-node-port-service"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -85,7 +84,6 @@ func TestCreateServiceNodePort(t *testing.T) {
...
@@ -85,7 +84,6 @@ func TestCreateServiceNodePort(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateServiceNodePort
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateServiceNodePort
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
...
@@ -100,7 +98,7 @@ func TestCreateServiceNodePort(t *testing.T) {
...
@@ -100,7 +98,7 @@ func TestCreateServiceNodePort(t *testing.T) {
func
TestCreateServiceExternalName
(
t
*
testing
.
T
)
{
func
TestCreateServiceExternalName
(
t
*
testing
.
T
)
{
service
:=
&
v1
.
Service
{}
service
:=
&
v1
.
Service
{}
service
.
Name
=
"my-external-name-service"
service
.
Name
=
"my-external-name-service"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -119,7 +117,6 @@ func TestCreateServiceExternalName(t *testing.T) {
...
@@ -119,7 +117,6 @@ func TestCreateServiceExternalName(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateServiceExternalName
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateServiceExternalName
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
...
...
pkg/kubectl/cmd/create/create_serviceaccount_test.go
View file @
c85e69ae
...
@@ -32,7 +32,7 @@ import (
...
@@ -32,7 +32,7 @@ import (
func
TestCreateServiceAccount
(
t
*
testing
.
T
)
{
func
TestCreateServiceAccount
(
t
*
testing
.
T
)
{
serviceAccountObject
:=
&
v1
.
ServiceAccount
{}
serviceAccountObject
:=
&
v1
.
ServiceAccount
{}
serviceAccountObject
.
Name
=
"my-service-account"
serviceAccountObject
.
Name
=
"my-service-account"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -51,7 +51,6 @@ func TestCreateServiceAccount(t *testing.T) {
...
@@ -51,7 +51,6 @@ func TestCreateServiceAccount(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreateServiceAccount
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreateServiceAccount
(
tf
,
ioStreams
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
cmd
.
Flags
()
.
Set
(
"output"
,
"name"
)
...
...
pkg/kubectl/cmd/create/create_test.go
View file @
c85e69ae
...
@@ -51,7 +51,7 @@ func TestCreateObject(t *testing.T) {
...
@@ -51,7 +51,7 @@ func TestCreateObject(t *testing.T) {
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
rc
.
Items
[
0
]
.
Name
=
"redis-master-controller"
rc
.
Items
[
0
]
.
Name
=
"redis-master-controller"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -69,7 +69,6 @@ func TestCreateObject(t *testing.T) {
...
@@ -69,7 +69,6 @@ func TestCreateObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreate
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreate
(
tf
,
ioStreams
)
...
@@ -87,7 +86,7 @@ func TestCreateMultipleObject(t *testing.T) {
...
@@ -87,7 +86,7 @@ func TestCreateMultipleObject(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
svc
,
rc
:=
testData
()
_
,
svc
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -107,7 +106,6 @@ func TestCreateMultipleObject(t *testing.T) {
...
@@ -107,7 +106,6 @@ func TestCreateMultipleObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreate
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreate
(
tf
,
ioStreams
)
...
@@ -127,7 +125,7 @@ func TestCreateDirectory(t *testing.T) {
...
@@ -127,7 +125,7 @@ func TestCreateDirectory(t *testing.T) {
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
rc
.
Items
[
0
]
.
Name
=
"name"
rc
.
Items
[
0
]
.
Name
=
"name"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -145,7 +143,6 @@ func TestCreateDirectory(t *testing.T) {
...
@@ -145,7 +143,6 @@ func TestCreateDirectory(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdCreate
(
tf
,
ioStreams
)
cmd
:=
NewCmdCreate
(
tf
,
ioStreams
)
...
...
pkg/kubectl/cmd/delete.go
View file @
c85e69ae
...
@@ -146,7 +146,7 @@ func NewCmdDelete(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra
...
@@ -146,7 +146,7 @@ func NewCmdDelete(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra
}
}
func
(
o
*
DeleteOptions
)
Complete
(
f
cmdutil
.
Factory
,
args
[]
string
,
cmd
*
cobra
.
Command
)
error
{
func
(
o
*
DeleteOptions
)
Complete
(
f
cmdutil
.
Factory
,
args
[]
string
,
cmd
*
cobra
.
Command
)
error
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/delete_test.go
View file @
c85e69ae
...
@@ -52,7 +52,7 @@ func TestDeleteObjectByTuple(t *testing.T) {
...
@@ -52,7 +52,7 @@ func TestDeleteObjectByTuple(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -77,7 +77,6 @@ func TestDeleteObjectByTuple(t *testing.T) {
...
@@ -77,7 +77,6 @@ func TestDeleteObjectByTuple(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -118,7 +117,7 @@ func TestOrphanDependentsInDeleteObject(t *testing.T) {
...
@@ -118,7 +117,7 @@ func TestOrphanDependentsInDeleteObject(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -137,7 +136,6 @@ func TestOrphanDependentsInDeleteObject(t *testing.T) {
...
@@ -137,7 +136,6 @@ func TestOrphanDependentsInDeleteObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
// DeleteOptions.PropagationPolicy should be Foreground, when cascade is true (default).
// DeleteOptions.PropagationPolicy should be Foreground, when cascade is true (default).
foregroundPolicy
:=
metav1
.
DeletePropagationForeground
foregroundPolicy
:=
metav1
.
DeletePropagationForeground
...
@@ -170,7 +168,7 @@ func TestDeleteNamedObject(t *testing.T) {
...
@@ -170,7 +168,7 @@ func TestDeleteNamedObject(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -195,7 +193,6 @@ func TestDeleteNamedObject(t *testing.T) {
...
@@ -195,7 +193,6 @@ func TestDeleteNamedObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -223,7 +220,7 @@ func TestDeleteObject(t *testing.T) {
...
@@ -223,7 +220,7 @@ func TestDeleteObject(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -240,7 +237,6 @@ func TestDeleteObject(t *testing.T) {
...
@@ -240,7 +237,6 @@ func TestDeleteObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -260,7 +256,7 @@ func TestDeleteObjectGraceZero(t *testing.T) {
...
@@ -260,7 +256,7 @@ func TestDeleteObjectGraceZero(t *testing.T) {
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
count
:=
0
count
:=
0
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -288,7 +284,6 @@ func TestDeleteObjectGraceZero(t *testing.T) {
...
@@ -288,7 +284,6 @@ func TestDeleteObjectGraceZero(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -307,7 +302,7 @@ func TestDeleteObjectGraceZero(t *testing.T) {
...
@@ -307,7 +302,7 @@ func TestDeleteObjectGraceZero(t *testing.T) {
func
TestDeleteObjectNotFound
(
t
*
testing
.
T
)
{
func
TestDeleteObjectNotFound
(
t
*
testing
.
T
)
{
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -322,7 +317,6 @@ func TestDeleteObjectNotFound(t *testing.T) {
...
@@ -322,7 +317,6 @@ func TestDeleteObjectNotFound(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
options
:=
&
DeleteOptions
{
options
:=
&
DeleteOptions
{
FilenameOptions
:
resource
.
FilenameOptions
{
FilenameOptions
:
resource
.
FilenameOptions
{
...
@@ -345,7 +339,7 @@ func TestDeleteObjectNotFound(t *testing.T) {
...
@@ -345,7 +339,7 @@ func TestDeleteObjectNotFound(t *testing.T) {
func
TestDeleteObjectIgnoreNotFound
(
t
*
testing
.
T
)
{
func
TestDeleteObjectIgnoreNotFound
(
t
*
testing
.
T
)
{
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -360,7 +354,6 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
...
@@ -360,7 +354,6 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -382,7 +375,7 @@ func TestDeleteAllNotFound(t *testing.T) {
...
@@ -382,7 +375,7 @@ func TestDeleteAllNotFound(t *testing.T) {
svc
.
Items
=
append
(
svc
.
Items
,
api
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
}})
svc
.
Items
=
append
(
svc
.
Items
,
api
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
}})
notFoundError
:=
&
errors
.
NewNotFound
(
api
.
Resource
(
"services"
),
"foo"
)
.
ErrStatus
notFoundError
:=
&
errors
.
NewNotFound
(
api
.
Resource
(
"services"
),
"foo"
)
.
ErrStatus
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -403,7 +396,6 @@ func TestDeleteAllNotFound(t *testing.T) {
...
@@ -403,7 +396,6 @@ func TestDeleteAllNotFound(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
// Make sure we can explicitly choose to fail on NotFound errors, even with --all
// Make sure we can explicitly choose to fail on NotFound errors, even with --all
options
:=
&
DeleteOptions
{
options
:=
&
DeleteOptions
{
...
@@ -429,7 +421,7 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
...
@@ -429,7 +421,7 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
svc
,
_
:=
testData
()
_
,
svc
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -454,7 +446,6 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
...
@@ -454,7 +446,6 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -472,7 +463,7 @@ func TestDeleteMultipleObject(t *testing.T) {
...
@@ -472,7 +463,7 @@ func TestDeleteMultipleObject(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
svc
,
rc
:=
testData
()
_
,
svc
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -491,7 +482,6 @@ func TestDeleteMultipleObject(t *testing.T) {
...
@@ -491,7 +482,6 @@ func TestDeleteMultipleObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -510,7 +500,7 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
...
@@ -510,7 +500,7 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
svc
,
_
:=
testData
()
_
,
svc
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -529,7 +519,6 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
...
@@ -529,7 +519,6 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
options
:=
&
DeleteOptions
{
options
:=
&
DeleteOptions
{
...
@@ -558,7 +547,7 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
...
@@ -558,7 +547,7 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
func
TestDeleteMultipleResourcesWithTheSameName
(
t
*
testing
.
T
)
{
func
TestDeleteMultipleResourcesWithTheSameName
(
t
*
testing
.
T
)
{
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
svc
,
rc
:=
testData
()
_
,
svc
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -582,7 +571,6 @@ func TestDeleteMultipleResourcesWithTheSameName(t *testing.T) {
...
@@ -582,7 +571,6 @@ func TestDeleteMultipleResourcesWithTheSameName(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -599,7 +587,7 @@ func TestDeleteDirectory(t *testing.T) {
...
@@ -599,7 +587,7 @@ func TestDeleteDirectory(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -616,7 +604,6 @@ func TestDeleteDirectory(t *testing.T) {
...
@@ -616,7 +604,6 @@ func TestDeleteDirectory(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -634,7 +621,7 @@ func TestDeleteMultipleSelector(t *testing.T) {
...
@@ -634,7 +621,7 @@ func TestDeleteMultipleSelector(t *testing.T) {
initTestErrorHandler
(
t
)
initTestErrorHandler
(
t
)
pods
,
svc
,
_
:=
testData
()
pods
,
svc
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -663,7 +650,6 @@ func TestDeleteMultipleSelector(t *testing.T) {
...
@@ -663,7 +650,6 @@ func TestDeleteMultipleSelector(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdDelete
(
tf
,
streams
)
cmd
:=
NewCmdDelete
(
tf
,
streams
)
...
@@ -703,10 +689,9 @@ func TestResourceErrors(t *testing.T) {
...
@@ -703,10 +689,9 @@ func TestResourceErrors(t *testing.T) {
for
k
,
testCase
:=
range
testCases
{
for
k
,
testCase
:=
range
testCases
{
t
.
Run
(
k
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
k
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/describe.go
View file @
c85e69ae
...
@@ -122,7 +122,7 @@ func NewCmdDescribe(parent string, f cmdutil.Factory, streams genericclioptions.
...
@@ -122,7 +122,7 @@ func NewCmdDescribe(parent string, f cmdutil.Factory, streams genericclioptions.
func
(
o
*
DescribeOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
DescribeOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
var
err
error
var
err
error
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/describe_test.go
View file @
c85e69ae
...
@@ -41,7 +41,7 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
...
@@ -41,7 +41,7 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
}()
}()
cmdutil
.
DescriberFn
=
d
.
describerFor
cmdutil
.
DescriberFn
=
d
.
describerFor
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"non-default"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
_
,
_
,
codec
:=
cmdtesting
.
NewExternalScheme
()
_
,
_
,
codec
:=
cmdtesting
.
NewExternalScheme
()
...
@@ -52,7 +52,6 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
...
@@ -52,7 +52,6 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
tf
.
Namespace
=
"non-default"
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
streams
)
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
streams
)
cmd
.
Run
(
cmd
,
[]
string
{
"type"
,
"foo"
})
cmd
.
Run
(
cmd
,
[]
string
{
"type"
,
"foo"
})
...
@@ -82,7 +81,7 @@ func TestDescribeUnknownNamespacedSchemaObject(t *testing.T) {
...
@@ -82,7 +81,7 @@ func TestDescribeUnknownNamespacedSchemaObject(t *testing.T) {
NegotiatedSerializer
:
unstructuredSerializer
,
NegotiatedSerializer
:
unstructuredSerializer
,
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
cmdtesting
.
NewInternalNamespacedType
(
""
,
""
,
"foo"
,
"non-default"
))},
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
cmdtesting
.
NewInternalNamespacedType
(
""
,
""
,
"foo"
,
"non-default"
))},
}
}
tf
.
Namespace
=
"non-default"
tf
.
WithNamespace
(
"non-default"
)
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -107,7 +106,7 @@ func TestDescribeObject(t *testing.T) {
...
@@ -107,7 +106,7 @@ func TestDescribeObject(t *testing.T) {
cmdutil
.
DescriberFn
=
d
.
describerFor
cmdutil
.
DescriberFn
=
d
.
describerFor
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -123,7 +122,6 @@ func TestDescribeObject(t *testing.T) {
...
@@ -123,7 +122,6 @@ func TestDescribeObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -149,7 +147,7 @@ func TestDescribeListObjects(t *testing.T) {
...
@@ -149,7 +147,7 @@ func TestDescribeListObjects(t *testing.T) {
cmdutil
.
DescriberFn
=
d
.
describerFor
cmdutil
.
DescriberFn
=
d
.
describerFor
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -160,7 +158,6 @@ func TestDescribeListObjects(t *testing.T) {
...
@@ -160,7 +158,6 @@ func TestDescribeListObjects(t *testing.T) {
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
tf
.
Namespace
=
"test"
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
streams
)
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
streams
)
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
if
buf
.
String
()
!=
fmt
.
Sprintf
(
"%s
\n\n
%s"
,
d
.
Output
,
d
.
Output
)
{
if
buf
.
String
()
!=
fmt
.
Sprintf
(
"%s
\n\n
%s"
,
d
.
Output
,
d
.
Output
)
{
...
@@ -177,7 +174,7 @@ func TestDescribeObjectShowEvents(t *testing.T) {
...
@@ -177,7 +174,7 @@ func TestDescribeObjectShowEvents(t *testing.T) {
cmdutil
.
DescriberFn
=
d
.
describerFor
cmdutil
.
DescriberFn
=
d
.
describerFor
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -186,7 +183,6 @@ func TestDescribeObjectShowEvents(t *testing.T) {
...
@@ -186,7 +183,6 @@ func TestDescribeObjectShowEvents(t *testing.T) {
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
pods
)},
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
pods
)},
}
}
tf
.
Namespace
=
"test"
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
genericclioptions
.
NewTestIOStreamsDiscard
())
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
genericclioptions
.
NewTestIOStreamsDiscard
())
cmd
.
Flags
()
.
Set
(
"show-events"
,
"true"
)
cmd
.
Flags
()
.
Set
(
"show-events"
,
"true"
)
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
...
@@ -204,7 +200,7 @@ func TestDescribeObjectSkipEvents(t *testing.T) {
...
@@ -204,7 +200,7 @@ func TestDescribeObjectSkipEvents(t *testing.T) {
cmdutil
.
DescriberFn
=
d
.
describerFor
cmdutil
.
DescriberFn
=
d
.
describerFor
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -213,7 +209,6 @@ func TestDescribeObjectSkipEvents(t *testing.T) {
...
@@ -213,7 +209,6 @@ func TestDescribeObjectSkipEvents(t *testing.T) {
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
pods
)},
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
pods
)},
}
}
tf
.
Namespace
=
"test"
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
genericclioptions
.
NewTestIOStreamsDiscard
())
cmd
:=
NewCmdDescribe
(
"kubectl"
,
tf
,
genericclioptions
.
NewTestIOStreamsDiscard
())
cmd
.
Flags
()
.
Set
(
"show-events"
,
"false"
)
cmd
.
Flags
()
.
Set
(
"show-events"
,
"false"
)
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
...
...
pkg/kubectl/cmd/diff.go
View file @
c85e69ae
...
@@ -407,7 +407,7 @@ func NewDownloader(f cmdutil.Factory) (*Downloader, error) {
...
@@ -407,7 +407,7 @@ func NewDownloader(f cmdutil.Factory) (*Downloader, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
d
.
ns
,
_
,
_
=
f
.
Default
Namespace
()
d
.
ns
,
_
,
_
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
return
&
d
,
nil
return
&
d
,
nil
}
}
...
@@ -451,7 +451,7 @@ func RunDiff(f cmdutil.Factory, diff *DiffProgram, options *DiffOptions, from, t
...
@@ -451,7 +451,7 @@ func RunDiff(f cmdutil.Factory, diff *DiffProgram, options *DiffOptions, from, t
printer
:=
Printer
{}
printer
:=
Printer
{}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/drain.go
View file @
c85e69ae
...
@@ -263,7 +263,7 @@ func (o *DrainOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
...
@@ -263,7 +263,7 @@ func (o *DrainOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
o
.
nodeInfos
=
[]
*
resource
.
Info
{}
o
.
nodeInfos
=
[]
*
resource
.
Info
{}
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/edit_test.go
View file @
c85e69ae
...
@@ -224,12 +224,8 @@ func TestEdit(t *testing.T) {
...
@@ -224,12 +224,8 @@ func TestEdit(t *testing.T) {
Client
:
fake
.
CreateHTTPClient
(
reqResp
),
Client
:
fake
.
CreateHTTPClient
(
reqResp
),
},
nil
},
nil
}
}
tf
.
WithNamespace
(
testcase
.
Namespace
)
if
len
(
testcase
.
Namespace
)
>
0
{
tf
.
Namespace
=
testcase
.
Namespace
}
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
CommandVal
=
"edit test cmd invocation"
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
errBuf
:=
genericclioptions
.
NewTestIOStreams
()
var
cmd
*
cobra
.
Command
var
cmd
*
cobra
.
Command
...
...
pkg/kubectl/cmd/exec.go
View file @
c85e69ae
...
@@ -166,7 +166,7 @@ func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []s
...
@@ -166,7 +166,7 @@ func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []s
}
}
}
}
namespace
,
_
,
err
:=
f
.
Default
Namespace
()
namespace
,
_
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/exec_test.go
View file @
c85e69ae
...
@@ -132,7 +132,7 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -132,7 +132,7 @@ func TestPodAndContainer(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -141,7 +141,6 @@ func TestPodAndContainer(t *testing.T) {
...
@@ -141,7 +141,6 @@ func TestPodAndContainer(t *testing.T) {
NegotiatedSerializer
:
ns
,
NegotiatedSerializer
:
ns
,
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
cmd
:=
&
cobra
.
Command
{}
cmd
:=
&
cobra
.
Command
{}
...
@@ -193,7 +192,7 @@ func TestExec(t *testing.T) {
...
@@ -193,7 +192,7 @@ func TestExec(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -212,7 +211,6 @@ func TestExec(t *testing.T) {
...
@@ -212,7 +211,6 @@ func TestExec(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ex
:=
&
fakeRemoteExecutor
{}
ex
:=
&
fakeRemoteExecutor
{}
if
test
.
execErr
{
if
test
.
execErr
{
...
...
pkg/kubectl/cmd/expose.go
View file @
c85e69ae
...
@@ -201,7 +201,7 @@ func (o *ExposeServiceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) e
...
@@ -201,7 +201,7 @@ func (o *ExposeServiceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) e
return
err
return
err
}
}
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/expose_test.go
View file @
c85e69ae
...
@@ -467,7 +467,7 @@ func TestRunExposeService(t *testing.T) {
...
@@ -467,7 +467,7 @@ func TestRunExposeService(t *testing.T) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
test
.
ns
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -486,7 +486,6 @@ func TestRunExposeService(t *testing.T) {
...
@@ -486,7 +486,6 @@ func TestRunExposeService(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
test
.
ns
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdExposeService
(
tf
,
ioStreams
)
cmd
:=
NewCmdExposeService
(
tf
,
ioStreams
)
...
...
pkg/kubectl/cmd/get/get.go
View file @
c85e69ae
...
@@ -189,7 +189,7 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
...
@@ -189,7 +189,7 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
}
}
var
err
error
var
err
error
o
.
Namespace
,
o
.
ExplicitNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
ExplicitNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/get/get_test.go
View file @
c85e69ae
This diff is collapsed.
Click to expand it.
pkg/kubectl/cmd/label.go
View file @
c85e69ae
...
@@ -188,7 +188,7 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
...
@@ -188,7 +188,7 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
return
fmt
.
Errorf
(
"--list and --output may not be specified together"
)
return
fmt
.
Errorf
(
"--list and --output may not be specified together"
)
}
}
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/label_test.go
View file @
c85e69ae
...
@@ -322,10 +322,9 @@ func TestLabelErrors(t *testing.T) {
...
@@ -322,10 +322,9 @@ func TestLabelErrors(t *testing.T) {
for
k
,
testCase
:=
range
testCases
{
for
k
,
testCase
:=
range
testCases
{
t
.
Run
(
k
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
k
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
_
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
_
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -357,7 +356,7 @@ func TestLabelErrors(t *testing.T) {
...
@@ -357,7 +356,7 @@ func TestLabelErrors(t *testing.T) {
func
TestLabelForResourceFromFile
(
t
*
testing
.
T
)
{
func
TestLabelForResourceFromFile
(
t
*
testing
.
T
)
{
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -388,7 +387,6 @@ func TestLabelForResourceFromFile(t *testing.T) {
...
@@ -388,7 +387,6 @@ func TestLabelForResourceFromFile(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -411,7 +409,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
...
@@ -411,7 +409,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
}
}
func
TestLabelLocal
(
t
*
testing
.
T
)
{
func
TestLabelLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
tf
.
UnstructuredClient
=
&
fake
.
RESTClient
{
...
@@ -421,7 +419,6 @@ func TestLabelLocal(t *testing.T) {
...
@@ -421,7 +419,6 @@ func TestLabelLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -446,7 +443,7 @@ func TestLabelLocal(t *testing.T) {
...
@@ -446,7 +443,7 @@ func TestLabelLocal(t *testing.T) {
func
TestLabelMultipleObjects
(
t
*
testing
.
T
)
{
func
TestLabelMultipleObjects
(
t
*
testing
.
T
)
{
pods
,
_
,
_
:=
testData
()
pods
,
_
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -479,7 +476,6 @@ func TestLabelMultipleObjects(t *testing.T) {
...
@@ -479,7 +476,6 @@ func TestLabelMultipleObjects(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
ioStreams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/logs.go
View file @
c85e69ae
...
@@ -156,7 +156,7 @@ func (o *LogsOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
...
@@ -156,7 +156,7 @@ func (o *LogsOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s"
,
logsUsageStr
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s"
,
logsUsageStr
)
}
}
var
err
error
var
err
error
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/logs_test.go
View file @
c85e69ae
...
@@ -58,7 +58,7 @@ func TestLog(t *testing.T) {
...
@@ -58,7 +58,7 @@ func TestLog(t *testing.T) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
logContent
:=
"test log content"
logContent
:=
"test log content"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -80,7 +80,6 @@ func TestLog(t *testing.T) {
...
@@ -80,7 +80,6 @@ func TestLog(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
oldLogFn
:=
polymorphichelpers
.
LogsForObjectFn
oldLogFn
:=
polymorphichelpers
.
LogsForObjectFn
defer
func
()
{
defer
func
()
{
...
@@ -123,6 +122,7 @@ func testPod() *api.Pod {
...
@@ -123,6 +122,7 @@ func testPod() *api.Pod {
func
TestValidateLogFlags
(
t
*
testing
.
T
)
{
func
TestValidateLogFlags
(
t
*
testing
.
T
)
{
f
:=
cmdtesting
.
NewTestFactory
()
f
:=
cmdtesting
.
NewTestFactory
()
defer
f
.
Cleanup
()
defer
f
.
Cleanup
()
f
.
WithNamespace
(
""
)
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
...
...
pkg/kubectl/cmd/patch.go
View file @
c85e69ae
...
@@ -152,7 +152,7 @@ func (o *PatchOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
...
@@ -152,7 +152,7 @@ func (o *PatchOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
return
o
.
PrintFlags
.
ToPrinter
()
return
o
.
PrintFlags
.
ToPrinter
()
}
}
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/patch_test.go
View file @
c85e69ae
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
func
TestPatchObject
(
t
*
testing
.
T
)
{
func
TestPatchObject
(
t
*
testing
.
T
)
{
_
,
svc
,
_
:=
testData
()
_
,
svc
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -55,7 +55,6 @@ func TestPatchObject(t *testing.T) {
...
@@ -55,7 +55,6 @@ func TestPatchObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
stream
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
stream
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdPatch
(
tf
,
stream
)
cmd
:=
NewCmdPatch
(
tf
,
stream
)
...
@@ -73,7 +72,7 @@ func TestPatchObject(t *testing.T) {
...
@@ -73,7 +72,7 @@ func TestPatchObject(t *testing.T) {
func
TestPatchObjectFromFile
(
t
*
testing
.
T
)
{
func
TestPatchObjectFromFile
(
t
*
testing
.
T
)
{
_
,
svc
,
_
:=
testData
()
_
,
svc
,
_
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -90,7 +89,6 @@ func TestPatchObjectFromFile(t *testing.T) {
...
@@ -90,7 +89,6 @@ func TestPatchObjectFromFile(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
stream
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
stream
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdPatch
(
tf
,
stream
)
cmd
:=
NewCmdPatch
(
tf
,
stream
)
...
@@ -111,7 +109,7 @@ func TestPatchNoop(t *testing.T) {
...
@@ -111,7 +109,7 @@ func TestPatchNoop(t *testing.T) {
getObject
:=
&
svc
.
Items
[
0
]
getObject
:=
&
svc
.
Items
[
0
]
patchObject
:=
&
svc
.
Items
[
0
]
patchObject
:=
&
svc
.
Items
[
0
]
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -130,7 +128,6 @@ func TestPatchNoop(t *testing.T) {
...
@@ -130,7 +128,6 @@ func TestPatchNoop(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
// Patched
// Patched
{
{
...
@@ -159,7 +156,7 @@ func TestPatchObjectFromFileOutput(t *testing.T) {
...
@@ -159,7 +156,7 @@ func TestPatchObjectFromFileOutput(t *testing.T) {
}
}
svcCopy
.
Labels
[
"post-patch"
]
=
"post-patch-value"
svcCopy
.
Labels
[
"post-patch"
]
=
"post-patch-value"
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -178,7 +175,6 @@ func TestPatchObjectFromFileOutput(t *testing.T) {
...
@@ -178,7 +175,6 @@ func TestPatchObjectFromFileOutput(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
stream
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
stream
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdPatch
(
tf
,
stream
)
cmd
:=
NewCmdPatch
(
tf
,
stream
)
...
...
pkg/kubectl/cmd/plugin.go
View file @
c85e69ae
...
@@ -158,7 +158,7 @@ type factoryAttrsPluginEnvProvider struct {
...
@@ -158,7 +158,7 @@ type factoryAttrsPluginEnvProvider struct {
}
}
func
(
p
*
factoryAttrsPluginEnvProvider
)
Env
()
(
plugins
.
EnvList
,
error
)
{
func
(
p
*
factoryAttrsPluginEnvProvider
)
Env
()
(
plugins
.
EnvList
,
error
)
{
cmdNamespace
,
_
,
err
:=
p
.
factory
.
Default
Namespace
()
cmdNamespace
,
_
,
err
:=
p
.
factory
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
plugins
.
EnvList
{},
err
return
plugins
.
EnvList
{},
err
}
}
...
...
pkg/kubectl/cmd/portforward.go
View file @
c85e69ae
...
@@ -174,7 +174,7 @@ func (o *PortForwardOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
...
@@ -174,7 +174,7 @@ func (o *PortForwardOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
return
cmdutil
.
UsageErrorf
(
cmd
,
"TYPE/NAME and list of ports are required for port-forward"
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"TYPE/NAME and list of ports are required for port-forward"
)
}
}
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/portforward_test.go
View file @
c85e69ae
...
@@ -73,7 +73,7 @@ func testPortForward(t *testing.T, flags map[string]string, args []string) {
...
@@ -73,7 +73,7 @@ func testPortForward(t *testing.T, flags map[string]string, args []string) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
var
err
error
var
err
error
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -94,7 +94,6 @@ func testPortForward(t *testing.T, flags map[string]string, args []string) {
...
@@ -94,7 +94,6 @@ func testPortForward(t *testing.T, flags map[string]string, args []string) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
ff
:=
&
fakePortForwarder
{}
ff
:=
&
fakePortForwarder
{}
if
test
.
pfErr
{
if
test
.
pfErr
{
...
...
pkg/kubectl/cmd/replace.go
View file @
c85e69ae
...
@@ -179,7 +179,7 @@ func (o *ReplaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
...
@@ -179,7 +179,7 @@ func (o *ReplaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
o
.
Builder
=
f
.
NewBuilder
o
.
Builder
=
f
.
NewBuilder
o
.
BuilderArgs
=
args
o
.
BuilderArgs
=
args
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/replace_test.go
View file @
c85e69ae
...
@@ -32,7 +32,7 @@ import (
...
@@ -32,7 +32,7 @@ import (
func
TestReplaceObject
(
t
*
testing
.
T
)
{
func
TestReplaceObject
(
t
*
testing
.
T
)
{
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -62,7 +62,6 @@ func TestReplaceObject(t *testing.T) {
...
@@ -62,7 +62,6 @@ func TestReplaceObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdReplace
(
tf
,
streams
)
cmd
:=
NewCmdReplace
(
tf
,
streams
)
...
@@ -89,7 +88,7 @@ func TestReplaceObject(t *testing.T) {
...
@@ -89,7 +88,7 @@ func TestReplaceObject(t *testing.T) {
func
TestReplaceMultipleObject
(
t
*
testing
.
T
)
{
func
TestReplaceMultipleObject
(
t
*
testing
.
T
)
{
_
,
svc
,
rc
:=
testData
()
_
,
svc
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -133,7 +132,6 @@ func TestReplaceMultipleObject(t *testing.T) {
...
@@ -133,7 +132,6 @@ func TestReplaceMultipleObject(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdReplace
(
tf
,
streams
)
cmd
:=
NewCmdReplace
(
tf
,
streams
)
...
@@ -160,7 +158,7 @@ func TestReplaceMultipleObject(t *testing.T) {
...
@@ -160,7 +158,7 @@ func TestReplaceMultipleObject(t *testing.T) {
func
TestReplaceDirectory
(
t
*
testing
.
T
)
{
func
TestReplaceDirectory
(
t
*
testing
.
T
)
{
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -191,7 +189,6 @@ func TestReplaceDirectory(t *testing.T) {
...
@@ -191,7 +189,6 @@ func TestReplaceDirectory(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdReplace
(
tf
,
streams
)
cmd
:=
NewCmdReplace
(
tf
,
streams
)
...
@@ -218,7 +215,7 @@ func TestReplaceDirectory(t *testing.T) {
...
@@ -218,7 +215,7 @@ func TestReplaceDirectory(t *testing.T) {
func
TestForceReplaceObjectNotFound
(
t
*
testing
.
T
)
{
func
TestForceReplaceObjectNotFound
(
t
*
testing
.
T
)
{
_
,
_
,
rc
:=
testData
()
_
,
_
,
rc
:=
testData
()
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -238,7 +235,6 @@ func TestForceReplaceObjectNotFound(t *testing.T) {
...
@@ -238,7 +235,6 @@ func TestForceReplaceObjectNotFound(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdReplace
(
tf
,
streams
)
cmd
:=
NewCmdReplace
(
tf
,
streams
)
...
...
pkg/kubectl/cmd/rollingupdate.go
View file @
c85e69ae
...
@@ -209,7 +209,7 @@ func (o *RollingUpdateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a
...
@@ -209,7 +209,7 @@ func (o *RollingUpdateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a
}
}
var
err
error
var
err
error
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_history.go
View file @
c85e69ae
...
@@ -74,7 +74,7 @@ func RunHistory(f cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []str
...
@@ -74,7 +74,7 @@ func RunHistory(f cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []str
return
fmt
.
Errorf
(
"revision must be a positive integer: %v"
,
revision
)
return
fmt
.
Errorf
(
"revision must be a positive integer: %v"
,
revision
)
}
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_pause.go
View file @
c85e69ae
...
@@ -104,7 +104,7 @@ func (o *PauseConfig) CompletePause(f cmdutil.Factory, cmd *cobra.Command, args
...
@@ -104,7 +104,7 @@ func (o *PauseConfig) CompletePause(f cmdutil.Factory, cmd *cobra.Command, args
o
.
Pauser
=
polymorphichelpers
.
ObjectPauserFn
o
.
Pauser
=
polymorphichelpers
.
ObjectPauserFn
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_pause_test.go
View file @
c85e69ae
...
@@ -40,7 +40,7 @@ var rolloutPauseGroupVersionDecoder = schema.GroupVersion{Group: "extensions", V
...
@@ -40,7 +40,7 @@ var rolloutPauseGroupVersionDecoder = schema.GroupVersion{Group: "extensions", V
func
TestRolloutPause
(
t
*
testing
.
T
)
{
func
TestRolloutPause
(
t
*
testing
.
T
)
{
deploymentName
:=
"deployment/nginx-deployment"
deploymentName
:=
"deployment/nginx-deployment"
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
ns
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
ns
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
encoder
:=
ns
.
EncoderForVersion
(
info
.
Serializer
,
rolloutPauseGroupVersionEncoder
)
encoder
:=
ns
.
EncoderForVersion
(
info
.
Serializer
,
rolloutPauseGroupVersionEncoder
)
...
@@ -62,7 +62,6 @@ func TestRolloutPause(t *testing.T) {
...
@@ -62,7 +62,6 @@ func TestRolloutPause(t *testing.T) {
},
},
}
}
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdRolloutPause
(
tf
,
streams
)
cmd
:=
NewCmdRolloutPause
(
tf
,
streams
)
...
...
pkg/kubectl/cmd/rollout/rollout_resume.go
View file @
c85e69ae
...
@@ -102,7 +102,7 @@ func (o *ResumeConfig) CompleteResume(f cmdutil.Factory, cmd *cobra.Command, arg
...
@@ -102,7 +102,7 @@ func (o *ResumeConfig) CompleteResume(f cmdutil.Factory, cmd *cobra.Command, arg
o
.
Resumer
=
polymorphichelpers
.
ObjectResumerFn
o
.
Resumer
=
polymorphichelpers
.
ObjectResumerFn
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_status.go
View file @
c85e69ae
...
@@ -104,7 +104,7 @@ func (o *RolloutStatusOptions) Complete(f cmdutil.Factory, args []string) error
...
@@ -104,7 +104,7 @@ func (o *RolloutStatusOptions) Complete(f cmdutil.Factory, args []string) error
o
.
Builder
=
f
.
NewBuilder
()
o
.
Builder
=
f
.
NewBuilder
()
var
err
error
var
err
error
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/rollout/rollout_undo.go
View file @
c85e69ae
...
@@ -109,7 +109,7 @@ func (o *UndoOptions) CompleteUndo(f cmdutil.Factory, cmd *cobra.Command, out io
...
@@ -109,7 +109,7 @@ func (o *UndoOptions) CompleteUndo(f cmdutil.Factory, cmd *cobra.Command, out io
o
.
Out
=
out
o
.
Out
=
out
o
.
DryRun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
o
.
DryRun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/run.go
View file @
c85e69ae
...
@@ -265,7 +265,7 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
...
@@ -265,7 +265,7 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
return
cmdutil
.
UsageErrorf
(
cmd
,
"--port must be set when exposing a service"
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"--port must be set when exposing a service"
)
}
}
namespace
,
_
,
err
:=
f
.
Default
Namespace
()
namespace
,
_
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/run_test.go
View file @
c85e69ae
...
@@ -170,7 +170,7 @@ func TestRunArgsFollowDashRules(t *testing.T) {
...
@@ -170,7 +170,7 @@ func TestRunArgsFollowDashRules(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -190,7 +190,6 @@ func TestRunArgsFollowDashRules(t *testing.T) {
...
@@ -190,7 +190,6 @@ func TestRunArgsFollowDashRules(t *testing.T) {
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{}
cmd
:=
NewCmdRun
(
tf
,
genericclioptions
.
NewTestIOStreamsDiscard
())
cmd
:=
NewCmdRun
(
tf
,
genericclioptions
.
NewTestIOStreamsDiscard
())
...
@@ -505,7 +504,7 @@ func TestRunValidations(t *testing.T) {
...
@@ -505,7 +504,7 @@ func TestRunValidations(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
_
,
_
,
codec
:=
cmdtesting
.
NewExternalScheme
()
_
,
_
,
codec
:=
cmdtesting
.
NewExternalScheme
()
...
@@ -513,7 +512,6 @@ func TestRunValidations(t *testing.T) {
...
@@ -513,7 +512,6 @@ func TestRunValidations(t *testing.T) {
NegotiatedSerializer
:
scheme
.
Codecs
,
NegotiatedSerializer
:
scheme
.
Codecs
,
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
cmdtesting
.
NewInternalType
(
""
,
""
,
""
))},
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
cmdtesting
.
NewInternalType
(
""
,
""
,
""
))},
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
_
,
bufErr
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
_
,
bufErr
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/scale.go
View file @
c85e69ae
...
@@ -156,7 +156,7 @@ func (o *ScaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
...
@@ -156,7 +156,7 @@ func (o *ScaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
}
}
o
.
PrintObj
=
printer
.
PrintObj
o
.
PrintObj
=
printer
.
PrintObj
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_env.go
View file @
c85e69ae
...
@@ -233,7 +233,7 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
...
@@ -233,7 +233,7 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
o
.
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_env_test.go
View file @
c85e69ae
...
@@ -45,7 +45,7 @@ import (
...
@@ -45,7 +45,7 @@ import (
)
)
func
TestSetEnvLocal
(
t
*
testing
.
T
)
{
func
TestSetEnvLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -56,7 +56,6 @@ func TestSetEnvLocal(t *testing.T) {
...
@@ -56,7 +56,6 @@ func TestSetEnvLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -83,7 +82,7 @@ func TestSetEnvLocal(t *testing.T) {
...
@@ -83,7 +82,7 @@ func TestSetEnvLocal(t *testing.T) {
}
}
func
TestSetMultiResourcesEnvLocal
(
t
*
testing
.
T
)
{
func
TestSetMultiResourcesEnvLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -94,7 +93,6 @@ func TestSetMultiResourcesEnvLocal(t *testing.T) {
...
@@ -94,7 +93,6 @@ func TestSetMultiResourcesEnvLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -447,16 +445,15 @@ func TestSetEnvRemote(t *testing.T) {
...
@@ -447,16 +445,15 @@ func TestSetEnvRemote(t *testing.T) {
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
GroupVersion
:
groupVersion
,
GroupVersion
:
groupVersion
,
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
tf
.
Namespace
,
input
.
args
[
1
])
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
"test"
,
input
.
args
[
1
])
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
...
@@ -585,10 +582,9 @@ func TestSetEnvFromResource(t *testing.T) {
...
@@ -585,10 +582,9 @@ func TestSetEnvFromResource(t *testing.T) {
},
},
}
}
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
GroupVersion
:
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
},
GroupVersion
:
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
},
...
...
pkg/kubectl/cmd/set/set_image.go
View file @
c85e69ae
...
@@ -150,7 +150,7 @@ func (o *SetImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
...
@@ -150,7 +150,7 @@ func (o *SetImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
o
.
PrintObj
=
printer
.
PrintObj
o
.
PrintObj
=
printer
.
PrintObj
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_image_test.go
View file @
c85e69ae
...
@@ -46,7 +46,7 @@ import (
...
@@ -46,7 +46,7 @@ import (
)
)
func
TestImageLocal
(
t
*
testing
.
T
)
{
func
TestImageLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -57,7 +57,6 @@ func TestImageLocal(t *testing.T) {
...
@@ -57,7 +57,6 @@ func TestImageLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -159,7 +158,7 @@ func TestSetImageValidation(t *testing.T) {
...
@@ -159,7 +158,7 @@ func TestSetImageValidation(t *testing.T) {
}
}
func
TestSetMultiResourcesImageLocal
(
t
*
testing
.
T
)
{
func
TestSetMultiResourcesImageLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -170,7 +169,6 @@ func TestSetMultiResourcesImageLocal(t *testing.T) {
...
@@ -170,7 +169,6 @@ func TestSetMultiResourcesImageLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -532,15 +530,14 @@ func TestSetImageRemote(t *testing.T) {
...
@@ -532,15 +530,14 @@ func TestSetImageRemote(t *testing.T) {
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
GroupVersion
:
groupVersion
,
GroupVersion
:
groupVersion
,
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
tf
.
Namespace
,
input
.
args
[
1
])
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
"test"
,
input
.
args
[
1
])
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
...
...
pkg/kubectl/cmd/set/set_resources.go
View file @
c85e69ae
...
@@ -160,7 +160,7 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
...
@@ -160,7 +160,7 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
}
}
o
.
PrintObj
=
printer
.
PrintObj
o
.
PrintObj
=
printer
.
PrintObj
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_resources_test.go
View file @
c85e69ae
...
@@ -45,7 +45,7 @@ import (
...
@@ -45,7 +45,7 @@ import (
)
)
func
TestResourcesLocal
(
t
*
testing
.
T
)
{
func
TestResourcesLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -56,7 +56,6 @@ func TestResourcesLocal(t *testing.T) {
...
@@ -56,7 +56,6 @@ func TestResourcesLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -94,7 +93,7 @@ func TestResourcesLocal(t *testing.T) {
...
@@ -94,7 +93,7 @@ func TestResourcesLocal(t *testing.T) {
}
}
func
TestSetMultiResourcesLimitsLocal
(
t
*
testing
.
T
)
{
func
TestSetMultiResourcesLimitsLocal
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -105,7 +104,6 @@ func TestSetMultiResourcesLimitsLocal(t *testing.T) {
...
@@ -105,7 +104,6 @@ func TestSetMultiResourcesLimitsLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -455,15 +453,14 @@ func TestSetResourcesRemote(t *testing.T) {
...
@@ -455,15 +453,14 @@ func TestSetResourcesRemote(t *testing.T) {
t
.
Run
(
fmt
.
Sprintf
(
"%d"
,
i
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"%d"
,
i
),
func
(
t
*
testing
.
T
)
{
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
GroupVersion
:
groupVersion
,
GroupVersion
:
groupVersion
,
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
tf
.
Namespace
,
input
.
args
[
1
])
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
"test"
,
input
.
args
[
1
])
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
...
...
pkg/kubectl/cmd/set/set_selector.go
View file @
c85e69ae
...
@@ -132,7 +132,7 @@ func (o *SetSelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
...
@@ -132,7 +132,7 @@ func (o *SetSelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
o
.
dryrun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
o
.
dryrun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
o
.
output
=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
o
.
output
=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_selector_test.go
View file @
c85e69ae
...
@@ -317,7 +317,7 @@ func TestGetResourcesAndSelector(t *testing.T) {
...
@@ -317,7 +317,7 @@ func TestGetResourcesAndSelector(t *testing.T) {
}
}
func
TestSelectorTest
(
t
*
testing
.
T
)
{
func
TestSelectorTest
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -328,7 +328,6 @@ func TestSelectorTest(t *testing.T) {
...
@@ -328,7 +328,6 @@ func TestSelectorTest(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/set/set_serviceaccount.go
View file @
c85e69ae
...
@@ -141,7 +141,7 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
...
@@ -141,7 +141,7 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
}
}
o
.
PrintObj
=
printer
.
PrintObj
o
.
PrintObj
=
printer
.
PrintObj
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_serviceaccount_test.go
View file @
c85e69ae
...
@@ -68,7 +68,7 @@ func TestSetServiceAccountLocal(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestSetServiceAccountLocal(t *testing.T) {
for
i
,
input
:=
range
inputs
{
for
i
,
input
:=
range
inputs
{
t
.
Run
(
fmt
.
Sprintf
(
"%d"
,
i
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"%d"
,
i
),
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -81,7 +81,6 @@ func TestSetServiceAccountLocal(t *testing.T) {
...
@@ -81,7 +81,6 @@ func TestSetServiceAccountLocal(t *testing.T) {
outputFormat
:=
"yaml"
outputFormat
:=
"yaml"
tf
.
Namespace
=
"test"
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
cmd
:=
NewCmdServiceAccount
(
tf
,
streams
)
cmd
:=
NewCmdServiceAccount
(
tf
,
streams
)
cmd
.
Flags
()
.
Set
(
"output"
,
outputFormat
)
cmd
.
Flags
()
.
Set
(
"output"
,
outputFormat
)
...
@@ -105,7 +104,7 @@ func TestSetServiceAccountLocal(t *testing.T) {
...
@@ -105,7 +104,7 @@ func TestSetServiceAccountLocal(t *testing.T) {
func
TestSetServiceAccountMultiLocal
(
t
*
testing
.
T
)
{
func
TestSetServiceAccountMultiLocal
(
t
*
testing
.
T
)
{
testapi
.
Default
=
testapi
.
Groups
[
""
]
testapi
.
Default
=
testapi
.
Groups
[
""
]
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -116,7 +115,6 @@ func TestSetServiceAccountMultiLocal(t *testing.T) {
...
@@ -116,7 +115,6 @@ func TestSetServiceAccountMultiLocal(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
tf
.
ClientConfigVal
=
&
restclient
.
Config
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
schema
.
GroupVersion
{
Version
:
""
}}}
outputFormat
:=
"name"
outputFormat
:=
"name"
...
@@ -326,15 +324,14 @@ func TestSetServiceAccountRemote(t *testing.T) {
...
@@ -326,15 +324,14 @@ func TestSetServiceAccountRemote(t *testing.T) {
t
.
Run
(
input
.
apiPrefix
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
input
.
apiPrefix
,
func
(
t
*
testing
.
T
)
{
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
groupVersion
:=
schema
.
GroupVersion
{
Group
:
input
.
apiGroup
,
Version
:
input
.
apiVersion
}
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
testapi
.
Default
=
testapi
.
Groups
[
input
.
testAPIGroup
]
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
GroupVersion
:
groupVersion
,
GroupVersion
:
groupVersion
,
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
NegotiatedSerializer
:
serializer
.
DirectCodecFactory
{
CodecFactory
:
scheme
.
Codecs
},
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
tf
.
Namespace
,
input
.
args
[
1
])
resourcePath
:=
testapi
.
Default
.
ResourcePath
(
input
.
args
[
0
]
+
"s"
,
"test"
,
input
.
args
[
1
])
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
case
p
==
resourcePath
&&
m
==
http
.
MethodGet
:
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Header
:
defaultHeader
(),
Body
:
objBody
(
input
.
object
)},
nil
...
@@ -387,7 +384,7 @@ func TestServiceAccountValidation(t *testing.T) {
...
@@ -387,7 +384,7 @@ func TestServiceAccountValidation(t *testing.T) {
}
}
for
_
,
input
:=
range
inputs
{
for
_
,
input
:=
range
inputs
{
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
input
.
name
,
func
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
...
@@ -400,7 +397,6 @@ func TestServiceAccountValidation(t *testing.T) {
...
@@ -400,7 +397,6 @@ func TestServiceAccountValidation(t *testing.T) {
outputFormat
:=
""
outputFormat
:=
""
tf
.
Namespace
=
"test"
streams
:=
genericclioptions
.
NewTestIOStreamsDiscard
()
streams
:=
genericclioptions
.
NewTestIOStreamsDiscard
()
cmd
:=
NewCmdServiceAccount
(
tf
,
streams
)
cmd
:=
NewCmdServiceAccount
(
tf
,
streams
)
...
...
pkg/kubectl/cmd/set/set_subject.go
View file @
c85e69ae
...
@@ -131,7 +131,7 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
...
@@ -131,7 +131,7 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
o
.
PrintObj
=
printer
.
PrintObj
o
.
PrintObj
=
printer
.
PrintObj
var
enforceNamespace
bool
var
enforceNamespace
bool
o
.
namespace
,
enforceNamespace
,
err
=
f
.
Default
Namespace
()
o
.
namespace
,
enforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/set/set_subject_test.go
View file @
c85e69ae
...
@@ -28,11 +28,9 @@ import (
...
@@ -28,11 +28,9 @@ import (
)
)
func
TestValidate
(
t
*
testing
.
T
)
{
func
TestValidate
(
t
*
testing
.
T
)
{
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
tf
.
Namespace
=
"test"
tests
:=
map
[
string
]
struct
{
tests
:=
map
[
string
]
struct
{
options
*
SubjectOptions
options
*
SubjectOptions
expectErr
bool
expectErr
bool
...
...
pkg/kubectl/cmd/taint.go
View file @
c85e69ae
...
@@ -124,7 +124,7 @@ func NewCmdTaint(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.
...
@@ -124,7 +124,7 @@ func NewCmdTaint(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.
// 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
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
func
(
o
*
TaintOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
(
err
error
)
{
namespace
,
_
,
err
:=
f
.
Default
Namespace
()
namespace
,
_
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/testing/BUILD
View file @
c85e69ae
...
@@ -18,7 +18,6 @@ go_library(
...
@@ -18,7 +18,6 @@ go_library(
"//pkg/kubectl/genericclioptions:go_default_library",
"//pkg/kubectl/genericclioptions:go_default_library",
"//pkg/kubectl/genericclioptions/resource:go_default_library",
"//pkg/kubectl/genericclioptions/resource:go_default_library",
"//pkg/kubectl/validation:go_default_library",
"//pkg/kubectl/validation:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
...
pkg/kubectl/cmd/testing/fake.go
View file @
c85e69ae
...
@@ -25,8 +25,6 @@ import (
...
@@ -25,8 +25,6 @@ import (
"path/filepath"
"path/filepath"
"time"
"time"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -234,12 +232,12 @@ func (d *fakeCachedDiscoveryClient) ServerResources() ([]*metav1.APIResourceList
...
@@ -234,12 +232,12 @@ func (d *fakeCachedDiscoveryClient) ServerResources() ([]*metav1.APIResourceList
type
TestFactory
struct
{
type
TestFactory
struct
{
cmdutil
.
Factory
cmdutil
.
Factory
kubeConfigFlags
*
genericclioptions
.
TestConfigFlags
Client
kubectl
.
RESTClient
Client
kubectl
.
RESTClient
ScaleGetter
scaleclient
.
ScalesGetter
ScaleGetter
scaleclient
.
ScalesGetter
UnstructuredClient
kubectl
.
RESTClient
UnstructuredClient
kubectl
.
RESTClient
Namespace
string
ClientConfigVal
*
restclient
.
Config
ClientConfigVal
*
restclient
.
Config
CommandVal
string
FakeDynamicClient
*
fakedynamic
.
FakeDynamicClient
FakeDynamicClient
*
fakedynamic
.
FakeDynamicClient
tempConfigFile
*
os
.
File
tempConfigFile
*
os
.
File
...
@@ -276,6 +274,7 @@ func NewTestFactory() *TestFactory {
...
@@ -276,6 +274,7 @@ func NewTestFactory() *TestFactory {
return
&
TestFactory
{
return
&
TestFactory
{
Factory
:
cmdutil
.
NewFactory
(
configFlags
),
Factory
:
cmdutil
.
NewFactory
(
configFlags
),
kubeConfigFlags
:
configFlags
,
FakeDynamicClient
:
fakedynamic
.
NewSimpleDynamicClient
(
legacyscheme
.
Scheme
),
FakeDynamicClient
:
fakedynamic
.
NewSimpleDynamicClient
(
legacyscheme
.
Scheme
),
tempConfigFile
:
tmpFile
,
tempConfigFile
:
tmpFile
,
...
@@ -283,6 +282,11 @@ func NewTestFactory() *TestFactory {
...
@@ -283,6 +282,11 @@ func NewTestFactory() *TestFactory {
}
}
}
}
func
(
f
*
TestFactory
)
WithNamespace
(
ns
string
)
*
TestFactory
{
f
.
kubeConfigFlags
.
WithNamespace
(
ns
)
return
f
}
func
(
f
*
TestFactory
)
Cleanup
()
{
func
(
f
*
TestFactory
)
Cleanup
()
{
if
f
.
tempConfigFile
==
nil
{
if
f
.
tempConfigFile
==
nil
{
return
return
...
@@ -295,10 +299,6 @@ func (f *TestFactory) ToRESTConfig() (*restclient.Config, error) {
...
@@ -295,10 +299,6 @@ func (f *TestFactory) ToRESTConfig() (*restclient.Config, error) {
return
f
.
ClientConfigVal
,
nil
return
f
.
ClientConfigVal
,
nil
}
}
func
(
f
*
TestFactory
)
BareClientConfig
()
(
*
restclient
.
Config
,
error
)
{
return
f
.
ClientConfigVal
,
nil
}
func
(
f
*
TestFactory
)
ClientForMapping
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
func
(
f
*
TestFactory
)
ClientForMapping
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
return
f
.
Client
,
nil
return
f
.
Client
,
nil
}
}
...
@@ -314,10 +314,6 @@ func (f *TestFactory) Validator(validate bool) (validation.Schema, error) {
...
@@ -314,10 +314,6 @@ func (f *TestFactory) Validator(validate bool) (validation.Schema, error) {
return
validation
.
NullSchema
{},
nil
return
validation
.
NullSchema
{},
nil
}
}
func
(
f
*
TestFactory
)
DefaultNamespace
()
(
string
,
bool
,
error
)
{
return
f
.
Namespace
,
false
,
nil
}
func
(
f
*
TestFactory
)
OpenAPISchema
()
(
openapi
.
Resources
,
error
)
{
func
(
f
*
TestFactory
)
OpenAPISchema
()
(
openapi
.
Resources
,
error
)
{
if
f
.
OpenAPISchemaFunc
!=
nil
{
if
f
.
OpenAPISchemaFunc
!=
nil
{
return
f
.
OpenAPISchemaFunc
()
return
f
.
OpenAPISchemaFunc
()
...
@@ -325,10 +321,6 @@ func (f *TestFactory) OpenAPISchema() (openapi.Resources, error) {
...
@@ -325,10 +321,6 @@ func (f *TestFactory) OpenAPISchema() (openapi.Resources, error) {
return
openapitesting
.
EmptyResources
{},
nil
return
openapitesting
.
EmptyResources
{},
nil
}
}
func
(
f
*
TestFactory
)
Command
(
*
cobra
.
Command
,
bool
)
string
{
return
f
.
CommandVal
}
func
(
f
*
TestFactory
)
NewBuilder
()
*
resource
.
Builder
{
func
(
f
*
TestFactory
)
NewBuilder
()
*
resource
.
Builder
{
mapper
,
err
:=
f
.
ToRESTMapper
()
mapper
,
err
:=
f
.
ToRESTMapper
()
...
@@ -425,10 +417,6 @@ func (f *TestFactory) DiscoveryClient() (discovery.CachedDiscoveryInterface, err
...
@@ -425,10 +417,6 @@ func (f *TestFactory) DiscoveryClient() (discovery.CachedDiscoveryInterface, err
return
cachedClient
,
nil
return
cachedClient
,
nil
}
}
func
(
f
*
TestFactory
)
ClientSetForVersion
(
requiredVersion
*
schema
.
GroupVersion
)
(
internalclientset
.
Interface
,
error
)
{
return
f
.
ClientSet
()
}
func
testRESTMapper
()
meta
.
RESTMapper
{
func
testRESTMapper
()
meta
.
RESTMapper
{
groupResources
:=
testDynamicResources
()
groupResources
:=
testDynamicResources
()
mapper
:=
restmapper
.
NewDiscoveryRESTMapper
(
groupResources
)
mapper
:=
restmapper
.
NewDiscoveryRESTMapper
(
groupResources
)
...
...
pkg/kubectl/cmd/top_node_test.go
View file @
c85e69ae
...
@@ -50,7 +50,7 @@ func TestTopNodeAllMetrics(t *testing.T) {
...
@@ -50,7 +50,7 @@ func TestTopNodeAllMetrics(t *testing.T) {
expectedMetricsPath
:=
fmt
.
Sprintf
(
"%s/%s/nodes"
,
baseMetricsAddress
,
metricsApiVersion
)
expectedMetricsPath
:=
fmt
.
Sprintf
(
"%s/%s/nodes"
,
baseMetricsAddress
,
metricsApiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -78,7 +78,6 @@ func TestTopNodeAllMetrics(t *testing.T) {
...
@@ -78,7 +78,6 @@ func TestTopNodeAllMetrics(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -103,7 +102,7 @@ func TestTopNodeAllMetricsCustomDefaults(t *testing.T) {
...
@@ -103,7 +102,7 @@ func TestTopNodeAllMetricsCustomDefaults(t *testing.T) {
expectedMetricsPath
:=
fmt
.
Sprintf
(
"%s/%s/nodes"
,
customBaseMetricsAddress
,
metricsApiVersion
)
expectedMetricsPath
:=
fmt
.
Sprintf
(
"%s/%s/nodes"
,
customBaseMetricsAddress
,
metricsApiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -131,7 +130,6 @@ func TestTopNodeAllMetricsCustomDefaults(t *testing.T) {
...
@@ -131,7 +130,6 @@ func TestTopNodeAllMetricsCustomDefaults(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -167,7 +165,7 @@ func TestTopNodeWithNameMetrics(t *testing.T) {
...
@@ -167,7 +165,7 @@ func TestTopNodeWithNameMetrics(t *testing.T) {
expectedPath
:=
fmt
.
Sprintf
(
"%s/%s/nodes/%s"
,
baseMetricsAddress
,
metricsApiVersion
,
expectedMetrics
.
Name
)
expectedPath
:=
fmt
.
Sprintf
(
"%s/%s/nodes/%s"
,
baseMetricsAddress
,
metricsApiVersion
,
expectedMetrics
.
Name
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes/%s"
,
apiPrefix
,
apiVersion
,
expectedMetrics
.
Name
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes/%s"
,
apiPrefix
,
apiVersion
,
expectedMetrics
.
Name
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -195,7 +193,6 @@ func TestTopNodeWithNameMetrics(t *testing.T) {
...
@@ -195,7 +193,6 @@ func TestTopNodeWithNameMetrics(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -234,7 +231,7 @@ func TestTopNodeWithLabelSelectorMetrics(t *testing.T) {
...
@@ -234,7 +231,7 @@ func TestTopNodeWithLabelSelectorMetrics(t *testing.T) {
expectedQuery
:=
fmt
.
Sprintf
(
"labelSelector=%s"
,
url
.
QueryEscape
(
label
))
expectedQuery
:=
fmt
.
Sprintf
(
"labelSelector=%s"
,
url
.
QueryEscape
(
label
))
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -262,7 +259,6 @@ func TestTopNodeWithLabelSelectorMetrics(t *testing.T) {
...
@@ -262,7 +259,6 @@ func TestTopNodeWithLabelSelectorMetrics(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -289,7 +285,7 @@ func TestTopNodeAllMetricsFromMetricsServer(t *testing.T) {
...
@@ -289,7 +285,7 @@ func TestTopNodeAllMetricsFromMetricsServer(t *testing.T) {
expectedMetrics
,
nodes
:=
testNodeV1beta1MetricsData
()
expectedMetrics
,
nodes
:=
testNodeV1beta1MetricsData
()
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -315,7 +311,6 @@ func TestTopNodeAllMetricsFromMetricsServer(t *testing.T) {
...
@@ -315,7 +311,6 @@ func TestTopNodeAllMetricsFromMetricsServer(t *testing.T) {
fakemetricsClientset
.
AddReactor
(
"list"
,
"nodes"
,
func
(
action
core
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
fakemetricsClientset
.
AddReactor
(
"list"
,
"nodes"
,
func
(
action
core
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
return
true
,
expectedMetrics
,
nil
return
true
,
expectedMetrics
,
nil
})
})
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -357,7 +352,7 @@ func TestTopNodeWithNameMetricsFromMetricsServer(t *testing.T) {
...
@@ -357,7 +352,7 @@ func TestTopNodeWithNameMetricsFromMetricsServer(t *testing.T) {
}
}
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes/%s"
,
apiPrefix
,
apiVersion
,
expectedMetrics
.
Name
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes/%s"
,
apiPrefix
,
apiVersion
,
expectedMetrics
.
Name
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -383,7 +378,6 @@ func TestTopNodeWithNameMetricsFromMetricsServer(t *testing.T) {
...
@@ -383,7 +378,6 @@ func TestTopNodeWithNameMetricsFromMetricsServer(t *testing.T) {
fakemetricsClientset
.
AddReactor
(
"get"
,
"nodes"
,
func
(
action
core
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
fakemetricsClientset
.
AddReactor
(
"get"
,
"nodes"
,
func
(
action
core
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
return
true
,
&
expectedMetrics
,
nil
return
true
,
&
expectedMetrics
,
nil
})
})
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -435,7 +429,7 @@ func TestTopNodeWithLabelSelectorMetricsFromMetricsServer(t *testing.T) {
...
@@ -435,7 +429,7 @@ func TestTopNodeWithLabelSelectorMetricsFromMetricsServer(t *testing.T) {
label
:=
"key=value"
label
:=
"key=value"
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
expectedNodePath
:=
fmt
.
Sprintf
(
"/%s/%s/nodes"
,
apiPrefix
,
apiVersion
)
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
...
@@ -462,7 +456,6 @@ func TestTopNodeWithLabelSelectorMetricsFromMetricsServer(t *testing.T) {
...
@@ -462,7 +456,6 @@ func TestTopNodeWithLabelSelectorMetricsFromMetricsServer(t *testing.T) {
fakemetricsClientset
.
AddReactor
(
"list"
,
"nodes"
,
func
(
action
core
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
fakemetricsClientset
.
AddReactor
(
"list"
,
"nodes"
,
func
(
action
core
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
return
true
,
expectedMetrics
,
nil
return
true
,
expectedMetrics
,
nil
})
})
tf
.
Namespace
=
"test"
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/top_pod.go
View file @
c85e69ae
...
@@ -121,7 +121,7 @@ func (o *TopPodOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s
...
@@ -121,7 +121,7 @@ func (o *TopPodOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s"
,
cmd
.
Use
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s"
,
cmd
.
Use
)
}
}
o
.
Namespace
,
_
,
err
=
f
.
Default
Namespace
()
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/top_pod_test.go
View file @
c85e69ae
...
@@ -164,7 +164,7 @@ func TestTopPod(t *testing.T) {
...
@@ -164,7 +164,7 @@ func TestTopPod(t *testing.T) {
}
}
}
}
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
testNS
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -190,7 +190,6 @@ func TestTopPod(t *testing.T) {
...
@@ -190,7 +190,6 @@ func TestTopPod(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
testNS
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -309,7 +308,7 @@ func TestTopPodWithMetricsServer(t *testing.T) {
...
@@ -309,7 +308,7 @@ func TestTopPodWithMetricsServer(t *testing.T) {
})
})
}
}
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
testNS
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -329,7 +328,6 @@ func TestTopPodWithMetricsServer(t *testing.T) {
...
@@ -329,7 +328,6 @@ func TestTopPodWithMetricsServer(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
testNS
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
@@ -508,7 +506,7 @@ func TestTopPodCustomDefaults(t *testing.T) {
...
@@ -508,7 +506,7 @@ func TestTopPodCustomDefaults(t *testing.T) {
}
}
}
}
tf
:=
cmdtesting
.
NewTestFactory
()
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
testNS
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacyscheme
.
Codecs
ns
:=
legacyscheme
.
Codecs
...
@@ -534,7 +532,6 @@ func TestTopPodCustomDefaults(t *testing.T) {
...
@@ -534,7 +532,6 @@ func TestTopPodCustomDefaults(t *testing.T) {
}
}
}),
}),
}
}
tf
.
Namespace
=
testNS
tf
.
ClientConfigVal
=
defaultClientConfig
()
tf
.
ClientConfigVal
=
defaultClientConfig
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
buf
,
_
:=
genericclioptions
.
NewTestIOStreams
()
...
...
pkg/kubectl/cmd/util/editor/editoptions.go
View file @
c85e69ae
...
@@ -129,7 +129,7 @@ func (o *EditOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Comm
...
@@ -129,7 +129,7 @@ func (o *EditOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Comm
return
fmt
.
Errorf
(
"the edit mode doesn't support output the patch"
)
return
fmt
.
Errorf
(
"the edit mode doesn't support output the patch"
)
}
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
Default
Namespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/util/factory.go
View file @
c85e69ae
...
@@ -62,11 +62,6 @@ type Factory interface {
...
@@ -62,11 +62,6 @@ type Factory interface {
// and which implements the common patterns for CLI interactions with generic resources.
// and which implements the common patterns for CLI interactions with generic resources.
NewBuilder
()
*
resource
.
Builder
NewBuilder
()
*
resource
.
Builder
// Returns the default namespace to use in cases where no
// other namespace is specified and whether the namespace was
// overridden.
DefaultNamespace
()
(
string
,
bool
,
error
)
// Returns a RESTClient for working with the specified RESTMapping or an error. This is intended
// Returns a RESTClient for working with the specified RESTMapping or an error. This is intended
// for working with arbitrary resources and is not guaranteed to point to a Kubernetes APIServer.
// for working with arbitrary resources and is not guaranteed to point to a Kubernetes APIServer.
ClientForMapping
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
ClientForMapping
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
...
...
pkg/kubectl/cmd/util/factory_client_access.go
View file @
c85e69ae
...
@@ -118,10 +118,6 @@ func (f *factoryImpl) RESTClient() (*restclient.RESTClient, error) {
...
@@ -118,10 +118,6 @@ func (f *factoryImpl) RESTClient() (*restclient.RESTClient, error) {
return
restclient
.
RESTClientFor
(
clientConfig
)
return
restclient
.
RESTClientFor
(
clientConfig
)
}
}
func
(
f
*
factoryImpl
)
DefaultNamespace
()
(
string
,
bool
,
error
)
{
return
f
.
clientGetter
.
ToRawKubeConfigLoader
()
.
Namespace
()
}
func
(
f
*
factoryImpl
)
ClientForMapping
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
func
(
f
*
factoryImpl
)
ClientForMapping
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
cfg
,
err
:=
f
.
clientGetter
.
ToRESTConfig
()
cfg
,
err
:=
f
.
clientGetter
.
ToRESTConfig
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kubectl/genericclioptions/BUILD
View file @
c85e69ae
...
@@ -30,6 +30,7 @@ go_library(
...
@@ -30,6 +30,7 @@ go_library(
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/restmapper:go_default_library",
"//vendor/k8s.io/client-go/restmapper:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd/api:go_default_library",
"//vendor/k8s.io/client-go/util/homedir:go_default_library",
"//vendor/k8s.io/client-go/util/homedir:go_default_library",
],
],
)
)
...
...
pkg/kubectl/genericclioptions/config_flags_fake.go
View file @
c85e69ae
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/rest"
"k8s.io/client-go/restmapper"
"k8s.io/client-go/restmapper"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi
"k8s.io/client-go/tools/clientcmd/api"
)
)
type
TestConfigFlags
struct
{
type
TestConfigFlags
struct
{
...
@@ -74,6 +75,36 @@ func (f *TestConfigFlags) WithDiscoveryClient(c discovery.CachedDiscoveryInterfa
...
@@ -74,6 +75,36 @@ func (f *TestConfigFlags) WithDiscoveryClient(c discovery.CachedDiscoveryInterfa
return
f
return
f
}
}
func
(
f
*
TestConfigFlags
)
WithNamespace
(
ns
string
)
*
TestConfigFlags
{
if
f
.
clientConfig
==
nil
{
panic
(
"attempt to obtain a test RawKubeConfigLoader with no clientConfig specified"
)
}
f
.
clientConfig
=
&
namespacedClientConfig
{
delegate
:
f
.
clientConfig
,
namespace
:
ns
,
}
return
f
}
func
NewTestConfigFlags
()
*
TestConfigFlags
{
func
NewTestConfigFlags
()
*
TestConfigFlags
{
return
&
TestConfigFlags
{}
return
&
TestConfigFlags
{}
}
}
type
namespacedClientConfig
struct
{
delegate
clientcmd
.
ClientConfig
namespace
string
}
func
(
c
*
namespacedClientConfig
)
Namespace
()
(
string
,
bool
,
error
)
{
return
c
.
namespace
,
false
,
nil
}
func
(
c
*
namespacedClientConfig
)
RawConfig
()
(
clientcmdapi
.
Config
,
error
)
{
return
c
.
delegate
.
RawConfig
()
}
func
(
c
*
namespacedClientConfig
)
ClientConfig
()
(
*
rest
.
Config
,
error
)
{
return
c
.
delegate
.
ClientConfig
()
}
func
(
c
*
namespacedClientConfig
)
ConfigAccess
()
clientcmd
.
ConfigAccess
{
return
c
.
delegate
.
ConfigAccess
()
}
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