diff --git a/.web-docs/components/builder/iso/README.md b/.web-docs/components/builder/iso/README.md index 9f79c695..e8249fd3 100644 --- a/.web-docs/components/builder/iso/README.md +++ b/.web-docs/components/builder/iso/README.md @@ -135,7 +135,7 @@ JSON Example: - `sound` (bool) - Enable virtual sound card device. Defaults to `false`. -- `usb` (bool) - Enable a the USB 2.0 controllers for the virtual machine. +- `usb` (bool) - Enable USB 2.0 controllers for the virtual machine. Defaults to `false`. ~> **Note:** To enable USB 3.0 controllers, set a `usb_xhci.present` @@ -174,7 +174,7 @@ JSON Example: the virtual machine should yield the CPU when polling the port. By default, the builder will assume this as `FALSE`. - * `AUTO:(yield)` - Specifies to use auto-detection to determine the + * `AUTO: (yield)` - Specifies to use auto-detection to determine the serial port to use. This has one option to determine how the virtual machine should support the serial port. @@ -278,7 +278,7 @@ JSON Example: -- `tools_upload_flavor` (string) - The flavor of VMware tools to upload into the virtual machine based on +- `tools_upload_flavor` (string) - The flavor of VMware Tools to upload into the virtual machine based on the guest operating system. Allowed values are `darwin` (macOS), `linux`, and `windows`. Default is empty and no version will be uploaded. @@ -286,7 +286,7 @@ JSON Example: `tools_upload_flavor` is non-empty. This is a [configuration template](/packer/docs/templates/legacy_json_templates/engine) that has a single valid variable: `Flavor`, which will be the value of - `tools_upload_flavor`. By default the upload path is set to + `tools_upload_flavor`. By default, the upload path is set to `{{.Flavor}}.iso`. ~> **Note:** This setting is not used when `remote_type` is `esxi`. @@ -687,24 +687,26 @@ wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg This may be relative or absolute. If relative, the path is relative to the working directory when packer is executed. - If you are running a remote hypervisor build, the output_dir is the path on your - local machine (the machine running Packer) to which Packer will export - the vm if you have `"skip_export": false`. If you want to manage the - virtual machine's path on the remote datastore, use `remote_output_dir`. + If you are running a remote hypervisor build, the `output_dir` is the + path on your local machine (the machine running Packer) to which + Packer will export the virtual machine if you have + `"skip_export": false`. If you want to manage the virtual machine's + path on the remote datastore, use `remote_output_dir`. This directory must not exist or be empty prior to running the builder. - By default this is output-BUILDNAME where "BUILDNAME" is the name of the - build. + By default, this is `output-BUILDNAME` where `BUILDNAME` is the name of + the build. - `remote_output_directory` (string) - This is the directory on your remote hypervisor where you will save your - vm, relative to your remote_datastore. + virtual machine, relative to your remote_datastore. This option's default value is your `vm_name`, and the final path of your - vm will be vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx where + virtual machine will be + `vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx` where `$remote_datastore` and `$vm_name` match their corresponding template - options + options. For example, setting `"remote_output_directory": "path/to/subdir` will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`. diff --git a/.web-docs/components/builder/vmx/README.md b/.web-docs/components/builder/vmx/README.md index 6b1368e8..8673c9d7 100644 --- a/.web-docs/components/builder/vmx/README.md +++ b/.web-docs/components/builder/vmx/README.md @@ -53,8 +53,8 @@ JSON Example: -- `source_path` (string) - Path to the source VMX file to clone. If - remote_type is enabled then this specifies a path on the remote_host. +- `source_path` (string) - Path to the source `.vmx` file to clone. If `remote_type` is enabled + then this specifies a path on the `remote_host`. @@ -63,31 +63,31 @@ JSON Example: -- `linked` (bool) - By default Packer creates a 'full' clone of the virtual machine - specified in source_path. The resultant virtual machine is fully - independent from the parent it was cloned from. +- `linked` (bool) - By default, the plugin creates a 'full' clone of the virtual machine + specified in `source_path`. The resultant virtual machine is fully + independent of the parent it was cloned from. - Setting linked to true instead causes Packer to create the virtual - machine as a 'linked' clone. Linked clones use and require ongoing + Setting linked to true instead causes the plugin to create the virtual + machine as a linked clone. Linked clones use and require ongoing access to the disks of the parent virtual machine. The benefit of a linked clone is that the clones virtual disk is typically very much smaller than would be the case for a full clone. Additionally, the cloned virtual machine can also be created much faster. Creating a linked clone will typically only be of benefit in some advanced build - scenarios. Most users will wish to create a full clone instead. Defaults - to false. + scenarios. Most users will wish to create a full clone instead. + Defaults to `false`. -- `attach_snapshot` (string) - Default to `null/empty`. The name of an - **existing** snapshot to which the builder shall attach the VM before - starting it. If no snapshot is specified the builder will simply start the - VM from it's current state i.e. snapshot. +- `attach_snapshot` (string) - The name of an existing snapshot to which the builder shall attach the + virtual machine before powering on. If no snapshot is specified the + virtual machine is started from its current state. Default to + `null/empty`. -- `vm_name` (string) - This is the name of the VMX file for the new virtual - machine, without the file extension. By default this is packer-BUILDNAME, - where "BUILDNAME" is the name of the build. +- `vm_name` (string) - This is the name of the `.vmx` file for the virtual machine, without + the file extension. By default, this is `packer-BUILDNAME`, where + `BUILDNAME` is the name of the build. -- `snapshot_name` (string) - This is the name of the initial snapshot created after provisioning and cleanup. - if left blank, no initial snapshot will be created +- `snapshot_name` (string) - This is the name of the initial snapshot created after provisioning and + cleanup. If blank, no snapshot is created. @@ -148,7 +148,7 @@ JSON Example: -- `tools_upload_flavor` (string) - The flavor of VMware tools to upload into the virtual machine based on +- `tools_upload_flavor` (string) - The flavor of VMware Tools to upload into the virtual machine based on the guest operating system. Allowed values are `darwin` (macOS), `linux`, and `windows`. Default is empty and no version will be uploaded. @@ -156,7 +156,7 @@ JSON Example: `tools_upload_flavor` is non-empty. This is a [configuration template](/packer/docs/templates/legacy_json_templates/engine) that has a single valid variable: `Flavor`, which will be the value of - `tools_upload_flavor`. By default the upload path is set to + `tools_upload_flavor`. By default, the upload path is set to `{{.Flavor}}.iso`. ~> **Note:** This setting is not used when `remote_type` is `esxi`. @@ -459,24 +459,26 @@ wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg This may be relative or absolute. If relative, the path is relative to the working directory when packer is executed. - If you are running a remote hypervisor build, the output_dir is the path on your - local machine (the machine running Packer) to which Packer will export - the vm if you have `"skip_export": false`. If you want to manage the - virtual machine's path on the remote datastore, use `remote_output_dir`. + If you are running a remote hypervisor build, the `output_dir` is the + path on your local machine (the machine running Packer) to which + Packer will export the virtual machine if you have + `"skip_export": false`. If you want to manage the virtual machine's + path on the remote datastore, use `remote_output_dir`. This directory must not exist or be empty prior to running the builder. - By default this is output-BUILDNAME where "BUILDNAME" is the name of the - build. + By default, this is `output-BUILDNAME` where `BUILDNAME` is the name of + the build. - `remote_output_directory` (string) - This is the directory on your remote hypervisor where you will save your - vm, relative to your remote_datastore. + virtual machine, relative to your remote_datastore. This option's default value is your `vm_name`, and the final path of your - vm will be vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx where + virtual machine will be + `vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx` where `$remote_datastore` and `$vm_name` match their corresponding template - options + options. For example, setting `"remote_output_directory": "path/to/subdir` will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`. diff --git a/builder/vmware/common/driver_esxi.go b/builder/vmware/common/driver_esxi.go index f1a7e57e..8d71c69a 100644 --- a/builder/vmware/common/driver_esxi.go +++ b/builder/vmware/common/driver_esxi.go @@ -456,7 +456,7 @@ func (d *EsxiDriver) HostAddress(multistep.StateBag) (string, error) { } } - // ..unfortunately nothing was found + // If an interface is not found, return an error. return "", fmt.Errorf("error locating an interface matching host address: %v", host) } @@ -495,13 +495,12 @@ func (d *EsxiDriver) GuestAddress(multistep.StateBag) (string, error) { return "", fmt.Errorf("error matching address for guest") } - // find the MAC address according to the interface name + // Find the MAC address for the interface. result, ok := addrs[intf] if !ok { return "", fmt.Errorf("error finding MAC address for interface %s", intf) } - // ..and we're good return result, nil } @@ -509,8 +508,8 @@ func (d *EsxiDriver) VNCAddress(ctx context.Context, _ string, portMin, portMax var vncPort int // Process ports ESXi is listening on to determine which are available. - // This process uses best effort to detect which are unavailable and will - // iignore any ports listened to by only localhost. + // This process detects which are unavailable ignore any ports listened to + // by only localhost. r, err := d.esxcli("network", "ip", "connection", "list") if err != nil { err = fmt.Errorf("error retrieving network information for host: %v", err) @@ -806,7 +805,7 @@ func (d *EsxiDriver) mkdir(path string) error { } func (d *EsxiDriver) upload(dst, src string, ui packersdk.Ui) error { - // Get the size to setup the progress tracker. + // Get the size to set up the progress tracker. info, err := os.Stat(src) if err != nil { return err diff --git a/builder/vmware/common/driver_parser.go b/builder/vmware/common/driver_parser.go index 713da4a2..68f11d91 100644 --- a/builder/vmware/common/driver_parser.go +++ b/builder/vmware/common/driver_parser.go @@ -252,7 +252,7 @@ func parseDhcpConfig(in chan string) (tkGroup, error) { case ";": // If we encounter a line-terminator, then the list of tokens we've been - // aggregating are ready to be parsed. Afterwards, we can write them + // aggregating are ready to be parsed. Afterward, we can write them // to our current tree node. arg := toParameter(tokens) @@ -357,7 +357,7 @@ func tokenizeNetworkMapConfig(in chan byte) chan string { state += string(by) } - // If we made it here, then we can guarantee that the we didn't just + // If we made it here, then we can guarantee that we didn't just // process a newline. Clear this flag for the next one we find. lastnewline = false } @@ -442,7 +442,7 @@ func parseNetworkMapConfig(in chan string) (NetworkMap, error) { } } - // Go through our unsorted map, and collect all of the keys for "network". + // Go through our unsorted map, and collect all the keys for "network". result := make([]map[string]string, 0) var keys []string for k := range unsorted { @@ -461,7 +461,7 @@ func parseNetworkMapConfig(in chan string) (NetworkMap, error) { } /** higher-level parsing */ -/// parameters +// parameters type pParameter interface { repr() string } @@ -1137,8 +1137,9 @@ func ReadDhcpConfiguration(fd *os.File) (DhcpConfiguration, error) { return nil, err } - // This closure is just to the goro that follows it in recursively walking - // through all of the declarations and writing them individually to a chan. + // This closure is just to the goroutine that follows it in recursively + // walking through all the declarations and writing them individually to a + // channel. var walkDeclarations func(root pDeclaration, out chan *configDeclaration) walkDeclarations = func(root pDeclaration, out chan *configDeclaration) { @@ -1149,15 +1150,15 @@ func ReadDhcpConfiguration(fd *os.File) (DhcpConfiguration, error) { } } - // That way this goro can take each individual declaration and write it to - // a channel. + // That way this goroutine can take each individual declaration and write + // it to a channel. each := make(chan *configDeclaration) go func(out chan *configDeclaration) { walkDeclarations(*global, out) out <- nil }(each) - // For this loop to convert it into a itemized list. + // For this loop to convert it into an itemized list. var result DhcpConfiguration for decl := <-each; decl != nil; decl = <-each { result = append(result, *decl) @@ -1293,8 +1294,7 @@ func tokenizeNetworkingConfig(in chan byte) chan string { case '\t': fallthrough case ' ': - // If we receive whitespace, then this is just a write to our - // state and then we reset. + // Ignore whitespace. if len(state) == 0 { continue } @@ -1998,7 +1998,7 @@ func flattenNetworkingConfig(in chan networkingCommandEntry) NetworkingConfig { // Constructor for networking file func ReadNetworkingConfig(fd *os.File) (NetworkingConfig, error) { - // start piecing together all of the differents parts of the file and split + // start piecing together all the different parts of the file and split // it into its individual rows. fromfile := consumeFile(fd) tokenized := tokenizeNetworkingConfig(fromfile) @@ -2210,7 +2210,7 @@ func filterOutCharacters(ignore []byte, in chan byte) chan byte { // consumeOpenClosePair consumes bytes within a pair of some bytes, like parentheses, brackets, braces. // We start by reading bytes until we encounter openByte. These will be returned as -// the first parameter. Then we can enter a goro and consume bytes until we get to +// the first parameter. Then we can enter a goroutine and consume bytes until we get to // closeByte. At that point we're done, and we can exit. func consumeOpenClosePair(openByte, closeByte byte, in chan byte) ([]byte, chan byte) { result := make([]byte, 0) @@ -2226,8 +2226,8 @@ func consumeOpenClosePair(openByte, closeByte byte, in chan byte) ([]byte, chan } } - // Now we can feed input to our goro and a consumer can see what's contained - // between their requested pairs + // Now we can feed input to our goroutine and a consumer can see what's + // contained between their requested pairs. out := make(chan byte) go func(out chan byte) { by := openByte @@ -2301,11 +2301,11 @@ func readDhcpdLeaseEntry(in chan byte) (entry *dhcpLeaseEntry, err error) { macLineRe := regexp.MustCompile(`hardware\s+ethernet\s+(.+?)\s*$`) uidLineRe := regexp.MustCompile(`uid\s+(.+?)\s*$`) - /// Read up to the lease item and validate that it actually matches + // Read up to the lease item and validate that it actually matches lease, ch := consumeOpenClosePair('{', '}', in) - // If we couldn't read the lease, then this item is busted and we're prolly - // done reading the channel. + // If we couldn't read the lease, then this item is mangled and we should + // bail. if len(lease) == 0 { return nil, nil } @@ -2317,13 +2317,13 @@ func readDhcpdLeaseEntry(in chan byte) (entry *dhcpLeaseEntry, err error) { } if by, ok := <-ch; ok && by == '{' { - // If we found a lease match and we're definitely beginning a lease + // If we found a lease match, and we're definitely beginning a lease // entry, then create our storage. entry = &dhcpLeaseEntry{address: matches[1]} } else if ok { - // If we didn't see a begin brace, then this entry is mangled which - // means that we should probably bail + // If we didn't see a starting brace, then this entry is mangled which + // means that we should probably bail. return &dhcpLeaseEntry{address: matches[1]}, fmt.Errorf("missing parameters for lease entry %v", matches[1]) } else if !ok { @@ -2331,7 +2331,7 @@ func readDhcpdLeaseEntry(in chan byte) (entry *dhcpLeaseEntry, err error) { return nil, nil } - /// Now we can parse the inside of the block. + // Now we can parse the inside of the block. for insideBraces := true; insideBraces; { item, ok := consumeUntilSentinel(';', ch) item_s := string(item) @@ -2468,7 +2468,7 @@ func readAppleDhcpdLeaseEntry(in chan byte) (entry *appleDhcpLeaseEntry, err err var key, val string switch len(splittedLine) { case 0: - // should never happens as Split always returns at least 1 item + // This should never happen as Split always returns at least 1 item. fallthrough case 1: log.Printf("error parsing invalid line: `%s`", item_s) diff --git a/builder/vmware/common/driver_workstation9.go b/builder/vmware/common/driver_workstation9.go index 1a1a5c48..c18f1243 100644 --- a/builder/vmware/common/driver_workstation9.go +++ b/builder/vmware/common/driver_workstation9.go @@ -20,7 +20,7 @@ import ( // Template for the network mapper configuration file, 'netmap.conf'. // This file is used to map network devices to their respective network names. -// This template is used to generate the file if if the default file does not +// This template is used to generate the file if the default file does not // exist on the system. const netmapTemplate = ` # This file is automatically generated. diff --git a/builder/vmware/common/hw_config.go b/builder/vmware/common/hw_config.go index 5549787d..c357a747 100644 --- a/builder/vmware/common/hw_config.go +++ b/builder/vmware/common/hw_config.go @@ -55,7 +55,7 @@ type HWConfig struct { NetworkAdapterType string `mapstructure:"network_adapter_type" required:"false"` // Enable virtual sound card device. Defaults to `false`. Sound bool `mapstructure:"sound" required:"false"` - // Enable a the USB 2.0 controllers for the virtual machine. + // Enable USB 2.0 controllers for the virtual machine. // Defaults to `false`. // // ~> **Note:** To enable USB 3.0 controllers, set a `usb_xhci.present` @@ -94,7 +94,7 @@ type HWConfig struct { // the virtual machine should yield the CPU when polling the port. By // default, the builder will assume this as `FALSE`. // - // * `AUTO:(yield)` - Specifies to use auto-detection to determine the + // * `AUTO: (yield)` - Specifies to use auto-detection to determine the // serial port to use. This has one option to determine how the virtual // machine should support the serial port. // diff --git a/builder/vmware/common/output_config.go b/builder/vmware/common/output_config.go index 0efe4e62..9dca00b5 100644 --- a/builder/vmware/common/output_config.go +++ b/builder/vmware/common/output_config.go @@ -18,24 +18,26 @@ type OutputConfig struct { // This may be relative or absolute. If relative, the path is relative to // the working directory when packer is executed. // - // If you are running a remote hypervisor build, the output_dir is the path on your - // local machine (the machine running Packer) to which Packer will export - // the vm if you have `"skip_export": false`. If you want to manage the - // virtual machine's path on the remote datastore, use `remote_output_dir`. + // If you are running a remote hypervisor build, the `output_dir` is the + // path on your local machine (the machine running Packer) to which + // Packer will export the virtual machine if you have + // `"skip_export": false`. If you want to manage the virtual machine's + // path on the remote datastore, use `remote_output_dir`. // // This directory must not exist or be empty prior to running // the builder. // - // By default this is output-BUILDNAME where "BUILDNAME" is the name of the - // build. + // By default, this is `output-BUILDNAME` where `BUILDNAME` is the name of + // the build. OutputDir string `mapstructure:"output_directory" required:"false"` // This is the directory on your remote hypervisor where you will save your - // vm, relative to your remote_datastore. + // virtual machine, relative to your remote_datastore. // // This option's default value is your `vm_name`, and the final path of your - // vm will be vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx where - // `$remote_datastore` and `$vm_name` match their corresponding template - // options + // virtual machine will be + // `vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx` where + //`$remote_datastore` and `$vm_name` match their corresponding template + // options. // // For example, setting `"remote_output_directory": "path/to/subdir` // will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`. diff --git a/builder/vmware/common/ssh.go b/builder/vmware/common/ssh.go index 4e908c4e..537c14b7 100644 --- a/builder/vmware/common/ssh.go +++ b/builder/vmware/common/ssh.go @@ -25,7 +25,7 @@ func CommHost(config *SSHConfig) func(multistep.StateBag) (string, error) { } // Snag the port from the communicator config. This way we can use it - // to perform a 3-way handshake with all of the hosts we suspect in + // to perform a 3-way handshake with all the hosts we suspect in // order to determine which one of the hosts is the correct one. port := comm.Port() diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go index 3f0ace70..bdc24c44 100644 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -60,7 +60,7 @@ func (s StepCleanVMX) Run(ctx context.Context, state multistep.StateBag) multist // attribute that begins with "cdrom-" ui.Message(fmt.Sprintf("Detaching ISO from CD-ROM device %s...", device)) - // Simply turn the CDROM device into a native cdrom instead of an iso + // Simply turn the CD-ROM device into a native cdrom instead of an iso vmxData[fmt.Sprintf("%s.devicetype", device)] = "cdrom-raw" vmxData[fmt.Sprintf("%s.filename", device)] = "auto detect" vmxData[fmt.Sprintf("%s.clientdevice", device)] = "TRUE" diff --git a/builder/vmware/common/step_configure_vmx.go b/builder/vmware/common/step_configure_vmx.go index 639b8602..b0214fd7 100644 --- a/builder/vmware/common/step_configure_vmx.go +++ b/builder/vmware/common/step_configure_vmx.go @@ -168,10 +168,6 @@ func DefaultDiskAndCDROMTypes(diskAdapterType string, cdromAdapterType string) D CDROMType: "ide", CDROMType_PrimarySecondary: "0", } - /// Use the disk adapter type that the user specified to tweak the .vmx - // Also sync the cdrom adapter type according to what's common for that disk type. - // XXX: If the cdrom type is modified, make sure to update common/step_clean_vmx.go - // so that it will regex the correct cdrom device for removal. diskAdapterType = strings.ToLower(diskAdapterType) switch diskAdapterType { case "ide": @@ -200,7 +196,7 @@ func DefaultDiskAndCDROMTypes(diskAdapterType string, cdromAdapterType string) D diskData.CDROMType_PrimarySecondary = "0" } - /// Handle the cdrom adapter type. If the disk adapter type and the + // Handle the cdrom adapter type. If the disk adapter type and the // cdrom adapter type are the same, then ensure that the cdrom is the // secondary device on whatever bus the disk adapter is on. if cdromAdapterType == "" { diff --git a/builder/vmware/common/step_export_test.go b/builder/vmware/common/step_export_test.go index e4720a56..2adc541f 100644 --- a/builder/vmware/common/step_export_test.go +++ b/builder/vmware/common/step_export_test.go @@ -60,8 +60,8 @@ func TestStepExport_ReturnIfSkip(t *testing.T) { } func TestStepExport_localArgs(t *testing.T) { - // even though we aren't overriding the remote args and they are present, - // test shouldn't use them since remoteType is not set to esx. + // Although the remote arguments are available and not being overridden, + // the test should ignore them because remoteType is not specified as 'esx'. state := testState(t) driverConfig := &DriverConfig{} state.Put("driverConfig", driverConfig) @@ -95,8 +95,8 @@ func TestStepExport_localArgs(t *testing.T) { } func TestStepExport_localArgsExportOutputPath(t *testing.T) { - // even though we aren't overriding the remote args and they are present, - // test shouldn't use them since remoteType is not set to esx. + // Although the remote arguments are available and not being overridden, + // the test should ignore them because remoteType is not specified as 'esx'. state := testState(t) driverConfig := &DriverConfig{} state.Put("driverConfig", driverConfig) @@ -131,8 +131,8 @@ func TestStepExport_localArgsExportOutputPath(t *testing.T) { } func TestStepExport_localArgs_OvftoolOptions(t *testing.T) { - // even though we aren't overriding the remote args and they are present, - // test shouldn't use them since remoteType is not set to esx. + // Although the remote arguments are available and not being overridden, + // the test should ignore them because remoteType is not specified as 'esx'. state := testState(t) driverConfig := &DriverConfig{} state.Put("driverConfig", driverConfig) @@ -167,8 +167,8 @@ func TestStepExport_localArgs_OvftoolOptions(t *testing.T) { } func TestStepExport_RemoteArgs(t *testing.T) { - // Even though we aren't overriding the remote args and they are present, - // test shouldn't use them since remoteType is not set to esx. + // Although the remote arguments are available and not being overridden, + // the test should ignore them because remoteType is not specified as 'esx'. state := remoteExportTestState(t) step := new(StepExport) @@ -201,8 +201,8 @@ func TestStepExport_RemoteArgs(t *testing.T) { } func TestStepExport_RemoteArgsWithExportOutputPath(t *testing.T) { - // Even though we aren't overriding the remote args and they are present, - // test shouldn't use them since remoteType is not set to esx. + // Although the remote arguments are available and not being overridden, + // the test should ignore them because remoteType is not specified as 'esx'. state := remoteExportTestState(t) state.Put("export_output_path", "local_output") step := new(StepExport) diff --git a/builder/vmware/common/step_output_dir.go b/builder/vmware/common/step_output_dir.go index 9bcd1494..b33e7274 100644 --- a/builder/vmware/common/step_output_dir.go +++ b/builder/vmware/common/step_output_dir.go @@ -13,9 +13,8 @@ import ( packersdk "github.com/hashicorp/packer-plugin-sdk/packer" ) -// StepOutputDir sets up the output directory by creating it if it does -// not exist, deleting it if it does exist and we're forcing, and cleaning -// it up when we're done with it. +// StepOutputDir manages the output directory configuration for a build step, +// including forceful directory overwrite. type StepOutputDir struct { Force bool diff --git a/builder/vmware/common/step_output_dir_test.go b/builder/vmware/common/step_output_dir_test.go index a7729ff6..8409fa78 100644 --- a/builder/vmware/common/step_output_dir_test.go +++ b/builder/vmware/common/step_output_dir_test.go @@ -194,7 +194,6 @@ func TestStepOutputDir_halt(t *testing.T) { } func TestStepOutputDir_Remote(t *testing.T) { - // Tests remote driver state := testState(t) driver := new(RemoteDriverMock) state.Put("driver", driver) @@ -210,15 +209,16 @@ func TestStepOutputDir_Remote(t *testing.T) { VMName: "testVM", RemoteType: "esxi", } - // Delete the test output directory when done + + // Delete the test output directory when complete. defer os.RemoveAll(td) - // Test the run + // Test the run. if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } - // We don't pre-create the output path for export but we do set it in state. + // Store the output path in state. exportOutputPath := state.Get("export_output_path").(string) if exportOutputPath != td { t.Fatalf("err: should have set export_output_path!") diff --git a/builder/vmware/common/step_remote_upload.go b/builder/vmware/common/step_remote_upload.go index 3b77f890..f1a648f3 100644 --- a/builder/vmware/common/step_remote_upload.go +++ b/builder/vmware/common/step_remote_upload.go @@ -12,8 +12,9 @@ import ( packersdk "github.com/hashicorp/packer-plugin-sdk/packer" ) -// stepRemoteUpload uploads some thing from the state bag to a remote driver -// (if it can) and stores that new remote path into the state bag. +// stepRemoteUpload uploads a file from the state bag to the remote +// machine. It will upload the file to the remote machine and then +// store the new path in the state bag. type StepRemoteUpload struct { Key string Message string diff --git a/builder/vmware/common/step_run.go b/builder/vmware/common/step_run.go index 06e1fc50..1b17f19a 100644 --- a/builder/vmware/common/step_run.go +++ b/builder/vmware/common/step_run.go @@ -61,8 +61,7 @@ func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S return multistep.ActionHalt } - // instance_id is the generic term used so that users can have access to the - // instance id inside of the provisioners, used in step_provision. + // Set the instance ID so that we can use it in the provisioners. state.Put("instance_id", vmxPath) return multistep.ActionContinue diff --git a/builder/vmware/common/step_shutdown.go b/builder/vmware/common/step_shutdown.go index 7b3fd88f..4406eec9 100644 --- a/builder/vmware/common/step_shutdown.go +++ b/builder/vmware/common/step_shutdown.go @@ -122,7 +122,7 @@ LockWaitLoop: if !s.Testing { // Windows takes a while to yield control of the files when the // process is exiting. Ubuntu and macOS will yield control of the files - // but the the hypervisor may overwrite the VMX cleanup steps that run + // but the hypervisor may overwrite the VMX cleanup steps that run // after this, so we wait to ensure hypervisor has exited and flushed the // VMX. diff --git a/builder/vmware/common/step_vnc_connect.go b/builder/vmware/common/step_vnc_connect.go index 70b28c73..9ccf4b52 100644 --- a/builder/vmware/common/step_vnc_connect.go +++ b/builder/vmware/common/step_vnc_connect.go @@ -102,7 +102,7 @@ func (s *StepVNCConnect) ConnectVNCOverWebsocketClient(state multistep.StateBag) } nc.PayloadType = websocket.BinaryFrame - // Setup the VNC connection over the websocket + // Set up the VNC connection over the websocket. ccconfig := &vnc.ClientConfig{ Auth: []vnc.ClientAuth{new(vnc.ClientAuthNone)}, Exclusive: false, diff --git a/builder/vmware/common/tools_config.go b/builder/vmware/common/tools_config.go index 64030af8..12a8c335 100644 --- a/builder/vmware/common/tools_config.go +++ b/builder/vmware/common/tools_config.go @@ -26,7 +26,7 @@ const ( var allowedToolsFlavorValues = []string{ToolsFlavorMacOS, ToolsFlavorLinux, ToolsFlavorWindows} type ToolsConfig struct { - // The flavor of VMware tools to upload into the virtual machine based on + // The flavor of VMware Tools to upload into the virtual machine based on // the guest operating system. Allowed values are `darwin` (macOS), `linux`, // and `windows`. Default is empty and no version will be uploaded. ToolsUploadFlavor string `mapstructure:"tools_upload_flavor" required:"false"` @@ -34,7 +34,7 @@ type ToolsConfig struct { // `tools_upload_flavor` is non-empty. This is a [configuration // template](/packer/docs/templates/legacy_json_templates/engine) that has a // single valid variable: `Flavor`, which will be the value of - // `tools_upload_flavor`. By default the upload path is set to + // `tools_upload_flavor`. By default, the upload path is set to // `{{.Flavor}}.iso`. // // ~> **Note:** This setting is not used when `remote_type` is `esxi`. diff --git a/builder/vmware/common/vmx.go b/builder/vmware/common/vmx.go index 794dd79f..22c2baeb 100644 --- a/builder/vmware/common/vmx.go +++ b/builder/vmware/common/vmx.go @@ -52,7 +52,7 @@ func EncodeVMX(contents map[string]string) string { ".virtualssd", } - // a list of VMX key fragments that are case sensitive + // a list of VMX key fragments that are case-sensitive // fragments are used to cover multiples (i.e. multiple disks) caseSensitive := []string{ ".virtualSSD", @@ -69,7 +69,7 @@ func EncodeVMX(contents map[string]string) string { } } key := k - // case sensitive key fragments + // Case-sensitive key fragments. for _, c := range caseSensitive { key = strings.Replace(key, strings.ToLower(c), c, 1) } diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index fd859818..51e0bd1a 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -38,13 +38,12 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) if err != nil { return nil, fmt.Errorf("failed creating driver : %s", err) } - // Before we get deep into the build, make sure ovftool is present and - // credentials are valid, if we're going to use ovftool. + if err := driver.VerifyOvfTool(b.config.SkipExport, b.config.SkipValidateCredentials); err != nil { return nil, err } - // Setup the state bag + // Set up the state bag. state := new(multistep.BasicStateBag) state.Put("config", &b.config) state.Put("debug", b.config.PackerDebug) @@ -203,16 +202,13 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, } - // Run! b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) - // If there was an error, return that if rawErr, ok := state.GetOk("error"); ok { return nil, rawErr.(error) } - // If we were interrupted or cancelled, then just exit. if _, ok := state.GetOk(multistep.StateCancelled); ok { return nil, errors.New("build was cancelled") } @@ -221,7 +217,6 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) return nil, errors.New("build was halted") } - // Compile the artifact list exportOutputPath := state.Get("export_output_path").(string) // set in StepOutputDir return vmwcommon.NewArtifact(b.config.RemoteType, b.config.Format, exportOutputPath, b.config.VMName, b.config.SkipExport, b.config.KeepRegistered, state) diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 0c692967..a74b3de7 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -124,7 +124,7 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi // Extra VMDKs after primary disk and CDROM. unitSkip := 2 - // If the CDROM is on a different bus we only have to skip the primary disk's unit. + // If the CD-ROM is on a different bus we only have to skip the primary disk's unit. if diskAndCDConfigData.CDROMType != diskAndCDConfigData.DiskType { unitSkip = 1 } @@ -193,7 +193,7 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi templateData.DiskAndCDConfigData = diskAndCDConfigData - /// Now that we figured out the CDROM device to add, store it + /// Now that we figured out the CD-ROM device to add, store it /// to the list of temporary build devices in our statebag tmpBuildDevices := state.Get("temporaryDevices").([]string) tmpCdromDevice := fmt.Sprintf("%s0:%s", templateData.CDROMType, templateData.CDROMType_PrimarySecondary) @@ -378,8 +378,6 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi vmxDir := config.OutputDir if config.RemoteType != "" { - // For remote builds, we just put the VMX in a temporary - // directory since it just gets uploaded anyways. vmxDir, err = tmp.Dir("vmw-iso") if err != nil { err := fmt.Errorf("error preparing VMX template: %s", err) diff --git a/builder/vmware/vmx/config.go b/builder/vmware/vmx/config.go index c5b830be..9fb9581a 100644 --- a/builder/vmware/vmx/config.go +++ b/builder/vmware/vmx/config.go @@ -36,34 +36,34 @@ type Config struct { vmwcommon.VMXConfig `mapstructure:",squash"` vmwcommon.ExportConfig `mapstructure:",squash"` vmwcommon.DiskConfig `mapstructure:",squash"` - // By default Packer creates a 'full' clone of the virtual machine - // specified in source_path. The resultant virtual machine is fully - // independent from the parent it was cloned from. + // By default, the plugin creates a 'full' clone of the virtual machine + // specified in `source_path`. The resultant virtual machine is fully + // independent of the parent it was cloned from. // - // Setting linked to true instead causes Packer to create the virtual - // machine as a 'linked' clone. Linked clones use and require ongoing + // Setting linked to true instead causes the plugin to create the virtual + // machine as a linked clone. Linked clones use and require ongoing // access to the disks of the parent virtual machine. The benefit of a // linked clone is that the clones virtual disk is typically very much // smaller than would be the case for a full clone. Additionally, the // cloned virtual machine can also be created much faster. Creating a // linked clone will typically only be of benefit in some advanced build - // scenarios. Most users will wish to create a full clone instead. Defaults - // to false. + // scenarios. Most users will wish to create a full clone instead. + // Defaults to `false`. Linked bool `mapstructure:"linked" required:"false"` - // Default to `null/empty`. The name of an - // **existing** snapshot to which the builder shall attach the VM before - // starting it. If no snapshot is specified the builder will simply start the - // VM from it's current state i.e. snapshot. + // The name of an existing snapshot to which the builder shall attach the + // virtual machine before powering on. If no snapshot is specified the + // virtual machine is started from its current state. Default to + // `null/empty`. AttachSnapshot string `mapstructure:"attach_snapshot" required:"false"` - // Path to the source VMX file to clone. If - // remote_type is enabled then this specifies a path on the remote_host. + // Path to the source `.vmx` file to clone. If `remote_type` is enabled + // then this specifies a path on the `remote_host`. SourcePath string `mapstructure:"source_path" required:"true"` - // This is the name of the VMX file for the new virtual - // machine, without the file extension. By default this is packer-BUILDNAME, - // where "BUILDNAME" is the name of the build. + // This is the name of the `.vmx` file for the virtual machine, without + // the file extension. By default, this is `packer-BUILDNAME`, where + // `BUILDNAME` is the name of the build. VMName string `mapstructure:"vm_name" required:"false"` - // This is the name of the initial snapshot created after provisioning and cleanup. - // if left blank, no initial snapshot will be created + // This is the name of the initial snapshot created after provisioning and + // cleanup. If blank, no snapshot is created. SnapshotName string `mapstructure:"snapshot_name" required:"false"` ctx interpolate.Context diff --git a/docs-partials/builder/vmware/common/HWConfig-not-required.mdx b/docs-partials/builder/vmware/common/HWConfig-not-required.mdx index 631c23b4..8c59a573 100644 --- a/docs-partials/builder/vmware/common/HWConfig-not-required.mdx +++ b/docs-partials/builder/vmware/common/HWConfig-not-required.mdx @@ -28,7 +28,7 @@ - `sound` (bool) - Enable virtual sound card device. Defaults to `false`. -- `usb` (bool) - Enable a the USB 2.0 controllers for the virtual machine. +- `usb` (bool) - Enable USB 2.0 controllers for the virtual machine. Defaults to `false`. ~> **Note:** To enable USB 3.0 controllers, set a `usb_xhci.present` @@ -67,7 +67,7 @@ the virtual machine should yield the CPU when polling the port. By default, the builder will assume this as `FALSE`. - * `AUTO:(yield)` - Specifies to use auto-detection to determine the + * `AUTO: (yield)` - Specifies to use auto-detection to determine the serial port to use. This has one option to determine how the virtual machine should support the serial port. diff --git a/docs-partials/builder/vmware/common/OutputConfig-not-required.mdx b/docs-partials/builder/vmware/common/OutputConfig-not-required.mdx index 634dbeb0..342eb3d4 100644 --- a/docs-partials/builder/vmware/common/OutputConfig-not-required.mdx +++ b/docs-partials/builder/vmware/common/OutputConfig-not-required.mdx @@ -5,24 +5,26 @@ This may be relative or absolute. If relative, the path is relative to the working directory when packer is executed. - If you are running a remote hypervisor build, the output_dir is the path on your - local machine (the machine running Packer) to which Packer will export - the vm if you have `"skip_export": false`. If you want to manage the - virtual machine's path on the remote datastore, use `remote_output_dir`. + If you are running a remote hypervisor build, the `output_dir` is the + path on your local machine (the machine running Packer) to which + Packer will export the virtual machine if you have + `"skip_export": false`. If you want to manage the virtual machine's + path on the remote datastore, use `remote_output_dir`. This directory must not exist or be empty prior to running the builder. - By default this is output-BUILDNAME where "BUILDNAME" is the name of the - build. + By default, this is `output-BUILDNAME` where `BUILDNAME` is the name of + the build. - `remote_output_directory` (string) - This is the directory on your remote hypervisor where you will save your - vm, relative to your remote_datastore. + virtual machine, relative to your remote_datastore. This option's default value is your `vm_name`, and the final path of your - vm will be vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx where + virtual machine will be + `vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx` where `$remote_datastore` and `$vm_name` match their corresponding template - options + options. For example, setting `"remote_output_directory": "path/to/subdir` will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`. diff --git a/docs-partials/builder/vmware/common/ToolsConfig-not-required.mdx b/docs-partials/builder/vmware/common/ToolsConfig-not-required.mdx index 61639f30..da9cff5b 100644 --- a/docs-partials/builder/vmware/common/ToolsConfig-not-required.mdx +++ b/docs-partials/builder/vmware/common/ToolsConfig-not-required.mdx @@ -1,6 +1,6 @@ -- `tools_upload_flavor` (string) - The flavor of VMware tools to upload into the virtual machine based on +- `tools_upload_flavor` (string) - The flavor of VMware Tools to upload into the virtual machine based on the guest operating system. Allowed values are `darwin` (macOS), `linux`, and `windows`. Default is empty and no version will be uploaded. @@ -8,7 +8,7 @@ `tools_upload_flavor` is non-empty. This is a [configuration template](/packer/docs/templates/legacy_json_templates/engine) that has a single valid variable: `Flavor`, which will be the value of - `tools_upload_flavor`. By default the upload path is set to + `tools_upload_flavor`. By default, the upload path is set to `{{.Flavor}}.iso`. ~> **Note:** This setting is not used when `remote_type` is `esxi`. diff --git a/docs-partials/builder/vmware/vmx/Config-not-required.mdx b/docs-partials/builder/vmware/vmx/Config-not-required.mdx index 1bff27cc..b513627c 100644 --- a/docs-partials/builder/vmware/vmx/Config-not-required.mdx +++ b/docs-partials/builder/vmware/vmx/Config-not-required.mdx @@ -1,29 +1,29 @@ -- `linked` (bool) - By default Packer creates a 'full' clone of the virtual machine - specified in source_path. The resultant virtual machine is fully - independent from the parent it was cloned from. +- `linked` (bool) - By default, the plugin creates a 'full' clone of the virtual machine + specified in `source_path`. The resultant virtual machine is fully + independent of the parent it was cloned from. - Setting linked to true instead causes Packer to create the virtual - machine as a 'linked' clone. Linked clones use and require ongoing + Setting linked to true instead causes the plugin to create the virtual + machine as a linked clone. Linked clones use and require ongoing access to the disks of the parent virtual machine. The benefit of a linked clone is that the clones virtual disk is typically very much smaller than would be the case for a full clone. Additionally, the cloned virtual machine can also be created much faster. Creating a linked clone will typically only be of benefit in some advanced build - scenarios. Most users will wish to create a full clone instead. Defaults - to false. + scenarios. Most users will wish to create a full clone instead. + Defaults to `false`. -- `attach_snapshot` (string) - Default to `null/empty`. The name of an - **existing** snapshot to which the builder shall attach the VM before - starting it. If no snapshot is specified the builder will simply start the - VM from it's current state i.e. snapshot. +- `attach_snapshot` (string) - The name of an existing snapshot to which the builder shall attach the + virtual machine before powering on. If no snapshot is specified the + virtual machine is started from its current state. Default to + `null/empty`. -- `vm_name` (string) - This is the name of the VMX file for the new virtual - machine, without the file extension. By default this is packer-BUILDNAME, - where "BUILDNAME" is the name of the build. +- `vm_name` (string) - This is the name of the `.vmx` file for the virtual machine, without + the file extension. By default, this is `packer-BUILDNAME`, where + `BUILDNAME` is the name of the build. -- `snapshot_name` (string) - This is the name of the initial snapshot created after provisioning and cleanup. - if left blank, no initial snapshot will be created +- `snapshot_name` (string) - This is the name of the initial snapshot created after provisioning and + cleanup. If blank, no snapshot is created. diff --git a/docs-partials/builder/vmware/vmx/Config-required.mdx b/docs-partials/builder/vmware/vmx/Config-required.mdx index acef042c..e2e57934 100644 --- a/docs-partials/builder/vmware/vmx/Config-required.mdx +++ b/docs-partials/builder/vmware/vmx/Config-required.mdx @@ -1,6 +1,6 @@ -- `source_path` (string) - Path to the source VMX file to clone. If - remote_type is enabled then this specifies a path on the remote_host. +- `source_path` (string) - Path to the source `.vmx` file to clone. If `remote_type` is enabled + then this specifies a path on the `remote_host`.