mirror of
https://git.numenor-labs.us/dsfx.git
synced 2025-04-29 08:10:34 +00:00
43 lines
883 B
Go
43 lines
883 B
Go
package conf
|
|
|
|
import "koti.casa/numenor-labs/dsfx/internal/lib/system"
|
|
|
|
const (
|
|
// DefaultConfigDir is the default directory for the dsfxctl configuration.
|
|
DefaultConfigDir = "/etc/dsfxnode/config"
|
|
// DefaultHost is the default host for the dsfxctl application.
|
|
DefaultHost = "0.0.0.0"
|
|
// DefaultPort is the default port for the dsfxctl application.
|
|
DefaultPort = "8000"
|
|
)
|
|
|
|
// Conf holds the configuration for the dsfxctl application.
|
|
type Conf struct {
|
|
// Directories
|
|
ConfigDir string
|
|
// Networking
|
|
Host string
|
|
Port string
|
|
}
|
|
|
|
func FromSystem(sys system.System) Conf {
|
|
var c Conf
|
|
|
|
c.ConfigDir = sys.GetEnv("DSFXNODE_CONFIG_DIR")
|
|
if c.ConfigDir == "" {
|
|
c.ConfigDir = DefaultConfigDir
|
|
}
|
|
|
|
c.Host = sys.GetEnv("DSFXNODE_HOST")
|
|
if c.Host == "" {
|
|
c.Host = DefaultHost
|
|
}
|
|
|
|
c.Port = sys.GetEnv("DSFXNODE_PORT")
|
|
if c.Port == "" {
|
|
c.Port = DefaultPort
|
|
}
|
|
|
|
return c
|
|
}
|