commandbuilder

package
v0.0.0-...-a6be64f Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 8 Imported by: 0

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 Argument

type Argument struct {
	Scheme      string
	Hostname    string
	Port        string
	Username    string
	Password    string
	Raw         string
	Options     map[string]string
	Environment map[string]string
	Workdir     string
	// contains filtered or unexported fields
}

func ParseArgument

func ParseArgument(value string) (Argument, error)

func (*Argument) Clear

func (argument *Argument) Clear()

func (*Argument) Clone

func (argument *Argument) Clone() *Argument

Clone connection

func (*Argument) GetEnvironment

func (argument *Argument) GetEnvironment(name string) (string, error)

func (*Argument) GetOption

func (argument *Argument) GetOption(name string) (string, error)

func (*Argument) HasEnvironment

func (argument *Argument) HasEnvironment(name string) bool

func (*Argument) HasOption

func (argument *Argument) HasOption(name string) bool

func (*Argument) IsEmpty

func (argument *Argument) IsEmpty() bool

func (*Argument) IsSimpleValue

func (argument *Argument) IsSimpleValue() bool

func (*Argument) ParseDsn

func (argument *Argument) ParseDsn() error

func (*Argument) ParseUrl

func (argument *Argument) ParseUrl() error

func (*Argument) ParseUserHost

func (argument *Argument) ParseUserHost() error

func (*Argument) Set

func (argument *Argument) Set(value string) error

type Connection

type Connection struct {
	// Type of command
	Type string

	Ssh    Argument
	Docker Argument

	// Working directory for eg. ssh
	Workdir string

	// Environment variables
	Environment Environment
	// contains filtered or unexported fields
}

func (*Connection) Clone

func (connection *Connection) Clone() (conn *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() string

Detect docker container id with docker-compose support

func (*Connection) DockerGetEnvironment

func (connection *Connection) DockerGetEnvironment() map[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) IsDocker

func (connection *Connection) IsDocker() bool

Checks if connection is using Docker

func (*Connection) IsEmpty

func (connection *Connection) IsEmpty() (status bool)

Check if connection has set any settings

func (*Connection) IsSsh

func (connection *Connection) IsSsh() bool

Checks if connection is using SSH

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) SetDocker

func (connection *Connection) SetDocker(configuration string) error

Set docker configuration using string (query, dsn, user@host..)

func (*Connection) SetSsh

func (connection *Connection) SetSsh(configuration string) error

Set SSH configuration using string (query, dsn, user@host..)

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

type Environment

type Environment struct {
	Vars map[string]string
}

func (*Environment) AddMap

func (env *Environment) AddMap(vars map[string]string)

Add environment map (adds/overwrites)

func (*Environment) Clear

func (env *Environment) Clear()

Clears environment map

func (*Environment) GetMap

func (env *Environment) GetMap() map[string]string

Get all environment vars as map

func (*Environment) IsEmpty

func (env *Environment) IsEmpty() bool

Check if environment is empty

func (*Environment) Set

func (env *Environment) Set(name string, value string)

Set one environment variable

func (*Environment) SetMap

func (env *Environment) SetMap(vars map[string]string)

Set environment map (absolute)

Jump to

Keyboard shortcuts

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