stageui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package stageui provides drift item types for the stage command. All core drift types are defined in the driftui package and re-exported here for backwards compatibility.

Index

Constants

View Source
const (
	DriftItemTypeResource = driftui.DriftItemTypeResource
	DriftItemTypeLink     = driftui.DriftItemTypeLink
	DriftItemTypeChild    = driftui.DriftItemTypeChild
)

Constant aliases for backwards compatibility

View Source
const (
	ItemTypeResource = shared.ItemTypeResource
	ItemTypeChild    = shared.ItemTypeChild
	ItemTypeLink     = shared.ItemTypeLink

	ActionCreate   = shared.ActionCreate
	ActionUpdate   = shared.ActionUpdate
	ActionDelete   = shared.ActionDelete
	ActionRecreate = shared.ActionRecreate
	ActionNoChange = shared.ActionNoChange
)

Re-export constants for backwards compatibility.

View Source
const MaxExpandDepth = 2

MaxExpandDepth is the maximum nesting depth for expanding child blueprints. Children at this depth will be shown but cannot be expanded further in the left pane. Their details are still viewable in the right pane when selected.

Variables

View Source
var BuildDriftItems = driftui.BuildDriftItems

BuildDriftItems creates DriftItems from a ReconciliationCheckResult.

View Source
var HumanReadableAction = driftui.HumanReadableAction

HumanReadableAction converts a ReconciliationAction to a human-readable label.

View Source
var HumanReadableDriftType = driftui.HumanReadableDriftType

HumanReadableDriftType converts a ReconciliationType to a short uppercase label.

View Source
var HumanReadableDriftTypeLabel = driftui.HumanReadableDriftTypeLabel

HumanReadableDriftTypeLabel converts a ReconciliationType to a human-readable label.

View Source
var SortDriftItems = driftui.SortDriftItems

SortDriftItems sorts items alphabetically by name.

Functions

func BuildExportChangeHierarchy

func BuildExportChangeHierarchy(
	rootChanges *changes.BlueprintChanges,
	rootName string,
) []splitpane.Item

BuildExportChangeHierarchy builds a flat list of StageExportsInstanceItems from BlueprintChanges, suitable for display in the exports view.

func HasAnyExportChanges

func HasAnyExportChanges(bc *changes.BlueprintChanges) bool

HasAnyExportChanges checks if BlueprintChanges has any real export changes (either directly or in child blueprints). Export changes that are just "resolve on deploy" placeholders (newValue is nil and path is in ResolveOnDeploy) are not considered actual changes.

func HasAnyExportsToShow

func HasAnyExportsToShow(bc *changes.BlueprintChanges) bool

HasAnyExportsToShow checks if BlueprintChanges has any exports to display (including resolve-on-deploy placeholders). This is used when there are actual deployment changes and we want to show all exports.

func ToSplitPaneItems

func ToSplitPaneItems(items []StageItem) []splitpane.Item

ToSplitPaneItems converts a slice of StageItems to splitpane.Items.

Types

type ActionType

type ActionType = shared.ActionType

Type aliases for backwards compatibility with shared types.

type ChildChangeState

type ChildChangeState struct {
	Name      string
	Action    ActionType
	Changes   *changes.BlueprintChanges
	New       bool
	Removed   bool
	Timestamp int64
}

ChildChangeState tracks the state of a child blueprint's changes.

type DriftDetailsRenderer

type DriftDetailsRenderer = driftui.DriftDetailsRenderer

Type aliases for backwards compatibility

type DriftFooterRenderer

type DriftFooterRenderer = driftui.DriftFooterRenderer

Type aliases for backwards compatibility

type DriftItem

type DriftItem = driftui.DriftItem

Type aliases for backwards compatibility

type DriftItemType

type DriftItemType = driftui.DriftItemType

Type aliases for backwards compatibility

type DriftSectionGrouper

type DriftSectionGrouper = driftui.DriftSectionGrouper

Type aliases for backwards compatibility

type InstanceStateFetchedMsg

type InstanceStateFetchedMsg struct {
	InstanceState *state.InstanceState
}

InstanceStateFetchedMsg is sent when instance state has been successfully fetched.

type ItemType

type ItemType = shared.ItemType

Type aliases for backwards compatibility with shared types.

type LinkChangeState

type LinkChangeState struct {
	ResourceAName string
	ResourceBName string
	Action        ActionType
	Changes       *provider.LinkChanges
	New           bool
	Removed       bool
	Timestamp     int64
}

LinkChangeState tracks the state of a link's changes.

type MainModel

type MainModel struct {
	Error error
	// contains filtered or unexported fields
}

MainModel is the top-level model for the stage command TUI. It manages the session state and delegates to sub-models.

func NewStageApp

func NewStageApp(cfg StageAppConfig) (*MainModel, error)

NewStageApp creates a new stage application with the given configuration.

func (MainModel) Init

func (m MainModel) Init() tea.Cmd

func (*MainModel) NeedsOptionsInput

func (m *MainModel) NeedsOptionsInput() bool

NeedsOptionsInput returns whether the model requires options input.

func (*MainModel) Stage

func (m *MainModel) Stage() tea.Model

Stage returns the stage model (as tea.Model interface).

func (*MainModel) StageOptionsForm

func (m *MainModel) StageOptionsForm() *StageOptionsFormModel

StageOptionsForm returns the stage options form model.

func (MainModel) Update

func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (MainModel) View

func (m MainModel) View() string

type OverviewItem

type OverviewItem struct {
	Item        StageItem
	ElementPath string
}

OverviewItem holds a stage item with its full element path for overview display.

type ResourceChangeState

type ResourceChangeState struct {
	Name      string
	Action    ActionType
	Changes   *provider.Changes
	New       bool
	Removed   bool
	Recreate  bool
	Timestamp int64
}

ResourceChangeState tracks the state of a resource's changes.

type StageAppConfig

type StageAppConfig struct {
	DeployEngine           engine.DeployEngine
	Logger                 *zap.Logger
	BlueprintFile          string
	IsDefaultBlueprintFile bool
	InstanceID             string
	InstanceName           string
	Destroy                bool
	SkipDriftCheck         bool
	Styles                 *stylespkg.Styles
	Headless               bool
	HeadlessWriter         io.Writer
	JSONMode               bool
	Preflight              tea.Model
}

StageAppConfig holds the configuration for creating a new stage application.

type StageCompleteMsg

type StageCompleteMsg struct {
	ChangesetID   string
	Changes       *changes.BlueprintChanges
	Items         []StageItem
	InstanceState *state.InstanceState // Pre-deployment instance state for unchanged items
}

StageCompleteMsg is a message indicating that staging has completed. This is emitted to allow parent models to react to staging completion.

type StageDetailsRenderer

type StageDetailsRenderer struct {
	// MaxExpandDepth is used to determine when to show the drill-down hint
	MaxExpandDepth int
	// NavigationStackDepth is the current depth of navigation stack
	NavigationStackDepth int
}

StageDetailsRenderer implements splitpane.DetailsRenderer for stage UI.

func (*StageDetailsRenderer) RenderDetails

func (r *StageDetailsRenderer) RenderDetails(item splitpane.Item, width int, s *styles.Styles) string

RenderDetails renders the right pane content for a selected item.

type StageErrorMsg

type StageErrorMsg struct {
	Err error
}

StageErrorMsg is a message containing an error from the staging process.

type StageEventMsg

type StageEventMsg types.ChangeStagingEvent

StageEventMsg is a message containing a change staging event.

type StageExportsDetailsRenderer

type StageExportsDetailsRenderer struct{}

StageExportsDetailsRenderer renders export change details for a selected instance.

func (*StageExportsDetailsRenderer) RenderDetails

func (r *StageExportsDetailsRenderer) RenderDetails(item splitpane.Item, width int, s *styles.Styles) string

RenderDetails renders the export change details for the selected instance.

type StageExportsFooterRenderer

type StageExportsFooterRenderer struct{}

StageExportsFooterRenderer renders the footer for the stage exports view.

func (*StageExportsFooterRenderer) RenderFooter

func (r *StageExportsFooterRenderer) RenderFooter(model *splitpane.Model, s *styles.Styles) string

RenderFooter renders the exports view footer with navigation hints.

type StageExportsHeaderRenderer

type StageExportsHeaderRenderer struct {
	InstanceName string
}

StageExportsHeaderRenderer renders the header for the stage exports view.

func (*StageExportsHeaderRenderer) RenderHeader

func (r *StageExportsHeaderRenderer) RenderHeader(model *splitpane.Model, s *styles.Styles) string

RenderHeader renders the exports view header.

type StageExportsInstanceItem

type StageExportsInstanceItem struct {
	// Name is the display name for the instance
	Name string
	// Path is the full path for hierarchy (e.g., "childA/childB")
	Path string
	// Depth is the nesting level for indentation
	Depth int
	// NewCount is the number of new exports
	NewCount int
	// ModifiedCount is the number of modified exports
	ModifiedCount int
	// RemovedCount is the number of removed exports
	RemovedCount int
	// UnchangedCount is the number of unchanged exports
	UnchangedCount int
	// Changes holds the BlueprintChanges for this instance
	Changes *changes.BlueprintChanges
}

StageExportsInstanceItem represents a blueprint instance in the exports change view. It shows export changes for the root instance or any child blueprint.

func (*StageExportsInstanceItem) CanDrillDown

func (i *StageExportsInstanceItem) CanDrillDown() bool

CanDrillDown indicates whether the item can be drilled into.

func (*StageExportsInstanceItem) GetAction

func (i *StageExportsInstanceItem) GetAction() string

GetAction returns action badge text summarizing export changes.

func (*StageExportsInstanceItem) GetChildren

func (i *StageExportsInstanceItem) GetChildren() []splitpane.Item

GetChildren returns child items (none for exports view).

func (*StageExportsInstanceItem) GetDepth

func (i *StageExportsInstanceItem) GetDepth() int

GetDepth returns the nesting depth for indentation.

func (*StageExportsInstanceItem) GetID

func (i *StageExportsInstanceItem) GetID() string

GetID returns a unique identifier for the item.

func (*StageExportsInstanceItem) GetIcon

func (i *StageExportsInstanceItem) GetIcon(selected bool) string

GetIcon returns a status icon for the item.

func (*StageExportsInstanceItem) GetItemType

func (i *StageExportsInstanceItem) GetItemType() string

GetItemType returns the type for section grouping.

func (*StageExportsInstanceItem) GetName

func (i *StageExportsInstanceItem) GetName() string

GetName returns the display name for the item.

func (*StageExportsInstanceItem) GetParentID

func (i *StageExportsInstanceItem) GetParentID() string

GetParentID returns the parent item ID.

func (*StageExportsInstanceItem) HasExportChanges

func (i *StageExportsInstanceItem) HasExportChanges() bool

HasExportChanges returns true if there are any export changes.

func (*StageExportsInstanceItem) IsExpandable

func (i *StageExportsInstanceItem) IsExpandable() bool

IsExpandable indicates whether the item can be expanded in-place.

type StageExportsModel

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

StageExportsModel is a Bubble Tea model for viewing blueprint export changes. It uses a split pane with instance hierarchy on the left and export change details on the right.

func NewStageExportsModel

func NewStageExportsModel(
	blueprintChanges *changes.BlueprintChanges,
	instanceName string,
	width, height int,
	s *styles.Styles,
) StageExportsModel

NewStageExportsModel creates a new exports change view model.

func (StageExportsModel) HasExportChanges

func (m StageExportsModel) HasExportChanges() bool

HasExportChanges returns true if there are any export changes.

func (StageExportsModel) Init

func (m StageExportsModel) Init() tea.Cmd

Init implements tea.Model.

func (StageExportsModel) Update

func (m StageExportsModel) Update(msg tea.Msg) (StageExportsModel, tea.Cmd)

Update implements tea.Model.

func (StageExportsModel) View

func (m StageExportsModel) View() string

View implements tea.Model.

type StageFooterRenderer

type StageFooterRenderer struct {
	ChangesetID  string
	InstanceID   string
	InstanceName string
	// Destroy indicates whether this is a destroy operation
	Destroy bool
	// Change summary counts for footer display
	CreateCount   int
	UpdateCount   int
	RecreateCount int
	DeleteCount   int
	// HasExportChanges indicates whether there are export changes to show
	HasExportChanges bool
	// Delegate is an optional custom footer renderer that takes precedence when set.
	// This allows the deploy flow to inject its own footer (e.g., confirmation form).
	Delegate splitpane.FooterRenderer
}

StageFooterRenderer implements splitpane.FooterRenderer for stage UI. It supports a delegate pattern to allow custom footer rendering (e.g., for deploy flow).

func (*StageFooterRenderer) RenderFooter

func (r *StageFooterRenderer) RenderFooter(model *splitpane.Model, s *styles.Styles) string

RenderFooter renders the stage-specific footer with changeset and deploy instructions. If a Delegate is set, it defers to the delegate for rendering.

type StageItem

type StageItem struct {
	Type         ItemType
	Name         string
	ResourceType string // For resources: the resource type (e.g., "aws/sqs/queue")
	DisplayName  string // For resources: the metadata display name if provided
	Action       ActionType
	Changes      any // *provider.Changes, *changes.BlueprintChanges, or *provider.LinkChanges
	New          bool
	Removed      bool
	Recreate     bool
	// For child blueprints: the parent child name (empty for top-level items)
	ParentChild string
	// For child blueprints: indicates nesting depth for indentation
	Depth int
	// For child blueprints: the instance state for this child (if it exists)
	// This is used to show resources with NO CHANGE status that aren't in the changeset.
	InstanceState *state.InstanceState
	// For resources: the resource state (if it exists)
	// This is used to show Resource ID and Outputs in the details pane
	// when the resource has state but Changes doesn't include CurrentResourceState.
	ResourceState *state.ResourceState
	// For links: the link state (if it exists)
	// This is used to show the Link ID in the details pane.
	LinkState *state.LinkState
}

StageItem represents an item in the staging list.

func (*StageItem) CanDrillDown

func (i *StageItem) CanDrillDown() bool

CanDrillDown returns true if the item can be drilled into.

func (*StageItem) GetAction

func (i *StageItem) GetAction() string

GetAction returns the action badge text.

func (*StageItem) GetChildren

func (i *StageItem) GetChildren() []splitpane.Item

GetChildren returns child items when expanded.

func (*StageItem) GetDepth

func (i *StageItem) GetDepth() int

GetDepth returns the nesting depth for indentation.

func (*StageItem) GetID

func (i *StageItem) GetID() string

GetID returns a unique identifier for the item.

func (*StageItem) GetIcon

func (i *StageItem) GetIcon(selected bool) string

GetIcon returns a status icon for the item. When selected is false, the icon is styled; when true, it's unstyled so the selection style can apply uniformly.

func (*StageItem) GetIconStyled

func (i *StageItem) GetIconStyled(s *styles.Styles, styled bool) string

GetIconStyled returns a styled icon for the item.

func (*StageItem) GetItemType

func (i *StageItem) GetItemType() string

GetItemType returns the type for section grouping.

func (*StageItem) GetLinkResourceNames

func (i *StageItem) GetLinkResourceNames() (string, string)

GetLinkResourceNames returns the resource names for a link item.

func (*StageItem) GetName

func (i *StageItem) GetName() string

GetName returns the display name for the item.

func (*StageItem) GetParentID

func (i *StageItem) GetParentID() string

GetParentID returns the parent item ID.

func (*StageItem) GetResourceGroup

func (i *StageItem) GetResourceGroup() *shared.ResourceGroup

GetResourceGroup returns the abstract resource group for this item, if any.

func (*StageItem) IsExpandable

func (i *StageItem) IsExpandable() bool

IsExpandable returns true if the item can be expanded in-place.

type StageModel

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

StageModel is the model for the stage view.

func NewStageModel

func NewStageModel(cfg StageModelConfig) StageModel

NewStageModel creates a new stage model with the given configuration.

func (*StageModel) ChangesetID

func (m *StageModel) ChangesetID() string

ChangesetID returns the changeset ID.

func (*StageModel) CountChangeSummary

func (m *StageModel) CountChangeSummary() (create, update, delete, recreate int)

CountChangeSummary returns counts of create, update, delete, recreate actions. This is the exported version of countChangeSummary.

func (*StageModel) Destroy

func (m *StageModel) Destroy() bool

Destroy returns whether this is a destroy staging operation.

func (*StageModel) Err

func (m *StageModel) Err() error

Err returns the error stored in the model.

func (*StageModel) Finished

func (m *StageModel) Finished() bool

Finished returns whether staging has completed.

func (*StageModel) GetChanges

func (m *StageModel) GetChanges() *changes.BlueprintChanges

GetChanges returns the complete blueprint changes from staging.

func (*StageModel) GetChangesetID

func (m *StageModel) GetChangesetID() string

GetChangesetID returns the changeset ID created during staging.

func (*StageModel) GetError

func (m *StageModel) GetError() error

GetError returns any error that occurred during staging.

func (*StageModel) GetItems

func (m *StageModel) GetItems() []StageItem

GetItems returns the staged items collected during streaming.

func (StageModel) Init

func (m StageModel) Init() tea.Cmd

func (*StageModel) IsFinished

func (m *StageModel) IsFinished() bool

IsFinished returns true if staging has completed.

func (*StageModel) Items

func (m *StageModel) Items() []StageItem

Items returns the staging items.

func (*StageModel) SetBlueprintFile

func (m *StageModel) SetBlueprintFile(file string)

SetBlueprintFile sets the blueprint file path.

func (*StageModel) SetBlueprintSource

func (m *StageModel) SetBlueprintSource(source string)

SetBlueprintSource sets the blueprint source type.

func (*StageModel) SetDeployFlowMode

func (m *StageModel) SetDeployFlowMode(deployFlow bool)

SetDeployFlowMode sets the deploy flow mode. When true, the staging model won't print the apply hint or quit after staging completes. This should be set when staging is part of a deploy command flow.

func (*StageModel) SetDestroy

func (m *StageModel) SetDestroy(destroy bool)

SetDestroy sets the destroy mode.

func (*StageModel) SetFooterRenderer

func (m *StageModel) SetFooterRenderer(renderer splitpane.FooterRenderer)

SetFooterRenderer sets a custom footer renderer that overrides the default stage footer. This allows parent models (like deploy) to inject their own footer rendering.

func (*StageModel) SetInstanceID

func (m *StageModel) SetInstanceID(id string)

SetInstanceID sets the instance ID.

func (*StageModel) SetInstanceName

func (m *StageModel) SetInstanceName(name string)

SetInstanceName sets the instance name.

func (*StageModel) SetSkipDriftCheck

func (m *StageModel) SetSkipDriftCheck(skipDriftCheck bool)

SetSkipDriftCheck sets the skip drift check option.

func (*StageModel) SkipDriftCheck

func (m *StageModel) SkipDriftCheck() bool

SkipDriftCheck returns whether drift check should be skipped.

func (*StageModel) StartStaging

func (m *StageModel) StartStaging() tea.Cmd

StartStaging initiates the staging process. Returns a tea.Cmd that starts the staging workflow.

func (StageModel) Update

func (m StageModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (StageModel) View

func (m StageModel) View() string

type StageModelConfig

type StageModelConfig struct {
	DeployEngine   engine.DeployEngine
	Logger         *zap.Logger
	InstanceID     string
	InstanceName   string
	Destroy        bool
	SkipDriftCheck bool
	Styles         *stylespkg.Styles
	IsHeadless     bool
	HeadlessWriter io.Writer
	JSONMode       bool
}

StageModelConfig holds the configuration for creating a new StageModel.

type StageOptionsFormConfig

type StageOptionsFormConfig struct {
	// InitialInstanceName is the pre-populated instance name (from flag/env/config).
	InitialInstanceName string
	// InitialDestroy is the pre-populated destroy value (from flag/env/config).
	InitialDestroy bool
	// InitialSkipDriftCheck is the pre-populated skip drift check value (from flag/env/config).
	InitialSkipDriftCheck bool
	// Engine is used to check if an instance exists.
	Engine engine.DeployEngine
}

StageOptionsFormConfig holds the initial values for the stage options form.

type StageOptionsFormModel

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

StageOptionsFormModel provides a form for configuring staging options. It uses a two-phase approach: 1. First, prompt for instance name 2. If the instance exists, prompt for destroy and skip drift check options For new instances, destroy and skip drift check are not applicable.

func NewStageOptionsFormModel

func NewStageOptionsFormModel(styles *stylespkg.Styles, config StageOptionsFormConfig) *StageOptionsFormModel

NewStageOptionsFormModel creates a new stage options form model.

func (*StageOptionsFormModel) Init

func (m *StageOptionsFormModel) Init() tea.Cmd

func (*StageOptionsFormModel) Update

func (*StageOptionsFormModel) View

func (m *StageOptionsFormModel) View() string

type StageOptionsSelectedMsg

type StageOptionsSelectedMsg struct {
	InstanceName   string
	Destroy        bool
	SkipDriftCheck bool
	// InstanceExists indicates whether the instance already exists.
	// This is useful for the caller to know if they're staging for a new or existing instance.
	InstanceExists bool
}

StageOptionsSelectedMsg is sent when the user completes the stage options form.

type StageSectionGrouper

type StageSectionGrouper struct {
	shared.SectionGrouper
}

StageSectionGrouper implements splitpane.SectionGrouper for stage UI.

type StageStartedMsg

type StageStartedMsg struct {
	ChangesetID string
}

StageStartedMsg is a message indicating that staging has started.

type StageStartedWithStateMsg

type StageStartedWithStateMsg struct {
	ChangesetID   string
	InstanceState *state.InstanceState
}

StageStartedWithStateMsg is a message indicating that staging has started and includes the fetched instance state (if available).

type StageStreamClosedMsg

type StageStreamClosedMsg struct{}

StageStreamClosedMsg is sent when the staging event stream is closed. This typically happens due to a stream timeout or the connection being dropped.

Jump to

Keyboard shortcuts

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