Documentation
¶
Index ¶
- func CopyClosures(src System, dest System, paths []string, extraNixOpts nixopts.NixOptionsSet) error
- type CachedPasswordProvider
- type Command
- type CommandRunner
- type Filesystem
- type LocalFilesystem
- func (LocalFilesystem) CreateFile(path string) error
- func (LocalFilesystem) Glob(pattern string) ([]string, error)
- func (LocalFilesystem) MkdirAll(path string, perm os.FileMode) error
- func (LocalFilesystem) ReadDir(path string) ([]os.FileInfo, error)
- func (LocalFilesystem) ReadFile(path string) ([]byte, error)
- func (LocalFilesystem) ReadLink(name string) (string, error)
- func (LocalFilesystem) RealPath(path string) (string, error)
- func (LocalFilesystem) Stat(path string) (os.FileInfo, error)
- type LocalSystem
- type NixStoreType
- type PasswordProvider
- type RootElevator
- type SFTPFilesystem
- func (f *SFTPFilesystem) CreateFile(path string) error
- func (f *SFTPFilesystem) Glob(pattern string) ([]string, error)
- func (f *SFTPFilesystem) MkdirAll(path string, perm os.FileMode) error
- func (f *SFTPFilesystem) ReadDir(path string) ([]os.FileInfo, error)
- func (f *SFTPFilesystem) ReadFile(path string) ([]byte, error)
- func (f *SFTPFilesystem) ReadLink(path string) (string, error)
- func (f *SFTPFilesystem) RealPath(path string) (string, error)
- func (f *SFTPFilesystem) Stat(path string) (os.FileInfo, error)
- type SSHConfig
- type SSHConfigOptions
- type SSHSystem
- func (s *SSHSystem) Address() string
- func (s *SSHSystem) AddressWithScheme() string
- func (s *SSHSystem) Clone() (*SSHSystem, error)
- func (s *SSHSystem) Close()
- func (s *SSHSystem) FS() Filesystem
- func (s *SSHSystem) HasCommand(name string) bool
- func (s *SSHSystem) IsNixOS() bool
- func (s *SSHSystem) IsRemote() bool
- func (s *SSHSystem) Logger() logger.Logger
- func (s *SSHSystem) Reconnect() error
- func (s *SSHSystem) Run(cmd *Command) (int, error)
- type System
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyClosures ¶
func CopyClosures(src System, dest System, paths []string, extraNixOpts nixopts.NixOptionsSet) error
Invoke the `nix-copy-closure` command to copy between two types of systems.
Types ¶
type CachedPasswordProvider ¶
type CachedPasswordProvider struct {
// contains filtered or unexported fields
}
func (*CachedPasswordProvider) GetPassword ¶
func (p *CachedPasswordProvider) GetPassword() (string, error)
func (*CachedPasswordProvider) PromptForPassword ¶
type Command ¶
type Command struct {
Name string
Args []string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Env map[string]string
// contains filtered or unexported fields
}
func NewCommand ¶
func (*Command) AsRoot ¶
func (c *Command) AsRoot(elevator *RootElevator) *Command
func (*Command) BuildArgs ¶
Build an arguments array, suitable for passing to exec.Command or other argument string slice parameters.
This does not set environment variables; use BuildShellWrapper() for that or use cmd.Env directly at the call site for System.Run() implementations.
func (*Command) BuildShellWrapper ¶
Build a safe `sh -c` wrapper that can support setting environment variables for a process inline.
This is required for environments that sanitize environment variables, such as when commands are ran using `sudo` or other root elevation commands, or running commands on systems using SSH without proper AcceptEnv settings configured.
func (*Command) InheritEnv ¶
Inherit the passed environment variables' values explicitly into the command's env map.
Useful when passing variables over `sudo` or SSH environment variable sanitation barriers.
type CommandRunner ¶
type Filesystem ¶
type Filesystem interface {
Stat(path string) (os.FileInfo, error)
ReadLink(path string) (string, error)
MkdirAll(path string, perm os.FileMode) error
ReadFile(path string) ([]byte, error)
CreateFile(path string) error
ReadDir(path string) ([]os.FileInfo, error)
RealPath(path string) (string, error)
Glob(pattern string) ([]string, error)
}
type LocalFilesystem ¶
type LocalFilesystem struct{}
func (LocalFilesystem) CreateFile ¶
func (LocalFilesystem) CreateFile(path string) error
type LocalSystem ¶
type LocalSystem struct {
// contains filtered or unexported fields
}
func NewLocalSystem ¶
func NewLocalSystem(logger logger.Logger) *LocalSystem
func (*LocalSystem) FS ¶
func (l *LocalSystem) FS() Filesystem
func (*LocalSystem) HasCommand ¶
func (l *LocalSystem) HasCommand(name string) bool
func (*LocalSystem) IsNixOS ¶
func (l *LocalSystem) IsNixOS() bool
func (*LocalSystem) IsRemote ¶
func (l *LocalSystem) IsRemote() bool
func (*LocalSystem) Logger ¶
func (l *LocalSystem) Logger() logger.Logger
type NixStoreType ¶
type NixStoreType string
const ( NixStoreTypeSSH NixStoreType = "ssh" NixStoreTypeSSHNG NixStoreType = "ssh-ng" )
type PasswordProvider ¶
type RootElevator ¶
type RootElevator struct {
Command string
Flags []string
Method settings.PasswordInputMethod
PasswordProvider PasswordProvider
}
func ElevatorFromConfig ¶
func ElevatorFromConfig(cfg *settings.RootCommandSettings) (*RootElevator, error)
func (*RootElevator) PromptIfNecessary ¶
func (e *RootElevator) PromptIfNecessary(ctx context.Context) error
type SFTPFilesystem ¶
type SFTPFilesystem struct {
// contains filtered or unexported fields
}
func NewSFTPFilesystem ¶
func NewSFTPFilesystem(client *sftp.Client) *SFTPFilesystem
func (*SFTPFilesystem) CreateFile ¶
func (f *SFTPFilesystem) CreateFile(path string) error
func (*SFTPFilesystem) MkdirAll ¶
func (f *SFTPFilesystem) MkdirAll(path string, perm os.FileMode) error
type SSHConfig ¶
type SSHConfig struct {
User string
Address string
Port int
AuthMethods []ssh.AuthMethod
HostKeyVerification settings.HostKeyVerificationType
KnownHostsFiles []string
StoreType NixStoreType
// contains filtered or unexported fields
}
func NewSSHConfig ¶
func NewSSHConfig(ctx context.Context, host string, log logger.Logger, options SSHConfigOptions) (*SSHConfig, error)
Initialize a new SSH configuration that can be passed to configure an SSH system instance.
The context is required to construct the password callback such that it can be canceled gracefully.
type SSHConfigOptions ¶
type SSHConfigOptions struct {
AgentManager *sshUtils.AgentManager
KnownHostsFiles []string
HostKeyVerification settings.HostKeyVerificationType
PrivateKeyCmd []string
}
type SSHSystem ¶
type SSHSystem struct {
// contains filtered or unexported fields
}
func (*SSHSystem) AddressWithScheme ¶
func (*SSHSystem) Clone ¶
Create a new SSH connection instance from the existing information of this instance.
Caller must keep the `cfg` field alive until ALL clones are closed.
func (*SSHSystem) FS ¶
func (s *SSHSystem) FS() Filesystem
func (*SSHSystem) HasCommand ¶
type System ¶
type System interface {
CommandRunner
IsNixOS() bool
IsRemote() bool
FS() Filesystem
}