overlay

package
v0.0.0-...-0fb5249 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDoesNotExist = fmt.Errorf("overlay does not exist")

Functions

func BuildAllOverlays

func BuildAllOverlays(nodes []node.Node, allNodes []node.Node, workerCount int) error

func BuildHostOverlay

func BuildHostOverlay() error

Build overlay for the host, so no argument needs to be given

func BuildOverlay

func BuildOverlay(nodeConf node.Node, allNodes []node.Node, context string, overlayNames []string) error

Build the given overlays for a node and create an image for them

func BuildOverlayIndir

func BuildOverlayIndir(nodeData node.Node, allNodes []node.Node, overlayNames []string, outputDir string) error

Build the given overlays for a node in the given directory.

func BuildSpecificOverlays

func BuildSpecificOverlays(nodes []node.Node, allNodes []node.Node, overlayNames []string, workerCount int) error

func CarefulWriteBuffer

func CarefulWriteBuffer(destFile string, buffer bytes.Buffer, backupFile bool, perm fs.FileMode) (err error)

Writes buffer to the destination file. If wwbackup is set a wwbackup will be created.

func FindOverlays

func FindOverlays() (overlayList []string)

Get all overlays present in warewulf

func Image

func Image(nodeName string, context string, overlayNames []string) string

Image returns the full path to an overlay image based on the context and the overlays contained in it.

If a context is provided, the image file name is based on that context name, in the form __{CONTEXT}__.

If the context is empty ("") the image file name is a concatenated list of the contained overlays joined by "-".

If the context is empty and no overlays are specified, the empty string is returned.

func RemoveImage

func RemoveImage(nodeName string, context string, overlayNames []string) error

func RenderTemplateFile

func RenderTemplateFile(fileName string, data TemplateStruct) (
	buffer bytes.Buffer, backupFile, writeFile *bool,
	err error,
)

Parses the template with the given filename, variables must be in data. Returns the parsed template as bytes.Buffer, and the bool variables for backupFile and writeFile. If something goes wrong an error is returned.

func ScanLines

func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)

Simple version of ScanLines, but include the line break

func UniqueField

func UniqueField(sep string, index int, input string) string

UniqueField returns a filtered version of a multi-line input string. input is expected to be a field-separated format with one record per line (terminated by `\n`). Order of lines is preserved, with the first matching line taking precedence.

For example, parsing /etc/passwd filter /etc/passwd for unique user names:

Lines without the index field (e.g., blank lines) are always included in the output.

UniqueField(":", 0, passwdContent)

func ValidateName

func ValidateName(name string) error

ValidateName validates that an overlay name consists only of safe characters. It does not check whether the overlay actually exists.

Types

type FieldInfo

type FieldInfo struct {
	Field      reflect.StructField // Complete field metadata including tags
	ParentType reflect.Type        // The containing struct type
	FullPath   string              // Full path like ".NetDevs.Ipaddr6"
	VarName    string              // Original variable name from template
}

FieldInfo contains detailed type information about a template variable

type Overlay

type Overlay string

Overlay represents an overlay directory path.

func Create

func Create(name string) (overlay Overlay, err error)

Create creates a new overlay directory for the given overlay

Returns an error if the overlay already exists or if directory creation fails.

func Get

func Get(name string) (overlay Overlay, err error)

Get returns the filesystem path of an overlay identified by its name,

func (Overlay) AddFile

func (overlay Overlay) AddFile(filePath string, content []byte, parents bool, force bool) error

func (Overlay) Chmod

func (overlay Overlay) Chmod(path string, mode uint64) (err error)

chmod for the given path in the overlay

func (Overlay) Chown

func (overlay Overlay) Chown(path string, uid, gid int) (err error)

chown file or dir in overlay

func (Overlay) CloneToSite

func (overlay Overlay) CloneToSite() (siteOverlay Overlay, err error)

CloneToSite creates a site overlay from an existing distribution overlay.

If the distribution overlay doesn't exist, return an error.

func (Overlay) Delete

func (overlay Overlay) Delete(force bool) (err error)

func (Overlay) DeleteFile

func (overlay Overlay) DeleteFile(filePath string, force, cleanup bool) (err error)

DeleteFile deletes a file or the entire overlay directory. before deletion.

func (Overlay) Exists

func (overlay Overlay) Exists() bool

Exists checks whether the overlay path exists and is a directory.

Returns:

  • true if the overlay path exists and is a directory; false otherwise.

func (Overlay) File

func (overlay Overlay) File(filePath string) string

File constructs a full path to a file within the overlay's root filesystem.

Parameters:

  • filePath: The relative path of the file within the overlay.

Returns:

  • The full path to the specified file in the overlay's rootfs. If the specified path is not contained within the overlay, the empty string is returned.

func (Overlay) GetFiles

func (overlay Overlay) GetFiles() (files []string, err error)

Get all the files as a string slice for a given overlay

func (Overlay) IsDistributionOverlay

func (overlay Overlay) IsDistributionOverlay() bool

IsDistributionOverlay determines whether the overlay is a distribution overlay.

A distribution overlay is identified by its parent directory matching the configured distribution overlay directory path.

Returns:

  • true if the overlay is a distribution overlay; false otherwise.

func (Overlay) IsSiteOverlay

func (overlay Overlay) IsSiteOverlay() bool

IsSiteOverlay determines whether the overlay is a site overlay.

A site overlay is identified by its parent directory matching the configured site overlay directory path.

Returns:

  • true if the overlay is a site overlay; false otherwise.

func (Overlay) Mkdir

func (overlay Overlay) Mkdir(path string, mode int32) (err error)

func (Overlay) Name

func (overlay Overlay) Name() string

Name returns the base name of the overlay directory.

This is derived from the full path of the overlay.

func (Overlay) ParseCommentVars

func (overlay Overlay) ParseCommentVars(file string) (retMap map[string]string)

ParseCommentVars parses a template file for comments that contain variable documentations. The comments must be in the format `{{/* key: value */}}`. The content is parsed as YAML.

func (Overlay) ParseVarFields

func (overlay Overlay) ParseVarFields(file string) map[string]FieldInfo

ParseVarFields returns detailed type information for each variable in the template by using reflection to resolve the actual struct fields being referenced.

func (Overlay) Path

func (overlay Overlay) Path() string

Path returns the string representation of the overlay path.

This method allows the Overlay type to be easily converted back to its underlying string representation.

func (Overlay) Rootfs

func (overlay Overlay) Rootfs() string

Rootfs returns the path to the root filesystem (rootfs) within the overlay.

If the "rootfs" directory exists inside the overlay path, it returns the path to the "rootfs" directory. Otherwise, it checks if the overlay path itself is a directory and returns that. If neither exists, it defaults to returning the "rootfs" path.

type TemplateStruct

type TemplateStruct struct {
	Id            string
	Hostname      string
	BuildHost     string
	BuildTime     string
	BuildTimeUnix string
	BuildSource   string
	Ipaddr        string
	IpCIDR        string
	Netmask       string
	Network       string
	NetworkCIDR   string
	Overlay       string
	Ipaddr6       string
	PrefixLen6    string
	IpCIDR6       string
	Network6      string
	NetworkCIDR6  string
	Ipv6          bool
	Dhcp          warewulfconf.DHCPConf
	Nfs           warewulfconf.NFSConf
	Ssh           warewulfconf.SSHConf
	Warewulf      warewulfconf.WarewulfConf
	Tftp          warewulfconf.TFTPConf
	Paths         warewulfconf.BuildConfig
	AllNodes      []node.Node
	node.Node
	// backward compatiblity
	Container     string
	ContainerName string
	ThisNode      *node.Node
}

struct which contains the variables to which are available in the templates.

func InitStruct

func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (TemplateStruct, error)

Initialize an TemplateStruct with the given node.NodeInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL