Documentation
¶
Overview ¶
Package confirm provides confirmation prompt utilities for destructive operations.
Index ¶
- Variables
- func IsTTY() bool
- func PromptForConfirmation(_ io.Writer) bool
- func SetStdinReaderForTests(reader io.Reader) func()
- func SetTTYCheckerForTests(checker func() bool) func()
- func ShouldSkipPrompt(force bool) bool
- func ShowDeletionPreview(writer io.Writer, preview *DeletionPreview)
- type DeletionPreview
Constants ¶
This section is empty.
Variables ¶
var ErrDeletionCancelled = errors.New("deletion cancelled")
ErrDeletionCancelled is returned when the user cancels a deletion operation.
Functions ¶
func IsTTY ¶
func IsTTY() bool
IsTTY returns true if stdin is connected to a terminal. This is used to skip confirmation prompts in non-interactive environments (CI/pipelines).
func PromptForConfirmation ¶
PromptForConfirmation reads user input and checks for "yes" confirmation. Returns true only if the user types exactly "yes" (case-insensitive). Note: The prompt text is displayed by ShowDeletionPreview.
func SetStdinReaderForTests ¶
SetStdinReaderForTests overrides the stdin reader for testing. Returns a restore function that should be called to reset the override.
func SetTTYCheckerForTests ¶
func SetTTYCheckerForTests(checker func() bool) func()
SetTTYCheckerForTests overrides the TTY checker for testing. Returns a restore function that should be called to reset the override.
func ShouldSkipPrompt ¶
ShouldSkipPrompt returns true if the confirmation prompt should be skipped. This happens when force flag is set OR stdin is not a TTY (non-interactive environment).
func ShowDeletionPreview ¶
func ShowDeletionPreview(writer io.Writer, preview *DeletionPreview)
ShowDeletionPreview displays information about what will be deleted and the confirmation prompt. This includes the cluster name, provider, and any associated resources.
Types ¶
type DeletionPreview ¶
type DeletionPreview struct {
ClusterName string
Provider v1alpha1.Provider
// Docker resources
Nodes []string // Container names for Docker nodes
Registries []string // Registry container names
// Hetzner Cloud resources
Servers []string // Server names
PlacementGroup string // Placement group name (if exists)
Firewall string // Firewall name (if exists)
Network string // Network name (if exists)
}
DeletionPreview contains all resources that will be deleted.