Documentation
¶
Index ¶
- func ApplyPlannedChanges(ctx context.Context, plan *plans.Plan, configInst *eval.ConfigInstance, ...) (*states.State, tfdiags.Diagnostics)
- func ContextWithTracer(parent context.Context, tracer *Tracer) context.Context
- type PersistState
- type PersistingState
- func (s *PersistingState) Close() *states.State
- func (s *PersistingState) DeposeResourceInstanceObjectForceKey(addr addrs.AbsResourceInstance, forcedKey states.DeposedKey) error
- func (s *PersistingState) MaybeMoveResourceInstance(src, dst addrs.AbsResourceInstance) (bool, error)
- func (s *PersistingState) MaybeRestoreResourceInstanceDeposed(addr addrs.AbsResourceInstance, key states.DeposedKey) (bool, error)
- func (s *PersistingState) RemoveResourceInstanceObjectFull(addr addrs.AbsResourceInstanceObject, ...) error
- func (s *PersistingState) SetResourceInstanceObjectFull(addr addrs.AbsResourceInstanceObject, ...) error
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPlannedChanges ¶
func ApplyPlannedChanges(ctx context.Context, plan *plans.Plan, configInst *eval.ConfigInstance, plugins plugins.Plugins, persistState PersistState) (*states.State, tfdiags.Diagnostics)
ApplyPlannedChanges is a temporary placeholder entrypoint for a new approach to applying based on an execution graph generated during the planning phase.
The signature here is a little confusing because we're currently reusing our old-style plan and state models, even though their shape isn't quite right for what we need here. A future version of this function will hopefully have a signature more tailored to the needs of the new apply engine, once we have a stronger understanding of what those needs are.
func ContextWithTracer ¶
ContextWithTracer returns a new context derived from parent that carries a Tracer.
Use the resulting context when calling ApplyPlannedChanges, to get event notification callbacks throughout the planning process.
Types ¶
type PersistState ¶
type PersistingState ¶
type PersistingState struct {
// contains filtered or unexported fields
}
PersistingState is a wrapper around SyncState that persists the working copy to whatever persistence callback is defined.
Critically, this assumes that the persist callback does not modify the state while the apply engine is running. In the current shims to the local backend, the callback overwrites the StateManager's current state and calls Persist. Nothing else during the apply process reads or modifies the state through the state manager, which means that this approach is safe.
This additional complexity and potential fragility here is in service of preventing as many state.DeepCopy() calls as possible. If we did not share the lock between state sync and persisting below, persist would need to perform it's own deep copy of the state as modifications here proceed.
A potentially better approach would be to share the StateManager from the local backend with this implementation, but that would blur some of the intentional separation of concerns. Ideally, this all goes away once we start work on granular state storage. That will necessitate re-engineering all of these abstractions anyways, and is not worth over-complicating at this point in time.
func NewPersistingState ¶
func NewPersistingState(working *states.State, persist PersistState) *PersistingState
func (*PersistingState) Close ¶
func (s *PersistingState) Close() *states.State
func (*PersistingState) DeposeResourceInstanceObjectForceKey ¶
func (s *PersistingState) DeposeResourceInstanceObjectForceKey(addr addrs.AbsResourceInstance, forcedKey states.DeposedKey) error
func (*PersistingState) MaybeMoveResourceInstance ¶
func (s *PersistingState) MaybeMoveResourceInstance(src, dst addrs.AbsResourceInstance) (bool, error)
func (*PersistingState) MaybeRestoreResourceInstanceDeposed ¶
func (s *PersistingState) MaybeRestoreResourceInstanceDeposed(addr addrs.AbsResourceInstance, key states.DeposedKey) (bool, error)
func (*PersistingState) RemoveResourceInstanceObjectFull ¶
func (s *PersistingState) RemoveResourceInstanceObjectFull(addr addrs.AbsResourceInstanceObject, providerInstAddr addrs.AbsProviderInstanceCorrect) error
func (*PersistingState) SetResourceInstanceObjectFull ¶
func (s *PersistingState) SetResourceInstanceObjectFull(addr addrs.AbsResourceInstanceObject, obj *states.ResourceInstanceObjectFullSrc) error
type Tracer ¶
type Tracer struct {
// StartManagedResourceInstanceObjectFinalPlan and
// EndManagedResourceInstanceObjectFinalPlan mark the beginning and end of
// the work to produce the final plan for the identified managed resource
// instance object.
StartManagedResourceInstanceObjectFinalPlan func(ctx context.Context, addr addrs.AbsResourceInstanceObject, priorVal, configVal, expectedVal cty.Value) context.Context
EndManagedResourceInstanceObjectFinalPlan func(ctx context.Context, addr addrs.AbsResourceInstanceObject, priorVal, plannedVal cty.Value, diags tfdiags.Diagnostics)
// StartManagedResourceInstanceObjectApply and
// EndManagedResourceInstanceObjectApply mark the beginning and end of
// the work to apply the final plan for the identified managed resource
// instance object.
StartManagedResourceInstanceObjectApply func(ctx context.Context, addr addrs.AbsResourceInstanceObject, priorVal, plannedVal cty.Value) context.Context
EndManagedResourceInstanceObjectApply func(ctx context.Context, addr addrs.AbsResourceInstanceObject, resultVal cty.Value, diags tfdiags.Diagnostics)
// StartManagedResourceInstanceObjectForget and
// EndManagedResourceInstanceObjectForget mark the beginning and end of
// the work to "forget" the identified managed resource/ instance object.
StartManagedResourceInstanceObjectForget func(ctx context.Context, addr addrs.AbsResourceInstanceObject, priorVal cty.Value) context.Context
EndManagedResourceInstanceObjectForget func(ctx context.Context, addr addrs.AbsResourceInstanceObject, diags tfdiags.Diagnostics)
// Provisioner Hooks for Managed Resources
StartProvisionInstanceStep func(ctx context.Context, addr addrs.AbsResourceInstance, typeName string) context.Context
ProvisionOutput func(ctx context.Context, addr addrs.AbsResourceInstance, typeName string, line string, configMarks cty.ValueMarks)
StopProvisionInstanceStep func(ctx context.Context, addr addrs.AbsResourceInstance, typeName string, diags tfdiags.Diagnostics)
// StartDataResourceInstanceRead and EndDataResourceInstanceRead mark the
// beginning and end of the work to read data for the identified data
// resource instance.
//
// These events occur only when the data resource instance read was delayed
// due to there not being enough information to read it during the planning
// phase.
StartDataResourceInstanceRead func(ctx context.Context, addr addrs.AbsResourceInstance) context.Context
EndDataResourceInstanceRead func(ctx context.Context, addr addrs.AbsResourceInstance, resultVal cty.Value, diags tfdiags.Diagnostics)
// We also embed [shared.Tracer] for some events that are common across
// plan and apply. [ApplyPlannedChanges] automatically ensures that this
// nested tracer reaches the shared codepaths that rely on it.
shared.Tracer
PersistState func(*states.SyncState) error
}
Tracer is a container for various callbacks used to report various events that can occur during a call to ApplyPlannedChanges.
Pass a pointer to an object of this type to ContextWithTracer to get an annotated context.Context, and then pass it to ApplyPlannedChanges.
Any fields left as nil will be ignored. Non-nil callbacks will be called whenever the associated event (mentioned in the field's documentation comment) occurs.
Some callback functions come in "Start" and "End" pairs that share a common suffix. In those cases, the Start function is expected to return a context is a child of the one passed to the callback function, possibly annotated with additional information such as OpenTelemetry trace metadata. The returned context is then used for all of the requests that occur between the Start and End calls, and finally the same context is passed to the corresponding End function so that e.g. an OpenTelemetry trace can be closed. Implementations that don't need to preserve additional context can just directly return the provided context without modification.