Skip to content

Commit

Permalink
🐛 Unconditionally set NegotiatedSerializer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alvaroaleman committed Sep 13, 2021
1 parent 386c2b5 commit 8100b57
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/client/apiutil/apimachinery.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,12 @@ func createRestConfig(gvk schema.GroupVersionKind, isUnstructured bool, baseConf
protobufSchemeLock.RUnlock()
}

if cfg.NegotiatedSerializer == nil {
if isUnstructured {
// If the object is unstructured, we need to preserve the GVK information.
// Use our own custom serializer.
cfg.NegotiatedSerializer = serializerWithDecodedGVK{serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
} else {
cfg.NegotiatedSerializer = serializerWithTargetZeroingDecode{NegotiatedSerializer: serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
}
if isUnstructured {
// If the object is unstructured, we need to preserve the GVK information.
// Use our own custom serializer.
cfg.NegotiatedSerializer = serializerWithDecodedGVK{serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
} else {
cfg.NegotiatedSerializer = serializerWithTargetZeroingDecode{NegotiatedSerializer: serializer.WithoutConversionCodecFactory{CodecFactory: codecs}}
}

return cfg
Expand Down

0 comments on commit 8100b57

Please sign in to comment.