model

package
v1.0.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: AGPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CREATE = Action("CREATE")
	UPDATE = Action("UPDATE")
	PATCH  = Action("PATCH")
	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 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 IsReconciliationPaused added in v0.9.0

func IsReconciliationPaused(object client.Object) bool

func NewRequeueError

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

Types

type Action

type Action string

func ActionCreatePtr

func ActionCreatePtr() *Action

func ActionDeletePtr

func ActionDeletePtr() *Action

func ActionPatchPtr

func ActionPatchPtr() *Action

func ActionStatusPtr

func ActionStatusPtr() *Action

func ActionUpdatePtr

func ActionUpdatePtr() *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(reader client.Reader) GraphClient

type GraphOption

type GraphOption interface {
	ApplyTo(*GraphOptions)
}

func WithClientOption added in v0.9.0

func WithClientOption(opt any) GraphOption

func WithPropagationPolicy added in v0.9.0

func WithPropagationPolicy(policy client.PropagationPolicy) GraphOption

type GraphOptions added in v0.9.0

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

type GraphWriter

type GraphWriter interface {
	// Root setups the given obj as root vertex of the underlying DAG.
	Root(dag *graph.DAG, objOld, objNew client.Object, action *Action)

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

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

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

	// Patch patches the given objOld by the new version objNew in the underlying DAG.
	Patch(dag *graph.DAG, objOld, objNew client.Object, opts ...GraphOption)

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

	// Do does 'action' to 'objOld' and 'objNew' and return the vertex created.
	// this method creates a vertex directly even if the given object already exists in the underlying DAG.
	// WARN: this is a rather low-level API, will be refactored out in near future, avoid to use it.
	Do(dag *graph.DAG, objOld, objNew client.Object, action *Action, parent *ObjectVertex, opts ...GraphOption) *ObjectVertex

	// IsAction tells whether the action of the vertex of this obj is same as 'action'.
	IsAction(dag *graph.DAG, obj client.Object, action *Action) bool

	// DependOn setups dependencies between 'object' and 'dependencies',
	// which will guarantee the Write Order to the K8s cluster of these objects.
	// if multiple vertices exist(which can occur when ForceCreatingVertexOption being used), the one with the largest depth will be used.
	DependOn(dag *graph.DAG, object client.Object, dependencies ...client.Object)

	// FindAll finds all objects that have same type with obj in the underlying DAG.
	// obey the GraphOption if provided.
	FindAll(dag *graph.DAG, obj interface{}, opts ...GraphOption) []client.Object

	// FindMatchedVertex finds the matched vertex in the underlying DAG.
	FindMatchedVertex(dag *graph.DAG, object client.Object) graph.Vertex
}

type HaveDifferentTypeWithOption

type HaveDifferentTypeWithOption struct{}

HaveDifferentTypeWithOption is used in FindAll method to find all objects have different type with the given one.

func (*HaveDifferentTypeWithOption) ApplyTo added in v0.9.0

func (o *HaveDifferentTypeWithOption) ApplyTo(opts *GraphOptions)

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 root object.

type ObjectVertex

type ObjectVertex struct {
	Obj               client.Object
	OriObj            client.Object
	Action            *Action
	ClientOpt         any
	PropagationPolicy client.PropagationPolicy
}

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

func FindRootVertex

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

func NewObjectVertex added in v0.9.0

func NewObjectVertex(oldObj, newObj client.Object, action *Action, opts ...GraphOption) *ObjectVertex

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 ReplaceIfExistingOption

type ReplaceIfExistingOption struct{}

ReplaceIfExistingOption tells the GraphWriter methods to replace Obj and OriObj with the given ones if already existing. used in Action methods: Create, Update, Patch, Status and Delete

func (*ReplaceIfExistingOption) ApplyTo added in v0.9.0

func (o *ReplaceIfExistingOption) ApplyTo(opts *GraphOptions)

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