Documentation
¶
Index ¶
- Constants
- Variables
- func AddIncludeLine(sshConfigPath, includePath string) error
- func DefaultCachePath() (string, error)
- func DefaultIncludePath() (string, error)
- func GenerateIncludeFile(cache *Cache, outputPath string) error
- func ValidateName(name string) bool
- type Cache
- func (c *Cache) AllContainers() []Container
- func (c *Cache) CacheAge(hostAlias string) string
- func (c *Cache) GetContainers(hostAlias string) []Container
- func (c *Cache) IsStale(hostAlias string, maxAge time.Duration) bool
- func (c *Cache) MergeUpdate(hostAlias string, discovered []Container)
- func (c *Cache) RefreshExisting(hostAlias string, discovered []Container)
- func (c *Cache) RemoveStaleHosts(validHosts []string)
- func (c *Cache) RenameHost(oldAlias, newAlias string)
- func (c *Cache) Save() error
- func (c *Cache) Update(hostAlias string, containers []Container)
- type Container
- type DiscoverResult
- type HostCache
Constants ¶
const ( ShellUnknown = "" // not yet tested ShellNone = "none" // no shell found )
Shell detection results.
const KeySep = "::"
KeySep is the separator between host alias and container name in composite keys. Using "::" because "--" can appear in SSH host aliases.
Variables ¶
var ShellCandidates = []string{"bash", "sh", "ash"}
ShellCandidates lists shell names to search via "command -v" during detection.
Functions ¶
func AddIncludeLine ¶
AddIncludeLine adds an `Include` directive to ~/.ssh/config if not already present. Uses raw text manipulation to avoid stripping comments.
func DefaultCachePath ¶
DefaultCachePath returns the default cache file path.
func DefaultIncludePath ¶
DefaultIncludePath returns the default path for the generated SSH config include file.
func GenerateIncludeFile ¶
GenerateIncludeFile creates the SSH config include file at the given path with Host entries for all cached containers. Uses ProxyJump to route through the parent host, so all parent SSH config (keys, proxies, etc.) is inherited.
func ValidateName ¶
ValidateName checks if a container name is safe to use in SSH config and shell commands. Also used for user-provided aliases.
Types ¶
type Cache ¶
type Cache struct {
Hosts map[string]HostCache `json:"hosts"`
// contains filtered or unexported fields
}
Cache stores discovered container data locally.
func LoadCache ¶
LoadCache loads the container cache from disk. Returns an empty cache if the file doesn't exist or is corrupted.
func (*Cache) AllContainers ¶
AllContainers returns all cached containers across all hosts.
func (*Cache) GetContainers ¶
GetContainers returns cached containers for a host.
func (*Cache) IsStale ¶
IsStale returns true if the cache for the given host is older than maxAge, or if the host is not in the cache.
func (*Cache) MergeUpdate ¶
MergeUpdate merges newly discovered containers with existing cached data. Keeps aliases for containers that are still running, adds new containers, and marks stopped containers with empty status.
func (*Cache) RefreshExisting ¶ added in v1.1.2
RefreshExisting updates only containers already in cache for a host. Preserves aliases and shell info. Removes containers that are no longer running. Does NOT add newly discovered containers that weren't previously selected.
func (*Cache) RemoveStaleHosts ¶
RemoveStaleHosts removes cached entries for hosts not in the provided list.
func (*Cache) RenameHost ¶
RenameHost moves all cached containers from oldAlias to newAlias.
type Container ¶
type Container struct {
ID string `json:"id"`
Name string `json:"name"` // original Docker container name
Alias string `json:"alias,omitempty"` // user-defined display name (defaults to Name)
Image string `json:"image"`
Status string `json:"status"`
Host string `json:"host"` // parent SSH host alias
Shell string `json:"shell,omitempty"` // detected shell path, empty = unknown, "none" = no shell
}
Container represents a Docker container discovered on a remote host.
func Discover ¶
Discover runs `docker ps` on a remote host via SSH and returns the list of running containers.
func (Container) DisplayName ¶
DisplayName returns the alias if set, otherwise the original name.
func (Container) ShellLabel ¶
ShellLabel returns a short label for display in the finder.
type DiscoverResult ¶
DiscoverResult holds the result of discovering containers on a single host.
func DiscoverAll ¶
func DiscoverAll(hosts []string, timeout time.Duration, concurrency int, verbose bool) []DiscoverResult
DiscoverAll runs discovery on multiple hosts concurrently with a concurrency limit.