@@ -21,6 +21,7 @@ package apiutil
21
21
22
22
import (
23
23
"fmt"
24
+ "reflect"
24
25
"sync"
25
26
26
27
"k8s.io/apimachinery/pkg/api/meta"
@@ -117,7 +118,7 @@ func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi
117
118
// RESTClientForGVK constructs a new rest.Interface capable of accessing the resource associated
118
119
// with the given GroupVersionKind. The REST client will be configured to use the negotiated serializer from
119
120
// baseConfig, if set, otherwise a default serializer will be set.
120
- func RESTClientForGVK (gvk schema.GroupVersionKind , isUnstructured bool , baseConfig * rest.Config , codecs serializer.CodecFactory ) (rest.Interface , error ) {
121
+ func RESTClientForGVK (scheme * runtime. Scheme , gvk schema.GroupVersionKind , isUnstructured bool , baseConfig * rest.Config , codecs serializer.CodecFactory ) (rest.Interface , error ) {
121
122
return rest .RESTClientFor (createRestConfig (gvk , isUnstructured , baseConfig , codecs ))
122
123
}
123
124
@@ -134,6 +135,12 @@ func (f serializerWithDecodedGVK) DecoderToVersion(serializer runtime.Decoder, _
134
135
return serializer
135
136
}
136
137
138
+ type protoMessage interface {
139
+ ProtoMessage ()
140
+ }
141
+
142
+ var protoMessageType = reflect .TypeOf (new (protoMessage )).Elem ()
143
+
137
144
// createRestConfig copies the base config and updates needed fields for a new rest config.
138
145
func createRestConfig (gvk schema.GroupVersionKind , isUnstructured bool , baseConfig * rest.Config , codecs serializer.CodecFactory ) * rest.Config {
139
146
gv := gvk .GroupVersion ()
@@ -149,13 +156,14 @@ func createRestConfig(gvk schema.GroupVersionKind, isUnstructured bool, baseConf
149
156
cfg .UserAgent = rest .DefaultKubernetesUserAgent ()
150
157
}
151
158
// TODO(FillZpp): In the long run, we want to check discovery or something to make sure that this is actually true.
152
- if cfg .ContentType == "" && ! isUnstructured {
153
- protobufSchemeLock .RLock ()
154
- if protobufScheme .Recognizes (gvk ) {
155
- cfg .ContentType = runtime .ContentTypeProtobuf
156
- }
157
- protobufSchemeLock .RUnlock ()
158
- }
159
+ // if cfg.ContentType == "" && !isUnstructured {
160
+ // protobufSchemeLock.RLock()
161
+ // gvkType, found := protobufScheme.AllKnownTypes()[gvk]
162
+ // if found && gvkType.Implements(protoMessageType) {
163
+ // cfg.ContentType = runtime.ContentTypeProtobuf
164
+ // }
165
+ // protobufSchemeLock.RUnlock()
166
+ // }
159
167
160
168
if cfg .NegotiatedSerializer == nil {
161
169
if isUnstructured {
0 commit comments