First pass at a rework of the overlay subsystem in Warewulf
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
@@ -19,15 +20,15 @@ func templateFileInclude(path string) string {
|
||||
}
|
||||
|
||||
func templateContainerFileInclude(containername string, filepath string) string {
|
||||
wwlog.Printf(wwlog.DEBUG, "Including VNFS file into template: %s: %s\n", containername, filepath)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Including file from Container into template: %s:%s\n", containername, filepath)
|
||||
|
||||
if containername == "" {
|
||||
wwlog.Printf(wwlog.WARN, "VNFS not set for template import request: %s: %s\n", containername, filepath)
|
||||
wwlog.Printf(wwlog.WARN, "Container is not defined for node: %s\n", filepath)
|
||||
return ""
|
||||
}
|
||||
|
||||
if !container.ValidSource(containername) {
|
||||
wwlog.Printf(wwlog.WARN, "Template required VNFS does not exist: %s\n", containername)
|
||||
wwlog.Printf(wwlog.WARN, "Template requires file(s) from non-existant container: %s:%s\n", containername, filepath)
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -35,10 +36,15 @@ func templateContainerFileInclude(containername string, filepath string) string
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Including file from container: %s:%s\n", containerDir, filepath)
|
||||
|
||||
if !util.IsFile(path.Join(containerDir, filepath)) {
|
||||
wwlog.Printf(wwlog.WARN, "Requested file from container does not exist: %s:%s\n", containername, filepath)
|
||||
return ""
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(path.Join(containerDir, filepath))
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Template include: %s\n", err)
|
||||
wwlog.Printf(wwlog.ERROR, "Template include failed: %s\n", err)
|
||||
}
|
||||
return strings.TrimSuffix(string(content), "\n")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user