Documentation
¶
Overview ¶
Package config defines drift's configuration types and loading logic.
Config resolution order:
- ~/.config/drift/config.toml (global hosts)
- .drift/config.toml (project hosts + mappings, walked up from cwd)
Project config hosts with the same name override global hosts. Env vars in auth fields ($VAR) are expanded at connection time.
Index ¶
- func DeleteGlobalHost(cfg *MergedConfig, name string) error
- func DeleteProjectHost(cfg *MergedConfig, name string) error
- func SaveGlobalHost(cfg *MergedConfig, h Host, oldName string) error
- func SaveProjectHost(cfg *MergedConfig, h Host, oldName string) error
- type Auth
- type Defaults
- type GlobalConfig
- type Host
- type HostScope
- type Mapping
- type MergedConfig
- type ProjectConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteGlobalHost ¶
func DeleteGlobalHost(cfg *MergedConfig, name string) error
DeleteGlobalHost removes a host by name from the global config file.
func DeleteProjectHost ¶
func DeleteProjectHost(cfg *MergedConfig, name string) error
DeleteProjectHost removes a host by name from the project config file.
func SaveGlobalHost ¶
func SaveGlobalHost(cfg *MergedConfig, h Host, oldName string) error
SaveGlobalHost adds or replaces a host in the global config file. If oldName != "" the host with that name is replaced; otherwise a new host is appended.
func SaveProjectHost ¶
func SaveProjectHost(cfg *MergedConfig, h Host, oldName string) error
SaveProjectHost adds or replaces a host in the project config file.
Types ¶
type Auth ¶
type Auth struct {
Type string `toml:"type"` // "password" | "keyfile" | "agent"
Password string `toml:"password"` // supports $ENV_VAR references
KeyFile string `toml:"key_file"` // path, ~ expanded at connect time
Passphrase string `toml:"passphrase"` // supports $ENV_VAR references
}
Auth configures how to authenticate with a Host.
type GlobalConfig ¶
GlobalConfig is the structure of ~/.config/drift/config.toml.
type Host ¶
type Host struct {
Name string `toml:"name"` // unique identifier, e.g. "prod"
Hostname string `toml:"hostname"` // IP or domain
Port int `toml:"port"` // default: 22 (sftp) or 21 (ftp)
User string `toml:"user"`
Auth Auth `toml:"auth"`
RootPath string `toml:"root_path"` // remote base directory
Protocol string `toml:"protocol"` // "sftp" (default), "ftp", or "ftps" (FTP over explicit TLS)
Mappings []Mapping `toml:"mappings,omitempty"` // per-host path mappings
}
Host represents a remote SFTP/SSH or FTP target.
func SortedHostsByName ¶
SortedHostsByName returns a copy of hosts sorted by name and hostname.
type HostScope ¶
type HostScope int
HostScope indicates whether a host was defined globally or in a project config.
type Mapping ¶
type Mapping struct {
Local string `toml:"local"` // relative to project root
Remote string `toml:"remote"` // relative to Host.RootPath
}
Mapping maps a local directory/file to a remote path.
type MergedConfig ¶
type MergedConfig struct {
GlobalDefaults Defaults
ProjectDefaults Defaults
GlobalHosts []Host // hosts from ~/.config/drift/config.toml
ProjectHosts []Host // hosts from .drift/config.toml
Hosts map[string]Host // merged view: project overrides global, keyed by Name
Mappings []Mapping
ProjectRoot string // absolute path of the directory containing .drift/
}
MergedConfig is the runtime-resolved configuration after merging global and project configs.
func Load ¶
func Load(startDir string) (*MergedConfig, error)
Load finds and merges global and project configs relative to startDir. startDir is typically os.Getwd().
type ProjectConfig ¶
type ProjectConfig struct {
Defaults Defaults `toml:"defaults"`
Hosts []Host `toml:"hosts"`
Mappings []Mapping `toml:"mappings"`
}
ProjectConfig is the structure of .drift/config.toml.