deploy

package
v3.144.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 59 Imported by: 4

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

View Source
const (
	OpSame                 display.StepOp = "same"                   // nothing to do.
	OpCreate               display.StepOp = "create"                 // creating a new resource.
	OpUpdate               display.StepOp = "update"                 // updating an existing resource.
	OpDelete               display.StepOp = "delete"                 // deleting an existing resource.
	OpReplace              display.StepOp = "replace"                // replacing a resource with a new one.
	OpCreateReplacement    display.StepOp = "create-replacement"     // creating a new resource for a replacement.
	OpDeleteReplaced       display.StepOp = "delete-replaced"        // deleting an existing resource after replacement.
	OpRead                 display.StepOp = "read"                   // reading an existing resource.
	OpReadReplacement      display.StepOp = "read-replacement"       // reading an existing resource for a replacement.
	OpRefresh              display.StepOp = "refresh"                // refreshing an existing resource.
	OpReadDiscard          display.StepOp = "discard"                // removing a resource that was read.
	OpDiscardReplaced      display.StepOp = "discard-replaced"       // discarding a read resource that was replaced.
	OpRemovePendingReplace display.StepOp = "remove-pending-replace" // removing a pending replace resource.
	OpImport               display.StepOp = "import"                 // import an existing resource.
	OpImportReplacement    display.StepOp = "import-replacement"     // replace an existing resource

)

Variables

StepOps contains the full set of step operation types.

Functions

func Color added in v3.35.2

func Color(op display.StepOp) string

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

func ColorProgress added in v3.35.2

func ColorProgress(op display.StepOp) string

ColorProgress returns a suggested coloring for lines of this of type which are progressing.

func ConstrainedTo added in v3.35.2

func ConstrainedTo(op display.StepOp, constraint display.StepOp) bool

ConstrainedTo returns true if this operation is no more impactful than the constraint.

func IsReplacementStep added in v3.114.0

func IsReplacementStep(op display.StepOp) bool

func PastTense added in v3.35.2

func PastTense(op display.StepOp) string

func Prefix added in v3.35.2

func Prefix(op display.StepOp, done bool) string

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

func RawPrefix added in v3.35.2

func RawPrefix(op display.StepOp) string

RawPrefix returns the uncolorized prefix text.

func SnapshotIntegrityErrorf added in v3.130.0

func SnapshotIntegrityErrorf(format string, args ...interface{}) error

Creates a new snapshot integrity error with a message produced by the given format string and arguments. Supports wrapping errors with %w. Snapshot integrity errors are raised by Snapshot.VerifyIntegrity when a problem is detected with a snapshot (e.g. missing or out-of-order dependencies, or unparseable data).

func Suffix added in v3.35.2

func Suffix(op display.StepOp) string

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

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 CallbacksClient added in v3.107.0

type CallbacksClient struct {
	pulumirpc.CallbacksClient
	// contains filtered or unexported fields
}

func NewCallbacksClient added in v3.107.0

func NewCallbacksClient(conn *grpc.ClientConn) *CallbacksClient

func (*CallbacksClient) Close added in v3.107.0

func (c *CallbacksClient) Close() error

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 (*CreateStep) Deployment

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) Fail added in v3.114.0

func (s *CreateStep) Fail()

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() display.StepOp

func (*CreateStep) Provider

func (s *CreateStep) Provider() string

func (*CreateStep) Res

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

func (*CreateStep) Skip added in v3.114.0

func (s *CreateStep) Skip()

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 (*DeleteStep) Deployment

func (s *DeleteStep) Deployment() *Deployment

func (*DeleteStep) Fail added in v3.114.0

func (s *DeleteStep) Fail()

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() display.StepOp

func (*DeleteStep) Provider

func (s *DeleteStep) Provider() string

func (*DeleteStep) Res

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

func (*DeleteStep) Skip added in v3.114.0

func (s *DeleteStep) Skip()

func (*DeleteStep) Type

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

func (*DeleteStep) URN

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

type Deployment

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

func NewDeployment(
	ctx *plugin.Context,
	opts *Options,
	events Events,
	target *Target,
	prev *Snapshot,
	plan *Plan,
	source Source,
	localPolicyPackPaths []string,
	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

func NewImportDeployment(
	ctx *plugin.Context,
	opts *Options,
	events Events,
	target *Target,
	projectName tokens.PackageName,
	imports []Import,
) (*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

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

func (*Deployment) Diag

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

func (*Deployment) EnsureProvider added in v3.69.0

func (d *Deployment) EnsureProvider(provider string) error

EnsureProvider ensures that the provider for the given resource is available in the registry. It assumes the provider is available in the previous snapshot.

func (*Deployment) Execute

func (d *Deployment) Execute(ctx context.Context) (*Plan, error)

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

func (*Deployment) GetProvider

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

func (*Deployment) Olds

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

func (*Deployment) Prev

func (d *Deployment) Prev() *Snapshot

func (*Deployment) SameProvider added in v3.9.1

func (d *Deployment) SameProvider(res *resource.State) error

func (*Deployment) Source

func (d *Deployment) Source() Source

func (*Deployment) Target

func (d *Deployment) Target() *Target

type EvalRunInfo

type EvalRunInfo struct {
	// the package metadata.
	Proj *workspace.Project `json:"proj" yaml:"proj"`
	// the package's working directory.
	Pwd string `json:"pwd" yaml:"pwd"`
	// the path to the program.
	Program string `json:"program" yaml:"program"`
	// the path to the project's directory.
	ProjectRoot string `json:"projectRoot,omitempty" yaml:"projectRoot,omitempty"`
	// any arguments to pass to the package.
	Args []string `json:"args,omitempty" yaml:"args,omitempty"`
	// the target being deployed into.
	Target *Target `json:"target,omitempty" yaml:"target,omitempty"`
}

EvalRunInfo provides information required to execute and deploy resources within a package.

type EvalSourceOptions added in v3.120.0

type EvalSourceOptions struct {
	// true if the evaluation is producing resources for a dry-run/preview.
	DryRun bool
	// the degree of parallelism for resource operations (<=1 for serial).
	Parallel int32
	// true to disable resource reference support.
	DisableResourceReferences bool
	// true to disable output value support.
	DisableOutputValues bool
	// AttachDebugger to launch the language host in debug mode.
	AttachDebugger bool
}

EvalRunInfoOptions provides options for configuring an evaluation source.

type Events

type Events interface {
	StepExecutorEvents
	PolicyEvents
}

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

type GoalPlan added in v3.24.0

type GoalPlan struct {
	// the type of resource.
	Type tokens.Type
	// the name for the resource's URN.
	Name string
	// true if this resource is custom, managed by a plugin.
	Custom bool
	// the resource's checked input properties we expect to change.
	InputDiff PlanDiff
	// the resource's output properties we expect to change (only set for RegisterResourceOutputs)
	OutputDiff PlanDiff
	// an optional parent URN for this resource.
	Parent resource.URN
	// true to protect this resource from deletion.
	Protect bool
	// dependencies of this resource object.
	Dependencies []resource.URN
	// the provider to use for this resource.
	Provider string
	// the set of dependencies that affect each property.
	PropertyDependencies map[resource.PropertyKey][]resource.URN
	// true if this resource should be deleted prior to replacement.
	DeleteBeforeReplace *bool
	// a list of property names to ignore during changes.
	IgnoreChanges []string
	// outputs that should always be treated as secrets.
	AdditionalSecretOutputs []resource.PropertyKey
	// Structured Alias objects to be assigned to this resource
	Aliases []resource.Alias
	// the expected ID of the resource, if any.
	ID resource.ID
	// an optional config object for resource options
	CustomTimeouts resource.CustomTimeouts
}

Goal is a desired state for a resource object. Normally it represents a subset of the resource's state expressed by a program, however if Output is true, it represents a more complete, post-deployment view of the state.

func NewGoalPlan added in v3.24.0

func NewGoalPlan(inputDiff *resource.ObjectDiff, goal *resource.Goal) *GoalPlan

type Import

type Import struct {
	Type              tokens.Type       // The type token for the resource. Required.
	Name              string            // 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.
	PluginDownloadURL string            // The provider PluginDownloadURL to use for the resource, if any.
	PluginChecksums   map[string][]byte // The provider checksums to use for the resource, if any.
	Protect           bool              // Whether to mark the resource as protected after import
	Properties        []string          // Which properties to include (Defaults to required properties)

	// True if this import should create an empty component resource. ID must not be set if this is used.
	Component bool
	// True if this is a remote component resource. Component must be true if this is true.
	Remote bool
}

An Import specifies a resource to import.

type ImportOptions

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 (*ImportStep) Deployment

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) Fail added in v3.114.0

func (s *ImportStep) Fail()

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() display.StepOp

func (*ImportStep) Provider

func (s *ImportStep) Provider() string

func (*ImportStep) Res

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

func (*ImportStep) Skip added in v3.114.0

func (s *ImportStep) Skip()

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 DeserializeManifest added in v3.22.0

func DeserializeManifest(m apitype.ManifestV1) (*Manifest, error)

DeserializeManifest deserializes a typed ManifestV1 into a `deploy.Manifest`.

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.

func (Manifest) Serialize added in v3.22.0

func (m Manifest) Serialize() apitype.ManifestV1

Serialize turns a manifest into a data structure suitable for serialization.

type Options

type Options struct {
	// true if the process is a dry run (that is, won't make any changes), such as
	// during a preview action or when previewing another action like refresh or
	// destroy.
	DryRun bool
	// the degree of parallelism for resource operations (<=1 for serial).
	Parallel int32
	// whether or not to refresh before executing the deployment.
	Refresh bool
	// whether or not to exit after refreshing (i.e. this is specifically a
	// refresh operation).
	RefreshOnly bool
	// if specified, only operate on the specified resources.
	Targets UrnTargets
	// if specified, mark the specified resources for replacement.
	ReplaceTargets UrnTargets
	// true if target dependents should be computed automatically.
	TargetDependents bool
	// whether or not to use legacy diffing behavior.
	UseLegacyDiff bool
	// true if the deployment should use legacy refresh diffing behavior and
	// report only output changes, as opposed to computing diffs against desired
	// state.
	UseLegacyRefreshDiff bool
	// true to disable resource reference support.
	DisableResourceReferences bool
	// true to disable output value support.
	DisableOutputValues bool
	// true to enable plan generation.
	GeneratePlan bool
	// true if we should continue with the deployment even if a resource operation fails.
	ContinueOnError bool
	// Autonamer can resolve user's preference for custom autonaming options for a given resource.
	Autonamer autonaming.Autonamer
}

Options controls the deployment process.

func (Options) DegreeOfParallelism

func (o Options) DegreeOfParallelism() int32

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 Plan added in v3.24.0

type Plan struct {
	ResourcePlans map[resource.URN]*ResourcePlan
	Manifest      Manifest
	// The configuration in use during the plan.
	Config config.Map
}

A Plan is a mapping from URNs to ResourcePlans. The plan defines an expected set of resources and the expected inputs and operations for each. The inputs and operations are treated as constraints, and may allow for inputs or operations that do not exactly match those recorded in the plan. In the case of inputs, unknown values in the plan accept any value (including no value) as valid. For operations, a same step is allowed in place of an update or a replace step, and an update is allowed in place of a replace step. All resource options are required to match exactly.

func NewPlan added in v3.24.0

func NewPlan(config config.Map) Plan

func (*Plan) Clone added in v3.24.0

func (plan *Plan) Clone() *Plan

Clone makes a deep copy of the given plan and returns a pointer to the clone.

type PlanDiff added in v3.24.0

type PlanDiff struct {
	Adds    resource.PropertyMap   // the resource's properties we expect to add.
	Deletes []resource.PropertyKey // the resource's properties we expect to delete.
	Updates resource.PropertyMap   // the resource's properties we expect to update.
}

PlanDiff holds the results of diffing two object property maps.

func NewPlanDiff added in v3.24.0

func NewPlanDiff(inputDiff *resource.ObjectDiff) PlanDiff

func (*PlanDiff) ContainsDelete added in v3.24.0

func (planDiff *PlanDiff) ContainsDelete(key resource.PropertyKey) bool

Returns true if the Deletes array contains the given key

func (*PlanDiff) MakeError added in v3.24.0

func (planDiff *PlanDiff) MakeError(
	key resource.PropertyKey,
	actualOperation string,
	actualValue *resource.PropertyValue,
) string

type PolicyEvents

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

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 PruneResult added in v3.135.1

type PruneResult struct {
	// The URN of the resource before it was pruned.
	OldURN resource.URN
	// The URN of the resource after it was pruned. This will differ from the OldURN if the resource URN was changed as a
	// result of pruning (e.g. because a missing parent dependency was removed).
	NewURN resource.URN
	// True if and only if the resource was pending deletion.
	Delete bool
	// A list of dependencies that were removed as a result of pruning.
	RemovedDependencies []resource.StateDependency
}

A PruneResult describes the changes made to a resource in a snapshot as a result of pruning dangling dependencies.

type QuerySource

type QuerySource interface {
	Wait() error
}

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]workspace.PluginSpec,
	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() string
	// 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
	// The source position of the resource read
	SourcePosition() string
}

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

type ReadResult

type ReadResult struct {
	State  *resource.State
	Result ResultState
}

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 (*ReadStep) Deployment

func (s *ReadStep) Deployment() *Deployment

func (*ReadStep) Fail added in v3.114.0

func (s *ReadStep) Fail()

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() display.StepOp

func (*ReadStep) Provider

func (s *ReadStep) Provider() string

func (*ReadStep) Res

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

func (*ReadStep) Skip added in v3.114.0

func (s *ReadStep) Skip()

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 (*RefreshStep) Deployment

func (s *RefreshStep) Deployment() *Deployment

func (*RefreshStep) DetailedDiff added in v3.120.0

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

func (*RefreshStep) Diffs added in v3.120.0

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

func (*RefreshStep) Fail added in v3.114.0

func (s *RefreshStep) Fail()

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() display.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() display.StepOp

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

func (*RefreshStep) Skip added in v3.114.0

func (s *RefreshStep) Skip()

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.
	Result ResultState     // the result of the registration.
}

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

func (s *RemovePendingReplaceStep) Deployment() *Deployment

func (*RemovePendingReplaceStep) Fail added in v3.114.0

func (s *RemovePendingReplaceStep) Fail()

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) Skip added in v3.114.0

func (s *RemovePendingReplaceStep) Skip()

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 (*ReplaceStep) Deployment

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) Fail added in v3.114.0

func (s *ReplaceStep) Fail()

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() display.StepOp

func (*ReplaceStep) Provider

func (s *ReplaceStep) Provider() string

func (*ReplaceStep) Res

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

func (*ReplaceStep) Skip added in v3.114.0

func (s *ReplaceStep) Skip()

func (*ReplaceStep) Type

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

func (*ReplaceStep) URN

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

type ResourcePlan added in v3.24.0

type ResourcePlan struct {
	Goal    *GoalPlan
	Ops     []display.StepOp
	Outputs resource.PropertyMap
	// The random byte seed used for resource goal.
	Seed []byte
}

A ResourcePlan represents the planned goal state and resource operations for a single resource. The operations are ordered.

type ResultState added in v3.114.0

type ResultState int
const (
	ResultStateSuccess ResultState = iota
	ResultStateFailed
	ResultStateSkipped
)

type SameStep

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

SameStep is a mutating step that does nothing.

func (*SameStep) Apply

func (*SameStep) Deployment

func (s *SameStep) Deployment() *Deployment

func (*SameStep) Fail added in v3.114.0

func (s *SameStep) Fail()

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() display.StepOp

func (*SameStep) Provider

func (s *SameStep) Provider() string

func (*SameStep) Res

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

func (*SameStep) Skip added in v3.114.0

func (s *SameStep) Skip()

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 serializing this snapshot.
	Resources         []*resource.State    // fetches all resources and their associated states.
	PendingOperations []resource.Operation // all currently pending resource operations.
	Metadata          SnapshotMetadata     // metadata associated with the snapshot.
}

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,
	metadata SnapshotMetadata,
) *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() (*Snapshot, 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 does not modify the snapshot (and resource.States in the snapshot) in-place, but returns an independent structure, with minimal copying necessary.

func (*Snapshot) Prune added in v3.135.0

func (snap *Snapshot) Prune() []PruneResult

Prune removes all dangling dependencies from this snapshot, *which is assumed to be topologically sorted with respect to dependencies*. A dangling dependency is one which points a resource which is not present in the snapshot. An absence of dangling resources is a necessary but not sufficient condition for a snapshot to be valid; the VerifyIntegrity method should be used to ensure that a snapshot is well-formed.

Prune returns a list of PruneResults, each of which describes the changes made to a resource in the snapshot. These changes include any URN rewriting that was necessary to remove dangling parent dependencies, as well as the set of dependencies that were removed.

func (*Snapshot) Toposort added in v3.135.0

func (snap *Snapshot) Toposort() error

Toposort attempts sorts this snapshot so that it is topologically sorted with respect to dependencies (where a dependency could be a provider, parent-child relationship, dependency, and so on). Resources in the resulting snapshot will appear in an order such that all dependencies of a resource will appear before the resource itself. Sorting may fail if there are cycles in the snapshot, or in cases where references between resources are genuinely ambiguous (e.g. if there are multiple deleted versions of a resource with the same URN that cannot be meaningfully differentiated). As a result of this, callers should be mindful that the snapshot could be left in an invalid state if sorting terminates mid-way through due to an error.

This method is generally only used for repairing invalid snapshots, since most snapshots are built in response to resource registrations from a program, and programs are required to submit such registrations in a dependency-respecting order. Note that sortedness is a necessary but not sufficient condition for a snapshot to be valid; the VerifyIntegrity method should be used to ensure that a snapshot is well-formed.

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

N.B. Constraints 2 does NOT apply for resources that are pending deletion. This is because they may have had their provider replaced but not yet be replaced themselves yet (due to a partial update). Pending replacement resources also can't just be wholly removed from the snapshot because they may have dependents that are not being replaced and thus would fail validation if the pending replacement resource was removed and not re-created (again due to partial updates).

type SnapshotIntegrityError added in v3.130.0

type SnapshotIntegrityError struct {
	// The underlying error that caused this integrity error, if applicable.
	Err error

	// The operation which caused the error. Defaults to SnapshotIntegrityWrite.
	Op SnapshotIntegrityOperation

	// The stack trace at the point the error was raised.
	Stack []byte

	// Metadata about the operation that caused the error, if available.
	Metadata *SnapshotIntegrityErrorMetadata
}

A snapshot integrity error is raised when a snapshot is found to be malformed or invalid in some way (e.g. missing or out-of-order dependencies, or unparseable data).

func AsSnapshotIntegrityError added in v3.130.0

func AsSnapshotIntegrityError(err error) (*SnapshotIntegrityError, bool)

Returns a tuple in which the second element is true if and only if any error in the given error's tree is a SnapshotIntegrityError. In that case, the first element will be the first SnapshotIntegrityError in the tree. In the event that there is no such SnapshotIntegrityError, the first element will be nil.

func (*SnapshotIntegrityError) Error added in v3.130.0

func (s *SnapshotIntegrityError) Error() string

func (*SnapshotIntegrityError) ForRead added in v3.131.0

Returns a copy of the given snapshot integrity error with the operation set to SnapshotIntegrityRead and metadata set to the given snapshot's integrity error metadata.

func (*SnapshotIntegrityError) Unwrap added in v3.130.0

func (s *SnapshotIntegrityError) Unwrap() error

type SnapshotIntegrityErrorMetadata added in v3.135.0

type SnapshotIntegrityErrorMetadata struct {
	// The version of the Pulumi engine that caused the integrity error.
	Version string
	// The command/invocation of the Pulumi engine that caused the integrity error.
	Command string
	// The error message associated with the integrity error.
	Error string
}

SnapshotIntegrityErrorMetadata contains metadata about a snapshot integrity error, such as the version and invocation of the Pulumi engine that caused it.

type SnapshotIntegrityOperation added in v3.131.0

type SnapshotIntegrityOperation int

The set of operations alongside which snapshot integrity checks can be performed.

const (
	// Snapshot integrity checks were performed at write time.
	SnapshotIntegrityWrite SnapshotIntegrityOperation = 0
	// Snapshot integrity checks were performed at read time.
	SnapshotIntegrityRead SnapshotIntegrityOperation = 1
)

type SnapshotMetadata added in v3.135.0

type SnapshotMetadata struct {
	// Metadata associated with any integrity error affecting the snapshot.
	IntegrityErrorMetadata *SnapshotIntegrityErrorMetadata
}

SnapshotMetadata contains metadata about a snapshot.

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, providers ProviderSource) (SourceIterator, error)
}

A Source can generate a new set of resources that the planner will process accordingly.

var NullSource Source = &nullSource{}

Deprecated: A NullSource with no project name.

func NewErrorSource

func NewErrorSource(project tokens.PackageName) Source

func NewEvalSource

func NewEvalSource(
	plugctx *plugin.Context,
	runinfo *EvalRunInfo,
	defaultProviderInfo map[tokens.Package]workspace.PluginSpec,
	opts EvalSourceOptions,
) 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 NewNullSource added in v3.20.0

func NewNullSource(project tokens.PackageName) Source

NullSource is a 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.

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 SourceResourceMonitor

type SourceResourceMonitor interface {
	Address() string
	Cancel() error
	AbortChan() <-chan bool
	Invoke(ctx context.Context, req *pulumirpc.ResourceInvokeRequest) (*pulumirpc.InvokeResponse, error)
	Call(ctx context.Context, req *pulumirpc.ResourceCallRequest) (*pulumirpc.CallResponse, 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) (*emptypb.Empty, error)
}

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

type Step

type Step interface {
	// Apply applies 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() (resource.Status, StepCompleteFunc, error)

	// the operation performed by this step.
	Op() display.StepOp
	// the resource URN (for before and after).
	URN() resource.URN
	// the type of the resource affected by this step.
	Type() tokens.Type
	// the provider reference for the resource affected by this step.
	Provider() string
	// the state of the resource before performing this step.
	Old() *resource.State
	// the state of the resource after performing this step.
	New() *resource.State
	// the latest state for the resource that is known (worst case, old).
	Res() *resource.State
	// true if this step represents a logical operation in the program.
	Logical() bool
	// the deployment to which this step belongs.
	Deployment() *Deployment

	// Calling Fail will mark the step as failed.
	Fail()
	// Calling Skip will mark the step as skipped.
	Skip()
}

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,
	otherDeletions map[resource.URN]bool,
	old *resource.State,
	pendingReplace bool,
) Step

func NewDeleteStep

func NewDeleteStep(deployment *Deployment, otherDeletions map[resource.URN]bool, old *resource.State) Step

func NewImportReplacementStep

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

func NewImportStep

func NewImportStep(deployment *Deployment, reg RegisterResourceEvent, new *resource.State,
	ignoreChanges []string, randomSeed []byte,
) 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 StepApplyFailed added in v3.92.0

type StepApplyFailed struct {
	Err error
}

StepApplyFailed is a sentinel error for errors that arise when step application fails. We (the step executor) are not responsible for reporting those errors so this sentinel ensures that we don't do so.

func (StepApplyFailed) Error added in v3.92.0

func (saf StepApplyFailed) Error() string

func (StepApplyFailed) Unwrap added in v3.92.0

func (saf StepApplyFailed) Unwrap() error

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. You _should not_ modify the resource state in these functions -- doing so will race with the snapshot writing code.

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 Target

type Target struct {
	Name         tokens.StackName // the target stack name.
	Organization tokens.Name      // the target organization name (if any).
	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 TransformFunction added in v3.107.0

type TransformFunction func(
	ctx context.Context,
	name, typ string, custom bool, parent resource.URN,
	props resource.PropertyMap,
	opts *pulumirpc.TransformResourceOptions,
) (resource.PropertyMap, *pulumirpc.TransformResourceOptions, error)

A transformation function that can be applied to a resource.

type TransformInvokeFunction added in v3.124.0

A transformation function that can be applied to an invoke.

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 (*UpdateStep) Deployment

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) Fail added in v3.114.0

func (s *UpdateStep) Fail()

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() display.StepOp

func (*UpdateStep) Provider

func (s *UpdateStep) Provider() string

func (*UpdateStep) Res

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

func (*UpdateStep) Skip added in v3.114.0

func (s *UpdateStep) Skip()

func (*UpdateStep) Type

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

func (*UpdateStep) URN

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

type UrnTargets added in v3.44.2

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

An immutable set of urns to target with an operation.

The zero value of UrnTargets is the set of all URNs.

func NewUrnTargets added in v3.44.2

func NewUrnTargets(urnOrGlobs []string) UrnTargets

Create a new set of targets.

Each element is considered a glob if it contains any '*' and an URN otherwise. No other URN validation is performed.

If len(urnOrGlobs) == 0, an unconstrained set will be created.

func NewUrnTargetsFromUrns added in v3.44.2

func NewUrnTargetsFromUrns(urns []resource.URN) UrnTargets

Create a new set of targets from fully resolved URNs.

func (UrnTargets) Clone added in v3.90.0

func (t UrnTargets) Clone() UrnTargets

Return a copy of the UrnTargets

func (UrnTargets) Contains added in v3.44.2

func (t UrnTargets) Contains(urn resource.URN) bool

Check if Targets contains the URN.

If method receiver is not initialized, `true` is always returned.

func (UrnTargets) IsConstrained added in v3.44.2

func (t UrnTargets) IsConstrained() bool

Return if the target set constrains the set of acceptable URNs.

func (UrnTargets) Literals added in v3.44.2

func (t UrnTargets) Literals() []resource.URN

URN literals specified as targets.

It doesn't make sense to iterate over all targets, since the list of targets may be infinite.

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