Skip to content

Commit

Permalink
Merge pull request #382 from terinjokes/patches/client-serializer
Browse files Browse the repository at this point in the history
✨ support custom negotiated serializer 🐛
  • Loading branch information
k8s-ci-robot authored Apr 8, 2019
2 parents 962ab1f + 7ba0932 commit 742c722
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/client/apiutil/apimachinery.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi
}

// RESTClientForGVK constructs a new rest.Interface capable of accessing the resource associated
// with the given GroupVersionKind.
// with the given GroupVersionKind. The REST client will be configured to use the negotiated serializer from
// baseConfig, if set, otherwise a default serializer will be set.
func RESTClientForGVK(gvk schema.GroupVersionKind, baseConfig *rest.Config, codecs serializer.CodecFactory) (rest.Interface, error) {
cfg := createRestConfig(gvk, baseConfig)
cfg.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: codecs}
if cfg.NegotiatedSerializer == nil {
cfg.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: codecs}
}
return rest.RESTClientFor(cfg)
}

Expand Down

0 comments on commit 742c722

Please sign in to comment.