mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-26 07:02:01 +00:00
Refactor loops over SupportedMediaTypes() where mediaType is used to match a single SerializerInfo{}
We have an existing helper function for this: runtime.SerializerInfoForMediaType() This is common prep-work for encoding runtime.Objects into JSON/YAML for transmission over the wire or writing to ComponentConfigs. Kubernetes-commit: 47e52d2981dc2a5c5950042f50688cf24dd92eda
This commit is contained in:
parent
95d8a92c48
commit
6c6c98c9ca
@ -59,15 +59,9 @@ func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
|
|||||||
// ContentConfig returns a rest.ContentConfig for dynamic types.
|
// ContentConfig returns a rest.ContentConfig for dynamic types.
|
||||||
// Deprecated only used by test code and its wrong
|
// Deprecated only used by test code and its wrong
|
||||||
func ContentConfig() rest.ContentConfig {
|
func ContentConfig() rest.ContentConfig {
|
||||||
var jsonInfo runtime.SerializerInfo
|
|
||||||
// TODO: scheme.Codecs here should become "pkg/apis/server/scheme" which is the minimal core you need
|
// TODO: scheme.Codecs here should become "pkg/apis/server/scheme" which is the minimal core you need
|
||||||
// to talk to a kubernetes server
|
// to talk to a kubernetes server
|
||||||
for _, info := range scheme.Codecs.SupportedMediaTypes() {
|
jsonInfo, _ := runtime.SerializerInfoForMediaType(scheme.Codecs.SupportedMediaTypes(), runtime.ContentTypeJSON)
|
||||||
if info.MediaType == runtime.ContentTypeJSON {
|
|
||||||
jsonInfo = info
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonInfo.Serializer = dynamicCodec{}
|
jsonInfo.Serializer = dynamicCodec{}
|
||||||
jsonInfo.PrettySerializer = nil
|
jsonInfo.PrettySerializer = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user