Documentation
¶
Index ¶
- Constants
- func CreateActions[GA any, Alpha any, Beta any](ops GenericOps[GA, Alpha, Beta], node Node, ...) ([]exec.Action, error)
- func CreatePreconditions(want Node) (exec.EventList, error)
- func DeleteActions[GA any, Alpha any, Beta any](ops GenericOps[GA, Alpha, Beta], got, want Node) ([]exec.Action, error)
- func DeletePreconditions(got, want Node) exec.EventList
- func GenericGet[GA any, Alpha any, Beta any](ctx context.Context, gcp cloud.Cloud, resourceName string, ...) error
- func NewGenericDeleteAction[GA any, Alpha any, Beta any](want exec.EventList, ops GenericOps[GA, Alpha, Beta], got Node) *genericDeleteAction[GA, Alpha, Beta]
- func RecreateActions[GA any, Alpha any, Beta any](ops GenericOps[GA, Alpha, Beta], got, want Node, ...) ([]exec.Action, error)
- func UpdateActions[GA any, Alpha any, Beta any](ops GenericOps[GA, Alpha, Beta], got, want Node, ...) ([]exec.Action, error)
- type Builder
- type BuilderBase
- func (b *BuilderBase) AddInRef(ref ResourceRef)
- func (b *BuilderBase) Defaults(id *cloud.ResourceID)
- func (b *BuilderBase) ID() *cloud.ResourceID
- func (b *BuilderBase) Init(id *cloud.ResourceID, state NodeState, ownership OwnershipStatus, ...)
- func (b *BuilderBase) Ownership() OwnershipStatus
- func (b *BuilderBase) SetOwnership(os OwnershipStatus)
- func (b *BuilderBase) SetState(state NodeState)
- func (b *BuilderBase) State() NodeState
- func (b *BuilderBase) Version() meta.Version
- type CreateFuncs
- type CreateFuncsByScope
- type DeleteFuncs
- type DeleteFuncsByScope
- type GenericOps
- type GetFuncs
- type GetFuncsByScope
- type Node
- type NodeBase
- type NodeState
- type Operation
- type OwnershipStatus
- type Plan
- type PlanDetails
- type ResourceRef
- type UntypedResource
- type UpdateFuncs
- type UpdateFuncsByScope
Constants ¶
const ( // Resource does not have a .Fingerprint field. Note: this // means that the resource is technically not compliant with // API conventions but these exceptions occur throughout the // GCE APIs and we have to work around them. UpdateFuncsNoFingerprint = 1 << iota )
Variables ¶
This section is empty.
Functions ¶
func CreateActions ¶ added in v1.26.0
func CreatePreconditions ¶ added in v1.26.0
func DeleteActions ¶ added in v1.26.0
func DeletePreconditions ¶ added in v1.26.0
func GenericGet ¶ added in v1.26.0
func NewGenericDeleteAction ¶ added in v1.26.0
func RecreateActions ¶ added in v1.26.0
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 CreateFuncs ¶ added in v1.26.0
type CreateFuncs[GA any, Alpha any, Beta any] struct { GA CreateFuncsByScope[GA] Alpha CreateFuncsByScope[Alpha] Beta CreateFuncsByScope[Beta] }
func (*CreateFuncs[GA, Alpha, Beta]) Do ¶ added in v1.26.0
func (f *CreateFuncs[GA, Alpha, Beta]) Do( ctx context.Context, id *cloud.ResourceID, r api.Resource[GA, Alpha, Beta], ) error
type CreateFuncsByScope ¶ added in v1.26.0
type DeleteFuncs ¶ added in v1.26.0
type DeleteFuncs[GA any, Alpha any, Beta any] struct { GA DeleteFuncsByScope[GA] Alpha DeleteFuncsByScope[Alpha] Beta DeleteFuncsByScope[Beta] }
func (*DeleteFuncs[GA, Alpha, Beta]) Do ¶ added in v1.26.0
func (f *DeleteFuncs[GA, Alpha, Beta]) Do(ctx context.Context, id *cloud.ResourceID) error
type DeleteFuncsByScope ¶ added in v1.26.0
type DeleteFuncsByScope[T any] struct { Global func(context.Context, *meta.Key, ...cloud.Option) error Regional func(context.Context, *meta.Key, ...cloud.Option) error Zonal func(context.Context, *meta.Key, ...cloud.Option) error }
func (*DeleteFuncsByScope[T]) Do ¶ added in v1.26.0
func (s *DeleteFuncsByScope[T]) Do(ctx context.Context, id *cloud.ResourceID, options ...cloud.Option) error
type GenericOps ¶ added in v1.26.0
type GenericOps[GA any, Alpha any, Beta any] interface { GetFuncs(gcp cloud.Cloud) *GetFuncs[GA, Alpha, Beta] CreateFuncs(gcp cloud.Cloud) *CreateFuncs[GA, Alpha, Beta] UpdateFuncs(gcp cloud.Cloud) *UpdateFuncs[GA, Alpha, Beta] DeleteFuncs(gcp cloud.Cloud) *DeleteFuncs[GA, Alpha, Beta] }
GenericOps are a typed dispatch for (API version, scope) for CRUD verbs. Set the field to nil if the operation is not supported.
type GetFuncs ¶ added in v1.26.0
type GetFuncs[GA any, Alpha any, Beta any] struct { GA GetFuncsByScope[GA] Alpha GetFuncsByScope[Alpha] Beta GetFuncsByScope[Beta] }
type GetFuncsByScope ¶ added in v1.26.0
type GetFuncsByScope[T any] struct { Global func(context.Context, *meta.Key, ...cloud.Option) (*T, error) Regional func(context.Context, *meta.Key, ...cloud.Option) (*T, error) Zonal func(context.Context, *meta.Key, ...cloud.Option) (*T, error) }
GetFuncsByScope dispatches the operation by the appropriate scope. Set the field to nil if the scope is not supported.
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 ¶
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
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) Explain ¶ added in v1.26.0
Explain returns a human-readable string that is suitable for analysis. It will be rather verbose.
func (*Plan) GraphvizString ¶
GraphvizString returns a Graphviz-formatted summary of the plan.
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.
type UpdateFuncs ¶ added in v1.26.0
type UpdateFuncs[GA any, Alpha any, Beta any] struct { GA UpdateFuncsByScope[GA] Alpha UpdateFuncsByScope[Alpha] Beta UpdateFuncsByScope[Beta] Options int }