Documentation ¶
Index ¶
- Constants
- Variables
- func KindNames(scheme Scheme) []string
- func KindVersion(t string) (string, string)
- func MustProtoType(proto interface{}) reflect.Type
- func ProtoType(proto interface{}) (reflect.Type, error)
- func RegisterByType(s Scheme, typ string, proto TypedObject) error
- func TypeName(args ...string) string
- func TypeNames(scheme Scheme) []string
- func TypedObjectEqual(a, b TypedObject) bool
- func TypedObjectFactory(proto TypedObject) func() TypedObject
- func UnstructuredTypesEqual(a, b *UnstructuredTypedObject) bool
- func Validate(o interface{}) error
- type BaseScheme
- type Binary
- type ConvertingDecoder
- type DirectDecoder
- type Encoding
- type EncodingWrapper
- type JSONMarhaler
- type KnownTypes
- type MarshalFunction
- type Marshaler
- type Object
- type ObjectType
- type ObjectVersionedType
- type Scheme
- type SchemeBase
- type TypeGetter
- type TypeSetter
- type TypedObject
- type TypedObjectConverter
- type TypedObjectDecoder
- type TypedObjectEncoder
- type UnmarshalFunction
- type Unmarshaler
- type Unstructured
- type UnstructuredConverter
- type UnstructuredMap
- type UnstructuredTypedObject
- func (u *UnstructuredTypedObject) DeepCopy() *UnstructuredTypedObject
- func (u *UnstructuredTypedObject) DeepCopyInto(out **UnstructuredTypedObject)
- func (u *UnstructuredTypedObject) Evaluate(types Scheme) (TypedObject, error)
- func (u UnstructuredTypedObject) GetRaw() ([]byte, error)
- func (u UnstructuredTypedObject) MarshalJSON() ([]byte, error)
- func (_ UnstructuredTypedObject) OpenAPISchemaFormat() string
- func (_ UnstructuredTypedObject) OpenAPISchemaType() []string
- func (u *UnstructuredTypedObject) SetType(ttype string)
- func (s *UnstructuredTypedObject) ToUnstructured() (*UnstructuredTypedObject, error)
- func (u *UnstructuredTypedObject) UnmarshalJSON(data []byte) error
- type UnstructuredTypedObjectList
- type UnstructuredVersionedTypedObject
- func (u *UnstructuredVersionedTypedObject) DeepCopy() *UnstructuredVersionedTypedObject
- func (s *UnstructuredVersionedTypedObject) GetKind() string
- func (s *UnstructuredVersionedTypedObject) GetVersion() string
- func (s *UnstructuredVersionedTypedObject) ToUnstructured() (*UnstructuredTypedObject, error)
- type Validater
- type VersionedTypedObject
Constants ¶
const ATTR_TYPE = "type"
const VersionSeparator = "/"
Variables ¶
var DefaultJSONEncoding = &EncodingWrapper{ Marshaler: MarshalFunction(json.Marshal), Unmarshaler: UnmarshalFunction(json.Unmarshal), }
var DefaultYAMLEncoding = &EncodingWrapper{ Marshaler: MarshalFunction(yaml.Marshal), Unmarshaler: UnmarshalFunction(func(data []byte, obj interface{}) error { return yaml.Unmarshal(data, obj) }), }
Functions ¶
func KindVersion ¶
func MustProtoType ¶
func RegisterByType ¶
func RegisterByType(s Scheme, typ string, proto TypedObject) error
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.
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 ¶
MarshalJSON returns m as the JSON encoding of m.
func (*Binary) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.
type ConvertingDecoder ¶
type ConvertingDecoder struct { TypedObjectConverter // contains filtered or unexported fields }
ConvertingDecoder uses a serialization form 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 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 ¶
func (MarshalFunction) Marshal ¶
func (f MarshalFunction) Marshal(obj interface{}) ([]byte, error)
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 ¶
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 ¶
func (UnmarshalFunction) Unmarshal ¶
func (f UnmarshalFunction) Unmarshal(data []byte, obj interface{}) error
type Unmarshaler ¶
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 ¶
func (m UnstructuredMap) FlatMerge(o UnstructuredMap) UnstructuredMap
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 ¶
func (u *UnstructuredTypedObject) DeepCopy() *UnstructuredTypedObject
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 ¶
func (l UnstructuredTypedObjectList) Copy() UnstructuredTypedObjectList
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 (u *UnstructuredVersionedTypedObject) DeepCopy() *UnstructuredVersionedTypedObject
func (*UnstructuredVersionedTypedObject) GetKind ¶
func (s *UnstructuredVersionedTypedObject) GetKind() string
func (*UnstructuredVersionedTypedObject) GetVersion ¶
func (s *UnstructuredVersionedTypedObject) GetVersion() string
func (*UnstructuredVersionedTypedObject) ToUnstructured ¶
func (s *UnstructuredVersionedTypedObject) ToUnstructured() (*UnstructuredTypedObject, error)
type VersionedTypedObject ¶
type VersionedTypedObject interface { TypedObject GetKind() string GetVersion() string }