util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Addr string

Addr specifies api_server listening address

View Source
var AwsAccessKeyID string

AwsAccessKeyID specifies S3 access key id

View Source
var AwsSecretAccessKey string

AwsSecretAccessKey specifies S3 secret access key

View Source
var ErrContainerExitNonZero = fmt.Errorf("container exit with non zero")

ErrContainerExitNonZero ...

View Source
var S3Endpoint string

S3Endpoint specifies s3 object storage address

Functions

func Command

func Command(workDir, command string, args ...string) (string, error)

Command ...

func MkDir

func MkDir(dir string) error

MkDir ...

func RandomResource

func RandomResource(rs []*types.Resource) (*types.Resource, error)

RandomResource ...

func SSHKeyPath

func SSHKeyPath() string

SSHKeyPath ...

func Unzip

func Unzip(filePath, destDir string) (err error)

Unzip unzips a archive file

func Wget

func Wget(rawURL string, dest string) (string, error)

Wget ...

Types

type CommandError

type CommandError struct {
	WorkDir string
	Cmd     string
	Args    []string
	Err     error
	Output  string
}

CommandError saves command execution error

func (*CommandError) Error

func (c *CommandError) Error() string

type DockerExecutor

type DockerExecutor struct {
	*client.Client
}

DockerExecutor encapsulate docker client executor

func NewDockerExecutor

func NewDockerExecutor(host string) (*DockerExecutor, error)

NewDockerExecutor ...

func (*DockerExecutor) RmContainer

func (d *DockerExecutor) RmContainer(containerID string) error

RmContainer rms container

func (*DockerExecutor) Run

func (d *DockerExecutor) Run(dockerImage string, envs map[string]string, cmd *string, args ...string) (string, *bytes.Buffer, error)

Run runs a docker container

type SSHConfig

type SSHConfig struct {
	Host       string // hostname of the SSH server
	Port       uint   // port of the SSH server
	User       string // username to login to the SSH server
	Password   string // password of the user
	KeyFile    string // path to the private key file
	Passphrase string // passphrase of the private key file
	// Timeout is the maximum wait time for the TCP connection to establish
	Timeout time.Duration
}

SSHConfig ...

type SSHExecutor

type SSHExecutor struct {
	Config *easyssh.MakeConfig
}

SSHExecutor ...

func NewSSHExecutor

func NewSSHExecutor(c SSHConfig) SSHExecutor

NewSSHExecutor creates a ssh executor

func (*SSHExecutor) Execute

func (ssh *SSHExecutor) Execute(cmd string, timeout ...time.Duration) ([]byte, []byte, error)

Execute executes a command on a remote host

Jump to

Keyboard shortcuts

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