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
86a0193f
Commit
86a0193f
authored
Feb 20, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4311 from kazegusuri/update_nil_label
kubectl label command crashes when a resource has no labels
parents
93d77ab6
a841b91a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
label.go
pkg/kubectl/cmd/label.go
+4
-0
label_test.go
pkg/kubectl/cmd/label_test.go
+11
-0
No files found.
pkg/kubectl/cmd/label.go
View file @
86a0193f
...
...
@@ -160,6 +160,10 @@ func labelFunc(obj runtime.Object, overwrite bool, resourceVersion string, label
}
}
if
meta
.
Labels
==
nil
{
meta
.
Labels
=
make
(
map
[
string
]
string
)
}
for
key
,
value
:=
range
labels
{
meta
.
Labels
[
key
]
=
value
}
...
...
pkg/kubectl/cmd/label_test.go
View file @
86a0193f
...
...
@@ -230,6 +230,17 @@ func TestLabelFunc(t *testing.T) {
},
},
},
{
obj
:
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{},
},
labels
:
map
[
string
]
string
{
"a"
:
"b"
},
expected
:
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
},
},
},
}
for
_
,
test
:=
range
tests
{
out
,
err
:=
labelFunc
(
test
.
obj
,
test
.
overwrite
,
test
.
version
,
test
.
labels
,
test
.
remove
)
...
...
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