confirm

package
v5.24.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package confirm provides confirmation prompt utilities for destructive operations.

Index

Constants

This section is empty.

Variables

View Source
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

func PromptForConfirmation(_ io.Writer) bool

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

func SetStdinReaderForTests(reader io.Reader) func()

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

func ShouldSkipPrompt(force bool) bool

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.

Jump to

Keyboard shortcuts

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