Fix newline handling in file, softlink, and ImportLink template functions
Use state-based routing instead of sentinel strings, so whitespace-trimming
syntax (e.g. `{{- file "name" -}}`) correctly creates all named files and
symlinks.
Fixes: #2118
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
Co-authored-by: Christian Goll <cgoll@suse.com>
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
|
||||
@@ -118,19 +117,6 @@ func createIgnitionJson(node *node.Node) string {
|
||||
return string(tmpYaml)
|
||||
}
|
||||
|
||||
func importSoftlink(lnk string) string {
|
||||
target, err := filepath.EvalSymlinks(lnk)
|
||||
if err != nil {
|
||||
return "abort"
|
||||
}
|
||||
wwlog.Debug("importing softlink pointing to: %s", target)
|
||||
return softlink(target)
|
||||
}
|
||||
|
||||
func softlink(target string) string {
|
||||
return fmt.Sprintf("{{ /* softlink \"%s\" */ }}", target)
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user