deploy

package
v0.15.1-rc2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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.

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 plan.
	RefreshOnly bool   // whether or not to exit after refreshing.
}

Options controls the planning and deployment process.

func (Options) DegreeOfParallelism added in v0.15.0

func (o Options) DegreeOfParallelism() int

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

func (p *Plan) Ctx() *plugin.Context

func (*Plan) Diag

func (p *Plan) Diag() diag.Sink

func (*Plan) Execute added in v0.15.1

func (p *Plan) Execute(ctx context.Context, opts Options, preview bool) error

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

func (*Plan) GetProvider added in v0.15.0

func (p *Plan) GetProvider(ref providers.Reference) (plugin.Provider, bool)

func (*Plan) Olds

func (p *Plan) Olds() map[resource.URN]*resource.State

func (*Plan) Prev

func (p *Plan) Prev() *Snapshot

func (*Plan) Source

func (p *Plan) Source() Source

func (*Plan) Target

func (p *Plan) Target() *Target

type PlanPendingOperationsError added in v0.15.0

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

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 ReadResult struct {
	State *resource.State
}

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.

func (*ReadStep) Apply added in v0.15.0

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

func (*ReadStep) Logical added in v0.15.0

func (s *ReadStep) Logical() bool

func (*ReadStep) New added in v0.15.0

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

func (*ReadStep) Old added in v0.15.0

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

func (*ReadStep) Op added in v0.15.0

func (s *ReadStep) Op() StepOp

func (*ReadStep) Plan added in v0.15.0

func (s *ReadStep) Plan() *Plan

func (*ReadStep) Provider added in v0.15.0

func (s *ReadStep) Provider() string

func (*ReadStep) Res added in v0.15.0

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

func (*ReadStep) Type added in v0.15.0

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

func (*ReadStep) URN added in v0.15.0

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

type RefreshStep added in v0.15.1

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 plan executor as the optional first step in plan execution.

func (*RefreshStep) Apply added in v0.15.1

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

func (*RefreshStep) Logical added in v0.15.1

func (s *RefreshStep) Logical() bool

func (*RefreshStep) New added in v0.15.1

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

func (*RefreshStep) Old added in v0.15.1

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

func (*RefreshStep) Op added in v0.15.1

func (s *RefreshStep) Op() StepOp

func (*RefreshStep) Plan added in v0.15.1

func (s *RefreshStep) Plan() *Plan

func (*RefreshStep) Provider added in v0.15.1

func (s *RefreshStep) Provider() string

func (*RefreshStep) Res added in v0.15.1

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

func (*RefreshStep) ResultOp added in v0.15.1

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 added in v0.15.1

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

func (*RefreshStep) URN added in v0.15.1

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

func (*SameStep) Apply

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

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

func (s *SameStep) Plan() *Plan

func (*SameStep) Provider added in v0.15.0

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.
	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, 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) 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, 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 NewErrorSource added in v0.15.1

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, 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 NewDeleteReplacementStep

func NewDeleteReplacementStep(plan *Plan, old *resource.State, pendingDelete bool) Step

func NewDeleteStep

func NewDeleteStep(plan *Plan, old *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 NewRefreshStep added in v0.15.1

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

NewRefreshStep creates a new Refresh step.

func NewReplaceStep

func NewReplaceStep(plan *Plan, old *resource.State, new *resource.State,
	keys []resource.PropertyKey, pendingDelete bool) Step

func NewSameStep

func NewSameStep(plan *Plan, reg RegisterResourceEvent, old *resource.State, new *resource.State) Step

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.
	OpRefresh           StepOp = "refresh"            // refreshing an existing 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) (map[config.Key]string, 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) 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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