Documentation
¶
Overview ¶
Package iago provides a framework for running tasks on remote hosts.
Index ¶
- Variables
- func CleanPath(path string) string
- func Expand(h Host, s string) string
- func GetIntVar(host Host, key string) int
- func GetStringVar(host Host, key string) string
- func Ignore(e error)
- func Panic(e error)
- func ParseSSHConfig(configFile string) (*sshConfig, error)
- type CmdRunner
- type Download
- type ErrorHandler
- type Group
- type Host
- type Path
- type Perm
- type Shell
- type TaskError
- type Upload
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotAbsolute is returned when a path is relative, but was expected to be absolute. ErrNotAbsolute = errors.New("not an absolute path") // ErrNotRelative is returned when a path is absolute, but was expected to be relative. ErrNotRelative = errors.New("not a relative path") )
var DefaultTimeout = 30 * time.Second
DefaultTimeout is the default timeout for an action.
Functions ¶
func Expand ¶
Expand expands any environment variables in the string 's' using the environment of the host 'h'.
func GetStringVar ¶
GetStringVar gets a string variable from the host.
func ParseSSHConfig ¶
ParseSSHConfig returns a ssh configuration object that can be used to create a ssh.ClientConfig for a given host alias.
Types ¶
type CmdRunner ¶
type CmdRunner interface {
Run(cmd string) error
RunContext(ctx context.Context, cmd string) error
Start(cmd string) error
Wait() error
StdinPipe() (io.WriteCloser, error)
StdoutPipe() (io.ReadCloser, error)
StderrPipe() (io.ReadCloser, error)
}
CmdRunner defines an interface for running commands on remote hosts. This interface is based on the "exec.Cmd" struct.
type ErrorHandler ¶
type ErrorHandler func(error)
ErrorHandler is a function that handles errors from actions.
type Group ¶
type Group struct {
Hosts []Host
ErrorHandler ErrorHandler
Timeout time.Duration
}
Group is a group of hosts.
func NewSSHGroup ¶
NewSSHGroup returns a new ssh group from the given host aliases. The sshConfigFile argument specifies the ssh config file to use. If sshConfigFile is empty, the default configuration files will be used: ~/.ssh/config.
The host aliases should be defined in the ssh config file, and the config file should contain the necessary information to connect to the hosts without a passphrase. This usually means setting up the ssh-agent with the necessary keys beforehand (and entering the passphrase), or specifying the passphrase-less key to use with the IdentityFile option. Moreover, the config file should specify whether or not to use strict host key checking using the StrictHostKeyChecking option. If strict host key checking is enabled, the ssh server's host keys should be present in the known_hosts files specified by UserKnownHostsFile (the default known_hosts files will be used if this option is not specified).
Finally, the specified hosts must all contain a authorized_keys file containing the public key of the user running this program.
type Host ¶
type Host interface {
// Name returns the name of this host.
Name() string
// Address returns the address of the host.
Address() string
// GetEnv retrieves the value of the environment variable named by the key.
// It returns the value, which will be empty if the variable is not present.
GetEnv(key string) string
// GetFS returns the file system of the host.
GetFS() fs.FS
// NewCommand returns a new command runner.
NewCommand() (CmdRunner, error)
// Close closes the connection to the host.
Close() error
// SetVar sets a host variable with the given key and value
SetVar(key string, val any)
// GetVar gets the host variable with the given key.
// Returns (val, true) if the variable exists, (nil, false) otherwise.
GetVar(key string) (val any, ok bool)
}
Host is a connection to a remote host.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a path to a file or directory, relative to the prefix.
func NewPath ¶
NewPath returns a new Path struct. prefix must be an absolute path, and path must be relative to the prefix.
func NewPathFromAbs ¶
NewPathFromAbs returns a new Path struct from an absolute path.
type Perm ¶
type Perm struct {
// contains filtered or unexported fields
}
Perm describes the permissions that should be used when creating files or directories. Perm can use different permissions for files and directories. By default, it uses 644 for files and 755 for directories. If a file permission is specified by using NewPerm(), the WithDirPerm() method may be called to modify the directory permissions.
func NewPerm ¶
NewPerm returns a Perm with the requested file permission. Note that this will also set the directory permission. If a different directory permission is desired, you must call WithDirPerm on the returned Perm also.
func (Perm) GetDirPerm ¶
GetDirPerm returns the current directory permission, or the current file permission, or 755 if no permissions were set.
func (Perm) GetFilePerm ¶
GetFilePerm returns the current file permission, or 644 if no file permission was set.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package iagotest provides utilities for external libraries to test using the iago package.
|
Package iagotest provides utilities for external libraries to test using the iago package. |
|
Package sftpfs provides a filesystem interface to an SFTP server using the github.com/pkg/sftp package.
|
Package sftpfs provides a filesystem interface to an SFTP server using the github.com/pkg/sftp package. |