storage

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigInvalid = errors.New("adminstorage: storage configuration is invalid")

ErrConfigInvalid indicates configuration validation failed.

View Source
var ErrPreviewUnsupported = errors.New("adminstorage: preview not supported")

ErrPreviewUnsupported indicates the service was constructed without a preview helper.

View Source
var ErrRepositoryRequired = errors.New("adminstorage: repository is required")

ErrRepositoryRequired indicates the service was constructed without a repository.

Functions

This section is empty.

Types

type Option

type Option func(*Service)

Option mutates the service configuration.

func WithAuditRecorder

func WithAuditRecorder(recorder jobs.AuditRecorder) Option

WithAuditRecorder overrides the audit recorder dependency.

func WithClock

func WithClock(clock func() time.Time) Option

WithClock overrides the clock used for audit timestamps.

func WithPreviewer

func WithPreviewer(preview PreviewFunc) Option

WithPreviewer wires a preview helper used to verify storage profiles before activation.

func WithValidator

func WithValidator(validator Validator) Option

WithValidator overrides the configuration validator used by the service.

type PreviewFunc

type PreviewFunc func(ctx context.Context, profile storage.Profile) (PreviewResult, error)

PreviewFunc attempts to initialise a storage profile without mutating runtime state.

type PreviewResult

type PreviewResult struct {
	Profile      storage.Profile      `json:"profile"`
	Capabilities storage.Capabilities `json:"capabilities"`
	Diagnostics  map[string]any       `json:"diagnostics,omitempty"`
	Warnings     []string             `json:"warnings,omitempty"`
}

PreviewResult reports metadata gathered during preview initialisation.

type Schemas

type Schemas struct {
	Config  string
	Profile string
}

Schemas exposes JSON schema helpers for admin surfaces.

type Service

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

Service synchronises runtime storage profiles with the backing repository and emits audit events.

func NewService

func NewService(repo storageconfig.Repository, recorder jobs.AuditRecorder, opts ...Option) *Service

NewService constructs a storage admin service.

func (*Service) Aliases

func (s *Service) Aliases() map[string]string

Aliases returns a copy of the current alias mapping.

func (*Service) ApplyConfig

func (s *Service) ApplyConfig(ctx context.Context, cfg runtimeconfig.StorageConfig) error

ApplyConfig maps the supplied runtime storage configuration to repository writes.

func (*Service) GetProfile

func (s *Service) GetProfile(ctx context.Context, name string) (*storage.Profile, error)

GetProfile returns a single profile by name.

func (*Service) ListProfiles

func (s *Service) ListProfiles(ctx context.Context) ([]storage.Profile, error)

ListProfiles returns the stored profiles ordered by name.

func (*Service) PreviewProfile

func (s *Service) PreviewProfile(ctx context.Context, profile storage.Profile) (PreviewResult, error)

PreviewProfile initialises the supplied profile using the configured previewer.

func (*Service) ResolveAlias

func (s *Service) ResolveAlias(alias string) (string, bool)

ResolveAlias resolves an alias to its target profile name.

func (*Service) Schemas

func (s *Service) Schemas() Schemas

Schemas returns JSON schema helpers for admin integrations.

func (*Service) ValidateConfig

func (s *Service) ValidateConfig(cfg runtimeconfig.StorageConfig) error

ValidateConfig ensures profile collections and aliases are well formed.

func (*Service) ValidateProfile

func (s *Service) ValidateProfile(profile storage.Profile, aliases map[string]string) error

ValidateProfile validates a single profile with optional alias mappings.

type Validator

type Validator func(runtimeconfig.StorageConfig) error

Validator validates runtime configuration payloads before they are persisted.

Jump to

Keyboard shortcuts

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