Documentation ¶
Index ¶
- type Cmd
- type Host
- type Local
- func (l Local) Chmod(ctx context.Context, name string, mode os.FileMode) error
- func (l Local) Chown(ctx context.Context, name string, uid, gid int) error
- func (l Local) Lookup(ctx context.Context, username string) (*user.User, error)
- func (l Local) LookupGroup(ctx context.Context, name string) (*user.Group, error)
- func (l Local) Lstat(ctx context.Context, name string) (os.FileInfo, error)
- func (l Local) Mkdir(ctx context.Context, name string, perm os.FileMode) error
- func (l Local) ReadFile(ctx context.Context, name string) ([]byte, error)
- func (l Local) Remove(ctx context.Context, name string) error
- func (l Local) Run(ctx context.Context, cmd Cmd) (WaitStatus, string, string, error)
- func (l Local) String() string
- func (l Local) WriteFile(ctx context.Context, name string, data []byte, perm os.FileMode) error
- type Ssh
- func (s Ssh) Chmod(ctx context.Context, name string, mode os.FileMode) error
- func (s Ssh) Chown(ctx context.Context, name string, uid, gid int) error
- func (s Ssh) Lookup(ctx context.Context, username string) (*user.User, error)
- func (s Ssh) LookupGroup(ctx context.Context, name string) (*user.Group, error)
- func (s Ssh) Lstat(ctx context.Context, name string) (os.FileInfo, error)
- func (s Ssh) Mkdir(ctx context.Context, name string, perm os.FileMode) error
- func (s Ssh) ReadFile(ctx context.Context, name string) ([]byte, error)
- func (s Ssh) Remove(ctx context.Context, name string) error
- func (s Ssh) Run(ctx context.Context, cmd Cmd) (WaitStatus, string, string, error)
- func (s Ssh) String() string
- func (s Ssh) WriteFile(ctx context.Context, name string, data []byte, perm os.FileMode) error
- type WaitStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct { // Path is the path of the command to run. // // This is the only field that must be set to a non-zero // value. If Path is relative, it is evaluated relative // to Dir. Path string // Args holds command line arguments, including the command as Args[0]. // If the Args field is empty or nil, Run uses {Path}. Args []string // Env specifies the environment of the process. // Each entry is of the form "key=value". // If Env is nil, the new process uses LANG=en_US.UTF-8 // If Env contains duplicate environment keys, only the last // value in the slice for each duplicate key is used. Env []string // Dir specifies the working directory of the command. // If Dir is the empty string, Run runs the command in /tmp Dir string // Stdin specifies the process's standard input. // // If Stdin is nil, the process reads from the null device (os.DevNull). // // If Stdin is an *os.File, the process's standard input is connected // directly to that file. // // Otherwise, during the execution of the command a separate // goroutine reads from Stdin and delivers that data to the command // over a pipe. In this case, Wait does not complete until the goroutine // stops copying, either because it has reached the end of Stdin // (EOF or a read error), or because writing to the pipe returned an error, // or because a nonzero WaitDelay was set and expired. Stdin io.Reader }
Cmd represents a command to be run.
type Host ¶
type Host interface { // Chmod works similar to os.Chmod. Chmod(ctx context.Context, name string, mode os.FileMode) error // Chown works similar to os.Chown. Chown(ctx context.Context, name string, uid, gid int) error // Lookup works similar to os/user.Lookup Lookup(ctx context.Context, username string) (*user.User, error) // LookupGroup works similar to os/user.LookupGroup LookupGroup(ctx context.Context, name string) (*user.Group, error) // Lstat works similar to os.Lstat, but it always returns non-nil Sys(). Lstat(ctx context.Context, name string) (os.FileInfo, error) // Mkdir works similar to os.Mkdir. Mkdir(ctx context.Context, name string, perm os.FileMode) error // ReadFile works similar to os.ReadFile. ReadFile(ctx context.Context, name string) ([]byte, error) // Remove works similar to os.Remove. Remove(ctx context.Context, name string) error // Run starts the specified command and waits for it to complete. // Returns WaitStatus, stdout, stderr, error Run(ctx context.Context, cmd Cmd) (WaitStatus, string, string, error) // WriteFile works similar to os.WriteFile. WriteFile(ctx context.Context, name string, data []byte, perm os.FileMode) error // A string representation of the host which uniquely identifies it, eg, its FQDN. String() string }
Host defines an interface for interacting with a host.
type Local ¶
type Local struct{}
Local interacts with the local machine running the code.
func (Local) LookupGroup ¶
type Ssh ¶
type Ssh struct {
Hostname string
}
Ssh interacts with a remote machine connecting to it via SSH protocol.
func (Ssh) LookupGroup ¶
type WaitStatus ¶
type WaitStatus struct { // ExitCode returns the exit code of the exited process, or -1 if the process hasn't exited or was terminated by a signal. ExitCode int // Exited reports whether the program has exited. On Unix systems this reports true if the program exited due to calling exit, but false if the program terminated due to a signal. Exited bool // Signal describes a process signal. Signal string }
WaitStatus
func (*WaitStatus) String ¶
func (ws *WaitStatus) String() string
func (*WaitStatus) Success ¶
func (ws *WaitStatus) Success() bool
Success reports whether the program exited successfully, such as with exit status 0 on Unix.
Click to show internal directories.
Click to hide internal directories.