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:
Jonathon Anderson
2024-12-12 12:11:04 -07:00
parent b0d0e26b4a
commit a80ba8ee01
30 changed files with 78 additions and 203 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
@@ -109,12 +110,12 @@ func (config *NodesYaml) DelProfile(nodeID string) error {
Write the the NodeYaml to disk.
*/
func (config *NodesYaml) Persist() error {
return config.PersistToFile(ConfigFile)
return config.PersistToFile(warewulfconf.Get().Paths.NodesConf())
}
func (config *NodesYaml) PersistToFile(configFile string) error {
if configFile == "" {
configFile = ConfigFile
configFile = warewulfconf.Get().Paths.NodesConf()
}
out, dumpErr := config.Dump()
if dumpErr != nil {