Skip to content

Commit 7268193

Browse files
alvaroalemaniawia002
authored andcommitted
🐛 Unconditionally set NegotiatedSerializer
We currently only set the NegotiatedSerializer when there is none set yet. Unfortunately, various things will break if someone sets their own in the rest config, hence always set it.
1 parent 2d2f85f commit 7268193

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/client/apiutil/apimachinery.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,12 @@ func createRestConfig(gvk schema.GroupVersionKind, isUnstructured bool, baseConf
157157
protobufSchemeLock.RUnlock()
158158
}
159159

160-
if cfg.NegotiatedSerializer == nil {
161-
if isUnstructured {
162-
// If the object is unstructured, we need to preserve the GVK information.
163-
// Use our own custom serializer.
164-
cfg.NegotiatedSerializer = serializerWithDecodedGVK{serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
165-
} else {
166-
cfg.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: codecs}
167-
}
160+
if isUnstructured {
161+
// If the object is unstructured, we need to preserve the GVK information.
162+
// Use our own custom serializer.
163+
cfg.NegotiatedSerializer = serializerWithDecodedGVK{serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
164+
} else {
165+
cfg.NegotiatedSerializer = serializerWithTargetZeroingDecode{NegotiatedSerializer: serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
168166
}
169167

170168
return cfg

0 commit comments

Comments
 (0)