client

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSSHClient

func NewSSHClient(cfg *Config) (*ssh.Client, error)

NewSSHClient creates a new SSH client from the given config.

Settings from ~/.ssh/config are applied first, overriding any values in cfg. Host keys are verified against ~/.ssh/known_hosts.

Authentication is attempted in order:

  1. Password prompt, if cfg.AskPassword() is true.
  2. SSH agent via SSH_AUTH_SOCK, if the socket is available and has signers.
  3. Identity file (defaults: id_ed25519, id_rsa, id_ecdsa); prompts for passphrase if needed.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(cOpts ...ClientOptions) (*Client, error)

func (*Client) AllShorts added in v0.2.0

func (cli *Client) AllShorts(ctx context.Context) ([]container.Short, error)

func (*Client) Close

func (cli *Client) Close() error

func (*Client) DaemonHost

func (cli *Client) DaemonHost() string

func (*Client) DaemonVersion

func (cli *Client) DaemonVersion() string

func (*Client) FilesIn added in v0.3.0

func (cli *Client) FilesIn(ctx context.Context, root file.Info) ([]file.Info, error)

FilesIn returns the files in the given directory inside the container. If the Path field of the root is empty, it defaults to the working directory of the container, or "/" if the working directory is not set.

func (*Client) Logs

func (cli *Client) Logs(ctx context.Context, id string) (LogSeq, context.CancelFunc)

func (*Client) PauseContainer added in v0.2.0

func (cli *Client) PauseContainer(ctx context.Context, id string) error

func (*Client) StartContainer added in v0.2.0

func (cli *Client) StartContainer(ctx context.Context, id string) error

func (*Client) StopContainer added in v0.2.0

func (cli *Client) StopContainer(ctx context.Context, id string) error

func (*Client) Terminal added in v0.5.0

func (cli *Client) Terminal(ctx context.Context, id string, in io.Reader, out io.Writer) error

Terminal opens an interactive shell session inside the container identified by id. It creates a Docker exec process, attaches stdin/stdout/stderr with a PTY, and bridges in/out to the exec connection. The call blocks until the shell exits.

func (*Client) UnpauseContainer added in v0.2.0

func (cli *Client) UnpauseContainer(ctx context.Context, id string) error

type ClientOptions

type ClientOptions func(*Config)

func WithAskPassword

func WithAskPassword(ask bool) ClientOptions

func WithDockerHost

func WithDockerHost(host string) ClientOptions

func WithHost

func WithHost(host string) ClientOptions

func WithIdentityFile

func WithIdentityFile(identityFile string) ClientOptions

func WithUsername

func WithUsername(username string) ClientOptions

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(opts ...ClientOptions) (*Config, error)

NewSSHClient creates a new SSH client for the given optins.

Note that the host, username, port and identity file can be rewritten during ssh client construction with the value provided in the ~/.ssh/config file.

Use the method of the client to get the constructed Addr, Host, Port, Username, AskPassword, SSHDir and DockerSocket.

func (*Config) Addr

func (cfg *Config) Addr() string

func (*Config) AskPassword

func (cfg *Config) AskPassword() bool

func (*Config) DockerHost

func (cfg *Config) DockerHost() string

func (*Config) Host

func (cfg *Config) Host() string

func (*Config) Port

func (cfg *Config) Port() string

func (*Config) SSHDir

func (cfg *Config) SSHDir() string

func (*Config) Username

func (cfg *Config) Username() string

type LogSeq

type LogSeq = iter.Seq2[string, error]

Jump to

Keyboard shortcuts

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