Documentation
¶
Index ¶
- type Command
- type CommandResult
- type Config
- func (c *Config) Close() error
- func (c *Config) CreateFile(target, data string, perm os.FileMode) error
- func (c *Config) CreateFileWithReader(target string, reader io.Reader, perm os.FileMode) error
- func (c *Config) CreateGroup(name string) error
- func (c *Config) CreateZip(target, data string) error
- func (c *Config) Exec(command string) (stdOut string, stdErr string, exitStatus int, err error)
- func (c *Config) ExecAndWait(command string) (stdOut string, stdErr string, exitStatus int, err error)
- func (c *Config) ExistsFile(file string) (bool, error)
- func (c *Config) GetFile(to, from string, perm os.FileMode) (int64, error)
- func (c *Config) MkDir(dir string) error
- func (c *Config) SetChmod(name, mode string) error
- func (c *Config) SetChown(name string, uid string) error
- func (c *Config) Shell(inReader io.Reader, outWriter, errWriter io.Writer) error
- func (c *Config) Start(cmd *Command) error
- func (c *Config) StartAndWait(cmd *Command) error
- func (c *Config) SudoMkDir(dir string) error
- func (c *Config) UnZip(target, data string) error
- func (c *Config) UserMod(name string, group string) error
- type HostCommandResult
- type HostCommandResultMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Command string Stdin bytes.Buffer Stdout bytes.Buffer Stderr bytes.Buffer ExitStatus int }
Command encapsulate a remote command
type CommandResult ¶
type CommandResult struct { Hosts HostCommandResultMap Success uint32 `json:"success" yaml:"success" toml:"success" mapstructure:"success"` Failures uint32 `json:"failures" yaml:"failures" toml:"failures" mapstructure:"failures"` }
CommandResult encapsulate the results of a command execution per host
func (*CommandResult) JSON ¶
func (r *CommandResult) JSON(pp bool) ([]byte, error)
JSON returns the command result in JSON format. With pp will be an indent JSON
func (*CommandResult) TOML ¶
func (r *CommandResult) TOML() ([]byte, error)
TOML returns the command result in TOML format
func (*CommandResult) YAML ¶
func (r *CommandResult) YAML() ([]byte, error)
YAML returns the command result in YAML format
type Config ¶
type Config struct { Address string // contains filtered or unexported fields }
Config store the SSH configuration
func (*Config) CreateFile ¶
CreateFile creates a file with the filename 'target' and the given content using the uid, gid and permissions provided.
func (*Config) CreateFileWithReader ¶
CreateFileWithReader creates a file with the filename 'target' and the given content using the uid, gid and permissions provided.
func (*Config) CreateGroup ¶
CreateGroup create group for users
func (*Config) CreateZip ¶
CreateZip creates a zip file with the filename 'target' and content given in 'data'
func (*Config) ExecAndWait ¶
func (c *Config) ExecAndWait(command string) (stdOut string, stdErr string, exitStatus int, err error)
ExecAndWait executes a command in the remote host and waits for it to exit
func (*Config) ExistsFile ¶
ExistsFile return true if a file exists
func (*Config) StartAndWait ¶
StartAndWait initiates the connection, runs command on remote host and waits for output
type HostCommandResult ¶
type HostCommandResult struct { Stdout string `json:"stdout" yaml:"stdout" toml:"stdout" mapstructure:"stdout"` Stderr string `json:"stderr" yaml:"stderr" toml:"stderr" mapstructure:"stderr"` ExitStatus int `json:"exitstatus" yaml:"exitstatus" toml:"exitstatus" mapstructure:"exitstatus"` }
HostCommandResult encapsulate the results of a command from one host
type HostCommandResultMap ¶
type HostCommandResultMap struct { sync.RWMutex `json:"-" yaml:"-" toml:"-" mapstructure:"-"` Results map[string]*HostCommandResult `json:"hosts" yaml:"hosts" toml:"hosts" mapstructure:"hosts"` // this was set to an exportable field to allow for easier marshaling }
HostCommandResultMap is a type safe map wrapped with mutex locks around get/set calls where the keys are the hosts and values are HostCommandResults
func NewHostCommandResultMap ¶
func NewHostCommandResultMap() HostCommandResultMap
NewHostCommandResultMap initializes/makes the map
func (*HostCommandResultMap) GetSnapshot ¶
func (rm *HostCommandResultMap) GetSnapshot() map[string]*HostCommandResult
GetSnapshot returns a snapshot of the given HostCommandResultMap
func (*HostCommandResultMap) Load ¶
func (rm *HostCommandResultMap) Load(key string) (*HostCommandResult, bool)
Load returns the HostCommandResult associated with the host in the given HostCommandResultMap
func (*HostCommandResultMap) Store ¶
func (rm *HostCommandResultMap) Store(key string, value *HostCommandResult)
Store updates the value at the given key in the given HostCommandResultMap