Documentation
¶
Overview ¶
Package host gives the core and its agent modules access to a machine: this one, or another over SSH. A Machine is probed once (one round trip, generated from every module's Spec); For returns the agent.Host a module sees, confined to its Spec and with every write journaled.
Index ¶
- Variables
- func SpecEnv(s agent.Spec) []string
- func Unsetting(h agent.Host, unset []string) agent.Host
- func Without(env, unset []string) []string
- type FS
- type Facts
- type Machine
- func (m *Machine) Close()
- func (m *Machine) CommitIdentity(ctx context.Context) error
- func (m *Machine) Exec() agent.Exec
- func (m *Machine) FS(ctx context.Context) (FS, error)
- func (m *Machine) For(ctx context.Context, s agent.Spec, in agent.Install, w Writes) (agent.Host, error)
- func (m *Machine) GitProbe(ctx context.Context, dirs, excl []string) ([]repos.GitState, error)
- func (m *Machine) IsSnapshot() bool
- func (m *Machine) Locks() agent.Locks
- func (m *Machine) Path() agent.Path
- func (m *Machine) PrepareIdentity(ctx context.Context) (string, error)
- func (m *Machine) Procs() agent.Procs
- func (m *Machine) ReadIdentity(ctx context.Context) (string, error)
- func (m *Machine) ShortNames(ctx context.Context, paths []string) map[string]string
- func (m *Machine) Writes() []SnapshotWrite
- type SnapshotFile
- type SnapshotWrite
- type Writes
Constants ¶
This section is empty.
Variables ¶
var Hopsesh = agent.Binary{ Name: "hopsesh", Candidates: map[string][]string{ "*": {"~/.local/bin/hopsesh", "/opt/homebrew/bin/hopsesh", "/usr/local/bin/hopsesh", "/Applications/hopsesh.app/Contents/Resources/bin/hopsesh"}, "windows": {"~/AppData/Local/Programs/hopsesh/hopsesh.exe"}, }, VersionArgs: []string{"version"}, }
Hopsesh is hopsesh itself on a machine: the probe reports whether it is there (to work with it as a peer) and its version.
Functions ¶
Types ¶
type FS ¶
type FS interface {
agent.FS
Remove(p string) error // a file or an empty folder
Truncate(p string, size int64) error
Chtimes(p string, t time.Time) error
MkdirAll(p string) error
}
FS is the core's filesystem: the module FS plus what the journal and the installer need.
type Facts ¶
type Facts struct {
DesktopProtocols map[string]bool `json:"desktopProtocols,omitempty"`
Endpoint string `json:"endpoint"`
OS string `json:"os"`
Arch string `json:"arch"`
Home string `json:"home"`
Env map[string]string `json:"env"`
Binaries map[string]agent.BinaryFact `json:"binaries"`
HasGit bool `json:"hasGit"`
}
Facts is what one probe learned about a machine.
func ProbeLocal ¶
ProbeLocal learns this machine's facts for the given modules.
type Machine ¶
type Machine struct {
Name string
Local bool
Conn *transport.Conn // nil for this machine
Facts Facts
Log *slog.Logger
// contains filtered or unexported fields
}
Machine is a place sessions live: this machine, one reached over SSH, or a snapshot another machine's hopsesh sent.
func NewSnapshot ¶
func NewSnapshot(name string, facts Facts, files []SnapshotFile) *Machine
NewSnapshot is another machine seen only through files its hopsesh sent (a push): the session's files, nothing else. Nothing runs there and no process is alive; writes are recorded for the sender (Writes).
func (*Machine) Close ¶
func (m *Machine) Close()
Close ends the machine's SFTP session and shared SSH connection.
func (*Machine) CommitIdentity ¶ added in v0.4.0
func (*Machine) FS ¶
FS returns the machine's filesystem (opening SFTP on first use for a remote machine).
func (*Machine) For ¶
func (m *Machine) For(ctx context.Context, s agent.Spec, in agent.Install, w Writes) (agent.Host, error)
For returns the Host a module sees on this machine: facts limited to what its Spec declares, writes through w (the journal, or nil for read-only work), confined to the install's roots and away from its secrets.
func (*Machine) GitProbe ¶
GitProbe returns the git state of folders on the machine. excl are agent-managed worktree folders.
func (*Machine) IsSnapshot ¶
IsSnapshot reports whether the machine is a snapshot.
func (*Machine) PrepareIdentity ¶ added in v0.4.0
PrepareIdentity reserves a persistent endpoint identifier, independent of SSH aliases and display names. A plan reserves a new identifier in memory; only Apply persists it.
func (*Machine) ReadIdentity ¶ added in v0.4.0
ReadIdentity reads an already initialized endpoint without reserving or writing one.
func (*Machine) ShortNames ¶
ShortNames returns the 8.3 short form of each path on a Windows machine ("C:\Users\LIHUA~1\proj"), for the paths that have one that differs. A session can name the same folder either way; moves rewrite both. Other systems, snapshots, and drives with short names turned off give none.
func (*Machine) Writes ¶
func (m *Machine) Writes() []SnapshotWrite
Writes returns the writes made to a snapshot machine, in order.
type SnapshotFile ¶
type SnapshotFile struct {
Path string `json:"path"`
Data []byte `json:"data"`
Mode fs.FileMode `json:"mode"`
ModTime time.Time `json:"modTime"`
}
SnapshotFile is one file of a snapshot: its path on the machine it came from.
type SnapshotWrite ¶
type SnapshotWrite struct {
Op string `json:"op"` // write | append | rename
Path string `json:"path"`
From string `json:"from,omitempty"` // rename
Data []byte `json:"data,omitempty"`
Perm fs.FileMode `json:"perm,omitempty"`
Append agent.AppendOptions
}
SnapshotWrite is a write made to a snapshot. It is not applied anywhere: the machine the snapshot came from replays it (journaled there).
type Writes ¶
type Writes interface {
WriteFile(fsys FS, machine, p string, b []byte, perm fs.FileMode) error
Append(fsys FS, machine, p string, b []byte, o agent.AppendOptions) error
Rename(fsys FS, machine, from, to string) error
}
Writes is where module writes go: the journal records how to undo each before it happens.