ssh

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ssh builds argument vectors for invoking either `gcloud compute ssh` or the system `ssh` binary, given a set of user-chosen Options.

The package is intentionally UI-free: it has no Bubble Tea dependencies and is fully unit-testable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildGcloudArgs

func BuildGcloudArgs(opts Options) []string

BuildGcloudArgs returns argv to pass to `exec.Command("gcloud", args...)`.

Each --ssh-flag value becomes its own argv element. gcloud forwards each element to ssh as a single token, so "-l USER" must be split as "--ssh-flag=-l --ssh-flag=USER" rather than joined-and-quoted.

func BuildSSHArgs

func BuildSSHArgs(opts Options) []string

BuildSSHArgs returns argv to pass to `exec.Command("ssh", args...)`.

opts.InternalIP is intentionally ignored here: in ssh mode the dialog has already encoded the desired address into opts.Host.

func LookupBinary

func LookupBinary(name string) (string, bool)

LookupBinary returns the absolute path to `name` if found on $PATH.

Types

type Method

type Method int

Method selects which binary the caller will launch.

const (
	MethodGcloud Method = iota
	MethodSSH
)

type Options

type Options struct {
	// Method is used by callers to pick BuildGcloudArgs vs BuildSSHArgs;
	// the builders themselves do not read it.
	Method   Method
	Project  string // gcloud only
	Zone     string // gcloud only
	Instance string // gcloud only — used as the SSH target

	Host string // ssh only — the destination address
	User string // optional, both modes

	IAPTunnel   bool   // gcloud only
	InternalIP  bool   // gcloud only — ssh mode encodes the IP into Host instead
	PortForward string // optional, both modes — "L:H:R"
}

Options bundles every choice the SSH dialog can produce.

Jump to

Keyboard shortcuts

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