From 7ce286ac3edef8652a9c33feeffa120fef87c90e Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Tue, 3 May 2022 14:24:50 +0200 Subject: [PATCH] updated overlay includes mire vars and split func --- internal/pkg/overlay/datastructure.go | 4 ++++ internal/pkg/overlay/overlay.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/internal/pkg/overlay/datastructure.go b/internal/pkg/overlay/datastructure.go index 70e5f79b..0c4c35d7 100644 --- a/internal/pkg/overlay/datastructure.go +++ b/internal/pkg/overlay/datastructure.go @@ -37,4 +37,8 @@ type TemplateStruct struct { Dhcp warewulfconf.DhcpConf Nfs warewulfconf.NfsConf Warewulf warewulfconf.WarewulfConf + Overlays []string + Containers []string + Kernels []string + Profiles []string } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 06272a48..00329e9a 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -17,6 +17,8 @@ import ( "text/template" "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/util" "github.com/hpcng/warewulf/internal/pkg/warewulfconf" @@ -301,6 +303,15 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir dt := time.Now() tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST") 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 { wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir) overlaySourceDir := OverlaySourceDir(overlayName) @@ -360,6 +371,9 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir backupFile = false return "" }, + "split": func(s string, d string) []string { + return strings.Split(s, d) + }, // }).ParseGlob(path.Join(OverlayDir, destFile+".ww*")) }).ParseGlob(location) if err != nil {