module

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TEMPLATE_DOCKER_INFO         = "{{.engine}} info"
	TEMPLATE_PULL_IMAGE          = "{{.engine}} pull {{.options}} {{.name}}"
	TEMPLATE_CREATE_CONTAINER    = "{{.engine}} create {{.options}} {{.image}} {{.command}}"
	TEMPLATE_START_CONTAINER     = "{{.engine}} start {{.options}} {{.containers}}"
	TEMPLATE_STOP_CONTAINER      = "{{.engine}} stop {{.options}} {{.containers}}"
	TEMPLATE_RESTART_CONTAINER   = "{{.engine}} restart {{.options}} {{.containers}}"
	TEMPLATE_WAIT_CONTAINER      = "{{.engine}} wait {{.options}} {{.containers}}"
	TEMPLATE_REMOVE_CONTAINER    = "{{.engine}} rm {{.options}} {{.containers}}"
	TEMPLATE_LIST_CONTAINERS     = "{{.engine}} ps {{.options}}"
	TEMPLATE_CONTAINER_EXEC      = "{{.engine}} exec {{.options}} {{.container}} {{.command}}"
	TEMPLATE_COPY_FROM_CONTAINER = "{{.engine}} cp {{.options}} {{.container}}:{{.srcPath}} {{.destPath}}"
	TEMPLATE_COPY_INTO_CONTAINER = "{{.engine}} cp {{.options}}  {{.srcPath}} {{.container}}:{{.destPath}}"
	TEMPLATE_INSPECT_CONTAINER   = "{{.engine}} inspect {{.options}} {{.container}}"
	TEMPLATE_CONTAINER_LOGS      = "{{.engine}} logs {{.options}} {{.container}}"
	TEMPLATE_UPDATE_CONTAINER    = "{{.engine}} update {{.options}} {{.container}}"
)
View Source
const (
	// text
	TEMPLATE_SED = "sed {{.options}} {{.files}}"

	// storage (filesystem/block)
	TEMPLATE_LIST     = "ls {{.options}} {{.files}}"
	TEMPLATE_MKDIR    = "mkdir {{.options}} {{.directorys}}"
	TEMPLATE_RMDIR    = "rmdir {{.options}} {{.directorys}}"
	TEMPLATE_REMOVE   = "rm {{.options}} {{.files}}"
	TEMPLATE_RENAME   = "mv {{.options}} {{.source}} {{.dest}}"
	TEMPLATE_COPY     = "cp {{.options}} {{.source}} {{.dest}}"
	TEMPLATE_CHMOD    = "chmod {{.options}} {{.mode}} {{.file}}"
	TEMPLATE_STAT     = "stat {{.options}} {{.files}}"
	TEMPLATE_CAT      = "cat {{.options}} {{.files}}"
	TEMPLATE_MKFS     = "mkfs.ext4 {{.options}} {{.device}}"
	TEMPLATE_MOUNT    = "mount {{.options}} {{.source}} {{.directory}}"
	TEMPLATE_UMOUNT   = "umount {{.options}} {{.directory}}"
	TEMPLATE_TUNE2FS  = "tune2fs {{.options}} {{.device}}"
	TEMPLATE_FUSER    = "fuser {{.options}} {{.names}}"
	TEMPLATE_DISKFREE = "df {{.options}} {{.files}}"
	TEMPLATE_LSBLK    = "lsblk {{.options}} {{.devices}}"
	TEMPLATE_BLKID    = "blkid {{.options}} {{.device}}"

	// network
	TEMPLATE_SS   = "ss {{.options}} '{{.filter}}'"
	TEMPLATE_PING = "ping {{.options}} {{.destination}}"
	TEMPLATE_CURL = "curl {{.options}} {{.url}}"

	// kernel
	TEMPLATE_WHOAMI   = "whoami"
	TEMPLATE_DATE     = "date {{.options}} {{.format}}"
	TEMPLATE_UNAME    = "uname {{.options}}"
	TEMPLATE_MODPROBE = "modprobe {{.options}} {{.modulename}} {{.arguments}}"
	TEMPLATE_MODINFO  = "modinfo {{.modulename}}"

	// others
	TEMPLATE_TAR  = "tar {{.options}} {{.file}}"
	TEMPLATE_DPKG = "dpkg {{.options}}"
	TEMPLATE_RPM  = "rpm {{.options}}"
	TEMPLATE_SCP  = "scp {{.options}} {{.source}} {{.user}}@{{.host}}:{{.target}}"

	// bash
	TEMPLATE_COMMAND     = "{{.command}}"
	TEMPLATE_BASH_SCEIPT = "bash {{.scriptPath}} {{.arguments}}"
)
View Source
const (
	TEMP_DIR = "/tmp"
)

Variables

View Source
var (
	ERR_UNREACHED = errors.New("remote unreached")
)

Functions

func VerifyHost

func VerifyHost(host string, remote net.Addr, key ssh.PublicKey) error

Types

type DockerCli

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

func NewDockerCli

func NewDockerCli(sshClient *SSHClient) *DockerCli

func (*DockerCli) AddOption

func (s *DockerCli) AddOption(format string, args ...interface{}) *DockerCli

func (*DockerCli) ContainerExec

func (cli *DockerCli) ContainerExec(containerId, command string) *DockerCli

func (*DockerCli) ContainerLogs added in v0.1.0

func (cli *DockerCli) ContainerLogs(containerId string) *DockerCli

func (*DockerCli) CopyFromContainer

func (cli *DockerCli) CopyFromContainer(containerId, srcPath, destPath string) *DockerCli

func (*DockerCli) CopyIntoContainer

func (cli *DockerCli) CopyIntoContainer(srcPath, containerId, destPath string) *DockerCli

func (*DockerCli) CreateContainer

func (cli *DockerCli) CreateContainer(image, command string) *DockerCli

func (*DockerCli) DockerInfo added in v0.1.0

func (cli *DockerCli) DockerInfo() *DockerCli

func (*DockerCli) Execute

func (cli *DockerCli) Execute(options ExecOptions) (string, error)

func (*DockerCli) InspectContainer

func (cli *DockerCli) InspectContainer(containerId string) *DockerCli

func (*DockerCli) ListContainers

func (cli *DockerCli) ListContainers() *DockerCli

func (*DockerCli) PullImage

func (cli *DockerCli) PullImage(image string) *DockerCli

func (*DockerCli) RemoveContainer

func (cli *DockerCli) RemoveContainer(containerId ...string) *DockerCli

func (*DockerCli) RestartContainer

func (cli *DockerCli) RestartContainer(containerId ...string) *DockerCli

func (*DockerCli) StartContainer

func (cli *DockerCli) StartContainer(containerId ...string) *DockerCli

func (*DockerCli) StopContainer

func (cli *DockerCli) StopContainer(containerId ...string) *DockerCli

func (*DockerCli) WaitContainer

func (cli *DockerCli) WaitContainer(containerId ...string) *DockerCli

type ExecOptions added in v0.1.0

type ExecOptions struct {
	ExecWithSudo   bool
	ExecInLocal    bool
	ExecSudoAlias  string
	ExecTimeoutSec int
	ExecWithEngine string
}

type FileManager

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

func NewFileManager

func NewFileManager(sshClient *SSHClient) *FileManager

func (*FileManager) Download

func (f *FileManager) Download(remotePath, localPath string) error

func (*FileManager) Install

func (f *FileManager) Install(content, destPath string) error

func (*FileManager) Upload

func (f *FileManager) Upload(localPath, remotePath string) error

type Module

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

func NewModule

func NewModule(sshClient *SSHClient) *Module

func (*Module) DockerCli

func (m *Module) DockerCli() *DockerCli

func (*Module) File

func (m *Module) File() *FileManager

func (*Module) Shell

func (m *Module) Shell() *Shell

type SSHClient added in v0.1.0

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

func NewSSHClient added in v0.1.0

func NewSSHClient(config SSHConfig) (*SSHClient, error)

func (*SSHClient) Client added in v0.1.0

func (client *SSHClient) Client() *goph.Client

func (*SSHClient) Config added in v0.1.0

func (client *SSHClient) Config() SSHConfig

type SSHConfig

type SSHConfig struct {
	User              string
	Host              string
	Port              uint
	ForwardAgent      bool // ForwardAgent > PrivateKeyPath > Password
	BecomeMethod      string
	BecomeFlags       string
	BecomeUser        string
	PrivateKeyPath    string
	ConnectRetries    int
	ConnectTimeoutSec int
}

type Shell

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

TODO(P1): support command pipe

func NewShell

func NewShell(sshClient *SSHClient) *Shell

func (*Shell) AddOption

func (s *Shell) AddOption(format string, args ...interface{}) *Shell

func (*Shell) BashScript added in v0.1.0

func (s *Shell) BashScript(scriptPath string, args ...string) *Shell

func (*Shell) BlkId added in v0.3.0

func (s *Shell) BlkId(device string) *Shell

func (*Shell) Cat added in v0.1.0

func (s *Shell) Cat(files ...string) *Shell

func (*Shell) Chmod

func (s *Shell) Chmod(mode, file string) *Shell

func (*Shell) Command

func (s *Shell) Command(command string) *Shell

func (*Shell) Copy added in v0.1.0

func (s *Shell) Copy(source, dest string) *Shell

func (*Shell) Curl added in v0.1.0

func (s *Shell) Curl(url string) *Shell

func (*Shell) Date added in v0.1.0

func (s *Shell) Date(format string) *Shell

func (*Shell) DiskFree

func (s *Shell) DiskFree(file ...string) *Shell

func (*Shell) Dpkg added in v0.1.0

func (s *Shell) Dpkg() *Shell

func (*Shell) Execute

func (s *Shell) Execute(options ExecOptions) (string, error)

func (*Shell) Fuser

func (s *Shell) Fuser(name ...string) *Shell

func (*Shell) List added in v0.1.0

func (s *Shell) List(files ...string) *Shell

storage(filesystem/block)

func (*Shell) LsBlk added in v0.1.0

func (s *Shell) LsBlk(device ...string) *Shell

func (*Shell) Mkdir

func (s *Shell) Mkdir(directory ...string) *Shell

func (*Shell) Mkfs

func (s *Shell) Mkfs(device string) *Shell

func (*Shell) ModInfo added in v0.1.0

func (s *Shell) ModInfo(modulename string) *Shell

func (*Shell) ModProbe

func (s *Shell) ModProbe(modulename string, args ...string) *Shell

func (*Shell) Mount

func (s *Shell) Mount(source, directory string) *Shell

func (*Shell) Ping added in v0.1.0

func (s *Shell) Ping(destination string) *Shell

func (*Shell) Remove

func (s *Shell) Remove(file ...string) *Shell

func (*Shell) Rename

func (s *Shell) Rename(source, dest string) *Shell

func (*Shell) Rmdir

func (s *Shell) Rmdir(directory ...string) *Shell

func (*Shell) Rpm added in v0.1.0

func (s *Shell) Rpm() *Shell

func (*Shell) Scp added in v0.2.0

func (s *Shell) Scp(source, user, host, target string) *Shell

func (*Shell) Sed added in v0.1.0

func (s *Shell) Sed(file ...string) *Shell

text

func (*Shell) SocketStatistics added in v0.1.0

func (s *Shell) SocketStatistics(filter string) *Shell

network

func (*Shell) Stat added in v0.1.0

func (s *Shell) Stat(files ...string) *Shell

func (*Shell) String added in v0.1.0

func (s *Shell) String() (string, error)

func (*Shell) Tar added in v0.1.0

func (s *Shell) Tar(file string) *Shell

other

func (*Shell) Tune2FS added in v0.3.0

func (s *Shell) Tune2FS(device string) *Shell

func (*Shell) Umount

func (s *Shell) Umount(directory string) *Shell

func (*Shell) UnixName added in v0.1.0

func (s *Shell) UnixName() *Shell

func (*Shell) Whoami added in v0.1.0

func (s *Shell) Whoami() *Shell

kernel

type TimeoutError added in v0.1.0

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

func (*TimeoutError) Error added in v0.1.0

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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