Documentation
¶
Index ¶
- Constants
- func AppendRunLog(host Host, rec RunLogRecord) error
- func AuthLabel(host Host) string
- func BuildRemoteCommand(command string, env map[string]string) (string, error)
- func BuildRemoteCommandWithCWD(command string, env map[string]string, cwd string) (string, error)
- func DecryptPassword(value string) (string, error)
- func EncryptPassword(password string) (string, error)
- func ErrorString(err error) string
- func ExecuteRemote(host Host, command string, opts RunOptions) ([]byte, error)
- func HasDoctorErrors(issues []DoctorIssue) bool
- func HostGroupName(host Host) string
- func HostLogName(host Host) string
- func JoinRemotePath(base, elem string) string
- func LegacyStorePath() (string, error)
- func LoadRunEnv(file string, inline []string) (map[string]string, error)
- func LocalDirPath(remotePath, localPath string) string
- func LocalFilePath(remotePath, localPath string) string
- func LoginRemote(host Host) error
- func LoginRemoteWithOptions(host Host, opts LoginOptions) error
- func NewRemoteScriptPath(value time.Time) string
- func NewRemoteScriptPathInDir(value time.Time, dir string) string
- func NewRunTaskID(startedAt time.Time, host Host, rec RunLogRecord) string
- func Now() time.Time
- func ParseLogLineRange(spec string) (start int, end int, ok bool, err error)
- func ParseTimeout(value string) (time.Duration, error)
- func PasswordKeyPath() (string, error)
- func ReadConfigFile() (string, []byte, error)
- func ReadHostsFile(path string) ([]string, error)
- func ReadRunLogOutputByID(target, taskID string) ([]byte, error)
- func ReadRunLogs(target, match string, tail int) ([]string, error)
- func ReadRunLogsSelected(target, match string, tail int, rangeSpec string) ([]string, error)
- func RemoteFilePath(localPath, remotePath string) string
- func RemoteRelPath(root, current string) string
- func RunOutputPath(taskID string, startedAt time.Time) (string, string, error)
- func RunStatus(err error) string
- func SaveConfig(config *Config) error
- func SaveStore(store *Store) error
- func SelectLogLines(lines []string, rangeSpec string, tail int) ([]string, error)
- func SetNowForTest(fn func() time.Time) func()
- func SetUserHomeDirForTest(fn func() (string, error)) func()
- func SinceMS(start time.Time) int64
- func StorePath() (string, error)
- func ValidateSudoUser(user string) error
- type AuthProfile
- type BatchHostSource
- type Config
- func (c Config) EffectiveHost(host Host, overrides HostOverrides) (EffectiveHost, bool, error)
- func (c Config) FindAuthProfile(name string) (AuthProfile, bool)
- func (c Config) ResolveConnection(host Host) (ResolvedConnection, error)
- func (c Config) ResolveEffectiveHost(target string, overrides HostOverrides) (EffectiveHost, bool, error)
- type Defaults
- type DoctorIssue
- type EffectiveHost
- type Host
- type HostOverrides
- type LoginOptions
- type RemoteClient
- type ResolveConnectionOptions
- type ResolvedConnection
- type RunLogRecord
- type RunOptions
- type Store
- type TransferJob
- type TransferOptions
- type TransferResult
- func FetchRemote(host Host, remotePath, localPath string, opts TransferOptions) (result TransferResult, err error)
- func UploadRemote(host Host, localPath, remotePath string, opts TransferOptions) (result TransferResult, err error)
- func UploadRemoteBatch(host Host, jobs []TransferJob, opts TransferOptions) (result TransferResult, err error)
Constants ¶
View Source
const ( DoctorOK = "ok" DoctorWarn = "warn" DoctorError = "error" )
View Source
const ( HostKeyCheckKnownHosts = "known_hosts" HostKeyCheckInsecure = "insecure" DefaultConnectTimeout = "20s" DefaultRemoteScriptDir = "/tmp" DefaultKnownHostsPath = "~/.ssh/known_hosts" )
View Source
const ( DefaultSSHPort = 22 DefaultGroup = "default" ConfigVersion = 1 ConfigEnvKey = "SSHC_CONFIG" ConfigFileName = "sshc.config.json" LegacyConfigFileName = "hosts.json" )
View Source
const MaskedSecret = "***"
Variables ¶
This section is empty.
Functions ¶
func AppendRunLog ¶
func AppendRunLog(host Host, rec RunLogRecord) error
func BuildRemoteCommand ¶
func DecryptPassword ¶ added in v0.5.0
func EncryptPassword ¶ added in v0.5.0
func ErrorString ¶
func ExecuteRemote ¶
func ExecuteRemote(host Host, command string, opts RunOptions) ([]byte, error)
func HasDoctorErrors ¶ added in v0.6.0
func HasDoctorErrors(issues []DoctorIssue) bool
func HostGroupName ¶
func HostLogName ¶
func JoinRemotePath ¶
func LegacyStorePath ¶ added in v0.5.0
func LocalDirPath ¶
func LocalFilePath ¶
func LoginRemote ¶
func LoginRemoteWithOptions ¶
func LoginRemoteWithOptions(host Host, opts LoginOptions) error
func NewRemoteScriptPath ¶
func NewRunTaskID ¶ added in v0.6.0
func NewRunTaskID(startedAt time.Time, host Host, rec RunLogRecord) string
func ParseLogLineRange ¶ added in v0.6.0
func PasswordKeyPath ¶ added in v0.5.0
func ReadConfigFile ¶ added in v0.6.0
func ReadHostsFile ¶ added in v0.6.0
func ReadRunLogOutputByID ¶ added in v0.6.0
func ReadRunLogsSelected ¶ added in v0.6.0
func RemoteFilePath ¶
func RemoteRelPath ¶
func RunOutputPath ¶ added in v0.6.0
func SaveConfig ¶ added in v0.6.0
func SelectLogLines ¶ added in v0.6.0
func SetNowForTest ¶
func SetUserHomeDirForTest ¶
func ValidateSudoUser ¶
Types ¶
type AuthProfile ¶ added in v0.6.0
type AuthProfile struct {
Name string `json:"name"`
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
PasswordEnc string `json:"password_enc,omitempty"`
KeyPath string `json:"key_path,omitempty"`
Remark string `json:"remark,omitempty"`
}
func MaskAuthProfile ¶ added in v0.6.0
func MaskAuthProfile(profile AuthProfile) AuthProfile
type BatchHostSource ¶ added in v0.6.0
type Config ¶ added in v0.6.0
type Config struct {
Version int `json:"version"`
LogsPath string `json:"logs_path,omitempty"`
Defaults Defaults `json:"defaults,omitempty"`
AuthProfiles []AuthProfile `json:"auth_profiles"`
Hosts []Host `json:"hosts"`
}
func LoadConfig ¶ added in v0.6.0
func LoadConfigWithSSHConfig ¶ added in v0.6.0
func MaskConfig ¶ added in v0.6.0
func (Config) EffectiveHost ¶ added in v0.6.0
func (c Config) EffectiveHost(host Host, overrides HostOverrides) (EffectiveHost, bool, error)
func (Config) FindAuthProfile ¶ added in v0.6.0
func (c Config) FindAuthProfile(name string) (AuthProfile, bool)
func (Config) ResolveConnection ¶ added in v0.6.0
func (c Config) ResolveConnection(host Host) (ResolvedConnection, error)
func (Config) ResolveEffectiveHost ¶ added in v0.6.0
func (c Config) ResolveEffectiveHost(target string, overrides HostOverrides) (EffectiveHost, bool, error)
type Defaults ¶ added in v0.6.0
type Defaults struct {
User string `json:"user,omitempty"`
Port int `json:"port,omitempty"`
ConnectTimeout string `json:"connect_timeout,omitempty"`
RunTimeout string `json:"run_timeout,omitempty"`
RemoteScriptDir string `json:"remote_script_dir,omitempty"`
HostKeyCheck string `json:"host_key_check,omitempty"`
KnownHostsPath string `json:"known_hosts_path,omitempty"`
}
type DoctorIssue ¶ added in v0.6.0
type DoctorIssue struct {
Level string `json:"level"`
Item string `json:"item"`
Message string `json:"message"`
}
func CheckConfig ¶ added in v0.6.0
func CheckConfig(config Config) []DoctorIssue
type EffectiveHost ¶ added in v0.6.0
type EffectiveHost struct {
Host
ConnectTimeout string
RunTimeout string
RemoteScriptDir string
HostKeyCheck string
KnownHostsPath string
}
func (EffectiveHost) ToHost ¶ added in v0.6.0
func (h EffectiveHost) ToHost() Host
type Host ¶
type Host struct {
Name string `json:"name"`
IP string `json:"ip"`
AuthRef string `json:"auth_ref,omitempty"`
User string `json:"user"`
Password string `json:"password,omitempty"`
PasswordEnc string `json:"password_enc,omitempty"`
KeyPath string `json:"key_path,omitempty"`
Remark string `json:"remark,omitempty"`
Group string `json:"group,omitempty"`
Port int `json:"port,omitempty"`
Jump string `json:"jump,omitempty"`
ConnectTimeout string `json:"connect_timeout,omitempty"`
RunTimeout string `json:"run_timeout,omitempty"`
RemoteScriptDir string `json:"remote_script_dir,omitempty"`
HostKeyCheck string `json:"host_key_check,omitempty"`
KnownHostsPath string `json:"known_hosts_path,omitempty"`
}
func LoadSSHConfigHosts ¶
func ResolveBatchHosts ¶ added in v0.6.0
func ResolveBatchHosts(source BatchHostSource) ([]Host, error)
func ResolveHostWithSSHConfig ¶ added in v0.6.0
func ResolveHostWithSSHConfig(target string, overrides HostOverrides) (Host, bool, error)
type HostOverrides ¶ added in v0.6.0
type LoginOptions ¶
type RemoteClient ¶ added in v0.6.0
type ResolveConnectionOptions ¶ added in v0.6.0
type ResolveConnectionOptions struct {
Jump string
}
type ResolvedConnection ¶ added in v0.6.0
func ResolveConnectionForHost ¶ added in v0.6.0
func ResolveConnectionForHost(host Host) (ResolvedConnection, error)
func ResolveConnectionWithSSHConfig ¶ added in v0.6.0
func ResolveConnectionWithSSHConfig(target string, opts ResolveConnectionOptions) (ResolvedConnection, bool, error)
type RunLogRecord ¶
type RunLogRecord struct {
Target string
TaskID string
Command string
Status string
StartedAt time.Time
DurationMS int64
Output string
OutputFile string
OutputBytes int64
OutputSHA256 string
OutputInline bool
OutputPreview string
Error string
CWD string
Script string
RemoteScript string
KeepRemoteScript bool
}
type RunOptions ¶
type Store ¶
func LoadConfigSettings ¶ added in v0.5.0
func LoadStoreWithSSHConfig ¶
func (Store) MatchHosts ¶
type TransferJob ¶
type TransferOptions ¶
type TransferResult ¶
type TransferResult struct {
Bytes int64
Files int
Directories int
Elapsed time.Duration
LocalSHA256 string
RemoteSHA256 string
SHA256OK bool
}
func FetchRemote ¶
func FetchRemote(host Host, remotePath, localPath string, opts TransferOptions) (result TransferResult, err error)
func UploadRemote ¶
func UploadRemote(host Host, localPath, remotePath string, opts TransferOptions) (result TransferResult, err error)
func UploadRemoteBatch ¶
func UploadRemoteBatch(host Host, jobs []TransferJob, opts TransferOptions) (result TransferResult, err error)
Click to show internal directories.
Click to hide internal directories.