mirror of
https://github.com/0x1d/rcond.git
synced 2025-12-16 10:54:29 +01:00
feat: basic configuration UI
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user