Documentation
¶
Index ¶
- Variables
- func ErrParseYAML(err error) error
- func ParseConfig(raw []byte) (*config.FileConfig, error)
- func ShortContainerID(id string) string
- func UnifiedDiff(oldText, newText string) string
- type Audit
- type ConfigRevisionView
- type ConfigSchema
- type ConfigService
- func (s *ConfigService) Document(maskSecrets bool) (*config.FileConfig, error)
- func (s *ConfigService) Path() string
- func (s *ConfigService) Raw() ([]byte, error)
- func (s *ConfigService) Restore(revID uint, in SaveRawInput) (*SaveRawResult, error)
- func (s *ConfigService) Revisions() *RevisionService
- func (s *ConfigService) SaveRaw(in SaveRawInput) (*SaveRawResult, error)
- type DomainView
- type FieldDef
- type GroupDef
- type Monitor
- type RevisionService
- type RuntimeDeps
- type SaveRawInput
- type SaveRawResult
- type SchemaFieldKind
- type SessionView
Constants ¶
This section is empty.
Variables ¶
var (
ErrRevisionNotFound = errors.New("config revision not found")
)
Errors surfaced to handlers.
Functions ¶
func ErrParseYAML ¶
ErrParseYAML is returned when a save/restore cannot parse the incoming YAML into a FileConfig.
func ParseConfig ¶
func ParseConfig(raw []byte) (*config.FileConfig, error)
ParseConfig is a helper for handler-side validation that mirrors config.parseDocument but is exported via the service layer.
func ShortContainerID ¶
func UnifiedDiff ¶
UnifiedDiff returns a small line-based unified diff between two byte slices. We avoid external deps by implementing a tiny LCS-based diff sufficient for human-readable config change review. The output is intentionally simple (no hunk headers, no line counts) — adequate for the admin UI which colors +/- lines.
Types ¶
type Audit ¶
type Audit struct{}
Audit records admin actions in SQLite.
type ConfigRevisionView ¶
type ConfigRevisionView struct {
ID uint `json:"id"`
CreatedAt string `json:"createdAt"`
Actor string `json:"actor"`
ClientIP string `json:"clientIp"`
Summary string `json:"summary"`
BytesSize int `json:"bytesSize"`
}
ConfigRevisionView is the list-time projection of a ConfigRevision row.
func ToViews ¶
func ToViews(rows []*model.ConfigRevision) []*ConfigRevisionView
type ConfigSchema ¶
type ConfigSchema struct {
SchemaVersion int `json:"schemaVersion"`
Groups []*GroupDef `json:"groups"`
}
ConfigSchema is the UI-facing description of the config document.
func NewConfigSchema ¶
func NewConfigSchema() *ConfigSchema
NewConfigSchema returns a static, pure description of the FileConfig shape. It does not load the file and has no side effects.
func (*ConfigSchema) FieldByPath ¶
func (s *ConfigSchema) FieldByPath(p string) *FieldDef
FieldByPath returns the FieldDef for a given dotted path, or nil if not found.
type ConfigService ¶
type ConfigService struct {
// contains filtered or unexported fields
}
ConfigService reads/writes the server YAML file.
func NewConfigService ¶
func NewConfigService(path string, reload *config.Manager) *ConfigService
func (*ConfigService) Document ¶
func (s *ConfigService) Document(maskSecrets bool) (*config.FileConfig, error)
func (*ConfigService) Path ¶
func (s *ConfigService) Path() string
func (*ConfigService) Raw ¶
func (s *ConfigService) Raw() ([]byte, error)
func (*ConfigService) Restore ¶
func (s *ConfigService) Restore(revID uint, in SaveRawInput) (*SaveRawResult, error)
Restore writes a historical revision's YAML back to disk, persisting a new revision row that records the lineage.
func (*ConfigService) Revisions ¶
func (s *ConfigService) Revisions() *RevisionService
Revisions returns the revision service.
func (*ConfigService) SaveRaw ¶
func (s *ConfigService) SaveRaw(in SaveRawInput) (*SaveRawResult, error)
SaveRaw atomically writes the YAML, persists a revision row, computes a unified diff (using the on-disk file BEFORE the save), and triggers the reload manager if present. The caller is responsible for writing the audit row.
type DomainView ¶
type FieldDef ¶
type FieldDef struct {
Path string `json:"path"`
Label string `json:"label"`
Kind SchemaFieldKind `json:"kind"`
Required bool `json:"required,omitempty"`
HelpText string `json:"helpText,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Min *int `json:"min,omitempty"`
Max *int `json:"max,omitempty"`
EnumValues []string `json:"enumValues,omitempty"`
Default any `json:"default,omitempty"`
Item *FieldDef `json:"item,omitempty"` // list<kind>
ValueFields []*FieldDef `json:"valueFields,omitempty"` // kvMap value fields
}
FieldDef describes a single field for the UI.
type GroupDef ¶
type GroupDef struct {
Key string `json:"key"`
Label string `json:"label"`
Path string `json:"path"`
Kind string `json:"kind"` // "object" | "list" | "kvMap"
Fields []*FieldDef `json:"fields"`
}
GroupDef describes a top-level config group rendered as a section.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor provides read-only views of runtime state.
func NewMonitor ¶
func NewMonitor(deps RuntimeDeps) *Monitor
func (*Monitor) AdminStatus ¶ added in v1.29.4
AdminStatus returns resolved admin console settings for read-only display.
func (*Monitor) Domains ¶
func (m *Monitor) Domains() []DomainView
func (*Monitor) Sessions ¶
func (m *Monitor) Sessions() []SessionView
func (*Monitor) StatsGlobal ¶
type RevisionService ¶
type RevisionService struct{}
RevisionService manages ConfigRevision rows. It deliberately does not transact with the file write itself: the on-disk save is atomic (SaveRawAtomic), but the SQLite write and the file rename are not. On failure between the two, the next save will overwrite the orphan revision. See plan PR-2 §2.3 for the rationale.
func NewRevisionService ¶
func NewRevisionService() *RevisionService
func (*RevisionService) Get ¶
func (s *RevisionService) Get(id uint) (*model.ConfigRevision, error)
Get returns one revision by ID.
func (*RevisionService) List ¶
func (s *RevisionService) List(limit int) ([]*model.ConfigRevision, error)
List returns the most recent N revisions, newest first.
func (*RevisionService) Save ¶
func (s *RevisionService) Save(yamlText, summary, actor, clientIP string) (*model.ConfigRevision, error)
Save persists a new revision row with the given YAML. Returns the row.
type RuntimeDeps ¶
type RuntimeDeps struct {
Ctx *types.Context
Domain string
HTTPPort int
TCPPort int
Secure bool
ServerVersion string
Started time.Time
ConfigPath string
ReloadManager *config.Manager
Admin *config.ResolvedAdmin
}
RuntimeDeps holds shared admin runtime dependencies.
type SaveRawInput ¶
SaveRawInput carries audit metadata for SaveRaw.
type SaveRawResult ¶
SaveRawResult is the outcome of a save/restore.
type SchemaFieldKind ¶
type SchemaFieldKind string
SchemaFieldKind describes the UI control to render for a field.
const ( KindString SchemaFieldKind = "string" KindInt SchemaFieldKind = "int" KindPort SchemaFieldKind = "port" KindBool SchemaFieldKind = "bool" KindEnum SchemaFieldKind = "enum" KindDuration SchemaFieldKind = "duration" KindSecret SchemaFieldKind = "secret" )
type SessionView ¶
type SessionView struct {
ContainerID string `json:"containerId"`
ClientID string `json:"clientId"`
Type string `json:"type"`
AuthType string `json:"authType"`
Version string `json:"version"`
PublicEntry string `json:"publicEntry"`
SourcePort *int `json:"sourcePort,omitempty"`
UseNewProtocol bool `json:"useNewProtocol"`
ConfigIndex *int `json:"configIndex,omitempty"`
ConfigMatch string `json:"configMatch"` // "exact" | "partial" | "missing" | ""
MatchIssues []string `json:"matchIssues,omitempty"`
}