Documentation
¶
Overview ¶
Package operations provides async, cancellable wrappers for stackit actions.
Operations emit progress via channels, allowing UIs to show live progress and support cancellation. They wrap existing action implementations without modifying them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseOperation ¶
type BaseOperation struct {
// contains filtered or unexported fields
}
BaseOperation provides common functionality for operations.
func (*BaseOperation) SetCancel ¶
func (o *BaseOperation) SetCancel(cancel context.CancelFunc)
SetCancel sets the cancel function for the operation.
type Operation ¶
type Operation interface {
// ID returns the unique identifier for this operation instance.
ID() string
// Start begins the operation and returns a channel that will receive
// progress updates. The channel is closed when the operation completes.
// The provided context can be used to cancel the operation.
Start(ctx context.Context) <-chan Progress
// Cancel requests cancellation of the operation. This is best-effort;
// the operation may complete before cancellation takes effect.
Cancel()
}
Operation represents an async, cancellable operation.
type Progress ¶
type Progress struct {
// OperationID uniquely identifies this operation instance.
OperationID string
// Status is the current state of the operation.
Status Status
// Step is a human-readable description of the current step.
// Example: "Submitting feature-1"
Step string
// Branch is the branch currently being processed, if applicable.
Branch string
// Current is the 0-based index of the current step.
Current int
// Total is the total number of steps in the operation.
Total int
// Result contains step-specific output (e.g., PR URL).
Result any
// Error contains the error if Status is StatusFailed.
Error error
}
Progress represents an update from a running operation.
type Status ¶
type Status string
Status represents the current state of an operation or step.
const ( // StatusPending indicates the operation/step has not started. StatusPending Status = "pending" // StatusRunning indicates the operation/step is in progress. StatusRunning Status = "running" // StatusCompleted indicates the operation/step finished successfully. StatusCompleted Status = "completed" // StatusFailed indicates the operation/step failed with an error. StatusFailed Status = "failed" // StatusCanceled indicates the operation was canceled. StatusCanceled Status = "canceled" // StatusSkipped indicates the step was skipped. StatusSkipped Status = "skipped" )
type SubmitOperation ¶
type SubmitOperation struct {
BaseOperation
// contains filtered or unexported fields
}
SubmitOperation wraps the submit action as an async Operation.
func NewSubmitOperation ¶
func NewSubmitOperation(ctx *app.Context, options submitAction.Options) *SubmitOperation
NewSubmitOperation creates a new submit operation.
func (*SubmitOperation) Confirm ¶
func (o *SubmitOperation) Confirm(_ string, defaultYes bool) (bool, error)
Confirm auto-confirms with the default value. Operations don't support interactive confirmation.
func (*SubmitOperation) IsInteractive ¶
func (o *SubmitOperation) IsInteractive() bool
IsInteractive returns false - operations are not interactive.
func (*SubmitOperation) OnEvent ¶
func (o *SubmitOperation) OnEvent(e submitAction.Event)
OnEvent handles events from the submit action
type SyncOperation ¶
type SyncOperation struct {
BaseOperation
// contains filtered or unexported fields
}
SyncOperation wraps the sync action as an async Operation.
func NewSyncOperation ¶
func NewSyncOperation(ctx *app.Context, options syncAction.Options) *SyncOperation
NewSyncOperation creates a new sync operation.