Refactor softlink functions to remove repetition and add flexibility

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-11-15 15:09:40 -07:00
parent a8b2f11114
commit fc82244749
2 changed files with 10 additions and 5 deletions

View File

@@ -125,10 +125,14 @@ func createIgnitionJson(node *node.Node) string {
}
func importSoftlink(lnk string) string {
path, err := filepath.EvalSymlinks(lnk)
target, err := filepath.EvalSymlinks(lnk)
if err != nil {
return "abort"
}
wwlog.Debug("importing softlink pointing to: %s", path)
return fmt.Sprintf("{{ /* softlink \"%s\" */ }}", path)
wwlog.Debug("importing softlink pointing to: %s", target)
return softlink(target)
}
func softlink(target string) string {
return fmt.Sprintf("{{ /* softlink \"%s\" */ }}", target)
}