2025-03-21 20:23:15 -04:00
|
|
|
package conf
|
|
|
|
|
2025-03-21 22:51:04 -04:00
|
|
|
import "koti.casa/numenor-labs/dsfx/internal/lib/system"
|
2025-03-21 20:23:15 -04:00
|
|
|
|
|
|
|
const (
|
|
|
|
// DefaultConfigDir is the default directory for the dsfxctl configuration.
|
|
|
|
DefaultConfigDir = "/etc/dsfxctl"
|
|
|
|
// DefaultHost is the default host for the dsfxctl application.
|
|
|
|
DefaultHost = "0.0.0.0"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Conf holds the configuration for the dsfxctl application.
|
|
|
|
type Conf struct {
|
|
|
|
// Directories
|
|
|
|
ConfigDir string
|
|
|
|
// Networking
|
|
|
|
Host string
|
|
|
|
}
|
|
|
|
|
|
|
|
func FromSystem(sys system.System) Conf {
|
|
|
|
var c Conf
|
|
|
|
|
|
|
|
c.ConfigDir = sys.GetEnv("DSFXCTL_CONFIG_DIR")
|
|
|
|
if c.ConfigDir == "" {
|
|
|
|
c.ConfigDir = DefaultConfigDir
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Host = sys.GetEnv("DSFXCTL_HOST")
|
|
|
|
if c.Host == "" {
|
|
|
|
c.Host = DefaultHost
|
|
|
|
}
|
|
|
|
|
|
|
|
return c
|
|
|
|
}
|