Move tstruct.Overlay from wwctl to overlay.InitStruct

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-12-18 12:14:54 -07:00
committed by Christian Goll
parent c03dc9436b
commit 0b00233ab7
4 changed files with 5 additions and 5 deletions

View File

@@ -57,12 +57,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeConf = node.NewNode(hostName)
nodeConf.ClusterName = hostName
}
tstruct, err := overlay.InitStruct(nodeConf)
tstruct, err := overlay.InitStruct(overlayName, nodeConf)
if err != nil {
return err
}
tstruct.BuildSource = overlayFile
tstruct.Overlay = overlayName
buffer, backupFile, writeFile, err := overlay.RenderTemplateFile(overlayFile, tstruct)
if err != nil {
return err

View File

@@ -21,7 +21,7 @@ func Hostfile() (err error) {
}
hostname, _ := os.Hostname()
tstruct, err := overlay.InitStruct(node.NewNode(hostname))
tstruct, err := overlay.InitStruct(overlay_.Name(), node.NewNode(hostname))
if err != nil {
return err
}

View File

@@ -46,8 +46,9 @@ type TemplateStruct struct {
/*
Initialize an TemplateStruct with the given node.NodeInfo
*/
func InitStruct(nodeData node.Node) (TemplateStruct, error) {
func InitStruct(overlayName string, nodeData node.Node) (TemplateStruct, error) {
var tstruct TemplateStruct
tstruct.Overlay = overlayName
hostname, _ := os.Hostname()
tstruct.BuildHost = hostname
controller := warewulfconf.Get()

View File

@@ -283,7 +283,7 @@ func BuildOverlayIndir(nodeData node.Node, overlayNames []string, outputDir stri
wwlog.Debug("Created directory in overlay: %s", location)
} else if filepath.Ext(location) == ".ww" {
tstruct, err := InitStruct(nodeData)
tstruct, err := InitStruct(overlayName, nodeData)
if err != nil {
return fmt.Errorf("failed to initial data for %s: %w", nodeData.Id(), err)
}