config.go RawHistoryFolder
1package in
2
3import (
4 "context"
5
6 "gordon/internal/domain"
7)
8
9// ConfigService defines the contract for configuration management.
10type ConfigService interface {
11 // Load loads the configuration from the configured source.
12 Load(ctx context.Context) error
13
14 // GetRoutes returns all configured routes.
15 GetRoutes(ctx context.Context) []domain.Route
16
17 // GetRoute returns a single route by domain.
18 GetRoute(ctx context.Context, domain string) (*domain.Route, error)
19
20 // AddRoute adds a new route to the configuration.
21 AddRoute(ctx context.Context, route domain.Route) error
22
23 // UpdateRoute updates an existing route.
24 UpdateRoute(ctx context.Context, route domain.Route) error
25
26 // RemoveRoute removes a route from the configuration.
27 RemoveRoute(ctx context.Context, domain string) error
28
29 // Save persists the current configuration to disk.
30 Save(ctx context.Context) error
31
32 // Watch starts watching for configuration changes.
33 // The onChange callback is called when configuration changes are detected.
34 Watch(ctx context.Context, onChange func()) error
35
36 // GetServerPort returns the configured server port.
37 GetServerPort() int
38
39 // GetRegistryPort returns the configured registry port.
40 GetRegistryPort() int
41
42 // GetRegistryDomain returns the configured registry domain.
43 GetRegistryDomain() string
44
45 // GetDataDir returns the configured data directory.
46 GetDataDir() string
47
48 // IsAutoRouteEnabled returns whether auto-route is enabled.
49 IsAutoRouteEnabled() bool
50
51 // IsNetworkIsolationEnabled returns whether network isolation is enabled.
52 IsNetworkIsolationEnabled() bool
53
54 // GetNetworkPrefix returns the prefix for created networks.
55 GetNetworkPrefix() string
56
57 // GetExternalRoutes returns all configured external routes.
58 GetExternalRoutes() map[string]string
59
60 // GetAllAttachments returns all configured attachments.
61 GetAllAttachments(ctx context.Context) map[string][]string
62
63 // GetAttachmentsFor returns attachments for a specific domain or network group.
64 GetAttachmentsFor(ctx context.Context, domainOrGroup string) ([]string, error)
65
66 // AddAttachment adds an image to a domain/group's attachments.
67 AddAttachment(ctx context.Context, domainOrGroup, image string) error
68
69 // RemoveAttachment removes an image from a domain/group's attachments.
70 RemoveAttachment(ctx context.Context, domainOrGroup, image string) error
71}