Documentation ¶
Overview ¶
Package target provides a way to interact with local and remote systems.
- Copyright (C) 2023 Intel Corporation
- SPDX-License-Identifier: MIT
Index ¶
- func RunLocalCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error)
- func RunLocalCommandWithInput(cmd *exec.Cmd, input string) (stdout string, stderr string, exitCode int, err error)
- func RunLocalCommandWithInputWithTimeout(cmd *exec.Cmd, input string, timeout int) (stdout string, stderr string, exitCode int, err error)
- func RunLocalCommandWithTimeout(cmd *exec.Cmd, timeout int) (stdout string, stderr string, exitCode int, err error)
- type LocalTarget
- func (t *LocalTarget) CanConnect() bool
- func (t *LocalTarget) CanElevatePrivileges() bool
- func (t *LocalTarget) CreateDirectory(baseDir string, targetDir string) (dir string, err error)
- func (t *LocalTarget) CreateTempDirectory(rootDir string) (tempDir string, err error)
- func (t *LocalTarget) GetArchitecture() (arch string, err error)
- func (t *LocalTarget) GetName() (host string)
- func (t *LocalTarget) GetSudo() (sudo string)
- func (t *LocalTarget) PullFile(srcPath string, dstDir string) (err error)
- func (t *LocalTarget) PushFile(srcPath string, dstPath string) (err error)
- func (t *LocalTarget) RemoveDirectory(targetDir string) (err error)
- func (t *LocalTarget) RunCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error)
- func (t *LocalTarget) RunCommandWithTimeout(cmd *exec.Cmd, timeout int) (stdout string, stderr string, exitCode int, err error)
- func (t *LocalTarget) SetSudo(sudo string)
- type RemoteTarget
- func (t *RemoteTarget) CanConnect() bool
- func (t *RemoteTarget) CreateDirectory(baseDir string, targetDir string) (dir string, err error)
- func (t *RemoteTarget) CreateTempDirectory(rootDir string) (tempDir string, err error)
- func (t *RemoteTarget) GetArchitecture() (arch string, err error)
- func (t *RemoteTarget) GetName() (host string)
- func (t *RemoteTarget) GetSudo() (sudo string)
- func (t *RemoteTarget) PullFile(srcPath string, dstDir string) (err error)
- func (t *RemoteTarget) PushFile(srcPath string, dstDir string) (err error)
- func (t *RemoteTarget) RemoveDirectory(targetDir string) (err error)
- func (t *RemoteTarget) RunCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error)
- func (t *RemoteTarget) RunCommandWithTimeout(cmd *exec.Cmd, timeout int) (stdout string, stderr string, exitCode int, err error)
- func (t *RemoteTarget) SetSudo(sudo string)
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunLocalCommand ¶
Types ¶
type LocalTarget ¶
type LocalTarget struct {
// contains filtered or unexported fields
}
func NewLocalTarget ¶
func NewLocalTarget(host string, sudo string) *LocalTarget
func (*LocalTarget) CanConnect ¶
func (t *LocalTarget) CanConnect() bool
func (*LocalTarget) CanElevatePrivileges ¶
func (t *LocalTarget) CanElevatePrivileges() bool
func (*LocalTarget) CreateDirectory ¶
func (t *LocalTarget) CreateDirectory(baseDir string, targetDir string) (dir string, err error)
func (*LocalTarget) CreateTempDirectory ¶
func (t *LocalTarget) CreateTempDirectory(rootDir string) (tempDir string, err error)
CreateTempDirectory creates a temporary directory on the local target in the directory specified by rootDir. If rootDir is an empty string, the temporary directory will be created in the system's default directory for temporary files, e.g. /tmp. The full path to the temporary directory is returned.
func (*LocalTarget) GetArchitecture ¶
func (t *LocalTarget) GetArchitecture() (arch string, err error)
func (*LocalTarget) GetName ¶
func (t *LocalTarget) GetName() (host string)
func (*LocalTarget) GetSudo ¶
func (t *LocalTarget) GetSudo() (sudo string)
func (*LocalTarget) PullFile ¶
func (t *LocalTarget) PullFile(srcPath string, dstDir string) (err error)
func (*LocalTarget) PushFile ¶
func (t *LocalTarget) PushFile(srcPath string, dstPath string) (err error)
PushFile copies file from src to dst
srcPath: full path to source file dstPath: destination directory or full path to destination file
func (*LocalTarget) RemoveDirectory ¶
func (t *LocalTarget) RemoveDirectory(targetDir string) (err error)
func (*LocalTarget) RunCommand ¶
func (*LocalTarget) RunCommandWithTimeout ¶
func (*LocalTarget) SetSudo ¶
func (t *LocalTarget) SetSudo(sudo string)
type RemoteTarget ¶
type RemoteTarget struct {
// contains filtered or unexported fields
}
func NewRemoteTarget ¶
func (*RemoteTarget) CanConnect ¶
func (t *RemoteTarget) CanConnect() bool
func (*RemoteTarget) CreateDirectory ¶
func (t *RemoteTarget) CreateDirectory(baseDir string, targetDir string) (dir string, err error)
func (*RemoteTarget) CreateTempDirectory ¶
func (t *RemoteTarget) CreateTempDirectory(rootDir string) (tempDir string, err error)
CreateTempDirectory creates a temporary directory on the remote target in the directory specified by rootDir. If rootDir is an empty string, the temporary directory will be created in the system's default directory for temporary files, e.g. /tmp. The full path to the temporary directory is returned.
func (*RemoteTarget) GetArchitecture ¶
func (t *RemoteTarget) GetArchitecture() (arch string, err error)
func (*RemoteTarget) GetName ¶
func (t *RemoteTarget) GetName() (host string)
func (*RemoteTarget) GetSudo ¶
func (t *RemoteTarget) GetSudo() (sudo string)
func (*RemoteTarget) PullFile ¶
func (t *RemoteTarget) PullFile(srcPath string, dstDir string) (err error)
func (*RemoteTarget) PushFile ¶
func (t *RemoteTarget) PushFile(srcPath string, dstDir string) (err error)
func (*RemoteTarget) RemoveDirectory ¶
func (t *RemoteTarget) RemoveDirectory(targetDir string) (err error)
func (*RemoteTarget) RunCommand ¶
func (*RemoteTarget) RunCommandWithTimeout ¶
func (*RemoteTarget) SetSudo ¶
func (t *RemoteTarget) SetSudo(sudo string)
type Target ¶
type Target interface { RunCommand(*exec.Cmd) (string, string, int, error) RunCommandWithTimeout(*exec.Cmd, int) (string, string, int, error) CreateTempDirectory(string) (string, error) GetArchitecture() (string, error) PushFile(string, string) error PullFile(string, string) error CreateDirectory(string, string) (string, error) RemoveDirectory(string) error GetName() string CanConnect() bool GetSudo() string SetSudo(string) }