Skip to content

Commit

Permalink
fix: run once command list
Browse files Browse the repository at this point in the history
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 <ryan.johnson@broadcom.com>
  • Loading branch information
tenthirtyam authored and lbajolet-hashicorp committed May 10, 2024
1 parent a03ab4c commit ac740b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .web-docs/components/builder/vsphere-clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Example of usage:

<!-- Code generated from the comments of the WindowsOptions struct in builder/vsphere/clone/step_customize.go; DO NOT EDIT MANUALLY -->

- `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.

Expand Down
11 changes: 7 additions & 4 deletions builder/vsphere/clone/step_customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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,
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Code generated from the comments of the WindowsOptions struct in builder/vsphere/clone/step_customize.go; DO NOT EDIT MANUALLY -->

- `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.

Expand Down

0 comments on commit ac740b1

Please # to comment.