Documentation
¶
Overview ¶
Package client contains the definitions of the different clients that can be used in a test.
Index ¶
- func AgentSelectorAnyPod(agentType kubernetes.KubernetesObjRefOutput) metav1.ListOptions
- func DefaultWindowsAgentInstallPath(host *Host) string
- func NewDockerAgentClient(context common.Context, dockerAgentOutput agent.DockerAgentOutput, ...) (agentclient.Agent, error)
- func NewHostAgentClient(context common.Context, hostOutput remote.HostOutput, waitForAgentReady bool) (agentclient.Agent, error)
- func NewHostAgentClientWithParams(context common.Context, hostOutput remote.HostOutput, ...) (agentclient.Agent, error)
- func NewK8sAgentClient(context common.Context, podSelector metav1.ListOptions, ...) (agentclient.Agent, error)
- type Docker
- func (docker *Docker) DownloadFile(containerName, containerPath, localPath string) error
- func (docker *Docker) ExecuteCommand(containerName string, commands ...string) string
- func (docker *Docker) ExecuteCommandStdoutStdErr(containerName string, commands ...string) (stdout string, stderr string, err error)
- func (docker *Docker) ExecuteCommandWithErr(containerName string, commands ...string) (string, error)
- func (docker *Docker) ListContainers() ([]string, error)
- type EC2Metadata
- type EnvVar
- type ExecuteOption
- type ExecuteParams
- type Host
- func (h *Host) AppendFile(os, path string, content []byte) (int64, error)
- func (h *Host) CopyFile(src string, dst string)
- func (h *Host) CopyFileFromFS(fs fs.FS, src, dst string)
- func (h *Host) CopyFolder(srcFolder string, dstFolder string) error
- func (h *Host) DialPort(port uint16) (net.Conn, error)
- func (h *Host) EnsureFileIsReadable(path string) error
- func (h Host) Execute(command string, options ...ExecuteOption) (string, error)
- func (h *Host) FileExists(path string) (bool, error)
- func (h *Host) FindFiles(name string) ([]string, error)
- func (h *Host) GetAgentConfigFolder() (string, error)
- func (h *Host) GetFile(src string, dst string) error
- func (h *Host) GetFolder(srcFolder string, dstFolder string) error
- func (h *Host) GetLogsFolder() (string, error)
- func (h *Host) GetTmpFolder() (string, error)
- func (h *Host) HTTPTransport() http.RoundTripper
- func (h *Host) JoinPath(path ...string) string
- func (h *Host) Lstat(path string) (fs.FileInfo, error)
- func (h *Host) MkdirAll(path string) error
- func (h Host) MustExecute(command string, options ...ExecuteOption) string
- func (h *Host) NewHTTPClient() *http.Client
- func (h *Host) ReadDir(path string) ([]fs.DirEntry, error)
- func (h *Host) ReadFile(path string) ([]byte, error)
- func (h *Host) ReadFilePrivileged(path string) ([]byte, error)
- func (h Host) Reconnect() error
- func (h *Host) Remove(path string) error
- func (h *Host) RemoveAll(path string) error
- func (h Host) Start(command string, options ...ExecuteOption) (*ssh.Session, io.WriteCloser, io.Reader, error)
- func (h *Host) WriteFile(path string, content []byte) (int64, error)
- type HostArtifactClient
- type KubernetesClient
- type PodExecOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentSelectorAnyPod ¶
func AgentSelectorAnyPod(agentType kubernetes.KubernetesObjRefOutput) metav1.ListOptions
AgentSelectorAnyPod creates a selector for any pod that runs the agent of the given type. For example, you can pass Agent.LinuxNodeAgent to select any pod that runs the node agent.
func DefaultWindowsAgentInstallPath ¶
DefaultWindowsAgentInstallPath returns a reasonable default for the AgentInstallPath.
If the Agent is installed, the installPath is read from the registry. If the registry key is not found, returns the default install path.
func NewDockerAgentClient ¶
func NewDockerAgentClient(context common.Context, dockerAgentOutput agent.DockerAgentOutput, options ...agentclientparams.Option) (agentclient.Agent, error)
NewDockerAgentClient creates an Agent client for a Docker install
func NewHostAgentClient ¶
func NewHostAgentClient(context common.Context, hostOutput remote.HostOutput, waitForAgentReady bool) (agentclient.Agent, error)
NewHostAgentClient creates an Agent client for host install
func NewHostAgentClientWithParams ¶
func NewHostAgentClientWithParams(context common.Context, hostOutput remote.HostOutput, options ...agentclientparams.Option) (agentclient.Agent, error)
NewHostAgentClientWithParams creates an Agent client for host install with custom parameters
func NewK8sAgentClient ¶
func NewK8sAgentClient(context common.Context, podSelector metav1.ListOptions, clusterClient *KubernetesClient, options ...agentclientparams.Option) (agentclient.Agent, error)
NewK8sAgentClient creates an Agent client for a Kubernetes install, passing the ListOptions to select the pod that runs the agent. There are some helper functions to create common selectors, such as AgentSelectorAnyPod that will select any pod that runs the agent.
Types ¶
type Docker ¶
type Docker struct {
// contains filtered or unexported fields
}
A Docker client that is connected to an docker.Deamon.
func NewDocker ¶
NewDocker creates a new instance of Docker NOTE: docker+ssh does not support password protected SSH keys.
func (*Docker) DownloadFile ¶
DownloadFile downloads a file or directory from the container to the local filesystem.
func (*Docker) ExecuteCommand ¶
ExecuteCommand executes a command on containerName and returns the output.
func (*Docker) ExecuteCommandStdoutStdErr ¶
func (docker *Docker) ExecuteCommandStdoutStdErr(containerName string, commands ...string) (stdout string, stderr string, err 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) ListContainers ¶
ListContainers returns a list of container names.
type EC2Metadata ¶
type EC2Metadata struct {
// contains filtered or unexported fields
}
EC2Metadata contains a pointer to a VM and its AWS token
func NewEC2Metadata ¶
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 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 {
HostArtifactClient
// contains filtered or unexported fields
}
A Host client that is connected to an ssh.Client.
func NewHost ¶
NewHost creates a new ssh client to connect to a remote host with reconnect retry logic
func (*Host) AppendFile ¶
AppendFile append content to the file and returns the number of bytes appened and error if any
func (*Host) CopyFile ¶
CopyFile creates a sftp session and copy a single file to the remote host through SSH
func (*Host) CopyFileFromFS ¶
CopyFileFromFS creates a sftp session and copy a single embedded file to the remote host through SSH
func (*Host) CopyFolder ¶
CopyFolder create a sftp session and copy a folder to remote host through SSH
func (*Host) EnsureFileIsReadable ¶
EnsureFileIsReadable add readable rights to a remote file
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 ¶
FileExists create a sftp session to and returns true if the file exists and is a regular file
func (*Host) GetAgentConfigFolder ¶
GetAgentConfigFolder returns the agent config folder path for the host
func (*Host) GetFile ¶
GetFile create a sftp session and copy a single file from the remote host through SSH
func (*Host) GetFolder ¶
GetFolder create a sftp session and copy a folder from the remote host through SSH
func (*Host) GetLogsFolder ¶
GetLogsFolder returns the logs folder path for the host
func (*Host) GetTmpFolder ¶
GetTmpFolder returns the temporary folder path for the host
func (*Host) HTTPTransport ¶
func (h *Host) HTTPTransport() http.RoundTripper
HTTPTransport returns an http.RoundTripper which dials the remote host. This transport can only reach the host.
func (*Host) Lstat ¶
Lstat returns a FileInfo structure describing path. if path is a symbolic link, the FileInfo structure describes the symbolic link.
func (*Host) MkdirAll ¶
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) NewHTTPClient ¶
NewHTTPClient returns an *http.Client which dials the remote host. This client can only reach the host.
func (*Host) ReadFilePrivileged ¶
ReadFilePrivileged reads the content of the file with a privileged user, 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 ¶
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 ¶
RemoveAll recursively removes all files/folders in the specified directory. Returns an error if the directory does not exist.
type HostArtifactClient ¶
HostArtifactClient is a client that can get files from the artifact bucket to the remote host
type KubernetesClient ¶
type KubernetesClient struct {
K8sConfig *rest.Config
K8sClient kubeClient.Interface
}
KubernetesClient is a wrapper around the k8s client library and provides convenience methods for interacting with a k8s cluster
func NewKubernetesClient ¶
func NewKubernetesClient(config *rest.Config) (*KubernetesClient, error)
NewKubernetesClient creates a new KubernetesClient
func (*KubernetesClient) DownloadFromPod ¶
func (k *KubernetesClient) DownloadFromPod(namespace, podName, container, srcPath, destPath string) error
DownloadFromPod downloads a folder from a pod to a local destination
func (*KubernetesClient) PodExec ¶
func (k *KubernetesClient) PodExec(namespace, pod, container string, cmd []string, podOptions ...PodExecOption) (stdout, stderr string, err error)
PodExec execs into a given namespace/pod and returns the output for the given command
type PodExecOption ¶
type PodExecOption func(*corev1.PodExecOptions)
PodExecOption is a function that can be used to modify the PodExecOptions
Source Files
¶
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] |