services -> domains
This commit is contained in:
@@ -79,8 +79,10 @@ type DHCPStaticLease struct {
|
||||
Hostname string `yaml:"hostname,omitempty" json:"hostname,omitempty"`
|
||||
}
|
||||
|
||||
// GlobalConfig represents the main configuration structure
|
||||
type GlobalConfig struct {
|
||||
// State represents Wild Central's runtime state — operator settings, networking
|
||||
// configuration, DDNS, DHCP, etc. Persisted in {dataDir}/state.yaml and mutated
|
||||
// via the API. This is NOT boot-time config (which comes from env vars).
|
||||
type State struct {
|
||||
Operator struct {
|
||||
Email string `yaml:"email,omitempty" json:"email,omitempty"`
|
||||
} `yaml:"operator,omitempty" json:"operator,omitempty"`
|
||||
@@ -109,22 +111,21 @@ type GlobalConfig struct {
|
||||
ExtraPorts []ExtraPort `yaml:"extraPorts,omitempty" json:"extraPorts,omitempty"`
|
||||
} `yaml:"nftables,omitempty" json:"nftables,omitempty"`
|
||||
DDNS struct {
|
||||
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
|
||||
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
|
||||
Records []string `yaml:"records,omitempty" json:"records,omitempty"`
|
||||
IntervalMinutes int `yaml:"intervalMinutes,omitempty" json:"intervalMinutes,omitempty"`
|
||||
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
|
||||
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
|
||||
IntervalMinutes int `yaml:"intervalMinutes,omitempty" json:"intervalMinutes,omitempty"`
|
||||
} `yaml:"ddns,omitempty" json:"ddns,omitempty"`
|
||||
} `yaml:"cloud,omitempty" json:"cloud,omitempty"`
|
||||
}
|
||||
|
||||
// LoadState loads state from the specified path
|
||||
func LoadState(configPath string) (*GlobalConfig, error) {
|
||||
func LoadState(configPath string) (*State, error) {
|
||||
data, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reading config file %s: %w", configPath, err)
|
||||
}
|
||||
|
||||
config := &GlobalConfig{}
|
||||
config := &State{}
|
||||
if err := yaml.Unmarshal(data, config); err != nil {
|
||||
return nil, fmt.Errorf("parsing config file: %w", err)
|
||||
}
|
||||
@@ -133,7 +134,7 @@ func LoadState(configPath string) (*GlobalConfig, error) {
|
||||
}
|
||||
|
||||
// SaveState saves the state to the specified path
|
||||
func SaveState(config *GlobalConfig, configPath string) error {
|
||||
func SaveState(config *State, configPath string) error {
|
||||
// Ensure the directory exists
|
||||
if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil {
|
||||
return fmt.Errorf("creating config directory: %w", err)
|
||||
@@ -148,7 +149,7 @@ func SaveState(config *GlobalConfig, configPath string) error {
|
||||
}
|
||||
|
||||
// IsEmpty checks if the configuration is empty or uninitialized
|
||||
func (c *GlobalConfig) IsEmpty() bool {
|
||||
func (c *State) IsEmpty() bool {
|
||||
if c == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user