Skip to content

Commit

Permalink
Merge pull request warewulf#894 from mslacken/FixProvisionBuild
Browse files Browse the repository at this point in the history
calling the overlay build functions direclty
  • Loading branch information
anderbubble authored Oct 26, 2023
2 parents 92b651d + 2b49bca commit f1d45d2
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 118 deletions.
35 changes: 9 additions & 26 deletions internal/pkg/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,9 @@ import (
"github.com/pkg/errors"
)

/*
func BuildSystemOverlay(nodeList []node.NodeInfo) error {
return nil
}
func BuildRuntimeOverlay(nodeList []node.NodeInfo) error {
return nil
}
func FindSystemOverlays() ([]string, error) {
return findAllOverlays("system")
}
func FindRuntimeOverlays() ([]string, error) {
return findAllOverlays("runtime")
}
*/
var (
ErrDoesNotExist = errors.New("overlay does not exist")
)

/*
Build all overlays (runtime and generic) for a node
Expand Down Expand Up @@ -141,6 +125,9 @@ func OverlayInit(overlayName string) error {
Build the given overlays for a node and create a Image for them
*/
func BuildOverlay(nodeInfo node.NodeInfo, context string, overlayNames []string) error {
if len(overlayNames) == 0 {
return nil
}
// create the dir where the overlay images will reside
name := fmt.Sprintf("overlay %s/%v", nodeInfo.Id.Get(), overlayNames)
overlayImage := OverlayImage(nodeInfo.Id.Get(), context, overlayNames)
Expand Down Expand Up @@ -187,7 +174,7 @@ exists it will be created.
*/
func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir string) error {
if len(overlayNames) == 0 {
return errors.New("At least one valid overlay is needed to build for a node")
return nil
}
if !util.IsDir(outputDir) {
return errors.Errorf("output must a be a directory: %s", outputDir)
Expand All @@ -204,14 +191,10 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
for _, overlayName := range overlayNames {
wwlog.Verbose("Building overlay %s for node %s in %s", overlayName, nodeInfo.Id.Get(), outputDir)
overlaySourceDir := OverlaySourceDir(overlayName)
wwlog.Debug("Starting to build overlay %s\nChanging directory to OverlayDir: %s", overlayName, overlaySourceDir)
wwlog.Debug("Changing directory to OverlayDir: %s", overlaySourceDir)
err := os.Chdir(overlaySourceDir)
if err != nil {
return errors.Wrap(err, "could not change directory to overlay dir")
}
wwlog.Debug("Checking to see if overlay directory exists: %s", overlaySourceDir)
if !util.IsDir(overlaySourceDir) {
return errors.New("overlay does not exist: " + overlayName)
return errors.Wrapf(ErrDoesNotExist, "directory: %s name: %s", overlaySourceDir, overlayName)
}

wwlog.Verbose("Walking the overlay structure: %s", overlaySourceDir)
Expand Down
Loading

0 comments on commit f1d45d2

Please sign in to comment.