Documentation
¶
Index ¶
- func ChooseFromListDialog[TItem any](title string, items []TItem, toItemFunc func(item *TItem) (string, string)) (*TItem, error)
- func ChooseOrgAndProject(orgsAndProjects []portalapi.OrganizationWithProjects) (*portalapi.ProjectInfo, error)
- func ChooseTargetPodDialog(pods []corev1.Pod) (*corev1.Pod, error)
- func DoConfirmDialog(ctx context.Context, title string, body string, question string) (bool, error)
- func DoConfirmQuestion(ctx context.Context, question string) (bool, error)
- func GetPodDescription(pod *corev1.Pod) string
- func GetStatefulSetDescription(sts *appsv1.StatefulSet) string
- func IsInteractiveMode() bool
- func RequireLoggedIn(ctx context.Context, authProvider *auth.AuthProviderConfig) (*auth.TokenSet, error)
- func SetInteractiveMode(isInteractive bool)
- type Task
- type TaskOutput
- type TaskRunFunc
- type TaskRunner
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseFromListDialog ¶
func ChooseFromListDialog[TItem any](title string, items []TItem, toItemFunc func(item *TItem) (string, string)) (*TItem, error)
Show a dialog to user to select an item from the provided list. The toItemFunc() is used to convert the items into a (name, description) tuple for display. The selected item in the list is returned (or error).
func ChooseOrgAndProject ¶
func ChooseOrgAndProject(orgsAndProjects []portalapi.OrganizationWithProjects) (*portalapi.ProjectInfo, error)
ChooseOrgAndProject fetches all the organizations and projects from the portal (that the user has access to) and then displays an interactive list for the user to choose the project from.
func DoConfirmDialog ¶
Show the user a confirm dialog and wait for a yes/no answer.
func DoConfirmQuestion ¶
Show the user a one-line confirm question and wait for a yes/no answer.
func GetPodDescription ¶
func GetStatefulSetDescription ¶
func GetStatefulSetDescription(sts *appsv1.StatefulSet) string
func IsInteractiveMode ¶
func IsInteractiveMode() bool
func RequireLoggedIn ¶
func RequireLoggedIn(ctx context.Context, authProvider *auth.AuthProviderConfig) (*auth.TokenSet, error)
RequireLoggedIn ensures that the user is logged in. If the user is not logged in, it will prompt the user to log in.
func SetInteractiveMode ¶
func SetInteractiveMode(isInteractive bool)
Set the interactive mode of the UI library.
Types ¶
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task represents a single task with its title, function, and status
type TaskOutput ¶
type TaskOutput struct {
// contains filtered or unexported fields
}
TaskOutput contains the outputs from a given task and is shown along with the task's status.
func (*TaskOutput) AppendLine ¶
func (to *TaskOutput) AppendLine(line string)
Append a new line at the end of the output.
func (*TaskOutput) AppendLinef ¶
func (to *TaskOutput) AppendLinef(format string, a ...any)
AppendLinef appends a new formatted line at the end of the output using fmt.Sprintf.
func (*TaskOutput) SetFooterLines ¶
func (to *TaskOutput) SetFooterLines(lines []string)
Update the footer lines to the provided ones. Also logged in non-interactive mode.
func (*TaskOutput) SetHeaderLines ¶
func (to *TaskOutput) SetHeaderLines(lines []string)
Update the header lines to the provided ones. Also logged in non-interactive mode.
type TaskRunFunc ¶
type TaskRunFunc func(output *TaskOutput) error
TaskRunFunc is the function signature for task execution functions
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner manages and executes a sequence of tasks with visual progress
func (*TaskRunner) AddTask ¶
func (m *TaskRunner) AddTask(title string, runFunc TaskRunFunc)
AddTask adds a new task to the runner
func (*TaskRunner) Run ¶
func (m *TaskRunner) Run() error
Run starts executing tasks sequentially and displays the progress
type TaskStatus ¶
type TaskStatus int
TaskStatus represents the current state of a task
const ( StatusPending TaskStatus = iota StatusRunning StatusCompleted StatusFailed )