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
d9ce524d
Commit
d9ce524d
authored
Aug 04, 2016
by
Kris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose dynamic client's content config
parent
79ed7064
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
client.go
pkg/client/typed/dynamic/client.go
+18
-7
No files found.
pkg/client/typed/dynamic/client.go
View file @
d9ce524d
...
@@ -55,9 +55,12 @@ func NewClient(conf *restclient.Config) (*Client, error) {
...
@@ -55,9 +55,12 @@ func NewClient(conf *restclient.Config) (*Client, error) {
confCopy
:=
*
conf
confCopy
:=
*
conf
conf
=
&
confCopy
conf
=
&
confCopy
// TODO: it's questionable that this should be using anything other than unstructured schema and JSON
contentConfig
:=
ContentConfig
()
conf
.
ContentType
=
runtime
.
ContentTypeJSON
contentConfig
.
GroupVersion
=
conf
.
GroupVersion
conf
.
AcceptContentTypes
=
runtime
.
ContentTypeJSON
if
conf
.
NegotiatedSerializer
!=
nil
{
contentConfig
.
NegotiatedSerializer
=
conf
.
NegotiatedSerializer
}
conf
.
ContentConfig
=
contentConfig
if
conf
.
APIPath
==
""
{
if
conf
.
APIPath
==
""
{
conf
.
APIPath
=
"/api"
conf
.
APIPath
=
"/api"
...
@@ -66,10 +69,6 @@ func NewClient(conf *restclient.Config) (*Client, error) {
...
@@ -66,10 +69,6 @@ func NewClient(conf *restclient.Config) (*Client, error) {
if
len
(
conf
.
UserAgent
)
==
0
{
if
len
(
conf
.
UserAgent
)
==
0
{
conf
.
UserAgent
=
restclient
.
DefaultKubernetesUserAgent
()
conf
.
UserAgent
=
restclient
.
DefaultKubernetesUserAgent
()
}
}
if
conf
.
NegotiatedSerializer
==
nil
{
streamingInfo
,
_
:=
api
.
Codecs
.
StreamingSerializerForMediaType
(
"application/json;stream=watch"
,
nil
)
conf
.
NegotiatedSerializer
=
serializer
.
NegotiatedSerializerWrapper
(
runtime
.
SerializerInfo
{
Serializer
:
dynamicCodec
{}},
streamingInfo
)
}
cl
,
err
:=
restclient
.
RESTClientFor
(
conf
)
cl
,
err
:=
restclient
.
RESTClientFor
(
conf
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -255,6 +254,18 @@ func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
...
@@ -255,6 +254,18 @@ func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
return
runtime
.
UnstructuredJSONScheme
.
Encode
(
obj
,
w
)
return
runtime
.
UnstructuredJSONScheme
.
Encode
(
obj
,
w
)
}
}
// ContentConfig returns a restclient.ContentConfig for dynamic types.
func
ContentConfig
()
restclient
.
ContentConfig
{
// TODO: it's questionable that this should be using anything other than unstructured schema and JSON
codec
:=
dynamicCodec
{}
streamingInfo
,
_
:=
api
.
Codecs
.
StreamingSerializerForMediaType
(
"application/json;stream=watch"
,
nil
)
return
restclient
.
ContentConfig
{
AcceptContentTypes
:
runtime
.
ContentTypeJSON
,
ContentType
:
runtime
.
ContentTypeJSON
,
NegotiatedSerializer
:
serializer
.
NegotiatedSerializerWrapper
(
runtime
.
SerializerInfo
{
Serializer
:
codec
},
streamingInfo
),
}
}
// paramaterCodec is a codec converts an API object to query
// paramaterCodec is a codec converts an API object to query
// parameters without trying to convert to the target version.
// parameters without trying to convert to the target version.
type
parameterCodec
struct
{}
type
parameterCodec
struct
{}
...
...
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