From 8323cb8aa781d52ccca7c2b121ef5b91b0c0f0f9 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Mon, 16 Oct 2023 16:38:13 +0200 Subject: [PATCH] moved initialization of ConfigFile to New() setting the ConfigFile (location of nodes.conf) in init() led to the situation that a configured Paths.Sysconfdir is ignored. Signed-off-by: Christian Goll --- internal/pkg/node/constructors.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index 3b4109a4..08c27b19 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -40,7 +40,10 @@ defaultnode: netmask: 255.255.255.0 onboot: true` -func init() { +/* +Creates a new nodeDb object from the on-disk configuration +*/ +func New() (NodeYaml, error) { conf := warewulfconf.Get() if ConfigFile == "" { ConfigFile = path.Join(conf.Paths.Sysconfdir, "warewulf/nodes.conf") @@ -48,12 +51,6 @@ func init() { if DefaultConfig == "" { DefaultConfig = path.Join(conf.Paths.Datadir, "warewulf/defaults.conf") } -} - -/* -Creates a new nodeDb object from the on-disk configuration -*/ -func New() (NodeYaml, error) { wwlog.Verbose("Opening node configuration file: %s", ConfigFile) data, err := os.ReadFile(ConfigFile) if err != nil {