feat: basic configuration UI

This commit is contained in:
2025-05-28 07:13:38 +02:00
parent b5b7d08f9f
commit d16db82cab
8 changed files with 765 additions and 12 deletions

View File

@@ -8,17 +8,46 @@ import (
)
type Config struct {
RunMode RunMode `yaml:"runmode"`
Hostname string `yaml:"hostname" envconfig:"HOSTNAME"`
Rcond RcondConfig `yaml:"rcond"`
Network NetworkConfig `yaml:"network"`
Wifi WifiConfig `yaml:"wifi"`
Cluster ClusterConfig `yaml:"cluster"`
UI UIConfig `yaml:"ui"`
}
type RunMode string
const (
RunModeNode RunMode = "node"
RunModeUI RunMode = "ui"
)
type RcondConfig struct {
Addr string `yaml:"addr" envconfig:"RCOND_ADDR"`
ApiToken string `yaml:"api_token" envconfig:"RCOND_API_TOKEN"`
}
type WifiConfig struct {
AP APConfig `yaml:"ap"`
STA STAConfig `yaml:"sta"`
}
type APConfig struct {
SSID string `yaml:"ssid" envconfig:"WIFI_AP_SSID"`
Password string `yaml:"password" envconfig:"WIFI_AP_PASSWORD"`
Encryption string `yaml:"encryption" envconfig:"WIFI_AP_ENCRYPTION"`
Interface string `yaml:"interface" envconfig:"WIFI_AP_INTERFACE"`
}
type STAConfig struct {
SSID string `yaml:"ssid" envconfig:"WIFI_STA_SSID"`
Password string `yaml:"password" envconfig:"WIFI_STA_PASSWORD"`
Encryption string `yaml:"encryption" envconfig:"WIFI_STA_ENCRYPTION"`
Interface string `yaml:"interface" envconfig:"WIFI_STA_INTERFACE"`
}
type NetworkConfig struct {
Connections []ConnectionConfig `yaml:"connections"`
}
@@ -50,6 +79,10 @@ type ClusterConfig struct {
LogLevel string `yaml:"log_level" envconfig:"CLUSTER_LOG_LEVEL"`
}
type UIConfig struct {
Enabled bool `yaml:"enabled" envconfig:"UI_ENABLED"`
}
// LoadConfig reads the configuration from a YAML file and environment variables.
func LoadConfig(filename string) (*Config, error) {
var config Config