Rename "container" to "image"

- Updated `wwctl upgrade` to handle updates
- Maintained `.Container` and `.ContainerName` in tstruct
- Added `ContainerName()` methods to node and profile objects
- Added `--container`, `-C` aliases to wwctl commands (`<node|profile> <add|set>`)
- Added `wwctl container` alias
- Added support for `container_exit.sh` if `image_exit.sh` is not found

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-18 17:34:48 -07:00
parent 96396ed47e
commit 45a690ca4e
142 changed files with 2212 additions and 2183 deletions

View File

@@ -39,8 +39,9 @@ type TemplateStruct struct {
AllNodes []node.Node
node.Node
// backward compatiblity
Container string
ThisNode *node.Node
Container string
ContainerName string
ThisNode *node.Node
}
/*
@@ -74,7 +75,8 @@ func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (T
// init some convenience vars
tstruct.Id = nodeData.Id()
tstruct.Hostname = nodeData.Id()
tstruct.Container = nodeData.ContainerName
tstruct.Container = nodeData.ImageName
tstruct.ContainerName = nodeData.ImageName
// Backwards compatibility for templates using "Keys"
tstruct.AllNodes = allNodes
dt := time.Now()

View File

@@ -10,7 +10,7 @@ import (
"strings"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/container"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/util"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
@@ -73,32 +73,32 @@ func templateFileBlock(inc string, abortStr string) (string, error) {
}
/*
Reads a file relative to given container.
Reads a file relative to given image.
Templates in the file are no evaluated.
*/
func templateContainerFileInclude(containername string, filepath string) string {
wwlog.Verbose("Including file from Container into template: %s:%s", containername, filepath)
func templateImageFileInclude(imagename string, filepath string) string {
wwlog.Verbose("Including file from Image into template: %s:%s", imagename, filepath)
if containername == "" {
wwlog.Warn("Container is not defined for node: %s", filepath)
if imagename == "" {
wwlog.Warn("Image is not defined for node: %s", filepath)
return ""
}
if !container.ValidSource(containername) {
wwlog.Warn("Template requires file(s) from non-existant container: %s:%s", containername, filepath)
if !image.ValidSource(imagename) {
wwlog.Warn("Template requires file(s) from non-existant image: %s:%s", imagename, filepath)
return ""
}
containerDir := container.RootFsDir(containername)
imageDir := image.RootFsDir(imagename)
wwlog.Debug("Including file from container: %s:%s", containerDir, filepath)
wwlog.Debug("Including file from image: %s:%s", imageDir, filepath)
if !util.IsFile(path.Join(containerDir, filepath)) {
wwlog.Warn("Requested file from container does not exist: %s:%s", containername, filepath)
if !util.IsFile(path.Join(imageDir, filepath)) {
wwlog.Warn("Requested file from image does not exist: %s:%s", imagename, filepath)
return ""
}
content, err := os.ReadFile(path.Join(containerDir, filepath))
content, err := os.ReadFile(path.Join(imageDir, filepath))
if err != nil {
wwlog.Error("Template include failed: %s", err)

View File

@@ -227,7 +227,7 @@ func FindOverlays() (overlayList []string, err error) {
}
/*
Build the given overlays for a node and create a Image for them
Build the given overlays for a node and create an image for them
*/
func BuildOverlay(nodeConf node.Node, allNodes []node.Node, context string, overlayNames []string) error {
if len(overlayNames) == 0 && context == "" {
@@ -469,7 +469,7 @@ func RenderTemplateFile(fileName string, data TemplateStruct) (
// Build our FuncMap
funcMap := template.FuncMap{
"Include": templateFileInclude,
"IncludeFrom": templateContainerFileInclude,
"IncludeFrom": templateImageFileInclude,
"IncludeBlock": templateFileBlock,
"ImportLink": importSoftlink,
"basename": path.Base,