diff --git a/cmd/dsfxctl/main.go b/cmd/dsfxctl/main.go index 98f7af7..e3daadf 100644 --- a/cmd/dsfxctl/main.go +++ b/cmd/dsfxctl/main.go @@ -3,7 +3,7 @@ package main import ( "context" - "koti.casa/numenor-labs/dsfx/internal/client/client" + "koti.casa/numenor-labs/dsfx/internal/client" "koti.casa/numenor-labs/dsfx/internal/lib/disk" "koti.casa/numenor-labs/dsfx/internal/lib/system" ) diff --git a/internal/client/client/app.go b/internal/client/client.go similarity index 85% rename from internal/client/client/app.go rename to internal/client/client.go index 1e3702b..da33501 100644 --- a/internal/client/client/app.go +++ b/internal/client/client.go @@ -14,17 +14,46 @@ import ( "koti.casa/numenor-labs/dsfx/internal/lib/network" "koti.casa/numenor-labs/dsfx/internal/lib/storage/scoped" "koti.casa/numenor-labs/dsfx/internal/lib/system" - - "koti.casa/numenor-labs/dsfx/internal/client/conf" ) +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 loadConfigFromSystem(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 +} + // Client represents the client application for dsfxctl. type Client struct { // resources disk disk.Disk system system.System // configuration - conf conf.Conf + conf Conf // storage scopes configScope disk.Disk } @@ -32,7 +61,7 @@ type Client struct { // New creates a new Client instance with the provided disk, system, and // configuration. func New(disk disk.Disk, system system.System) *Client { - conf := conf.FromSystem(system) + conf := loadConfigFromSystem(system) return &Client{ // resources diff --git a/internal/client/conf/conf.go b/internal/client/conf/conf.go deleted file mode 100644 index e7eea74..0000000 --- a/internal/client/conf/conf.go +++ /dev/null @@ -1,34 +0,0 @@ -package conf - -import "koti.casa/numenor-labs/dsfx/internal/lib/system" - -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 -}