Documentation
¶
Overview ¶
Package config provides configuration management for AgentManager.
Index ¶
- Constants
- func GetCachePath() string
- func GetConfigPath() string
- func GetDataPath() string
- func GetLogPath() string
- func InitConfig() error
- type APIConfig
- type AgentConfig
- type CatalogConfig
- type Config
- type DetectionConfig
- type HelperConfig
- type Loader
- func (l *Loader) Get(key string) interface{}
- func (l *Loader) GetBool(key string) bool
- func (l *Loader) GetFilePath() string
- func (l *Loader) GetInt(key string) int
- func (l *Loader) GetString(key string) string
- func (l *Loader) Load(customPath string) (*Config, error)
- func (l *Loader) Save(cfg *Config) error
- func (l *Loader) Set(key string, value interface{})
- func (l *Loader) SetAndSave(key string, value interface{}) error
- type LoggingConfig
- type UIConfig
- type UpdateConfig
Constants ¶
const ( // ConfigFileName is the name of the config file (without extension) ConfigFileName = "config" // EnvPrefix is the prefix for environment variables EnvPrefix = "AGENTMGR" )
Variables ¶
This section is empty.
Functions ¶
func GetConfigPath ¶
func GetConfigPath() string
GetConfigPath returns the default config file path.
func InitConfig ¶
func InitConfig() error
InitConfig creates the config directory and default config file if they don't exist.
Types ¶
type APIConfig ¶
type APIConfig struct {
// EnableGRPC enables the gRPC server
EnableGRPC bool `yaml:"enable_grpc" json:"enable_grpc" mapstructure:"enable_grpc"`
// GRPCPort is the port for the gRPC server
GRPCPort int `yaml:"grpc_port" json:"grpc_port" mapstructure:"grpc_port"`
// EnableREST enables the REST server
EnableREST bool `yaml:"enable_rest" json:"enable_rest" mapstructure:"enable_rest"`
// RESTPort is the port for the REST server
RESTPort int `yaml:"rest_port" json:"rest_port" mapstructure:"rest_port"`
// RequireAuth requires authentication for API calls
RequireAuth bool `yaml:"require_auth" json:"require_auth" mapstructure:"require_auth"`
// AuthToken is the authentication token
AuthToken string `yaml:"auth_token" json:"auth_token" mapstructure:"auth_token"`
}
APIConfig contains API server settings.
type AgentConfig ¶
type AgentConfig struct {
// PreferredMethod is the preferred installation method
PreferredMethod string `yaml:"preferred_method" json:"preferred_method" mapstructure:"preferred_method"`
// CustomPaths are additional paths to check for this agent
CustomPaths []string `yaml:"custom_paths" json:"custom_paths" mapstructure:"custom_paths"`
// Hidden hides this agent from listings
Hidden bool `yaml:"hidden" json:"hidden" mapstructure:"hidden"`
// PinnedVersion prevents updates past this version
PinnedVersion string `yaml:"pinned_version" json:"pinned_version" mapstructure:"pinned_version"`
// Disabled prevents detection and management
Disabled bool `yaml:"disabled" json:"disabled" mapstructure:"disabled"`
}
AgentConfig contains per-agent configuration overrides.
type CatalogConfig ¶
type CatalogConfig struct {
// SourceURL is the URL to fetch the catalog from
SourceURL string `yaml:"source_url" json:"source_url" mapstructure:"source_url"`
// RefreshInterval is how often to refresh in background
RefreshInterval time.Duration `yaml:"refresh_interval" json:"refresh_interval" mapstructure:"refresh_interval"`
// RefreshOnStart enables auto-refresh when the app starts.
//
// Deprecated: this field is not currently wired to any startup behavior
// and is retained only for backward compatibility with existing config
// files (reading a YAML config that sets it will not error). The catalog
// refresh cadence is controlled by RefreshInterval and the manager's
// cache TTL. Do not rely on this flag in new code — it is scheduled for
// removal once the TUI display reference is cleaned up.
RefreshOnStart bool `yaml:"refresh_on_start" json:"refresh_on_start" mapstructure:"refresh_on_start"`
// GitHubToken is an optional token for higher API rate limits
GitHubToken string `yaml:"github_token" json:"github_token" mapstructure:"github_token"`
}
CatalogConfig contains catalog-related settings.
type Config ¶
type Config struct {
// Catalog settings
Catalog CatalogConfig `yaml:"catalog" json:"catalog" mapstructure:"catalog"`
// Detection settings
Detection DetectionConfig `yaml:"detection" json:"detection" mapstructure:"detection"`
// Update settings
Updates UpdateConfig `yaml:"updates" json:"updates" mapstructure:"updates"`
// UI settings
UI UIConfig `yaml:"ui" json:"ui" mapstructure:"ui"`
// API settings
API APIConfig `yaml:"api" json:"api" mapstructure:"api"`
// Helper/Systray settings
Helper HelperConfig `yaml:"helper" json:"helper" mapstructure:"helper"`
// Logging settings
Logging LoggingConfig `yaml:"logging" json:"logging" mapstructure:"logging"`
// Agent-specific overrides
Agents map[string]AgentConfig `yaml:"agents" json:"agents" mapstructure:"agents"`
}
Config represents the application configuration.
func (*Config) GetAgentConfig ¶
func (c *Config) GetAgentConfig(agentID string) AgentConfig
GetAgentConfig returns the configuration for a specific agent.
func (*Config) GetPinnedVersion ¶
GetPinnedVersion returns the pinned version for an agent, if any.
func (*Config) IsAgentDisabled ¶
IsAgentDisabled returns true if the agent is disabled.
func (*Config) IsAgentHidden ¶
IsAgentHidden returns true if the agent is configured as hidden.
type DetectionConfig ¶
type DetectionConfig struct {
// CacheDuration is how long to cache detected agents before re-detecting
CacheDuration time.Duration `yaml:"cache_duration" json:"cache_duration" mapstructure:"cache_duration"`
// UpdateCheckCacheDuration is how long to cache update check results
UpdateCheckCacheDuration time.Duration `yaml:"update_check_cache_duration" json:"update_check_cache_duration" mapstructure:"update_check_cache_duration"`
// CacheEnabled enables caching of detected agents
CacheEnabled bool `yaml:"cache_enabled" json:"cache_enabled" mapstructure:"cache_enabled"`
}
DetectionConfig contains agent detection settings.
type HelperConfig ¶
type HelperConfig struct {
// CLIPath is the custom path to the agentmgr CLI binary
CLIPath string `yaml:"cli_path" json:"cli_path" mapstructure:"cli_path"`
// ShowAgentCount shows the agent count in the menu bar (macOS)
ShowAgentCount bool `yaml:"show_agent_count" json:"show_agent_count" mapstructure:"show_agent_count"`
// RefreshOnClick refreshes agents when clicking the systray icon
RefreshOnClick bool `yaml:"refresh_on_click" json:"refresh_on_click" mapstructure:"refresh_on_click"`
// NotifyOnStartup shows a notification when the helper starts
NotifyOnStartup bool `yaml:"notify_on_startup" json:"notify_on_startup" mapstructure:"notify_on_startup"`
}
HelperConfig contains systray helper settings.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles configuration loading and saving.
func (*Loader) GetFilePath ¶
GetFilePath returns the path to the config file.
func (*Loader) Load ¶
Load loads configuration from file, environment, and flags. Priority: flags > env > file > defaults
func (*Loader) SetAndSave ¶
SetAndSave sets a configuration value and saves the entire config to file.
type LoggingConfig ¶
type LoggingConfig struct {
// Level is the log level (debug, info, warn, error)
Level string `yaml:"level" json:"level" mapstructure:"level"`
// Format is the log format (json, text)
Format string `yaml:"format" json:"format" mapstructure:"format"`
// File is an optional log file path
File string `yaml:"file" json:"file" mapstructure:"file"`
// MaxSize is the max size in MB before rotation
MaxSize int `yaml:"max_size" json:"max_size" mapstructure:"max_size"`
// MaxAge is the max days to keep old logs
MaxAge int `yaml:"max_age" json:"max_age" mapstructure:"max_age"`
}
LoggingConfig contains logging settings.
type UIConfig ¶
type UIConfig struct {
// Theme is the TUI theme name
Theme string `yaml:"theme" json:"theme" mapstructure:"theme"`
// ShowHidden shows hidden agents in listings
ShowHidden bool `yaml:"show_hidden" json:"show_hidden" mapstructure:"show_hidden"`
// PageSize is the number of items per page in tables
PageSize int `yaml:"page_size" json:"page_size" mapstructure:"page_size"`
// UseColors enables colored output
UseColors bool `yaml:"use_colors" json:"use_colors" mapstructure:"use_colors"`
// CompactMode reduces whitespace in output
CompactMode bool `yaml:"compact_mode" json:"compact_mode" mapstructure:"compact_mode"`
}
UIConfig contains UI-related settings.
type UpdateConfig ¶
type UpdateConfig struct {
// AutoCheck enables automatic update checking
AutoCheck bool `yaml:"auto_check" json:"auto_check" mapstructure:"auto_check"`
// CheckInterval is how often to check for updates
CheckInterval time.Duration `yaml:"check_interval" json:"check_interval" mapstructure:"check_interval"`
// Notify enables desktop notifications for updates
Notify bool `yaml:"notify" json:"notify" mapstructure:"notify"`
// AutoUpdate enables automatic updating (use with caution)
AutoUpdate bool `yaml:"auto_update" json:"auto_update" mapstructure:"auto_update"`
// ExcludeAgents lists agents to exclude from auto-update
ExcludeAgents []string `yaml:"exclude_agents" json:"exclude_agents" mapstructure:"exclude_agents"`
}
UpdateConfig contains update-related settings.