client

package
v0.56.0-devel Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package client contains the definitions of the different clients that can be used in a test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDockerAgentClient added in v0.51.0

func NewDockerAgentClient(context e2e.Context, dockerAgentOutput agent.DockerAgentOutput, options ...agentclientparams.Option) (agentclient.Agent, error)

NewDockerAgentClient creates an Agent client for a Docker install

func NewHostAgentClient added in v0.51.0

func NewHostAgentClient(context e2e.Context, hostOutput remote.HostOutput, waitForAgentReady bool) (agentclient.Agent, error)

NewHostAgentClient creates an Agent client for host install

func NewHostAgentClientWithParams added in v0.54.0

func NewHostAgentClientWithParams(context e2e.Context, hostOutput remote.HostOutput, options ...agentclientparams.Option) (agentclient.Agent, error)

NewHostAgentClientWithParams creates an Agent client for host install with custom parameters

Types

type Docker

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

A Docker client that is connected to an docker.Deamon.

func NewDocker

func NewDocker(t *testing.T, dockerOutput docker.ManagerOutput) (*Docker, error)

NewDocker creates a new instance of Docker NOTE: docker+ssh does not support password protected SSH keys.

func (*Docker) ExecuteCommand

func (docker *Docker) ExecuteCommand(containerName string, commands ...string) string

ExecuteCommand executes a command on containerName and returns the output.

func (*Docker) ExecuteCommandStdoutStdErr

func (docker *Docker) ExecuteCommandStdoutStdErr(containerName string, commands ...string) (string, string, error)

ExecuteCommandStdoutStdErr executes a command on containerName and returns the output, the error output and an error.

func (*Docker) ExecuteCommandWithErr

func (docker *Docker) ExecuteCommandWithErr(containerName string, commands ...string) (string, error)

ExecuteCommandWithErr executes a command on containerName and returns the output and an error.

func (*Docker) GetClient

func (docker *Docker) GetClient() *client.Client

GetClient gets the docker client.

type EC2Metadata

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

EC2Metadata contains a pointer to a VM and its AWS token

func NewEC2Metadata

func NewEC2Metadata(t *testing.T, h *Host, osFamily os.Family) *EC2Metadata

NewEC2Metadata creates a new EC2Metadata given an EC2 [VM]

func (*EC2Metadata) Get

func (m *EC2Metadata) Get(name string) string

Get returns EC2 instance name

type EnvVar

type EnvVar map[string]string

EnvVar alias to map representing env variables

type ExecuteOption

type ExecuteOption func(*ExecuteParams) error

ExecuteOption alias to a functional option changing a given Params instance

func WithEnvVariables

func WithEnvVariables(env EnvVar) ExecuteOption

WithEnvVariables allows to set env variable for the command that will be executed

type ExecuteParams

type ExecuteParams struct {
	EnvVariables EnvVar
}

ExecuteParams contains parameters for VM.Execute commands

type Host

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

A Host client that is connected to an ssh.Client.

func NewHost

func NewHost(context e2e.Context, hostOutput remote.HostOutput) (*Host, error)

NewHost creates a new ssh client to connect to a remote host with reconnect retry logic

func (*Host) AppendFile

func (h *Host) AppendFile(os, path string, content []byte) (int64, error)

AppendFile append content to the file and returns the number of bytes appened and error if any

func (*Host) CopyFile

func (h *Host) CopyFile(src string, dst string)

CopyFile create a sftp session and copy a single file to the remote host through SSH

func (*Host) CopyFolder

func (h *Host) CopyFolder(srcFolder string, dstFolder string) error

CopyFolder create a sftp session and copy a folder to remote host through SSH

func (*Host) DialPort

func (h *Host) DialPort(port uint16) (net.Conn, error)

DialPort creates a connection from the remote host to its `port`.

func (*Host) Execute

func (h *Host) Execute(command string, options ...ExecuteOption) (string, error)

Execute executes a command and returns an error if any.

func (*Host) FileExists

func (h *Host) FileExists(path string) (bool, error)

FileExists create a sftp session to and returns true if the file exists and is a regular file

func (*Host) GetFile

func (h *Host) GetFile(src string, dst string) error

GetFile create a sftp session and copy a single file from the remote host through SSH

func (*Host) Lstat

func (h *Host) Lstat(path string) (fs.FileInfo, error)

Lstat returns a FileInfo structure describing path. if path is a symbolic link, the FileInfo structure describes the symbolic link.

func (*Host) MkdirAll

func (h *Host) MkdirAll(path string) error

MkdirAll creates the specified directory along with any necessary parents. If the path is already a directory, does nothing and returns nil. Otherwise returns an error if any.

func (*Host) MustExecute

func (h *Host) MustExecute(command string, options ...ExecuteOption) string

MustExecute executes a command and requires no error.

func (*Host) ReadDir

func (h *Host) ReadDir(path string) ([]fs.DirEntry, error)

ReadDir returns list of directory entries in path

func (*Host) ReadFile

func (h *Host) ReadFile(path string) ([]byte, error)

ReadFile reads the content of the file, return bytes read and error if any

func (*Host) Reconnect

func (h *Host) Reconnect() error

Reconnect closes the current ssh client and creates a new one, with retries.

func (*Host) Remove

func (h *Host) Remove(path string) error

Remove removes the specified file or directory. Returns an error if file or directory does not exist, or if the directory is not empty.

func (*Host) RemoveAll

func (h *Host) RemoveAll(path string) error

RemoveAll recursively removes all files/folders in the specified directory. Returns an error if the directory does not exist.

func (*Host) WriteFile

func (h *Host) WriteFile(path string, content []byte) (int64, error)

WriteFile write content to the file and returns the number of bytes written and error if any

Directories

Path Synopsis
Package agentclient provides an interface to run Agent commands.
Package agentclient provides an interface to run Agent commands.
Package agentclientparams implements function parameters for [e2e.Agent]
Package agentclientparams implements function parameters for [e2e.Agent]

Jump to

Keyboard shortcuts

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