model

package
v0.6.0-beta.18 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE = Action("CREATE")
	UPDATE = Action("UPDATE")
	DELETE = Action("DELETE")
	STATUS = Action("STATUS")
)

Variables

This section is empty.

Functions

func AddScheme

func AddScheme(addToScheme func(*runtime.Scheme) error)

func DefaultLess

func DefaultLess(v1, v2 graph.Vertex) bool

func FindAll

func FindAll[T interface{}](dag *graph.DAG) []graph.Vertex

func GetScheme

func GetScheme() *runtime.Scheme

func IsObjectDeleting

func IsObjectDeleting(object client.Object) bool

func IsObjectStatusUpdating

func IsObjectStatusUpdating(object client.Object) bool

func IsObjectUpdating

func IsObjectUpdating(object client.Object) bool

func IsOwnerOf

func IsOwnerOf(owner, obj client.Object) bool

func NewRequeueError

func NewRequeueError(after time.Duration, reason string) error

Types

type Action

type Action string

func ActionPtr

func ActionPtr(action Action) *Action

type GVKNObjKey

type GVKNObjKey struct {
	schema.GroupVersionKind
	client.ObjectKey
}

func GetGVKName

func GetGVKName(object client.Object) (*GVKNObjKey, error)

type GraphClient

type GraphClient interface {
	client.Reader
	GraphWriter
}

func NewGraphClient

func NewGraphClient(cli client.Client) GraphClient

type GraphWriter

type GraphWriter interface {
	// Root setups the given obj as root vertex of the underlying DAG.
	// this func should be called once before any others.
	Root(dag *graph.DAG, objOld, objNew client.Object)

	// Create saves the object obj in the underlying DAG.
	Create(dag *graph.DAG, obj client.Object)

	// Delete deletes the given obj from the underlying DAG.
	Delete(dag *graph.DAG, obj client.Object)

	// Update updates the given obj in the underlying DAG.
	Update(dag *graph.DAG, objOld, objNew client.Object)

	// Status updates the given obj's status in the underlying DAG.
	Status(dag *graph.DAG, objOld, objNew client.Object)

	// DependOn setups dependencies between 'object' and 'dependency',
	// which will guarantee the Write Order to the K8s cluster of these objects.
	DependOn(dag *graph.DAG, object client.Object, dependency ...client.Object)
}

type ObjectSnapshot

type ObjectSnapshot map[GVKNObjKey]client.Object

func ReadCacheSnapshot

func ReadCacheSnapshot(transCtx graph.TransformContext, root client.Object, ml client.MatchingLabels, kinds ...client.ObjectList) (ObjectSnapshot, error)

ReadCacheSnapshot reads all objects owned by our cluster

type ObjectVertex

type ObjectVertex struct {
	Obj       client.Object
	OriObj    client.Object
	Immutable bool
	IsOrphan  bool
	Action    *Action
}

ObjectVertex describes expected object spec and how to reach it obj always represents the expected part: new object in Create/Update action and old object in Delete action oriObj is set in Update action all transformers doing their object manipulation works on obj.spec the root vertex(i.e. the cluster vertex) will be treated specially: as all its meta, spec and status can be updated in one reconciliation loop Update is ignored when immutable=true orphan object will be force deleted when action is DELETE

func FindRootVertex

func FindRootVertex(dag *graph.DAG) (*ObjectVertex, error)

func (*ObjectVertex) String

func (v *ObjectVertex) String() string

type ParallelTransformer

type ParallelTransformer struct {
	Transformers []graph.Transformer
}

ParallelTransformer executes a group of transformers in parallel. TODO: make DAG thread-safe if ParallelTransformer called.

func (*ParallelTransformer) Transform

func (t *ParallelTransformer) Transform(ctx graph.TransformContext, dag *graph.DAG) error

type RequeueError

type RequeueError interface {
	RequeueAfter() time.Duration
	Reason() string
}

Jump to

Keyboard shortcuts

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