localhost

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GatherInventory

func GatherInventory(remote *ssh.Client) (*entity.Inventory, error)

Types

type LocalhostClient

type LocalhostClient struct {
	Host string

	Env *entity.EnvList //export FOO="bar"; export BAR="baz";

	Inventory *entity.Inventory
	// contains filtered or unexported fields
}

LocalhostClient is a wrapper over the SSH connection/sessions.

func (*LocalhostClient) Close

func (c *LocalhostClient) Close() error

Close closes the client.

func (*LocalhostClient) Connect

func (c *LocalhostClient) Connect(_ entity.NetworkHost) error

Connect connects to the host using SSH.

Args:

  • _ entity.NetworkHost: The network host to connect to.

Returns:

  • An error if there's a problem connecting, otherwise nil.

func (*LocalhostClient) Download

func (c *LocalhostClient) Download(src, dst string, silent bool) error

func (*LocalhostClient) GenerateOnRemote

func (c *LocalhostClient) GenerateOnRemote(data []byte, dest string) error

func (LocalhostClient) GetConnection

func (c LocalhostClient) GetConnection() *ssh.Client

GetConnection acquires a connection with the remote host using SSH.

It is assumed that this method will only be called on the localhost client, and thus does not require an existing connection.

func (*LocalhostClient) GetHost

func (c *LocalhostClient) GetHost() string

GetHost returns the host of the LocalhostClient.

func (*LocalhostClient) GetInventory

func (c *LocalhostClient) GetInventory() *entity.Inventory

GetInventory returns the inventory of the LocalhostClient.

func (*LocalhostClient) GetSSHConfig

func (c *LocalhostClient) GetSSHConfig() *ssh.ClientConfig

GetSSHConfig returns a pointer to an SSH client configuration struct.

Returns:

  • A pointer to the SSH client config. Note that for local machines, this method always returns nil, as it doesn't need to reconnect.

func (*LocalhostClient) GetShell

func (c *LocalhostClient) GetShell() string

GetShell returns the shell of the LocalhostClient.

func (LocalhostClient) GetTube

func (c LocalhostClient) GetTube() string

GetTube is a method to get the tube name of the LocalhostClient.

Returns:

  • The name of the tube as a string.

func (*LocalhostClient) Prefix

func (c *LocalhostClient) Prefix() (string, int)

Prefix returns the client's prefix.

func (*LocalhostClient) Run

func (c *LocalhostClient) Run(task *entity.Task) error

Run starts the given task on localhost, does not wait for it to finish.

func (LocalhostClient) SetConnection

func (c LocalhostClient) SetConnection(client *ssh.Client)

SetConnection sets a pre-existing SSH connection for the current session.

This is primarily used when reconnecting to an existing host.

func (*LocalhostClient) SetTube

func (c *LocalhostClient) SetTube(name string)

SetTube sets the tube name for the LocalhostClient.

Args:

  • name (string): The new tube name to set.

func (*LocalhostClient) Signal

func (c *LocalhostClient) Signal(sig os.Signal) error

func (*LocalhostClient) Stderr

func (c *LocalhostClient) Stderr() io.Reader

Stderr returns the client's standard error.

func (*LocalhostClient) Stdin

func (c *LocalhostClient) Stdin() io.WriteCloser

Stdin returns the client's standard input.

func (*LocalhostClient) Stdout

func (c *LocalhostClient) Stdout() io.Reader

Stdout returns the client's standard output.

func (*LocalhostClient) Upload

func (c *LocalhostClient) Upload(src, dst string) error

func (*LocalhostClient) Wait

func (c *LocalhostClient) Wait() error

Wait waits until the command finishes.

func (*LocalhostClient) Write

func (c *LocalhostClient) Write(p []byte) (n int, err error)

Write implements writing byte into stdin.

func (*LocalhostClient) WriteClose

func (c *LocalhostClient) WriteClose() error

Jump to

Keyboard shortcuts

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