runtime

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 13 Imported by: 13

Documentation

Index

Constants

View Source
const ATTR_TYPE = "type"
View Source
const VersionSeparator = "/"

Variables

View Source
var DefaultYAMLEncoding = &EncodingWrapper{
	Marshaler:   MarshalFunction(yaml.Marshal),
	Unmarshaler: UnmarshalFunction(func(data []byte, obj interface{}) error { return yaml.Unmarshal(data, obj) }),
}

Functions

func KindNames

func KindNames(scheme Scheme) []string

func KindVersion

func KindVersion(t string) (string, string)

func MustProtoType

func MustProtoType(proto interface{}) reflect.Type

func ProtoType

func ProtoType(proto interface{}) (reflect.Type, error)

func RegisterByType

func RegisterByType(s Scheme, typ string, proto TypedObject) error

func TypeName

func TypeName(args ...string) string

func TypeNames

func TypeNames(scheme Scheme) []string

func TypedObjectEqual

func TypedObjectEqual(a, b TypedObject) bool

TypedObjectEqual compares two typed objects using the unstructured type.

func TypedObjectFactory

func TypedObjectFactory(proto TypedObject) func() TypedObject

func UnstructuredTypesEqual

func UnstructuredTypesEqual(a, b *UnstructuredTypedObject) bool

UnstructuredTypesEqual compares two unstructured object.

func Validate

func Validate(o interface{}) error

Types

type BaseScheme

type BaseScheme interface {
	BaseScheme() Scheme
}

type Binary

type Binary []byte

Binary holds binary data which will be marshaled a base64 encoded string. If the string starts with a '!', the data is used as string byte sequence.

func (Binary) MarshalJSON

func (m Binary) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (*Binary) UnmarshalJSON

func (m *Binary) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type ConvertingDecoder

type ConvertingDecoder struct {
	TypedObjectConverter
	// contains filtered or unexported fields
}

ConvertingDecoder uses a serialization from different from the intended object type, that is converted to achieve the decode result.

func MustNewConvertingDecoder

func MustNewConvertingDecoder(proto interface{}, conv TypedObjectConverter) *ConvertingDecoder

func NewConvertingDecoder

func NewConvertingDecoder(proto interface{}, conv TypedObjectConverter) (*ConvertingDecoder, error)

func (*ConvertingDecoder) CreateData

func (d *ConvertingDecoder) CreateData() interface{}

func (*ConvertingDecoder) Decode

func (d *ConvertingDecoder) Decode(data []byte, unmarshaler Unmarshaler) (TypedObject, error)

type DirectDecoder

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

func MustNewDirectDecoder

func MustNewDirectDecoder(proto interface{}) *DirectDecoder

func NewDirectDecoder

func NewDirectDecoder(proto interface{}) (*DirectDecoder, error)

func (*DirectDecoder) CreateInstance

func (d *DirectDecoder) CreateInstance() TypedObject

func (*DirectDecoder) Decode

func (d *DirectDecoder) Decode(data []byte, unmarshaler Unmarshaler) (TypedObject, error)

func (*DirectDecoder) Encode

func (d *DirectDecoder) Encode(obj TypedObject, marshaler Marshaler) ([]byte, error)

type Encoding

type Encoding interface {
	Unmarshaler
	Marshaler
}

type EncodingWrapper

type EncodingWrapper struct {
	Unmarshaler
	Marshaler
}

type JSONMarhaler

type JSONMarhaler interface {
	MarshalJSON() ([]byte, error)
}

type KnownTypes

type KnownTypes map[string]TypedObjectDecoder

KnownTypes is a set of known type names mapped to appropriate object decoders.

func (KnownTypes) Copy

func (t KnownTypes) Copy() KnownTypes

Copy provides a copy of the actually known types.

func (KnownTypes) TypeNames

func (t KnownTypes) TypeNames() []string

TypeNames return a sorted list of known type names.

type MarshalFunction

type MarshalFunction func(obj interface{}) ([]byte, error)

func (MarshalFunction) Marshal

func (f MarshalFunction) Marshal(obj interface{}) ([]byte, error)

type Marshaler

type Marshaler interface {
	Marshal(obj interface{}) ([]byte, error)
}

type Object

type Object interface{}

type ObjectType

type ObjectType struct {
	// Type describes the type of the object.
	Type string `json:"type"`
}

ObjectType describes the type of a object.

func NewObjectType

func NewObjectType(typ string) ObjectType

NewObjectType creates an ObjectType value.

func (ObjectType) GetType

func (t ObjectType) GetType() string

GetType returns the type of the object.

func (*ObjectType) SetType

func (t *ObjectType) SetType(typ string)

SetType sets the type of the object.

type ObjectVersionedType

type ObjectVersionedType ObjectType

func NewVersionedObjectType

func NewVersionedObjectType(args ...string) ObjectVersionedType

NewVersionedObjectType creates an ObjectVersionedType value.

func (ObjectVersionedType) GetKind

func (v ObjectVersionedType) GetKind() string

GetKind returns the kind of the object.

func (ObjectVersionedType) GetType

func (t ObjectVersionedType) GetType() string

GetType returns the type of the object.

func (ObjectVersionedType) GetVersion

func (v ObjectVersionedType) GetVersion() string

GetVersion returns the version of the object.

func (*ObjectVersionedType) SetKind

func (v *ObjectVersionedType) SetKind(kind string)

SetKind sets the kind of the object.

func (*ObjectVersionedType) SetType

func (t *ObjectVersionedType) SetType(typ string)

SetType sets the type of the object.

func (*ObjectVersionedType) SetVersion

func (v *ObjectVersionedType) SetVersion(version string)

SetVersion sets the version of the object.

type Scheme

type Scheme interface {
	RegisterByDecoder(typ string, decoder TypedObjectDecoder) error

	ValidateInterface(object TypedObject) error
	CreateUnstructured() Unstructured
	Convert(object TypedObject) (TypedObject, error)
	GetDecoder(otype string) TypedObjectDecoder
	Decode(data []byte, unmarshaler Unmarshaler) (TypedObject, error)
	Encode(obj TypedObject, marshaler Marshaler) ([]byte, error)
	EnforceDecode(data []byte, unmarshaler Unmarshaler) (TypedObject, error)
	KnownTypes() KnownTypes
	KnownTypeNames() []string
}

Scheme is the interface to describe a set of object types that implement a dedicated interface. As such it knows about the desired interface of the instances and can validate it. Additionally, it provides an implementation for generic unstructured objects that can be used to decode any serialized from of object candidates and provide the effective type.

type SchemeBase

type SchemeBase interface {
	AddKnownTypes(scheme Scheme)
	Scheme
}

func MustNewDefaultScheme

func MustNewDefaultScheme(protoIfce interface{}, protoUnstr Unstructured, acceptUnknown bool, defaultdecoder TypedObjectDecoder, base ...Scheme) SchemeBase

func NewDefaultScheme

func NewDefaultScheme(protoIfce interface{}, protoUnstr Unstructured, acceptUnknown bool, defaultdecoder TypedObjectDecoder, base ...Scheme) (SchemeBase, error)

type TypeGetter

type TypeGetter interface {
	// GetType returns the type of the access object.
	GetType() string
}

TypeGetter is the interface to be implemented for extracting a type.

type TypeSetter

type TypeSetter interface {
	// SetType sets the type of an abstract element
	SetType(typ string)
}

TypeSetter is the interface to be implemented for extracting a type.

type TypedObject

type TypedObject interface {
	TypeGetter
}

TypedObject defines the accessor for a typed object with additional data.

type TypedObjectConverter

type TypedObjectConverter interface {
	ConvertTo(in interface{}) (TypedObject, error)
}

TypedObjectConverter converts a versioned representation into the intended type required by the scheme.

type TypedObjectDecoder

type TypedObjectDecoder interface {
	Decode(data []byte, unmarshaler Unmarshaler) (TypedObject, error)
}

TypedObjectDecoder is able to provide an effective typed object for some serilaized form. The technical deserialization is done by an Unmarshaler.

type TypedObjectEncoder

type TypedObjectEncoder interface {
	Encode(TypedObject, Marshaler) ([]byte, error)
}

TypedObjectEncoder is able to provide a versioned representation of an effective TypedObject.

type UnmarshalFunction

type UnmarshalFunction func(data []byte, obj interface{}) error

func (UnmarshalFunction) Unmarshal

func (f UnmarshalFunction) Unmarshal(data []byte, obj interface{}) error

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(data []byte, obj interface{}) error
}

type Unstructured

type Unstructured interface {
	TypeGetter
	GetRaw() ([]byte, error)
}

Unstructured is the interface to represent generic object data for types handled by schemes.

type UnstructuredConverter

type UnstructuredConverter interface {
	ToUnstructured() (*UnstructuredTypedObject, error)
}

UnstructuredConverter converts the actual object to an UnstructuredTypedObject.

type UnstructuredMap

type UnstructuredMap map[string]interface{}

UnstructuredMap is a generic data map.

func ToUnstructuredObject

func ToUnstructuredObject(obj interface{}) (UnstructuredMap, error)

ToUnstructuredObject converts any object into a structure map.

func (UnstructuredMap) FlatCopy

func (m UnstructuredMap) FlatCopy() UnstructuredMap

FlatCopy just copies the attributes.

func (UnstructuredMap) FlatMerge

FlatMerge just joins the direct attribute set.

type UnstructuredTypedObject

type UnstructuredTypedObject struct {
	ObjectType `json:",inline"`
	Object     UnstructuredMap `json:"-"`
}

UnstructuredTypedObject describes a generic typed object. +kubebuilder:pruning:PreserveUnknownFields

func NewEmptyUnstructured

func NewEmptyUnstructured(ttype string) *UnstructuredTypedObject

NewEmptyUnstructured creates a new typed object without additional data.

func NewUnstructuredType

func NewUnstructuredType(ttype string, data UnstructuredMap) *UnstructuredTypedObject

NewUnstructuredType creates a new unstructured typed object.

func ToUnstructuredTypedObject

func ToUnstructuredTypedObject(obj TypedObject) (*UnstructuredTypedObject, error)

ToUnstructuredTypedObject converts a typed object to a unstructured object.

func (*UnstructuredTypedObject) DeepCopy

DeepCopy is a deepcopy function, copying the receiver, creating a new UnstructuredTypedObject.

func (*UnstructuredTypedObject) DeepCopyInto

func (u *UnstructuredTypedObject) DeepCopyInto(out **UnstructuredTypedObject)

DeepCopyInto is deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*UnstructuredTypedObject) Evaluate

func (u *UnstructuredTypedObject) Evaluate(types Scheme) (TypedObject, error)

Evaluate converts a unstructured object into a typed object.

func (UnstructuredTypedObject) GetRaw

func (u UnstructuredTypedObject) GetRaw() ([]byte, error)

func (UnstructuredTypedObject) MarshalJSON

func (u UnstructuredTypedObject) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom json unmarshal method for a unstructured type.

func (UnstructuredTypedObject) OpenAPISchemaFormat

func (_ UnstructuredTypedObject) OpenAPISchemaFormat() string

func (UnstructuredTypedObject) OpenAPISchemaType

func (_ UnstructuredTypedObject) OpenAPISchemaType() []string

func (*UnstructuredTypedObject) SetType

func (u *UnstructuredTypedObject) SetType(ttype string)

func (*UnstructuredTypedObject) ToUnstructured

func (s *UnstructuredTypedObject) ToUnstructured() (*UnstructuredTypedObject, error)

func (*UnstructuredTypedObject) UnmarshalJSON

func (u *UnstructuredTypedObject) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a custom json unmarshal method for a unstructured typed object.

type UnstructuredTypedObjectList

type UnstructuredTypedObjectList []*UnstructuredTypedObject

func (UnstructuredTypedObjectList) Copy

type UnstructuredVersionedTypedObject

type UnstructuredVersionedTypedObject struct {
	UnstructuredTypedObject `json:",inline"`
}

func NewEmptyUnstructuredVersioned

func NewEmptyUnstructuredVersioned(ttype string) *UnstructuredVersionedTypedObject

NewEmptyUnstructuredVersioned creates a new typed object without additional data.

func ToUnstructuredVersionedTypedObject

func ToUnstructuredVersionedTypedObject(obj TypedObject) (*UnstructuredVersionedTypedObject, error)

func (*UnstructuredVersionedTypedObject) DeepCopy

func (*UnstructuredVersionedTypedObject) GetKind

func (*UnstructuredVersionedTypedObject) GetVersion

func (s *UnstructuredVersionedTypedObject) GetVersion() string

func (*UnstructuredVersionedTypedObject) ToUnstructured

type Validater

type Validater interface {
	Validate() error
}

type VersionedTypedObject

type VersionedTypedObject interface {
	TypedObject
	GetKind() string
	GetVersion() string
}

Jump to

Keyboard shortcuts

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