Skip to content

Commit 742c722

Browse files
authored
Merge pull request #382 from terinjokes/patches/client-serializer
✨ support custom negotiated serializer 🐛
2 parents 962ab1f + 7ba0932 commit 742c722

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/client/apiutil/apimachinery.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi
6666
}
6767

6868
// RESTClientForGVK constructs a new rest.Interface capable of accessing the resource associated
69-
// with the given GroupVersionKind.
69+
// with the given GroupVersionKind. The REST client will be configured to use the negotiated serializer from
70+
// baseConfig, if set, otherwise a default serializer will be set.
7071
func RESTClientForGVK(gvk schema.GroupVersionKind, baseConfig *rest.Config, codecs serializer.CodecFactory) (rest.Interface, error) {
7172
cfg := createRestConfig(gvk, baseConfig)
72-
cfg.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: codecs}
73+
if cfg.NegotiatedSerializer == nil {
74+
cfg.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: codecs}
75+
}
7376
return rest.RESTClientFor(cfg)
7477
}
7578

0 commit comments

Comments
 (0)