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
65080ea1
Commit
65080ea1
authored
May 11, 2017
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ParsePodFullName():code robustness
parent
3fbfafdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
runtime.go
pkg/kubelet/container/runtime.go
+1
-1
mirror_client_test.go
pkg/kubelet/pod/mirror_client_test.go
+1
-1
No files found.
pkg/kubelet/container/runtime.go
View file @
65080ea1
...
...
@@ -608,7 +608,7 @@ func BuildPodFullName(name, namespace string) string {
// Parse the pod full name.
func
ParsePodFullName
(
podFullName
string
)
(
string
,
string
,
error
)
{
parts
:=
strings
.
Split
(
podFullName
,
"_"
)
if
len
(
parts
)
!=
2
{
if
len
(
parts
)
!=
2
||
parts
[
0
]
==
""
||
parts
[
1
]
==
""
{
return
""
,
""
,
fmt
.
Errorf
(
"failed to parse the pod full name %q"
,
podFullName
)
}
return
parts
[
0
],
parts
[
1
],
nil
...
...
pkg/kubelet/pod/mirror_client_test.go
View file @
65080ea1
...
...
@@ -32,7 +32,7 @@ func TestParsePodFullName(t *testing.T) {
"bar.org_foo.com"
:
{
Name
:
"bar.org"
,
Namespace
:
"foo.com"
},
"bar-bar_foo"
:
{
Name
:
"bar-bar"
,
Namespace
:
"foo"
},
}
failedCases
:=
[]
string
{
"barfoo"
,
"bar_foo_foo"
,
""
}
failedCases
:=
[]
string
{
"barfoo"
,
"bar_foo_foo"
,
""
,
"bar_"
,
"_foo"
}
for
podFullName
,
expected
:=
range
successfulCases
{
name
,
namespace
,
err
:=
kubecontainer
.
ParsePodFullName
(
podFullName
)
...
...
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