make the configuration to be based in warewulf.conf

defaults will be se by the Makefile

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-03-03 16:02:41 +01:00
parent 32b4bb74cc
commit 377702a179
18 changed files with 130 additions and 174 deletions

View File

@@ -6,9 +6,9 @@ import (
"path"
"strings"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
)
@@ -18,8 +18,9 @@ the path is relative to SYSCONFDIR.
Templates in the file are no evaluated.
*/
func templateFileInclude(inc string) string {
conf := warewulfconf.New()
if !strings.HasPrefix(inc, "/") {
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
inc = path.Join(conf.SYSCONFDIR(), "warewulf", inc)
}
wwlog.Debug("Including file into template: %s", inc)
content, err := os.ReadFile(inc)
@@ -35,8 +36,9 @@ is the file to read, the second the abort string
Templates in the file are no evaluated.
*/
func templateFileBlock(inc string, abortStr string) (string, error) {
conf := warewulfconf.New()
if !strings.HasPrefix(inc, "/") {
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
inc = path.Join(conf.SYSCONFDIR(), "warewulf", inc)
}
wwlog.Debug("Including file block into template: %s", inc)
readFile, err := os.Open(inc)