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
89c9c249
Commit
89c9c249
authored
Mar 07, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21964 from caesarxuchao/fix-thirdparty-parameter
Auto commit by PR queue bot
parents
61c9a004
4adb1105
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
5 deletions
+54
-5
master.go
pkg/master/master.go
+1
-1
master_test.go
pkg/master/master_test.go
+35
-4
codec.go
pkg/registry/thirdpartyresourcedata/codec.go
+18
-0
No files found.
pkg/master/master.go
View file @
89c9c249
...
@@ -658,7 +658,7 @@ func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupV
...
@@ -658,7 +658,7 @@ func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupV
OptionsExternalVersion
:
&
optionsExternalVersion
,
OptionsExternalVersion
:
&
optionsExternalVersion
,
Serializer
:
thirdpartyresourcedata
.
NewNegotiatedSerializer
(
api
.
Codecs
,
kind
,
externalVersion
,
internalVersion
),
Serializer
:
thirdpartyresourcedata
.
NewNegotiatedSerializer
(
api
.
Codecs
,
kind
,
externalVersion
,
internalVersion
),
ParameterCodec
:
api
.
ParameterCodec
,
ParameterCodec
:
thirdpartyresourcedata
.
NewThirdPartyParameterCodec
(
api
.
ParameterCodec
)
,
Context
:
m
.
RequestContextMapper
,
Context
:
m
.
RequestContextMapper
,
...
...
pkg/master/master_test.go
View file @
89c9c249
...
@@ -568,8 +568,7 @@ func testInstallThirdPartyAPIListVersion(t *testing.T, version string) {
...
@@ -568,8 +568,7 @@ func testInstallThirdPartyAPIListVersion(t *testing.T, version string) {
}
}
if
len
(
list
.
Items
)
!=
len
(
test
.
items
)
{
if
len
(
list
.
Items
)
!=
len
(
test
.
items
)
{
t
.
Errorf
(
"unexpected length: %d vs %d"
,
len
(
list
.
Items
),
len
(
test
.
items
))
t
.
Fatalf
(
"unexpected length: %d vs %d"
,
len
(
list
.
Items
),
len
(
test
.
items
))
return
}
}
// The order of elements in LIST is not guaranteed.
// The order of elements in LIST is not guaranteed.
mapping
:=
make
(
map
[
string
]
int
)
mapping
:=
make
(
map
[
string
]
int
)
...
@@ -715,8 +714,7 @@ func testInstallThirdPartyAPIPostForVersion(t *testing.T, version string) {
...
@@ -715,8 +714,7 @@ func testInstallThirdPartyAPIPostForVersion(t *testing.T, version string) {
resp
,
err
:=
http
.
Post
(
server
.
URL
+
"/apis/company.com/"
+
version
+
"/namespaces/default/foos"
,
"application/json"
,
bytes
.
NewBuffer
(
data
))
resp
,
err
:=
http
.
Post
(
server
.
URL
+
"/apis/company.com/"
+
version
+
"/namespaces/default/foos"
,
"application/json"
,
bytes
.
NewBuffer
(
data
))
if
!
assert
.
NoError
(
err
)
{
if
!
assert
.
NoError
(
err
)
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
return
}
}
assert
.
Equal
(
http
.
StatusCreated
,
resp
.
StatusCode
)
assert
.
Equal
(
http
.
StatusCreated
,
resp
.
StatusCode
)
...
@@ -829,6 +827,39 @@ func httpDelete(url string) (*http.Response, error) {
...
@@ -829,6 +827,39 @@ func httpDelete(url string) (*http.Response, error) {
return
client
.
Do
(
req
)
return
client
.
Do
(
req
)
}
}
func
TestInstallThirdPartyAPIListOptions
(
t
*
testing
.
T
)
{
for
_
,
version
:=
range
versionsToTest
{
testInstallThirdPartyAPIListOptionsForVersion
(
t
,
version
)
}
}
func
testInstallThirdPartyAPIListOptionsForVersion
(
t
*
testing
.
T
,
version
string
)
{
_
,
etcdserver
,
server
,
assert
:=
initThirdParty
(
t
,
version
)
// TODO: Uncomment when fix #19254
// defer server.Close()
defer
etcdserver
.
Terminate
(
t
)
// send a GET request with query parameter
resp
,
err
:=
httpGetWithRV
(
server
.
URL
+
"/apis/company.com/"
+
version
+
"/namespaces/default/foos"
)
if
!
assert
.
NoError
(
err
)
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
assert
.
Equal
(
http
.
StatusOK
,
resp
.
StatusCode
)
}
func
httpGetWithRV
(
url
string
)
(
*
http
.
Response
,
error
)
{
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
q
:=
req
.
URL
.
Query
()
// resourceversion is part of a ListOptions
q
.
Add
(
"resourceversion"
,
"0"
)
req
.
URL
.
RawQuery
=
q
.
Encode
()
client
:=
&
http
.
Client
{}
return
client
.
Do
(
req
)
}
func
TestInstallThirdPartyResourceRemove
(
t
*
testing
.
T
)
{
func
TestInstallThirdPartyResourceRemove
(
t
*
testing
.
T
)
{
for
_
,
version
:=
range
versionsToTest
{
for
_
,
version
:=
range
versionsToTest
{
testInstallThirdPartyResourceRemove
(
t
,
version
)
testInstallThirdPartyResourceRemove
(
t
,
version
)
...
...
pkg/registry/thirdpartyresourcedata/codec.go
View file @
89c9c249
...
@@ -21,12 +21,14 @@ import (
...
@@ -21,12 +21,14 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io"
"io"
"net/url"
"strings"
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
apiutil
"k8s.io/kubernetes/pkg/api/util"
apiutil
"k8s.io/kubernetes/pkg/api/util"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
...
@@ -364,3 +366,19 @@ func (t *thirdPartyResourceDataCreator) New(kind unversioned.GroupVersionKind) (
...
@@ -364,3 +366,19 @@ func (t *thirdPartyResourceDataCreator) New(kind unversioned.GroupVersionKind) (
return
t
.
delegate
.
New
(
kind
)
return
t
.
delegate
.
New
(
kind
)
}
}
}
}
func
NewThirdPartyParameterCodec
(
p
runtime
.
ParameterCodec
)
runtime
.
ParameterCodec
{
return
&
thirdPartyParameterCodec
{
p
}
}
type
thirdPartyParameterCodec
struct
{
delegate
runtime
.
ParameterCodec
}
func
(
t
*
thirdPartyParameterCodec
)
DecodeParameters
(
parameters
url
.
Values
,
from
unversioned
.
GroupVersion
,
into
runtime
.
Object
)
error
{
return
t
.
delegate
.
DecodeParameters
(
parameters
,
v1
.
SchemeGroupVersion
,
into
)
}
func
(
t
*
thirdPartyParameterCodec
)
EncodeParameters
(
obj
runtime
.
Object
,
to
unversioned
.
GroupVersion
)
(
url
.
Values
,
error
)
{
return
t
.
delegate
.
EncodeParameters
(
obj
,
v1
.
SchemeGroupVersion
)
}
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