refactor: Replace 'reach' field with 'public' boolean in service registration and related components
This commit is contained in:
@@ -17,14 +17,6 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Reach describes how a service is exposed.
|
||||
type Reach string
|
||||
|
||||
const (
|
||||
ReachInternal Reach = "internal" // LAN-visible — DNS + proxy + TLS
|
||||
ReachPublic Reach = "public" // internet-visible — + DDNS + external HAProxy
|
||||
)
|
||||
|
||||
// BackendType describes how the gateway handles traffic for this service.
|
||||
type BackendType string
|
||||
|
||||
@@ -54,7 +46,7 @@ type Service struct {
|
||||
Source string `yaml:"source,omitempty" json:"source,omitempty"` // who registered: wild-cloud, wild-works, manual
|
||||
Backend Backend `yaml:"backend" json:"backend"` // where to route
|
||||
Subdomains bool `yaml:"subdomains,omitempty" json:"subdomains,omitempty"` // also match *.domain
|
||||
Reach Reach `yaml:"reach" json:"reach"` // internal or public
|
||||
Public bool `yaml:"public,omitempty" json:"public,omitempty"` // true = internet-visible (DDNS + external), false = LAN only
|
||||
TLS TLSMode `yaml:"tls,omitempty" json:"tls,omitempty"` // passthrough or terminate
|
||||
}
|
||||
|
||||
@@ -106,9 +98,7 @@ func (m *Manager) Register(svc Service) error {
|
||||
if svc.Backend.Type == "" {
|
||||
return fmt.Errorf("backend type is required")
|
||||
}
|
||||
if svc.Reach == "" {
|
||||
return fmt.Errorf("reach is required")
|
||||
}
|
||||
// Public field is a bool — no validation needed (defaults to false)
|
||||
|
||||
// Default TLS mode based on backend type
|
||||
if svc.TLS == "" {
|
||||
@@ -133,7 +123,7 @@ func (m *Manager) Register(svc Service) error {
|
||||
return fmt.Errorf("writing service file: %w", err)
|
||||
}
|
||||
|
||||
slog.Info("service registered", "domain", svc.Domain, "reach", svc.Reach, "source", svc.Source, "subdomains", svc.Subdomains)
|
||||
slog.Info("service registered", "domain", svc.Domain, "public", svc.Public, "source", svc.Source, "subdomains", svc.Subdomains)
|
||||
|
||||
if m.reconcileFn != nil {
|
||||
go m.reconcileFn()
|
||||
@@ -249,8 +239,8 @@ func (m *Manager) Update(domain string, updates map[string]any) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if reach, ok := updates["reach"].(string); ok {
|
||||
svc.Reach = Reach(reach)
|
||||
if public, ok := updates["public"].(bool); ok {
|
||||
svc.Public = public
|
||||
}
|
||||
if sub, ok := updates["subdomains"].(bool); ok {
|
||||
svc.Subdomains = sub
|
||||
|
||||
Reference in New Issue
Block a user