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
012a438d
Unverified
Commit
012a438d
authored
Nov 14, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68655 from goodluckbot/kubectl-cordon-drain-uncordon
Support multiple arguments for cordon and drain
parents
22eb2b0d
df31468c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
drain.go
pkg/kubectl/cmd/drain/drain.go
+0
-3
drain_test.go
pkg/kubectl/cmd/drain/drain_test.go
+25
-1
No files found.
pkg/kubectl/cmd/drain/drain.go
View file @
012a438d
...
...
@@ -235,9 +235,6 @@ func (o *DrainOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
if
len
(
args
)
>
0
&&
len
(
o
.
Selector
)
>
0
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"error: cannot specify both a node name and a --selector option"
)
}
if
len
(
args
)
>
0
&&
len
(
args
)
!=
1
{
return
cmdutil
.
UsageErrorf
(
cmd
,
fmt
.
Sprintf
(
"USAGE: %s [flags]"
,
cmd
.
Use
))
}
o
.
DryRun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
...
...
pkg/kubectl/cmd/drain/drain_test.go
View file @
012a438d
...
...
@@ -142,6 +142,22 @@ func TestCordon(t *testing.T) {
arg
:
"bar"
,
expectFatal
:
true
,
},
{
description
:
"cordon for multiple nodes"
,
node
:
node
,
expected
:
cordoned_node
,
cmd
:
NewCmdCordon
,
arg
:
"node node1 node2"
,
expectFatal
:
false
,
},
{
description
:
"uncordon for multiple nodes"
,
node
:
cordoned_node
,
expected
:
node
,
cmd
:
NewCmdUncordon
,
arg
:
"node node1 node2"
,
expectFatal
:
false
,
},
}
for
_
,
test
:=
range
tests
{
...
...
@@ -160,10 +176,18 @@ func TestCordon(t *testing.T) {
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
m
:=
&
MyReq
{
req
}
switch
{
case
m
.
isFor
(
"GET"
,
"/nodes/node1"
)
:
fallthrough
case
m
.
isFor
(
"GET"
,
"/nodes/node2"
)
:
fallthrough
case
m
.
isFor
(
"GET"
,
"/nodes/node"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
cmdtesting
.
DefaultHeader
(),
Body
:
cmdtesting
.
ObjBody
(
codec
,
test
.
node
)},
nil
case
m
.
isFor
(
"GET"
,
"/nodes/bar"
)
:
return
&
http
.
Response
{
StatusCode
:
404
,
Header
:
cmdtesting
.
DefaultHeader
(),
Body
:
cmdtesting
.
StringBody
(
"nope"
)},
nil
case
m
.
isFor
(
"PATCH"
,
"/nodes/node1"
)
:
fallthrough
case
m
.
isFor
(
"PATCH"
,
"/nodes/node2"
)
:
fallthrough
case
m
.
isFor
(
"PATCH"
,
"/nodes/node"
)
:
data
,
err
:=
ioutil
.
ReadAll
(
req
.
Body
)
if
err
!=
nil
{
...
...
@@ -209,7 +233,7 @@ func TestCordon(t *testing.T) {
saw_fatal
=
true
panic
(
e
)
})
cmd
.
SetArgs
(
[]
string
{
test
.
arg
}
)
cmd
.
SetArgs
(
strings
.
Split
(
test
.
arg
,
" "
)
)
cmd
.
Execute
()
}()
...
...
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