serializer

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var YurtHubSerializer = NewSerializerManager()

YurtHubSerializer is a global serializer manager for yurthub

Functions

func NewUnstructuredCreator

func NewUnstructuredCreator() runtime.ObjectCreater

NewUnstructuredCreator returns a simple object creator that always returns an Unstructured or UnstructuredList

func NewUnstructuredNegotiatedSerializer

func NewUnstructuredNegotiatedSerializer() runtime.NegotiatedSerializer

NewUnstructuredNegotiatedSerializer returns a negotiated serializer for Unstructured resources

Types

type Serializer

type Serializer struct {
	runtime.ClientNegotiator
	// contains filtered or unexported fields
}

Serializer is used for transforming objects into a serialized format and back for cache manager of hub agent.

func (*Serializer) Decode

func (s *Serializer) Decode(b []byte) (runtime.Object, error)

Decode decodes byte data into runtime object with embedded contentType.

func (*Serializer) Encode added in v0.4.1

func (s *Serializer) Encode(obj runtime.Object) ([]byte, error)

Encode encode object and return bytes of it.

func (*Serializer) WatchDecoder

func (s *Serializer) WatchDecoder(body io.ReadCloser) (*restclientwatch.Decoder, error)

WatchDecoder generates a Decoder for decoding response of watch request.

func (*Serializer) WatchEncode

func (s *Serializer) WatchEncode(w io.Writer, event *watch.Event) (int, error)

WatchEncode writes watch event to provided io.Writer

type SerializerManager

type SerializerManager struct {
	sync.Mutex
	// NegotiatedSerializer is used for obtaining encoders and decoders for multiple
	// supported media types.
	NegotiatedSerializer runtime.NegotiatedSerializer
	// UnstructuredNegotiatedSerializer is used to obtain encoders and decoders
	// for resources not registered in the scheme
	UnstructuredNegotiatedSerializer runtime.NegotiatedSerializer
	// ClientNegotiators includes all of ClientNegotiators by GroupVersionResource
	ClientNegotiators map[schema.GroupVersionResource]*yurtClientNegotiator
	// WatchEventClientNegotiator is a ClientNegotiators for WatchEvent
	WatchEventClientNegotiator runtime.ClientNegotiator
}

SerializerManager is responsible for managing *rest.Serializers

func NewSerializerManager

func NewSerializerManager() *SerializerManager

NewSerializerManager creates a *SerializerManager object with no version conversion

func (*SerializerManager) CreateSerializer

func (sm *SerializerManager) CreateSerializer(contentType, group, version, resource string) *Serializer

CreateSerializer will returns a Serializer object for encoding or decoding runtime object.

func (*SerializerManager) GetNegotiatedSerializer

GetNegotiatedSerializer returns an NegotiatedSerializer object based on GroupVersionResource

type UnstructuredNegotiatedSerializer

type UnstructuredNegotiatedSerializer struct {
	// contains filtered or unexported fields
}

func (UnstructuredNegotiatedSerializer) DecoderToVersion

DecoderToVersion do nothing, and returns a decoder that does not do conversion

func (UnstructuredNegotiatedSerializer) EncoderForVersion

EncoderForVersion do nothing, but returns a encoder, if the object is unstructured, the encoder will encode object without conversion

func (UnstructuredNegotiatedSerializer) SupportedMediaTypes

func (s UnstructuredNegotiatedSerializer) SupportedMediaTypes() []runtime.SerializerInfo

type WithVersionCodecFactory

type WithVersionCodecFactory struct {
	serializer.CodecFactory
}

WithVersionCodecFactory is a CodecFactory that will explicitly ignore requests to perform conversion. It keeps the gvk during deserialization. This wrapper is used while code migrates away from using conversion (such as external clients)

func (WithVersionCodecFactory) DecoderToVersion

func (f WithVersionCodecFactory) DecoderToVersion(serializer runtime.Decoder, _ runtime.GroupVersioner) runtime.Decoder

DecoderToVersion returns an decoder that does not do conversion, and keeps the gvk information

func (WithVersionCodecFactory) EncoderForVersion

func (f WithVersionCodecFactory) EncoderForVersion(serializer runtime.Encoder, version runtime.GroupVersioner) runtime.Encoder

EncoderForVersion returns an encoder that does not do conversion, but does set the group version kind of the object when serialized.

type WithVersionDecoder

type WithVersionDecoder struct {
	runtime.Decoder
}

WithVersionDecoder keeps the group version kind of a deserialized object.

func (WithVersionDecoder) Decode

Decode does not do conversion. It keeps the gvk during deserialization.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL