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
6b2f3c81
Commit
6b2f3c81
authored
Aug 06, 2017
by
Di Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forbid kubectl edit an empty list
parent
f75f49e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
0.request
...ectl/cmd/testdata/edit/testcase-edit-from-empty/0.request
+0
-0
0.response
...ctl/cmd/testdata/edit/testcase-edit-from-empty/0.response
+9
-0
test.yaml
...ectl/cmd/testdata/edit/testcase-edit-from-empty/test.yaml
+15
-0
editoptions.go
pkg/kubectl/cmd/util/editor/editoptions.go
+4
-5
No files found.
pkg/kubectl/cmd/testdata/edit/testcase-edit-from-empty/0.request
0 → 100755
View file @
6b2f3c81
pkg/kubectl/cmd/testdata/edit/testcase-edit-from-empty/0.response
0 → 100755
View file @
6b2f3c81
{
"kind": "ConfigMapList",
"apiVersion": "v1",
"metadata": {
"selfLink": "/api/v1/namespaces/edit-test/configmaps",
"resourceVersion": "252"
},
"items": []
}
pkg/kubectl/cmd/testdata/edit/testcase-edit-from-empty/test.yaml
0 → 100755
View file @
6b2f3c81
description
:
add a testcase description
mode
:
edit
args
:
-
configmap
namespace
:
"
edit-test"
expectedStderr
:
-
edit cancelled, no objects found.
expectedExitCode
:
1
steps
:
-
type
:
request
expectedMethod
:
GET
expectedPath
:
/api/v1/namespaces/edit-test/configmaps
expectedInput
:
0.request
resultingStatusCode
:
200
resultingOutput
:
0.response
pkg/kubectl/cmd/util/editor/editoptions.go
View file @
6b2f3c81
...
...
@@ -336,6 +336,9 @@ func (o *EditOptions) Run() error {
if
err
!=
nil
{
return
err
}
if
len
(
infos
)
==
0
{
return
errors
.
New
(
"edit cancelled, no objects found."
)
}
return
editFn
(
infos
)
case
ApplyEditMode
:
infos
,
err
:=
o
.
OriginalResult
.
Infos
()
...
...
@@ -500,11 +503,7 @@ func getPrinter(format string) *editPrinterOptions {
}
}
func
(
o
*
EditOptions
)
visitToPatch
(
originalInfos
[]
*
resource
.
Info
,
patchVisitor
resource
.
Visitor
,
results
*
editResults
,
)
error
{
func
(
o
*
EditOptions
)
visitToPatch
(
originalInfos
[]
*
resource
.
Info
,
patchVisitor
resource
.
Visitor
,
results
*
editResults
)
error
{
err
:=
patchVisitor
.
Visit
(
func
(
info
*
resource
.
Info
,
incomingErr
error
)
error
{
editObjUID
,
err
:=
meta
.
NewAccessor
()
.
UID
(
info
.
Object
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment