rnode

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	// ID uniquely identifying this resource.
	ID() *cloud.ResourceID

	// State of the node.
	State() NodeState
	// SetState of the node.
	SetState(state NodeState)

	// Ownership of this resource.
	Ownership() OwnershipStatus
	// SetOwnership of this resource.
	SetOwnership(os OwnershipStatus)

	// Resource (cloud type) for this Node.
	Resource() UntypedResource
	// SetResource to a new value.
	SetResource(UntypedResource) error

	// Version of the resource. This is used when fetching the
	// resource from the Cloud.
	Version() meta.Version

	// OutRefs parses the outgoing references of the Resource.
	OutRefs() ([]ResourceRef, error)
	// AddInRef to this node Builder.
	AddInRef(ref ResourceRef)

	// SyncFromCloud downloads the resource from the Cloud. This
	// may result in one or more blocking calls to the GCE APIs.
	SyncFromCloud(ctx context.Context, cl cloud.Cloud) error

	// Build the node, converting this to a Node in a Graph.
	Build() (Node, error)
	// contains filtered or unexported methods
}

Builder is a Node in the graph Builder.

type BuilderBase

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

BuilderBase implements the non-type specific fields.

func (*BuilderBase) AddInRef

func (b *BuilderBase) AddInRef(ref ResourceRef)

func (*BuilderBase) Defaults

func (b *BuilderBase) Defaults(id *cloud.ResourceID)

Defaults sets the default values for a empty Builder node.

func (*BuilderBase) ID

func (b *BuilderBase) ID() *cloud.ResourceID

func (*BuilderBase) Init

func (b *BuilderBase) Init(
	id *cloud.ResourceID,
	state NodeState,
	ownership OwnershipStatus,
	resource UntypedResource,
)

Init the values of the BuilderBase.

func (*BuilderBase) Ownership

func (b *BuilderBase) Ownership() OwnershipStatus

func (*BuilderBase) SetOwnership

func (b *BuilderBase) SetOwnership(os OwnershipStatus)

func (*BuilderBase) SetState

func (b *BuilderBase) SetState(state NodeState)

func (*BuilderBase) State

func (b *BuilderBase) State() NodeState

func (*BuilderBase) Version

func (b *BuilderBase) Version() meta.Version

type Node

type Node interface {
	// ID uniquely identifying this resource.
	ID() *cloud.ResourceID
	// State of the node.
	State() NodeState
	// Ownership of this resource.
	Ownership() OwnershipStatus
	// OutRefs of this resource pointing to other resources.
	OutRefs() []ResourceRef
	// InRefs pointing to this resource.
	InRefs() []ResourceRef
	// Resource is the cloud resource (e.g. the Resource[compute.Address,...]).
	Resource() UntypedResource
	// Builder returns a node builder that has the same attributes and
	// underlying type but has no contents in the resource. This is used to
	// populate a graph for getting the current state from Cloud (i.e. the "got"
	// graph).
	Builder() Builder
	// Diff this node (want) with the state of the Node (got). This computes
	// whether the Sync operation will be an update or recreation.
	Diff(got Node) (*PlanDetails, error)
	// Plan returns the plan for updating this Node.
	Plan() *Plan
	// Actions needed to perform the plan. This will be empty for graphs that
	// have not been planned. "got" is the current state of the Node in the
	// "got" graph.
	Actions(got Node) ([]exec.Action, error)
}

Node in the resource graph.

type NodeBase

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

NodeBase are common non-typed fields for implementing a Node in the graph.

func (*NodeBase) ID

func (n *NodeBase) ID() *cloud.ResourceID

func (*NodeBase) InRefs

func (n *NodeBase) InRefs() []ResourceRef

func (*NodeBase) InitFromBuilder

func (n *NodeBase) InitFromBuilder(b Builder) error

InitFromBuilder is an rgraph library internal method for common initialization from a Builder.

func (*NodeBase) OutRefs

func (n *NodeBase) OutRefs() []ResourceRef

func (*NodeBase) Ownership

func (n *NodeBase) Ownership() OwnershipStatus

func (*NodeBase) Plan

func (n *NodeBase) Plan() *Plan

func (*NodeBase) State

func (n *NodeBase) State() NodeState

type NodeState

type NodeState string

NodeState is the state of the node in the Graph.

const (
	// NodeUnknown is the initial state of the Node.
	NodeUnknown NodeState = "Unknown"
	// NodeExists means the resource exists in the graph.
	NodeExists NodeState = "Exists"
	// NodeDoesNotExist is a tombstone for a Node. It means that
	// the given Node should not exist in the Graph.
	NodeDoesNotExist NodeState = "DoesNotExist"
	// NodeStateError means that the resource could not be fetched
	// from the Cloud.
	NodeStateError NodeState = "Error"
)

type Operation

type Operation string

Operation to perform on the Node.

var (
	// OpUnknown means no planning has been done.
	OpUnknown Operation = "Unknown"
	// OpNothing means nothing will happen.
	OpNothing Operation = "Nothing"
	// OpCreate will create the resource.
	OpCreate Operation = "Create"
	// OpRecreate will update the resource by first deleting, then creating the
	// resource. This is necessary as some resources cannot be updated directly
	// in place.
	OpRecreate Operation = "Recreate"
	// OpUpdate will call one or more updates ethods. The specific RPCs called
	// to do the update will be specific to the resource type itself.
	OpUpdate Operation = "Update"
	// OpDelete will delete the resource.
	OpDelete Operation = "Delete"
)

type OwnershipStatus

type OwnershipStatus string

OwnershipStatus of the node in the graph.

var (
	// OwnershipUnknown is the initial state of a Node.
	OwnershipUnknown OwnershipStatus = "Unknown"
	// OwnershipManaged means the Node's lifecycle and values are
	// to be planned and sync'd.
	OwnershipManaged OwnershipStatus = "Managed"
	// OwnershipExternal means the Node's lifecycle is not managed
	// by planning. The resource will not be mutated in any way
	// and is present in the graph for read-only purposes.
	OwnershipExternal OwnershipStatus = "External"
)

type Plan

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

Plan for what will be done to the Node.

func (*Plan) Details

func (p *Plan) Details() *PlanDetails

Details returns details on the current plan.

func (*Plan) GraphvizString

func (p *Plan) GraphvizString() string

GraphvizString returns a Graphviz-formatted summary of the plan.

func (*Plan) Op

func (p *Plan) Op() Operation

Op to perform.

func (*Plan) Set

func (p *Plan) Set(a PlanDetails)

Set the plan to the specified action.

func (*Plan) String

func (p *Plan) String() string

type PlanDetails

type PlanDetails struct {
	// Operation associated with this explanation.
	Operation Operation
	// Why is a human readable string describing why this operation was
	// selected.
	Why string
	// Diff is an optional description of the diff between the current and
	// wanted resources.
	Diff *api.DiffResult
}

PlanDetails is a human-readable reasons describing the Sync operation that has been planned.

type ResourceRef

type ResourceRef struct {
	// From is the object containing the reference.
	From *cloud.ResourceID
	// Path to the field with the value in From.
	Path api.Path
	// To is the resource that is referenced.
	To *cloud.ResourceID
}

ResourceRef identifies a reference from the resource From in the field Path to the resource To.

type UntypedResource

type UntypedResource interface {
	ResourceID() *cloud.ResourceID
	Version() meta.Version
}

UntypedResource is the type-erased version of Resource.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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