commandbuilder

package
v0.0.0-...-44f1c1a Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2017 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default SSH options
	ConnectionSshArguments = []string{"-oBatchMode=yes -oPasswordAuthentication=no"}

	// Default Docker options
	ConnectionDockerArguments = []string{"exec", "-i"}
)

Functions

func CommandInterfaceBuilder

func CommandInterfaceBuilder(command string, args ...string) []interface{}

Convert string arguments to interfaces for shell.Cmd usage

Types

type Connection

type Connection struct {
	// Type of command
	// local: for local execution
	// ssh: for execution using ssh
	// docker: for execution using a docker container
	Type string

	// Hostname for ssh execution
	Hostname string

	// Username for ssh execution
	User string

	// Password for ssh execution
	Password string

	// Docker container ID for execution inside docker container
	// compose:name for automatic docker-compose lookup (docker-compose.yml must be in working directory)
	Docker string

	// Working directory for eg. ssh
	WorkDir string

	// Environment variables
	Environment map[string]string
}

func (*Connection) Clone

func (connection *Connection) Clone() Connection

Clone connection

func (*Connection) CommandBuilder

func (connection *Connection) CommandBuilder(command string, args ...string) []interface{}

Build command for shell.Cmd usage will automatically check if SSH'ed or docker exec will be used

func (*Connection) DockerCommandBuilder

func (connection *Connection) DockerCommandBuilder(cmd string, args ...string) []interface{}

Create dockerized command

func (*Connection) DockerGetContainerId

func (connection *Connection) DockerGetContainerId(containerName string) string

Detect docker container id with docker-compose support

func (*Connection) GetType

func (connection *Connection) GetType() string

Return type of connection, will guess type based on settings if type is empty

func (*Connection) IsEmpty

func (connection *Connection) IsEmpty() bool

func (*Connection) LocalCommandBuilder

func (connection *Connection) LocalCommandBuilder(cmd string, args ...string) []interface{}

Create local command

func (*Connection) RawCommandBuilder

func (connection *Connection) RawCommandBuilder(command string, args ...string) []interface{}

Build raw command (not automatically quoted) for shell.Cmd usage will automatically check if SSH'ed or docker exec will be used

func (*Connection) RawShellCommandBuilder

func (connection *Connection) RawShellCommandBuilder(args ...string) []interface{}

Run raw command (not automatically quoted) using an shell (eg. for running pipes or multiple commands) will automatically check if SSH'ed or docker exec will be used

func (*Connection) ShellCommandBuilder

func (connection *Connection) ShellCommandBuilder(args ...string) []interface{}

Run command using an shell (eg. for running pipes or multiple commands) will automatically check if SSH'ed or docker exec will be used

func (*Connection) SshCommandBuilder

func (connection *Connection) SshCommandBuilder(command string, args ...string) []interface{}

Create SSH'ed command

func (*Connection) SshConnectionHostnameString

func (connection *Connection) SshConnectionHostnameString() string

Build ssh connection string (eg. user@hostname)

func (*Connection) String

func (connection *Connection) String() string

Create human readable string representation of command

Jump to

Keyboard shortcuts

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