Skip to content

Commit 7ba0932

Browse files
committed
fix(client): support custom negotiated serializer
The Kubernetes client allows for users to configure a serializer which is used to encode and decode resources exchanged with the Kubernetes API server. This changeset modifies the controller-runtime client to only set the default serializer if the NegotiatedSerializer option is nil. Signed-off-by: Terin Stock <[email protected]>
1 parent 962ab1f commit 7ba0932

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)