updated overlay includes mire vars and split func

This commit is contained in:
Christian Goll
2022-05-03 14:24:50 +02:00
parent 8f1ab4f883
commit 7ce286ac3e
2 changed files with 18 additions and 0 deletions

View File

@@ -37,4 +37,8 @@ type TemplateStruct struct {
Dhcp warewulfconf.DhcpConf Dhcp warewulfconf.DhcpConf
Nfs warewulfconf.NfsConf Nfs warewulfconf.NfsConf
Warewulf warewulfconf.WarewulfConf Warewulf warewulfconf.WarewulfConf
Overlays []string
Containers []string
Kernels []string
Profiles []string
} }

View File

@@ -17,6 +17,8 @@ import (
"text/template" "text/template"
"time" "time"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
@@ -301,6 +303,15 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
dt := time.Now() dt := time.Now()
tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST") tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST")
tstruct.BuildTimeUnix = strconv.FormatInt(dt.Unix(), 10) tstruct.BuildTimeUnix = strconv.FormatInt(dt.Unix(), 10)
tstruct.Containers, _ = container.ListSources()
profiles, _ := nodeDB.FindAllProfiles()
var profileList []string
for _, profile := range profiles {
profileList = append(profileList, profile.Id.Get())
}
tstruct.Profiles = profileList
tstruct.Overlays, _ = FindOverlays()
tstruct.Kernels, _ = kernel.ListKernels()
for _, overlayName := range overlayNames { for _, overlayName := range overlayNames {
wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir) wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir)
overlaySourceDir := OverlaySourceDir(overlayName) overlaySourceDir := OverlaySourceDir(overlayName)
@@ -360,6 +371,9 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
backupFile = false backupFile = false
return "" return ""
}, },
"split": func(s string, d string) []string {
return strings.Split(s, d)
},
// }).ParseGlob(path.Join(OverlayDir, destFile+".ww*")) // }).ParseGlob(path.Join(OverlayDir, destFile+".ww*"))
}).ParseGlob(location) }).ParseGlob(location)
if err != nil { if err != nil {