common

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDockerClient

func CreateDockerClient(cfg *manifest.Config) *dockercli.Client

CreateDockerClient creates a Docker client using config context and identifier.

func CreatePlanner

func CreatePlanner(docker *dockercli.Client, pr ui.Printer) *planner.Planner

CreatePlanner creates a planner with Docker client and printer configured.

func DisplayDockerInfo

func DisplayDockerInfo(pr ui.Printer, cfg *manifest.Config)

DisplayDockerInfo shows the Docker context and identifier information

func GetConfirmation

func GetConfirmation(cmd *cobra.Command, pr ui.Printer, opts ConfirmationOptions) (bool, error)

GetConfirmation handles user confirmation with TTY detection and appropriate prompting.

func GetDestroyConfirmation

func GetDestroyConfirmation(cmd *cobra.Command, pr ui.Printer, opts DestroyConfirmationOptions) (bool, error)

GetDestroyConfirmation handles user confirmation for destroy operations, requiring the user to type the identifier name.

func LoadConfigWithWarnings

func LoadConfigWithWarnings(cmd *cobra.Command, pr ui.Printer) (*manifest.Config, error)

LoadConfigWithWarnings loads the configuration from the --config flag and displays warnings.

func MaskSecretsSimple

func MaskSecretsSimple(yamlStr string, stack manifest.Stack, strategy string) string

MaskSecretsSimple redacts secret-like values from a YAML string based on stack config. This is a pragmatic heuristic: it masks occurrences of values provided via stack/environment inline env and sops secrets (after decryption via BuildInlineEnv), as well as common sensitive keys.

func ProgressOperation

func ProgressOperation(pr ui.StdPrinter, message string, operation func(*ui.Progress) error) error

ProgressOperation runs an operation with a progress bar.

func RunWithRollingOrDirect

func RunWithRollingOrDirect(cmd *cobra.Command, verbose bool, fn func(runCtx context.Context) (string, error)) (string, bool, error)

RunWithRollingOrDirect executes fn while showing rolling logs when stdout is a TTY and verbose is false. Returns the fn's string result and whether the rolling TUI was used.

func SelectManifestPath

func SelectManifestPath(cmd *cobra.Command, pr ui.Printer, root string, maxDepth int) (string, bool, error)

SelectManifestPath scans for manifest files up to maxDepth and presents an interactive picker of docker.context values when attached to a TTY. Returns the chosen manifest path and whether a selection was made. On non-TTY, returns ok=false with no error.

func SpinnerOperation

func SpinnerOperation(pr ui.StdPrinter, message string, operation func() error) error

SpinnerOperation runs an operation with a spinner, automatically handling start/stop.

func ValidateWithDocker

func ValidateWithDocker(ctx context.Context, cfg *manifest.Config, docker *dockercli.Client) error

ValidateWithDocker runs validation against the configuration and Docker client.

Types

type CLIContext

type CLIContext struct {
	Ctx     context.Context
	Config  *manifest.Config
	Docker  *dockercli.Client
	Printer ui.Printer
	Planner *planner.Planner
}

CLIContext contains all the components needed for most CLI operations.

func SetupCLIContext

func SetupCLIContext(cmd *cobra.Command) (*CLIContext, error)

SetupCLIContext performs the standard CLI setup: load config, create Docker client, validate, and create planner.

func (*CLIContext) ApplyPlan

func (ctx *CLIContext) ApplyPlan() error

ApplyPlan executes the plan with progress tracking.

func (*CLIContext) BuildDestroyPlan

func (ctx *CLIContext) BuildDestroyPlan() (*planner.Plan, error)

BuildDestroyPlan creates a destruction plan for all managed resources.

func (*CLIContext) BuildPlan

func (ctx *CLIContext) BuildPlan() (*planner.Plan, error)

BuildPlan creates a plan using the CLI context with spinner UI.

func (*CLIContext) ExecuteDestroy

func (ctx *CLIContext) ExecuteDestroy(bgCtx context.Context) error

ExecuteDestroy executes the destruction of all managed resources.

func (*CLIContext) PrunePlan

func (ctx *CLIContext) PrunePlan() error

PrunePlan executes pruning with spinner.

type ConfirmationOptions

type ConfirmationOptions struct {
	SkipConfirmation bool
	Message          string
}

ConfirmationOptions configures the confirmation prompt behavior.

type DestroyConfirmationOptions

type DestroyConfirmationOptions struct {
	SkipConfirmation bool
	Identifier       string
}

DestroyConfirmationOptions configures the destroy confirmation prompt behavior.

Jump to

Keyboard shortcuts

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