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
27f61cb2
Commit
27f61cb2
authored
Oct 12, 2016
by
yuexiao-wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update function name for public function in commend
Signed-off-by:
yuexiao-wang
<
wang.yuexiao@zte.com.cn
>
parent
9b726d6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
fieldpath.go
pkg/fieldpath/fieldpath.go
+3
-3
fieldpath_test.go
pkg/fieldpath/fieldpath_test.go
+3
-3
No files found.
pkg/fieldpath/fieldpath.go
View file @
27f61cb2
...
@@ -63,7 +63,7 @@ func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error)
...
@@ -63,7 +63,7 @@ func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error)
return
accessor
.
GetNamespace
(),
nil
return
accessor
.
GetNamespace
(),
nil
}
}
return
""
,
fmt
.
Errorf
(
"
U
nsupported fieldPath: %v"
,
fieldPath
)
return
""
,
fmt
.
Errorf
(
"
u
nsupported fieldPath: %v"
,
fieldPath
)
}
}
// TODO: move the functions below to pkg/api/util/resources
// TODO: move the functions below to pkg/api/util/resources
...
@@ -146,7 +146,7 @@ func InternalExtractContainerResourceValue(fs *api.ResourceFieldSelector, contai
...
@@ -146,7 +146,7 @@ func InternalExtractContainerResourceValue(fs *api.ResourceFieldSelector, contai
return
convertResourceMemoryToString
(
container
.
Resources
.
Requests
.
Memory
(),
divisor
)
return
convertResourceMemoryToString
(
container
.
Resources
.
Requests
.
Memory
(),
divisor
)
}
}
return
""
,
fmt
.
Errorf
(
"
U
nsupported container resource : %v"
,
fs
.
Resource
)
return
""
,
fmt
.
Errorf
(
"
u
nsupported container resource : %v"
,
fs
.
Resource
)
}
}
// findContainerInPod finds a container by its name in the provided pod
// findContainerInPod finds a container by its name in the provided pod
...
@@ -159,7 +159,7 @@ func findContainerInPod(pod *v1.Pod, containerName string) (*v1.Container, error
...
@@ -159,7 +159,7 @@ func findContainerInPod(pod *v1.Pod, containerName string) (*v1.Container, error
return
nil
,
fmt
.
Errorf
(
"container %s not found"
,
containerName
)
return
nil
,
fmt
.
Errorf
(
"container %s not found"
,
containerName
)
}
}
// convertResourceCPUT
O
String converts cpu value to the format of divisor and returns
// convertResourceCPUT
o
String converts cpu value to the format of divisor and returns
// ceiling of the value.
// ceiling of the value.
func
convertResourceCPUToString
(
cpu
*
resource
.
Quantity
,
divisor
resource
.
Quantity
)
(
string
,
error
)
{
func
convertResourceCPUToString
(
cpu
*
resource
.
Quantity
,
divisor
resource
.
Quantity
)
(
string
,
error
)
{
c
:=
int64
(
math
.
Ceil
(
float64
(
cpu
.
MilliValue
())
/
float64
(
divisor
.
MilliValue
())))
c
:=
int64
(
math
.
Ceil
(
float64
(
cpu
.
MilliValue
())
/
float64
(
divisor
.
MilliValue
())))
...
...
pkg/fieldpath/fieldpath_test.go
View file @
27f61cb2
...
@@ -99,7 +99,7 @@ func TestExtractFieldPathAsString(t *testing.T) {
...
@@ -99,7 +99,7 @@ func TestExtractFieldPathAsString(t *testing.T) {
Namespace
:
"object-namespace"
,
Namespace
:
"object-namespace"
,
},
},
},
},
expectedMessageFragment
:
"
U
nsupported fieldPath"
,
expectedMessageFragment
:
"
u
nsupported fieldPath"
,
},
},
}
}
...
@@ -108,13 +108,13 @@ func TestExtractFieldPathAsString(t *testing.T) {
...
@@ -108,13 +108,13 @@ func TestExtractFieldPathAsString(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
if
tc
.
expectedMessageFragment
!=
""
{
if
tc
.
expectedMessageFragment
!=
""
{
if
!
strings
.
Contains
(
err
.
Error
(),
tc
.
expectedMessageFragment
)
{
if
!
strings
.
Contains
(
err
.
Error
(),
tc
.
expectedMessageFragment
)
{
t
.
Errorf
(
"%v:
U
nexpected error message: %q, expected to contain %q"
,
tc
.
name
,
err
,
tc
.
expectedMessageFragment
)
t
.
Errorf
(
"%v:
u
nexpected error message: %q, expected to contain %q"
,
tc
.
name
,
err
,
tc
.
expectedMessageFragment
)
}
}
}
else
{
}
else
{
t
.
Errorf
(
"%v: unexpected error: %v"
,
tc
.
name
,
err
)
t
.
Errorf
(
"%v: unexpected error: %v"
,
tc
.
name
,
err
)
}
}
}
else
if
e
:=
tc
.
expectedValue
;
e
!=
""
&&
e
!=
actual
{
}
else
if
e
:=
tc
.
expectedValue
;
e
!=
""
&&
e
!=
actual
{
t
.
Errorf
(
"%v:
U
nexpected result; got %q, expected %q"
,
tc
.
name
,
actual
,
e
)
t
.
Errorf
(
"%v:
u
nexpected result; got %q, expected %q"
,
tc
.
name
,
actual
,
e
)
}
}
}
}
}
}
...
...
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