sysconfig

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sysconfig provides system configuration management.

Index

Constants

View Source
const (
	AuditDefaultRetentionDays = 365
	AuditMaxRetentionDays     = 3650
)

Audit retention bounds; 0 keeps events forever.

View Source
const (
	DecisionFilterDefaultThreshold = 0.5
	DecisionFilterDefaultTimeout   = 30
	DecisionFilterMaxTimeout       = 120
	DecisionFilterMaxOptions       = 26
)

Decision filter bounds. A System One server accepts up to 255 options per question; the logprob backends of goatkit-llm read single option letters, so 26 is the limit every backend can answer.

View Source
const AuditSettingsKey = "Audit::Settings"

AuditSettingsKey holds the audit log settings as one JSON value.

View Source
const DecisionFilterKey = "PostMaster::DecisionFilter"

DecisionFilterKey holds the inbound-mail decision filter settings as one JSON value.

View Source
const DefaultCustomerPortalLandingPage = "/customer/tickets"

DefaultCustomerPortalLandingPage is where customers go after signing in when CustomerPortal::LandingPage is unset or unusable. Migration 000003 and defaults.yaml seed the same value.

Variables

This section is empty.

Functions

func AuditReadAccessEnabled added in v0.11.0

func AuditReadAccessEnabled(db *sql.DB) bool

AuditReadAccessEnabled reports whether read access is recorded. The value is cached for a minute so ticket views do not read sysconfig each time.

func CustomerPortalOverrides

func CustomerPortalOverrides(db *sql.DB, customerID string) map[string]bool

CustomerPortalOverrides reports which of a company's portal fields are explicitly set (overriding the global default) vs inheriting. True = override present, false = inheriting.

func DeleteCustomerPortalConfigKeyForCompany

func DeleteCustomerPortalConfigKeyForCompany(db *sql.DB, customerID, key string) error

DeleteCustomerPortalConfigKeyForCompany removes a single override row for a company, causing reads to fall back to the global default.

func InvalidateAuditReadAccess added in v0.11.0

func InvalidateAuditReadAccess()

InvalidateAuditReadAccess drops the cached read-access flag.

func PasswordRequirementKey added in v0.10.0

func PasswordRequirementKey(code string) string

PasswordRequirementKey returns the i18n key describing the requirement a validation/requirement code stands for. The min_size text carries an {n} placeholder for PasswordMinSize.

func SaveAuditSettings added in v0.11.0

func SaveAuditSettings(db *sql.DB, cfg AuditSettings, userID int) error

SaveAuditSettings validates and stores the settings. Validation failures come back as *AuditSettingsValidationError.

func SaveCustomerPortalConfig

func SaveCustomerPortalConfig(db *sql.DB, cfg CustomerPortalConfig, userID int) error

SaveCustomerPortalConfig persists portal settings as sysconfig overrides.

func SaveCustomerPortalConfigForCompany

func SaveCustomerPortalConfigForCompany(db *sql.DB, customerID string, cfg CustomerPortalConfig, userID int) error

SaveCustomerPortalConfigForCompany writes overrides scoped to a specific customer, creating defaults on demand.

func SaveDecisionFilterConfig added in v0.11.0

func SaveDecisionFilterConfig(db *sql.DB, cfg DecisionFilterConfig, userID int) error

SaveDecisionFilterConfig normalizes, validates and stores the settings. Validation failures come back as *DecisionFilterValidationError, before any storage check, so callers can report them as the caller's mistake.

func Value

func Value(db *sql.DB, name string) (string, bool)

Value reads a sysconfig value, preferring modified overrides and falling back to sysconfig_default or the embedded defaults.yaml when the tables are absent.

Types

type AuditSettings added in v0.11.0

type AuditSettings struct {
	RetentionDays    int  `json:"retention_days"`
	RecordReadAccess bool `json:"record_read_access"`
}

AuditSettings configures the audit log: how long events are kept and whether read access (ticket views, downloads, exports) is recorded.

func DefaultAuditSettings added in v0.11.0

func DefaultAuditSettings() AuditSettings

DefaultAuditSettings keeps events for a year and does not record reads.

func LoadAuditSettings added in v0.11.0

func LoadAuditSettings(db *sql.DB) (AuditSettings, error)

LoadAuditSettings reads the audit settings. A missing value is the default; a value that does not parse is an error with the default returned.

func (AuditSettings) Validate added in v0.11.0

func (s AuditSettings) Validate() error

Validate reports a setting outside its bounds.

type AuditSettingsValidationError added in v0.11.0

type AuditSettingsValidationError struct{ Err error }

AuditSettingsValidationError marks settings the caller must correct.

func (*AuditSettingsValidationError) Error added in v0.11.0

func (*AuditSettingsValidationError) Unwrap added in v0.11.0

func (e *AuditSettingsValidationError) Unwrap() error

type CustomerPortalConfig

type CustomerPortalConfig struct {
	Enabled       bool
	LoginRequired bool
	Title         string
	FooterText    string
	LandingPage   string
}

CustomerPortalConfig holds portal settings stored in sysconfig tables, either the global values or a company's values with its overrides applied.

func DefaultCustomerPortalConfig

func DefaultCustomerPortalConfig() CustomerPortalConfig

DefaultCustomerPortalConfig returns the built-in defaults when no sysconfig rows exist.

func LoadCustomerPortalConfig

func LoadCustomerPortalConfig(db *sql.DB) (CustomerPortalConfig, error)

LoadCustomerPortalConfig reads portal settings from sysconfig tables.

func LoadCustomerPortalConfigForCompany

func LoadCustomerPortalConfigForCompany(db *sql.DB, customerID string) (CustomerPortalConfig, error)

LoadCustomerPortalConfigForCompany returns overrides for a specific customer when present, falling back to global values.

func LoadCustomerPortalConfigForCustomerUser added in v0.10.0

func LoadCustomerPortalConfigForCustomerUser(db *sql.DB, login string) (CustomerPortalConfig, error)

LoadCustomerPortalConfigForCustomerUser returns the portal settings that apply to a signed-in customer: their company's (customer_user.customer_id) overrides on top of the global values. An unknown login gets the global values.

func (CustomerPortalConfig) LandingPath added in v0.10.0

func (cfg CustomerPortalConfig) LandingPath() string

LandingPath returns the local path customers are sent to when they enter the portal. An absolute path ("/customer/tickets") is used as is, a relative one ("tickets") is resolved against /customer. Anything that is not a plain local path (a URL, "//host", backslashes) falls back to DefaultCustomerPortalLandingPage so the setting cannot redirect off-site.

type DecisionFilterConfig added in v0.11.0

type DecisionFilterConfig struct {
	Enabled bool `json:"enabled"`
	// ProviderID selects a goatkit-llm decide provider; 0 uses the org's
	// active decide provider.
	ProviderID     int64               `json:"provider_id,omitempty"`
	Threshold      float64             `json:"threshold"`
	TimeoutSeconds int                 `json:"timeout_seconds"`
	Queue          DecisionFilterField `json:"queue"`
	Priority       DecisionFilterField `json:"priority"`
	Type           DecisionFilterField `json:"type"`
}

DecisionFilterConfig configures the inbound-mail decision filter: before PostMaster creates a ticket, goatkit-llm's llm_decide answers one choice question per enabled field, and answers at or above Threshold confidence set the queue, priority or type of the new ticket.

func DefaultDecisionFilterConfig added in v0.11.0

func DefaultDecisionFilterConfig() DecisionFilterConfig

DefaultDecisionFilterConfig is the disabled filter with default bounds.

func LoadDecisionFilterConfig added in v0.11.0

func LoadDecisionFilterConfig(db *sql.DB) (DecisionFilterConfig, error)

LoadDecisionFilterConfig reads the decision filter settings. A missing value is the disabled default; a value that does not parse is an error so the filter stays off rather than run on a half-read config.

func (*DecisionFilterConfig) Normalize added in v0.11.0

func (c *DecisionFilterConfig) Normalize()

Normalize trims text and drops blank and duplicate options. Unset bounds are left for Validate to reject; LoadDecisionFilterConfig decodes over the defaults, so a stored value that omits them keeps the defaults.

func (DecisionFilterConfig) Validate added in v0.11.0

func (c DecisionFilterConfig) Validate() error

Validate reports the first setting a decision request could not use. It expects a normalized config.

type DecisionFilterField added in v0.11.0

type DecisionFilterField struct {
	Enabled      bool                   `json:"enabled"`
	Instructions string                 `json:"instructions,omitempty"`
	Options      []DecisionFilterOption `json:"options,omitempty"`
}

DecisionFilterField is one classified ticket attribute. Options are the candidate queue, priority or type names, in the order the question lists them.

type DecisionFilterOption added in v0.11.0

type DecisionFilterOption struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

DecisionFilterOption is a candidate answer: the stored name of a queue, priority or type, and an optional description telling the model when it applies.

type DecisionFilterValidationError added in v0.11.0

type DecisionFilterValidationError struct{ Err error }

DecisionFilterValidationError marks a config the caller must correct (a 400, not a 500).

func (*DecisionFilterValidationError) Error added in v0.11.0

func (*DecisionFilterValidationError) Unwrap added in v0.11.0

type DeployedConfig

type DeployedConfig struct {
	Version   string                 `yaml:"version"`
	Timestamp time.Time              `yaml:"timestamp"`
	Settings  map[string]interface{} `yaml:"settings"`
	Metadata  map[string]interface{} `yaml:"metadata"`
}

DeployedConfig represents the deployed configuration file structure.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles system configuration loading and deployment.

func NewManager

func NewManager(db *sql.DB) *Manager

NewManager creates a new configuration manager.

func (*Manager) Deploy

func (m *Manager) Deploy(outputPath string) error

Deploy generates configuration files from database settings.

func (*Manager) Get

func (m *Manager) Get(name string) (interface{}, error)

Get retrieves a configuration value.

func (*Manager) GetArray

func (m *Manager) GetArray(name string) []string

GetArray retrieves an array configuration value.

func (*Manager) GetBool

func (m *Manager) GetBool(name string) bool

GetBool retrieves a boolean configuration value.

func (*Manager) GetInt

func (m *Manager) GetInt(name string) int

GetInt retrieves an integer configuration value.

func (*Manager) GetSettings

func (m *Manager) GetSettings() map[string]*Setting

GetSettings returns all settings for UI display.

func (*Manager) GetString

func (m *Manager) GetString(name string) string

GetString retrieves a string configuration value.

func (*Manager) Load

func (m *Manager) Load() error

Load loads all configuration settings from the database.

func (*Manager) Reset

func (m *Manager) Reset(name string, userID int) error

Reset resets a setting to its default value.

func (*Manager) Set

func (m *Manager) Set(name, value string, userID int) error

Set updates a configuration value.

type Option

type Option struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

Option represents a select option.

type PasswordPolicy

type PasswordPolicy struct {
	// PasswordRegExp is a custom regex pattern that passwords must match.
	// Example: "[a-z]|[A-Z]|[0-9]" requires at least one letter or digit.
	PasswordRegExp string `json:"password_reg_exp"`

	// PasswordMinSize is the minimum password length. 0 = disabled.
	PasswordMinSize int `json:"password_min_size"`

	// PasswordMin2Lower2UpperCharacters requires at least 2 lowercase AND 2 uppercase letters.
	PasswordMin2Lower2UpperCharacters bool `json:"password_min_2_lower_2_upper_characters"`

	// PasswordMin2Characters requires at least 2 letter characters (alphabetic).
	PasswordMin2Characters bool `json:"password_min_2_characters"`

	// PasswordNeedDigit requires at least 1 digit (0-9).
	PasswordNeedDigit bool `json:"password_need_digit"`

	// PasswordMaxLoginFailed is the max failed login attempts before account locked (0 = disabled).
	// Note: This is only used for agents, not customers in OTRS.
	PasswordMaxLoginFailed int `json:"password_max_login_failed"`
}

PasswordPolicy holds OTRS-compatible password policy settings. These settings are stored in sysconfig_default with names like: - CustomerPreferencesGroups###Password (for customers) - PreferencesGroups###Password (for agents)

func DefaultAgentPasswordPolicy

func DefaultAgentPasswordPolicy() PasswordPolicy

DefaultAgentPasswordPolicy returns default policy for agents (all disabled, matching OTRS defaults).

func DefaultCustomerPasswordPolicy

func DefaultCustomerPasswordPolicy() PasswordPolicy

DefaultCustomerPasswordPolicy returns default policy (all disabled, matching OTRS defaults).

func LoadAgentPasswordPolicy

func LoadAgentPasswordPolicy(db *sql.DB) (PasswordPolicy, error)

LoadAgentPasswordPolicy loads agent password policy from sysconfig.

func LoadCustomerPasswordPolicy

func LoadCustomerPasswordPolicy(db *sql.DB) (PasswordPolicy, error)

LoadCustomerPasswordPolicy loads customer password policy from sysconfig.

func (*PasswordPolicy) GetRequirements

func (p *PasswordPolicy) GetRequirements() []string

GetRequirements returns a list of active password requirements for display.

func (*PasswordPolicy) HasRequirements

func (p *PasswordPolicy) HasRequirements() bool

HasRequirements returns true if any password policy rules are enabled.

func (*PasswordPolicy) ValidatePassword

func (p *PasswordPolicy) ValidatePassword(password string) *PasswordValidationError

ValidatePassword validates a password against the policy. Returns nil if valid, or a PasswordValidationError if invalid. Validation order matches OTRS: RegExp -> MinSize -> 2Lower2Upper -> NeedDigit -> 2Characters

type PasswordValidationError

type PasswordValidationError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

PasswordValidationError holds details about why password validation failed.

type Setting

type Setting struct {
	ID                       int       `json:"id"`
	Name                     string    `json:"name"`
	Description              string    `json:"description"`
	Navigation               string    `json:"navigation"`
	IsInvisible              bool      `json:"is_invisible"`
	IsReadonly               bool      `json:"is_readonly"`
	IsRequired               bool      `json:"is_required"`
	IsValid                  bool      `json:"is_valid"`
	HasConfigLevel           int       `json:"has_configlevel"`
	UserModificationPossible bool      `json:"user_modification_possible"`
	UserModificationActive   bool      `json:"user_modification_active"`
	XMLContentRaw            string    `json:"xml_content_raw"`
	XMLContentParsed         string    `json:"xml_content_parsed"`
	XMLFilename              string    `json:"xml_filename"`
	EffectiveValue           string    `json:"effective_value"`
	CreateTime               time.Time `json:"create_time"`
	ChangeTime               time.Time `json:"change_time"`
	CreateBy                 int       `json:"create_by"`
	ChangeBy                 int       `json:"change_by"`

	// Parsed configuration data
	Type         string      `json:"type"`
	Default      interface{} `json:"default"`
	Options      []Option    `json:"options,omitempty"`
	Min          *int        `json:"min,omitempty"`
	Max          *int        `json:"max,omitempty"`
	Validation   string      `json:"validation,omitempty"`
	DependsOn    string      `json:"depends_on,omitempty"`
	DependsValue string      `json:"depends_value,omitempty"`
}

Setting represents a configuration setting.

Jump to

Keyboard shortcuts

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