workspace

package
v0.19.1069 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	WorkDir      string
	StackName    string
	Runtime      string
	Config       map[string]string
	EnvVars      map[string]string
	StateBackend *StateBackend
	Logger       *zap.Logger
}

Options configures a Pulumi workspace.

type PreviewOpts added in v0.19.915

type PreviewOpts struct {
	// PlanOutPath, if set, makes Pulumi save an update plan to this path so
	// a subsequent Up can replay it deterministically.
	PlanOutPath string
}

PreviewOpts are optional knobs for Preview.

type PreviewResult

type PreviewResult struct {
	StdOut          string           `json:"stdout"`
	StdErr          string           `json:"stderr"`
	ChangeSummary   map[string]int   `json:"change_summary"`
	ResourceChanges []ResourceChange `json:"resource_changes,omitempty"`
	Diagnostics     []string         `json:"diagnostics,omitempty"`
}

PreviewResult contains the output of a pulumi preview with structured resource changes comparable to terraform's plan JSON.

type ResourceChange

type ResourceChange struct {
	URN          string                          `json:"urn"`
	Type         string                          `json:"type"`
	Name         string                          `json:"name"`
	Action       string                          `json:"action"`
	Diffs        []string                        `json:"diffs,omitempty"`
	DetailedDiff map[string]apitype.PropertyDiff `json:"detailed_diff,omitempty"`
	OldInputs    map[string]any                  `json:"old_inputs,omitempty"`
	NewInputs    map[string]any                  `json:"new_inputs,omitempty"`
	Provider     string                          `json:"provider,omitempty"`
}

ResourceChange represents a single resource change in a preview, structured to mirror terraform's resource_changes for UI parity.

type StateBackend

type StateBackend struct {
	APIEndpoint string
	WorkspaceID string
	Token       string
	JobID       string
}

StateBackend configures the state backend for Pulumi.

type UpOpts added in v0.19.915

type UpOpts struct {
	// PlanInPath, if set, makes Pulumi apply this previously-saved update
	// plan instead of computing a new diff. Up will fail if reality has
	// drifted from what the plan expected.
	PlanInPath string
}

UpOpts are optional knobs for Up.

type UpResult

type UpResult struct {
	StdOut  string         `json:"stdout"`
	StdErr  string         `json:"stderr"`
	Outputs map[string]any `json:"outputs"`
}

UpResult contains the output of a pulumi up.

type Workspace

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

Workspace wraps the Pulumi Automation API for programmatic Pulumi operations.

func New

func New(ctx context.Context, opts *Options) (*Workspace, error)

New creates a new Pulumi workspace with a local file backend for state.

func (*Workspace) Destroy

func (w *Workspace) Destroy(ctx context.Context) error

Destroy runs `pulumi destroy`.

func (*Workspace) DestroyPreview

func (w *Workspace) DestroyPreview(ctx context.Context) (*PreviewResult, error)

DestroyPreview generates a synthetic preview of what destroy would do by inspecting the current stack state.

func (*Workspace) EncryptionSalt added in v0.19.915

func (w *Workspace) EncryptionSalt(ctx context.Context) (string, error)

EncryptionSalt returns the stack's per-stack encryption salt. Pulumi generates this lazily the first time it encrypts a value with the passphrase secrets manager, and persists it in the stack config file. Returns "" if no salt has been generated yet.

func (*Workspace) ExportState

func (w *Workspace) ExportState(ctx context.Context) ([]byte, error)

ExportState exports the current stack state as JSON bytes.

func (*Workspace) ImportState

func (w *Workspace) ImportState(ctx context.Context, stateJSON []byte) error

ImportState imports stack state from JSON bytes.

func (*Workspace) Outputs

func (w *Workspace) Outputs(ctx context.Context) (map[string]any, error)

Outputs returns the current stack outputs.

func (*Workspace) Preview

func (w *Workspace) Preview(ctx context.Context, opts *PreviewOpts) (*PreviewResult, error)

Preview runs `pulumi preview` with event streaming to capture structured per-resource changes, producing output comparable to terraform plan JSON. When opts.PlanOutPath is set, a Pulumi update plan is also written to that path; pass it back via UpOpts.PlanInPath on a subsequent Up to skip the implicit re-preview and guard against drift between plan and apply.

func (*Workspace) SetEncryptionSalt added in v0.19.915

func (w *Workspace) SetEncryptionSalt(ctx context.Context, salt string) error

SetEncryptionSalt writes salt onto the stack's config file so that secret values encrypted under that salt elsewhere (e.g. an update plan saved by a previous job) can be decrypted here. No-op when salt is empty.

func (*Workspace) StateDir

func (w *Workspace) StateDir() string

StateDir returns the path to the local state backend directory.

func (*Workspace) Up

func (w *Workspace) Up(ctx context.Context, opts *UpOpts) (*UpResult, error)

Up runs `pulumi up` and returns the result. When opts.PlanInPath is set, Pulumi applies that previously-saved update plan instead of computing a fresh diff — faster, and refuses to apply if reality has drifted.

Jump to

Keyboard shortcuts

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