Documentation
¶
Overview ¶
Package config provides application configuration management.
Index ¶
- func InitializeDashboardManager(configPath string)
- func Load(configPath string) error
- func LoadFromFile(configFile string) error
- func MustLoad(configPath string)
- func ValidateSecrets(cfg *Config) error
- type AppConfig
- type AuthConfig
- type CORSConfig
- type ColorScheme
- type Config
- type Dashboard
- type DashboardConfig
- type DashboardManager
- func (dm *DashboardManager) GetColorScheme(config *DashboardConfig, color string) ColorScheme
- func (dm *DashboardManager) GetIconPath(config *DashboardConfig, icon string) string
- func (dm *DashboardManager) GetTilesByCategory(config *DashboardConfig) map[string][]Tile
- func (dm *DashboardManager) LoadDashboard(name string) (*DashboardConfig, error)
- func (dm *DashboardManager) ReloadDashboard(name string) error
- type DashboardSpec
- type DatabaseConfig
- type EmailConfig
- type EmailInboundConfig
- type EnvVariable
- type FeaturesConfig
- type IntegrationsConfig
- type LoggingConfig
- type MaintenanceConfig
- type MetricsConfig
- type PushConfig
- type QuickAction
- type RateLimitingConfig
- type RunnerConfig
- type SecretType
- type SecretValidator
- type ServerConfig
- type Stat
- type StorageConfig
- type SwaggerConfig
- type Synthesizer
- type TestCredential
- type TestDataGenerator
- type TicketConfig
- type Tile
- type ValkeyConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeDashboardManager ¶
func InitializeDashboardManager(configPath string)
InitializeDashboardManager initializes the global dashboard manager.
func LoadFromFile ¶
LoadFromFile loads configuration from a specific file (useful for testing).
func ValidateSecrets ¶
Types ¶
type AppConfig ¶
type AppConfig struct {
Name string `mapstructure:"name"`
Version string `mapstructure:"version"`
Env string `mapstructure:"env"`
Debug bool `mapstructure:"debug"`
Timezone string `mapstructure:"timezone"`
DemoMode bool `mapstructure:"demo_mode"`
}
func (*AppConfig) IsDevelopment ¶
IsDevelopment returns true if running in development mode.
func (*AppConfig) IsProduction ¶
IsProduction returns true if running in production mode.
type AuthConfig ¶
type AuthConfig struct {
JWT struct {
Secret string `mapstructure:"secret"`
Issuer string `mapstructure:"issuer"`
Audience string `mapstructure:"audience"`
AccessTokenTTL time.Duration `mapstructure:"access_token_ttl"`
RefreshTokenTTL time.Duration `mapstructure:"refresh_token_ttl"`
} `mapstructure:"jwt"`
Session struct {
CookieName string `mapstructure:"cookie_name"`
Secure bool `mapstructure:"secure"`
HTTPOnly bool `mapstructure:"http_only"`
SameSite string `mapstructure:"same_site"`
MaxAge int `mapstructure:"max_age"`
SessionMaxTime int `mapstructure:"SessionMaxTime"`
SessionMaxIdleTime int `mapstructure:"SessionMaxIdleTime"`
} `mapstructure:"session"`
Password struct {
MinLength int `mapstructure:"min_length"`
RequireUppercase bool `mapstructure:"require_uppercase"`
RequireLowercase bool `mapstructure:"require_lowercase"`
RequireNumber bool `mapstructure:"require_number"`
RequireSpecial bool `mapstructure:"require_special"`
BcryptCost int `mapstructure:"bcrypt_cost"`
} `mapstructure:"password"`
}
type CORSConfig ¶
type ColorScheme ¶
type ColorScheme struct {
Background string `yaml:"bg"`
Text string `yaml:"text"`
Button string `yaml:"button"`
}
ColorScheme represents CSS classes for different color states.
type Config ¶
type Config struct {
App AppConfig `mapstructure:"app"`
Server ServerConfig `mapstructure:"server"`
Database DatabaseConfig `mapstructure:"database"`
Valkey ValkeyConfig `mapstructure:"valkey"`
Auth AuthConfig `mapstructure:"auth"`
Email EmailConfig `mapstructure:"email"`
Storage StorageConfig `mapstructure:"storage"`
Ticket TicketConfig `mapstructure:"ticket"`
Logging LoggingConfig `mapstructure:"logging"`
Metrics MetricsConfig `mapstructure:"metrics"`
RateLimiting RateLimitingConfig `mapstructure:"rate_limiting"`
Features FeaturesConfig `mapstructure:"features"`
Maintenance MaintenanceConfig `mapstructure:"maintenance"`
Integrations IntegrationsConfig `mapstructure:"integrations"`
Runner RunnerConfig `mapstructure:"runner"`
Push PushConfig `mapstructure:"push"`
}
Config represents the application configuration.
type Dashboard ¶
type Dashboard struct {
Title string `yaml:"title"`
Subtitle string `yaml:"subtitle"`
Theme string `yaml:"theme"`
Stats []Stat `yaml:"stats"`
Tiles []Tile `yaml:"tiles"`
QuickActions []QuickAction `yaml:"quick_actions"`
}
Dashboard represents the main dashboard configuration.
type DashboardConfig ¶
type DashboardConfig struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Created string `yaml:"created"`
Description string `yaml:"description"`
} `yaml:"metadata"`
Spec DashboardSpec `yaml:"spec"`
}
DashboardConfig represents the complete YAML configuration for a dashboard.
type DashboardManager ¶
type DashboardManager struct {
// contains filtered or unexported fields
}
DashboardManager manages dashboard configurations.
var DefaultDashboardManager *DashboardManager
Global dashboard manager instance.
func NewDashboardManager ¶
func NewDashboardManager(configPath string) *DashboardManager
NewDashboardManager creates a new dashboard manager.
func (*DashboardManager) GetColorScheme ¶
func (dm *DashboardManager) GetColorScheme(config *DashboardConfig, color string) ColorScheme
GetColorScheme returns the CSS classes for a color.
func (*DashboardManager) GetIconPath ¶
func (dm *DashboardManager) GetIconPath(config *DashboardConfig, icon string) string
GetIconPath returns the SVG path for an icon.
func (*DashboardManager) GetTilesByCategory ¶
func (dm *DashboardManager) GetTilesByCategory(config *DashboardConfig) map[string][]Tile
GetTilesByCategory returns tiles grouped by category.
func (*DashboardManager) LoadDashboard ¶
func (dm *DashboardManager) LoadDashboard(name string) (*DashboardConfig, error)
LoadDashboard loads a dashboard configuration from YAML.
func (*DashboardManager) ReloadDashboard ¶
func (dm *DashboardManager) ReloadDashboard(name string) error
ReloadDashboard forces a reload of a dashboard configuration.
type DashboardSpec ¶
type DashboardSpec struct {
Dashboard Dashboard `yaml:"dashboard"`
Colors map[string]ColorScheme `yaml:"colors"`
Icons map[string]string `yaml:"icons"`
}
DashboardSpec contains the actual dashboard configuration.
type DatabaseConfig ¶
type DatabaseConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Name string `mapstructure:"name"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
SSLMode string `mapstructure:"ssl_mode"`
MaxOpenConns int `mapstructure:"max_open_conns"`
MaxIdleConns int `mapstructure:"max_idle_conns"`
ConnMaxLifetime time.Duration `mapstructure:"conn_max_lifetime"`
LogQueries bool `mapstructure:"log_queries"`
Migrations struct {
AutoMigrate bool `mapstructure:"auto_migrate"`
Path string `mapstructure:"path"`
} `mapstructure:"migrations"`
}
func (*DatabaseConfig) GetDSN ¶
func (c *DatabaseConfig) GetDSN() string
GetDSN returns the PostgreSQL connection string.
type EmailConfig ¶
type EmailConfig struct {
Enabled bool `mapstructure:"enabled"`
From string `mapstructure:"from"`
FromName string `mapstructure:"from_name"`
SMTP struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
AuthType string `mapstructure:"auth_type"`
TLS bool `mapstructure:"tls"`
TLSMode string `mapstructure:"tls_mode"`
SkipVerify bool `mapstructure:"skip_verify"`
} `mapstructure:"smtp"`
Templates struct {
Path string `mapstructure:"path"`
} `mapstructure:"templates"`
Queue struct {
Workers int `mapstructure:"workers"`
BufferSize int `mapstructure:"buffer_size"`
RetryAttempts int `mapstructure:"retry_attempts"`
RetryDelay time.Duration `mapstructure:"retry_delay"`
} `mapstructure:"queue"`
Inbound EmailInboundConfig `mapstructure:"inbound"`
}
func (*EmailConfig) EffectiveTLSMode ¶
func (c *EmailConfig) EffectiveTLSMode() string
EffectiveTLSMode normalizes the TLS mode for outbound SMTP connections. Supported values: "none", "starttls", "smtps" (implicit TLS). If TLSMode is empty we fall back to the legacy TLS boolean flag.
type EmailInboundConfig ¶
type EnvVariable ¶
type FeaturesConfig ¶
type FeaturesConfig struct {
Registration bool `mapstructure:"registration"`
LostPassword bool `mapstructure:"lost_password"`
SocialLogin bool `mapstructure:"social_login"`
TwoFactorAuth bool `mapstructure:"two_factor_auth"`
APIKeys bool `mapstructure:"api_keys"`
Webhooks bool `mapstructure:"webhooks"`
LDAP bool `mapstructure:"ldap"`
SAML bool `mapstructure:"saml"`
KnowledgeBase bool `mapstructure:"knowledge_base"`
CustomerPortal bool `mapstructure:"customer_portal"`
AgentCollisionDetection bool `mapstructure:"agent_collision_detection"`
}
type IntegrationsConfig ¶
type IntegrationsConfig struct {
Slack struct {
Enabled bool `mapstructure:"enabled"`
WebhookURL string `mapstructure:"webhook_url"`
} `mapstructure:"slack"`
Teams struct {
Enabled bool `mapstructure:"enabled"`
WebhookURL string `mapstructure:"webhook_url"`
} `mapstructure:"teams"`
Webhook struct {
Enabled bool `mapstructure:"enabled"`
Endpoints []string `mapstructure:"endpoints"`
Timeout time.Duration `mapstructure:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts"`
} `mapstructure:"webhook"`
}
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level"`
Format string `mapstructure:"format"`
Output string `mapstructure:"output"`
Fields []string `mapstructure:"fields"`
File struct {
Path string `mapstructure:"path"`
Filename string `mapstructure:"filename"`
MaxSize int `mapstructure:"max_size"`
MaxBackups int `mapstructure:"max_backups"`
MaxAge int `mapstructure:"max_age"`
Compress bool `mapstructure:"compress"`
} `mapstructure:"file"`
}
type MaintenanceConfig ¶
type MaintenanceConfig struct {
Mode bool `mapstructure:"mode"`
Message string `mapstructure:"message"`
AllowedIPs []string `mapstructure:"allowed_ips"`
TimeNotifyUpcomingMinutes int `mapstructure:"time_notify_upcoming_minutes"` // Minutes before maintenance to show notification
DefaultNotifyMessage string `mapstructure:"default_notify_message"` // Default notification message
DefaultLoginMessage string `mapstructure:"default_login_message"` // Default login page message
}
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `mapstructure:"enabled"`
Prometheus struct {
Enabled bool `mapstructure:"enabled"`
Port int `mapstructure:"port"`
Path string `mapstructure:"path"`
} `mapstructure:"prometheus"`
OpenTelemetry struct {
Enabled bool `mapstructure:"enabled"`
Endpoint string `mapstructure:"endpoint"`
ServiceName string `mapstructure:"service_name"`
TraceRatio float64 `mapstructure:"trace_ratio"`
} `mapstructure:"opentelemetry"`
}
type PushConfig ¶ added in v0.8.1
type QuickAction ¶
type QuickAction struct {
Name string `yaml:"name"`
Action string `yaml:"action,omitempty"`
URL string `yaml:"url,omitempty"`
Endpoint string `yaml:"endpoint,omitempty"`
Icon string `yaml:"icon"`
Color string `yaml:"color"`
Confirm string `yaml:"confirm,omitempty"`
}
QuickAction represents a quick action button.
type RateLimitingConfig ¶
type RunnerConfig ¶
type RunnerConfig struct {
SessionCleanup struct {
Interval time.Duration `mapstructure:"interval"`
} `mapstructure:"session_cleanup"`
}
RunnerConfig contains configuration for background task runner.
type SecretType ¶
type SecretType string
const ( SecretTypeHex SecretType = "hex" SecretTypeAlphaNum SecretType = "alphanum" SecretTypeMixed SecretType = "mixed" SecretTypeAPIKey SecretType = "apikey" SecretTypePassword SecretType = "password" )
type SecretValidator ¶
type SecretValidator struct {
// contains filtered or unexported fields
}
func NewSecretValidator ¶
func NewSecretValidator(cfg *Config) *SecretValidator
func (*SecretValidator) Validate ¶
func (v *SecretValidator) Validate() error
type ServerConfig ¶
type ServerConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
ReadTimeout time.Duration `mapstructure:"read_timeout"`
WriteTimeout time.Duration `mapstructure:"write_timeout"`
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout"`
CORS CORSConfig `mapstructure:"cors"`
Swagger SwaggerConfig `mapstructure:"swagger"`
}
func (*ServerConfig) GetServerAddr ¶
func (c *ServerConfig) GetServerAddr() string
GetServerAddr returns the server listen address.
type Stat ¶
type Stat struct {
Name string `yaml:"name"`
Query string `yaml:"query,omitempty"`
Command string `yaml:"command,omitempty"`
Parser string `yaml:"parser,omitempty"`
Suffix string `yaml:"suffix,omitempty"`
Icon string `yaml:"icon"`
Color string `yaml:"color"`
}
Stat represents a dashboard statistic.
type StorageConfig ¶
type StorageConfig struct {
Type string `mapstructure:"type"`
Local struct {
Path string `mapstructure:"path"`
PublicPath string `mapstructure:"public_path"`
} `mapstructure:"local"`
S3 struct {
Bucket string `mapstructure:"bucket"`
Region string `mapstructure:"region"`
AccessKey string `mapstructure:"access_key"`
SecretKey string `mapstructure:"secret_key"`
Endpoint string `mapstructure:"endpoint"`
} `mapstructure:"s3"`
Attachments struct {
MaxSize int64 `mapstructure:"max_size"`
AllowedTypes []string `mapstructure:"allowed_types"`
} `mapstructure:"attachments"`
}
type SwaggerConfig ¶
type SwaggerConfig struct {
Enabled bool `mapstructure:"enabled"` // Whether to serve Swagger UI at /swagger/
Public bool `mapstructure:"public"` // If true, no auth required; if false, requires login
}
SwaggerConfig controls API documentation exposure.
type Synthesizer ¶
type Synthesizer struct {
// contains filtered or unexported fields
}
func NewSynthesizer ¶
func NewSynthesizer(outputPath string) *Synthesizer
func (*Synthesizer) GenerateSecret ¶
func (s *Synthesizer) GenerateSecret(secretType SecretType, length int, keyType string, envPrefix string) (string, error)
func (*Synthesizer) GetGeneratedCount ¶
func (s *Synthesizer) GetGeneratedCount() int
func (*Synthesizer) SynthesizeEnv ¶
func (s *Synthesizer) SynthesizeEnv(rotateOnly bool) error
func (*Synthesizer) SynthesizeTestData ¶
func (s *Synthesizer) SynthesizeTestData() error
SynthesizeTestData generates test data SQL and CSV files.
type TestCredential ¶
type TestCredential struct {
Username string
Password string
Email string
FirstName string
LastName string
Role string
Type string // "agent" or "customer"
}
TestCredential represents a test user credential.
type TestDataGenerator ¶
type TestDataGenerator struct {
// contains filtered or unexported fields
}
TestDataGenerator generates test data SQL and CSV files.
func NewTestDataGenerator ¶
func NewTestDataGenerator(synthesizer *Synthesizer) *TestDataGenerator
NewTestDataGenerator creates a new test data generator.
func (*TestDataGenerator) Generate ¶
func (g *TestDataGenerator) Generate() error
Generate creates test data with secure passwords.
func (*TestDataGenerator) GetCredentialByUsername ¶
func (g *TestDataGenerator) GetCredentialByUsername(username string) *TestCredential
GetCredentialByUsername returns a specific credential.
func (*TestDataGenerator) GetCredentials ¶
func (g *TestDataGenerator) GetCredentials() []TestCredential
GetCredentials returns the generated credentials.
func (*TestDataGenerator) SetPaths ¶
func (g *TestDataGenerator) SetPaths(sqlPath, csvPath string)
SetPaths sets custom paths for output files.
type TicketConfig ¶
type TicketConfig struct {
IDPrefix string `mapstructure:"id_prefix"`
IDFormat string `mapstructure:"id_format"`
DefaultPriority string `mapstructure:"default_priority"`
DefaultStatus string `mapstructure:"default_status"`
AutoAssign bool `mapstructure:"auto_assign"`
Service struct {
DefaultUnknownCustomer bool `mapstructure:"default_unknown_customer"`
} `mapstructure:"service"`
SLA struct {
Enabled bool `mapstructure:"enabled"`
FirstResponse time.Duration `mapstructure:"first_response"`
Resolution time.Duration `mapstructure:"resolution"`
} `mapstructure:"sla"`
Notifications struct {
CustomerCreate bool `mapstructure:"customer_create"`
CustomerUpdate bool `mapstructure:"customer_update"`
AgentAssign bool `mapstructure:"agent_assign"`
AgentMention bool `mapstructure:"agent_mention"`
} `mapstructure:"notifications"`
Frontend struct {
AgentTicketNote struct {
RequiredTimeUnits bool `mapstructure:"required_time_units"`
} `mapstructure:"agent_ticket_note"`
} `mapstructure:"frontend"`
BulkActions struct {
MaxSelectAll int `mapstructure:"max_select_all"`
} `mapstructure:"bulk_actions"`
}
type Tile ¶
type Tile struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
URL string `yaml:"url"`
Icon string `yaml:"icon"`
Color string `yaml:"color"`
Category string `yaml:"category"`
Featured bool `yaml:"featured,omitempty"`
}
Tile represents a dashboard tile/tool.
type ValkeyConfig ¶
type ValkeyConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
MaxRetries int `mapstructure:"max_retries"`
PoolSize int `mapstructure:"pool_size"`
MinIdleConns int `mapstructure:"min_idle_conns"`
Session struct {
Prefix string `mapstructure:"prefix"`
TTL time.Duration `mapstructure:"ttl"`
} `mapstructure:"session"`
Cache struct {
Prefix string `mapstructure:"prefix"`
TTL time.Duration `mapstructure:"ttl"`
} `mapstructure:"cache"`
}
func (*ValkeyConfig) GetValkeyAddr ¶
func (c *ValkeyConfig) GetValkeyAddr() string
GetValkeyAddr returns the Valkey server address.