config

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigData

type ConfigData struct {
	FilePath string
	Sections map[string]*Section
	Order    []string
}

ConfigData holds all sections and their ordering

type FileMutexManager added in v0.9.2

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

func NewFileMutexManager added in v0.9.2

func NewFileMutexManager() *FileMutexManager

func (*FileMutexManager) WithReadLock added in v0.9.2

func (fm *FileMutexManager) WithReadLock(path string, fn func() error) error

func (*FileMutexManager) WithWriteLock added in v0.9.2

func (fm *FileMutexManager) WithWriteLock(path string, fn func() error) error

type FormatStyle

type FormatStyle int

SectionConfig manages the configuration system FormatStyle defines different configuration file formats

const (
	FormatDefault FormatStyle = iota
	FormatSystemd
	FormatINI
)

type PropertyType

type PropertyType string

PropertyType represents the type of a configuration property

const (
	TypeString PropertyType = "string"
	TypeInt    PropertyType = "int"
	TypeBool   PropertyType = "bool"
	TypeArray  PropertyType = "array"
	TypeObject PropertyType = "object"
)

type Schema

type Schema struct {
	Type        PropertyType
	Description string
	Required    bool
	MinLength   *int
	MaxLength   *int
	Properties  map[string]*Schema
	Items       *Schema // For array types
	Pattern     *string // For string validation
}

Schema represents a configuration schema definition

type Section

type Section struct {
	Type       string
	ID         string
	Properties map[string]string
}

Section represents a single configuration section

type SectionConfig

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

func NewSectionConfig

func NewSectionConfig(idSchema *Schema) *SectionConfig

func (*SectionConfig) GetPlugin

func (sc *SectionConfig) GetPlugin(typeName string) *SectionPlugin

func (*SectionConfig) Parse

func (sc *SectionConfig) Parse(filename string) (*ConfigData, error)

Parse reads and parses a configuration file

func (*SectionConfig) RegisterPlugin

func (sc *SectionConfig) RegisterPlugin(plugin *SectionPlugin)

func (*SectionConfig) Write

func (sc *SectionConfig) Write(config *ConfigData) error

type SectionPlugin

type SectionPlugin struct {
	TypeName    string
	Properties  map[string]*Schema
	IDProperty  string
	Validations []ValidationFunc
	FolderPath  string
}

SectionPlugin defines the schema and behavior for a specific section type

type ValidationFunc

type ValidationFunc func(data map[string]string) error

type WatchCallback

type WatchCallback func(*ConfigData)

WatchCallback is called when configuration changes are detected

Jump to

Keyboard shortcuts

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