config

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides configuration management for AgentManager.

Index

Constants

View Source
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 GetCachePath

func GetCachePath() string

GetCachePath returns the cache directory path.

func GetConfigPath

func GetConfigPath() string

GetConfigPath returns the default config file path.

func GetDataPath

func GetDataPath() string

GetDataPath returns the data directory path.

func GetLogPath

func GetLogPath() string

GetLogPath returns the log directory 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
	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 Default

func Default() *Config

Default returns the default configuration.

func (*Config) GetAgentConfig

func (c *Config) GetAgentConfig(agentID string) AgentConfig

GetAgentConfig returns the configuration for a specific agent.

func (*Config) GetPinnedVersion

func (c *Config) GetPinnedVersion(agentID string) string

GetPinnedVersion returns the pinned version for an agent, if any.

func (*Config) IsAgentDisabled

func (c *Config) IsAgentDisabled(agentID string) bool

IsAgentDisabled returns true if the agent is disabled.

func (*Config) IsAgentHidden

func (c *Config) IsAgentHidden(agentID string) bool

IsAgentHidden returns true if the agent is configured as hidden.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

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 NewLoader

func NewLoader() *Loader

NewLoader creates a new configuration loader.

func (*Loader) Get

func (l *Loader) Get(key string) interface{}

Get gets a configuration value by key path.

func (*Loader) GetBool

func (l *Loader) GetBool(key string) bool

GetBool gets a bool configuration value by key path.

func (*Loader) GetFilePath

func (l *Loader) GetFilePath() string

GetFilePath returns the path to the config file.

func (*Loader) GetInt

func (l *Loader) GetInt(key string) int

GetInt gets an int configuration value by key path.

func (*Loader) GetString

func (l *Loader) GetString(key string) string

GetString gets a string configuration value by key path.

func (*Loader) Load

func (l *Loader) Load(customPath string) (*Config, error)

Load loads configuration from file, environment, and flags. Priority: flags > env > file > defaults

func (*Loader) Save

func (l *Loader) Save(cfg *Config) error

Save saves the configuration to file.

func (*Loader) Set

func (l *Loader) Set(key string, value interface{})

Set sets a configuration value by key path.

func (*Loader) SetAndSave

func (l *Loader) SetAndSave(key string, value interface{}) error

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.

Jump to

Keyboard shortcuts

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