config.go RawHistoryFolder
1package in
2
3import (
4 "context"
5
6 "github.com/bnema/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 // Reload re-reads the configuration file from disk and loads it into memory.
15 // This is different from Load() which only loads from the cached viper values.
16 Reload(ctx context.Context) error
17
18 // GetRoutes returns all configured routes.
19 GetRoutes(ctx context.Context) []domain.Route
20
21 // GetRoute returns a single route by domain.
22 GetRoute(ctx context.Context, domain string) (*domain.Route, error)
23
24 // AddRoute adds a new route to the configuration.
25 AddRoute(ctx context.Context, route domain.Route) error
26
27 // UpdateRoute updates an existing route.
28 UpdateRoute(ctx context.Context, route domain.Route) error
29
30 // RemoveRoute removes a route from the configuration.
31 RemoveRoute(ctx context.Context, domain string) error
32
33 // Save persists the current configuration to disk.
34 Save(ctx context.Context) error
35
36 // Watch starts watching for configuration changes.
37 // The onChange callback is called when configuration changes are detected.
38 Watch(ctx context.Context, onChange func()) error
39
40 // GetServerPort returns the configured server port.
41 GetServerPort() int
42
43 // GetRegistryPort returns the configured registry port.
44 GetRegistryPort() int
45
46 // GetRegistryDomain returns the configured registry domain.
47 GetRegistryDomain() string
48
49 // GetDataDir returns the configured data directory.
50 GetDataDir() string
51
52 // IsAutoRouteEnabled returns whether auto-route is enabled.
53 IsAutoRouteEnabled() bool
54
55 // IsNetworkIsolationEnabled returns whether network isolation is enabled.
56 IsNetworkIsolationEnabled() bool
57
58 // GetNetworkPrefix returns the prefix for created networks.
59 GetNetworkPrefix() string
60
61 // GetExternalRoutes returns all configured external routes.
62 GetExternalRoutes() map[string]string
63
64 // GetAllAttachments returns all configured attachments.
65 GetAllAttachments(ctx context.Context) map[string][]string
66
67 // GetAttachmentsFor returns attachments for a specific domain or network group.
68 GetAttachmentsFor(ctx context.Context, domainOrGroup string) ([]string, error)
69
70 // AddAttachment adds an image to a domain/group's attachments.
71 AddAttachment(ctx context.Context, domainOrGroup, image string) error
72
73 // RemoveAttachment removes an image from a domain/group's attachments.
74 RemoveAttachment(ctx context.Context, domainOrGroup, image string) error
75}