Skip to content

Commit af41a18

Browse files
committed
Do guest template expansion for provisioning scripts
The LIMA_CIDATA_* variables are not a supported API and can change without warning. Signed-off-by: Jan Dubois <[email protected]>
1 parent bd7442e commit af41a18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/limayaml/defaults.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
427427
if provision.Mode == ProvisionModeDependency && provision.SkipDefaultDependencyResolution == nil {
428428
provision.SkipDefaultDependencyResolution = ptr.Of(false)
429429
}
430+
if out, err := executeGuestTemplate(provision.Script); err == nil {
431+
provision.Script = out.String()
432+
} else {
433+
logrus.WithError(err).Warnf("Couldn't process provisioning script %q as a template", provision.Script)
434+
}
430435
}
431436

432437
if y.GuestInstallPrefix == nil {
@@ -795,7 +800,7 @@ func executeHostTemplate(format, instDir string) (bytes.Buffer, error) {
795800
"User": user.Username,
796801

797802
"Instance": filepath.Base(instDir), // DEPRECATED, use `{{.Name}}`
798-
"LimaHome": limaHome, // DEPRECATED, (use `Dir` instead of `{{.LimaHome}}/{{.Instance}}`
803+
"LimaHome": limaHome, // DEPRECATED, use `{{.Dir}}` instead of `{{.LimaHome}}/{{.Instance}}`
799804
}
800805
var out bytes.Buffer
801806
if err := tmpl.Execute(&out, data); err == nil {

0 commit comments

Comments
 (0)