Documentation
¶
Overview ¶
Package stateutil provides shared utilities for fetching and working with blueprint instance state across TUI components.
Index ¶
- func DescribeEngineState(engineConfig *stateio.EngineConfig) string
- func FetchInstanceState(ctx context.Context, eng engine.DeployEngine, instanceID, instanceName string) *state.InstanceState
- func FindChildInstanceState(instanceState *state.InstanceState, childName string) *state.InstanceState
- func FindLinkState(instanceState *state.InstanceState, name string) *state.LinkState
- func FindResourceState(instanceState *state.InstanceState, name string) *state.ResourceState
- func FormatFailureText(heading string, details []LabelledValue, err error) string
- func RenderFailure(styles *stylespkg.Styles, heading string, details []LabelledValue, err error, ...) string
- func RenderProgress(spinnerView string, status string, width int) string
- type LabelledValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DescribeEngineState ¶ added in v0.10.0
func DescribeEngineState(engineConfig *stateio.EngineConfig) string
DescribeEngineState describes the state an import or export works on, such as "memfile state in /path", or "state" when there is no engine config to describe.
func FetchInstanceState ¶
func FetchInstanceState(ctx context.Context, eng engine.DeployEngine, instanceID, instanceName string) *state.InstanceState
FetchInstanceState attempts to fetch the instance state for an existing deployment. Returns nil if the instance doesn't exist or if there's an error (new deployment case).
func FindChildInstanceState ¶
func FindChildInstanceState(instanceState *state.InstanceState, childName string) *state.InstanceState
FindChildInstanceState finds the instance state for a child blueprint by name.
func FindLinkState ¶
func FindLinkState(instanceState *state.InstanceState, name string) *state.LinkState
FindLinkState finds a link state by logical name.
func FindResourceState ¶
func FindResourceState(instanceState *state.InstanceState, name string) *state.ResourceState
FindResourceState finds a resource state by logical name. It uses the instance state's ResourceIDs map to look up the resource ID, then retrieves the state from Resources.
func FormatFailureText ¶ added in v0.10.0
func FormatFailureText(heading string, details []LabelledValue, err error) string
FormatFailureText formats an import or export failure as plain text for headless output: the heading and error summary on the first line, then the given details, the cause and the hint, each indented under it.
func RenderFailure ¶ added in v0.10.0
func RenderFailure( styles *stylespkg.Styles, heading string, details []LabelledValue, err error, width int, ) string
RenderFailure renders an import or export failure for a TUI: the heading, the given details followed by the error and its cause as aligned labelled lines, and the hint on what to do. Every line is wrapped to fit within width.
Types ¶
type LabelledValue ¶ added in v0.10.0
LabelledValue is one line of a failure view, such as the state or file an import or export was working on.