typed

package
v0.2.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MPL-2.0 Imports: 4 Imported by: 31

Documentation

Overview

Package typed generic based resource definition.

Index

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]) DeepCopy

func (t *Resource[T, RD]) DeepCopy() resource.Resource

DeepCopy returns a deep copy of Resource.

func (*Resource[T, RD]) Metadata

func (t *Resource[T, RD]) Metadata() *resource.Metadata

Metadata implements Resource.

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.

func (*Resource[T, RD]) TypedSpec

func (t *Resource[T, RD]) TypedSpec() *T

TypedSpec returns a pointer to spec field.

func (*Resource[T, RD]) UnmarshalProto

func (t *Resource[T, RD]) UnmarshalProto(md *resource.Metadata, protoBytes []byte) error

UnmarshalProto implements protobuf.Unmarshaler interface in a generic way.

UnmarshalProto requires that the spec implements the protobuf.ProtoUnmarshaller interface.

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.

Jump to

Keyboard shortcuts

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