deploy

package
v2.25.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package deploy contains the logic for planning and executing resource deployments. This includes the following: - Manage the deployment lifecycle by coordinating the execution and parallelism of the underlying operations. - A builtin provider for interacting with the engine.

Index

Constants

This section is empty.

Variables

StepOps contains the full set of step operation types.

Functions

This section is empty.

Types

type BackendClient

type BackendClient interface {
	// GetStackOutputs returns the outputs (if any) for the named stack or an error if the stack cannot be found.
	GetStackOutputs(ctx context.Context, name string) (resource.PropertyMap, error)

	// GetStackResourceOutputs returns the resource outputs for a stack, or an error if the stack
	// cannot be found. Resources are retrieved from the latest stack snapshot, which may include
	// ongoing updates. They are returned in a `PropertyMap` mapping resource URN to another
	// `Propertymap` with members `type` (containing the Pulumi type ID for the resource) and
	// `outputs` (containing the resource outputs themselves).
	GetStackResourceOutputs(ctx context.Context, stackName string) (resource.PropertyMap, error)
}

BackendClient is used to retrieve information about stacks from a backend.

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) Deployment added in v2.15.0

func (s *CreateStep) Deployment() *Deployment

func (*CreateStep) DetailedDiff

func (s *CreateStep) DetailedDiff() map[string]plugin.PropertyDiff

func (*CreateStep) Diffs

func (s *CreateStep) Diffs() []resource.PropertyKey

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) Provider

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) Deployment added in v2.15.0

func (s *DeleteStep) Deployment() *Deployment

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) Provider

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 Deployment added in v2.15.0

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

A Deployment manages the iterative computation and execution of a deployment based on a stream of goal states. A running deployment emits events that indicate its progress. These events must be used to record the new state of the deployment target.

func NewDeployment added in v2.15.0

func NewDeployment(ctx *plugin.Context, target *Target, prev *Snapshot, source Source,
	localPolicyPackPaths []string, preview bool, backendClient BackendClient) (*Deployment, error)

NewDeployment creates a new deployment 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 deployment 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 deployment uses internal concurrency and parallelism in various ways, so it must be closed if for some reason it isn't carried out to its final conclusion. This will result in cancellation and reclamation of resources.

func NewImportDeployment added in v2.15.0

func NewImportDeployment(ctx *plugin.Context, target *Target, projectName tokens.PackageName, imports []Import,
	preview bool) (*Deployment, error)

NewImportDeployment creates a new import deployment from a resource snapshot plus a set of resources to import.

From the old and new states, it understands how to orchestrate an evaluation and analyze the resulting resources. The deployment 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 deployment uses internal concurrency and parallelism in various ways, so it must be closed if for some reason it isn't carried out to its final conclusion. This will result in cancellation and reclamation of resources.

func (*Deployment) Ctx added in v2.15.0

func (d *Deployment) Ctx() *plugin.Context

func (*Deployment) Diag added in v2.15.0

func (d *Deployment) Diag() diag.Sink

func (*Deployment) Execute added in v2.15.0

func (d *Deployment) Execute(ctx context.Context, opts Options, preview bool) result.Result

Execute executes a deployment to completion, using the given cancellation context and running a preview or update.

func (*Deployment) GetProvider added in v2.15.0

func (d *Deployment) GetProvider(ref providers.Reference) (plugin.Provider, bool)

func (*Deployment) Olds added in v2.15.0

func (d *Deployment) Olds() map[resource.URN]*resource.State

func (*Deployment) Prev added in v2.15.0

func (d *Deployment) Prev() *Snapshot

func (*Deployment) Source added in v2.15.0

func (d *Deployment) Source() Source

func (*Deployment) Target added in v2.15.0

func (d *Deployment) Target() *Target

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 {
	StepExecutorEvents
	PolicyEvents
}

Events is an interface that can be used to hook interesting engine events.

type Import added in v2.12.0

type Import struct {
	Type     tokens.Type     // The type token for the resource. Required.
	Name     tokens.QName    // The name of the resource. Required.
	ID       resource.ID     // The ID of the resource. Required.
	Parent   resource.URN    // The parent of the resource, if any.
	Provider resource.URN    // The specific provider to use for the resource, if any.
	Version  *semver.Version // The provider version to use for the resource, if any.
	Protect  bool            // Whether to mark the resource as protected after import
}

An Import specifies a resource to import.

type ImportOptions added in v2.12.0

type ImportOptions struct {
	Events   Events // an optional events callback interface.
	Parallel int    // the degree of parallelism for resource operations (<=1 for serial).
}

ImportOptions controls the import process.

type ImportStep

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

func (*ImportStep) Apply

func (s *ImportStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)

func (*ImportStep) Deployment added in v2.15.0

func (s *ImportStep) Deployment() *Deployment

func (*ImportStep) DetailedDiff

func (s *ImportStep) DetailedDiff() map[string]plugin.PropertyDiff

func (*ImportStep) Diffs

func (s *ImportStep) Diffs() []resource.PropertyKey

func (*ImportStep) Logical

func (s *ImportStep) Logical() bool

func (*ImportStep) New

func (s *ImportStep) New() *resource.State

func (*ImportStep) Old

func (s *ImportStep) Old() *resource.State

func (*ImportStep) Op

func (s *ImportStep) Op() StepOp

func (*ImportStep) Provider

func (s *ImportStep) Provider() string

func (*ImportStep) Res

func (s *ImportStep) Res() *resource.State

func (*ImportStep) Type

func (s *ImportStep) Type() tokens.Type

func (*ImportStep) URN

func (s *ImportStep) URN() resource.URN

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.

func (Manifest) NewMagic

func (m Manifest) NewMagic() string

NewMagic creates a magic cookie out of a manifest; this can be used to check for tampering. This ignores any existing magic value already stored on the manifest.

type Options

type Options struct {
	Events                    Events         // an optional events callback interface.
	Parallel                  int            // the degree of parallelism for resource operations (<=1 for serial).
	Refresh                   bool           // whether or not to refresh before executing the deployment.
	RefreshOnly               bool           // whether or not to exit after refreshing.
	RefreshTargets            []resource.URN // The specific resources to refresh during a refresh op.
	ReplaceTargets            []resource.URN // Specific resources to replace.
	DestroyTargets            []resource.URN // Specific resources to destroy.
	UpdateTargets             []resource.URN // Specific resources to update.
	TargetDependents          bool           // true if we're allowing things to proceed, even with unspecified targets
	TrustDependencies         bool           // whether or not to trust the resource dependency graph.
	UseLegacyDiff             bool           // whether or not to use legacy diffing behavior.
	DisableResourceReferences bool           // true to disable resource reference support.
}

Options controls the deployment process.

func (Options) DegreeOfParallelism

func (o Options) DegreeOfParallelism() int

DegreeOfParallelism returns the degree of parallelism that should be used during the deployment process.

func (Options) InfiniteParallelism

func (o Options) InfiniteParallelism() bool

InfiniteParallelism returns whether or not the requested level of parallelism is unbounded.

type PlanPendingOperationsError

type PlanPendingOperationsError struct {
	Operations []resource.Operation
}

PlanPendingOperationsError is an error returned from `NewPlan` if there exist pending operations in the snapshot that we are preparing to operate upon. The engine does not allow any operations to be pending when operating on a snapshot.

func (PlanPendingOperationsError) Error

type PolicyEvents

type PolicyEvents interface {
	OnPolicyViolation(resource.URN, plugin.AnalyzeDiagnostic)
}

PolicyEvents is an interface that can be used to hook policy events.

type ProviderSource

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 QuerySource

type QuerySource interface {
	Wait() result.Result
}

QuerySource is used to synchronously wait for a query result.

func NewQuerySource

func NewQuerySource(cancel context.Context, plugctx *plugin.Context, client BackendClient,
	runinfo *EvalRunInfo, defaultProviderVersions map[tokens.Package]*semver.Version,
	provs ProviderSource) (QuerySource, error)

NewQuerySource creates a `QuerySource` for some target runtime environment specified by `runinfo`, and supported by language plugins provided in `plugctx`.

type ReadResourceEvent

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)
	// The names of any additional outputs that should be treated as secrets.
	AdditionalSecretOutputs() []resource.PropertyKey
}

ReadResourceEvent is an event that asks the engine to read the state of an existing resource.

type ReadResult

type ReadResult struct {
	State *resource.State
}

type ReadStep

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 deployment) is the target of a RegisterResource in the next deployment, 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 deployment, a ReadReplacement step will be issued to indicate the transition from owned to external.

func (*ReadStep) Apply

func (s *ReadStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)

func (*ReadStep) Deployment added in v2.15.0

func (s *ReadStep) Deployment() *Deployment

func (*ReadStep) Logical

func (s *ReadStep) Logical() bool

func (*ReadStep) New

func (s *ReadStep) New() *resource.State

func (*ReadStep) Old

func (s *ReadStep) Old() *resource.State

func (*ReadStep) Op

func (s *ReadStep) Op() StepOp

func (*ReadStep) Provider

func (s *ReadStep) Provider() string

func (*ReadStep) Res

func (s *ReadStep) Res() *resource.State

func (*ReadStep) Type

func (s *ReadStep) Type() tokens.Type

func (*ReadStep) URN

func (s *ReadStep) URN() resource.URN

type RefreshStep

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

RefreshStep is a step used to track the progress of a refresh operation. A refresh operation updates the an existing resource by reading its current state from its provider plugin. These steps are not issued by the step generator; instead, they are issued by the deployment executor as the optional first step in deployment execution.

func (*RefreshStep) Apply

func (s *RefreshStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)

func (*RefreshStep) Deployment added in v2.15.0

func (s *RefreshStep) Deployment() *Deployment

func (*RefreshStep) Logical

func (s *RefreshStep) Logical() bool

func (*RefreshStep) New

func (s *RefreshStep) New() *resource.State

func (*RefreshStep) Old

func (s *RefreshStep) Old() *resource.State

func (*RefreshStep) Op

func (s *RefreshStep) Op() StepOp

func (*RefreshStep) Provider

func (s *RefreshStep) Provider() string

func (*RefreshStep) Res

func (s *RefreshStep) Res() *resource.State

func (*RefreshStep) ResultOp

func (s *RefreshStep) ResultOp() StepOp

ResultOp returns the operation that corresponds to the change to this resource after reading its current state, if any.

func (*RefreshStep) Type

func (s *RefreshStep) Type() tokens.Type

func (*RefreshStep) URN

func (s *RefreshStep) URN() resource.URN

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.
}

RegisterResult is the state of the resource after it has been registered.

type RemovePendingReplaceStep

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

func (*RemovePendingReplaceStep) Apply

func (*RemovePendingReplaceStep) Deployment added in v2.15.0

func (s *RemovePendingReplaceStep) Deployment() *Deployment

func (*RemovePendingReplaceStep) Logical

func (s *RemovePendingReplaceStep) Logical() bool

func (*RemovePendingReplaceStep) New

func (*RemovePendingReplaceStep) Old

func (*RemovePendingReplaceStep) Op

func (*RemovePendingReplaceStep) Provider

func (s *RemovePendingReplaceStep) Provider() string

func (*RemovePendingReplaceStep) Res

func (*RemovePendingReplaceStep) Type

func (*RemovePendingReplaceStep) URN

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) Deployment added in v2.15.0

func (s *ReplaceStep) Deployment() *Deployment

func (*ReplaceStep) DetailedDiff

func (s *ReplaceStep) DetailedDiff() map[string]plugin.PropertyDiff

func (*ReplaceStep) Diffs

func (s *ReplaceStep) Diffs() []resource.PropertyKey

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) Provider

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.

func (*SameStep) Apply

func (s *SameStep) Apply(preview bool) (resource.Status, StepCompleteFunc, error)

func (*SameStep) Deployment added in v2.15.0

func (s *SameStep) Deployment() *Deployment

func (*SameStep) IsSkippedCreate

func (s *SameStep) IsSkippedCreate() bool

func (*SameStep) Logical

func (s *SameStep) Logical() bool

func (*SameStep) New

func (s *SameStep) New() *resource.State

func (*SameStep) Old

func (s *SameStep) Old() *resource.State

func (*SameStep) Op

func (s *SameStep) Op() StepOp

func (*SameStep) Provider

func (s *SameStep) Provider() string

func (*SameStep) Res

func (s *SameStep) Res() *resource.State

func (*SameStep) Type

func (s *SameStep) Type() tokens.Type

func (*SameStep) URN

func (s *SameStep) URN() resource.URN

type Snapshot

type Snapshot struct {
	Manifest          Manifest             // a deployment manifest of versions, checksums, and so on.
	SecretsManager    secrets.Manager      // the manager to use use when seralizing this snapshot.
	Resources         []*resource.State    // fetches all resources and their associated states.
	PendingOperations []resource.Operation // all currently pending resource operations.
}

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

func NewSnapshot(manifest Manifest, secretsManager secrets.Manager,
	resources []*resource.State, ops []resource.Operation) *Snapshot

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) NormalizeURNReferences

func (snap *Snapshot) NormalizeURNReferences() error

NormalizeURNReferences fixes up all URN references in a snapshot to use the new URNs instead of potentially-aliased URNs. This will affect resources that are "old", and which would be expected to be updated to refer to the new names later in the deployment. But until they are, we still want to ensure that any serialization of the snapshot uses URN references which do not need to be indirected through any alias lookups, and which instead refer directly to the URN of a resource in the resources map.

Note: This method modifies the snapshot (and resource.States in the snapshot) in-place.

func (*Snapshot) VerifyIntegrity

func (snap *Snapshot) VerifyIntegrity() error

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:

  1. Provider resources must be referenceable (i.e. they must have a valid URN and ID)
  2. A resource's provider must precede the resource in the resource list
  3. Parents must precede children in the resource list
  4. Dependents must precede their dependencies in the resource list
  5. For every URN in the snapshot, there must be at most one resource with that URN that is not pending deletion
  6. 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{}

	// 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, result.Result)
}

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 NewErrorSource

func NewErrorSource(project tokens.PackageName) Source

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.

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, result.Result)
}

A SourceIterator enumerates the list of resources that a source has to offer and tracks associated state.

type SourceResourceMonitor

type SourceResourceMonitor interface {
	Address() string
	Cancel() error
	Invoke(ctx context.Context, req *pulumirpc.InvokeRequest) (*pulumirpc.InvokeResponse, error)
	ReadResource(ctx context.Context,
		req *pulumirpc.ReadResourceRequest) (*pulumirpc.ReadResourceResponse, error)
	RegisterResource(ctx context.Context,
		req *pulumirpc.RegisterResourceRequest) (*pulumirpc.RegisterResourceResponse, error)
	RegisterResourceOutputs(ctx context.Context,
		req *pulumirpc.RegisterResourceOutputsRequest) (*pbempty.Empty, error)
}

SourceResourceMonitor directs resource operations from the `Source` to various resource providers.

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.
	Deployment() *Deployment // the owning deployment.
}

Step is a specification for a deployment operation.

func NewCreateReplacementStep

func NewCreateReplacementStep(deployment *Deployment, reg RegisterResourceEvent, old, new *resource.State,
	keys, diffs []resource.PropertyKey, detailedDiff map[string]plugin.PropertyDiff, pendingDelete bool) Step

func NewCreateStep

func NewCreateStep(deployment *Deployment, reg RegisterResourceEvent, new *resource.State) Step

func NewDeleteReplacementStep

func NewDeleteReplacementStep(deployment *Deployment, old *resource.State, pendingReplace bool) Step

func NewDeleteStep

func NewDeleteStep(deployment *Deployment, old *resource.State) Step

func NewImportReplacementStep

func NewImportReplacementStep(deployment *Deployment, reg RegisterResourceEvent, original, new *resource.State,
	ignoreChanges []string) Step

func NewImportStep

func NewImportStep(deployment *Deployment, reg RegisterResourceEvent, new *resource.State,
	ignoreChanges []string) Step

func NewReadReplacementStep

func NewReadReplacementStep(deployment *Deployment, event ReadResourceEvent, old, 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

func NewReadStep(deployment *Deployment, event ReadResourceEvent, old, new *resource.State) Step

NewReadStep creates a new Read step.

func NewRefreshStep

func NewRefreshStep(deployment *Deployment, old *resource.State, done chan<- bool) Step

NewRefreshStep creates a new Refresh step.

func NewRemovePendingReplaceStep

func NewRemovePendingReplaceStep(deployment *Deployment, old *resource.State) Step

func NewReplaceStep

func NewReplaceStep(deployment *Deployment, old, new *resource.State, keys, diffs []resource.PropertyKey,
	detailedDiff map[string]plugin.PropertyDiff, pendingDelete bool) Step

func NewSameStep

func NewSameStep(deployment *Deployment, reg RegisterResourceEvent, old, new *resource.State) Step

func NewSkippedCreateStep

func NewSkippedCreateStep(deployment *Deployment, reg RegisterResourceEvent, new *resource.State) Step

NewSkippedCreateStep produces a SameStep for a resource that was created but not targeted by the user (and thus was skipped). These act as no-op steps (hence 'same') since we are not actually creating the resource, but ensure that we complete resource-registration and convey the right information downstream. For example, we will not write these into the checkpoint file.

func NewUpdateStep

func NewUpdateStep(deployment *Deployment, reg RegisterResourceEvent, old, new *resource.State,
	stables, diffs []resource.PropertyKey, detailedDiff map[string]plugin.PropertyDiff,

	ignoreChanges []string) Step

type StepCompleteFunc

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 StepExecutorEvents

type StepExecutorEvents interface {
	OnResourceStepPre(step Step) (interface{}, error)
	OnResourceStepPost(ctx interface{}, step Step, status resource.Status, err error) error
	OnResourceOutputs(step Step) error
}

StepExecutorEvents is an interface that can be used to hook resource lifecycle events.

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.
	OpRefresh              StepOp = "refresh"                // refreshing an existing resource.
	OpReadDiscard          StepOp = "discard"                // removing a resource that was read.
	OpDiscardReplaced      StepOp = "discard-replaced"       // discarding a read resource that was replaced.
	OpRemovePendingReplace StepOp = "remove-pending-replace" // removing a pending replace resource.
	OpImport               StepOp = "import"                 // import an existing resource.
	OpImportReplacement    StepOp = "import-replacement"     // replace an existing resource with an imported resource.
)

func (StepOp) Color

func (op StepOp) Color() string

Color returns a suggested color for lines of this op type.

func (StepOp) PastTense

func (op StepOp) PastTense() string

func (StepOp) Prefix

func (op StepOp) Prefix() string

Prefix returns a suggested prefix for lines of this op type.

func (StepOp) RawPrefix

func (op StepOp) RawPrefix() string

RawPrefix returns the uncolorized prefix text.

func (StepOp) Suffix

func (op StepOp) Suffix() string

Suffix returns a suggested suffix for lines of this op type.

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.

func (*Target) GetPackageConfig

func (t *Target) GetPackageConfig(pkg tokens.Package) (resource.PropertyMap, error)

GetPackageConfig returns the set of configuration parameters for the indicated package, if any.

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) Deployment added in v2.15.0

func (s *UpdateStep) Deployment() *Deployment

func (*UpdateStep) DetailedDiff

func (s *UpdateStep) DetailedDiff() map[string]plugin.PropertyDiff

func (*UpdateStep) Diffs

func (s *UpdateStep) Diffs() []resource.PropertyKey

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) Provider

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

Directories

Path Synopsis
Package providers contains the logic for managing provider resources (versioning, loading, resource operations).
Package providers contains the logic for managing provider resources (versioning, loading, resource operations).

Jump to

Keyboard shortcuts

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