From da7ef9cf6c3219da61ed517caabfd730e37290ba Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Tue, 5 Dec 2023 21:47:37 -0500 Subject: [PATCH] fix: `windows_options` nil and length check Return `nil` if `RunOnceCommandList` is `nil` or if it is an empty slice. Ref: #269 Signed-off-by: Ryan Johnson --- builder/vsphere/clone/step_customize.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builder/vsphere/clone/step_customize.go b/builder/vsphere/clone/step_customize.go index e11a78797..406aea084 100644 --- a/builder/vsphere/clone/step_customize.go +++ b/builder/vsphere/clone/step_customize.go @@ -356,13 +356,12 @@ func (w *WindowsOptions) sysprep() *types.CustomizationSysprep { } func (w *WindowsOptions) guiRunOnce() *types.CustomizationGuiRunOnce { - obj := &types.CustomizationGuiRunOnce{ - CommandList: *w.RunOnceCommandList, - } - if len(obj.CommandList) < 1 { + if w.RunOnceCommandList == nil || len(*w.RunOnceCommandList) < 1 { return nil } - return obj + return &types.CustomizationGuiRunOnce{ + CommandList: *w.RunOnceCommandList, + } } func boolValue(p *bool, fallback bool) bool {