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
2e7993e0
Commit
2e7993e0
authored
Feb 04, 2016
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20674 from caesarxuchao/decode-status
To be compatible with release 1.1, decode Status even if the APIVersion is not set in the response
parents
15df7c72
0d772a7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
request.go
pkg/client/unversioned/request.go
+7
-4
restclient_test.go
pkg/client/unversioned/restclient_test.go
+5
-1
No files found.
pkg/client/unversioned/request.go
View file @
2e7993e0
...
@@ -841,10 +841,13 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) Resu
...
@@ -841,10 +841,13 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) Resu
// Did the server give us a status response?
// Did the server give us a status response?
isStatusResponse
:=
false
isStatusResponse
:=
false
var
status
*
unversioned
.
Status
// Because release-1.1 server returns Status with empty APIVersion at paths
result
,
err
:=
runtime
.
Decode
(
r
.
content
.
Codec
,
body
)
// to the Extensions resources, we need to use DecodeInto here to provide
if
out
,
ok
:=
result
.
(
*
unversioned
.
Status
);
err
==
nil
&&
ok
&&
len
(
out
.
Status
)
>
0
{
// default groupVersion, otherwise a status response won't be correctly
status
=
out
// decoded.
status
:=
&
unversioned
.
Status
{}
err
:=
runtime
.
DecodeInto
(
r
.
content
.
Codec
,
body
,
status
)
if
err
==
nil
&&
len
(
status
.
Status
)
>
0
{
isStatusResponse
=
true
isStatusResponse
=
true
}
}
...
...
pkg/client/unversioned/restclient_test.go
View file @
2e7993e0
...
@@ -109,7 +109,11 @@ func TestDoRequestFailed(t *testing.T) {
...
@@ -109,7 +109,11 @@ func TestDoRequestFailed(t *testing.T) {
t
.
Errorf
(
"unexpected error type %v"
,
err
)
t
.
Errorf
(
"unexpected error type %v"
,
err
)
}
}
actual
:=
ss
.
Status
()
actual
:=
ss
.
Status
()
if
!
reflect
.
DeepEqual
(
status
,
&
actual
)
{
expected
:=
*
status
// The decoder will apply the default Version and Kind to the Status.
expected
.
APIVersion
=
"v1"
expected
.
Kind
=
"Status"
if
!
reflect
.
DeepEqual
(
&
expected
,
&
actual
)
{
t
.
Errorf
(
"Unexpected mis-match: %s"
,
util
.
ObjectDiff
(
status
,
&
actual
))
t
.
Errorf
(
"Unexpected mis-match: %s"
,
util
.
ObjectDiff
(
status
,
&
actual
))
}
}
}
}
...
...
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