deploy

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 License: Apache-2.0 Imports: 23 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 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, 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) 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.

func (*DeleteStep) Apply

func (s *DeleteStep) Apply(preview bool) (resource.Status, 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) 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).
}

Options controls 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

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

func (p *Plan) IsRefresh() bool

func (*Plan) Olds

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

func (*Plan) Prev

func (p *Plan) Prev() *Snapshot

func (*Plan) Provider

func (p *Plan) Provider(pkg tokens.Package) (plugin.Provider, error)

Provider fetches the provider for a given resource type, possibly lazily allocating the plugins for it. If a provider could not be found, or an error occurred while creating it, a non-nil error is returned.

func (*Plan) Source

func (p *Plan) Source() Source

func (*Plan) Start

func (p *Plan) Start(opts Options) (*PlanIterator, error)

Start initializes and returns an iterator that can be used to step through a plan's individual steps.

func (*Plan) Target

func (p *Plan) Target() *Target

type PlanIterator

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

PlanIterator can be used to step through and/or execute a plan's proposed actions.

func (*PlanIterator) Apply

func (iter *PlanIterator) Apply(step Step, preview bool) (resource.Status, error)

Apply performs a plan's step and records its result in the iterator's state.

func (*PlanIterator) Close

func (iter *PlanIterator) Close() error

Close terminates the iteration of this plan.

func (*PlanIterator) Creates

func (iter *PlanIterator) Creates() map[resource.URN]bool

func (*PlanIterator) Deletes

func (iter *PlanIterator) Deletes() map[resource.URN]bool

func (*PlanIterator) Done

func (iter *PlanIterator) Done() bool

func (*PlanIterator) Dones

func (iter *PlanIterator) Dones() map[*resource.State]bool

func (*PlanIterator) Next

func (iter *PlanIterator) Next() (Step, error)

Next advances the plan by a single step, and returns the next step to be performed. In doing so, it will perform evaluation of the program as much as necessary to determine the next step. If there is no further action to be taken, Next will return a nil step pointer.

func (*PlanIterator) Plan

func (iter *PlanIterator) Plan() *Plan

func (*PlanIterator) Provider

func (iter *PlanIterator) Provider(t tokens.Type) (plugin.Provider, error)

Provider fetches the provider for a given resource type, possibly lazily allocating the plugins for it. If a provider could not be found, or an error occurred while creating it, a non-nil error is returned.

func (*PlanIterator) Replaces

func (iter *PlanIterator) Replaces() map[resource.URN]bool

func (*PlanIterator) Resources

func (iter *PlanIterator) Resources() []*resource.State

func (*PlanIterator) Sames

func (iter *PlanIterator) Sames() map[resource.URN]bool

func (*PlanIterator) Steps

func (iter *PlanIterator) Steps() int

func (*PlanIterator) Updates

func (iter *PlanIterator) Updates() map[resource.URN]bool

type PlanSummary

type PlanSummary interface {
	Steps() int
	Creates() map[resource.URN]bool
	Updates() map[resource.URN]bool
	Replaces() map[resource.URN]bool
	Deletes() map[resource.URN]bool
	Sames() map[resource.URN]bool
	Resources() []*resource.State
}

PlanSummary is an interface for summarizing the progress of a plan.

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

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) *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 enforces a couple of invariants:

  1. Parents should always come before children in the resource list
  2. Dependents should always come before their dependencies in the resource list
  3. For every URN in the snapshot, there must be at most one resource with that URN that is not pending deletion
  4. The magic manifest number should change every time the snapshot is mutated

type Source

type Source interface {
	io.Closer

	// Project returns the package name of the Pulumi project we are obtaining resources from.
	Project() tokens.PackageName
	// Info returns a serializable payload that can be used to stamp snapshots for future reconciliation.
	Info() interface{}
	// IsRefresh indicates whether this source returns events source from existing state (true), and hence can simply
	// be assumed to reflect existing state, or whether the events should acted upon (false).
	IsRefresh() bool

	// Iterate begins iterating the source.  Error is non-nil upon failure; otherwise, a valid iterator is returned.
	Iterate(opts Options) (SourceIterator, error)
}

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

var NullSource Source = &nullSource{}

NullSource is a singleton source that never returns any resources. This may be used in scenarios where the "new" version of the world is meant to be empty, either for testing purposes, or removal of an existing stack.

func NewEvalSource

func NewEvalSource(plugctx *plugin.Context, runinfo *EvalRunInfo, dryRun bool) Source

NewEvalSource returns a planning source that fetches resources by evaluating a package with a set of args and a confgiuration map. This evaluation is performed using the given plugin context and may optionally use the given plugin host (or the default, if this is nil). Note that closing the eval source also closes the host.

func NewFixedSource

func NewFixedSource(ctx tokens.PackageName, steps []SourceEvent) Source

NewFixedSource returns a valid planning source that is comprised of a list of pre-computed steps.

func NewRefreshSource

func NewRefreshSource(plugctx *plugin.Context, proj *workspace.Project, target *Target, dryRun bool) Source

NewRefreshSource returns a new source that generates events based on reading an existing checkpoint state, combined with refreshing its associated resource state from the cloud provider.

type SourceEvent

type SourceEvent interface {
	// contains filtered or unexported methods
}

SourceEvent is an event associated with the enumeration of a plan. It is an intent expressed by the source program, and it is the responsibility of the engine to make it so.

type SourceIterator

type SourceIterator interface {
	io.Closer

	// Next returns the next event from the source.
	Next() (SourceEvent, error)
}

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

type Step

type Step interface {
	Apply(preview bool) (resource.Status, 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.
	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 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 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.
)

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

Jump to

Keyboard shortcuts

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