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 {
config.GroupVersion = ©GroupVersion
//}
config.Codec = $.codecs|raw$.LegacyCodec(*config.GroupVersion)
config.NegotiatedSerializer = $.codecs|raw$
if config.QPS == 0 {
config.QPS = 5
}
...
...
@@ -232,11 +233,7 @@ func setConfigDefaults(config *$.Config|raw$) error {
config.GroupVersion = ©GroupVersion
//}
codec, ok := $.codecs|raw$.SerializerForFileExtension("json")
if !ok {
return $.Errorf|raw$("unable to find serializer for JSON")
}
config.Codec = codec
config.NegotiatedSerializer = $.codecs|raw$
if config.QPS == 0 {
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 {
config
.
GroupVersion
=
&
copyGroupVersion
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
config
.
QPS
=
5
}
...
...
pkg/api/testapi/testapi.go
View file @
b4c83022
...
...
@@ -45,13 +45,14 @@ import (
)
var
(
Groups
=
make
(
map
[
string
]
TestGroup
)
Default
TestGroup
Autoscaling
TestGroup
Batch
TestGroup
Extensions
TestGroup
Apps
TestGroup
Federation
TestGroup
Groups
=
make
(
map
[
string
]
TestGroup
)
Default
TestGroup
Autoscaling
TestGroup
Batch
TestGroup
Extensions
TestGroup
Apps
TestGroup
Federation
TestGroup
NegotiatedSerializer
=
api
.
Codecs
)
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 {
config
.
GroupVersion
=
&
copyGroupVersion
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
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 {
config
.
GroupVersion
=
&
copyGroupVersion
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
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 {
config
.
GroupVersion
=
&
copyGroupVersion
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
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 {
config
.
GroupVersion
=
&
copyGroupVersion
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
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 {
config
.
GroupVersion
=
&
copyGroupVersion
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
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.
package
v1
import
(
fmt
"fmt"
api
"k8s.io/kubernetes/pkg/api"
registered
"k8s.io/kubernetes/pkg/apimachinery/registered"
restclient
"k8s.io/kubernetes/pkg/client/restclient"
...
...
@@ -150,11 +149,7 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
//}
codec
,
ok
:=
api
.
Codecs
.
SerializerForFileExtension
(
"json"
)
if
!
ok
{
return
fmt
.
Errorf
(
"unable to find serializer for JSON"
)
}
config
.
Codec
=
codec
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
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.
package
v1beta1
import
(
fmt
"fmt"
api
"k8s.io/kubernetes/pkg/api"
registered
"k8s.io/kubernetes/pkg/apimachinery/registered"
restclient
"k8s.io/kubernetes/pkg/client/restclient"
...
...
@@ -115,11 +114,7 @@ func setConfigDefaults(config *restclient.Config) error {
config
.
GroupVersion
=
&
copyGroupVersion
//}
codec
,
ok
:=
api
.
Codecs
.
SerializerForFileExtension
(
"json"
)
if
!
ok
{
return
fmt
.
Errorf
(
"unable to find serializer for JSON"
)
}
config
.
Codec
=
codec
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
config
.
QPS
=
5
...
...
pkg/client/restclient/client.go
View file @
b4c83022
...
...
@@ -63,7 +63,7 @@ type RESTClient struct {
// 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
// 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
if
!
strings
.
HasSuffix
(
base
.
Path
,
"/"
)
{
base
.
Path
+=
"/"
...
...
@@ -90,7 +90,7 @@ func NewRESTClient(baseURL *url.URL, versionedAPIPath string, config ContentConf
contentConfig
:
config
,
Throttle
:
throttle
,
Client
:
client
,
}
}
,
nil
}
// 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 {
// Verb begins a request with a verb (GET, POST, PUT, DELETE).
//
// Example usage of RESTClient's request building interface:
// c := NewRESTClient(url, codec)
// c, err := NewRESTClient(...)
// if err != nil { ... }
// resp, err := c.Verb("GET").
// Path("pods").
// SelectorParam("labels", "area=staging").
...
...
pkg/client/restclient/config.go
View file @
b4c83022
...
...
@@ -130,9 +130,15 @@ type ContentConfig struct {
// a RESTClient directly. When initializing a Client, will be set with the default
// code version.
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
// to a RESTClient or Client. Required when initializing a RESTClient, optional
// when initializing a Client.
//
// DEPRECATED: Please use NegotiatedSerializer instead.
Codec
runtime
.
Codec
}
...
...
@@ -144,8 +150,8 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
if
config
.
GroupVersion
==
nil
{
return
nil
,
fmt
.
Errorf
(
"GroupVersion is required when initializing a RESTClient"
)
}
if
config
.
Codec
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
Codec
is required when initializing a RESTClient"
)
if
config
.
NegotiatedSerializer
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
NegotiatedSerializer
is required when initializing a RESTClient"
)
}
baseURL
,
versionedAPIPath
,
err
:=
defaultServerUrlFor
(
config
)
...
...
@@ -163,16 +169,14 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
httpClient
=
&
http
.
Client
{
Transport
:
transport
}
}
client
:=
NewRESTClient
(
baseURL
,
versionedAPIPath
,
config
.
ContentConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
return
client
,
nil
return
NewRESTClient
(
baseURL
,
versionedAPIPath
,
config
.
ContentConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
}
// UnversionedRESTClientFor is the same as RESTClientFor, except that it allows
// the config.Version to be empty.
func
UnversionedRESTClientFor
(
config
*
Config
)
(
*
RESTClient
,
error
)
{
if
config
.
Codec
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
Codec
is required when initializing a RESTClient"
)
if
config
.
NegotiatedSerializer
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
NeogitatedSerializer
is required when initializing a RESTClient"
)
}
baseURL
,
versionedAPIPath
,
err
:=
defaultServerUrlFor
(
config
)
...
...
@@ -196,8 +200,7 @@ func UnversionedRESTClientFor(config *Config) (*RESTClient, error) {
versionConfig
.
GroupVersion
=
&
v
}
client
:=
NewRESTClient
(
baseURL
,
versionedAPIPath
,
versionConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
return
client
,
nil
return
NewRESTClient
(
baseURL
,
versionedAPIPath
,
versionConfig
,
config
.
QPS
,
config
.
Burst
,
config
.
RateLimiter
,
httpClient
)
}
// 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) {
}
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"
)
}
if
_
,
err
:=
RESTClientFor
(
&
Config
{
Host
:
"127.0.0.1"
,
ContentConfig
:
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}});
err
==
nil
{
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
)
}
}
pkg/client/restclient/request_test.go
View file @
b4c83022
...
...
@@ -1308,5 +1308,9 @@ func testRESTClient(t testing.TB, srv *httptest.Server) *RESTClient {
}
}
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 {
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
config
.
QPS
=
5
}
...
...
pkg/client/unversioned/autoscaling.go
View file @
b4c83022
...
...
@@ -73,6 +73,7 @@ func setAutoscalingDefaults(config *restclient.Config) error {
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
config
.
QPS
=
5
}
...
...
pkg/client/unversioned/batch.go
View file @
b4c83022
...
...
@@ -73,6 +73,7 @@ func setBatchDefaults(config *restclient.Config) error {
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
config
.
QPS
=
5
}
...
...
pkg/client/unversioned/extensions.go
View file @
b4c83022
...
...
@@ -127,6 +127,7 @@ func setExtensionsDefaults(config *restclient.Config) error {
//}
config
.
Codec
=
api
.
Codecs
.
LegacyCodec
(
*
config
.
GroupVersion
)
config
.
NegotiatedSerializer
=
api
.
Codecs
if
config
.
QPS
==
0
{
config
.
QPS
=
5
}
...
...
pkg/client/unversioned/helper.go
View file @
b4c83022
...
...
@@ -231,6 +231,9 @@ func SetKubernetesDefaults(config *restclient.Config) error {
// TODO: Unconditionally set the config.Version, until we fix the config.
copyGroupVersion
:=
g
.
GroupVersion
config
.
GroupVersion
=
&
copyGroupVersion
if
config
.
NegotiatedSerializer
==
nil
{
config
.
NegotiatedSerializer
=
api
.
Codecs
}
if
config
.
Codec
==
nil
{
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) {
restclient
.
Config
{
APIPath
:
"/api"
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
Codec
:
testapi
.
Default
.
Codec
(),
GroupVersion
:
testapi
.
Default
.
GroupVersion
(),
Codec
:
testapi
.
Default
.
Codec
(),
NegotiatedSerializer
:
testapi
.
NegotiatedSerializer
,
},
QPS
:
5
,
Burst
:
10
,
...
...
@@ -125,7 +126,7 @@ func TestHelperGetServerAPIVersions(t *testing.T) {
w
.
Write
(
output
)
}))
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
{
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) {
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
)
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"
)
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