setup

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package setup provides the interactive wizard for configuring gocker.

Index

Constants

View Source
const (
	IsolationFull   = "full"
	IsolationHybrid = "hybrid"
	IsolationShared = "shared"
)

Variables

IsolationChoices are the options offered in the wizard, in display order.

Functions

func Choose

func Choose(prompt string, options []string, def string) string

Choose presents a numbered list and returns the selected option. Accepts either the 1-based index or the option string itself. Falls back to def on empty or unparseable input.

func ChooseIsolation

func ChooseIsolation(interactive bool, defaultMode string) string

ChooseIsolation runs the interactive prompt (or returns the default in non-interactive mode).

func ConfigureDockerContext

func ConfigureDockerContext(ctx context.Context, socket string) (bool, error)

ConfigureDockerContext creates and selects a docker context named "gocker" pointing at the given socket. Returns (changed, err). No-op if already set.

func Confirm

func Confirm(prompt string, def bool) bool

Confirm prompts for y/n and returns the answer. Uses def if input is empty or unparseable.

func DetectShell

func DetectShell(shellPath string) string

DetectShell returns "bash", "zsh", "fish", or "" for unsupported shells.

func Input

func Input(prompt, def string) string

Input prompts for a free-text string, returning def if empty.

func InstallShellBlock

func InstallShellBlock(rcPath, shell, socket string) (bool, error)

InstallShellBlock inserts (or updates) a sentinel-wrapped block in the given rc file that exports DOCKER_HOST and testcontainers overrides pointing at the gocker socket. Returns (changed, err).

Idempotency rules:

  1. If the rc file already exports DOCKER_HOST pointing at this socket (outside our block), leave everything alone.
  2. If our block already exists and matches the desired content, no change.
  3. Otherwise, remove any existing block and append a fresh one.

func IsInteractive

func IsInteractive() bool

IsInteractive returns true if stdin is a terminal.

func PrintIsolationExplanations

func PrintIsolationExplanations()

PrintIsolationExplanations prints a short explanation of each mode before the prompt. Kept short so users can actually read it.

func RunWizard

func RunWizard(ctx context.Context, opts Options) error

RunWizard executes the interactive (or silent) configuration wizard. Called after install steps in 'gocker setup'.

func ShellRCPath

func ShellRCPath(shell, home string) string

ShellRCPath returns the rc file to modify for the given shell.

Types

type Options

type Options struct {
	NonInteractive bool // --yes: use CI-friendly defaults, skip shell/docker prompts
}

Options controls wizard behavior.

Jump to

Keyboard shortcuts

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