host

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentClientWrapper

type AgentClientWrapper struct {
	BaseHost types.BaseHost
	// contains filtered or unexported fields
}

AgentClientWrapper wraps a BaseHost and provides a full Host implementation with the use of an ephemeral agent.

func NewAgentClientWrapper

func NewAgentClientWrapper(ctx context.Context, baseHost types.BaseHost) (*AgentClientWrapper, error)

func (*AgentClientWrapper) AppendFile

func (h *AgentClientWrapper) AppendFile(ctx context.Context, name string, data io.Reader, perm types.FileMode) error

func (*AgentClientWrapper) Chmod

func (h *AgentClientWrapper) Chmod(ctx context.Context, name string, mode types.FileMode) error

func (*AgentClientWrapper) Close

func (h *AgentClientWrapper) Close(ctx context.Context) error

func (*AgentClientWrapper) Getegid

func (h *AgentClientWrapper) Getegid(ctx context.Context) (uint64, error)

func (*AgentClientWrapper) Geteuid

func (h *AgentClientWrapper) Geteuid(ctx context.Context) (uint64, error)

func (*AgentClientWrapper) Lchown

func (h *AgentClientWrapper) Lchown(ctx context.Context, name string, uid, gid uint32) error

func (*AgentClientWrapper) Lookup

func (h *AgentClientWrapper) Lookup(ctx context.Context, username string) (*userPkg.User, error)

func (*AgentClientWrapper) LookupGroup

func (h *AgentClientWrapper) LookupGroup(ctx context.Context, name string) (*userPkg.Group, error)

func (*AgentClientWrapper) Lstat

func (h *AgentClientWrapper) Lstat(ctx context.Context, name string) (*types.Stat_t, error)

func (*AgentClientWrapper) Mkdir

func (h *AgentClientWrapper) Mkdir(ctx context.Context, name string, mode types.FileMode) error

func (*AgentClientWrapper) Mknod

func (h *AgentClientWrapper) Mknod(ctx context.Context, pathName string, mode types.FileMode, dev types.FileDevice) error

func (*AgentClientWrapper) ReadDir

func (h *AgentClientWrapper) ReadDir(ctx context.Context, name string) (<-chan types.DirEntResult, func())

func (*AgentClientWrapper) ReadFile

func (h *AgentClientWrapper) ReadFile(ctx context.Context, name string) (io.ReadCloser, error)
func (h *AgentClientWrapper) Readlink(ctx context.Context, name string) (string, error)

func (*AgentClientWrapper) Remove

func (h *AgentClientWrapper) Remove(ctx context.Context, name string) error

func (*AgentClientWrapper) Run

func (*AgentClientWrapper) String

func (h *AgentClientWrapper) String() string
func (h *AgentClientWrapper) Symlink(ctx context.Context, oldname, newname string) error

func (*AgentClientWrapper) Type

func (h *AgentClientWrapper) Type() string

func (*AgentClientWrapper) WriteFile

func (h *AgentClientWrapper) WriteFile(ctx context.Context, name string, data io.Reader, perm types.FileMode) error

type Docker

type Docker struct {
	// User/group and image in the format "[<name|uid>[:<group|gid>]@]<image>" (eg: root@ubuntu)
	ConnectionString string
}

Docker uses docker exec to target a running container.

func NewDocker

func NewDocker(ctx context.Context, connection string) (Docker, error)

func (Docker) Close

func (h Docker) Close(ctx context.Context) error

func (Docker) Run

func (h Docker) Run(ctx context.Context, cmd types.Cmd) (types.WaitStatus, error)

func (Docker) String

func (h Docker) String() string

func (Docker) Type

func (h Docker) Type() string

type Local

type Local struct{}

Local interacts with the local machine running the code.

func (Local) AppendFile

func (h Local) AppendFile(ctx context.Context, name string, data io.Reader, mode types.FileMode) error

func (Local) Chmod

func (h Local) Chmod(ctx context.Context, name string, mode types.FileMode) error

func (Local) Close

func (h Local) Close(ctx context.Context) error

func (Local) Getegid

func (h Local) Getegid(ctx context.Context) (uint64, error)

func (Local) Geteuid

func (h Local) Geteuid(ctx context.Context) (uint64, error)

func (Local) Lchown

func (h Local) Lchown(ctx context.Context, name string, uid, gid uint32) error

func (Local) Lookup

func (h Local) Lookup(ctx context.Context, username string) (*user.User, error)

func (Local) LookupGroup

func (h Local) LookupGroup(ctx context.Context, name string) (*user.Group, error)

func (Local) Lstat

func (h Local) Lstat(ctx context.Context, name string) (*types.Stat_t, error)

func (Local) Mkdir

func (h Local) Mkdir(ctx context.Context, name string, mode types.FileMode) error

func (Local) Mknod

func (h Local) Mknod(ctx context.Context, pathName string, mode types.FileMode, dev types.FileDevice) error

func (Local) ReadDir

func (h Local) ReadDir(ctx context.Context, name string) (<-chan types.DirEntResult, func())

func (Local) ReadFile

func (h Local) ReadFile(ctx context.Context, name string) (io.ReadCloser, error)
func (h Local) Readlink(ctx context.Context, name string) (string, error)

func (Local) Remove

func (h Local) Remove(ctx context.Context, name string) error

func (Local) Run

func (h Local) Run(ctx context.Context, cmd types.Cmd) (types.WaitStatus, error)

func (Local) String

func (h Local) String() string
func (h Local) Symlink(ctx context.Context, oldname, newname string) error

func (Local) Type

func (h Local) Type() string

func (Local) WriteFile

func (h Local) WriteFile(ctx context.Context, name string, data io.Reader, mode types.FileMode) error

type LoggingWrapper

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

LoggingWrapper wraps Host logging received commands.

func NewLoggingWrapper

func NewLoggingWrapper(host types.Host) *LoggingWrapper

func (*LoggingWrapper) AppendFile

func (h *LoggingWrapper) AppendFile(ctx context.Context, name string, data io.Reader, mode types.FileMode) error

func (*LoggingWrapper) Chmod

func (h *LoggingWrapper) Chmod(ctx context.Context, name string, mode types.FileMode) error

func (*LoggingWrapper) Close

func (h *LoggingWrapper) Close(ctx context.Context) error

func (*LoggingWrapper) Getegid

func (h *LoggingWrapper) Getegid(ctx context.Context) (uint64, error)

func (*LoggingWrapper) Geteuid

func (h *LoggingWrapper) Geteuid(ctx context.Context) (uint64, error)

func (*LoggingWrapper) Lchown

func (h *LoggingWrapper) Lchown(ctx context.Context, name string, uid, gid uint32) error

func (*LoggingWrapper) Lookup

func (h *LoggingWrapper) Lookup(ctx context.Context, username string) (*user.User, error)

func (*LoggingWrapper) LookupGroup

func (h *LoggingWrapper) LookupGroup(ctx context.Context, name string) (*user.Group, error)

func (*LoggingWrapper) Lstat

func (h *LoggingWrapper) Lstat(ctx context.Context, name string) (*types.Stat_t, error)

func (*LoggingWrapper) Mkdir

func (h *LoggingWrapper) Mkdir(ctx context.Context, name string, mode types.FileMode) error

func (*LoggingWrapper) Mknod

func (h *LoggingWrapper) Mknod(ctx context.Context, path string, mode types.FileMode, dev types.FileDevice) error

func (*LoggingWrapper) ReadDir

func (h *LoggingWrapper) ReadDir(ctx context.Context, name string) (dirEntResultCh <-chan types.DirEntResult, cancel func())

func (*LoggingWrapper) ReadFile

func (h *LoggingWrapper) ReadFile(ctx context.Context, name string) (io.ReadCloser, error)
func (h *LoggingWrapper) Readlink(ctx context.Context, name string) (string, error)

func (*LoggingWrapper) Remove

func (h *LoggingWrapper) Remove(ctx context.Context, name string) error

func (*LoggingWrapper) Run

func (*LoggingWrapper) String

func (h *LoggingWrapper) String() string
func (h *LoggingWrapper) Symlink(ctx context.Context, oldname, newname string) error

func (*LoggingWrapper) Type

func (h *LoggingWrapper) Type() string

func (*LoggingWrapper) WriteFile

func (h *LoggingWrapper) WriteFile(ctx context.Context, name string, data io.Reader, mode types.FileMode) error

type Ssh

type Ssh struct {
	Hostname string
	// contains filtered or unexported fields
}

Ssh interacts with a remote machine connecting to it via SSH protocol.

func NewSsh

func NewSsh(ctx context.Context, options SshOptions) (Ssh, error)

func NewSshAuthority

func NewSshAuthority(ctx context.Context, authority string, sshClientConfig SshClientConfig) (Ssh, error)

NewSshAuthority creates a new Ssh from given authority in the format [<user>[;fingerprint=<host-key fingerprint>]@]<host>[:<port>] based on https://www.iana.org/assignments/uri-schemes/prov/ssh

func (Ssh) Close

func (h Ssh) Close(ctx context.Context) error

func (Ssh) Run

func (h Ssh) Run(ctx context.Context, cmd types.Cmd) (_ types.WaitStatus, retErr error)

func (Ssh) String

func (h Ssh) String() string

func (Ssh) Type

func (h Ssh) Type() string

type SshClientConfig

type SshClientConfig struct {
	// RekeyThreshold as in ssh.Config
	RekeyThreshold uint64
	// KeyExchanges as in ssh.Config
	KeyExchanges []string
	// Ciphers as in ssh.Config
	Ciphers []string
	// MACs as in ssh.Config
	MACs []string
	// HostKeyAlgorithms as in ssh.ClientConfig
	HostKeyAlgorithms []string
	// Timeout aas in ssh.ClientConfig
	Timeout time.Duration
}

type SshOptions

type SshOptions struct {
	SshClientConfig
	User string
	// Fingerprint is an optional unpadded base64 encoded sha256 hash as introduced by
	// https://www.openssh.com/txt/release-6.8.
	// Eg: SHA256:uwhOoCVTS7b3wlX1popZs5k609OaD1vQurHU34cCWPk
	Fingerprint string
	Host        string
	Port        int
}

type SudoWrapper

type SudoWrapper struct {
	BaseHost types.BaseHost
	Password *string
	// contains filtered or unexported fields
}

SudoWrapper wraps another BaseHost and runs all commands with sudo.

func NewSudoWrapper

func NewSudoWrapper(ctx context.Context, baseHost types.BaseHost) (*SudoWrapper, error)

func (SudoWrapper) Close

func (h SudoWrapper) Close(ctx context.Context) error

func (*SudoWrapper) Run

func (h *SudoWrapper) Run(ctx context.Context, cmd types.Cmd) (types.WaitStatus, error)

func (SudoWrapper) String

func (h SudoWrapper) String() string

func (SudoWrapper) Type

func (h SudoWrapper) Type() string

Directories

Path Synopsis
This lib package contains common functions used at various places.
This lib package contains common functions used at various places.

Jump to

Keyboard shortcuts

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