Documentation ¶
Overview ¶
Package typed generic based resource definition.
Index ¶
- type DeepCopyable
- type Resource
- func (t *Resource[T, RD]) DeepCopy() resource.Resource
- func (t *Resource[T, RD]) Metadata() *resource.Metadata
- func (t *Resource[T, RD]) ResourceDefinition() spec.ResourceDefinitionSpec
- func (t *Resource[T, RD]) Spec() interface{}
- func (t *Resource[T, RD]) TypedSpec() *T
- func (t *Resource[T, RD]) UnmarshalProto(md *resource.Metadata, protoBytes []byte) error
- type ResourceDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeepCopyable ¶
type DeepCopyable[T any] interface { DeepCopy() T }
DeepCopyable requires a spec to have DeepCopy method which will be used during Resource copy.
type Resource ¶
type Resource[T DeepCopyable[T], RD ResourceDefinition[T]] struct { // contains filtered or unexported fields }
Resource provides a generic base implementation for resource.Resource.
func NewResource ¶
func NewResource[T DeepCopyable[T], RD ResourceDefinition[T]](md resource.Metadata, spec T) *Resource[T, RD]
NewResource initializes and returns a new instance of Resource with typed spec field.
func (*Resource[T, RD]) ResourceDefinition ¶
func (t *Resource[T, RD]) ResourceDefinition() spec.ResourceDefinitionSpec
ResourceDefinition implements spec.ResourceDefinitionProvider interface.
func (*Resource[T, RD]) Spec ¶
func (t *Resource[T, RD]) Spec() interface{}
Spec implements resource.Resource.
type ResourceDefinition ¶
type ResourceDefinition[T any] interface { ResourceDefinition(md resource.Metadata, spec T) spec.ResourceDefinitionSpec }
ResourceDefinition is a phantom type which acts as info supplier for Resource String and ResourceDefinition methods. It intantianed only during String and ResourceDefinition calls, so it should never contain any data which survives those calls. Any empty struct{} will do.