Configure destination of grub.cfg at overlay render time

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-10-29 20:41:05 -06:00
parent be97ef15a0
commit 40f0cebe64
4 changed files with 17 additions and 2 deletions

View File

@@ -571,7 +571,20 @@ func BuildOverlayIndir(nodeData node.Node, allNodes []node.Node, overlayNames []
}
fileBuffer.Reset()
}
outputPath = path.Join(path.Dir(originalOutputPath), filenameFromTemplate[0][1])
if path.IsAbs(filenameFromTemplate[0][1]) {
outputPath = filenameFromTemplate[0][1]
// Create parent directory for absolute paths
parentDir := path.Dir(outputPath)
sourceDirInfo, err := os.Stat(path.Dir(walkPath))
if err != nil {
return fmt.Errorf("could not stat source directory: %w", err)
}
if err := os.MkdirAll(parentDir, sourceDirInfo.Mode()); err != nil {
return fmt.Errorf("could not create parent directory for absolute path: %w", err)
}
} else {
outputPath = path.Join(path.Dir(originalOutputPath), filenameFromTemplate[0][1])
}
writingToNamedFile = true
isLink = false
} else {