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
056536ff
Commit
056536ff
authored
Nov 05, 2015
by
Hongchao Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
component status: nil error should return empty string
If error is nil, it should return empty string instead of \"nil\". JSON marshalling will omit empty error in such case.
parent
bdac1981
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
6 deletions
+4
-6
get_test.go
pkg/kubectl/cmd/get_test.go
+1
-1
rest.go
pkg/registry/componentstatus/rest.go
+1
-3
rest_test.go
pkg/registry/componentstatus/rest_test.go
+2
-2
No files found.
pkg/kubectl/cmd/get_test.go
View file @
056536ff
...
...
@@ -88,7 +88,7 @@ func testData() (*api.PodList, *api.ServiceList, *api.ReplicationControllerList)
func
testComponentStatusData
()
*
api
.
ComponentStatusList
{
good
:=
api
.
ComponentStatus
{
Conditions
:
[]
api
.
ComponentCondition
{
{
Type
:
api
.
ComponentHealthy
,
Status
:
api
.
ConditionTrue
,
Message
:
"ok"
,
Error
:
"nil"
},
{
Type
:
api
.
ComponentHealthy
,
Status
:
api
.
ConditionTrue
,
Message
:
"ok"
},
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"servergood"
},
}
...
...
pkg/registry/componentstatus/rest.go
View file @
056536ff
...
...
@@ -85,11 +85,9 @@ func ToConditionStatus(s probe.Result) api.ConditionStatus {
func
(
rs
*
REST
)
getComponentStatus
(
name
string
,
server
apiserver
.
Server
)
*
api
.
ComponentStatus
{
transport
:=
rs
.
rt
status
,
msg
,
err
:=
server
.
DoServerCheck
(
transport
)
var
errorMsg
string
errorMsg
:=
""
if
err
!=
nil
{
errorMsg
=
err
.
Error
()
}
else
{
errorMsg
=
"nil"
}
c
:=
&
api
.
ComponentCondition
{
...
...
pkg/registry/componentstatus/rest_test.go
View file @
056536ff
...
...
@@ -81,7 +81,7 @@ func TestList_NoError(t *testing.T) {
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
expect
:=
&
api
.
ComponentStatusList
{
Items
:
[]
api
.
ComponentStatus
{
*
(
createTestStatus
(
"test1"
,
api
.
ConditionTrue
,
"ok"
,
"
nil
"
))},
Items
:
[]
api
.
ComponentStatus
{
*
(
createTestStatus
(
"test1"
,
api
.
ConditionTrue
,
"ok"
,
""
))},
}
if
e
,
a
:=
expect
,
got
;
!
reflect
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"Got unexpected object. Diff: %s"
,
util
.
ObjectDiff
(
e
,
a
))
...
...
@@ -124,7 +124,7 @@ func TestGet_NoError(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
expect
:=
createTestStatus
(
"test1"
,
api
.
ConditionTrue
,
"ok"
,
"
nil
"
)
expect
:=
createTestStatus
(
"test1"
,
api
.
ConditionTrue
,
"ok"
,
""
)
if
e
,
a
:=
expect
,
got
;
!
reflect
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"Got unexpected object. Diff: %s"
,
util
.
ObjectDiff
(
e
,
a
))
}
...
...
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