51 lines
1.1 KiB
Go

package conf
import "koti.casa/numenor-labs/dsfx/internal/lib/system"
const (
// DefaultConfigDir is the default directory for the dsfx configuration.
DefaultConfigDir = "/etc/dsfx/config"
// DefaultStorageDir is the default directory for the dsfx storage.
DefaultStorageDir = "/etc/dsfx/data"
// 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
StorageDir string
// Networking
Host string
Port string
}
func FromSystem(sys system.System) Conf {
var c Conf
c.ConfigDir = sys.GetEnv("DSFX_CONFIG_DIR")
if c.ConfigDir == "" {
c.ConfigDir = DefaultConfigDir
}
c.StorageDir = sys.GetEnv("DSFX_STORAGE_DIR")
if c.StorageDir == "" {
c.StorageDir = DefaultStorageDir
}
c.Host = sys.GetEnv("DSFX_HOST")
if c.Host == "" {
c.Host = DefaultHost
}
c.Port = sys.GetEnv("DSFX_PORT")
if c.Port == "" {
c.Port = DefaultPort
}
return c
}