Documentation
¶
Index ¶
- type Change
- type ChangeType
- type ConfigAdapter
- type ConfigEvent
- type ConfigStore
- type EventType
- type HotReloadManager
- type LintIssue
- type LintRule
- type Linter
- type Metadata
- type ReloadHandler
- type Schema
- type SchemaRegistry
- type UniversalLinter
- type ValidationError
- type ValidationResult
- type ValidationWarning
- type Validator
- type Version
- type VersionManager
- func (vm *VersionManager) CreateVersion(kind YAMLKind, name string, doc *YAMLDocument, message string) (*Version, error)
- func (vm *VersionManager) DiffVersions(kind YAMLKind, name string, fromID, toID string) ([]Change, error)
- func (vm *VersionManager) GetCurrent(kind YAMLKind, name string) (*YAMLDocument, error)
- func (vm *VersionManager) GetVersion(kind YAMLKind, name string, versionID string) (*Version, error)
- func (vm *VersionManager) ListAll(kind YAMLKind) ([]*YAMLDocument, error)
- func (vm *VersionManager) ListVersions(kind YAMLKind, name string) ([]*Version, error)
- func (vm *VersionManager) Rollback(kind YAMLKind, name string, versionID string) error
- type VersionStats
- type YAMLDocument
- type YAMLKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Type ChangeType `json:"type"`
Path string `json:"path"`
OldValue interface{} `json:"old_value,omitempty"`
NewValue interface{} `json:"new_value,omitempty"`
Description string `json:"description,omitempty"`
}
Change represents a change between versions.
type ChangeType ¶
type ChangeType string
ChangeType represents the type of change.
const ( ChangeTypeAdd ChangeType = "add" ChangeTypeModify ChangeType = "modify" ChangeTypeDelete ChangeType = "delete" )
type ConfigAdapter ¶
type ConfigAdapter struct {
// contains filtered or unexported fields
}
ConfigAdapter provides a simplified interface for accessing GoatFlow configuration settings. It wraps the VersionManager and provides methods to read config values.
func NewConfigAdapter ¶
func NewConfigAdapter(vm *VersionManager) *ConfigAdapter
NewConfigAdapter creates a new ConfigAdapter wrapping the given VersionManager.
func (*ConfigAdapter) GetConfigSettings ¶
func (ca *ConfigAdapter) GetConfigSettings() ([]map[string]interface{}, error)
GetConfigSettings returns all configuration settings.
func (*ConfigAdapter) GetConfigValue ¶
func (ca *ConfigAdapter) GetConfigValue(name string) (interface{}, error)
GetConfigValue retrieves a configuration value by name. It returns the "value" field if set, otherwise the "default" field.
func (*ConfigAdapter) ImportConfigYAML ¶
func (ca *ConfigAdapter) ImportConfigYAML(path string) error
ImportConfigYAML imports a Config.yaml file and stores its settings.
type ConfigEvent ¶
type ConfigEvent struct {
Type EventType `json:"type"`
Kind YAMLKind `json:"kind"`
Name string `json:"name"`
Version *Version `json:"version,omitempty"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
}
ConfigEvent represents a configuration change event.
type ConfigStore ¶
type ConfigStore interface {
// Version management
CreateVersion(kind YAMLKind, name string, doc *YAMLDocument, message string) (*Version, error)
GetVersion(kind YAMLKind, name string, versionID string) (*Version, error)
ListVersions(kind YAMLKind, name string) ([]*Version, error)
Rollback(kind YAMLKind, name string, versionID string) error
// Current configuration
GetCurrent(kind YAMLKind, name string) (*YAMLDocument, error)
SetCurrent(kind YAMLKind, name string, doc *YAMLDocument) error
List(kind YAMLKind) ([]*YAMLDocument, error)
Delete(kind YAMLKind, name string) error
// Watching
Watch(kind YAMLKind) (<-chan ConfigEvent, error)
StopWatch(kind YAMLKind)
}
ConfigStore interface for storing and retrieving configurations.
type HotReloadManager ¶
type HotReloadManager struct {
// contains filtered or unexported fields
}
HotReloadManager manages hot reloading for all YAML configurations.
func NewHotReloadManager ¶
func NewHotReloadManager(versionMgr *VersionManager, validator Validator) (*HotReloadManager, error)
NewHotReloadManager creates a new hot reload manager.
func (*HotReloadManager) Events ¶
func (hrm *HotReloadManager) Events() <-chan ConfigEvent
Events returns the event channel.
func (*HotReloadManager) RegisterHandler ¶
func (hrm *HotReloadManager) RegisterHandler(kind YAMLKind, handler ReloadHandler)
RegisterHandler registers a reload handler for a specific kind.
func (*HotReloadManager) Stop ¶
func (hrm *HotReloadManager) Stop()
Stop stops the hot reload manager.
func (*HotReloadManager) WatchDirectory ¶
func (hrm *HotReloadManager) WatchDirectory(dir string, kind YAMLKind) error
WatchDirectory starts watching a directory for YAML changes.
type LintIssue ¶
type LintIssue struct {
Severity string `json:"severity"`
Rule string `json:"rule"`
Message string `json:"message"`
Path string `json:"path"`
Line int `json:"line,omitempty"`
}
LintIssue represents a linting issue.
type LintRule ¶
type LintRule struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Severity string `json:"severity"`
Enabled bool `json:"enabled"`
}
LintRule represents a linting rule.
type Linter ¶
type Linter interface {
Lint(doc *YAMLDocument) ([]LintIssue, error)
GetRules(kind YAMLKind) []LintRule
}
Linter interface for linting YAML documents.
type Metadata ¶
type Metadata struct {
Name string `yaml:"name" json:"name"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
Version string `yaml:"version,omitempty" json:"version,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
Created time.Time `yaml:"created,omitempty" json:"created,omitempty"`
Modified time.Time `yaml:"modified,omitempty" json:"modified,omitempty"`
Author string `yaml:"author,omitempty" json:"author,omitempty"`
}
Metadata contains common metadata for all YAML types.
type ReloadHandler ¶
type ReloadHandler func(document *YAMLDocument) error
ReloadHandler is a function that handles configuration reloads.
type Schema ¶
type Schema struct {
ID string `json:"$id,omitempty"`
Schema string `json:"$schema,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type"`
Properties map[string]interface{} `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Additional interface{} `json:"additionalProperties,omitempty"`
}
Schema represents a JSON schema for validation.
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry manages JSON schemas for YAML validation.
func NewSchemaRegistry ¶
func NewSchemaRegistry() *SchemaRegistry
NewSchemaRegistry creates a new schema registry.
func (*SchemaRegistry) GetSchema ¶
func (sr *SchemaRegistry) GetSchema(kind YAMLKind) (*Schema, error)
GetSchema returns the schema for a specific kind.
func (*SchemaRegistry) RegisterSchema ¶
func (sr *SchemaRegistry) RegisterSchema(kind YAMLKind, schema *Schema) error
RegisterSchema registers a schema for a specific kind.
func (*SchemaRegistry) Validate ¶
func (sr *SchemaRegistry) Validate(doc *YAMLDocument) (*ValidationResult, error)
Validate validates a document against its schema.
type UniversalLinter ¶
type UniversalLinter struct {
// contains filtered or unexported fields
}
UniversalLinter provides linting for all YAML document types.
func NewUniversalLinter ¶
func NewUniversalLinter() *UniversalLinter
NewUniversalLinter creates a new universal linter.
func (*UniversalLinter) GetRules ¶
func (ul *UniversalLinter) GetRules(kind YAMLKind) []LintRule
GetRules returns rules for a specific kind.
func (*UniversalLinter) Lint ¶
func (ul *UniversalLinter) Lint(doc *YAMLDocument) ([]LintIssue, error)
Lint performs linting on a document.
func (*UniversalLinter) RegisterRule ¶
func (ul *UniversalLinter) RegisterRule(kind YAMLKind, rule LintRule)
RegisterRule registers a new lint rule.
type ValidationError ¶
type ValidationError struct {
Path string `json:"path"`
Message string `json:"message"`
Code string `json:"code"`
}
ValidationError represents a validation error.
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid"`
Errors []ValidationError `json:"errors,omitempty"`
Warnings []ValidationWarning `json:"warnings,omitempty"`
}
ValidationResult represents the result of validation.
type ValidationWarning ¶
type ValidationWarning struct {
Path string `json:"path"`
Message string `json:"message"`
Code string `json:"code"`
}
ValidationWarning represents a validation warning.
type Validator ¶
type Validator interface {
Validate(doc *YAMLDocument) (*ValidationResult, error)
GetSchema(kind YAMLKind) (*Schema, error)
}
Validator interface for validating YAML documents.
type Version ¶
type Version struct {
ID string `json:"id"`
Number string `json:"number"`
Kind YAMLKind `json:"kind"`
Name string `json:"name"`
Hash string `json:"hash"`
ParentHash string `json:"parent_hash,omitempty"`
Timestamp time.Time `json:"timestamp"`
Author string `json:"author"`
Message string `json:"message"`
Document *YAMLDocument `json:"document"`
Changes []Change `json:"changes,omitempty"`
Stats *VersionStats `json:"stats,omitempty"`
}
Version represents a version of any YAML configuration.
type VersionManager ¶
type VersionManager struct {
// contains filtered or unexported fields
}
VersionManager manages versions for all YAML configuration types.
func GetVersionManager ¶
func GetVersionManager() *VersionManager
GetVersionManager returns the last created version manager (best-effort singleton).
func NewVersionManager ¶
func NewVersionManager(storageDir string) *VersionManager
NewVersionManager creates a new version manager.
func (*VersionManager) CreateVersion ¶
func (vm *VersionManager) CreateVersion(kind YAMLKind, name string, doc *YAMLDocument, message string) (*Version, error)
CreateVersion creates a new version for a YAML document.
func (*VersionManager) DiffVersions ¶
func (vm *VersionManager) DiffVersions(kind YAMLKind, name string, fromID, toID string) ([]Change, error)
DiffVersions compares two versions.
func (*VersionManager) GetCurrent ¶
func (vm *VersionManager) GetCurrent(kind YAMLKind, name string) (*YAMLDocument, error)
GetCurrent returns the current version of a document.
func (*VersionManager) GetVersion ¶
func (vm *VersionManager) GetVersion(kind YAMLKind, name string, versionID string) (*Version, error)
GetVersion retrieves a specific version.
func (*VersionManager) ListAll ¶
func (vm *VersionManager) ListAll(kind YAMLKind) ([]*YAMLDocument, error)
ListAll returns all current documents of a specific kind.
func (*VersionManager) ListVersions ¶
func (vm *VersionManager) ListVersions(kind YAMLKind, name string) ([]*Version, error)
ListVersions returns all versions for a document.
type VersionStats ¶
type VersionStats struct {
TotalFields int `json:"total_fields"`
ChangedFields int `json:"changed_fields"`
AddedFields int `json:"added_fields"`
DeletedFields int `json:"deleted_fields"`
CustomStats map[string]int `json:"custom_stats,omitempty"`
}
VersionStats contains statistics about a version.
type YAMLDocument ¶
type YAMLDocument struct {
APIVersion string `yaml:"apiVersion" json:"apiVersion"`
Kind string `yaml:"kind" json:"kind"`
Metadata Metadata `yaml:"metadata" json:"metadata"`
Spec interface{} `yaml:"spec" json:"spec"`
Data map[string]interface{} `yaml:"data,omitempty" json:"data,omitempty"`
}
YAMLDocument represents any YAML configuration document.