negotiated_codec.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package serializer
  14. import (
  15. "k8s.io/kubernetes/pkg/runtime"
  16. )
  17. // TODO: We should figure out what happens when someone asks
  18. // encoder for version and it conflicts with the raw serializer.
  19. type negotiatedSerializerWrapper struct {
  20. info runtime.SerializerInfo
  21. streamInfo runtime.StreamSerializerInfo
  22. }
  23. func NegotiatedSerializerWrapper(info runtime.SerializerInfo, streamInfo runtime.StreamSerializerInfo) runtime.NegotiatedSerializer {
  24. return &negotiatedSerializerWrapper{info, streamInfo}
  25. }
  26. func (n *negotiatedSerializerWrapper) SupportedMediaTypes() []string {
  27. return []string{}
  28. }
  29. func (n *negotiatedSerializerWrapper) SerializerForMediaType(mediaType string, options map[string]string) (runtime.SerializerInfo, bool) {
  30. return n.info, true
  31. }
  32. func (n *negotiatedSerializerWrapper) SupportedStreamingMediaTypes() []string {
  33. return []string{}
  34. }
  35. func (n *negotiatedSerializerWrapper) StreamingSerializerForMediaType(mediaType string, options map[string]string) (runtime.StreamSerializerInfo, bool) {
  36. return n.streamInfo, true
  37. }
  38. func (n *negotiatedSerializerWrapper) EncoderForVersion(e runtime.Encoder, _ runtime.GroupVersioner) runtime.Encoder {
  39. return e
  40. }
  41. func (n *negotiatedSerializerWrapper) DecoderToVersion(d runtime.Decoder, _gv runtime.GroupVersioner) runtime.Decoder {
  42. return d
  43. }