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 // FindRoutesByImage returns all routes that match the given image name.
25 // Image names are normalized by stripping the registry domain prefix before comparison.
26 FindRoutesByImage(ctx context.Context, imageName string) []domain.Route
27
28 // AddRoute adds a new route to the configuration.
29 AddRoute(ctx context.Context, route domain.Route) error
30
31 // UpdateRoute updates an existing route.
32 UpdateRoute(ctx context.Context, route domain.Route) error
33
34 // RemoveRoute removes a route from the configuration.
35 RemoveRoute(ctx context.Context, domain string) error
36
37 // Save persists the current configuration to disk.
38 Save(ctx context.Context) error
39
40 // Watch starts watching for configuration changes.
41 // The onChange callback is called when configuration changes are detected.
42 Watch(ctx context.Context, onChange func()) error
43
44 // GetServerPort returns the configured server port.
45 GetServerPort() int
46
47 // GetRegistryPort returns the configured registry port.
48 GetRegistryPort() int
49
50 // GetRegistryDomain returns the configured registry domain.
51 GetRegistryDomain() string
52
53 // GetDataDir returns the configured data directory.
54 GetDataDir() string
55
56 // IsAutoRouteEnabled returns whether auto-route is enabled.
57 IsAutoRouteEnabled() bool
58
59 // IsNetworkIsolationEnabled returns whether network isolation is enabled.
60 IsNetworkIsolationEnabled() bool
61
62 // GetNetworkPrefix returns the prefix for created networks.
63 GetNetworkPrefix() string
64
65 // GetExternalRoutes returns all configured external routes.
66 GetExternalRoutes() map[string]string
67
68 // GetAllAttachments returns all configured attachments.
69 GetAllAttachments(ctx context.Context) map[string][]string
70
71 // GetAttachmentsFor returns attachments for a specific domain or network group.
72 GetAttachmentsFor(ctx context.Context, domainOrGroup string) ([]string, error)
73
74 // FindAttachmentTargetsByImage returns all attachment targets that match the given image name.
75 FindAttachmentTargetsByImage(ctx context.Context, imageName string) []string
76
77 // AddAttachment adds an image to a domain/group's attachments.
78 AddAttachment(ctx context.Context, domainOrGroup, image string) error
79
80 // RemoveAttachment removes an image from a domain/group's attachments.
81 RemoveAttachment(ctx context.Context, domainOrGroup, image string) error
82
83 // Auto-route domain allowlist
84 GetAutoRouteAllowedDomains(ctx context.Context) ([]string, error)
85 AddAutoRouteAllowedDomain(ctx context.Context, pattern string) error
86 RemoveAutoRouteAllowedDomain(ctx context.Context, pattern string) error
87
88 // Preview and auto config
89 GetPreviewConfig() domain.PreviewConfig
90 IsPreviewEnabled() bool
91 IsAutoEnabled() bool
92 GetPreviewTagPatterns() []string
93 GetAllowedDomains() []string
94}