From ac740b19f160bcd2398e9d6ca16b04a53fdcc69c Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Fri, 10 May 2024 14:13:36 -0400 Subject: [PATCH] fix: run once command list Updates RunOnceCommandList to a slice of strings `[]string` and updates 'guiRunOnce()` to pass "" if no commands are provided. This will ensure that the function addresses each case. Ref: #419 Signed-off-by: Ryan Johnson --- .web-docs/components/builder/vsphere-clone/README.md | 2 +- builder/vsphere/clone/step_customize.go | 11 +++++++---- .../vsphere/clone/WindowsOptions-not-required.mdx | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.web-docs/components/builder/vsphere-clone/README.md b/.web-docs/components/builder/vsphere-clone/README.md index bae7a5dc..a9fb2f43 100644 --- a/.web-docs/components/builder/vsphere-clone/README.md +++ b/.web-docs/components/builder/vsphere-clone/README.md @@ -458,7 +458,7 @@ Example of usage: -- `run_once_command_list` (\*[]string) - Specifies a list of commands to run at first logon after the guest operating system is customized. +- `run_once_command_list` ([]string) - Specifies a list of commands to run at first logon after the guest operating system is customized. - `auto_logon` (\*bool) - Specifies whether the guest operating system automatically logs on as Administrator. diff --git a/builder/vsphere/clone/step_customize.go b/builder/vsphere/clone/step_customize.go index 243035a0..0c53eb42 100644 --- a/builder/vsphere/clone/step_customize.go +++ b/builder/vsphere/clone/step_customize.go @@ -82,7 +82,7 @@ type LinuxOptions struct { type WindowsOptions struct { // Specifies a list of commands to run at first logon after the guest operating system is customized. - RunOnceCommandList *[]string `mapstructure:"run_once_command_list"` + RunOnceCommandList []string `mapstructure:"run_once_command_list"` // Specifies whether the guest operating system automatically logs on as Administrator. AutoLogon *bool `mapstructure:"auto_logon"` // Specifies how many times the guest operating system should auto-logon the Administrator account when `auto_logon` is set to `true`. Default:s to `1`. @@ -389,11 +389,14 @@ func (w *WindowsOptions) sysprep() *types.CustomizationSysprep { } func (w *WindowsOptions) guiRunOnce() *types.CustomizationGuiRunOnce { - if w.RunOnceCommandList == nil || len(*w.RunOnceCommandList) < 1 { - return nil + if w.RunOnceCommandList == nil || len(w.RunOnceCommandList) == 0 { + return &types.CustomizationGuiRunOnce{ + CommandList: []string{""}, + } } + return &types.CustomizationGuiRunOnce{ - CommandList: *w.RunOnceCommandList, + CommandList: w.RunOnceCommandList, } } diff --git a/docs-partials/builder/vsphere/clone/WindowsOptions-not-required.mdx b/docs-partials/builder/vsphere/clone/WindowsOptions-not-required.mdx index 7dbf6d1a..87c9b299 100644 --- a/docs-partials/builder/vsphere/clone/WindowsOptions-not-required.mdx +++ b/docs-partials/builder/vsphere/clone/WindowsOptions-not-required.mdx @@ -1,6 +1,6 @@ -- `run_once_command_list` (\*[]string) - Specifies a list of commands to run at first logon after the guest operating system is customized. +- `run_once_command_list` ([]string) - Specifies a list of commands to run at first logon after the guest operating system is customized. - `auto_logon` (\*bool) - Specifies whether the guest operating system automatically logs on as Administrator.