Documentation ¶
Index ¶
- Constants
- func AddScheme(addToScheme func(*runtime.Scheme) error)
- func DefaultLess(v1, v2 graph.Vertex) bool
- func GetScheme() *runtime.Scheme
- func IsObjectDeleting(object client.Object) bool
- func IsObjectStatusUpdating(object client.Object) bool
- func IsObjectUpdating(object client.Object) bool
- func IsOwnerOf(owner, obj client.Object) bool
- func NewRequeueError(after time.Duration, reason string) error
- type Action
- type GVKNObjKey
- type GraphClient
- type GraphOption
- type GraphWriter
- type ObjectSnapshot
- type ObjectVertex
- type ParallelTransformer
- type RequeueError
Constants ¶
const ( // 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, Noop and Delete ReplaceIfExistingOption = "ReplaceIfExisting" // HaveDifferentTypeWithOption is used in FindAll method to find all objects have different type with the given one. HaveDifferentTypeWithOption = "HaveDifferentTypeWith" )
Variables ¶
This section is empty.
Functions ¶
func DefaultLess ¶
func IsObjectDeleting ¶
func IsObjectStatusUpdating ¶
func IsObjectUpdating ¶
Types ¶
type Action ¶
type Action string
func ActionCreatePtr ¶
func ActionCreatePtr() *Action
func ActionDeletePtr ¶
func ActionDeletePtr() *Action
func ActionNoopPtr ¶
func ActionNoopPtr() *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(cli client.Client) GraphClient
type GraphOption ¶
type GraphOption string
GraphOption specifies behaviors of GraphWriter methods. currently enum is enough, maybe extend to interface in the future.
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) // Noop means not to commit any change made to this obj in the execute phase. Noop(dag *graph.DAG, obj 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) *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 }
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 ¶
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 (*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