Documentation
¶
Overview ¶
Package hosts defines the host search record model and pluggable cloud backends.
Index ¶
- func CacheKeySHA256(providerID string, payload []byte) string
- func DedupeKey(h Record) string
- func DefaultCacheDir() (string, error)
- func DefaultCacheKey(p Backend, q Query) ([]byte, error)
- func ExternalIP(r Record) string
- func IsConnectableRecord(r Record) bool
- func IsDockerRecord(r Record) bool
- func IsTrueNASAPIShellRecord(r Record) bool
- func MetaSSHIdentityFile(r *Record) (path string, ok bool)
- func MetaSSHPort(r *Record) (port int, ok bool)
- func NameMatches(name string, q Query) (bool, error)
- func NodeDisplayIP(r Record) string
- func ParseBackendNames(s string) []string
- func ParseProviders(s string) []string
- func PrimaryIPTrimmed(r Record) string
- type Backend
- type CacheEntry
- type FileCache
- type Query
- type Record
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheKeySHA256 ¶
CacheKeySHA256 builds a stable cache key from provider id and payload.
func DefaultCacheDir ¶
DefaultCacheDir returns XDG-style cache directory for honey.
func DefaultCacheKey ¶
DefaultCacheKey serializes query fields for caching per provider instance.
func ExternalIP ¶ added in v0.3.0
ExternalIP returns the VM's public/out-of-VPC address when present. GCP and AWS store it in ExtraIPs while PrimaryIP is the private address used for SSH.
func IsConnectableRecord ¶ added in v0.3.0
IsConnectableRecord reports whether honey can exec, upload, or open a terminal on r.
func IsDockerRecord ¶ added in v0.3.0
IsDockerRecord reports whether r is a connectable Docker container or swarm task row.
func IsTrueNASAPIShellRecord ¶ added in v0.3.0
IsTrueNASAPIShellRecord reports whether r is a TrueNAS row that can use /websocket/shell (shape only; backend config is checked at runtime).
func MetaSSHIdentityFile ¶ added in v0.2.9
MetaSSHIdentityFile returns the private key path from r.Meta["ssh_identity_file"] when set (recipe-level ssh_private_key applied by cue-exec; not inventory search meta).
func MetaSSHPort ¶ added in v0.2.9
MetaSSHPort returns the TCP port from r.Meta["ssh_port"] when it is a valid decimal integer in 1..65535.
func NameMatches ¶
NameMatches applies NameSubstring, NameRegex, or accepts all if both empty.
func NodeDisplayIP ¶ added in v0.3.0
NodeDisplayIP prefers ExternalIP for UI tables; falls back to PrimaryIP.
func ParseBackendNames ¶
ParseBackendNames splits a comma-separated list of backend names (trimmed, lowercased). Empty input returns nil.
func ParseProviders ¶
ParseProviders splits comma list; empty means all.
func PrimaryIPTrimmed ¶ added in v0.3.0
PrimaryIPTrimmed returns r.PrimaryIP with surrounding whitespace removed.
Types ¶
type Backend ¶
type Backend interface {
ID() string
// BackendName is an optional config label (YAML backends.*.name) used with --backends.
// Empty for unnamed backends (e.g. default flag-only quartet).
BackendName() string
// CacheIdentity distinguishes multiple instances with the same ID() (e.g. two GCP projects).
// May be empty when a single implicit backend is used.
CacheIdentity() string
Search(ctx context.Context, q Query) ([]Record, error)
}
Backend is implemented by each cloud integration.
func FilterBackendsByNames ¶
FilterBackendsByNames keeps backends matching any token in want (case-insensitive). Tokens without ":" match BackendName() across all kinds (legacy --backends / URL behavior). Tokens with "kind:name" match a single YAML backend kind and name (e.g. truenas:prod, kubernetes:prod). Unnamed backends (BackendName() empty) are excluded when want is non-empty. When want is empty, provs is returned unchanged.
type CacheEntry ¶
CacheEntry is a single cached provider result.
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache is a simple JSON file cache with TTL.
func NewFileCache ¶
NewFileCache creates a JSON-backed cache at path with ttl.
type Query ¶
type Query struct {
NameSubstring string
NameRegex string
Providers []string // e.g. gcp, aws, k8s, consul — empty means all
GCPProject string
GCPZone string
AWSProfile string
AWSRegion string
KubeContext string
K8sMode string
K8sDebugImage string
ConsulAddr string
ConsulDatacenter string
ConsulToken string
ProxmoxURL string
ProxmoxUser string
ProxmoxPassword string
ProxmoxTokenID string
ProxmoxTokenSecret string
ProxmoxInsecure bool
TrueNASURL string
TrueNASUser string
TrueNASAPIKey string
TrueNASInsecure bool
DockerHost string
DockerMode string
DockerAllContainers bool
DockerViaLocal string
DockerViaSSHHost string
DockerSocket string
DockerPlatform string
DockerSSHUser string
}
Query carries global and per-provider filters for a search run.
type Record ¶
type Record struct {
Provider string `json:"provider"`
Name string `json:"name"`
PrimaryIP string `json:"primary_ip"`
ExtraIPs []string `json:"extra_ips,omitempty"`
Zone string `json:"zone,omitempty"`
Region string `json:"region,omitempty"`
Meta map[string]string `json:"meta,omitempty"`
}
Record is a normalized host across cloud providers.
func CloneWithMetaSSHIdentityFile ¶ added in v0.2.9
CloneWithMetaSSHIdentityFile returns a shallow copy of r with meta["ssh_identity_file"] set.
func CloneWithMetaSSHPort ¶ added in v0.2.9
CloneWithMetaSSHPort returns a shallow copy of r with meta["ssh_port"] set to the decimal string for port (used by cue-exec to apply recipe-level ports).
func MergeDedupe ¶
MergeDedupe merges slices and removes exact duplicates by DedupeKey.