Documentation
¶
Overview ¶
Package setup provides the interactive wizard for configuring gocker.
Index ¶
- Constants
- Variables
- func Choose(prompt string, options []string, def string) string
- func ChooseIsolation(interactive bool, defaultMode string) string
- func ConfigureDockerContext(ctx context.Context, socket string) (bool, error)
- func Confirm(prompt string, def bool) bool
- func DetectShell(shellPath string) string
- func Input(prompt, def string) string
- func InstallShellBlock(rcPath, shell, socket string) (bool, error)
- func IsInteractive() bool
- func NormalizeTerminal()
- func PrintIsolationExplanations()
- func RunWizard(ctx context.Context, opts Options) error
- func ShellRCPath(shell, home string) string
- type Options
Constants ¶
const ( IsolationFull = "full" IsolationHybrid = "hybrid" )
Variables ¶
var IsolationChoices = []string{IsolationFull, IsolationHybrid, IsolationShared}
IsolationChoices are the options offered in the wizard, in display order.
Functions ¶
func Choose ¶
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 ¶
ChooseIsolation runs the interactive prompt (or returns the default in non-interactive mode).
func ConfigureDockerContext ¶
ConfigureDockerContext creates and selects a docker context named "gocker" pointing at the given socket. Returns (changed, err). No-op if already set.
func Confirm ¶
Confirm prompts for y/n and returns the answer. Uses def if input is empty or unparseable.
func DetectShell ¶
DetectShell returns "bash", "zsh", "fish", or "" for unsupported shells.
func InstallShellBlock ¶
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:
- If the rc file already exports DOCKER_HOST pointing at this socket (outside our block), leave everything alone.
- If our block already exists and matches the desired content, no change.
- Otherwise, remove any existing block and append a fresh one.
func NormalizeTerminal ¶ added in v0.7.8
func NormalizeTerminal()
NormalizeTerminal forces the terminal into the standard line-editing (canonical + echo) mode before prompting. Earlier steps in `gocker setup` invoke the Apple `container` CLI via ExecInteractive; if it exits without restoring termios cleanly, the terminal stays in raw mode and every subsequent prompt hangs forever because Enter produces CR (`\r`), not LF (`\n`) — and our line-readers wait for LF.
`stty sane` is the cross-shell universal "fix my terminal" command. No-op on non-interactive stdin and silent if stty isn't available.
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 ¶
RunWizard executes the interactive (or silent) configuration wizard. Called after install steps in 'gocker setup'.
func ShellRCPath ¶
ShellRCPath returns the rc file to modify for the given shell.