From 88f8feecfe09195ffec6dcd3f20bc67fc61e6afd Mon Sep 17 00:00:00 2001 From: Sylvia Moss Date: Mon, 19 Apr 2021 14:28:48 +0200 Subject: [PATCH] Extract vmware plugin (#10920) --- builder/vmware/common/artifact_test.go | 11 - builder/vmware/common/driver_config_test.go | 84 -- builder/vmware/common/driver_esx5_test.go | 104 -- builder/vmware/common/driver_mock_test.go | 9 - builder/vmware/common/driver_parser_test.go | 1288 ----------------- .../common/driver_workstation_unix_test.go | 15 - builder/vmware/common/hw_config_test.go | 315 ---- builder/vmware/common/output_config_test.go | 25 - .../vmware/common/output_dir_local_test.go | 9 - .../vmware/common/remote_driver_mock_test.go | 10 - builder/vmware/common/run_config_test.go | 119 -- builder/vmware/common/ssh_config_test.go | 111 -- builder/vmware/common/ssh_test.go | 29 - builder/vmware/common/step_clean_vmx_test.go | 219 --- .../vmware/common/step_compact_disk_test.go | 62 - .../vmware/common/step_configure_vmx_test.go | 379 ----- .../vmware/common/step_configure_vnc_test.go | 25 - .../vmware/common/step_create_disks_test.go | 144 -- builder/vmware/common/step_export_test.go | 233 --- .../common/step_http_ip_discover_test.go | 34 - builder/vmware/common/step_output_dir_test.go | 224 --- .../vmware/common/step_prepare_tools_test.go | 178 --- builder/vmware/common/step_register_test.go | 94 -- .../vmware/common/step_remote_upload_test.go | 40 - builder/vmware/common/step_run_test.go | 83 -- builder/vmware/common/step_shutdown_test.go | 205 --- .../common/step_suppress_messages_test.go | 37 - builder/vmware/common/step_test.go | 20 - .../testdata/apple-dhcpd-example.leases | 40 - .../vmware/common/testdata/dhcpd-example.conf | 20 - .../common/testdata/dhcpd-example.leases | 32 - .../common/testdata/netmap-example.conf | 11 - .../vmware/common/testdata/networking-example | 19 - builder/vmware/common/tools_config_test.go | 65 - builder/vmware/common/vmx_config_test.go | 24 - builder/vmware/common/vmx_test.go | 46 - builder/vmware/iso/builder_acc_test.go | 42 - builder/vmware/iso/builder_test.go | 651 --------- builder/vmware/iso/step_create_vmx_test.go | 339 ----- builder/vmware/iso/testdata/http/preseed.cfg | 42 - builder/vmware/iso/testdata/minimal.json | 30 - builder/vmware/version/version.go | 13 - builder/vmware/vmx/builder_test.go | 68 - builder/vmware/vmx/config_test.go | 177 --- builder/vmware/vmx/step_clone_vmx_test.go | 104 -- builder/vmware/vmx/step_test.go | 20 - command/plugin.go | 4 - command/vendored_plugins.go | 4 + go.mod | 10 +- go.sum | 24 +- .../hashicorp/packer-plugin-vmware/LICENSE | 373 +++++ .../builder}/vmware/common/artifact.go | 0 .../builder}/vmware/common/disk_config.go | 0 .../builder}/vmware/common/driver.go | 2 +- .../builder}/vmware/common/driver_config.go | 0 .../builder}/vmware/common/driver_esx5.go | 4 +- .../builder}/vmware/common/driver_fusion5.go | 0 .../builder}/vmware/common/driver_fusion6.go | 0 .../builder}/vmware/common/driver_mock.go | 0 .../builder}/vmware/common/driver_parser.go | 24 +- .../builder}/vmware/common/driver_player5.go | 0 .../vmware/common/driver_player5_windows.go | 0 .../builder}/vmware/common/driver_player6.go | 0 .../vmware/common/driver_player6_windows.go | 0 .../vmware/common/driver_player_unix.go | 0 .../vmware/common/driver_workstation10.go | 0 .../common/driver_workstation10_windows.go | 0 .../vmware/common/driver_workstation9.go | 0 .../common/driver_workstation9_windows.go | 0 .../vmware/common/driver_workstation_unix.go | 0 .../builder}/vmware/common/export_config.go | 0 .../vmware/common/host_ip_ifconfig.go | 0 .../builder}/vmware/common/hw_config.go | 0 .../builder}/vmware/common/output_config.go | 0 .../builder}/vmware/common/output_dir.go | 0 .../vmware/common/output_dir_local.go | 0 .../builder}/vmware/common/remote_driver.go | 0 .../vmware/common/remote_driver_mock.go | 0 .../builder}/vmware/common/run_config.go | 0 .../builder}/vmware/common/ssh.go | 0 .../builder}/vmware/common/ssh_config.go | 0 .../vmware/common/step_clean_files.go | 0 .../builder}/vmware/common/step_clean_vmx.go | 0 .../vmware/common/step_compact_disk.go | 0 .../vmware/common/step_configure_vmx.go | 0 .../vmware/common/step_configure_vnc.go | 0 .../vmware/common/step_create_disks.go | 0 .../builder}/vmware/common/step_export.go | 0 .../vmware/common/step_http_ip_discover.go | 0 .../builder}/vmware/common/step_output_dir.go | 2 +- .../vmware/common/step_prepare_tools.go | 0 .../builder}/vmware/common/step_register.go | 2 +- .../vmware/common/step_remote_upload.go | 0 .../builder}/vmware/common/step_run.go | 0 .../builder}/vmware/common/step_shutdown.go | 0 .../vmware/common/step_suppress_messages.go | 0 .../vmware/common/step_upload_tools.go | 0 .../builder}/vmware/common/step_upload_vmx.go | 0 .../vmware/common/step_vnc_boot_command.go | 0 .../vmware/common/step_vnc_connect.go | 0 .../builder}/vmware/common/tools_config.go | 0 .../builder}/vmware/common/vmx.go | 0 .../builder}/vmware/common/vmx_config.go | 0 .../builder}/vmware/iso/builder.go | 2 +- .../builder}/vmware/iso/config.go | 2 +- .../builder}/vmware/iso/config.hcl2spec.go | 0 .../builder}/vmware/iso/step_create_vmx.go | 10 +- .../builder}/vmware/vmx/builder.go | 2 +- .../builder}/vmware/vmx/config.go | 2 +- .../builder}/vmware/vmx/config.hcl2spec.go | 0 .../builder}/vmware/vmx/step_clone_vmx.go | 2 +- .../builder/vsphere/clone/config.go | 4 +- .../builder/vsphere/clone/config.hcl2spec.go | 2 +- .../builder/vsphere/clone/step_clone.go | 4 +- .../vsphere/clone/step_clone.hcl2spec.go | 2 +- .../builder/vsphere/clone/step_customize.go | 4 +- .../vsphere/clone/step_customize.hcl2spec.go | 2 +- .../builder/vsphere/common/config_location.go | 4 +- .../common/config_location.hcl2spec.go | 2 +- .../builder/vsphere/common/output_config.go | 4 +- .../vsphere/common/output_config.hcl2spec.go | 2 +- .../builder/vsphere/common/step_add_cdrom.go | 4 +- .../vsphere/common/step_add_cdrom.hcl2spec.go | 2 +- .../builder/vsphere/common/step_add_floppy.go | 4 +- .../common/step_add_floppy.hcl2spec.go | 2 +- .../vsphere/common/step_boot_command.go | 2 +- .../vsphere/common/step_config_params.go | 4 +- .../common/step_config_params.hcl2spec.go | 2 +- .../builder/vsphere/common/step_connect.go | 4 +- .../vsphere/common/step_connect.hcl2spec.go | 2 +- .../builder/vsphere/common/step_export.go | 4 +- .../vsphere/common/step_export.hcl2spec.go | 2 +- .../builder/vsphere/common/step_hardware.go | 4 +- .../vsphere/common/step_hardware.hcl2spec.go | 2 +- .../common/step_import_to_content_library.go | 4 +- ...step_import_to_content_library.hcl2spec.go | 2 +- .../vsphere/common/step_remove_cdrom.go | 4 +- .../common/step_remove_cdrom.hcl2spec.go | 2 +- .../builder/vsphere/common/step_run.go | 4 +- .../vsphere/common/step_run.hcl2spec.go | 2 +- .../builder/vsphere/common/step_shutdown.go | 4 +- .../vsphere/common/step_shutdown.hcl2spec.go | 2 +- .../vsphere/common/step_wait_for_ip.go | 4 +- .../common/step_wait_for_ip.hcl2spec.go | 2 +- .../builder/vsphere/common/storage_config.go | 4 +- .../vsphere/common/storage_config.hcl2spec.go | 2 +- .../builder/vsphere/iso/config.go | 4 +- .../builder/vsphere/iso/config.hcl2spec.go | 2 +- .../builder/vsphere/iso/step_create.go | 4 +- .../vsphere/iso/step_create.hcl2spec.go | 2 +- .../x/crypto/chacha20/chacha_arm64.go | 1 + .../x/crypto/chacha20/chacha_noasm.go | 1 + .../x/crypto/chacha20/chacha_ppc64le.go | 1 + .../x/crypto/chacha20/chacha_s390x.go | 1 + .../x/crypto/curve25519/curve25519_amd64.go | 1 + .../x/crypto/curve25519/curve25519_noasm.go | 1 + vendor/golang.org/x/crypto/ed25519/ed25519.go | 1 + .../x/crypto/ed25519/ed25519_go113.go | 1 + .../x/crypto/internal/subtle/aliasing.go | 1 + .../crypto/internal/subtle/aliasing_purego.go | 1 + .../x/crypto/poly1305/bits_compat.go | 1 + .../x/crypto/poly1305/bits_go1.13.go | 1 + .../golang.org/x/crypto/poly1305/mac_noasm.go | 1 + .../golang.org/x/crypto/poly1305/sum_amd64.go | 1 + .../x/crypto/poly1305/sum_ppc64le.go | 1 + .../golang.org/x/crypto/poly1305/sum_s390x.go | 1 + vendor/golang.org/x/net/http2/Dockerfile | 2 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 3 +- .../x/sys/unix/zerrors_darwin_amd64.go | 25 + .../x/sys/unix/zerrors_darwin_arm64.go | 25 + .../x/sys/unix/zerrors_freebsd_arm.go | 9 + vendor/golang.org/x/sys/unix/zerrors_linux.go | 4 + .../x/sys/unix/zerrors_zos_s390x.go | 1 + .../x/text/internal/language/language.go | 90 +- .../x/text/internal/language/parse.go | 28 +- vendor/golang.org/x/text/language/go1_1.go | 1 + vendor/golang.org/x/text/language/go1_2.go | 1 + vendor/golang.org/x/text/language/language.go | 4 + vendor/golang.org/x/text/language/tables.go | 8 +- .../x/text/secure/bidirule/bidirule10.0.0.go | 1 + .../x/text/secure/bidirule/bidirule9.0.0.go | 1 + .../x/text/unicode/bidi/tables10.0.0.go | 1 + .../x/text/unicode/bidi/tables11.0.0.go | 1 + .../x/text/unicode/bidi/tables12.0.0.go | 1 + .../x/text/unicode/bidi/tables13.0.0.go | 1 + .../x/text/unicode/bidi/tables9.0.0.go | 1 + .../x/text/unicode/norm/tables10.0.0.go | 1 + .../x/text/unicode/norm/tables11.0.0.go | 1 + .../x/text/unicode/norm/tables12.0.0.go | 1 + .../x/text/unicode/norm/tables13.0.0.go | 1 + .../x/text/unicode/norm/tables9.0.0.go | 1 + vendor/modules.txt | 16 +- .../content/docs/builders/vmware/index.mdx | 27 - website/content/docs/builders/vmware/iso.mdx | 294 ---- website/content/docs/builders/vmware/vmx.mdx | 239 --- .../vmware/common/DiskConfig-not-required.mdx | 47 - .../common/DriverConfig-not-required.mdx | 42 - .../common/ExportConfig-not-required.mdx | 37 - .../vmware/common/HWConfig-not-required.mdx | 91 -- .../common/OutputConfig-not-required.mdx | 36 - .../builder/vmware/common/ParallelUnion.mdx | 5 - .../vmware/common/RunConfig-not-required.mdx | 39 - .../builder/vmware/common/RunConfig.mdx | 5 - .../vmware/common/SerialConfigPipe.mdx | 5 - .../common/ToolsConfig-not-required.mdx | 18 - .../vmware/common/VMXConfig-not-required.mdx | 24 - .../vmware/iso/Config-not-required.mdx | 42 - .../vmware/vmx/Config-not-required.mdx | 26 - .../builder/vmware/vmx/Config-required.mdx | 6 - .../partials/builder/vmware/vmx/Config.mdx | 5 - .../building_on_remote_vsphere_hypervisor.mdx | 66 - website/data/docs-nav-data.json | 17 - website/data/docs-remote-plugins.json | 6 + 213 files changed, 656 insertions(+), 7100 deletions(-) delete mode 100644 builder/vmware/common/artifact_test.go delete mode 100644 builder/vmware/common/driver_config_test.go delete mode 100644 builder/vmware/common/driver_esx5_test.go delete mode 100644 builder/vmware/common/driver_mock_test.go delete mode 100644 builder/vmware/common/driver_parser_test.go delete mode 100644 builder/vmware/common/driver_workstation_unix_test.go delete mode 100644 builder/vmware/common/hw_config_test.go delete mode 100644 builder/vmware/common/output_config_test.go delete mode 100644 builder/vmware/common/output_dir_local_test.go delete mode 100644 builder/vmware/common/remote_driver_mock_test.go delete mode 100644 builder/vmware/common/run_config_test.go delete mode 100644 builder/vmware/common/ssh_config_test.go delete mode 100644 builder/vmware/common/ssh_test.go delete mode 100644 builder/vmware/common/step_clean_vmx_test.go delete mode 100644 builder/vmware/common/step_compact_disk_test.go delete mode 100644 builder/vmware/common/step_configure_vmx_test.go delete mode 100644 builder/vmware/common/step_configure_vnc_test.go delete mode 100644 builder/vmware/common/step_create_disks_test.go delete mode 100644 builder/vmware/common/step_export_test.go delete mode 100644 builder/vmware/common/step_http_ip_discover_test.go delete mode 100644 builder/vmware/common/step_output_dir_test.go delete mode 100644 builder/vmware/common/step_prepare_tools_test.go delete mode 100644 builder/vmware/common/step_register_test.go delete mode 100644 builder/vmware/common/step_remote_upload_test.go delete mode 100644 builder/vmware/common/step_run_test.go delete mode 100644 builder/vmware/common/step_shutdown_test.go delete mode 100644 builder/vmware/common/step_suppress_messages_test.go delete mode 100644 builder/vmware/common/step_test.go delete mode 100644 builder/vmware/common/testdata/apple-dhcpd-example.leases delete mode 100644 builder/vmware/common/testdata/dhcpd-example.conf delete mode 100644 builder/vmware/common/testdata/dhcpd-example.leases delete mode 100644 builder/vmware/common/testdata/netmap-example.conf delete mode 100644 builder/vmware/common/testdata/networking-example delete mode 100644 builder/vmware/common/tools_config_test.go delete mode 100644 builder/vmware/common/vmx_config_test.go delete mode 100644 builder/vmware/common/vmx_test.go delete mode 100644 builder/vmware/iso/builder_acc_test.go delete mode 100644 builder/vmware/iso/builder_test.go delete mode 100644 builder/vmware/iso/step_create_vmx_test.go delete mode 100644 builder/vmware/iso/testdata/http/preseed.cfg delete mode 100644 builder/vmware/iso/testdata/minimal.json delete mode 100644 builder/vmware/version/version.go delete mode 100644 builder/vmware/vmx/builder_test.go delete mode 100644 builder/vmware/vmx/config_test.go delete mode 100644 builder/vmware/vmx/step_clone_vmx_test.go delete mode 100644 builder/vmware/vmx/step_test.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-vmware/LICENSE rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/artifact.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/disk_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver.go (99%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_esx5.go (99%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_fusion5.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_fusion6.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_mock.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_parser.go (99%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_player5.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_player5_windows.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_player6.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_player6_windows.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_player_unix.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_workstation10.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_workstation10_windows.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_workstation9.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_workstation9_windows.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/driver_workstation_unix.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/export_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/host_ip_ifconfig.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/hw_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/output_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/output_dir.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/output_dir_local.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/remote_driver.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/remote_driver_mock.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/run_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/ssh.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/ssh_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_clean_files.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_clean_vmx.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_compact_disk.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_configure_vmx.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_configure_vnc.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_create_disks.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_export.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_http_ip_discover.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_output_dir.go (99%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_prepare_tools.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_register.go (97%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_remote_upload.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_run.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_shutdown.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_suppress_messages.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_upload_tools.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_upload_vmx.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_vnc_boot_command.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/step_vnc_connect.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/tools_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/vmx.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/common/vmx_config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/iso/builder.go (98%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/iso/config.go (99%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/iso/config.hcl2spec.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/iso/step_create_vmx.go (98%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/vmx/builder.go (98%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/vmx/config.go (98%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/vmx/config.hcl2spec.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-vmware/builder}/vmware/vmx/step_clone_vmx.go (98%) delete mode 100644 website/content/docs/builders/vmware/index.mdx delete mode 100644 website/content/docs/builders/vmware/iso.mdx delete mode 100644 website/content/docs/builders/vmware/vmx.mdx delete mode 100644 website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/HWConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/ParallelUnion.mdx delete mode 100644 website/content/partials/builder/vmware/common/RunConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/RunConfig.mdx delete mode 100644 website/content/partials/builder/vmware/common/SerialConfigPipe.mdx delete mode 100644 website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/iso/Config-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/vmx/Config-not-required.mdx delete mode 100644 website/content/partials/builder/vmware/vmx/Config-required.mdx delete mode 100644 website/content/partials/builder/vmware/vmx/Config.mdx delete mode 100644 website/content/partials/builders/building_on_remote_vsphere_hypervisor.mdx diff --git a/builder/vmware/common/artifact_test.go b/builder/vmware/common/artifact_test.go deleted file mode 100644 index fb849c1bf..000000000 --- a/builder/vmware/common/artifact_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package common - -import ( - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestLocalArtifact_impl(t *testing.T) { - var _ packersdk.Artifact = new(artifact) -} diff --git a/builder/vmware/common/driver_config_test.go b/builder/vmware/common/driver_config_test.go deleted file mode 100644 index 9f98185a2..000000000 --- a/builder/vmware/common/driver_config_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package common - -import ( - "fmt" - "reflect" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func TestDriverConfigPrepare(t *testing.T) { - tc := []struct { - name string - config *DriverConfig - expectedConfig *DriverConfig - errs []error - }{ - { - name: "Set default values", - config: new(DriverConfig), - expectedConfig: &DriverConfig{ - FusionAppPath: "/Applications/VMware Fusion.app", - RemoteDatastore: "datastore1", - RemoteCacheDatastore: "datastore1", - RemoteCacheDirectory: "packer_cache", - RemotePort: 22, - RemoteUser: "root", - }, - errs: nil, - }, - { - name: "Override default values", - config: &DriverConfig{ - FusionAppPath: "foo", - RemoteDatastore: "set-datastore1", - RemoteCacheDatastore: "set-datastore1", - RemoteCacheDirectory: "set_packer_cache", - RemotePort: 443, - RemoteUser: "admin", - }, - expectedConfig: &DriverConfig{ - FusionAppPath: "foo", - RemoteDatastore: "set-datastore1", - RemoteCacheDatastore: "set-datastore1", - RemoteCacheDirectory: "set_packer_cache", - RemotePort: 443, - RemoteUser: "admin", - }, - errs: nil, - }, - { - name: "Invalid remote type", - config: &DriverConfig{ - RemoteType: "invalid", - RemoteHost: "host", - }, - expectedConfig: nil, - errs: []error{fmt.Errorf("Only 'esx5' value is accepted for remote_type")}, - }, - { - name: "Remote host not set", - config: &DriverConfig{ - RemoteType: "esx5", - }, - expectedConfig: nil, - errs: []error{fmt.Errorf("remote_host must be specified")}, - }, - } - - for _, c := range tc { - t.Run(c.name, func(t *testing.T) { - errs := c.config.Prepare(interpolate.NewContext()) - if !reflect.DeepEqual(errs, c.errs) { - t.Fatalf("bad: \n expected '%v' \nactual '%v'", c.errs, errs) - } - if len(c.errs) == 0 { - if diff := cmp.Diff(c.config, c.expectedConfig); diff != "" { - t.Fatalf("bad value: %s", diff) - } - } - }) - } -} diff --git a/builder/vmware/common/driver_esx5_test.go b/builder/vmware/common/driver_esx5_test.go deleted file mode 100644 index d51ac56cd..000000000 --- a/builder/vmware/common/driver_esx5_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package common - -import ( - "fmt" - "net" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/communicator" - "github.com/hashicorp/packer-plugin-sdk/multistep" - "github.com/hashicorp/packer-plugin-sdk/template/config" -) - -func TestESX5Driver_implDriver(t *testing.T) { - var _ Driver = new(ESX5Driver) -} - -func TestESX5Driver_UpdateVMX(t *testing.T) { - var driver ESX5Driver - data := make(map[string]string) - driver.UpdateVMX("0.0.0.0", "", 5900, data) - if _, ok := data["remotedisplay.vnc.ip"]; ok { - // Do not add the remotedisplay.vnc.ip on ESXi - t.Fatal("invalid VMX data key: remotedisplay.vnc.ip") - } - if enabled := data["remotedisplay.vnc.enabled"]; enabled != "TRUE" { - t.Errorf("bad VMX data for key remotedisplay.vnc.enabled: %v", enabled) - } - if port := data["remotedisplay.vnc.port"]; port != fmt.Sprint(port) { - t.Errorf("bad VMX data for key remotedisplay.vnc.port: %v", port) - } -} - -func TestESX5Driver_implOutputDir(t *testing.T) { - var _ OutputDir = new(ESX5Driver) -} - -func TestESX5Driver_implVNCAddressFinder(t *testing.T) { - var _ VNCAddressFinder = new(ESX5Driver) -} - -func TestESX5Driver_implRemoteDriver(t *testing.T) { - var _ RemoteDriver = new(ESX5Driver) -} - -func TestESX5Driver_HostIP(t *testing.T) { - expected_host := "127.0.0.1" - - //create mock SSH server - listen, _ := net.Listen("tcp", fmt.Sprintf("%s:0", expected_host)) - port := listen.Addr().(*net.TCPAddr).Port - defer listen.Close() - - driver := ESX5Driver{Host: "localhost", Port: port} - state := new(multistep.BasicStateBag) - - if host, _ := driver.HostIP(state); host != expected_host { - t.Error(fmt.Sprintf("Expected string, %s but got %s", expected_host, host)) - } -} - -func TestESX5Driver_CommHost(t *testing.T) { - const expected_host = "127.0.0.1" - - conf := make(map[string]interface{}) - conf["communicator"] = "winrm" - conf["winrm_username"] = "username" - conf["winrm_password"] = "password" - conf["winrm_host"] = expected_host - - var commConfig communicator.Config - err := config.Decode(&commConfig, nil, conf) - if err != nil { - t.Fatalf("error decoding config: %v", err) - } - state := new(multistep.BasicStateBag) - sshConfig := SSHConfig{Comm: commConfig} - state.Put("sshConfig", &sshConfig) - driver := ESX5Driver{CommConfig: *(&sshConfig.Comm)} - - host, err := driver.CommHost(state) - if err != nil { - t.Fatalf("should not have error: %s", err) - } - if host != expected_host { - t.Errorf("bad host name: %s", host) - } - address, ok := state.GetOk("vm_address") - if !ok { - t.Error("state not updated with vm_address") - } - if address.(string) != expected_host { - t.Errorf("bad vm_address: %s", address.(string)) - } -} - -func TestESX5Driver_VerifyOvfTool(t *testing.T) { - driver := ESX5Driver{} - // should always skip validation if export is skipped, so this should always - // pass even when ovftool is not installed. - err := driver.VerifyOvfTool(true, false) - if err != nil { - t.Fatalf("shouldn't fail ever because should always skip check") - } -} diff --git a/builder/vmware/common/driver_mock_test.go b/builder/vmware/common/driver_mock_test.go deleted file mode 100644 index 5a056e149..000000000 --- a/builder/vmware/common/driver_mock_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package common - -import ( - "testing" -) - -func TestDriverMock_impl(t *testing.T) { - var _ Driver = new(DriverMock) -} diff --git a/builder/vmware/common/driver_parser_test.go b/builder/vmware/common/driver_parser_test.go deleted file mode 100644 index dbd24fa18..000000000 --- a/builder/vmware/common/driver_parser_test.go +++ /dev/null @@ -1,1288 +0,0 @@ -package common - -import ( - "testing" - - "bytes" - "encoding/hex" - "os" - "path/filepath" - "strings" -) - -func consumeString(s string) (out chan byte) { - out = make(chan byte) - go func() { - for _, ch := range s { - out <- byte(ch) - } - close(out) - }() - return -} - -func collectIntoStringList(in chan string) (result []string) { - for item := range in { - result = append(result, item) - } - return -} - -func uncommentFromString(s string) string { - inCh := consumeString(s) - out := uncomment(inCh) - - result := "" - for reading := true; reading; { - if item, ok := <-out; !ok { - break - } else { - result += string(item) - } - } - return result -} - -func TestParserUncomment(t *testing.T) { - var result string - - test_0 := "this is a straight-up line" - result_0 := test_0 - - result = uncommentFromString(test_0) - if result != result_0 { - t.Errorf("Expected %#v, received %#v", result_0, result) - } - - test_1 := "this is a straight-up line with a newline\n" - result_1 := test_1 - - result = uncommentFromString(test_1) - if result != result_1 { - t.Errorf("Expected %#v, received %#v", result_1, result) - } - - test_2 := "this line has a comment # at its end" - result_2 := "this line has a comment " - - result = uncommentFromString(test_2) - if result != result_2 { - t.Errorf("Expected %#v, received %#v", result_2, result) - } - - test_3 := "# this whole line is commented" - result_3 := "" - - result = uncommentFromString(test_3) - if result != result_3 { - t.Errorf("Expected %#v, received %#v", result_3, result) - } - - test_4 := "this\nhas\nmultiple\nlines" - result_4 := test_4 - - result = uncommentFromString(test_4) - if result != result_4 { - t.Errorf("Expected %#v, received %#v", result_4, result) - } - - test_5 := "this only has\n# one line" - result_5 := "this only has\n" - result = uncommentFromString(test_5) - if result != result_5 { - t.Errorf("Expected %#v, received %#v", result_5, result) - } - - test_6 := "this is\npartially # commented" - result_6 := "this is\npartially " - - result = uncommentFromString(test_6) - if result != result_6 { - t.Errorf("Expected %#v, received %#v", result_6, result) - } - - test_7 := "this # has\nmultiple # lines\ncommented # out" - result_7 := "this \nmultiple \ncommented " - - result = uncommentFromString(test_7) - if result != result_7 { - t.Errorf("Expected %#v, received %#v", result_7, result) - } -} - -func tokenizeDhcpConfigFromString(s string) []string { - inCh := consumeString(s) - out := tokenizeDhcpConfig(inCh) - - result := make([]string, 0) - for { - if item, ok := <-out; !ok { - break - } else { - result = append(result, item) - } - } - return result -} - -func TestParserTokenizeDhcp(t *testing.T) { - - test_1 := ` -subnet 127.0.0.0 netmask 255.255.255.252 { - item 1234 5678; - tabbed item-1 1234; - quoted item-2 "hola mundo."; -} -` - expected := []string{ - "subnet", "127.0.0.0", "netmask", "255.255.255.252", "{", - "item", "1234", "5678", ";", - "tabbed", "item-1", "1234", ";", - "quoted", "item-2", "\"hola mundo.\"", ";", - "}", - } - result := tokenizeDhcpConfigFromString(test_1) - - t.Logf("testing for: %v", expected) - t.Logf("checking out: %v", result) - if len(result) != len(expected) { - t.Fatalf("length of token lists do not match (%d != %d)", len(result), len(expected)) - } - - for index := range expected { - if expected[index] != result[index] { - t.Errorf("unexpected token at index %d: %v != %v", index, expected[index], result[index]) - } - } -} - -func consumeTokens(tokes []string) chan string { - out := make(chan string) - go func() { - for _, item := range tokes { - out <- item - } - out <- ";" - close(out) - }() - return out -} - -func TestParserDhcpParameters(t *testing.T) { - var ch chan string - - test_1 := []string{"option", "whee", "whooo"} - ch = consumeTokens(test_1) - - result := parseTokenParameter(ch) - if result.name != "option" { - t.Errorf("expected name %s, got %s", test_1[0], result.name) - } - if len(result.operand) == 2 { - if result.operand[0] != "whee" { - t.Errorf("expected operand[%d] as %s, got %s", 0, "whee", result.operand[0]) - } - if result.operand[1] != "whooo" { - t.Errorf("expected operand[%d] as %s, got %s", 0, "whooo", result.operand[1]) - } - } else { - t.Errorf("expected %d operands, got %d", 2, len(result.operand)) - } - - test_2 := []string{"whaaa", "whoaaa", ";", "wooops"} - ch = consumeTokens(test_2) - - result = parseTokenParameter(ch) - if result.name != "whaaa" { - t.Errorf("expected name %s, got %s", test_2[0], result.name) - } - if len(result.operand) == 1 { - if result.operand[0] != "whoaaa" { - t.Errorf("expected operand[%d] as %s, got %s", 0, "whoaaa", result.operand[0]) - } - } else { - t.Errorf("expected %d operands, got %d", 1, len(result.operand)) - } - - test_3 := []string{"optionz", "only", "{", "culled"} - ch = consumeTokens(test_3) - - result = parseTokenParameter(ch) - if result.name != "optionz" { - t.Errorf("expected name %s, got %s", test_3[0], result.name) - } - if len(result.operand) == 1 { - if result.operand[0] != "only" { - t.Errorf("expected operand[%d] as %s, got %s", 0, "only", result.operand[0]) - } - } else { - t.Errorf("expected %d operands, got %d", 1, len(result.operand)) - } -} - -func consumeDhcpConfig(items []string) (tkGroup, error) { - out := make(chan string) - tch := consumeTokens(items) - - go func() { - for item := range tch { - out <- item - } - close(out) - }() - - return parseDhcpConfig(out) -} - -func compareSlice(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i := range a { - if a[i] != b[i] { - return false - } - } - return true -} - -func TestParserDhcpConfigParse(t *testing.T) { - test_1 := []string{ - "allow", "unused-option", ";", - "lease-option", "1234", ";", - "more", "options", "hi", ";", - } - result_1, err := consumeDhcpConfig(test_1) - if err != nil { - t.Fatalf("%s", err) - } - if len(result_1.params) != 4 { - t.Fatalf("expected %d params, got %d", 3, len(result_1.params)) - } - if result_1.params[0].name != "allow" { - t.Errorf("expected %s, got %s", "allow", result_1.params[0].name) - } - if !compareSlice(result_1.params[0].operand, []string{"unused-option"}) { - t.Errorf("unexpected options parsed: %v", result_1.params[0].operand) - } - if result_1.params[1].name != "lease-option" { - t.Errorf("expected %s, got %s", "lease-option", result_1.params[1].name) - } - if !compareSlice(result_1.params[1].operand, []string{"1234"}) { - t.Errorf("unexpected options parsed: %v", result_1.params[1].operand) - } - if result_1.params[2].name != "more" { - t.Errorf("expected %s, got %s", "lease-option", result_1.params[2].name) - } - if !compareSlice(result_1.params[2].operand, []string{"options", "hi"}) { - t.Errorf("unexpected options parsed: %v", result_1.params[2].operand) - } - - test_2 := []string{ - "first-option", ";", - "child", "group", "{", - "blah", ";", - "meh", ";", - "}", - "hidden", "option", "57005", ";", - "host", "device", "two", "{", - "skipped", "option", ";", - "more", "skipped", "options", ";", - "}", - "last", "option", "but", "unterminated", - } - result_2, err := consumeDhcpConfig(test_2) - if err != nil { - t.Fatalf("%s", err) - } - if len(result_2.groups) != 2 { - t.Fatalf("expected %d groups, got %d", 2, len(result_2.groups)) - } - - if len(result_2.params) != 3 { - t.Errorf("expected %d options, got %d", 3, len(result_2.params)) - } - - group0 := result_2.groups[0] - if group0.id.name != "child" { - t.Errorf("expected group %s, got %s", "child", group0.id.name) - } - if len(group0.id.operand) != 1 { - t.Errorf("expected group operand %d, got %d", 1, len(group0.params)) - } - if len(group0.params) != 2 { - t.Errorf("expected group params %d, got %d", 2, len(group0.params)) - } - - group1 := result_2.groups[1] - if group1.id.name != "host" { - t.Errorf("expected group %s, got %s", "host", group1.id.name) - } - if len(group1.id.operand) != 2 { - t.Errorf("expected group operand %d, got %d", 2, len(group1.params)) - } - if len(group1.params) != 2 { - t.Errorf("expected group params %d, got %d", 2, len(group1.params)) - } -} - -func TestParserReadDhcpConfig(t *testing.T) { - expected := []string{ - `{global} -grants : map[unknown-clients:0] -parameters : map[default-lease-time:1800 max-lease-time:7200] -`, - - `{subnet4 172.33.33.0/24},{global} -address : range4:172.33.33.128-172.33.33.254 -options : map[broadcast-address:172.33.33.255 routers:172.33.33.2] -grants : map[unknown-clients:0] -parameters : map[default-lease-time:2400 max-lease-time:9600] -`, - - `{host name:vmnet8},{global} -address : hardware-address:ethernet[00:50:56:c0:00:08],fixed-address4:172.33.33.1 -options : map[domain-name:"packer.test"] -grants : map[unknown-clients:0] -parameters : map[default-lease-time:1800 max-lease-time:7200] -`, - } - - f, err := os.Open(filepath.Join("testdata", "dhcpd-example.conf")) - if err != nil { - t.Fatalf("Unable to open dhcpd.conf sample: %s", err) - } - defer f.Close() - - config, err := ReadDhcpConfiguration(f) - if err != nil { - t.Fatalf("Unable to read dhcpd.conf samplpe: %s", err) - } - - if len(config) != 3 { - t.Fatalf("expected %d entries, got %d", 3, len(config)) - } - - for index, item := range config { - if item.repr() != expected[index] { - t.Errorf("Parsing of declaration %d did not match what was expected", index) - t.Logf("Result from parsing:\n%s", item.repr()) - t.Logf("Expected to parse:\n%s", expected[index]) - } - } -} - -func TestParserTokenizeNetworkMap(t *testing.T) { - - test_1 := "group.attribute = \"string\"" - expected := []string{ - "group.attribute", "=", "\"string\"", - } - result := tokenizeDhcpConfigFromString(test_1) - if len(result) != len(expected) { - t.Fatalf("length of token lists do not match (%d != %d)", len(result), len(expected)) - } - - for index := range expected { - if expected[index] != result[index] { - t.Errorf("unexpected token at index %d: %v != %v", index, expected[index], result[index]) - } - } - - test_2 := "attribute == \"" - expected = []string{ - "attribute", "==", "\"", - } - result = tokenizeDhcpConfigFromString(test_2) - if len(result) != len(expected) { - t.Fatalf("length of token lists do not match (%d != %d)", len(result), len(expected)) - } - - test_3 := "attribute ....... ======\nnew lines should make no difference" - expected = []string{ - "attribute", ".......", "======", "new", "lines", "should", "make", "no", "difference", - } - result = tokenizeDhcpConfigFromString(test_3) - if len(result) != len(expected) { - t.Fatalf("length of token lists do not match (%d != %d)", len(result), len(expected)) - } - - test_4 := "\t\t\t\t thishadwhitespacebeforebeingparsed\t \t \t \t\n\n" - expected = []string{ - "thishadwhitespacebeforebeingparsed", - } - result = tokenizeDhcpConfigFromString(test_4) - if len(result) != len(expected) { - t.Fatalf("length of token lists do not match (%d != %d)", len(result), len(expected)) - } -} - -func TestParserReadNetworkMap(t *testing.T) { - f, err := os.Open(filepath.Join("testdata", "netmap-example.conf")) - if err != nil { - t.Fatalf("Unable to open netmap.conf sample: %s", err) - } - defer f.Close() - - netmap, err := ReadNetworkMap(f) - if err != nil { - t.Fatalf("Unable to read netmap.conf samplpe: %s", err) - } - - expected_keys := []string{"device", "name"} - for _, item := range netmap { - for _, name := range expected_keys { - _, ok := item[name] - if !ok { - t.Errorf("unable to find expected key %v in map: %v", name, item) - } - } - } - - expected_vmnet0 := [][]string{ - []string{"device", "vmnet0"}, - []string{"name", "Bridged"}, - } - for _, item := range netmap { - if item["device"] != "vmnet0" { - continue - } - for _, expectpair := range expected_vmnet0 { - name := expectpair[0] - value := expectpair[1] - if item[name] != value { - t.Errorf("expected value %v for attribute %v, got %v", value, name, item[name]) - } - } - } - - expected_vmnet1 := [][]string{ - []string{"device", "vmnet1"}, - []string{"name", "HostOnly"}, - } - for _, item := range netmap { - if item["device"] != "vmnet1" { - continue - } - for _, expectpair := range expected_vmnet1 { - name := expectpair[0] - value := expectpair[1] - if item[name] != value { - t.Errorf("expected value %v for attribute %v, got %v", value, name, item[name]) - } - } - } - - expected_vmnet8 := [][]string{ - []string{"device", "vmnet8"}, - []string{"name", "NAT"}, - } - for _, item := range netmap { - if item["device"] != "vmnet8" { - continue - } - for _, expectpair := range expected_vmnet8 { - name := expectpair[0] - value := expectpair[1] - if item[name] != value { - t.Errorf("expected value %v for attribute %v, got %v", value, name, item[name]) - } - } - } -} - -func collectIntoString(in chan byte) string { - result := "" - for item := range in { - result += string(item) - } - return result -} - -func TestParserConsumeUntilSentinel(t *testing.T) { - - test_1 := "consume until a semicolon; yeh?" - expected_1 := "consume until a semicolon" - - ch := consumeString(test_1) - resultch, _ := consumeUntilSentinel(';', ch) - result := string(resultch) - if expected_1 != result { - t.Errorf("expected %#v, got %#v", expected_1, result) - } - - test_2 := "; this is only a semi" - expected_2 := "" - - ch = consumeString(test_2) - resultch, _ = consumeUntilSentinel(';', ch) - result = string(resultch) - if expected_2 != result { - t.Errorf("expected %#v, got %#v", expected_2, result) - } -} - -func TestParserFilterCharacters(t *testing.T) { - - test_1 := []string{" ", "ignore all spaces"} - expected_1 := "ignoreallspaces" - - ch := consumeString(test_1[1]) - outch := filterOutCharacters(bytes.NewBufferString(test_1[0]).Bytes(), ch) - result := collectIntoString(outch) - if result != expected_1 { - t.Errorf("expected %#v, got %#v", expected_1, result) - } - - test_2 := []string{"\n\v\t\r ", "ignore\nall\rwhite\v\v space "} - expected_2 := "ignoreallwhitespace" - - ch = consumeString(test_2[1]) - outch = filterOutCharacters(bytes.NewBufferString(test_2[0]).Bytes(), ch) - result = collectIntoString(outch) - if result != expected_2 { - t.Errorf("expected %#v, got %#v", expected_2, result) - } -} - -func TestParserConsumeOpenClosePair(t *testing.T) { - test_1 := "(everything)" - expected_1 := []string{"", test_1} - - testch := consumeString(test_1) - prefix, ch := consumeOpenClosePair('(', ')', testch) - if string(prefix) != expected_1[0] { - t.Errorf("expected prefix %#v, got %#v", expected_1[0], prefix) - } - result := collectIntoString(ch) - if result != expected_1[1] { - t.Errorf("expected %#v, got %#v", expected_1[1], test_1) - } - - test_2 := "prefixed (everything)" - expected_2 := []string{"prefixed ", "(everything)"} - - testch = consumeString(test_2) - prefix, ch = consumeOpenClosePair('(', ')', testch) - if string(prefix) != expected_2[0] { - t.Errorf("expected prefix %#v, got %#v", expected_2[0], prefix) - } - result = collectIntoString(ch) - if result != expected_2[1] { - t.Errorf("expected %#v, got %#v", expected_2[1], test_2) - } - - test_3 := "this(is()suffixed" - expected_3 := []string{"this", "(is()"} - - testch = consumeString(test_3) - prefix, ch = consumeOpenClosePair('(', ')', testch) - if string(prefix) != expected_3[0] { - t.Errorf("expected prefix %#v, got %#v", expected_3[0], prefix) - } - result = collectIntoString(ch) - if result != expected_3[1] { - t.Errorf("expected %#v, got %#v", expected_3[1], test_2) - } -} - -func TestParserCombinators(t *testing.T) { - - test_1 := "across # ignore\nmultiple lines;" - expected_1 := "across multiple lines" - - ch := consumeString(test_1) - inch := uncomment(ch) - whch := filterOutCharacters([]byte{'\n'}, inch) - resultch, _ := consumeUntilSentinel(';', whch) - result := string(resultch) - if expected_1 != result { - t.Errorf("expected %#v, got %#v", expected_1, result) - } - - test_2 := "lease blah {\n blah\r\n# skipping this line\nblahblah # ignore semicolon;\n last item;\n\n };;;;;;" - expected_2 := []string{"lease blah ", "{ blahblahblah last item; }"} - - ch = consumeString(test_2) - inch = uncomment(ch) - whch = filterOutCharacters([]byte{'\n', '\v', '\r'}, inch) - prefix, pairch := consumeOpenClosePair('{', '}', whch) - - result = collectIntoString(pairch) - if string(prefix) != expected_2[0] { - t.Errorf("expected prefix %#v, got %#v", expected_2[0], prefix) - } - if result != expected_2[1] { - t.Errorf("expected %#v, got %#v", expected_2[1], result) - } - - test_3 := "lease blah { # comment\n item 1;\n item 2;\n } not imortant" - expected_3_prefix := "lease blah " - expected_3 := []string{"{ item 1", " item 2", " }"} - - sch := consumeString(test_3) - inch = uncomment(sch) - wch := filterOutCharacters([]byte{'\n', '\v', '\r'}, inch) - lease, itemch := consumeOpenClosePair('{', '}', wch) - if string(lease) != expected_3_prefix { - t.Errorf("expected %#v, got %#v", expected_3_prefix, string(lease)) - } - - result_3 := []string{} - for reading := true; reading; { - item, ok := consumeUntilSentinel(';', itemch) - result_3 = append(result_3, string(item)) - if !ok { - reading = false - } - } - - for index := range expected_3 { - if expected_3[index] != result_3[index] { - t.Errorf("expected index %d as %#v, got %#v", index, expected_3[index], result_3[index]) - } - } -} - -func TestParserDhcpdLeaseBytesDecoder(t *testing.T) { - test_1 := "00:0d:0e:0a:0d:00" - expected_1 := []byte{0, 13, 14, 10, 13, 0} - - result, err := decodeDhcpdLeaseBytes(test_1) - if err != nil { - t.Errorf("unable to decode address: %s", err) - } - if !bytes.Equal(result, expected_1) { - t.Errorf("expected %v, got %v", expected_1, result) - } - - test_2 := "11" - expected_2 := []byte{17} - - result, err = decodeDhcpdLeaseBytes(test_2) - if err != nil { - t.Errorf("unable to decode address: %s", err) - } - if !bytes.Equal(result, expected_2) { - t.Errorf("expected %v, got %v", expected_2, result) - } - - failtest_1 := "" - _, err = decodeDhcpdLeaseBytes(failtest_1) - if err == nil { - t.Errorf("expected decoding error: %s", err) - } - - failtest_2 := "000000" - _, err = decodeDhcpdLeaseBytes(failtest_2) - if err == nil { - t.Errorf("expected decoding error: %s", err) - } - - failtest_3 := "000:00" - _, err = decodeDhcpdLeaseBytes(failtest_3) - if err == nil { - t.Errorf("expected decoding error: %s", err) - } - - failtest_4 := "00:00:" - _, err = decodeDhcpdLeaseBytes(failtest_4) - if err == nil { - t.Errorf("expected decoding error: %s", err) - } -} - -func consumeLeaseString(s string) chan byte { - sch := consumeString(s) - uncommentedch := uncomment(sch) - return filterOutCharacters([]byte{'\n', '\r', '\v'}, uncommentedch) -} - -func TestParserReadDhcpdLeaseEntry(t *testing.T) { - test_1 := "lease 127.0.0.1 {\nhardware ethernet 00:11:22:33 ;\nuid 00:11 ;\n }" - expected_1 := map[string]string{ - "address": "127.0.0.1", - "ether": "00112233", - "uid": "0011", - } - - result, err := readDhcpdLeaseEntry(consumeLeaseString(test_1)) - if err != nil { - t.Errorf("error parsing entry: %v", err) - } - if result.address != expected_1["address"] { - t.Errorf("expected address %v, got %v", expected_1["address"], result.address) - } - if hex.EncodeToString(result.ether) != expected_1["ether"] { - t.Errorf("expected ether %v, got %v", expected_1["ether"], hex.EncodeToString(result.ether)) - } - if hex.EncodeToString(result.uid) != expected_1["uid"] { - t.Errorf("expected uid %v, got %v", expected_1["uid"], hex.EncodeToString(result.uid)) - } - - test_2 := " \n\t lease 192.168.21.254{ hardware\n ethernet 44:55:66:77:88:99;uid 00:1\n1:22:3\r3:44;\n starts 57005 2006/01/02 15:04:05;ends 57005 2006/01/03 15:04:05;\tunknown item1; unknown item2; } " - expected_2 := map[string]string{ - "address": "192.168.21.254", - "ether": "445566778899", - "uid": "0011223344", - "starts": "2006-01-02 15:04:05 +0000 UTC", - "ends": "2006-01-03 15:04:05 +0000 UTC", - } - result, err = readDhcpdLeaseEntry(consumeLeaseString(test_2)) - if err != nil { - t.Errorf("error parsing entry: %v", err) - } - if result.address != expected_2["address"] { - t.Errorf("expected address %v, got %v", expected_2["address"], result.address) - } - if hex.EncodeToString(result.ether) != expected_2["ether"] { - t.Errorf("expected ether %v, got %v", expected_2["ether"], hex.EncodeToString(result.ether)) - } - if hex.EncodeToString(result.uid) != expected_2["uid"] { - t.Errorf("expected uid %v, got %v", expected_2["uid"], hex.EncodeToString(result.uid)) - } - if result.starts.String() != expected_2["starts"] { - t.Errorf("expected starts %v, got %v", expected_2["starts"], result.starts) - } - if result.ends.String() != expected_2["ends"] { - t.Errorf("expected ends %v, got %v", expected_2["ends"], result.ends) - } - if result.starts_weekday != 57005 { - t.Errorf("expected starts weekday %v, got %v", 57005, result.starts_weekday) - } - if result.ends_weekday != 57005 { - t.Errorf("expected ends weekday %v, got %v", 57005, result.ends_weekday) - } -} - -func TestParserReadDhcpdLeases(t *testing.T) { - f, err := os.Open(filepath.Join("testdata", "dhcpd-example.leases")) - if err != nil { - t.Fatalf("Unable to open dhcpd.leases sample: %s", err) - } - defer f.Close() - - results, err := ReadDhcpdLeaseEntries(f) - if err != nil { - t.Fatalf("Error reading lease: %s", err) - } - - // some simple utilities - filter_address := func(address string, items []dhcpLeaseEntry) (result []dhcpLeaseEntry) { - for _, item := range items { - if item.address == address { - result = append(result, item) - } - } - return - } - - find_uid := func(uid string, items []dhcpLeaseEntry) *dhcpLeaseEntry { - for _, item := range items { - if uid == hex.EncodeToString(item.uid) { - return &item - } - } - return nil - } - - find_ether := func(ether string, items []dhcpLeaseEntry) *dhcpLeaseEntry { - for _, item := range items { - if ether == hex.EncodeToString(item.ether) { - return &item - } - } - return nil - } - - // actual unit tests - test_1 := map[string]string{ - "address": "127.0.0.19", - "uid": "010dead099aabb", - "ether": "0dead099aabb", - } - test_1_findings := filter_address(test_1["address"], results) - if len(test_1_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_1_findings)) - } else { - res := find_ether(test_1["ether"], test_1_findings) - if res == nil { - t.Errorf("unable to find item with ether %v", test_1["ether"]) - } else if hex.EncodeToString(res.uid) != test_1["uid"] { - t.Errorf("expected uid %s, got %s", test_1["uid"], hex.EncodeToString(res.uid)) - } - } - - test_2 := map[string]string{ - "address": "127.0.0.19", - "uid": "010dead0667788", - "ether": "0dead0667788", - } - test_2_findings := filter_address(test_2["address"], results) - if len(test_2_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_2_findings)) - } else { - res := find_ether(test_2["ether"], test_2_findings) - if res == nil { - t.Errorf("unable to find item with ether %v", test_2["ether"]) - } else if hex.EncodeToString(res.uid) != test_2["uid"] { - t.Errorf("expected uid %s, got %s", test_2["uid"], hex.EncodeToString(res.uid)) - } - } - - test_3 := map[string]string{ - "address": "127.0.0.17", - "uid": "010dead0334455", - "ether": "0dead0667788", - } - test_3_findings := filter_address(test_3["address"], results) - if len(test_3_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_3_findings)) - } else { - res := find_uid(test_3["uid"], test_3_findings) - if res == nil { - t.Errorf("unable to find item with uid %v", test_3["uid"]) - } else if hex.EncodeToString(res.ether) != test_3["ether"] { - t.Errorf("expected ethernet hardware %s, got %s", test_3["ether"], hex.EncodeToString(res.ether)) - } - } - - test_4 := map[string]string{ - "address": "127.0.0.17", - "uid": "010dead0001122", - "ether": "0dead0667788", - } - test_4_findings := filter_address(test_4["address"], results) - if len(test_4_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_4_findings)) - } else { - res := find_uid(test_4["uid"], test_4_findings) - if res == nil { - t.Errorf("unable to find item with uid %v", test_4["uid"]) - } else if hex.EncodeToString(res.ether) != test_4["ether"] { - t.Errorf("expected ethernet hardware %s, got %s", test_4["ether"], hex.EncodeToString(res.ether)) - } - } -} - -func consumeAppleLeaseString(s string) chan byte { - sch := consumeString(s) - uncommentedch := uncomment(sch) - return filterOutCharacters([]byte{'\r', '\v'}, uncommentedch) -} - -func TestParserReadAppleDhcpdLeaseEntry(t *testing.T) { - test_1 := `{ - ip_address=192.168.111.3 - hw_address=1,0:c:56:3c:e7:22 - identifier=1,0:c:56:3c:e7:22 - lease=0x5fd78ae2 - name=vagrant-2019 - fake=field - }` - expected_1 := map[string]string{ - "ipAddress": "192.168.111.3", - "hwAddress": "000c563ce722", - "id": "000c563ce722", - "lease": "0x5fd78ae2", - "name": "vagrant-2019", - } - expected_extra_1 := map[string]string{ - "fake": "field", - } - - result, err := readAppleDhcpdLeaseEntry(consumeAppleLeaseString(test_1)) - if err != nil { - t.Errorf("error parsing entry: %v", err) - } - if result.ipAddress != expected_1["ipAddress"] { - t.Errorf("expected ipAddress %v, got %v", expected_1["ipAddress"], result.ipAddress) - } - if hex.EncodeToString(result.hwAddress) != expected_1["hwAddress"] { - t.Errorf("expected hwAddress %v, got %v", expected_1["hwAddress"], hex.EncodeToString(result.hwAddress)) - } - if hex.EncodeToString(result.id) != expected_1["id"] { - t.Errorf("expected id %v, got %v", expected_1["id"], hex.EncodeToString(result.id)) - } - if result.lease != expected_1["lease"] { - t.Errorf("expected lease %v, got %v", expected_1["lease"], result.lease) - } - if result.name != expected_1["name"] { - t.Errorf("expected name %v, got %v", expected_1["name"], result.name) - } - if result.extra["fake"] != expected_extra_1["fake"] { - t.Errorf("expected extra %v, got %v", expected_extra_1["fake"], result.extra["fake"]) - } - - test_2 := `{ - ip_address=192.168.111.4 - hw_address=1,0:c:56:3c:e7:23 - identifier=1,0:c:56:3c:e7:23 - }` - expected_2 := map[string]string{ - "ipAddress": "192.168.111.4", - "hwAddress": "000c563ce723", - "id": "000c563ce723", - } - - result, err = readAppleDhcpdLeaseEntry(consumeAppleLeaseString(test_2)) - if err != nil { - t.Errorf("error parsing entry: %v", err) - } - if result.ipAddress != expected_2["ipAddress"] { - t.Errorf("expected ipAddress %v, got %v", expected_2["ipAddress"], result.ipAddress) - } - if hex.EncodeToString(result.hwAddress) != expected_2["hwAddress"] { - t.Errorf("expected hwAddress %v, got %v", expected_2["hwAddress"], hex.EncodeToString(result.hwAddress)) - } - if hex.EncodeToString(result.id) != expected_2["id"] { - t.Errorf("expected id %v, got %v", expected_2["id"], hex.EncodeToString(result.id)) - } -} - -func TestParserReadAppleDhcpdLeases(t *testing.T) { - f, err := os.Open(filepath.Join("testdata", "apple-dhcpd-example.leases")) - if err != nil { - t.Fatalf("Unable to open dhcpd.leases sample: %s", err) - } - defer f.Close() - - results, err := ReadAppleDhcpdLeaseEntries(f) - if err != nil { - t.Fatalf("Error reading lease: %s", err) - } - - // some simple utilities - filter_ipAddr := func(ipAddress string, items []appleDhcpLeaseEntry) (result []appleDhcpLeaseEntry) { - for _, item := range items { - if item.ipAddress == ipAddress { - result = append(result, item) - } - } - return - } - - find_id := func(id string, items []appleDhcpLeaseEntry) *appleDhcpLeaseEntry { - for _, item := range items { - if id == hex.EncodeToString(item.id) { - return &item - } - } - return nil - } - - find_hwAddr := func(hwAddr string, items []appleDhcpLeaseEntry) *appleDhcpLeaseEntry { - for _, item := range items { - if hwAddr == hex.EncodeToString(item.hwAddress) { - return &item - } - } - return nil - } - - // actual unit tests - test_1 := map[string]string{ - "ipAddress": "127.0.0.19", - "id": "0dead099aabb", - "hwAddress": "0dead099aabb", - } - test_1_findings := filter_ipAddr(test_1["ipAddress"], results) - if len(test_1_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_1_findings)) - } else { - res := find_hwAddr(test_1["hwAddress"], test_1_findings) - if res == nil { - t.Errorf("unable to find item with hwAddress %v", test_1["hwAddress"]) - } else if hex.EncodeToString(res.id) != test_1["id"] { - t.Errorf("expected id %s, got %s", test_1["id"], hex.EncodeToString(res.id)) - } - } - - test_2 := map[string]string{ - "ipAddress": "127.0.0.19", - "id": "0dead0667788", - "hwAddress": "0dead0667788", - } - test_2_findings := filter_ipAddr(test_2["ipAddress"], results) - if len(test_2_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_2_findings)) - } else { - res := find_hwAddr(test_2["hwAddress"], test_2_findings) - if res == nil { - t.Errorf("unable to find item with hwAddress %v", test_2["hwAddress"]) - } else if hex.EncodeToString(res.id) != test_2["id"] { - t.Errorf("expected id %s, got %s", test_2["id"], hex.EncodeToString(res.id)) - } - } - - test_3 := map[string]string{ - "ipAddress": "127.0.0.17", - "id": "0dead0334455", - "hwAddress": "0dead0667788", - } - test_3_findings := filter_ipAddr(test_3["ipAddress"], results) - if len(test_3_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_3_findings)) - } else { - res := find_id(test_3["id"], test_3_findings) - if res == nil { - t.Errorf("unable to find item with id %v", test_3["id"]) - } else if hex.EncodeToString(res.hwAddress) != test_3["hwAddress"] { - t.Errorf("expected hardware address %s, got %s", test_3["hwAddress"], hex.EncodeToString(res.hwAddress)) - } - } - - test_4 := map[string]string{ - "ipAddress": "127.0.0.17", - "id": "0dead0001122", - "hwAddress": "0dead0667788", - } - test_4_findings := filter_ipAddr(test_4["ipAddress"], results) - if len(test_4_findings) != 2 { - t.Errorf("expected %d matching entries, got %d", 2, len(test_4_findings)) - } else { - res := find_id(test_4["id"], test_4_findings) - if res == nil { - t.Errorf("unable to find item with id %v", test_4["id"]) - } else if hex.EncodeToString(res.hwAddress) != test_4["hwAddress"] { - t.Errorf("expected hardware address %s, got %s", test_4["hwAddress"], hex.EncodeToString(res.hwAddress)) - } - } - - test_5 := map[string]string{ - "ipAddress": "127.0.0.20", - "id": "0dead099aabc", - "hwAddress": "0dead099aabc", - } - test_5_findings := filter_ipAddr(test_5["ipAddress"], results) - if len(test_5_findings) != 1 { - t.Errorf("expected %d matching entries, got %d", 1, len(test_5_findings)) - } else { - res := find_id(test_5["id"], test_5_findings) - if res == nil { - t.Errorf("unable to find item with id %v", test_5["id"]) - } else if hex.EncodeToString(res.hwAddress) != test_5["hwAddress"] { - t.Errorf("expected hardware address %s, got %s", test_5["hwAddress"], hex.EncodeToString(res.hwAddress)) - } - } -} - -func TestParserTokenizeNetworkingConfig(t *testing.T) { - tests := []string{ - "words words words", - "newlines\n\n\n\n\n\n\n\nnewlines\r\r\r\r\r\r\r\rnewlines\n\n\n\n", - " newline-less", - } - expects := [][]string{ - []string{"words", "words", "words"}, - []string{"newlines", "\n", "newlines", "\n", "newlines", "\n"}, - []string{"newline-less"}, - } - - for testnum := 0; testnum < len(tests); testnum += 1 { - inCh := consumeString(tests[testnum]) - outCh := tokenizeNetworkingConfig(inCh) - result := collectIntoStringList(outCh) - - expected := expects[testnum] - if len(result) != len(expected) { - t.Errorf("test %d expected %d items, got %d instead", 1+testnum, len(expected), len(result)) - continue - } - - ok := true - for index := 0; index < len(expected); index += 1 { - if result[index] != expected[index] { - ok = false - } - } - if !ok { - t.Errorf("test %d expected %#v, got %#v", 1+testnum, expects[testnum], result) - } - } -} - -func TestParserSplitNetworkingConfig(t *testing.T) { - tests := []string{ - "this is a story\n\n\nabout some newlines", - "\n\n\nthat can begin and end with newlines\n\n\n", - " in\n\n\nsome\ncases\nit\ncan\nend\nwith\nan\nempty\nstring\n\n\n\n", - "\n\n\nand\nbegin\nwith\nan\nempty\nstring ", - } - expects := [][]string{ - []string{"this is a story", "about some newlines"}, - []string{"that can begin and end with newlines"}, - []string{"in", "some", "cases", "it", "can", "end", "with", "an", "empty", "string"}, - []string{"and", "begin", "with", "an", "empty", "string"}, - } - - for testnum := 0; testnum < len(tests); testnum += 1 { - inCh := consumeString(tests[testnum]) - stringCh := tokenizeNetworkingConfig(inCh) - outCh := splitNetworkingConfig(stringCh) - - result := make([]string, 0) - for item := range outCh { - result = append(result, strings.Join(item, " ")) - } - - expected := expects[testnum] - if len(result) != len(expected) { - t.Errorf("test %d expected %d items, got %d instead", 1+testnum, len(expected), len(result)) - continue - } - - ok := true - for index := 0; index < len(expected); index += 1 { - if result[index] != expected[index] { - ok = false - } - } - if !ok { - t.Errorf("test %d expected %#v, got %#v", 1+testnum, expects[testnum], result) - } - } -} - -func TestParserParseNetworkingConfigVersion(t *testing.T) { - success_tests := []string{"VERSION=4,2"} - failure_tests := []string{ - "VERSION=1=2", - "VERSION=3,4,5", - "VERSION=a,b", - } - - for testnum := 0; testnum < len(success_tests); testnum += 1 { - test := []string{success_tests[testnum]} - if _, err := networkingReadVersion(test); err != nil { - t.Errorf("success-test %d parsing failed: %v", 1+testnum, err) - } - } - - for testnum := 0; testnum < len(success_tests); testnum += 1 { - test := []string{failure_tests[testnum]} - if _, err := networkingReadVersion(test); err == nil { - t.Errorf("failure-test %d should have failed", 1+testnum) - } - } -} - -func TestParserParseNetworkingConfigEntries(t *testing.T) { - tests := []string{ - "answer VNET_999_ANYTHING option", - "remove_answer VNET_123_ALSOANYTHING", - "add_nat_portfwd 24 udp 42 127.0.0.1 24", - "remove_nat_portfwd 42 tcp 2502", - "add_dhcp_mac_to_ip 57005 00:0d:0e:0a:0d:00 127.0.0.2", - "remove_dhcp_mac_to_ip 57005 00:0d:0e:0a:0d:00", - "add_bridge_mapping string 51", - "remove_bridge_mapping string", - "add_nat_prefix 57005 /24", - "remove_nat_prefix 57005 /31", - } - - for testnum := 0; testnum < len(tests); testnum += 1 { - test := strings.Split(tests[testnum], " ") - parser := NetworkingParserByCommand(test[0]) - if parser == nil { - t.Errorf("test %d unable to parse command: %#v", 1+testnum, test) - continue - } - operand_parser := *parser - - _, err := operand_parser(test[1:]) - if err != nil { - t.Errorf("test %d unable to parse command parameters %#v: %v", 1+testnum, test, err) - } - } -} - -func TestParserReadNetworingConfig(t *testing.T) { - expected_answer_vnet_1 := map[string]string{ - "DHCP": "yes", - "DHCP_CFG_HASH": "01F4CE0D79A1599698B6E5814CCB68058BB0ED5E", - "HOSTONLY_NETMASK": "255.255.255.0", - "HOSTONLY_SUBNET": "192.168.70.0", - "NAT": "no", - "VIRTUAL_ADAPTER": "yes", - } - - f, err := os.Open(filepath.Join("testdata", "networking-example")) - if err != nil { - t.Fatalf("Unable to open networking-example sample: %v", err) - } - defer f.Close() - - config, err := ReadNetworkingConfig(f) - if err != nil { - t.Fatalf("error parsing networking-example: %v", err) - } - - if vnet, ok := config.answer[1]; ok { - for ans_key := range expected_answer_vnet_1 { - result, ok := vnet[ans_key] - if !ok { - t.Errorf("unable to find key %s in VNET_%d answer", ans_key, 1) - continue - } - - if result != expected_answer_vnet_1[ans_key] { - t.Errorf("expected key %s for VNET_%d to be %v, got %v", ans_key, 1, expected_answer_vnet_1[ans_key], result) - } - } - - } else { - t.Errorf("unable to find VNET_%d answer", 1) - } - - expected_answer_vnet_8 := map[string]string{ - "DHCP": "yes", - "DHCP_CFG_HASH": "C30F14F65A0FE4B5DCC6C67497D7A8A33E5E538C", - "HOSTONLY_NETMASK": "255.255.255.0", - "HOSTONLY_SUBNET": "172.16.41.0", - "NAT": "yes", - "VIRTUAL_ADAPTER": "yes", - } - - if vnet, ok := config.answer[8]; ok { - for ans_key := range expected_answer_vnet_8 { - result, ok := vnet[ans_key] - if !ok { - t.Errorf("unable to find key %s in VNET_%d answer", ans_key, 8) - continue - } - - if result != expected_answer_vnet_8[ans_key] { - t.Errorf("expected key %s for VNET_%d to be %v, got %v", ans_key, 8, expected_answer_vnet_8[ans_key], result) - } - } - - } else { - t.Errorf("unable to find VNET_%d answer", 8) - } - - expected_nat_portfwd_8 := map[string]string{ - "tcp/2200": "172.16.41.129:3389", - "tcp/2201": "172.16.41.129:3389", - "tcp/2222": "172.16.41.129:22", - "tcp/3389": "172.16.41.131:3389", - "tcp/55985": "172.16.41.129:5985", - "tcp/55986": "172.16.41.129:5986", - } - - if vnet, ok := config.nat_portfwd[8-1]; ok { - for nat_key := range expected_nat_portfwd_8 { - result, ok := vnet[nat_key] - if !ok { - t.Errorf("unable to find key %s in VNET_%d nat_portfwd", nat_key, 8) - continue - } - - if result != expected_nat_portfwd_8[nat_key] { - t.Errorf("expected key %s for VNET_%d to be %v, got %v", nat_key, 8, expected_nat_portfwd_8[nat_key], result) - } - } - } else { - t.Errorf("unable to find VNET_%d answer", 8-1) - } -} diff --git a/builder/vmware/common/driver_workstation_unix_test.go b/builder/vmware/common/driver_workstation_unix_test.go deleted file mode 100644 index e0e3e6ecf..000000000 --- a/builder/vmware/common/driver_workstation_unix_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// +build !windows - -package common - -import ( - "testing" -) - -func TestWorkstationVersion_ws14(t *testing.T) { - input := `VMware Workstation Information: -VMware Workstation 14.1.1 build-7528167 Release` - if err := workstationTestVersion("10", input); err != nil { - t.Fatal(err) - } -} diff --git a/builder/vmware/common/hw_config_test.go b/builder/vmware/common/hw_config_test.go deleted file mode 100644 index 28ffb5111..000000000 --- a/builder/vmware/common/hw_config_test.go +++ /dev/null @@ -1,315 +0,0 @@ -package common - -import ( - "strings" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func TestHWConfigPrepare(t *testing.T) { - c := new(HWConfig) - - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if c.CpuCount < 0 { - t.Errorf("bad cpu count: %d", c.CpuCount) - } - - if c.CoreCount < 0 { - t.Errorf("bad core count: %d", c.CoreCount) - } - - if c.MemorySize < 0 { - t.Errorf("bad memory size: %d", c.MemorySize) - } - - if c.Sound { - t.Errorf("peripheral choice (sound) should be conservative: %t", c.Sound) - } - - if c.USB { - t.Errorf("peripheral choice (usb) should be conservative: %t", c.USB) - } - - if strings.ToUpper(c.Parallel) != "NONE" { - t.Errorf("parallel port should not be defined: %s", c.Parallel) - } - - if strings.ToUpper(c.Serial) != "NONE" { - t.Errorf("serial port should not be defined: %s", c.Serial) - } -} - -func TestHWConfigParallel_File(t *testing.T) { - c := new(HWConfig) - - c.Parallel = "file:filename" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasParallel() { - t.Errorf("parallel port should be defined") - } - - parallel, err := c.ReadParallel() - if err != nil { - t.Fatalf("Unable to read parallel port definition: %s", err) - } - - switch parallel.Union.(type) { - case *ParallelPortFile: - break - default: - t.Errorf("parallel port should be a file type") - } - - if parallel.File.Filename != "filename" { - t.Errorf("parallel port filename should be \"filename\": %s", parallel.File.Filename) - } -} - -func TestHWConfigParallel_Device(t *testing.T) { - c := new(HWConfig) - - c.Parallel = "device:devicename,uni" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasParallel() { - t.Errorf("parallel port should be defined") - } - - parallel, err := c.ReadParallel() - if err != nil { - t.Fatalf("Unable to read parallel port definition: %s", err) - } - - switch parallel.Union.(type) { - case *ParallelPortDevice: - break - default: - t.Errorf("parallel port should be a device type") - } - - if strings.ToLower(parallel.Device.Bidirectional) != "false" { - t.Errorf("parallel port device should not be bidirectional: %s", parallel.Device.Bidirectional) - } - - if parallel.Device.Devicename != "devicename" { - t.Errorf("parallel port device should be \"devicename\": %s", parallel.Device.Devicename) - } -} - -func TestHWConfigParallel_Auto(t *testing.T) { - c := new(HWConfig) - - c.Parallel = "auto:bi" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasParallel() { - t.Errorf("parallel port should be defined") - } - - parallel, err := c.ReadParallel() - if err != nil { - t.Fatalf("Unable to read parallel port definition: %s", err) - } - - switch parallel.Union.(type) { - case *ParallelPortAuto: - break - default: - t.Errorf("parallel port should be an auto type") - } - - if strings.ToLower(parallel.Auto.Bidirectional) != "true" { - t.Errorf("parallel port device should be bidirectional: %s", parallel.Auto.Bidirectional) - } -} - -func TestHWConfigParallel_None(t *testing.T) { - c := new(HWConfig) - - c.Parallel = "none" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasParallel() { - t.Errorf("parallel port should be defined") - } - - parallel, err := c.ReadParallel() - if err != nil { - t.Fatalf("Unable to read parallel port definition: %s", err) - } - - if parallel.Union != nil { - t.Errorf("parallel port shouldn't exist") - } -} - -func TestHWConfigSerial_File(t *testing.T) { - c := new(HWConfig) - - c.Serial = "file:filename,true" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasSerial() { - t.Errorf("serial port should be defined") - } - - serial, err := c.ReadSerial() - if err != nil { - t.Fatalf("Unable to read serial port definition: %s", err) - } - - switch serial.Union.(type) { - case *SerialConfigFile: - break - default: - t.Errorf("serial port should be a file type") - } - - if serial.File.Filename != "filename" { - t.Errorf("serial port filename should be \"filename\": %s", serial.File.Filename) - } - - if strings.ToLower(serial.File.Yield) != "true" { - t.Errorf("serial port yield should be true: %s", serial.File.Yield) - } -} - -func TestHWConfigSerial_Device(t *testing.T) { - c := new(HWConfig) - - c.Serial = "device:devicename,true" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasSerial() { - t.Errorf("serial port should be defined") - } - - serial, err := c.ReadSerial() - if err != nil { - t.Fatalf("Unable to read serial port definition: %s", err) - } - - switch serial.Union.(type) { - case *SerialConfigDevice: - break - default: - t.Errorf("serial port should be a device type") - } - - if serial.Device.Devicename != "devicename" { - t.Errorf("serial port device should be \"devicename\": %s", serial.Device.Devicename) - } - - if strings.ToLower(serial.Device.Yield) != "true" { - t.Errorf("serial port device should yield: %s", serial.Device.Yield) - } -} - -func TestHWConfigSerial_Pipe(t *testing.T) { - c := new(HWConfig) - - c.Serial = "pipe:mypath,client,app,true" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasSerial() { - t.Errorf("serial port should be defined") - } - - serial, err := c.ReadSerial() - if err != nil { - t.Fatalf("Unable to read serial port definition: %s", err) - } - - switch serial.Union.(type) { - case *SerialConfigPipe: - break - default: - t.Errorf("serial port should be a pipe type") - } - - if serial.Pipe.Filename != "mypath" { - t.Errorf("serial port pipe name should be \"mypath\": %s", serial.Pipe.Filename) - } - - if strings.ToLower(serial.Pipe.Endpoint) != "client" { - t.Errorf("serial port endpoint should be \"client\": %s", serial.Pipe.Endpoint) - } - - if strings.ToLower(serial.Pipe.Host) != "true" { - t.Errorf("serial port host type for app should be true: %s", serial.Pipe.Host) - } - - if strings.ToLower(serial.Pipe.Yield) != "true" { - t.Errorf("serial port should yield: %s", serial.Pipe.Yield) - } -} - -func TestHWConfigSerial_Auto(t *testing.T) { - c := new(HWConfig) - - c.Serial = "auto:true" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasSerial() { - t.Errorf("serial port should be defined") - } - - serial, err := c.ReadSerial() - if err != nil { - t.Fatalf("Unable to read serial port definition: %s", err) - } - - switch serial.Union.(type) { - case *SerialConfigAuto: - break - default: - t.Errorf("serial port should be an auto type") - } - - if strings.ToLower(serial.Auto.Yield) != "true" { - t.Errorf("serial port should yield: %s", serial.Auto.Yield) - } -} - -func TestHWConfigSerial_None(t *testing.T) { - c := new(HWConfig) - - c.Serial = "none" - if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if !c.HasSerial() { - t.Errorf("serial port should be defined") - } - - serial, err := c.ReadSerial() - if err != nil { - t.Fatalf("Unable to read serial port definition: %s", err) - } - - if serial.Union != nil { - t.Errorf("serial port shouldn't exist") - } -} diff --git a/builder/vmware/common/output_config_test.go b/builder/vmware/common/output_config_test.go deleted file mode 100644 index dddf61561..000000000 --- a/builder/vmware/common/output_config_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package common - -import ( - "testing" - - "github.com/hashicorp/packer-plugin-sdk/common" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func TestOutputConfigPrepare(t *testing.T) { - c := new(OutputConfig) - if c.OutputDir != "" { - t.Fatalf("what: %s", c.OutputDir) - } - - pc := &common.PackerConfig{PackerBuildName: "foo"} - errs := c.Prepare(interpolate.NewContext(), pc) - if len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if c.OutputDir == "" { - t.Fatal("should have output dir") - } -} diff --git a/builder/vmware/common/output_dir_local_test.go b/builder/vmware/common/output_dir_local_test.go deleted file mode 100644 index 3026c6c66..000000000 --- a/builder/vmware/common/output_dir_local_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package common - -import ( - "testing" -) - -func TestLocalOutputDir_impl(t *testing.T) { - var _ OutputDir = new(LocalOutputDir) -} diff --git a/builder/vmware/common/remote_driver_mock_test.go b/builder/vmware/common/remote_driver_mock_test.go deleted file mode 100644 index 110e4990b..000000000 --- a/builder/vmware/common/remote_driver_mock_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package common - -import ( - "testing" -) - -func TestRemoteDriverMock_impl(t *testing.T) { - var _ Driver = new(RemoteDriverMock) - var _ RemoteDriver = new(RemoteDriverMock) -} diff --git a/builder/vmware/common/run_config_test.go b/builder/vmware/common/run_config_test.go deleted file mode 100644 index 8c71938b3..000000000 --- a/builder/vmware/common/run_config_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package common - -import ( - "fmt" - "reflect" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/hashicorp/packer-plugin-sdk/bootcommand" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func TestRunConfig_Prepare(t *testing.T) { - tc := []struct { - name string - config *RunConfig - expectedConfig *RunConfig - driver *DriverConfig - errs []error - warnings []string - }{ - { - name: "VNC dafaults", - config: &RunConfig{}, - expectedConfig: &RunConfig{ - VNCPortMin: 5900, - VNCPortMax: 6000, - VNCBindAddress: "127.0.0.1", - }, - driver: new(DriverConfig), - errs: nil, - warnings: nil, - }, - { - name: "VNC port min less than vnc port max", - config: &RunConfig{ - VNCPortMin: 5000, - VNCPortMax: 5900, - }, - expectedConfig: &RunConfig{ - VNCPortMin: 5000, - VNCPortMax: 5900, - VNCBindAddress: "127.0.0.1", - }, - driver: new(DriverConfig), - errs: nil, - warnings: nil, - }, - { - name: "VNC port min bigger than vnc port max", - config: &RunConfig{ - VNCPortMin: 5900, - VNCPortMax: 5000, - }, - expectedConfig: nil, - driver: new(DriverConfig), - errs: []error{fmt.Errorf("vnc_port_min must be less than vnc_port_max")}, - warnings: nil, - }, - { - name: "VNC port min must be positive", - config: &RunConfig{ - VNCPortMin: -1, - }, - expectedConfig: nil, - driver: new(DriverConfig), - errs: []error{fmt.Errorf("vnc_port_min must be positive")}, - warnings: nil, - }, - { - name: "fail when vnc_over_websocket set when remote_type is not set", - config: &RunConfig{ - VNCOverWebsocket: true, - }, - expectedConfig: nil, - driver: new(DriverConfig), - errs: []error{fmt.Errorf("'vnc_over_websocket' can only be used with remote VMWare builds.")}, - warnings: nil, - }, - { - name: "warn about ignored vnc configuration", - config: &RunConfig{ - VNCOverWebsocket: true, - VNCPortMin: 5000, - VNCPortMax: 5900, - }, - expectedConfig: &RunConfig{ - VNCOverWebsocket: true, - VNCPortMin: 5000, - VNCPortMax: 5900, - }, - driver: &DriverConfig{RemoteType: "esxi"}, - errs: nil, - warnings: []string{"[WARN] When 'vnc_over_websocket' is set " + - "any other VNC configuration will be ignored."}, - }, - } - - for _, c := range tc { - t.Run(c.name, func(t *testing.T) { - warnings, errs := c.config.Prepare(interpolate.NewContext(), c.driver) - if !reflect.DeepEqual(errs, c.errs) { - t.Fatalf("bad: \n expected '%v' \nactual '%v'", c.errs, errs) - } - if diff := cmp.Diff(warnings, c.warnings); diff != "" { - t.Fatalf("unexpected warnings: %s", diff) - } - if len(c.errs) == 0 { - if diff := cmp.Diff(c.config, c.expectedConfig, - cmpopts.IgnoreFields(bootcommand.VNCConfig{}, - "BootConfig", - )); diff != "" { - t.Fatalf("unexpected config: %s", diff) - } - } - }) - } -} diff --git a/builder/vmware/common/ssh_config_test.go b/builder/vmware/common/ssh_config_test.go deleted file mode 100644 index d41781044..000000000 --- a/builder/vmware/common/ssh_config_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package common - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/communicator" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func testSSHConfig() *SSHConfig { - return &SSHConfig{ - Comm: communicator.Config{ - SSH: communicator.SSH{ - SSHUsername: "foo", - }, - }, - } -} - -func TestSSHConfigPrepare(t *testing.T) { - c := testSSHConfig() - errs := c.Prepare(interpolate.NewContext()) - if len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if c.Comm.SSHPort != 22 { - t.Errorf("bad ssh port: %d", c.Comm.SSHPort) - } -} - -func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) { - var c *SSHConfig - var errs []error - - c = testSSHConfig() - c.Comm.SSHPrivateKeyFile = "" - errs = c.Prepare(interpolate.NewContext()) - if len(errs) > 0 { - t.Fatalf("should not have error: %#v", errs) - } - - c = testSSHConfig() - c.Comm.SSHPrivateKeyFile = "/i/dont/exist" - errs = c.Prepare(interpolate.NewContext()) - if len(errs) == 0 { - t.Fatal("should have error") - } - - // Test bad contents - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.Remove(tf.Name()) - defer tf.Close() - - if _, err := tf.Write([]byte("HELLO!")); err != nil { - t.Fatalf("err: %s", err) - } - - c = testSSHConfig() - c.Comm.SSHPrivateKeyFile = tf.Name() - errs = c.Prepare(interpolate.NewContext()) - if len(errs) == 0 { - t.Fatal("should have error") - } - - // Test good contents - tf.Seek(0, 0) - tf.Truncate(0) - tf.Write([]byte(testPem)) - c = testSSHConfig() - c.Comm.SSHPrivateKeyFile = tf.Name() - errs = c.Prepare(interpolate.NewContext()) - if len(errs) > 0 { - t.Fatalf("should not have error: %#v", errs) - } -} - -const testPem = ` ------BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAxd4iamvrwRJvtNDGQSIbNvvIQN8imXTRWlRY62EvKov60vqu -hh+rDzFYAIIzlmrJopvOe0clqmi3mIP9dtkjPFrYflq52a2CF5q+BdwsJXuRHbJW -LmStZUwW1khSz93DhvhmK50nIaczW63u4EO/jJb3xj+wxR1Nkk9bxi3DDsYFt8SN -AzYx9kjlEYQ/+sI4/ATfmdV9h78SVotjScupd9KFzzi76gWq9gwyCBLRynTUWlyD -2UOfJRkOvhN6/jKzvYfVVwjPSfA9IMuooHdScmC4F6KBKJl/zf/zETM0XyzIDNmH -uOPbCiljq2WoRM+rY6ET84EO0kVXbfx8uxUsqQIDAQABAoIBAQCkPj9TF0IagbM3 -5BSs/CKbAWS4dH/D4bPlxx4IRCNirc8GUg+MRb04Xz0tLuajdQDqeWpr6iLZ0RKV -BvreLF+TOdV7DNQ4XE4gSdJyCtCaTHeort/aordL3l0WgfI7mVk0L/yfN1PEG4YG -E9q1TYcyrB3/8d5JwIkjabxERLglCcP+geOEJp+QijbvFIaZR/n2irlKW4gSy6ko -9B0fgUnhkHysSg49ChHQBPQ+o5BbpuLrPDFMiTPTPhdfsvGGcyCGeqfBA56oHcSF -K02Fg8OM+Bd1lb48LAN9nWWY4WbwV+9bkN3Ym8hO4c3a/Dxf2N7LtAQqWZzFjvM3 -/AaDvAgBAoGBAPLD+Xn1IYQPMB2XXCXfOuJewRY7RzoVWvMffJPDfm16O7wOiW5+ -2FmvxUDayk4PZy6wQMzGeGKnhcMMZTyaq2g/QtGfrvy7q1Lw2fB1VFlVblvqhoJa -nMJojjC4zgjBkXMHsRLeTmgUKyGs+fdFbfI6uejBnnf+eMVUMIdJ+6I9AoGBANCn -kWO9640dttyXURxNJ3lBr2H3dJOkmD6XS+u+LWqCSKQe691Y/fZ/ZL0Oc4Mhy7I6 -hsy3kDQ5k2V0fkaNODQIFJvUqXw2pMewUk8hHc9403f4fe9cPrL12rQ8WlQw4yoC -v2B61vNczCCUDtGxlAaw8jzSRaSI5s6ax3K7enbdAoGBAJB1WYDfA2CoAQO6y9Sl -b07A/7kQ8SN5DbPaqrDrBdJziBQxukoMJQXJeGFNUFD/DXFU5Fp2R7C86vXT7HIR -v6m66zH+CYzOx/YE6EsUJms6UP9VIVF0Rg/RU7teXQwM01ZV32LQ8mswhTH20o/3 -uqMHmxUMEhZpUMhrfq0isyApAoGAe1UxGTXfj9AqkIVYylPIq2HqGww7+jFmVEj1 -9Wi6S6Sq72ffnzzFEPkIQL/UA4TsdHMnzsYKFPSbbXLIWUeMGyVTmTDA5c0e5XIR -lPhMOKCAzv8w4VUzMnEkTzkFY5JqFCD/ojW57KvDdNZPVB+VEcdxyAW6aKELXMAc -eHLc1nkCgYEApm/motCTPN32nINZ+Vvywbv64ZD+gtpeMNP3CLrbe1X9O+H52AXa -1jCoOldWR8i2bs2NVPcKZgdo6fFULqE4dBX7Te/uYEIuuZhYLNzRO1IKU/YaqsXG -3bfQ8hKYcSnTfE0gPtLDnqCIxTocaGLSHeG3TH9fTw+dA8FvWpUztI4= ------END RSA PRIVATE KEY----- -` diff --git a/builder/vmware/common/ssh_test.go b/builder/vmware/common/ssh_test.go deleted file mode 100644 index fef692e48..000000000 --- a/builder/vmware/common/ssh_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package common - -import ( - "testing" - - "github.com/hashicorp/packer-plugin-sdk/communicator" -) - -func TestCommHost(t *testing.T) { - state := testState(t) - config := SSHConfig{ - Comm: communicator.Config{ - Type: "ssh", - SSH: communicator.SSH{ - SSHHost: "127.0.0.1", - }, - }, - } - - hostFunc := CommHost(&config) - out, err := hostFunc(state) - if err != nil { - t.Fatalf("Should not have had an error") - } - - if out != "127.0.0.1" { - t.Fatalf("Should have respected ssh override.") - } -} diff --git a/builder/vmware/common/step_clean_vmx_test.go b/builder/vmware/common/step_clean_vmx_test.go deleted file mode 100644 index ac319e946..000000000 --- a/builder/vmware/common/step_clean_vmx_test.go +++ /dev/null @@ -1,219 +0,0 @@ -package common - -import ( - "context" - "io/ioutil" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepCleanVMX_impl(t *testing.T) { - var _ multistep.Step = new(StepCleanVMX) -} - -func TestStepCleanVMX(t *testing.T) { - state := testState(t) - step := new(StepCleanVMX) - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - state.Put("vmx_path", vmxPath) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } -} - -func TestStepCleanVMX_floppyPath(t *testing.T) { - state := testState(t) - step := new(StepCleanVMX) - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - if err := ioutil.WriteFile(vmxPath, []byte(testVMXFloppyPath), 0644); err != nil { - t.Fatalf("err: %s", err) - } - - // Set the path to the temporary vmx - state.Put("vmx_path", vmxPath) - - // Add the floppy device to the list of temporary build devices - state.Put("temporaryDevices", []string{"floppy0"}) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the resulting data - vmxContents, err := ioutil.ReadFile(vmxPath) - if err != nil { - t.Fatalf("err: %s", err) - } - vmxData := ParseVMX(string(vmxContents)) - - cases := []struct { - Key string - Value string - }{ - {"floppy0.present", "FALSE"}, - {"floppy0.filetype", ""}, - {"floppy0.filename", ""}, - } - - for _, tc := range cases { - if tc.Value == "" { - if _, ok := vmxData[tc.Key]; ok { - t.Fatalf("should not have key: %s", tc.Key) - } - } else { - if vmxData[tc.Key] != tc.Value { - t.Fatalf("bad: %s %#v", tc.Key, vmxData[tc.Key]) - } - } - } -} - -func TestStepCleanVMX_isoPath(t *testing.T) { - state := testState(t) - step := new(StepCleanVMX) - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - if err := ioutil.WriteFile(vmxPath, []byte(testVMXISOPath), 0644); err != nil { - t.Fatalf("err: %s", err) - } - - // Set the path to the temporary vmx - state.Put("vmx_path", vmxPath) - - // Add the cdrom device to the list of temporary build devices - state.Put("temporaryDevices", []string{"ide0:0"}) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the resulting data - vmxContents, err := ioutil.ReadFile(vmxPath) - if err != nil { - t.Fatalf("err: %s", err) - } - vmxData := ParseVMX(string(vmxContents)) - - cases := []struct { - Key string - Value string - }{ - {"ide0:0.filename", "auto detect"}, - {"ide0:0.devicetype", "cdrom-raw"}, - {"ide0:1.filename", "bar"}, - {"foo", "bar"}, - } - - for _, tc := range cases { - if tc.Value == "" { - if _, ok := vmxData[tc.Key]; ok { - t.Fatalf("should not have key: %s", tc.Key) - } - } else { - if vmxData[tc.Key] != tc.Value { - t.Fatalf("bad: %s %#v", tc.Key, vmxData[tc.Key]) - } - } - } -} - -func TestStepCleanVMX_ethernet(t *testing.T) { - state := testState(t) - step := &StepCleanVMX{ - RemoveEthernetInterfaces: true, - } - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - if err := ioutil.WriteFile(vmxPath, []byte(testVMXEthernet), 0644); err != nil { - t.Fatalf("err: %s", err) - } - - // Set the path to the temporary vmx - state.Put("vmx_path", vmxPath) - - // TODO: Add the ethernet devices to the list of temporary build devices - // state.Put("temporaryDevices", []string{"ethernet0", "ethernet1"}) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the resulting data - vmxContents, err := ioutil.ReadFile(vmxPath) - if err != nil { - t.Fatalf("err: %s", err) - } - vmxData := ParseVMX(string(vmxContents)) - - cases := []struct { - Key string - Value string - }{ - {"ethernet0.addresstype", ""}, - {"ethernet0.bsdname", ""}, - {"ethernet0.connectiontype", ""}, - {"ethernet1.addresstype", ""}, - {"ethernet1.bsdname", ""}, - {"ethernet1.connectiontype", ""}, - {"foo", "bar"}, - } - - for _, tc := range cases { - if tc.Value == "" { - if _, ok := vmxData[tc.Key]; ok { - t.Fatalf("should not have key: %s", tc.Key) - } - } else { - if vmxData[tc.Key] != tc.Value { - t.Fatalf("bad: %s %#v", tc.Key, vmxData[tc.Key]) - } - } - } -} - -const testVMXFloppyPath = ` -floppy0.present = "TRUE" -floppy0.filetype = "file" -` - -const testVMXISOPath = ` -ide0:0.devicetype = "cdrom-image" -ide0:0.filename = "foo" -ide0:1.filename = "bar" -foo = "bar" -` - -const testVMXEthernet = ` -ethernet0.addresstype = "generated" -ethernet0.bsdname = "en0" -ethernet0.connectiontype = "nat" -ethernet1.addresstype = "generated" -ethernet1.bsdname = "en1" -ethernet1.connectiontype = "nat" -foo = "bar" -` diff --git a/builder/vmware/common/step_compact_disk_test.go b/builder/vmware/common/step_compact_disk_test.go deleted file mode 100644 index c4a2c8699..000000000 --- a/builder/vmware/common/step_compact_disk_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package common - -import ( - "context" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepCompactDisk_impl(t *testing.T) { - var _ multistep.Step = new(StepCompactDisk) -} - -func TestStepCompactDisk(t *testing.T) { - state := testState(t) - step := new(StepCompactDisk) - - diskFullPaths := []string{"foo"} - state.Put("disk_full_paths", diskFullPaths) - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.CompactDiskCalled { - t.Fatal("should've called") - } - if driver.CompactDiskPath != "foo" { - t.Fatal("should call with right path") - } -} - -func TestStepCompactDisk_skip(t *testing.T) { - state := testState(t) - step := new(StepCompactDisk) - step.Skip = true - - diskFullPaths := []string{"foo"} - state.Put("disk_full_paths", diskFullPaths) - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if driver.CompactDiskCalled { - t.Fatal("should not have called") - } -} diff --git a/builder/vmware/common/step_configure_vmx_test.go b/builder/vmware/common/step_configure_vmx_test.go deleted file mode 100644 index dce4cb7f4..000000000 --- a/builder/vmware/common/step_configure_vmx_test.go +++ /dev/null @@ -1,379 +0,0 @@ -package common - -import ( - "context" - "io/ioutil" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - "github.com/stretchr/testify/assert" -) - -func testVMXFile(t *testing.T) string { - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - - // displayName must always be set - err = WriteVMX(tf.Name(), map[string]string{"displayName": "PackerBuild"}) - if err != nil { - t.Fatalf("error writing .vmx file: %v", err) - } - tf.Close() - - return tf.Name() -} - -func TestStepConfigureVMX_impl(t *testing.T) { - var _ multistep.Step = new(StepConfigureVMX) -} - -func TestStepConfigureVMX(t *testing.T) { - state := testState(t) - step := new(StepConfigureVMX) - step.CustomData = map[string]string{ - "foo": "bar", - } - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - state.Put("vmx_path", vmxPath) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the resulting data - vmxContents, err := ioutil.ReadFile(vmxPath) - if err != nil { - t.Fatalf("err: %s", err) - } - vmxData := ParseVMX(string(vmxContents)) - - cases := []struct { - Key string - Value string - }{ - // Stuff we set - {"msg.autoanswer", "true"}, - {"uuid.action", "create"}, - - // Custom data - {"foo", "bar"}, - - // Stuff that should NOT exist - {"floppy0.present", ""}, - } - - for _, tc := range cases { - if tc.Value == "" { - if _, ok := vmxData[tc.Key]; ok { - t.Fatalf("should not have key: %s", tc.Key) - } - } else { - if vmxData[tc.Key] != tc.Value { - t.Fatalf("bad: %s %#v", tc.Key, vmxData[tc.Key]) - } - } - } -} - -func TestStepConfigureVMX_floppyPath(t *testing.T) { - state := testState(t) - step := new(StepConfigureVMX) - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - - state.Put("floppy_path", "foo") - state.Put("vmx_path", vmxPath) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the resulting data - vmxContents, err := ioutil.ReadFile(vmxPath) - if err != nil { - t.Fatalf("err: %s", err) - } - vmxData := ParseVMX(string(vmxContents)) - - cases := []struct { - Key string - Value string - }{ - {"floppy0.present", "TRUE"}, - {"floppy0.filetype", "file"}, - {"floppy0.filename", "foo"}, - } - - for _, tc := range cases { - if tc.Value == "" { - if _, ok := vmxData[tc.Key]; ok { - t.Fatalf("should not have key: %s", tc.Key) - } - } else { - if vmxData[tc.Key] != tc.Value { - t.Fatalf("bad: %s %#v", tc.Key, vmxData[tc.Key]) - } - } - } - -} - -func TestStepConfigureVMX_generatedAddresses(t *testing.T) { - state := testState(t) - step := new(StepConfigureVMX) - - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - - additionalTestVmxData := []struct { - Key string - Value string - }{ - {"foo", "bar"}, - {"ethernet0.generatedaddress", "foo"}, - {"ethernet1.generatedaddress", "foo"}, - {"ethernet1.generatedaddressoffset", "foo"}, - } - - // Get any existing VMX data from the VMX file - vmxData, err := ReadVMX(vmxPath) - if err != nil { - t.Fatalf("err %s", err) - } - - // Add the additional key/value pairs we need for this test to the existing VMX data - for _, data := range additionalTestVmxData { - vmxData[data.Key] = data.Value - } - - // Recreate the VMX file so it includes all the data needed for this test - err = WriteVMX(vmxPath, vmxData) - if err != nil { - t.Fatalf("err: %s", err) - } - - state.Put("vmx_path", vmxPath) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the resulting data - vmxContents, err := ioutil.ReadFile(vmxPath) - if err != nil { - t.Fatalf("err: %s", err) - } - vmxData = ParseVMX(string(vmxContents)) - - cases := []struct { - Key string - Value string - }{ - {"foo", "bar"}, - {"ethernet0.generatedaddress", ""}, - {"ethernet1.generatedaddress", ""}, - {"ethernet1.generatedaddressoffset", ""}, - } - - for _, tc := range cases { - if tc.Value == "" { - if _, ok := vmxData[tc.Key]; ok { - t.Fatalf("should not have key: %s", tc.Key) - } - } else { - if vmxData[tc.Key] != tc.Value { - t.Fatalf("bad: %s %#v", tc.Key, vmxData[tc.Key]) - } - } - } -} - -// Should fail if the displayName key is not found in the VMX -func TestStepConfigureVMX_displayNameMissing(t *testing.T) { - state := testState(t) - step := new(StepConfigureVMX) - - // testVMXFile adds displayName key/value pair to the VMX - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - - // Bad: Delete displayName from the VMX/Create an empty VMX file - err := WriteVMX(vmxPath, map[string]string{}) - if err != nil { - t.Fatalf("err: %s", err) - } - - state.Put("vmx_path", vmxPath) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v. Should halt when displayName key is missing from VMX", action) - } - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should store error in state when displayName key is missing from VMX") - } -} - -// Should store the value of displayName in the statebag -func TestStepConfigureVMX_displayNameStore(t *testing.T) { - state := testState(t) - step := new(StepConfigureVMX) - - // testVMXFile adds displayName key/value pair to the VMX - vmxPath := testVMXFile(t) - defer os.Remove(vmxPath) - - state.Put("vmx_path", vmxPath) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // The value of displayName must be stored in the statebag - if _, ok := state.GetOk("display_name"); !ok { - t.Fatalf("displayName should be stored in the statebag as 'display_name'") - } -} - -func TestStepConfigureVMX_vmxPathBad(t *testing.T) { - state := testState(t) - step := new(StepConfigureVMX) - - state.Put("vmx_path", "some_bad_path") - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v. Should halt when vmxPath is bad", action) - } - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should store error in state when vmxPath is bad") - } - -} - -func TestStepConfigureVMX_DefaultDiskAndCDROMTypes(t *testing.T) { - type testCase struct { - inDiskAdapter string - inCDromAdapter string - expectedOut DiskAndCDConfigData - reason string - } - testcases := []testCase{ - { - inDiskAdapter: "", - inCDromAdapter: "", - expectedOut: DiskAndCDConfigData{ - SCSI_Present: "TRUE", - SCSI_diskAdapterType: "", - SATA_Present: "FALSE", - NVME_Present: "FALSE", - - DiskType: "scsi", - CDROMType: "ide", - CDROMType_PrimarySecondary: "0", - }, - reason: "Test that default creases scsi disk with ide cd", - }, - { - inDiskAdapter: "ide", - inCDromAdapter: "", - expectedOut: DiskAndCDConfigData{ - SCSI_Present: "FALSE", - SCSI_diskAdapterType: "lsilogic", - SATA_Present: "FALSE", - NVME_Present: "FALSE", - - DiskType: "ide", - CDROMType: "ide", - CDROMType_PrimarySecondary: "1", - }, - reason: "ide disk adapter should pass through and not get defaulted to scsi", - }, - { - inDiskAdapter: "sata", - inCDromAdapter: "", - expectedOut: DiskAndCDConfigData{ - SCSI_Present: "FALSE", - SCSI_diskAdapterType: "lsilogic", - SATA_Present: "TRUE", - NVME_Present: "FALSE", - - DiskType: "sata", - CDROMType: "sata", - CDROMType_PrimarySecondary: "1", - }, - reason: "when disk is set to sata, cdromtype should also default to sata", - }, - { - inDiskAdapter: "nvme", - inCDromAdapter: "", - expectedOut: DiskAndCDConfigData{ - SCSI_Present: "FALSE", - SCSI_diskAdapterType: "lsilogic", - SATA_Present: "TRUE", - NVME_Present: "TRUE", - - DiskType: "nvme", - CDROMType: "sata", - CDROMType_PrimarySecondary: "0", - }, - reason: "when disk is set to nvme, cdromtype should default to sata", - }, - { - inDiskAdapter: "scsi", - inCDromAdapter: "", - expectedOut: DiskAndCDConfigData{ - SCSI_Present: "TRUE", - SCSI_diskAdapterType: "lsilogic", - SATA_Present: "FALSE", - NVME_Present: "FALSE", - - DiskType: "scsi", - CDROMType: "ide", - CDROMType_PrimarySecondary: "0", - }, - reason: "when disk is set to scsi, adapter should default back to lsilogic", - }, - { - inDiskAdapter: "scsi", - inCDromAdapter: "scsi", - expectedOut: DiskAndCDConfigData{ - SCSI_Present: "TRUE", - SCSI_diskAdapterType: "lsilogic", - SATA_Present: "FALSE", - NVME_Present: "FALSE", - - DiskType: "scsi", - CDROMType: "scsi", - CDROMType_PrimarySecondary: "0", - }, - reason: "when cdrom adapter is set, it should override the default", - }, - } - for _, tc := range testcases { - diskConfigData := DefaultDiskAndCDROMTypes(tc.inDiskAdapter, tc.inCDromAdapter) - assert.Equal(t, diskConfigData, tc.expectedOut, tc.reason) - } -} diff --git a/builder/vmware/common/step_configure_vnc_test.go b/builder/vmware/common/step_configure_vnc_test.go deleted file mode 100644 index a89b75999..000000000 --- a/builder/vmware/common/step_configure_vnc_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package common - -import ( - "fmt" - "testing" -) - -func TestStepConfigureVNC_implVNCAddressFinder(t *testing.T) { - var _ VNCAddressFinder = new(StepConfigureVNC) -} - -func TestStepConfigureVNC_UpdateVMX(t *testing.T) { - var s StepConfigureVNC - data := make(map[string]string) - s.UpdateVMX("0.0.0.0", "", 5900, data) - if ip := data["remotedisplay.vnc.ip"]; ip != "0.0.0.0" { - t.Errorf("bad VMX data for key remotedisplay.vnc.ip: %v", ip) - } - if enabled := data["remotedisplay.vnc.enabled"]; enabled != "TRUE" { - t.Errorf("bad VMX data for key remotedisplay.vnc.enabled: %v", enabled) - } - if port := data["remotedisplay.vnc.port"]; port != fmt.Sprint(port) { - t.Errorf("bad VMX data for key remotedisplay.vnc.port: %v", port) - } -} diff --git a/builder/vmware/common/step_create_disks_test.go b/builder/vmware/common/step_create_disks_test.go deleted file mode 100644 index afe357df5..000000000 --- a/builder/vmware/common/step_create_disks_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package common - -import ( - "context" - "path/filepath" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - "github.com/stretchr/testify/assert" -) - -func TestStepCreateDisks_impl(t *testing.T) { - var _ multistep.Step = new(StepCreateDisks) -} - -func strPtr(s string) *string { - return &s -} -func NewTestCreateDiskStep() *StepCreateDisks { - return &StepCreateDisks{ - OutputDir: strPtr("output_dir"), - CreateMainDisk: true, - DiskName: "disk_name", - MainDiskSize: uint(1024), - AdditionalDiskSize: []uint{}, - DiskAdapterType: "fake_adapter", - DiskTypeId: "1", - } -} - -func TestStepCreateDisks_MainOnly(t *testing.T) { - state := testState(t) - step := NewTestCreateDiskStep() - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - driver := state.Get("driver").(*DriverMock) - if !driver.CreateDiskCalled { - t.Fatalf("Should have called create disk.") - } - - diskFullPaths, ok := state.Get("disk_full_paths").([]string) - if !ok { - t.Fatalf("Should be able to load disk_full_paths from state") - } - - assert.Equal(t, diskFullPaths, []string{filepath.Join("output_dir", "disk_name.vmdk")}) - - // Cleanup - step.Cleanup(state) -} - -func TestStepCreateDisks_MainAndExtra(t *testing.T) { - state := testState(t) - step := NewTestCreateDiskStep() - step.AdditionalDiskSize = []uint{1024, 2048, 4096} - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - driver := state.Get("driver").(*DriverMock) - if !driver.CreateDiskCalled { - t.Fatalf("Should have called create disk.") - } - - diskFullPaths, ok := state.Get("disk_full_paths").([]string) - if !ok { - t.Fatalf("Should be able to load disk_full_paths from state") - } - - assert.Equal(t, diskFullPaths, - []string{ - filepath.Join("output_dir", "disk_name.vmdk"), - filepath.Join("output_dir", "disk_name-1.vmdk"), - filepath.Join("output_dir", "disk_name-2.vmdk"), - filepath.Join("output_dir", "disk_name-3.vmdk"), - }) - // Cleanup - step.Cleanup(state) -} - -func TestStepCreateDisks_ExtraOnly(t *testing.T) { - state := testState(t) - step := NewTestCreateDiskStep() - step.CreateMainDisk = false - step.AdditionalDiskSize = []uint{1024, 2048, 4096} - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - driver := state.Get("driver").(*DriverMock) - if !driver.CreateDiskCalled { - t.Fatalf("Should have called create disk.") - } - - diskFullPaths, ok := state.Get("disk_full_paths").([]string) - if !ok { - t.Fatalf("Should be able to load disk_full_paths from state") - } - - assert.Equal(t, diskFullPaths, - []string{ - filepath.Join("output_dir", "disk_name-1.vmdk"), - filepath.Join("output_dir", "disk_name-2.vmdk"), - filepath.Join("output_dir", "disk_name-3.vmdk"), - }) - - // Cleanup - step.Cleanup(state) -} - -func TestStepCreateDisks_Nothing(t *testing.T) { - state := testState(t) - step := NewTestCreateDiskStep() - step.CreateMainDisk = false - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - driver := state.Get("driver").(*DriverMock) - if driver.CreateDiskCalled { - t.Fatalf("Should not have called create disk.") - } - - // Cleanup - step.Cleanup(state) -} diff --git a/builder/vmware/common/step_export_test.go b/builder/vmware/common/step_export_test.go deleted file mode 100644 index b462dd2b0..000000000 --- a/builder/vmware/common/step_export_test.go +++ /dev/null @@ -1,233 +0,0 @@ -package common - -import ( - "context" - "path/filepath" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - "github.com/stretchr/testify/assert" -) - -func TestStepExport_impl(t *testing.T) { - var _ multistep.Step = new(StepExport) -} - -func stringPointer(s string) *string { - return &s -} - -func remoteExportTestState(t *testing.T) multistep.StateBag { - state := testState(t) - driverConfig := &DriverConfig{ - RemoteHost: "123.45.67.8", - RemotePassword: "password", - RemoteUser: "user", - RemoteType: "esx5", - } - state.Put("driverConfig", driverConfig) - state.Put("display_name", "vm_name") - return state -} - -func TestStepExport_ReturnIfSkip(t *testing.T) { - state := testState(t) - driverConfig := &DriverConfig{} - state.Put("driverConfig", driverConfig) - step := new(StepExport) - - step.SkipExport = true - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // We told step to skip so it should not have reached the driver's Export - // func. - d := state.Get("driver").(*DriverMock) - if d.ExportCalled { - t.Fatal("Should not have called the driver export func") - } - - // Cleanup - step.Cleanup(state) -} - -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. - state := testState(t) - driverConfig := &DriverConfig{} - state.Put("driverConfig", driverConfig) - step := new(StepExport) - - step.SkipExport = false - step.OutputDir = stringPointer("test-output") - step.VMName = "test-name" - step.Format = "ova" - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Check that step ran, and called Export with the expected args. - d := state.Get("driver").(*DriverMock) - if !d.ExportCalled { - t.Fatal("Should have called the driver export func") - } - - assert.Equal(t, d.ExportArgs, - []string{ - filepath.Join("test-output", "test-name.vmx"), - filepath.Join("test-output", "test-name.ova")}) - - // Cleanup - step.Cleanup(state) -} - -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. - state := testState(t) - driverConfig := &DriverConfig{} - state.Put("driverConfig", driverConfig) - state.Put("export_output_path", "local_output") - step := new(StepExport) - - step.SkipExport = false - step.OutputDir = stringPointer("test-output") - step.VMName = "test-name" - step.Format = "ova" - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Check that step ran, and called Export with the expected args. - d := state.Get("driver").(*DriverMock) - if !d.ExportCalled { - t.Fatal("Should have called the driver export func") - } - - assert.Equal(t, d.ExportArgs, - []string{ - filepath.Join("local_output", "test-name.vmx"), - filepath.Join("local_output", "test-name.ova")}) - - // Cleanup - step.Cleanup(state) -} - -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. - state := testState(t) - driverConfig := &DriverConfig{} - state.Put("driverConfig", driverConfig) - step := new(StepExport) - - step.SkipExport = false - step.OutputDir = stringPointer("test-output") - step.VMName = "test-name" - step.Format = "ova" - step.OVFToolOptions = []string{"--option=value", "--second-option=\"quoted value\""} - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Check that step ran, and called Export with the expected args. - d := state.Get("driver").(*DriverMock) - if !d.ExportCalled { - t.Fatal("Should have called the driver export func") - } - - assert.Equal(t, d.ExportArgs, []string{"--option=value", - "--second-option=\"quoted value\"", - filepath.Join("test-output", "test-name.vmx"), - filepath.Join("test-output", "test-name.ova")}) - - // Cleanup - step.Cleanup(state) -} - -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. - state := remoteExportTestState(t) - step := new(StepExport) - - step.SkipExport = false - step.OutputDir = stringPointer("test-output") - step.VMName = "test-name" - step.Format = "ova" - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Check that step ran, and called Export with the expected args. - d := state.Get("driver").(*DriverMock) - if !d.ExportCalled { - t.Fatal("Should have called the driver export func") - } - - assert.Equal(t, d.ExportArgs, []string{"--noSSLVerify=true", - "--skipManifestCheck", - "-tt=ova", - "vi://user:password@123.45.67.8/vm_name", - filepath.Join("test-output", "test-name.ova")}) - - // Cleanup - step.Cleanup(state) -} - -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. - state := remoteExportTestState(t) - state.Put("export_output_path", "local_output") - step := new(StepExport) - - step.SkipExport = false - step.OutputDir = stringPointer("test-output") - step.VMName = "test-name" - step.Format = "ova" - - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Check that step ran, and called Export with the expected args. - d := state.Get("driver").(*DriverMock) - if !d.ExportCalled { - t.Fatal("Should have called the driver export func") - } - - assert.Equal(t, d.ExportArgs, []string{"--noSSLVerify=true", - "--skipManifestCheck", - "-tt=ova", - "vi://user:password@123.45.67.8/vm_name", - filepath.Join("local_output", "test-name.ova")}) - - // Cleanup - step.Cleanup(state) -} diff --git a/builder/vmware/common/step_http_ip_discover_test.go b/builder/vmware/common/step_http_ip_discover_test.go deleted file mode 100644 index e0f5b6d59..000000000 --- a/builder/vmware/common/step_http_ip_discover_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package common - -import ( - "context" - "errors" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepHTTPIPDiscover_Run(t *testing.T) { - state := testState(t) - step := new(StepHTTPIPDiscover) - driverMock := state.Get("driver").(Driver) - hostIp, _ := driverMock.HostIP(state) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - httpIp := state.Get("http_ip").(string) - if httpIp != hostIp { - t.Fatalf("bad: Http ip is %s but was supposed to be %s", httpIp, hostIp) - } - - // Halt step when fails to get ip - state.Put("driver", &DriverMock{HostIPErr: errors.New("error")}) - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: step was supposed to fail %#v", action) - } -} diff --git a/builder/vmware/common/step_output_dir_test.go b/builder/vmware/common/step_output_dir_test.go deleted file mode 100644 index 9ede26abd..000000000 --- a/builder/vmware/common/step_output_dir_test.go +++ /dev/null @@ -1,224 +0,0 @@ -package common - -import ( - "context" - "io/ioutil" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func testOutputDir(t *testing.T) string { - td, err := ioutil.TempDir("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - os.RemoveAll(td) - - return td -} - -func TestStepOutputDir_impl(t *testing.T) { - var _ multistep.Step = new(StepOutputDir) -} - -func TestStepOutputDir(t *testing.T) { - state := testState(t) - driver := new(DriverMock) - state.Put("driver", driver) - - td := testOutputDir(t) - outconfig := &OutputConfig{ - OutputDir: td, - } - - step := &StepOutputDir{ - OutputConfig: outconfig, - VMName: "testVM", - } - // Delete the test output directory when done - defer os.RemoveAll(td) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - if _, err := os.Stat(td); err != nil { - t.Fatalf("err: %s", err) - } - - // Test the cleanup - step.Cleanup(state) - if _, err := os.Stat(td); err != nil { - t.Fatalf("err: %s", err) - } -} - -func TestStepOutputDir_existsNoForce(t *testing.T) { - state := testState(t) - - td := testOutputDir(t) - outconfig := &OutputConfig{ - OutputDir: td, - } - - step := &StepOutputDir{ - OutputConfig: outconfig, - VMName: "testVM", - } - // Delete the test output directory when done - defer os.RemoveAll(td) - - // Make sure the dir exists - if err := os.MkdirAll(td, 0755); err != nil { - t.Fatalf("err: %s", err) - } - defer os.RemoveAll(td) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should have error") - } - - // Test the cleanup - step.Cleanup(state) - if _, err := os.Stat(td); err != nil { - t.Fatal("should not delete dir") - } -} - -func TestStepOutputDir_existsForce(t *testing.T) { - state := testState(t) - - td := testOutputDir(t) - outconfig := &OutputConfig{ - OutputDir: td, - } - - step := &StepOutputDir{ - OutputConfig: outconfig, - VMName: "testVM", - } - step.Force = true - - // Delete the test output directory when done - defer os.RemoveAll(td) - - // Make sure the dir exists - if err := os.MkdirAll(td, 0755); err != nil { - t.Fatalf("err: %s", err) - } - defer os.RemoveAll(td) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - if _, err := os.Stat(td); err != nil { - t.Fatalf("err: %s", err) - } -} - -func TestStepOutputDir_cancel(t *testing.T) { - state := testState(t) - td := testOutputDir(t) - outconfig := &OutputConfig{ - OutputDir: td, - } - - step := &StepOutputDir{ - OutputConfig: outconfig, - VMName: "testVM", - } - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - if _, err := os.Stat(td); err != nil { - t.Fatalf("err: %s", err) - } - - // Test cancel/halt - state.Put(multistep.StateCancelled, true) - step.Cleanup(state) - if _, err := os.Stat(td); err == nil { - t.Fatal("directory should not exist") - } -} - -func TestStepOutputDir_halt(t *testing.T) { - state := testState(t) - td := testOutputDir(t) - outconfig := &OutputConfig{ - OutputDir: td, - } - - step := &StepOutputDir{ - OutputConfig: outconfig, - VMName: "testVM", - } - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - if _, err := os.Stat(td); err != nil { - t.Fatalf("err: %s", err) - } - - // Test cancel/halt - state.Put(multistep.StateHalted, true) - step.Cleanup(state) - if _, err := os.Stat(td); err == nil { - t.Fatal("directory should not exist") - } -} - -func TestStepOutputDir_Remote(t *testing.T) { - // Tests remote driver - state := testState(t) - driver := new(RemoteDriverMock) - state.Put("driver", driver) - - td := testOutputDir(t) - outconfig := &OutputConfig{ - OutputDir: td, - RemoteOutputDir: "remote_path", - } - - step := &StepOutputDir{ - OutputConfig: outconfig, - VMName: "testVM", - RemoteType: "esx5", - } - // Delete the test output directory when done - defer os.RemoveAll(td) - - // 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. - 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_prepare_tools_test.go b/builder/vmware/common/step_prepare_tools_test.go deleted file mode 100644 index 99bc9ff45..000000000 --- a/builder/vmware/common/step_prepare_tools_test.go +++ /dev/null @@ -1,178 +0,0 @@ -package common - -import ( - "context" - "io/ioutil" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepPrepareTools_impl(t *testing.T) { - var _ multistep.Step = new(StepPrepareTools) -} - -func TestStepPrepareTools(t *testing.T) { - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - tf.Close() - defer os.Remove(tf.Name()) - - state := testState(t) - step := &StepPrepareTools{ - RemoteType: "", - ToolsUploadFlavor: "foo", - } - - driver := state.Get("driver").(*DriverMock) - - // Mock results - driver.ToolsIsoPathResult = tf.Name() - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.ToolsIsoPathCalled { - t.Fatal("tools iso path should be called") - } - if driver.ToolsIsoPathFlavor != "foo" { - t.Fatalf("bad: %#v", driver.ToolsIsoPathFlavor) - } - - // Test the resulting state - path, ok := state.GetOk("tools_upload_source") - if !ok { - t.Fatal("should have tools_upload_source") - } - if path != tf.Name() { - t.Fatalf("bad: %#v", path) - } -} - -func TestStepPrepareTools_esx5(t *testing.T) { - state := testState(t) - step := &StepPrepareTools{ - RemoteType: "esx5", - ToolsUploadFlavor: "foo", - } - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if driver.ToolsIsoPathCalled { - t.Fatal("tools iso path should NOT be called") - } -} - -func TestStepPrepareTools_nonExist(t *testing.T) { - state := testState(t) - step := &StepPrepareTools{ - RemoteType: "", - ToolsUploadFlavor: "foo", - } - - driver := state.Get("driver").(*DriverMock) - - // Mock results - driver.ToolsIsoPathResult = "foo" - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should have error") - } - - // Test the driver - if !driver.ToolsIsoPathCalled { - t.Fatal("tools iso path should be called") - } - if driver.ToolsIsoPathFlavor != "foo" { - t.Fatalf("bad: %#v", driver.ToolsIsoPathFlavor) - } - - // Test the resulting state - if _, ok := state.GetOk("tools_upload_source"); ok { - t.Fatal("should NOT have tools_upload_source") - } -} - -func TestStepPrepareTools_SourcePath(t *testing.T) { - state := testState(t) - step := &StepPrepareTools{ - RemoteType: "", - ToolsSourcePath: "/path/to/tool.iso", - } - - driver := state.Get("driver").(*DriverMock) - - // Mock results - driver.ToolsIsoPathResult = "foo" - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("Should have failed when stat failed %#v", action) - } - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should have error") - } - - // Test the driver - if driver.ToolsIsoPathCalled { - t.Fatal("tools iso path should not be called when ToolsSourcePath is set") - } - - // Test the resulting state - if _, ok := state.GetOk("tools_upload_source"); ok { - t.Fatal("should NOT have tools_upload_source") - } -} - -func TestStepPrepareTools_SourcePath_exists(t *testing.T) { - state := testState(t) - step := &StepPrepareTools{ - RemoteType: "", - ToolsSourcePath: "./step_prepare_tools.go", - } - - driver := state.Get("driver").(*DriverMock) - - // Mock results - driver.ToolsIsoPathResult = "foo" - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("Step should succeed when stat succeeds: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if driver.ToolsIsoPathCalled { - t.Fatal("tools iso path should not be called when ToolsSourcePath is set") - } - - // Test the resulting state - if _, ok := state.GetOk("tools_upload_source"); !ok { - t.Fatal("should have tools_upload_source") - } -} diff --git a/builder/vmware/common/step_register_test.go b/builder/vmware/common/step_register_test.go deleted file mode 100644 index 50d615e9c..000000000 --- a/builder/vmware/common/step_register_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package common - -import ( - "context" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepRegister_impl(t *testing.T) { - var _ multistep.Step = new(StepRegister) -} - -func TestStepRegister_regularDriver(t *testing.T) { - state := testState(t) - step := new(StepRegister) - - state.Put("vmx_path", "foo") - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Cleanup - step.Cleanup(state) -} - -func TestStepRegister_remoteDriver(t *testing.T) { - state := testState(t) - step := &StepRegister{ - KeepRegistered: false, - SkipExport: true, - } - - driver := new(RemoteDriverMock) - - state.Put("driver", driver) - state.Put("vmx_path", "foo") - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // verify - if !driver.RegisterCalled { - t.Fatal("register should be called") - } - if driver.RegisterPath != "foo" { - t.Fatal("should call with correct path") - } - if driver.UnregisterCalled { - t.Fatal("unregister should not be called") - } - - // cleanup - step.Cleanup(state) - if !driver.UnregisterCalled { - t.Fatal("unregister should be called") - } - if driver.UnregisterPath != "foo" { - t.Fatal("should unregister proper path") - } -} -func TestStepRegister_WithoutUnregister_remoteDriver(t *testing.T) { - state := testState(t) - step := &StepRegister{KeepRegistered: true} - - driver := new(RemoteDriverMock) - - state.Put("driver", driver) - state.Put("vmx_path", "foo") - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // cleanup - step.Cleanup(state) - if driver.UnregisterCalled { - t.Fatal("unregister should not be called") - } -} diff --git a/builder/vmware/common/step_remote_upload_test.go b/builder/vmware/common/step_remote_upload_test.go deleted file mode 100644 index 5b4dea78b..000000000 --- a/builder/vmware/common/step_remote_upload_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package common - -import ( - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepRemoteUpload_Cleanup(t *testing.T) { - state := new(multistep.BasicStateBag) - driver := new(RemoteDriverMock) - state.Put("driver", driver) - state.Put("path_key", "packer_cache") - - // Should clean up cache - s := &StepRemoteUpload{ - Key: "path_key", - DoCleanup: true, - } - s.Cleanup(state) - - if !driver.CacheRemoved { - t.Fatalf("bad: remote cache was not removed") - } - if driver.RemovedCachePath != "packer_cache" { - t.Fatalf("bad: removed cache path was expected to be packer_cache but was %s", driver.RemovedCachePath) - } - - // Should NOT clean up cache - s = &StepRemoteUpload{ - Key: "path_key", - } - driver = new(RemoteDriverMock) - state.Put("driver", driver) - s.Cleanup(state) - - if driver.CacheRemoved { - t.Fatalf("bad: remote cache was removed but was expected to not") - } -} diff --git a/builder/vmware/common/step_run_test.go b/builder/vmware/common/step_run_test.go deleted file mode 100644 index 5ee60d4a9..000000000 --- a/builder/vmware/common/step_run_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package common - -import ( - "context" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepRun_impl(t *testing.T) { - var _ multistep.Step = new(StepRun) -} - -func TestStepRun(t *testing.T) { - state := testState(t) - step := new(StepRun) - - state.Put("vmx_path", "foo") - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.StartCalled { - t.Fatal("start should be called") - } - if driver.StartPath != "foo" { - t.Fatalf("bad: %#v", driver.StartPath) - } - if driver.StartHeadless { - t.Fatal("bad") - } - - // Test cleanup - step.Cleanup(state) - if driver.StopCalled { - t.Fatal("stop should not be called if not running") - } -} - -func TestStepRun_cleanupRunning(t *testing.T) { - state := testState(t) - step := new(StepRun) - - state.Put("vmx_path", "foo") - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.StartCalled { - t.Fatal("start should be called") - } - if driver.StartPath != "foo" { - t.Fatalf("bad: %#v", driver.StartPath) - } - if driver.StartHeadless { - t.Fatal("bad") - } - - // Mark that it is running - driver.IsRunningResult = true - - // Test cleanup - step.Cleanup(state) - if !driver.StopCalled { - t.Fatal("stop should be called") - } -} diff --git a/builder/vmware/common/step_shutdown_test.go b/builder/vmware/common/step_shutdown_test.go deleted file mode 100644 index 5559b3b61..000000000 --- a/builder/vmware/common/step_shutdown_test.go +++ /dev/null @@ -1,205 +0,0 @@ -package common - -import ( - "context" - "io/ioutil" - "os" - "path/filepath" - "testing" - "time" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func testLocalOutputDir(t *testing.T) *LocalOutputDir { - td, err := ioutil.TempDir("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - os.RemoveAll(td) - - result := new(LocalOutputDir) - result.SetOutputDir(td) - return result -} - -func testStepShutdownState(t *testing.T) multistep.StateBag { - dir := testLocalOutputDir(t) - if err := dir.MkdirAll(); err != nil { - t.Fatalf("err: %s", err) - } - - state := testState(t) - state.Put("communicator", new(packersdk.MockCommunicator)) - state.Put("dir", dir) - state.Put("vmx_path", "foo") - return state -} - -func TestStepShutdown_impl(t *testing.T) { - var _ multistep.Step = new(StepShutdown) -} - -func TestStepShutdown_command(t *testing.T) { - state := testStepShutdownState(t) - step := new(StepShutdown) - step.Command = "foo" - step.Timeout = 10 * time.Second - step.Testing = true - - comm := state.Get("communicator").(*packersdk.MockCommunicator) - driver := state.Get("driver").(*DriverMock) - driver.IsRunningResult = true - - // Set not running after some time - go func() { - time.Sleep(100 * time.Millisecond) - driver.Lock() - defer driver.Unlock() - driver.IsRunningResult = false - }() - - resultCh := make(chan multistep.StepAction, 1) - go func() { - resultCh <- step.Run(context.Background(), state) - }() - - select { - case <-resultCh: - t.Fatal("should not have returned so quickly") - case <-time.After(50 * time.Millisecond): - } - - var action multistep.StepAction - select { - case action = <-resultCh: - case <-time.After(5 * time.Second): - t.Fatal("should've returned by now") - } - - // Test the run - if action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if driver.StopCalled { - t.Fatal("stop should not be called") - } - - if !comm.StartCalled { - t.Fatal("start should be called") - } - if comm.StartCmd.Command != "foo" { - t.Fatalf("bad: %#v", comm.StartCmd.Command) - } - - // Clean up the created test output directory - dir := state.Get("dir").(*LocalOutputDir) - if err := dir.RemoveAll(); err != nil { - t.Fatalf("Error cleaning up directory: %s", err) - } -} - -func TestStepShutdown_noCommand(t *testing.T) { - state := testStepShutdownState(t) - step := new(StepShutdown) - - comm := state.Get("communicator").(*packersdk.MockCommunicator) - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.StopCalled { - t.Fatal("stop should be called") - } - if driver.StopPath != "foo" { - t.Fatal("should call with right path") - } - - if comm.StartCalled { - t.Fatal("start should not be called") - } - - // Clean up the created test output directory - dir := state.Get("dir").(*LocalOutputDir) - if err := dir.RemoveAll(); err != nil { - t.Fatalf("Error cleaning up directory: %s", err) - } -} - -func TestStepShutdown_locks(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1 due to the requirement of access to the VMware binaries.") - } - - state := testStepShutdownState(t) - step := new(StepShutdown) - step.Testing = true - - dir := state.Get("dir").(*LocalOutputDir) - comm := state.Get("communicator").(*packersdk.MockCommunicator) - driver := state.Get("driver").(*DriverMock) - - // Create some lock files - lockPath := filepath.Join(dir.dir, "nope.lck") - err := ioutil.WriteFile(lockPath, []byte("foo"), 0644) - if err != nil { - t.Fatalf("err: %s", err) - } - - // Remove the lock file after a certain time - go func() { - time.Sleep(100 * time.Millisecond) - os.Remove(lockPath) - }() - - resultCh := make(chan multistep.StepAction, 1) - go func() { - resultCh <- step.Run(context.Background(), state) - }() - - select { - case <-resultCh: - t.Fatal("should not have returned so quickly") - case <-time.After(50 * time.Millisecond): - } - - var action multistep.StepAction - select { - case action = <-resultCh: - case <-time.After(300 * time.Millisecond): - t.Fatal("should've returned by now") - } - - // Test the run - if action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.StopCalled { - t.Fatal("stop should be called") - } - if driver.StopPath != "foo" { - t.Fatal("should call with right path") - } - - if comm.StartCalled { - t.Fatal("start should not be called") - } -} diff --git a/builder/vmware/common/step_suppress_messages_test.go b/builder/vmware/common/step_suppress_messages_test.go deleted file mode 100644 index 695f006cd..000000000 --- a/builder/vmware/common/step_suppress_messages_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package common - -import ( - "context" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepSuppressMessages_impl(t *testing.T) { - var _ multistep.Step = new(StepSuppressMessages) -} - -func TestStepSuppressMessages(t *testing.T) { - state := testState(t) - step := new(StepSuppressMessages) - - state.Put("vmx_path", "foo") - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test the driver - if !driver.SuppressMessagesCalled { - t.Fatal("should've called") - } - if driver.SuppressMessagesPath != "foo" { - t.Fatal("should call with right path") - } -} diff --git a/builder/vmware/common/step_test.go b/builder/vmware/common/step_test.go deleted file mode 100644 index 71cd088a5..000000000 --- a/builder/vmware/common/step_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package common - -import ( - "bytes" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func testState(t *testing.T) multistep.StateBag { - state := new(multistep.BasicStateBag) - state.Put("driver", new(DriverMock)) - state.Put("ui", &packersdk.BasicUi{ - Reader: new(bytes.Buffer), - Writer: new(bytes.Buffer), - }) - state.Put("temporaryDevices", []string{}) - return state -} diff --git a/builder/vmware/common/testdata/apple-dhcpd-example.leases b/builder/vmware/common/testdata/apple-dhcpd-example.leases deleted file mode 100644 index 53aacb19c..000000000 --- a/builder/vmware/common/testdata/apple-dhcpd-example.leases +++ /dev/null @@ -1,40 +0,0 @@ -# this entry is normal -{ - ip_address=127.0.0.17 - hw_address=1,d:ea:d0:66:77:88 - identifier=1,d:ea:d0:0:11:22 - lease=0x5fd78ae2 - name=vagrant-2019 -} - -# this entry has tabs -{ - ip_address=127.0.0.17 - hw_address=1,d:ea:d0:66:77:88 - identifier=1,d:ea:d0:33:44:55 - lease=0x5fd7b4e5 - name=vagrant-2019 -} - -# These next two entries have the same address, but different uids -{ - ip_address=127.0.0.19 - hw_address=1,d:ea:d0:66:77:88 - identifier=1,d:ea:d0:66:77:88 - lease=0x5fd72edc - name=vagrant-2019 -} -{ - ip_address=127.0.0.19 - hw_address=1,d:ea:d0:99:aa:bb - identifier=1,d:ea:d0:99:aa:bb - lease=0x5fd72edc - name=vagrant-2019 -} - -# this entry does not have all fields -{ - ip_address=127.0.0.20 - hw_address=1,d:ea:d0:99:aa:bc - identifier=1,d:ea:d0:99:aa:bc -} \ No newline at end of file diff --git a/builder/vmware/common/testdata/dhcpd-example.conf b/builder/vmware/common/testdata/dhcpd-example.conf deleted file mode 100644 index af61c1423..000000000 --- a/builder/vmware/common/testdata/dhcpd-example.conf +++ /dev/null @@ -1,20 +0,0 @@ -allow unknown-clients; # global.grants -default-lease-time 1800; # global.parameters -max-lease-time 7200; # global.parameters - -subnet 172.33.33.0 netmask 255.255.255.0 { # subnet4 - range 172.33.33.128 172.33.33.254; # subnet4.address - option broadcast-address 172.33.33.255; # subnet4.options -# allow unknown-clients; # subnet4.grants - default-lease-time 2400; # subnet4.parameters - max-lease-time 9600; # subnet4.parameters - option routers 172.33.33.2; # subnet4.options -} -host vmnet8 { # host - hardware ethernet 00:50:56:C0:00:08; # host.address - fixed-address 172.33.33.1; # host.address - option domain-name "packer.test"; # host.options -# allow unknown-clients; # subnet4.grants -# default-lease-time 1800; # subnet4.parameters -# max-lease-time 7200; # subnet4.parameters -} diff --git a/builder/vmware/common/testdata/dhcpd-example.leases b/builder/vmware/common/testdata/dhcpd-example.leases deleted file mode 100644 index da95d2955..000000000 --- a/builder/vmware/common/testdata/dhcpd-example.leases +++ /dev/null @@ -1,32 +0,0 @@ -# This entry is normal -lease 127.0.0.17 { - starts 3 2020/05/13 12:00:37; - ends 3 2020/05/13 12:30:37; - hardware ethernet 0d:ea:d0:66:77:88; - uid 01:0d:ea:d0:00:11:22; -} - -# This entry has tabs -lease 127.0.0.17 { - starts 6 2020/06/12 22:28:54; - ends 6 2020/06/12 22:58:54; - hardware ethernet 0d:ea:d0:66:77:88; - uid 01:0d:ea:d0:33:44:55; -} - -# These next two entries have the same address, but different uids -lease 127.0.0.19 { - starts 4 2020/05/28 11:35:06; - ends 4 2020/05/28 12:05:06; - hardware ethernet 0d:ea:d0:66:77:88; - uid 01:0d:ea:d0:66:77:88; - client-hostname "VAGRANT-ADA-LUZ"; -} - -lease 127.0.0.19 { - starts 5 2020/08/20 20:32:03; - ends 5 2020/08/20 21:02:03; - hardware ethernet 0d:ea:d0:99:aa:bb; - uid 01:0d:ea:d0:99:aa:bb; - client-hostname "WINDOWS-SQABBAS"; -} diff --git a/builder/vmware/common/testdata/netmap-example.conf b/builder/vmware/common/testdata/netmap-example.conf deleted file mode 100644 index d697419de..000000000 --- a/builder/vmware/common/testdata/netmap-example.conf +++ /dev/null @@ -1,11 +0,0 @@ -network8.device = "vmnet8" -network0.name = "Bridged" -network2.device = "vmnet57005" -network3.name = "butneeds" -network0.device = "vmnet0" -network1.name = "HostOnly" -network8.name = "NAT" -network1.device = "vmnet1" -network3.notuseful = "blah" -network3.device = "nameanddevice" -network2.name = "bleep bloop" diff --git a/builder/vmware/common/testdata/networking-example b/builder/vmware/common/testdata/networking-example deleted file mode 100644 index 7117ac8f6..000000000 --- a/builder/vmware/common/testdata/networking-example +++ /dev/null @@ -1,19 +0,0 @@ -VERSION=1,0 -answer VNET_1_DHCP yes -answer VNET_1_DHCP_CFG_HASH 01F4CE0D79A1599698B6E5814CCB68058BB0ED5E -answer VNET_1_HOSTONLY_NETMASK 255.255.255.0 -answer VNET_1_HOSTONLY_SUBNET 192.168.70.0 -answer VNET_1_NAT no -answer VNET_1_VIRTUAL_ADAPTER yes -answer VNET_8_DHCP yes -answer VNET_8_DHCP_CFG_HASH C30F14F65A0FE4B5DCC6C67497D7A8A33E5E538C -answer VNET_8_HOSTONLY_NETMASK 255.255.255.0 -answer VNET_8_HOSTONLY_SUBNET 172.16.41.0 -answer VNET_8_NAT yes -answer VNET_8_VIRTUAL_ADAPTER yes -add_nat_portfwd 8 tcp 2200 172.16.41.129 3389 -add_nat_portfwd 8 tcp 2201 172.16.41.129 3389 -add_nat_portfwd 8 tcp 2222 172.16.41.129 22 -add_nat_portfwd 8 tcp 3389 172.16.41.131 3389 -add_nat_portfwd 8 tcp 55985 172.16.41.129 5985 -add_nat_portfwd 8 tcp 55986 172.16.41.129 5986 diff --git a/builder/vmware/common/tools_config_test.go b/builder/vmware/common/tools_config_test.go deleted file mode 100644 index 4358fa33b..000000000 --- a/builder/vmware/common/tools_config_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package common - -import ( - "testing" - - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func TestToolsConfigPrepare_Empty(t *testing.T) { - c := &ToolsConfig{} - - errs := c.Prepare(interpolate.NewContext()) - if len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if c.ToolsUploadPath != "{{ .Flavor }}.iso" { - t.Fatal("should have defaulted tools upload path") - } -} - -func TestToolsConfigPrepare_SetUploadPath(t *testing.T) { - c := &ToolsConfig{ - ToolsUploadPath: "path/to/tools.iso", - } - - errs := c.Prepare(interpolate.NewContext()) - if len(errs) > 0 { - t.Fatalf("err: %#v", errs) - } - - if c.ToolsUploadPath != "path/to/tools.iso" { - t.Fatal("should have used given tools upload path") - } -} - -func TestToolsConfigPrepare_ErrorIfOnlySource(t *testing.T) { - c := &ToolsConfig{ - ToolsSourcePath: "path/to/tools.iso", - } - - errs := c.Prepare(interpolate.NewContext()) - if len(errs) != 1 { - t.Fatalf("Should have received an error because the flavor and " + - "upload path aren't set") - } -} - -func TestToolsConfigPrepare_SourceSuccess(t *testing.T) { - for _, c := range []*ToolsConfig{ - &ToolsConfig{ - ToolsSourcePath: "path/to/tools.iso", - ToolsUploadPath: "partypath.iso", - }, - &ToolsConfig{ - ToolsSourcePath: "path/to/tools.iso", - ToolsUploadFlavor: "linux", - }, - } { - errs := c.Prepare(interpolate.NewContext()) - if len(errs) != 0 { - t.Fatalf("Should not have received an error") - } - } -} diff --git a/builder/vmware/common/vmx_config_test.go b/builder/vmware/common/vmx_config_test.go deleted file mode 100644 index f963d0b29..000000000 --- a/builder/vmware/common/vmx_config_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package common - -import ( - "testing" - - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -func TestVMXConfigPrepare(t *testing.T) { - c := new(VMXConfig) - c.VMXData = map[string]string{ - "one": "foo", - "two": "bar", - } - - errs := c.Prepare(interpolate.NewContext()) - if len(errs) > 0 { - t.Fatalf("bad: %#v", errs) - } - - if len(c.VMXData) != 2 { - t.Fatal("should have two items in VMXData") - } -} diff --git a/builder/vmware/common/vmx_test.go b/builder/vmware/common/vmx_test.go deleted file mode 100644 index 967f01259..000000000 --- a/builder/vmware/common/vmx_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package common - -import "testing" - -func TestParseVMX(t *testing.T) { - contents := ` -.encoding = "UTF-8" -config.version = "8" -scsi0:0.virtualSSD = 1 -` - - results := ParseVMX(contents) - if len(results) != 3 { - t.Fatalf("not correct number of results: %d", len(results)) - } - - if results[".encoding"] != "UTF-8" { - t.Errorf("invalid .encoding: %s", results[".encoding"]) - } - - if results["config.version"] != "8" { - t.Errorf("invalid config.version: %s", results["config.version"]) - } - - if results["scsi0:0.virtualssd"] != "1" { - t.Errorf("invalid scsi0:0.virtualssd: %s", results["scsi0:0.virtualssd"]) - } -} - -func TestEncodeVMX(t *testing.T) { - contents := map[string]string{ - ".encoding": "UTF-8", - "config.version": "8", - "scsi0:0.virtualssd": "1", - } - - expected := `.encoding = "UTF-8" -config.version = "8" -scsi0:0.virtualSSD = 1 -` - - result := EncodeVMX(contents) - if result != expected { - t.Errorf("invalid results: %s", result) - } -} diff --git a/builder/vmware/iso/builder_acc_test.go b/builder/vmware/iso/builder_acc_test.go deleted file mode 100644 index 2f0047223..000000000 --- a/builder/vmware/iso/builder_acc_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package iso - -import ( - "fmt" - "io/ioutil" - "os/exec" - "path/filepath" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/acctest" - "github.com/hashicorp/packer-plugin-sdk/acctest/testutils" -) - -func TestBuilderAcc_basic(t *testing.T) { - templatePath := filepath.Join("testdata", "minimal.json") - bytes, err := ioutil.ReadFile(templatePath) - if err != nil { - t.Fatalf("failed to load template file %s", templatePath) - } - - testCase := &acctest.PluginTestCase{ - Name: "vmware-iso_builder_basic_test", - Setup: func() error { - return nil - }, - Teardown: func() error { - testutils.CleanupFiles("output-vmware-iso", "packer_cache") - return nil - }, - Template: string(bytes), - Type: "vmware-iso", - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - return nil - }, - } - acctest.TestPlugin(t, testCase) -} diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go deleted file mode 100644 index cf0205ca0..000000000 --- a/builder/vmware/iso/builder_test.go +++ /dev/null @@ -1,651 +0,0 @@ -package iso - -import ( - "fmt" - "io/ioutil" - "os" - "reflect" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/common" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func testConfig() map[string]interface{} { - return map[string]interface{}{ - "iso_checksum": "md5:0B0F137F17AC10944716020B018F8126", - "iso_url": "http://www.packer.io", - "shutdown_command": "foo", - "ssh_username": "foo", - - common.BuildNameConfigKey: "foo", - } -} - -func TestBuilder_ImplementsBuilder(t *testing.T) { - var raw interface{} - raw = &Builder{} - if _, ok := raw.(packersdk.Builder); !ok { - t.Error("Builder must implement builder.") - } -} - -func TestBuilderPrepare_Defaults(t *testing.T) { - var b Builder - config := testConfig() - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - if b.config.DiskName != "disk" { - t.Errorf("bad disk name: %s", b.config.DiskName) - } - - if b.config.OutputDir != "output-foo" { - t.Errorf("bad output dir: %s", b.config.OutputDir) - } - - if b.config.Version != "9" { - t.Errorf("bad Version: %s", b.config.Version) - } - - if b.config.VMName != "packer-foo" { - t.Errorf("bad vm name: %s", b.config.VMName) - } -} - -func TestBuilderPrepare_DiskSize(t *testing.T) { - var b Builder - config := testConfig() - - delete(config, "disk_size") - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("bad err: %s", err) - } - - if b.config.DiskSize != 40000 { - t.Fatalf("bad size: %d", b.config.DiskSize) - } - - config["disk_size"] = 60000 - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - if b.config.DiskSize != 60000 { - t.Fatalf("bad size: %d", b.config.DiskSize) - } -} - -func TestBuilderPrepare_FloppyFiles(t *testing.T) { - var b Builder - config := testConfig() - - delete(config, "floppy_files") - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("bad err: %s", err) - } - - if len(b.config.FloppyFiles) != 0 { - t.Fatalf("bad: %#v", b.config.FloppyFiles) - } - - floppies_path := "../../test-fixtures/floppies" - config["floppy_files"] = []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)} - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - expected := []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)} - if !reflect.DeepEqual(b.config.FloppyFiles, expected) { - t.Fatalf("bad: %#v", b.config.FloppyFiles) - } -} - -func TestBuilderPrepare_InvalidFloppies(t *testing.T) { - var b Builder - config := testConfig() - config["floppy_files"] = []string{"nonexistent.bat", "nonexistent.ps1"} - - b = Builder{} - _, _, errs := b.Prepare(config) - if errs == nil { - t.Fatalf("Nonexistent floppies should trigger multierror") - } - - if len(errs.(*packersdk.MultiError).Errors) != 2 { - t.Fatalf("Multierror should work and report 2 errors") - } -} - -func TestBuilderPrepare_RemoteType(t *testing.T) { - var b Builder - config := testConfig() - - config["format"] = "ovf" - config["remote_host"] = "foobar.example.com" - config["remote_password"] = "supersecret" - config["skip_validate_credentials"] = true - // Bad - config["remote_type"] = "foobar" - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - config["remote_type"] = "esx5" - // Bad - config["remote_host"] = "" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Good - config["remote_type"] = "" - config["format"] = "" - config["remote_host"] = "" - config["remote_password"] = "" - config["remote_private_key_file"] = "" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - // Good - config["remote_type"] = "esx5" - config["remote_host"] = "foobar.example.com" - config["remote_password"] = "supersecret" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } -} - -func TestBuilderPrepare_Export(t *testing.T) { - type testCase struct { - InputConfigVals map[string]string - ExpectedSkipExportValue bool - ExpectedFormat string - ExpectedErr bool - Reason string - } - testCases := []testCase{ - { - InputConfigVals: map[string]string{ - "remote_type": "", - "format": "", - }, - ExpectedSkipExportValue: true, - ExpectedFormat: "vmx", - ExpectedErr: false, - Reason: "should have defaulted format to vmx.", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "esx5", - "format": "", - "remote_host": "fakehost.com", - "remote_password": "fakepassword", - "remote_username": "fakeuser", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ovf", - ExpectedErr: false, - Reason: "should have defaulted format to ovf with remote set to esx5.", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "esx5", - "format": "", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ovf", - ExpectedErr: true, - Reason: "should have errored because remote host isn't set for remote build.", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "invalid", - "format": "", - "remote_host": "fakehost.com", - "remote_password": "fakepassword", - "remote_username": "fakeuser", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ovf", - ExpectedErr: true, - Reason: "should error with invalid remote type", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "", - "format": "invalid", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "invalid", - ExpectedErr: true, - Reason: "should error with invalid format", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "", - "format": "ova", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ova", - ExpectedErr: false, - Reason: "should set user-given ova format", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "esx5", - "format": "ova", - "remote_host": "fakehost.com", - "remote_password": "fakepassword", - "remote_username": "fakeuser", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ova", - ExpectedErr: false, - Reason: "should set user-given ova format", - }, - } - for _, tc := range testCases { - config := testConfig() - for k, v := range tc.InputConfigVals { - config[k] = v - } - config["skip_validate_credentials"] = true - outCfg := &Config{} - warns, errs := (outCfg).Prepare(config) - - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - - if (errs != nil) != tc.ExpectedErr { - t.Fatalf("received error: \n %s \n but 'expected err' was %t", errs, tc.ExpectedErr) - } - - if outCfg.Format != tc.ExpectedFormat { - t.Fatalf("Expected: %s. Actual: %s. Reason: %s", tc.ExpectedFormat, - outCfg.Format, tc.Reason) - } - if outCfg.SkipExport != tc.ExpectedSkipExportValue { - t.Fatalf("For SkipExport expected %t but recieved %t", - tc.ExpectedSkipExportValue, outCfg.SkipExport) - } - } -} - -func TestBuilderPrepare_RemoteExport(t *testing.T) { - var b Builder - config := testConfig() - - config["remote_type"] = "esx5" - config["remote_host"] = "foobar.example.com" - config["skip_validate_credentials"] = true - // Bad - config["remote_password"] = "" - _, warns, err := b.Prepare(config) - if len(warns) != 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Good - config["remote_password"] = "supersecret" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) != 0 { - t.Fatalf("err: %s", err) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } -} - -func TestBuilderPrepare_Format(t *testing.T) { - var b Builder - config := testConfig() - - // Bad - config["format"] = "foobar" - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - goodFormats := []string{"ova", "ovf", "vmx"} - - for _, format := range goodFormats { - // Good - config["format"] = format - config["remote_type"] = "esx5" - config["remote_host"] = "hosty.hostface" - config["remote_password"] = "password" - config["skip_validate_credentials"] = true - - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - } -} - -func TestBuilderPrepare_InvalidKey(t *testing.T) { - var b Builder - config := testConfig() - - // Add a random key - config["i_should_not_be_valid"] = true - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } -} - -func TestBuilderPrepare_OutputDir(t *testing.T) { - var b Builder - config := testConfig() - - // Test with existing dir - dir, err := ioutil.TempDir("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.RemoveAll(dir) - - config["output_directory"] = dir - b = Builder{} - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("err: %s", err) - } - - // Test with a good one - config["output_directory"] = "i-hope-i-dont-exist" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } -} - -func TestBuilderPrepare_ToolsUploadPath(t *testing.T) { - var b Builder - config := testConfig() - - // Test a default - delete(config, "tools_upload_path") - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if b.config.ToolsUploadPath == "" { - t.Fatalf("bad value: %s", b.config.ToolsUploadPath) - } - - // Test with a bad value - config["tools_upload_path"] = "{{{nope}" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test with a good one - config["tools_upload_path"] = "hey" - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } -} - -func TestBuilderPrepare_VMXTemplatePath(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["vmx_template_path"] = "/i/dont/exist/forreal" - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.Remove(tf.Name()) - defer tf.Close() - - if _, err := tf.Write([]byte("HELLO!")); err != nil { - t.Fatalf("err: %s", err) - } - - config["vmx_template_path"] = tf.Name() - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - // Bad template - tf2, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.Remove(tf2.Name()) - defer tf2.Close() - - if _, err := tf2.Write([]byte("{{foo}")); err != nil { - t.Fatalf("err: %s", err) - } - - config["vmx_template_path"] = tf2.Name() - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } -} - -func TestBuilderPrepare_VNCPort(t *testing.T) { - var b Builder - config := testConfig() - - // Bad - config["vnc_port_min"] = 1000 - config["vnc_port_max"] = 500 - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Bad - config["vnc_port_min"] = -500 - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Good - config["vnc_port_min"] = 500 - config["vnc_port_max"] = 1000 - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } -} - -func TestBuilderCheckCollisions(t *testing.T) { - config := testConfig() - config["vmx_data"] = map[string]string{ - "no.collision": "awesomesauce", - "ide0:0.fileName": "is a collision", - "displayName": "also a collision", - } - { - var b Builder - _, warns, _ := b.Prepare(config) - if len(warns) != 1 { - t.Fatalf("Should have warning about two collisions.") - } - } - { - config["vmx_template_path"] = "some/path.vmx" - var b Builder - _, warns, _ := b.Prepare(config) - if len(warns) != 0 { - t.Fatalf("Should not check for collisions with custom template.") - } - } - -} - -func TestBuilderPrepare_CommConfig(t *testing.T) { - // Test Winrm - { - config := testConfig() - config["communicator"] = "winrm" - config["winrm_username"] = "username" - config["winrm_password"] = "password" - config["winrm_host"] = "1.2.3.4" - - var b Builder - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - if b.config.SSHConfig.Comm.WinRMUser != "username" { - t.Errorf("bad winrm_username: %s", b.config.SSHConfig.Comm.WinRMUser) - } - if b.config.SSHConfig.Comm.WinRMPassword != "password" { - t.Errorf("bad winrm_password: %s", b.config.SSHConfig.Comm.WinRMPassword) - } - if host := b.config.SSHConfig.Comm.Host(); host != "1.2.3.4" { - t.Errorf("bad host: %s", host) - } - } - - // Test SSH - { - config := testConfig() - config["communicator"] = "ssh" - config["ssh_username"] = "username" - config["ssh_password"] = "password" - config["ssh_host"] = "1.2.3.4" - - var b Builder - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - - if b.config.SSHConfig.Comm.SSHUsername != "username" { - t.Errorf("bad ssh_username: %s", b.config.SSHConfig.Comm.SSHUsername) - } - if b.config.SSHConfig.Comm.SSHPassword != "password" { - t.Errorf("bad ssh_password: %s", b.config.SSHConfig.Comm.SSHPassword) - } - if host := b.config.SSHConfig.Comm.Host(); host != "1.2.3.4" { - t.Errorf("bad host: %s", host) - } - } -} diff --git a/builder/vmware/iso/step_create_vmx_test.go b/builder/vmware/iso/step_create_vmx_test.go deleted file mode 100644 index 9af6f06ea..000000000 --- a/builder/vmware/iso/step_create_vmx_test.go +++ /dev/null @@ -1,339 +0,0 @@ -package iso - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "runtime" - "strings" - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/tmp" - builderT "github.com/hashicorp/packer/acctest" -) - -const vmxTestTemplate string = `{"builders":[{%s}],"provisioners":[{%s}]}` - -func createFloppyOutput(prefix string) (string, map[string]string, error) { - f, err := tmp.File(prefix) - if err != nil { - return "", map[string]string{}, fmt.Errorf("unable to create temp file") - } - f.Close() - - output := f.Name() - outputFile := strings.Replace(output, "\\", "\\\\", -1) - vmxData := map[string]string{ - "floppy0.present": "TRUE", - "floppy0.fileType": "file", - "floppy0.clientDevice": "FALSE", - "floppy0.fileName": outputFile, - "floppy0.startConnected": "TRUE", - } - return output, vmxData, nil -} - -func readFloppyOutput(path string) (string, error) { - f, err := os.Open(path) - if err != nil { - return "", fmt.Errorf("Unable to open file %s", path) - } - defer f.Close() - data, err := ioutil.ReadAll(f) - if err != nil { - return "", fmt.Errorf("Unable to read file: %s", err) - } - if len(data) == 0 { - return "", nil - } - return string(data[:bytes.IndexByte(data, 0)]), nil -} - -// RenderConfig helps create dynamic packer template configs for parsing by -// builderT without having to write the config to a file. -func RenderConfig(builderConfig map[string]interface{}, provisionerConfig map[string]string) string { - // set up basic build template - t := map[string][]map[string]interface{}{ - "builders": { - map[string]interface{}{ - "type": "test", - "iso_url": "https://archive.org/download/ut-ttylinux-i686-12.6/ut-ttylinux-i686-12.6.iso", - "iso_checksum": "md5:43c1feeae55a44c6ef694b8eb18408a6", - "ssh_username": "root", - "ssh_password": "password", - "ssh_wait_timeout": "45s", - "boot_command": []string{"", "rootpassword", "udhcpc"}, - "shutdown_command": "/sbin/shutdown -h; exit 0", - "ssh_key_exchange_algorithms": []string{"diffie-hellman-group1-sha1"}, - }, - }, - "provisioners": { - map[string]interface{}{ - "type": "shell", - "inline": []string{"echo hola mundo"}, - }, - }, - } - // apply special builder overrides - for k, v := range builderConfig { - t["builders"][0][k] = v - } - // Apply special provisioner overrides - for k, v := range provisionerConfig { - t["provisioners"][0][k] = v - } - - j, _ := json.Marshal(t) - return string(j) -} - -func TestStepCreateVmx_SerialFile(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1 due to the requirement of access to the VMware binaries.") - } - - tmpfile, err := tmp.File("SerialFileInput.") - if err != nil { - t.Fatalf("unable to create temp file") - } - serialConfig := map[string]interface{}{ - "serial": fmt.Sprintf("file:%s", filepath.ToSlash(tmpfile.Name())), - } - - configString := RenderConfig(serialConfig, map[string]string{}) - - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - _, err := os.Stat(tmpfile.Name()) - if err != nil { - return fmt.Errorf("VMware builder did not create a file for serial port: %s", err) - } - return nil - }, - Teardown: func() error { - f, _ := os.Stat(tmpfile.Name()) - if f != nil { - if err := os.Remove(tmpfile.Name()); err != nil { - return fmt.Errorf("Unable to remove file %s: %s", tmpfile.Name(), err) - } - } - return nil - }, - }) -} - -func TestStepCreateVmx_SerialPort(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1 due to the requirement of access to the VMware binaries.") - } - - var defaultSerial string - if runtime.GOOS == "windows" { - defaultSerial = "COM1" - } else { - defaultSerial = "/dev/ttyS0" - } - - config := map[string]interface{}{ - "serial": fmt.Sprintf("device:%s", filepath.ToSlash(defaultSerial)), - } - provision := map[string]string{ - "inline": "dmesg | egrep -o '^serial8250: ttyS1 at' > /dev/fd0", - } - - // where to write output - output, vmxData, err := createFloppyOutput("SerialPortOutput.") - if err != nil { - t.Fatalf("Error creating output: %s", err) - } - - config["vmx_data"] = vmxData - configString := RenderConfig(config, provision) - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - _, err := os.Stat(output) - if err != nil { - return fmt.Errorf("VMware builder did not create a file for serial port: %s", err) - } - // check the output - data, err := readFloppyOutput(output) - if err != nil { - return fmt.Errorf("%s", err) - } - - if data != "serial8250: ttyS1 at\n" { - return fmt.Errorf("Serial port not detected : %v", data) - } - return nil - }, - Teardown: func() error { - if _, err := os.Stat(output); err == nil { - os.Remove(output) - } - return nil - }, - }) -} - -func TestStepCreateVmx_ParallelPort(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1 due to the requirement of access to the VMware binaries.") - } - - var defaultParallel string - if runtime.GOOS == "windows" { - defaultParallel = "LPT1" - } else { - defaultParallel = "/dev/lp0" - } - - config := map[string]interface{}{ - "parallel": fmt.Sprintf("device:%s,uni", filepath.ToSlash(defaultParallel)), - } - provision := map[string]string{ - "inline": "cat /proc/modules | egrep -o '^parport ' > /dev/fd0", - } - - // where to write output - output, vmxData, err := createFloppyOutput("ParallelPortOutput.") - if err != nil { - t.Fatalf("Error creating output: %s", err) - } - - config["vmx_data"] = vmxData - configString := RenderConfig(config, provision) - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - _, err := os.Stat(output) - if err != nil { - return fmt.Errorf("VMware builder did not create a file for serial port: %s", err) - } - // check the output - data, err := readFloppyOutput(output) - if err != nil { - t.Errorf("%s", err) - } - - if data != "parport \n" { - t.Errorf("Parallel port not detected : %v", data) - } - return nil - }, - Teardown: func() error { - if _, err := os.Stat(output); err == nil { - os.Remove(output) - } - return nil - }, - }) -} - -func TestStepCreateVmx_Usb(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1 due to the requirement of access to the VMware binaries.") - } - - config := map[string]interface{}{ - "usb": "TRUE", - } - provision := map[string]string{ - "inline": "dmesg | egrep -m1 -o 'USB hub found$' > /dev/fd0", - } - - output, vmxData, err := createFloppyOutput("UsbOutput.") - if err != nil { - t.Fatalf("Error creating output: %s", err) - } - - config["vmx_data"] = vmxData - configString := RenderConfig(config, provision) - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - _, err := os.Stat(output) - if err != nil { - return fmt.Errorf("VMware builder did not create a file for serial port: %s", err) - } - // check the output - data, err := readFloppyOutput(output) - if err != nil { - t.Errorf("%s", err) - } - - if data != "USB hub found\n" { - t.Errorf("USB support not detected : %v", data) - } - return nil - }, - Teardown: func() error { - if _, err := os.Stat(output); err == nil { - os.Remove(output) - } - return nil - }, - }) -} - -func TestStepCreateVmx_Sound(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1 due to the requirement of access to the VMware binaries.") - } - - config := map[string]interface{}{ - "sound": "TRUE", - } - provision := map[string]string{ - "inline": "cat /proc/modules | egrep -o '^soundcore' > /dev/fd0", - } - - // where to write output - output, vmxData, err := createFloppyOutput("SoundOutput.") - if err != nil { - t.Fatalf("Error creating output: %s", err) - } - defer func() { - if _, err := os.Stat(output); err == nil { - os.Remove(output) - } - }() - - config["vmx_data"] = vmxData - configString := RenderConfig(config, provision) - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - _, err := os.Stat(output) - if err != nil { - return fmt.Errorf("VMware builder did not create a file for serial port: %s", err) - } - // check the output - data, err := readFloppyOutput(output) - if err != nil { - t.Errorf("%s", err) - } - - if data != "soundcore\n" { - t.Errorf("Soundcard not detected : %v", data) - } - return nil - }, - Teardown: func() error { - if _, err := os.Stat(output); err == nil { - os.Remove(output) - } - return nil - }, - }) -} diff --git a/builder/vmware/iso/testdata/http/preseed.cfg b/builder/vmware/iso/testdata/http/preseed.cfg deleted file mode 100644 index 559fb9f70..000000000 --- a/builder/vmware/iso/testdata/http/preseed.cfg +++ /dev/null @@ -1,42 +0,0 @@ -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# Keyboard selection. -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/xkb-keymap select us - -choose-mirror-bin mirror/http/proxy string -d-i base-installer/kernel/override-image string linux-server -d-i clock-setup/utc boolean true -d-i clock-setup/utc-auto boolean true -d-i finish-install/reboot_in_progress note -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean true -d-i mirror/country string manual -d-i mirror/http/directory string /ubuntu/ -d-i mirror/http/hostname string archive.ubuntu.com -d-i mirror/http/proxy string -d-i partman-auto-lvm/guided_size string max -d-i partman-auto/choose_recipe select atomic -d-i partman-auto/method string lvm -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true -d-i partman-lvm/device_remove_lvm boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true -d-i partman/confirm_write_new_label boolean true -d-i passwd/user-fullname string vagrant -d-i passwd/user-uid string 1000 -d-i passwd/user-password password vagrant -d-i passwd/user-password-again password vagrant -d-i passwd/username string vagrant -d-i pkgsel/include string openssh-server cryptsetup build-essential libssl-dev libreadline-dev zlib1g-dev linux-source dkms nfs-kernel-server nfs-common linux-headers-$(uname -r) perl -d-i pkgsel/install-language-support boolean false -d-i pkgsel/update-policy select none -d-i pkgsel/upgrade select full-upgrade -d-i time/zone string UTC -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false -tasksel tasksel/first multiselect standard, server \ No newline at end of file diff --git a/builder/vmware/iso/testdata/minimal.json b/builder/vmware/iso/testdata/minimal.json deleted file mode 100644 index d27047c3a..000000000 --- a/builder/vmware/iso/testdata/minimal.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "builders": [ - { - "type": "vmware-iso", - "boot_command": [ - "", - "", - "", - "/install/vmlinuz", - " initrd=/install/initrd.gz", - " auto-install/enable=true", - " debconf/priority=critical", - " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", - " -- ", - "" - ], - "boot_wait": "10s", - "guest_os_type": "ubuntu-64", - "http_directory": "./testdata/http", - "iso_checksum": "sha256:946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2", - "iso_url": "http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso", - "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", - "headless": true, - "ssh_password": "vagrant", - "ssh_username": "vagrant", - "ssh_timeout": "10000s", - "tools_upload_flavor": "linux" - } - ] -} \ No newline at end of file diff --git a/builder/vmware/version/version.go b/builder/vmware/version/version.go deleted file mode 100644 index d0b8b6e63..000000000 --- a/builder/vmware/version/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package version - -import ( - "github.com/hashicorp/packer-plugin-sdk/version" - packerVersion "github.com/hashicorp/packer/version" -) - -var VMwarePluginVersion *version.PluginVersion - -func init() { - VMwarePluginVersion = version.InitializePluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease) -} diff --git a/builder/vmware/vmx/builder_test.go b/builder/vmware/vmx/builder_test.go deleted file mode 100644 index 55b57b453..000000000 --- a/builder/vmware/vmx/builder_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package vmx - -import ( - "fmt" - "io/ioutil" - "os" - "reflect" - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestBuilderPrepare_FloppyFiles(t *testing.T) { - var b Builder - - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - tf.Close() - defer os.Remove(tf.Name()) - - config := testConfig(t) - config["source_path"] = tf.Name() - - delete(config, "floppy_files") - _, warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("bad err: %s", err) - } - - if len(b.config.FloppyFiles) != 0 { - t.Fatalf("bad: %#v", b.config.FloppyFiles) - } - - floppies_path := "../../test-fixtures/floppies" - config["floppy_files"] = []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)} - b = Builder{} - _, warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("should not have error: %s", err) - } - expected := []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)} - if !reflect.DeepEqual(b.config.FloppyFiles, expected) { - t.Fatalf("bad: %#v", b.config.FloppyFiles) - } -} - -func TestBuilderPrepare_InvalidFloppies(t *testing.T) { - var b Builder - config := testConfig(t) - config["floppy_files"] = []string{"nonexistent.bat", "nonexistent.ps1"} - b = Builder{} - _, _, errs := b.Prepare(config) - if errs == nil { - t.Fatalf("Nonexistent floppies should trigger multierror") - } - - if len(errs.(*packersdk.MultiError).Errors) != 2 { - t.Fatalf("Multierror should work and report 2 errors") - } -} diff --git a/builder/vmware/vmx/config_test.go b/builder/vmware/vmx/config_test.go deleted file mode 100644 index cd386f4a2..000000000 --- a/builder/vmware/vmx/config_test.go +++ /dev/null @@ -1,177 +0,0 @@ -package vmx - -import ( - "io/ioutil" - "os" - "testing" -) - -func testConfig(t *testing.T) map[string]interface{} { - return map[string]interface{}{ - "ssh_username": "foo", - "shutdown_command": "foo", - "source_path": "config_test.go", - } -} - -func testConfigErr(t *testing.T, warns []string, err error) { - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should error") - } -} - -func testConfigOk(t *testing.T, warns []string, err error) { - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("bad: %s", err) - } -} - -func TestNewConfig_sourcePath(t *testing.T) { - // Bad - cfg := testConfig(t) - delete(cfg, "source_path") - warns, errs := (&Config{}).Prepare(cfg) - testConfigErr(t, warns, errs) - - // Bad - cfg = testConfig(t) - cfg["source_path"] = "/i/dont/exist" - warns, errs = (&Config{}).Prepare(cfg) - testConfigErr(t, warns, errs) - - // Good - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - tf.Close() - defer os.Remove(tf.Name()) - - cfg = testConfig(t) - cfg["source_path"] = tf.Name() - warns, errs = (&Config{}).Prepare(cfg) - testConfigOk(t, warns, errs) -} - -func TestNewConfig_exportConfig(t *testing.T) { - type testCase struct { - InputConfigVals map[string]string - ExpectedSkipExportValue bool - ExpectedFormat string - ExpectedErr bool - Reason string - } - testCases := []testCase{ - { - InputConfigVals: map[string]string{ - "remote_type": "", - "format": "", - }, - ExpectedSkipExportValue: true, - ExpectedFormat: "vmx", - ExpectedErr: false, - Reason: "should have defaulted format to vmx.", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "esx5", - "format": "", - "remote_host": "fakehost.com", - "remote_password": "fakepassword", - "remote_username": "fakeuser", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ovf", - ExpectedErr: false, - Reason: "should have defaulted format to ovf with remote set to esx5.", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "esx5", - "format": "", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ovf", - ExpectedErr: true, - Reason: "should have errored because remote host isn't set for remote build.", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "invalid", - "format": "", - "remote_host": "fakehost.com", - "remote_password": "fakepassword", - "remote_username": "fakeuser", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ovf", - ExpectedErr: true, - Reason: "should error with invalid remote type", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "", - "format": "invalid", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "invalid", - ExpectedErr: true, - Reason: "should error with invalid format", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "", - "format": "ova", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ova", - ExpectedErr: false, - Reason: "should set user-given ova format", - }, - { - InputConfigVals: map[string]string{ - "remote_type": "esx5", - "format": "ova", - "remote_host": "fakehost.com", - "remote_password": "fakepassword", - "remote_username": "fakeuser", - }, - ExpectedSkipExportValue: false, - ExpectedFormat: "ova", - ExpectedErr: false, - Reason: "should set user-given ova format", - }, - } - for _, tc := range testCases { - cfg := testConfig(t) - for k, v := range tc.InputConfigVals { - cfg[k] = v - } - cfg["skip_validate_credentials"] = true - outCfg := &Config{} - warns, errs := (outCfg).Prepare(cfg) - - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - - if (errs != nil) != tc.ExpectedErr { - t.Fatalf("received error: \n %s \n but 'expected err' was %t", errs, tc.ExpectedErr) - } - - if outCfg.Format != tc.ExpectedFormat { - t.Fatalf("Expected: %s. Actual: %s. Reason: %s", tc.ExpectedFormat, - outCfg.Format, tc.Reason) - } - if outCfg.SkipExport != tc.ExpectedSkipExportValue { - t.Fatalf("For SkipExport expected %t but recieved %t", - tc.ExpectedSkipExportValue, outCfg.SkipExport) - } - } -} diff --git a/builder/vmware/vmx/step_clone_vmx_test.go b/builder/vmware/vmx/step_clone_vmx_test.go deleted file mode 100644 index 8f3675fa1..000000000 --- a/builder/vmware/vmx/step_clone_vmx_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package vmx - -import ( - "context" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/stretchr/testify/assert" -) - -const ( - scsiFilename = "scsiDisk.vmdk" - sataFilename = "sataDisk.vmdk" - nvmeFilename = "nvmeDisk.vmdk" - ideFilename = "ideDisk.vmdk" -) - -func TestStepCloneVMX_impl(t *testing.T) { - var _ multistep.Step = new(StepCloneVMX) -} - -func TestStepCloneVMX(t *testing.T) { - // Setup some state - td, err := ioutil.TempDir("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.RemoveAll(td) - - // Set up mock vmx file contents - var testCloneVMX = fmt.Sprintf("scsi0:0.filename = \"%s\"\n"+ - "sata0:0.filename = \"%s\"\n"+ - "nvme0:0.filename = \"%s\"\n"+ - "ide1:0.filename = \"%s\"\n"+ - "ide0:0.filename = \"auto detect\"\n"+ - "ethernet0.connectiontype = \"nat\"\n", scsiFilename, - sataFilename, nvmeFilename, ideFilename) - - // Set up expected mock disk file paths - diskFilenames := []string{scsiFilename, sataFilename, ideFilename, nvmeFilename} - var diskFullPaths []string - for _, diskFilename := range diskFilenames { - diskFullPaths = append(diskFullPaths, filepath.Join(td, diskFilename)) - } - - // Create the source - sourcePath := filepath.Join(td, "source.vmx") - if err := ioutil.WriteFile(sourcePath, []byte(testCloneVMX), 0644); err != nil { - t.Fatalf("err: %s", err) - } - - // Create the dest because the mock driver won't - destPath := filepath.Join(td, "foo.vmx") - if err := ioutil.WriteFile(destPath, []byte(testCloneVMX), 0644); err != nil { - t.Fatalf("err: %s", err) - } - - state := testState(t) - step := new(StepCloneVMX) - step.OutputDir = &td - step.Path = sourcePath - step.VMName = "foo" - - driver := state.Get("driver").(*vmwcommon.DriverMock) - - // Test the run - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test we cloned - if !driver.CloneCalled { - t.Fatal("should call clone") - } - - // Test that we have our paths - if vmxPath, ok := state.GetOk("vmx_path"); !ok { - t.Fatal("should set vmx_path") - } else if vmxPath != destPath { - t.Fatalf("bad path to vmx: %#v", vmxPath) - } - - if stateDiskPaths, ok := state.GetOk("disk_full_paths"); !ok { - t.Fatal("should set disk_full_paths") - } else { - assert.ElementsMatchf(t, stateDiskPaths.([]string), diskFullPaths, - "%s\nshould contain the same elements as:\n%s", stateDiskPaths.([]string), diskFullPaths) - } - - // Test we got the network type - if networkType, ok := state.GetOk("vmnetwork"); !ok { - t.Fatal("should set vmnetwork") - } else if networkType != "nat" { - t.Fatalf("bad network type: %#v", networkType) - } -} diff --git a/builder/vmware/vmx/step_test.go b/builder/vmware/vmx/step_test.go deleted file mode 100644 index d0b84d44e..000000000 --- a/builder/vmware/vmx/step_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package vmx - -import ( - "bytes" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" -) - -func testState(t *testing.T) multistep.StateBag { - state := new(multistep.BasicStateBag) - state.Put("driver", new(vmwcommon.DriverMock)) - state.Put("ui", &packersdk.BasicUi{ - Reader: new(bytes.Buffer), - Writer: new(bytes.Buffer), - }) - return state -} diff --git a/command/plugin.go b/command/plugin.go index 0038c7976..b99a67e5d 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -50,8 +50,6 @@ import ( tritonbuilder "github.com/hashicorp/packer/builder/triton" uclouduhostbuilder "github.com/hashicorp/packer/builder/ucloud/uhost" vagrantbuilder "github.com/hashicorp/packer/builder/vagrant" - vmwareisobuilder "github.com/hashicorp/packer/builder/vmware/iso" - vmwarevmxbuilder "github.com/hashicorp/packer/builder/vmware/vmx" yandexbuilder "github.com/hashicorp/packer/builder/yandex" alicloudimportpostprocessor "github.com/hashicorp/packer/post-processor/alicloud-import" artificepostprocessor "github.com/hashicorp/packer/post-processor/artifice" @@ -125,8 +123,6 @@ var Builders = map[string]packersdk.Builder{ "triton": new(tritonbuilder.Builder), "ucloud-uhost": new(uclouduhostbuilder.Builder), "vagrant": new(vagrantbuilder.Builder), - "vmware-iso": new(vmwareisobuilder.Builder), - "vmware-vmx": new(vmwarevmxbuilder.Builder), "yandex": new(yandexbuilder.Builder), } diff --git a/command/vendored_plugins.go b/command/vendored_plugins.go index a66f20a2c..12fecfe3f 100644 --- a/command/vendored_plugins.go +++ b/command/vendored_plugins.go @@ -28,6 +28,8 @@ import ( virtualboxisobuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/iso" virtualboxovfbuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/ovf" virtualboxvmbuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/vm" + vmwareisobuilder "github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso" + vmwarevmxbuilder "github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx" vsphereclonebuilder "github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone" vsphereisobuilder "github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso" vspherepostprocessor "github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere" @@ -56,6 +58,8 @@ var VendoredBuilders = map[string]packersdk.Builder{ "virtualbox-iso": new(virtualboxisobuilder.Builder), "virtualbox-ovf": new(virtualboxovfbuilder.Builder), "virtualbox-vm": new(virtualboxvmbuilder.Builder), + "vmware-iso": new(vmwareisobuilder.Builder), + "vmware-vmx": new(vmwarevmxbuilder.Builder), } // VendoredProvisioners are provisioner components that were once bundled with the diff --git a/go.mod b/go.mod index 567b3f4f9..0428e28fe 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,8 @@ require ( github.com/hashicorp/packer-plugin-googlecompute v0.0.1 github.com/hashicorp/packer-plugin-sdk v0.2.0 github.com/hashicorp/packer-plugin-virtualbox v0.0.1 - github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6 + github.com/hashicorp/packer-plugin-vmware v0.0.1 + github.com/hashicorp/packer-plugin-vsphere v0.0.1 github.com/hetznercloud/hcloud-go v1.15.1 github.com/hyperonecom/h1-client-go v0.0.0-20191203060043-b46280e4c4a4 github.com/jdcloud-api/jdcloud-sdk-go v1.9.1-0.20190605102154-3d81a50ca961 @@ -82,18 +83,17 @@ require ( github.com/ucloud/ucloud-sdk-go v0.16.3 github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6 github.com/ulikunitz/xz v0.5.6 - github.com/vmware/govmomi v0.24.1 github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0 github.com/yandex-cloud/go-genproto v0.0.0-20200915125933-33de72a328bd github.com/yandex-cloud/go-sdk v0.0.0-20200921111412-ef15ded2014c github.com/zclconf/go-cty v1.8.1 github.com/zclconf/go-cty-yaml v1.0.1 - golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad + golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc golang.org/x/mod v0.4.1 - golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 + golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 + golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 golang.org/x/tools v0.1.0 google.golang.org/grpc v1.36.1 ) diff --git a/go.sum b/go.sum index 3168c660c..0b1f883e5 100644 --- a/go.sum +++ b/go.sum @@ -452,6 +452,7 @@ github.com/hashicorp/packer v1.6.7-0.20210208125835-f616955ebcb6/go.mod h1:7f5Zp github.com/hashicorp/packer v1.6.7-0.20210217093213-201869d627bf/go.mod h1:+EWPPcqee4h8S/y913Dnta1eJkgiqsGXBQgB75A2qV0= github.com/hashicorp/packer v1.7.0/go.mod h1:3KRJcwOctl2JaAGpQMI1bWQRArfWNWqcYjO6AOsVVGQ= github.com/hashicorp/packer v1.7.1/go.mod h1:ApnmMINvuhhnfPyTVqZu6jznDWPVYDJUw7e188DFCmo= +github.com/hashicorp/packer v1.7.2/go.mod h1:c/QB/DWK5fSdtNWrTb9etWacmbm01UY23ZILpGundCY= github.com/hashicorp/packer-plugin-amazon v0.0.1 h1:EuyjNK9bL7WhQeIJzhBJxOx8nyc61ai5UbOsb1PIVwI= github.com/hashicorp/packer-plugin-amazon v0.0.1/go.mod h1:12c9msibyHdId+Mk/pCbdRb1KaLIhaNyxeJ6n8bZt30= github.com/hashicorp/packer-plugin-ansible v0.0.2 h1:nvBtCedXhUI5T6Up5+bmhlY7rmk8FjWuFv9A2joK7TU= @@ -471,15 +472,18 @@ github.com/hashicorp/packer-plugin-sdk v0.0.14/go.mod h1:tNb3XzJPnjMl3QuUdKmF47B github.com/hashicorp/packer-plugin-sdk v0.1.0/go.mod h1:CFsC20uZjtER/EnTn/CSMKD0kEdkqOVev8mtOmfnZiI= github.com/hashicorp/packer-plugin-sdk v0.1.1/go.mod h1:1d3nqB9LUsXMQaNUiL67Q+WYEtjsVcLNTX8ikVlpBrc= github.com/hashicorp/packer-plugin-sdk v0.1.2/go.mod h1:KRjczE1/c9NV5Re+PXt3myJsVTI/FxEHpZjRjOH0Fug= +github.com/hashicorp/packer-plugin-sdk v0.1.3-0.20210407232143-c217d82aefb6/go.mod h1:xePpgQgQYv/bamiypx3hH9ukidxDdcN8q0R0wLi8IEQ= github.com/hashicorp/packer-plugin-sdk v0.1.3/go.mod h1:xePpgQgQYv/bamiypx3hH9ukidxDdcN8q0R0wLi8IEQ= github.com/hashicorp/packer-plugin-sdk v0.2.0 h1:A4Dq7p4y1vscY4gMzp7GQaXyDJYYhP4ukp4fapPSOY4= github.com/hashicorp/packer-plugin-sdk v0.2.0/go.mod h1:0DiOMEBldmB0HEhp0npFSSygC8bIvW43pphEgWkp2WU= -github.com/hashicorp/packer-plugin-virtualbox v0.0.0-20210415132603-5d753f7335b4 h1:AQk/P0QydTRFda9br8Dv3DDv7DCjGLHwfLjXmudA900= -github.com/hashicorp/packer-plugin-virtualbox v0.0.0-20210415132603-5d753f7335b4/go.mod h1:OOGNMK8Y8zjsYngesZH5kCbH0Fj8PKvhqPp8w1ejM3Y= github.com/hashicorp/packer-plugin-virtualbox v0.0.1 h1:vTfy7a10RUVMdNnDLo0EQrCVbAG4rGWkaDTMC7MVBi4= github.com/hashicorp/packer-plugin-virtualbox v0.0.1/go.mod h1:OOGNMK8Y8zjsYngesZH5kCbH0Fj8PKvhqPp8w1ejM3Y= -github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6 h1:pOv7Apd4P3KEpNBHLV4E7tKlwHoInCU/bnPVadGSDxY= -github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6/go.mod h1:XMhsLDDT7sD2BWaruLvGPynnn4IqdbrfvuKhb1GK1RI= +github.com/hashicorp/packer-plugin-vmware v0.0.0-20210416150724-592c0637562a h1:LpZ+8Y1vozsI4vuAjUpUOEzFl+jNSY4SL1kfGkVMmb8= +github.com/hashicorp/packer-plugin-vmware v0.0.0-20210416150724-592c0637562a/go.mod h1:NsiT4IOeDKf/aszQNX+/B1xHrfBR3RdUM3sSqANgNec= +github.com/hashicorp/packer-plugin-vmware v0.0.1 h1:jRQAdjHwg3zeCBb52KoZsuxugrHcQhjgQln72o9eGgM= +github.com/hashicorp/packer-plugin-vmware v0.0.1/go.mod h1:NsiT4IOeDKf/aszQNX+/B1xHrfBR3RdUM3sSqANgNec= +github.com/hashicorp/packer-plugin-vsphere v0.0.1 h1:4SUmRP+mGpBJHp6dLL4dmBCC+yDseTktb9YNLj11mVI= +github.com/hashicorp/packer-plugin-vsphere v0.0.1/go.mod h1:XMhsLDDT7sD2BWaruLvGPynnn4IqdbrfvuKhb1GK1RI= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.2 h1:yJoyfZXo4Pk2p/M/viW+YLibBFiIbKoP79gu7kDAFP0= github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= @@ -778,8 +782,9 @@ golang.org/x/crypto v0.0.0-20200422194213-44a606286825/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc h1:+q90ECDSAQirdykUN6sPEiBXBsp8Csjcca8Oy7bgLTA= +golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -861,8 +866,9 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 h1:b0LrWgu8+q7z4J+0Y3Umo5q1dL7NXBkKBWkaVkAq17E= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d h1:BgJvlyh+UqCUaPlscHJ+PN8GcpfrFdr7NHjd1JL0+Gs= +golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -943,8 +949,9 @@ golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -955,8 +962,9 @@ golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5f golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= diff --git a/vendor/github.com/hashicorp/packer-plugin-vmware/LICENSE b/vendor/github.com/hashicorp/packer-plugin-vmware/LICENSE new file mode 100644 index 000000000..a612ad981 --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/builder/vmware/common/artifact.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/artifact.go similarity index 100% rename from builder/vmware/common/artifact.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/artifact.go diff --git a/builder/vmware/common/disk_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/disk_config.go similarity index 100% rename from builder/vmware/common/disk_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/disk_config.go diff --git a/builder/vmware/common/driver.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver.go similarity index 99% rename from builder/vmware/common/driver.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver.go index 511c3d8fa..d2fbcfe4b 100644 --- a/builder/vmware/common/driver.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver.go @@ -88,7 +88,7 @@ type Driver interface { // NewDriver returns a new driver implementation for this operating // system, or an error if the driver couldn't be initialized. func NewDriver(dconfig *DriverConfig, config *SSHConfig, vmName string) (Driver, error) { - drivers := []Driver{} + var drivers []Driver if dconfig.RemoteType != "" { esx5Driver, err := NewESX5Driver(dconfig, config, vmName) diff --git a/builder/vmware/common/driver_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_config.go similarity index 100% rename from builder/vmware/common/driver_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_config.go diff --git a/builder/vmware/common/driver_esx5.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_esx5.go similarity index 99% rename from builder/vmware/common/driver_esx5.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_esx5.go index 2a92e60eb..6e5770cc0 100644 --- a/builder/vmware/common/driver_esx5.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_esx5.go @@ -199,7 +199,7 @@ func (d *ESX5Driver) ReloadVM() error { func (d *ESX5Driver) Start(vmxPathLocal string, headless bool) error { for i := 0; i < 20; i++ { //intentionally not checking for error since poweron may fail specially after initial VM registration - d.sh("vim-cmd", "vmsvc/power.on", d.vmId) + _ = d.sh("vim-cmd", "vmsvc/power.on", d.vmId) time.Sleep((time.Duration(i) * time.Second) + 1) running, err := d.IsRunning(vmxPathLocal) if err != nil { @@ -525,7 +525,7 @@ func (d *ESX5Driver) VNCAddress(ctx context.Context, _ string, portMin, portMax } } - vncTimeout := time.Duration(15 * time.Second) + vncTimeout := 15 * time.Second envTimeout := os.Getenv("PACKER_ESXI_VNC_PROBE_TIMEOUT") if envTimeout != "" { if parsedTimeout, err := time.ParseDuration(envTimeout); err != nil { diff --git a/builder/vmware/common/driver_fusion5.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_fusion5.go similarity index 100% rename from builder/vmware/common/driver_fusion5.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_fusion5.go diff --git a/builder/vmware/common/driver_fusion6.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_fusion6.go similarity index 100% rename from builder/vmware/common/driver_fusion6.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_fusion6.go diff --git a/builder/vmware/common/driver_mock.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_mock.go similarity index 100% rename from builder/vmware/common/driver_mock.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_mock.go diff --git a/builder/vmware/common/driver_parser.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_parser.go similarity index 99% rename from builder/vmware/common/driver_parser.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_parser.go index 825fa7bd5..300fbf0d2 100644 --- a/builder/vmware/common/driver_parser.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_parser.go @@ -138,9 +138,7 @@ type tkParameter struct { func (e *tkParameter) String() string { var values []string - for _, val := range e.operand { - values = append(values, val) - } + values = append(values, e.operand...) return fmt.Sprintf("%s [%s]", e.name, strings.Join(values, ",")) } @@ -156,9 +154,7 @@ func (e *tkGroup) String() string { var id []string id = append(id, e.id.name) - for _, val := range e.id.operand { - id = append(id, val) - } + id = append(id, e.id.operand...) var config []string for _, val := range e.params { @@ -640,10 +636,6 @@ type pDeclarationGroup struct{} func (e pDeclarationGroup) repr() string { return fmt.Sprintf("{group}") } -type pDeclarationClass struct{ name string } - -func (e pDeclarationClass) repr() string { return fmt.Sprintf("{class}") } - /** parsers */ func parseParameter(val tkParameter) (pParameter, error) { switch val.name { @@ -1024,9 +1016,9 @@ func (e *configDeclaration) IP4() (net.IP, error) { var result []string for _, entry := range e.address { - switch entry.(type) { + switch v := entry.(type) { case pParameterAddress4: - for _, s := range entry.(pParameterAddress4) { + for _, s := range v { result = append(result, s) } } @@ -1057,9 +1049,9 @@ func (e *configDeclaration) IP6() (net.IP, error) { var result []string for _, entry := range e.address { - switch entry.(type) { + switch v := entry.(type) { case pParameterAddress6: - for _, s := range entry.(pParameterAddress6) { + for _, s := range v { result = append(result, s) } } @@ -1089,9 +1081,9 @@ func (e *configDeclaration) Hardware() (net.HardwareAddr, error) { var result []pParameterHardware for _, addr := range e.address { - switch addr.(type) { + switch v := addr.(type) { case pParameterHardware: - result = append(result, addr.(pParameterHardware)) + result = append(result, v) } } diff --git a/builder/vmware/common/driver_player5.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player5.go similarity index 100% rename from builder/vmware/common/driver_player5.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player5.go diff --git a/builder/vmware/common/driver_player5_windows.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player5_windows.go similarity index 100% rename from builder/vmware/common/driver_player5_windows.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player5_windows.go diff --git a/builder/vmware/common/driver_player6.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player6.go similarity index 100% rename from builder/vmware/common/driver_player6.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player6.go diff --git a/builder/vmware/common/driver_player6_windows.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player6_windows.go similarity index 100% rename from builder/vmware/common/driver_player6_windows.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player6_windows.go diff --git a/builder/vmware/common/driver_player_unix.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player_unix.go similarity index 100% rename from builder/vmware/common/driver_player_unix.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_player_unix.go diff --git a/builder/vmware/common/driver_workstation10.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation10.go similarity index 100% rename from builder/vmware/common/driver_workstation10.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation10.go diff --git a/builder/vmware/common/driver_workstation10_windows.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation10_windows.go similarity index 100% rename from builder/vmware/common/driver_workstation10_windows.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation10_windows.go diff --git a/builder/vmware/common/driver_workstation9.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation9.go similarity index 100% rename from builder/vmware/common/driver_workstation9.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation9.go diff --git a/builder/vmware/common/driver_workstation9_windows.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation9_windows.go similarity index 100% rename from builder/vmware/common/driver_workstation9_windows.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation9_windows.go diff --git a/builder/vmware/common/driver_workstation_unix.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation_unix.go similarity index 100% rename from builder/vmware/common/driver_workstation_unix.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/driver_workstation_unix.go diff --git a/builder/vmware/common/export_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/export_config.go similarity index 100% rename from builder/vmware/common/export_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/export_config.go diff --git a/builder/vmware/common/host_ip_ifconfig.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/host_ip_ifconfig.go similarity index 100% rename from builder/vmware/common/host_ip_ifconfig.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/host_ip_ifconfig.go diff --git a/builder/vmware/common/hw_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/hw_config.go similarity index 100% rename from builder/vmware/common/hw_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/hw_config.go diff --git a/builder/vmware/common/output_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/output_config.go similarity index 100% rename from builder/vmware/common/output_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/output_config.go diff --git a/builder/vmware/common/output_dir.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/output_dir.go similarity index 100% rename from builder/vmware/common/output_dir.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/output_dir.go diff --git a/builder/vmware/common/output_dir_local.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/output_dir_local.go similarity index 100% rename from builder/vmware/common/output_dir_local.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/output_dir_local.go diff --git a/builder/vmware/common/remote_driver.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/remote_driver.go similarity index 100% rename from builder/vmware/common/remote_driver.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/remote_driver.go diff --git a/builder/vmware/common/remote_driver_mock.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/remote_driver_mock.go similarity index 100% rename from builder/vmware/common/remote_driver_mock.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/remote_driver_mock.go diff --git a/builder/vmware/common/run_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/run_config.go similarity index 100% rename from builder/vmware/common/run_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/run_config.go diff --git a/builder/vmware/common/ssh.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/ssh.go similarity index 100% rename from builder/vmware/common/ssh.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/ssh.go diff --git a/builder/vmware/common/ssh_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/ssh_config.go similarity index 100% rename from builder/vmware/common/ssh_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/ssh_config.go diff --git a/builder/vmware/common/step_clean_files.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_clean_files.go similarity index 100% rename from builder/vmware/common/step_clean_files.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_clean_files.go diff --git a/builder/vmware/common/step_clean_vmx.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_clean_vmx.go similarity index 100% rename from builder/vmware/common/step_clean_vmx.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_clean_vmx.go diff --git a/builder/vmware/common/step_compact_disk.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_compact_disk.go similarity index 100% rename from builder/vmware/common/step_compact_disk.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_compact_disk.go diff --git a/builder/vmware/common/step_configure_vmx.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_configure_vmx.go similarity index 100% rename from builder/vmware/common/step_configure_vmx.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_configure_vmx.go diff --git a/builder/vmware/common/step_configure_vnc.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_configure_vnc.go similarity index 100% rename from builder/vmware/common/step_configure_vnc.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_configure_vnc.go diff --git a/builder/vmware/common/step_create_disks.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_create_disks.go similarity index 100% rename from builder/vmware/common/step_create_disks.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_create_disks.go diff --git a/builder/vmware/common/step_export.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_export.go similarity index 100% rename from builder/vmware/common/step_export.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_export.go diff --git a/builder/vmware/common/step_http_ip_discover.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_http_ip_discover.go similarity index 100% rename from builder/vmware/common/step_http_ip_discover.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_http_ip_discover.go diff --git a/builder/vmware/common/step_output_dir.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_output_dir.go similarity index 99% rename from builder/vmware/common/step_output_dir.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_output_dir.go index 6b59655a3..e51d24d75 100644 --- a/builder/vmware/common/step_output_dir.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_output_dir.go @@ -81,7 +81,7 @@ func (s *StepOutputDir) Run(ctx context.Context, state multistep.StateBag) multi if exists { if s.Force { ui.Message("Deleting previous output directory...") - dir.RemoveAll() + _ = dir.RemoveAll() } else { state.Put("error", fmt.Errorf( "Output directory '%s' already exists.", dir.String())) diff --git a/builder/vmware/common/step_prepare_tools.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_prepare_tools.go similarity index 100% rename from builder/vmware/common/step_prepare_tools.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_prepare_tools.go diff --git a/builder/vmware/common/step_register.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_register.go similarity index 97% rename from builder/vmware/common/step_register.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_register.go index 058be5e9e..de22484b5 100644 --- a/builder/vmware/common/step_register.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_register.go @@ -75,7 +75,7 @@ func (s *StepRegister) Cleanup(state multistep.StateBag) { } log.Printf("error destroying vm: %s", err) time.Sleep(1 * time.Second) - if time.Since(start) >= time.Duration(30*time.Minute) { + if time.Since(start) >= 30*time.Minute { ui.Error("Error unregistering VM; timed out. You may " + "need to manually clean up your machine") break diff --git a/builder/vmware/common/step_remote_upload.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_remote_upload.go similarity index 100% rename from builder/vmware/common/step_remote_upload.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_remote_upload.go diff --git a/builder/vmware/common/step_run.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_run.go similarity index 100% rename from builder/vmware/common/step_run.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_run.go diff --git a/builder/vmware/common/step_shutdown.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_shutdown.go similarity index 100% rename from builder/vmware/common/step_shutdown.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_shutdown.go diff --git a/builder/vmware/common/step_suppress_messages.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_suppress_messages.go similarity index 100% rename from builder/vmware/common/step_suppress_messages.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_suppress_messages.go diff --git a/builder/vmware/common/step_upload_tools.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_upload_tools.go similarity index 100% rename from builder/vmware/common/step_upload_tools.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_upload_tools.go diff --git a/builder/vmware/common/step_upload_vmx.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_upload_vmx.go similarity index 100% rename from builder/vmware/common/step_upload_vmx.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_upload_vmx.go diff --git a/builder/vmware/common/step_vnc_boot_command.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_vnc_boot_command.go similarity index 100% rename from builder/vmware/common/step_vnc_boot_command.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_vnc_boot_command.go diff --git a/builder/vmware/common/step_vnc_connect.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_vnc_connect.go similarity index 100% rename from builder/vmware/common/step_vnc_connect.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/step_vnc_connect.go diff --git a/builder/vmware/common/tools_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/tools_config.go similarity index 100% rename from builder/vmware/common/tools_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/tools_config.go diff --git a/builder/vmware/common/vmx.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/vmx.go similarity index 100% rename from builder/vmware/common/vmx.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/vmx.go diff --git a/builder/vmware/common/vmx_config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/vmx_config.go similarity index 100% rename from builder/vmware/common/vmx_config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/common/vmx_config.go diff --git a/builder/vmware/iso/builder.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/builder.go similarity index 98% rename from builder/vmware/iso/builder.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/builder.go index 7b712356c..7c319d697 100644 --- a/builder/vmware/iso/builder.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/builder.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/packer-plugin-sdk/multistep" "github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + vmwcommon "github.com/hashicorp/packer-plugin-vmware/builder/vmware/common" ) type Builder struct { diff --git a/builder/vmware/iso/config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/config.go similarity index 99% rename from builder/vmware/iso/config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/config.go index 4ba46b76c..2da79527c 100644 --- a/builder/vmware/iso/config.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/config.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + vmwcommon "github.com/hashicorp/packer-plugin-vmware/builder/vmware/common" ) type Config struct { diff --git a/builder/vmware/iso/config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/config.hcl2spec.go similarity index 100% rename from builder/vmware/iso/config.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/config.hcl2spec.go diff --git a/builder/vmware/iso/step_create_vmx.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/step_create_vmx.go similarity index 98% rename from builder/vmware/iso/step_create_vmx.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/step_create_vmx.go index 12f4642da..021a59982 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso/step_create_vmx.go @@ -13,7 +13,7 @@ import ( packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer-plugin-sdk/tmp" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + vmwcommon "github.com/hashicorp/packer-plugin-vmware/builder/vmware/common" ) type vmxTemplateData struct { @@ -161,8 +161,8 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi Network_Adapter: "e1000", - Sound_Present: map[bool]string{true: "TRUE", false: "FALSE"}[bool(config.HWConfig.Sound)], - Usb_Present: map[bool]string{true: "TRUE", false: "FALSE"}[bool(config.HWConfig.USB)], + Sound_Present: map[bool]string{true: "TRUE", false: "FALSE"}[config.HWConfig.Sound], + Usb_Present: map[bool]string{true: "TRUE", false: "FALSE"}[config.HWConfig.USB], Serial_Present: "FALSE", Parallel_Present: "FALSE", @@ -284,8 +284,6 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi templateData.Serial_Auto = "TRUE" case nil: templateData.Serial_Present = "FALSE" - break - default: err := fmt.Errorf("Error processing VMX template: %v", serial) state.Put("error", err) @@ -322,8 +320,6 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi templateData.Parallel_Bidirectional = parallel.Auto.Bidirectional case nil: templateData.Parallel_Present = "FALSE" - break - default: err := fmt.Errorf("Error processing VMX template: %v", parallel) state.Put("error", err) diff --git a/builder/vmware/vmx/builder.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/builder.go similarity index 98% rename from builder/vmware/vmx/builder.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/builder.go index b8ec91906..7e7b8deb5 100644 --- a/builder/vmware/vmx/builder.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/builder.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/packer-plugin-sdk/multistep" "github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + vmwcommon "github.com/hashicorp/packer-plugin-vmware/builder/vmware/common" ) // Builder implements packersdk.Builder and builds the actual VMware diff --git a/builder/vmware/vmx/config.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/config.go similarity index 98% rename from builder/vmware/vmx/config.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/config.go index 4b44b1f52..f5522d9b3 100644 --- a/builder/vmware/vmx/config.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/config.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + vmwcommon "github.com/hashicorp/packer-plugin-vmware/builder/vmware/common" ) // Config is the configuration structure for the builder. diff --git a/builder/vmware/vmx/config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/config.hcl2spec.go similarity index 100% rename from builder/vmware/vmx/config.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/config.hcl2spec.go diff --git a/builder/vmware/vmx/step_clone_vmx.go b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/step_clone_vmx.go similarity index 98% rename from builder/vmware/vmx/step_clone_vmx.go rename to vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/step_clone_vmx.go index 3ae63e596..23165796d 100644 --- a/builder/vmware/vmx/step_clone_vmx.go +++ b/vendor/github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx/step_clone_vmx.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/tmp" - vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + vmwcommon "github.com/hashicorp/packer-plugin-vmware/builder/vmware/common" ) // StepCloneVMX takes a VMX file and clones the VM into the output directory. diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.go index 900e901f7..9127df32d 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package clone diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.hcl2spec.go index 4ca2c4fb9..ac1f584f3 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package clone diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.go index 3d6021f83..0f3845401 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type CloneConfig,vAppConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type CloneConfig,vAppConfig package clone diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.hcl2spec.go index e02a3c174..cdaf03958 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_clone.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type CloneConfig,vAppConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package clone diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go index 86714317a..e5797f639 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type CustomizeConfig,LinuxOptions,NetworkInterfaces,NetworkInterface,GlobalDnsSettings,GlobalRoutingSettings +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type CustomizeConfig,LinuxOptions,NetworkInterfaces,NetworkInterface,GlobalDnsSettings,GlobalRoutingSettings package clone import ( diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.hcl2spec.go index 0634474a3..28364c020 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type CustomizeConfig,LinuxOptions,NetworkInterfaces,NetworkInterface,GlobalDnsSettings,GlobalRoutingSettings"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package clone diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.go index 06c651a10..ad8968c7b 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type LocationConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type LocationConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.hcl2spec.go index c55712475..62cb7204b 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/config_location.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type LocationConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.go index 1aef6cc30..e894a9da6 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type OutputConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type OutputConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.hcl2spec.go index 0cec88325..5957ffe07 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/output_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type OutputConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.go index fe1dfd2fb..358852387 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type CDRomConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type CDRomConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.hcl2spec.go index 205232829..5edd0915b 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_cdrom.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type CDRomConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.go index 41b3b09ee..0df37b68e 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type FloppyConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type FloppyConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.hcl2spec.go index a42511314..0a383056a 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_add_floppy.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type FloppyConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_boot_command.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_boot_command.go index 7de930748..59997a4e8 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_boot_command.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_boot_command.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common import ( diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.go index fc86d9816..4ad92ad68 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type ConfigParamsConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type ConfigParamsConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.hcl2spec.go index a68cb3ad2..e15d69dd4 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_config_params.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type ConfigParamsConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.go index 0398c6997..fdde16cf2 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type ConnectConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type ConnectConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.hcl2spec.go index fa5782e33..99d2e8764 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_connect.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type ConnectConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.go index 4aafda86f..03ee75ef6 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type ExportConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type ExportConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.hcl2spec.go index 21824d5d5..684147396 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_export.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type ExportConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.go index edf0314eb..9a4127f77 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type HardwareConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type HardwareConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.hcl2spec.go index 334e6a644..2c2b3a381 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_hardware.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type HardwareConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.go index 2e2350f6a..6e39582b2 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type ContentLibraryDestinationConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type ContentLibraryDestinationConfig package common import ( diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.hcl2spec.go index 2c42538fb..5b00995c5 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type ContentLibraryDestinationConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.go index f3a104ddf..d7315f6ce 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type RemoveCDRomConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type RemoveCDRomConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.hcl2spec.go index 826cacdf4..1a94ef47b 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_remove_cdrom.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type RemoveCDRomConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.go index dff47eda4..effcc6e4e 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type RunConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type RunConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.hcl2spec.go index 5ecc99cae..c69d5dd44 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_run.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type RunConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.go index 6d99929c5..a60463854 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type ShutdownConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type ShutdownConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.hcl2spec.go index 323e771c8..a7ce05d4a 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_shutdown.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type ShutdownConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.go index 2fb183bde..ce575d12a 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type WaitIpConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type WaitIpConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.hcl2spec.go index c65302f31..b94aa779a 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_wait_for_ip.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type WaitIpConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.go index 6650616d5..429d244d4 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type StorageConfig,DiskConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type StorageConfig,DiskConfig package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.hcl2spec.go index 1d8fbd8c5..ad57d92e8 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/storage_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type StorageConfig,DiskConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.go index 94a2d850c..c5234b519 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package iso diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.hcl2spec.go index c502743b7..f4b627b73 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package iso diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.go index 10ff39336..f9cd0de62 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type NIC,CreateConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type NIC,CreateConfig package iso diff --git a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.hcl2spec.go index 130cd6a1c..cf296c8b2 100644 --- a/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.hcl2spec.go +++ b/vendor/github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/step_create.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type NIC,CreateConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package iso diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go index c474e5a80..94c71ac1a 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.11 && gc && !purego // +build go1.11,gc,!purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go b/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go index 3e8a609fb..025b49897 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (!arm64 && !s390x && !ppc64le) || (arm64 && !go1.11) || !gc || purego // +build !arm64,!s390x,!ppc64le arm64,!go1.11 !gc purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go index 2806c6325..da420b2e9 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc && !purego // +build gc,!purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go index a0774dde1..c5898db46 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc && !purego // +build gc,!purego package chacha20 diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go b/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go index 877b6de29..84858480d 100644 --- a/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go +++ b/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && gc && !purego // +build amd64,gc,!purego package curve25519 diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go b/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go index 80d3300af..259728af7 100644 --- a/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go +++ b/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !amd64 || !gc || purego // +build !amd64 !gc purego package curve25519 diff --git a/vendor/golang.org/x/crypto/ed25519/ed25519.go b/vendor/golang.org/x/crypto/ed25519/ed25519.go index c7f8c7e64..71ad917da 100644 --- a/vendor/golang.org/x/crypto/ed25519/ed25519.go +++ b/vendor/golang.org/x/crypto/ed25519/ed25519.go @@ -5,6 +5,7 @@ // In Go 1.13, the ed25519 package was promoted to the standard library as // crypto/ed25519, and this package became a wrapper for the standard library one. // +//go:build !go1.13 // +build !go1.13 // Package ed25519 implements the Ed25519 signature algorithm. See diff --git a/vendor/golang.org/x/crypto/ed25519/ed25519_go113.go b/vendor/golang.org/x/crypto/ed25519/ed25519_go113.go index d1448d8d2..b5974dc8b 100644 --- a/vendor/golang.org/x/crypto/ed25519/ed25519_go113.go +++ b/vendor/golang.org/x/crypto/ed25519/ed25519_go113.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.13 // +build go1.13 // Package ed25519 implements the Ed25519 signature algorithm. See diff --git a/vendor/golang.org/x/crypto/internal/subtle/aliasing.go b/vendor/golang.org/x/crypto/internal/subtle/aliasing.go index 281c27ef0..4fad24f8d 100644 --- a/vendor/golang.org/x/crypto/internal/subtle/aliasing.go +++ b/vendor/golang.org/x/crypto/internal/subtle/aliasing.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !purego // +build !purego // Package subtle implements functions that are often useful in cryptographic diff --git a/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go b/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go index e20a29659..80ccbed2c 100644 --- a/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go +++ b/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build purego // +build purego // Package subtle implements functions that are often useful in cryptographic diff --git a/vendor/golang.org/x/crypto/poly1305/bits_compat.go b/vendor/golang.org/x/crypto/poly1305/bits_compat.go index 157a69f61..45b5c966b 100644 --- a/vendor/golang.org/x/crypto/poly1305/bits_compat.go +++ b/vendor/golang.org/x/crypto/poly1305/bits_compat.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.13 // +build !go1.13 package poly1305 diff --git a/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go b/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go index a0a185f0f..ed52b3418 100644 --- a/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go +++ b/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.13 // +build go1.13 package poly1305 diff --git a/vendor/golang.org/x/crypto/poly1305/mac_noasm.go b/vendor/golang.org/x/crypto/poly1305/mac_noasm.go index af6c94f92..f184b67d9 100644 --- a/vendor/golang.org/x/crypto/poly1305/mac_noasm.go +++ b/vendor/golang.org/x/crypto/poly1305/mac_noasm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (!amd64 && !ppc64le && !s390x) || !gc || purego // +build !amd64,!ppc64le,!s390x !gc purego package poly1305 diff --git a/vendor/golang.org/x/crypto/poly1305/sum_amd64.go b/vendor/golang.org/x/crypto/poly1305/sum_amd64.go index cf3a69ed3..6d522333f 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_amd64.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc && !purego // +build gc,!purego package poly1305 diff --git a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go index cb4b7185d..4a069941a 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc && !purego // +build gc,!purego package poly1305 diff --git a/vendor/golang.org/x/crypto/poly1305/sum_s390x.go b/vendor/golang.org/x/crypto/poly1305/sum_s390x.go index 188a665e1..62cc9f847 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_s390x.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_s390x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc && !purego // +build gc,!purego package poly1305 diff --git a/vendor/golang.org/x/net/http2/Dockerfile b/vendor/golang.org/x/net/http2/Dockerfile index 53fc52579..851224595 100644 --- a/vendor/golang.org/x/net/http2/Dockerfile +++ b/vendor/golang.org/x/net/http2/Dockerfile @@ -38,7 +38,7 @@ RUN make RUN make install WORKDIR /root -RUN wget http://curl.haxx.se/download/curl-7.45.0.tar.gz +RUN wget https://curl.se/download/curl-7.45.0.tar.gz RUN tar -zxvf curl-7.45.0.tar.gz WORKDIR /root/curl-7.45.0 RUN ./configure --with-ssl --with-nghttp2=/usr/local diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 0bdc9b530..f2bc86314 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -56,6 +56,7 @@ includes_Darwin=' #define _DARWIN_C_SOURCE #define KERNEL #define _DARWIN_USE_64_BIT_INODE +#define __APPLE_USE_RFC_3542 #include #include #include @@ -501,7 +502,7 @@ ccflags="$@" $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL)_/ || $2 ~ /^TP_STATUS_/ || $2 ~ /^FALLOC_/ || - $2 ~ /^ICMP(V6)?_FILTER$/ || + $2 ~ /^ICMP(V6)?_FILTER/ || $2 == "SOMAXCONN" || $2 == "NAME_MAX" || $2 == "IFNAMSIZ" || diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index 0100cb12f..991996b60 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -776,15 +776,24 @@ const ( IPV6_2292PKTINFO = 0x13 IPV6_2292PKTOPTIONS = 0x19 IPV6_2292RTHDR = 0x18 + IPV6_3542DSTOPTS = 0x32 + IPV6_3542HOPLIMIT = 0x2f + IPV6_3542HOPOPTS = 0x31 + IPV6_3542NEXTHOP = 0x30 + IPV6_3542PKTINFO = 0x2e + IPV6_3542RTHDR = 0x33 IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 + IPV6_AUTOFLOWLABEL = 0x3b IPV6_BINDV6ONLY = 0x1b IPV6_BOUND_IF = 0x7d IPV6_CHECKSUM = 0x1a IPV6_DEFAULT_MULTICAST_HOPS = 0x1 IPV6_DEFAULT_MULTICAST_LOOP = 0x1 IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 @@ -796,6 +805,8 @@ const ( IPV6_FW_GET = 0x22 IPV6_FW_ZERO = 0x21 IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 IPV6_IPSEC_POLICY = 0x1c IPV6_JOIN_GROUP = 0xc IPV6_LEAVE_GROUP = 0xd @@ -807,20 +818,34 @@ const ( IPV6_MAX_SOCK_SRC_FILTER = 0x80 IPV6_MIN_MEMBERSHIPS = 0x1f IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a IPV6_MULTICAST_HOPS = 0xa IPV6_MULTICAST_IF = 0x9 IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e IPV6_PORTRANGE = 0xe IPV6_PORTRANGE_DEFAULT = 0x0 IPV6_PORTRANGE_HIGH = 0x1 IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x3d + IPV6_RECVRTHDR = 0x26 IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x39 IPV6_RTHDR_LOOSE = 0x0 IPV6_RTHDR_STRICT = 0x1 IPV6_RTHDR_TYPE_0 = 0x0 IPV6_SOCKOPT_RESERVED1 = 0x3 IPV6_TCLASS = 0x24 IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a IPV6_V6ONLY = 0x1b IPV6_VERSION = 0x60 IPV6_VERSION_MASK = 0xf0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index df26a1968..e644eaf5e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -776,15 +776,24 @@ const ( IPV6_2292PKTINFO = 0x13 IPV6_2292PKTOPTIONS = 0x19 IPV6_2292RTHDR = 0x18 + IPV6_3542DSTOPTS = 0x32 + IPV6_3542HOPLIMIT = 0x2f + IPV6_3542HOPOPTS = 0x31 + IPV6_3542NEXTHOP = 0x30 + IPV6_3542PKTINFO = 0x2e + IPV6_3542RTHDR = 0x33 IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 + IPV6_AUTOFLOWLABEL = 0x3b IPV6_BINDV6ONLY = 0x1b IPV6_BOUND_IF = 0x7d IPV6_CHECKSUM = 0x1a IPV6_DEFAULT_MULTICAST_HOPS = 0x1 IPV6_DEFAULT_MULTICAST_LOOP = 0x1 IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 @@ -796,6 +805,8 @@ const ( IPV6_FW_GET = 0x22 IPV6_FW_ZERO = 0x21 IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 IPV6_IPSEC_POLICY = 0x1c IPV6_JOIN_GROUP = 0xc IPV6_LEAVE_GROUP = 0xd @@ -807,20 +818,34 @@ const ( IPV6_MAX_SOCK_SRC_FILTER = 0x80 IPV6_MIN_MEMBERSHIPS = 0x1f IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a IPV6_MULTICAST_HOPS = 0xa IPV6_MULTICAST_IF = 0x9 IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e IPV6_PORTRANGE = 0xe IPV6_PORTRANGE_DEFAULT = 0x0 IPV6_PORTRANGE_HIGH = 0x1 IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x3d + IPV6_RECVRTHDR = 0x26 IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x39 IPV6_RTHDR_LOOSE = 0x0 IPV6_RTHDR_STRICT = 0x1 IPV6_RTHDR_TYPE_0 = 0x0 IPV6_SOCKOPT_RESERVED1 = 0x3 IPV6_TCLASS = 0x24 IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a IPV6_V6ONLY = 0x1b IPV6_VERSION = 0x60 IPV6_VERSION_MASK = 0xf0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go index 0326a6b3a..3df99f285 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go @@ -1022,6 +1022,15 @@ const ( MAP_RESERVED0100 = 0x100 MAP_SHARED = 0x1 MAP_STACK = 0x400 + MCAST_BLOCK_SOURCE = 0x54 + MCAST_EXCLUDE = 0x2 + MCAST_INCLUDE = 0x1 + MCAST_JOIN_GROUP = 0x50 + MCAST_JOIN_SOURCE_GROUP = 0x52 + MCAST_LEAVE_GROUP = 0x51 + MCAST_LEAVE_SOURCE_GROUP = 0x53 + MCAST_UNBLOCK_SOURCE = 0x55 + MCAST_UNDEFINED = 0x0 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MNT_ACLS = 0x8000000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 3b1b9287b..35de419c6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -974,6 +974,10 @@ const ( HUGETLBFS_MAGIC = 0x958458f6 IBSHIFT = 0x10 ICMPV6_FILTER = 0x1 + ICMPV6_FILTER_BLOCK = 0x1 + ICMPV6_FILTER_BLOCKOTHERS = 0x3 + ICMPV6_FILTER_PASS = 0x2 + ICMPV6_FILTER_PASSONLY = 0x4 ICMP_FILTER = 0x1 ICRNL = 0x100 IFA_F_DADFAILED = 0x8 diff --git a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go index 4117ce08a..c8c790903 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go @@ -137,6 +137,7 @@ const ( IP_TTL = 3 IP_UNBLOCK_SOURCE = 11 ICANON = 0x0010 + ICMP6_FILTER = 0x26 ICRNL = 0x0002 IEXTEN = 0x0020 IGNBRK = 0x0004 diff --git a/vendor/golang.org/x/text/internal/language/language.go b/vendor/golang.org/x/text/internal/language/language.go index 1e74d1aff..f41aedcfc 100644 --- a/vendor/golang.org/x/text/internal/language/language.go +++ b/vendor/golang.org/x/text/internal/language/language.go @@ -303,9 +303,17 @@ func (t Tag) Extensions() []string { // are of the allowed values defined for the Unicode locale extension ('u') in // https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers. // TypeForKey will traverse the inheritance chain to get the correct value. +// +// If there are multiple types associated with a key, only the first will be +// returned. If there is no type associated with a key, it returns the empty +// string. func (t Tag) TypeForKey(key string) string { - if start, end, _ := t.findTypeForKey(key); end != start { - return t.str[start:end] + if _, start, end, _ := t.findTypeForKey(key); end != start { + s := t.str[start:end] + if p := strings.IndexByte(s, '-'); p >= 0 { + s = s[:p] + } + return s } return "" } @@ -329,13 +337,13 @@ func (t Tag) SetTypeForKey(key, value string) (Tag, error) { // Remove the setting if value is "". if value == "" { - start, end, _ := t.findTypeForKey(key) - if start != end { - // Remove key tag and leading '-'. - start -= 4 - + start, sep, end, _ := t.findTypeForKey(key) + if start != sep { // Remove a possible empty extension. - if (end == len(t.str) || t.str[end+2] == '-') && t.str[start-2] == '-' { + switch { + case t.str[start-2] != '-': // has previous elements. + case end == len(t.str), // end of string + end+2 < len(t.str) && t.str[end+2] == '-': // end of extension start -= 2 } if start == int(t.pVariant) && end == len(t.str) { @@ -381,14 +389,14 @@ func (t Tag) SetTypeForKey(key, value string) (Tag, error) { t.str = string(buf[:uStart+len(b)]) } else { s := t.str - start, end, hasExt := t.findTypeForKey(key) - if start == end { + start, sep, end, hasExt := t.findTypeForKey(key) + if start == sep { if hasExt { b = b[2:] } - t.str = fmt.Sprintf("%s-%s%s", s[:start], b, s[end:]) + t.str = fmt.Sprintf("%s-%s%s", s[:sep], b, s[end:]) } else { - t.str = fmt.Sprintf("%s%s%s", s[:start], value, s[end:]) + t.str = fmt.Sprintf("%s-%s%s", s[:start+3], value, s[end:]) } } return t, nil @@ -399,10 +407,10 @@ func (t Tag) SetTypeForKey(key, value string) (Tag, error) { // wasn't found. The hasExt return value reports whether an -u extension was present. // Note: the extensions are typically very small and are likely to contain // only one key-type pair. -func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) { +func (t Tag) findTypeForKey(key string) (start, sep, end int, hasExt bool) { p := int(t.pExt) if len(key) != 2 || p == len(t.str) || p == 0 { - return p, p, false + return p, p, p, false } s := t.str @@ -410,10 +418,10 @@ func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) { for p++; s[p] != 'u'; p++ { if s[p] > 'u' { p-- - return p, p, false + return p, p, p, false } if p = nextExtension(s, p); p == len(s) { - return len(s), len(s), false + return len(s), len(s), len(s), false } } // Proceed to the hyphen following the extension name. @@ -424,40 +432,28 @@ func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) { // Iterate over keys until we get the end of a section. for { - // p points to the hyphen preceding the current token. - if p3 := p + 3; s[p3] == '-' { - // Found a key. - // Check whether we just processed the key that was requested. - if curKey == key { - return start, p, true + end = p + for p++; p < len(s) && s[p] != '-'; p++ { + } + n := p - end - 1 + if n <= 2 && curKey == key { + if sep < end { + sep++ } - // Set to the next key and continue scanning type tokens. - curKey = s[p+1 : p3] + return start, sep, end, true + } + switch n { + case 0, // invalid string + 1: // next extension + return end, end, end, true + case 2: + // next key + curKey = s[end+1 : p] if curKey > key { - return p, p, true + return end, end, end, true } - // Start of the type token sequence. - start = p + 4 - // A type is at least 3 characters long. - p += 7 // 4 + 3 - } else { - // Attribute or type, which is at least 3 characters long. - p += 4 - } - // p points past the third character of a type or attribute. - max := p + 5 // maximum length of token plus hyphen. - if len(s) < max { - max = len(s) - } - for ; p < max && s[p] != '-'; p++ { - } - // Bail if we have exhausted all tokens or if the next token starts - // a new extension. - if p == len(s) || s[p+2] == '-' { - if curKey == key { - return start, p, true - } - return p, p, true + start = end + sep = p } } } diff --git a/vendor/golang.org/x/text/internal/language/parse.go b/vendor/golang.org/x/text/internal/language/parse.go index a2fdad89d..c696fd0bd 100644 --- a/vendor/golang.org/x/text/internal/language/parse.go +++ b/vendor/golang.org/x/text/internal/language/parse.go @@ -138,7 +138,7 @@ func (s *scanner) resizeRange(oldStart, oldEnd, newSize int) { b = make([]byte, n) copy(b, s.b[:oldStart]) } else { - b = s.b[:n:n] + b = s.b[:n] } copy(b[end:], s.b[oldEnd:]) s.b = b @@ -483,7 +483,7 @@ func parseExtensions(scan *scanner) int { func parseExtension(scan *scanner) int { start, end := scan.start, scan.end switch scan.token[0] { - case 'u': + case 'u': // https://www.ietf.org/rfc/rfc6067.txt attrStart := end scan.scan() for last := []byte{}; len(scan.token) > 2; scan.scan() { @@ -503,27 +503,29 @@ func parseExtension(scan *scanner) int { last = scan.token end = scan.end } + // Scan key-type sequences. A key is of length 2 and may be followed + // by 0 or more "type" subtags from 3 to the maximum of 8 letters. var last, key []byte for attrEnd := end; len(scan.token) == 2; last = key { key = scan.token - keyEnd := scan.end - end = scan.acceptMinSize(3) + end = scan.end + for scan.scan(); end < scan.end && len(scan.token) > 2; scan.scan() { + end = scan.end + } // TODO: check key value validity - if keyEnd == end || bytes.Compare(key, last) != 1 { + if bytes.Compare(key, last) != 1 || scan.err != nil { // We have an invalid key or the keys are not sorted. // Start scanning keys from scratch and reorder. p := attrEnd + 1 scan.next = p keys := [][]byte{} for scan.scan(); len(scan.token) == 2; { - keyStart, keyEnd := scan.start, scan.end - end = scan.acceptMinSize(3) - if keyEnd != end { - keys = append(keys, scan.b[keyStart:end]) - } else { - scan.setError(ErrSyntax) - end = keyStart + keyStart := scan.start + end = scan.end + for scan.scan(); end < scan.end && len(scan.token) > 2; scan.scan() { + end = scan.end } + keys = append(keys, scan.b[keyStart:end]) } sort.Stable(bytesSort{keys, 2}) if n := len(keys); n > 0 { @@ -547,7 +549,7 @@ func parseExtension(scan *scanner) int { break } } - case 't': + case 't': // https://www.ietf.org/rfc/rfc6497.txt scan.scan() if n := len(scan.token); n >= 2 && n <= 3 && isAlpha(scan.token[1]) { _, end = parseTag(scan) diff --git a/vendor/golang.org/x/text/language/go1_1.go b/vendor/golang.org/x/text/language/go1_1.go index 380f4c09f..c7435583b 100644 --- a/vendor/golang.org/x/text/language/go1_1.go +++ b/vendor/golang.org/x/text/language/go1_1.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.2 // +build !go1.2 package language diff --git a/vendor/golang.org/x/text/language/go1_2.go b/vendor/golang.org/x/text/language/go1_2.go index 38268c57a..77aaaa299 100644 --- a/vendor/golang.org/x/text/language/go1_2.go +++ b/vendor/golang.org/x/text/language/go1_2.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.2 // +build go1.2 package language diff --git a/vendor/golang.org/x/text/language/language.go b/vendor/golang.org/x/text/language/language.go index abfa17f66..289b3a36d 100644 --- a/vendor/golang.org/x/text/language/language.go +++ b/vendor/golang.org/x/text/language/language.go @@ -412,6 +412,10 @@ func (t Tag) Extensions() []Extension { // are of the allowed values defined for the Unicode locale extension ('u') in // https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers. // TypeForKey will traverse the inheritance chain to get the correct value. +// +// If there are multiple types associated with a key, only the first will be +// returned. If there is no type associated with a key, it returns the empty +// string. func (t Tag) TypeForKey(key string) string { if !compact.Tag(t).MayHaveExtensions() { if key != "rg" && key != "va" { diff --git a/vendor/golang.org/x/text/language/tables.go b/vendor/golang.org/x/text/language/tables.go index 87e58a02a..96b57f610 100644 --- a/vendor/golang.org/x/text/language/tables.go +++ b/vendor/golang.org/x/text/language/tables.go @@ -47,7 +47,7 @@ const ( _Zzzz = 251 ) -var regionToGroups = []uint8{ // 357 elements +var regionToGroups = []uint8{ // 358 elements // Entry 0 - 3F 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, @@ -98,8 +98,8 @@ var regionToGroups = []uint8{ // 357 elements 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, -} // Size: 381 bytes + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +} // Size: 382 bytes var paradigmLocales = [][3]uint16{ // 3 elements 0: [3]uint16{0x139, 0x0, 0x7b}, @@ -295,4 +295,4 @@ var matchRegion = []regionIntelligibility{ // 15 elements 14: {lang: 0x529, script: 0x3c, group: 0x80, distance: 0x5}, } // Size: 114 bytes -// Total table size 1471 bytes (1KiB); checksum: 4CB1CD46 +// Total table size 1472 bytes (1KiB); checksum: F86C669 diff --git a/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go b/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go index e4c62289f..8a7392c4a 100644 --- a/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go +++ b/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.10 // +build go1.10 package bidirule diff --git a/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go b/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go index 02b9e1e9d..bb0a92001 100644 --- a/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go +++ b/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.10 // +build !go1.10 package bidirule diff --git a/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go index d8c94e1bd..42fa8d72c 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.10 && !go1.13 // +build go1.10,!go1.13 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go index 16b11db53..56a0e1ea2 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.13 && !go1.14 // +build go1.13,!go1.14 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go index 647f2d427..baacf32b4 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.14 && !go1.16 // +build go1.14,!go1.16 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go index c937d0976..f248effae 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.16 // +build go1.16 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go index 0ca0193eb..f517fdb20 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build !go1.10 // +build !go1.10 package bidi diff --git a/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go index 26fbd55a1..f5a078827 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.10 && !go1.13 // +build go1.10,!go1.13 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go index 2c58f09ba..cb7239c43 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.13 && !go1.14 // +build go1.13,!go1.14 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go index 7e1ae096e..11b273300 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.14 && !go1.16 // +build go1.14,!go1.16 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go index 9ea1b4214..96a130d30 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.16 // +build go1.16 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go index 942906929..0175eae50 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build !go1.10 // +build !go1.10 package norm diff --git a/vendor/modules.txt b/vendor/modules.txt index c2bbb514a..0a2a74cba 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -572,7 +572,12 @@ github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/iso github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/ovf github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/vm -# github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6 +# github.com/hashicorp/packer-plugin-vmware v0.0.1 +## explicit +github.com/hashicorp/packer-plugin-vmware/builder/vmware/common +github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso +github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx +# github.com/hashicorp/packer-plugin-vsphere v0.0.1 ## explicit github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common @@ -805,7 +810,6 @@ github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma # github.com/vmware/govmomi v0.24.1 -## explicit github.com/vmware/govmomi github.com/vmware/govmomi/find github.com/vmware/govmomi/internal @@ -938,7 +942,7 @@ go.opencensus.io/trace go.opencensus.io/trace/internal go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate -# golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad +# golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc ## explicit golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish @@ -973,7 +977,7 @@ golang.org/x/mobile/event/key golang.org/x/mod/module golang.org/x/mod/semver golang.org/x/mod/sumdb/dirhash -# golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 +# golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d ## explicit golang.org/x/net/context golang.org/x/net/context/ctxhttp @@ -1003,7 +1007,7 @@ golang.org/x/oauth2/jwt ## explicit golang.org/x/sync/errgroup golang.org/x/sync/semaphore -# golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 +# golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 ## explicit golang.org/x/sys/cpu golang.org/x/sys/execabs @@ -1013,7 +1017,7 @@ golang.org/x/sys/unix golang.org/x/sys/windows # golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 golang.org/x/term -# golang.org/x/text v0.3.5 +# golang.org/x/text v0.3.6 golang.org/x/text/encoding golang.org/x/text/encoding/charmap golang.org/x/text/encoding/htmlindex diff --git a/website/content/docs/builders/vmware/index.mdx b/website/content/docs/builders/vmware/index.mdx deleted file mode 100644 index 58930e194..000000000 --- a/website/content/docs/builders/vmware/index.mdx +++ /dev/null @@ -1,27 +0,0 @@ ---- -description: | - The VMware Packer builder is able to create VMware virtual machines for use - with any VMware product. -page_title: VMware - Builders ---- - -# VMware Builder - -The VMware Packer builder is able to create VMware virtual machines for use -with any VMware product. - -Packer actually comes with multiple builders able to create VMware machines, -depending on the strategy you want to use to build the image. Packer supports -the following VMware builders: - -- [vmware-iso](/docs/builders/vmware-iso) - Starts from an ISO file, - creates a brand new VMware VM, installs an OS, provisions software within - the OS, then exports that machine to create an image. This is best for - people who want to start from scratch. - -- [vmware-vmx](/docs/builders/vmware-vmx) - This builder imports an - existing VMware machine (from a VMX file), runs provisioners on top of that - VM, and exports that machine to create an image. This is best if you have - an existing VMware VM you want to use as the source. As an additional - benefit, you can feed the artifact of this builder back into Packer to - iterate on a machine. diff --git a/website/content/docs/builders/vmware/iso.mdx b/website/content/docs/builders/vmware/iso.mdx deleted file mode 100644 index 925dcb77e..000000000 --- a/website/content/docs/builders/vmware/iso.mdx +++ /dev/null @@ -1,294 +0,0 @@ ---- -modeline: | - vim: set ft=pandoc: -description: | - This VMware Packer builder is able to create VMware virtual machines from an - ISO file as a source. It currently supports building virtual machines on hosts - running VMware Fusion for OS X, VMware Workstation for Linux and Windows, and - VMware Player on Linux. It can also build machines directly on VMware vSphere - Hypervisor using SSH as opposed to the vSphere API. -page_title: VMware ISO - Builders ---- - -# VMware Builder (from ISO) - -Type: `vmware-iso` -Artifact BuilderId: `mitchellh.vmware` -If remote_type is esx: Artifact BuilderId: `mitchellh.vmware-esx` - -This VMware Packer builder is able to create VMware virtual machines from an ISO -file as a source. It currently supports building virtual machines on hosts -running [VMware Fusion](https://www.vmware.com/products/fusion/overview.html) for -OS X, [VMware -Workstation](https://www.vmware.com/products/workstation/overview.html) for Linux -and Windows, and [VMware Player](https://www.vmware.com/products/player/) on -Linux. It can also build machines directly on [VMware vSphere -Hypervisor](https://www.vmware.com/products/vsphere-hypervisor/) using SSH as -opposed to the vSphere API. - -The builder builds a virtual machine by creating a new virtual machine from -scratch, booting it, installing an OS, provisioning software within the OS, then -shutting it down. The result of the VMware builder is a directory containing all -the files necessary to run the virtual machine. - -## Basic Example - -Here is a basic example. This example is not functional. It will start the OS -installer but then fail because we don't provide the preseed file for Ubuntu to -self-install. Still, the example serves to show the basic configuration: - - - - -```json -{ - "type": "vmware-iso", - "iso_url": "http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso", - "iso_checksum": "md5:af5f788aee1b32c4b2634734309cc9e9", - "ssh_username": "packer", - "ssh_password": "packer", - "shutdown_command": "shutdown -P now" -} -``` - - - - -```hcl -source "vmware-iso" "basic-example" { - iso_url = "http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso" - iso_checksum = "md5:af5f788aee1b32c4b2634734309cc9e9" - ssh_username = "packer" - ssh_password = "packer" - shutdown_command = "shutdown -P now" -} - -build { - sources = ["sources.vmware-iso.basic-example"] -} -``` - - - - -## VMware-ISO Builder Configuration Reference - -There are many configuration options available for the builder. In addition to -the items listed here, you will want to look at the general configuration -references for [ISO](#iso-configuration), -[HTTP](#http-directory-configuration), -[Floppy](#floppy-configuration), -[CD](#cd-configuration), -[Boot](#boot-configuration), -[Driver](#driver-configuration), -[Hardware](#hardware-configuration), -[Output](#output-configuration), -[Run](#run-configuration), -[Shutdown](#shutdown-configuration), -[Communicator](#communicator-configuration), -[Tools](#tools-configuration), -[vmx](#vmx-configuration), -[Export](#export-configuration), -configuration references, which are -necessary for this build to succeed and can be found further down the page. - -#### Optional: - -@include 'builder/vmware/iso/Config-not-required.mdx' - -### Extra Disk Configuration - -#### Optional: - -@include 'builder/vmware/common/DiskConfig-not-required.mdx' - -### ISO Configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig.mdx' - -#### Required: - -@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-required.mdx' - -#### Optional: - -@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-not-required.mdx' - -### Http directory configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx' - -#### Optional: - -@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx' - -### Floppy configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig.mdx' - -#### Optional: - -@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig-not-required.mdx' - -### CD configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx' - -### Shutdown configuration - -#### Optional: - -@include 'packer-plugin-sdk/shutdowncommand/ShutdownConfig-not-required.mdx' - -### Driver configuration - -#### Optional: - -@include 'builder/vmware/common/DriverConfig-not-required.mdx' - -### Hardware configuration - -#### Optional: - -@include 'builder/vmware/common/HWConfig-not-required.mdx' - -### Output configuration - -#### Optional: - -@include 'builder/vmware/common/OutputConfig-not-required.mdx' - -### Run configuration - -@include 'builder/vmware/common/RunConfig.mdx' - -#### Optional: - -@include 'builder/vmware/common/RunConfig-not-required.mdx' - -### Tools configuration - -#### Optional: - -@include 'builder/vmware/common/ToolsConfig-not-required.mdx' - -### VMX configuration - -#### Optional: - -@include 'builder/vmware/common/VMXConfig-not-required.mdx' - -### Export configuration - -#### Optional: - -@include 'builder/vmware/common/ExportConfig-not-required.mdx' - -### Communicator configuration - -#### Optional common fields: - -@include 'packer-plugin-sdk/communicator/Config-not-required.mdx' - -#### Optional SSH fields: - -@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx' - -#### Optional WinRM fields: - -@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx' - -## Boot Configuration - -@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx' - -@include 'packer-plugin-sdk/bootcommand/VNCConfig.mdx' - --> **Note**: for the `HTTPIP` to be resolved correctly, your VM's network -configuration has to include a `hostonly` or `nat` type network interface. -If you are using this feature, it is recommended to leave the default network -configuration while you are building the VM, and use the `vmx_data_post` hook -to modify the network configuration after the VM is done building. - -#### Optional: - -@include 'packer-plugin-sdk/bootcommand/VNCConfig-not-required.mdx' - -@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx' - -For more examples of various boot commands, see the sample projects from our -[community templates page](/community-tools#templates). - -## VMX Template - -The heart of a VMware machine is the "vmx" file. This contains all the virtual -hardware metadata necessary for the VM to function. Packer by default uses a -[safe, flexible VMX -file](https://github.com/hashicorp/packer/blob/20541a7eda085aa5cf35bfed5069592ca49d106e/builder/vmware/step_create_vmx.go#L84). -But for advanced users, this template can be customized. This allows Packer to -build virtual machines of effectively any guest operating system type. - -~> **This is an advanced feature.** Modifying the VMX template can easily -cause your virtual machine to not boot properly. Please only modify the template -if you know what you're doing. - -Within the template, a handful of variables are available so that your template -can continue working with the rest of the Packer machinery. Using these -variables isn't required, however. - -- `Name` - The name of the virtual machine. -- `GuestOS` - The VMware-valid guest OS type. -- `DiskName` - The filename (without the suffix) of the main virtual disk. -- `ISOPath` - The path to the ISO to use for the OS installation. -- `Version` - The Hardware version VMWare will execute this vm under. Also - known as the `virtualhw.version`. - -@include 'builders/building_on_remote_vsphere_hypervisor.mdx' - -### VNC port discovery - -Packer needs to decide on a port to use for VNC when building remotely. To find -an open port, we try to connect to ports in the range of `vnc_port_min` to -`vnc_port_max`. If we notice something is listening on a port in the range, we -try to connect to the next one, and so on until we find a port that has nothing -listening on it. If you have many clients building on the ESXi host, there -might be competition for the VNC ports. You can adjust how long Packer waits -for a connection timeout by setting `PACKER_ESXI_VNC_PROBE_TIMEOUT`. This -defaults to 15 seconds. Set this shorter if VNC connections are refused, and -set it longer if Packer can't find an open port. This is intended as an -advanced configuration option. Please make sure your firewall settings are -correct before adjusting. - -### Using a Floppy for Linux kickstart file or preseed - -Depending on your network configuration, it may be difficult to use packer's -built-in HTTP server with ESXi. Instead, you can provide a kickstart or preseed -file by attaching a floppy disk. An example below, based on RHEL: - -```json -{ - "builders": [ - { - "type": "vmware-iso", - "floppy_files": ["folder/ks.cfg"], - "boot_command": " text ks=floppy " - } - ] -} -``` - -It's also worth noting that `ks=floppy` has been deprecated. Later versions of -the Anaconda installer (used in RHEL/CentOS 7 and Fedora) may require -a different syntax to source a kickstart file from a mounted floppy image. - -```json -{ - "builders": [ - { - "type": "vmware-iso", - "floppy_files": ["folder/ks.cfg"], - "boot_command": " inst.text inst.ks=hd:fd0:/ks.cfg " - } - ] -} -``` diff --git a/website/content/docs/builders/vmware/vmx.mdx b/website/content/docs/builders/vmware/vmx.mdx deleted file mode 100644 index c679160e7..000000000 --- a/website/content/docs/builders/vmware/vmx.mdx +++ /dev/null @@ -1,239 +0,0 @@ ---- -modeline: | - vim: set ft=pandoc: -description: | - This VMware Packer builder is able to create VMware virtual machines from an - existing VMware virtual machine (a VMX file). It currently supports building - virtual machines on hosts running VMware Fusion Professional for OS X, VMware - Workstation for Linux and Windows, and VMware Player on Linux. -page_title: VMware VMX - Builders ---- - -# VMware Builder (from VMX) - -Type: `vmware-vmx` -Artifact BuilderId: `mitchellh.vmware` -If remote_type is esx: Artifact BuilderId: `mitchellh.vmware-esx` - -This VMware Packer builder is able to create VMware virtual machines from an -existing VMware virtual machine (a VMX file). It currently supports building -virtual machines on hosts running [VMware Fusion -Professional](https://www.vmware.com/products/fusion-professional/) for OS X, -[VMware Workstation](https://www.vmware.com/products/workstation/overview.html) -for Linux and Windows, and [VMware -Player](https://www.vmware.com/products/player/) on Linux. - -The builder builds a virtual machine by cloning the VMX file using the clone -capabilities introduced in VMware Fusion Professional 6, Workstation 10, and -Player 6. After cloning the VM, it provisions software within the new machine, -shuts it down, and compacts the disks. The resulting folder contains a new -VMware virtual machine. - -## Basic Example - -Here is an example. This example is fully functional as long as the source path -points to a real VMX file with the proper settings: - - - - -```json -{ - "type": "vmware-vmx", - "source_path": "/path/to/a/vm.vmx", - "ssh_username": "root", - "ssh_password": "root", - "shutdown_command": "shutdown -P now" -} -``` - - - - -```hcl -source "vmware-vmx" "basic-example" { - source_path = "/path/to/a/vm.vmx" - ssh_username = "root" - ssh_password = "root" - shutdown_command = "shutdown -P now" -} - -build { - sources = ["sources.vmware-vmx.basic-example"] -} -``` - - - - -## Configuration Reference - -There are many configuration options available for the VMware builder. They are -organized below into two categories: required and optional. Within each -category, the available options are alphabetized and described. - -There are many configuration options available for the builder. In addition to -the items listed here, you will want to look at the general configuration -references for -[HTTP](#http-directory-configuration), -[Floppy](#floppy-configuration), -[Boot](#boot-configuration), -[Driver](#driver-configuration), -[Output](#output-configuration), -[Run](#run-configuration), -[Shutdown](#shutdown-configuration), -[Communicator](#communicator-configuration), -[Tools](#tools-configuration), -[vmx](#vmx-configuration), -[Export](#export-configuration), -configuration references, which are -necessary for this build to succeed and can be found further down the page. - -### Required: - -@include 'builder/vmware/vmx/Config-required.mdx' - -#### Optional: - -@include 'builder/vmware/vmx/Config-not-required.mdx' - -### Extra Disk Configuration - -#### Optional: - -@include 'builder/vmware/common/DiskConfig-not-required.mdx' - -### Http directory configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx' - -#### Optional: - -@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx' - -### Floppy configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig.mdx' - -#### Optional: - -@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig-not-required.mdx' - -### CD configuration - -@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx' - -#### Optional: - -@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx' - -### Export configuration - -#### Optional: - -@include 'builder/vmware/common/ExportConfig-not-required.mdx' - -### Output configuration - -#### Optional: - -@include 'builder/vmware/common/OutputConfig-not-required.mdx' - -### Run configuration - -@include 'builder/vmware/common/RunConfig.mdx' - -#### Optional: - -@include 'builder/vmware/common/RunConfig-not-required.mdx' - -### Driver configuration - -#### Optional: - -@include 'builder/vmware/common/DriverConfig-not-required.mdx' - -### Tools configuration - -#### Optional: - -@include 'builder/vmware/common/ToolsConfig-not-required.mdx' - -### VMX configuration - -#### Optional: - -@include 'builder/vmware/common/VMXConfig-not-required.mdx' - -### Communicator configuration - -#### Optional common fields: - -@include 'packer-plugin-sdk/communicator/Config-not-required.mdx' - -#### Optional SSH fields: - -@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx' - -#### Optional WinRM fields: - -@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx' - -## Shutdown Configuration - -@include 'packer-plugin-sdk/shutdowncommand/ShutdownConfig-not-required.mdx' - -## Boot Configuration - -@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx' - -@include 'packer-plugin-sdk/bootcommand/VNCConfig.mdx' - --> **Note**: for the `HTTPIP` to be resolved correctly, your VM's network -configuration has to include a `hostonly` or `nat` type network interface. -If you are using this feature, it is recommended to leave the default network -configuration while you are building the VM, and use the `vmx_data_post` hook -to modify the network configuration after the VM is done building. - -#### Optional: - -@include 'packer-plugin-sdk/bootcommand/VNCConfig-not-required.mdx' - -@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx' - -For more examples of various boot commands, see the sample projects from our -[community templates page](/community-tools#templates). - -```json -{ - "builders": [ - { - "type": "vmware-vmx", - "boot_key_interval": "10ms", - ... - } - ] -} -``` - -Example boot command. This is actually a working boot command used to start an -Ubuntu 12.04 installer: - -```text -[ - "", - "/install/vmlinuz noapic ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", - "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", - "hostname={{ .Name }} ", - "fb=false debconf/frontend=noninteractive ", - "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", - "keyboard-configuration/variant=USA console-setup/ask_detect=false ", - "initrd=/install/initrd.gz -- " -] -``` - -For more examples of various boot commands, see the sample projects from our -[community templates page](/community-tools#templates). - -@include 'builders/building_on_remote_vsphere_hypervisor.mdx' diff --git a/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx b/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx deleted file mode 100644 index e02d5a8df..000000000 --- a/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx +++ /dev/null @@ -1,47 +0,0 @@ - - -- `disk_additional_size` ([]uint) - The size(s) of any additional - hard disks for the VM in megabytes. If this is not specified then the VM - will only contain a primary hard disk. The builder uses expandable, not - fixed-size virtual hard disks, so the actual file representing the disk will - not use the full size unless it is full. - -- `disk_adapter_type` (string) - The adapter type of the VMware virtual disk to create. This option is - for advanced usage, modify only if you know what you're doing. Some of - the options you can specify are `ide`, `sata`, `nvme` or `scsi` (which - uses the "lsilogic" scsi interface by default). If you specify another - option, Packer will assume that you're specifying a `scsi` interface of - that specified type. For more information, please consult [Virtual Disk - Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf) - for desktop VMware clients. For ESXi, refer to the proper ESXi - documentation. - -- `vmdk_name` (string) - The filename of the virtual disk that'll be created, - without the extension. This defaults to "disk". - -- `disk_type_id` (string) - The type of VMware virtual disk to create. This - option is for advanced usage. - - For desktop VMware clients: - - Type ID | Description - ------- | --- - `0` | Growable virtual disk contained in a single file (monolithic sparse). - `1` | Growable virtual disk split into 2GB files (split sparse). - `2` | Preallocated virtual disk contained in a single file (monolithic flat). - `3` | Preallocated virtual disk split into 2GB files (split flat). - `4` | Preallocated virtual disk compatible with ESX server (VMFS flat). - `5` | Compressed disk optimized for streaming. - - The default is `1`. - - For ESXi, this defaults to `zeroedthick`. The available options for ESXi - are: `zeroedthick`, `eagerzeroedthick`, `thin`. `rdm:dev`, `rdmp:dev`, - `2gbsparse` are not supported. Due to default disk compaction, when using - `zeroedthick` or `eagerzeroedthick` set `skip_compaction` to `true`. - - For more information, please consult the [Virtual Disk Manager User's - Guide](https://www.vmware.com/pdf/VirtualDiskManager.pdf) for desktop - VMware clients. For ESXi, refer to the proper ESXi documentation. - - diff --git a/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx b/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx deleted file mode 100644 index a2939ce93..000000000 --- a/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx +++ /dev/null @@ -1,42 +0,0 @@ - - -- `cleanup_remote_cache` (bool) - When set to true, Packer will cleanup the cache folder where the ISO file is stored during the build on the remote machine. - By default, this is set to false. - -- `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is - /Applications/VMware Fusion.app but this setting allows you to - customize this. - -- `remote_type` (string) - The type of remote machine that will be used to - build this VM rather than a local desktop product. The only value accepted - for this currently is esx5. If this is not set, a desktop product will - be used. By default, this is not set. - -- `remote_datastore` (string) - The path to the datastore where the VM will be stored - on the ESXi machine. - -- `remote_cache_datastore` (string) - The path to the datastore where supporting files - will be stored during the build on the remote machine. - -- `remote_cache_directory` (string) - The path where the ISO and/or floppy files will - be stored during the build on the remote machine. The path is relative to - the remote_cache_datastore on the remote machine. - -- `remote_host` (string) - The host of the remote machine used for access. - This is only required if remote_type is enabled. - -- `remote_port` (int) - The SSH port of the remote machine - -- `remote_username` (string) - The SSH username used to access the remote machine. - -- `remote_password` (string) - The SSH password for access to the remote machine. - -- `remote_private_key_file` (string) - The SSH key for access to the remote machine. - -- `skip_validate_credentials` (bool) - When Packer is preparing to run a - remote esxi build, and export is not disable, by default it runs a no-op - ovftool command to make sure that the remote_username and remote_password - given are valid. If you set this flag to true, Packer will skip this - validation. Default: false. - - diff --git a/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx b/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx deleted file mode 100644 index efe285b3b..000000000 --- a/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx +++ /dev/null @@ -1,37 +0,0 @@ - - -- `format` (string) - Either "ovf", "ova" or "vmx", this specifies the output - format of the exported virtual machine. This defaults to "ovf" for - remote (esx) builds, and "vmx" for local builds. - Before using this option, you need to install ovftool. - Since ovftool is only capable of password based authentication - remote_password must be set when exporting the VM from a remote instance. - If you are building locally, Packer will create a vmx and then - export that vm to an ovf or ova. Packer will not delete the vmx and vmdk - files; this is left up to the user if you don't want to keep those - files. - -- `ovftool_options` ([]string) - Extra options to pass to ovftool during export. Each item in the array - is a new argument. The options `--noSSLVerify`, `--skipManifestCheck`, - and `--targetType` are used by Packer for remote exports, and should not - be passed to this argument. For ovf/ova exports from local builds, Packer - does not automatically set any ovftool options. - -- `skip_export` (bool) - Defaults to `false`. When true, Packer will not export the VM. This can - be useful if the build output is not the resultant image, but created - inside the VM. - -- `keep_registered` (bool) - Set this to true if you would like to keep a remotely-built - VM registered with the remote ESXi server. If you do not need to export - the vm, then also set `skip_export: true` in order to avoid unnecessarily - using ovftool to export the vm. Defaults to false. - -- `skip_compaction` (bool) - VMware-created disks are defragmented and - compacted at the end of the build process using vmware-vdiskmanager or - vmkfstools in ESXi. In certain rare cases, this might actually end up - making the resulting disks slightly larger. If you find this to be the case, - you can disable compaction using this configuration value. Defaults to - false. Default to true for ESXi when disk_type_id is not explicitly - defined and false otherwise. - - diff --git a/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx b/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx deleted file mode 100644 index 29e5f982c..000000000 --- a/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx +++ /dev/null @@ -1,91 +0,0 @@ - - -- `cpus` (int) - The number of cpus to use when building the VM. - -- `memory` (int) - The amount of memory to use when building the VM in megabytes. - -- `cores` (int) - The number of cores per socket to use when building the VM. This - corresponds to the cpuid.coresPerSocket option in the .vmx file. - -- `network` (string) - This is the network type that the virtual machine will be created with. - This can be one of the generic values that map to a device such as - hostonly, nat, or bridged. If the network is not one of these values, - then it is assumed to be a VMware network device. (VMnet0..x) - -- `network_adapter_type` (string) - This is the ethernet adapter type the the virtual machine will be - created with. By default the `e1000` network adapter type will be used - by Packer. For more information, please consult [Choosing a network - adapter for your virtual - machine](https://kb.vmware.com/s/article/1001805) for desktop VMware - clients. For ESXi, refer to the proper ESXi documentation. - -- `network_name` (string) - The custom name of the network. Sets the vmx value "ethernet0.networkName" - -- `sound` (bool) - Specify whether to enable VMware's virtual soundcard device when - building the VM. Defaults to false. - -- `usb` (bool) - Enable VMware's USB bus when building the guest VM. Defaults to false. - To enable usage of the XHCI bus for USB 3 (5 Gbit/s), one can use the - vmx_data option to enable it by specifying true for the usb_xhci.present - property. - -- `serial` (string) - This specifies a serial port to add to the VM. It has a format of - `Type:option1,option2,...`. The field `Type` can be one of the following - values: `FILE`, `DEVICE`, `PIPE`, `AUTO`, or `NONE`. - - * `FILE:path(,yield)` - Specifies the path to the local file to be used - as the serial port. - - * `yield` (bool) - This is an optional boolean that specifies - whether the vm should yield the cpu when polling the port. By - default, the builder will assume this as `FALSE`. - - * `DEVICE:path(,yield)` - Specifies the path to the local device to be -   used as the serial port. If `path` is empty, then default to the first - serial port. - - * `yield` (bool) - This is an optional boolean that specifies - whether the vm should yield the cpu when polling the port. By - default, the builder will assume this as `FALSE`. - - * `PIPE:path,endpoint,host(,yield)` - Specifies to use the named-pipe - "path" as a serial port. This has a few options that determine how the - VM should use the named-pipe. - - * `endpoint` (string) - Chooses the type of the VM-end, which can be - either a `client` or `server`. - - * `host` (string) - Chooses the type of the host-end, which can - be either `app` (application) or `vm` (another virtual-machine). - - * `yield` (bool) - This is an optional boolean that specifies - whether the vm 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 - serial port to use. This has one option to determine how the VM should - support the serial port. - - * `yield` (bool) - This is an optional boolean that specifies - whether the vm should yield the cpu when polling the port. By - default, the builder will assume this as `FALSE`. - - * `NONE` - Specifies to not use a serial port. (default) - -- `parallel` (string) - This specifies a parallel port to add to the VM. It has the format of - `Type:option1,option2,...`. Type can be one of the following values: - `FILE`, `DEVICE`, `AUTO`, or `NONE`. - - * `FILE:path` - Specifies the path to the local file to be used - for the parallel port. - - * `DEVICE:path` - Specifies the path to the local device to be used - for the parallel port. - - * `AUTO:direction` - Specifies to use auto-detection to determine the - parallel port. Direction can be `BI` to specify bidirectional - communication or `UNI` to specify unidirectional communication. - - * `NONE` - Specifies to not use a parallel port. (default) - - diff --git a/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx b/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx deleted file mode 100644 index f65fada56..000000000 --- a/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx +++ /dev/null @@ -1,36 +0,0 @@ - - -- `output_directory` (string) - This is the path on your local machine (the one running Packer) to the - directory where the resulting virtual machine will be created. - 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 esx 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`. - - 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. - -- `remote_output_directory` (string) - This is the directoy on your remote esx host where you will save your - vm, 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 - - For example, setting `"remote_output_directory": "path/to/subdir` - will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`. - - Packer will not create the remote datastore for you; it must already - exist. However, Packer will create all directories defined in the option - that do not currently exist. - - This option will be ignored unless you are building on a remote esx host. - - diff --git a/website/content/partials/builder/vmware/common/ParallelUnion.mdx b/website/content/partials/builder/vmware/common/ParallelUnion.mdx deleted file mode 100644 index e0411af00..000000000 --- a/website/content/partials/builder/vmware/common/ParallelUnion.mdx +++ /dev/null @@ -1,5 +0,0 @@ - - -parallel port - - diff --git a/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx b/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx deleted file mode 100644 index 7b754ab8e..000000000 --- a/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx +++ /dev/null @@ -1,39 +0,0 @@ - - -- `headless` (bool) - Packer defaults to building VMware virtual machines - by launching a GUI that shows the console of the machine being built. When - this value is set to true, the machine will start without a console. For - VMware machines, Packer will output VNC connection information in case you - need to connect to the console to debug the build process. - Some users have experienced issues where Packer cannot properly connect - to a VM if it is headless; this appears to be a result of not ever having - launched the VMWare GUI and accepting the evaluation license, or - supplying a real license. If you experience this, launching VMWare and - accepting the license should resolve your problem. - -- `vnc_bind_address` (string) - The IP address that should be - binded to for VNC. By default packer will use 127.0.0.1 for this. If you - wish to bind to all interfaces use 0.0.0.0. - -- `vnc_port_min` (int) - The minimum and maximum port - to use for VNC access to the virtual machine. The builder uses VNC to type - the initial boot_command. Because Packer generally runs in parallel, - Packer uses a randomly chosen port in this range that appears available. By - default this is 5900 to 6000. The minimum and maximum ports are - inclusive. - -- `vnc_port_max` (int) - VNC Port Max - -- `vnc_disable_password` (bool) - Don't auto-generate a VNC password that - is used to secure the VNC communication with the VM. This must be set to - true if building on ESXi 6.5 and 6.7 with VNC enabled. Defaults to - false. - -- `vnc_over_websocket` (bool) - When set to true, Packer will connect to the remote VNC server over a websocket connection - and any other VNC configuration option will be ignored. - Remote builds using ESXi 6.7+ allows to connect to the VNC server only over websocket, - for these the `vnc_over_websocket` must be set to true. - -- `insecure_connection` (bool) - Do not validate VNC over websocket server's TLS certificate. Defaults to `false`. - - diff --git a/website/content/partials/builder/vmware/common/RunConfig.mdx b/website/content/partials/builder/vmware/common/RunConfig.mdx deleted file mode 100644 index 0727ccdcf..000000000 --- a/website/content/partials/builder/vmware/common/RunConfig.mdx +++ /dev/null @@ -1,5 +0,0 @@ - - -~> **Note:** If [vnc_over_websocket](#vnc_over_websocket) is set to true, any other VNC configuration will be ignored. - - diff --git a/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx b/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx deleted file mode 100644 index b7135496a..000000000 --- a/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx +++ /dev/null @@ -1,5 +0,0 @@ - - -serial conversions - - diff --git a/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx b/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx deleted file mode 100644 index fd7bc011c..000000000 --- a/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx +++ /dev/null @@ -1,18 +0,0 @@ - - -- `tools_upload_flavor` (string) - The flavor of the VMware Tools ISO to - upload into the VM. Valid values are darwin, linux, and windows. By - default, this is empty, which means VMware tools won't be uploaded. - -- `tools_upload_path` (string) - The path in the VM to upload the VMware tools. This only takes effect if - `tools_upload_flavor` is non-empty. This is a [configuration - template](/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 `{{.Flavor}}.iso`. This setting is not used - when `remote_type` is `esx5`. - -- `tools_source_path` (string) - The path on your local machine to fetch the vmware tools from. If this - is not set but the tools_upload_flavor is set, then Packer will try to - load the VMWare tools from the VMWare installation directory. - - diff --git a/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx b/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx deleted file mode 100644 index 953369fe5..000000000 --- a/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx +++ /dev/null @@ -1,24 +0,0 @@ - - -- `vmx_data` (map[string]string) - Arbitrary key/values to enter - into the virtual machine VMX file. This is for advanced users who want to - set properties that aren't yet supported by the builder. - -- `vmx_data_post` (map[string]string) - Identical to vmx_data, - except that it is run after the virtual machine is shutdown, and before the - virtual machine is exported. - -- `vmx_remove_ethernet_interfaces` (bool) - Remove all ethernet interfaces - from the VMX file after building. This is for advanced users who understand - the ramifications, but is useful for building Vagrant boxes since Vagrant - will create ethernet interfaces when provisioning a box. Defaults to - false. - -- `display_name` (string) - The name that will appear in your vSphere client, - and will be used for the vmx basename. This will override the "displayname" - value in your vmx file. It will also override the "displayname" if you have - set it in the "vmx_data" Packer option. This option is useful if you are - chaining vmx builds and want to make sure that the display name of each step - in the chain is unique. - - diff --git a/website/content/partials/builder/vmware/iso/Config-not-required.mdx b/website/content/partials/builder/vmware/iso/Config-not-required.mdx deleted file mode 100644 index 18340b45f..000000000 --- a/website/content/partials/builder/vmware/iso/Config-not-required.mdx +++ /dev/null @@ -1,42 +0,0 @@ - - -- `disk_size` (uint) - The size of the hard disk for the VM in megabytes. - The builder uses expandable, not fixed-size virtual hard disks, so the - actual file representing the disk will not use the full size unless it - is full. By default this is set to 40000 (about 40 GB). - -- `cdrom_adapter_type` (string) - The adapter type (or bus) that will be used - by the cdrom device. This is chosen by default based on the disk adapter - type. VMware tends to lean towards ide for the cdrom device unless - sata is chosen for the disk adapter and so Packer attempts to mirror - this logic. This field can be specified as either ide, sata, or scsi. - -- `guest_os_type` (string) - The guest OS type being installed. This will be - set in the VMware VMX. By default this is other. By specifying a more - specific OS type, VMware may perform some optimizations or virtual hardware - changes to better support the operating system running in the - virtual machine. Valid values differ by platform and version numbers, and may - not match other VMware API's representation of the guest OS names. Consult your - platform for valid values. - -- `version` (string) - The [vmx hardware - version](http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003746) - for the new virtual machine. Only the default value has been tested, any - other value is experimental. Default value is `9`. - -- `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. - -- `vmx_disk_template_path` (string) - VMX Disk Template Path - -- `vmx_template_path` (string) - Path to a [configuration template](/docs/templates/legacy_json_templates/engine) that - defines the contents of the virtual machine VMX file for VMware. The - engine has access to the template variables `{{ .DiskNumber }}` and - `{{ .DiskName }}`. - - This is for **advanced users only** as this can render the virtual machine - non-functional. See below for more information. For basic VMX - modifications, try `vmx_data` first. - - diff --git a/website/content/partials/builder/vmware/vmx/Config-not-required.mdx b/website/content/partials/builder/vmware/vmx/Config-not-required.mdx deleted file mode 100644 index 622717752..000000000 --- a/website/content/partials/builder/vmware/vmx/Config-not-required.mdx +++ /dev/null @@ -1,26 +0,0 @@ - - -- `linked` (bool) - By default Packer creates a 'full' clone of the virtual machine - specified in source_path. The resultant virtual machine is fully - independant from 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 - 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. - -- `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. - -- `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. - - diff --git a/website/content/partials/builder/vmware/vmx/Config-required.mdx b/website/content/partials/builder/vmware/vmx/Config-required.mdx deleted file mode 100644 index acef042cf..000000000 --- a/website/content/partials/builder/vmware/vmx/Config-required.mdx +++ /dev/null @@ -1,6 +0,0 @@ - - -- `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. - - diff --git a/website/content/partials/builder/vmware/vmx/Config.mdx b/website/content/partials/builder/vmware/vmx/Config.mdx deleted file mode 100644 index c9bda9b93..000000000 --- a/website/content/partials/builder/vmware/vmx/Config.mdx +++ /dev/null @@ -1,5 +0,0 @@ - - -Config is the configuration structure for the builder. - - diff --git a/website/content/partials/builders/building_on_remote_vsphere_hypervisor.mdx b/website/content/partials/builders/building_on_remote_vsphere_hypervisor.mdx deleted file mode 100644 index bba7d3d92..000000000 --- a/website/content/partials/builders/building_on_remote_vsphere_hypervisor.mdx +++ /dev/null @@ -1,66 +0,0 @@ -## Building on a Remote vSphere Hypervisor - -In addition to using the desktop products of VMware locally to build virtual -machines, Packer can use a remote VMware Hypervisor to build the virtual -machine. - --> **Note:** Packer supports ESXi 5.1 and above. - -Before using a remote vSphere Hypervisor, you need to enable GuestIPHack by -running the following command: - -```shell-session -$ esxcli system settings advanced set -o /Net/GuestIPHack -i 1 -``` - -When using a remote VMware Hypervisor, the builder still downloads the ISO and -various files locally, and uploads these to the remote machine. Packer currently -uses SSH to communicate to the ESXi machine rather than the vSphere API. -If you want to use vSphere API, see the [vsphere-iso](/docs/builders/vsphere/vsphere-iso) builder. - -Packer also requires VNC to issue boot commands during a build, which may be -disabled on some remote VMware Hypervisors. Please consult the appropriate -documentation on how to update VMware Hypervisor's firewall to allow these -connections. VNC can be disabled by not setting a `boot_command` and setting -`disable_vnc` to `true`. - -Please note that you should disable vMotion for the host you intend to run -Packer builds on; a vMotion event will cause the Packer build to fail. - -To use a remote VMware vSphere Hypervisor to build your virtual machine, fill in -the required `remote_*` configurations: - -- `remote_type` - This must be set to "esx5". - -- `remote_host` - The host of the remote machine. - -Additionally, there are some optional configurations that you'll likely have to -modify as well: - -- `remote_port` - The SSH port of the remote machine - -- `remote_datastore` - The path to the datastore where the VM will be stored - on the ESXi machine. - -- `remote_cache_datastore` - The path to the datastore where supporting files - will be stored during the build on the remote machine. - -- `remote_cache_directory` - The path where the ISO and/or floppy files will - be stored during the build on the remote machine. The path is relative to - the `remote_cache_datastore` on the remote machine. - -- `remote_username` - The SSH username used to access the remote machine. - -- `remote_password` - The SSH password for access to the remote machine. - -- `remote_private_key_file` - The SSH key for access to the remote machine. - -- `format` (string) - Either "ovf", "ova" or "vmx", this specifies the output - format of the exported virtual machine. This defaults to "ovf". - Before using this option, you need to install `ovftool`. This option - currently only works when option remote_type is set to "esx5". - Since ovftool is only capable of password based authentication - `remote_password` must be set when exporting the VM. - -- `vnc_disable_password` - This must be set to "true" when using VNC with - ESXi 6.5 or 6.7. diff --git a/website/data/docs-nav-data.json b/website/data/docs-nav-data.json index 9c179c938..7b12f5b5d 100644 --- a/website/data/docs-nav-data.json +++ b/website/data/docs-nav-data.json @@ -873,23 +873,6 @@ "title": "Vagrant", "path": "builders/vagrant" }, - { - "title": "VMware", - "routes": [ - { - "title": "Overview", - "path": "builders/vmware" - }, - { - "title": "VMWare ISO", - "path": "builders/vmware/iso" - }, - { - "title": "VMWare VMX", - "path": "builders/vmware/vmx" - } - ] - }, { "title": "Yandex.Cloud", "path": "builders/yandex" diff --git a/website/data/docs-remote-plugins.json b/website/data/docs-remote-plugins.json index 2e363e2bd..1ae99ccd1 100644 --- a/website/data/docs-remote-plugins.json +++ b/website/data/docs-remote-plugins.json @@ -34,5 +34,11 @@ "path": "virtualbox", "repo": "hashicorp/packer-plugin-virtualbox", "version": "latest" + }, + { + "title": "VMware", + "path": "vmware", + "repo": "hashicorp/packer-plugin-vmware", + "version": "latest" } ]