package config import ( "fmt" "strings" ) type LogLevel string const ( LogLevelDebug LogLevel = "DEBUG" LogLevelInfo LogLevel = "INFO" LogLevelWarn LogLevel = "WARN" LogLevelError LogLevel = "ERROR" ) func (l *LogLevel) UnmarshalText(data []byte) error { raw := strings.ToUpper(string(data)) switch LogLevel(raw) { case LogLevelDebug, LogLevelInfo, LogLevelWarn, LogLevelError: *l = LogLevel(raw) return nil default: return fmt.Errorf("invalid log level: %q", data) } } //go:generate -command roleconfig go run git.wzray.com/homelab/hivemind/internal/codegen/roleconfig //go:generate roleconfig -name NodeConfig type NodeConfig struct { Hostname string `toml:"hostname"` Address string `toml:"address"` Port int `toml:"port"` KeepaliveInterval int `toml:"keepalive_interval" gen:"positive"` LogLevel LogLevel `toml:"log_level"` BootstrapMaster string `toml:"bootstrap_master" gen:"no"` ListenOn string `toml:"listen_on" gen:"ip"` }