config

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package config loads optional YAML settings and backend definitions for honey.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildJSONSchema added in v0.2.8

func BuildJSONSchema() map[string]any

BuildJSONSchema returns a JSON Schema payload generated from the UI schema.

func DefaultPluginsDir added in v0.2.9

func DefaultPluginsDir() string

DefaultPluginsDir returns ~/.config/honey/plugins (or XDG_CONFIG_HOME/honey/plugins).

func DefaultRecipesDirs added in v0.2.6

func DefaultRecipesDirs() []string

DefaultRecipesDirs returns the list of directories to check for default CUE recipes.

func DefaultRecordDir added in v0.2.8

func DefaultRecordDir(configPath string) string

DefaultRecordDir returns the directory used for session recordings when --record-dir is not set: <directory of config.yaml>/records (e.g. ~/.config/honey/records). If configPath is empty, returns the conventional honey config directory (.../honey/records) matching default config.yaml search paths.

func ListDefaultRecipes added in v0.2.6

func ListDefaultRecipes() []string

ListDefaultRecipes returns a list of absolute paths to all .cue files found in the default recipe directories.

func ParseBytes added in v0.2.8

func ParseBytes(s string) (int64, error)

ParseBytes converts a size string ("5GiB", "64MiB", "1024") into bytes. Accepted suffixes (case-insensitive): KiB, MiB, GiB, TiB. Bare integers are taken as bytes. Fractional values and SI suffixes (KB, MB, …) are rejected.

func ResolvePath

func ResolvePath(explicit string) (string, error)

ResolvePath returns an explicit path from --config or HONEY_CONFIG then the first existing default file, or "" if none exist.

func ResolveRecordDir added in v0.2.8

func ResolveRecordDir(cfg *File, configPath string, recordDirFlag string, recordDirFlagChanged bool) string

ResolveRecordDir returns the session recordings directory (CLI TUI, web server, cue-exec). Precedence when recordDirFlagChanged is true: non-empty global --record-dir value, otherwise DefaultRecordDir(configPath) (explicit empty flag keeps the default path). When recordDirFlagChanged is false: defaults.record_dir from cfg if set, otherwise DefaultRecordDir(configPath).

Types

type AWSBackend

type AWSBackend struct {
	Name    string `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	Profile string `yaml:"profile" json:"profile" honey:"label=Profile" validate:"required"`
	Region  string `yaml:"region" json:"region" honey:"label=Region"`
}

AWSBackend configures one Amazon EC2 listing.

type BackendRow

type BackendRow struct {
	Kind string `json:"kind"`
	Name string `json:"name,omitempty"`
	Hint string `json:"hint,omitempty"`
}

BackendRow describes one YAML backends.* entry (for CLI / MCP listing).

type BackendSchema added in v0.2.8

type BackendSchema struct {
	Label  string        `json:"label"`
	Fields []SchemaField `json:"fields"`
}

BackendSchema describes one backend kind and its field layout.

type Backends

type Backends struct {
	GCP        []GCPBackend        `yaml:"gcp" json:"gcp" honey:"label=Google Cloud;order=10" validate:"dive"`
	AWS        []AWSBackend        `yaml:"aws" json:"aws" honey:"label=AWS;order=20" validate:"dive"`
	Kubernetes []KubernetesBackend `yaml:"kubernetes" json:"kubernetes" honey:"label=Kubernetes;order=30" validate:"dive"`
	Consul     []ConsulBackend     `yaml:"consul" json:"consul" honey:"label=Consul;order=40" validate:"dive"`
	Proxmox    []ProxmoxBackend    `yaml:"proxmox" json:"proxmox" honey:"label=Proxmox;order=50" validate:"dive"`
	Local      []LocalBackend      `yaml:"local" json:"local" honey:"label=Local;order=60" validate:"dive"`
}

Backends lists optional multiple instances per provider type. If a slice is nil or omitted, that provider is not defined by the file (use CLI defaults). If a slice is non-empty, one backend is created per element.

type ConsulBackend

type ConsulBackend struct {
	Name       string `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	Addr       string `yaml:"addr" json:"addr" honey:"label=Address" validate:"required,url"`
	Datacenter string `yaml:"datacenter" json:"datacenter" honey:"label=Datacenter"`
	Token      string `yaml:"token" json:"token" honey:"label=Token;secret"`
}

ConsulBackend configures one HashiCorp Consul catalog listing.

type Defaults

type Defaults struct {
	SSHUser        string `yaml:"ssh_user" json:"ssh_user" honey:"label=SSH user"`
	CacheTTL       string `yaml:"cache_ttl" json:"cache_ttl" honey:"label=Cache TTL"` // e.g. "5m", "1h"
	K8sMode        string `yaml:"k8s_mode" json:"k8s_mode" honey:"label=Kubernetes mode;enum=nodes|pods;enum_as_warning"`
	K8sDebugImage  string `yaml:"k8s_debug_image" json:"k8s_debug_image" honey:"label=Kubernetes debug image"`
	CacheDir       string `yaml:"cache_dir" json:"cache_dir" honey:"label=Cache directory"`
	RecordDir      string `yaml:"record_dir" json:"record_dir" honey:"label=Session recordings directory"`
	Output         string `yaml:"output" json:"output" honey:"label=Output;enum=table|json|tui;enum_as_warning"` // e.g. "table", "json", "tui" (default)
	Name           string `yaml:"name" json:"name" honey:"label=Name filter"`
	NameRegex      string `yaml:"name_regex" json:"name_regex" honey:"label=Name regex"`
	AISystemPrompt string `yaml:"ai_system_prompt" json:"ai_system_prompt" honey:"label=Default system prompt for CUE recipe ai step"`

	// secretsprovider unwraps the stack AES data key (see internal/cuetry/secrets/doc.go).
	// Examples: gcpkms://projects/…/cryptoKeys/…, awskms://, vault-transit://mount/key,
	// k8s://namespace/secret, keyring://service/user, age://, age-file://path.
	SecretsProvider string `` /* 135-byte string literal not displayed */
	// encryptedkey is provider-specific ciphertext or field name (see secrets package doc).
	EncryptedKey string `yaml:"encryptedkey,omitempty" json:"encryptedkey,omitempty" honey:"label=Stack encrypted data key blob;secret;reserved"`
}

Defaults apply when CLI flags are unset.

func (Defaults) DefaultsCacheTTL

func (d Defaults) DefaultsCacheTTL() (time.Duration, bool, error)

DefaultsCacheTTL parses Defaults.CacheTTL or returns empty and ok=false.

type File

type File struct {
	Version  int            `yaml:"version" json:"version"`
	Defaults Defaults       `yaml:"defaults" json:"defaults"`
	Backends Backends       `yaml:"backends" json:"backends"`
	Transfer TransferConfig `yaml:"transfer" json:"transfer"`
	Plugins  Plugins        `yaml:"plugins,omitempty" json:"plugins,omitempty"`
}

File is the optional honey YAML configuration.

func Load

func Load(path string) (*File, error)

Load reads and parses a YAML config file.

func ParseYAML added in v0.2.7

func ParseYAML(b []byte) (*File, error)

ParseYAML parses a honey config document from memory (used by web API PUT validation).

func (*File) HasAnyBackend

func (f *File) HasAnyBackend() bool

HasAnyBackend returns true if the file defines at least one backend entry.

func (*File) Save added in v0.2.6

func (f *File) Save(path string) error

Save serializes the config and writes it to path.

func (*File) Validate added in v0.2.9

func (f *File) Validate() error

Validate checks the configuration struct recursively according to validate tags.

type GCPBackend

type GCPBackend struct {
	Name    string `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	Project string `yaml:"project" json:"project" honey:"label=Project" validate:"required"`
	Zone    string `yaml:"zone" json:"zone" honey:"label=Zone"`
}

GCPBackend configures one Google Cloud Compute Engine listing.

type KubernetesBackend

type KubernetesBackend struct {
	Name       string `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	Context    string `yaml:"context" json:"context" honey:"label=Context"`
	Kubeconfig string `yaml:"kubeconfig" json:"kubeconfig" honey:"label=Kubeconfig path"`
	Mode       string `yaml:"mode" json:"mode" honey:"label=Mode;enum=nodes|pods;enum_as_warning;default=nodes"`
	DebugImage string `yaml:"debug_image" json:"debug_image" honey:"label=Debug image"`
}

KubernetesBackend configures one Kubernetes nodes/pods listing.

type LocalBackend added in v0.2.9

type LocalBackend struct {
	Name  string      `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	Hosts []LocalHost `yaml:"hosts" json:"hosts" honey:"label=Hosts" validate:"dive"`
}

LocalBackend configures manually defined host lists.

type LocalHost added in v0.2.9

type LocalHost struct {
	Name      string            `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	PrimaryIP string            `yaml:"primary_ip" json:"primary_ip" honey:"label=Primary IP" validate:"required,ip"`
	ExtraIPs  []string          `yaml:"extra_ips,omitempty" json:"extra_ips,omitempty" honey:"label=Extra IPs" validate:"dive,ip"`
	Zone      string            `yaml:"zone,omitempty" json:"zone,omitempty" honey:"label=Zone"`
	Region    string            `yaml:"region,omitempty" json:"region,omitempty" honey:"label=Region"`
	Meta      map[string]string `yaml:"meta,omitempty" json:"meta,omitempty" honey:"label=Metadata"`
}

LocalHost represents a manually defined static server.

type Plugins added in v0.2.9

type Plugins struct {
	Enabled           *bool    `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Directory         string   `yaml:"directory,omitempty" json:"directory,omitempty"`
	Allowlist         []string `yaml:"allowlist,omitempty" json:"allowlist,omitempty"`
	MaxMemoryMB       int      `yaml:"max_memory_mb,omitempty" json:"max_memory_mb,omitempty"`
	TimeoutMS         int      `yaml:"timeout_ms,omitempty" json:"timeout_ms,omitempty"`
	NetworkDeny       *bool    `yaml:"network_deny,omitempty" json:"network_deny,omitempty"`
	NetworkAllowHosts []string `yaml:"network_allow_hosts,omitempty" json:"network_allow_hosts,omitempty"`
}

Plugins configures WASM plugins loaded from disk (Extism).

func (Plugins) WithDefaults added in v0.2.9

func (p Plugins) WithDefaults() PluginsEffective

WithDefaults returns effective plugin settings (plugins disabled unless explicitly enabled).

type PluginsEffective added in v0.2.9

type PluginsEffective struct {
	Enabled           bool
	Directory         string
	Allowlist         []string
	MaxMemoryMB       int
	TimeoutMS         int
	NetworkDeny       bool
	NetworkAllowHosts []string
}

PluginsEffective holds resolved plugin settings for runtime.

type ProxmoxBackend added in v0.2.3

type ProxmoxBackend struct {
	Name        string `yaml:"name" json:"name" honey:"label=Name" validate:"required"`
	URL         string `yaml:"url" json:"url" honey:"label=URL" validate:"required,url"`
	User        string `yaml:"user" json:"user" honey:"label=User" validate:"required_without=TokenID"`
	Password    string `yaml:"password" json:"password" honey:"label=Password;secret" validate:"required_without=TokenSecret"`
	TokenID     string `yaml:"token_id" json:"token_id" honey:"label=Token ID" validate:"required_without=User"`
	TokenSecret string `yaml:"token_secret" json:"token_secret" honey:"label=Token secret;secret" validate:"required_without=Password"`
	Insecure    bool   `yaml:"insecure" json:"insecure" honey:"label=Insecure TLS;default=false"`
	// ExecMode: ssh (default) = guest SSH for commands/SFTP/tunnels; pve = QEMU commands via guest agent API, LXC commands/SFTP over guest SSH (PVE has no LXC REST exec; web UI LXC console uses termproxy when token_id is set);
	// hybrid = QEMU via guest agent + SSH for files; LXC uses guest SSH for commands and files.
	ExecMode string `yaml:"exec_mode" json:"exec_mode" honey:"label=Exec mode;enum=ssh|pve|hybrid;enum_as_warning"`
}

ProxmoxBackend configures one Proxmox VE listing.

type SchemaField added in v0.2.8

type SchemaField struct {
	Key           string          `json:"key"`
	Label         string          `json:"label"`
	Type          SchemaFieldType `json:"type"`
	Format        string          `json:"format,omitempty"` // "ip", "url", etc.
	Required      bool            `json:"required,omitempty"`
	Secret        bool            `json:"secret,omitempty"`
	Enum          []string        `json:"enum,omitempty"`
	EnumAsWarning bool            `json:"enum_as_warning,omitempty"`
	Default       any             `json:"default,omitempty"`
	Items         []SchemaField   `json:"items,omitempty"` // For nested array of objects
}

SchemaField describes one editable key in defaults/backends schema.

type SchemaFieldType added in v0.2.8

type SchemaFieldType string

SchemaFieldType describes supported primitive config field kinds.

const (
	SchemaFieldTypeString  SchemaFieldType = "string"
	SchemaFieldTypeBoolean SchemaFieldType = "boolean"
	SchemaFieldTypeInteger SchemaFieldType = "integer"
	SchemaFieldTypeArray   SchemaFieldType = "array"
)

Primitive field kinds for defaults/backends schema and JSON Schema "type".

type TransferConfig added in v0.2.8

type TransferConfig struct {
	PresignedMaxSize        string `yaml:"presigned_max_size,omitempty" json:"presigned_max_size,omitempty"`
	MultipartThreshold      string `yaml:"multipart_threshold,omitempty" json:"multipart_threshold,omitempty"`
	PresignedURLTTL         string `yaml:"presigned_url_ttl,omitempty" json:"presigned_url_ttl,omitempty"`
	PresignedRetryWithAgent *bool  `yaml:"presigned_retry_with_agent,omitempty" json:"presigned_retry_with_agent,omitempty"`
	ForceAgentPath          bool   `yaml:"force_agent_path,omitempty" json:"force_agent_path,omitempty"`
}

TransferConfig controls the agent-transfer code path. Zero values mean "use defaults" — call WithDefaults() to materialize.

func (TransferConfig) WithDefaults added in v0.2.8

func (c TransferConfig) WithDefaults() TransferConfigEffective

WithDefaults returns an effective config, parsing strings to bytes / durations and substituting defaults for unset fields.

type TransferConfigEffective added in v0.2.8

type TransferConfigEffective struct {
	PresignedMaxSizeBytes   int64
	MultipartThresholdBytes int64
	PresignedURLTTL         time.Duration
	PresignedRetryWithAgent bool
	ForceAgentPath          bool
}

TransferConfigEffective is the post-defaults form used by callers.

type UISchema added in v0.2.8

type UISchema struct {
	TopLevelKeys []string                 `json:"top_level_keys"`
	Defaults     []SchemaField            `json:"defaults"`
	Backends     map[string]BackendSchema `json:"backends"`
	BackendOrder []string                 `json:"backend_order"`
}

UISchema is the lightweight UI-focused schema payload.

func BuildUISchema added in v0.2.8

func BuildUISchema() UISchema

BuildUISchema returns the lightweight schema used by web UI rendering and linting.

type ValidationError added in v0.2.9

type ValidationError struct {
	Path    string `json:"path"`
	Message string `json:"message"`
}

ValidationError represents a single field validation error.

type ValidationErrors added in v0.2.9

type ValidationErrors []ValidationError

ValidationErrors is a slice of ValidationError that serializes to JSON.

func (ValidationErrors) Error added in v0.2.9

func (e ValidationErrors) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL