Documentation ¶
Index ¶
- Variables
- type Chain
- type CreateStep
- func (s *CreateStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
- func (s *CreateStep) Keys() []resource.PropertyKey
- func (s *CreateStep) Logical() bool
- func (s *CreateStep) New() *resource.State
- func (s *CreateStep) Old() *resource.State
- func (s *CreateStep) Op() StepOp
- func (s *CreateStep) Plan() *Plan
- func (s *CreateStep) Provider() string
- func (s *CreateStep) Res() *resource.State
- func (s *CreateStep) Type() tokens.Type
- func (s *CreateStep) URN() resource.URN
- type DeleteStep
- func (s *DeleteStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
- func (s *DeleteStep) Logical() bool
- func (s *DeleteStep) New() *resource.State
- func (s *DeleteStep) Old() *resource.State
- func (s *DeleteStep) Op() StepOp
- func (s *DeleteStep) Plan() *Plan
- func (s *DeleteStep) Provider() string
- func (s *DeleteStep) Res() *resource.State
- func (s *DeleteStep) Type() tokens.Type
- func (s *DeleteStep) URN() resource.URN
- type EvalRunInfo
- type Events
- type Manifest
- type Options
- type Plan
- func (p *Plan) Ctx() *plugin.Context
- func (p *Plan) Diag() diag.Sink
- func (p *Plan) GetProvider(ref providers.Reference) (plugin.Provider, bool)
- func (p *Plan) IsRefresh() bool
- func (p *Plan) Olds() map[resource.URN]*resource.State
- func (p *Plan) Prev() *Snapshot
- func (p *Plan) SignalCancellation() error
- func (p *Plan) Source() Source
- func (p *Plan) Target() *Target
- type PlanExecutor
- type PlanSummary
- type ProviderSource
- type ReadResourceEvent
- type ReadResult
- type ReadStep
- func (s *ReadStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
- func (s *ReadStep) Logical() bool
- func (s *ReadStep) New() *resource.State
- func (s *ReadStep) Old() *resource.State
- func (s *ReadStep) Op() StepOp
- func (s *ReadStep) Plan() *Plan
- func (s *ReadStep) Provider() string
- func (s *ReadStep) Res() *resource.State
- func (s *ReadStep) Type() tokens.Type
- func (s *ReadStep) URN() resource.URN
- type RegisterResourceEvent
- type RegisterResourceOutputsEvent
- type RegisterResult
- type ReplaceStep
- func (s *ReplaceStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
- func (s *ReplaceStep) Keys() []resource.PropertyKey
- func (s *ReplaceStep) Logical() bool
- func (s *ReplaceStep) New() *resource.State
- func (s *ReplaceStep) Old() *resource.State
- func (s *ReplaceStep) Op() StepOp
- func (s *ReplaceStep) Plan() *Plan
- func (s *ReplaceStep) Provider() string
- func (s *ReplaceStep) Res() *resource.State
- func (s *ReplaceStep) Type() tokens.Type
- func (s *ReplaceStep) URN() resource.URN
- type SameStep
- func (s *SameStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
- func (s *SameStep) Logical() bool
- func (s *SameStep) New() *resource.State
- func (s *SameStep) Old() *resource.State
- func (s *SameStep) Op() StepOp
- func (s *SameStep) Plan() *Plan
- func (s *SameStep) Provider() string
- func (s *SameStep) Res() *resource.State
- func (s *SameStep) Type() tokens.Type
- func (s *SameStep) URN() resource.URN
- type Snapshot
- type Source
- type SourceEvent
- type SourceIterator
- type Step
- func NewCreateReplacementStep(plan *Plan, reg RegisterResourceEvent, old *resource.State, ...) Step
- func NewCreateStep(plan *Plan, reg RegisterResourceEvent, new *resource.State) Step
- func NewDeleteReplacementStep(plan *Plan, old *resource.State, pendingDelete bool) Step
- func NewDeleteStep(plan *Plan, old *resource.State) Step
- func NewReadReplacementStep(plan *Plan, event ReadResourceEvent, old *resource.State, new *resource.State) Step
- func NewReadStep(plan *Plan, event ReadResourceEvent, old *resource.State, new *resource.State) Step
- func NewReplaceStep(plan *Plan, old *resource.State, new *resource.State, ...) Step
- func NewSameStep(plan *Plan, reg RegisterResourceEvent, old *resource.State, ...) Step
- func NewUpdateStep(plan *Plan, reg RegisterResourceEvent, old *resource.State, ...) Step
- type StepCompleteFunc
- type StepOp
- type Target
- type UpdateStep
- func (s *UpdateStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
- func (s *UpdateStep) Logical() bool
- func (s *UpdateStep) New() *resource.State
- func (s *UpdateStep) Old() *resource.State
- func (s *UpdateStep) Op() StepOp
- func (s *UpdateStep) Plan() *Plan
- func (s *UpdateStep) Provider() string
- func (s *UpdateStep) Res() *resource.State
- func (s *UpdateStep) Type() tokens.Type
- func (s *UpdateStep) URN() resource.URN
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPreviewFailed is returned whenever a preview fails. ErrPreviewFailed = errors.New("preview failed") // ErrUpdateFailed is returned whenever an update fails. ErrUpdateFailed = errors.New("update failed") // ErrCanceled is returned whenever a plan is canceled. ErrCanceled = errors.New("plan canceled") )
var StepOps = []StepOp{ OpSame, OpCreate, OpUpdate, OpDelete, OpReplace, OpCreateReplacement, OpDeleteReplaced, OpRead, OpReadReplacement, }
StepOps contains the full set of step operation types.
Functions ¶
This section is empty.
Types ¶
type Chain ¶ added in v0.15.0
type Chain = []Step
A Chain is a sequence of Steps that must be executed in the given order.
type CreateStep ¶
type CreateStep struct {
// contains filtered or unexported fields
}
CreateStep is a mutating step that creates an entirely new resource.
func (*CreateStep) Apply ¶
func (s *CreateStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
func (*CreateStep) Keys ¶
func (s *CreateStep) Keys() []resource.PropertyKey
func (*CreateStep) Logical ¶
func (s *CreateStep) Logical() bool
func (*CreateStep) New ¶
func (s *CreateStep) New() *resource.State
func (*CreateStep) Old ¶
func (s *CreateStep) Old() *resource.State
func (*CreateStep) Op ¶
func (s *CreateStep) Op() StepOp
func (*CreateStep) Plan ¶
func (s *CreateStep) Plan() *Plan
func (*CreateStep) Provider ¶ added in v0.15.0
func (s *CreateStep) Provider() string
func (*CreateStep) Res ¶
func (s *CreateStep) Res() *resource.State
func (*CreateStep) Type ¶
func (s *CreateStep) Type() tokens.Type
func (*CreateStep) URN ¶
func (s *CreateStep) URN() resource.URN
type DeleteStep ¶
type DeleteStep struct {
// contains filtered or unexported fields
}
DeleteStep is a mutating step that deletes an existing resource. If `old` is marked "External", DeleteStep is a no-op.
func (*DeleteStep) Apply ¶
func (s *DeleteStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
func (*DeleteStep) Logical ¶
func (s *DeleteStep) Logical() bool
func (*DeleteStep) New ¶
func (s *DeleteStep) New() *resource.State
func (*DeleteStep) Old ¶
func (s *DeleteStep) Old() *resource.State
func (*DeleteStep) Op ¶
func (s *DeleteStep) Op() StepOp
func (*DeleteStep) Plan ¶
func (s *DeleteStep) Plan() *Plan
func (*DeleteStep) Provider ¶ added in v0.15.0
func (s *DeleteStep) Provider() string
func (*DeleteStep) Res ¶
func (s *DeleteStep) Res() *resource.State
func (*DeleteStep) Type ¶
func (s *DeleteStep) Type() tokens.Type
func (*DeleteStep) URN ¶
func (s *DeleteStep) URN() resource.URN
type EvalRunInfo ¶
type EvalRunInfo struct { Proj *workspace.Project `json:"proj" yaml:"proj"` // the package metadata. Pwd string `json:"pwd" yaml:"pwd"` // the package's working directory. Program string `json:"program" yaml:"program"` // the path to the program. Args []string `json:"args,omitempty" yaml:"args,omitempty"` // any arguments to pass to the package. Target *Target `json:"target,omitempty" yaml:"target,omitempty"` // the target being deployed into. }
EvalRunInfo provides information required to execute and deploy resources within a package.
type Events ¶
type Events interface { OnResourceStepPre(step Step) (interface{}, error) OnResourceStepPost(ctx interface{}, step Step, status resource.Status, err error) error OnResourceOutputs(step Step) error }
Events is an interface that can be used to hook interesting engine/planning events.
type Manifest ¶
type Manifest struct { Time time.Time // the time this snapshot was taken. Magic string // a magic cookie. Version string // the pulumi command version. Plugins []workspace.PluginInfo // the plugin versions also loaded. }
Manifest captures versions for all binaries used to construct this snapshot.
type Options ¶
type Options struct { Events Events // an optional events callback interface. Parallel int // the degree of parallelism for resource operations (<=1 for serial). }
Options controls the planning and deployment process.
func (Options) DegreeOfParallelism ¶ added in v0.15.0
DegreeOfParallelism returns the degree of parallelism that should be used during the planning and deployment process.
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan is the output of analyzing resource graphs and contains the steps necessary to perform an infrastructure deployment. A plan can be generated out of whole cloth from a resource graph -- in the case of new deployments -- however, it can alternatively be generated by diffing two resource graphs -- in the case of updates to existing stacks (presumably more common). The plan contains step objects that can be used to drive a deployment.
func NewPlan ¶
func NewPlan(ctx *plugin.Context, target *Target, prev *Snapshot, source Source, analyzers []tokens.QName, preview bool) (*Plan, error)
NewPlan creates a new deployment plan from a resource snapshot plus a package to evaluate.
From the old and new states, it understands how to orchestrate an evaluation and analyze the resulting resources. The plan may be used to simply inspect a series of operations, or actually perform them; these operations are generated based on analysis of the old and new states. If a resource exists in new, but not old, for example, it results in a create; if it exists in both, but is different, it results in an update; and so on and so forth.
Note that a plan uses internal concurrency and parallelism in various ways, so it must be closed if for some reason a plan isn't carried out to its final conclusion. This will result in cancelation and reclamation of OS resources.
func (*Plan) GetProvider ¶ added in v0.15.0
func (*Plan) SignalCancellation ¶ added in v0.14.3
type PlanExecutor ¶ added in v0.15.0
type PlanExecutor struct {
// contains filtered or unexported fields
}
PlanExecutor is responsible for taking a plan and driving it to completion. Its primary responsibility is to own a `stepGenerator` and `stepExecutor`, serving as the glue that links the two subsystems together.
func NewPlanExecutor ¶ added in v0.15.0
func NewPlanExecutor(parentCtx context.Context, plan *Plan, opts Options, preview bool, src SourceIterator) *PlanExecutor
NewPlanExecutor creates a new PlanExecutor suitable for executing the given plan.
func (*PlanExecutor) Execute ¶ added in v0.15.0
func (pe *PlanExecutor) Execute() error
Execute executes a plan to completion, using the given cancellation context and running a preview or update.
func (*PlanExecutor) Summary ¶ added in v0.15.0
func (pe *PlanExecutor) Summary() PlanSummary
Summary returns a PlanSummary of the plan that was executed.
type PlanSummary ¶
type PlanSummary interface { Steps() int Creates() map[resource.URN]bool Updates() map[resource.URN]bool Replaces() map[resource.URN]bool Deletes() map[resource.URN]bool Sames() map[resource.URN]bool }
PlanSummary is an interface for summarizing the progress of a plan.
type ProviderSource ¶ added in v0.15.0
type ProviderSource interface { // GetProvider fetches the provider plugin for the given reference. GetProvider(ref providers.Reference) (plugin.Provider, bool) }
A ProviderSource allows a Source to lookup provider plugins.
type ReadResourceEvent ¶ added in v0.15.0
type ReadResourceEvent interface { SourceEvent // ID is the requested ID of this read. ID() resource.ID // Name is the requested name of this read. Name() tokens.QName // Type is type of the resource being read. Type() tokens.Type // Provider is a reference to the provider instance to use for this read. Provider() string // Parent is the parent resource of the resource being read. Parent() resource.URN // Properties is the property bag that will be passed to Read as search parameters. Properties() resource.PropertyMap // Dependencies returns the list of URNs upon which this read depends. Dependencies() []resource.URN // Done indicates that we are done with this event. Done(result *ReadResult) }
ReadResourceEvent is an event that asks the engine to read the state of a resource that already exists.
type ReadResult ¶ added in v0.15.0
type ReadStep ¶ added in v0.15.0
type ReadStep struct {
// contains filtered or unexported fields
}
ReadStep is a step indicating that an existing resources will be "read" and projected into the Pulumi object model. Resources that are read are marked with the "External" bit which indicates to the engine that it does not own this resource's lifeycle.
A resource with a given URN can transition freely between an "external" state and a non-external state. If a URN that was previously marked "External" (i.e. was the target of a ReadStep in a previous plan) is the target of a RegisterResource in the next plan, a CreateReplacement step will be issued to indicate the transition from external to owned. If a URN that was previously not marked "External" is the target of a ReadResource in the next plan, a ReadReplacement step will be issued to indicate the transition from owned to external.
type RegisterResourceEvent ¶
type RegisterResourceEvent interface { SourceEvent // Goal returns the goal state for the resource object that was allocated by the program. Goal() *resource.Goal // Done indicates that we are done with this step. It must be called to perform cleanup associated with the step. Done(result *RegisterResult) }
RegisterResourceEvent is a step that asks the engine to provision a resource.
type RegisterResourceOutputsEvent ¶
type RegisterResourceOutputsEvent interface { SourceEvent // URN is the resource URN that this completion applies to. URN() resource.URN // Outputs returns a property map of output properties to add to a resource before completing. Outputs() resource.PropertyMap // Done indicates that we are done with this step. It must be called to perform cleanup associated with the step. Done() }
RegisterResourceOutputsEvent is an event that asks the engine to complete the provisioning of a resource.
type RegisterResult ¶
type RegisterResult struct { State *resource.State // the resource state. Stable bool // if true, the resource state is stable and may be trusted. Stables []resource.PropertyKey // an optional list of specific resource properties that are stable. }
RegisterResult is the state of the resource after it has been registered.
type ReplaceStep ¶
type ReplaceStep struct {
// contains filtered or unexported fields
}
ReplaceStep is a logical step indicating a resource will be replaced. This is comprised of three physical steps: a creation of the new resource, any number of intervening updates of dependents to the new resource, and then a deletion of the now-replaced old resource. This logical step is primarily here for tools and visualization.
func (*ReplaceStep) Apply ¶
func (s *ReplaceStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
func (*ReplaceStep) Keys ¶
func (s *ReplaceStep) Keys() []resource.PropertyKey
func (*ReplaceStep) Logical ¶
func (s *ReplaceStep) Logical() bool
func (*ReplaceStep) New ¶
func (s *ReplaceStep) New() *resource.State
func (*ReplaceStep) Old ¶
func (s *ReplaceStep) Old() *resource.State
func (*ReplaceStep) Op ¶
func (s *ReplaceStep) Op() StepOp
func (*ReplaceStep) Plan ¶
func (s *ReplaceStep) Plan() *Plan
func (*ReplaceStep) Provider ¶ added in v0.15.0
func (s *ReplaceStep) Provider() string
func (*ReplaceStep) Res ¶
func (s *ReplaceStep) Res() *resource.State
func (*ReplaceStep) Type ¶
func (s *ReplaceStep) Type() tokens.Type
func (*ReplaceStep) URN ¶
func (s *ReplaceStep) URN() resource.URN
type SameStep ¶
type SameStep struct {
// contains filtered or unexported fields
}
SameStep is a mutating step that does nothing.
type Snapshot ¶
type Snapshot struct { Manifest Manifest // a deployment manifest of versions, checksums, and so on. Resources []*resource.State // fetches all resources and their associated states. }
Snapshot is a view of a collection of resources in an stack at a point in time. It describes resources; their IDs, names, and properties; their dependencies; and more. A snapshot is a diffable entity and can be used to create or apply an infrastructure deployment plan in order to make reality match the snapshot state.
func NewSnapshot ¶
NewSnapshot creates a snapshot from the given arguments. The resources must be in topologically sorted order. This property is not checked; for verification, please refer to the VerifyIntegrity function below.
func (*Snapshot) VerifyIntegrity ¶
VerifyIntegrity checks a snapshot to ensure it is well-formed. Because of the cost of this operation, integrity verification is only performed on demand, and not automatically during snapshot construction.
This function verifies a number of invariants:
- Provider resources must be referenceable (i.e. they must have a valid URN and ID)
- A resource's provider must precede the resource in the resource list
- Parents must precede children in the resource list
- Dependents must precede their dependencies in the resource list
- For every URN in the snapshot, there must be at most one resource with that URN that is not pending deletion
- The magic manifest number should change every time the snapshot is mutated
type Source ¶
type Source interface { io.Closer // Project returns the package name of the Pulumi project we are obtaining resources from. Project() tokens.PackageName // Info returns a serializable payload that can be used to stamp snapshots for future reconciliation. Info() interface{} // IsRefresh indicates whether this source returns events source from existing state (true), and hence can simply // be assumed to reflect existing state, or whether the events should acted upon (false). IsRefresh() bool // Iterate begins iterating the source. Error is non-nil upon failure; otherwise, a valid iterator is returned. Iterate(ctx context.Context, opts Options, providers ProviderSource) (SourceIterator, error) }
A Source can generate a new set of resources that the planner will process accordingly.
var NullSource Source = &nullSource{}
NullSource is a singleton source that never returns any resources. This may be used in scenarios where the "new" version of the world is meant to be empty, either for testing purposes, or removal of an existing stack.
func NewEvalSource ¶
func NewEvalSource(plugctx *plugin.Context, runinfo *EvalRunInfo, defaultProviderVersions map[tokens.Package]*semver.Version, dryRun bool) Source
NewEvalSource returns a planning source that fetches resources by evaluating a package with a set of args and a confgiuration map. This evaluation is performed using the given plugin context and may optionally use the given plugin host (or the default, if this is nil). Note that closing the eval source also closes the host.
func NewFixedSource ¶
func NewFixedSource(ctx tokens.PackageName, steps []SourceEvent) Source
NewFixedSource returns a valid planning source that is comprised of a list of pre-computed steps.
func NewRefreshSource ¶
func NewRefreshSource(plugctx *plugin.Context, proj *workspace.Project, target *Target, dryRun bool) Source
NewRefreshSource returns a new source that generates events based on reading an existing checkpoint state, combined with refreshing its associated resource state from the cloud provider.
type SourceEvent ¶
type SourceEvent interface {
// contains filtered or unexported methods
}
SourceEvent is an event associated with the enumeration of a plan. It is an intent expressed by the source program, and it is the responsibility of the engine to make it so.
type SourceIterator ¶
type SourceIterator interface { io.Closer // Next returns the next event from the source. Next() (SourceEvent, error) }
A SourceIterator enumerates the list of resources that a source has to offer and tracks associated state.
type Step ¶
type Step interface { // Apply applies or previews this step. It returns the status of the resource after the step application, // a function to call to signal that this step has fully completed, and an error, if one occurred while applying // the step. // // The returned StepCompleteFunc, if not nil, must be called after committing the results of this step into // the state of the deployment. Apply(preview bool) (resource.Status, StepCompleteFunc, error) // applies or previews this step. Op() StepOp // the operation performed by this step. URN() resource.URN // the resource URN (for before and after). Type() tokens.Type // the type affected by this step. Provider() string // the provider reference for this step. Old() *resource.State // the state of the resource before performing this step. New() *resource.State // the state of the resource after performing this step. Res() *resource.State // the latest state for the resource that is known (worst case, old). Logical() bool // true if this step represents a logical operation in the program. Plan() *Plan // the owning plan. }
Step is a specification for a deployment operation.
func NewCreateReplacementStep ¶
func NewCreateReplacementStep(plan *Plan, reg RegisterResourceEvent, old *resource.State, new *resource.State, keys []resource.PropertyKey, pendingDelete bool) Step
func NewCreateStep ¶
func NewCreateStep(plan *Plan, reg RegisterResourceEvent, new *resource.State) Step
func NewReadReplacementStep ¶ added in v0.15.0
func NewReadReplacementStep(plan *Plan, event ReadResourceEvent, old *resource.State, new *resource.State) Step
NewReadReplacementStep creates a new Read step with the `replacing` flag set. When executed, it will pend deletion of the "old" resource, which must not be an external resource.
func NewReadStep ¶ added in v0.15.0
func NewReadStep(plan *Plan, event ReadResourceEvent, old *resource.State, new *resource.State) Step
NewReadStep creates a new Read step.
func NewReplaceStep ¶
func NewSameStep ¶
func NewUpdateStep ¶
func NewUpdateStep(plan *Plan, reg RegisterResourceEvent, old *resource.State, new *resource.State, stables []resource.PropertyKey) Step
type StepCompleteFunc ¶ added in v0.15.0
type StepCompleteFunc func()
StepCompleteFunc is the type of functions returned from Step.Apply. These functions are to be called when the engine has fully retired a step.
type StepOp ¶
type StepOp string
StepOp represents the kind of operation performed by a step. It evaluates to its string label.
const ( OpSame StepOp = "same" // nothing to do. OpCreate StepOp = "create" // creating a new resource. OpUpdate StepOp = "update" // updating an existing resource. OpDelete StepOp = "delete" // deleting an existing resource. OpReplace StepOp = "replace" // replacing a resource with a new one. OpCreateReplacement StepOp = "create-replacement" // creating a new resource for a replacement. OpDeleteReplaced StepOp = "delete-replaced" // deleting an existing resource after replacement. OpRead StepOp = "read" // reading an existing resource. OpReadReplacement StepOp = "read-replacement" // reading an existing resource for a replacement. )
type Target ¶
type Target struct { Name tokens.QName // the target stack name. Config config.Map // optional configuration key/value pairs. Decrypter config.Decrypter // decrypter for secret configuration values. Snapshot *Snapshot // the last snapshot deployed to the target. }
Target represents information about a deployment target.
type UpdateStep ¶
type UpdateStep struct {
// contains filtered or unexported fields
}
UpdateStep is a mutating step that updates an existing resource's state.
func (*UpdateStep) Apply ¶
func (s *UpdateStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)
func (*UpdateStep) Logical ¶
func (s *UpdateStep) Logical() bool
func (*UpdateStep) New ¶
func (s *UpdateStep) New() *resource.State
func (*UpdateStep) Old ¶
func (s *UpdateStep) Old() *resource.State
func (*UpdateStep) Op ¶
func (s *UpdateStep) Op() StepOp
func (*UpdateStep) Plan ¶
func (s *UpdateStep) Plan() *Plan
func (*UpdateStep) Provider ¶ added in v0.15.0
func (s *UpdateStep) Provider() string
func (*UpdateStep) Res ¶
func (s *UpdateStep) Res() *resource.State
func (*UpdateStep) Type ¶
func (s *UpdateStep) Type() tokens.Type
func (*UpdateStep) URN ¶
func (s *UpdateStep) URN() resource.URN