Configure nodes.conf path dynamically from config
Removes the use of init() to initialize the variable. - Closes: #1596 - See also: #1569 Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
|
||||
"dario.cat/mergo"
|
||||
@@ -14,23 +13,13 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
var (
|
||||
ConfigFile string
|
||||
)
|
||||
|
||||
func init() {
|
||||
conf := warewulfconf.Get()
|
||||
if ConfigFile == "" {
|
||||
ConfigFile = path.Join(conf.Paths.Sysconfdir, "warewulf/nodes.conf")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Creates a new nodeDb object from the on-disk configuration
|
||||
*/
|
||||
func New() (NodesYaml, error) {
|
||||
wwlog.Verbose("Opening node configuration file: %s", ConfigFile)
|
||||
data, err := os.ReadFile(ConfigFile)
|
||||
nodesConf := warewulfconf.Get().Paths.NodesConf()
|
||||
wwlog.Verbose("Opening node configuration file: %s", nodesConf)
|
||||
data, err := os.ReadFile(nodesConf)
|
||||
if err != nil {
|
||||
return NodesYaml{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user