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
b4c83022
Commit
b4c83022
authored
Apr 26, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NegotiatedSerializer to config
parent
43b644ea
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
63 additions
and
50 deletions
+63
-50
generator_for_group.go
cmd/libs/go2idl/client-gen/generators/generator_for_group.go
+3
-6
testgroup_client.go
...et/typed/testgroup.k8s.io/unversioned/testgroup_client.go
+2
-1
testapi.go
pkg/api/testapi/testapi.go
+8
-7
batch_client.go
...internalclientset/typed/batch/unversioned/batch_client.go
+2
-1
core_client.go
...d/internalclientset/typed/core/unversioned/core_client.go
+2
-1
extensions_client.go
...ientset/typed/extensions/unversioned/extensions_client.go
+2
-1
core_client.go
...entset_generated/release_1_2/typed/core/v1/core_client.go
+2
-1
extensions_client.go
...release_1_2/typed/extensions/v1beta1/extensions_client.go
+2
-1
core_client.go
...entset_generated/release_1_3/typed/core/v1/core_client.go
+1
-6
extensions_client.go
...release_1_3/typed/extensions/v1beta1/extensions_client.go
+1
-6
client.go
pkg/client/restclient/client.go
+4
-3
config.go
pkg/client/restclient/config.go
+12
-9
config_test.go
pkg/client/restclient/config_test.go
+2
-2
request_test.go
pkg/client/restclient/request_test.go
+5
-1
apps.go
pkg/client/unversioned/apps.go
+1
-0
autoscaling.go
pkg/client/unversioned/autoscaling.go
+1
-0
batch.go
pkg/client/unversioned/batch.go
+1
-0
extensions.go
pkg/client/unversioned/extensions.go
+1
-0
helper.go
pkg/client/unversioned/helper.go
+3
-0
helper_test.go
pkg/client/unversioned/helper_test.go
+4
-3
remotecommand_test.go
pkg/client/unversioned/remotecommand/remotecommand_test.go
+4
-1
No files found.
cmd/libs/go2idl/client-gen/generators/generator_for_group.go
View file @
b4c83022
...
@@ -204,7 +204,8 @@ func setConfigDefaults(config *$.Config|raw$) error {
...
@@ -204,7 +204,8 @@ func setConfigDefaults(config *$.Config|raw$) error {
config.GroupVersion = ©GroupVersion
config.GroupVersion = ©GroupVersion
//}
//}
config.Codec = $.codecs|raw$.LegacyCodec(*config.GroupVersion)
config.NegotiatedSerializer = $.codecs|raw$
if config.QPS == 0 {
if config.QPS == 0 {
config.QPS = 5
config.QPS = 5
}
}
...
@@ -232,11 +233,7 @@ func setConfigDefaults(config *$.Config|raw$) error {
...
@@ -232,11 +233,7 @@ func setConfigDefaults(config *$.Config|raw$) error {
config.GroupVersion = ©GroupVersion
config.GroupVersion = ©GroupVersion
//}
//}
codec, ok := $.codecs|raw$.SerializerForFileExtension("json")
config.NegotiatedSerializer = $.codecs|raw$
if !ok {
return $.Errorf|raw$("unable to find serializer for JSON")
}
config.Codec = codec
if config.QPS == 0 {
if config.QPS == 0 {
config.QPS = 5
config.QPS = 5
...
...
cmd/libs/go2idl/client-gen/testoutput/clientset_generated/test_internalclientset/typed/testgroup.k8s.io/unversioned/testgroup_client.go
View file @
b4c83022
...
@@ -80,7 +80,8 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -80,7 +80,8 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/api/testapi/testapi.go
View file @
b4c83022
...
@@ -45,13 +45,14 @@ import (
...
@@ -45,13 +45,14 @@ import (
)
)
var
(
var
(
Groups
=
make
(
map
[
string
]
TestGroup
)
Groups
=
make
(
map
[
string
]
TestGroup
)
Default
TestGroup
Default
TestGroup
Autoscaling
TestGroup
Autoscaling
TestGroup
Batch
TestGroup
Batch
TestGroup
Extensions
TestGroup
Extensions
TestGroup
Apps
TestGroup
Apps
TestGroup
Federation
TestGroup
Federation
TestGroup
NegotiatedSerializer
=
api
.
Codecs
)
)
type
TestGroup
struct
{
type
TestGroup
struct
{
...
...
pkg/client/clientset_generated/internalclientset/typed/batch/unversioned/batch_client.go
View file @
b4c83022
...
@@ -80,7 +80,8 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -80,7 +80,8 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/clientset_generated/internalclientset/typed/core/unversioned/core_client.go
View file @
b4c83022
...
@@ -155,7 +155,8 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -155,7 +155,8 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/clientset_generated/internalclientset/typed/extensions/unversioned/extensions_client.go
View file @
b4c83022
...
@@ -110,7 +110,8 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -110,7 +110,8 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/clientset_generated/release_1_2/typed/core/v1/core_client.go
View file @
b4c83022
...
@@ -149,7 +149,8 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -149,7 +149,8 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/clientset_generated/release_1_2/typed/extensions/v1beta1/extensions_client.go
View file @
b4c83022
...
@@ -114,7 +114,8 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -114,7 +114,8 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/clientset_generated/release_1_3/typed/core/v1/core_client.go
View file @
b4c83022
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
v1
package
v1
import
(
import
(
fmt
"fmt"
api
"k8s.io/kubernetes/pkg/api"
api
"k8s.io/kubernetes/pkg/api"
registered
"k8s.io/kubernetes/pkg/apimachinery/registered"
registered
"k8s.io/kubernetes/pkg/apimachinery/registered"
restclient
"k8s.io/kubernetes/pkg/client/restclient"
restclient
"k8s.io/kubernetes/pkg/client/restclient"
...
@@ -150,11 +149,7 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -150,11 +149,7 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
codec
,
ok
:=
api
.
Codecs
.
SerializerForFileExtension
(
"json"
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
!
ok
{
return
fmt
.
Errorf
(
"unable to find serializer for JSON"
)
}
config
.
Codec
=
codec
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
...
...
pkg/client/clientset_generated/release_1_3/typed/extensions/v1beta1/extensions_client.go
View file @
b4c83022
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
v1beta1
package
v1beta1
import
(
import
(
fmt
"fmt"
api
"k8s.io/kubernetes/pkg/api"
api
"k8s.io/kubernetes/pkg/api"
registered
"k8s.io/kubernetes/pkg/apimachinery/registered"
registered
"k8s.io/kubernetes/pkg/apimachinery/registered"
restclient
"k8s.io/kubernetes/pkg/client/restclient"
restclient
"k8s.io/kubernetes/pkg/client/restclient"
...
@@ -115,11 +114,7 @@ func setConfigDefaults(config *restclient.Config) error {
...
@@ -115,11 +114,7 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
//}
//}
codec
,
ok
:=
api
.
Codecs
.
SerializerForFileExtension
(
"json"
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
!
ok
{
return
fmt
.
Errorf
(
"unable to find serializer for JSON"
)
}
config
.
Codec
=
codec
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
...
...
pkg/client/restclient/client.go
View file @
b4c83022
...
@@ -63,7 +63,7 @@ type RESTClient struct {
...
@@ -63,7 +63,7 @@ type RESTClient struct {
// NewRESTClient creates a new RESTClient. This client performs generic REST functions
// NewRESTClient creates a new RESTClient. This client performs generic REST functions
// such as Get, Put, Post, and Delete on specified paths. Codec controls encoding and
// such as Get, Put, Post, and Delete on specified paths. Codec controls encoding and
// decoding of responses from the server.
// decoding of responses from the server.
func
NewRESTClient
(
baseURL
*
url
.
URL
,
versionedAPIPath
string
,
config
ContentConfig
,
maxQPS
float32
,
maxBurst
int
,
rateLimiter
flowcontrol
.
RateLimiter
,
client
*
http
.
Client
)
*
RESTClient
{
func
NewRESTClient
(
baseURL
*
url
.
URL
,
versionedAPIPath
string
,
config
ContentConfig
,
maxQPS
float32
,
maxBurst
int
,
rateLimiter
flowcontrol
.
RateLimiter
,
client
*
http
.
Client
)
(
*
RESTClient
,
error
)
{
base
:=
*
baseURL
base
:=
*
baseURL
if
!
strings
.
HasSuffix
(
base
.
Path
,
"/"
)
{
if
!
strings
.
HasSuffix
(
base
.
Path
,
"/"
)
{
base
.
Path
+=
"/"
base
.
Path
+=
"/"
...
@@ -90,7 +90,7 @@ func NewRESTClient(baseURL *url.URL, versionedAPIPath string, config ContentConf
...
@@ -90,7 +90,7 @@ func NewRESTClient(baseURL *url.URL, versionedAPIPath string, config ContentConf
contentConfig
:
config
,
contentConfig
:
config
,
Throttle
:
throttle
,
Throttle
:
throttle
,
Client
:
client
,
Client
:
client
,
}
}
,
nil
}
}
// GetRateLimiter returns rate limier for a given client, or nil if it's called on a nil client
// GetRateLimiter returns rate limier for a given client, or nil if it's called on a nil client
...
@@ -122,7 +122,8 @@ func readExpBackoffConfig() BackoffManager {
...
@@ -122,7 +122,8 @@ func readExpBackoffConfig() BackoffManager {
// Verb begins a request with a verb (GET, POST, PUT, DELETE).
// Verb begins a request with a verb (GET, POST, PUT, DELETE).
//
//
// Example usage of RESTClient's request building interface:
// Example usage of RESTClient's request building interface:
// c := NewRESTClient(url, codec)
// c, err := NewRESTClient(...)
// if err != nil { ... }
// resp, err := c.Verb("GET").
// resp, err := c.Verb("GET").
// Path("pods").
// Path("pods").
// SelectorParam("labels", "area=staging").
// SelectorParam("labels", "area=staging").
...
...
pkg/client/restclient/config.go
View file @
b4c83022
...
@@ -130,9 +130,15 @@ type ContentConfig struct {
...
@@ -130,9 +130,15 @@ type ContentConfig struct {
// a RESTClient directly. When initializing a Client, will be set with the default
// a RESTClient directly. When initializing a Client, will be set with the default
// code version.
// code version.
GroupVersion
*
unversioned
.
GroupVersion
GroupVersion
*
unversioned
.
GroupVersion
// NegotiatedSerializer is used for obtaining encoders and decoders for multiple
// supported media types.
NegotiatedSerializer
runtime
.
NegotiatedSerializer
// Codec specifies the encoding and decoding behavior for runtime.Objects passed
// Codec specifies the encoding and decoding behavior for runtime.Objects passed
// to a RESTClient or Client. Required when initializing a RESTClient, optional
// to a RESTClient or Client. Required when initializing a RESTClient, optional
// when initializing a Client.
// when initializing a Client.
//
// DEPRECATED: Please use NegotiatedSerializer instead.
Codec
runtime
.
Codec
Codec
runtime
.
Codec
}
}
...
@@ -144,8 +150,8 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
...
@@ -144,8 +150,8 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
if
config
.
GroupVersion
==
nil
{
if
config
.
GroupVersion
==
nil
{
return
nil
,
fmt
.
Errorf
(
"GroupVersion is required when initializing a RESTClient"
)
return
nil
,
fmt
.
Errorf
(
"GroupVersion is required when initializing a RESTClient"
)
}
}
if
config
.
Codec
==
nil
{
if
config
.
NegotiatedSerializer
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
Codec
is required when initializing a RESTClient"
)
return
nil
,
fmt
.
Errorf
(
"
NegotiatedSerializer
is required when initializing a RESTClient"
)
}
}
baseURL
,
versionedAPIPath
,
err
:=
defaultServerUrlFor
(
config
)
baseURL
,
versionedAPIPath
,
err
:=
defaultServerUrlFor
(
config
)
...
@@ -163,16 +169,14 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
...
@@ -163,16 +169,14 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
httpClient
=
&
http
.
Client
{
Transport
:
transport
}
httpClient
=
&
http
.
Client
{
Transport
:
transport
}
}
}
client
:=
NewRESTClient
(
baseURL
,
versionedAPIPath
,
config
.
ContentConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
return
NewRESTClient
(
baseURL
,
versionedAPIPath
,
config
.
ContentConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
return
client
,
nil
}
}
// UnversionedRESTClientFor is the same as RESTClientFor, except that it allows
// UnversionedRESTClientFor is the same as RESTClientFor, except that it allows
// the config.Version to be empty.
// the config.Version to be empty.
func
UnversionedRESTClientFor
(
config
*
Config
)
(
*
RESTClient
,
error
)
{
func
UnversionedRESTClientFor
(
config
*
Config
)
(
*
RESTClient
,
error
)
{
if
config
.
Codec
==
nil
{
if
config
.
NegotiatedSerializer
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
Codec
is required when initializing a RESTClient"
)
return
nil
,
fmt
.
Errorf
(
"
NeogitatedSerializer
is required when initializing a RESTClient"
)
}
}
baseURL
,
versionedAPIPath
,
err
:=
defaultServerUrlFor
(
config
)
baseURL
,
versionedAPIPath
,
err
:=
defaultServerUrlFor
(
config
)
...
@@ -196,8 +200,7 @@ func UnversionedRESTClientFor(config *Config) (*RESTClient, error) {
...
@@ -196,8 +200,7 @@ func UnversionedRESTClientFor(config *Config) (*RESTClient, error) {
versionConfig
.
GroupVersion
=
&
v
versionConfig
.
GroupVersion
=
&
v
}
}
client
:=
NewRESTClient
(
baseURL
,
versionedAPIPath
,
versionConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
return
NewRESTClient
(
baseURL
,
versionedAPIPath
,
versionConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
return
client
,
nil
}
}
// SetKubernetesDefaults sets default values on the provided client config for accessing the
// SetKubernetesDefaults sets default values on the provided client config for accessing the
...
...
pkg/client/restclient/config_test.go
View file @
b4c83022
...
@@ -87,13 +87,13 @@ func TestSetKubernetesDefaultsUserAgent(t *testing.T) {
...
@@ -87,13 +87,13 @@ func TestSetKubernetesDefaultsUserAgent(t *testing.T) {
}
}
func
TestRESTClientRequires
(
t
*
testing
.
T
)
{
func
TestRESTClientRequires
(
t
*
testing
.
T
)
{
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
Codec
:
testapi
.
Default
.
Codec
()
}});
err
==
nil
{
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
NegotiatedSerializer
:
testapi
.
NegotiatedSerializer
}});
err
==
nil
{
t
.
Errorf
(
"unexpected non-error"
)
t
.
Errorf
(
"unexpected non-error"
)
}
}
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}});
err
==
nil
{
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}});
err
==
nil
{
t
.
Errorf
(
"unexpected non-error"
)
t
.
Errorf
(
"unexpected non-error"
)
}
}
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
Codec
:
testapi
.
Default
.
Codec
()
}});
err
!=
nil
{
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
NegotiatedSerializer
:
testapi
.
NegotiatedSerializer
}});
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
}
}
pkg/client/restclient/request_test.go
View file @
b4c83022
...
@@ -1308,5 +1308,9 @@ func testRESTClient(t testing.TB, srv *httptest.Server) *RESTClient {
...
@@ -1308,5 +1308,9 @@ func testRESTClient(t testing.TB, srv *httptest.Server) *RESTClient {
}
}
}
}
versionedAPIPath
:=
testapi
.
Default
.
ResourcePath
(
""
,
""
,
""
)
versionedAPIPath
:=
testapi
.
Default
.
ResourcePath
(
""
,
""
,
""
)
return
NewRESTClient
(
baseURL
,
versionedAPIPath
,
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
Codec
:
testapi
.
Default
.
Codec
()},
0
,
0
,
nil
,
nil
)
client
,
err
:=
NewRESTClient
(
baseURL
,
versionedAPIPath
,
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
Codec
:
testapi
.
Default
.
Codec
()},
0
,
0
,
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create a client: %v"
,
err
)
}
return
client
}
}
pkg/client/unversioned/apps.go
View file @
b4c83022
...
@@ -72,6 +72,7 @@ func setAppsDefaults(config *restclient.Config) error {
...
@@ -72,6 +72,7 @@ func setAppsDefaults(config *restclient.Config) error {
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/unversioned/autoscaling.go
View file @
b4c83022
...
@@ -73,6 +73,7 @@ func setAutoscalingDefaults(config *restclient.Config) error {
...
@@ -73,6 +73,7 @@ func setAutoscalingDefaults(config *restclient.Config) error {
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/unversioned/batch.go
View file @
b4c83022
...
@@ -73,6 +73,7 @@ func setBatchDefaults(config *restclient.Config) error {
...
@@ -73,6 +73,7 @@ func setBatchDefaults(config *restclient.Config) error {
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/unversioned/extensions.go
View file @
b4c83022
...
@@ -127,6 +127,7 @@ func setExtensionsDefaults(config *restclient.Config) error {
...
@@ -127,6 +127,7 @@ func setExtensionsDefaults(config *restclient.Config) error {
//}
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
if
config
.
QPS
==
0
{
config
.
QPS
=
5
config
.
QPS
=
5
}
}
...
...
pkg/client/unversioned/helper.go
View file @
b4c83022
...
@@ -231,6 +231,9 @@ func SetKubernetesDefaults(config *restclient.Config) error {
...
@@ -231,6 +231,9 @@ func SetKubernetesDefaults(config *restclient.Config) error {
// TODO: Unconditionally set the config.Version, until we fix the config.
// TODO: Unconditionally set the config.Version, until we fix the config.
copyGroupVersion
:=
g
.
GroupVersion
copyGroupVersion
:=
g
.
GroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
if
config
.
NegotiatedSerializer
==
nil
{
config
.
NegotiatedSerializer
=
api
.
Codecs
}
if
config
.
Codec
==
nil
{
if
config
.
Codec
==
nil
{
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
}
}
...
...
pkg/client/unversioned/helper_test.go
View file @
b4c83022
...
@@ -40,8 +40,9 @@ func TestSetKubernetesDefaults(t *testing.T) {
...
@@ -40,8 +40,9 @@ func TestSetKubernetesDefaults(t *testing.T) {
restclient
.
Config
{
restclient
.
Config
{
APIPath
:
"/api"
,
APIPath
:
"/api"
,
ContentConfig
:
restclient
.
ContentConfig
{
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
Codec
:
testapi
.
Default
.
Codec
(),
Codec
:
testapi
.
Default
.
Codec
(),
NegotiatedSerializer
:
testapi
.
NegotiatedSerializer
,
},
},
QPS
:
5
,
QPS
:
5
,
Burst
:
10
,
Burst
:
10
,
...
@@ -125,7 +126,7 @@ func TestHelperGetServerAPIVersions(t *testing.T) {
...
@@ -125,7 +126,7 @@ func TestHelperGetServerAPIVersions(t *testing.T) {
w
.
Write
(
output
)
w
.
Write
(
output
)
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
got
,
err
:=
restclient
.
ServerAPIVersions
(
&
restclient
.
Config
{
Host
:
server
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
unversioned
.
GroupVersion
{
Group
:
"invalid version"
,
Version
:
"one"
},
Codec
:
testapi
.
Default
.
Codec
()
}})
got
,
err
:=
restclient
.
ServerAPIVersions
(
&
restclient
.
Config
{
Host
:
server
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
&
unversioned
.
GroupVersion
{
Group
:
"invalid version"
,
Version
:
"one"
},
NegotiatedSerializer
:
testapi
.
NegotiatedSerializer
}})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected encoding error: %v"
,
err
)
t
.
Fatalf
(
"unexpected encoding error: %v"
,
err
)
}
}
...
...
pkg/client/unversioned/remotecommand/remotecommand_test.go
View file @
b4c83022
...
@@ -212,7 +212,10 @@ func TestStream(t *testing.T) {
...
@@ -212,7 +212,10 @@ func TestStream(t *testing.T) {
server
:=
httptest
.
NewServer
(
fakeServer
(
t
,
name
,
exec
,
testCase
.
Stdin
,
testCase
.
Stdout
,
testCase
.
Stderr
,
testCase
.
Error
,
testCase
.
Tty
,
testCase
.
MessageCount
,
testCase
.
ServerProtocols
))
server
:=
httptest
.
NewServer
(
fakeServer
(
t
,
name
,
exec
,
testCase
.
Stdin
,
testCase
.
Stdout
,
testCase
.
Stderr
,
testCase
.
Error
,
testCase
.
Tty
,
testCase
.
MessageCount
,
testCase
.
ServerProtocols
))
url
,
_
:=
url
.
ParseRequestURI
(
server
.
URL
)
url
,
_
:=
url
.
ParseRequestURI
(
server
.
URL
)
c
:=
restclient
.
NewRESTClient
(
url
,
""
,
restclient
.
ContentConfig
{
GroupVersion
:
&
unversioned
.
GroupVersion
{
Group
:
"x"
}},
-
1
,
-
1
,
nil
,
nil
)
c
,
err
:=
restclient
.
NewRESTClient
(
url
,
""
,
restclient
.
ContentConfig
{
GroupVersion
:
&
unversioned
.
GroupVersion
{
Group
:
"x"
}},
-
1
,
-
1
,
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create a client: %v"
,
err
)
}
req
:=
c
.
Post
()
.
Resource
(
"testing"
)
req
:=
c
.
Post
()
.
Resource
(
"testing"
)
if
exec
{
if
exec
{
...
...
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