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 MetaSSHIdentityFile(r *Record) (path string, ok bool)
- func MetaSSHPort(r *Record) (port int, ok bool)
- func NameMatches(name string, q Query) (bool, error)
- func ParseBackendNames(s string) []string
- func ParseProviders(s string) []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 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 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.
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 only backends whose BackendName() matches one of want (case-insensitive). 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
}
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.