From 001886670d310bc0de6dbd03f132e6fc145e556a Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Nov 2020 11:54:31 -0800 Subject: [PATCH 01/10] move Ui definition into the packer plugin sdk. --- builder/alicloud/ecs/builder.go | 3 +- builder/alicloud/ecs/packer_helper.go | 6 ++-- builder/alicloud/ecs/step_attach_keypair.go | 6 ++-- .../alicloud/ecs/step_check_source_image.go | 4 +-- builder/alicloud/ecs/step_config_eip.go | 6 ++-- builder/alicloud/ecs/step_config_key_pair.go | 6 ++-- builder/alicloud/ecs/step_config_public_ip.go | 4 +-- .../ecs/step_config_security_group.go | 6 ++-- builder/alicloud/ecs/step_config_vpc.go | 6 ++-- builder/alicloud/ecs/step_config_vswitch.go | 6 ++-- builder/alicloud/ecs/step_create_image.go | 6 ++-- builder/alicloud/ecs/step_create_instance.go | 6 ++-- builder/alicloud/ecs/step_create_snapshot.go | 6 ++-- builder/alicloud/ecs/step_create_tags.go | 4 +-- .../ecs/step_delete_images_snapshots.go | 4 +-- builder/alicloud/ecs/step_pre_validate.go | 5 +-- .../alicloud/ecs/step_region_copy_image.go | 6 ++-- builder/alicloud/ecs/step_run_instance.go | 6 ++-- builder/alicloud/ecs/step_share_image.go | 4 +-- builder/alicloud/ecs/step_stop_instance.go | 4 +-- builder/amazon/chroot/builder.go | 3 +- builder/amazon/chroot/step_attach_volume.go | 8 ++--- .../amazon/chroot/step_check_root_device.go | 4 +-- builder/amazon/chroot/step_create_volume.go | 6 ++-- builder/amazon/chroot/step_early_unflock.go | 4 +-- builder/amazon/chroot/step_flock.go | 4 +-- builder/amazon/chroot/step_instance_info.go | 4 +-- builder/amazon/chroot/step_mount_device.go | 8 ++--- builder/amazon/chroot/step_prepare_device.go | 4 +-- builder/amazon/chroot/step_register_ami.go | 4 +-- builder/amazon/chroot/step_snapshot.go | 6 ++-- builder/amazon/common/ssm/session.go | 4 +-- builder/amazon/common/step_ami_region_copy.go | 5 +-- builder/amazon/common/step_cleanup_volumes.go | 4 +-- .../amazon/common/step_create_ssm_tunnel.go | 4 +-- builder/amazon/common/step_create_tags.go | 4 +-- builder/amazon/common/step_deregister_ami.go | 4 +-- builder/amazon/common/step_get_password.go | 3 +- .../common/step_iam_instance_profile.go | 6 ++-- builder/amazon/common/step_key_pair.go | 6 ++-- .../common/step_modify_ami_attributes.go | 4 +-- .../amazon/common/step_modify_ebs_instance.go | 4 +-- builder/amazon/common/step_network_info.go | 4 +-- builder/amazon/common/step_pre_validate.go | 4 +-- .../amazon/common/step_run_source_instance.go | 6 ++-- .../amazon/common/step_run_spot_instance.go | 6 ++-- builder/amazon/common/step_security_group.go | 6 ++-- builder/amazon/common/step_source_ami_info.go | 4 +-- .../amazon/common/step_stop_ebs_instance.go | 4 +-- builder/amazon/common/tags.go | 4 +-- builder/amazon/ebs/builder.go | 3 +- builder/amazon/ebs/step_create_ami.go | 6 ++-- builder/amazon/ebssurrogate/builder.go | 3 +- .../amazon/ebssurrogate/step_register_ami.go | 6 ++-- .../ebssurrogate/step_snapshot_volumes.go | 8 ++--- builder/amazon/ebsvolume/builder.go | 3 +- .../amazon/ebsvolume/step_tag_ebs_volumes.go | 4 +-- builder/amazon/instance/builder.go | 3 +- builder/amazon/instance/step_bundle_volume.go | 3 +- builder/amazon/instance/step_register_ami.go | 4 +-- builder/amazon/instance/step_upload_bundle.go | 3 +- .../amazon/instance/step_upload_x509_cert.go | 3 +- builder/azure/arm/builder.go | 7 ++-- builder/azure/arm/step_capture_image.go | 4 +-- .../azure/arm/step_certificate_in_keyvault.go | 4 +-- .../azure/arm/step_create_resource_group.go | 6 ++-- .../azure/arm/step_delete_additional_disks.go | 4 +-- builder/azure/arm/step_deploy_template.go | 8 ++--- .../azure/arm/step_get_additional_disks.go | 4 +-- builder/azure/arm/step_get_certificate.go | 4 +-- builder/azure/arm/step_get_ip_address.go | 4 +-- builder/azure/arm/step_get_os_disk.go | 4 +-- builder/azure/arm/step_power_off_compute.go | 4 +-- .../step_publish_to_shared_image_gallery.go | 4 +-- builder/azure/arm/step_set_certificate.go | 4 +-- builder/azure/arm/step_snapshot_data_disks.go | 4 +-- builder/azure/arm/step_snapshot_os_disk.go | 4 +-- builder/azure/arm/step_validate_template.go | 4 +-- builder/azure/chroot/builder.go | 3 +- builder/azure/chroot/packerui_test.go | 3 +- builder/azure/chroot/step_attach_disk.go | 8 ++--- builder/azure/chroot/step_create_image.go | 4 +-- .../azure/chroot/step_create_new_diskset.go | 6 ++-- .../step_create_shared_image_version.go | 4 +-- .../azure/chroot/step_create_snapshotset.go | 6 ++-- builder/azure/chroot/step_mount_device.go | 8 ++--- .../step_resolve_plaform_image_version.go | 4 +-- .../step_verify_shared_image_destination.go | 4 +-- .../chroot/step_verify_shared_image_source.go | 4 +-- .../azure/chroot/step_verify_source_disk.go | 4 +-- .../chroot/step_verify_source_disk_test.go | 4 +-- builder/azure/dtl/builder.go | 9 ++--- builder/azure/dtl/step_capture_image.go | 4 +-- .../azure/dtl/step_delete_virtual_machine.go | 4 +-- builder/azure/dtl/step_deploy_template.go | 4 +-- builder/azure/dtl/step_power_off_compute.go | 4 +-- .../step_publish_to_shared_image_gallery.go | 4 +-- builder/cloudstack/builder.go | 5 +-- .../cloudstack/step_configure_networking.go | 6 ++-- builder/cloudstack/step_create_instance.go | 6 ++-- .../cloudstack/step_create_security_group.go | 6 ++-- builder/cloudstack/step_create_template.go | 4 +-- builder/cloudstack/step_detach_iso.go | 4 +-- builder/cloudstack/step_keypair.go | 6 ++-- builder/cloudstack/step_prepare_config.go | 3 +- builder/cloudstack/step_shutdown_instance.go | 4 +-- builder/digitalocean/builder.go | 3 +- builder/digitalocean/step_create_droplet.go | 6 ++-- builder/digitalocean/step_create_ssh_key.go | 6 ++-- builder/digitalocean/step_droplet_info.go | 4 +-- builder/digitalocean/step_power_off.go | 4 +-- builder/digitalocean/step_shutdown.go | 4 +-- builder/digitalocean/step_snapshot.go | 4 +-- builder/docker/builder.go | 3 +- builder/docker/driver_docker.go | 4 +-- builder/docker/exec.go | 4 +-- builder/docker/step_commit.go | 4 +-- builder/docker/step_export.go | 4 +-- builder/docker/step_pull.go | 4 +-- builder/docker/step_run.go | 6 ++-- builder/docker/step_temp_dir.go | 3 +- builder/file/builder.go | 3 +- builder/googlecompute/builder.go | 3 +- builder/googlecompute/driver_gce.go | 5 +-- .../step_check_existing_image.go | 4 +-- builder/googlecompute/step_create_image.go | 4 +-- builder/googlecompute/step_create_instance.go | 5 +-- .../step_create_windows_password.go | 3 +- .../step_import_os_login_ssh_key.go | 6 ++-- builder/googlecompute/step_instance_info.go | 4 +-- builder/googlecompute/step_start_tunnel.go | 4 +-- .../googlecompute/step_teardown_instance.go | 6 ++-- .../googlecompute/step_wait_startup_script.go | 4 +-- builder/hcloud/builder.go | 3 +- builder/hcloud/step_create_server.go | 6 ++-- builder/hcloud/step_create_snapshot.go | 4 +-- builder/hcloud/step_create_sshkey.go | 6 ++-- builder/hcloud/step_shutdown_server.go | 4 +-- builder/hyperone/builder.go | 3 +- builder/hyperone/step_copy_files.go | 4 +-- builder/hyperone/step_create_image.go | 6 ++-- builder/hyperone/step_create_ssh_key.go | 4 +-- builder/hyperone/step_create_vm.go | 6 ++-- builder/hyperone/step_create_vm_from_disk.go | 6 ++-- builder/hyperone/step_detach_disk.go | 4 +-- builder/hyperone/step_mount_chroot.go | 4 +-- builder/hyperone/step_mount_extra.go | 4 +-- builder/hyperone/step_post_mount_commands.go | 4 +-- builder/hyperone/step_pre_mount_commands.go | 4 +-- builder/hyperone/step_prepare_device.go | 4 +-- builder/hyperone/step_stop_vm.go | 4 +-- builder/hyperone/utils.go | 3 +- builder/hyperv/common/step_clone_vm.go | 6 ++-- .../hyperv/common/step_collate_artifacts.go | 4 +-- builder/hyperv/common/step_compact_disk.go | 4 +-- builder/hyperv/common/step_configure_ip.go | 4 +-- builder/hyperv/common/step_configure_vlan.go | 4 +-- .../hyperv/common/step_create_build_dir.go | 6 ++-- .../common/step_create_external_switch.go | 6 ++-- builder/hyperv/common/step_create_switch.go | 6 ++-- builder/hyperv/common/step_create_vm.go | 6 ++-- builder/hyperv/common/step_disable_vlan.go | 4 +-- .../common/step_enable_integration_service.go | 4 +-- builder/hyperv/common/step_export_vm.go | 4 +-- builder/hyperv/common/step_mount_dvddrive.go | 6 ++-- .../hyperv/common/step_mount_floppydrive.go | 6 ++-- .../common/step_mount_guest_additions.go | 6 ++-- .../common/step_mount_secondary_dvd_images.go | 6 ++-- .../common/step_polling_installation.go | 4 +-- builder/hyperv/common/step_reboot_vm.go | 4 +-- builder/hyperv/common/step_run.go | 6 ++-- builder/hyperv/common/step_set_boot_order.go | 4 +-- .../common/step_set_first_boot_device.go | 4 +-- builder/hyperv/common/step_shutdown.go | 5 +-- builder/hyperv/common/step_sleep.go | 4 +-- .../hyperv/common/step_type_boot_command.go | 4 +-- .../hyperv/common/step_unmount_dvddrive.go | 4 +-- .../hyperv/common/step_unmount_floppydrive.go | 4 +-- .../common/step_unmount_guest_additions.go | 4 +-- .../step_unmount_secondary_dvd_images.go | 4 +-- .../step_wait_for_install_to_complete.go | 6 ++-- builder/hyperv/iso/builder.go | 3 +- builder/hyperv/vmcx/builder.go | 3 +- builder/jdcloud/builder.go | 3 +- builder/jdcloud/step_config_credentials.go | 6 ++-- builder/jdcloud/step_create_image.go | 4 +-- builder/jdcloud/step_create_instance.go | 6 ++-- builder/jdcloud/step_stop_instance.go | 4 +-- builder/jdcloud/step_validate_parameters.go | 6 ++-- builder/linode/builder.go | 3 +- builder/linode/step_create_image.go | 4 +-- builder/linode/step_create_linode.go | 6 ++-- builder/linode/step_create_ssh_key.go | 4 +-- builder/linode/step_shutdown_linode.go | 4 +-- builder/lxc/builder.go | 3 +- builder/lxc/step_export.go | 4 +-- builder/lxc/step_lxc_create.go | 6 ++-- builder/lxc/step_prepare_output_dir.go | 6 ++-- builder/lxc/step_provision.go | 3 +- builder/lxc/step_wait_init.go | 4 +-- builder/lxd/builder.go | 3 +- builder/lxd/step_lxd_launch.go | 6 ++-- builder/lxd/step_provision.go | 3 +- builder/lxd/step_publish.go | 4 +-- builder/ncloud/builder.go | 3 +- .../step_create_block_storage_instance.go | 4 +-- builder/ncloud/step_create_login_key.go | 4 +-- .../ncloud/step_create_public_ip_instance.go | 4 +-- builder/ncloud/step_create_server_image.go | 4 +-- builder/ncloud/step_create_server_instance.go | 4 +-- .../step_delete_block_storage_instance.go | 4 +-- builder/ncloud/step_get_rootpassword.go | 4 +-- builder/ncloud/step_stop_server_instance.go | 4 +-- .../ncloud/step_terminate_server_instance.go | 4 +-- builder/ncloud/step_validate_template.go | 4 +-- builder/null/builder.go | 3 +- builder/oneandone/builder.go | 3 +- builder/oneandone/step_create_server.go | 6 ++-- builder/oneandone/step_create_sshkey.go | 4 +-- builder/oneandone/step_take_snapshot.go | 4 +-- builder/openstack/access_config.go | 6 ++-- builder/openstack/builder.go | 3 +- builder/openstack/step_add_image_members.go | 4 +-- builder/openstack/step_allocate_ip.go | 6 ++-- builder/openstack/step_create_image.go | 4 +-- builder/openstack/step_create_volume.go | 6 ++-- builder/openstack/step_detach_volume.go | 4 +-- builder/openstack/step_discover_network.go | 4 +-- builder/openstack/step_get_password.go | 3 +- builder/openstack/step_key_pair.go | 8 ++--- builder/openstack/step_load_flavor.go | 4 +-- builder/openstack/step_run_source_server.go | 6 ++-- builder/openstack/step_source_image_info.go | 6 ++-- builder/openstack/step_stop_server.go | 4 +-- .../openstack/step_update_image_mindisk.go | 4 +-- builder/openstack/step_update_image_tags.go | 4 +-- .../openstack/step_update_image_visibility.go | 4 +-- .../openstack/step_wait_for_rackconnect.go | 4 +-- builder/oracle/classic/builder.go | 3 +- builder/oracle/classic/step_add_keys.go | 6 ++-- builder/oracle/classic/step_attach_volume.go | 6 ++-- builder/oracle/classic/step_create_image.go | 6 ++-- .../oracle/classic/step_create_instance.go | 6 ++-- .../classic/step_create_ip_reservation.go | 6 ++-- .../classic/step_create_persistent_volume.go | 6 ++-- .../oracle/classic/step_create_pv_builder.go | 6 ++-- .../oracle/classic/step_create_pv_master.go | 6 ++-- builder/oracle/classic/step_list_images.go | 4 +-- builder/oracle/classic/step_security.go | 6 ++-- builder/oracle/classic/step_snapshot.go | 6 ++-- .../classic/step_terminate_pv_master.go | 4 +-- builder/oracle/classic/step_upload_image.go | 3 +- builder/oracle/common/step_ssh_key_pair.go | 4 +-- builder/oracle/oci/builder.go | 3 +- builder/oracle/oci/step_create_instance.go | 6 ++-- .../oci/step_get_default_credentials.go | 3 +- builder/oracle/oci/step_image.go | 4 +-- builder/oracle/oci/step_instance_info.go | 4 +-- builder/osc/bsu/builder.go | 3 +- builder/osc/bsu/step_create_omi.go | 6 ++-- builder/osc/bsusurrogate/builder.go | 3 +- builder/osc/bsusurrogate/step_register_omi.go | 6 ++-- .../osc/bsusurrogate/step_snapshop_volumes.go | 8 ++--- builder/osc/bsuvolume/builder.go | 3 +- builder/osc/bsuvolume/step_tag_bsu_volumes.go | 4 +-- builder/osc/chroot/builder.go | 3 +- builder/osc/chroot/run_local_commands.go | 3 +- builder/osc/chroot/step_check_root_device.go | 4 +-- builder/osc/chroot/step_chroot_provision.go | 3 +- builder/osc/chroot/step_copy_files.go | 6 ++-- builder/osc/chroot/step_create_omi.go | 4 +-- builder/osc/chroot/step_create_volume.go | 6 ++-- builder/osc/chroot/step_early_cleanup.go | 4 +-- builder/osc/chroot/step_early_unflock.go | 4 +-- builder/osc/chroot/step_flock.go | 4 +-- builder/osc/chroot/step_link_volume.go | 8 ++--- builder/osc/chroot/step_mount_device.go | 8 ++--- builder/osc/chroot/step_mount_extra.go | 6 ++-- .../osc/chroot/step_post_mount_commands.go | 4 +-- builder/osc/chroot/step_pre_mount_commands.go | 4 +-- builder/osc/chroot/step_prepare_device.go | 4 +-- builder/osc/chroot/step_snapshot.go | 6 ++-- builder/osc/chroot/step_vm_info.go | 4 +-- builder/osc/common/step_cleanup_volumes.go | 4 +-- builder/osc/common/step_create_tags.go | 4 +-- builder/osc/common/step_deregister_omi.go | 4 +-- builder/osc/common/step_get_password.go | 3 +- builder/osc/common/step_key_pair.go | 6 ++-- builder/osc/common/step_network_info.go | 4 +-- builder/osc/common/step_pre_validate.go | 4 +-- builder/osc/common/step_public_ip.go | 6 ++-- builder/osc/common/step_run_source_vm.go | 6 ++-- builder/osc/common/step_security_group.go | 6 ++-- builder/osc/common/step_source_omi_info.go | 4 +-- builder/osc/common/step_stop_bsu_backed_vm.go | 4 +-- builder/osc/common/step_update_bsu_vm.go | 2 +- builder/osc/common/step_update_omi.go | 4 +-- builder/osc/common/tags.go | 6 ++-- .../parallels/common/step_attach_floppy.go | 6 ++-- .../common/step_attach_parallels_tools.go | 8 ++--- builder/parallels/common/step_compact_disk.go | 6 ++-- builder/parallels/common/step_output_dir.go | 6 ++-- builder/parallels/common/step_prlctl.go | 6 ++-- builder/parallels/common/step_run.go | 8 ++--- builder/parallels/common/step_shutdown.go | 5 +-- .../common/step_type_boot_command.go | 4 +-- .../common/step_upload_parallels_tools.go | 7 ++-- .../parallels/common/step_upload_version.go | 5 +-- builder/parallels/iso/builder.go | 3 +- builder/parallels/iso/step_attach_iso.go | 8 ++--- builder/parallels/iso/step_create_disk.go | 4 +-- builder/parallels/iso/step_create_vm.go | 6 ++-- builder/parallels/iso/step_set_boot_order.go | 6 ++-- builder/parallels/pvm/builder.go | 3 +- builder/parallels/pvm/step_import.go | 6 ++-- builder/profitbricks/builder.go | 3 +- builder/profitbricks/step_create_server.go | 8 ++--- builder/profitbricks/step_create_ssh_key.go | 4 +-- builder/profitbricks/step_take_snapshot.go | 4 +-- builder/proxmox/clone/builder.go | 3 +- builder/proxmox/clone/step_ssh_key_pair.go | 6 ++-- builder/proxmox/common/builder.go | 3 +- .../common/step_convert_to_template.go | 4 +-- .../common/step_finalize_template_config.go | 4 +-- builder/proxmox/common/step_start_vm.go | 6 ++-- .../proxmox/common/step_type_boot_command.go | 4 +-- builder/proxmox/iso/builder.go | 3 +- builder/proxmox/iso/step_finalize_iso.go | 4 +-- .../iso/step_upload_additional_isos.go | 4 +-- builder/proxmox/iso/step_upload_iso.go | 4 +-- builder/qemu/builder.go | 3 +- builder/qemu/step_configure_qmp.go | 6 ++-- builder/qemu/step_configure_vnc.go | 6 ++-- builder/qemu/step_convert_disk.go | 4 +-- builder/qemu/step_copy_disk.go | 4 +-- builder/qemu/step_create_disk.go | 4 +-- builder/qemu/step_http_ip_discover.go | 4 +-- builder/qemu/step_port_forward.go | 4 +-- builder/qemu/step_prepare_output_dir.go | 6 ++-- builder/qemu/step_resize_disk.go | 4 +-- builder/qemu/step_run.go | 8 ++--- builder/qemu/step_set_iso.go | 4 +-- builder/qemu/step_shutdown.go | 5 +-- builder/qemu/step_type_boot_command.go | 6 ++-- builder/qemu/step_wait_guest_address.go | 4 +-- builder/scaleway/builder.go | 3 +- builder/scaleway/step_create_image.go | 4 +-- builder/scaleway/step_create_server.go | 6 ++-- builder/scaleway/step_create_ssh_key.go | 4 +-- builder/scaleway/step_pre_validate.go | 4 +-- builder/scaleway/step_remove_volume.go | 4 +-- builder/scaleway/step_server_info.go | 4 +-- builder/scaleway/step_shutdown.go | 4 +-- builder/scaleway/step_snapshot.go | 4 +-- builder/tencentcloud/cvm/builder.go | 3 +- builder/tencentcloud/cvm/common.go | 8 ++--- builder/triton/builder.go | 3 +- builder/triton/driver_triton.go | 6 ++-- .../triton/step_create_image_from_machine.go | 4 +-- builder/triton/step_create_source_machine.go | 6 ++-- builder/triton/step_delete_machine.go | 4 +-- builder/triton/step_stop_machine.go | 4 +-- .../triton/step_wait_for_stop_to_not_fail.go | 4 +-- builder/ucloud/common/utils.go | 4 +-- builder/ucloud/uhost/builder.go | 3 +- .../ucloud/uhost/step_check_source_image.go | 4 +-- .../uhost/step_config_security_group.go | 4 +-- builder/ucloud/uhost/step_config_subnet.go | 4 +-- builder/ucloud/uhost/step_config_vpc.go | 4 +-- builder/ucloud/uhost/step_copy_image.go | 6 ++-- builder/ucloud/uhost/step_create_image.go | 6 ++-- builder/ucloud/uhost/step_create_instance.go | 6 ++-- builder/ucloud/uhost/step_pre_validate.go | 7 ++-- builder/ucloud/uhost/step_stop_instance.go | 4 +-- builder/vagrant/builder.go | 3 +- builder/vagrant/step_add_box.go | 4 +-- builder/vagrant/step_create_vagrantfile.go | 4 +-- builder/vagrant/step_package.go | 4 +-- builder/vagrant/step_up.go | 6 ++-- .../virtualbox/common/step_attach_floppy.go | 8 ++--- builder/virtualbox/common/step_attach_isos.go | 4 +-- .../virtualbox/common/step_configure_vrdp.go | 6 ++-- .../common/step_download_guest_additions.go | 4 +-- builder/virtualbox/common/step_export.go | 4 +-- .../virtualbox/common/step_port_forwarding.go | 6 ++-- .../virtualbox/common/step_remove_devices.go | 6 ++-- builder/virtualbox/common/step_run.go | 8 ++--- builder/virtualbox/common/step_shutdown.go | 5 +-- .../virtualbox/common/step_ssh_key_pair.go | 6 ++-- .../common/step_suppress_messages.go | 4 +-- .../common/step_type_boot_command.go | 4 +-- .../common/step_upload_guest_additions.go | 3 +- .../virtualbox/common/step_upload_version.go | 3 +- builder/virtualbox/common/step_vboxmanage.go | 6 ++-- builder/virtualbox/iso/builder.go | 3 +- builder/virtualbox/iso/step_create_disk.go | 4 +-- builder/virtualbox/iso/step_create_vm.go | 6 ++-- builder/virtualbox/ovf/builder.go | 3 +- builder/virtualbox/ovf/step_import.go | 6 ++-- builder/virtualbox/vm/builder.go | 3 +- builder/virtualbox/vm/step_create_snapshot.go | 4 +-- builder/virtualbox/vm/step_set_snapshot.go | 6 ++-- builder/vmware/common/driver_esx5.go | 5 +-- builder/vmware/common/remote_driver.go | 6 ++-- builder/vmware/common/remote_driver_mock.go | 6 ++-- builder/vmware/common/step_clean_files.go | 6 ++-- builder/vmware/common/step_clean_vmx.go | 6 ++-- builder/vmware/common/step_compact_disk.go | 6 ++-- builder/vmware/common/step_configure_vmx.go | 4 +-- builder/vmware/common/step_configure_vnc.go | 6 ++-- builder/vmware/common/step_create_disks.go | 6 ++-- builder/vmware/common/step_export.go | 4 +-- .../vmware/common/step_http_ip_discover.go | 4 +-- builder/vmware/common/step_output_dir.go | 6 ++-- builder/vmware/common/step_register.go | 6 ++-- builder/vmware/common/step_remote_upload.go | 4 +-- builder/vmware/common/step_run.go | 8 ++--- builder/vmware/common/step_shutdown.go | 5 +-- .../vmware/common/step_suppress_messages.go | 4 +-- builder/vmware/common/step_upload_tools.go | 3 +- builder/vmware/common/step_upload_vmx.go | 6 ++-- .../vmware/common/step_vnc_boot_command.go | 6 ++-- builder/vmware/common/step_vnc_connect.go | 4 +-- builder/vmware/iso/builder.go | 3 +- builder/vmware/iso/step_create_vmx.go | 6 ++-- builder/vmware/vmx/builder.go | 3 +- builder/vmware/vmx/step_clone_vmx.go | 4 +-- builder/vsphere/clone/builder.go | 3 +- builder/vsphere/clone/step_clone.go | 4 +-- builder/vsphere/clone/step_customize.go | 4 +-- builder/vsphere/common/cleanup_vm.go | 4 +-- builder/vsphere/common/step_add_cdrom.go | 4 +-- builder/vsphere/common/step_add_floppy.go | 6 ++-- builder/vsphere/common/step_boot_command.go | 4 +-- builder/vsphere/common/step_config_params.go | 4 +-- builder/vsphere/common/step_download.go | 4 +-- builder/vsphere/common/step_export.go | 3 +- builder/vsphere/common/step_hardware.go | 4 +-- .../common/step_import_to_content_library.go | 3 +- builder/vsphere/common/step_remote_upload.go | 8 ++--- builder/vsphere/common/step_remove_cdrom.go | 4 +-- builder/vsphere/common/step_remove_floppy.go | 4 +-- builder/vsphere/common/step_run.go | 6 ++-- builder/vsphere/common/step_shutdown.go | 3 +- builder/vsphere/common/step_snapshot.go | 4 +-- builder/vsphere/common/step_ssh_key_pair.go | 6 ++-- builder/vsphere/common/step_template.go | 4 +-- builder/vsphere/common/step_wait_for_ip.go | 4 +-- builder/vsphere/driver/driver.go | 4 +-- builder/vsphere/driver/driver_mock.go | 4 +-- builder/vsphere/driver/vm.go | 4 +-- builder/vsphere/iso/builder.go | 3 +- builder/vsphere/iso/step_create.go | 4 +-- builder/yandex/builder.go | 3 +- builder/yandex/driver_yc.go | 6 ++-- builder/yandex/step_create_image.go | 4 +-- builder/yandex/step_create_instance.go | 8 ++--- builder/yandex/step_create_ssh_key.go | 4 +-- builder/yandex/step_instance_info.go | 4 +-- builder/yandex/step_teardown_instance.go | 4 +-- builder/yandex/step_wait_cloudinit_script.go | 4 +-- builder/yandex/util.go | 4 +-- command/build.go | 5 +-- command/build_parallel_test.go | 5 +-- command/meta.go | 3 +- command/signal.go | 4 +-- go.mod | 1 + hcl2template/internal/mock.go | 7 ++-- hcl2template/types.hcl_post-processor.go | 3 +- hcl2template/types.hcl_provisioner.go | 4 ++- helper/communicator/step_connect.go | 4 +-- helper/communicator/step_connect_ssh.go | 3 +- helper/communicator/step_connect_winrm.go | 7 ++-- helper/communicator/step_debug_ssh_keys.go | 4 +-- helper/communicator/step_ssh_keygen.go | 4 +-- main.go | 3 +- packer-plugin-sdk/adapter/adapter.go | 7 ++-- .../chroot/run_local_commands.go | 3 +- .../chroot/step_chroot_provision.go | 3 +- packer-plugin-sdk/chroot/step_copy_files.go | 6 ++-- .../chroot/step_copy_files_test.go | 3 +- .../chroot/step_early_cleanup.go | 4 +-- packer-plugin-sdk/chroot/step_mount_extra.go | 6 ++-- .../chroot/step_post_mount_commands.go | 4 +-- .../chroot/step_pre_mount_commands.go | 4 +-- .../multistep/commonsteps/multistep_debug.go | 4 +-- .../multistep/commonsteps/multistep_runner.go | 18 +++++----- .../commonsteps/step_cleanup_temp_keys.go | 3 +- .../commonsteps/step_create_cdrom.go | 4 +-- .../commonsteps/step_create_floppy.go | 4 +-- .../multistep/commonsteps/step_download.go | 7 ++-- .../multistep/commonsteps/step_http_server.go | 6 ++-- .../multistep/commonsteps/step_output_dir.go | 6 ++-- .../multistep/commonsteps/step_provision.go | 5 +-- packer-plugin-sdk/packer/ui.go | 16 +++++++++ .../shell-local/localexec/run_and_stream.go | 3 +- packer-plugin-sdk/shell-local/run.go | 3 +- packer/build.go | 5 +-- packer/builder.go | 4 ++- packer/builder_mock.go | 5 +-- packer/builder_mock.hcl2spec.go | 7 ++-- packer/communicator.go | 3 +- packer/hook.go | 6 ++-- packer/hook_mock.go | 6 ++-- packer/hook_test.go | 4 ++- packer/plugin/builder.go | 3 +- packer/plugin/hook.go | 3 +- packer/plugin/post_processor.go | 3 +- packer/plugin/post_processor_test.go | 3 +- packer/plugin/provisioner.go | 3 +- packer/post_processor.go | 8 +++-- packer/post_processor_mock.go | 5 +-- packer/provisioner.go | 11 +++--- packer/provisioner_mock.go | 5 +-- packer/provisioner_timeout.go | 4 ++- packer/rpc/build.go | 3 +- packer/rpc/build_test.go | 5 +-- packer/rpc/builder.go | 3 +- packer/rpc/client.go | 3 +- packer/rpc/hook.go | 3 +- packer/rpc/post_processor.go | 3 +- packer/rpc/post_processor_test.go | 5 +-- packer/rpc/provisioner.go | 3 +- packer/rpc/server.go | 3 +- packer/rpc/ui.go | 10 +++--- packer/run_interfaces.go | 7 ++-- packer/testing.go | 4 ++- packer/ui.go | 36 +++++++------------ .../alicloud-import/post-processor.go | 3 +- .../amazon-import/post-processor.go | 3 +- post-processor/artifice/post-processor.go | 3 +- post-processor/checksum/post-processor.go | 3 +- .../checksum/post-processor_test.go | 3 +- post-processor/compress/post-processor.go | 3 +- .../compress/post-processor_test.go | 3 +- .../digitalocean-import/post-processor.go | 3 +- .../docker-import/post-processor.go | 3 +- post-processor/docker-push/post-processor.go | 3 +- post-processor/docker-save/post-processor.go | 3 +- post-processor/docker-tag/post-processor.go | 3 +- .../exoscale-import/post-processor.go | 9 ++--- .../googlecompute-export/post-processor.go | 3 +- .../googlecompute-import/post-processor.go | 9 ++--- post-processor/manifest/post-processor.go | 3 +- post-processor/shell-local/post-processor.go | 3 +- .../ucloud-import/post-processor.go | 3 +- .../vagrant-cloud/post-processor.go | 3 +- .../vagrant-cloud/step_confirm_upload.go | 4 +-- .../vagrant-cloud/step_create_provider.go | 6 ++-- .../vagrant-cloud/step_create_version.go | 4 +-- .../vagrant-cloud/step_prepare_upload.go | 4 +-- .../vagrant-cloud/step_release_version.go | 4 +-- post-processor/vagrant-cloud/step_upload.go | 4 +-- .../vagrant-cloud/step_verify_box.go | 4 +-- post-processor/vagrant/aws.go | 3 +- post-processor/vagrant/azure.go | 3 +- post-processor/vagrant/digitalocean.go | 3 +- post-processor/vagrant/docker.go | 3 +- post-processor/vagrant/google.go | 3 +- post-processor/vagrant/hyperv.go | 3 +- post-processor/vagrant/libvirt.go | 3 +- post-processor/vagrant/lxc.go | 3 +- post-processor/vagrant/parallels.go | 3 +- post-processor/vagrant/post-processor.go | 5 +-- post-processor/vagrant/provider.go | 3 +- post-processor/vagrant/scaleway.go | 3 +- post-processor/vagrant/util.go | 6 ++-- post-processor/vagrant/virtualbox.go | 3 +- post-processor/vagrant/vmware.go | 3 +- .../vsphere-template/post-processor.go | 3 +- .../step_choose_datacenter.go | 4 +-- .../vsphere-template/step_create_folder.go | 4 +-- .../vsphere-template/step_create_snapshot.go | 3 +- .../vsphere-template/step_mark_as_template.go | 3 +- post-processor/vsphere/post-processor.go | 3 +- .../yandex-export/post-processor.go | 3 +- .../yandex-import/post-processor.go | 3 +- post-processor/yandex-import/storage.go | 4 +-- post-processor/yandex-import/utils.go | 7 ++-- provisioner/ansible-local/provisioner.go | 21 +++++------ provisioner/ansible/mock_ansible.go | 5 +-- provisioner/ansible/provisioner.go | 15 ++++---- provisioner/azure-dtlartifact/provisioner.go | 3 +- provisioner/breakpoint/provisioner.go | 3 +- provisioner/chef-client/provisioner.go | 25 ++++++------- provisioner/chef-solo/provisioner.go | 17 ++++----- provisioner/converge/provisioner.go | 9 ++--- provisioner/file/provisioner.go | 7 ++-- provisioner/inspec/provisioner.go | 5 +-- provisioner/powershell/provisioner.go | 3 +- provisioner/puppet-masterless/provisioner.go | 13 +++---- provisioner/puppet-server/provisioner.go | 9 ++--- provisioner/salt-masterless/provisioner.go | 15 ++++---- provisioner/shell-local/provisioner.go | 3 +- provisioner/shell/provisioner.go | 3 +- provisioner/sleep/provisioner.go | 3 +- provisioner/windows-restart/provisioner.go | 5 +-- provisioner/windows-shell/provisioner.go | 3 +- 598 files changed, 1528 insertions(+), 1317 deletions(-) create mode 100644 packer-plugin-sdk/packer/ui.go diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 9fc5f679f..93a801dd2 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -80,7 +81,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/alicloud/ecs/packer_helper.go b/builder/alicloud/ecs/packer_helper.go index 4074d7ad7..51169f4ec 100644 --- a/builder/alicloud/ecs/packer_helper.go +++ b/builder/alicloud/ecs/packer_helper.go @@ -4,15 +4,15 @@ import ( "fmt" "strconv" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func cleanUpMessage(state multistep.StateBag, module string) { _, cancelled := state.GetOk(multistep.StateCancelled) _, halted := state.GetOk(multistep.StateHalted) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if cancelled || halted { ui.Say(fmt.Sprintf("Deleting %s because of cancellation or error...", module)) @@ -22,7 +22,7 @@ func cleanUpMessage(state multistep.StateBag, module string) { } func halt(state multistep.StateBag, err error, prefix string) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if prefix != "" { err = fmt.Errorf("%s: %s", prefix, err) diff --git a/builder/alicloud/ecs/step_attach_keypair.go b/builder/alicloud/ecs/step_attach_keypair.go index 16596eef1..55f81f8ca 100644 --- a/builder/alicloud/ecs/step_attach_keypair.go +++ b/builder/alicloud/ecs/step_attach_keypair.go @@ -6,8 +6,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepAttachKeyPair struct { @@ -21,7 +21,7 @@ var attachKeyPairNotRetryErrors = []string{ } func (s *stepAttachKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*ClientWrapper) config := state.Get("config").(*Config) instance := state.Get("instance").(*ecs.Instance) @@ -52,7 +52,7 @@ func (s *stepAttachKeyPair) Run(ctx context.Context, state multistep.StateBag) m func (s *stepAttachKeyPair) Cleanup(state multistep.StateBag) { client := state.Get("client").(*ClientWrapper) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*ecs.Instance) keyPairName := config.Comm.SSHKeyPairName if keyPairName == "" { diff --git a/builder/alicloud/ecs/step_check_source_image.go b/builder/alicloud/ecs/step_check_source_image.go index 66c26dc96..95c2168c5 100644 --- a/builder/alicloud/ecs/step_check_source_image.go +++ b/builder/alicloud/ecs/step_check_source_image.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCheckAlicloudSourceImage struct { @@ -16,7 +16,7 @@ type stepCheckAlicloudSourceImage struct { func (s *stepCheckAlicloudSourceImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) describeImagesRequest := ecs.CreateDescribeImagesRequest() describeImagesRequest.RegionId = config.AlicloudRegion diff --git a/builder/alicloud/ecs/step_config_eip.go b/builder/alicloud/ecs/step_config_eip.go index 4053a6bcd..ce17b35d4 100644 --- a/builder/alicloud/ecs/step_config_eip.go +++ b/builder/alicloud/ecs/step_config_eip.go @@ -9,8 +9,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepConfigAlicloudEIP struct { @@ -28,7 +28,7 @@ var allocateEipAddressRetryErrors = []string{ func (s *stepConfigAlicloudEIP) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*ecs.Instance) if s.SSHPrivateIp { @@ -96,7 +96,7 @@ func (s *stepConfigAlicloudEIP) Cleanup(state multistep.StateBag) { client := state.Get("client").(*ClientWrapper) instance := state.Get("instance").(*ecs.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) unassociateEipAddressRequest := ecs.CreateUnassociateEipAddressRequest() unassociateEipAddressRequest.AllocationId = s.allocatedId diff --git a/builder/alicloud/ecs/step_config_key_pair.go b/builder/alicloud/ecs/step_config_key_pair.go index 428198bec..49e551f01 100644 --- a/builder/alicloud/ecs/step_config_key_pair.go +++ b/builder/alicloud/ecs/step_config_key_pair.go @@ -8,8 +8,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepConfigAlicloudKeyPair struct { @@ -22,7 +22,7 @@ type stepConfigAlicloudKeyPair struct { } func (s *stepConfigAlicloudKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key") @@ -108,7 +108,7 @@ func (s *stepConfigAlicloudKeyPair) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Remove the keypair ui.Say("Deleting temporary keypair...") diff --git a/builder/alicloud/ecs/step_config_public_ip.go b/builder/alicloud/ecs/step_config_public_ip.go index 8d8c7403e..94a6a2cbf 100644 --- a/builder/alicloud/ecs/step_config_public_ip.go +++ b/builder/alicloud/ecs/step_config_public_ip.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepConfigAlicloudPublicIP struct { @@ -17,7 +17,7 @@ type stepConfigAlicloudPublicIP struct { func (s *stepConfigAlicloudPublicIP) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*ecs.Instance) if s.SSHPrivateIp { diff --git a/builder/alicloud/ecs/step_config_security_group.go b/builder/alicloud/ecs/step_config_security_group.go index 694a10817..0a3ff9685 100644 --- a/builder/alicloud/ecs/step_config_security_group.go +++ b/builder/alicloud/ecs/step_config_security_group.go @@ -6,8 +6,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -30,7 +30,7 @@ var deleteSecurityGroupRetryErrors = []string{ func (s *stepConfigAlicloudSecurityGroup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) networkType := state.Get("networktype").(InstanceNetWork) if len(s.SecurityGroupId) != 0 { @@ -117,7 +117,7 @@ func (s *stepConfigAlicloudSecurityGroup) Cleanup(state multistep.StateBag) { cleanUpMessage(state, "security group") client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, err := client.WaitForExpected(&WaitForExpectArgs{ RequestFunc: func() (responses.AcsResponse, error) { diff --git a/builder/alicloud/ecs/step_config_vpc.go b/builder/alicloud/ecs/step_config_vpc.go index 53ecb8476..72d990aac 100644 --- a/builder/alicloud/ecs/step_config_vpc.go +++ b/builder/alicloud/ecs/step_config_vpc.go @@ -7,8 +7,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -35,7 +35,7 @@ var deleteVpcRetryErrors = []string{ func (s *stepConfigAlicloudVPC) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.VpcId) != 0 { describeVpcsRequest := ecs.CreateDescribeVpcsRequest() @@ -118,7 +118,7 @@ func (s *stepConfigAlicloudVPC) Cleanup(state multistep.StateBag) { cleanUpMessage(state, "VPC") client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, err := client.WaitForExpected(&WaitForExpectArgs{ RequestFunc: func() (responses.AcsResponse, error) { diff --git a/builder/alicloud/ecs/step_config_vswitch.go b/builder/alicloud/ecs/step_config_vswitch.go index 38e51a346..0718e1f8e 100644 --- a/builder/alicloud/ecs/step_config_vswitch.go +++ b/builder/alicloud/ecs/step_config_vswitch.go @@ -6,8 +6,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -33,7 +33,7 @@ var deleteVSwitchRetryErrors = []string{ func (s *stepConfigAlicloudVSwitch) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vpcId := state.Get("vpcid").(string) config := state.Get("config").(*Config) @@ -176,7 +176,7 @@ func (s *stepConfigAlicloudVSwitch) Cleanup(state multistep.StateBag) { cleanUpMessage(state, "vSwitch") client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, err := client.WaitForExpected(&WaitForExpectArgs{ RequestFunc: func() (responses.AcsResponse, error) { diff --git a/builder/alicloud/ecs/step_create_image.go b/builder/alicloud/ecs/step_create_image.go index a1f47b61a..7506777cf 100644 --- a/builder/alicloud/ecs/step_create_image.go +++ b/builder/alicloud/ecs/step_create_image.go @@ -9,8 +9,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -27,7 +27,7 @@ var createImageRetryErrors = []string{ func (s *stepCreateAlicloudImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) tempImageName := config.AlicloudImageName if config.ImageEncrypted.True() { @@ -95,7 +95,7 @@ func (s *stepCreateAlicloudImage) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !cancelled && !halted && encryptedSet { ui.Say(fmt.Sprintf("Deleting temporary image %s(%s) and related snapshots after finishing encryption...", s.image.ImageId, s.image.ImageName)) diff --git a/builder/alicloud/ecs/step_create_instance.go b/builder/alicloud/ecs/step_create_instance.go index 0d9958d40..a086a42a1 100644 --- a/builder/alicloud/ecs/step_create_instance.go +++ b/builder/alicloud/ecs/step_create_instance.go @@ -12,8 +12,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -41,7 +41,7 @@ var deleteInstanceRetryErrors = []string{ func (s *stepCreateAlicloudInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating instance...") createInstanceRequest, err := s.buildCreateInstanceRequest(state) @@ -91,7 +91,7 @@ func (s *stepCreateAlicloudInstance) Cleanup(state multistep.StateBag) { cleanUpMessage(state, "instance") client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, err := client.WaitForExpected(&WaitForExpectArgs{ RequestFunc: func() (responses.AcsResponse, error) { diff --git a/builder/alicloud/ecs/step_create_snapshot.go b/builder/alicloud/ecs/step_create_snapshot.go index 056a4ba87..dd29c2925 100644 --- a/builder/alicloud/ecs/step_create_snapshot.go +++ b/builder/alicloud/ecs/step_create_snapshot.go @@ -7,8 +7,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateAlicloudSnapshot struct { @@ -19,7 +19,7 @@ type stepCreateAlicloudSnapshot struct { func (s *stepCreateAlicloudSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*ecs.Instance) describeDisksRequest := ecs.CreateDescribeDisksRequest() @@ -77,7 +77,7 @@ func (s *stepCreateAlicloudSnapshot) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting the snapshot because of cancellation or error...") diff --git a/builder/alicloud/ecs/step_create_tags.go b/builder/alicloud/ecs/step_create_tags.go index f374dcba4..31224a709 100644 --- a/builder/alicloud/ecs/step_create_tags.go +++ b/builder/alicloud/ecs/step_create_tags.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateTags struct { @@ -16,7 +16,7 @@ type stepCreateTags struct { func (s *stepCreateTags) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) imageId := state.Get("alicloudimage").(string) snapshotIds := state.Get("alicloudsnapshots").([]string) diff --git a/builder/alicloud/ecs/step_delete_images_snapshots.go b/builder/alicloud/ecs/step_delete_images_snapshots.go index bffbb5068..4eac1d103 100644 --- a/builder/alicloud/ecs/step_delete_images_snapshots.go +++ b/builder/alicloud/ecs/step_delete_images_snapshots.go @@ -6,8 +6,8 @@ import ( "log" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepDeleteAlicloudImageSnapshots struct { @@ -54,7 +54,7 @@ func (s *stepDeleteAlicloudImageSnapshots) Run(ctx context.Context, state multis func (s *stepDeleteAlicloudImageSnapshots) deleteImageAndSnapshots(state multistep.StateBag, imageName string, region string) error { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) describeImagesRequest := ecs.CreateDescribeImagesRequest() describeImagesRequest.RegionId = region diff --git a/builder/alicloud/ecs/step_pre_validate.go b/builder/alicloud/ecs/step_pre_validate.go index 8481f34f4..6a2f6723e 100644 --- a/builder/alicloud/ecs/step_pre_validate.go +++ b/builder/alicloud/ecs/step_pre_validate.go @@ -7,6 +7,7 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepPreValidate struct { @@ -27,7 +28,7 @@ func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) mul } func (s *stepPreValidate) validateRegions(state multistep.StateBag) error { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.AlicloudSkipValidation { @@ -55,7 +56,7 @@ func (s *stepPreValidate) validateRegions(state multistep.StateBag) error { } func (s *stepPreValidate) validateDestImageName(state multistep.StateBag) error { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*ClientWrapper) config := state.Get("config").(*Config) diff --git a/builder/alicloud/ecs/step_region_copy_image.go b/builder/alicloud/ecs/step_region_copy_image.go index 6905b179d..716639f12 100644 --- a/builder/alicloud/ecs/step_region_copy_image.go +++ b/builder/alicloud/ecs/step_region_copy_image.go @@ -7,8 +7,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -31,7 +31,7 @@ func (s *stepRegionCopyAlicloudImage) Run(ctx context.Context, state multistep.S } client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) srcImageId := state.Get("alicloudimage").(string) alicloudImages := state.Get("alicloudimages").(map[string]string) @@ -83,7 +83,7 @@ func (s *stepRegionCopyAlicloudImage) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Stopping copy image because cancellation or error...")) client := state.Get("client").(*ClientWrapper) diff --git a/builder/alicloud/ecs/step_run_instance.go b/builder/alicloud/ecs/step_run_instance.go index d84d2028c..2f99e9f3e 100644 --- a/builder/alicloud/ecs/step_run_instance.go +++ b/builder/alicloud/ecs/step_run_instance.go @@ -6,8 +6,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepRunAlicloudInstance struct { @@ -15,7 +15,7 @@ type stepRunAlicloudInstance struct { func (s *stepRunAlicloudInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*ecs.Instance) startInstanceRequest := ecs.CreateStartInstanceRequest() @@ -42,7 +42,7 @@ func (s *stepRunAlicloudInstance) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*ClientWrapper) instance := state.Get("instance").(*ecs.Instance) diff --git a/builder/alicloud/ecs/step_share_image.go b/builder/alicloud/ecs/step_share_image.go index 552f41de4..f7c07a0b2 100644 --- a/builder/alicloud/ecs/step_share_image.go +++ b/builder/alicloud/ecs/step_share_image.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepShareAlicloudImage struct { @@ -41,7 +41,7 @@ func (s *stepShareAlicloudImage) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*ClientWrapper) alicloudImages := state.Get("alicloudimages").(map[string]string) diff --git a/builder/alicloud/ecs/step_stop_instance.go b/builder/alicloud/ecs/step_stop_instance.go index 7b6daaaab..7fbebc19b 100644 --- a/builder/alicloud/ecs/step_stop_instance.go +++ b/builder/alicloud/ecs/step_stop_instance.go @@ -8,8 +8,8 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepStopAlicloudInstance struct { @@ -20,7 +20,7 @@ type stepStopAlicloudInstance struct { func (s *stepStopAlicloudInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ClientWrapper) instance := state.Get("instance").(*ecs.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !s.DisableStop { ui.Say(fmt.Sprintf("Stopping instance: %s", instance.InstanceId)) diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index a6c750aca..2ae2ad611 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -345,7 +346,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The amazon-chroot builder only works on Linux environments.") } diff --git a/builder/amazon/chroot/step_attach_volume.go b/builder/amazon/chroot/step_attach_volume.go index d87b03ca0..572ebce6e 100644 --- a/builder/amazon/chroot/step_attach_volume.go +++ b/builder/amazon/chroot/step_attach_volume.go @@ -8,8 +8,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepAttachVolume attaches the previously created volume to an @@ -28,7 +28,7 @@ func (s *StepAttachVolume) Run(ctx context.Context, state multistep.StateBag) mu ec2conn := state.Get("ec2").(*ec2.EC2) device := state.Get("device").(string) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) volumeId := state.Get("volume_id").(string) // For the API call, it expects "sd" prefixed devices. @@ -65,7 +65,7 @@ func (s *StepAttachVolume) Run(ctx context.Context, state multistep.StateBag) mu } func (s *StepAttachVolume) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } @@ -77,7 +77,7 @@ func (s *StepAttachVolume) CleanupFunc(state multistep.StateBag) error { } ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Detaching EBS volume...") _, err := ec2conn.DetachVolume(&ec2.DetachVolumeInput{VolumeId: &s.volumeId}) diff --git a/builder/amazon/chroot/step_check_root_device.go b/builder/amazon/chroot/step_check_root_device.go index cb1d06d8e..e9391c41e 100644 --- a/builder/amazon/chroot/step_check_root_device.go +++ b/builder/amazon/chroot/step_check_root_device.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCheckRootDevice makes sure the root device on the AMI is EBS-backed. @@ -14,7 +14,7 @@ type StepCheckRootDevice struct{} func (s *StepCheckRootDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { image := state.Get("source_image").(*ec2.Image) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Checking the root device on source AMI...") diff --git a/builder/amazon/chroot/step_create_volume.go b/builder/amazon/chroot/step_create_volume.go index f59bf689d..2b4a2a061 100644 --- a/builder/amazon/chroot/step_create_volume.go +++ b/builder/amazon/chroot/step_create_volume.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -32,7 +32,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) volTags, err := awscommon.TagMap(s.RootVolumeTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state) if err != nil { @@ -129,7 +129,7 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) { } ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting the created EBS volume...") _, err := ec2conn.DeleteVolume(&ec2.DeleteVolumeInput{VolumeId: &s.volumeId}) diff --git a/builder/amazon/chroot/step_early_unflock.go b/builder/amazon/chroot/step_early_unflock.go index a5378557f..5abe7dd1d 100644 --- a/builder/amazon/chroot/step_early_unflock.go +++ b/builder/amazon/chroot/step_early_unflock.go @@ -5,9 +5,9 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/chroot" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepEarlyUnflock unlocks the flock. @@ -15,7 +15,7 @@ type StepEarlyUnflock struct{} func (s *StepEarlyUnflock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { cleanup := state.Get("flock_cleanup").(chroot.Cleanup) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) log.Println("Unlocking file lock...") if err := cleanup.CleanupFunc(state); err != nil { diff --git a/builder/amazon/chroot/step_flock.go b/builder/amazon/chroot/step_flock.go index 5465a72fe..c8d92f5a3 100644 --- a/builder/amazon/chroot/step_flock.go +++ b/builder/amazon/chroot/step_flock.go @@ -7,8 +7,8 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepFlock provisions the instance within a chroot. @@ -20,7 +20,7 @@ type StepFlock struct { } func (s *StepFlock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) lockfile := "/var/lock/packer-chroot/lock" if err := os.MkdirAll(filepath.Dir(lockfile), 0755); err != nil { diff --git a/builder/amazon/chroot/step_instance_info.go b/builder/amazon/chroot/step_instance_info.go index 618577146..4cc488991 100644 --- a/builder/amazon/chroot/step_instance_info.go +++ b/builder/amazon/chroot/step_instance_info.go @@ -8,8 +8,8 @@ import ( "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepInstanceInfo verifies that this builder is running on an EC2 instance. @@ -18,7 +18,7 @@ type StepInstanceInfo struct{} func (s *StepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) session := state.Get("awsSession").(*session.Session) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Get our own instance ID ui.Say("Gathering information about this EC2 instance...") diff --git a/builder/amazon/chroot/step_mount_device.go b/builder/amazon/chroot/step_mount_device.go index d167e73eb..b4e56f42c 100644 --- a/builder/amazon/chroot/step_mount_device.go +++ b/builder/amazon/chroot/step_mount_device.go @@ -10,9 +10,9 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -36,7 +36,7 @@ type StepMountDevice struct { func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := state.Get("device").(string) if config.NVMEDevicePath != "" { // customizable device path for mounting NVME block devices on c5 and m5 HVM @@ -127,7 +127,7 @@ func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) mul } func (s *StepMountDevice) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } @@ -138,7 +138,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error { return nil } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) ui.Say("Unmounting the root device...") diff --git a/builder/amazon/chroot/step_prepare_device.go b/builder/amazon/chroot/step_prepare_device.go index 970c29b13..464dd950e 100644 --- a/builder/amazon/chroot/step_prepare_device.go +++ b/builder/amazon/chroot/step_prepare_device.go @@ -6,8 +6,8 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" ) @@ -18,7 +18,7 @@ type StepPrepareDevice struct { func (s *StepPrepareDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := config.DevicePath if device == "" { diff --git a/builder/amazon/chroot/step_register_ami.go b/builder/amazon/chroot/step_register_ami.go index 74f10e271..1f29a051c 100644 --- a/builder/amazon/chroot/step_register_ami.go +++ b/builder/amazon/chroot/step_register_ami.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/random" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -26,7 +26,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) snapshotID := state.Get("snapshot_id").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Registering the AMI...") diff --git a/builder/amazon/chroot/step_snapshot.go b/builder/amazon/chroot/step_snapshot.go index ba7391516..3f01cd1b2 100644 --- a/builder/amazon/chroot/step_snapshot.go +++ b/builder/amazon/chroot/step_snapshot.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepSnapshot creates a snapshot of the created volume. @@ -22,7 +22,7 @@ type StepSnapshot struct { func (s *StepSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) volumeId := state.Get("volume_id").(string) ui.Say("Creating snapshot...") @@ -72,7 +72,7 @@ func (s *StepSnapshot) Cleanup(state multistep.StateBag) { if cancelled || halted { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Removing snapshot since we cancelled or halted...") _, err := ec2conn.DeleteSnapshot(&ec2.DeleteSnapshotInput{SnapshotId: &s.snapshotId}) if err != nil { diff --git a/builder/amazon/common/ssm/session.go b/builder/amazon/common/ssm/session.go index 8e3f0fa84..4dc3cf923 100644 --- a/builder/amazon/common/ssm/session.go +++ b/builder/amazon/common/ssm/session.go @@ -13,7 +13,7 @@ import ( "github.com/aws/aws-sdk-go/service/ssm" "github.com/aws/aws-sdk-go/service/ssm/ssmiface" "github.com/hashicorp/packer/builder/amazon/common/awserrors" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/shell-local/localexec" ) @@ -89,7 +89,7 @@ func (s Session) getCommand(ctx context.Context) ([]string, string, error) { // context. If you do not wish to terminate the session manually: calling // StopSession on a instance of this driver will terminate the active session // created from calling StartSession. -func (s Session) Start(ctx context.Context, ui packer.Ui) error { +func (s Session) Start(ctx context.Context, ui packersdk.Ui) error { for ctx.Err() == nil { log.Printf("ssm: Starting PortForwarding session to instance %s", s.InstanceID) args, sessionID, err := s.getCommand(ctx) diff --git a/builder/amazon/common/step_ami_region_copy.go b/builder/amazon/common/step_ami_region_copy.go index 1395b3f80..182cb9de3 100644 --- a/builder/amazon/common/step_ami_region_copy.go +++ b/builder/amazon/common/step_ami_region_copy.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2/ec2iface" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -62,7 +63,7 @@ func (s *StepAMIRegionCopy) DeduplicateRegions(intermediary bool) { } func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) amis := state.Get("amis").(map[string]string) snapshots := state.Get("snapshots").(map[string][]string) intermediary, _ := state.Get("intermediary_image").(bool) @@ -150,7 +151,7 @@ func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) m func (s *StepAMIRegionCopy) Cleanup(state multistep.StateBag) { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.toDelete) == 0 { return diff --git a/builder/amazon/common/step_cleanup_volumes.go b/builder/amazon/common/step_cleanup_volumes.go index 67c0a7939..87a562bd2 100644 --- a/builder/amazon/common/step_cleanup_volumes.go +++ b/builder/amazon/common/step_cleanup_volumes.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepCleanupVolumes cleans up any orphaned volumes that were not designated to @@ -29,7 +29,7 @@ func (s *StepCleanupVolumes) Cleanup(state multistep.StateBag) { if instanceRaw != nil { instance = instanceRaw.(*ec2.Instance) } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if instance == nil { ui.Say("No volumes to clean up, skipping") return diff --git a/builder/amazon/common/step_create_ssm_tunnel.go b/builder/amazon/common/step_create_ssm_tunnel.go index 2b1de42af..cdb41f8bf 100644 --- a/builder/amazon/common/step_create_ssm_tunnel.go +++ b/builder/amazon/common/step_create_ssm_tunnel.go @@ -10,9 +10,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ssm" pssm "github.com/hashicorp/packer/builder/amazon/common/ssm" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateSSMTunnel struct { @@ -27,7 +27,7 @@ type StepCreateSSMTunnel struct { // Run executes the Packer build step that creates a session tunnel. func (s *StepCreateSSMTunnel) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !s.SSMAgentEnabled { return multistep.ActionContinue diff --git a/builder/amazon/common/step_create_tags.go b/builder/amazon/common/step_create_tags.go index c875f5e49..4301c4c40 100644 --- a/builder/amazon/common/step_create_tags.go +++ b/builder/amazon/common/step_create_tags.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/builder/amazon/common/awserrors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -24,7 +24,7 @@ type StepCreateTags struct { func (s *StepCreateTags) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) session := state.Get("awsSession").(*session.Session) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) amis := state.Get("amis").(map[string]string) if len(s.Tags) == 0 && len(s.SnapshotTags) == 0 { diff --git a/builder/amazon/common/step_deregister_ami.go b/builder/amazon/common/step_deregister_ami.go index 8ab5685c7..ea5a4f385 100644 --- a/builder/amazon/common/step_deregister_ami.go +++ b/builder/amazon/common/step_deregister_ami.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDeregisterAMI struct { @@ -24,7 +24,7 @@ func (s *StepDeregisterAMI) Run(ctx context.Context, state multistep.StateBag) m return multistep.ActionContinue } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ec2conn := state.Get("ec2").(*ec2.EC2) // Add the session region to list of regions will deregister AMIs in regions := append(s.Regions, *ec2conn.Config.Region) diff --git a/builder/amazon/common/step_get_password.go b/builder/amazon/common/step_get_password.go index 007f8c5f2..f1e1410cc 100644 --- a/builder/amazon/common/step_get_password.go +++ b/builder/amazon/common/step_get_password.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -28,7 +29,7 @@ type StepGetPassword struct { } func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip if we're not using winrm if s.Comm.Type != "winrm" { diff --git a/builder/amazon/common/step_iam_instance_profile.go b/builder/amazon/common/step_iam_instance_profile.go index 91a6ec2b0..09ac5030c 100644 --- a/builder/amazon/common/step_iam_instance_profile.go +++ b/builder/amazon/common/step_iam_instance_profile.go @@ -8,8 +8,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/iam" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -25,7 +25,7 @@ type StepIamInstanceProfile struct { func (s *StepIamInstanceProfile) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { iamsvc := state.Get("iam").(*iam.IAM) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) state.Put("iamInstanceProfile", "") @@ -147,7 +147,7 @@ func (s *StepIamInstanceProfile) Run(ctx context.Context, state multistep.StateB func (s *StepIamInstanceProfile) Cleanup(state multistep.StateBag) { iamsvc := state.Get("iam").(*iam.IAM) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) var err error if s.roleIsAttached == true { diff --git a/builder/amazon/common/step_key_pair.go b/builder/amazon/common/step_key_pair.go index a477524de..2de8d676c 100644 --- a/builder/amazon/common/step_key_pair.go +++ b/builder/amazon/common/step_key_pair.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -23,7 +23,7 @@ type StepKeyPair struct { } func (s *StepKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key") @@ -114,7 +114,7 @@ func (s *StepKeyPair) Cleanup(state multistep.StateBag) { } ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Remove the keypair ui.Say("Deleting temporary keypair...") diff --git a/builder/amazon/common/step_modify_ami_attributes.go b/builder/amazon/common/step_modify_ami_attributes.go index b60caff4c..3f45639dd 100644 --- a/builder/amazon/common/step_modify_ami_attributes.go +++ b/builder/amazon/common/step_modify_ami_attributes.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -28,7 +28,7 @@ type StepModifyAMIAttributes struct { func (s *StepModifyAMIAttributes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) session := state.Get("awsSession").(*session.Session) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) amis := state.Get("amis").(map[string]string) snapshots := state.Get("snapshots").(map[string][]string) diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index a578bcb24..776deced6 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2/ec2iface" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -21,7 +21,7 @@ type StepModifyEBSBackedInstance struct { func (s *StepModifyEBSBackedInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(ec2iface.EC2API) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip when it is a spot instance if s.Skip { diff --git a/builder/amazon/common/step_network_info.go b/builder/amazon/common/step_network_info.go index b66bef233..75477863a 100644 --- a/builder/amazon/common/step_network_info.go +++ b/builder/amazon/common/step_network_info.go @@ -8,8 +8,8 @@ import ( "sort" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepNetworkInfo queries AWS for information about @@ -46,7 +46,7 @@ func mostFreeSubnet(subnets []*ec2.Subnet) *ec2.Subnet { func (s *StepNetworkInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // VPC if s.VpcId == "" && !s.VpcFilter.Empty() { diff --git a/builder/amazon/common/step_pre_validate.go b/builder/amazon/common/step_pre_validate.go index 993b4d940..7f43fc0be 100644 --- a/builder/amazon/common/step_pre_validate.go +++ b/builder/amazon/common/step_pre_validate.go @@ -10,8 +10,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2/ec2iface" "github.com/hashicorp/packer/builder/amazon/common/awserrors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -28,7 +28,7 @@ type StepPreValidate struct { } func (s *StepPreValidate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if accessConfig, ok := state.GetOk("access_config"); ok { accessconf := accessConfig.(*AccessConfig) diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index ded2f19ff..49e32fab2 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -13,8 +13,8 @@ import ( "github.com/hashicorp/packer/builder/amazon/common/awserrors" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -49,7 +49,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa securityGroupIds := aws.StringSlice(state.Get("securityGroupIds").([]string)) iamInstanceProfile := aws.String(state.Get("iamInstanceProfile").(string)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) userData := s.UserData if s.UserDataFile != "" { @@ -371,7 +371,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Terminate the source instance if it exists if s.instanceId != "" { diff --git a/builder/amazon/common/step_run_spot_instance.go b/builder/amazon/common/step_run_spot_instance.go index 039198f78..587efae64 100644 --- a/builder/amazon/common/step_run_spot_instance.go +++ b/builder/amazon/common/step_run_spot_instance.go @@ -14,8 +14,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2/ec2iface" "github.com/hashicorp/packer/builder/amazon/common/awserrors" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/random" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -161,7 +161,7 @@ func (s *StepRunSpotInstance) LoadUserData() (string, error) { func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(ec2iface.EC2API) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Launching a spot AWS instance...") @@ -485,7 +485,7 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag) func (s *StepRunSpotInstance) Cleanup(state multistep.StateBag) { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) launchTemplateName := state.Get("launchTemplateName").(string) // Terminate the source instance if it exists diff --git a/builder/amazon/common/step_security_group.go b/builder/amazon/common/step_security_group.go index d77f4bfb4..515e4a42c 100644 --- a/builder/amazon/common/step_security_group.go +++ b/builder/amazon/common/step_security_group.go @@ -11,8 +11,8 @@ import ( "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -28,7 +28,7 @@ type StepSecurityGroup struct { func (s *StepSecurityGroup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vpcId := state.Get("vpc_id").(string) if len(s.SecurityGroupIds) > 0 { @@ -165,7 +165,7 @@ func (s *StepSecurityGroup) Cleanup(state multistep.StateBag) { } ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting temporary security group...") diff --git a/builder/amazon/common/step_source_ami_info.go b/builder/amazon/common/step_source_ami_info.go index 3c387a1c0..32b4dabc5 100644 --- a/builder/amazon/common/step_source_ami_info.go +++ b/builder/amazon/common/step_source_ami_info.go @@ -8,8 +8,8 @@ import ( "time" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -45,7 +45,7 @@ func mostRecentAmi(images []*ec2.Image) *ec2.Image { func (s *StepSourceAMIInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) params := &ec2.DescribeImagesInput{} diff --git a/builder/amazon/common/step_stop_ebs_instance.go b/builder/amazon/common/step_stop_ebs_instance.go index db0591e44..4351de063 100644 --- a/builder/amazon/common/step_stop_ebs_instance.go +++ b/builder/amazon/common/step_stop_ebs_instance.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/builder/amazon/common/awserrors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -21,7 +21,7 @@ type StepStopEBSBackedInstance struct { func (s *StepStopEBSBackedInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip when it is a spot instance if s.Skip { diff --git a/builder/amazon/common/tags.go b/builder/amazon/common/tags.go index 299574c25..2ecac7f8c 100644 --- a/builder/amazon/common/tags.go +++ b/builder/amazon/common/tags.go @@ -5,8 +5,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -14,7 +14,7 @@ import ( type TagMap map[string]string type EC2Tags []*ec2.Tag -func (t EC2Tags) Report(ui packer.Ui) { +func (t EC2Tags) Report(ui packersdk.Ui) { for _, tag := range t { ui.Message(fmt.Sprintf("Adding tag: \"%s\": \"%s\"", aws.StringValue(tag.Key), aws.StringValue(tag.Value))) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index a7be359c2..3271bc93b 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -150,7 +151,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { session, err := b.config.Session() if err != nil { diff --git a/builder/amazon/ebs/step_create_ami.go b/builder/amazon/ebs/step_create_ami.go index 25efa7666..8f741c3d5 100644 --- a/builder/amazon/ebs/step_create_ami.go +++ b/builder/amazon/ebs/step_create_ami.go @@ -10,8 +10,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/builder/amazon/common/awserrors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/random" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -26,7 +26,7 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Create the image amiName := config.AMIName @@ -144,7 +144,7 @@ func (s *stepCreateAMI) Cleanup(state multistep.StateBag) { } ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deregistering the AMI and deleting associated snapshots because " + "of cancellation, or error...") diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index a6036bd76..d8453421d 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -173,7 +174,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/ebssurrogate/step_register_ami.go b/builder/amazon/ebssurrogate/step_register_ami.go index 66865250f..cf4cc1465 100644 --- a/builder/amazon/ebssurrogate/step_register_ami.go +++ b/builder/amazon/ebssurrogate/step_register_ami.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/random" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -31,7 +31,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) snapshotIds := state.Get("snapshot_ids").(map[string]string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Registering the AMI...") @@ -127,7 +127,7 @@ func (s *StepRegisterAMI) Cleanup(state multistep.StateBag) { } ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deregistering the AMI because cancellation or error...") deregisterOpts := &ec2.DeregisterImageInput{ImageId: s.image.ImageId} diff --git a/builder/amazon/ebssurrogate/step_snapshot_volumes.go b/builder/amazon/ebssurrogate/step_snapshot_volumes.go index 3888fddce..f3225766a 100644 --- a/builder/amazon/ebssurrogate/step_snapshot_volumes.go +++ b/builder/amazon/ebssurrogate/step_snapshot_volumes.go @@ -10,8 +10,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" multierror "github.com/hashicorp/go-multierror" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -31,7 +31,7 @@ type StepSnapshotVolumes struct { func (s *StepSnapshotVolumes) snapshotVolume(ctx context.Context, deviceName string, state multistep.StateBag) error { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*ec2.Instance) var volumeId string @@ -88,7 +88,7 @@ func (s *StepSnapshotVolumes) snapshotVolume(ctx context.Context, deviceName str } func (s *StepSnapshotVolumes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) s.snapshotIds = map[string]string{} @@ -132,7 +132,7 @@ func (s *StepSnapshotVolumes) Cleanup(state multistep.StateBag) { if cancelled || halted { ec2conn := state.Get("ec2").(*ec2.EC2) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Removing snapshots since we cancelled or halted...") s.snapshotMutex.Lock() for _, snapshotId := range s.snapshotIds { diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index d5d5bddb1..cea518c6a 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -164,7 +165,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/ebsvolume/step_tag_ebs_volumes.go b/builder/amazon/ebsvolume/step_tag_ebs_volumes.go index 911b2c138..aede0c511 100644 --- a/builder/amazon/ebsvolume/step_tag_ebs_volumes.go +++ b/builder/amazon/ebsvolume/step_tag_ebs_volumes.go @@ -8,8 +8,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -21,7 +21,7 @@ type stepTagEBSVolumes struct { func (s *stepTagEBSVolumes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) volumes := make(EbsVolumes) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 6a706b0ae..80f8c7c4b 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -233,7 +234,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/instance/step_bundle_volume.go b/builder/amazon/instance/step_bundle_volume.go index 6bcee9b43..043f4f096 100644 --- a/builder/amazon/instance/step_bundle_volume.go +++ b/builder/amazon/instance/step_bundle_volume.go @@ -7,6 +7,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -28,7 +29,7 @@ func (s *StepBundleVolume) Run(ctx context.Context, state multistep.StateBag) mu comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*Config) instance := state.Get("instance").(*ec2.Instance) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) x509RemoteCertPath := state.Get("x509RemoteCertPath").(string) x509RemoteKeyPath := state.Get("x509RemoteKeyPath").(string) diff --git a/builder/amazon/instance/step_register_ami.go b/builder/amazon/instance/step_register_ami.go index 10992c1cc..40a72cadc 100644 --- a/builder/amazon/instance/step_register_ami.go +++ b/builder/amazon/instance/step_register_ami.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/random" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -24,7 +24,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) manifestPath := state.Get("remote_manifest_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Registering the AMI...") diff --git a/builder/amazon/instance/step_upload_bundle.go b/builder/amazon/instance/step_upload_bundle.go index 8ff2d18c4..6a8dd3186 100644 --- a/builder/amazon/instance/step_upload_bundle.go +++ b/builder/amazon/instance/step_upload_bundle.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -28,7 +29,7 @@ func (s *StepUploadBundle) Run(ctx context.Context, state multistep.StateBag) mu config := state.Get("config").(*Config) manifestName := state.Get("manifest_name").(string) manifestPath := state.Get("manifest_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) accessKey := config.AccessKey secretKey := config.SecretKey diff --git a/builder/amazon/instance/step_upload_x509_cert.go b/builder/amazon/instance/step_upload_x509_cert.go index 37cf4ae6a..a46eb024f 100644 --- a/builder/amazon/instance/step_upload_x509_cert.go +++ b/builder/amazon/instance/step_upload_x509_cert.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepUploadX509Cert struct{} @@ -14,7 +15,7 @@ type StepUploadX509Cert struct{} func (s *StepUploadX509Cert) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) x509RemoteCertPath := config.X509UploadPath + "/cert.pem" x509RemoteKeyPath := config.X509UploadPath + "/key.pem" diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index bee0539a1..e7f28b256 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Builder struct { @@ -51,7 +52,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { ui.Say("Running builder ...") @@ -339,7 +340,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, nil } -func (b *Builder) writeSSHPrivateKey(ui packer.Ui, debugKeyPath string) { +func (b *Builder) writeSSHPrivateKey(ui packersdk.Ui, debugKeyPath string) { f, err := os.Create(debugKeyPath) if err != nil { ui.Say(fmt.Sprintf("Error saving debug key: %s", err)) @@ -455,7 +456,7 @@ func (b *Builder) getServicePrincipalTokens(say func(string)) (*adal.ServicePrin return b.config.ClientConfig.GetServicePrincipalTokens(say) } -func getObjectIdFromToken(ui packer.Ui, token *adal.ServicePrincipalToken) string { +func getObjectIdFromToken(ui packersdk.Ui, token *adal.ServicePrincipalToken) string { claims := jwt.MapClaims{} var p jwt.Parser diff --git a/builder/azure/arm/step_capture_image.go b/builder/azure/arm/step_capture_image.go index 025fc96d3..34431971a 100644 --- a/builder/azure/arm/step_capture_image.go +++ b/builder/azure/arm/step_capture_image.go @@ -6,8 +6,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCaptureImage struct { @@ -20,7 +20,7 @@ type StepCaptureImage struct { error func(e error) } -func NewStepCaptureImage(client *AzureClient, ui packer.Ui) *StepCaptureImage { +func NewStepCaptureImage(client *AzureClient, ui packersdk.Ui) *StepCaptureImage { var step = &StepCaptureImage{ client: client, get: func(client *AzureClient) *CaptureTemplate { diff --git a/builder/azure/arm/step_certificate_in_keyvault.go b/builder/azure/arm/step_certificate_in_keyvault.go index 1d1b5800d..62b6d0d6d 100644 --- a/builder/azure/arm/step_certificate_in_keyvault.go +++ b/builder/azure/arm/step_certificate_in_keyvault.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCertificateInKeyVault struct { @@ -17,7 +17,7 @@ type StepCertificateInKeyVault struct { error func(e error) } -func NewStepCertificateInKeyVault(cli common.AZVaultClientIface, ui packer.Ui, config *Config) *StepCertificateInKeyVault { +func NewStepCertificateInKeyVault(cli common.AZVaultClientIface, ui packersdk.Ui, config *Config) *StepCertificateInKeyVault { var step = &StepCertificateInKeyVault{ client: cli, config: config, diff --git a/builder/azure/arm/step_create_resource_group.go b/builder/azure/arm/step_create_resource_group.go index ff0bab59c..9f9ee0edb 100644 --- a/builder/azure/arm/step_create_resource_group.go +++ b/builder/azure/arm/step_create_resource_group.go @@ -7,8 +7,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateResourceGroup struct { @@ -19,7 +19,7 @@ type StepCreateResourceGroup struct { exists func(ctx context.Context, resourceGroupName string) (bool, error) } -func NewStepCreateResourceGroup(client *AzureClient, ui packer.Ui) *StepCreateResourceGroup { +func NewStepCreateResourceGroup(client *AzureClient, ui packersdk.Ui) *StepCreateResourceGroup { var step = &StepCreateResourceGroup{ client: client, say: func(message string) { ui.Say(message) }, @@ -113,7 +113,7 @@ func (s *StepCreateResourceGroup) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if state.Get(constants.ArmIsExistingResourceGroup).(bool) { ui.Say("\nThe resource group was not created by Packer, not deleting ...") return diff --git a/builder/azure/arm/step_delete_additional_disks.go b/builder/azure/arm/step_delete_additional_disks.go index 6ff15a893..0d4e7cf53 100644 --- a/builder/azure/arm/step_delete_additional_disks.go +++ b/builder/azure/arm/step_delete_additional_disks.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDeleteAdditionalDisk struct { @@ -21,7 +21,7 @@ type StepDeleteAdditionalDisk struct { error func(e error) } -func NewStepDeleteAdditionalDisks(client *AzureClient, ui packer.Ui) *StepDeleteAdditionalDisk { +func NewStepDeleteAdditionalDisks(client *AzureClient, ui packersdk.Ui) *StepDeleteAdditionalDisk { var step = &StepDeleteAdditionalDisk{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_deploy_template.go b/builder/azure/arm/step_deploy_template.go index 481af6156..a91cb70fe 100644 --- a/builder/azure/arm/step_deploy_template.go +++ b/builder/azure/arm/step_deploy_template.go @@ -9,8 +9,8 @@ import ( "time" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -27,7 +27,7 @@ type StepDeployTemplate struct { name string } -func NewStepDeployTemplate(client *AzureClient, ui packer.Ui, config *Config, deploymentName string, factory templateFactoryFunc) *StepDeployTemplate { +func NewStepDeployTemplate(client *AzureClient, ui packersdk.Ui, config *Config, deploymentName string, factory templateFactoryFunc) *StepDeployTemplate { var step = &StepDeployTemplate{ client: client, say: func(message string) { ui.Say(message) }, @@ -73,7 +73,7 @@ func (s *StepDeployTemplate) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("\nThe resource group was not created by Packer, deleting individual resources ...") deploymentName := s.name @@ -109,7 +109,7 @@ func (s *StepDeployTemplate) deployTemplate(ctx context.Context, resourceGroupNa func (s *StepDeployTemplate) deleteTemplate(ctx context.Context, state multistep.StateBag) error { deploymentName := s.name resourceGroupName := state.Get(constants.ArmResourceGroupName).(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Removing the created Deployment object: '%s'", deploymentName)) f, err := s.client.DeploymentsClient.Delete(ctx, resourceGroupName, deploymentName) diff --git a/builder/azure/arm/step_get_additional_disks.go b/builder/azure/arm/step_get_additional_disks.go index 51468a3cd..f1131a907 100644 --- a/builder/azure/arm/step_get_additional_disks.go +++ b/builder/azure/arm/step_get_additional_disks.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepGetDataDisk struct { @@ -19,7 +19,7 @@ type StepGetDataDisk struct { error func(e error) } -func NewStepGetAdditionalDisks(client *AzureClient, ui packer.Ui) *StepGetDataDisk { +func NewStepGetAdditionalDisks(client *AzureClient, ui packersdk.Ui) *StepGetDataDisk { var step = &StepGetDataDisk{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_get_certificate.go b/builder/azure/arm/step_get_certificate.go index ca19b262e..26f1b49a5 100644 --- a/builder/azure/arm/step_get_certificate.go +++ b/builder/azure/arm/step_get_certificate.go @@ -6,8 +6,8 @@ import ( "time" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepGetCertificate struct { @@ -18,7 +18,7 @@ type StepGetCertificate struct { pause func() } -func NewStepGetCertificate(client *AzureClient, ui packer.Ui) *StepGetCertificate { +func NewStepGetCertificate(client *AzureClient, ui packersdk.Ui) *StepGetCertificate { var step = &StepGetCertificate{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_get_ip_address.go b/builder/azure/arm/step_get_ip_address.go index 03620ae00..b284441e6 100644 --- a/builder/azure/arm/step_get_ip_address.go +++ b/builder/azure/arm/step_get_ip_address.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type EndpointType int @@ -33,7 +33,7 @@ type StepGetIPAddress struct { error func(e error) } -func NewStepGetIPAddress(client *AzureClient, ui packer.Ui, endpoint EndpointType) *StepGetIPAddress { +func NewStepGetIPAddress(client *AzureClient, ui packersdk.Ui, endpoint EndpointType) *StepGetIPAddress { var step = &StepGetIPAddress{ client: client, endpoint: endpoint, diff --git a/builder/azure/arm/step_get_os_disk.go b/builder/azure/arm/step_get_os_disk.go index 78eda273b..1fb177472 100644 --- a/builder/azure/arm/step_get_os_disk.go +++ b/builder/azure/arm/step_get_os_disk.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepGetOSDisk struct { @@ -19,7 +19,7 @@ type StepGetOSDisk struct { error func(e error) } -func NewStepGetOSDisk(client *AzureClient, ui packer.Ui) *StepGetOSDisk { +func NewStepGetOSDisk(client *AzureClient, ui packersdk.Ui) *StepGetOSDisk { var step = &StepGetOSDisk{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_power_off_compute.go b/builder/azure/arm/step_power_off_compute.go index f6100ae9a..b7af984fc 100644 --- a/builder/azure/arm/step_power_off_compute.go +++ b/builder/azure/arm/step_power_off_compute.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepPowerOffCompute struct { @@ -16,7 +16,7 @@ type StepPowerOffCompute struct { error func(e error) } -func NewStepPowerOffCompute(client *AzureClient, ui packer.Ui) *StepPowerOffCompute { +func NewStepPowerOffCompute(client *AzureClient, ui packersdk.Ui) *StepPowerOffCompute { var step = &StepPowerOffCompute{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_publish_to_shared_image_gallery.go b/builder/azure/arm/step_publish_to_shared_image_gallery.go index ed7f050b9..5b81d229d 100644 --- a/builder/azure/arm/step_publish_to_shared_image_gallery.go +++ b/builder/azure/arm/step_publish_to_shared_image_gallery.go @@ -7,8 +7,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" "github.com/Azure/go-autorest/autorest/date" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepPublishToSharedImageGallery struct { @@ -19,7 +19,7 @@ type StepPublishToSharedImageGallery struct { toSIG func() bool } -func NewStepPublishToSharedImageGallery(client *AzureClient, ui packer.Ui, config *Config) *StepPublishToSharedImageGallery { +func NewStepPublishToSharedImageGallery(client *AzureClient, ui packersdk.Ui, config *Config) *StepPublishToSharedImageGallery { var step = &StepPublishToSharedImageGallery{ client: client, say: func(message string) { diff --git a/builder/azure/arm/step_set_certificate.go b/builder/azure/arm/step_set_certificate.go index 563cc55c1..285f0e19a 100644 --- a/builder/azure/arm/step_set_certificate.go +++ b/builder/azure/arm/step_set_certificate.go @@ -4,8 +4,8 @@ import ( "context" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSetCertificate struct { @@ -14,7 +14,7 @@ type StepSetCertificate struct { error func(e error) } -func NewStepSetCertificate(config *Config, ui packer.Ui) *StepSetCertificate { +func NewStepSetCertificate(config *Config, ui packersdk.Ui) *StepSetCertificate { var step = &StepSetCertificate{ config: config, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_snapshot_data_disks.go b/builder/azure/arm/step_snapshot_data_disks.go index 63e9b0f71..5fc2a263d 100644 --- a/builder/azure/arm/step_snapshot_data_disks.go +++ b/builder/azure/arm/step_snapshot_data_disks.go @@ -8,8 +8,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSnapshotDataDisks struct { @@ -20,7 +20,7 @@ type StepSnapshotDataDisks struct { enable func() bool } -func NewStepSnapshotDataDisks(client *AzureClient, ui packer.Ui, config *Config) *StepSnapshotDataDisks { +func NewStepSnapshotDataDisks(client *AzureClient, ui packersdk.Ui, config *Config) *StepSnapshotDataDisks { var step = &StepSnapshotDataDisks{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_snapshot_os_disk.go b/builder/azure/arm/step_snapshot_os_disk.go index bc84d0d94..9aa1bf00b 100644 --- a/builder/azure/arm/step_snapshot_os_disk.go +++ b/builder/azure/arm/step_snapshot_os_disk.go @@ -7,8 +7,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSnapshotOSDisk struct { @@ -19,7 +19,7 @@ type StepSnapshotOSDisk struct { enable func() bool } -func NewStepSnapshotOSDisk(client *AzureClient, ui packer.Ui, config *Config) *StepSnapshotOSDisk { +func NewStepSnapshotOSDisk(client *AzureClient, ui packersdk.Ui, config *Config) *StepSnapshotOSDisk { var step = &StepSnapshotOSDisk{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/arm/step_validate_template.go b/builder/azure/arm/step_validate_template.go index 4f3204659..cd09bba69 100644 --- a/builder/azure/arm/step_validate_template.go +++ b/builder/azure/arm/step_validate_template.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepValidateTemplate struct { @@ -18,7 +18,7 @@ type StepValidateTemplate struct { factory templateFactoryFunc } -func NewStepValidateTemplate(client *AzureClient, ui packer.Ui, config *Config, factory templateFactoryFunc) *StepValidateTemplate { +func NewStepValidateTemplate(client *AzureClient, ui packersdk.Ui, config *Config, factory templateFactoryFunc) *StepValidateTemplate { var step = &StepValidateTemplate{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index 58e146d3e..b0d0c83e4 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -23,6 +23,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -392,7 +393,7 @@ func checkHyperVGeneration(s string) interface{} { s, compute.PossibleHyperVGenerationValues()) } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { switch runtime.GOOS { case "linux", "freebsd": break diff --git a/builder/azure/chroot/packerui_test.go b/builder/azure/chroot/packerui_test.go index af7b250ec..fb2435a18 100644 --- a/builder/azure/chroot/packerui_test.go +++ b/builder/azure/chroot/packerui_test.go @@ -5,10 +5,11 @@ import ( "strings" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // testUI returns a test ui plus a function to retrieve the errors written to the ui -func testUI() (packer.Ui, func() string) { +func testUI() (packersdk.Ui, func() string) { errorBuffer := &strings.Builder{} ui := &packer.BasicUi{ Reader: strings.NewReader(""), diff --git a/builder/azure/chroot/step_attach_disk.go b/builder/azure/chroot/step_attach_disk.go index 53a0b16c3..1fe61051f 100644 --- a/builder/azure/chroot/step_attach_disk.go +++ b/builder/azure/chroot/step_attach_disk.go @@ -7,8 +7,8 @@ import ( "time" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var _ multistep.Step = &StepAttachDisk{} @@ -19,7 +19,7 @@ type StepAttachDisk struct { func (s *StepAttachDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) diskset := state.Get(stateBagKey_Diskset).(Diskset) diskResourceID := diskset.OS().String() @@ -57,7 +57,7 @@ func (s *StepAttachDisk) Run(ctx context.Context, state multistep.StateBag) mult } func (s *StepAttachDisk) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } @@ -67,7 +67,7 @@ func (s *StepAttachDisk) CleanupFunc(state multistep.StateBag) error { if s.attached { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) diskset := state.Get(stateBagKey_Diskset).(Diskset) diskResourceID := diskset.OS().String() diff --git a/builder/azure/chroot/step_create_image.go b/builder/azure/chroot/step_create_image.go index 952374f7d..d52dee3ee 100644 --- a/builder/azure/chroot/step_create_image.go +++ b/builder/azure/chroot/step_create_image.go @@ -10,8 +10,8 @@ import ( "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var _ multistep.Step = &StepCreateImage{} @@ -28,7 +28,7 @@ type StepCreateImage struct { func (s *StepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) diskset := state.Get(stateBagKey_Diskset).(Diskset) diskResourceID := diskset.OS().String() diff --git a/builder/azure/chroot/step_create_new_diskset.go b/builder/azure/chroot/step_create_new_diskset.go index ad690ecad..9749bd31a 100644 --- a/builder/azure/chroot/step_create_new_diskset.go +++ b/builder/azure/chroot/step_create_new_diskset.go @@ -8,8 +8,8 @@ import ( "time" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest/to" @@ -44,7 +44,7 @@ type StepCreateNewDiskset struct { func (s *StepCreateNewDiskset) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) s.disks = make(Diskset) @@ -214,7 +214,7 @@ func (s StepCreateNewDiskset) getDatadiskDefinitionFromImage(lun int32) compute. func (s *StepCreateNewDiskset) Cleanup(state multistep.StateBag) { if !s.SkipCleanup { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) for _, d := range s.disks { diff --git a/builder/azure/chroot/step_create_shared_image_version.go b/builder/azure/chroot/step_create_shared_image_version.go index d32da7e92..68db7fb9f 100644 --- a/builder/azure/chroot/step_create_shared_image_version.go +++ b/builder/azure/chroot/step_create_shared_image_version.go @@ -10,8 +10,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateSharedImageVersion struct { @@ -23,7 +23,7 @@ type StepCreateSharedImageVersion struct { func (s *StepCreateSharedImageVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) snapshotset := state.Get(stateBagKey_Snapshotset).(Diskset) ui.Say(fmt.Sprintf("Creating image version %s\n using %q for os disk.", diff --git a/builder/azure/chroot/step_create_snapshotset.go b/builder/azure/chroot/step_create_snapshotset.go index 6af98710a..f742e9dbe 100644 --- a/builder/azure/chroot/step_create_snapshotset.go +++ b/builder/azure/chroot/step_create_snapshotset.go @@ -8,8 +8,8 @@ import ( "time" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest/to" @@ -29,7 +29,7 @@ type StepCreateSnapshotset struct { func (s *StepCreateSnapshotset) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) diskset := state.Get(stateBagKey_Diskset).(Diskset) s.snapshots = make(Diskset) @@ -92,7 +92,7 @@ func (s *StepCreateSnapshotset) Run(ctx context.Context, state multistep.StateBa func (s *StepCreateSnapshotset) Cleanup(state multistep.StateBag) { if !s.SkipCleanup { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) for _, resource := range s.snapshots { diff --git a/builder/azure/chroot/step_mount_device.go b/builder/azure/chroot/step_mount_device.go index 315b61d5b..9c535bd22 100644 --- a/builder/azure/chroot/step_mount_device.go +++ b/builder/azure/chroot/step_mount_device.go @@ -12,9 +12,9 @@ import ( "runtime" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -29,7 +29,7 @@ type StepMountDevice struct { } func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := state.Get("device").(string) config := state.Get("config").(*Config) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) @@ -110,7 +110,7 @@ func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) mul } func (s *StepMountDevice) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } @@ -121,7 +121,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error { return nil } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) ui.Say("Unmounting the root device...") diff --git a/builder/azure/chroot/step_resolve_plaform_image_version.go b/builder/azure/chroot/step_resolve_plaform_image_version.go index d0f4a9ed2..cf5b3363b 100644 --- a/builder/azure/chroot/step_resolve_plaform_image_version.go +++ b/builder/azure/chroot/step_resolve_plaform_image_version.go @@ -8,8 +8,8 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepResolvePlatformImageVersion resolves the exact PIR version when the version is 'latest' @@ -20,7 +20,7 @@ type StepResolvePlatformImageVersion struct { // Run retrieves all available versions of a PIR image and stores the latest in the PlatformImage func (pi *StepResolvePlatformImageVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if strings.EqualFold(pi.Version, "latest") { azcli := state.Get("azureclient").(client.AzureClientSet) diff --git a/builder/azure/chroot/step_verify_shared_image_destination.go b/builder/azure/chroot/step_verify_shared_image_destination.go index 156e8413f..ac2da44ca 100644 --- a/builder/azure/chroot/step_verify_shared_image_destination.go +++ b/builder/azure/chroot/step_verify_shared_image_destination.go @@ -9,8 +9,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var _ multistep.Step = &StepVerifySharedImageDestination{} @@ -25,7 +25,7 @@ type StepVerifySharedImageDestination struct { // Run retrieves the image metadata from Azure and compares the location to Location. Verifies the OS Type. func (s *StepVerifySharedImageDestination) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMessage := func(message string, parameters ...interface{}) multistep.StepAction { err := fmt.Errorf(message, parameters...) diff --git a/builder/azure/chroot/step_verify_shared_image_source.go b/builder/azure/chroot/step_verify_shared_image_source.go index 5f6d243c6..3c29aa177 100644 --- a/builder/azure/chroot/step_verify_shared_image_source.go +++ b/builder/azure/chroot/step_verify_shared_image_source.go @@ -9,8 +9,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var _ multistep.Step = &StepVerifySharedImageSource{} @@ -26,7 +26,7 @@ type StepVerifySharedImageSource struct { // Run retrieves the image metadata from Azure and compares the location to Location. Verifies the OS Type. func (s *StepVerifySharedImageSource) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMessage := func(message string, parameters ...interface{}) multistep.StepAction { err := fmt.Errorf(message, parameters...) diff --git a/builder/azure/chroot/step_verify_source_disk.go b/builder/azure/chroot/step_verify_source_disk.go index 1bf65a436..2aa19dc68 100644 --- a/builder/azure/chroot/step_verify_source_disk.go +++ b/builder/azure/chroot/step_verify_source_disk.go @@ -10,8 +10,8 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepVerifySourceDisk struct { @@ -21,7 +21,7 @@ type StepVerifySourceDisk struct { func (s StepVerifySourceDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { azcli := state.Get("azureclient").(client.AzureClientSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Checking source disk location") resource, err := azure.ParseResourceID(s.SourceDiskResourceID) diff --git a/builder/azure/chroot/step_verify_source_disk_test.go b/builder/azure/chroot/step_verify_source_disk_test.go index d0149a439..6f6084d93 100644 --- a/builder/azure/chroot/step_verify_source_disk_test.go +++ b/builder/azure/chroot/step_verify_source_disk_test.go @@ -12,8 +12,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func Test_StepVerifySourceDisk_Run(t *testing.T) { @@ -152,6 +152,6 @@ func Test_StepVerifySourceDisk_Run(t *testing.T) { } type uiThatRemebersErrors struct { - packer.Ui + packersdk.Ui LastError string } diff --git a/builder/azure/dtl/builder.go b/builder/azure/dtl/builder.go index ad32a4d83..4d1eb516a 100644 --- a/builder/azure/dtl/builder.go +++ b/builder/azure/dtl/builder.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Builder struct { @@ -51,7 +52,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { ui.Say("Running builder ...") @@ -261,7 +262,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack return &Artifact{}, nil } -func (b *Builder) writeSSHPrivateKey(ui packer.Ui, debugKeyPath string) { +func (b *Builder) writeSSHPrivateKey(ui packersdk.Ui, debugKeyPath string) { f, err := os.Create(debugKeyPath) if err != nil { ui.Say(fmt.Sprintf("Error saving debug key: %s", err)) @@ -323,7 +324,7 @@ func (b *Builder) getServicePrincipalToken(say func(string)) (*adal.ServicePrinc return b.config.ClientConfig.GetServicePrincipalToken(say, b.config.ClientConfig.CloudEnvironment().ResourceManagerEndpoint) } -func (b *Builder) getSubnetInformation(ctx context.Context, ui packer.Ui, azClient AzureClient) (*string, *string, error) { +func (b *Builder) getSubnetInformation(ctx context.Context, ui packersdk.Ui, azClient AzureClient) (*string, *string, error) { num := int32(10) virtualNetworkPage, err := azClient.DtlVirtualNetworksClient.List(ctx, b.config.LabResourceGroupName, b.config.LabName, "", "", &num, "") @@ -346,7 +347,7 @@ func (b *Builder) getSubnetInformation(ctx context.Context, ui packer.Ui, azClie return nil, nil, fmt.Errorf("No available Subnet with available space in resource group %s", b.config.LabResourceGroupName) } -func getObjectIdFromToken(ui packer.Ui, token *adal.ServicePrincipalToken) string { +func getObjectIdFromToken(ui packersdk.Ui, token *adal.ServicePrincipalToken) string { claims := jwt.MapClaims{} var p jwt.Parser diff --git a/builder/azure/dtl/step_capture_image.go b/builder/azure/dtl/step_capture_image.go index 6e0f84fb3..da01d2f3e 100644 --- a/builder/azure/dtl/step_capture_image.go +++ b/builder/azure/dtl/step_capture_image.go @@ -7,8 +7,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCaptureImage struct { @@ -20,7 +20,7 @@ type StepCaptureImage struct { error func(e error) } -func NewStepCaptureImage(client *AzureClient, ui packer.Ui, config *Config) *StepCaptureImage { +func NewStepCaptureImage(client *AzureClient, ui packersdk.Ui, config *Config) *StepCaptureImage { var step = &StepCaptureImage{ client: client, get: func(client *AzureClient) *CaptureTemplate { diff --git a/builder/azure/dtl/step_delete_virtual_machine.go b/builder/azure/dtl/step_delete_virtual_machine.go index d85d18407..d0d6f3a66 100644 --- a/builder/azure/dtl/step_delete_virtual_machine.go +++ b/builder/azure/dtl/step_delete_virtual_machine.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDeleteVirtualMachine struct { @@ -17,7 +17,7 @@ type StepDeleteVirtualMachine struct { error func(e error) } -func NewStepDeleteVirtualMachine(client *AzureClient, ui packer.Ui, config *Config) *StepDeleteVirtualMachine { +func NewStepDeleteVirtualMachine(client *AzureClient, ui packersdk.Ui, config *Config) *StepDeleteVirtualMachine { var step = &StepDeleteVirtualMachine{ client: client, config: config, diff --git a/builder/azure/dtl/step_deploy_template.go b/builder/azure/dtl/step_deploy_template.go index cae494bd6..9c1b3ae58 100644 --- a/builder/azure/dtl/step_deploy_template.go +++ b/builder/azure/dtl/step_deploy_template.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDeployTemplate struct { @@ -25,7 +25,7 @@ type StepDeployTemplate struct { name string } -func NewStepDeployTemplate(client *AzureClient, ui packer.Ui, config *Config, deploymentName string, factory templateFactoryFuncDtl) *StepDeployTemplate { +func NewStepDeployTemplate(client *AzureClient, ui packersdk.Ui, config *Config, deploymentName string, factory templateFactoryFuncDtl) *StepDeployTemplate { var step = &StepDeployTemplate{ client: client, say: func(message string) { ui.Say(message) }, diff --git a/builder/azure/dtl/step_power_off_compute.go b/builder/azure/dtl/step_power_off_compute.go index 2bc224c34..3504149f2 100644 --- a/builder/azure/dtl/step_power_off_compute.go +++ b/builder/azure/dtl/step_power_off_compute.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepPowerOffCompute struct { @@ -17,7 +17,7 @@ type StepPowerOffCompute struct { error func(e error) } -func NewStepPowerOffCompute(client *AzureClient, ui packer.Ui, config *Config) *StepPowerOffCompute { +func NewStepPowerOffCompute(client *AzureClient, ui packersdk.Ui, config *Config) *StepPowerOffCompute { var step = &StepPowerOffCompute{ client: client, diff --git a/builder/azure/dtl/step_publish_to_shared_image_gallery.go b/builder/azure/dtl/step_publish_to_shared_image_gallery.go index e4c6d8231..3fa62523d 100644 --- a/builder/azure/dtl/step_publish_to_shared_image_gallery.go +++ b/builder/azure/dtl/step_publish_to_shared_image_gallery.go @@ -6,8 +6,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepPublishToSharedImageGallery struct { @@ -18,7 +18,7 @@ type StepPublishToSharedImageGallery struct { toSIG func() bool } -func NewStepPublishToSharedImageGallery(client *AzureClient, ui packer.Ui, config *Config) *StepPublishToSharedImageGallery { +func NewStepPublishToSharedImageGallery(client *AzureClient, ui packersdk.Ui, config *Config) *StepPublishToSharedImageGallery { var step = &StepPublishToSharedImageGallery{ client: client, say: func(message string) { diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index 9dde567e3..302323da3 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -18,7 +19,7 @@ const BuilderId = "packer.cloudstack" type Builder struct { config Config runner multistep.Runner - ui packer.Ui + ui packersdk.Ui } func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() } @@ -33,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run implements the packer.Builder interface. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { b.ui = ui // Create a CloudStack API client. diff --git a/builder/cloudstack/step_configure_networking.go b/builder/cloudstack/step_configure_networking.go index 7de5a0a35..44ea28bdf 100644 --- a/builder/cloudstack/step_configure_networking.go +++ b/builder/cloudstack/step_configure_networking.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -20,7 +20,7 @@ type stepSetupNetworking struct { func (s *stepSetupNetworking) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Setup networking...") @@ -188,7 +188,7 @@ func (s *stepSetupNetworking) Run(ctx context.Context, state multistep.StateBag) // Cleanup any resources that may have been created during the Run phase. func (s *stepSetupNetworking) Cleanup(state multistep.StateBag) { client := state.Get("client").(*cloudstack.CloudStackClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cleanup networking...") diff --git a/builder/cloudstack/step_create_instance.go b/builder/cloudstack/step_create_instance.go index 682f0659b..0636b5723 100644 --- a/builder/cloudstack/step_create_instance.go +++ b/builder/cloudstack/step_create_instance.go @@ -8,8 +8,8 @@ import ( "net" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -30,7 +30,7 @@ type stepCreateInstance struct { func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating instance...") @@ -169,7 +169,7 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) func (s *stepCreateInstance) Cleanup(state multistep.StateBag) { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceID, ok := state.Get("instance_id").(string) if !ok || instanceID == "" { diff --git a/builder/cloudstack/step_create_security_group.go b/builder/cloudstack/step_create_security_group.go index e479d0558..25772e178 100644 --- a/builder/cloudstack/step_create_security_group.go +++ b/builder/cloudstack/step_create_security_group.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -17,7 +17,7 @@ type stepCreateSecurityGroup struct { func (s *stepCreateSecurityGroup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(config.SecurityGroups) > 0 { state.Put("security_groups", config.SecurityGroups) @@ -75,7 +75,7 @@ func (s *stepCreateSecurityGroup) Run(ctx context.Context, state multistep.State func (s *stepCreateSecurityGroup) Cleanup(state multistep.StateBag) { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.tempSG == "" { return diff --git a/builder/cloudstack/step_create_template.go b/builder/cloudstack/step_create_template.go index f3f0ad03f..1ed8e7420 100644 --- a/builder/cloudstack/step_create_template.go +++ b/builder/cloudstack/step_create_template.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -15,7 +15,7 @@ type stepCreateTemplate struct{} func (s *stepCreateTemplate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Creating template: %s", config.TemplateName)) diff --git a/builder/cloudstack/step_detach_iso.go b/builder/cloudstack/step_detach_iso.go index 9e0a17d7c..2e6028ba4 100644 --- a/builder/cloudstack/step_detach_iso.go +++ b/builder/cloudstack/step_detach_iso.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -14,7 +14,7 @@ type stepDetachIso struct{} // Detaches currently ISO file attached to a virtual machine if any. func (s *stepDetachIso) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) // Check if state uses iso file and has need to eject it diff --git a/builder/cloudstack/step_keypair.go b/builder/cloudstack/step_keypair.go index 41761c976..6e0935416 100644 --- a/builder/cloudstack/step_keypair.go +++ b/builder/cloudstack/step_keypair.go @@ -7,8 +7,8 @@ import ( "runtime" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -19,7 +19,7 @@ type stepKeypair struct { } func (s *stepKeypair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key") @@ -119,7 +119,7 @@ func (s *stepKeypair) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*cloudstack.CloudStackClient) cfg := state.Get("config").(*Config) diff --git a/builder/cloudstack/step_prepare_config.go b/builder/cloudstack/step_prepare_config.go index f7cbcd637..5b40e7bb7 100644 --- a/builder/cloudstack/step_prepare_config.go +++ b/builder/cloudstack/step_prepare_config.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -16,7 +17,7 @@ type stepPrepareConfig struct{} func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Preparing config...") diff --git a/builder/cloudstack/step_shutdown_instance.go b/builder/cloudstack/step_shutdown_instance.go index c14a41f82..c96b51bf2 100644 --- a/builder/cloudstack/step_shutdown_instance.go +++ b/builder/cloudstack/step_shutdown_instance.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -14,7 +14,7 @@ type stepShutdownInstance struct{} func (s *stepShutdownInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Shutting down instance...") diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index 76cf9fbc3..f812ca39b 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/oauth2" ) @@ -37,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { client := godo.NewClient(oauth2.NewClient(context.TODO(), &apiTokenSource{ AccessToken: b.config.APIToken, })) diff --git a/builder/digitalocean/step_create_droplet.go b/builder/digitalocean/step_create_droplet.go index e24a4de46..8a83caaeb 100644 --- a/builder/digitalocean/step_create_droplet.go +++ b/builder/digitalocean/step_create_droplet.go @@ -9,8 +9,8 @@ import ( "io/ioutil" "github.com/digitalocean/godo" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateDroplet struct { @@ -19,7 +19,7 @@ type stepCreateDroplet struct { func (s *stepCreateDroplet) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) sshKeyId := state.Get("ssh_key_id").(int) @@ -84,7 +84,7 @@ func (s *stepCreateDroplet) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*godo.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Destroy the droplet we just created ui.Say("Destroying droplet...") diff --git a/builder/digitalocean/step_create_ssh_key.go b/builder/digitalocean/step_create_ssh_key.go index 36eaf0ed3..911d28484 100644 --- a/builder/digitalocean/step_create_ssh_key.go +++ b/builder/digitalocean/step_create_ssh_key.go @@ -12,8 +12,8 @@ import ( "runtime" "github.com/digitalocean/godo" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" "golang.org/x/crypto/ssh" ) @@ -27,7 +27,7 @@ type stepCreateSSHKey struct { func (s *stepCreateSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) ui.Say("Creating temporary ssh key for droplet...") @@ -114,7 +114,7 @@ func (s *stepCreateSSHKey) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*godo.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting temporary ssh key...") _, err := client.Keys.DeleteByID(context.TODO(), s.keyId) diff --git a/builder/digitalocean/step_droplet_info.go b/builder/digitalocean/step_droplet_info.go index 44e5f5e4e..9ca1fd65b 100644 --- a/builder/digitalocean/step_droplet_info.go +++ b/builder/digitalocean/step_droplet_info.go @@ -5,15 +5,15 @@ import ( "fmt" "github.com/digitalocean/godo" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepDropletInfo struct{} func (s *stepDropletInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) dropletID := state.Get("droplet_id").(int) diff --git a/builder/digitalocean/step_power_off.go b/builder/digitalocean/step_power_off.go index f75fe898b..d72ba4bda 100644 --- a/builder/digitalocean/step_power_off.go +++ b/builder/digitalocean/step_power_off.go @@ -6,8 +6,8 @@ import ( "log" "github.com/digitalocean/godo" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepPowerOff struct{} @@ -15,7 +15,7 @@ type stepPowerOff struct{} func (s *stepPowerOff) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) dropletId := state.Get("droplet_id").(int) droplet, _, err := client.Droplets.Get(context.TODO(), dropletId) diff --git a/builder/digitalocean/step_shutdown.go b/builder/digitalocean/step_shutdown.go index 8076ad539..a49524eed 100644 --- a/builder/digitalocean/step_shutdown.go +++ b/builder/digitalocean/step_shutdown.go @@ -7,8 +7,8 @@ import ( "time" "github.com/digitalocean/godo" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepShutdown struct{} @@ -16,7 +16,7 @@ type stepShutdown struct{} func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) dropletId := state.Get("droplet_id").(int) // Gracefully power off the droplet. We have to retry this a number diff --git a/builder/digitalocean/step_snapshot.go b/builder/digitalocean/step_snapshot.go index b28a5e38c..c87be05e5 100644 --- a/builder/digitalocean/step_snapshot.go +++ b/builder/digitalocean/step_snapshot.go @@ -8,8 +8,8 @@ import ( "time" "github.com/digitalocean/godo" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepSnapshot struct { @@ -18,7 +18,7 @@ type stepSnapshot struct { func (s *stepSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) dropletId := state.Get("droplet_id").(int) var snapshotRegions []string diff --git a/builder/docker/builder.go b/builder/docker/builder.go index 87b29680e..d4f8569c2 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" ) @@ -35,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { }, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { driver := &DockerDriver{Ctx: &b.config.ctx, Ui: ui} if err := driver.Verify(); err != nil { return nil, err diff --git a/builder/docker/driver_docker.go b/builder/docker/driver_docker.go index 81058a754..3d1cb7d11 100644 --- a/builder/docker/driver_docker.go +++ b/builder/docker/driver_docker.go @@ -12,12 +12,12 @@ import ( "sync" "github.com/hashicorp/go-version" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) type DockerDriver struct { - Ui packer.Ui + Ui packersdk.Ui Ctx *interpolate.Context l sync.Mutex diff --git a/builder/docker/exec.go b/builder/docker/exec.go index 309fdcc5d..1b5375c12 100644 --- a/builder/docker/exec.go +++ b/builder/docker/exec.go @@ -3,11 +3,11 @@ package docker import ( "os/exec" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shell-local/localexec" ) -func runAndStream(cmd *exec.Cmd, ui packer.Ui) error { +func runAndStream(cmd *exec.Cmd, ui packersdk.Ui) error { args := make([]string, len(cmd.Args)-1) copy(args, cmd.Args[1:]) diff --git a/builder/docker/step_commit.go b/builder/docker/step_commit.go index ca5948336..8ef4012b6 100644 --- a/builder/docker/step_commit.go +++ b/builder/docker/step_commit.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCommit commits the container to a image. @@ -14,7 +14,7 @@ type StepCommit struct { } func (s *StepCommit) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config, ok := state.Get("config").(*Config) if !ok { err := fmt.Errorf("error encountered obtaining docker config") diff --git a/builder/docker/step_export.go b/builder/docker/step_export.go index 107761ce8..9bdbe1ba3 100644 --- a/builder/docker/step_export.go +++ b/builder/docker/step_export.go @@ -6,15 +6,15 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepExport exports the container to a flat tar file. type StepExport struct{} func (s *StepExport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config, ok := state.Get("config").(*Config) if !ok { err := fmt.Errorf("error encountered obtaining docker config") diff --git a/builder/docker/step_pull.go b/builder/docker/step_pull.go index b18d01444..b13e94489 100644 --- a/builder/docker/step_pull.go +++ b/builder/docker/step_pull.go @@ -5,14 +5,14 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepPull struct{} func (s *StepPull) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config, ok := state.Get("config").(*Config) if !ok { err := fmt.Errorf("error encountered obtaining docker config") diff --git a/builder/docker/step_run.go b/builder/docker/step_run.go index ce9c46a40..00bfd212f 100644 --- a/builder/docker/step_run.go +++ b/builder/docker/step_run.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRun struct { @@ -13,7 +13,7 @@ type StepRun struct { } func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config, ok := state.Get("config").(*Config) if !ok { err := fmt.Errorf("error encountered obtaining docker config") @@ -66,7 +66,7 @@ func (s *StepRun) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Kill the container. We don't handle errors because errors usually // just mean that the container doesn't exist anymore, which isn't a diff --git a/builder/docker/step_temp_dir.go b/builder/docker/step_temp_dir.go index 9879939d7..3f7e44739 100644 --- a/builder/docker/step_temp_dir.go +++ b/builder/docker/step_temp_dir.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepTempDir creates a temporary directory that we use in order to @@ -55,7 +56,7 @@ func ConfigTmpDir() (string, error) { } func (s *StepTempDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating a temporary directory for sharing data...") diff --git a/builder/file/builder.go b/builder/file/builder.go index f2a8d2969..5b096ce0a 100644 --- a/builder/file/builder.go +++ b/builder/file/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const BuilderId = "packer.file" @@ -37,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run is where the actual build should take place. It takes a Build and a Ui. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { artifact := new(FileArtifact) // Create all directories leading to target diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index f3b73d0ef..e1fe4184c 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // The unique ID for this builder. @@ -35,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a googlecompute Packer build and returns a packer.Artifact // representing a GCE machine image. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { cfg := GCEDriverConfig{ Ui: ui, ProjectId: b.config.ProjectId, diff --git a/builder/googlecompute/driver_gce.go b/builder/googlecompute/driver_gce.go index 5ade084c2..a00f4fe77 100644 --- a/builder/googlecompute/driver_gce.go +++ b/builder/googlecompute/driver_gce.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/builder/googlecompute/version" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/useragent" vaultapi "github.com/hashicorp/vault/api" @@ -33,11 +34,11 @@ type driverGCE struct { projectId string service *compute.Service osLoginService *oslogin.Service - ui packer.Ui + ui packersdk.Ui } type GCEDriverConfig struct { - Ui packer.Ui + Ui packersdk.Ui ProjectId string Account *ServiceAccount ImpersonateServiceAccountName string diff --git a/builder/googlecompute/step_check_existing_image.go b/builder/googlecompute/step_check_existing_image.go index faabae456..a57461dda 100644 --- a/builder/googlecompute/step_check_existing_image.go +++ b/builder/googlecompute/step_check_existing_image.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCheckExistingImage represents a Packer build step that checks if the @@ -16,7 +16,7 @@ type StepCheckExistingImage int func (s *StepCheckExistingImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) d := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Checking image does not exist...") c.imageAlreadyExists = d.ImageExists(c.ImageName) diff --git a/builder/googlecompute/step_create_image.go b/builder/googlecompute/step_create_image.go index 0c37d6acf..2c28c3a50 100644 --- a/builder/googlecompute/step_create_image.go +++ b/builder/googlecompute/step_create_image.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCreateImage represents a Packer build step that creates GCE machine @@ -21,7 +21,7 @@ type StepCreateImage int func (s *StepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if config.SkipCreateImage { ui.Say("Skipping image creation...") diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index 371fee64a..cc71687bc 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCreateInstance represents a Packer build step that creates GCE instances. @@ -104,7 +105,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) c := state.Get("config").(*Config) d := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) sourceImage, err := getImage(c, d) if err != nil { @@ -215,7 +216,7 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting instance...") errCh, err := driver.DeleteInstance(config.Zone, name) diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index d86116091..54d6f75e5 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCreateWindowsPassword represents a Packer build step that sets the windows password on a Windows GCE instance. @@ -25,7 +26,7 @@ type StepCreateWindowsPassword struct { // Run executes the Packer build step that sets the windows password on a Windows GCE instance. func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) d := state.Get("driver").(Driver) c := state.Get("config").(*Config) name := state.Get("instance_name").(string) diff --git a/builder/googlecompute/step_import_os_login_ssh_key.go b/builder/googlecompute/step_import_os_login_ssh_key.go index 833e73fb0..576aab376 100644 --- a/builder/googlecompute/step_import_os_login_ssh_key.go +++ b/builder/googlecompute/step_import_os_login_ssh_key.go @@ -6,8 +6,8 @@ import ( "encoding/hex" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "google.golang.org/api/oauth2/v2" ) @@ -23,7 +23,7 @@ type StepImportOSLoginSSHKey struct { func (s *StepImportOSLoginSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !config.UseOSLogin { return multistep.ActionContinue @@ -100,7 +100,7 @@ func (s *StepImportOSLoginSSHKey) Run(ctx context.Context, state multistep.State func (s *StepImportOSLoginSSHKey) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !config.UseOSLogin { return diff --git a/builder/googlecompute/step_instance_info.go b/builder/googlecompute/step_instance_info.go index cd388df9f..471c37274 100644 --- a/builder/googlecompute/step_instance_info.go +++ b/builder/googlecompute/step_instance_info.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepInstanceInfo represents a Packer build step that gathers GCE instance info. @@ -20,7 +20,7 @@ type StepInstanceInfo struct { func (s *StepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceName := state.Get("instance_name").(string) diff --git a/builder/googlecompute/step_start_tunnel.go b/builder/googlecompute/step_start_tunnel.go index bda9e8d32..2c6d02ddd 100644 --- a/builder/googlecompute/step_start_tunnel.go +++ b/builder/googlecompute/step_start_tunnel.go @@ -19,9 +19,9 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -257,7 +257,7 @@ func (s *StepStartTunnel) Run(ctx context.Context, state multistep.StateBag) mul } // shell out to create the tunnel. - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceName := state.Get("instance_name").(string) c := state.Get("config").(*Config) diff --git a/builder/googlecompute/step_teardown_instance.go b/builder/googlecompute/step_teardown_instance.go index b545634f4..93b0e3aff 100644 --- a/builder/googlecompute/step_teardown_instance.go +++ b/builder/googlecompute/step_teardown_instance.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepTeardownInstance represents a Packer build step that tears down GCE @@ -20,7 +20,7 @@ type StepTeardownInstance struct { func (s *StepTeardownInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.InstanceName if name == "" { @@ -57,7 +57,7 @@ func (s *StepTeardownInstance) Run(ctx context.Context, state multistep.StateBag func (s *StepTeardownInstance) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting disk...") errCh, err := driver.DeleteDisk(config.Zone, config.DiskName) diff --git a/builder/googlecompute/step_wait_startup_script.go b/builder/googlecompute/step_wait_startup_script.go index 25c64988b..8723f0690 100644 --- a/builder/googlecompute/step_wait_startup_script.go +++ b/builder/googlecompute/step_wait_startup_script.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -18,7 +18,7 @@ type StepWaitStartupScript int func (s *StepWaitStartupScript) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceName := state.Get("instance_name").(string) if config.WrapStartupScriptFile.False() { diff --git a/builder/hcloud/builder.go b/builder/hcloud/builder.go index f46b62c33..daf135e57 100644 --- a/builder/hcloud/builder.go +++ b/builder/hcloud/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hetznercloud/hcloud-go/hcloud" ) @@ -34,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { opts := []hcloud.ClientOption{ hcloud.WithToken(b.config.HCloudToken), hcloud.WithEndpoint(b.config.Endpoint), diff --git a/builder/hcloud/step_create_server.go b/builder/hcloud/step_create_server.go index 05d84407a..c5936ed78 100644 --- a/builder/hcloud/step_create_server.go +++ b/builder/hcloud/step_create_server.go @@ -7,8 +7,8 @@ import ( "sort" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hetznercloud/hcloud-go/hcloud" ) @@ -18,7 +18,7 @@ type stepCreateServer struct { func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("hcloudClient").(*hcloud.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) sshKeyId := state.Get("ssh_key_id").(int) @@ -144,7 +144,7 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) { } client := state.Get("hcloudClient").(*hcloud.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Destroy the server we just created ui.Say("Destroying server...") diff --git a/builder/hcloud/step_create_snapshot.go b/builder/hcloud/step_create_snapshot.go index 26550d66e..9764b76d8 100644 --- a/builder/hcloud/step_create_snapshot.go +++ b/builder/hcloud/step_create_snapshot.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hetznercloud/hcloud-go/hcloud" ) @@ -13,7 +13,7 @@ type stepCreateSnapshot struct{} func (s *stepCreateSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("hcloudClient").(*hcloud.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) serverID := state.Get("server_id").(int) diff --git a/builder/hcloud/step_create_sshkey.go b/builder/hcloud/step_create_sshkey.go index fa6a05e68..9f2a666a8 100644 --- a/builder/hcloud/step_create_sshkey.go +++ b/builder/hcloud/step_create_sshkey.go @@ -11,8 +11,8 @@ import ( "os" "runtime" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" "github.com/hetznercloud/hcloud-go/hcloud" "golang.org/x/crypto/ssh" @@ -27,7 +27,7 @@ type stepCreateSSHKey struct { func (s *stepCreateSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("hcloudClient").(*hcloud.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) ui.Say("Creating temporary ssh key for server...") @@ -115,7 +115,7 @@ func (s *stepCreateSSHKey) Cleanup(state multistep.StateBag) { } client := state.Get("hcloudClient").(*hcloud.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting temporary ssh key...") _, err := client.SSHKey.Delete(context.TODO(), &hcloud.SSHKey{ID: s.keyId}) diff --git a/builder/hcloud/step_shutdown_server.go b/builder/hcloud/step_shutdown_server.go index 25cba2de8..20a390e4a 100644 --- a/builder/hcloud/step_shutdown_server.go +++ b/builder/hcloud/step_shutdown_server.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hetznercloud/hcloud-go/hcloud" ) @@ -13,7 +13,7 @@ type stepShutdownServer struct{} func (s *stepShutdownServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("hcloudClient").(*hcloud.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) serverID := state.Get("server_id").(int) ui.Say("Shutting down server...") diff --git a/builder/hyperone/builder.go b/builder/hyperone/builder.go index d1cb42047..cb1653138 100644 --- a/builder/hyperone/builder.go +++ b/builder/hyperone/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" openapi "github.com/hyperonecom/h1-client-go" ) @@ -51,7 +52,7 @@ type wrappedCommandTemplate struct { Command string } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { wrappedCommand := func(command string) (string, error) { ictx := b.config.ctx ictx.Data = &wrappedCommandTemplate{Command: command} diff --git a/builder/hyperone/step_copy_files.go b/builder/hyperone/step_copy_files.go index 7eade9313..5d952c1b3 100644 --- a/builder/hyperone/step_copy_files.go +++ b/builder/hyperone/step_copy_files.go @@ -6,15 +6,15 @@ import ( "log" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCopyFiles struct{} func (s *stepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(config.ChrootCopyFiles) == 0 { return multistep.ActionContinue diff --git a/builder/hyperone/step_create_image.go b/builder/hyperone/step_create_image.go index 9b12e3a53..06599085e 100644 --- a/builder/hyperone/step_create_image.go +++ b/builder/hyperone/step_create_image.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" openapi "github.com/hyperonecom/h1-client-go" ) @@ -15,7 +15,7 @@ type stepCreateImage struct { func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*openapi.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) vmID := state.Get("vm_id").(string) @@ -55,7 +55,7 @@ func (s *stepCreateImage) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*openapi.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, err := client.ImageApi.ImageDelete(context.TODO(), s.imageID) if err != nil { diff --git a/builder/hyperone/step_create_ssh_key.go b/builder/hyperone/step_create_ssh_key.go index 1180ae61f..fb0f629c5 100644 --- a/builder/hyperone/step_create_ssh_key.go +++ b/builder/hyperone/step_create_ssh_key.go @@ -10,8 +10,8 @@ import ( "os" "runtime" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -21,7 +21,7 @@ type stepCreateSSHKey struct { } func (s *stepCreateSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) ui.Say("Creating a temporary ssh key for the VM...") diff --git a/builder/hyperone/step_create_vm.go b/builder/hyperone/step_create_vm.go index 05b4b340b..daa61b90e 100644 --- a/builder/hyperone/step_create_vm.go +++ b/builder/hyperone/step_create_vm.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" openapi "github.com/hyperonecom/h1-client-go" ) @@ -20,7 +20,7 @@ const ( func (s *stepCreateVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*openapi.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) sshKey := state.Get("ssh_public_key").(string) @@ -173,7 +173,7 @@ func (s *stepCreateVM) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Deleting VM %s...", s.vmID)) err := deleteVMWithDisks(s.vmID, state) diff --git a/builder/hyperone/step_create_vm_from_disk.go b/builder/hyperone/step_create_vm_from_disk.go index 39969e780..f0775e3b7 100644 --- a/builder/hyperone/step_create_vm_from_disk.go +++ b/builder/hyperone/step_create_vm_from_disk.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" openapi "github.com/hyperonecom/h1-client-go" ) @@ -15,7 +15,7 @@ type stepCreateVMFromDisk struct { func (s *stepCreateVMFromDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*openapi.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) sshKey := state.Get("ssh_public_key").(string) chrootDiskID := state.Get("chroot_disk_id").(string) @@ -53,7 +53,7 @@ func (s *stepCreateVMFromDisk) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Deleting VM %s (from chroot disk)...", s.vmID)) err := deleteVMWithDisks(s.vmID, state) diff --git a/builder/hyperone/step_detach_disk.go b/builder/hyperone/step_detach_disk.go index d258cabb2..63c6cb2d2 100644 --- a/builder/hyperone/step_detach_disk.go +++ b/builder/hyperone/step_detach_disk.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" openapi "github.com/hyperonecom/h1-client-go" ) @@ -15,7 +15,7 @@ type stepDetachDisk struct { func (s *stepDetachDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*openapi.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmID := state.Get("vm_id").(string) chrootDiskID := state.Get("chroot_disk_id").(string) diff --git a/builder/hyperone/step_mount_chroot.go b/builder/hyperone/step_mount_chroot.go index c4b5dd0d6..e2647c1de 100644 --- a/builder/hyperone/step_mount_chroot.go +++ b/builder/hyperone/step_mount_chroot.go @@ -6,15 +6,15 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepMountChroot struct{} func (s *stepMountChroot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := state.Get("device").(string) log.Printf("Mount path: %s", config.ChrootMountPath) diff --git a/builder/hyperone/step_mount_extra.go b/builder/hyperone/step_mount_extra.go index 318803746..5d51904d5 100644 --- a/builder/hyperone/step_mount_extra.go +++ b/builder/hyperone/step_mount_extra.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepMountExtra struct{} @@ -13,7 +13,7 @@ type stepMountExtra struct{} func (s *stepMountExtra) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Mounting additional paths within the chroot...") for _, mountInfo := range config.ChrootMounts { diff --git a/builder/hyperone/step_post_mount_commands.go b/builder/hyperone/step_post_mount_commands.go index 7d943f34a..2ab56f186 100644 --- a/builder/hyperone/step_post_mount_commands.go +++ b/builder/hyperone/step_post_mount_commands.go @@ -3,8 +3,8 @@ package hyperone import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type postMountCommandsData struct { @@ -16,7 +16,7 @@ type stepPostMountCommands struct{} func (s *stepPostMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := state.Get("device").(string) ictx := config.ctx diff --git a/builder/hyperone/step_pre_mount_commands.go b/builder/hyperone/step_pre_mount_commands.go index b96551af2..fbbb0db4e 100644 --- a/builder/hyperone/step_pre_mount_commands.go +++ b/builder/hyperone/step_pre_mount_commands.go @@ -3,8 +3,8 @@ package hyperone import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type preMountCommandsData struct { @@ -16,7 +16,7 @@ type stepPreMountCommands struct{} func (s *stepPreMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := state.Get("device").(string) ictx := config.ctx diff --git a/builder/hyperone/step_prepare_device.go b/builder/hyperone/step_prepare_device.go index a4474fe3a..a8b1a052e 100644 --- a/builder/hyperone/step_prepare_device.go +++ b/builder/hyperone/step_prepare_device.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const ( @@ -16,7 +16,7 @@ const ( type stepPrepareDevice struct{} func (s *stepPrepareDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.ChrootDevice != "" { diff --git a/builder/hyperone/step_stop_vm.go b/builder/hyperone/step_stop_vm.go index 4189cf15b..a736356f1 100644 --- a/builder/hyperone/step_stop_vm.go +++ b/builder/hyperone/step_stop_vm.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" openapi "github.com/hyperonecom/h1-client-go" ) @@ -13,7 +13,7 @@ type stepStopVM struct{} func (s *stepStopVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*openapi.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmID := state.Get("vm_id").(string) ui.Say("Stopping VM...") diff --git a/builder/hyperone/utils.go b/builder/hyperone/utils.go index 8d83d26c0..a2526e1cd 100644 --- a/builder/hyperone/utils.go +++ b/builder/hyperone/utils.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" openapi "github.com/hyperonecom/h1-client-go" ) @@ -24,7 +25,7 @@ func formatOpenAPIError(err error) string { func runCommands(commands []string, ictx interpolate.Context, state multistep.StateBag) error { ctx := context.TODO() - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) comm := state.Get("communicator").(packer.Communicator) diff --git a/builder/hyperv/common/step_clone_vm.go b/builder/hyperv/common/step_clone_vm.go index a6a101e4f..397f075b5 100644 --- a/builder/hyperv/common/step_clone_vm.go +++ b/builder/hyperv/common/step_clone_vm.go @@ -7,8 +7,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step clones an existing virtual machine. @@ -38,7 +38,7 @@ type StepCloneVM struct { func (s *StepCloneVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cloning virtual machine...") path := state.Get("build_dir").(string) @@ -167,7 +167,7 @@ func (s *StepCloneVM) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.KeepRegistered { ui.Say("keep_registered set. Skipping unregister/deletion of VM.") diff --git a/builder/hyperv/common/step_collate_artifacts.go b/builder/hyperv/common/step_collate_artifacts.go index 7f0561e90..597d26c4f 100644 --- a/builder/hyperv/common/step_collate_artifacts.go +++ b/builder/hyperv/common/step_collate_artifacts.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCollateArtifacts struct { @@ -17,7 +17,7 @@ type StepCollateArtifacts struct { // specified output directory func (s *StepCollateArtifacts) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Collating build artifacts...") diff --git a/builder/hyperv/common/step_compact_disk.go b/builder/hyperv/common/step_compact_disk.go index 75f174d22..d374f102f 100644 --- a/builder/hyperv/common/step_compact_disk.go +++ b/builder/hyperv/common/step_compact_disk.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCompactDisk struct { @@ -15,7 +15,7 @@ type StepCompactDisk struct { // Run runs a compaction/optimisation process on attached VHD/VHDX disks func (s *StepCompactDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.SkipCompaction { ui.Say("Skipping disk compaction...") diff --git a/builder/hyperv/common/step_configure_ip.go b/builder/hyperv/common/step_configure_ip.go index 70682a6df..617c20587 100644 --- a/builder/hyperv/common/step_configure_ip.go +++ b/builder/hyperv/common/step_configure_ip.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepConfigureIp struct { @@ -16,7 +16,7 @@ type StepConfigureIp struct { func (s *StepConfigureIp) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error configuring ip address: %s" vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_configure_vlan.go b/builder/hyperv/common/step_configure_vlan.go index 810c200c2..146df7f23 100644 --- a/builder/hyperv/common/step_configure_vlan.go +++ b/builder/hyperv/common/step_configure_vlan.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepConfigureVlan struct { @@ -15,7 +15,7 @@ type StepConfigureVlan struct { func (s *StepConfigureVlan) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error configuring vlan: %s" vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_create_build_dir.go b/builder/hyperv/common/step_create_build_dir.go index d66257bac..707db2124 100644 --- a/builder/hyperv/common/step_create_build_dir.go +++ b/builder/hyperv/common/step_create_build_dir.go @@ -7,8 +7,8 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -26,7 +26,7 @@ type StepCreateBuildDir struct { // Creates the main directory used to house the VMs files and folders // during the build func (s *StepCreateBuildDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating build directory...") @@ -58,7 +58,7 @@ func (s *StepCreateBuildDir) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting build directory...") err := os.RemoveAll(s.buildDir) diff --git a/builder/hyperv/common/step_create_external_switch.go b/builder/hyperv/common/step_create_external_switch.go index ec8d41339..a372238ff 100644 --- a/builder/hyperv/common/step_create_external_switch.go +++ b/builder/hyperv/common/step_create_external_switch.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -23,7 +23,7 @@ type StepCreateExternalSwitch struct { // build VM to connect to the outside world. func (s *StepCreateExternalSwitch) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) errorMsg := "Error creating external switch: %s" @@ -79,7 +79,7 @@ func (s *StepCreateExternalSwitch) Cleanup(state multistep.StateBag) { return } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Unregistering and deleting external switch...") diff --git a/builder/hyperv/common/step_create_switch.go b/builder/hyperv/common/step_create_switch.go index 2e46036cd..48d420498 100644 --- a/builder/hyperv/common/step_create_switch.go +++ b/builder/hyperv/common/step_create_switch.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const ( @@ -35,7 +35,7 @@ type StepCreateSwitch struct { func (s *StepCreateSwitch) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.SwitchType) == 0 { s.SwitchType = DefaultSwitchType @@ -70,7 +70,7 @@ func (s *StepCreateSwitch) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Unregistering and deleting switch...") err := driver.DeleteVirtualSwitch(s.SwitchName) diff --git a/builder/hyperv/common/step_create_vm.go b/builder/hyperv/common/step_create_vm.go index 1b5e22c73..7b9375aa2 100644 --- a/builder/hyperv/common/step_create_vm.go +++ b/builder/hyperv/common/step_create_vm.go @@ -7,8 +7,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates the actual virtual machine. @@ -40,7 +40,7 @@ type StepCreateVM struct { func (s *StepCreateVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating virtual machine...") var path string @@ -179,7 +179,7 @@ func (s *StepCreateVM) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.KeepRegistered { ui.Say("keep_registered set. Skipping unregister/deletion of VM.") diff --git a/builder/hyperv/common/step_disable_vlan.go b/builder/hyperv/common/step_disable_vlan.go index f2caf89a4..b73922caa 100644 --- a/builder/hyperv/common/step_disable_vlan.go +++ b/builder/hyperv/common/step_disable_vlan.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDisableVlan struct { @@ -13,7 +13,7 @@ type StepDisableVlan struct { func (s *StepDisableVlan) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error disabling vlan: %s" vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_enable_integration_service.go b/builder/hyperv/common/step_enable_integration_service.go index 4a1a3a7d5..15420c704 100644 --- a/builder/hyperv/common/step_enable_integration_service.go +++ b/builder/hyperv/common/step_enable_integration_service.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepEnableIntegrationService struct { @@ -14,7 +14,7 @@ type StepEnableIntegrationService struct { func (s *StepEnableIntegrationService) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Enabling Integration Service...") vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_export_vm.go b/builder/hyperv/common/step_export_vm.go index f94d4f7e1..0bf3fce48 100644 --- a/builder/hyperv/common/step_export_vm.go +++ b/builder/hyperv/common/step_export_vm.go @@ -5,8 +5,8 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepExportVm struct { @@ -16,7 +16,7 @@ type StepExportVm struct { func (s *StepExportVm) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.SkipExport { ui.Say("Skipping export of virtual machine...") diff --git a/builder/hyperv/common/step_mount_dvddrive.go b/builder/hyperv/common/step_mount_dvddrive.go index 37b10bf8e..95113c2f7 100644 --- a/builder/hyperv/common/step_mount_dvddrive.go +++ b/builder/hyperv/common/step_mount_dvddrive.go @@ -7,8 +7,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepMountDvdDrive struct { @@ -18,7 +18,7 @@ type StepMountDvdDrive struct { func (s *StepMountDvdDrive) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error mounting dvd drive: %s" vmName := state.Get("vmName").(string) @@ -100,7 +100,7 @@ func (s *StepMountDvdDrive) Cleanup(state multistep.StateBag) { dvdController := dvdControllerState.(DvdControllerProperties) driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error unmounting os dvd drive: %s" ui.Say("Clean up os dvd drive...") diff --git a/builder/hyperv/common/step_mount_floppydrive.go b/builder/hyperv/common/step_mount_floppydrive.go index e2cb9e1b1..f26ce933c 100644 --- a/builder/hyperv/common/step_mount_floppydrive.go +++ b/builder/hyperv/common/step_mount_floppydrive.go @@ -8,8 +8,8 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -47,7 +47,7 @@ func (s *StepMountFloppydrive) Run(ctx context.Context, state multistep.StateBag return multistep.ActionHalt } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Mounting floppy drive...") @@ -76,7 +76,7 @@ func (s *StepMountFloppydrive) Cleanup(state multistep.StateBag) { errorMsg := "Error unmounting floppy drive: %s" vmName := state.Get("vmName").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cleanup floppy drive...") diff --git a/builder/hyperv/common/step_mount_guest_additions.go b/builder/hyperv/common/step_mount_guest_additions.go index 4f215220d..2e8ab92c1 100644 --- a/builder/hyperv/common/step_mount_guest_additions.go +++ b/builder/hyperv/common/step_mount_guest_additions.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepMountGuestAdditions struct { @@ -16,7 +16,7 @@ type StepMountGuestAdditions struct { } func (s *StepMountGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.GuestAdditionsMode != "attach" { ui.Say("Skipping mounting Integration Services Setup Disk...") @@ -74,7 +74,7 @@ func (s *StepMountGuestAdditions) Cleanup(state multistep.StateBag) { } dvdController := dvdControllerState.(DvdControllerProperties) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) errorMsg := "Error unmounting Integration Services dvd drive: %s" diff --git a/builder/hyperv/common/step_mount_secondary_dvd_images.go b/builder/hyperv/common/step_mount_secondary_dvd_images.go index fe1921ff8..a52845c25 100644 --- a/builder/hyperv/common/step_mount_secondary_dvd_images.go +++ b/builder/hyperv/common/step_mount_secondary_dvd_images.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepMountSecondaryDvdImages struct { @@ -22,7 +22,7 @@ type DvdControllerProperties struct { func (s *StepMountSecondaryDvdImages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Mounting secondary DVD images...") vmName := state.Get("vmName").(string) @@ -84,7 +84,7 @@ func (s *StepMountSecondaryDvdImages) Cleanup(state multistep.StateBag) { dvdControllers := dvdControllersState.([]DvdControllerProperties) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) errorMsg := "Error unmounting secondary dvd drive: %s" diff --git a/builder/hyperv/common/step_polling_installation.go b/builder/hyperv/common/step_polling_installation.go index a2db5f9cb..2d15ad424 100644 --- a/builder/hyperv/common/step_polling_installation.go +++ b/builder/hyperv/common/step_polling_installation.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const port string = "13000" @@ -19,7 +19,7 @@ type StepPollingInstallation struct { } func (s *StepPollingInstallation) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error polling VM: %s" vmIp := state.Get("ip").(string) diff --git a/builder/hyperv/common/step_reboot_vm.go b/builder/hyperv/common/step_reboot_vm.go index 335f66c1f..85cb697b1 100644 --- a/builder/hyperv/common/step_reboot_vm.go +++ b/builder/hyperv/common/step_reboot_vm.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRebootVm struct { @@ -14,7 +14,7 @@ type StepRebootVm struct { func (s *StepRebootVm) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) errorMsg := "Error rebooting vm: %s" vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_run.go b/builder/hyperv/common/step_run.go index 035aa35bf..b176be2af 100644 --- a/builder/hyperv/common/step_run.go +++ b/builder/hyperv/common/step_run.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRun struct { @@ -18,7 +18,7 @@ type StepRun struct { func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Determine Host IP for HyperV machine...") @@ -62,7 +62,7 @@ func (s *StepRun) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !s.Headless && s.GuiCancelFunc != nil { ui.Say("Disconnecting from vmconnect...") diff --git a/builder/hyperv/common/step_set_boot_order.go b/builder/hyperv/common/step_set_boot_order.go index 7e4b9d3d1..b5b72fb63 100644 --- a/builder/hyperv/common/step_set_boot_order.go +++ b/builder/hyperv/common/step_set_boot_order.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSetBootOrder struct { @@ -14,7 +14,7 @@ type StepSetBootOrder struct { func (s *StepSetBootOrder) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.BootOrder != nil { diff --git a/builder/hyperv/common/step_set_first_boot_device.go b/builder/hyperv/common/step_set_first_boot_device.go index cf3c60fa4..20dbb676f 100644 --- a/builder/hyperv/common/step_set_first_boot_device.go +++ b/builder/hyperv/common/step_set_first_boot_device.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSetFirstBootDevice struct { @@ -103,7 +103,7 @@ func ParseBootDeviceIdentifier(deviceIdentifier string, generation uint) (string func (s *StepSetFirstBootDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.FirstBootDevice != "" { diff --git a/builder/hyperv/common/step_shutdown.go b/builder/hyperv/common/step_shutdown.go index 741c6d815..9a9dfef54 100644 --- a/builder/hyperv/common/step_shutdown.go +++ b/builder/hyperv/common/step_shutdown.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -18,7 +19,7 @@ import ( // Uses: // communicator packer.Communicator // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -32,7 +33,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.Command != "" { diff --git a/builder/hyperv/common/step_sleep.go b/builder/hyperv/common/step_sleep.go index 5420c7f0d..a69f74c50 100644 --- a/builder/hyperv/common/step_sleep.go +++ b/builder/hyperv/common/step_sleep.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSleep struct { @@ -15,7 +15,7 @@ type StepSleep struct { } func (s *StepSleep) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.ActionName) > 0 { ui.Say(s.ActionName + "! Waiting for " + fmt.Sprintf("%v", uint(s.Minutes)) + diff --git a/builder/hyperv/common/step_type_boot_command.go b/builder/hyperv/common/step_type_boot_command.go index 3fbd0871f..c40fdb19b 100644 --- a/builder/hyperv/common/step_type_boot_command.go +++ b/builder/hyperv/common/step_type_boot_command.go @@ -6,9 +6,9 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -29,7 +29,7 @@ type StepTypeBootCommand struct { func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { httpPort := state.Get("http_port").(int) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) hostIp := state.Get("http_ip").(string) diff --git a/builder/hyperv/common/step_unmount_dvddrive.go b/builder/hyperv/common/step_unmount_dvddrive.go index bdd98e30f..b59bc5f20 100644 --- a/builder/hyperv/common/step_unmount_dvddrive.go +++ b/builder/hyperv/common/step_unmount_dvddrive.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepUnmountDvdDrive struct { @@ -14,7 +14,7 @@ type StepUnmountDvdDrive struct { func (s *StepUnmountDvdDrive) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Unmount/delete os dvd drive...") diff --git a/builder/hyperv/common/step_unmount_floppydrive.go b/builder/hyperv/common/step_unmount_floppydrive.go index eccfb5dc4..06bd7aaa5 100644 --- a/builder/hyperv/common/step_unmount_floppydrive.go +++ b/builder/hyperv/common/step_unmount_floppydrive.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepUnmountFloppyDrive struct { @@ -14,7 +14,7 @@ type StepUnmountFloppyDrive struct { func (s *StepUnmountFloppyDrive) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Generation > 1 { return multistep.ActionContinue diff --git a/builder/hyperv/common/step_unmount_guest_additions.go b/builder/hyperv/common/step_unmount_guest_additions.go index 663d64077..12451f2fc 100644 --- a/builder/hyperv/common/step_unmount_guest_additions.go +++ b/builder/hyperv/common/step_unmount_guest_additions.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepUnmountGuestAdditions struct { @@ -14,7 +14,7 @@ type StepUnmountGuestAdditions struct { func (s *StepUnmountGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Unmount/delete Integration Services dvd drive...") diff --git a/builder/hyperv/common/step_unmount_secondary_dvd_images.go b/builder/hyperv/common/step_unmount_secondary_dvd_images.go index c33617fe0..8429de0c4 100644 --- a/builder/hyperv/common/step_unmount_secondary_dvd_images.go +++ b/builder/hyperv/common/step_unmount_secondary_dvd_images.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepUnmountSecondaryDvdImages struct { @@ -13,7 +13,7 @@ type StepUnmountSecondaryDvdImages struct { func (s *StepUnmountSecondaryDvdImages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Unmount/delete secondary dvd drives...") diff --git a/builder/hyperv/common/step_wait_for_install_to_complete.go b/builder/hyperv/common/step_wait_for_install_to_complete.go index da4ac90ba..5c54eac1b 100644 --- a/builder/hyperv/common/step_wait_for_install_to_complete.go +++ b/builder/hyperv/common/step_wait_for_install_to_complete.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const ( @@ -18,7 +18,7 @@ type StepWaitForPowerOff struct { func (s *StepWaitForPowerOff) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Waiting for vm to be powered down...") @@ -52,7 +52,7 @@ type StepWaitForInstallToComplete struct { func (s *StepWaitForInstallToComplete) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if len(s.ActionName) > 0 { diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index b5df8e57c..fb8634df2 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -176,7 +177,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index ad91ec126..74eec6810 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -216,7 +217,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index 8dc291b6f..a19c81049 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -42,7 +43,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("hook", hook) diff --git a/builder/jdcloud/step_config_credentials.go b/builder/jdcloud/step_config_credentials.go index 848f44874..9f036486a 100644 --- a/builder/jdcloud/step_config_credentials.go +++ b/builder/jdcloud/step_config_credentials.go @@ -5,19 +5,19 @@ import ( "fmt" "io/ioutil" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis" ) type stepConfigCredentials struct { InstanceSpecConfig *JDCloudInstanceSpecConfig - ui packer.Ui + ui packersdk.Ui } func (s *stepConfigCredentials) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - s.ui = state.Get("ui").(packer.Ui) + s.ui = state.Get("ui").(packersdk.Ui) password := s.InstanceSpecConfig.Comm.SSHPassword privateKeyPath := s.InstanceSpecConfig.Comm.SSHPrivateKeyFile privateKeyName := s.InstanceSpecConfig.Comm.SSHKeyPairName diff --git a/builder/jdcloud/step_create_image.go b/builder/jdcloud/step_create_image.go index 4e1fde048..315d8f169 100644 --- a/builder/jdcloud/step_create_image.go +++ b/builder/jdcloud/step_create_image.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis" ) @@ -16,7 +16,7 @@ type stepCreateJDCloudImage struct { func (s *stepCreateJDCloudImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating images") req := apis.NewCreateImageRequest(Region, s.InstanceSpecConfig.InstanceId, s.InstanceSpecConfig.ImageName, "") diff --git a/builder/jdcloud/step_create_instance.go b/builder/jdcloud/step_create_instance.go index 745b98085..266b55914 100644 --- a/builder/jdcloud/step_create_instance.go +++ b/builder/jdcloud/step_create_instance.go @@ -6,8 +6,8 @@ import ( "regexp" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/jdcloud-api/jdcloud-sdk-go/core" "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis" vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models" @@ -19,7 +19,7 @@ import ( type stepCreateJDCloudInstance struct { InstanceSpecConfig *JDCloudInstanceSpecConfig CredentialConfig *JDCloudCredentialConfig - ui packer.Ui + ui packersdk.Ui } func (s *stepCreateJDCloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { @@ -27,7 +27,7 @@ func (s *stepCreateJDCloudInstance) Run(_ context.Context, state multistep.State privateKey := s.InstanceSpecConfig.Comm.SSHPrivateKey keyName := s.InstanceSpecConfig.Comm.SSHKeyPairName password := s.InstanceSpecConfig.Comm.SSHPassword - s.ui = state.Get("ui").(packer.Ui) + s.ui = state.Get("ui").(packersdk.Ui) s.ui.Say("Creating instances") instanceSpec := vm.InstanceSpec{ diff --git a/builder/jdcloud/step_stop_instance.go b/builder/jdcloud/step_stop_instance.go index a167b0fc6..99465ff07 100644 --- a/builder/jdcloud/step_stop_instance.go +++ b/builder/jdcloud/step_stop_instance.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis" ) @@ -15,7 +15,7 @@ type stepStopJDCloudInstance struct { func (s *stepStopJDCloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Stopping this instance") req := apis.NewStopInstanceRequest(Region, s.InstanceSpecConfig.InstanceId) diff --git a/builder/jdcloud/step_validate_parameters.go b/builder/jdcloud/step_validate_parameters.go index 708617957..b31fcfbde 100644 --- a/builder/jdcloud/step_validate_parameters.go +++ b/builder/jdcloud/step_validate_parameters.go @@ -4,21 +4,21 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis" vpc "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/apis" ) type stepValidateParameters struct { InstanceSpecConfig *JDCloudInstanceSpecConfig - ui packer.Ui + ui packersdk.Ui state multistep.StateBag } func (s *stepValidateParameters) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - s.ui = state.Get("ui").(packer.Ui) + s.ui = state.Get("ui").(packersdk.Ui) s.state = state s.ui.Say("Validating parameters...") diff --git a/builder/linode/builder.go b/builder/linode/builder.go index 670cc2d35..c1890dff5 100644 --- a/builder/linode/builder.go +++ b/builder/linode/builder.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // The unique ID for this builder. @@ -36,7 +37,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (ret packer.Artifact, err error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (ret packer.Artifact, err error) { ui.Say("Running builder ...") client := newLinodeClient(b.config.PersonalAccessToken) diff --git a/builder/linode/step_create_image.go b/builder/linode/step_create_image.go index 58da16e73..c9839fe38 100644 --- a/builder/linode/step_create_image.go +++ b/builder/linode/step_create_image.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/linode/linodego" ) @@ -15,7 +15,7 @@ type stepCreateImage struct { func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) disk := state.Get("disk").(*linodego.InstanceDisk) instance := state.Get("instance").(*linodego.Instance) diff --git a/builder/linode/step_create_linode.go b/builder/linode/step_create_linode.go index 50db58696..ab67db698 100644 --- a/builder/linode/step_create_linode.go +++ b/builder/linode/step_create_linode.go @@ -5,8 +5,8 @@ import ( "errors" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/linode/linodego" ) @@ -16,7 +16,7 @@ type stepCreateLinode struct { func (s *stepCreateLinode) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating Linode...") @@ -89,7 +89,7 @@ func (s *stepCreateLinode) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.client.DeleteInstance(context.Background(), instance.(*linodego.Instance).ID); err != nil { ui.Error("Error cleaning up Linode: " + err.Error()) diff --git a/builder/linode/step_create_ssh_key.go b/builder/linode/step_create_ssh_key.go index c5f7ad4cb..9c0dde950 100644 --- a/builder/linode/step_create_ssh_key.go +++ b/builder/linode/step_create_ssh_key.go @@ -10,8 +10,8 @@ import ( "io/ioutil" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -24,7 +24,7 @@ type StepCreateSSHKey struct { // Run executes the Packer build step that generates SSH key pairs. // The key pairs are added to the ssh config func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.Comm.SSHPrivateKeyFile != "" { diff --git a/builder/linode/step_shutdown_linode.go b/builder/linode/step_shutdown_linode.go index 82069e19c..0f63f9157 100644 --- a/builder/linode/step_shutdown_linode.go +++ b/builder/linode/step_shutdown_linode.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/linode/linodego" ) @@ -15,7 +15,7 @@ type stepShutdownLinode struct { func (s *stepShutdownLinode) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance := state.Get("instance").(*linodego.Instance) ui.Say("Shutting down Linode...") diff --git a/builder/lxc/builder.go b/builder/lxc/builder.go index 53195c764..64ccfd1f7 100644 --- a/builder/lxc/builder.go +++ b/builder/lxc/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -35,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxc/step_export.go b/builder/lxc/step_export.go index f017f551a..470222e3f 100644 --- a/builder/lxc/step_export.go +++ b/builder/lxc/step_export.go @@ -9,15 +9,15 @@ import ( "os/user" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepExport struct{} func (s *stepExport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.ContainerName diff --git a/builder/lxc/step_lxc_create.go b/builder/lxc/step_lxc_create.go index afcc2da79..aa0a07e3a 100644 --- a/builder/lxc/step_lxc_create.go +++ b/builder/lxc/step_lxc_create.go @@ -7,15 +7,15 @@ import ( "os/user" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepLxcCreate struct{} func (s *stepLxcCreate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.ContainerName @@ -65,7 +65,7 @@ func (s *stepLxcCreate) Run(ctx context.Context, state multistep.StateBag) multi func (s *stepLxcCreate) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) command := []string{ "lxc-destroy", "-f", "-n", config.ContainerName, diff --git a/builder/lxc/step_prepare_output_dir.go b/builder/lxc/step_prepare_output_dir.go index 65e7b40b0..2c89b5e3f 100644 --- a/builder/lxc/step_prepare_output_dir.go +++ b/builder/lxc/step_prepare_output_dir.go @@ -6,15 +6,15 @@ import ( "os" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepPrepareOutputDir struct{} func (stepPrepareOutputDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if _, err := os.Stat(config.OutputDir); err == nil && config.PackerForce { ui.Say("Deleting previous output directory...") @@ -35,7 +35,7 @@ func (stepPrepareOutputDir) Cleanup(state multistep.StateBag) { if cancelled || halted { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting output directory...") for i := 0; i < 5; i++ { diff --git a/builder/lxc/step_provision.go b/builder/lxc/step_provision.go index 5d8beae4c..c9ca5c812 100644 --- a/builder/lxc/step_provision.go +++ b/builder/lxc/step_provision.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepProvision provisions the instance within a chroot. @@ -16,7 +17,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi hook := state.Get("hook").(packer.Hook) config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) // Create our communicator diff --git a/builder/lxc/step_wait_init.go b/builder/lxc/step_wait_init.go index c4e733edc..7d47aa712 100644 --- a/builder/lxc/step_wait_init.go +++ b/builder/lxc/step_wait_init.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepWaitInit struct { @@ -17,7 +17,7 @@ type StepWaitInit struct { } func (s *StepWaitInit) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) var err error diff --git a/builder/lxd/builder.go b/builder/lxd/builder.go index 34be34e62..cbc52fcff 100644 --- a/builder/lxd/builder.go +++ b/builder/lxd/builder.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -33,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxd/step_lxd_launch.go b/builder/lxd/step_lxd_launch.go index 420c6564a..468463040 100644 --- a/builder/lxd/step_lxd_launch.go +++ b/builder/lxd/step_lxd_launch.go @@ -7,15 +7,15 @@ import ( "strconv" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepLxdLaunch struct{} func (s *stepLxdLaunch) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.ContainerName image := config.Image @@ -55,7 +55,7 @@ func (s *stepLxdLaunch) Run(ctx context.Context, state multistep.StateBag) multi func (s *stepLxdLaunch) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cleanup_args := []string{ "delete", "--force", config.ContainerName, diff --git a/builder/lxd/step_provision.go b/builder/lxd/step_provision.go index 1fa1b47c0..5670dfbaf 100644 --- a/builder/lxd/step_provision.go +++ b/builder/lxd/step_provision.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepProvision provisions the container @@ -15,7 +16,7 @@ type StepProvision struct{} func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) // Create our communicator diff --git a/builder/lxd/step_publish.go b/builder/lxd/step_publish.go index 7f7d838b1..4e9c2ca56 100644 --- a/builder/lxd/step_publish.go +++ b/builder/lxd/step_publish.go @@ -5,15 +5,15 @@ import ( "fmt" "regexp" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepPublish struct{} func (s *stepPublish) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.ContainerName stop_args := []string{ diff --git a/builder/ncloud/builder.go b/builder/ncloud/builder.go index 284a881d3..84fc4130c 100644 --- a/builder/ncloud/builder.go +++ b/builder/ncloud/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Builder assume this implements packer.Builder @@ -31,7 +32,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { ui.Message("Creating Naver Cloud Platform Connection ...") config := Config{ AccessKey: b.config.AccessKey, diff --git a/builder/ncloud/step_create_block_storage_instance.go b/builder/ncloud/step_create_block_storage_instance.go index d0f584507..767484243 100644 --- a/builder/ncloud/step_create_block_storage_instance.go +++ b/builder/ncloud/step_create_block_storage_instance.go @@ -9,8 +9,8 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCreateBlockStorageInstance struct is for making extra block storage @@ -23,7 +23,7 @@ type StepCreateBlockStorageInstance struct { } // NewStepCreateBlockStorageInstance make StepCreateBlockStorage struct to make extra block storage -func NewStepCreateBlockStorageInstance(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepCreateBlockStorageInstance { +func NewStepCreateBlockStorageInstance(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepCreateBlockStorageInstance { var step = &StepCreateBlockStorageInstance{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_create_login_key.go b/builder/ncloud/step_create_login_key.go index 7cf7ae505..5189c97db 100644 --- a/builder/ncloud/step_create_login_key.go +++ b/builder/ncloud/step_create_login_key.go @@ -6,8 +6,8 @@ import ( "time" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type LoginKey struct { @@ -22,7 +22,7 @@ type StepCreateLoginKey struct { Error func(e error) } -func NewStepCreateLoginKey(conn *NcloudAPIClient, ui packer.Ui) *StepCreateLoginKey { +func NewStepCreateLoginKey(conn *NcloudAPIClient, ui packersdk.Ui) *StepCreateLoginKey { var step = &StepCreateLoginKey{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_create_public_ip_instance.go b/builder/ncloud/step_create_public_ip_instance.go index 17820c241..1fcfce714 100644 --- a/builder/ncloud/step_create_public_ip_instance.go +++ b/builder/ncloud/step_create_public_ip_instance.go @@ -8,8 +8,8 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreatePublicIPInstance struct { @@ -21,7 +21,7 @@ type StepCreatePublicIPInstance struct { Config *Config } -func NewStepCreatePublicIPInstance(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepCreatePublicIPInstance { +func NewStepCreatePublicIPInstance(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepCreatePublicIPInstance { var step = &StepCreatePublicIPInstance{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_create_server_image.go b/builder/ncloud/step_create_server_image.go index 9b36b3ffc..3e665721e 100644 --- a/builder/ncloud/step_create_server_image.go +++ b/builder/ncloud/step_create_server_image.go @@ -7,8 +7,8 @@ import ( "time" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateServerImage struct { @@ -19,7 +19,7 @@ type StepCreateServerImage struct { Config *Config } -func NewStepCreateServerImage(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepCreateServerImage { +func NewStepCreateServerImage(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepCreateServerImage { var step = &StepCreateServerImage{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_create_server_instance.go b/builder/ncloud/step_create_server_instance.go index 48b1b11ef..4d8a80891 100644 --- a/builder/ncloud/step_create_server_instance.go +++ b/builder/ncloud/step_create_server_instance.go @@ -10,8 +10,8 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateServerInstance struct { @@ -24,7 +24,7 @@ type StepCreateServerInstance struct { serverInstanceNo string } -func NewStepCreateServerInstance(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepCreateServerInstance { +func NewStepCreateServerInstance(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepCreateServerInstance { var step = &StepCreateServerInstance{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_delete_block_storage_instance.go b/builder/ncloud/step_delete_block_storage_instance.go index a3cdc70a5..72cf85b17 100644 --- a/builder/ncloud/step_delete_block_storage_instance.go +++ b/builder/ncloud/step_delete_block_storage_instance.go @@ -8,8 +8,8 @@ import ( "time" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDeleteBlockStorageInstance struct { @@ -20,7 +20,7 @@ type StepDeleteBlockStorageInstance struct { Config *Config } -func NewStepDeleteBlockStorageInstance(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepDeleteBlockStorageInstance { +func NewStepDeleteBlockStorageInstance(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepDeleteBlockStorageInstance { var step = &StepDeleteBlockStorageInstance{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_get_rootpassword.go b/builder/ncloud/step_get_rootpassword.go index 94daf1382..6c724a34d 100644 --- a/builder/ncloud/step_get_rootpassword.go +++ b/builder/ncloud/step_get_rootpassword.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepGetRootPassword struct { @@ -17,7 +17,7 @@ type StepGetRootPassword struct { Config *Config } -func NewStepGetRootPassword(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepGetRootPassword { +func NewStepGetRootPassword(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepGetRootPassword { var step = &StepGetRootPassword{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_stop_server_instance.go b/builder/ncloud/step_stop_server_instance.go index b95dca774..e0ed00dd3 100644 --- a/builder/ncloud/step_stop_server_instance.go +++ b/builder/ncloud/step_stop_server_instance.go @@ -7,8 +7,8 @@ import ( "time" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepStopServerInstance struct { @@ -18,7 +18,7 @@ type StepStopServerInstance struct { Error func(e error) } -func NewStepStopServerInstance(conn *NcloudAPIClient, ui packer.Ui) *StepStopServerInstance { +func NewStepStopServerInstance(conn *NcloudAPIClient, ui packersdk.Ui) *StepStopServerInstance { var step = &StepStopServerInstance{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_terminate_server_instance.go b/builder/ncloud/step_terminate_server_instance.go index b8de7b79f..706220f81 100644 --- a/builder/ncloud/step_terminate_server_instance.go +++ b/builder/ncloud/step_terminate_server_instance.go @@ -6,8 +6,8 @@ import ( "time" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepTerminateServerInstance struct { @@ -17,7 +17,7 @@ type StepTerminateServerInstance struct { Error func(e error) } -func NewStepTerminateServerInstance(conn *NcloudAPIClient, ui packer.Ui) *StepTerminateServerInstance { +func NewStepTerminateServerInstance(conn *NcloudAPIClient, ui packersdk.Ui) *StepTerminateServerInstance { var step = &StepTerminateServerInstance{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/ncloud/step_validate_template.go b/builder/ncloud/step_validate_template.go index 52866e5ee..36ca61c49 100644 --- a/builder/ncloud/step_validate_template.go +++ b/builder/ncloud/step_validate_template.go @@ -9,8 +9,8 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/olekukonko/tablewriter" ) @@ -27,7 +27,7 @@ type StepValidateTemplate struct { } // NewStepValidateTemplate : function for Validation a template -func NewStepValidateTemplate(conn *NcloudAPIClient, ui packer.Ui, config *Config) *StepValidateTemplate { +func NewStepValidateTemplate(conn *NcloudAPIClient, ui packersdk.Ui, config *Config) *StepValidateTemplate { var step = &StepValidateTemplate{ Conn: conn, Say: func(message string) { ui.Say(message) }, diff --git a/builder/null/builder.go b/builder/null/builder.go index a48da95fb..1397e5fcc 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const BuilderId = "fnoeding.null" @@ -28,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { steps := []multistep.Step{} steps = append(steps, diff --git a/builder/oneandone/builder.go b/builder/oneandone/builder.go index 915d1c470..b6cee6d01 100644 --- a/builder/oneandone/builder.go +++ b/builder/oneandone/builder.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const BuilderId = "packer.oneandone" @@ -30,7 +31,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) diff --git a/builder/oneandone/step_create_server.go b/builder/oneandone/step_create_server.go index 3cd1e7de7..18293e86b 100644 --- a/builder/oneandone/step_create_server.go +++ b/builder/oneandone/step_create_server.go @@ -7,14 +7,14 @@ import ( "time" "github.com/1and1/oneandone-cloudserver-sdk-go" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateServer struct{} func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) token := oneandone.SetToken(c.Token) @@ -105,7 +105,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu func (s *stepCreateServer) Cleanup(state multistep.StateBag) { c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Removing Server...") diff --git a/builder/oneandone/step_create_sshkey.go b/builder/oneandone/step_create_sshkey.go index 2da8f5839..64dd5f667 100644 --- a/builder/oneandone/step_create_sshkey.go +++ b/builder/oneandone/step_create_sshkey.go @@ -7,8 +7,8 @@ import ( "fmt" "io/ioutil" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -18,7 +18,7 @@ type StepCreateSSHKey struct { } func (s *StepCreateSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) if c.Comm.SSHPrivateKeyFile != "" { diff --git a/builder/oneandone/step_take_snapshot.go b/builder/oneandone/step_take_snapshot.go index c5b128ef5..2c8571f79 100644 --- a/builder/oneandone/step_take_snapshot.go +++ b/builder/oneandone/step_take_snapshot.go @@ -4,14 +4,14 @@ import ( "context" "github.com/1and1/oneandone-cloudserver-sdk-go" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepTakeSnapshot struct{} func (s *stepTakeSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) ui.Say("Creating Snapshot...") diff --git a/builder/openstack/access_config.go b/builder/openstack/access_config.go index fafcdae65..8c18beed0 100644 --- a/builder/openstack/access_config.go +++ b/builder/openstack/access_config.go @@ -16,7 +16,7 @@ import ( "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/utils/openstack/clientconfig" "github.com/hashicorp/go-cleanhttp" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -240,7 +240,7 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error { return nil } -func (c *AccessConfig) enableDebug(ui packer.Ui) { +func (c *AccessConfig) enableDebug(ui packersdk.Ui) { c.osClient.HTTPClient = http.Client{ Transport: &DebugRoundTripper{ ui: ui, @@ -288,7 +288,7 @@ func (c *AccessConfig) getEndpointType() gophercloud.Availability { } type DebugRoundTripper struct { - ui packer.Ui + ui packersdk.Ui rt http.RoundTripper numReauthAttempts int } diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index a61b1d547..b4a9fb80e 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -72,7 +73,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { if b.config.PackerDebug { b.config.enableDebug(ui) } diff --git a/builder/openstack/step_add_image_members.go b/builder/openstack/step_add_image_members.go index cbbb9f5e6..d612d8510 100644 --- a/builder/openstack/step_add_image_members.go +++ b/builder/openstack/step_add_image_members.go @@ -5,15 +5,15 @@ import ( "fmt" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/members" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepAddImageMembers struct{} func (s *stepAddImageMembers) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { imageId := state.Get("image").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if len(config.ImageMembers) == 0 { diff --git a/builder/openstack/step_allocate_ip.go b/builder/openstack/step_allocate_ip.go index 6ba8c0262..c113d3385 100644 --- a/builder/openstack/step_allocate_ip.go +++ b/builder/openstack/step_allocate_ip.go @@ -6,8 +6,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepAllocateIp struct { @@ -18,7 +18,7 @@ type StepAllocateIp struct { } func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) server := state.Get("server").(*servers.Server) @@ -145,7 +145,7 @@ func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) mult func (s *StepAllocateIp) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceIP := state.Get("access_ip").(*floatingips.FloatingIP) // Don't clean up if unless required diff --git a/builder/openstack/step_create_image.go b/builder/openstack/step_create_image.go index b2f792d0d..f6d241dc0 100644 --- a/builder/openstack/step_create_image.go +++ b/builder/openstack/step_create_image.go @@ -11,8 +11,8 @@ import ( "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateImage struct { @@ -22,7 +22,7 @@ type stepCreateImage struct { func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) server := state.Get("server").(*servers.Server) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // We need the v2 compute client computeClient, err := config.computeV2Client() diff --git a/builder/openstack/step_create_volume.go b/builder/openstack/step_create_volume.go index 687d92a54..3c820580a 100644 --- a/builder/openstack/step_create_volume.go +++ b/builder/openstack/step_create_volume.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateVolume struct { @@ -25,7 +25,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu } config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) sourceImage := state.Get("source_image").(string) // We will need Block Storage and Image services clients. @@ -99,7 +99,7 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) { } config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) blockStorageClient, err := config.blockStorageV3Client() if err != nil { diff --git a/builder/openstack/step_detach_volume.go b/builder/openstack/step_detach_volume.go index d711e87a2..05553d587 100644 --- a/builder/openstack/step_detach_volume.go +++ b/builder/openstack/step_detach_volume.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDetachVolume struct { @@ -20,7 +20,7 @@ func (s *StepDetachVolume) Run(ctx context.Context, state multistep.StateBag) mu } config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) blockStorageClient, err := config.blockStorageV3Client() if err != nil { diff --git a/builder/openstack/step_discover_network.go b/builder/openstack/step_discover_network.go index 811c98a55..210272497 100644 --- a/builder/openstack/step_discover_network.go +++ b/builder/openstack/step_discover_network.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDiscoverNetwork struct { @@ -17,7 +17,7 @@ type StepDiscoverNetwork struct { func (s *StepDiscoverNetwork) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) networkClient, err := config.networkV2Client() if err != nil { diff --git a/builder/openstack/step_get_password.go b/builder/openstack/step_get_password.go index f039198fb..6d77bbb71 100644 --- a/builder/openstack/step_get_password.go +++ b/builder/openstack/step_get_password.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -24,7 +25,7 @@ type StepGetPassword struct { func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip if we're not using winrm if s.Comm.Type != "winrm" { diff --git a/builder/openstack/step_key_pair.go b/builder/openstack/step_key_pair.go index 1faa67787..77da85df0 100644 --- a/builder/openstack/step_key_pair.go +++ b/builder/openstack/step_key_pair.go @@ -11,8 +11,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" "golang.org/x/crypto/ssh" ) @@ -26,7 +26,7 @@ type StepKeyPair struct { } func (s *StepKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key") @@ -123,7 +123,7 @@ func (s *StepKeyPair) Run(ctx context.Context, state multistep.StateBag) multist } // Work around for https://github.com/hashicorp/packer/issues/2526 -func berToDer(ber []byte, ui packer.Ui) []byte { +func berToDer(ber []byte, ui packersdk.Ui) []byte { // Check if x/crypto/ssh can parse the key _, err := ssh.ParsePrivateKey(ber) if err == nil { @@ -171,7 +171,7 @@ func (s *StepKeyPair) Cleanup(state multistep.StateBag) { } config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // We need the v2 compute client computeClient, err := config.computeV2Client() diff --git a/builder/openstack/step_load_flavor.go b/builder/openstack/step_load_flavor.go index 7e7176640..a865a4374 100644 --- a/builder/openstack/step_load_flavor.go +++ b/builder/openstack/step_load_flavor.go @@ -7,8 +7,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" flavors_utils "github.com/gophercloud/utils/openstack/compute/v2/flavors" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepLoadFlavor gets the FlavorRef from a Flavor. It first assumes @@ -20,7 +20,7 @@ type StepLoadFlavor struct { func (s *StepLoadFlavor) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // We need the v2 compute client client, err := config.computeV2Client() diff --git a/builder/openstack/step_run_source_server.go b/builder/openstack/step_run_source_server.go index 007023de8..1524a76f8 100644 --- a/builder/openstack/step_run_source_server.go +++ b/builder/openstack/step_run_source_server.go @@ -9,8 +9,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRunSourceServer struct { @@ -31,7 +31,7 @@ func (s *StepRunSourceServer) Run(ctx context.Context, state multistep.StateBag) flavor := state.Get("flavor_id").(string) sourceImage := state.Get("source_image").(string) networks := state.Get("networks").([]servers.Network) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // We need the v2 compute client computeClient, err := config.computeV2Client() @@ -141,7 +141,7 @@ func (s *StepRunSourceServer) Cleanup(state multistep.StateBag) { } config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // We need the v2 compute client computeClient, err := config.computeV2Client() diff --git a/builder/openstack/step_source_image_info.go b/builder/openstack/step_source_image_info.go index 3b7c5b798..915c16bd7 100644 --- a/builder/openstack/step_source_image_info.go +++ b/builder/openstack/step_source_image_info.go @@ -9,8 +9,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/imageservice/v2/imageimport" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" "github.com/gophercloud/gophercloud/pagination" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSourceImageInfo struct { @@ -35,7 +35,7 @@ func PropertiesSatisfied(image *images.Image, props *map[string]string) bool { func (s *StepSourceImageInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client, err := config.imageV2Client() if err != nil { @@ -181,7 +181,7 @@ func (s *StepSourceImageInfo) Run(ctx context.Context, state multistep.StateBag) func (s *StepSourceImageInfo) Cleanup(state multistep.StateBag) { if s.ExternalSourceImageURL != "" { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client, err := config.imageV2Client() if err != nil { diff --git a/builder/openstack/step_stop_server.go b/builder/openstack/step_stop_server.go index f4e00e25e..6a7baa5d8 100644 --- a/builder/openstack/step_stop_server.go +++ b/builder/openstack/step_stop_server.go @@ -8,14 +8,14 @@ import ( "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/startstop" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepStopServer struct{} func (s *StepStopServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) server := state.Get("server").(*servers.Server) diff --git a/builder/openstack/step_update_image_mindisk.go b/builder/openstack/step_update_image_mindisk.go index 15412f29b..fcaf55468 100644 --- a/builder/openstack/step_update_image_mindisk.go +++ b/builder/openstack/step_update_image_mindisk.go @@ -5,15 +5,15 @@ import ( "fmt" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepUpdateImageMinDisk struct{} func (s *stepUpdateImageMinDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { imageId := state.Get("image").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.ImageMinDisk == 0 { diff --git a/builder/openstack/step_update_image_tags.go b/builder/openstack/step_update_image_tags.go index 8f0adf582..34fdc674d 100644 --- a/builder/openstack/step_update_image_tags.go +++ b/builder/openstack/step_update_image_tags.go @@ -6,15 +6,15 @@ import ( "strings" imageservice "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepUpdateImageTags struct{} func (s *stepUpdateImageTags) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { imageId := state.Get("image").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if len(config.ImageTags) == 0 { diff --git a/builder/openstack/step_update_image_visibility.go b/builder/openstack/step_update_image_visibility.go index fb2ab9fd1..e7da67d7c 100644 --- a/builder/openstack/step_update_image_visibility.go +++ b/builder/openstack/step_update_image_visibility.go @@ -5,15 +5,15 @@ import ( "fmt" imageservice "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepUpdateImageVisibility struct{} func (s *stepUpdateImageVisibility) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { imageId := state.Get("image").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.ImageVisibility == "" { diff --git a/builder/openstack/step_wait_for_rackconnect.go b/builder/openstack/step_wait_for_rackconnect.go index 3386642f5..d97da15f4 100644 --- a/builder/openstack/step_wait_for_rackconnect.go +++ b/builder/openstack/step_wait_for_rackconnect.go @@ -6,8 +6,8 @@ import ( "time" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepWaitForRackConnect struct { @@ -21,7 +21,7 @@ func (s *StepWaitForRackConnect) Run(ctx context.Context, state multistep.StateB config := state.Get("config").(*Config) server := state.Get("server").(*servers.Server) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // We need the v2 compute client computeClient, err := config.computeV2Client() diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index fc97066f1..8e672881f 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // BuilderId uniquely identifies the builder @@ -45,7 +46,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { loggingEnabled := os.Getenv("PACKER_OCI_CLASSIC_LOGGING") != "" httpClient := cleanhttp.DefaultClient() config := &opc.Config{ diff --git a/builder/oracle/classic/step_add_keys.go b/builder/oracle/classic/step_add_keys.go index 60a448560..bf1598d85 100644 --- a/builder/oracle/classic/step_add_keys.go +++ b/builder/oracle/classic/step_add_keys.go @@ -6,8 +6,8 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepAddKeysToAPI struct { @@ -17,7 +17,7 @@ type stepAddKeysToAPI struct { func (s *stepAddKeysToAPI) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) client := state.Get("client").(*compute.Client) @@ -62,7 +62,7 @@ func (s *stepAddKeysToAPI) Cleanup(state multistep.StateBag) { // No keys were generated; none need to be cleaned up. return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting SSH keys...") deleteInput := compute.DeleteSSHKeyInput{Name: config.Comm.SSHKeyPairName} client := state.Get("client").(*compute.Client) diff --git a/builder/oracle/classic/step_attach_volume.go b/builder/oracle/classic/step_attach_volume.go index e0882f35b..686c01a2b 100644 --- a/builder/oracle/classic/step_attach_volume.go +++ b/builder/oracle/classic/step_attach_volume.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepAttachVolume struct { @@ -17,7 +17,7 @@ type stepAttachVolume struct { func (s *stepAttachVolume) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*compute.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceInfo := state.Get(s.InstanceInfoKey).(*compute.InstanceInfo) saClient := client.StorageAttachments() @@ -47,7 +47,7 @@ func (s *stepAttachVolume) Cleanup(state multistep.StateBag) { return } client := state.Get("client").(*compute.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) saClient := client.StorageAttachments() saI := &compute.DeleteStorageAttachmentInput{ diff --git a/builder/oracle/classic/step_create_image.go b/builder/oracle/classic/step_create_image.go index 481d03406..7eae037d1 100644 --- a/builder/oracle/classic/step_create_image.go +++ b/builder/oracle/classic/step_create_image.go @@ -6,15 +6,15 @@ import ( "log" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateImage struct { } func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*compute.Client) config := state.Get("config").(*Config) imageFile := state.Get("image_file").(string) @@ -55,7 +55,7 @@ func (s *stepCreateImage) Cleanup(state multistep.StateBag) { client := state.Get("client").(*compute.Client) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cleaning up Image...") machineImageClient := client.MachineImages() diff --git a/builder/oracle/classic/step_create_instance.go b/builder/oracle/classic/step_create_instance.go index 35fd4e9b6..86ea5d74f 100644 --- a/builder/oracle/classic/step_create_instance.go +++ b/builder/oracle/classic/step_create_instance.go @@ -5,15 +5,15 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateInstance struct{} func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating Instance...") config := state.Get("config").(*Config) @@ -63,7 +63,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) { } // terminate instance - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*compute.Client) config := state.Get("config").(*Config) diff --git a/builder/oracle/classic/step_create_ip_reservation.go b/builder/oracle/classic/step_create_ip_reservation.go index 367ba9221..24948c68a 100644 --- a/builder/oracle/classic/step_create_ip_reservation.go +++ b/builder/oracle/classic/step_create_ip_reservation.go @@ -5,15 +5,15 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) type stepCreateIPReservation struct{} func (s *stepCreateIPReservation) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) client := state.Get("client").(*compute.Client) @@ -47,7 +47,7 @@ func (s *stepCreateIPReservation) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cleaning up IP reservations...") client := state.Get("client").(*compute.Client) diff --git a/builder/oracle/classic/step_create_persistent_volume.go b/builder/oracle/classic/step_create_persistent_volume.go index 349fc0b8b..268354c62 100644 --- a/builder/oracle/classic/step_create_persistent_volume.go +++ b/builder/oracle/classic/step_create_persistent_volume.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreatePersistentVolume struct { @@ -20,7 +20,7 @@ type stepCreatePersistentVolume struct { func (s *stepCreatePersistentVolume) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*compute.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating Volume...") c := &compute.CreateStorageVolumeInput{ @@ -49,7 +49,7 @@ func (s *stepCreatePersistentVolume) Run(ctx context.Context, state multistep.St func (s *stepCreatePersistentVolume) Cleanup(state multistep.StateBag) { client := state.Get("client").(*compute.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cleaning up Volume...") c := &compute.DeleteStorageVolumeInput{ diff --git a/builder/oracle/classic/step_create_pv_builder.go b/builder/oracle/classic/step_create_pv_builder.go index a544c9615..c10849a8b 100644 --- a/builder/oracle/classic/step_create_pv_builder.go +++ b/builder/oracle/classic/step_create_pv_builder.go @@ -6,8 +6,8 @@ import ( "log" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreatePVBuilder struct { @@ -18,7 +18,7 @@ type stepCreatePVBuilder struct { func (s *stepCreatePVBuilder) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating builder instance...") config := state.Get("config").(*Config) @@ -73,7 +73,7 @@ func (s *stepCreatePVBuilder) Cleanup(state multistep.StateBag) { } // terminate instance - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*compute.Client) ui.Say("Terminating builder instance...") diff --git a/builder/oracle/classic/step_create_pv_master.go b/builder/oracle/classic/step_create_pv_master.go index 28e85fe6d..bb4843ddc 100644 --- a/builder/oracle/classic/step_create_pv_master.go +++ b/builder/oracle/classic/step_create_pv_master.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreatePVMaster struct { @@ -16,7 +16,7 @@ type stepCreatePVMaster struct { } func (s *stepCreatePVMaster) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating master instance...") config := state.Get("config").(*Config) @@ -75,7 +75,7 @@ func (s *stepCreatePVMaster) Cleanup(state multistep.StateBag) { } // terminate instance - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*compute.Client) ui.Say("Terminating builder instance...") diff --git a/builder/oracle/classic/step_list_images.go b/builder/oracle/classic/step_list_images.go index 8b30d2cbb..b7aea6e56 100644 --- a/builder/oracle/classic/step_list_images.go +++ b/builder/oracle/classic/step_list_images.go @@ -5,15 +5,15 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepListImages struct{} func (s *stepListImages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) client := state.Get("client").(*compute.Client) ui.Say("Adding image to image list...") diff --git a/builder/oracle/classic/step_security.go b/builder/oracle/classic/step_security.go index d6ad9252c..b290e41a4 100644 --- a/builder/oracle/classic/step_security.go +++ b/builder/oracle/classic/step_security.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepSecurity struct { @@ -19,7 +19,7 @@ type stepSecurity struct { } func (s *stepSecurity) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) runID := state.Get("run_id").(string) client := state.Get("client").(*compute.Client) @@ -115,7 +115,7 @@ func (s *stepSecurity) Cleanup(state multistep.StateBag) { } client := state.Get("client").(*compute.Client) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say("Deleting temporary rules and lists...") diff --git a/builder/oracle/classic/step_snapshot.go b/builder/oracle/classic/step_snapshot.go index 993bc2835..6120df025 100644 --- a/builder/oracle/classic/step_snapshot.go +++ b/builder/oracle/classic/step_snapshot.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepSnapshot struct { @@ -15,7 +15,7 @@ type stepSnapshot struct { func (s *stepSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating Snapshot...") config := state.Get("config").(*Config) client := state.Get("client").(*compute.Client) @@ -53,7 +53,7 @@ func (s *stepSnapshot) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting Snapshot...") client := state.Get("client").(*compute.Client) snapClient := client.Snapshots() diff --git a/builder/oracle/classic/step_terminate_pv_master.go b/builder/oracle/classic/step_terminate_pv_master.go index 0d4d2a013..87820ff48 100644 --- a/builder/oracle/classic/step_terminate_pv_master.go +++ b/builder/oracle/classic/step_terminate_pv_master.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepTerminatePVMaster struct { @@ -14,7 +14,7 @@ type stepTerminatePVMaster struct { func (s *stepTerminatePVMaster) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting master Instance...") client := state.Get("client").(*compute.Client) diff --git a/builder/oracle/classic/step_upload_image.go b/builder/oracle/classic/step_upload_image.go index 04fd1e896..a8519462a 100644 --- a/builder/oracle/classic/step_upload_image.go +++ b/builder/oracle/classic/step_upload_image.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -25,7 +26,7 @@ type uploadCmdData struct { } func (s *stepUploadImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*Config) runID := state.Get("run_id").(string) diff --git a/builder/oracle/common/step_ssh_key_pair.go b/builder/oracle/common/step_ssh_key_pair.go index 3a87a824a..4ea4f5a9c 100644 --- a/builder/oracle/common/step_ssh_key_pair.go +++ b/builder/oracle/common/step_ssh_key_pair.go @@ -11,8 +11,8 @@ import ( "runtime" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -23,7 +23,7 @@ type StepKeyPair struct { } func (s *StepKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key") diff --git a/builder/oracle/oci/builder.go b/builder/oracle/oci/builder.go index 0368ac678..bc385e7f7 100644 --- a/builder/oracle/oci/builder.go +++ b/builder/oracle/oci/builder.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/oracle/oci-go-sdk/core" ) @@ -38,7 +39,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := NewDriverOCI(&b.config) if err != nil { return nil, err diff --git a/builder/oracle/oci/step_create_instance.go b/builder/oracle/oci/step_create_instance.go index 0ebe41eab..bc4a0a067 100644 --- a/builder/oracle/oci/step_create_instance.go +++ b/builder/oracle/oci/step_create_instance.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCreateInstance struct{} @@ -13,7 +13,7 @@ type stepCreateInstance struct{} func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(Driver) - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) config = state.Get("config").(*Config) ) @@ -47,7 +47,7 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) func (s *stepCreateInstance) Cleanup(state multistep.StateBag) { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) idRaw, ok := state.GetOk("instance_id") if !ok { diff --git a/builder/oracle/oci/step_get_default_credentials.go b/builder/oracle/oci/step_get_default_credentials.go index 602565050..902f8c050 100644 --- a/builder/oracle/oci/step_get_default_credentials.go +++ b/builder/oracle/oci/step_get_default_credentials.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepGetDefaultCredentials struct { @@ -19,7 +20,7 @@ type stepGetDefaultCredentials struct { func (s *stepGetDefaultCredentials) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(*driverOCI) - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) id = state.Get("instance_id").(string) ) diff --git a/builder/oracle/oci/step_image.go b/builder/oracle/oci/step_image.go index 460aa9c91..69b0550b9 100644 --- a/builder/oracle/oci/step_image.go +++ b/builder/oracle/oci/step_image.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepImage struct{} @@ -13,7 +13,7 @@ type stepImage struct{} func (s *stepImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(Driver) - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) instanceID = state.Get("instance_id").(string) ) diff --git a/builder/oracle/oci/step_instance_info.go b/builder/oracle/oci/step_instance_info.go index e1052b5ed..11edc3f1d 100644 --- a/builder/oracle/oci/step_instance_info.go +++ b/builder/oracle/oci/step_instance_info.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepInstanceInfo struct{} @@ -13,7 +13,7 @@ type stepInstanceInfo struct{} func (s *stepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(Driver) - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) id = state.Get("instance_id").(string) ) diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index 0f05b93ad..c36ae8346 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -84,7 +85,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsu/step_create_omi.go b/builder/osc/bsu/step_create_omi.go index 0b7935173..63199f344 100644 --- a/builder/osc/bsu/step_create_omi.go +++ b/builder/osc/bsu/step_create_omi.go @@ -7,8 +7,8 @@ import ( "github.com/antihax/optional" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -21,7 +21,7 @@ func (s *stepCreateOMI) Run(ctx context.Context, state multistep.StateBag) multi config := state.Get("config").(*Config) oscconn := state.Get("osc").(*osc.APIClient) vm := state.Get("vm").(osc.Vm) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Create the image omiName := config.OMIName @@ -113,7 +113,7 @@ func (s *stepCreateOMI) Cleanup(state multistep.StateBag) { } oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deregistering the OMI because cancellation or error...") DeleteOpts := osc.DeleteImageRequest{ImageId: s.image.ImageId} diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index b4e2f2db2..18d4802ca 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -102,7 +103,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsusurrogate/step_register_omi.go b/builder/osc/bsusurrogate/step_register_omi.go index f63a87135..eea7beb76 100644 --- a/builder/osc/bsusurrogate/step_register_omi.go +++ b/builder/osc/bsusurrogate/step_register_omi.go @@ -6,8 +6,8 @@ import ( "github.com/antihax/optional" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -24,7 +24,7 @@ func (s *StepRegisterOMI) Run(ctx context.Context, state multistep.StateBag) mul config := state.Get("config").(*Config) oscconn := state.Get("osc").(*osc.APIClient) snapshotIds := state.Get("snapshot_ids").(map[string]string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Registering the OMI...") @@ -100,7 +100,7 @@ func (s *StepRegisterOMI) Cleanup(state multistep.StateBag) { } oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deregistering the OMI because cancellation or error...") deregisterOpts := osc.DeleteImageRequest{ImageId: s.image.ImageId} diff --git a/builder/osc/bsusurrogate/step_snapshop_volumes.go b/builder/osc/bsusurrogate/step_snapshop_volumes.go index 2f1d027dd..29abadd13 100644 --- a/builder/osc/bsusurrogate/step_snapshop_volumes.go +++ b/builder/osc/bsusurrogate/step_snapshop_volumes.go @@ -9,8 +9,8 @@ import ( "github.com/antihax/optional" multierror "github.com/hashicorp/go-multierror" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -25,7 +25,7 @@ type StepSnapshotVolumes struct { func (s *StepSnapshotVolumes) snapshotVolume(ctx context.Context, deviceName string, state multistep.StateBag) error { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(osc.Vm) var volumeId string @@ -60,7 +60,7 @@ func (s *StepSnapshotVolumes) snapshotVolume(ctx context.Context, deviceName str } func (s *StepSnapshotVolumes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) s.snapshotIds = map[string]string{} @@ -98,7 +98,7 @@ func (s *StepSnapshotVolumes) Cleanup(state multistep.StateBag) { if cancelled || halted { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Removing snapshots since we cancelled or halted...") for _, snapshotID := range s.snapshotIds { _, _, err := oscconn.SnapshotApi.DeleteSnapshot(context.Background(), &osc.DeleteSnapshotOpts{ diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 05a2f9c43..57f4454e1 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -87,7 +88,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // clientConfig, err := b.config.Config() // if err != nil { // return nil, err diff --git a/builder/osc/bsuvolume/step_tag_bsu_volumes.go b/builder/osc/bsuvolume/step_tag_bsu_volumes.go index 4d313ffd3..53b515fdb 100644 --- a/builder/osc/bsuvolume/step_tag_bsu_volumes.go +++ b/builder/osc/bsuvolume/step_tag_bsu_volumes.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/outscale/osc-sdk-go/osc" ) @@ -20,7 +20,7 @@ type stepTagBSUVolumes struct { func (s *stepTagBSUVolumes) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) vm := state.Get("vm").(osc.Vm) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) volumes := make(BsuVolumes) for _, instanceBlockDevices := range vm.BlockDeviceMappings { diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 7740bc357..b05463b1c 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -187,7 +188,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The outscale-chroot builder only works on Linux environments.") } diff --git a/builder/osc/chroot/run_local_commands.go b/builder/osc/chroot/run_local_commands.go index 175a2afa6..0220db88d 100644 --- a/builder/osc/chroot/run_local_commands.go +++ b/builder/osc/chroot/run_local_commands.go @@ -5,11 +5,12 @@ import ( "fmt" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) -func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx interpolate.Context, ui packer.Ui) error { +func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx interpolate.Context, ui packersdk.Ui) error { ctx := context.TODO() for _, rawCmd := range commands { intCmd, err := interpolate.Render(rawCmd, &ictx) diff --git a/builder/osc/chroot/step_check_root_device.go b/builder/osc/chroot/step_check_root_device.go index 418fd3909..97566e8d3 100644 --- a/builder/osc/chroot/step_check_root_device.go +++ b/builder/osc/chroot/step_check_root_device.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -14,7 +14,7 @@ type StepCheckRootDevice struct{} func (s *StepCheckRootDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { image := state.Get("source_image").(osc.Image) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Checking the root device on source OMI...") diff --git a/builder/osc/chroot/step_chroot_provision.go b/builder/osc/chroot/step_chroot_provision.go index ef659c41b..607c68306 100644 --- a/builder/osc/chroot/step_chroot_provision.go +++ b/builder/osc/chroot/step_chroot_provision.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepChrootProvision provisions the instance within a chroot. @@ -16,7 +17,7 @@ type StepChrootProvision struct { func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) // Create our communicator diff --git a/builder/osc/chroot/step_copy_files.go b/builder/osc/chroot/step_copy_files.go index a7c7adbcb..6be919506 100644 --- a/builder/osc/chroot/step_copy_files.go +++ b/builder/osc/chroot/step_copy_files.go @@ -7,8 +7,8 @@ import ( "log" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCopyFiles copies some files from the host into the chroot environment. @@ -23,7 +23,7 @@ type StepCopyFiles struct { func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) stderr := new(bytes.Buffer) @@ -63,7 +63,7 @@ func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multi } func (s *StepCopyFiles) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } diff --git a/builder/osc/chroot/step_create_omi.go b/builder/osc/chroot/step_create_omi.go index cfd43fdb4..051ca7740 100644 --- a/builder/osc/chroot/step_create_omi.go +++ b/builder/osc/chroot/step_create_omi.go @@ -6,8 +6,8 @@ import ( "github.com/antihax/optional" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -21,7 +21,7 @@ func (s *StepCreateOMI) Run(ctx context.Context, state multistep.StateBag) multi config := state.Get("config").(*Config) osconn := state.Get("osc").(*osc.APIClient) snapshotId := state.Get("snapshot_id").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating the OMI...") diff --git a/builder/osc/chroot/step_create_volume.go b/builder/osc/chroot/step_create_volume.go index f2fdc7ab3..447c7f652 100644 --- a/builder/osc/chroot/step_create_volume.go +++ b/builder/osc/chroot/step_create_volume.go @@ -8,8 +8,8 @@ import ( "github.com/antihax/optional" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/outscale/osc-sdk-go/osc" ) @@ -32,7 +32,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu config := state.Get("config").(*Config) oscconn := state.Get("osc").(*osc.APIClient) vm := state.Get("vm").(osc.Vm) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) var err error @@ -127,7 +127,7 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) { } oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting the created BSU volume...") _, _, err := oscconn.VolumeApi.DeleteVolume(context.Background(), &osc.DeleteVolumeOpts{ diff --git a/builder/osc/chroot/step_early_cleanup.go b/builder/osc/chroot/step_early_cleanup.go index e84ac77e2..e8cf9593f 100644 --- a/builder/osc/chroot/step_early_cleanup.go +++ b/builder/osc/chroot/step_early_cleanup.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepEarlyCleanup performs some of the cleanup steps early in order to @@ -14,7 +14,7 @@ import ( type StepEarlyCleanup struct{} func (s *StepEarlyCleanup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cleanupKeys := []string{ "copy_files_cleanup", "mount_extra_cleanup", diff --git a/builder/osc/chroot/step_early_unflock.go b/builder/osc/chroot/step_early_unflock.go index 3a39fb7fe..fa3828315 100644 --- a/builder/osc/chroot/step_early_unflock.go +++ b/builder/osc/chroot/step_early_unflock.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepEarlyUnflock unlocks the flock. @@ -14,7 +14,7 @@ type StepEarlyUnflock struct{} func (s *StepEarlyUnflock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { cleanup := state.Get("flock_cleanup").(Cleanup) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) log.Println("Unlocking file lock...") if err := cleanup.CleanupFunc(state); err != nil { diff --git a/builder/osc/chroot/step_flock.go b/builder/osc/chroot/step_flock.go index 5465a72fe..c8d92f5a3 100644 --- a/builder/osc/chroot/step_flock.go +++ b/builder/osc/chroot/step_flock.go @@ -7,8 +7,8 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepFlock provisions the instance within a chroot. @@ -20,7 +20,7 @@ type StepFlock struct { } func (s *StepFlock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) lockfile := "/var/lock/packer-chroot/lock" if err := os.MkdirAll(filepath.Dir(lockfile), 0755); err != nil { diff --git a/builder/osc/chroot/step_link_volume.go b/builder/osc/chroot/step_link_volume.go index 6940e64c4..e14244dc1 100644 --- a/builder/osc/chroot/step_link_volume.go +++ b/builder/osc/chroot/step_link_volume.go @@ -6,8 +6,8 @@ import ( "github.com/antihax/optional" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -26,7 +26,7 @@ func (s *StepLinkVolume) Run(ctx context.Context, state multistep.StateBag) mult oscconn := state.Get("osc").(*osc.APIClient) device := state.Get("device").(string) vm := state.Get("vm").(osc.Vm) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) volumeId := state.Get("volume_id").(string) // For the API call, it expects "sd" prefixed devices. @@ -67,7 +67,7 @@ func (s *StepLinkVolume) Run(ctx context.Context, state multistep.StateBag) mult } func (s *StepLinkVolume) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } @@ -79,7 +79,7 @@ func (s *StepLinkVolume) CleanupFunc(state multistep.StateBag) error { } oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Detaching BSU volume...") _, _, err := oscconn.VolumeApi.UnlinkVolume(context.Background(), &osc.UnlinkVolumeOpts{ diff --git a/builder/osc/chroot/step_mount_device.go b/builder/osc/chroot/step_mount_device.go index 936425ac0..11bbebfe9 100644 --- a/builder/osc/chroot/step_mount_device.go +++ b/builder/osc/chroot/step_mount_device.go @@ -9,8 +9,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -32,7 +32,7 @@ type StepMountDevice struct { func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := state.Get("device").(string) if config.NVMEDevicePath != "" { // customizable device path for mounting NVME block devices on c5 and m5 HVM @@ -153,7 +153,7 @@ func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multi } func (s *StepMountDevice) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } @@ -164,7 +164,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error { return nil } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) ui.Say("Unmounting the root device...") diff --git a/builder/osc/chroot/step_mount_extra.go b/builder/osc/chroot/step_mount_extra.go index f9b70dc4f..87706081f 100644 --- a/builder/osc/chroot/step_mount_extra.go +++ b/builder/osc/chroot/step_mount_extra.go @@ -8,8 +8,8 @@ import ( "os/exec" "syscall" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepMountExtra mounts the attached device. @@ -23,7 +23,7 @@ type StepMountExtra struct { func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) s.mounts = make([]string, 0, len(config.ChrootMounts)) @@ -76,7 +76,7 @@ func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) mult } func (s *StepMountExtra) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) diff --git a/builder/osc/chroot/step_post_mount_commands.go b/builder/osc/chroot/step_post_mount_commands.go index 303ddeee5..cbfb8e176 100644 --- a/builder/osc/chroot/step_post_mount_commands.go +++ b/builder/osc/chroot/step_post_mount_commands.go @@ -3,8 +3,8 @@ package chroot import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type postMountCommandsData struct { @@ -22,7 +22,7 @@ func (s *StepPostMountCommands) Run(ctx context.Context, state multistep.StateBa config := state.Get("config").(*Config) device := state.Get("device").(string) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) if len(s.Commands) == 0 { diff --git a/builder/osc/chroot/step_pre_mount_commands.go b/builder/osc/chroot/step_pre_mount_commands.go index 26e93adf3..4ddb5523a 100644 --- a/builder/osc/chroot/step_pre_mount_commands.go +++ b/builder/osc/chroot/step_pre_mount_commands.go @@ -3,8 +3,8 @@ package chroot import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type preMountCommandsData struct { @@ -19,7 +19,7 @@ type StepPreMountCommands struct { func (s *StepPreMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) device := state.Get("device").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) if len(s.Commands) == 0 { diff --git a/builder/osc/chroot/step_prepare_device.go b/builder/osc/chroot/step_prepare_device.go index 65af71acf..79e5ee9a8 100644 --- a/builder/osc/chroot/step_prepare_device.go +++ b/builder/osc/chroot/step_prepare_device.go @@ -6,8 +6,8 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepPrepareDevice finds an available device and sets it. @@ -16,7 +16,7 @@ type StepPrepareDevice struct { func (s *StepPrepareDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) device := config.DevicePath if device == "" { diff --git a/builder/osc/chroot/step_snapshot.go b/builder/osc/chroot/step_snapshot.go index 04e036462..ba518ce72 100644 --- a/builder/osc/chroot/step_snapshot.go +++ b/builder/osc/chroot/step_snapshot.go @@ -7,8 +7,8 @@ import ( "github.com/antihax/optional" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -23,7 +23,7 @@ type StepSnapshot struct { func (s *StepSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) volumeId := state.Get("volume_id").(string) ui.Say("Creating snapshot...") @@ -75,7 +75,7 @@ func (s *StepSnapshot) Cleanup(state multistep.StateBag) { if cancelled || halted { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Removing snapshot since we cancelled or halted...") _, _, err := oscconn.SnapshotApi.DeleteSnapshot(context.Background(), &osc.DeleteSnapshotOpts{ DeleteSnapshotRequest: optional.NewInterface(osc.DeleteSnapshotRequest{SnapshotId: s.snapshotId}), diff --git a/builder/osc/chroot/step_vm_info.go b/builder/osc/chroot/step_vm_info.go index fa9d6079e..6ae4c8b9b 100644 --- a/builder/osc/chroot/step_vm_info.go +++ b/builder/osc/chroot/step_vm_info.go @@ -6,8 +6,8 @@ import ( "log" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -17,7 +17,7 @@ type StepVmInfo struct{} func (s *StepVmInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) //session := state.Get("clientConfig").(*session.Session) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Get our own vm ID ui.Say("Gathering information about this Outscale vm...") diff --git a/builder/osc/common/step_cleanup_volumes.go b/builder/osc/common/step_cleanup_volumes.go index 171dfaa40..a71cc1fbb 100644 --- a/builder/osc/common/step_cleanup_volumes.go +++ b/builder/osc/common/step_cleanup_volumes.go @@ -6,8 +6,8 @@ import ( "reflect" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -32,7 +32,7 @@ func (s *StepCleanupVolumes) Cleanup(state multistep.StateBag) { if vmRaw != nil { vm = vmRaw.(osc.Vm) } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if vm.VmId == "" { ui.Say("No volumes to clean up, skipping") return diff --git a/builder/osc/common/step_create_tags.go b/builder/osc/common/step_create_tags.go index db06dec96..902ce1c5a 100644 --- a/builder/osc/common/step_create_tags.go +++ b/builder/osc/common/step_create_tags.go @@ -7,8 +7,8 @@ import ( "github.com/antihax/optional" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/hashicorp/packer/builder/osc/common/retry" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/outscale/osc-sdk-go/osc" ) @@ -21,7 +21,7 @@ type StepCreateTags struct { func (s *StepCreateTags) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("accessConfig").(*AccessConfig) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) omis := state.Get("omis").(map[string]string) if !s.Tags.IsSet() && !s.SnapshotTags.IsSet() { diff --git a/builder/osc/common/step_deregister_omi.go b/builder/osc/common/step_deregister_omi.go index f080d3d3c..e7d538659 100644 --- a/builder/osc/common/step_deregister_omi.go +++ b/builder/osc/common/step_deregister_omi.go @@ -8,8 +8,8 @@ import ( "github.com/antihax/optional" "github.com/outscale/osc-sdk-go/osc" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepDeregisterOMI struct { @@ -26,7 +26,7 @@ func (s *StepDeregisterOMI) Run(_ context.Context, state multistep.StateBag) mul return multistep.ActionContinue } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) s.Regions = append(s.Regions, s.AccessConfig.GetRegion()) diff --git a/builder/osc/common/step_get_password.go b/builder/osc/common/step_get_password.go index ccef02481..c68570601 100644 --- a/builder/osc/common/step_get_password.go +++ b/builder/osc/common/step_get_password.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -28,7 +29,7 @@ type StepGetPassword struct { } func (s *StepGetPassword) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip if we're not using winrm if s.Comm.Type != "winrm" { diff --git a/builder/osc/common/step_key_pair.go b/builder/osc/common/step_key_pair.go index 6589c4831..be3d5f1cf 100644 --- a/builder/osc/common/step_key_pair.go +++ b/builder/osc/common/step_key_pair.go @@ -8,8 +8,8 @@ import ( "github.com/antihax/optional" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -22,7 +22,7 @@ type StepKeyPair struct { } func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key") @@ -110,7 +110,7 @@ func (s *StepKeyPair) Cleanup(state multistep.StateBag) { var ( conn = state.Get("osc").(*osc.APIClient) - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) ) // Remove the keypair diff --git a/builder/osc/common/step_network_info.go b/builder/osc/common/step_network_info.go index e1fdb8bfe..e3ed82abc 100644 --- a/builder/osc/common/step_network_info.go +++ b/builder/osc/common/step_network_info.go @@ -8,8 +8,8 @@ import ( "sort" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -48,7 +48,7 @@ func mostFreeOscSubnet(subnets []osc.Subnet) osc.Subnet { //Run ... func (s *StepNetworkInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // NET if s.NetId == "" && !s.NetFilter.Empty() { diff --git a/builder/osc/common/step_pre_validate.go b/builder/osc/common/step_pre_validate.go index 7c3151505..3ac8d3622 100644 --- a/builder/osc/common/step_pre_validate.go +++ b/builder/osc/common/step_pre_validate.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -20,7 +20,7 @@ type StepPreValidate struct { } func (s *StepPreValidate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.ForceDeregister { ui.Say("Force Deregister flag found, skipping prevalidating OMI Name") return multistep.ActionContinue diff --git a/builder/osc/common/step_public_ip.go b/builder/osc/common/step_public_ip.go index 51d4f2c8c..2074ba8b7 100644 --- a/builder/osc/common/step_public_ip.go +++ b/builder/osc/common/step_public_ip.go @@ -6,8 +6,8 @@ import ( "github.com/antihax/optional" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -22,7 +22,7 @@ type StepPublicIp struct { func (s *StepPublicIp) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { var ( - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) conn = state.Get("osc").(*osc.APIClient) ) @@ -61,7 +61,7 @@ func (s *StepPublicIp) Cleanup(state multistep.StateBag) { var ( conn = state.Get("osc").(*osc.APIClient) - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) ) // Remove the Public IP diff --git a/builder/osc/common/step_run_source_vm.go b/builder/osc/common/step_run_source_vm.go index 36188058a..d81f7396e 100644 --- a/builder/osc/common/step_run_source_vm.go +++ b/builder/osc/common/step_run_source_vm.go @@ -14,8 +14,8 @@ import ( "github.com/hashicorp/packer/builder/osc/common/retry" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -48,7 +48,7 @@ type StepRunSourceVm struct { func (s *StepRunSourceVm) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) securityGroupIds := state.Get("securityGroupIds").([]string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) userData := s.UserData if s.UserDataFile != "" { @@ -302,7 +302,7 @@ func (s *StepRunSourceVm) Run(ctx context.Context, state multistep.StateBag) mul func (s *StepRunSourceVm) Cleanup(state multistep.StateBag) { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Terminate the source vm if it exists if s.vmId != "" { diff --git a/builder/osc/common/step_security_group.go b/builder/osc/common/step_security_group.go index 789f101e7..79fb5192a 100644 --- a/builder/osc/common/step_security_group.go +++ b/builder/osc/common/step_security_group.go @@ -8,8 +8,8 @@ import ( "github.com/antihax/optional" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" "github.com/outscale/osc-sdk-go/osc" ) @@ -25,7 +25,7 @@ type StepSecurityGroup struct { func (s *StepSecurityGroup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { var ( - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) conn = state.Get("osc").(*osc.APIClient) netID = state.Get("net_id").(string) ) @@ -153,7 +153,7 @@ func (s *StepSecurityGroup) Cleanup(state multistep.StateBag) { } var ( - ui = state.Get("ui").(packer.Ui) + ui = state.Get("ui").(packersdk.Ui) conn = state.Get("osc").(*osc.APIClient) ) diff --git a/builder/osc/common/step_source_omi_info.go b/builder/osc/common/step_source_omi_info.go index 64e1df704..18fc81877 100644 --- a/builder/osc/common/step_source_omi_info.go +++ b/builder/osc/common/step_source_omi_info.go @@ -8,8 +8,8 @@ import ( "time" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -43,7 +43,7 @@ func mostRecentOscOmi(images []osc.Image) osc.Image { func (s *StepSourceOMIInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) params := osc.ReadImagesRequest{ Filters: osc.FiltersImage{}, diff --git a/builder/osc/common/step_stop_bsu_backed_vm.go b/builder/osc/common/step_stop_bsu_backed_vm.go index 5c45a126b..aad924cd7 100644 --- a/builder/osc/common/step_stop_bsu_backed_vm.go +++ b/builder/osc/common/step_stop_bsu_backed_vm.go @@ -7,8 +7,8 @@ import ( "github.com/antihax/optional" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/hashicorp/packer/builder/osc/common/retry" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -20,7 +20,7 @@ type StepStopBSUBackedVm struct { func (s *StepStopBSUBackedVm) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { oscconn := state.Get("osc").(*osc.APIClient) vm := state.Get("vm").(osc.Vm) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip when it is a spot vm if s.Skip { diff --git a/builder/osc/common/step_update_bsu_vm.go b/builder/osc/common/step_update_bsu_vm.go index 48cbbcd13..325b5db6a 100644 --- a/builder/osc/common/step_update_bsu_vm.go +++ b/builder/osc/common/step_update_bsu_vm.go @@ -14,7 +14,7 @@ type StepUpdateBSUBackedVm struct { func (s *StepUpdateBSUBackedVm) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { // oapiconn := state.Get("oapi").(*oapi.Client) // vm := state.Get("vm").(*oapi.Vm) - // ui := state.Get("ui").(packer.Ui) + // ui := state.Get("ui").(packersdk.Ui) // Set SriovNetSupport to "simple". See http://goo.gl/icuXh5 // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) diff --git a/builder/osc/common/step_update_omi.go b/builder/osc/common/step_update_omi.go index d523426de..790e977d1 100644 --- a/builder/osc/common/step_update_omi.go +++ b/builder/osc/common/step_update_omi.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/outscale/osc-sdk-go/osc" ) @@ -20,7 +20,7 @@ type StepUpdateOMIAttributes struct { func (s *StepUpdateOMIAttributes) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("accessConfig").(*AccessConfig) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) omis := state.Get("omis").(map[string]string) snapshots := state.Get("snapshots").(map[string][]string) diff --git a/builder/osc/common/tags.go b/builder/osc/common/tags.go index 446c191bb..dca8922a4 100644 --- a/builder/osc/common/tags.go +++ b/builder/osc/common/tags.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/outscale/osc-sdk-go/osc" ) @@ -14,7 +14,7 @@ import ( type TagMap map[string]string type OSCTags []osc.ResourceTag -func (t OSCTags) Report(ui packer.Ui) { +func (t OSCTags) Report(ui packersdk.Ui) { for _, tag := range t { ui.Message(fmt.Sprintf("Adding tag: \"%s\": \"%s\"", tag.Key, tag.Value)) @@ -46,7 +46,7 @@ func (t TagMap) OSCTags(ctx interpolate.Context, region string, state multistep. return oscTags, nil } -func CreateOSCTags(conn *osc.APIClient, resourceID string, ui packer.Ui, tags OSCTags) error { +func CreateOSCTags(conn *osc.APIClient, resourceID string, ui packersdk.Ui, tags OSCTags) error { tags.Report(ui) _, _, err := conn.TagApi.CreateTags(context.Background(), &osc.CreateTagsOpts{ diff --git a/builder/parallels/common/step_attach_floppy.go b/builder/parallels/common/step_attach_floppy.go index 7d310ab75..854a9204c 100644 --- a/builder/parallels/common/step_attach_floppy.go +++ b/builder/parallels/common/step_attach_floppy.go @@ -5,15 +5,15 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepAttachFloppy is a step that attaches a floppy to the virtual machine. // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -34,7 +34,7 @@ func (s *StepAttachFloppy) Run(ctx context.Context, state multistep.StateBag) mu } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Deleting any current floppy disk...") diff --git a/builder/parallels/common/step_attach_parallels_tools.go b/builder/parallels/common/step_attach_parallels_tools.go index 638408115..f1a8a807a 100644 --- a/builder/parallels/common/step_attach_parallels_tools.go +++ b/builder/parallels/common/step_attach_parallels_tools.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepAttachParallelsTools is a step that attaches Parallels Tools ISO image @@ -15,7 +15,7 @@ import ( // Uses: // driver Driver // parallels_tools_path string -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -28,7 +28,7 @@ type StepAttachParallelsTools struct { // If ISO image is not specified, then this step will be skipped. func (s *StepAttachParallelsTools) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) // If we're not attaching the guest additions then just return @@ -65,7 +65,7 @@ func (s *StepAttachParallelsTools) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) log.Println("Detaching Parallels Tools ISO...") diff --git a/builder/parallels/common/step_compact_disk.go b/builder/parallels/common/step_compact_disk.go index e757336ef..26aea8479 100644 --- a/builder/parallels/common/step_compact_disk.go +++ b/builder/parallels/common/step_compact_disk.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCompactDisk is a step that removes all empty blocks from expanding @@ -14,7 +14,7 @@ import ( // Uses: // driver Driver // vmName string -// ui packer.Ui +// ui packersdk.Ui // // Produces: // @@ -26,7 +26,7 @@ type StepCompactDisk struct { func (s *StepCompactDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Skip { ui.Say("Skipping disk compaction step...") diff --git a/builder/parallels/common/step_output_dir.go b/builder/parallels/common/step_output_dir.go index 97115d8e4..b0b7083b9 100644 --- a/builder/parallels/common/step_output_dir.go +++ b/builder/parallels/common/step_output_dir.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepOutputDir sets up the output directory by creating it if it does @@ -23,7 +23,7 @@ type StepOutputDir struct { // Run sets up the output directory. func (s *StepOutputDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if _, err := os.Stat(s.Path); err == nil && s.Force { ui.Say("Deleting previous output directory...") @@ -60,7 +60,7 @@ func (s *StepOutputDir) Cleanup(state multistep.StateBag) { } if cancelled || halted { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting output directory...") for i := 0; i < 5; i++ { diff --git a/builder/parallels/common/step_prlctl.go b/builder/parallels/common/step_prlctl.go index 5f31812b6..431b0a327 100644 --- a/builder/parallels/common/step_prlctl.go +++ b/builder/parallels/common/step_prlctl.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -19,7 +19,7 @@ type commandTemplate struct { // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -31,7 +31,7 @@ type StepPrlctl struct { // Run executes `prlctl` commands. func (s *StepPrlctl) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if len(s.Commands) > 0 { diff --git a/builder/parallels/common/step_run.go b/builder/parallels/common/step_run.go index a0772fdd0..a98ff9190 100644 --- a/builder/parallels/common/step_run.go +++ b/builder/parallels/common/step_run.go @@ -4,15 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepRun is a step that starts the virtual machine. // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -23,7 +23,7 @@ type StepRun struct { // Run starts the VM. func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Starting the virtual machine...") @@ -50,7 +50,7 @@ func (s *StepRun) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if running, _ := driver.IsRunning(s.vmName); running { if err := driver.Stop(s.vmName); err != nil { diff --git a/builder/parallels/common/step_shutdown.go b/builder/parallels/common/step_shutdown.go index cd1f5a232..20c06a39a 100644 --- a/builder/parallels/common/step_shutdown.go +++ b/builder/parallels/common/step_shutdown.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepShutdown is a step that shuts down the machine. It first attempts to do @@ -18,7 +19,7 @@ import ( // Uses: // communicator packer.Communicator // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -32,7 +33,7 @@ type StepShutdown struct { func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.Command != "" { diff --git a/builder/parallels/common/step_type_boot_command.go b/builder/parallels/common/step_type_boot_command.go index 31f55e8f7..344e8aa4b 100644 --- a/builder/parallels/common/step_type_boot_command.go +++ b/builder/parallels/common/step_type_boot_command.go @@ -5,9 +5,9 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -32,7 +32,7 @@ type StepTypeBootCommand struct { func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { debug := state.Get("debug").(bool) httpPort := state.Get("http_port").(int) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) driver := state.Get("driver").(Driver) // Wait the for the vm to boot. diff --git a/builder/parallels/common/step_upload_parallels_tools.go b/builder/parallels/common/step_upload_parallels_tools.go index f70e7b60b..e50ca8923 100644 --- a/builder/parallels/common/step_upload_parallels_tools.go +++ b/builder/parallels/common/step_upload_parallels_tools.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -16,7 +17,7 @@ import ( // Uses: // communicator packer.Communicator // parallels_tools_path string -// ui packer.Ui +// ui packersdk.Ui // // Produces: type toolsPathTemplate struct { @@ -29,7 +30,7 @@ type toolsPathTemplate struct { // Uses: // communicator packer.Communicator // parallels_tools_path string -// ui packer.Ui +// ui packersdk.Ui type StepUploadParallelsTools struct { ParallelsToolsFlavor string ParallelsToolsGuestPath string @@ -40,7 +41,7 @@ type StepUploadParallelsTools struct { // Run uploads the Parallels Tools ISO to the VM. func (s *StepUploadParallelsTools) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // If we're attaching then don't do this, since we attached. if s.ParallelsToolsMode != ParallelsToolsModeUpload { diff --git a/builder/parallels/common/step_upload_version.go b/builder/parallels/common/step_upload_version.go index 072bece70..a42d6257d 100644 --- a/builder/parallels/common/step_upload_version.go +++ b/builder/parallels/common/step_upload_version.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepUploadVersion is a step that uploads a file containing the version of @@ -16,7 +17,7 @@ import ( // Uses: // communicator packer.Communicator // driver Driver -// ui packer.Ui +// ui packersdk.Ui type StepUploadVersion struct { Path string } @@ -25,7 +26,7 @@ type StepUploadVersion struct { func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Path == "" { log.Println("ParallelsVersionFile is empty. Not uploading.") diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 0fa823f0a..2788537bf 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -180,7 +181,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/parallels/iso/step_attach_iso.go b/builder/parallels/iso/step_attach_iso.go index ccaced1c0..c59c80c33 100644 --- a/builder/parallels/iso/step_attach_iso.go +++ b/builder/parallels/iso/step_attach_iso.go @@ -6,8 +6,8 @@ import ( "log" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step attaches the ISO to the virtual machine. @@ -15,7 +15,7 @@ import ( // Uses: // driver Driver // iso_path string -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -25,7 +25,7 @@ type stepAttachISO struct{} func (s *stepAttachISO) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(parallelscommon.Driver) isoPath := state.Get("iso_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) // Attach the disk to the cdrom0 device. We couldn't use a separated device because it is failed to boot in PD9 [GH-1667] @@ -55,7 +55,7 @@ func (s *stepAttachISO) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) // Detach ISO by setting an empty string image. diff --git a/builder/parallels/iso/step_create_disk.go b/builder/parallels/iso/step_create_disk.go index dbe71e4b7..d70f6d749 100644 --- a/builder/parallels/iso/step_create_disk.go +++ b/builder/parallels/iso/step_create_disk.go @@ -6,8 +6,8 @@ import ( "strconv" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates the virtual disk that will be used as the @@ -17,7 +17,7 @@ type stepCreateDisk struct{} func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) command := []string{ diff --git a/builder/parallels/iso/step_create_vm.go b/builder/parallels/iso/step_create_vm.go index ad7a32f81..f92ce5ddf 100644 --- a/builder/parallels/iso/step_create_vm.go +++ b/builder/parallels/iso/step_create_vm.go @@ -6,8 +6,8 @@ import ( "strconv" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates the actual virtual machine. @@ -22,7 +22,7 @@ func (s *stepCreateVM) Run(ctx context.Context, state multistep.StateBag) multis config := state.Get("config").(*Config) driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.VMName commands := make([][]string, 3) @@ -91,7 +91,7 @@ func (s *stepCreateVM) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Unregistering virtual machine...") if err := driver.Prlctl("unregister", s.vmName); err != nil { diff --git a/builder/parallels/iso/step_set_boot_order.go b/builder/parallels/iso/step_set_boot_order.go index 7d50251be..d8891dd81 100644 --- a/builder/parallels/iso/step_set_boot_order.go +++ b/builder/parallels/iso/step_set_boot_order.go @@ -5,15 +5,15 @@ import ( "fmt" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step sets the device boot order for the virtual machine. // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -21,7 +21,7 @@ type stepSetBootOrder struct{} func (s *stepSetBootOrder) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) // Set new boot order diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 532c37658..c535d55d4 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Builder implements packer.Builder and builds the actual Parallels @@ -33,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a Parallels appliance. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/parallels/pvm/step_import.go b/builder/parallels/pvm/step_import.go index 1530ee301..6ee096504 100644 --- a/builder/parallels/pvm/step_import.go +++ b/builder/parallels/pvm/step_import.go @@ -5,8 +5,8 @@ import ( "fmt" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step imports an PVM VM into Parallels. @@ -18,7 +18,7 @@ type StepImport struct { func (s *StepImport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say(fmt.Sprintf("Importing VM: %s", s.SourcePath)) @@ -41,7 +41,7 @@ func (s *StepImport) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(parallelscommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Unregistering virtual machine...") if err := driver.Prlctl("unregister", s.vmName); err != nil { diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index 2261a96f5..c89c805ee 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const BuilderId = "packer.profitbricks" @@ -29,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("config", &b.config) diff --git a/builder/profitbricks/step_create_server.go b/builder/profitbricks/step_create_server.go index 21464c673..7bcd60986 100644 --- a/builder/profitbricks/step_create_server.go +++ b/builder/profitbricks/step_create_server.go @@ -9,15 +9,15 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/profitbricks/profitbricks-sdk-go" ) type stepCreateServer struct{} func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) profitbricks.SetAuth(c.PBUsername, c.PBPassword) @@ -158,7 +158,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu func (s *stepCreateServer) Cleanup(state multistep.StateBag) { c := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Removing Virtual Data Center...") @@ -240,7 +240,7 @@ func (d *stepCreateServer) getImageId(imageName string, c *Config) string { return "" } -func (d *stepCreateServer) getImageAlias(imageAlias string, location string, ui packer.Ui) string { +func (d *stepCreateServer) getImageAlias(imageAlias string, location string, ui packersdk.Ui) string { if imageAlias == "" { return "" } diff --git a/builder/profitbricks/step_create_ssh_key.go b/builder/profitbricks/step_create_ssh_key.go index 19d8a2044..aaa8fae48 100644 --- a/builder/profitbricks/step_create_ssh_key.go +++ b/builder/profitbricks/step_create_ssh_key.go @@ -6,8 +6,8 @@ import ( "encoding/pem" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -17,7 +17,7 @@ type StepCreateSSHKey struct { } func (s *StepCreateSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) if c.Comm.SSHPrivateKeyFile != "" { diff --git a/builder/profitbricks/step_take_snapshot.go b/builder/profitbricks/step_take_snapshot.go index c545f8521..58d3024e7 100644 --- a/builder/profitbricks/step_take_snapshot.go +++ b/builder/profitbricks/step_take_snapshot.go @@ -5,15 +5,15 @@ import ( "encoding/json" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/profitbricks/profitbricks-sdk-go" ) type stepTakeSnapshot struct{} func (s *stepTakeSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) ui.Say("Creating ProfitBricks snapshot...") diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index f84fb216e..b1cf07c4c 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -6,6 +6,7 @@ import ( proxmox "github.com/hashicorp/packer/builder/proxmox/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "context" "fmt" @@ -27,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return b.config.Prepare(raws...) } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("clone-config", &b.config) diff --git a/builder/proxmox/clone/step_ssh_key_pair.go b/builder/proxmox/clone/step_ssh_key_pair.go index 3626f80c8..f2bbb5fa1 100644 --- a/builder/proxmox/clone/step_ssh_key_pair.go +++ b/builder/proxmox/clone/step_ssh_key_pair.go @@ -7,8 +7,8 @@ import ( common "github.com/hashicorp/packer/builder/proxmox/common" "github.com/hashicorp/packer/helper/communicator/ssh" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -20,7 +20,7 @@ type StepSshKeyPair struct { } func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*common.Config) if c.Comm.SSHPassword != "" { @@ -99,7 +99,7 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult func (s *StepSshKeyPair) Cleanup(state multistep.StateBag) { if s.Debug { if err := os.Remove(s.DebugKeyPath); err != nil { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Error(fmt.Sprintf( "Error removing debug key '%s': %s", s.DebugKeyPath, err)) } diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index b592a6fdb..981c62576 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func NewSharedBuilder(id string, config Config, preSteps []multistep.Step, postSteps []multistep.Step, vmCreator ProxmoxVMCreator) *Builder { @@ -33,7 +34,7 @@ type Builder struct { vmCreator ProxmoxVMCreator } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state multistep.StateBag) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook, state multistep.StateBag) (packer.Artifact, error) { var err error tlsConfig := &tls.Config{ InsecureSkipVerify: b.config.SkipCertValidation, diff --git a/builder/proxmox/common/step_convert_to_template.go b/builder/proxmox/common/step_convert_to_template.go index 3d177bfc9..58d4dfe41 100644 --- a/builder/proxmox/common/step_convert_to_template.go +++ b/builder/proxmox/common/step_convert_to_template.go @@ -6,8 +6,8 @@ import ( "log" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepConvertToTemplate takes the running VM configured in earlier steps, stops it, and @@ -24,7 +24,7 @@ type templateConverter interface { var _ templateConverter = &proxmox.Client{} func (s *stepConvertToTemplate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("proxmoxClient").(templateConverter) vmRef := state.Get("vmRef").(*proxmox.VmRef) diff --git a/builder/proxmox/common/step_finalize_template_config.go b/builder/proxmox/common/step_finalize_template_config.go index 901d30bff..d1bdea3d6 100644 --- a/builder/proxmox/common/step_finalize_template_config.go +++ b/builder/proxmox/common/step_finalize_template_config.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepFinalizeTemplateConfig does any required modifications to the configuration _after_ @@ -23,7 +23,7 @@ type templateFinalizer interface { var _ templateFinalizer = &proxmox.Client{} func (s *stepFinalizeTemplateConfig) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("proxmoxClient").(templateFinalizer) c := state.Get("config").(*Config) vmRef := state.Get("vmRef").(*proxmox.VmRef) diff --git a/builder/proxmox/common/step_start_vm.go b/builder/proxmox/common/step_start_vm.go index 09951660f..53b3c6754 100644 --- a/builder/proxmox/common/step_start_vm.go +++ b/builder/proxmox/common/step_start_vm.go @@ -7,8 +7,8 @@ import ( "strconv" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepStartVM takes the given configuration and starts a VM on the given Proxmox node. @@ -24,7 +24,7 @@ type ProxmoxVMCreator interface { } func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("proxmoxClient").(*proxmox.Client) c := state.Get("config").(*Config) @@ -180,7 +180,7 @@ func (s *stepStartVM) Cleanup(state multistep.StateBag) { } client := state.Get("proxmoxClient").(startedVMCleaner) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Destroy the server we just created ui.Say("Stopping VM") diff --git a/builder/proxmox/common/step_type_boot_command.go b/builder/proxmox/common/step_type_boot_command.go index 878d9b837..bcbe71e5a 100644 --- a/builder/proxmox/common/step_type_boot_command.go +++ b/builder/proxmox/common/step_type_boot_command.go @@ -9,9 +9,9 @@ import ( "time" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -34,7 +34,7 @@ type commandTyper interface { var _ commandTyper = &proxmox.Client{} func (s *stepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) client := state.Get("proxmoxClient").(commandTyper) vmRef := state.Get("vmRef").(*proxmox.VmRef) diff --git a/builder/proxmox/iso/builder.go b/builder/proxmox/iso/builder.go index 8cc248aec..b6b59abcc 100644 --- a/builder/proxmox/iso/builder.go +++ b/builder/proxmox/iso/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // The unique id for the builder @@ -29,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { const downloadPathKey = "downloaded_iso_path" -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("iso-config", &b.config) diff --git a/builder/proxmox/iso/step_finalize_iso.go b/builder/proxmox/iso/step_finalize_iso.go index ee504c0e7..ef9388896 100644 --- a/builder/proxmox/iso/step_finalize_iso.go +++ b/builder/proxmox/iso/step_finalize_iso.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepFinalizeISOTemplate does any ISO-builder specific modifications after @@ -23,7 +23,7 @@ type templateFinalizer interface { var _ templateFinalizer = &proxmox.Client{} func (s *stepFinalizeISOTemplate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("proxmoxClient").(templateFinalizer) c := state.Get("iso-config").(*Config) vmRef := state.Get("vmRef").(*proxmox.VmRef) diff --git a/builder/proxmox/iso/step_upload_additional_isos.go b/builder/proxmox/iso/step_upload_additional_isos.go index e2b7af894..8b2c87f3a 100644 --- a/builder/proxmox/iso/step_upload_additional_isos.go +++ b/builder/proxmox/iso/step_upload_additional_isos.go @@ -7,8 +7,8 @@ import ( "path/filepath" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepUploadAdditionalISOs uploads all additional ISO files that are mountet @@ -18,7 +18,7 @@ type stepUploadAdditionalISOs struct{} var _ uploader = &proxmox.Client{} func (s *stepUploadAdditionalISOs) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("proxmoxClient").(uploader) c := state.Get("iso-config").(*Config) diff --git a/builder/proxmox/iso/step_upload_iso.go b/builder/proxmox/iso/step_upload_iso.go index 3edef379a..4a54bc87e 100644 --- a/builder/proxmox/iso/step_upload_iso.go +++ b/builder/proxmox/iso/step_upload_iso.go @@ -8,8 +8,8 @@ import ( "path/filepath" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepUploadISO uploads an ISO file to Proxmox so we can boot from it @@ -22,7 +22,7 @@ type uploader interface { var _ uploader = &proxmox.Client{} func (s *stepUploadISO) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("proxmoxClient").(uploader) c := state.Get("iso-config").(*Config) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index fc24b592c..3522ed59f 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const BuilderId = "transcend.qemu" @@ -34,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with Qemu driver, err := b.newDriver(b.config.QemuBinary) if err != nil { diff --git a/builder/qemu/step_configure_qmp.go b/builder/qemu/step_configure_qmp.go index de87d99bf..a85ed092b 100644 --- a/builder/qemu/step_configure_qmp.go +++ b/builder/qemu/step_configure_qmp.go @@ -8,15 +8,15 @@ import ( "time" "github.com/digitalocean/go-qemu/qmp" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step configures the VM to enable the QMP listener. // // Uses: // config *config -// ui packer.Ui +// ui packersdk.Ui // // Produces: type stepConfigureQMP struct { @@ -26,7 +26,7 @@ type stepConfigureQMP struct { func (s *stepConfigureQMP) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !config.QMPEnable { return multistep.ActionContinue diff --git a/builder/qemu/step_configure_vnc.go b/builder/qemu/step_configure_vnc.go index 87a095dc7..84da95bc9 100644 --- a/builder/qemu/step_configure_vnc.go +++ b/builder/qemu/step_configure_vnc.go @@ -6,16 +6,16 @@ import ( "log" "math/rand" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step configures the VM to enable the VNC server. // // Uses: // config *config -// ui packer.Ui +// ui packersdk.Ui // // Produces: // vnc_port int - The port that VNC is configured to listen on. @@ -40,7 +40,7 @@ func VNCPassword() string { func (s *stepConfigureVNC) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Find an open VNC port. Note that this can still fail later on // because we have to release the port at some point. But this does its diff --git a/builder/qemu/step_convert_disk.go b/builder/qemu/step_convert_disk.go index 1f7952248..09636b5b0 100644 --- a/builder/qemu/step_convert_disk.go +++ b/builder/qemu/step_convert_disk.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "os" @@ -28,7 +28,7 @@ type stepConvertDisk struct { func (s *stepConvertDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) diskName := s.VMName diff --git a/builder/qemu/step_copy_disk.go b/builder/qemu/step_copy_disk.go index c5600a31b..9a7cfd817 100644 --- a/builder/qemu/step_copy_disk.go +++ b/builder/qemu/step_copy_disk.go @@ -5,8 +5,8 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step copies the virtual disk that will be used as the @@ -24,7 +24,7 @@ type stepCopyDisk struct { func (s *stepCopyDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) isoPath := state.Get("iso_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) path := filepath.Join(s.OutputDir, s.VMName) if !s.DiskImage || s.UseBackingFile { diff --git a/builder/qemu/step_create_disk.go b/builder/qemu/step_create_disk.go index 8a0c8eb51..c8bc29940 100644 --- a/builder/qemu/step_create_disk.go +++ b/builder/qemu/step_create_disk.go @@ -6,8 +6,8 @@ import ( "log" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates the virtual disk that will be used as the @@ -25,7 +25,7 @@ type stepCreateDisk struct { func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := s.VMName if s.DiskImage && !s.UseBackingFile { diff --git a/builder/qemu/step_http_ip_discover.go b/builder/qemu/step_http_ip_discover.go index 416cdac56..3a87fd5a9 100644 --- a/builder/qemu/step_http_ip_discover.go +++ b/builder/qemu/step_http_ip_discover.go @@ -5,8 +5,8 @@ import ( "fmt" "net" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Step to discover the http ip @@ -16,7 +16,7 @@ type stepHTTPIPDiscover struct{} func (s *stepHTTPIPDiscover) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) hostIP := "" diff --git a/builder/qemu/step_port_forward.go b/builder/qemu/step_port_forward.go index 77dcc1248..279a913fc 100644 --- a/builder/qemu/step_port_forward.go +++ b/builder/qemu/step_port_forward.go @@ -5,9 +5,9 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step adds a NAT port forwarding definition so that SSH or WinRM is available @@ -21,7 +21,7 @@ type stepPortForward struct { func (s *stepPortForward) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.CommunicatorType == "none" { ui.Message("No communicator is set; skipping port forwarding setup.") diff --git a/builder/qemu/step_prepare_output_dir.go b/builder/qemu/step_prepare_output_dir.go index 75118fdf0..11370bd98 100644 --- a/builder/qemu/step_prepare_output_dir.go +++ b/builder/qemu/step_prepare_output_dir.go @@ -6,15 +6,15 @@ import ( "os" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepPrepareOutputDir struct{} func (stepPrepareOutputDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if _, err := os.Stat(config.OutputDir); err == nil && config.PackerForce { ui.Say("Deleting previous output directory...") @@ -35,7 +35,7 @@ func (stepPrepareOutputDir) Cleanup(state multistep.StateBag) { if cancelled || halted { config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting output directory...") for i := 0; i < 5; i++ { diff --git a/builder/qemu/step_resize_disk.go b/builder/qemu/step_resize_disk.go index c2daf20cf..33288e3b8 100644 --- a/builder/qemu/step_resize_disk.go +++ b/builder/qemu/step_resize_disk.go @@ -5,8 +5,8 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step resizes the virtual disk that will be used as the @@ -25,7 +25,7 @@ type stepResizeDisk struct { func (s *stepResizeDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) path := filepath.Join(s.OutputDir, s.VMName) command := s.buildResizeCommand(path) diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 873b79256..16a7470a1 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/hashicorp/go-version" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -18,13 +18,13 @@ type stepRun struct { DiskImage bool atLeastVersion2 bool - ui packer.Ui + ui packersdk.Ui } func (s *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - s.ui = state.Get("ui").(packer.Ui) + s.ui = state.Get("ui").(packersdk.Ui) // Figure out version of qemu; store on step for later use rawVersion, err := driver.Version() @@ -63,7 +63,7 @@ func (s *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S func (s *stepRun) Cleanup(state multistep.StateBag) { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := driver.Stop(); err != nil { ui.Error(fmt.Sprintf("Error shutting down VM: %s", err)) diff --git a/builder/qemu/step_set_iso.go b/builder/qemu/step_set_iso.go index 3f6263be7..3dec89501 100644 --- a/builder/qemu/step_set_iso.go +++ b/builder/qemu/step_set_iso.go @@ -5,9 +5,9 @@ import ( "fmt" "net/http" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step set iso_patch to available url @@ -17,7 +17,7 @@ type stepSetISO struct { } func (s *stepSetISO) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) iso_path := "" diff --git a/builder/qemu/step_shutdown.go b/builder/qemu/step_shutdown.go index 3dbe1743a..594c8b3ff 100644 --- a/builder/qemu/step_shutdown.go +++ b/builder/qemu/step_shutdown.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -19,7 +20,7 @@ import ( // communicator packer.Communicator // config *config // driver Driver -// ui packer.Ui +// ui packersdk.Ui // // Produces: // @@ -31,7 +32,7 @@ type stepShutdown struct { func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.Type == "none" { cancelCh := make(chan struct{}, 1) diff --git a/builder/qemu/step_type_boot_command.go b/builder/qemu/step_type_boot_command.go index 27a6f8e48..9167d914d 100644 --- a/builder/qemu/step_type_boot_command.go +++ b/builder/qemu/step_type_boot_command.go @@ -7,9 +7,9 @@ import ( "net" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/go-vnc" ) @@ -27,7 +27,7 @@ type bootCommandTemplateData struct { // Uses: // config *config // http_port int -// ui packer.Ui +// ui packersdk.Ui // vnc_port int // // Produces: @@ -38,7 +38,7 @@ func (s *stepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) config := state.Get("config").(*Config) debug := state.Get("debug").(bool) httpPort := state.Get("http_port").(int) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vncPort := state.Get("vnc_port").(int) vncIP := config.VNCBindAddress vncPassword := state.Get("vnc_password") diff --git a/builder/qemu/step_wait_guest_address.go b/builder/qemu/step_wait_guest_address.go index 938083e5b..3acf42f33 100644 --- a/builder/qemu/step_wait_guest_address.go +++ b/builder/qemu/step_wait_guest_address.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/digitalocean/go-qemu/qmp" ) @@ -26,7 +26,7 @@ type stepWaitGuestAddress struct { } func (s *stepWaitGuestAddress) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.CommunicatorType == "none" { ui.Message("No communicator is configured -- skipping StepWaitGuestAddress") diff --git a/builder/scaleway/builder.go b/builder/scaleway/builder.go index 9db7423cd..bc78d5253 100644 --- a/builder/scaleway/builder.go +++ b/builder/scaleway/builder.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -35,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { scwZone, err := scw.ParseZone(b.config.Zone) if err != nil { ui.Error(err.Error()) diff --git a/builder/scaleway/step_create_image.go b/builder/scaleway/step_create_image.go index 556a029e2..67244ff74 100644 --- a/builder/scaleway/step_create_image.go +++ b/builder/scaleway/step_create_image.go @@ -6,8 +6,8 @@ import ( "log" "github.com/hashicorp/go-uuid" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/api/marketplace/v1" "github.com/scaleway/scaleway-sdk-go/scw" @@ -17,7 +17,7 @@ type stepImage struct{} func (s *stepImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) snapshotID := state.Get("snapshot_id").(string) bootscriptID := "" diff --git a/builder/scaleway/step_create_server.go b/builder/scaleway/step_create_server.go index 08c4ec3c5..7ead2b1a7 100644 --- a/builder/scaleway/step_create_server.go +++ b/builder/scaleway/step_create_server.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -17,7 +17,7 @@ type stepCreateServer struct { func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) tags := []string{} var bootscript *string @@ -76,7 +76,7 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) { } instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Destroying server...") diff --git a/builder/scaleway/step_create_ssh_key.go b/builder/scaleway/step_create_ssh_key.go index 5d746029f..f4f533371 100644 --- a/builder/scaleway/step_create_ssh_key.go +++ b/builder/scaleway/step_create_ssh_key.go @@ -11,8 +11,8 @@ import ( "os" "runtime" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -22,7 +22,7 @@ type stepCreateSSHKey struct { } func (s *stepCreateSSHKey) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.Comm.SSHPrivateKeyFile != "" { diff --git a/builder/scaleway/step_pre_validate.go b/builder/scaleway/step_pre_validate.go index f991b787a..3d4afb6bc 100644 --- a/builder/scaleway/step_pre_validate.go +++ b/builder/scaleway/step_pre_validate.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -20,7 +20,7 @@ type stepPreValidate struct { } func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Force { ui.Say("Force flag found, skipping prevalidating image name") diff --git a/builder/scaleway/step_remove_volume.go b/builder/scaleway/step_remove_volume.go index 451047b3c..a9a3133a4 100644 --- a/builder/scaleway/step_remove_volume.go +++ b/builder/scaleway/step_remove_volume.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -25,7 +25,7 @@ func (s *stepRemoveVolume) Cleanup(state multistep.StateBag) { } instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) volumeID := state.Get("root_volume_id").(string) diff --git a/builder/scaleway/step_server_info.go b/builder/scaleway/step_server_info.go index 28dec4cd5..3cc88aab5 100644 --- a/builder/scaleway/step_server_info.go +++ b/builder/scaleway/step_server_info.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -14,7 +14,7 @@ type stepServerInfo struct{} func (s *stepServerInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) serverID := state.Get("server_id").(string) ui.Say("Waiting for server to become active...") diff --git a/builder/scaleway/step_shutdown.go b/builder/scaleway/step_shutdown.go index 8c8eb1471..b383f1765 100644 --- a/builder/scaleway/step_shutdown.go +++ b/builder/scaleway/step_shutdown.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -14,7 +14,7 @@ type stepShutdown struct{} func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) serverID := state.Get("server_id").(string) ui.Say("Shutting down server...") diff --git a/builder/scaleway/step_snapshot.go b/builder/scaleway/step_snapshot.go index e7e01637a..785b8ae07 100644 --- a/builder/scaleway/step_snapshot.go +++ b/builder/scaleway/step_snapshot.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -15,7 +15,7 @@ type stepSnapshot struct{} func (s *stepSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client)) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) volumeID := state.Get("root_volume_id").(string) diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index ecdfde864..1c1580d0c 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -64,7 +65,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { cvmClient, vpcClient, err := b.config.Client() if err != nil { return nil, err diff --git a/builder/tencentcloud/cvm/common.go b/builder/tencentcloud/cvm/common.go index d3fd7c398..fe12e238d 100644 --- a/builder/tencentcloud/cvm/common.go +++ b/builder/tencentcloud/cvm/common.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" @@ -196,7 +196,7 @@ func Say(state multistep.StateBag, message, prefix string) { message += "..." } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(message) } @@ -206,7 +206,7 @@ func Message(state multistep.StateBag, message, prefix string) { message = fmt.Sprintf("%s: %s", prefix, message) } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Message(message) } @@ -216,7 +216,7 @@ func Error(state multistep.StateBag, err error, prefix string) { err = fmt.Errorf("%s: %s", prefix, err) } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Error(err.Error()) } diff --git a/builder/triton/builder.go b/builder/triton/builder.go index ca41cb270..8ec1e8c5f 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -49,7 +50,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs.ErrorOrNil() } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { config := b.config driver, err := NewDriverTriton(ui, config) diff --git a/builder/triton/driver_triton.go b/builder/triton/driver_triton.go index 58d943216..30c856ba3 100644 --- a/builder/triton/driver_triton.go +++ b/builder/triton/driver_triton.go @@ -7,17 +7,17 @@ import ( "sort" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/joyent/triton-go/compute" terrors "github.com/joyent/triton-go/errors" ) type driverTriton struct { client *Client - ui packer.Ui + ui packersdk.Ui } -func NewDriverTriton(ui packer.Ui, config Config) (Driver, error) { +func NewDriverTriton(ui packersdk.Ui, config Config) (Driver, error) { client, err := config.AccessConfig.CreateTritonClient() if err != nil { return nil, err diff --git a/builder/triton/step_create_image_from_machine.go b/builder/triton/step_create_image_from_machine.go index bb2d66255..c0401f3c6 100644 --- a/builder/triton/step_create_image_from_machine.go +++ b/builder/triton/step_create_image_from_machine.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCreateImageFromMachine creates an image with the specified attributes @@ -17,7 +17,7 @@ type StepCreateImageFromMachine struct{} func (s *StepCreateImageFromMachine) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) machineId := state.Get("machine").(string) diff --git a/builder/triton/step_create_source_machine.go b/builder/triton/step_create_source_machine.go index 0da7f603e..1281d7eb4 100644 --- a/builder/triton/step_create_source_machine.go +++ b/builder/triton/step_create_source_machine.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCreateSourceMachine creates an machine with the specified attributes @@ -16,7 +16,7 @@ type StepCreateSourceMachine struct{} func (s *StepCreateSourceMachine) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if !config.MachineImageFilters.Empty() { ui.Say("Selecting an image based on search criteria") @@ -51,7 +51,7 @@ func (s *StepCreateSourceMachine) Run(ctx context.Context, state multistep.State func (s *StepCreateSourceMachine) Cleanup(state multistep.StateBag) { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) machineIdRaw, ok := state.GetOk("machine") if ok && machineIdRaw.(string) != "" { diff --git a/builder/triton/step_delete_machine.go b/builder/triton/step_delete_machine.go index d1d005c25..d663d4f26 100644 --- a/builder/triton/step_delete_machine.go +++ b/builder/triton/step_delete_machine.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepDeleteMachine deletes the machine with the ID specified in state["machine"] @@ -14,7 +14,7 @@ type StepDeleteMachine struct{} func (s *StepDeleteMachine) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) machineId := state.Get("machine").(string) diff --git a/builder/triton/step_stop_machine.go b/builder/triton/step_stop_machine.go index f6b243a23..571e9ca34 100644 --- a/builder/triton/step_stop_machine.go +++ b/builder/triton/step_stop_machine.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepStopMachine stops the machine with the given Machine ID, and waits @@ -15,7 +15,7 @@ type StepStopMachine struct{} func (s *StepStopMachine) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) machineId := state.Get("machine").(string) diff --git a/builder/triton/step_wait_for_stop_to_not_fail.go b/builder/triton/step_wait_for_stop_to_not_fail.go index ce226c871..51cf80a93 100644 --- a/builder/triton/step_wait_for_stop_to_not_fail.go +++ b/builder/triton/step_wait_for_stop_to_not_fail.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepWaitForStopNotToFail waits for 10 seconds before returning with continue @@ -14,7 +14,7 @@ import ( type StepWaitForStopNotToFail struct{} func (s *StepWaitForStopNotToFail) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Waiting 10 seconds to avoid potential SDC bug...") time.Sleep(10 * time.Second) return multistep.ActionContinue diff --git a/builder/ucloud/common/utils.go b/builder/ucloud/common/utils.go index 71d2bb04b..3df40a38e 100644 --- a/builder/ucloud/common/utils.go +++ b/builder/ucloud/common/utils.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ucloud/ucloud-sdk-go/services/uhost" ) @@ -63,7 +63,7 @@ func SSHHost(usePrivateIp bool) func(multistep.StateBag) (string, error) { } func Halt(state multistep.StateBag, err error, prefix string) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if prefix != "" { err = fmt.Errorf("%s: %s", prefix, err) diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index c2cd520f1..a4d652668 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -67,7 +68,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/ucloud/uhost/step_check_source_image.go b/builder/ucloud/uhost/step_check_source_image.go index afeec3978..00b5593fd 100644 --- a/builder/ucloud/uhost/step_check_source_image.go +++ b/builder/ucloud/uhost/step_check_source_image.go @@ -5,8 +5,8 @@ import ( "fmt" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepCheckSourceImageId struct { @@ -14,7 +14,7 @@ type stepCheckSourceImageId struct { } func (s *stepCheckSourceImageId) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*ucloudcommon.UCloudClient) ui.Say("Querying source image id...") diff --git a/builder/ucloud/uhost/step_config_security_group.go b/builder/ucloud/uhost/step_config_security_group.go index 297f7d002..1c8af55f7 100644 --- a/builder/ucloud/uhost/step_config_security_group.go +++ b/builder/ucloud/uhost/step_config_security_group.go @@ -5,8 +5,8 @@ import ( "fmt" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ucloud/ucloud-sdk-go/ucloud" ) @@ -17,7 +17,7 @@ type stepConfigSecurityGroup struct { func (s *stepConfigSecurityGroup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UNetConn - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.SecurityGroupId) != 0 { ui.Say(fmt.Sprintf("Trying to use specified security group %q...", s.SecurityGroupId)) diff --git a/builder/ucloud/uhost/step_config_subnet.go b/builder/ucloud/uhost/step_config_subnet.go index 6170b3f95..24da1b116 100644 --- a/builder/ucloud/uhost/step_config_subnet.go +++ b/builder/ucloud/uhost/step_config_subnet.go @@ -5,8 +5,8 @@ import ( "fmt" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepConfigSubnet struct { @@ -15,7 +15,7 @@ type stepConfigSubnet struct { func (s *stepConfigSubnet) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ucloudcommon.UCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.SubnetId) != 0 { ui.Say(fmt.Sprintf("Trying to use specified subnet %q...", s.SubnetId)) diff --git a/builder/ucloud/uhost/step_config_vpc.go b/builder/ucloud/uhost/step_config_vpc.go index dc54ddcf7..c35174c5a 100644 --- a/builder/ucloud/uhost/step_config_vpc.go +++ b/builder/ucloud/uhost/step_config_vpc.go @@ -6,8 +6,8 @@ import ( ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepConfigVPC struct { @@ -16,7 +16,7 @@ type stepConfigVPC struct { func (s *stepConfigVPC) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ucloudcommon.UCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if len(s.VPCId) != 0 { ui.Say(fmt.Sprintf("Trying to use specified vpc %q...", s.VPCId)) diff --git a/builder/ucloud/uhost/step_copy_image.go b/builder/ucloud/uhost/step_copy_image.go index 4f8eec37e..0ebef1d1e 100644 --- a/builder/ucloud/uhost/step_copy_image.go +++ b/builder/ucloud/uhost/step_copy_image.go @@ -9,8 +9,8 @@ import ( ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/packer-plugin-sdk/retry" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ucloud/ucloud-sdk-go/ucloud" ) @@ -28,7 +28,7 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag) client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UHostConn - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) srcImageId := state.Get("image_id").(string) artifactImages := state.Get("ucloud_images").(*ucloudcommon.ImageInfoSet) @@ -123,7 +123,7 @@ func (s *stepCopyUCloudImage) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UHostConn ui.Say(fmt.Sprintf("Deleting copied image because of cancellation or error...")) diff --git a/builder/ucloud/uhost/step_create_image.go b/builder/ucloud/uhost/step_create_image.go index 58e5da238..4837325fd 100644 --- a/builder/ucloud/uhost/step_create_image.go +++ b/builder/ucloud/uhost/step_create_image.go @@ -8,8 +8,8 @@ import ( ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/packer-plugin-sdk/retry" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ucloud/ucloud-sdk-go/services/uhost" "github.com/ucloud/ucloud-sdk-go/ucloud" ) @@ -22,7 +22,7 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UHostConn instance := state.Get("instance").(*uhost.UHostInstanceSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say(fmt.Sprintf("Creating image %s...", config.ImageName)) @@ -93,7 +93,7 @@ func (s *stepCreateImage) Cleanup(state multistep.StateBag) { client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UHostConn - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting image because of cancellation or error...") req := conn.NewTerminateCustomImageRequest() diff --git a/builder/ucloud/uhost/step_create_instance.go b/builder/ucloud/uhost/step_create_instance.go index 03d863a40..783c27c2e 100644 --- a/builder/ucloud/uhost/step_create_instance.go +++ b/builder/ucloud/uhost/step_create_instance.go @@ -10,8 +10,8 @@ import ( "time" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/ucloud/ucloud-sdk-go/services/uhost" "github.com/ucloud/ucloud-sdk-go/ucloud" @@ -38,7 +38,7 @@ type stepCreateInstance struct { func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UHostConn - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating Instance...") req, err := s.buildCreateInstanceRequest(state) @@ -136,7 +136,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) { _, cancelled := state.GetOk(multistep.StateCancelled) _, halted := state.GetOk(multistep.StateHalted) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ctx := context.TODO() if cancelled || halted { diff --git a/builder/ucloud/uhost/step_pre_validate.go b/builder/ucloud/uhost/step_pre_validate.go index 41b50e9a6..f945613fb 100644 --- a/builder/ucloud/uhost/step_pre_validate.go +++ b/builder/ucloud/uhost/step_pre_validate.go @@ -6,6 +6,7 @@ import ( ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepPreValidate struct { @@ -32,7 +33,7 @@ func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) mul } func (s *stepPreValidate) validateProjectIds(state multistep.StateBag) error { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say("Validating project_id and copied project_ids...") @@ -56,7 +57,7 @@ func (s *stepPreValidate) validateProjectIds(state multistep.StateBag) error { } func (s *stepPreValidate) validateRegions(state multistep.StateBag) error { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say("Validating region and copied regions...") @@ -79,7 +80,7 @@ func (s *stepPreValidate) validateRegions(state multistep.StateBag) error { } func (s *stepPreValidate) validateZones(state multistep.StateBag) error { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say("Validating availability_zone...") diff --git a/builder/ucloud/uhost/step_stop_instance.go b/builder/ucloud/uhost/step_stop_instance.go index 214d5e312..5d0c31b98 100644 --- a/builder/ucloud/uhost/step_stop_instance.go +++ b/builder/ucloud/uhost/step_stop_instance.go @@ -8,8 +8,8 @@ import ( ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/packer-plugin-sdk/retry" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ucloud/ucloud-sdk-go/services/uhost" "github.com/ucloud/ucloud-sdk-go/ucloud" ) @@ -21,7 +21,7 @@ func (s *stepStopInstance) Run(ctx context.Context, state multistep.StateBag) mu client := state.Get("client").(*ucloudcommon.UCloudClient) conn := client.UHostConn instance := state.Get("instance").(*uhost.UHostInstanceSet) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instance, err := client.DescribeUHostById(instance.UHostId) if err != nil { diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 3dc56f179..6463bd8be 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -273,7 +274,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox VagrantCWD, err := filepath.Abs(b.config.OutputDir) if err != nil { diff --git a/builder/vagrant/step_add_box.go b/builder/vagrant/step_add_box.go index 43693d184..38ff8c191 100644 --- a/builder/vagrant/step_add_box.go +++ b/builder/vagrant/step_add_box.go @@ -5,8 +5,8 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepAddBox struct { @@ -70,7 +70,7 @@ func (s *StepAddBox) generateAddArgs() []string { func (s *StepAddBox) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(VagrantDriver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.SkipAdd { ui.Say("skip_add was set so we assume the box is already in Vagrant...") diff --git a/builder/vagrant/step_create_vagrantfile.go b/builder/vagrant/step_create_vagrantfile.go index b6ec461af..3fb1c8c09 100644 --- a/builder/vagrant/step_create_vagrantfile.go +++ b/builder/vagrant/step_create_vagrantfile.go @@ -8,8 +8,8 @@ import ( "path/filepath" "text/template" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateVagrantfile struct { @@ -87,7 +87,7 @@ func (s *StepCreateVagrantfile) createVagrantfile() (string, error) { } func (s *StepCreateVagrantfile) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Skip the initialize step if we're trying to launch from a global ID. if s.GlobalID != "" { diff --git a/builder/vagrant/step_package.go b/builder/vagrant/step_package.go index 8b2bd023f..77128150b 100644 --- a/builder/vagrant/step_package.go +++ b/builder/vagrant/step_package.go @@ -4,8 +4,8 @@ import ( "context" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepPackage struct { @@ -17,7 +17,7 @@ type StepPackage struct { func (s *StepPackage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(VagrantDriver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.SkipPackage { ui.Say("skip_package flag set; not going to call Vagrant package on this box.") diff --git a/builder/vagrant/step_up.go b/builder/vagrant/step_up.go index d427de57a..7a8ebab5f 100644 --- a/builder/vagrant/step_up.go +++ b/builder/vagrant/step_up.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepUp struct { @@ -31,7 +31,7 @@ func (s *StepUp) generateArgs() []string { func (s *StepUp) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(VagrantDriver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Calling Vagrant Up (this can take some time)...") @@ -51,7 +51,7 @@ func (s *StepUp) Run(ctx context.Context, state multistep.StateBag) multistep.St func (s *StepUp) Cleanup(state multistep.StateBag) { driver := state.Get("driver").(VagrantDriver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("%sing Vagrant box...", s.TeardownMethod)) diff --git a/builder/virtualbox/common/step_attach_floppy.go b/builder/virtualbox/common/step_attach_floppy.go index c607fbe32..ae4bc1f2e 100644 --- a/builder/virtualbox/common/step_attach_floppy.go +++ b/builder/virtualbox/common/step_attach_floppy.go @@ -8,8 +8,8 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -17,7 +17,7 @@ import ( // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -45,7 +45,7 @@ func (s *StepAttachFloppy) Run(ctx context.Context, state multistep.StateBag) mu } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Deleting any current floppy disk...") @@ -88,7 +88,7 @@ func (s *StepAttachFloppy) Run(ctx context.Context, state multistep.StateBag) mu } func (s *StepAttachFloppy) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Cleaning up floppy disk...") if s.floppyPath == "" { return diff --git a/builder/virtualbox/common/step_attach_isos.go b/builder/virtualbox/common/step_attach_isos.go index b72d9eccf..5a6bbd624 100644 --- a/builder/virtualbox/common/step_attach_isos.go +++ b/builder/virtualbox/common/step_attach_isos.go @@ -6,8 +6,8 @@ import ( "log" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step attaches the boot ISO, cd_files iso, and guest additions to the @@ -22,7 +22,7 @@ type StepAttachISOs struct { func (s *StepAttachISOs) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // Check whether there is anything to attach - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Mounting ISOs...") diskMountMap := map[string]string{} diff --git a/builder/virtualbox/common/step_configure_vrdp.go b/builder/virtualbox/common/step_configure_vrdp.go index 77a6a7aca..9fd02cbeb 100644 --- a/builder/virtualbox/common/step_configure_vrdp.go +++ b/builder/virtualbox/common/step_configure_vrdp.go @@ -5,9 +5,9 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step configures the VM to enable the VRDP server @@ -15,7 +15,7 @@ import ( // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -30,7 +30,7 @@ type StepConfigureVRDP struct { func (s *StepConfigureVRDP) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) log.Printf("Looking for available port between %d and %d on %s", s.VRDPPortMin, s.VRDPPortMax, s.VRDPBindAddress) diff --git a/builder/virtualbox/common/step_download_guest_additions.go b/builder/virtualbox/common/step_download_guest_additions.go index e812ab436..b98bbec51 100644 --- a/builder/virtualbox/common/step_download_guest_additions.go +++ b/builder/virtualbox/common/step_download_guest_additions.go @@ -9,9 +9,9 @@ import ( "os" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -40,7 +40,7 @@ type StepDownloadGuestAdditions struct { func (s *StepDownloadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { var action multistep.StepAction driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // If we've disabled guest additions, don't download if s.GuestAdditionsMode == GuestAdditionsModeDisable { diff --git a/builder/virtualbox/common/step_export.go b/builder/virtualbox/common/step_export.go index b1c5d6987..31dc8db64 100644 --- a/builder/virtualbox/common/step_export.go +++ b/builder/virtualbox/common/step_export.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step cleans up forwarded ports and exports the VM to an OVF. @@ -36,7 +36,7 @@ func (s *StepExport) Run(ctx context.Context, state multistep.StateBag) multiste } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.OutputFilename == "" { s.OutputFilename = vmName diff --git a/builder/virtualbox/common/step_port_forwarding.go b/builder/virtualbox/common/step_port_forwarding.go index 19b3a6689..41c4bb923 100644 --- a/builder/virtualbox/common/step_port_forwarding.go +++ b/builder/virtualbox/common/step_port_forwarding.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step adds a NAT port forwarding definition so that SSH or WinRM is available @@ -17,7 +17,7 @@ import ( // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -32,7 +32,7 @@ type StepPortForwarding struct { func (s *StepPortForwarding) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.CommConfig.Type == "none" { diff --git a/builder/virtualbox/common/step_remove_devices.go b/builder/virtualbox/common/step_remove_devices.go index fbbce66da..1a0c7f385 100644 --- a/builder/virtualbox/common/step_remove_devices.go +++ b/builder/virtualbox/common/step_remove_devices.go @@ -6,8 +6,8 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -16,7 +16,7 @@ import ( // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -26,7 +26,7 @@ type StepRemoveDevices struct { func (s *StepRemoveDevices) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) // Remove the attached floppy disk, if it exists diff --git a/builder/virtualbox/common/step_run.go b/builder/virtualbox/common/step_run.go index ca148a876..01144e4fa 100644 --- a/builder/virtualbox/common/step_run.go +++ b/builder/virtualbox/common/step_run.go @@ -4,15 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step starts the virtual machine. // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -24,7 +24,7 @@ type StepRun struct { func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) ui.Say("Starting the virtual machine...") @@ -70,7 +70,7 @@ func (s *StepRun) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if running, _ := driver.IsRunning(s.vmName); running { if err := driver.VBoxManage("controlvm", s.vmName, "poweroff"); err != nil { diff --git a/builder/virtualbox/common/step_shutdown.go b/builder/virtualbox/common/step_shutdown.go index acc3c3513..ce980847f 100644 --- a/builder/virtualbox/common/step_shutdown.go +++ b/builder/virtualbox/common/step_shutdown.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -17,7 +18,7 @@ import ( // Uses: // communicator packer.Communicator // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -33,7 +34,7 @@ type StepShutdown struct { func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if s.ACPIShutdown { diff --git a/builder/virtualbox/common/step_ssh_key_pair.go b/builder/virtualbox/common/step_ssh_key_pair.go index 7383ed93c..aa9dbf16b 100644 --- a/builder/virtualbox/common/step_ssh_key_pair.go +++ b/builder/virtualbox/common/step_ssh_key_pair.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator/ssh" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -25,7 +25,7 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult return multistep.ActionContinue } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key for the communicator...") @@ -99,7 +99,7 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult func (s *StepSshKeyPair) Cleanup(state multistep.StateBag) { if s.Debug { if err := os.Remove(s.DebugKeyPath); err != nil { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Error(fmt.Sprintf( "Error removing debug key '%s': %s", s.DebugKeyPath, err)) } diff --git a/builder/virtualbox/common/step_suppress_messages.go b/builder/virtualbox/common/step_suppress_messages.go index 52d69d5f9..ddfc2b852 100644 --- a/builder/virtualbox/common/step_suppress_messages.go +++ b/builder/virtualbox/common/step_suppress_messages.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step sets some variables in VirtualBox so that annoying @@ -15,7 +15,7 @@ type StepSuppressMessages struct{} func (StepSuppressMessages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) log.Println("Suppressing annoying messages in VirtualBox") if err := driver.SuppressMessages(); err != nil { diff --git a/builder/virtualbox/common/step_type_boot_command.go b/builder/virtualbox/common/step_type_boot_command.go index 4e7587eae..8a728a858 100644 --- a/builder/virtualbox/common/step_type_boot_command.go +++ b/builder/virtualbox/common/step_type_boot_command.go @@ -6,9 +6,9 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -43,7 +43,7 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) debug := state.Get("debug").(bool) driver := state.Get("driver").(Driver) httpPort := state.Get("http_port").(int) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) // Wait the for the vm to boot. diff --git a/builder/virtualbox/common/step_upload_guest_additions.go b/builder/virtualbox/common/step_upload_guest_additions.go index 272ac5f1f..ea7b6ef37 100644 --- a/builder/virtualbox/common/step_upload_guest_additions.go +++ b/builder/virtualbox/common/step_upload_guest_additions.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -25,7 +26,7 @@ type StepUploadGuestAdditions struct { func (s *StepUploadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // If we're attaching then don't do this, since we attached. if s.GuestAdditionsMode != GuestAdditionsModeUpload { diff --git a/builder/virtualbox/common/step_upload_version.go b/builder/virtualbox/common/step_upload_version.go index 638aa1dac..46da0e6f1 100644 --- a/builder/virtualbox/common/step_upload_version.go +++ b/builder/virtualbox/common/step_upload_version.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step uploads a file containing the VirtualBox version, which @@ -19,7 +20,7 @@ type StepUploadVersion struct { func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.Path == "" { log.Println("VBoxVersionFile is empty. Not uploading.") diff --git a/builder/virtualbox/common/step_vboxmanage.go b/builder/virtualbox/common/step_vboxmanage.go index 6950fcb4f..0e2e9cbf1 100644 --- a/builder/virtualbox/common/step_vboxmanage.go +++ b/builder/virtualbox/common/step_vboxmanage.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -25,7 +25,7 @@ type commandTemplate struct { // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmName string // // Produces: @@ -36,7 +36,7 @@ type StepVBoxManage struct { func (s *StepVBoxManage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) if len(s.Commands) > 0 { diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 810451f95..13d5151de 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -230,7 +231,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/iso/step_create_disk.go b/builder/virtualbox/iso/step_create_disk.go index 14869ce71..efeccd1c0 100644 --- a/builder/virtualbox/iso/step_create_disk.go +++ b/builder/virtualbox/iso/step_create_disk.go @@ -5,8 +5,8 @@ import ( "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "path/filepath" "strconv" @@ -20,7 +20,7 @@ type stepCreateDisk struct{} func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) format := "VDI" diff --git a/builder/virtualbox/iso/step_create_vm.go b/builder/virtualbox/iso/step_create_vm.go index 2a6597b18..628cfacc2 100644 --- a/builder/virtualbox/iso/step_create_vm.go +++ b/builder/virtualbox/iso/step_create_vm.go @@ -7,8 +7,8 @@ import ( "strings" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates the actual virtual machine. @@ -22,7 +22,7 @@ type stepCreateVM struct { func (s *stepCreateVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) name := config.VMName @@ -73,7 +73,7 @@ func (s *stepCreateVM) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) _, cancelled := state.GetOk(multistep.StateCancelled) diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index e15dd870b..c07152f18 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Builder implements packer.Builder and builds the actual VirtualBox @@ -33,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/ovf/step_import.go b/builder/virtualbox/ovf/step_import.go index fcb081a9c..67a8659fe 100644 --- a/builder/virtualbox/ovf/step_import.go +++ b/builder/virtualbox/ovf/step_import.go @@ -5,8 +5,8 @@ import ( "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step imports an OVF VM into VirtualBox. @@ -20,7 +20,7 @@ type StepImport struct { func (s *StepImport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmPath := state.Get("vm_path").(string) ui.Say(fmt.Sprintf("Importing VM: %s", vmPath)) @@ -42,7 +42,7 @@ func (s *StepImport) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, cancelled := state.GetOk(multistep.StateCancelled) _, halted := state.GetOk(multistep.StateHalted) diff --git a/builder/virtualbox/vm/builder.go b/builder/virtualbox/vm/builder.go index 4118d8827..9732e7c0f 100644 --- a/builder/virtualbox/vm/builder.go +++ b/builder/virtualbox/vm/builder.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Builder implements packer.Builder and builds the actual VirtualBox @@ -33,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/vm/step_create_snapshot.go b/builder/virtualbox/vm/step_create_snapshot.go index 05a10177a..12bb0868b 100644 --- a/builder/virtualbox/vm/step_create_snapshot.go +++ b/builder/virtualbox/vm/step_create_snapshot.go @@ -6,8 +6,8 @@ import ( "log" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateSnapshot struct { @@ -17,7 +17,7 @@ type StepCreateSnapshot struct { func (s *StepCreateSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.TargetSnapshot != "" { running, err := driver.IsRunning(s.Name) if err != nil { diff --git a/builder/virtualbox/vm/step_set_snapshot.go b/builder/virtualbox/vm/step_set_snapshot.go index 2158a5187..d594a4296 100644 --- a/builder/virtualbox/vm/step_set_snapshot.go +++ b/builder/virtualbox/vm/step_set_snapshot.go @@ -5,8 +5,8 @@ import ( "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSetSnapshot struct { @@ -18,7 +18,7 @@ type StepSetSnapshot struct { func (s *StepSetSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vboxcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) snapshotTree, err := driver.LoadSnapshots(s.Name) if err != nil { err := fmt.Errorf("Error loading snapshots for VM: %s", err) @@ -64,7 +64,7 @@ func (s *StepSetSnapshot) Run(_ context.Context, state multistep.StateBag) multi func (s *StepSetSnapshot) Cleanup(state multistep.StateBag) { driver := state.Get("driver").(vboxcommon.Driver) if s.revertToSnapshot != "" { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.KeepRegistered { ui.Say("Keeping virtual machine state (keep_registered = true)") return diff --git a/builder/vmware/common/driver_esx5.go b/builder/vmware/common/driver_esx5.go index 73ca6b7e3..448698987 100644 --- a/builder/vmware/common/driver_esx5.go +++ b/builder/vmware/common/driver_esx5.go @@ -32,6 +32,7 @@ import ( helperssh "github.com/hashicorp/packer/helper/communicator/ssh" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh" gossh "golang.org/x/crypto/ssh" ) @@ -249,7 +250,7 @@ func (d *ESX5Driver) IsDestroyed() (bool, error) { return true, err } -func (d *ESX5Driver) UploadISO(localPath string, checksum string, ui packer.Ui) (string, error) { +func (d *ESX5Driver) UploadISO(localPath string, checksum string, ui packersdk.Ui) (string, error) { finalPath := d.CachePath(localPath) if err := d.mkdir(filepath.ToSlash(filepath.Dir(finalPath))); err != nil { return "", err @@ -793,7 +794,7 @@ func (d *ESX5Driver) mkdir(path string) error { return d.sh("mkdir", "-p", strconv.Quote(path)) } -func (d *ESX5Driver) upload(dst, src string, ui packer.Ui) error { +func (d *ESX5Driver) upload(dst, src string, ui packersdk.Ui) error { // Get size so we can set up progress tracker info, err := os.Stat(src) if err != nil { diff --git a/builder/vmware/common/remote_driver.go b/builder/vmware/common/remote_driver.go index f2c16cf12..2f35f4cd4 100644 --- a/builder/vmware/common/remote_driver.go +++ b/builder/vmware/common/remote_driver.go @@ -1,7 +1,7 @@ package common import ( - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type RemoteDriver interface { @@ -10,7 +10,7 @@ type RemoteDriver interface { // UploadISO uploads a local ISO to the remote side and returns the // new path that should be used in the VMX along with an error if it // exists. - UploadISO(path string, checksum string, ui packer.Ui) (string, error) + UploadISO(path string, checksum string, ui packersdk.Ui) (string, error) // RemoveCache deletes localPath from the remote cache. RemoveCache(localPath string) error @@ -28,7 +28,7 @@ type RemoteDriver interface { IsDestroyed() (bool, error) // Uploads a local file to remote side. - upload(dst, src string, ui packer.Ui) error + upload(dst, src string, ui packersdk.Ui) error // Download a remote file to a local file. Download(src, dst string) error diff --git a/builder/vmware/common/remote_driver_mock.go b/builder/vmware/common/remote_driver_mock.go index f20e5e69f..be5793932 100644 --- a/builder/vmware/common/remote_driver_mock.go +++ b/builder/vmware/common/remote_driver_mock.go @@ -1,7 +1,7 @@ package common import ( - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type RemoteDriverMock struct { @@ -40,7 +40,7 @@ type RemoteDriverMock struct { outputDir string } -func (d *RemoteDriverMock) UploadISO(path string, checksum string, ui packer.Ui) (string, error) { +func (d *RemoteDriverMock) UploadISO(path string, checksum string, ui packersdk.Ui) (string, error) { d.UploadISOCalled = true d.UploadISOPath = path return d.UploadISOResult, d.UploadISOErr @@ -68,7 +68,7 @@ func (d *RemoteDriverMock) IsDestroyed() (bool, error) { return d.IsDestroyedResult, d.IsDestroyedErr } -func (d *RemoteDriverMock) upload(dst, src string, ui packer.Ui) error { +func (d *RemoteDriverMock) upload(dst, src string, ui packersdk.Ui) error { return d.UploadErr } diff --git a/builder/vmware/common/step_clean_files.go b/builder/vmware/common/step_clean_files.go index 93072441f..ebdb4bd2f 100644 --- a/builder/vmware/common/step_clean_files.go +++ b/builder/vmware/common/step_clean_files.go @@ -6,8 +6,8 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // These are the extensions of files that are important for the function @@ -19,7 +19,7 @@ var KeepFileExtensions = []string{".nvram", ".vmdk", ".vmsd", ".vmx", ".vmxf"} // // Uses: // dir OutputDir -// ui packer.Ui +// ui packersdk.Ui // // Produces: // @@ -27,7 +27,7 @@ type StepCleanFiles struct{} func (StepCleanFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { dir := state.Get("dir").(OutputDir) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting unnecessary VMware files...") files, err := dir.ListFiles() diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go index f89865a06..b4720af4f 100644 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -6,15 +6,15 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step cleans up the VMX by removing or changing this prior to // being ready for use. // // Uses: -// ui packer.Ui +// ui packersdk.Ui // vmx_path string // // Produces: @@ -25,7 +25,7 @@ type StepCleanVMX struct { } func (s StepCleanVMX) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) ui.Say("Cleaning VMX prior to finishing up...") diff --git a/builder/vmware/common/step_compact_disk.go b/builder/vmware/common/step_compact_disk.go index 7605af6ca..be798fe59 100644 --- a/builder/vmware/common/step_compact_disk.go +++ b/builder/vmware/common/step_compact_disk.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step compacts the virtual disk for the VM unless the "skip_compaction" @@ -15,7 +15,7 @@ import ( // Uses: // driver Driver // disk_full_paths ([]string) - The full paths to all created disks -// ui packer.Ui +// ui packersdk.Ui // // Produces: // @@ -25,7 +25,7 @@ type StepCompactDisk struct { func (s StepCompactDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) diskFullPaths := state.Get("disk_full_paths").([]string) if s.Skip { diff --git a/builder/vmware/common/step_configure_vmx.go b/builder/vmware/common/step_configure_vmx.go index 68dc5709b..a915509b2 100644 --- a/builder/vmware/common/step_configure_vmx.go +++ b/builder/vmware/common/step_configure_vmx.go @@ -7,8 +7,8 @@ import ( "regexp" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step configures a VMX by setting some default settings as well @@ -32,7 +32,7 @@ func (s *StepConfigureVMX) Run(ctx context.Context, state multistep.StateBag) mu log.Printf("Configuring VMX...\n") var err error - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) vmxData, err := ReadVMX(vmxPath) diff --git a/builder/vmware/common/step_configure_vnc.go b/builder/vmware/common/step_configure_vnc.go index 4b8823f4f..498794757 100644 --- a/builder/vmware/common/step_configure_vnc.go +++ b/builder/vmware/common/step_configure_vnc.go @@ -6,15 +6,15 @@ import ( "log" "math/rand" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step configures the VM to enable the VNC server. // // Uses: -// ui packer.Ui +// ui packersdk.Ui // vmx_path string // // Produces: @@ -77,7 +77,7 @@ func (s *StepConfigureVNC) Run(ctx context.Context, state multistep.StateBag) mu } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) vmxData, err := ReadVMX(vmxPath) diff --git a/builder/vmware/common/step_create_disks.go b/builder/vmware/common/step_create_disks.go index 6038f1234..477ef540f 100644 --- a/builder/vmware/common/step_create_disks.go +++ b/builder/vmware/common/step_create_disks.go @@ -6,8 +6,8 @@ import ( "log" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates the virtual disks for the VM. @@ -15,7 +15,7 @@ import ( // Uses: // config *config // driver Driver -// ui packer.Ui +// ui packersdk.Ui // // Produces: // disk_full_paths ([]string) - The full paths to all created disks @@ -31,7 +31,7 @@ type StepCreateDisks struct { func (s *StepCreateDisks) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating required virtual machine disks") diff --git a/builder/vmware/common/step_export.go b/builder/vmware/common/step_export.go index 4ab7b4431..86b031774 100644 --- a/builder/vmware/common/step_export.go +++ b/builder/vmware/common/step_export.go @@ -8,8 +8,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step exports a VM built on ESXi using ovftool @@ -55,7 +55,7 @@ func (s *StepExport) generateLocalExportArgs(exportOutputPath string) ([]string, func (s *StepExport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("driverConfig").(*DriverConfig) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) driver := state.Get("driver").(Driver) // Skip export if requested diff --git a/builder/vmware/common/step_http_ip_discover.go b/builder/vmware/common/step_http_ip_discover.go index 8d80ebe24..87041775b 100644 --- a/builder/vmware/common/step_http_ip_discover.go +++ b/builder/vmware/common/step_http_ip_discover.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Step to discover the http ip @@ -16,7 +16,7 @@ type StepHTTPIPDiscover struct{} func (s *StepHTTPIPDiscover) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Determine the host IP hostIP, err := driver.HostIP(state) diff --git a/builder/vmware/common/step_output_dir.go b/builder/vmware/common/step_output_dir.go index 5123754d5..495b3f582 100644 --- a/builder/vmware/common/step_output_dir.go +++ b/builder/vmware/common/step_output_dir.go @@ -6,8 +6,8 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepOutputDir sets up the output directory by creating it if it does @@ -68,7 +68,7 @@ func (s *StepOutputDir) SetOutputAndExportDirs(state multistep.StateBag) OutputD } func (s *StepOutputDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Configuring output and export directories...") dir := s.SetOutputAndExportDirs(state) @@ -108,7 +108,7 @@ func (s *StepOutputDir) Cleanup(state multistep.StateBag) { if cancelled || halted { dir := state.Get("dir").(OutputDir) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) exists, _ := dir.DirExists() if exists { diff --git a/builder/vmware/common/step_register.go b/builder/vmware/common/step_register.go index baf33268d..24dd1fd7b 100644 --- a/builder/vmware/common/step_register.go +++ b/builder/vmware/common/step_register.go @@ -6,8 +6,8 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRegister struct { @@ -19,7 +19,7 @@ type StepRegister struct { func (s *StepRegister) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) @@ -44,7 +44,7 @@ func (s *StepRegister) Cleanup(state multistep.StateBag) { } driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) _, cancelled := state.GetOk(multistep.StateCancelled) _, halted := state.GetOk(multistep.StateHalted) diff --git a/builder/vmware/common/step_remote_upload.go b/builder/vmware/common/step_remote_upload.go index c54ed9072..abb9ae15a 100644 --- a/builder/vmware/common/step_remote_upload.go +++ b/builder/vmware/common/step_remote_upload.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // stepRemoteUpload uploads some thing from the state bag to a remote driver @@ -20,7 +20,7 @@ type StepRemoteUpload struct { func (s *StepRemoteUpload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) remote, ok := driver.(RemoteDriver) if !ok { diff --git a/builder/vmware/common/step_run.go b/builder/vmware/common/step_run.go index 090a36262..0cef4b60b 100644 --- a/builder/vmware/common/step_run.go +++ b/builder/vmware/common/step_run.go @@ -5,15 +5,15 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step runs the created virtual machine. // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmx_path string // // Produces: @@ -28,7 +28,7 @@ type StepRun struct { func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) // Set the VMX path so that we know we started the machine @@ -73,7 +73,7 @@ func (s *StepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S func (s *StepRun) Cleanup(state multistep.StateBag) { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // If we started the machine... stop it. if s.vmxPath != "" { diff --git a/builder/vmware/common/step_shutdown.go b/builder/vmware/common/step_shutdown.go index a75514a29..b1187672f 100644 --- a/builder/vmware/common/step_shutdown.go +++ b/builder/vmware/common/step_shutdown.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -21,7 +22,7 @@ import ( // communicator packer.Communicator // dir OutputDir // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmx_path string // // Produces: @@ -38,7 +39,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis comm := state.Get("communicator").(packer.Communicator) dir := state.Get("dir").(OutputDir) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) if s.Command != "" { diff --git a/builder/vmware/common/step_suppress_messages.go b/builder/vmware/common/step_suppress_messages.go index 0ab45c27c..f852237d8 100644 --- a/builder/vmware/common/step_suppress_messages.go +++ b/builder/vmware/common/step_suppress_messages.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step suppresses any messages that VMware product might show. @@ -14,7 +14,7 @@ type StepSuppressMessages struct{} func (s *StepSuppressMessages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) log.Println("Suppressing messages in VMX") diff --git a/builder/vmware/common/step_upload_tools.go b/builder/vmware/common/step_upload_tools.go index 5282a7191..bd5063625 100644 --- a/builder/vmware/common/step_upload_tools.go +++ b/builder/vmware/common/step_upload_tools.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -37,7 +38,7 @@ func (c *StepUploadTools) Run(ctx context.Context, state multistep.StateBag) mul comm := state.Get("communicator").(packer.Communicator) tools_source := state.Get("tools_upload_source").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Uploading the '%s' VMware Tools", c.ToolsUploadFlavor)) f, err := os.Open(tools_source) diff --git a/builder/vmware/common/step_upload_vmx.go b/builder/vmware/common/step_upload_vmx.go index 764c3c439..ce162b0d9 100644 --- a/builder/vmware/common/step_upload_vmx.go +++ b/builder/vmware/common/step_upload_vmx.go @@ -5,15 +5,15 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step upload the VMX to the remote host // // Uses: // driver Driver -// ui packer.Ui +// ui packersdk.Ui // vmx_path string // // Produces: @@ -25,7 +25,7 @@ type StepUploadVMX struct { func (c *StepUploadVMX) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vmxPath := state.Get("vmx_path").(string) if c.RemoteType == "esx5" { diff --git a/builder/vmware/common/step_vnc_boot_command.go b/builder/vmware/common/step_vnc_boot_command.go index 5841ba4c2..e68d64774 100644 --- a/builder/vmware/common/step_vnc_boot_command.go +++ b/builder/vmware/common/step_vnc_boot_command.go @@ -6,9 +6,9 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/go-vnc" ) @@ -17,7 +17,7 @@ import ( // // Uses: // http_port int -// ui packer.Ui +// ui packersdk.Ui // vnc_port int // // Produces: @@ -42,7 +42,7 @@ func (s *StepVNCBootCommand) Run(ctx context.Context, state multistep.StateBag) debug := state.Get("debug").(bool) httpPort := state.Get("http_port").(int) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) conn := state.Get("vnc_conn").(*vnc.ClientConn) defer conn.Close() diff --git a/builder/vmware/common/step_vnc_connect.go b/builder/vmware/common/step_vnc_connect.go index 85c3ab365..043236752 100644 --- a/builder/vmware/common/step_vnc_connect.go +++ b/builder/vmware/common/step_vnc_connect.go @@ -8,8 +8,8 @@ import ( "net" "net/url" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/mitchellh/go-vnc" "golang.org/x/net/websocket" ) @@ -25,7 +25,7 @@ func (s *StepVNCConnect) Run(ctx context.Context, state multistep.StateBag) mult if !s.VNCOverWebsocket && !s.VNCEnabled { return multistep.ActionContinue } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) var c *vnc.ClientConn var err error diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index e12edd4ee..fea117e93 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Builder struct { @@ -30,7 +31,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index e2dd96af9..749a6ce2f 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -10,8 +10,8 @@ import ( "strings" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -60,7 +60,7 @@ type additionalDiskTemplateData struct { // Uses: // config *config // iso_path string -// ui packer.Ui +// ui packersdk.Ui // // Produces: // vmx_path string - The path to the VMX file. @@ -72,7 +72,7 @@ type stepCreateVMX struct { func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) isoPath := state.Get("iso_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Convert the iso_path into a path relative to the .vmx file if possible if relativeIsoPath, err := filepath.Rel(config.VMXTemplatePath, filepath.FromSlash(isoPath)); err == nil { diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index fe6594e86..c4d1d0bc7 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Builder implements packer.Builder and builds the actual VMware @@ -35,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a VMware image. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vmware/vmx/step_clone_vmx.go b/builder/vmware/vmx/step_clone_vmx.go index 76bcdc73c..be55ec9bb 100644 --- a/builder/vmware/vmx/step_clone_vmx.go +++ b/builder/vmware/vmx/step_clone_vmx.go @@ -9,8 +9,8 @@ import ( "regexp" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -30,7 +30,7 @@ func (s *StepCloneVMX) Run(ctx context.Context, state multistep.StateBag) multis } driver := state.Get("driver").(vmwcommon.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Set the path we want for the new .vmx file and clone vmxPath := filepath.Join(*s.OutputDir, s.VMName+".vmx") diff --git a/builder/vsphere/clone/builder.go b/builder/vsphere/clone/builder.go index cec0ee29d..eea695d97 100644 --- a/builder/vsphere/clone/builder.go +++ b/builder/vsphere/clone/builder.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Builder struct { @@ -29,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/vsphere/clone/step_clone.go b/builder/vsphere/clone/step_clone.go index 850d2b3d5..f5f4f9f37 100644 --- a/builder/vsphere/clone/step_clone.go +++ b/builder/vsphere/clone/step_clone.go @@ -10,8 +10,8 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type vAppConfig struct { @@ -74,7 +74,7 @@ type StepCloneVM struct { } func (s *StepCloneVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) d := state.Get("driver").(*driver.VCenterDriver) vmPath := path.Join(s.Location.Folder, s.Location.VMName) diff --git a/builder/vsphere/clone/step_customize.go b/builder/vsphere/clone/step_customize.go index c5ebecf96..9818f7765 100644 --- a/builder/vsphere/clone/step_customize.go +++ b/builder/vsphere/clone/step_customize.go @@ -9,8 +9,8 @@ import ( "net" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/vmware/govmomi/vim25/types" ) @@ -124,7 +124,7 @@ func (c *CustomizeConfig) Prepare() []error { func (s *StepCustomize) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { vm := state.Get("vm").(*driver.VirtualMachineDriver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) identity, err := s.identitySettings() if err != nil { diff --git a/builder/vsphere/common/cleanup_vm.go b/builder/vsphere/common/cleanup_vm.go index c5055c5fc..6e8dc5484 100644 --- a/builder/vsphere/common/cleanup_vm.go +++ b/builder/vsphere/common/cleanup_vm.go @@ -2,8 +2,8 @@ package common import ( "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func CleanupVM(state multistep.StateBag) { @@ -14,7 +14,7 @@ func CleanupVM(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) st := state.Get("vm") if st == nil { diff --git a/builder/vsphere/common/step_add_cdrom.go b/builder/vsphere/common/step_add_cdrom.go index f272736dc..8ac3d92fd 100644 --- a/builder/vsphere/common/step_add_cdrom.go +++ b/builder/vsphere/common/step_add_cdrom.go @@ -8,8 +8,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type CDRomConfig struct { @@ -41,7 +41,7 @@ func (c *CDRomConfig) Prepare() []error { } func (s *StepAddCDRom) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(driver.VirtualMachine) if s.Config.CdromType == "sata" { diff --git a/builder/vsphere/common/step_add_floppy.go b/builder/vsphere/common/step_add_floppy.go index c82b08850..81016f5b5 100644 --- a/builder/vsphere/common/step_add_floppy.go +++ b/builder/vsphere/common/step_add_floppy.go @@ -8,8 +8,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type FloppyConfig struct { @@ -36,7 +36,7 @@ type StepAddFloppy struct { } func (s *StepAddFloppy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(driver.VirtualMachine) d := state.Get("driver").(driver.Driver) @@ -89,7 +89,7 @@ func (s *StepAddFloppy) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) d := state.Get("driver").(driver.Driver) if UploadedFloppyPath, ok := state.GetOk("uploaded_floppy_path"); ok { diff --git a/builder/vsphere/common/step_boot_command.go b/builder/vsphere/common/step_boot_command.go index 8d6658ad9..d1a4460d9 100644 --- a/builder/vsphere/common/step_boot_command.go +++ b/builder/vsphere/common/step_boot_command.go @@ -7,9 +7,9 @@ import ( "time" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "golang.org/x/mobile/event/key" ) @@ -42,7 +42,7 @@ type StepBootCommand struct { func (s *StepBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { debug := state.Get("debug").(bool) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) if s.Config.BootCommand == nil { diff --git a/builder/vsphere/common/step_config_params.go b/builder/vsphere/common/step_config_params.go index c317f25f5..7e35a0e7d 100644 --- a/builder/vsphere/common/step_config_params.go +++ b/builder/vsphere/common/step_config_params.go @@ -10,8 +10,8 @@ import ( "github.com/vmware/govmomi/vim25/types" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type ConfigParamsConfig struct { @@ -32,7 +32,7 @@ type StepConfigParams struct { } func (s *StepConfigParams) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) configParams := make(map[string]string) diff --git a/builder/vsphere/common/step_download.go b/builder/vsphere/common/step_download.go index 5b1adbda6..da22eea12 100644 --- a/builder/vsphere/common/step_download.go +++ b/builder/vsphere/common/step_download.go @@ -6,8 +6,8 @@ import ( "net/url" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Defining this interface ensures that we use the common step download, or the @@ -33,7 +33,7 @@ type StepDownload struct { func (s *StepDownload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(driver.Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) // Check whether iso is present on remote datastore. ds, err := driver.FindDatastore(s.Datastore, s.Host) diff --git a/builder/vsphere/common/step_export.go b/builder/vsphere/common/step_export.go index d3c857304..592644516 100644 --- a/builder/vsphere/common/step_export.go +++ b/builder/vsphere/common/step_export.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/pkg/errors" "github.com/vmware/govmomi/nfc" @@ -153,7 +154,7 @@ func (s *StepExport) Cleanup(multistep.StateBag) { } func (s *StepExport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) ui.Message("Starting export...") diff --git a/builder/vsphere/common/step_hardware.go b/builder/vsphere/common/step_hardware.go index 654a4145d..1ca1027dc 100644 --- a/builder/vsphere/common/step_hardware.go +++ b/builder/vsphere/common/step_hardware.go @@ -8,8 +8,8 @@ import ( "fmt" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type HardwareConfig struct { @@ -64,7 +64,7 @@ type StepConfigureHardware struct { } func (s *StepConfigureHardware) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(driver.VirtualMachine) if *s.Config != (HardwareConfig{}) { diff --git a/builder/vsphere/common/step_import_to_content_library.go b/builder/vsphere/common/step_import_to_content_library.go index 9eacdd5ec..d80d620d1 100644 --- a/builder/vsphere/common/step_import_to_content_library.go +++ b/builder/vsphere/common/step_import_to_content_library.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/vmware/govmomi/vapi/vcenter" ) @@ -117,7 +118,7 @@ type StepImportToContentLibrary struct { } func (s *StepImportToContentLibrary) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) var err error diff --git a/builder/vsphere/common/step_remote_upload.go b/builder/vsphere/common/step_remote_upload.go index 631ab0924..44911c1c7 100644 --- a/builder/vsphere/common/step_remote_upload.go +++ b/builder/vsphere/common/step_remote_upload.go @@ -7,8 +7,8 @@ import ( "path/filepath" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRemoteUpload struct { @@ -19,7 +19,7 @@ type StepRemoteUpload struct { } func (s *StepRemoteUpload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) d := state.Get("driver").(driver.Driver) if path, ok := state.GetOk("iso_path"); ok { @@ -54,7 +54,7 @@ func GetRemoteDirectoryAndPath(path string, ds driver.Datastore) (string, string return filename, remotePath, remoteDirectory, fullRemotePath } -func (s *StepRemoteUpload) uploadFile(path string, d driver.Driver, ui packer.Ui) (string, error) { +func (s *StepRemoteUpload) uploadFile(path string, d driver.Driver, ui packersdk.Ui) (string, error) { ds, err := d.FindDatastore(s.Datastore, s.Host) if err != nil { return "", fmt.Errorf("datastore doesn't exist: %v", err) @@ -98,7 +98,7 @@ func (s *StepRemoteUpload) Cleanup(state multistep.StateBag) { return } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) d := state.Get("driver").(*driver.VCenterDriver) ui.Say("Deleting cd_files image from remote datastore ...") diff --git a/builder/vsphere/common/step_remove_cdrom.go b/builder/vsphere/common/step_remove_cdrom.go index c3920ec29..0848aff76 100644 --- a/builder/vsphere/common/step_remove_cdrom.go +++ b/builder/vsphere/common/step_remove_cdrom.go @@ -7,8 +7,8 @@ import ( "context" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type RemoveCDRomConfig struct { @@ -21,7 +21,7 @@ type StepRemoveCDRom struct { } func (s *StepRemoveCDRom) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(driver.VirtualMachine) ui.Say("Eject CD-ROM drives...") diff --git a/builder/vsphere/common/step_remove_floppy.go b/builder/vsphere/common/step_remove_floppy.go index 4662c18b4..d94e4672d 100644 --- a/builder/vsphere/common/step_remove_floppy.go +++ b/builder/vsphere/common/step_remove_floppy.go @@ -4,8 +4,8 @@ import ( "context" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepRemoveFloppy struct { @@ -14,7 +14,7 @@ type StepRemoveFloppy struct { } func (s *StepRemoveFloppy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(driver.VirtualMachine) d := state.Get("driver").(driver.Driver) diff --git a/builder/vsphere/common/step_run.go b/builder/vsphere/common/step_run.go index 9262cb31e..82ba25237 100644 --- a/builder/vsphere/common/step_run.go +++ b/builder/vsphere/common/step_run.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type RunConfig struct { @@ -23,7 +23,7 @@ type StepRun struct { } func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) if s.Config.BootOrder != "" { @@ -54,7 +54,7 @@ func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.Ste } func (s *StepRun) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) if s.Config.BootOrder == "" && s.SetOrder { diff --git a/builder/vsphere/common/step_shutdown.go b/builder/vsphere/common/step_shutdown.go index 089aba26f..73f8594b7 100644 --- a/builder/vsphere/common/step_shutdown.go +++ b/builder/vsphere/common/step_shutdown.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type ShutdownConfig struct { @@ -52,7 +53,7 @@ type StepShutdown struct { } func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) if off, _ := vm.IsPoweredOff(); off { diff --git a/builder/vsphere/common/step_snapshot.go b/builder/vsphere/common/step_snapshot.go index ed595621d..af3afb8b9 100644 --- a/builder/vsphere/common/step_snapshot.go +++ b/builder/vsphere/common/step_snapshot.go @@ -4,8 +4,8 @@ import ( "context" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCreateSnapshot struct { @@ -13,7 +13,7 @@ type StepCreateSnapshot struct { } func (s *StepCreateSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) if s.CreateSnapshot { diff --git a/builder/vsphere/common/step_ssh_key_pair.go b/builder/vsphere/common/step_ssh_key_pair.go index 80fecaabc..91de68fb9 100644 --- a/builder/vsphere/common/step_ssh_key_pair.go +++ b/builder/vsphere/common/step_ssh_key_pair.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator/ssh" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -27,7 +27,7 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult return multistep.ActionContinue } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) comment := fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) if s.Comm.SSHPrivateKeyFile != "" { @@ -107,7 +107,7 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult func (s *StepSshKeyPair) Cleanup(state multistep.StateBag) { if s.Debug { if err := os.Remove(s.DebugKeyPath); err != nil { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Error(fmt.Sprintf( "Error removing debug key '%s': %s", s.DebugKeyPath, err)) } diff --git a/builder/vsphere/common/step_template.go b/builder/vsphere/common/step_template.go index 91c14ff58..481a2056f 100644 --- a/builder/vsphere/common/step_template.go +++ b/builder/vsphere/common/step_template.go @@ -4,8 +4,8 @@ import ( "context" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepConvertToTemplate struct { @@ -13,7 +13,7 @@ type StepConvertToTemplate struct { } func (s *StepConvertToTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) if s.ConvertToTemplate { diff --git a/builder/vsphere/common/step_wait_for_ip.go b/builder/vsphere/common/step_wait_for_ip.go index 9a37534c4..263a0db6c 100644 --- a/builder/vsphere/common/step_wait_for_ip.go +++ b/builder/vsphere/common/step_wait_for_ip.go @@ -11,8 +11,8 @@ import ( "time" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type WaitIpConfig struct { @@ -74,7 +74,7 @@ func (c *WaitIpConfig) GetIPNet() *net.IPNet { } func (s *StepWaitForIp) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) vm := state.Get("vm").(*driver.VirtualMachineDriver) var ip string diff --git a/builder/vsphere/driver/driver.go b/builder/vsphere/driver/driver.go index 8e565a653..472a82f5c 100644 --- a/builder/vsphere/driver/driver.go +++ b/builder/vsphere/driver/driver.go @@ -6,7 +6,7 @@ import ( "net/url" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/object" @@ -22,7 +22,7 @@ type Driver interface { NewVM(ref *types.ManagedObjectReference) VirtualMachine FindVM(name string) (VirtualMachine, error) FindCluster(name string) (*Cluster, error) - PreCleanVM(ui packer.Ui, vmPath string, force bool) error + PreCleanVM(ui packersdk.Ui, vmPath string, force bool) error CreateVM(config *CreateConfig) (VirtualMachine, error) NewDatastore(ref *types.ManagedObjectReference) Datastore diff --git a/builder/vsphere/driver/driver_mock.go b/builder/vsphere/driver/driver_mock.go index 7f8748606..6a2380514 100644 --- a/builder/vsphere/driver/driver_mock.go +++ b/builder/vsphere/driver/driver_mock.go @@ -3,7 +3,7 @@ package driver import ( "fmt" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi/vapi/library" "github.com/vmware/govmomi/vim25/types" ) @@ -52,7 +52,7 @@ func (d *DriverMock) FindCluster(name string) (*Cluster, error) { return nil, nil } -func (d *DriverMock) PreCleanVM(ui packer.Ui, vmPath string, force bool) error { +func (d *DriverMock) PreCleanVM(ui packersdk.Ui, vmPath string, force bool) error { d.PreCleanVMCalled = true if d.PreCleanShouldFail { return fmt.Errorf("pre clean failed") diff --git a/builder/vsphere/driver/vm.go b/builder/vsphere/driver/vm.go index acc80ec4e..d45fbbac1 100644 --- a/builder/vsphere/driver/vm.go +++ b/builder/vsphere/driver/vm.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/nfc" "github.com/vmware/govmomi/object" @@ -139,7 +139,7 @@ func (d *VCenterDriver) FindVM(name string) (VirtualMachine, error) { }, nil } -func (d *VCenterDriver) PreCleanVM(ui packer.Ui, vmPath string, force bool) error { +func (d *VCenterDriver) PreCleanVM(ui packersdk.Ui, vmPath string, force bool) error { vm, err := d.FindVM(vmPath) if err != nil { if _, ok := err.(*find.NotFoundError); !ok { diff --git a/builder/vsphere/iso/builder.go b/builder/vsphere/iso/builder.go index 837f4d7a6..8b6ff497a 100644 --- a/builder/vsphere/iso/builder.go +++ b/builder/vsphere/iso/builder.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Builder struct { @@ -28,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/vsphere/iso/step_create.go b/builder/vsphere/iso/step_create.go index 7b13f151a..ca2f3bd03 100644 --- a/builder/vsphere/iso/step_create.go +++ b/builder/vsphere/iso/step_create.go @@ -10,8 +10,8 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Defines a Network Adapter @@ -123,7 +123,7 @@ type StepCreateVM struct { } func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) d := state.Get("driver").(driver.Driver) vmPath := path.Join(s.Location.Folder, s.Location.VMName) diff --git a/builder/yandex/builder.go b/builder/yandex/builder.go index bbde04e84..c04479e3f 100644 --- a/builder/yandex/builder.go +++ b/builder/yandex/builder.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" @@ -49,7 +50,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a yandex Packer build and returns a packer.Artifact // representing a Yandex.Cloud compute image. -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := NewDriverYC(ui, &b.config.AccessConfig) ctx = requestid.ContextWithClientTraceID(ctx, uuid.New().String()) diff --git a/builder/yandex/driver_yc.go b/builder/yandex/driver_yc.go index 08e13d2aa..df4c9f46f 100644 --- a/builder/yandex/driver_yc.go +++ b/builder/yandex/driver_yc.go @@ -8,7 +8,7 @@ import ( "time" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/useragent" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -32,10 +32,10 @@ const ( type driverYC struct { sdk *ycsdk.SDK - ui packer.Ui + ui packersdk.Ui } -func NewDriverYC(ui packer.Ui, ac *AccessConfig) (Driver, error) { +func NewDriverYC(ui packersdk.Ui, ac *AccessConfig) (Driver, error) { log.Printf("[INFO] Initialize Yandex.Cloud client...") sdkConfig := ycsdk.Config{} diff --git a/builder/yandex/step_create_image.go b/builder/yandex/step_create_image.go index 429888a92..a225a522b 100644 --- a/builder/yandex/step_create_image.go +++ b/builder/yandex/step_create_image.go @@ -6,8 +6,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" @@ -20,7 +20,7 @@ type stepCreateImage struct { func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { sdk := state.Get("sdk").(*ycsdk.SDK) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) diskID := state.Get("disk_id").(string) diff --git a/builder/yandex/step_create_instance.go b/builder/yandex/step_create_instance.go index 0e6a99e89..46eb45aa9 100644 --- a/builder/yandex/step_create_instance.go +++ b/builder/yandex/step_create_instance.go @@ -7,8 +7,8 @@ import ( "io/ioutil" "github.com/c2h5oh/datasize" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -146,7 +146,7 @@ func getImage(ctx context.Context, c *Config, d Driver) (*Image, error) { func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { sdk := state.Get("sdk").(*ycsdk.SDK) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) @@ -317,7 +317,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) func (s *StepCreateInstance) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ctx, cancel := context.WithTimeout(context.Background(), config.StateTimeout) defer cancel() @@ -390,7 +390,7 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) { func (s *StepCreateInstance) writeSerialLogFile(ctx context.Context, state multistep.StateBag) error { sdk := state.Get("sdk").(*ycsdk.SDK) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceID := state.Get("instance_id").(string) ui.Say("Try get instance's serial port output and write to file " + s.SerialLogFile) diff --git a/builder/yandex/step_create_ssh_key.go b/builder/yandex/step_create_ssh_key.go index 19178848a..193287463 100644 --- a/builder/yandex/step_create_ssh_key.go +++ b/builder/yandex/step_create_ssh_key.go @@ -10,8 +10,8 @@ import ( "io/ioutil" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -21,7 +21,7 @@ type StepCreateSSHKey struct { } func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) if config.Communicator.SSHPrivateKeyFile != "" { diff --git a/builder/yandex/step_instance_info.go b/builder/yandex/step_instance_info.go index 3e7f0e3d5..e93758d07 100644 --- a/builder/yandex/step_instance_info.go +++ b/builder/yandex/step_instance_info.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" ycsdk "github.com/yandex-cloud/go-sdk" @@ -16,7 +16,7 @@ type stepInstanceInfo struct{} func (s *stepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { sdk := state.Get("sdk").(*ycsdk.SDK) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) instanceID := state.Get("instance_id").(string) diff --git a/builder/yandex/step_teardown_instance.go b/builder/yandex/step_teardown_instance.go index 0d34afe21..0c10b0673 100644 --- a/builder/yandex/step_teardown_instance.go +++ b/builder/yandex/step_teardown_instance.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" ycsdk "github.com/yandex-cloud/go-sdk" @@ -15,7 +15,7 @@ type StepTeardownInstance struct{} func (s *StepTeardownInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { sdk := state.Get("sdk").(*ycsdk.SDK) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) c := state.Get("config").(*Config) instanceID := state.Get("instance_id").(string) diff --git a/builder/yandex/step_wait_cloudinit_script.go b/builder/yandex/step_wait_cloudinit_script.go index 593def95c..35479f794 100644 --- a/builder/yandex/step_wait_cloudinit_script.go +++ b/builder/yandex/step_wait_cloudinit_script.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -22,7 +22,7 @@ type StepWaitCloudInitScript int func (s *StepWaitCloudInitScript) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { _ = state.Get("config").(*Config) driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceID := state.Get("instance_id").(string) ui.Say("Waiting for any running cloud-init script to finish...") diff --git a/builder/yandex/util.go b/builder/yandex/util.go index f11905f5a..42d2082a4 100644 --- a/builder/yandex/util.go +++ b/builder/yandex/util.go @@ -2,12 +2,12 @@ package yandex import ( "github.com/c2h5oh/datasize" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func stepHaltWithError(state multistep.StateBag, err error) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt diff --git a/command/build.go b/command/build.go index da0036ed1..e5acbdec9 100644 --- a/command/build.go +++ b/command/build.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/hcl/v2/hclparse" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/version" "golang.org/x/sync/semaphore" @@ -74,7 +75,7 @@ func (m *Meta) GetConfigFromHCL(cla *MetaArgs) (*hcl2template.PackerConfig, int) return cfg, writeDiags(m.Ui, parser.Files(), diags) } -func writeDiags(ui packer.Ui, files map[string]*hcl.File, diags hcl.Diagnostics) int { +func writeDiags(ui packersdk.Ui, files map[string]*hcl.File, diags hcl.Diagnostics) int { // write HCL errors/diagnostics if any. b := bytes.NewBuffer(nil) err := hcl.NewDiagnosticTextWriter(b, files, 80, false).WriteDiagnostics(diags) @@ -176,7 +177,7 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int packer.UiColorYellow, packer.UiColorBlue, } - buildUis := make(map[packer.Build]packer.Ui) + buildUis := make(map[packer.Build]packersdk.Ui) for i := range builds { ui := c.Ui if cla.Color { diff --git a/command/build_parallel_test.go b/command/build_parallel_test.go index abfc34d85..175cd6a02 100644 --- a/command/build_parallel_test.go +++ b/command/build_parallel_test.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/provisioner/sleep" ) @@ -36,7 +37,7 @@ func (b *ParallelTestBuilder) Prepare(raws ...interface{}) ([]string, []string, return nil, nil, nil } -func (b *ParallelTestBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { ui.Say("building") b.wg.Done() return nil, nil @@ -51,7 +52,7 @@ func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) return nil, nil, nil } -func (b *LockedBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { ui.Say("locking build") select { case <-b.unlock: diff --git a/command/meta.go b/command/meta.go index a57f7244b..60cae4c20 100644 --- a/command/meta.go +++ b/command/meta.go @@ -9,6 +9,7 @@ import ( kvflag "github.com/hashicorp/packer/command/flag-kv" "github.com/hashicorp/packer/helper/wrappedstreams" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" ) @@ -26,7 +27,7 @@ const ( // Packer command inherits. type Meta struct { CoreConfig *packer.CoreConfig - Ui packer.Ui + Ui packersdk.Ui Version string } diff --git a/command/signal.go b/command/signal.go index 5fcbacae7..091509026 100644 --- a/command/signal.go +++ b/command/signal.go @@ -7,10 +7,10 @@ import ( "os/signal" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -func handleTermInterrupt(ui packer.Ui) (context.Context, func()) { +func handleTermInterrupt(ui packersdk.Ui) (context.Context, func()) { ctx, cancelCtx := context.WithCancel(context.Background()) // Handle interrupts for this build sigCh := make(chan os.Signal, 1) diff --git a/go.mod b/go.mod index 352ad70ee..da0ef6825 100644 --- a/go.mod +++ b/go.mod @@ -59,6 +59,7 @@ require ( github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-cty-funcs v0.0.0-20200930094925-2721b1e36840 + github.com/hashicorp/go-getter v1.4.1 github.com/hashicorp/go-getter/gcs/v2 v2.0.0-20200604122502-a6995fa1edad github.com/hashicorp/go-getter/s3/v2 v2.0.0-20200604122502-a6995fa1edad github.com/hashicorp/go-getter/v2 v2.0.0-20200604122502-a6995fa1edad diff --git a/hcl2template/internal/mock.go b/hcl2template/internal/mock.go index 8b1dff62c..8a419ed5d 100644 --- a/hcl2template/internal/mock.go +++ b/hcl2template/internal/mock.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/json" @@ -77,7 +78,7 @@ func (b *MockBuilder) Prepare(raws ...interface{}) ([]string, []string, error) { return []string{"ID"}, nil, b.Config.Prepare(raws...) } -func (b *MockBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { return nil, nil } @@ -99,7 +100,7 @@ func (b *MockProvisioner) Prepare(raws ...interface{}) error { return b.Config.Prepare(raws...) } -func (b *MockProvisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (b *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { return nil } @@ -121,7 +122,7 @@ func (b *MockPostProcessor) Configure(raws ...interface{}) error { return b.Config.Prepare(raws...) } -func (b *MockPostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (b *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { return nil, false, false, nil } diff --git a/hcl2template/types.hcl_post-processor.go b/hcl2template/types.hcl_post-processor.go index 37ae1660f..d74366e7a 100644 --- a/hcl2template/types.hcl_post-processor.go +++ b/hcl2template/types.hcl_post-processor.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -62,7 +63,7 @@ func (p *HCL2PostProcessor) Configure(args ...interface{}) error { return p.PostProcessor.Configure(args...) } -func (p *HCL2PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *HCL2PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { generatedData := make(map[string]interface{}) if artifactStateData, ok := artifact.State("generated_data").(map[interface{}]interface{}); ok { for k, v := range artifactStateData { diff --git a/hcl2template/types.hcl_provisioner.go b/hcl2template/types.hcl_provisioner.go index c91d38cfd..dff9b31b5 100644 --- a/hcl2template/types.hcl_provisioner.go +++ b/hcl2template/types.hcl_provisioner.go @@ -3,9 +3,11 @@ package hcl2template import ( "context" "fmt" + "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -65,7 +67,7 @@ func (p *HCL2Provisioner) Prepare(args ...interface{}) error { return p.Provisioner.Prepare(args...) } -func (p *HCL2Provisioner) Provision(ctx context.Context, ui packer.Ui, c packer.Communicator, vars map[string]interface{}) error { +func (p *HCL2Provisioner) Provision(ctx context.Context, ui packersdk.Ui, c packer.Communicator, vars map[string]interface{}) error { err := p.HCL2Prepare(vars) if err != nil { return err diff --git a/helper/communicator/step_connect.go b/helper/communicator/step_connect.go index 8ecaa6b0e..5f4e881ec 100644 --- a/helper/communicator/step_connect.go +++ b/helper/communicator/step_connect.go @@ -6,8 +6,8 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/none" gossh "golang.org/x/crypto/ssh" ) @@ -57,7 +57,7 @@ func (s *StepConnect) pause(pauseLen time.Duration, ctx context.Context) bool { } func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) typeMap := map[string]multistep.Step{ "none": nil, diff --git a/helper/communicator/step_connect_ssh.go b/helper/communicator/step_connect_ssh.go index 93ba8a3a6..4b9e6b8c4 100644 --- a/helper/communicator/step_connect_ssh.go +++ b/helper/communicator/step_connect_ssh.go @@ -16,6 +16,7 @@ import ( helperssh "github.com/hashicorp/packer/helper/communicator/ssh" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh" gossh "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" @@ -34,7 +35,7 @@ type StepConnectSSH struct { } func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) var comm packer.Communicator var err error diff --git a/helper/communicator/step_connect_winrm.go b/helper/communicator/step_connect_winrm.go index 62d248701..7452687b3 100644 --- a/helper/communicator/step_connect_winrm.go +++ b/helper/communicator/step_connect_winrm.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/winrm" winrmcmd "github.com/masterzen/winrm" "golang.org/x/net/http/httpproxy" @@ -25,7 +26,7 @@ import ( // configuration when creating the step. // // Uses: -// ui packer.Ui +// ui packersdk.Ui // // Produces: // communicator packer.Communicator @@ -38,7 +39,7 @@ type StepConnectWinRM struct { } func (s *StepConnectWinRM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) var comm packer.Communicator var err error @@ -181,7 +182,7 @@ func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Co } log.Printf("Checking that WinRM is connected with: '%s'", connectCheckCommand) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) err := cmd.RunWithUi(ctx, comm, ui) if err != nil { diff --git a/helper/communicator/step_debug_ssh_keys.go b/helper/communicator/step_debug_ssh_keys.go index cd67e0641..ab3c62473 100644 --- a/helper/communicator/step_debug_ssh_keys.go +++ b/helper/communicator/step_debug_ssh_keys.go @@ -5,8 +5,8 @@ import ( "fmt" "io/ioutil" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepDumpSSHKey is a multistep Step implementation that writes the ssh @@ -17,7 +17,7 @@ type StepDumpSSHKey struct { } func (s *StepDumpSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Message(fmt.Sprintf("Saving key for debug purposes: %s", s.Path)) diff --git a/helper/communicator/step_ssh_keygen.go b/helper/communicator/step_ssh_keygen.go index 73e340529..34f695779 100644 --- a/helper/communicator/step_ssh_keygen.go +++ b/helper/communicator/step_ssh_keygen.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/hashicorp/packer/helper/communicator/sshkey" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepSSHKeyGen is a Packer build step that generates SSH key pairs. @@ -18,7 +18,7 @@ type StepSSHKeyGen struct { // Run executes the Packer build step that generates SSH key pairs. // The key pairs are added to the ssh config func (s *StepSSHKeyGen) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) comm := s.CommConf if comm.SSHPrivateKeyFile != "" { diff --git a/main.go b/main.go index 55b295b78..3041a22e5 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/go-uuid" "github.com/hashicorp/packer/command" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" "github.com/hashicorp/packer/packer/plugin" "github.com/hashicorp/packer/version" @@ -180,7 +181,7 @@ func wrappedMain() int { defer plugin.CleanupClients() - var ui packer.Ui + var ui packersdk.Ui if machineReadable { // Setup the UI as we're being machine-readable ui = &packer.MachineReadableUi{ diff --git a/packer-plugin-sdk/adapter/adapter.go b/packer-plugin-sdk/adapter/adapter.go index 8071fff52..230ffd34a 100644 --- a/packer-plugin-sdk/adapter/adapter.go +++ b/packer-plugin-sdk/adapter/adapter.go @@ -13,6 +13,7 @@ import ( "github.com/google/shlex" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -23,11 +24,11 @@ type Adapter struct { l net.Listener config *ssh.ServerConfig sftpCmd string - ui packer.Ui + ui packersdk.Ui comm packer.Communicator } -func NewAdapter(done <-chan struct{}, l net.Listener, config *ssh.ServerConfig, sftpCmd string, ui packer.Ui, comm packer.Communicator) *Adapter { +func NewAdapter(done <-chan struct{}, l net.Listener, config *ssh.ServerConfig, sftpCmd string, ui packersdk.Ui, comm packer.Communicator) *Adapter { return &Adapter{ done: done, l: l, @@ -63,7 +64,7 @@ func (c *Adapter) Serve() { } } -func (c *Adapter) Handle(conn net.Conn, ui packer.Ui) error { +func (c *Adapter) Handle(conn net.Conn, ui packersdk.Ui) error { log.Print("SSH proxy: accepted connection") _, chans, reqs, err := ssh.NewServerConn(conn, c.config) if err != nil { diff --git a/packer-plugin-sdk/chroot/run_local_commands.go b/packer-plugin-sdk/chroot/run_local_commands.go index 320c7dcca..fce3d5154 100644 --- a/packer-plugin-sdk/chroot/run_local_commands.go +++ b/packer-plugin-sdk/chroot/run_local_commands.go @@ -6,11 +6,12 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) -func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, ictx interpolate.Context, ui packer.Ui) error { +func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, ictx interpolate.Context, ui packersdk.Ui) error { ctx := context.TODO() for _, rawCmd := range commands { intCmd, err := interpolate.Render(rawCmd, &ictx) diff --git a/packer-plugin-sdk/chroot/step_chroot_provision.go b/packer-plugin-sdk/chroot/step_chroot_provision.go index e3e9030a7..60f2c3a17 100644 --- a/packer-plugin-sdk/chroot/step_chroot_provision.go +++ b/packer-plugin-sdk/chroot/step_chroot_provision.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepChrootProvision provisions the instance within a chroot. @@ -17,7 +18,7 @@ type StepChrootProvision struct { func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) // Create our communicator diff --git a/packer-plugin-sdk/chroot/step_copy_files.go b/packer-plugin-sdk/chroot/step_copy_files.go index 1d2efa7cf..50c76b68c 100644 --- a/packer-plugin-sdk/chroot/step_copy_files.go +++ b/packer-plugin-sdk/chroot/step_copy_files.go @@ -8,9 +8,9 @@ import ( "path/filepath" "runtime" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepCopyFiles copies some files from the host into the chroot environment. @@ -25,7 +25,7 @@ type StepCopyFiles struct { func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) stderr := new(bytes.Buffer) @@ -75,7 +75,7 @@ func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multi } func (s *StepCopyFiles) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) } diff --git a/packer-plugin-sdk/chroot/step_copy_files_test.go b/packer-plugin-sdk/chroot/step_copy_files_test.go index e5ebabc85..fc257188e 100644 --- a/packer-plugin-sdk/chroot/step_copy_files_test.go +++ b/packer-plugin-sdk/chroot/step_copy_files_test.go @@ -13,10 +13,11 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // testUI returns a test ui plus a function to retrieve the errors written to the ui -func testUI() (packer.Ui, func() string) { +func testUI() (packersdk.Ui, func() string) { errorBuffer := &strings.Builder{} ui := &packer.BasicUi{ Reader: strings.NewReader(""), diff --git a/packer-plugin-sdk/chroot/step_early_cleanup.go b/packer-plugin-sdk/chroot/step_early_cleanup.go index e84ac77e2..e8cf9593f 100644 --- a/packer-plugin-sdk/chroot/step_early_cleanup.go +++ b/packer-plugin-sdk/chroot/step_early_cleanup.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepEarlyCleanup performs some of the cleanup steps early in order to @@ -14,7 +14,7 @@ import ( type StepEarlyCleanup struct{} func (s *StepEarlyCleanup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cleanupKeys := []string{ "copy_files_cleanup", "mount_extra_cleanup", diff --git a/packer-plugin-sdk/chroot/step_mount_extra.go b/packer-plugin-sdk/chroot/step_mount_extra.go index 8d460718c..0ad511df2 100644 --- a/packer-plugin-sdk/chroot/step_mount_extra.go +++ b/packer-plugin-sdk/chroot/step_mount_extra.go @@ -8,9 +8,9 @@ import ( "os/exec" "syscall" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepMountExtra mounts the attached device. @@ -24,7 +24,7 @@ type StepMountExtra struct { func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) s.mounts = make([]string, 0, len(s.ChrootMounts)) @@ -77,7 +77,7 @@ func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) mult } func (s *StepMountExtra) Cleanup(state multistep.StateBag) { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if err := s.CleanupFunc(state); err != nil { ui.Error(err.Error()) diff --git a/packer-plugin-sdk/chroot/step_post_mount_commands.go b/packer-plugin-sdk/chroot/step_post_mount_commands.go index d6ee85968..55ecee7ca 100644 --- a/packer-plugin-sdk/chroot/step_post_mount_commands.go +++ b/packer-plugin-sdk/chroot/step_post_mount_commands.go @@ -3,9 +3,9 @@ package chroot import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type postMountCommandsData struct { @@ -23,7 +23,7 @@ func (s *StepPostMountCommands) Run(ctx context.Context, state multistep.StateBa config := state.Get("config").(interpolateContextProvider) device := state.Get("device").(string) mountPath := state.Get("mount_path").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) if len(s.Commands) == 0 { diff --git a/packer-plugin-sdk/chroot/step_pre_mount_commands.go b/packer-plugin-sdk/chroot/step_pre_mount_commands.go index 20404659f..41c413a13 100644 --- a/packer-plugin-sdk/chroot/step_pre_mount_commands.go +++ b/packer-plugin-sdk/chroot/step_pre_mount_commands.go @@ -3,9 +3,9 @@ package chroot import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type preMountCommandsData struct { @@ -20,7 +20,7 @@ type StepPreMountCommands struct { func (s *StepPreMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(interpolateContextProvider) device := state.Get("device").(string) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) if len(s.Commands) == 0 { diff --git a/packer-plugin-sdk/multistep/commonsteps/multistep_debug.go b/packer-plugin-sdk/multistep/commonsteps/multistep_debug.go index 74b45a61c..5c64d3545 100644 --- a/packer-plugin-sdk/multistep/commonsteps/multistep_debug.go +++ b/packer-plugin-sdk/multistep/commonsteps/multistep_debug.go @@ -5,13 +5,13 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MultistepDebugFn will return a proper multistep.DebugPauseFn to // use for debugging if you're using multistep in your builder. -func MultistepDebugFn(ui packer.Ui) multistep.DebugPauseFn { +func MultistepDebugFn(ui packersdk.Ui) multistep.DebugPauseFn { return func(loc multistep.DebugLocation, name string, state multistep.StateBag) { var locationString string switch loc { diff --git a/packer-plugin-sdk/multistep/commonsteps/multistep_runner.go b/packer-plugin-sdk/multistep/commonsteps/multistep_runner.go index d9654cc6c..119a7e8e3 100644 --- a/packer-plugin-sdk/multistep/commonsteps/multistep_runner.go +++ b/packer-plugin-sdk/multistep/commonsteps/multistep_runner.go @@ -8,12 +8,12 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -func newRunner(steps []multistep.Step, config common.PackerConfig, ui packer.Ui) (multistep.Runner, multistep.DebugPauseFn) { +func newRunner(steps []multistep.Step, config common.PackerConfig, ui packersdk.Ui) (multistep.Runner, multistep.DebugPauseFn) { switch config.PackerOnError { case "", "cleanup": case "abort": @@ -48,7 +48,7 @@ func newRunner(steps []multistep.Step, config common.PackerConfig, ui packer.Ui) // NewRunner returns a multistep.Runner that runs steps augmented with support // for -debug and -on-error command line arguments. -func NewRunner(steps []multistep.Step, config common.PackerConfig, ui packer.Ui) multistep.Runner { +func NewRunner(steps []multistep.Step, config common.PackerConfig, ui packersdk.Ui) multistep.Runner { runner, _ := newRunner(steps, config, ui) return runner } @@ -57,7 +57,7 @@ func NewRunner(steps []multistep.Step, config common.PackerConfig, ui packer.Ui) // with support for -debug and -on-error command line arguments. With -debug it // puts the multistep.DebugPauseFn that will pause execution between steps into // the state under the key "pauseFn". -func NewRunnerWithPauseFn(steps []multistep.Step, config common.PackerConfig, ui packer.Ui, state multistep.StateBag) multistep.Runner { +func NewRunnerWithPauseFn(steps []multistep.Step, config common.PackerConfig, ui packersdk.Ui, state multistep.StateBag) multistep.Runner { runner, pauseFn := newRunner(steps, config, ui) if pauseFn != nil { state.Put("pauseFn", pauseFn) @@ -72,7 +72,7 @@ func typeName(i interface{}) string { type abortStep struct { step multistep.Step cleanupProv bool - ui packer.Ui + ui packersdk.Ui } func (s abortStep) InnerStepName() string { @@ -98,7 +98,7 @@ func (s abortStep) Cleanup(state multistep.StateBag) { type askStep struct { step multistep.Step - ui packer.Ui + ui packersdk.Ui } func (s askStep) InnerStepName() string { @@ -148,7 +148,7 @@ const ( askRetry ) -func ask(ui packer.Ui, name string, state multistep.StateBag) askResponse { +func ask(ui packersdk.Ui, name string, state multistep.StateBag) askResponse { ui.Say(fmt.Sprintf("Step %q failed", name)) result := make(chan askResponse) @@ -168,7 +168,7 @@ func ask(ui packer.Ui, name string, state multistep.StateBag) askResponse { } } -func askPrompt(ui packer.Ui) askResponse { +func askPrompt(ui packersdk.Ui) askResponse { for { line, err := ui.Ask("[c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?") if err != nil { @@ -188,7 +188,7 @@ func askPrompt(ui packer.Ui) askResponse { } } -func handleAbortsAndInterupts(state multistep.StateBag, ui packer.Ui, stepName string) bool { +func handleAbortsAndInterupts(state multistep.StateBag, ui packersdk.Ui, stepName string) bool { // if returns false, don't run cleanup. If true, do run cleanup. _, alreadyLogged := state.GetOk("abort_step_logged") diff --git a/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go b/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go index 0bb41c342..aa9924797 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepCleanupTempKeys struct { @@ -32,7 +33,7 @@ func (s *StepCleanupTempKeys) Run(ctx context.Context, state multistep.StateBag) } comm := state.Get("communicator").(packer.Communicator) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cmd := new(packer.RemoteCmd) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom.go b/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom.go index 0729ae09c..fddeed117 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom.go @@ -11,8 +11,8 @@ import ( "runtime" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shell-local/localexec" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -36,7 +36,7 @@ func (s *StepCreateCD) Run(ctx context.Context, state multistep.StateBag) multis return multistep.ActionContinue } - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating CD disk...") if s.Label == "" { diff --git a/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go b/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go index 5354143df..920da32fa 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go @@ -10,8 +10,8 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" "github.com/mitchellh/go-fs" "github.com/mitchellh/go-fs/fat" @@ -42,7 +42,7 @@ func (s *StepCreateFloppy) Run(ctx context.Context, state multistep.StateBag) mu s.FilesAdded = make(map[string]bool) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Creating floppy disk...") // Create a temporary file to be our floppy drive diff --git a/packer-plugin-sdk/multistep/commonsteps/step_download.go b/packer-plugin-sdk/multistep/commonsteps/step_download.go index 36a38ae7c..dee8bcf76 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_download.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_download.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/filelock" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepDownload downloads a remote file using the download client within @@ -28,7 +29,7 @@ import ( // // Uses: // cache packer.Cache -// ui packer.Ui +// ui packersdk.Ui type StepDownload struct { // The checksum and the type of the checksum for the download Checksum string @@ -72,7 +73,7 @@ func (s *StepDownload) Run(ctx context.Context, state multistep.StateBag) multis defer log.Printf("Leaving retrieve loop for %s", s.Description) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say(fmt.Sprintf("Retrieving %s", s.Description)) var errs []error @@ -160,7 +161,7 @@ func (s *StepDownload) UseSourceToFindCacheTarget(source string) (*url.URL, stri return u, targetPath, nil } -func (s *StepDownload) download(ctx context.Context, ui packer.Ui, source string) (string, error) { +func (s *StepDownload) download(ctx context.Context, ui packersdk.Ui, source string) (string, error) { u, targetPath, err := s.UseSourceToFindCacheTarget(source) if err != nil { return "", err diff --git a/packer-plugin-sdk/multistep/commonsteps/step_http_server.go b/packer-plugin-sdk/multistep/commonsteps/step_http_server.go index 6da16718e..59a643055 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_http_server.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_http_server.go @@ -6,9 +6,9 @@ import ( "net/http" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/net" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This step creates and runs the HTTP server that is serving files from the @@ -16,7 +16,7 @@ import ( // template. // // Uses: -// ui packer.Ui +// ui packersdk.Ui // // Produces: // http_port int - The port the HTTP server started on. @@ -30,7 +30,7 @@ type StepHTTPServer struct { } func (s *StepHTTPServer) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if s.HTTPDir == "" { state.Put("http_port", 0) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_output_dir.go b/packer-plugin-sdk/multistep/commonsteps/step_output_dir.go index c1e43716a..3a747ff03 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_output_dir.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_output_dir.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepOutputDir sets up the output directory by creating it if it does @@ -23,7 +23,7 @@ type StepOutputDir struct { } func (s *StepOutputDir) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) if _, err := os.Stat(s.Path); err == nil { if !s.Force { @@ -70,7 +70,7 @@ func (s *StepOutputDir) Cleanup(state multistep.StateBag) { _, halted := state.GetOk(multistep.StateHalted) if cancelled || halted { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) ui.Say("Deleting output directory...") for i := 0; i < 5; i++ { diff --git a/packer-plugin-sdk/multistep/commonsteps/step_provision.go b/packer-plugin-sdk/multistep/commonsteps/step_provision.go index 9b7cc47e2..a7118b84c 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_provision.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_provision.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // StepProvision runs the provisioners. @@ -18,7 +19,7 @@ import ( // Uses: // communicator packer.Communicator // hook packer.Hook -// ui packer.Ui +// ui packersdk.Ui // // Produces: // @@ -109,7 +110,7 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa } hook := state.Get("hook").(packer.Hook) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) hookData := PopulateProvisionHookData(state) diff --git a/packer-plugin-sdk/packer/ui.go b/packer-plugin-sdk/packer/ui.go new file mode 100644 index 000000000..1bc1b4591 --- /dev/null +++ b/packer-plugin-sdk/packer/ui.go @@ -0,0 +1,16 @@ +package packer + +import "github.com/hashicorp/go-getter" + +// The Ui interface handles all communication for Packer with the outside +// world. This sort of control allows us to strictly control how output +// is formatted and various levels of output. +type Ui interface { + Ask(string) (string, error) + Say(string) + Message(string) + Error(string) + Machine(string, ...string) + // TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) + getter.ProgressTracker +} diff --git a/packer-plugin-sdk/shell-local/localexec/run_and_stream.go b/packer-plugin-sdk/shell-local/localexec/run_and_stream.go index d1c7d8d1c..c5f932015 100644 --- a/packer-plugin-sdk/shell-local/localexec/run_and_stream.go +++ b/packer-plugin-sdk/shell-local/localexec/run_and_stream.go @@ -12,13 +12,14 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/iochan" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // RunAndStream allows you to run a local command and stream output to the UI. // This does not require use of a shell-local communicator, so is a nice tool // for plugins that need to shell out to a local dependency and provide clear // output to users. -func RunAndStream(cmd *exec.Cmd, ui packer.Ui, sensitive []string) error { +func RunAndStream(cmd *exec.Cmd, ui packersdk.Ui, sensitive []string) error { stdout_r, stdout_w := io.Pipe() stderr_r, stderr_w := io.Pipe() defer stdout_w.Close() diff --git a/packer-plugin-sdk/shell-local/run.go b/packer-plugin-sdk/shell-local/run.go index 8e52f5a09..9b7a0b961 100644 --- a/packer-plugin-sdk/shell-local/run.go +++ b/packer-plugin-sdk/shell-local/run.go @@ -13,11 +13,12 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) -func Run(ctx context.Context, ui packer.Ui, config *Config, generatedData map[string]interface{}) (bool, error) { +func Run(ctx context.Context, ui packersdk.Ui, config *Config, generatedData map[string]interface{}) (bool, error) { if generatedData != nil { config.generatedData = generatedData } else { diff --git a/packer/build.go b/packer/build.go index 28e02f3c5..28313ee27 100644 --- a/packer/build.go +++ b/packer/build.go @@ -6,6 +6,7 @@ import ( "log" "sync" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/version" ) @@ -63,7 +64,7 @@ type Build interface { // Run runs the actual builder, returning an artifact implementation // of what is built. If anything goes wrong, an error is returned. // Run can be context cancelled. - Run(context.Context, Ui) ([]Artifact, error) + Run(context.Context, packersdk.Ui) ([]Artifact, error) // SetDebug will enable/disable debug mode. Debug mode is always // enabled by adding the additional key "packer_debug" to boolean @@ -231,7 +232,7 @@ func (b *CoreBuild) Prepare() (warn []string, err error) { } // Runs the actual build. Prepare must be called prior to running this. -func (b *CoreBuild) Run(ctx context.Context, originalUi Ui) ([]Artifact, error) { +func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]Artifact, error) { if !b.prepareCalled { panic("Prepare must be called first") } diff --git a/packer/builder.go b/packer/builder.go index 11bdc3046..9c0296632 100644 --- a/packer/builder.go +++ b/packer/builder.go @@ -2,6 +2,8 @@ package packer import ( "context" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Implementers of Builder are responsible for actually building images @@ -35,5 +37,5 @@ type Builder interface { Prepare(...interface{}) ([]string, []string, error) // Run is where the actual build should take place. It takes a Build and a Ui. - Run(context.Context, Ui, Hook) (Artifact, error) + Run(context.Context, packersdk.Ui, Hook) (Artifact, error) } diff --git a/packer/builder_mock.go b/packer/builder_mock.go index 06aa87291..e3585fd95 100644 --- a/packer/builder_mock.go +++ b/packer/builder_mock.go @@ -7,6 +7,7 @@ import ( "errors" "github.com/hashicorp/hcl/v2/hcldec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MockBuilder is an implementation of Builder that can be used for tests. @@ -22,7 +23,7 @@ type MockBuilder struct { PrepareConfig []interface{} RunCalled bool RunHook Hook - RunUi Ui + RunUi packersdk.Ui CancelCalled bool RunFn func(ctx context.Context) @@ -39,7 +40,7 @@ func (tb *MockBuilder) Prepare(config ...interface{}) ([]string, []string, error return tb.GeneratedVars, tb.PrepareWarnings, nil } -func (tb *MockBuilder) Run(ctx context.Context, ui Ui, h Hook) (Artifact, error) { +func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (Artifact, error) { tb.RunCalled = true tb.RunHook = h tb.RunUi = ui diff --git a/packer/builder_mock.hcl2spec.go b/packer/builder_mock.hcl2spec.go index 5f5de8a11..61687b14c 100644 --- a/packer/builder_mock.hcl2spec.go +++ b/packer/builder_mock.hcl2spec.go @@ -5,6 +5,7 @@ import ( "io" "github.com/hashicorp/hcl/v2/hcldec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -19,7 +20,7 @@ type FlatMockBuilder struct { PrepareConfig []interface{} `cty:"prepare_config" hcl:"prepare_config"` RunCalled *bool `cty:"run_called" hcl:"run_called"` RunHook Hook `cty:"run_hook" hcl:"run_hook"` - RunUi Ui `cty:"run_ui" hcl:"run_ui"` + RunUi packersdk.Ui `cty:"run_ui" hcl:"run_ui"` CancelCalled *bool `cty:"cancel_called" hcl:"cancel_called"` GeneratedVars []string `cty:"generated_vars" hcl:"generated_vars"` } @@ -120,7 +121,7 @@ type FlatMockPostProcessor struct { ConfigureError error `cty:"configure_error" hcl:"configure_error"` PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` PostProcessArtifact Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` - PostProcessUi Ui `cty:"post_process_ui" hcl:"post_process_ui"` + PostProcessUi packersdk.Ui `cty:"post_process_ui" hcl:"post_process_ui"` } // FlatMapstructure returns a new FlatMockPostProcessor. @@ -157,7 +158,7 @@ type FlatMockProvisioner struct { ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` ProvCommunicator Communicator `cty:"prov_communicator" hcl:"prov_communicator"` - ProvUi Ui `cty:"prov_ui" hcl:"prov_ui"` + ProvUi packersdk.Ui `cty:"prov_ui" hcl:"prov_ui"` } // FlatMapstructure returns a new FlatMockProvisioner. diff --git a/packer/communicator.go b/packer/communicator.go index 026737d4b..6bf76e86a 100644 --- a/packer/communicator.go +++ b/packer/communicator.go @@ -8,6 +8,7 @@ import ( "sync" "unicode" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/mitchellh/iochan" ) @@ -88,7 +89,7 @@ type ConfigurableCommunicator interface { // RunWithUi runs the remote command and streams the output to any configured // Writers for stdout/stderr, while also writing each line as it comes to a Ui. // RunWithUi will not return until the command finishes or is cancelled. -func (r *RemoteCmd) RunWithUi(ctx context.Context, c Communicator, ui Ui) error { +func (r *RemoteCmd) RunWithUi(ctx context.Context, c Communicator, ui packersdk.Ui) error { r.initchan() stdout_r, stdout_w := io.Pipe() diff --git a/packer/hook.go b/packer/hook.go index ee8104ac9..583fcb706 100644 --- a/packer/hook.go +++ b/packer/hook.go @@ -2,6 +2,8 @@ package packer import ( "context" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This is the hook that should be fired for provisioners to run. @@ -22,7 +24,7 @@ const HookCleanupProvision = "packer_cleanup_provision" // must be race-free. Cancel should attempt to cancel the hook in the quickest, // safest way possible. type Hook interface { - Run(context.Context, string, Ui, Communicator, interface{}) error + Run(context.Context, string, packersdk.Ui, Communicator, interface{}) error } // A Hook implementation that dispatches based on an internal mapping. @@ -33,7 +35,7 @@ type DispatchHook struct { // Runs the hook with the given name by dispatching it to the proper // hooks if a mapping exists. If a mapping doesn't exist, then nothing // happens. -func (h *DispatchHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { +func (h *DispatchHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { hooks, ok := h.Mapping[name] if !ok { // No hooks for that name. No problem. diff --git a/packer/hook_mock.go b/packer/hook_mock.go index 16571f1fe..f6243f988 100644 --- a/packer/hook_mock.go +++ b/packer/hook_mock.go @@ -2,6 +2,8 @@ package packer import ( "context" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MockHook is an implementation of Hook that can be used for tests. @@ -12,10 +14,10 @@ type MockHook struct { RunComm Communicator RunData interface{} RunName string - RunUi Ui + RunUi packersdk.Ui } -func (t *MockHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { +func (t *MockHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { t.RunCalled = true t.RunComm = comm diff --git a/packer/hook_test.go b/packer/hook_test.go index efe0f0fd0..8bbbb943e 100644 --- a/packer/hook_test.go +++ b/packer/hook_test.go @@ -3,6 +3,8 @@ package packer import ( "context" "testing" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestDispatchHook_Implements(t *testing.T) { @@ -40,7 +42,7 @@ type CancelHook struct { cancel func() } -func (h *CancelHook) Run(ctx context.Context, _ string, _ Ui, _ Communicator, _ interface{}) error { +func (h *CancelHook) Run(ctx context.Context, _ string, _ packersdk.Ui, _ Communicator, _ interface{}) error { h.cancel() <-ctx.Done() return ctx.Err() diff --git a/packer/plugin/builder.go b/packer/plugin/builder.go index abe508692..95ee181eb 100644 --- a/packer/plugin/builder.go +++ b/packer/plugin/builder.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdBuilder struct { @@ -31,7 +32,7 @@ func (b *cmdBuilder) Prepare(config ...interface{}) ([]string, []string, error) return b.builder.Prepare(config...) } -func (b *cmdBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { defer func() { r := recover() b.checkExit(r, nil) diff --git a/packer/plugin/hook.go b/packer/plugin/hook.go index e983e00af..92da9cb18 100644 --- a/packer/plugin/hook.go +++ b/packer/plugin/hook.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdHook struct { @@ -12,7 +13,7 @@ type cmdHook struct { client *Client } -func (c *cmdHook) Run(ctx context.Context, name string, ui packer.Ui, comm packer.Communicator, data interface{}) error { +func (c *cmdHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packer.Communicator, data interface{}) error { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/plugin/post_processor.go b/packer/plugin/post_processor.go index 98a956523..1d9877081 100644 --- a/packer/plugin/post_processor.go +++ b/packer/plugin/post_processor.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdPostProcessor struct { @@ -31,7 +32,7 @@ func (c *cmdPostProcessor) Configure(config ...interface{}) error { return c.p.Configure(config...) } -func (c *cmdPostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (c *cmdPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/plugin/post_processor_test.go b/packer/plugin/post_processor_test.go index b28340773..5c72d8f45 100644 --- a/packer/plugin/post_processor_test.go +++ b/packer/plugin/post_processor_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type helperPostProcessor byte @@ -17,7 +18,7 @@ func (helperPostProcessor) Configure(...interface{}) error { return nil } -func (helperPostProcessor) PostProcess(context.Context, packer.Ui, packer.Artifact) (packer.Artifact, bool, bool, error) { +func (helperPostProcessor) PostProcess(context.Context, packersdk.Ui, packer.Artifact) (packer.Artifact, bool, bool, error) { return nil, false, false, nil } diff --git a/packer/plugin/provisioner.go b/packer/plugin/provisioner.go index bc07d6b61..8602b7ad1 100644 --- a/packer/plugin/provisioner.go +++ b/packer/plugin/provisioner.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdProvisioner struct { @@ -31,7 +32,7 @@ func (c *cmdProvisioner) Prepare(configs ...interface{}) error { return c.p.Prepare(configs...) } -func (c *cmdProvisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (c *cmdProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/post_processor.go b/packer/post_processor.go index fd7df4e27..b1f32382c 100644 --- a/packer/post_processor.go +++ b/packer/post_processor.go @@ -1,6 +1,10 @@ package packer -import "context" +import ( + "context" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" +) // A PostProcessor is responsible for taking an artifact of a build // and doing some sort of post-processing to turn this into another @@ -22,5 +26,5 @@ type PostProcessor interface { // user input for keep_input_artifact is ignored and the artifact is either // kept or discarded according to the value set in `keep`. // PostProcess is cancellable using context - PostProcess(context.Context, Ui, Artifact) (a Artifact, keep bool, forceOverride bool, err error) + PostProcess(context.Context, packersdk.Ui, Artifact) (a Artifact, keep bool, forceOverride bool, err error) } diff --git a/packer/post_processor_mock.go b/packer/post_processor_mock.go index b03abd4eb..87284e819 100644 --- a/packer/post_processor_mock.go +++ b/packer/post_processor_mock.go @@ -4,6 +4,7 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MockPostProcessor is an implementation of PostProcessor that can be @@ -20,7 +21,7 @@ type MockPostProcessor struct { PostProcessCalled bool PostProcessArtifact Artifact - PostProcessUi Ui + PostProcessUi packersdk.Ui } func (t *MockPostProcessor) ConfigSpec() hcldec.ObjectSpec { return t.FlatMapstructure().HCL2Spec() } @@ -31,7 +32,7 @@ func (t *MockPostProcessor) Configure(configs ...interface{}) error { return t.ConfigureError } -func (t *MockPostProcessor) PostProcess(ctx context.Context, ui Ui, a Artifact) (Artifact, bool, bool, error) { +func (t *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a Artifact) (Artifact, bool, bool, error) { t.PostProcessCalled = true t.PostProcessArtifact = a t.PostProcessUi = ui diff --git a/packer/provisioner.go b/packer/provisioner.go index 78da57524..0fa22fb42 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -8,6 +8,7 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" ) @@ -25,7 +26,7 @@ type Provisioner interface { // given for cancellation, a UI is given to communicate with the user, and // a communicator is given that is guaranteed to be connected to some // machine so that provisioning can be done. - Provision(context.Context, Ui, Communicator, map[string]interface{}) error + Provision(context.Context, packersdk.Ui, Communicator, map[string]interface{}) error } // A HookedProvisioner represents a provisioner and information describing it @@ -119,7 +120,7 @@ func CastDataToMap(data interface{}) map[string]interface{} { } // Runs the provisioners in order. -func (h *ProvisionHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { +func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { // Shortcut if len(h.Provisioners) == 0 { return nil @@ -159,7 +160,7 @@ func (p *PausedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *PausedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { // Use a select to determine if we get cancelled during the wait ui.Say(fmt.Sprintf("Pausing %s before the next provisioner...", p.PauseBefore)) @@ -185,7 +186,7 @@ func (r *RetriedProvisioner) Prepare(raws ...interface{}) error { return r.Provisioner.Prepare(raws...) } -func (r *RetriedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData map[string]interface{}) error { +func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { if ctx.Err() != nil { // context was cancelled return ctx.Err() } @@ -230,7 +231,7 @@ func (p *DebuggedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *DebuggedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *DebuggedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { // Use a select to determine if we get cancelled during the wait message := "Pausing before the next provisioner . Press enter to continue." diff --git a/packer/provisioner_mock.go b/packer/provisioner_mock.go index 9b17228e3..1353c0d49 100644 --- a/packer/provisioner_mock.go +++ b/packer/provisioner_mock.go @@ -4,6 +4,7 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MockProvisioner is an implementation of Provisioner that can be @@ -16,7 +17,7 @@ type MockProvisioner struct { ProvCalled bool ProvRetried bool ProvCommunicator Communicator - ProvUi Ui + ProvUi packersdk.Ui } func (tp *MockProvisioner) ConfigSpec() hcldec.ObjectSpec { return tp.FlatMapstructure().HCL2Spec() } @@ -29,7 +30,7 @@ func (t *MockProvisioner) Prepare(configs ...interface{}) error { return nil } -func (t *MockProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData map[string]interface{}) error { +func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { if t.ProvCalled { t.ProvRetried = true return nil diff --git a/packer/provisioner_timeout.go b/packer/provisioner_timeout.go index a3104815c..14050a52d 100644 --- a/packer/provisioner_timeout.go +++ b/packer/provisioner_timeout.go @@ -4,6 +4,8 @@ import ( "context" "fmt" "time" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // TimeoutProvisioner is a Provisioner implementation that can timeout after a @@ -13,7 +15,7 @@ type TimeoutProvisioner struct { Timeout time.Duration } -func (p *TimeoutProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *TimeoutProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { ctx, cancel := context.WithTimeout(ctx, p.Timeout) defer cancel() diff --git a/packer/rpc/build.go b/packer/rpc/build.go index 02ac0f86d..58fa0e3d7 100644 --- a/packer/rpc/build.go +++ b/packer/rpc/build.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // An implementation of packer.Build where the build is actually executed @@ -46,7 +47,7 @@ func (b *build) Prepare() ([]string, error) { return resp.Warnings, err } -func (b *build) Run(ctx context.Context, ui packer.Ui) ([]packer.Artifact, error) { +func (b *build) Run(ctx context.Context, ui packersdk.Ui) ([]packer.Artifact, error) { nextId := b.mux.NextId() server := newServerWithMux(b.mux, nextId) server.RegisterUi(ui) diff --git a/packer/rpc/build_test.go b/packer/rpc/build_test.go index 9656c6227..ea4d4b22d 100644 --- a/packer/rpc/build_test.go +++ b/packer/rpc/build_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var testBuildArtifact = &packer.MockArtifact{} @@ -17,7 +18,7 @@ type testBuild struct { prepareWarnings []string runFn func(context.Context) runCalled bool - runUi packer.Ui + runUi packersdk.Ui setDebugCalled bool setForceCalled bool setOnErrorCalled bool @@ -35,7 +36,7 @@ func (b *testBuild) Prepare() ([]string, error) { return b.prepareWarnings, nil } -func (b *testBuild) Run(ctx context.Context, ui packer.Ui) ([]packer.Artifact, error) { +func (b *testBuild) Run(ctx context.Context, ui packersdk.Ui) ([]packer.Artifact, error) { b.runCalled = true b.runUi = ui diff --git a/packer/rpc/builder.go b/packer/rpc/builder.go index ae8b80a5c..4e321dee0 100644 --- a/packer/rpc/builder.go +++ b/packer/rpc/builder.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // An implementation of packer.Builder where the builder is actually executed @@ -51,7 +52,7 @@ func (b *builder) Prepare(config ...interface{}) ([]string, []string, error) { return resp.GeneratedVars, resp.Warnings, err } -func (b *builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { nextId := b.mux.NextId() server := newServerWithMux(b.mux, nextId) server.RegisterHook(hook) diff --git a/packer/rpc/client.go b/packer/rpc/client.go index a23437a72..ea2919c4b 100644 --- a/packer/rpc/client.go +++ b/packer/rpc/client.go @@ -6,6 +6,7 @@ import ( "net/rpc" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ugorji/go/codec" ) @@ -138,7 +139,7 @@ func (c *Client) Provisioner() packer.Provisioner { } } -func (c *Client) Ui() packer.Ui { +func (c *Client) Ui() packersdk.Ui { return &Ui{ commonClient: commonClient{ endpoint: DefaultUiEndpoint, diff --git a/packer/rpc/hook.go b/packer/rpc/hook.go index 12334b1d3..55de54a91 100644 --- a/packer/rpc/hook.go +++ b/packer/rpc/hook.go @@ -6,6 +6,7 @@ import ( "sync" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // An implementation of packer.Hook where the hook is actually executed @@ -31,7 +32,7 @@ type HookRunArgs struct { StreamId uint32 } -func (h *hook) Run(ctx context.Context, name string, ui packer.Ui, comm packer.Communicator, data interface{}) error { +func (h *hook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packer.Communicator, data interface{}) error { nextId := h.mux.NextId() server := newServerWithMux(h.mux, nextId) server.RegisterCommunicator(comm) diff --git a/packer/rpc/post_processor.go b/packer/rpc/post_processor.go index 00d492a0a..9a5037796 100644 --- a/packer/rpc/post_processor.go +++ b/packer/rpc/post_processor.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // An implementation of packer.PostProcessor where the PostProcessor is actually @@ -43,7 +44,7 @@ func (p *postProcessor) Configure(raw ...interface{}) error { return p.client.Call(p.endpoint+".Configure", args, new(interface{})) } -func (p *postProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *postProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { nextId := p.mux.NextId() server := newServerWithMux(p.mux, nextId) server.RegisterArtifact(a) diff --git a/packer/rpc/post_processor_test.go b/packer/rpc/post_processor_test.go index e6f7235a1..d4b5a01f2 100644 --- a/packer/rpc/post_processor_test.go +++ b/packer/rpc/post_processor_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var testPostProcessorArtifact = new(packer.MockArtifact) @@ -17,7 +18,7 @@ type TestPostProcessor struct { ppCalled bool ppArtifact packer.Artifact ppArtifactId string - ppUi packer.Ui + ppUi packersdk.Ui postProcessFn func(context.Context) error } @@ -30,7 +31,7 @@ func (pp *TestPostProcessor) Configure(v ...interface{}) error { return nil } -func (pp *TestPostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (pp *TestPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { pp.ppCalled = true pp.ppArtifact = a pp.ppArtifactId = a.Id() diff --git a/packer/rpc/provisioner.go b/packer/rpc/provisioner.go index 2d826e0a8..f1de8e0fc 100644 --- a/packer/rpc/provisioner.go +++ b/packer/rpc/provisioner.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // An implementation of packer.Provisioner where the provisioner is actually @@ -41,7 +42,7 @@ type ProvisionerProvisionArgs struct { StreamID uint32 } -func (p *provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { nextId := p.mux.NextId() server := newServerWithMux(p.mux, nextId) server.RegisterCommunicator(comm) diff --git a/packer/rpc/server.go b/packer/rpc/server.go index acfea8c7c..5dea62ce6 100644 --- a/packer/rpc/server.go +++ b/packer/rpc/server.go @@ -6,6 +6,7 @@ import ( "net/rpc" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ugorji/go/codec" ) @@ -122,7 +123,7 @@ func (s *Server) RegisterProvisioner(p packer.Provisioner) error { }) } -func (s *Server) RegisterUi(ui packer.Ui) error { +func (s *Server) RegisterUi(ui packersdk.Ui) error { return s.server.RegisterName(DefaultUiEndpoint, &UiServer{ ui: ui, register: s.server.RegisterName, diff --git a/packer/rpc/ui.go b/packer/rpc/ui.go index adcee28b5..6fd9de2ee 100644 --- a/packer/rpc/ui.go +++ b/packer/rpc/ui.go @@ -3,22 +3,22 @@ package rpc import ( "log" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.Ui where the Ui is actually executed +// An implementation of packersdk.Ui where the Ui is actually executed // over an RPC connection. type Ui struct { commonClient endpoint string } -var _ packer.Ui = new(Ui) +var _ packersdk.Ui = new(Ui) -// UiServer wraps a packer.Ui implementation and makes it exportable +// UiServer wraps a packersdk.Ui implementation and makes it exportable // as part of a Golang RPC server. type UiServer struct { - ui packer.Ui + ui packersdk.Ui register func(name string, rcvr interface{}) error } diff --git a/packer/run_interfaces.go b/packer/run_interfaces.go index 7e428fbe7..dc869932c 100644 --- a/packer/run_interfaces.go +++ b/packer/run_interfaces.go @@ -1,6 +1,9 @@ package packer -import "github.com/hashicorp/hcl/v2" +import ( + "github.com/hashicorp/hcl/v2" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" +) type GetBuildsOptions struct { // Get builds except the ones that match with except and with only the ones @@ -56,7 +59,7 @@ type ConfigFixer interface { } type InspectConfigOptions struct { - Ui + packersdk.Ui } type ConfigInspector interface { diff --git a/packer/testing.go b/packer/testing.go index 4df1b5de7..bf5e81a82 100644 --- a/packer/testing.go +++ b/packer/testing.go @@ -4,6 +4,8 @@ import ( "bytes" "io/ioutil" "testing" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCoreConfig(t *testing.T) *CoreConfig { @@ -29,7 +31,7 @@ func TestCore(t *testing.T, c *CoreConfig) *Core { return core } -func TestUi(t *testing.T) Ui { +func TestUi(t *testing.T) packersdk.Ui { var buf bytes.Buffer return &BasicUi{ Reader: &buf, diff --git a/packer/ui.go b/packer/ui.go index 46bfbf235..820992d57 100644 --- a/packer/ui.go +++ b/packer/ui.go @@ -16,6 +16,7 @@ import ( "unicode" getter "github.com/hashicorp/go-getter/v2" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) var ErrInterrupted = errors.New("interrupted") @@ -31,24 +32,11 @@ const ( UiColorCyan = 36 ) -// The Ui interface handles all communication for Packer with the outside -// world. This sort of control allows us to strictly control how output -// is formatted and various levels of output. -type Ui interface { - Ask(string) (string, error) - Say(string) - Message(string) - Error(string) - Machine(string, ...string) - // TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) - getter.ProgressTracker -} - type NoopUi struct { PB NoopProgressTracker } -var _ Ui = new(NoopUi) +var _ packersdk.Ui = new(NoopUi) func (*NoopUi) Ask(string) (string, error) { return "", errors.New("this is a noop ui") } func (*NoopUi) Say(string) { return } @@ -63,11 +51,11 @@ func (u *NoopUi) TrackProgress(src string, currentSize, totalSize int64, stream type ColoredUi struct { Color UiColor ErrorColor UiColor - Ui Ui + Ui packersdk.Ui PB getter.ProgressTracker } -var _ Ui = new(ColoredUi) +var _ packersdk.Ui = new(ColoredUi) func (u *ColoredUi) Ask(query string) (string, error) { return u.Ui.Ask(u.colorize(query, u.Color, true)) @@ -138,10 +126,10 @@ func (u *ColoredUi) supportsColors() bool { // with Say output. Machine-readable output has the proper target set. type TargetedUI struct { Target string - Ui Ui + Ui packersdk.Ui } -var _ Ui = new(TargetedUI) +var _ packersdk.Ui = new(TargetedUI) func (u *TargetedUI) Ask(query string) (string, error) { return u.Ui.Ask(u.prefixLines(true, query)) @@ -196,7 +184,7 @@ type BasicUi struct { PB getter.ProgressTracker } -var _ Ui = new(BasicUi) +var _ packersdk.Ui = new(BasicUi) func (rw *BasicUi) Ask(query string) (string, error) { rw.l.Lock() @@ -319,7 +307,7 @@ type MachineReadableUi struct { PB NoopProgressTracker } -var _ Ui = new(MachineReadableUi) +var _ packersdk.Ui = new(MachineReadableUi) func (u *MachineReadableUi) Ask(query string) (string, error) { return "", errors.New("machine-readable UI can't ask") @@ -381,11 +369,11 @@ func (u *MachineReadableUi) TrackProgress(src string, currentSize, totalSize int // TimestampedUi is a UI that wraps another UI implementation and // prefixes each message with an RFC3339 timestamp type TimestampedUi struct { - Ui Ui + Ui packersdk.Ui PB getter.ProgressTracker } -var _ Ui = new(TimestampedUi) +var _ packersdk.Ui = new(TimestampedUi) func (u *TimestampedUi) Ask(query string) (string, error) { return u.Ui.Ask(query) @@ -419,11 +407,11 @@ func (u *TimestampedUi) timestampLine(string string) string { // provides concurrency-safe access type SafeUi struct { Sem chan int - Ui Ui + Ui packersdk.Ui PB getter.ProgressTracker } -var _ Ui = new(SafeUi) +var _ packersdk.Ui = new(SafeUi) func (u *SafeUi) Ask(s string) (string, error) { u.Sem <- 1 diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index f965ad77b..c838191b3 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" packerecs "github.com/hashicorp/packer/builder/alicloud/ecs" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -164,7 +165,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index df4062c6a..5d866fab4 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -18,6 +18,7 @@ import ( awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -130,7 +131,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/artifice/post-processor.go b/post-processor/artifice/post-processor.go index 104d144fe..ee4d7737d 100644 --- a/post-processor/artifice/post-processor.go +++ b/post-processor/artifice/post-processor.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -55,7 +56,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { if len(artifact.Files()) > 0 { ui.Say(fmt.Sprintf("Discarding files from artifact: %s", strings.Join(artifact.Files(), ", "))) } diff --git a/post-processor/checksum/post-processor.go b/post-processor/checksum/post-processor.go index 5d0a9c2b5..df0fea928 100644 --- a/post-processor/checksum/post-processor.go +++ b/post-processor/checksum/post-processor.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -95,7 +96,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { files := artifact.Files() var h hash.Hash diff --git a/post-processor/checksum/post-processor_test.go b/post-processor/checksum/post-processor_test.go index ce527ab23..2c41b5ac9 100644 --- a/post-processor/checksum/post-processor_test.go +++ b/post-processor/checksum/post-processor_test.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" ) @@ -44,7 +45,7 @@ func TestChecksumSHA1(t *testing.T) { // Test Helpers -func setup(t *testing.T) (packer.Ui, packer.Artifact, error) { +func setup(t *testing.T) (packersdk.Ui, packer.Artifact, error) { // Create fake UI and Cache ui := packer.TestUi(t) diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index 0864a5dff..a0ffa700b 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/klauspost/pgzip" @@ -107,7 +108,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { func (p *PostProcessor) PostProcess( ctx context.Context, - ui packer.Ui, + ui packersdk.Ui, artifact packer.Artifact, ) (packer.Artifact, bool, bool, error) { var generatedData map[interface{}]interface{} diff --git a/post-processor/compress/post-processor_test.go b/post-processor/compress/post-processor_test.go index 1e1a7b8a4..15fa64f11 100644 --- a/post-processor/compress/post-processor_test.go +++ b/post-processor/compress/post-processor_test.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" ) @@ -184,7 +185,7 @@ func TestCompressInterpolation(t *testing.T) { // Test Helpers -func setup(t *testing.T) (packer.Ui, packer.Artifact, error) { +func setup(t *testing.T) (packersdk.Ui, packer.Artifact, error) { // Create fake UI and Cache ui := packer.TestUi(t) diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index fe652ecf1..9f7898829 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -23,6 +23,7 @@ import ( "github.com/hashicorp/packer/builder/digitalocean" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -148,7 +149,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/docker-import/post-processor.go b/post-processor/docker-import/post-processor.go index 7cde7c926..cfce7a6a8 100644 --- a/post-processor/docker-import/post-processor.go +++ b/post-processor/docker-import/post-processor.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/post-processor/artifice" @@ -50,7 +51,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { switch artifact.BuilderId() { case docker.BuilderId, artifice.BuilderId: break diff --git a/post-processor/docker-push/post-processor.go b/post-processor/docker-push/post-processor.go index facce79b5..723320752 100644 --- a/post-processor/docker-push/post-processor.go +++ b/post-processor/docker-push/post-processor.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" @@ -58,7 +59,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { if artifact.BuilderId() != dockerimport.BuilderId && artifact.BuilderId() != dockertag.BuilderId { err := fmt.Errorf( diff --git a/post-processor/docker-save/post-processor.go b/post-processor/docker-save/post-processor.go index bfa44d065..a15c7221e 100644 --- a/post-processor/docker-save/post-processor.go +++ b/post-processor/docker-save/post-processor.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" @@ -52,7 +53,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { if artifact.BuilderId() != dockerimport.BuilderId && artifact.BuilderId() != dockertag.BuilderId { err := fmt.Errorf( diff --git a/post-processor/docker-tag/post-processor.go b/post-processor/docker-tag/post-processor.go index 254e63859..21c8de182 100644 --- a/post-processor/docker-tag/post-processor.go +++ b/post-processor/docker-tag/post-processor.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" @@ -60,7 +61,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { if len(p.config.Tag) > 0 { ui.Say("Deprecation warning: \"tag\" option has been replaced with " + "\"tags\". In future versions of Packer, this configuration may " + diff --git a/post-processor/exoscale-import/post-processor.go b/post-processor/exoscale-import/post-processor.go index 685ef903f..12ff896d4 100644 --- a/post-processor/exoscale-import/post-processor.go +++ b/post-processor/exoscale-import/post-processor.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/packer/builder/qemu" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/post-processor/artifice" "github.com/hashicorp/packer/post-processor/exoscale-import/version" @@ -105,7 +106,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { switch a.BuilderId() { case qemu.BuilderId, file.BuilderId, artifice.BuilderId: break @@ -139,7 +140,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer. return &Artifact{id}, false, false, nil } -func (p *PostProcessor) uploadImage(ctx context.Context, ui packer.Ui, a packer.Artifact) (string, string, error) { +func (p *PostProcessor) uploadImage(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (string, string, error) { var ( imageFile = a.Files()[0] bucketFile = filepath.Base(imageFile) @@ -188,7 +189,7 @@ func (p *PostProcessor) uploadImage(ctx context.Context, ui packer.Ui, a packer. return output.Location, fmt.Sprintf("%x", hash.Sum(nil)), nil } -func (p *PostProcessor) deleteImage(ctx context.Context, ui packer.Ui, a packer.Artifact) error { +func (p *PostProcessor) deleteImage(ctx context.Context, ui packersdk.Ui, a packer.Artifact) error { var ( imageFile = a.Files()[0] bucketFile = filepath.Base(imageFile) @@ -210,7 +211,7 @@ func (p *PostProcessor) deleteImage(ctx context.Context, ui packer.Ui, a packer. return nil } -func (p *PostProcessor) registerTemplate(ctx context.Context, ui packer.Ui, url, md5sum string) (string, error) { +func (p *PostProcessor) registerTemplate(ctx context.Context, ui packersdk.Ui, url, md5sum string) (string, error) { var ( passwordEnabled = !p.config.TemplateDisablePassword sshkeyEnabled = !p.config.TemplateDisableSSHKey diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index f3bcc684a..1100f2c89 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/post-processor/artifice" @@ -118,7 +119,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { switch artifact.BuilderId() { case googlecompute.BuilderId, artifice.BuilderId: break diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index 8605a6629..fedacfd85 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/packer/builder/googlecompute" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/post-processor/artifice" @@ -143,7 +144,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { generatedData := artifact.State("generated_data") if generatedData == nil { // Make sure it's not a nil map so we can assign to it later. @@ -259,7 +260,7 @@ func CreateShieldedVMStateConfig(imageGuestOsFeatures []string, imagePlatformKey return shieldedVMStateConfig, nil } -func UploadToBucket(opts option.ClientOption, ui packer.Ui, artifact packer.Artifact, bucket string, gcsObjectName string) (string, error) { +func UploadToBucket(opts option.ClientOption, ui packersdk.Ui, artifact packer.Artifact, bucket string, gcsObjectName string) (string, error) { service, err := storage.NewService(context.TODO(), opts) if err != nil { return "", err @@ -295,7 +296,7 @@ func UploadToBucket(opts option.ClientOption, ui packer.Ui, artifact packer.Arti return storageObject.SelfLink, nil } -func CreateGceImage(opts option.ClientOption, ui packer.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string, shieldedVMStateConfig *compute.InitialStateConfig) (packer.Artifact, error) { +func CreateGceImage(opts option.ClientOption, ui packersdk.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string, shieldedVMStateConfig *compute.InitialStateConfig) (packer.Artifact, error) { service, err := compute.NewService(context.TODO(), opts) if err != nil { @@ -351,7 +352,7 @@ func CreateGceImage(opts option.ClientOption, ui packer.Ui, project string, rawI return &Artifact{paths: []string{op.TargetLink}}, nil } -func DeleteFromBucket(opts option.ClientOption, ui packer.Ui, bucket string, gcsObjectName string) error { +func DeleteFromBucket(opts option.ClientOption, ui packersdk.Ui, bucket string, gcsObjectName string) error { service, err := storage.NewService(context.TODO(), opts) if err != nil { diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 26e9ac191..ce6308294 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -73,7 +74,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, source packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source packer.Artifact) (packer.Artifact, bool, bool, error) { generatedData := source.State("generated_data") if generatedData == nil { // Make sure it's not a nil map so we can assign to it later. diff --git a/post-processor/shell-local/post-processor.go b/post-processor/shell-local/post-processor.go index b7ce71673..574e97a7d 100644 --- a/post-processor/shell-local/post-processor.go +++ b/post-processor/shell-local/post-processor.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" ) @@ -40,7 +41,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return sl.Validate(&p.config) } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { generatedData := make(map[string]interface{}) artifactStateData := artifact.State("generated_data") if artifactStateData != nil { diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index 1296f326d..ccb9a8897 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -15,6 +15,7 @@ import ( ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -154,7 +155,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index 602393620..2271a2211 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -23,6 +23,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -129,7 +130,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { if _, ok := builtins[artifact.BuilderId()]; !ok { return nil, false, false, fmt.Errorf( "Unknown artifact type: this post-processor requires an input artifact from the artifice post-processor, vagrant post-processor, or vagrant builder: %s", artifact.BuilderId()) diff --git a/post-processor/vagrant-cloud/step_confirm_upload.go b/post-processor/vagrant-cloud/step_confirm_upload.go index e338fcf8f..a5463cc0a 100644 --- a/post-processor/vagrant-cloud/step_confirm_upload.go +++ b/post-processor/vagrant-cloud/step_confirm_upload.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepConfirmUpload struct { @@ -13,7 +13,7 @@ type stepConfirmUpload struct { func (s *stepConfirmUpload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) upload := state.Get("upload").(*Upload) url := upload.CallbackPath diff --git a/post-processor/vagrant-cloud/step_create_provider.go b/post-processor/vagrant-cloud/step_create_provider.go index a6cfaa02f..add13f5c0 100644 --- a/post-processor/vagrant-cloud/step_create_provider.go +++ b/post-processor/vagrant-cloud/step_create_provider.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Provider struct { @@ -21,7 +21,7 @@ type stepCreateProvider struct { func (s *stepCreateProvider) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) box := state.Get("box").(*Box) version := state.Get("version").(*Version) providerName := state.Get("providerName").(string) @@ -68,7 +68,7 @@ func (s *stepCreateProvider) Run(ctx context.Context, state multistep.StateBag) func (s *stepCreateProvider) Cleanup(state multistep.StateBag) { client := state.Get("client").(*VagrantCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) box := state.Get("box").(*Box) version := state.Get("version").(*Version) diff --git a/post-processor/vagrant-cloud/step_create_version.go b/post-processor/vagrant-cloud/step_create_version.go index 75bd3f0a4..9333dd9e2 100644 --- a/post-processor/vagrant-cloud/step_create_version.go +++ b/post-processor/vagrant-cloud/step_create_version.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Version struct { @@ -18,7 +18,7 @@ type stepCreateVersion struct { func (s *stepCreateVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) box := state.Get("box").(*Box) diff --git a/post-processor/vagrant-cloud/step_prepare_upload.go b/post-processor/vagrant-cloud/step_prepare_upload.go index 463b5afbc..85b4a9b5a 100644 --- a/post-processor/vagrant-cloud/step_prepare_upload.go +++ b/post-processor/vagrant-cloud/step_prepare_upload.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Upload struct { @@ -19,7 +19,7 @@ type stepPrepareUpload struct { func (s *stepPrepareUpload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) box := state.Get("box").(*Box) version := state.Get("version").(*Version) provider := state.Get("provider").(*Provider) diff --git a/post-processor/vagrant-cloud/step_release_version.go b/post-processor/vagrant-cloud/step_release_version.go index d8e41a05a..d66a9e38e 100644 --- a/post-processor/vagrant-cloud/step_release_version.go +++ b/post-processor/vagrant-cloud/step_release_version.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepReleaseVersion struct { @@ -14,7 +14,7 @@ type stepReleaseVersion struct { func (s *stepReleaseVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) box := state.Get("box").(*Box) version := state.Get("version").(*Version) config := state.Get("config").(*Config) diff --git a/post-processor/vagrant-cloud/step_upload.go b/post-processor/vagrant-cloud/step_upload.go index 669011520..18c90b6ca 100644 --- a/post-processor/vagrant-cloud/step_upload.go +++ b/post-processor/vagrant-cloud/step_upload.go @@ -7,8 +7,8 @@ import ( "net/http" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" ) @@ -18,7 +18,7 @@ type stepUpload struct { func (s *stepUpload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) config := state.Get("config").(*Config) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) upload := state.Get("upload").(*Upload) artifactFilePath := state.Get("artifactFilePath").(string) url := upload.UploadPath diff --git a/post-processor/vagrant-cloud/step_verify_box.go b/post-processor/vagrant-cloud/step_verify_box.go index 4cf25a62e..6ad02132a 100644 --- a/post-processor/vagrant-cloud/step_verify_box.go +++ b/post-processor/vagrant-cloud/step_verify_box.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Box struct { @@ -27,7 +27,7 @@ type stepVerifyBox struct { func (s *stepVerifyBox) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) config := state.Get("config").(*Config) ui.Say(fmt.Sprintf("Verifying box is accessible: %s", config.Tag)) diff --git a/post-processor/vagrant/aws.go b/post-processor/vagrant/aws.go index be23f038d..dac7ecc06 100644 --- a/post-processor/vagrant/aws.go +++ b/post-processor/vagrant/aws.go @@ -7,6 +7,7 @@ import ( "text/template" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type AWSProvider struct{} @@ -15,7 +16,7 @@ func (p *AWSProvider) KeepInputArtifact() bool { return true } -func (p *AWSProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *AWSProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "aws"} diff --git a/post-processor/vagrant/azure.go b/post-processor/vagrant/azure.go index 031e70259..55bb016a7 100644 --- a/post-processor/vagrant/azure.go +++ b/post-processor/vagrant/azure.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type AzureProvider struct{} @@ -13,7 +14,7 @@ func (p *AzureProvider) KeepInputArtifact() bool { return true } -func (p *AzureProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *AzureProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "azure"} diff --git a/post-processor/vagrant/digitalocean.go b/post-processor/vagrant/digitalocean.go index 292b00600..28bbd7a63 100644 --- a/post-processor/vagrant/digitalocean.go +++ b/post-processor/vagrant/digitalocean.go @@ -7,6 +7,7 @@ import ( "text/template" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type digitalOceanVagrantfileTemplate struct { @@ -20,7 +21,7 @@ func (p *DigitalOceanProvider) KeepInputArtifact() bool { return true } -func (p *DigitalOceanProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *DigitalOceanProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "digital_ocean"} diff --git a/post-processor/vagrant/docker.go b/post-processor/vagrant/docker.go index 6f5aeb3dc..a4ab0b85c 100644 --- a/post-processor/vagrant/docker.go +++ b/post-processor/vagrant/docker.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type DockerProvider struct{} @@ -12,7 +13,7 @@ func (p *DockerProvider) KeepInputArtifact() bool { return false } -func (p *DockerProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *DockerProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "docker"} diff --git a/post-processor/vagrant/google.go b/post-processor/vagrant/google.go index a4d9dbf48..fb14d55b6 100644 --- a/post-processor/vagrant/google.go +++ b/post-processor/vagrant/google.go @@ -5,6 +5,7 @@ import ( "text/template" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type googleVagrantfileTemplate struct { @@ -17,7 +18,7 @@ func (p *GoogleProvider) KeepInputArtifact() bool { return true } -func (p *GoogleProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *GoogleProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "google"} diff --git a/post-processor/vagrant/hyperv.go b/post-processor/vagrant/hyperv.go index 657304963..9058aa54a 100644 --- a/post-processor/vagrant/hyperv.go +++ b/post-processor/vagrant/hyperv.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type HypervProvider struct{} @@ -15,7 +16,7 @@ func (p *HypervProvider) KeepInputArtifact() bool { return false } -func (p *HypervProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *HypervProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "hyperv"} diff --git a/post-processor/vagrant/libvirt.go b/post-processor/vagrant/libvirt.go index 5f14ba777..085935210 100644 --- a/post-processor/vagrant/libvirt.go +++ b/post-processor/vagrant/libvirt.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Lowercase a ascii letter. @@ -63,7 +64,7 @@ type LibVirtProvider struct{} func (p *LibVirtProvider) KeepInputArtifact() bool { return false } -func (p *LibVirtProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *LibVirtProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { diskName := artifact.State("diskName").(string) // Copy the disk image into the temporary directory (as box.img) diff --git a/post-processor/vagrant/lxc.go b/post-processor/vagrant/lxc.go index 771df9509..d5955df7d 100644 --- a/post-processor/vagrant/lxc.go +++ b/post-processor/vagrant/lxc.go @@ -5,6 +5,7 @@ import ( "path/filepath" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type LXCProvider struct{} @@ -13,7 +14,7 @@ func (p *LXCProvider) KeepInputArtifact() bool { return false } -func (p *LXCProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *LXCProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{ "provider": "lxc", diff --git a/post-processor/vagrant/parallels.go b/post-processor/vagrant/parallels.go index 41f9afa1a..c84bc832b 100644 --- a/post-processor/vagrant/parallels.go +++ b/post-processor/vagrant/parallels.go @@ -6,6 +6,7 @@ import ( "regexp" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // These are the extensions of files and directories that are unnecessary for the function @@ -18,7 +19,7 @@ func (p *ParallelsProvider) KeepInputArtifact() bool { return false } -func (p *ParallelsProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *ParallelsProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "parallels"} diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index 06f546523..e82925da5 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" @@ -104,7 +105,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) { +func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) { config, err := p.specificConfig(name) if err != nil { return nil, false, err @@ -204,7 +205,7 @@ func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui p return NewArtifact(name, outputPath), provider.KeepInputArtifact(), nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { name := p.config.ProviderOverride if name == "" { n, ok := builtins[artifact.BuilderId()] diff --git a/post-processor/vagrant/provider.go b/post-processor/vagrant/provider.go index e9b76d0c7..28d11bbe1 100644 --- a/post-processor/vagrant/provider.go +++ b/post-processor/vagrant/provider.go @@ -2,6 +2,7 @@ package vagrant import ( "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Provider is the interface that each provider must implement in order @@ -18,5 +19,5 @@ type Provider interface { // The Provider should return the contents for the Vagrantfile, // any metadata (including the provider type in that), and an error // if any. - Process(packer.Ui, packer.Artifact, string) (vagrantfile string, metadata map[string]interface{}, err error) + Process(packersdk.Ui, packer.Artifact, string) (vagrantfile string, metadata map[string]interface{}, err error) } diff --git a/post-processor/vagrant/scaleway.go b/post-processor/vagrant/scaleway.go index ee275cffd..9a6ec7087 100644 --- a/post-processor/vagrant/scaleway.go +++ b/post-processor/vagrant/scaleway.go @@ -7,6 +7,7 @@ import ( "text/template" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type scalewayVagrantfileTemplate struct { @@ -20,7 +21,7 @@ func (p *ScalewayProvider) KeepInputArtifact() bool { return true } -func (p *ScalewayProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *ScalewayProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "scaleway"} diff --git a/post-processor/vagrant/util.go b/post-processor/vagrant/util.go index b58e9ecfe..f1248c86f 100644 --- a/post-processor/vagrant/util.go +++ b/post-processor/vagrant/util.go @@ -11,7 +11,7 @@ import ( "path/filepath" "runtime" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" "github.com/klauspost/pgzip" ) @@ -72,7 +72,7 @@ func LinkFile(dst, src string) error { // DirToBox takes the directory and compresses it into a Vagrant-compatible // box. This function does not perform checks to verify that dir is // actually a proper box. This is an expected precondition. -func DirToBox(dst, dir string, ui packer.Ui, level int) error { +func DirToBox(dst, dir string, ui packersdk.Ui, level int) error { log.Printf("Turning dir into box: %s => %s", dir, dst) // Make the containing directory, if it does not already exist @@ -163,7 +163,7 @@ func DirToBox(dst, dir string, ui packer.Ui, level int) error { // This function is mainly used to check cases such as the host system having // a GNU tar incompatible uname that will cause the actual Vagrant box creation // to fail later -func CreateDummyBox(ui packer.Ui, level int) error { +func CreateDummyBox(ui packersdk.Ui, level int) error { ui.Say("Creating a dummy Vagrant box to ensure the host system can create one correctly") // Create a temporary dir to create dummy Vagrant box from diff --git a/post-processor/vagrant/virtualbox.go b/post-processor/vagrant/virtualbox.go index 3efda5e9f..afcbeb29c 100644 --- a/post-processor/vagrant/virtualbox.go +++ b/post-processor/vagrant/virtualbox.go @@ -12,6 +12,7 @@ import ( "regexp" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type VBoxProvider struct{} @@ -20,7 +21,7 @@ func (p *VBoxProvider) KeepInputArtifact() bool { return false } -func (p *VBoxProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *VBoxProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "virtualbox"} diff --git a/post-processor/vagrant/vmware.go b/post-processor/vagrant/vmware.go index 66d75b1ba..83db1964b 100644 --- a/post-processor/vagrant/vmware.go +++ b/post-processor/vagrant/vmware.go @@ -5,6 +5,7 @@ import ( "path/filepath" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type VMwareProvider struct{} @@ -13,7 +14,7 @@ func (p *VMwareProvider) KeepInputArtifact() bool { return false } -func (p *VMwareProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *VMwareProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "vmware_desktop"} diff --git a/post-processor/vsphere-template/post-processor.go b/post-processor/vsphere-template/post-processor.go index 2d3fc18b4..6e2661951 100644 --- a/post-processor/vsphere-template/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/post-processor/artifice" @@ -103,7 +104,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { if _, ok := builtins[artifact.BuilderId()]; !ok { return nil, false, false, fmt.Errorf("The Packer vSphere Template post-processor "+ "can only take an artifact from the VMware-iso builder, built on "+ diff --git a/post-processor/vsphere-template/step_choose_datacenter.go b/post-processor/vsphere-template/step_choose_datacenter.go index 0dd9f8b55..90ac9a86a 100644 --- a/post-processor/vsphere-template/step_choose_datacenter.go +++ b/post-processor/vsphere-template/step_choose_datacenter.go @@ -3,8 +3,8 @@ package vsphere_template import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi" "github.com/vmware/govmomi/find" ) @@ -14,7 +14,7 @@ type stepChooseDatacenter struct { } func (s *stepChooseDatacenter) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cli := state.Get("client").(*govmomi.Client) finder := find.NewFinder(cli.Client, false) diff --git a/post-processor/vsphere-template/step_create_folder.go b/post-processor/vsphere-template/step_create_folder.go index 8d16506ac..7ab7136e9 100644 --- a/post-processor/vsphere-template/step_create_folder.go +++ b/post-processor/vsphere-template/step_create_folder.go @@ -5,8 +5,8 @@ import ( "fmt" "path" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi" "github.com/vmware/govmomi/object" ) @@ -16,7 +16,7 @@ type stepCreateFolder struct { } func (s *stepCreateFolder) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cli := state.Get("client").(*govmomi.Client) dcPath := state.Get("dcPath").(string) diff --git a/post-processor/vsphere-template/step_create_snapshot.go b/post-processor/vsphere-template/step_create_snapshot.go index 6a091e841..302091e82 100644 --- a/post-processor/vsphere-template/step_create_snapshot.go +++ b/post-processor/vsphere-template/step_create_snapshot.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/post-processor/vsphere" "github.com/vmware/govmomi" ) @@ -38,7 +39,7 @@ func NewStepCreateSnapshot(artifact packer.Artifact, p *PostProcessor) *stepCrea } func (s *stepCreateSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cli := state.Get("client").(*govmomi.Client) dcPath := state.Get("dcPath").(string) diff --git a/post-processor/vsphere-template/step_mark_as_template.go b/post-processor/vsphere-template/step_mark_as_template.go index e4af31f83..87df4b008 100644 --- a/post-processor/vsphere-template/step_mark_as_template.go +++ b/post-processor/vsphere-template/step_mark_as_template.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/post-processor/vsphere" "github.com/vmware/govmomi" @@ -40,7 +41,7 @@ func NewStepMarkAsTemplate(artifact packer.Artifact, p *PostProcessor) *stepMark } func (s *stepMarkAsTemplate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) cli := state.Get("client").(*govmomi.Client) folder := state.Get("folder").(*object.Folder) dcPath := state.Get("dcPath").(string) diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index ba3645db5..ae617c66e 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" shelllocal "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -155,7 +156,7 @@ func getEncodedPassword(u *url.URL) (string, bool) { return password, false } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { source := "" for _, path := range artifact.Files() { if strings.HasSuffix(path, ".vmx") || strings.HasSuffix(path, ".ovf") || strings.HasSuffix(path, ".ova") { diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index e10deed7c..0a0cda0d7 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -127,7 +128,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { switch artifact.BuilderId() { case yandex.BuilderID, artifice.BuilderId: break diff --git a/post-processor/yandex-import/post-processor.go b/post-processor/yandex-import/post-processor.go index 8800e2381..f1c52147b 100644 --- a/post-processor/yandex-import/post-processor.go +++ b/post-processor/yandex-import/post-processor.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/builder/yandex" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/post-processor/artifice" @@ -121,7 +122,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { var imageSrc cloudImageSource var fileSource bool var err error diff --git a/post-processor/yandex-import/storage.go b/post-processor/yandex-import/storage.go index 536515ea4..2f30fa219 100644 --- a/post-processor/yandex-import/storage.go +++ b/post-processor/yandex-import/storage.go @@ -10,7 +10,7 @@ import ( "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const defaultS3Region = "ru-central1" @@ -46,7 +46,7 @@ func newYCStorageClient(storageEndpoint, accessKey, secretKey string) (*s3.S3, e } // Get path-style S3 URL and return presigned URL -func presignUrl(s3conn *s3.S3, ui packer.Ui, fullUrl string) (cloudImageSource, error) { +func presignUrl(s3conn *s3.S3, ui packersdk.Ui, fullUrl string) (cloudImageSource, error) { bucket, key, err := s3URLToBucketKey(fullUrl) if err != nil { return nil, err diff --git a/post-processor/yandex-import/utils.go b/post-processor/yandex-import/utils.go index 00b53a4a3..f6978af34 100644 --- a/post-processor/yandex-import/utils.go +++ b/post-processor/yandex-import/utils.go @@ -10,10 +10,11 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/hashicorp/packer/builder/yandex" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" ) -func uploadToBucket(s3conn *s3.S3, ui packer.Ui, artifact packer.Artifact, bucket string, objectName string) (cloudImageSource, error) { +func uploadToBucket(s3conn *s3.S3, ui packersdk.Ui, artifact packer.Artifact, bucket string, objectName string) (cloudImageSource, error) { ui.Say("Looking for qcow2 file in list of artifacts...") source := "" for _, path := range artifact.Files() { @@ -66,7 +67,7 @@ func uploadToBucket(s3conn *s3.S3, ui packer.Ui, artifact packer.Artifact, bucke }, nil } -func createYCImage(ctx context.Context, driver yandex.Driver, ui packer.Ui, folderID string, imageSrc cloudImageSource, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string) (*compute.Image, error) { +func createYCImage(ctx context.Context, driver yandex.Driver, ui packersdk.Ui, folderID string, imageSrc cloudImageSource, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string) (*compute.Image, error) { req := &compute.CreateImageRequest{ FolderId: folderID, Name: imageName, @@ -122,7 +123,7 @@ func createYCImage(ctx context.Context, driver yandex.Driver, ui packer.Ui, fold } -func deleteFromBucket(s3conn *s3.S3, ui packer.Ui, imageSrc cloudImageSource) error { +func deleteFromBucket(s3conn *s3.S3, ui packersdk.Ui, imageSrc cloudImageSource) error { var url string // switch on cloudImageSource type: cloud image id or storage URL switch v := imageSrc.(type) { diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index 96f9cf0be..e98889833 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" @@ -193,7 +194,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Ansible...") p.generatedData = generatedData @@ -317,7 +318,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) provisionPlaybookFiles(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packer.Communicator) error { var playbookDir string if p.config.PlaybookDir != "" { var err error @@ -338,7 +339,7 @@ func (p *Provisioner) provisionPlaybookFiles(ui packer.Ui, comm packer.Communica return nil } -func (p *Provisioner) provisionPlaybookFile(ui packer.Ui, comm packer.Communicator, playbookFile string) error { +func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packer.Communicator, playbookFile string) error { ui.Message(fmt.Sprintf("Uploading playbook file: %s", playbookFile)) remoteDir := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Dir(playbookFile))) @@ -355,7 +356,7 @@ func (p *Provisioner) provisionPlaybookFile(ui packer.Ui, comm packer.Communicat return nil } -func (p *Provisioner) executeGalaxy(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) error { ctx := context.TODO() rolesDir := filepath.ToSlash(filepath.Join(p.config.StagingDir, "roles")) galaxyFile := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.GalaxyFile))) @@ -377,7 +378,7 @@ func (p *Provisioner) executeGalaxy(ui packer.Ui, comm packer.Communicator) erro return nil } -func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator) error { inventory := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.InventoryFile))) extraArgs := fmt.Sprintf(" --extra-vars \"packer_build_name=%s packer_builder_type=%s packer_http_addr=%s -o IdentitiesOnly=yes\" ", @@ -410,7 +411,7 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator) err } func (p *Provisioner) executeAnsiblePlaybook( - ui packer.Ui, comm packer.Communicator, playbookFile, extraArgs, inventory string, + ui packersdk.Ui, comm packer.Communicator, playbookFile, extraArgs, inventory string, ) error { ctx := context.TODO() command := fmt.Sprintf("cd %s && %s %s%s -c local -i %s", @@ -460,7 +461,7 @@ func validateFileConfig(name string, config string, req bool) error { return nil } -func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return fmt.Errorf("Error opening: %s", err) @@ -473,7 +474,7 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst, sr return nil } -func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ctx := context.TODO() cmd := &packer.RemoteCmd{ Command: fmt.Sprintf("mkdir -p '%s'", dir), @@ -490,7 +491,7 @@ func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ctx := context.TODO() cmd := &packer.RemoteCmd{ Command: fmt.Sprintf("rm -rf '%s'", dir), @@ -507,7 +508,7 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) uploadDir(ui packer.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } diff --git a/provisioner/ansible/mock_ansible.go b/provisioner/ansible/mock_ansible.go index f0d1fe69a..db1a57ba6 100644 --- a/provisioner/ansible/mock_ansible.go +++ b/provisioner/ansible/mock_ansible.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type provisionLogicTracker struct { @@ -14,7 +15,7 @@ type provisionLogicTracker struct { happyPath bool } -func (l *provisionLogicTracker) setupAdapter(ui packer.Ui, comm packer.Communicator) (string, error) { +func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packer.Communicator) (string, error) { l.setupAdapterCalled = true if l.happyPath { return "fakeKeyString", nil @@ -22,7 +23,7 @@ func (l *provisionLogicTracker) setupAdapter(ui packer.Ui, comm packer.Communica return "", fmt.Errorf("chose sadpath") } -func (l *provisionLogicTracker) executeAnsible(ui packer.Ui, comm packer.Communicator, privKeyFile string) error { +func (l *provisionLogicTracker) executeAnsible(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { l.executeAnsibleCalled = true if l.happyPath { return fmt.Errorf("Chose sadpath") diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 63de5f4df..67701f0fe 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -34,6 +34,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/adapter" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" @@ -214,8 +215,8 @@ type Provisioner struct { ansibleMajVersion uint generatedData map[string]interface{} - setupAdapterFunc func(ui packer.Ui, comm packer.Communicator) (string, error) - executeAnsibleFunc func(ui packer.Ui, comm packer.Communicator, privKeyFile string) error + setupAdapterFunc func(ui packersdk.Ui, comm packer.Communicator) (string, error) + executeAnsibleFunc func(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error } func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } @@ -361,7 +362,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) setupAdapter(ui packer.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) setupAdapter(ui packersdk.Ui, comm packer.Communicator) (string, error) { ui.Message("Setting up proxy adapter for Ansible....") k, err := newUserKey(p.config.SSHAuthorizedKeyFile) @@ -502,7 +503,7 @@ func (p *Provisioner) createInventoryFile() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Ansible...") // Interpolate env vars to check for generated values like password and port p.generatedData = generatedData @@ -627,7 +628,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) executeGalaxy(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) error { galaxyFile := filepath.ToSlash(p.config.GalaxyFile) // ansible-galaxy install -r requirements.yml @@ -676,7 +677,7 @@ func (p *Provisioner) executeGalaxy(ui packer.Ui, comm packer.Communicator) erro } // Intended to be invoked from p.executeGalaxy depending on the Ansible Galaxy parameters passed to Packer -func (p *Provisioner) invokeGalaxyCommand(args []string, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) invokeGalaxyCommand(args []string, ui packersdk.Ui, comm packer.Communicator) error { ui.Message(fmt.Sprintf("Executing Ansible Galaxy")) cmd := exec.Command(p.config.GalaxyCommand, args...) @@ -781,7 +782,7 @@ func (p *Provisioner) createCmdArgs(httpAddr, inventory, playbook, privKeyFile s return args, envVars } -func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, privKeyFile string) error { +func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { playbook, _ := filepath.Abs(p.config.PlaybookFile) inventory := p.config.InventoryFile httpAddr := p.generatedData["PackerHTTPAddr"].(string) diff --git a/provisioner/azure-dtlartifact/provisioner.go b/provisioner/azure-dtlartifact/provisioner.go index 68e83ed79..612e24b01 100644 --- a/provisioner/azure-dtlartifact/provisioner.go +++ b/provisioner/azure-dtlartifact/provisioner.go @@ -13,6 +13,7 @@ import ( dtlBuilder "github.com/hashicorp/packer/builder/azure/dtl" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -96,7 +97,7 @@ func (p *Provisioner) Communicator() packer.Communicator { return p.communicator } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { p.communicator = comm diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index b1fb64611..a31f68e27 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -46,7 +47,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { if p.config.Disable { if p.config.Note != "" { ui.Say(fmt.Sprintf( diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index feef39f9e..13e2b2db6 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -240,7 +241,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { p.generatedData = generatedData p.communicator = comm @@ -348,7 +349,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, remotePath string, localPath string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, remotePath string, localPath string) error { ui.Message(fmt.Sprintf("Uploading %s...", localPath)) f, err := os.Open(localPath) @@ -361,7 +362,7 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, remoteP } func (p *Provisioner) createConfig( - ui packer.Ui, + ui packersdk.Ui, comm packer.Communicator, nodeName string, serverUrl string, @@ -423,7 +424,7 @@ func (p *Provisioner) createConfig( return remotePath, nil } -func (p *Provisioner) createKnifeConfig(ui packer.Ui, comm packer.Communicator, nodeName string, serverUrl string, clientKey string, sslVerifyMode string, trustedCertsDir string) (string, error) { +func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packer.Communicator, nodeName string, serverUrl string, clientKey string, sslVerifyMode string, trustedCertsDir string) (string, error) { ui.Message("Creating configuration file 'knife.rb'") // Read the template @@ -450,7 +451,7 @@ func (p *Provisioner) createKnifeConfig(ui packer.Ui, comm packer.Communicator, return remotePath, nil } -func (p *Provisioner) createJson(ui packer.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (string, error) { ui.Message("Creating JSON attribute file") jsonData := make(map[string]interface{}) @@ -479,7 +480,7 @@ func (p *Provisioner) createJson(ui packer.Ui, comm packer.Communicator) (string return remotePath, nil } -func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Creating directory: %s", dir)) @@ -503,7 +504,7 @@ func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) cleanNode(ui packer.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { +func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { ui.Say("Cleaning up chef node...") args := []string{"node", "delete", node} if err := p.knifeExec(ui, comm, node, knifeConfigPath, args); err != nil { @@ -513,7 +514,7 @@ func (p *Provisioner) cleanNode(ui packer.Ui, comm packer.Communicator, node str return nil } -func (p *Provisioner) cleanClient(ui packer.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { +func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { ui.Say("Cleaning up chef client...") args := []string{"client", "delete", node} if err := p.knifeExec(ui, comm, node, knifeConfigPath, args); err != nil { @@ -523,7 +524,7 @@ func (p *Provisioner) cleanClient(ui packer.Ui, comm packer.Communicator, node s return nil } -func (p *Provisioner) knifeExec(ui packer.Ui, comm packer.Communicator, node string, knifeConfigPath string, args []string) error { +func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string, args []string) error { flags := []string{ "-y", "-c", knifeConfigPath, @@ -555,7 +556,7 @@ func (p *Provisioner) knifeExec(ui packer.Ui, comm packer.Communicator, node str return nil } -func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ui.Message(fmt.Sprintf("Removing directory: %s", dir)) ctx := context.TODO() @@ -567,7 +568,7 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) executeChef(ui packer.Ui, comm packer.Communicator, config string, json string) error { +func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, config string, json string) error { p.config.ctx.Data = &ExecuteTemplate{ ConfigPath: config, JsonPath: json, @@ -604,7 +605,7 @@ func (p *Provisioner) executeChef(ui packer.Ui, comm packer.Communicator, config return nil } -func (p *Provisioner) installChef(ui packer.Ui, comm packer.Communicator, version string) error { +func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, version string) error { ui.Message("Installing Chef...") ctx := context.TODO() diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 07bf75432..61b4f3695 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -242,7 +243,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { ui.Say("Provisioning with chef-solo") if !p.config.SkipInstall { @@ -314,7 +315,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -328,7 +329,7 @@ func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, ds return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { f, err := os.Open(src) if err != nil { return err @@ -338,7 +339,7 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst str return comm.Upload(dst, f, nil) } -func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string, chefLicense string) (string, error) { +func (p *Provisioner) createConfig(ui packersdk.Ui, comm packer.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string, chefLicense string) (string, error) { ui.Message("Creating configuration file 'solo.rb'") cookbook_paths := make([]string, len(p.config.RemoteCookbookPaths)+len(localCookbooks)) @@ -394,7 +395,7 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local return remotePath, nil } -func (p *Provisioner) createJson(ui packer.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (string, error) { ui.Message("Creating JSON attribute file") jsonData := make(map[string]interface{}) @@ -423,7 +424,7 @@ func (p *Provisioner) createJson(ui packer.Ui, comm packer.Communicator) (string return remotePath, nil } -func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) ctx := context.TODO() @@ -447,7 +448,7 @@ func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) executeChef(ui packer.Ui, comm packer.Communicator, config string, json string) error { +func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, config string, json string) error { p.config.ctx.Data = &ExecuteTemplate{ ConfigPath: config, JsonPath: json, @@ -475,7 +476,7 @@ func (p *Provisioner) executeChef(ui packer.Ui, comm packer.Communicator, config return nil } -func (p *Provisioner) installChef(ui packer.Ui, comm packer.Communicator, version string) error { +func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, version string) error { ui.Message("Installing Chef...") ctx := context.TODO() diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index a34323cdf..d179cb1bb 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -111,7 +112,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } // Provision node somehow. TODO: actual docs -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { ui.Say("Provisioning with Converge") // bootstrapping @@ -132,7 +133,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) maybeBootstrap(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) error { ctx := context.TODO() if !p.config.Bootstrap { return nil @@ -174,7 +175,7 @@ func (p *Provisioner) maybeBootstrap(ui packer.Ui, comm packer.Communicator) err return nil } -func (p *Provisioner) sendModuleDirectories(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packer.Communicator) error { for _, dir := range p.config.ModuleDirs { if err := comm.UploadDir(dir.Destination, dir.Source, dir.Exclude); err != nil { return fmt.Errorf("Could not upload %q: %s", dir.Source, err) @@ -185,7 +186,7 @@ func (p *Provisioner) sendModuleDirectories(ui packer.Ui, comm packer.Communicat return nil } -func (p *Provisioner) applyModules(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) applyModules(ui packersdk.Ui, comm packer.Communicator) error { ctx := context.TODO() // create params JSON file params, err := json.Marshal(p.config.Params) diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index abf6e0ad4..60a267291 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -119,7 +120,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { if generatedData == nil { generatedData = make(map[string]interface{}) } @@ -132,7 +133,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C } } -func (p *Provisioner) ProvisionDownload(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packer.Communicator) error { dst, err := interpolate.Render(p.config.Destination, &p.config.ctx) if err != nil { return fmt.Errorf("Error interpolating destination: %s", err) @@ -181,7 +182,7 @@ func (p *Provisioner) ProvisionDownload(ui packer.Ui, comm packer.Communicator) return nil } -func (p *Provisioner) ProvisionUpload(ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) ProvisionUpload(ui packersdk.Ui, comm packer.Communicator) error { dst, err := interpolate.Render(p.config.Destination, &p.config.ctx) if err != nil { return fmt.Errorf("Error interpolating destination: %s", err) diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index fdf13cc5a..3bf669088 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -31,6 +31,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/adapter" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -190,7 +191,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Inspec...") p.config.ctx.Data = generatedData @@ -341,7 +342,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) executeInspec(ui packer.Ui, comm packer.Communicator, privKeyFile string) error { +func (p *Provisioner) executeInspec(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { var envvars []string args := []string{p.config.SubCommand, p.config.Profile} diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 2f44644e1..368a6ec6d 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/shell" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -257,7 +258,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say(fmt.Sprintf("Provisioning with Powershell...")) p.communicator = comm p.generatedData = generatedData diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index a851aa7e2..c982915b4 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -257,7 +258,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Puppet...") p.communicator = comm p.generatedData = generatedData @@ -366,7 +367,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) uploadHieraConfig(ui packer.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packer.Communicator) (string, error) { ui.Message("Uploading hiera configuration...") f, err := os.Open(p.config.HieraConfigPath) if err != nil { @@ -382,7 +383,7 @@ func (p *Provisioner) uploadHieraConfig(ui packer.Ui, comm packer.Communicator) return path, nil } -func (p *Provisioner) uploadManifests(ui packer.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packer.Communicator) (string, error) { // Create the remote manifests directory... ui.Message("Uploading manifests...") remoteManifestsPath := fmt.Sprintf("%s/manifests", p.config.StagingDir) @@ -428,7 +429,7 @@ func (p *Provisioner) uploadManifests(ui packer.Ui, comm packer.Communicator) (s return remoteManifestFile, nil } -func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} @@ -454,7 +455,7 @@ func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ctx := context.TODO() cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} @@ -469,7 +470,7 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index e652e3c5b..923a7e62d 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -227,7 +228,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Puppet...") p.communicator = comm p.generatedData = generatedData @@ -319,7 +320,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } -func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) ctx := context.TODO() @@ -343,7 +344,7 @@ func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ctx := context.TODO() cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} @@ -358,7 +359,7 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index fbf67db0e..b1631de4b 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -239,7 +240,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { var err error var src, dst string var formulas []string @@ -514,7 +515,7 @@ func hasValidFormulaURLs(s []string) bool { return true } -func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return fmt.Errorf("Error opening: %s", err) @@ -535,7 +536,7 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst, sr return nil } -func (p *Provisioner) moveFile(ui packer.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) moveFile(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Moving %s to %s", src, dst)) @@ -552,7 +553,7 @@ func (p *Provisioner) moveFile(ui packer.Ui, comm packer.Communicator, dst strin return nil } -func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) cmd := &packer.RemoteCmd{ Command: p.guestCommands.CreateDir(dir), @@ -567,7 +568,7 @@ func (p *Provisioner) createDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) statPath(ui packer.Ui, comm packer.Communicator, path string) error { +func (p *Provisioner) statPath(ui packersdk.Ui, comm packer.Communicator, path string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Verifying Path: %s", path)) cmd := &packer.RemoteCmd{ @@ -582,7 +583,7 @@ func (p *Provisioner) statPath(ui packer.Ui, comm packer.Communicator, path stri return nil } -func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Removing directory: %s", dir)) cmd := &packer.RemoteCmd{ @@ -597,7 +598,7 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri return nil } -func (p *Provisioner) uploadDir(ui packer.Ui, comm packer.Communicator, dst, src string, ignore []string) error { +func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packer.Communicator, dst, src string, ignore []string) error { _, temp_dst := filepath.Split(dst) if err := comm.UploadDir(temp_dst, src, ignore); err != nil { return err diff --git a/provisioner/shell-local/provisioner.go b/provisioner/shell-local/provisioner.go index 566e4e344..aecf871cb 100644 --- a/provisioner/shell-local/provisioner.go +++ b/provisioner/shell-local/provisioner.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" ) @@ -28,7 +29,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, _ packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, _ packer.Communicator, generatedData map[string]interface{}) error { _, retErr := sl.Run(ctx, ui, &p.config, generatedData) return retErr diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 4d6cd376f..189eec479 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/shell" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -177,7 +178,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { if generatedData == nil { generatedData = make(map[string]interface{}) } diff --git a/provisioner/sleep/provisioner.go b/provisioner/sleep/provisioner.go index e530e4761..4e01e808e 100644 --- a/provisioner/sleep/provisioner.go +++ b/provisioner/sleep/provisioner.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -25,7 +26,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return config.Decode(&p, &config.DecodeOpts{}, raws...) } -func (p *Provisioner) Provision(ctx context.Context, _ packer.Ui, _ packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, _ packersdk.Ui, _ packer.Communicator, _ map[string]interface{}) error { select { case <-ctx.Done(): return ctx.Err() diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index a14603b63..d3c6bdd92 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -59,7 +60,7 @@ type Config struct { type Provisioner struct { config Config comm packer.Communicator - ui packer.Ui + ui packersdk.Ui cancel chan struct{} cancelLock sync.Mutex } @@ -100,7 +101,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { p.cancelLock.Lock() p.cancel = make(chan struct{}) p.cancelLock.Unlock() diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index 25db70ef2..ec0a765cf 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/shell" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -159,7 +160,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with windows-shell...") scripts := make([]string, len(p.config.Scripts)) copy(scripts, p.config.Scripts) From c70870cb83b2119cfb44bdb804a1efa0e2b5ec3c Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Nov 2020 12:07:02 -0800 Subject: [PATCH 02/10] move multierror and multierrorappend into sdk --- builder/alicloud/ecs/artifact.go | 4 +- builder/alicloud/ecs/builder.go | 8 +- builder/alicloud/ecs/step_pre_validate.go | 7 +- builder/amazon/chroot/builder.go | 32 ++--- builder/amazon/common/artifact.go | 4 +- builder/amazon/common/step_ami_region_copy.go | 5 +- builder/amazon/ebs/builder.go | 16 +-- builder/amazon/ebssurrogate/builder.go | 24 ++-- builder/amazon/ebsvolume/artifact.go | 4 +- builder/amazon/ebsvolume/builder.go | 16 +-- builder/amazon/instance/builder.go | 26 ++-- builder/azure/arm/config.go | 119 +++++++++--------- builder/azure/chroot/builder.go | 34 ++--- builder/azure/common/artifact.go | 4 +- builder/azure/common/client/config.go | 14 +-- builder/azure/common/client/config_test.go | 8 +- builder/azure/dtl/config.go | 79 ++++++------ builder/cloudstack/config.go | 36 +++--- builder/cloudstack/step_prepare_config.go | 35 +++--- builder/digitalocean/config.go | 19 +-- builder/docker/config.go | 16 +-- builder/file/config.go | 8 +- builder/googlecompute/config.go | 48 +++---- builder/googlecompute/driver_gce.go | 7 +- builder/googlecompute/step_create_instance.go | 5 +- builder/hcloud/config.go | 21 ++-- builder/hyperone/config.go | 21 ++-- builder/hyperv/iso/builder.go | 26 ++-- builder/hyperv/iso/builder_test.go | 3 +- builder/hyperv/vmcx/builder.go | 36 +++--- builder/hyperv/vmcx/builder_test.go | 3 +- builder/jdcloud/builder.go | 6 +- builder/linode/config.go | 21 ++-- builder/lxc/config.go | 6 +- builder/lxd/config.go | 6 +- builder/ncloud/config.go | 32 ++--- builder/null/config.go | 14 +-- builder/oneandone/config.go | 9 +- builder/openstack/builder.go | 8 +- builder/oracle/classic/builder.go | 4 +- builder/oracle/classic/config.go | 20 +-- builder/oracle/classic/pv_config.go | 14 +-- builder/oracle/oci/config.go | 55 ++++---- builder/osc/bsu/builder.go | 10 +- builder/osc/bsusurrogate/builder.go | 16 +-- builder/osc/bsuvolume/artifact.go | 4 +- builder/osc/bsuvolume/builder.go | 12 +- builder/osc/chroot/builder.go | 20 +-- builder/osc/common/artifact.go | 4 +- builder/parallels/iso/builder.go | 30 ++--- builder/parallels/iso/builder_test.go | 3 +- builder/parallels/pvm/config.go | 26 ++-- builder/parallels/pvm/config_test.go | 4 +- builder/profitbricks/config.go | 13 +- builder/proxmox/clone/config.go | 6 +- builder/proxmox/common/config.go | 37 +++--- builder/proxmox/common/config_test.go | 6 +- builder/proxmox/iso/config.go | 32 ++--- builder/qemu/config.go | 44 +++---- builder/qemu/config_test.go | 3 +- builder/scaleway/config.go | 17 +-- builder/tencentcloud/cvm/artifact.go | 4 +- builder/tencentcloud/cvm/builder.go | 8 +- builder/ucloud/common/artifact.go | 4 +- builder/ucloud/uhost/builder.go | 8 +- builder/ucloud/uhost/step_pre_validate.go | 17 ++- builder/vagrant/builder.go | 20 +-- builder/virtualbox/iso/builder.go | 22 ++-- builder/virtualbox/iso/builder_test.go | 3 +- builder/virtualbox/ovf/config.go | 3 +- builder/virtualbox/ovf/config_test.go | 4 +- builder/virtualbox/vm/config.go | 22 ++-- builder/vmware/iso/builder_test.go | 3 +- builder/vmware/iso/config.go | 42 +++---- builder/vmware/vmx/builder_test.go | 4 +- builder/vmware/vmx/config.go | 36 +++--- builder/vsphere/clone/config.go | 32 ++--- builder/vsphere/common/step_export.go | 11 +- .../common/step_import_to_content_library.go | 9 +- builder/vsphere/iso/config.go | 32 ++--- builder/yandex/config.go | 26 ++-- .../packer}/multi_error.go | 0 .../packer}/multi_error_test.go | 0 packer-plugin-sdk/shell-local/config.go | 18 +-- packer/build.go | 2 +- .../alicloud-import/post-processor.go | 10 +- .../amazon-import/post-processor.go | 12 +- post-processor/checksum/post-processor.go | 6 +- post-processor/compress/post-processor.go | 4 +- .../digitalocean-import/post-processor.go | 8 +- .../exoscale-import/post-processor.go | 4 +- .../googlecompute-export/post-processor.go | 6 +- .../googlecompute-import/post-processor.go | 10 +- .../ucloud-import/post-processor.go | 12 +- .../vagrant-cloud/post-processor.go | 8 +- post-processor/vagrant/post-processor.go | 4 +- .../vsphere-template/post-processor.go | 8 +- post-processor/vsphere/post-processor.go | 6 +- .../yandex-export/post-processor.go | 8 +- .../yandex-import/post-processor.go | 8 +- provisioner/ansible-local/provisioner.go | 26 ++-- provisioner/ansible/provisioner.go | 20 +-- provisioner/chef-client/provisioner.go | 16 +-- provisioner/chef-solo/provisioner.go | 20 +-- provisioner/file/provisioner.go | 10 +- provisioner/inspec/provisioner.go | 20 +-- provisioner/powershell/provisioner.go | 16 +-- provisioner/puppet-masterless/provisioner.go | 18 +-- provisioner/puppet-server/provisioner.go | 10 +- provisioner/salt-masterless/provisioner.go | 14 +-- provisioner/shell/provisioner.go | 12 +- provisioner/windows-shell/provisioner.go | 10 +- 112 files changed, 908 insertions(+), 898 deletions(-) rename {packer => packer-plugin-sdk/packer}/multi_error.go (100%) rename {packer => packer-plugin-sdk/packer}/multi_error_test.go (100%) diff --git a/builder/alicloud/ecs/artifact.go b/builder/alicloud/ecs/artifact.go index 4be42ea5b..d1127d53c 100644 --- a/builder/alicloud/ecs/artifact.go +++ b/builder/alicloud/ecs/artifact.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Artifact struct { @@ -136,7 +136,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } } diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 93a801dd2..4ee4d2806 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -68,10 +68,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.AlicloudAccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.AlicloudImageConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.AlicloudAccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AlicloudImageConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) if errs != nil && len(errs.Errors) > 0 { return nil, nil, errs diff --git a/builder/alicloud/ecs/step_pre_validate.go b/builder/alicloud/ecs/step_pre_validate.go index 6a2f6723e..be7441157 100644 --- a/builder/alicloud/ecs/step_pre_validate.go +++ b/builder/alicloud/ecs/step_pre_validate.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -38,13 +37,13 @@ func (s *stepPreValidate) validateRegions(state multistep.StateBag) error { ui.Say("Prevalidating source region and copied regions...") - var errs *packer.MultiError + var errs *packersdk.MultiError if err := config.ValidateRegion(config.AlicloudRegion); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } for _, region := range config.AlicloudImageDestinationRegions { if err := config.ValidateRegion(region); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 2ae2ad611..48cfb7351 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -261,19 +261,19 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors or warnings - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string - errs = packer.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(&b.config.RootVolumeTags)...) - errs = packer.MultiErrorAppend(errs, b.config.SourceAmiFilter.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(&b.config.RootVolumeTags)...) + errs = packersdk.MultiErrorAppend(errs, b.config.SourceAmiFilter.Prepare()...) - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) for _, mounts := range b.config.ChrootMounts { if len(mounts) != 3 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("Each chroot_mounts entry should be three elements.")) break } @@ -284,43 +284,43 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { warns = append(warns, "source_ami and source_ami_filter are unused when from_scratch is true") } if b.config.RootVolumeSize == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("root_volume_size is required with from_scratch.")) } if len(b.config.PreMountCommands) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("pre_mount_commands is required with from_scratch.")) } if b.config.AMIVirtType == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("ami_virtualization_type is required with from_scratch.")) } if b.config.RootDeviceName == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("root_device_name is required with from_scratch.")) } if len(b.config.AMIMappings) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("ami_block_device_mappings is required with from_scratch.")) } } else { if b.config.SourceAmi == "" && b.config.SourceAmiFilter.Empty() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("source_ami or source_ami_filter is required.")) } if len(b.config.AMIMappings) > 0 && b.config.RootDeviceName != "" { if b.config.RootVolumeSize == 0 { // Although, they can specify the device size in the block // device mapping, it's easier to be specific here. - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("root_volume_size is required if ami_block_device_mappings is specified")) } warns = append(warns, "ami_block_device_mappings from source image will be completely overwritten") } else if len(b.config.AMIMappings) > 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("If ami_block_device_mappings is specified, root_device_name must be specified")) } else if b.config.RootDeviceName != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("If root_device_name is specified, ami_block_device_mappings must be specified")) } } @@ -332,7 +332,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } } if !valid { - errs = packer.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`)) + errs = packersdk.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`)) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/amazon/common/artifact.go b/builder/amazon/common/artifact.go index 89f2ef8a5..6ba0e626f 100644 --- a/builder/amazon/common/artifact.go +++ b/builder/amazon/common/artifact.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Artifact is an artifact implementation that contains built AMIs. @@ -103,7 +103,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } } diff --git a/builder/amazon/common/step_ami_region_copy.go b/builder/amazon/common/step_ami_region_copy.go index 182cb9de3..9acf967ea 100644 --- a/builder/amazon/common/step_ami_region_copy.go +++ b/builder/amazon/common/step_ami_region_copy.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2/ec2iface" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -105,7 +104,7 @@ func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) m var lock sync.Mutex var wg sync.WaitGroup - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) wg.Add(len(s.Regions)) for _, region := range s.Regions { var regKeyID string @@ -129,7 +128,7 @@ func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) m amis[region] = id snapshots[region] = snapshotIds if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } }(region) } diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 3271bc93b..25efc316c 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -114,20 +114,20 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string - errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...) + errs = packersdk.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...) - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) if b.config.IsSpotInstance() && (b.config.AMIENASupport.True() || b.config.AMISriovNetSupport) { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ "you use an AMI that already has either SR-IOV or ENA enabled.")) diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index d8453421d..d9f3b6751 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -113,20 +113,20 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string - errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...) + errs = packersdk.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...) - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...) if b.config.AMIVirtType == "" { - errs = packer.MultiErrorAppend(errs, errors.New("ami_virtualization_type is required.")) + errs = packersdk.MultiErrorAppend(errs, errors.New("ami_virtualization_type is required.")) } foundRootVolume := false @@ -134,13 +134,13 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if launchDevice.DeviceName == b.config.RootDevice.SourceDeviceName { foundRootVolume = true if launchDevice.OmitFromArtifact { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("You cannot set \"omit_from_artifact\": \"true\" for the root volume.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You cannot set \"omit_from_artifact\": \"true\" for the root volume.")) } } } if !foundRootVolume { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName)) } if b.config.RunConfig.SpotPriceAutoProduct != "" { @@ -162,7 +162,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } } if !valid { - errs = packer.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`)) + errs = packersdk.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`)) } if errs != nil && len(errs.Errors) > 0 { return nil, warns, errs diff --git a/builder/amazon/ebsvolume/artifact.go b/builder/amazon/ebsvolume/artifact.go index fbf7e178d..79037867b 100644 --- a/builder/amazon/ebsvolume/artifact.go +++ b/builder/amazon/ebsvolume/artifact.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // map of region to list of volume IDs @@ -86,7 +86,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } } diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index cea518c6a..a72627a9b 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -122,26 +122,26 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string - errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...) - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...) for _, d := range b.config.VolumeMappings { if err := d.Prepare(&b.config.ctx); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("AMIMapping: %s", err.Error())) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("AMIMapping: %s", err.Error())) } } b.config.launchBlockDevices = b.config.VolumeMappings if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if b.config.IsSpotInstance() && ((b.config.AMIENASupport.True()) || b.config.AMISriovNetSupport) { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ "you use an AMI that already has either SR-IOV or ENA enabled.")) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 80f8c7c4b..a4e3c03a0 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -177,41 +177,41 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) if b.config.AccountId == "" { - errs = packer.MultiErrorAppend(errs, errors.New("account_id is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("account_id is required")) } else { b.config.AccountId = strings.Replace(b.config.AccountId, "-", "", -1) } if b.config.S3Bucket == "" { - errs = packer.MultiErrorAppend(errs, errors.New("s3_bucket is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("s3_bucket is required")) } if b.config.X509CertPath == "" { - errs = packer.MultiErrorAppend(errs, errors.New("x509_cert_path is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("x509_cert_path is required")) } else if _, err := os.Stat(b.config.X509CertPath); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("x509_cert_path points to bad file: %s", err)) } if b.config.X509KeyPath == "" { - errs = packer.MultiErrorAppend(errs, errors.New("x509_key_path is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("x509_key_path is required")) } else if _, err := os.Stat(b.config.X509KeyPath); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("x509_key_path points to bad file: %s", err)) } if b.config.IsSpotInstance() && ((b.config.AMIENASupport.True()) || b.config.AMISriovNetSupport) { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ "you use an AMI that already has either SR-IOV or ENA enabled.")) diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 9ec804fd8..ee050f9e5 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -31,6 +31,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -625,8 +626,8 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } } - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) assertRequiredParametersSet(c, errs) assertTagProperties(c, errs) @@ -795,22 +796,22 @@ func provideDefaultValues(c *Config) { c.ClientConfig.SetDefaultValues() } -func assertTagProperties(c *Config, errs *packer.MultiError) { +func assertTagProperties(c *Config, errs *packersdk.MultiError) { if len(c.AzureTags) > 15 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags))) } for k, v := range c.AzureTags { if len(k) > 512 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k))) } if len(v) > 256 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", v, len(v))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", v, len(v))) } } } -func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { +func assertRequiredParametersSet(c *Config, errs *packersdk.MultiError) { c.ClientConfig.Validate(errs) ///////////////////////////////////////////// @@ -823,13 +824,13 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { " that this value follows the full resource id format: "+ "/subscriptions//resourcegroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/.\n"+ " Original error: %s", err) - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } else { if !strings.EqualFold(r.Provider, "Microsoft.ManagedIdentity") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource provider")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource provider")) } if !strings.EqualFold(r.ResourceType.String(), "userAssignedIdentities") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource type")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource type")) } } } @@ -838,45 +839,45 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { ///////////////////////////////////////////// // Capture if c.CaptureContainerName == "" && c.ManagedImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified")) } if c.CaptureNamePrefix == "" && c.ManagedImageResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified")) } if (c.CaptureNamePrefix != "" || c.CaptureContainerName != "") && (c.ManagedImageResourceGroupName != "" || c.ManagedImageName != "") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name.")) } if c.CaptureContainerName != "" { if !reCaptureContainerName.MatchString(c.CaptureContainerName) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String())) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String())) } if strings.HasSuffix(c.CaptureContainerName, "-") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'.")) } if strings.Contains(c.CaptureContainerName, "--") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'.")) } if c.CaptureNamePrefix == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified")) } if !reCaptureNamePrefix.MatchString(c.CaptureNamePrefix) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String())) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String())) } if strings.HasSuffix(c.CaptureNamePrefix, "-") || strings.HasSuffix(c.CaptureNamePrefix, ".") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period.")) } } if c.TempResourceGroupName != "" && c.BuildResourceGroupName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The settings temp_resource_group_name and build_resource_group_name cannot both be defined. Please define one or neither.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The settings temp_resource_group_name and build_resource_group_name cannot both be defined. Please define one or neither.")) } ///////////////////////////////////////////// @@ -897,55 +898,55 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { countSourceInputs := toInt(isImageUrl) + toInt(isCustomManagedImage) + toInt(isPlatformImage) + toInt(isSharedGallery) if countSourceInputs > 1 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)")) } if isImageUrl && c.ManagedImageResourceGroupName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD.")) } if c.SharedGallery.GalleryName != "" { if c.SharedGallery.Subscription == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified")) } if c.SharedGallery.ResourceGroup == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified")) } if c.SharedGallery.ImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified")) } if c.CaptureContainerName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead.")) } if c.CaptureNamePrefix != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead.")) } } else if c.ImageUrl == "" && c.CustomManagedImageName == "" { if c.ImagePublisher == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified")) } if c.ImageOffer == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified")) } if c.ImageSku == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified")) } } else if c.ImageUrl == "" && c.ImagePublisher == "" { if c.CustomManagedImageResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_resource_group_name must be specified")) } if c.CustomManagedImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified")) } if c.ManagedImageResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed_image_resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed_image_resource_group_name must be specified")) } if c.ManagedImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed_image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed_image_name must be specified")) } } else { if c.ImagePublisher != "" || c.ImageOffer != "" || c.ImageSku != "" || c.ImageVersion != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified")) } } @@ -956,58 +957,58 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { } if !xor((c.StorageAccount != "" || c.ResourceGroupName != ""), (c.ManagedImageName != "" || c.ManagedImageResourceGroupName != "")) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (storage_account and resource_group_name) or Managed Image (managed_image_resource_group_name and managed_image_name) output")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (storage_account and resource_group_name) or Managed Image (managed_image_resource_group_name and managed_image_name) output")) } if !xor(c.Location != "", c.BuildResourceGroupName != "") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a location to create the resource group in or an existing build_resource_group_name, but not both.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a location to create the resource group in or an existing build_resource_group_name, but not both.")) } if c.ManagedImageName == "" && c.ManagedImageResourceGroupName == "" { if c.StorageAccount == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A storage_account must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A storage_account must be specified")) } if c.ResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A resource_group_name must be specified")) } } if c.TempResourceGroupName != "" { if ok, err := assertResourceGroupName(c.TempResourceGroupName, "temp_resource_group_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.BuildResourceGroupName != "" { if ok, err := assertResourceGroupName(c.BuildResourceGroupName, "build_resource_group_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.ManagedImageResourceGroupName != "" { if ok, err := assertResourceGroupName(c.ManagedImageResourceGroupName, "managed_image_resource_group_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.ManagedImageName != "" { if ok, err := assertManagedImageName(c.ManagedImageName, "managed_image_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.ManagedImageName != "" && c.ManagedImageResourceGroupName != "" && c.SharedGalleryDestination.SigDestinationGalleryName != "" { if c.SharedGalleryDestination.SigDestinationResourceGroup == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A resource_group must be specified for shared_image_gallery_destination")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A resource_group must be specified for shared_image_gallery_destination")) } if c.SharedGalleryDestination.SigDestinationImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_name must be specified for shared_image_gallery_destination")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_name must be specified for shared_image_gallery_destination")) } if c.SharedGalleryDestination.SigDestinationImageVersion == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_version must be specified for shared_image_gallery_destination")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_version must be specified for shared_image_gallery_destination")) } if len(c.SharedGalleryDestination.SigDestinationReplicationRegions) == 0 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A list of replication_regions must be specified for shared_image_gallery_destination")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A list of replication_regions must be specified for shared_image_gallery_destination")) } if c.SharedGalleryDestination.SigDestinationSubscription == "" { c.SharedGalleryDestination.SigDestinationSubscription = c.ClientConfig.SubscriptionID @@ -1020,35 +1021,35 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { if c.ManagedImageOSDiskSnapshotName != "" { if ok, err := assertManagedImageOSDiskSnapshotName(c.ManagedImageOSDiskSnapshotName, "managed_image_os_disk_snapshot_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.ManagedImageDataDiskSnapshotPrefix != "" { if ok, err := assertManagedImageDataDiskSnapshotName(c.ManagedImageDataDiskSnapshotPrefix, "managed_image_data_disk_snapshot_prefix"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.CustomResourcePrefix != "" { if ok, err := assertResourceNamePrefix(c.CustomResourcePrefix, "custom_resource_build_prefix"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.VirtualNetworkName == "" && c.VirtualNetworkResourceGroupName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_resource_group_name is specified, so must virtual_network_name")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_resource_group_name is specified, so must virtual_network_name")) } if c.VirtualNetworkName == "" && c.VirtualNetworkSubnetName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must virtual_network_name")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must virtual_network_name")) } if c.AllowedInboundIpAddresses != nil && len(c.AllowedInboundIpAddresses) >= 1 { if c.VirtualNetworkName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_name is specified, allowed_inbound_ip_addresses cannot be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_name is specified, allowed_inbound_ip_addresses cannot be specified")) } else { if ok, err := assertAllowedInboundIpAddresses(c.AllowedInboundIpAddresses, "allowed_inbound_ip_addresses"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } } @@ -1057,7 +1058,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { // Plan Info if c.PlanInfo.PlanName != "" || c.PlanInfo.PlanProduct != "" || c.PlanInfo.PlanPublisher != "" || c.PlanInfo.PlanPromotionCode != "" { if c.PlanInfo.PlanName == "" || c.PlanInfo.PlanProduct == "" || c.PlanInfo.PlanPublisher == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("if either plan_name, plan_product, plan_publisher, or plan_promotion_code are defined then plan_name, plan_product, and plan_publisher must be defined")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("if either plan_name, plan_product, plan_publisher, or plan_promotion_code are defined then plan_name, plan_product, and plan_publisher must be defined")) } else { if c.AzureTags == nil { c.AzureTags = make(map[string]string) @@ -1084,9 +1085,9 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { } else if strings.EqualFold(c.OSType, constants.Target_Windows) { c.OSType = constants.Target_Windows } else if c.OSType == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified")) } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType)) } switch c.ManagedImageStorageAccountType { @@ -1095,7 +1096,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { case string(compute.StorageAccountTypesPremiumLRS): c.managedImageStorageAccountType = compute.StorageAccountTypesPremiumLRS default: - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType)) } switch c.DiskCachingType { @@ -1106,7 +1107,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { case "", string(compute.CachingTypesReadWrite): c.diskCachingType = compute.CachingTypesReadWrite default: - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The disk_caching_type %q is invalid", c.DiskCachingType)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The disk_caching_type %q is invalid", c.DiskCachingType)) } } diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index b0d0c83e4..dc6cd4eca 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -174,7 +174,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string // Defaults @@ -222,7 +222,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { &b.config.ctx); err == nil { b.config.TemporaryOSDiskID = def } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary disk id: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary disk id: %s", err)) } } @@ -232,7 +232,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { &b.config.ctx); err == nil { b.config.TemporaryOSDiskSnapshotID = def } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary snapshot id: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary snapshot id: %s", err)) } } @@ -242,7 +242,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { &b.config.ctx); err == nil { b.config.TemporaryDataDiskIDPrefix = def } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk id prefix: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk id prefix: %s", err)) } } @@ -252,7 +252,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { &b.config.ctx); err == nil { b.config.TemporaryDataDiskSnapshotIDPrefix = def } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk snapshot id prefix: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk snapshot id prefix: %s", err)) } } @@ -280,15 +280,15 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.FromScratch { if b.config.Source != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("source cannot be specified when building from_scratch")) } if b.config.OSDiskSizeGB == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("os_disk_size_gb is required with from_scratch")) } if len(b.config.PreMountCommands) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("pre_mount_commands is required with from_scratch")) } } else { @@ -306,25 +306,25 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { log.Println("Source is a shared image ID:", b.config.Source) b.config.sourceType = sourceSharedImage } else { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("source: %q is not a valid platform image specifier, nor is it a disk resource ID", b.config.Source)) } } if err := checkDiskCacheType(b.config.OSDiskCacheType); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("os_disk_cache_type: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("os_disk_cache_type: %v", err)) } if err := checkStorageAccountType(b.config.OSDiskStorageAccountType); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("os_disk_storage_account_type: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("os_disk_storage_account_type: %v", err)) } if err := checkDiskCacheType(b.config.DataDiskCacheType); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("data_disk_cache_type: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("data_disk_cache_type: %v", err)) } if err := checkStorageAccountType(b.config.DataDiskStorageAccountType); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("data_disk_storage_account_type: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("data_disk_storage_account_type: %v", err)) } if b.config.ImageResourceID != "" { @@ -332,7 +332,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if err != nil || !strings.EqualFold(r.Provider, "Microsoft.Compute") || !strings.EqualFold(r.ResourceType, "images") { - errs = packer.MultiErrorAppend(fmt.Errorf( + errs = packersdk.MultiErrorAppend(fmt.Errorf( "image_resource_id: %q is not a valid image resource id", b.config.ImageResourceID)) } } @@ -340,7 +340,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if azcommon.StringsContains(md.Keys, "shared_image_destination") { e, w := b.config.SharedImageGalleryDestination.Validate("shared_image_destination") if len(e) > 0 { - errs = packer.MultiErrorAppend(errs, e...) + errs = packersdk.MultiErrorAppend(errs, e...) } if len(w) > 0 { warns = append(warns, w...) @@ -348,11 +348,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if !azcommon.StringsContains(md.Keys, "shared_image_destination") && b.config.ImageResourceID == "" { - errs = packer.MultiErrorAppend(errs, errors.New("image_resource_id or shared_image_destination is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("image_resource_id or shared_image_destination is required")) } if err := checkHyperVGeneration(b.config.ImageHyperVGeneration); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("image_hyperv_generation: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("image_hyperv_generation: %v", err)) } if errs != nil { diff --git a/builder/azure/common/artifact.go b/builder/azure/common/artifact.go index 5c2f4ca51..04cc3de0b 100644 --- a/builder/azure/common/artifact.go +++ b/builder/azure/common/artifact.go @@ -9,7 +9,7 @@ import ( "github.com/Azure/go-autorest/autorest/azure" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Artifact is an artifact implementation that contains built Managed Images or Disks. @@ -96,7 +96,7 @@ func (a *Artifact) Destroy() error { if len(errs) == 1 { return errs[0] } else { - return &packer.MultiError{Errors: errs} + return &packersdk.MultiError{Errors: errs} } } diff --git a/builder/azure/common/client/config.go b/builder/azure/common/client/config.go index 5ee5e6c31..264a36b14 100644 --- a/builder/azure/common/client/config.go +++ b/builder/azure/common/client/config.go @@ -11,7 +11,7 @@ import ( "github.com/Azure/go-autorest/autorest/adal" "github.com/Azure/go-autorest/autorest/azure" jwt "github.com/dgrijalva/jwt-go" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Config allows for various ways to authenticate Azure clients. @@ -120,7 +120,7 @@ func (c *Config) setCloudEnvironment() error { return err } -func (c Config) Validate(errs *packer.MultiError) { +func (c Config) Validate(errs *packersdk.MultiError) { ///////////////////////////////////////////// // Authentication via OAUTH @@ -160,7 +160,7 @@ func (c Config) Validate(errs *packer.MultiError) { // Service principal using certificate if _, err := os.Stat(c.ClientCertPath); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_cert_path is not an accessible file: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_cert_path is not an accessible file: %v", err)) } return } @@ -176,20 +176,20 @@ func (c Config) Validate(errs *packer.MultiError) { claims := jwt.StandardClaims{} token, _, err := p.ParseUnverified(c.ClientJWT, &claims) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_jwt is not a JWT: %v", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_jwt is not a JWT: %v", err)) } else { if claims.ExpiresAt < time.Now().Add(5*time.Minute).Unix() { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_jwt will expire within 5 minutes, please use a JWT that is valid for at least 5 minutes")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_jwt will expire within 5 minutes, please use a JWT that is valid for at least 5 minutes")) } if t, ok := token.Header["x5t"]; !ok || t == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_jwt is missing the x5t header value, which is required for bearer JWT client authentication to Azure")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_jwt is missing the x5t header value, which is required for bearer JWT client authentication to Azure")) } } return } - errs = packer.MultiErrorAppend(errs, fmt.Errorf("No valid set of authentication values specified:\n"+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("No valid set of authentication values specified:\n"+ " to use the Managed Identity of the current machine, do not specify any of the fields below\n"+ " to use interactive user authentication, specify only subscription_id\n"+ " to use an Azure Active Directory service principal, specify either:\n"+ diff --git a/builder/azure/common/client/config_test.go b/builder/azure/common/client/config_test.go index 8f399b886..af9a56690 100644 --- a/builder/azure/common/client/config_test.go +++ b/builder/azure/common/client/config_test.go @@ -14,7 +14,7 @@ import ( "github.com/Azure/go-autorest/autorest/azure" jwt "github.com/dgrijalva/jwt-go" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func Test_ClientConfig_RequiredParametersSet(t *testing.T) { @@ -126,7 +126,7 @@ func Test_ClientConfig_RequiredParametersSet(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - errs := &packer.MultiError{} + errs := &packersdk.MultiError{} tt.config.Validate(errs) if (len(errs.Errors) != 0) != tt.wantErr { t.Errorf("newConfig() error = %v, wantErr %v", errs, tt.wantErr) @@ -312,7 +312,7 @@ func Test_ClientConfig_CanUseDeviceCode(t *testing.T) { } func assertValid(t *testing.T, cfg Config) { - errs := &packer.MultiError{} + errs := &packersdk.MultiError{} cfg.Validate(errs) if len(errs.Errors) != 0 { t.Fatal("Expected errs to be empty: ", errs) @@ -320,7 +320,7 @@ func assertValid(t *testing.T, cfg Config) { } func assertInvalid(t *testing.T, cfg Config) { - errs := &packer.MultiError{} + errs := &packersdk.MultiError{} cfg.Validate(errs) if len(errs.Errors) == 0 { t.Fatal("Expected errs to be non-empty") diff --git a/builder/azure/dtl/config.go b/builder/azure/dtl/config.go index fdb960905..aa49c7ccb 100644 --- a/builder/azure/dtl/config.go +++ b/builder/azure/dtl/config.go @@ -27,6 +27,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -424,8 +425,8 @@ func newConfig(raws ...interface{}) (*Config, []string, error) { } } - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) c.ClientConfig.Validate(errs) @@ -542,66 +543,66 @@ func provideDefaultValues(c *Config) { } } -func assertTagProperties(c *Config, errs *packer.MultiError) { +func assertTagProperties(c *Config, errs *packersdk.MultiError) { if len(c.AzureTags) > 15 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags))) } for k, v := range c.AzureTags { if len(k) > 512 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k))) } if len(*v) > 256 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", *v, len(*v))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", *v, len(*v))) } } } -func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { +func assertRequiredParametersSet(c *Config, errs *packersdk.MultiError) { c.ClientConfig.Validate(errs) ///////////////////////////////////////////// // Capture if c.CaptureContainerName == "" && c.ManagedImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified")) } if c.CaptureNamePrefix == "" && c.ManagedImageResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified")) } if (c.CaptureNamePrefix != "" || c.CaptureContainerName != "") && (c.ManagedImageResourceGroupName != "" || c.ManagedImageName != "") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name.")) } if c.CaptureContainerName != "" { if !reCaptureContainerName.MatchString(c.CaptureContainerName) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String())) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String())) } if strings.HasSuffix(c.CaptureContainerName, "-") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'.")) } if strings.Contains(c.CaptureContainerName, "--") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'.")) } if c.CaptureNamePrefix == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified")) } if !reCaptureNamePrefix.MatchString(c.CaptureNamePrefix) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String())) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String())) } if strings.HasSuffix(c.CaptureNamePrefix, "-") || strings.HasSuffix(c.CaptureNamePrefix, ".") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period.")) } } if c.LabResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The settings lab_resource_group_name needs to be defined.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The settings lab_resource_group_name needs to be defined.")) } ///////////////////////////////////////////// @@ -622,75 +623,75 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { countSourceInputs := toInt(isImageUrl) + toInt(isCustomManagedImage) + toInt(isPlatformImage) + toInt(isSharedGallery) if countSourceInputs > 1 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)")) } if isImageUrl && c.ManagedImageResourceGroupName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD.")) } if c.SharedGallery.GalleryName != "" { if c.SharedGallery.Subscription == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified")) } if c.SharedGallery.ResourceGroup == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified")) } if c.SharedGallery.ImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified")) } if c.CaptureContainerName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead.")) } if c.CaptureNamePrefix != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead.")) } } else if c.ImageUrl == "" && c.CustomManagedImageName == "" { if c.ImagePublisher == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified")) } if c.ImageOffer == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified")) } if c.ImageSku == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified")) } } else if c.ImageUrl == "" && c.ImagePublisher == "" { if c.CustomManagedImageResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An custom_managed_image_resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An custom_managed_image_resource_group_name must be specified")) } if c.CustomManagedImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified")) } if c.ManagedImageResourceGroupName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An managed_image_resource_group_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An managed_image_resource_group_name must be specified")) } if c.ManagedImageName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An managed_image_name must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An managed_image_name must be specified")) } } else { if c.ImagePublisher != "" || c.ImageOffer != "" || c.ImageSku != "" || c.ImageVersion != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified")) } } if c.ManagedImageResourceGroupName != "" { if ok, err := assertResourceGroupName(c.ManagedImageResourceGroupName, "managed_image_resource_group_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.ManagedImageName != "" { if ok, err := assertManagedImageName(c.ManagedImageName, "managed_image_name"); !ok { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.LabVirtualNetworkName == "" && c.LabResourceGroupName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If lab_resource_group_name is specified, so must lab_virtual_network_name")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If lab_resource_group_name is specified, so must lab_virtual_network_name")) } if c.LabVirtualNetworkName == "" && c.LabSubnetName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must lab_virtual_network_name")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must lab_virtual_network_name")) } ///////////////////////////////////////////// @@ -707,9 +708,9 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { } else if strings.EqualFold(c.OSType, constants.Target_Windows) { c.OSType = constants.Target_Windows } else if c.OSType == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified")) } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType)) } switch c.ManagedImageStorageAccountType { @@ -718,7 +719,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { case string(compute.StorageAccountTypesPremiumLRS): c.managedImageStorageAccountType = compute.StorageAccountTypesPremiumLRS default: - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType)) } // Errs check to make the linter happy. if errs != nil { diff --git a/builder/cloudstack/config.go b/builder/cloudstack/config.go index 0d05c3325..503008bfb 100644 --- a/builder/cloudstack/config.go +++ b/builder/cloudstack/config.go @@ -10,9 +10,9 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -182,7 +182,7 @@ func (c *Config) Prepare(raws ...interface{}) error { return err } - var errs *packer.MultiError + var errs *packersdk.MultiError // Set some defaults. if c.APIURL == "" { @@ -219,7 +219,7 @@ func (c *Config) Prepare(raws ...interface{}) error { if c.TemplateName == "" { name, err := interpolate.Render("packer-{{timestamp}}", nil) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to parse template name: %s ", err)) } @@ -240,71 +240,71 @@ func (c *Config) Prepare(raws ...interface{}) error { // Process required parameters. if c.APIURL == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a api_url must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a api_url must be specified")) } if c.APIKey == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a api_key must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a api_key must be specified")) } if c.SecretKey == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a secret_key must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a secret_key must be specified")) } if c.Network == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a network must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a network must be specified")) } if c.CreateSecurityGroup && !c.Expunge { - errs = packer.MultiErrorAppend(errs, errors.New("auto creating a temporary security group requires expunge")) + errs = packersdk.MultiErrorAppend(errs, errors.New("auto creating a temporary security group requires expunge")) } if c.ServiceOffering == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a service_offering must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a service_offering must be specified")) } if c.SourceISO == "" && c.SourceTemplate == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("either source_iso or source_template must be specified")) } if c.SourceISO != "" && c.SourceTemplate != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("only one of source_iso or source_template can be specified")) } if c.SourceISO != "" && c.DiskOffering == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a disk_offering must be specified when using source_iso")) } if c.SourceISO != "" && c.Hypervisor == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a hypervisor must be specified when using source_iso")) } if c.TemplateOS == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a template_os must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a template_os must be specified")) } if c.UserData != "" && c.UserDataFile != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("only one of user_data or user_data_file can be specified")) } if c.UserDataFile != "" { if _, err := os.Stat(c.UserDataFile); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile)) } } if c.Zone == "" { - errs = packer.MultiErrorAppend(errs, errors.New("a zone must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("a zone must be specified")) } if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } // Check for errors and return if we have any. diff --git a/builder/cloudstack/step_prepare_config.go b/builder/cloudstack/step_prepare_config.go index 5b40e7bb7..dd276fb0a 100644 --- a/builder/cloudstack/step_prepare_config.go +++ b/builder/cloudstack/step_prepare_config.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "regexp" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" @@ -22,20 +21,20 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m ui.Say("Preparing config...") var err error - var errs *packer.MultiError + var errs *packersdk.MultiError // First get the project and zone UUID's so we can use them in other calls when needed. if config.Project != "" && !isUUID(config.Project) { config.Project, _, err = client.Project.GetProjectID(config.Project) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"project", config.Project, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"project", config.Project, err}) } } if config.UserDataFile != "" { userdata, err := ioutil.ReadFile(config.UserDataFile) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("problem reading user data file: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("problem reading user data file: %s", err)) } config.UserData = string(userdata) } @@ -43,7 +42,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m if !isUUID(config.Zone) { config.Zone, _, err = client.Zone.GetZoneID(config.Zone) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"zone", config.Zone, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"zone", config.Zone, err}) } } @@ -51,7 +50,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m if config.DiskOffering != "" && !isUUID(config.DiskOffering) { config.DiskOffering, _, err = client.DiskOffering.GetDiskOfferingID(config.DiskOffering) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"disk offering", config.DiskOffering, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"disk offering", config.DiskOffering, err}) } } @@ -59,7 +58,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m if isUUID(config.PublicIPAddress) { ip, _, err := client.Address.GetPublicIpAddressByID(config.PublicIPAddress) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed to retrieve IP address: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed to retrieve IP address: %s", err)) } state.Put("ipaddress", ip.Ipaddress) } else { @@ -75,10 +74,10 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m ipAddrs, err := client.Address.ListPublicIpAddresses(p) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, err}) } if err == nil && ipAddrs.Count != 1 { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, ipAddrs}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, ipAddrs}) } if err == nil && ipAddrs.Count == 1 { config.PublicIPAddress = ipAddrs.PublicIpAddresses[0].Id @@ -89,7 +88,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m if !isUUID(config.Network) { config.Network, _, err = client.Network.GetNetworkID(config.Network, cloudstack.WithProject(config.Project)) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"network", config.Network, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"network", config.Network, err}) } } @@ -99,7 +98,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m if !isUUID(config.SecurityGroups[i]) { config.SecurityGroups[i], _, err = client.SecurityGroup.GetSecurityGroupID(config.SecurityGroups[i], cloudstack.WithProject(config.Project)) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"network", config.SecurityGroups[i], err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"network", config.SecurityGroups[i], err}) } } } @@ -108,7 +107,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m if !isUUID(config.ServiceOffering) { config.ServiceOffering, _, err = client.ServiceOffering.GetServiceOfferingID(config.ServiceOffering) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"service offering", config.ServiceOffering, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"service offering", config.ServiceOffering, err}) } } @@ -118,7 +117,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m } else { isoID, _, err := client.ISO.GetIsoID(config.SourceISO, "executable", config.Zone) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"ISO", config.SourceISO, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"ISO", config.SourceISO, err}) } state.Put("source", isoID) } @@ -130,7 +129,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m } else { templateID, _, err := client.Template.GetTemplateID(config.SourceTemplate, "executable", config.Zone) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"template", config.SourceTemplate, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"template", config.SourceTemplate, err}) } state.Put("source", templateID) } @@ -142,19 +141,19 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m types, err := client.GuestOS.ListOsTypes(p) if err != nil { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, err}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, err}) } if err == nil && types.Count != 1 { - errs = packer.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, types}) + errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, types}) } if err == nil && types.Count == 1 { config.TemplateOS = types.OsTypes[0].Id } } - // This is needed because nil is not always nil. When returning *packer.MultiError(nil) + // This is needed because nil is not always nil. When returning *packersdk.MultiError(nil) // as an error interface, that interface will no longer be equal to nil but it will be - // an interface with type *packer.MultiError and value nil which is different then a + // an interface with type *packersdk.MultiError and value nil which is different then a // nil interface. if errs != nil && len(errs.Errors) > 0 { state.Put("error", errs) diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index 958b04f66..529ee481f 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -148,38 +149,38 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.SnapshotTimeout = 60 * time.Minute } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.APIToken == "" { // Required configurations that will display errors if not set - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("api_token for auth must be specified")) } if c.Region == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("region is required")) } if c.Size == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("size is required")) } if c.Image == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("image is required")) } if c.UserData != "" && c.UserDataFile != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("only one of user_data or user_data_file can be specified")) } else if c.UserDataFile != "" { if _, err := os.Stat(c.UserDataFile); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New(fmt.Sprintf("user_data_file not found: %s", c.UserDataFile))) } } @@ -191,7 +192,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { for _, t := range c.Tags { if !tagRe.MatchString(t) { - errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf("invalid tag: %s", t))) + errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf("invalid tag: %s", t))) } } diff --git a/builder/docker/config.go b/builder/docker/config.go index 5fe0e8b54..5c341adb7 100644 --- a/builder/docker/config.go +++ b/builder/docker/config.go @@ -8,8 +8,8 @@ import ( "os" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/mapstructure" @@ -169,25 +169,25 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.Image == "" { - errs = packer.MultiErrorAppend(errs, errImageNotSpecified) + errs = packersdk.MultiErrorAppend(errs, errImageNotSpecified) } if (c.ExportPath != "" && c.Commit) || (c.ExportPath != "" && c.Discard) || (c.Commit && c.Discard) { - errs = packer.MultiErrorAppend(errs, errArtifactUseConflict) + errs = packersdk.MultiErrorAppend(errs, errArtifactUseConflict) } if c.ExportPath == "" && !c.Commit && !c.Discard { - errs = packer.MultiErrorAppend(errs, errArtifactNotUsed) + errs = packersdk.MultiErrorAppend(errs, errArtifactNotUsed) } if c.ExportPath != "" { if fi, err := os.Stat(c.ExportPath); err == nil && fi.IsDir() { - errs = packer.MultiErrorAppend(errs, errExportPathNotFile) + errs = packersdk.MultiErrorAppend(errs, errExportPathNotFile) } } @@ -200,7 +200,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.EcrLogin && c.LoginServer == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("ECR login requires login server to be provided.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("ECR login requires login server to be provided.")) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/file/config.go b/builder/file/config.go index 5560f73e5..65234e487 100644 --- a/builder/file/config.go +++ b/builder/file/config.go @@ -5,8 +5,8 @@ package file import ( "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -35,10 +35,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return warnings, err } - var errs *packer.MultiError + var errs *packersdk.MultiError if c.Target == "" { - errs = packer.MultiErrorAppend(errs, ErrTargetRequired) + errs = packersdk.MultiErrorAppend(errs, ErrTargetRequired) } if c.Content == "" && c.Source == "" { @@ -46,7 +46,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.Content != "" && c.Source != "" { - errs = packer.MultiErrorAppend(errs, ErrContentSourceConflict) + errs = packersdk.MultiErrorAppend(errs, ErrContentSourceConflict) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index cdf4581e5..bdee0be10 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -12,8 +12,8 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -310,7 +310,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError // Set defaults. if c.Network == "" && c.Subnetwork == "" { @@ -333,7 +333,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // monitoring relies on data gathered by Measured Boot. if !c.EnableVtpm { if c.EnableIntegrityMonitoring { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("You cannot enable Integrity Monitoring when vTPM is disabled.")) } } @@ -343,7 +343,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.OnHostMaintenance == "MIGRATE" && c.Preemptible { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("on_host_maintenance must be TERMINATE when using preemptible instances.")) } // Setting OnHostMaintenance Correct Defaults @@ -359,14 +359,14 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Make sure user sets a valid value for on_host_maintenance option if !(c.OnHostMaintenance == "MIGRATE" || c.OnHostMaintenance == "TERMINATE") { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("on_host_maintenance must be one of MIGRATE or TERMINATE.")) } if c.ImageName == "" { img, err := interpolate.Render("packer-{{timestamp}}", nil) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to parse image name: %s ", err)) } else { c.ImageName = img @@ -377,27 +377,27 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { imageErrorText := "Invalid image %s %q: The first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash" if len(c.ImageName) > 63 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Invalid image name: Must not be longer than 63 characters")) } if !validImageName.MatchString(c.ImageName) { - errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "name", c.ImageName))) + errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "name", c.ImageName))) } if len(c.ImageFamily) > 63 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Invalid image family: Must not be longer than 63 characters")) } if c.ImageFamily != "" { if !validImageName.MatchString(c.ImageFamily) { - errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "family", c.ImageFamily))) + errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "family", c.ImageFamily))) } } if len(c.ImageStorageLocations) > 1 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Invalid image storage locations: Must not have more than 1 region")) } @@ -419,7 +419,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Set up communicator if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } // set defaults for IAP @@ -449,7 +449,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.IAPConfig.IAP { if !SupportsIAPTunnel(&c.Comm) { err := fmt.Errorf("Error: IAP tunnel is not implemented for %s communicator", c.Comm.Type) - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } // These configuration values are copied early to the generic host parameter when configuring // StepConnect. As such they must be set now. Ideally we would handle this as part of @@ -462,7 +462,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Process required parameters. if c.ProjectId == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a project_id must be specified")) } @@ -475,12 +475,12 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.SourceImage == "" && c.SourceImageFamily == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a source_image or source_image_family must be specified")) } if c.Zone == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a zone must be specified")) } if c.Region == "" && len(c.Zone) > 2 { @@ -492,40 +492,40 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Authenticating via an account file if c.AccountFile != "" { if c.VaultGCPOauthEngine != "" && c.ImpersonateServiceAccount != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("You cannot "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You cannot "+ "specify impersonate_service_account, account_file and vault_gcp_oauth_engine at the same time")) } cfg, err := ProcessAccountFile(c.AccountFile) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } c.account = cfg } if c.OmitExternalIP && c.Address != "" { - errs = packer.MultiErrorAppend(fmt.Errorf("you can not specify an external address when 'omit_external_ip' is true")) + errs = packersdk.MultiErrorAppend(fmt.Errorf("you can not specify an external address when 'omit_external_ip' is true")) } if c.OmitExternalIP && !c.UseInternalIP { - errs = packer.MultiErrorAppend(fmt.Errorf("'use_internal_ip' must be true if 'omit_external_ip' is true")) + errs = packersdk.MultiErrorAppend(fmt.Errorf("'use_internal_ip' must be true if 'omit_external_ip' is true")) } if c.AcceleratorCount > 0 && len(c.AcceleratorType) == 0 { - errs = packer.MultiErrorAppend(fmt.Errorf("'accelerator_type' must be set when 'accelerator_count' is more than 0")) + errs = packersdk.MultiErrorAppend(fmt.Errorf("'accelerator_type' must be set when 'accelerator_count' is more than 0")) } if c.AcceleratorCount > 0 && c.OnHostMaintenance != "TERMINATE" { - errs = packer.MultiErrorAppend(fmt.Errorf("'on_host_maintenance' must be set to 'TERMINATE' when 'accelerator_count' is more than 0")) + errs = packersdk.MultiErrorAppend(fmt.Errorf("'on_host_maintenance' must be set to 'TERMINATE' when 'accelerator_count' is more than 0")) } // If DisableDefaultServiceAccount is provided, don't allow a value for ServiceAccountEmail if c.DisableDefaultServiceAccount && c.ServiceAccountEmail != "" { - errs = packer.MultiErrorAppend(fmt.Errorf("you may not specify a 'service_account_email' when 'disable_default_service_account' is true")) + errs = packersdk.MultiErrorAppend(fmt.Errorf("you may not specify a 'service_account_email' when 'disable_default_service_account' is true")) } if c.StartupScriptFile != "" { if _, err := os.Stat(c.StartupScriptFile); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("startup_script_file: %v", err)) } diff --git a/builder/googlecompute/driver_gce.go b/builder/googlecompute/driver_gce.go index a00f4fe77..8fd8ea600 100644 --- a/builder/googlecompute/driver_gce.go +++ b/builder/googlecompute/driver_gce.go @@ -18,7 +18,6 @@ import ( oslogin "google.golang.org/api/oslogin/v1" "github.com/hashicorp/packer/builder/googlecompute/version" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" "github.com/hashicorp/packer/packer-plugin-sdk/useragent" @@ -263,7 +262,7 @@ func (d *driverGCE) GetImageFromProjects(projects []string, name string, fromFam for _, project := range projects { image, err := d.GetImageFromProject(project, name, fromFamily) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if image != nil { return image, nil @@ -676,7 +675,7 @@ func (d *driverGCE) refreshGlobalOp(op *compute.Operation) stateRefreshFunc { if newOp.Status == "DONE" { if newOp.Error != nil { for _, e := range newOp.Error.Errors { - err = packer.MultiErrorAppend(err, fmt.Errorf(e.Message)) + err = packersdk.MultiErrorAppend(err, fmt.Errorf(e.Message)) } } } @@ -697,7 +696,7 @@ func (d *driverGCE) refreshZoneOp(zone string, op *compute.Operation) stateRefre if newOp.Status == "DONE" { if newOp.Error != nil { for _, e := range newOp.Error.Errors { - err = packer.MultiErrorAppend(err, fmt.Errorf(e.Message)) + err = packersdk.MultiErrorAppend(err, fmt.Errorf(e.Message)) } } } diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index cc71687bc..fdf43b817 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -8,7 +8,6 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -21,7 +20,7 @@ type StepCreateInstance struct { func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string) (map[string]string, error) { instanceMetadata := make(map[string]string) var err error - var errs *packer.MultiError + var errs *packersdk.MultiError // Copy metadata from config. for k, v := range c.Metadata { @@ -75,7 +74,7 @@ func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string) var content []byte content, err = ioutil.ReadFile(value) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } instanceMetadata[key] = string(content) } diff --git a/builder/hcloud/config.go b/builder/hcloud/config.go index 55d31e799..3dae727a3 100644 --- a/builder/hcloud/config.go +++ b/builder/hcloud/config.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -95,46 +96,46 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.ServerName = fmt.Sprintf("packer-%s", uuid.TimeOrderedUUID()) } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.HCloudToken == "" { // Required configurations that will display errors if not set - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("token for auth must be specified")) } if c.Location == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("location is required")) } if c.ServerType == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("server type is required")) } if c.Image == "" && c.ImageFilter == nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("image or image_filter is required")) } if c.ImageFilter != nil { if len(c.ImageFilter.WithSelector) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("image_filter.with_selector is required when specifying filter")) } else if c.Image != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("only one of image or image_filter can be specified")) } } if c.UserData != "" && c.UserDataFile != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("only one of user_data or user_data_file can be specified")) } else if c.UserDataFile != "" { if _, err := os.Stat(c.UserDataFile); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New(fmt.Sprintf("user_data_file not found: %s", c.UserDataFile))) } } diff --git a/builder/hyperone/config.go b/builder/hyperone/config.go index 7f5cd520e..b8fca7937 100644 --- a/builder/hyperone/config.go +++ b/builder/hyperone/config.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/json" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -265,39 +266,39 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // Validation - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, c.ImageTag.CopyOn(&c.ImageTags)...) - errs = packer.MultiErrorAppend(errs, c.VmTag.CopyOn(&c.VmTags)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, c.ImageTag.CopyOn(&c.ImageTags)...) + errs = packersdk.MultiErrorAppend(errs, c.VmTag.CopyOn(&c.VmTags)...) if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.Token == "" { - errs = packer.MultiErrorAppend(errs, errors.New("token is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("token is required")) } if c.VmType == "" { - errs = packer.MultiErrorAppend(errs, errors.New("vm type is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("vm type is required")) } if c.DiskSize == 0 { - errs = packer.MultiErrorAppend(errs, errors.New("disk size is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("disk size is required")) } if c.SourceImage == "" { - errs = packer.MultiErrorAppend(errs, errors.New("source image is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("source image is required")) } if c.ChrootDisk { if len(c.PreMountCommands) == 0 { - errs = packer.MultiErrorAppend(errs, errors.New("pre-mount commands are required for chroot disk")) + errs = packersdk.MultiErrorAppend(errs, errors.New("pre-mount commands are required for chroot disk")) } } for _, mounts := range c.ChrootMounts { if len(mounts) != 3 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("each chroot_mounts entry should have three elements")) break } diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index fb8634df2..ddfb0316c 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -105,21 +105,21 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors and warnings - var errs *packer.MultiError + var errs *packersdk.MultiError warnings := make([]string, 0) isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) - errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) commonErrs, commonWarns := b.config.CommonConfig.Prepare(&b.config.ctx, &b.config.PackerConfig) - packer.MultiErrorAppend(errs, commonErrs...) + packersdk.MultiErrorAppend(errs, commonErrs...) warnings = append(warnings, commonWarns...) if len(b.config.ISOConfig.ISOUrls) < 1 || @@ -128,7 +128,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { //We only create a new hard drive if an existing one to copy from does not exist err = b.checkDiskSize() if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -139,7 +139,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.Generation == 2 { if b.config.UseLegacyNetworkAdapter { err = errors.New("Generation 2 vms don't support legacy network adapters.") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -147,17 +147,17 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.Generation > 1 && b.config.FixedVHD { err = errors.New("Fixed VHD disks are only supported on Generation 1 virtual machines.") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if !b.config.SkipCompaction && b.config.FixedVHD { err = errors.New("Fixed VHD disks do not support compaction.") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if b.config.DifferencingDisk && b.config.FixedVHD { err = errors.New("Fixed VHD disks are not supported with differencing disks.") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } // Warnings diff --git a/builder/hyperv/iso/builder_test.go b/builder/hyperv/iso/builder_test.go index 0103b656a..43790ebb2 100644 --- a/builder/hyperv/iso/builder_test.go +++ b/builder/hyperv/iso/builder_test.go @@ -12,6 +12,7 @@ import ( hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -240,7 +241,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 74eec6810..40a1ed134 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -98,23 +98,23 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors and warnings - var errs *packer.MultiError + var errs *packersdk.MultiError warnings := make([]string, 0) if b.config.RawSingleISOUrl != "" || len(b.config.ISOUrls) > 0 { isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) } - errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) commonErrs, commonWarns := b.config.CommonConfig.Prepare(&b.config.ctx, &b.config.PackerConfig) - packer.MultiErrorAppend(errs, commonErrs...) + packersdk.MultiErrorAppend(errs, commonErrs...) warnings = append(warnings, commonWarns...) if b.config.Cpu < 1 { @@ -123,22 +123,22 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.CloneFromVMName == "" { if b.config.CloneFromVMCXPath == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vm_name must be specified if "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vm_name must be specified if "+ "clone_from_vmcx_path is not specified.")) } } else { virtualMachineExists, err := powershell.DoesVirtualMachineExist(b.config.CloneFromVMName) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to clone "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to clone "+ "from exists: %s", err)) } else { if !virtualMachineExists { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Virtual machine '%s' to clone from does not "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Virtual machine '%s' to clone from does not "+ "exist.", b.config.CloneFromVMName)) } else { b.config.Generation, err = powershell.GetVirtualMachineGeneration(b.config.CloneFromVMName) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting virtual machine to clone "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting virtual machine to clone "+ "from generation: %s", err)) } @@ -146,11 +146,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { virtualMachineSnapshotExists, err := powershell.DoesVirtualMachineSnapshotExist( b.config.CloneFromVMName, b.config.CloneFromSnapshotName) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine "+ "snapshot to clone from exists: %s", err)) } else { if !virtualMachineSnapshotExists { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Virtual machine snapshot '%s' on "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Virtual machine snapshot '%s' on "+ "virtual machine '%s' to clone from does not exist.", b.config.CloneFromSnapshotName, b.config.CloneFromVMName)) } @@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { virtualMachineOn, err := powershell.IsVirtualMachineOn(b.config.CloneFromVMName) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to "+ "clone is running: %s", err)) } else { if virtualMachineOn { @@ -173,13 +173,13 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.CloneFromVMCXPath == "" { if b.config.CloneFromVMName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vmcx_path be specified if "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vmcx_path be specified if "+ "clone_from_vm_name must is not specified.")) } } else { if _, err := os.Stat(b.config.CloneFromVMCXPath); os.IsNotExist(err) { if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("CloneFromVMCXPath does not exist: %s", err)) } } @@ -190,7 +190,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { keep := strings.Split(b.config.CloneFromVMCXPath, "Virtual Machines") b.config.CloneFromVMCXPath = keep[0] } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to "+ "parse the clone_from_vmcx_path to find the vm directory. "+ "Please provide the path to the folder containing the "+ "vmcx file, not the file itself. Example: instead of "+ diff --git a/builder/hyperv/vmcx/builder_test.go b/builder/hyperv/vmcx/builder_test.go index e6c25b9f5..e67f9f5a1 100644 --- a/builder/hyperv/vmcx/builder_test.go +++ b/builder/hyperv/vmcx/builder_test.go @@ -12,6 +12,7 @@ import ( hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -389,7 +390,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index a19c81049..2800f633e 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -31,9 +31,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, fmt.Errorf("[ERROR] Failed in decoding JSON->mapstructure") } - errs := &packer.MultiError{} - errs = packer.MultiErrorAppend(errs, b.config.JDCloudCredentialConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.JDCloudInstanceSpecConfig.Prepare(&b.config.ctx)...) + errs := &packersdk.MultiError{} + errs = packersdk.MultiErrorAppend(errs, b.config.JDCloudCredentialConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.JDCloudInstanceSpecConfig.Prepare(&b.config.ctx)...) if errs != nil && len(errs.Errors) != 0 { return nil, nil, errs } diff --git a/builder/linode/config.go b/builder/linode/config.go index f749fa113..0c84ffdcc 100644 --- a/builder/linode/config.go +++ b/builder/linode/config.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -62,7 +63,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError // Defaults @@ -75,7 +76,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if def, err := interpolate.Render("packer-{{timestamp}}", nil); err == nil { c.ImageLabel = def } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to render image name: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to render image name: %s", err)) } } @@ -84,7 +85,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if def, err := interpolate.Render("packer-{{timestamp}}", nil); err == nil { c.Label = def } else { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to render Linode label: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to render Linode label: %s", err)) } } @@ -92,7 +93,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { var err error c.RootPass, err = createRandomRootPassword() if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to generate root_pass: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to generate root_pass: %s", err)) } } @@ -102,29 +103,29 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } c.Comm.SSHPassword = c.RootPass if c.PersonalAccessToken == "" { // Required configurations that will display errors if not set - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("linode_token is required")) } if c.Region == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("region is required")) } if c.InstanceType == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("instance_type is required")) } if c.Image == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("image is required")) } @@ -135,7 +136,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { for _, t := range c.Tags { if !tagRe.MatchString(t) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("invalid tag: %s", t)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("invalid tag: %s", t)) } } diff --git a/builder/lxc/config.go b/builder/lxc/config.go index c02187794..fb66ef13c 100644 --- a/builder/lxc/config.go +++ b/builder/lxc/config.go @@ -8,8 +8,8 @@ import ( "os" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/mapstructure" @@ -80,7 +80,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError if c.OutputDir == "" { c.OutputDir = fmt.Sprintf("output-%s", c.PackerBuildName) @@ -103,7 +103,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } if _, err := os.Stat(c.ConfigFile); os.IsNotExist(err) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("LXC Config file appears to be missing: %s", c.ConfigFile)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("LXC Config file appears to be missing: %s", c.ConfigFile)) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/lxd/config.go b/builder/lxd/config.go index f737d283b..f4e94f121 100644 --- a/builder/lxd/config.go +++ b/builder/lxd/config.go @@ -6,8 +6,8 @@ package lxd import ( "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/mapstructure" @@ -56,7 +56,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError if c.ContainerName == "" { c.ContainerName = fmt.Sprintf("packer-%s", c.PackerBuildName) @@ -71,7 +71,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } if c.Image == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("`image` is a required parameter for LXD. Please specify an image by alias or fingerprint. e.g. `ubuntu-daily:x`")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("`image` is a required parameter for LXD. Please specify an image by alias or fingerprint. e.g. `ubuntu-daily:x`")) } if c.Profile == "" { diff --git a/builder/ncloud/config.go b/builder/ncloud/config.go index 9db019e74..90c0347c7 100644 --- a/builder/ncloud/config.go +++ b/builder/ncloud/config.go @@ -11,8 +11,8 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud" "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -75,65 +75,65 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return warnings, err } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.Comm.Prepare(nil); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.AccessKey == "" { - errs = packer.MultiErrorAppend(errs, errors.New("access_key is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("access_key is required")) } if c.SecretKey == "" { - errs = packer.MultiErrorAppend(errs, errors.New("secret_key is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("secret_key is required")) } if c.MemberServerImageNo == "" && c.ServerImageProductCode == "" { - errs = packer.MultiErrorAppend(errs, errors.New("server_image_product_code or member_server_image_no is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("server_image_product_code or member_server_image_no is required")) } if c.MemberServerImageNo != "" && c.ServerImageProductCode != "" { - errs = packer.MultiErrorAppend(errs, errors.New("Only one of server_image_product_code and member_server_image_no can be set")) + errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of server_image_product_code and member_server_image_no can be set")) } if c.ServerImageProductCode != "" && len(c.ServerImageProductCode) > 20 { - errs = packer.MultiErrorAppend(errs, errors.New("If server_image_product_code field is set, length of server_image_product_code should be max 20")) + errs = packersdk.MultiErrorAppend(errs, errors.New("If server_image_product_code field is set, length of server_image_product_code should be max 20")) } if c.ServerProductCode != "" && len(c.ServerProductCode) > 20 { - errs = packer.MultiErrorAppend(errs, errors.New("If server_product_code field is set, length of server_product_code should be max 20")) + errs = packersdk.MultiErrorAppend(errs, errors.New("If server_product_code field is set, length of server_product_code should be max 20")) } if c.ServerImageName != "" && (len(c.ServerImageName) < 3 || len(c.ServerImageName) > 30) { - errs = packer.MultiErrorAppend(errs, errors.New("If server_image_name field is set, length of server_image_name should be min 3 and max 20")) + errs = packersdk.MultiErrorAppend(errs, errors.New("If server_image_name field is set, length of server_image_name should be min 3 and max 20")) } if c.ServerImageDescription != "" && len(c.ServerImageDescription) > 1000 { - errs = packer.MultiErrorAppend(errs, errors.New("If server_image_description field is set, length of server_image_description should be max 1000")) + errs = packersdk.MultiErrorAppend(errs, errors.New("If server_image_description field is set, length of server_image_description should be max 1000")) } if c.BlockStorageSize != 0 { if c.BlockStorageSize < 10 || c.BlockStorageSize > 2000 { - errs = packer.MultiErrorAppend(errs, errors.New("The size of BlockStorageSize is at least 10 GB and up to 2000GB")) + errs = packersdk.MultiErrorAppend(errs, errors.New("The size of BlockStorageSize is at least 10 GB and up to 2000GB")) } else if int(c.BlockStorageSize/10)*10 != c.BlockStorageSize { return nil, errors.New("BlockStorageSize must be a multiple of 10 GB") } } if c.UserData != "" && c.UserDataFile != "" { - errs = packer.MultiErrorAppend(errs, errors.New("Only one of user_data or user_data_file can be specified.")) + errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of user_data or user_data_file can be specified.")) } else if c.UserDataFile != "" { if _, err := os.Stat(c.UserDataFile); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile)) } } if c.UserData != "" && len(c.UserData) > 21847 { - errs = packer.MultiErrorAppend(errs, errors.New("If user_data field is set, length of UserData should be max 21847")) + errs = packersdk.MultiErrorAppend(errs, errors.New("If user_data field is set, length of UserData should be max 21847")) } if c.Comm.Type == "winrm" && c.AccessControlGroupConfigurationNo == "" { - errs = packer.MultiErrorAppend(errs, errors.New("If Communicator is winrm, access_control_group_configuration_no is required")) + errs = packersdk.MultiErrorAppend(errs, errors.New("If Communicator is winrm, access_control_group_configuration_no is required")) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/null/config.go b/builder/null/config.go index 500cb0674..ed7b1ccc7 100644 --- a/builder/null/config.go +++ b/builder/null/config.go @@ -6,8 +6,8 @@ import ( "fmt" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -29,31 +29,31 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.CommConfig.Prepare(nil); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.CommConfig.Type != "none" { if c.CommConfig.Host() == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a Host must be specified, please reference your communicator documentation")) } if c.CommConfig.User() == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a Username must be specified, please reference your communicator documentation")) } if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKeyFile == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("one authentication method must be specified, please reference your communicator documentation")) } if (c.CommConfig.SSHAgentAuth && (c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKeyFile != "")) || (c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKeyFile != "") { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified")) } diff --git a/builder/oneandone/config.go b/builder/oneandone/config.go index c11e2e925..ebe1ccaed 100644 --- a/builder/oneandone/config.go +++ b/builder/oneandone/config.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/mapstructure" @@ -48,7 +49,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError if c.SnapshotName == "" { def, err := interpolate.Render("packer-{{timestamp}}", nil) @@ -61,7 +62,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.Image == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("1&1 'image' is required")) } @@ -90,7 +91,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { dcs, err := api.ListDatacenters() if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, err) } for _, dc := range dcs { @@ -102,7 +103,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index b4a9fb80e..1fd5f3456 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -51,10 +51,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) if errs != nil && len(errs.Errors) > 0 { return nil, nil, errs diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index 8e672881f..5ddaad9d5 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -36,9 +36,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError - errs = packer.MultiErrorAppend(errs, b.config.PVConfig.Prepare(&b.config.ctx)) + errs = packersdk.MultiErrorAppend(errs, b.config.PVConfig.Prepare(&b.config.ctx)) if errs != nil && len(errs.Errors) > 0 { return nil, nil, errs diff --git a/builder/oracle/classic/config.go b/builder/oracle/classic/config.go index a463fe787..86b4bf177 100644 --- a/builder/oracle/classic/config.go +++ b/builder/oracle/classic/config.go @@ -10,8 +10,8 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -80,7 +80,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } // Validate that all required fields are present - var errs *packer.MultiError + var errs *packersdk.MultiError required := map[string]string{ "username": c.Username, "password": c.Password, @@ -92,7 +92,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } for k, v := range required { if v == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("You must specify a %s.", k)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You must specify a %s.", k)) } } @@ -107,20 +107,20 @@ func (c *Config) Prepare(raws ...interface{}) error { } for _, ov := range objectValidation { if !reValidObject.MatchString(ov.value) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s can contain only alphanumeric characters, hyphens, underscores, and periods.", ov.name)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s can contain only alphanumeric characters, hyphens, underscores, and periods.", ov.name)) } } if c.Attributes != "" && c.AttributesFile != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified.")) } else if c.AttributesFile != "" { if _, err := os.Stat(c.AttributesFile); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("attributes_file not found: %s", c.AttributesFile)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("attributes_file not found: %s", c.AttributesFile)) } } if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if errs != nil && len(errs.Errors) > 0 { @@ -134,20 +134,20 @@ func (c *Config) Prepare(raws ...interface{}) error { err := json.Unmarshal([]byte(c.Attributes), &data) if err != nil { err = fmt.Errorf("Problem parsing json from attributes: %s", err) - packer.MultiErrorAppend(errs, err) + packersdk.MultiErrorAppend(errs, err) } c.attribs = data } else if c.AttributesFile != "" { fidata, err := ioutil.ReadFile(c.AttributesFile) if err != nil { err = fmt.Errorf("Problem reading attributes_file: %s", err) - packer.MultiErrorAppend(errs, err) + packersdk.MultiErrorAppend(errs, err) } err = json.Unmarshal(fidata, &data) c.attribs = data if err != nil { err = fmt.Errorf("Problem parsing json from attributes_file: %s", err) - packer.MultiErrorAppend(errs, err) + packersdk.MultiErrorAppend(errs, err) } c.attribs = data } diff --git a/builder/oracle/classic/pv_config.go b/builder/oracle/classic/pv_config.go index 8321dee5f..2fc707d64 100644 --- a/builder/oracle/classic/pv_config.go +++ b/builder/oracle/classic/pv_config.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -82,19 +82,19 @@ func (c *PVConfig) IsPV() bool { return c.PersistentVolumeSize > 0 } -func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) { +func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packersdk.MultiError) { if !c.IsPV() { if c.BuilderShape != "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("`builder_shape` has no meaning when `persistent_volume_size` is not set.")) } if c.BuilderImageList != "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("`builder_image_list` has no meaning when `persistent_volume_size` is not set.")) } if c.BuilderImageListEntry != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("`builder_image_list_entry` has no meaning when `persistent_volume_size` is not set.")) } return errs @@ -102,7 +102,7 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) { c.BuilderComm.SSHPty = true if c.BuilderComm.Type == "winrm" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("`ssh` is the only valid builder communicator type.")) } @@ -133,7 +133,7 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) { } if es := c.BuilderComm.Prepare(ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } return diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 77df0d321..ac214ae04 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ocicommon "github.com/oracle/oci-go-sdk/common" @@ -129,9 +130,9 @@ func (c *Config) Prepare(raws ...interface{}) error { return fmt.Errorf("Failed to mapstructure Config: %+v", err) } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } var tenancyOCID string @@ -143,28 +144,28 @@ func (c *Config) Prepare(raws ...interface{}) error { // key involved. var message string = " cannot be present when use_instance_principals is set to true." if c.AccessCfgFile != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file"+message)) } if c.AccessCfgFileAccount != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file_account"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file_account"+message)) } if c.UserID != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("user_ocid"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user_ocid"+message)) } if c.TenancyID != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("tenancy_ocid"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("tenancy_ocid"+message)) } if c.Region != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("region"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("region"+message)) } if c.Fingerprint != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("fingerprint"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("fingerprint"+message)) } if c.KeyFile != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("key_file"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("key_file"+message)) } if c.PassPhrase != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("pass_phrase"+message)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("pass_phrase"+message)) } // This check is used to facilitate testing. During testing a Mock struct // is assigned to c.configProvider otherwise testing fails because Instance @@ -235,23 +236,23 @@ func (c *Config) Prepare(raws ...interface{}) error { } if userOCID, _ := configProvider.UserOCID(); userOCID == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'user_ocid' must be specified")) } tenancyOCID, _ = configProvider.TenancyOCID() if tenancyOCID == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'tenancy_ocid' must be specified")) } if fingerprint, _ := configProvider.KeyFingerprint(); fingerprint == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'fingerprint' must be specified")) } if _, err := configProvider.PrivateRSAKey(); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'key_file' must be specified")) } @@ -259,7 +260,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } if c.AvailabilityDomain == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'availability_domain' must be specified")) } @@ -272,12 +273,12 @@ func (c *Config) Prepare(raws ...interface{}) error { } if c.Shape == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'shape' must be specified")) } if (c.SubnetID == "") && (c.CreateVnicDetails.SubnetId == nil) { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'subnet_ocid' must be specified")) } @@ -289,7 +290,7 @@ func (c *Config) Prepare(raws ...interface{}) error { } if (c.BaseImageID == "") && (c.BaseImageFilter == ListImagesRequest{}) { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'base_image_ocid' or 'base_image_filter' must be specified")) } @@ -307,19 +308,19 @@ func (c *Config) Prepare(raws ...interface{}) error { k = strings.TrimSpace(k) v = strings.TrimSpace(v) if len(k) > 100 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Tag key length too long. Maximum 100 but found %d. Key: %s", len(k), k)) } if len(k) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("Tag key empty in config")) } if len(v) > 100 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Tag value length too long. Maximum 100 but found %d. Key: %s", len(v), k)) } if len(v) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("Tag value empty in config")) } } @@ -328,7 +329,7 @@ func (c *Config) Prepare(raws ...interface{}) error { if c.ImageName == "" { name, err := interpolate.Render("packer-{{timestamp}}", nil) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to parse image name: %s", err)) } else { c.ImageName = name @@ -337,17 +338,17 @@ func (c *Config) Prepare(raws ...interface{}) error { // Optional UserData config if c.UserData != "" && c.UserDataFile != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified.")) } else if c.UserDataFile != "" { if _, err := os.Stat(c.UserDataFile); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile)) } } // read UserDataFile into string. if c.UserDataFile != "" { fiData, err := ioutil.ReadFile(c.UserDataFile) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Problem reading user_data_file: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Problem reading user_data_file: %s", err)) } c.UserData = string(fiData) } @@ -364,7 +365,7 @@ func (c *Config) Prepare(raws ...interface{}) error { if c.BootVolumeSizeInGBs == 0 { c.BootVolumeSizeInGBs = 50 } else if c.BootVolumeSizeInGBs < 50 || c.BootVolumeSizeInGBs > 16384 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'disk_size' must be between 50 and 16384 GBs")) } diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index c36ae8346..a8f281cf8 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -70,12 +70,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.OMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) if errs != nil && len(errs.Errors) > 0 { return nil, nil, errs diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index 18d4802ca..bc0d442be 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -71,16 +71,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.OMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...) if b.config.OMIVirtType == "" { - errs = packer.MultiErrorAppend(errs, errors.New("omi_virtualization_type is required.")) + errs = packersdk.MultiErrorAppend(errs, errors.New("omi_virtualization_type is required.")) } foundRootVolume := false @@ -91,7 +91,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if !foundRootVolume { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName)) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/osc/bsuvolume/artifact.go b/builder/osc/bsuvolume/artifact.go index 7dd31af52..4b70513c2 100644 --- a/builder/osc/bsuvolume/artifact.go +++ b/builder/osc/bsuvolume/artifact.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -87,7 +87,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } } diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 57f4454e1..999e75703 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -64,20 +64,20 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...) for _, d := range b.config.VolumeMappings { if err := d.Prepare(&b.config.ctx); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("OMIMapping: %s", err.Error())) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("OMIMapping: %s", err.Error())) } } b.config.launchBlockDevices, err = commonBlockDevices(b.config.VolumeMappings, &b.config.ctx) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index b05463b1c..198ca19c8 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -128,16 +128,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors or warnings - var errs *packer.MultiError + var errs *packersdk.MultiError var warns []string - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.OMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...) for _, mounts := range b.config.ChrootMounts { if len(mounts) != 3 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("Each chroot_mounts entry should be three elements.")) break } @@ -148,28 +148,28 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { warns = append(warns, "source_omi and source_omi_filter are unused when from_scratch is true") } if b.config.RootVolumeSize == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("root_volume_size is required with from_scratch.")) } if len(b.config.PreMountCommands) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("pre_mount_commands is required with from_scratch.")) } if b.config.OMIVirtType == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("omi_virtualization_type is required with from_scratch.")) } if b.config.RootDeviceName == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("root_device_name is required with from_scratch.")) } if len(b.config.OMIMappings) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("omi_block_device_mappings is required with from_scratch.")) } } else { if b.config.SourceOMI == "" && b.config.SourceOMIFilter.Empty() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("source_omi or source_omi_filter is required.")) } if len(b.config.OMIMappings) != 0 { diff --git a/builder/osc/common/artifact.go b/builder/osc/common/artifact.go index 8a11fcb9a..c543fa128 100644 --- a/builder/osc/common/artifact.go +++ b/builder/osc/common/artifact.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/antihax/optional" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" ) @@ -111,7 +111,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } } diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 2788537bf..eafe8f14e 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -106,25 +106,25 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors and warnings - var errs *packer.MultiError + var errs *packersdk.MultiError warnings := make([]string, 0) isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) - errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend( errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, b.config.HWConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.PrlctlConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.PrlctlPostConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.PrlctlVersionConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.HWConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.PrlctlConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.PrlctlPostConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.PrlctlVersionConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) if b.config.DiskSize == 0 { b.config.DiskSize = 40000 @@ -152,7 +152,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if b.config.DiskType != "expand" && b.config.DiskType != "plain" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("disk_type can only be expand, or plain")) } @@ -163,7 +163,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("hard_drive_interface can only be ide, sata, or scsi")) } diff --git a/builder/parallels/iso/builder_test.go b/builder/parallels/iso/builder_test.go index 06be93302..00e92c2f7 100644 --- a/builder/parallels/iso/builder_test.go +++ b/builder/parallels/iso/builder_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -92,7 +93,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/parallels/pvm/config.go b/builder/parallels/pvm/config.go index 27e7b5a43..d0c53be7d 100644 --- a/builder/parallels/pvm/config.go +++ b/builder/parallels/pvm/config.go @@ -8,10 +8,10 @@ import ( "os" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -73,22 +73,22 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // Prepare the errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, c.PrlctlConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.PrlctlPostConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.PrlctlVersionConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.PrlctlConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.PrlctlPostConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.PrlctlVersionConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...) if c.SourcePath == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required")) } else { if _, err := os.Stat(c.SourcePath); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is invalid: %s", err)) } } diff --git a/builder/parallels/pvm/config_test.go b/builder/parallels/pvm/config_test.go index 701eff59c..15f6a9ce1 100644 --- a/builder/parallels/pvm/config_test.go +++ b/builder/parallels/pvm/config_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig(t *testing.T) map[string]interface{} { @@ -90,7 +90,7 @@ func TestNewConfig_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/profitbricks/config.go b/builder/profitbricks/config.go index 3c9b994d3..a086e64db 100644 --- a/builder/profitbricks/config.go +++ b/builder/profitbricks/config.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/mitchellh/mapstructure" @@ -51,10 +52,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError if c.Comm.SSHPassword == "" && c.Comm.SSHPrivateKeyFile == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("Either ssh private key path or ssh password must be set.")) } @@ -101,21 +102,21 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.Image == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("ProfitBricks 'image' is required")) } if c.PBUsername == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("ProfitBricks username is required")) } if c.PBPassword == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("ProfitBricks password is required")) } diff --git a/builder/proxmox/clone/config.go b/builder/proxmox/clone/config.go index 01fa6971d..cc9c1db1a 100644 --- a/builder/proxmox/clone/config.go +++ b/builder/proxmox/clone/config.go @@ -4,7 +4,7 @@ package proxmoxclone import ( proxmox "github.com/hashicorp/packer/builder/proxmox/common" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -16,10 +16,10 @@ type Config struct { } func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { - var errs *packer.MultiError + var errs *packersdk.MultiError _, warnings, merrs := c.Config.Prepare(c, raws...) if merrs != nil { - errs = packer.MultiErrorAppend(errs, merrs) + errs = packersdk.MultiErrorAppend(errs, merrs) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/proxmox/common/config.go b/builder/proxmox/common/config.go index 916b3fdb7..6ed893dbd 100644 --- a/builder/proxmox/common/config.go +++ b/builder/proxmox/common/config.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -119,7 +120,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st return nil, nil, err } - var errs *packer.MultiError + var errs *packersdk.MultiError var warnings []string packer.LogSecretFilter.Set(c.Password) @@ -138,7 +139,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st var err error c.BootKeyInterval, err = time.ParseDuration(os.Getenv(bootcommand.PackerKeyEnv)) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if c.BootKeyInterval == 0 { @@ -191,11 +192,11 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st if c.Disks[idx].IOThread { // io thread is only supported by virtio-scsi-single controller if c.SCSIController != "virtio-scsi-single" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("io thread option requires virtio-scsi-single controller")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("io thread option requires virtio-scsi-single controller")) } else { // ... and only for virtio and scsi disks if !(c.Disks[idx].Type == "scsi" || c.Disks[idx].Type == "virtio") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("io thread option requires scsi or a virtio disk")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("io thread option requires scsi or a virtio disk")) } } } @@ -203,7 +204,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st // (currently zfspool|lvm|rbd|cephfs), the format parameter is mandatory. Make sure this is still up to date // when updating the vendored code! if !contains([]string{"zfspool", "lvm", "rbd", "cephfs"}, c.Disks[idx].StoragePoolType) && c.Disks[idx].DiskFormat == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("disk format must be specified for pool type %q", c.Disks[idx].StoragePoolType)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disk format must be specified for pool type %q", c.Disks[idx].StoragePoolType)) } } if c.SCSIController == "" { @@ -211,43 +212,43 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st c.SCSIController = "lsi" } - errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.Ctx)...) - errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.Ctx)...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.Ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.Ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.Ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.Ctx)...) // Required configurations that will display errors if not set if c.Username == "" { - errs = packer.MultiErrorAppend(errs, errors.New("username must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("username must be specified")) } if c.Password == "" { - errs = packer.MultiErrorAppend(errs, errors.New("password must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("password must be specified")) } if c.ProxmoxURLRaw == "" { - errs = packer.MultiErrorAppend(errs, errors.New("proxmox_url must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("proxmox_url must be specified")) } if c.proxmoxURL, err = url.Parse(c.ProxmoxURLRaw); err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Could not parse proxmox_url: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Could not parse proxmox_url: %s", err)) } if c.Node == "" { - errs = packer.MultiErrorAppend(errs, errors.New("node must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("node must be specified")) } if strings.ContainsAny(c.TemplateName, " ") { - errs = packer.MultiErrorAppend(errs, errors.New("template_name must not contain spaces")) + errs = packersdk.MultiErrorAppend(errs, errors.New("template_name must not contain spaces")) } for idx := range c.NICs { if c.NICs[idx].Bridge == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].bridge must be specified", idx)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].bridge must be specified", idx)) } if c.NICs[idx].Model != "virtio" && c.NICs[idx].PacketQueues > 0 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].packet_queues can only be set for 'virtio' driver", idx)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].packet_queues can only be set for 'virtio' driver", idx)) } } for idx := range c.Disks { if c.Disks[idx].StoragePool == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool must be specified", idx)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool must be specified", idx)) } if c.Disks[idx].StoragePoolType == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool_type must be specified", idx)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool_type must be specified", idx)) } } diff --git a/builder/proxmox/common/config_test.go b/builder/proxmox/common/config_test.go index b68c6fcc8..7f0441aaf 100644 --- a/builder/proxmox/common/config_test.go +++ b/builder/proxmox/common/config_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func mandatoryConfig(t *testing.T) map[string]interface{} { @@ -23,9 +23,9 @@ func TestRequiredParameters(t *testing.T) { if err == nil { t.Fatal("Expected empty configuration to fail") } - errs, ok := err.(*packer.MultiError) + errs, ok := err.(*packersdk.MultiError) if !ok { - t.Fatal("Expected errors to be packer.MultiError") + t.Fatal("Expected errors to be packersdk.MultiError") } required := []string{"username", "password", "proxmox_url", "node", "ssh_username"} diff --git a/builder/proxmox/iso/config.go b/builder/proxmox/iso/config.go index a5545f9eb..afdbc2465 100644 --- a/builder/proxmox/iso/config.go +++ b/builder/proxmox/iso/config.go @@ -10,8 +10,8 @@ import ( "strings" proxmox "github.com/hashicorp/packer/builder/proxmox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Config struct { @@ -25,10 +25,10 @@ type Config struct { } func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { - var errs *packer.MultiError + var errs *packersdk.MultiError _, warnings, merrs := c.Config.Prepare(c, raws...) if merrs != nil { - errs = packer.MultiErrorAppend(errs, merrs) + errs = packersdk.MultiErrorAppend(errs, merrs) } // Check ISO config @@ -39,16 +39,16 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { c.shouldUploadISO = false } else { isoWarnings, isoErrors := c.ISOConfig.Prepare(&c.Ctx) - errs = packer.MultiErrorAppend(errs, isoErrors...) + errs = packersdk.MultiErrorAppend(errs, isoErrors...) warnings = append(warnings, isoWarnings...) c.shouldUploadISO = true } if (c.ISOFile == "" && len(c.ISOConfig.ISOUrls) == 0) || (c.ISOFile != "" && len(c.ISOConfig.ISOUrls) != 0) { - errs = packer.MultiErrorAppend(errs, errors.New("either iso_file or iso_url, but not both, must be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("either iso_file or iso_url, but not both, must be specified")) } if len(c.ISOConfig.ISOUrls) != 0 && c.ISOStoragePool == "" { - errs = packer.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified")) } for idx := range c.AdditionalISOFiles { @@ -61,7 +61,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { } else { c.AdditionalISOFiles[idx].DownloadPathKey = "downloaded_additional_iso_path_" + strconv.Itoa(idx) isoWarnings, isoErrors := c.AdditionalISOFiles[idx].ISOConfig.Prepare(&c.Ctx) - errs = packer.MultiErrorAppend(errs, isoErrors...) + errs = packersdk.MultiErrorAppend(errs, isoErrors...) warnings = append(warnings, isoWarnings...) c.AdditionalISOFiles[idx].ShouldUploadISO = true } @@ -72,38 +72,38 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { if strings.HasPrefix(c.AdditionalISOFiles[idx].Device, "ide") { busnumber, err := strconv.Atoi(c.AdditionalISOFiles[idx].Device[3:]) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[3:])) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[3:])) } if busnumber == 2 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("IDE bus 2 is used by boot ISO")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("IDE bus 2 is used by boot ISO")) } if busnumber > 3 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("IDE bus index can't be higher than 3")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("IDE bus index can't be higher than 3")) } } if strings.HasPrefix(c.AdditionalISOFiles[idx].Device, "sata") { busnumber, err := strconv.Atoi(c.AdditionalISOFiles[idx].Device[4:]) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:])) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:])) } if busnumber > 5 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("SATA bus index can't be higher than 5")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("SATA bus index can't be higher than 5")) } } if strings.HasPrefix(c.AdditionalISOFiles[idx].Device, "scsi") { busnumber, err := strconv.Atoi(c.AdditionalISOFiles[idx].Device[4:]) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:])) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:])) } if busnumber > 30 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("SCSI bus index can't be higher than 30")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("SCSI bus index can't be higher than 30")) } } if (c.AdditionalISOFiles[idx].ISOFile == "" && len(c.AdditionalISOFiles[idx].ISOConfig.ISOUrls) == 0) || (c.AdditionalISOFiles[idx].ISOFile != "" && len(c.AdditionalISOFiles[idx].ISOConfig.ISOUrls) != 0) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("either iso_file or iso_url, but not both, must be specified for AdditionalISO file %s", c.AdditionalISOFiles[idx].Device)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("either iso_file or iso_url, but not both, must be specified for AdditionalISO file %s", c.AdditionalISOFiles[idx].Device)) } if len(c.ISOConfig.ISOUrls) != 0 && c.ISOStoragePool == "" { - errs = packer.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified")) + errs = packersdk.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified")) } } diff --git a/builder/qemu/config.go b/builder/qemu/config.go index cc0814667..7b56ff0e4 100644 --- a/builder/qemu/config.go +++ b/builder/qemu/config.go @@ -13,10 +13,10 @@ import ( "runtime" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -410,10 +410,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // Accumulate any errors and warnings - var errs *packer.MultiError + var errs *packersdk.MultiError warnings := make([]string, 0) - errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) if c.DiskSize == "" || c.DiskSize == "0" { c.DiskSize = "40960M" @@ -423,7 +423,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { re := regexp.MustCompile(`^[\d]+(b|k|m|g|t){0,1}$`) matched := re.MatchString(strings.ToLower(c.DiskSize)) if !matched { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Invalid disk size.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Invalid disk size.")) } else { // Okay, it's valid -- if it doesn't alreay have a suffix, then // append "M" as the default unit. @@ -510,9 +510,9 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.Format = "qcow2" } - errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) if c.NetDevice == "" { c.NetDevice = "virtio-net" @@ -527,17 +527,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } isoWarnings, isoErrs := c.ISOConfig.Prepare(&c.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) commConfigWarnings, es := c.CommConfig.Prepare(&c.ctx) if len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } warnings = append(warnings, commConfigWarnings...) if !(c.Format == "qcow2" || c.Format == "raw") { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("invalid format, only 'qcow2' or 'raw' are allowed")) } @@ -549,61 +549,61 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.UseBackingFile { c.SkipCompaction = true if !(c.DiskImage && c.Format == "qcow2") { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("use_backing_file can only be enabled for QCOW2 images and when disk_image is true")) } } if c.DiskImage && len(c.AdditionalDiskSize) > 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("disk_additional_size can only be used when disk_image is false")) } if c.SkipResizeDisk && !(c.DiskImage) { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("skip_resize_disk can only be used when disk_image is true")) } if _, ok := accels[c.Accelerator]; !ok { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("invalid accelerator, only 'kvm', 'tcg', 'xen', 'hax', 'hvf', 'whpx', or 'none' are allowed")) } if _, ok := diskInterface[c.DiskInterface]; !ok { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("unrecognized disk interface type")) } if _, ok := diskCache[c.DiskCache]; !ok { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("unrecognized disk cache type")) } if _, ok := diskDiscard[c.DiskDiscard]; !ok { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("unrecognized disk discard type")) } if _, ok := diskDZeroes[c.DetectZeroes]; !ok { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("unrecognized disk detect zeroes setting")) } if !c.PackerForce { if _, err := os.Stat(c.OutputDir); err == nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Output directory '%s' already exists. It must not exist.", c.OutputDir)) } } if c.VNCPortMin > c.VNCPortMax { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max")) } if c.NetBridge != "" && runtime.GOOS != "linux" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("net_bridge is only supported in Linux based OSes")) } diff --git a/builder/qemu/config_test.go b/builder/qemu/config_test.go index bcb867004..e74c7e336 100644 --- a/builder/qemu/config_test.go +++ b/builder/qemu/config_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" ) @@ -354,7 +355,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index 9b5ae70ad..d65c37ea6 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/useragent" @@ -221,17 +222,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.BootType = instance.BootTypeLocal.String() } - var errs *packer.MultiError + var errs *packersdk.MultiError if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } if c.ProjectID == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("scaleway Project ID must be specified")) } if c.SecretKey == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("scaleway Secret Key must be specified")) } @@ -241,17 +242,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.Zone == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("scaleway Zone is required")) + errs = packersdk.MultiErrorAppend( + errs, errors.New("Scaleway Zone is required")) } if c.CommercialType == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("commercial type is required")) } if c.Image == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("image is required")) } diff --git a/builder/tencentcloud/cvm/artifact.go b/builder/tencentcloud/cvm/artifact.go index d4ea37519..12bedc28e 100644 --- a/builder/tencentcloud/cvm/artifact.go +++ b/builder/tencentcloud/cvm/artifact.go @@ -7,7 +7,7 @@ import ( "sort" "strings" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312" ) @@ -133,7 +133,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else if len(errors) > 1 { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } else { return nil } diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 1c1580d0c..0a6baa017 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -52,10 +52,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.TencentCloudAccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.TencentCloudImageConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.TencentCloudRunConfig.Prepare(&b.config.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.TencentCloudAccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.TencentCloudImageConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.TencentCloudRunConfig.Prepare(&b.config.ctx)...) if errs != nil && len(errs.Errors) > 0 { return nil, nil, errs } diff --git a/builder/ucloud/common/artifact.go b/builder/ucloud/common/artifact.go index ae3b3554b..b1d13ec44 100644 --- a/builder/ucloud/common/artifact.go +++ b/builder/ucloud/common/artifact.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/ucloud/ucloud-sdk-go/ucloud" ) @@ -84,7 +84,7 @@ func (a *Artifact) Destroy() error { if len(errors) == 1 { return errors[0] } else { - return &packer.MultiError{Errors: errors} + return &packersdk.MultiError{Errors: errors} } } diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index a4d652668..5430adb5c 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -55,10 +55,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) if errs != nil && len(errs.Errors) > 0 { return nil, nil, errs diff --git a/builder/ucloud/uhost/step_pre_validate.go b/builder/ucloud/uhost/step_pre_validate.go index f945613fb..9242d9a1a 100644 --- a/builder/ucloud/uhost/step_pre_validate.go +++ b/builder/ucloud/uhost/step_pre_validate.go @@ -4,7 +4,6 @@ import ( "context" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -38,14 +37,14 @@ func (s *stepPreValidate) validateProjectIds(state multistep.StateBag) error { ui.Say("Validating project_id and copied project_ids...") - var errs *packer.MultiError + var errs *packersdk.MultiError if err := config.ValidateProjectId(s.ProjectId); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } for _, imageDestination := range s.ImageDestinations { if err := config.ValidateProjectId(imageDestination.ProjectId); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -62,13 +61,13 @@ func (s *stepPreValidate) validateRegions(state multistep.StateBag) error { ui.Say("Validating region and copied regions...") - var errs *packer.MultiError + var errs *packersdk.MultiError if err := config.ValidateRegion(s.Region); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } for _, imageDestination := range s.ImageDestinations { if err := config.ValidateRegion(imageDestination.Region); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -85,9 +84,9 @@ func (s *stepPreValidate) validateZones(state multistep.StateBag) error { ui.Say("Validating availability_zone...") - var errs *packer.MultiError + var errs *packersdk.MultiError if err := config.ValidateZone(s.Region, s.Zone); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 6463bd8be..eace841f6 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -167,7 +167,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors and warnings - var errs *packer.MultiError + var errs *packersdk.MultiError warnings := make([]string, 0) if b.config.OutputDir == "" { @@ -179,7 +179,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if b.config.Comm.Type != "ssh" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(`The Vagrant builder currently only supports the ssh communicator"`)) } // The box isn't a namespace like you'd pull from vagrant cloud @@ -189,11 +189,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.SourceBox == "" { if b.config.GlobalID == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required unless you have set global_id")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required unless you have set global_id")) } } else { if b.config.GlobalID != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("You may either set global_id or source_path but not both")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You may either set global_id or source_path but not both")) } // We're about to open up an actual boxfile. If the file is local to the // filesystem, let's make sure it exists before we get too far into the @@ -204,7 +204,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { u, err := url.Parse(b.config.SourceBox) if err == nil && (u.Scheme == "" || u.Scheme == "file") { if _, err := os.Stat(b.config.SourceBox); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Source box '%s' needs to exist at time of"+ " config validation! %v", b.config.SourceBox, err)) } @@ -215,7 +215,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.OutputVagrantfile != "" { b.config.OutputVagrantfile, err = filepath.Abs(b.config.OutputVagrantfile) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to determine absolute path for output vagrantfile: %s", err)) } } @@ -224,7 +224,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { for i, rawFile := range b.config.PackageInclude { inclFile, err := filepath.Abs(rawFile) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to determine absolute path for file to be included: %s", rawFile)) } b.config.PackageInclude[i] = inclFile @@ -248,7 +248,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } } if !matches { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(`TeardownMethod must be "halt", "suspend", or "destroy"`)) } } @@ -256,11 +256,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if b.config.SyncedFolder != "" { b.config.SyncedFolder, err = filepath.Abs(b.config.SyncedFolder) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to determine absolute path for synced_folder: %s", b.config.SyncedFolder)) } if _, err := os.Stat(b.config.SyncedFolder); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("synced_folder \"%s\" does not exist on the Packer host.", b.config.SyncedFolder)) } } diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 13d5151de..0b9557a8f 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -137,18 +137,18 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Accumulate any errors and warnings - var errs *packer.MultiError + var errs *packersdk.MultiError warnings := make([]string, 0) isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) - errs = packer.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.CDConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.CDConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend( errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) @@ -190,7 +190,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { case "ide", "sata", "scsi", "pcie": // do nothing default: - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("hard_drive_interface can only be ide, sata, pcie or scsi")) } @@ -199,7 +199,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if b.config.SATAPortCount > 30 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("sata_port_count cannot be greater than 30")) } @@ -208,12 +208,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } if b.config.NVMePortCount > 255 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("nvme_port_count cannot be greater than 255")) } if b.config.ISOInterface != "ide" && b.config.ISOInterface != "sata" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("iso_interface can only be ide or sata")) } diff --git a/builder/virtualbox/iso/builder_test.go b/builder/virtualbox/iso/builder_test.go index 194b6f782..d10d6f1b7 100644 --- a/builder/virtualbox/iso/builder_test.go +++ b/builder/virtualbox/iso/builder_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -132,7 +133,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/virtualbox/ovf/config.go b/builder/virtualbox/ovf/config.go index 8b57166ff..84894027f 100644 --- a/builder/virtualbox/ovf/config.go +++ b/builder/virtualbox/ovf/config.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -123,7 +124,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...) if c.SourcePath == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required")) } if c.GuestAdditionsInterface == "" { diff --git a/builder/virtualbox/ovf/config_test.go b/builder/virtualbox/ovf/config_test.go index 707b2419e..562e4ead9 100644 --- a/builder/virtualbox/ovf/config_test.go +++ b/builder/virtualbox/ovf/config_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig(t *testing.T) map[string]interface{} { @@ -50,7 +50,7 @@ func TestNewConfig_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/virtualbox/vm/config.go b/builder/virtualbox/vm/config.go index b4940b97a..f587b54d3 100644 --- a/builder/virtualbox/vm/config.go +++ b/builder/virtualbox/vm/config.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -103,7 +104,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.CommConfig.Comm.Type)...) errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...) - if c.GuestAdditionsInterface == "" { c.GuestAdditionsInterface = "ide" } @@ -111,7 +111,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { log.Printf("PostShutdownDelay: %s", c.PostShutdownDelay) if c.VMName == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("vm_name is required")) } @@ -131,15 +131,15 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { driver, err := vboxcommon.NewDriver() if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed creating VirtualBox driver: %s", err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed creating VirtualBox driver: %s", err)) } else { if c.AttachSnapshot != "" && c.TargetSnapshot != "" && c.AttachSnapshot == c.TargetSnapshot { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Attach snapshot %s and target snapshot %s cannot be the same", c.AttachSnapshot, c.TargetSnapshot)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Attach snapshot %s and target snapshot %s cannot be the same", c.AttachSnapshot, c.TargetSnapshot)) } snapshotTree, err := driver.LoadSnapshots(c.VMName) log.Printf("") if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed to load snapshots for VM %s: %s", c.VMName, err)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed to load snapshots for VM %s: %s", c.VMName, err)) } else { log.Printf("Snapshots loaded from VM %s", c.VMName) @@ -151,13 +151,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.AttachSnapshot != "" { log.Printf("Checking configuration attach_snapshot [%s]", c.AttachSnapshot) if nil == snapshotTree { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("No snapshots defined on VM %s. Unable to attach to %s", c.VMName, c.AttachSnapshot)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("No snapshots defined on VM %s. Unable to attach to %s", c.VMName, c.AttachSnapshot)) } else { snapshots := snapshotTree.GetSnapshotsByName(c.AttachSnapshot) if 0 >= len(snapshots) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Snapshot %s does not exist on VM %s", c.AttachSnapshot, c.VMName)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Snapshot %s does not exist on VM %s", c.AttachSnapshot, c.VMName)) } else if 1 < len(snapshots) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Multiple Snapshots with name %s exist on VM %s", c.AttachSnapshot, c.VMName)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Multiple Snapshots with name %s exist on VM %s", c.AttachSnapshot, c.VMName)) } else { attachSnapshot = snapshots[0] } @@ -169,7 +169,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { log.Printf("Currently no snapshots defined in VM %s", c.VMName) } else { if c.TargetSnapshot == attachSnapshot.Name { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s cannot be the same as the snapshot to which the builder shall attach: %s", c.TargetSnapshot, attachSnapshot.Name)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s cannot be the same as the snapshot to which the builder shall attach: %s", c.TargetSnapshot, attachSnapshot.Name)) } else { snapshots := snapshotTree.GetSnapshotsByName(c.TargetSnapshot) if 0 < len(snapshots) { @@ -182,9 +182,9 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { isChild = nil != snapshot.Parent && snapshot.Parent.UUID == attachSnapshot.UUID } if !isChild { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists and is not a direct child of %s", c.TargetSnapshot, attachSnapshot.Name)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists and is not a direct child of %s", c.TargetSnapshot, attachSnapshot.Name)) } else if !c.DeleteTargetSnapshot { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists as direct child of %s for VM %s. Use force_delete_snapshot = true to overwrite snapshot", + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists as direct child of %s for VM %s. Use force_delete_snapshot = true to overwrite snapshot", c.TargetSnapshot, attachSnapshot.Name, c.VMName)) diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go index 57cc59ec2..55f7fc757 100644 --- a/builder/vmware/iso/builder_test.go +++ b/builder/vmware/iso/builder_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -134,7 +135,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/vmware/iso/config.go b/builder/vmware/iso/config.go index fc6903576..4b7267ea8 100644 --- a/builder/vmware/iso/config.go +++ b/builder/vmware/iso/config.go @@ -10,10 +10,10 @@ import ( "strings" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -96,27 +96,27 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Accumulate any errors and warnings var warnings []string - var errs *packer.MultiError + var errs *packersdk.MultiError runConfigWarnings, runConfigErrs := c.RunConfig.Prepare(&c.ctx, &c.DriverConfig) warnings = append(warnings, runConfigWarnings...) - errs = packer.MultiErrorAppend(errs, runConfigErrs...) + errs = packersdk.MultiErrorAppend(errs, runConfigErrs...) isoWarnings, isoErrs := c.ISOConfig.Prepare(&c.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.HWConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VMXConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.HWConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VMXConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...) if c.DiskSize == 0 { c.DiskSize = 40000 @@ -134,7 +134,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.RemoteType == "esx5" { if c.DiskTypeId != "thin" && !c.SkipCompaction { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("skip_compaction must be 'true' for disk_type_id: %s", c.DiskTypeId)) } } @@ -153,7 +153,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.VMXTemplatePath != "" { if err := c.validateVMXTemplatePath(); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("vmx_template_path is invalid: %s", err)) } } else { @@ -191,13 +191,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err = c.DriverConfig.Validate(c.SkipExport) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if c.CdromAdapterType != "" { c.CdromAdapterType = strings.ToLower(c.CdromAdapterType) if c.CdromAdapterType != "ide" && c.CdromAdapterType != "sata" && c.CdromAdapterType != "scsi" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("cdrom_adapter_type must be one of ide, sata, or scsi")) } } diff --git a/builder/vmware/vmx/builder_test.go b/builder/vmware/vmx/builder_test.go index aaef376ac..48126aa96 100644 --- a/builder/vmware/vmx/builder_test.go +++ b/builder/vmware/vmx/builder_test.go @@ -7,7 +7,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestBuilderPrepare_FloppyFiles(t *testing.T) { @@ -62,7 +62,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) { t.Fatalf("Nonexistent floppies should trigger multierror") } - if len(errs.(*packer.MultiError).Errors) != 2 { + if len(errs.(*packersdk.MultiError).Errors) != 2 { t.Fatalf("Multierror should work and report 2 errors") } } diff --git a/builder/vmware/vmx/config.go b/builder/vmware/vmx/config.go index 0be17d7fb..eb4f950fb 100644 --- a/builder/vmware/vmx/config.go +++ b/builder/vmware/vmx/config.go @@ -8,10 +8,10 @@ import ( "os" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -81,30 +81,30 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Accumulate any errors and warnings var warnings []string - var errs *packer.MultiError + var errs *packersdk.MultiError runConfigWarnings, runConfigErrs := c.RunConfig.Prepare(&c.ctx, &c.DriverConfig) warnings = append(warnings, runConfigWarnings...) - errs = packer.MultiErrorAppend(errs, runConfigErrs...) - errs = packer.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, runConfigErrs...) + errs = packersdk.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...) if c.RemoteType == "" { if c.SourcePath == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required")) } else { if _, err := os.Stat(c.SourcePath); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is invalid: %s", err)) } } @@ -141,7 +141,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err = c.DriverConfig.Validate(c.SkipExport) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if c.ShutdownCommand == "" { diff --git a/builder/vsphere/clone/config.go b/builder/vsphere/clone/config.go index ced3d6d44..213420f41 100644 --- a/builder/vsphere/clone/config.go +++ b/builder/vsphere/clone/config.go @@ -6,9 +6,9 @@ package clone import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" packerCommon "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -67,33 +67,33 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // warnings := make([]string, 0) - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) - errs = packer.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.CloneConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.LocationConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.CloneConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.LocationConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) _, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm) // shutdownWarnings, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm) // warnings = append(warnings, shutdownWarnings...) - errs = packer.MultiErrorAppend(errs, shutdownErrs...) + errs = packersdk.MultiErrorAppend(errs, shutdownErrs...) if c.Export != nil { - errs = packer.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...) } if c.ContentLibraryDestinationConfig != nil { - errs = packer.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...) } if c.CustomizeConfig != nil { - errs = packer.MultiErrorAppend(errs, c.CustomizeConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.CustomizeConfig.Prepare()...) } if len(errs.Errors) > 0 { diff --git a/builder/vsphere/common/step_export.go b/builder/vsphere/common/step_export.go index 592644516..eba375ffd 100644 --- a/builder/vsphere/common/step_export.go +++ b/builder/vsphere/common/step_export.go @@ -17,7 +17,6 @@ import ( "strings" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -103,16 +102,16 @@ var sha = map[string]func() hash.Hash{ } func (c *ExportConfig) Prepare(ctx *interpolate.Context, lc *LocationConfig, pc *common.PackerConfig) []error { - var errs *packer.MultiError + var errs *packersdk.MultiError - errs = packer.MultiErrorAppend(errs, c.OutputDir.Prepare(ctx, pc)...) + errs = packersdk.MultiErrorAppend(errs, c.OutputDir.Prepare(ctx, pc)...) // manifest should default to sha256 if c.Manifest == "" { c.Manifest = "sha256" } if _, ok := sha[c.Manifest]; !ok { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("unknown hash: %s. available options include available options being 'none', 'sha1', 'sha256', 'sha512'", c.Manifest)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unknown hash: %s. available options include available options being 'none', 'sha1', 'sha256', 'sha512'", c.Manifest)) } if c.Name == "" { @@ -121,12 +120,12 @@ func (c *ExportConfig) Prepare(ctx *interpolate.Context, lc *LocationConfig, pc target := getTarget(c.OutputDir.OutputDir, c.Name) if !c.Force { if _, err := os.Stat(target); err == nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("file already exists: %s", target)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("file already exists: %s", target)) } } if err := os.MkdirAll(c.OutputDir.OutputDir, c.OutputDir.DirPerm); err != nil { - errs = packer.MultiErrorAppend(errs, errors.Wrap(err, "unable to make directory for export")) + errs = packersdk.MultiErrorAppend(errs, errors.Wrap(err, "unable to make directory for export")) } if errs != nil && len(errs.Errors) > 0 { diff --git a/builder/vsphere/common/step_import_to_content_library.go b/builder/vsphere/common/step_import_to_content_library.go index d80d620d1..dbd80f9fc 100644 --- a/builder/vsphere/common/step_import_to_content_library.go +++ b/builder/vsphere/common/step_import_to_content_library.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -67,10 +66,10 @@ type ContentLibraryDestinationConfig struct { } func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error { - var errs *packer.MultiError + var errs *packersdk.MultiError if c.Library == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("a library name must be provided")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a library name must be provided")) } if c.Ovf { @@ -79,7 +78,7 @@ func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error { } } else { if c.Name == lc.VMName { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("the content library destination name must be different from the VM name")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the content library destination name must be different from the VM name")) } if c.Name == "" { @@ -87,7 +86,7 @@ func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error { // otherwise vSphere won't be able to create the template which will be imported name, err := interpolate.Render(lc.VMName+"{{timestamp}}", nil) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to parse content library VM template name: %s", err)) } c.Name = name diff --git a/builder/vsphere/iso/config.go b/builder/vsphere/iso/config.go index 44d2acee1..0f5e153e0 100644 --- a/builder/vsphere/iso/config.go +++ b/builder/vsphere/iso/config.go @@ -6,9 +6,9 @@ package iso import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" packerCommon "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -68,35 +68,35 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } warnings := make([]string, 0) - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) if c.ISOUrls != nil || c.RawSingleISOUrl != "" { isoWarnings, isoErrs := c.ISOConfig.Prepare(&c.ctx) warnings = append(warnings, isoWarnings...) - errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packersdk.MultiErrorAppend(errs, isoErrs...) } - errs = packer.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.CreateConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.LocationConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.CreateConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.LocationConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...) - errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...) + errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) shutdownWarnings, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm) warnings = append(warnings, shutdownWarnings...) - errs = packer.MultiErrorAppend(errs, shutdownErrs...) + errs = packersdk.MultiErrorAppend(errs, shutdownErrs...) if c.Export != nil { - errs = packer.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...) } if c.ContentLibraryDestinationConfig != nil { - errs = packer.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...) } if len(errs.Errors) > 0 { diff --git a/builder/yandex/config.go b/builder/yandex/config.go index 37e75b60c..4a8b6ca1a 100644 --- a/builder/yandex/config.go +++ b/builder/yandex/config.go @@ -11,8 +11,8 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" @@ -130,13 +130,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError - errs = packer.MultiErrorAppend(errs, c.AccessConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.AccessConfig.Prepare(&c.ctx)...) if c.SerialLogFile != "" { if _, err := os.Stat(c.SerialLogFile); os.IsExist(err) { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Serial log file %s already exist", c.SerialLogFile)) } } @@ -162,7 +162,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.ImageMinDiskSizeGb < c.DiskSizeGb { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Invalid image_min_disk_size value (%d): Must be equal or greate than disk_size_gb (%d)", c.ImageMinDiskSizeGb, c.DiskSizeGb)) } @@ -174,7 +174,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.ImageName == "" { img, err := interpolate.Render("packer-{{timestamp}}", nil) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to render default image name: %s ", err)) } else { c.ImageName = img @@ -182,13 +182,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if len(c.ImageFamily) > 63 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Invalid image family: Must not be longer than 63 characters")) } if c.ImageFamily != "" { if !reImageFamily.MatchString(c.ImageFamily) { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Invalid image family: The first character must be a "+ "lowercase letter, and all following characters must be a dash, "+ "lowercase letter, or digit, except the last character, which cannot be a dash")) @@ -211,17 +211,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if es := c.Communicator.Prepare(&c.ctx); len(es) > 0 { - errs = packer.MultiErrorAppend(errs, es...) + errs = packersdk.MultiErrorAppend(errs, es...) } // Process required parameters. if c.SourceImageID == "" { if c.SourceImageFamily == "" && c.SourceImageName == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a source_image_name or source_image_family must be specified")) } if c.SourceImageFamily != "" && c.SourceImageName != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("one of source_image_name or source_image_family must be specified, not both")) } } @@ -239,7 +239,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if c.FolderID == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a folder_id must be specified")) } @@ -249,7 +249,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { for key, file := range c.MetadataFromFile { if _, err := os.Stat(file); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("cannot access file '%s' with content for value of metadata key '%s': %s", file, key, err)) } } diff --git a/packer/multi_error.go b/packer-plugin-sdk/packer/multi_error.go similarity index 100% rename from packer/multi_error.go rename to packer-plugin-sdk/packer/multi_error.go diff --git a/packer/multi_error_test.go b/packer-plugin-sdk/packer/multi_error_test.go similarity index 100% rename from packer/multi_error_test.go rename to packer-plugin-sdk/packer/multi_error_test.go diff --git a/packer-plugin-sdk/shell-local/config.go b/packer-plugin-sdk/shell-local/config.go index 9ee2d614d..ba68e6119 100644 --- a/packer-plugin-sdk/shell-local/config.go +++ b/packer-plugin-sdk/shell-local/config.go @@ -10,7 +10,7 @@ import ( "runtime" "strings" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/shell" configHelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -67,7 +67,7 @@ func Decode(config *Config, raws ...interface{}) error { } func Validate(config *Config) error { - var errs *packer.MultiError + var errs *packersdk.MultiError if runtime.GOOS == "windows" { if len(config.ExecuteCommand) == 0 { @@ -112,7 +112,7 @@ func Validate(config *Config) error { // Verify that the user has given us a command to run if config.Command == "" && len(config.Inline) == 0 && len(config.Scripts) == 0 && config.Script == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Command, Inline, Script and Scripts options cannot all be empty.")) } @@ -123,7 +123,7 @@ func Validate(config *Config) error { if config.Command != "" { if len(config.Inline) != 0 || len(config.Scripts) != 0 || config.Script != "" { - errs = packer.MultiErrorAppend(errs, tooManyOptionsErr) + errs = packersdk.MultiErrorAppend(errs, tooManyOptionsErr) } else { config.Inline = []string{config.Command} } @@ -131,20 +131,20 @@ func Validate(config *Config) error { if config.Script != "" { if len(config.Scripts) > 0 || len(config.Inline) > 0 { - errs = packer.MultiErrorAppend(errs, tooManyOptionsErr) + errs = packersdk.MultiErrorAppend(errs, tooManyOptionsErr) } else { config.Scripts = []string{config.Script} } } if len(config.Scripts) > 0 && config.Inline != nil { - errs = packer.MultiErrorAppend(errs, tooManyOptionsErr) + errs = packersdk.MultiErrorAppend(errs, tooManyOptionsErr) } // Check that all scripts we need to run exist locally for _, path := range config.Scripts { if _, err := os.Stat(path); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Bad script '%s': %s", path, err)) } } @@ -182,7 +182,7 @@ func Validate(config *Config) error { // Interoperability issues with WSL makes creating and running tempfiles // via golang's os package basically impossible. if len(config.Inline) > 0 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Packer is unable to use the Command and Inline "+ "features with the Windows Linux Subsystem. Please use "+ "the Script or Scripts options instead")) @@ -208,7 +208,7 @@ func Validate(config *Config) error { for _, kv := range config.Vars { vs := strings.SplitN(kv, "=", 2) if len(vs) != 2 || vs[0] == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Environment variable not in format 'key=value': %s", kv)) } } diff --git a/packer/build.go b/packer/build.go index 28313ee27..289b7c9f3 100644 --- a/packer/build.go +++ b/packer/build.go @@ -412,7 +412,7 @@ PostProcessorRunSeqLoop: } if len(errors) > 0 { - err = &MultiError{errors} + err = &packersdk.MultiError{errors} } return artifacts, err diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index c838191b3..8979be0a0 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -130,18 +130,18 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return err } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) // Check and render oss_key_name if err = interpolate.Validate(p.config.OSSKey, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing oss_key_name template: %s", err)) } - errs = packer.MultiErrorAppend(errs, p.config.AlicloudImageTag.CopyOn(&p.config.AlicloudImageTags)...) + errs = packersdk.MultiErrorAppend(errs, p.config.AlicloudImageTag.CopyOn(&p.config.AlicloudImageTags)...) // Check we have alicloud access variables defined somewhere - errs = packer.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...) // define all our required parameters templates := map[string]*string{ @@ -150,7 +150,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Check out required params are defined for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index 5d866fab4..a8b85d3f9 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -82,16 +82,16 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { p.config.S3Key = "packer-import-{{timestamp}}." + p.config.Format } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) // Check and render s3_key_name if err = interpolate.Validate(p.config.S3Key, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing s3_key_name template: %s", err)) } // Check we have AWS access variables defined somewhere - errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) // define all our required parameters templates := map[string]*string{ @@ -100,7 +100,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Check out required params are defined for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } @@ -108,12 +108,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { switch p.config.Format { case "ova", "raw", "vmdk", "vhd", "vhdx": default: - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("invalid format '%s'. Only 'ova', 'raw', 'vhd', 'vhdx', or 'vmdk' are allowed", p.config.Format)) } if p.config.S3Encryption != "" && p.config.S3Encryption != "AES256" && p.config.S3Encryption != "aws:kms" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("invalid s3 encryption format '%s'. Only 'AES256' and 'aws:kms' are allowed", p.config.S3Encryption)) } diff --git a/post-processor/checksum/post-processor.go b/post-processor/checksum/post-processor.go index df0fea928..ff5e58cc3 100644 --- a/post-processor/checksum/post-processor.go +++ b/post-processor/checksum/post-processor.go @@ -67,7 +67,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { if err != nil { return err } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) if p.config.ChecksumTypes == nil { p.config.ChecksumTypes = []string{"md5"} @@ -75,7 +75,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { for _, k := range p.config.ChecksumTypes { if h := getHash(k); h == nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unrecognized checksum type: %s", k)) } } @@ -85,7 +85,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } if err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing target template: %s", err)) } diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index a0ffa700b..e30c723e0 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -71,7 +71,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return err } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) // If there is no explicit number of Go threads to use, then set it if os.Getenv("GOMAXPROCS") == "" { @@ -93,7 +93,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } if err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing target template: %s", err)) } diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index 9f7898829..9fb14ba6c 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -113,10 +113,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { p.config.Timeout = 20 * time.Minute } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) if err = interpolate.Validate(p.config.ObjectName, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing space_object_name template: %s", err)) } @@ -130,13 +130,13 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } for key, ptr := range requiredArgs { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } if len(p.config.ImageRegions) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("image_regions must be set")) } diff --git a/post-processor/exoscale-import/post-processor.go b/post-processor/exoscale-import/post-processor.go index 12ff896d4..7ff1fb4f8 100644 --- a/post-processor/exoscale-import/post-processor.go +++ b/post-processor/exoscale-import/post-processor.go @@ -89,10 +89,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { "template_description": &p.config.TemplateDescription, } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) for k, v := range requiredArgs { if *v == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", k)) } } diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index 1100f2c89..9c69d93e1 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -82,10 +82,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return err } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) if len(p.config.Paths) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("paths must be specified")) } @@ -107,7 +107,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } if p.config.AccountFile != "" && p.config.VaultGCPOauthEngine != "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("May set either account_file or "+ "vault_gcp_oauth_engine, but not both.")) } diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index fedacfd85..d96157702 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -100,7 +100,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return err } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) // Set defaults if p.config.GCSObjectName == "" { @@ -109,18 +109,18 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Check and render gcs_object_name if err = interpolate.Validate(p.config.GCSObjectName, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing gcs_object_name template: %s", err)) } if p.config.AccountFile != "" { if p.config.VaultGCPOauthEngine != "" && p.config.ImpersonateServiceAccount != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("You cannot "+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You cannot "+ "specify impersonate_service_account, account_file and vault_gcp_oauth_engine at the same time")) } cfg, err := googlecompute.ProcessAccountFile(p.config.AccountFile) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } p.config.account = cfg } @@ -132,7 +132,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index ccb9a8897..b11ef97a9 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -106,16 +106,16 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { p.config.WaitImageReadyTimeout = ucloudcommon.DefaultCreateImageTimeout } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) // Check and render ufile_key_name if err = interpolate.Validate(p.config.UFileKey, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing ufile_key_name template: %s", err)) } // Check we have ucloud access variables defined somewhere - errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) // define all our required parameters templates := map[string]*string{ @@ -128,20 +128,20 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Check out required params are defined for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } imageName := p.config.ImageName if !ucloudcommon.ImageNamePattern.MatchString(imageName) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("expected %q to be 1-63 characters and only support chinese, english, numbers, '-_,.:[]', got %q", "image_name", imageName)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("expected %q to be 1-63 characters and only support chinese, english, numbers, '-_,.:[]', got %q", "image_name", imageName)) } switch p.config.Format { case ImageFileFormatVHD, ImageFileFormatRAW, ImageFileFormatVMDK, ImageFileFormatQCOW2: default: - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("expected %q only be one of 'raw', 'vhd', 'vmdk', or 'qcow2', got %q", "format", p.config.Format)) } diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index 2271a2211..34a3cf2d1 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -97,7 +97,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } // Accumulate any errors - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) // Required configuration templates := map[string]*string{ @@ -107,19 +107,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } if p.config.VagrantCloudUrl == VAGRANT_CLOUD_URL && p.config.AccessToken == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("access_token must be set if vagrant_cloud_url has not been overriden")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("access_token must be set if vagrant_cloud_url has not been overriden")) } // Create the HTTP client p.client, err = VagrantCloudClient{}.New(p.config.VagrantCloudUrl, p.config.AccessToken, p.insecureSkipTLSVerify) if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Failed to verify authentication token: %v", err)) } diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index e82925da5..bd8e61f45 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -272,11 +272,11 @@ func (p *PostProcessor) configureSingle(c *Config, raws ...interface{}) error { c.CompressionLevel = flate.DefaultCompression } - var errs *packer.MultiError + var errs *packersdk.MultiError if c.VagrantfileTemplate != "" && c.VagrantfileTemplateGenerated == false { _, err := os.Stat(c.VagrantfileTemplate) if err != nil { - errs = packer.MultiErrorAppend(errs, fmt.Errorf( + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf( "vagrantfile_template '%s' does not exist", c.VagrantfileTemplate)) } } diff --git a/post-processor/vsphere-template/post-processor.go b/post-processor/vsphere-template/post-processor.go index 6e2661951..fdb451ba9 100644 --- a/post-processor/vsphere-template/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -69,7 +69,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return err } - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) vc := map[string]*string{ "host": &p.config.Host, "username": &p.config.Username, @@ -78,19 +78,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { for key, ptr := range vc { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } if p.config.Folder != "" && !strings.HasPrefix(p.config.Folder, "/") { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Folder must be bound to the root")) } sdk, err := url.Parse(fmt.Sprintf("https://%v/sdk", p.config.Host)) if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error invalid vSphere sdk endpoint: %s", err)) return errs } diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index ae617c66e..1136e765e 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -82,14 +82,14 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } // Accumulate any errors - errs := new(packer.MultiError) + errs := new(packersdk.MultiError) if runtime.GOOS == "windows" { ovftool = "ovftool.exe" } if _, err := exec.LookPath(ovftool); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("ovftool not found: %s", err)) } @@ -105,7 +105,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index 0a0cda0d7..b0a7c6f81 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -83,19 +83,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError - errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) if len(p.config.Paths) == 0 { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("paths must be specified")) } // Validate templates in 'paths' for _, path := range p.config.Paths { if err = interpolate.Validate(path, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error parsing one of 'paths' template: %s", err)) } } diff --git a/post-processor/yandex-import/post-processor.go b/post-processor/yandex-import/post-processor.go index f1c52147b..a346e20a7 100644 --- a/post-processor/yandex-import/post-processor.go +++ b/post-processor/yandex-import/post-processor.go @@ -82,9 +82,9 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } // Accumulate any errors - var errs *packer.MultiError + var errs *packersdk.MultiError - errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...) if p.config.FolderID == "" { p.config.FolderID = os.Getenv("YC_FOLDER_ID") @@ -97,7 +97,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Check and render object_name if err = interpolate.Validate(p.config.ObjectName, &p.config.ctx); err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("error parsing object_name template: %s", err)) } @@ -110,7 +110,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { for key, ptr := range templates { if *ptr == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } } diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index e98889833..2e44ffbb6 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -110,29 +110,29 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } // Validation - var errs *packer.MultiError + var errs *packersdk.MultiError // Check that either playbook_file or playbook_files is specified if len(p.config.PlaybookFiles) != 0 && p.config.PlaybookFile != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Either playbook_file or playbook_files can be specified, not both")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Either playbook_file or playbook_files can be specified, not both")) } if len(p.config.PlaybookFiles) == 0 && p.config.PlaybookFile == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Either playbook_file or playbook_files must be specified")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Either playbook_file or playbook_files must be specified")) } if p.config.PlaybookFile != "" { err = validateFileConfig(p.config.PlaybookFile, "playbook_file", true) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } for _, playbookFile := range p.config.PlaybookFiles { if err := validateFileConfig(playbookFile, "playbook_files", true); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } else { playbookFile, err := filepath.Abs(playbookFile) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } else { p.playbookFiles = append(p.playbookFiles, playbookFile) } @@ -143,7 +143,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { if len(p.config.InventoryFile) > 0 { err = validateFileConfig(p.config.InventoryFile, "inventory_file", true) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -151,40 +151,40 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { if len(p.config.GalaxyFile) > 0 { err = validateFileConfig(p.config.GalaxyFile, "galaxy_file", true) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } // Check that the playbook_dir directory exists, if configured if len(p.config.PlaybookDir) > 0 { if err := validateDirConfig(p.config.PlaybookDir, "playbook_dir"); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } // Check that the group_vars directory exists, if configured if len(p.config.GroupVars) > 0 { if err := validateDirConfig(p.config.GroupVars, "group_vars"); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } // Check that the host_vars directory exists, if configured if len(p.config.HostVars) > 0 { if err := validateDirConfig(p.config.HostVars, "host_vars"); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } for _, path := range p.config.PlaybookPaths { err := validateDirConfig(path, "playbook_paths") if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } for _, path := range p.config.RolePaths { if err := validateDirConfig(path, "role_paths"); err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 67701f0fe..c58c99b51 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -251,17 +251,17 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.HostAlias = "default" } - var errs *packer.MultiError + var errs *packersdk.MultiError err = validateFileConfig(p.config.PlaybookFile, "playbook_file", true) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } // Check that the galaxy file exists, if configured if len(p.config.GalaxyFile) > 0 { err = validateFileConfig(p.config.GalaxyFile, "galaxy_file", true) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -270,14 +270,14 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { err = validateFileConfig(p.config.SSHAuthorizedKeyFile, "ssh_authorized_key_file", true) if err != nil { log.Println(p.config.SSHAuthorizedKeyFile, "does not exist") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if len(p.config.SSHHostKeyFile) > 0 { err = validateFileConfig(p.config.SSHHostKeyFile, "ssh_host_key_file", true) if err != nil { log.Println(p.config.SSHHostKeyFile, "does not exist") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } else { p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "ANSIBLE_HOST_KEY_CHECKING=False") @@ -288,21 +288,21 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if p.config.LocalPort > 65535 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("local_port: %d must be a valid port", p.config.LocalPort)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("local_port: %d must be a valid port", p.config.LocalPort)) } if len(p.config.InventoryDirectory) > 0 { err = validateInventoryDirectoryConfig(p.config.InventoryDirectory) if err != nil { log.Println(p.config.InventoryDirectory, "does not exist") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if !p.config.SkipVersionCheck { err = p.getVersion() if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -310,13 +310,13 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.userWasEmpty = true usr, err := user.Current() if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } else { p.config.User = usr.Username } } if p.config.User == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment.")) } // These fields exist so that we can replace the functions for testing diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index 13e2b2db6..87167e6e6 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -178,20 +178,20 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.KnifeCommand = p.guestOSTypeConfig.knifeCommand } - var errs *packer.MultiError + var errs *packersdk.MultiError if p.config.ConfigTemplate != "" { fi, err := os.Stat(p.config.ConfigTemplate) if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad config template path: %s", err)) } else if fi.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Config template path must be a file: %s", err)) } } if p.config.ServerUrl == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("server_url must be set")) } @@ -205,20 +205,20 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { pFileInfo, err := os.Stat(p.config.EncryptedDataBagSecretPath) if err != nil || pFileInfo.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad encrypted data bag secret '%s': %s", p.config.EncryptedDataBagSecretPath, err)) } } if (p.config.PolicyName != "") != (p.config.PolicyGroup != "") { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If either policy_name or policy_group are set, they must both be set.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If either policy_name or policy_group are set, they must both be set.")) } jsonValid := true for k, v := range p.config.Json { p.config.Json[k], err = p.deepJsonFix(k, v) if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error processing JSON: %s", err)) jsonValid = false } @@ -229,7 +229,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { // Do this early so that we can validate and show errors. p.config.Json, err = p.processJsonUserVars() if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error processing user variables in JSON: %s", err)) } } diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 61b4f3695..0bb4bcec1 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -159,14 +159,14 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } } - var errs *packer.MultiError + var errs *packersdk.MultiError if p.config.ConfigTemplate != "" { fi, err := os.Stat(p.config.ConfigTemplate) if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad config template path: %s", err)) } else if fi.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Config template path must be a file: %s", err)) } } @@ -175,7 +175,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { pFileInfo, err := os.Stat(path) if err != nil || !pFileInfo.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad cookbook path '%s': %s", path, err)) } } @@ -184,7 +184,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { pFileInfo, err := os.Stat(p.config.RolesPath) if err != nil || !pFileInfo.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad roles path '%s': %s", p.config.RolesPath, err)) } } @@ -193,7 +193,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { pFileInfo, err := os.Stat(p.config.DataBagsPath) if err != nil || !pFileInfo.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad data bags path '%s': %s", p.config.DataBagsPath, err)) } } @@ -202,7 +202,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { pFileInfo, err := os.Stat(p.config.EncryptedDataBagSecretPath) if err != nil || pFileInfo.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad encrypted data bag secret '%s': %s", p.config.EncryptedDataBagSecretPath, err)) } } @@ -211,7 +211,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { pFileInfo, err := os.Stat(p.config.EnvironmentsPath) if err != nil || !pFileInfo.IsDir() { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Bad environments path '%s': %s", p.config.EnvironmentsPath, err)) } } @@ -220,7 +220,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { for k, v := range p.config.Json { p.config.Json[k], err = p.deepJsonFix(k, v) if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error processing JSON: %s", err)) jsonValid = false } @@ -231,7 +231,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { // Do this early so that we can validate and show errors. p.config.Json, err = p.processJsonUserVars() if err != nil { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("Error processing user variables in JSON: %s", err)) } } diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 60a267291..b7f493a74 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -84,10 +84,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.Direction = "upload" } - var errs *packer.MultiError + var errs *packersdk.MultiError if p.config.Direction != "download" && p.config.Direction != "upload" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Direction must be one of: download, upload.")) } if p.config.Source != "" { @@ -97,19 +97,19 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { if p.config.Direction == "upload" { for _, src := range p.config.Sources { if _, err := os.Stat(src); p.config.Generated == false && err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Bad source '%s': %s", src, err)) } } } if len(p.config.Sources) < 1 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Source must be specified.")) } if p.config.Destination == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Destination must be specified.")) } diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index 3bf669088..8897f8a95 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -96,10 +96,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.SubCommand = "exec" } - var errs *packer.MultiError + var errs *packersdk.MultiError err = validateProfileConfig(p.config.Profile) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } // Check that the authorized key file exists @@ -107,14 +107,14 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { err = validateFileConfig(p.config.SSHAuthorizedKeyFile, "ssh_authorized_key_file", true) if err != nil { log.Println(p.config.SSHAuthorizedKeyFile, "does not exist") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if len(p.config.SSHHostKeyFile) > 0 { err = validateFileConfig(p.config.SSHHostKeyFile, "ssh_host_key_file", true) if err != nil { log.Println(p.config.SSHHostKeyFile, "does not exist") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } @@ -123,11 +123,11 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if _, ok := SupportedBackends[p.config.Backend]; !ok { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("backend: %s must be a valid backend", p.config.Backend)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("backend: %s must be a valid backend", p.config.Backend)) } if p.config.Backend == "docker" && p.config.Host == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("backend: host must be specified for docker backend")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("backend: host must be specified for docker backend")) } if p.config.Host == "" { @@ -135,27 +135,27 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if p.config.LocalPort > 65535 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("local_port: %d must be a valid port", p.config.LocalPort)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("local_port: %d must be a valid port", p.config.LocalPort)) } if len(p.config.AttributesDirectory) > 0 { err = validateDirectoryConfig(p.config.AttributesDirectory, "attrs") if err != nil { log.Println(p.config.AttributesDirectory, "does not exist") - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } } if p.config.User == "" { usr, err := user.Current() if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } else { p.config.User = usr.Username } } if p.config.User == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment.")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment.")) } if errs != nil && len(errs.Errors) > 0 { diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 368a6ec6d..d6ea048de 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -180,12 +180,12 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { var errs error if p.config.Script != "" && len(p.config.Scripts) > 0 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of script or scripts can be specified.")) } if p.config.ElevatedUser == "" && p.config.ElevatedPassword != "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Must supply an 'elevated_user' if 'elevated_password' provided")) } @@ -194,16 +194,16 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if len(p.config.Scripts) == 0 && p.config.Inline == nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Either a script file or inline script must be specified.")) } else if len(p.config.Scripts) > 0 && p.config.Inline != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Only a script file or an inline script can be specified, not both.")) } for _, path := range p.config.Scripts { if _, err := os.Stat(path); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Bad script '%s': %s", path, err)) } } @@ -212,20 +212,20 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { for _, kv := range p.config.Vars { vs := strings.SplitN(kv, "=", 2) if len(vs) != 2 || vs[0] == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Environment variable not in format 'key=value': %s", kv)) } } if p.config.ExecutionPolicy > 7 { - errs = packer.MultiErrorAppend(errs, fmt.Errorf(`Invalid execution `+ + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(`Invalid execution `+ `policy provided. Please supply one of: "bypass", "allsigned",`+ ` "default", "remotesigned", "restricted", "undefined", `+ `"unrestricted", "none".`)) } if !(p.config.DebugMode >= 0 && p.config.DebugMode <= 2) { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("%d is an invalid Trace level for `debug_mode`; valid values are 0, 1, and 2", p.config.DebugMode)) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%d is an invalid Trace level for `debug_mode`; valid values are 0, 1, and 2", p.config.DebugMode)) } if errs != nil { diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index c982915b4..46aa413e9 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -206,14 +206,14 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.Facter["packer_builder_type"] = p.config.PackerBuilderType // Validation - var errs *packer.MultiError + var errs *packersdk.MultiError if p.config.HieraConfigPath != "" { info, err := os.Stat(p.config.HieraConfigPath) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("hiera_config_path is invalid: %s", err)) } else if info.IsDir() { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("hiera_config_path must point to a file")) } } @@ -221,21 +221,21 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { if p.config.ManifestDir != "" { info, err := os.Stat(p.config.ManifestDir) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("manifest_dir is invalid: %s", err)) } else if !info.IsDir() { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("manifest_dir must point to a directory")) } } if p.config.ManifestFile == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A manifest_file must be specified.")) } else { _, err := os.Stat(p.config.ManifestFile) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("manifest_file is invalid: %s", err)) } } @@ -243,10 +243,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { for i, path := range p.config.ModulePaths { info, err := os.Stat(path) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("module_path[%d] is invalid: %s", i, err)) } else if !info.IsDir() { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("module_path[%d] must point to a directory", i)) } } diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index 923a7e62d..fa9004a59 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -198,14 +198,14 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.Facter["packer_build_name"] = p.config.PackerBuildName p.config.Facter["packer_builder_type"] = p.config.PackerBuilderType - var errs *packer.MultiError + var errs *packersdk.MultiError if p.config.ClientCertPath != "" { info, err := os.Stat(p.config.ClientCertPath) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_cert_dir is invalid: %s", err)) } else if !info.IsDir() { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_cert_dir must point to a directory")) } } @@ -213,10 +213,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { if p.config.ClientPrivateKeyPath != "" { info, err := os.Stat(p.config.ClientPrivateKeyPath) if err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_private_key_dir is invalid: %s", err)) } else if !info.IsDir() { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_private_key_dir must point to a directory")) } } diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index b1631de4b..2346ac263 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -151,40 +151,40 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.TempConfigDir = p.guestOSTypeConfig.tempDir } - var errs *packer.MultiError + var errs *packersdk.MultiError // require a salt state tree err = validateDirConfig(p.config.LocalStateTree, "local_state_tree", true) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if p.config.Formulas != nil && len(p.config.Formulas) > 0 { validURLs := hasValidFormulaURLs(p.config.Formulas) if !validURLs { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Invalid formula URL. Please verify the git URLs also contain a '//' subdir")) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Invalid formula URL. Please verify the git URLs also contain a '//' subdir")) } } err = validateDirConfig(p.config.LocalPillarRoots, "local_pillar_roots", false) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } err = validateFileConfig(p.config.MinionConfig, "minion_config", false) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } if p.config.MinionConfig != "" && (p.config.RemoteStateTree != "" || p.config.RemotePillarRoots != "") { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("remote_state_tree and remote_pillar_roots only apply when minion_config is not used")) } err = validateFileConfig(p.config.GrainsFile, "grains_file", false) if err != nil { - errs = packer.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } // build the command line args to pass onto salt diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 189eec479..6f0d0ce6d 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -137,9 +137,9 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.Vars = make([]string, 0) } - var errs *packer.MultiError + var errs *packersdk.MultiError if p.config.Script != "" && len(p.config.Scripts) > 0 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of script or scripts can be specified.")) } @@ -148,16 +148,16 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if len(p.config.Scripts) == 0 && p.config.Inline == nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Either a script file or inline script must be specified.")) } else if len(p.config.Scripts) > 0 && p.config.Inline != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Only a script file or an inline script can be specified, not both.")) } for _, path := range p.config.Scripts { if _, err := os.Stat(path); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Bad script '%s': %s", path, err)) } } @@ -166,7 +166,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { for _, kv := range p.config.Vars { vs := strings.SplitN(kv, "=", 2) if len(vs) != 2 || vs[0] == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Environment variable not in format 'key=value': %s", kv)) } } diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index ec0a765cf..0a46d7833 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -99,7 +99,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { var errs error if p.config.Script != "" && len(p.config.Scripts) > 0 { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of script or scripts can be specified.")) } @@ -108,16 +108,16 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if len(p.config.Scripts) == 0 && p.config.Inline == nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Either a script file or inline script must be specified.")) } else if len(p.config.Scripts) > 0 && p.config.Inline != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, errors.New("Only a script file or an inline script can be specified, not both.")) } for _, path := range p.config.Scripts { if _, err := os.Stat(path); err != nil { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Bad script '%s': %s", path, err)) } } @@ -126,7 +126,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { for _, kv := range p.config.Vars { vs := strings.SplitN(kv, "=", 2) if len(vs) != 2 || vs[0] == "" { - errs = packer.MultiErrorAppend(errs, + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Environment variable not in format 'key=value': %s", kv)) } } From 14bdb9516c8f7423c1d93c017cd1a224779c7276 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Nov 2020 12:17:11 -0800 Subject: [PATCH 03/10] move Artifact and artifact mock to the sdk --- builder/alicloud/ecs/artifact_test.go | 4 +-- builder/alicloud/ecs/builder.go | 2 +- builder/alicloud/ecs/builder_acc_test.go | 18 +++++------ builder/amazon/chroot/builder.go | 2 +- builder/amazon/common/artifact_test.go | 4 +-- builder/amazon/ebs/builder.go | 2 +- builder/amazon/ebs/builder_acc_test.go | 10 +++--- builder/amazon/ebs/tags_acc_test.go | 4 +-- builder/amazon/ebssurrogate/builder.go | 2 +- builder/amazon/ebsvolume/builder.go | 2 +- builder/amazon/instance/builder.go | 2 +- builder/azure/arm/builder.go | 2 +- builder/azure/chroot/builder.go | 2 +- builder/azure/dtl/builder.go | 2 +- builder/cloudstack/artifact_test.go | 6 ++-- builder/cloudstack/builder.go | 2 +- builder/digitalocean/artifact_test.go | 4 +-- builder/digitalocean/builder.go | 2 +- builder/docker/artifact_export_test.go | 4 +-- builder/docker/artifact_import_test.go | 4 +-- builder/docker/builder.go | 4 +-- builder/file/artifact_test.go | 4 +-- builder/file/builder.go | 2 +- builder/file/builder_test.go | 5 +-- builder/googlecompute/artifact_test.go | 4 +-- builder/googlecompute/builder.go | 4 +-- builder/hcloud/artifact_test.go | 4 +-- builder/hcloud/builder.go | 2 +- builder/hyperone/builder.go | 2 +- builder/hyperv/common/artifact.go | 4 +-- builder/hyperv/common/artifact_test.go | 4 +-- builder/hyperv/iso/builder.go | 4 +-- builder/hyperv/vmcx/builder.go | 4 +-- builder/jdcloud/builder.go | 2 +- builder/linode/artifact_test.go | 4 +-- builder/linode/builder.go | 2 +- builder/lxc/builder.go | 2 +- builder/lxd/builder.go | 2 +- builder/ncloud/builder.go | 2 +- builder/null/artifact_export_test.go | 4 +-- builder/null/builder.go | 2 +- builder/oneandone/builder.go | 2 +- builder/openstack/artifact_test.go | 4 +-- builder/openstack/builder.go | 2 +- builder/oracle/classic/builder.go | 2 +- builder/oracle/oci/artifact_test.go | 4 +-- builder/oracle/oci/builder.go | 2 +- builder/osc/bsu/builder.go | 2 +- builder/osc/bsusurrogate/builder.go | 2 +- builder/osc/bsuvolume/builder.go | 2 +- builder/osc/chroot/builder.go | 2 +- builder/parallels/common/artifact.go | 4 +-- builder/parallels/common/artifact_test.go | 4 +-- builder/parallels/iso/builder.go | 2 +- builder/parallels/pvm/builder.go | 4 +-- builder/profitbricks/artifact_test.go | 4 +-- builder/profitbricks/builder.go | 2 +- builder/proxmox/clone/builder.go | 2 +- builder/proxmox/common/artifact.go | 6 ++-- builder/proxmox/common/builder.go | 2 +- builder/proxmox/iso/builder.go | 2 +- builder/qemu/builder.go | 2 +- builder/scaleway/artifact_test.go | 4 +-- builder/scaleway/builder.go | 2 +- builder/tencentcloud/cvm/builder.go | 2 +- builder/triton/builder.go | 2 +- builder/ucloud/common/artifact_test.go | 4 +-- builder/ucloud/uhost/builder.go | 2 +- builder/ucloud/uhost/builder_acc_test.go | 4 +-- builder/vagrant/artifact.go | 4 +-- builder/vagrant/artifact_test.go | 6 ++-- builder/vagrant/builder.go | 4 +-- builder/virtualbox/common/artifact.go | 4 +-- builder/virtualbox/common/artifact_test.go | 4 +-- builder/virtualbox/iso/builder.go | 2 +- builder/virtualbox/ovf/builder.go | 4 +-- builder/virtualbox/vm/builder.go | 4 +-- builder/vmware/common/artifact.go | 4 +-- builder/vmware/common/artifact_test.go | 4 +-- builder/vmware/iso/builder.go | 2 +- builder/vmware/vmx/builder.go | 4 +-- builder/vsphere/clone/builder.go | 2 +- builder/vsphere/clone/builder_acc_test.go | 32 +++++++++---------- builder/vsphere/common/testing/utility.go | 4 +-- builder/vsphere/iso/builder.go | 2 +- builder/vsphere/iso/builder_acc_test.go | 18 +++++------ builder/yandex/artifact_test.go | 4 +-- builder/yandex/builder.go | 4 +-- command/build.go | 4 +-- command/build_parallel_test.go | 4 +-- hcl2template/internal/mock.go | 4 +-- hcl2template/types.hcl_post-processor.go | 2 +- helper/builder/testing/testing.go | 3 +- .../packer}/artifact.go | 0 .../packer}/artifact_mock.go | 0 .../packer}/artifact_test.go | 0 packer/build.go | 6 ++-- packer/builder.go | 2 +- packer/builder_mock.go | 4 +-- packer/builder_mock.hcl2spec.go | 20 ++++++------ packer/plugin/builder.go | 2 +- packer/plugin/post_processor.go | 2 +- packer/plugin/post_processor_test.go | 3 +- packer/post_processor.go | 2 +- packer/post_processor_mock.go | 6 ++-- packer/rpc/artifact.go | 8 ++--- packer/rpc/artifact_test.go | 3 +- packer/rpc/build.go | 4 +-- packer/rpc/build_test.go | 4 +-- packer/rpc/builder.go | 2 +- packer/rpc/client.go | 2 +- packer/rpc/post_processor.go | 2 +- packer/rpc/post_processor_test.go | 4 +-- packer/rpc/server.go | 2 +- .../alicloud-import/post-processor.go | 2 +- .../amazon-import/post-processor.go | 2 +- post-processor/artifice/post-processor.go | 3 +- post-processor/checksum/post-processor.go | 3 +- .../checksum/post-processor_test.go | 4 +-- post-processor/compress/artifact_test.go | 4 +-- post-processor/compress/post-processor.go | 5 ++- .../compress/post-processor_test.go | 4 +-- .../digitalocean-import/post-processor.go | 2 +- .../docker-import/post-processor.go | 3 +- post-processor/docker-push/post-processor.go | 3 +- .../docker-push/post-processor_test.go | 7 ++-- post-processor/docker-save/post-processor.go | 3 +- post-processor/docker-tag/post-processor.go | 3 +- .../docker-tag/post-processor_test.go | 7 ++-- .../exoscale-import/post-processor.go | 6 ++-- .../googlecompute-export/post-processor.go | 3 +- .../googlecompute-import/artifact_test.go | 4 +-- .../googlecompute-import/post-processor.go | 9 ++++-- post-processor/manifest/post-processor.go | 3 +- post-processor/shell-local/post-processor.go | 3 +- .../ucloud-import/post-processor.go | 2 +- post-processor/vagrant-cloud/artifact_test.go | 4 +-- .../vagrant-cloud/post-processor.go | 3 +- post-processor/vagrant/artifact_test.go | 4 +-- post-processor/vagrant/aws.go | 3 +- post-processor/vagrant/azure.go | 3 +- post-processor/vagrant/digitalocean.go | 3 +- post-processor/vagrant/docker.go | 3 +- post-processor/vagrant/google.go | 3 +- post-processor/vagrant/hyperv.go | 3 +- post-processor/vagrant/libvirt.go | 3 +- post-processor/vagrant/lxc.go | 3 +- post-processor/vagrant/parallels.go | 3 +- post-processor/vagrant/post-processor.go | 5 ++- post-processor/vagrant/provider.go | 3 +- post-processor/vagrant/scaleway.go | 3 +- post-processor/vagrant/virtualbox.go | 3 +- post-processor/vagrant/vmware.go | 3 +- .../vsphere-template/post-processor.go | 3 +- .../vsphere-template/step_create_snapshot.go | 3 +- .../vsphere-template/step_mark_as_template.go | 3 +- post-processor/vsphere/artifact_test.go | 4 +-- post-processor/vsphere/post-processor.go | 2 +- .../yandex-export/post-processor.go | 3 +- .../yandex-import/post-processor.go | 5 ++- post-processor/yandex-import/utils.go | 3 +- 161 files changed, 287 insertions(+), 311 deletions(-) rename {packer => packer-plugin-sdk/packer}/artifact.go (100%) rename {packer => packer-plugin-sdk/packer}/artifact_mock.go (100%) rename {packer => packer-plugin-sdk/packer}/artifact_test.go (100%) diff --git a/builder/alicloud/ecs/artifact_test.go b/builder/alicloud/ecs/artifact_test.go index 44e56531a..3038431da 100644 --- a/builder/alicloud/ecs/artifact_test.go +++ b/builder/alicloud/ecs/artifact_test.go @@ -4,11 +4,11 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { - var _ packer.Artifact = new(Artifact) + var _ packersdk.Artifact = new(Artifact) } func TestArtifactId(t *testing.T) { diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 4ee4d2806..160fd734a 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -81,7 +81,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/alicloud/ecs/builder_acc_test.go b/builder/alicloud/ecs/builder_acc_test.go index 7689cfd38..4de4c5741 100644 --- a/builder/alicloud/ecs/builder_acc_test.go +++ b/builder/alicloud/ecs/builder_acc_test.go @@ -9,7 +9,7 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" builderT "github.com/hashicorp/packer/helper/builder/testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const defaultTestRegion = "cn-beijing" @@ -104,7 +104,7 @@ const testBuilderAccWithDiskSettings = ` }` func checkImageDisksSettings() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -215,7 +215,7 @@ const testBuilderAccIgnoreDataDisks = ` }` func checkIgnoreDataDisks() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -308,7 +308,7 @@ const testBuilderAccRegionCopy = ` ` func checkRegionCopy(regions []string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -438,7 +438,7 @@ const testBuilderAccSharing = ` ` func checkECSImageSharing(uid string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -534,7 +534,7 @@ const testBuilderAccForceDeleteSnapshot = ` ` func checkSnapshotsDeleted(snapshotIds []string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { // Verify the snapshots are gone client, _ := testAliyunClient() data, err := json.Marshal(snapshotIds) @@ -587,7 +587,7 @@ const testBuilderAccImageTags = ` }` func checkImageTags() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -716,7 +716,7 @@ const testBuilderAccDataDiskEncrypted = ` }` func checkDataDiskEncrypted() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -815,7 +815,7 @@ const testBuilderAccSystemDiskEncrypted = ` }` func checkSystemDiskEncrypted() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 48cfb7351..5fdb9f315 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -346,7 +346,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The amazon-chroot builder only works on Linux environments.") } diff --git a/builder/amazon/common/artifact_test.go b/builder/amazon/common/artifact_test.go index 1add5f036..927e9a7ab 100644 --- a/builder/amazon/common/artifact_test.go +++ b/builder/amazon/common/artifact_test.go @@ -4,11 +4,11 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { - var _ packer.Artifact = new(Artifact) + var _ packersdk.Artifact = new(Artifact) } func TestArtifactId(t *testing.T) { diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 25efc316c..5831b7648 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -151,7 +151,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { diff --git a/builder/amazon/ebs/builder_acc_test.go b/builder/amazon/ebs/builder_acc_test.go index cf569a353..ffb773657 100644 --- a/builder/amazon/ebs/builder_acc_test.go +++ b/builder/amazon/ebs/builder_acc_test.go @@ -13,7 +13,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/builder/amazon/common" builderT "github.com/hashicorp/packer/helper/builder/testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestBuilderAcc_basic(t *testing.T) { @@ -89,7 +89,7 @@ func TestBuilderAcc_forceDeleteSnapshot(t *testing.T) { } func checkSnapshotsDeleted(snapshotIds []*string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { // Verify the snapshots are gone ec2conn, _ := testEC2Conn() snapshotResp, _ := ec2conn.DescribeSnapshots( @@ -122,7 +122,7 @@ func TestBuilderAcc_encryptedBoot(t *testing.T) { } func checkAMISharing(count int, uid, group string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -178,7 +178,7 @@ func checkAMISharing(count int, uid, group string) builderT.TestCheckFunc { } func checkRegionCopy(regions []string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } @@ -211,7 +211,7 @@ func checkRegionCopy(regions []string) builderT.TestCheckFunc { } func checkBootEncrypted() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { // Get the actual *Artifact pointer so we can access the AMIs directly artifactRaw := artifacts[0] diff --git a/builder/amazon/ebs/tags_acc_test.go b/builder/amazon/ebs/tags_acc_test.go index 1d0eb69b9..ac1c48dc0 100644 --- a/builder/amazon/ebs/tags_acc_test.go +++ b/builder/amazon/ebs/tags_acc_test.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/builder/amazon/common" builderT "github.com/hashicorp/packer/helper/builder/testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type TFBuilder struct { @@ -37,7 +37,7 @@ func TestBuilderTagsAcc_basic(t *testing.T) { } func checkTags() builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index d9f3b6751..93ffa92dd 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -174,7 +174,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index a72627a9b..ac6bd8250 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -165,7 +165,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index a4e3c03a0..f5b263bdd 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -234,7 +234,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index e7f28b256..aef35af43 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -52,7 +52,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { ui.Say("Running builder ...") diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index dc6cd4eca..23a7f6092 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -393,7 +393,7 @@ func checkHyperVGeneration(s string) interface{} { s, compute.PossibleHyperVGenerationValues()) } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { switch runtime.GOOS { case "linux", "freebsd": break diff --git a/builder/azure/dtl/builder.go b/builder/azure/dtl/builder.go index 4d1eb516a..28303b8c2 100644 --- a/builder/azure/dtl/builder.go +++ b/builder/azure/dtl/builder.go @@ -52,7 +52,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { ui.Say("Running builder ...") diff --git a/builder/cloudstack/artifact_test.go b/builder/cloudstack/artifact_test.go index b930083e0..5b2a85b6d 100644 --- a/builder/cloudstack/artifact_test.go +++ b/builder/cloudstack/artifact_test.go @@ -3,7 +3,7 @@ package cloudstack import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -12,8 +12,8 @@ const templateID = "286dd44a-ec6b-4789-b192-804f08f04b4c" func TestArtifact_Impl(t *testing.T) { var raw interface{} = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { - t.Fatalf("Artifact does not implement packer.Artifact") + if _, ok := raw.(packersdk.Artifact); !ok { + t.Fatalf("Artifact does not implement packersdk.Artifact") } } diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index 302323da3..2850dec13 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -34,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run implements the packer.Builder interface. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { b.ui = ui // Create a CloudStack API client. diff --git a/builder/digitalocean/artifact_test.go b/builder/digitalocean/artifact_test.go index 21c373fc8..19c1e69df 100644 --- a/builder/digitalocean/artifact_test.go +++ b/builder/digitalocean/artifact_test.go @@ -3,7 +3,7 @@ package digitalocean import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func generatedData() map[string]interface{} { @@ -13,7 +13,7 @@ func generatedData() map[string]interface{} { func TestArtifact_Impl(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be artifact") } } diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index f812ca39b..f9ac5fd5b 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -38,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { client := godo.NewClient(oauth2.NewClient(context.TODO(), &apiTokenSource{ AccessToken: b.config.APIToken, })) diff --git a/builder/docker/artifact_export_test.go b/builder/docker/artifact_export_test.go index 83d522090..364e3adb6 100644 --- a/builder/docker/artifact_export_test.go +++ b/builder/docker/artifact_export_test.go @@ -3,9 +3,9 @@ package docker import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestExportArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(ExportArtifact) + var _ packersdk.Artifact = new(ExportArtifact) } diff --git a/builder/docker/artifact_import_test.go b/builder/docker/artifact_import_test.go index 20aac11ee..119560c98 100644 --- a/builder/docker/artifact_import_test.go +++ b/builder/docker/artifact_import_test.go @@ -4,11 +4,11 @@ import ( "errors" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestImportArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(ImportArtifact) + var _ packersdk.Artifact = new(ImportArtifact) } func TestImportArtifactBuilderId(t *testing.T) { diff --git a/builder/docker/builder.go b/builder/docker/builder.go index d4f8569c2..7e785cbcc 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -36,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { }, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { driver := &DockerDriver{Ctx: &b.config.ctx, Ui: ui} if err := driver.Verify(); err != nil { return nil, err @@ -108,7 +108,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (p } // No errors, must've worked - var artifact packer.Artifact + var artifact packersdk.Artifact if b.config.Commit { artifact = &ImportArtifact{ IdValue: state.Get("image_id").(string), diff --git a/builder/file/artifact_test.go b/builder/file/artifact_test.go index c2c73d660..5e798f4ae 100644 --- a/builder/file/artifact_test.go +++ b/builder/file/artifact_test.go @@ -3,9 +3,9 @@ package file import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestNullArtifact(t *testing.T) { - var _ packer.Artifact = new(FileArtifact) + var _ packersdk.Artifact = new(FileArtifact) } diff --git a/builder/file/builder.go b/builder/file/builder.go index 5b096ce0a..62561abea 100644 --- a/builder/file/builder.go +++ b/builder/file/builder.go @@ -38,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run is where the actual build should take place. It takes a Build and a Ui. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { artifact := new(FileArtifact) // Create all directories leading to target diff --git a/builder/file/builder_test.go b/builder/file/builder_test.go index 3979ab853..83501f9e6 100644 --- a/builder/file/builder_test.go +++ b/builder/file/builder_test.go @@ -7,6 +7,7 @@ import ( builderT "github.com/hashicorp/packer/helper/builder/testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestBuilder_implBuilder(t *testing.T) { @@ -29,7 +30,7 @@ func TestBuilderFileAcc_copy(t *testing.T) { }) } -func checkContent(artifacts []packer.Artifact) error { +func checkContent(artifacts []packersdk.Artifact) error { content, err := ioutil.ReadFile("contentTest.txt") if err != nil { return err @@ -41,7 +42,7 @@ func checkContent(artifacts []packer.Artifact) error { return nil } -func checkCopy(artifacts []packer.Artifact) error { +func checkCopy(artifacts []packersdk.Artifact) error { content, err := ioutil.ReadFile("copyTest.txt") if err != nil { return err diff --git a/builder/googlecompute/artifact_test.go b/builder/googlecompute/artifact_test.go index 43194daf9..9b9ba10de 100644 --- a/builder/googlecompute/artifact_test.go +++ b/builder/googlecompute/artifact_test.go @@ -3,11 +3,11 @@ package googlecompute import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(Artifact) + var _ packersdk.Artifact = new(Artifact) } func TestArtifactState_StateData(t *testing.T) { diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index e1fe4184c..9cd7e557b 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -34,9 +34,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a googlecompute Packer build and returns a packer.Artifact +// Run executes a googlecompute Packer build and returns a packersdk.Artifact // representing a GCE machine image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { cfg := GCEDriverConfig{ Ui: ui, ProjectId: b.config.ProjectId, diff --git a/builder/hcloud/artifact_test.go b/builder/hcloud/artifact_test.go index 3e43ccda2..d7e802157 100644 --- a/builder/hcloud/artifact_test.go +++ b/builder/hcloud/artifact_test.go @@ -3,11 +3,11 @@ package hcloud import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { - var _ packer.Artifact = (*Artifact)(nil) + var _ packersdk.Artifact = (*Artifact)(nil) } func TestArtifactId(t *testing.T) { diff --git a/builder/hcloud/builder.go b/builder/hcloud/builder.go index daf135e57..413451755 100644 --- a/builder/hcloud/builder.go +++ b/builder/hcloud/builder.go @@ -35,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { opts := []hcloud.ClientOption{ hcloud.WithToken(b.config.HCloudToken), hcloud.WithEndpoint(b.config.Endpoint), diff --git a/builder/hyperone/builder.go b/builder/hyperone/builder.go index cb1653138..f123a19c5 100644 --- a/builder/hyperone/builder.go +++ b/builder/hyperone/builder.go @@ -52,7 +52,7 @@ type wrappedCommandTemplate struct { Command string } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { ictx := b.config.ctx ictx.Data = &wrappedCommandTemplate{Command: command} diff --git a/builder/hyperv/common/artifact.go b/builder/hyperv/common/artifact.go index d42070aed..e85f66948 100644 --- a/builder/hyperv/common/artifact.go +++ b/builder/hyperv/common/artifact.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This is the common builder ID to all of these artifacts. @@ -24,7 +24,7 @@ type artifact struct { // NewArtifact returns a hyperv artifact containing the files // in the given directory. -func NewArtifact(dir string, generatedData map[string]interface{}) (packer.Artifact, error) { +func NewArtifact(dir string, generatedData map[string]interface{}) (packersdk.Artifact, error) { files := make([]string, 0, 5) visit := func(path string, info os.FileInfo, err error) error { if err != nil { diff --git a/builder/hyperv/common/artifact_test.go b/builder/hyperv/common/artifact_test.go index 540b0d834..a6b9dcb27 100644 --- a/builder/hyperv/common/artifact_test.go +++ b/builder/hyperv/common/artifact_test.go @@ -6,11 +6,11 @@ import ( "path/filepath" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(artifact) + var _ packersdk.Artifact = new(artifact) } func TestNewArtifact(t *testing.T) { diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index ddfb0316c..41b7e3c2e 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -175,9 +175,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 40a1ed134..80f6ea3e7 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -215,9 +215,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index 2800f633e..fbbb9881e 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -43,7 +43,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("hook", hook) diff --git a/builder/linode/artifact_test.go b/builder/linode/artifact_test.go index d0e25b40e..855477178 100644 --- a/builder/linode/artifact_test.go +++ b/builder/linode/artifact_test.go @@ -3,13 +3,13 @@ package linode import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be artifact") } } diff --git a/builder/linode/builder.go b/builder/linode/builder.go index c1890dff5..2ae84f3c9 100644 --- a/builder/linode/builder.go +++ b/builder/linode/builder.go @@ -37,7 +37,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (ret packer.Artifact, err error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (ret packersdk.Artifact, err error) { ui.Say("Running builder ...") client := newLinodeClient(b.config.PersonalAccessToken) diff --git a/builder/lxc/builder.go b/builder/lxc/builder.go index 64ccfd1f7..3a350effc 100644 --- a/builder/lxc/builder.go +++ b/builder/lxc/builder.go @@ -36,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxd/builder.go b/builder/lxd/builder.go index cbc52fcff..8306f4bca 100644 --- a/builder/lxd/builder.go +++ b/builder/lxd/builder.go @@ -34,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/ncloud/builder.go b/builder/ncloud/builder.go index 84fc4130c..a690230f5 100644 --- a/builder/ncloud/builder.go +++ b/builder/ncloud/builder.go @@ -32,7 +32,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { ui.Message("Creating Naver Cloud Platform Connection ...") config := Config{ AccessKey: b.config.AccessKey, diff --git a/builder/null/artifact_export_test.go b/builder/null/artifact_export_test.go index 917578eff..72665260a 100644 --- a/builder/null/artifact_export_test.go +++ b/builder/null/artifact_export_test.go @@ -3,9 +3,9 @@ package null import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestNullArtifact(t *testing.T) { - var _ packer.Artifact = new(NullArtifact) + var _ packersdk.Artifact = new(NullArtifact) } diff --git a/builder/null/builder.go b/builder/null/builder.go index 1397e5fcc..cc4f9ea9c 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -29,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { steps := []multistep.Step{} steps = append(steps, diff --git a/builder/oneandone/builder.go b/builder/oneandone/builder.go index b6cee6d01..f6a67ff7e 100644 --- a/builder/oneandone/builder.go +++ b/builder/oneandone/builder.go @@ -31,7 +31,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) diff --git a/builder/openstack/artifact_test.go b/builder/openstack/artifact_test.go index 82aae40dd..8dec93bb3 100644 --- a/builder/openstack/artifact_test.go +++ b/builder/openstack/artifact_test.go @@ -3,11 +3,11 @@ package openstack import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { - var _ packer.Artifact = new(Artifact) + var _ packersdk.Artifact = new(Artifact) } func TestArtifactId(t *testing.T) { diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 1fd5f3456..206f6146f 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -73,7 +73,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { if b.config.PackerDebug { b.config.enableDebug(ui) } diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index 5ddaad9d5..f927259ff 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -46,7 +46,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { loggingEnabled := os.Getenv("PACKER_OCI_CLASSIC_LOGGING") != "" httpClient := cleanhttp.DefaultClient() config := &opc.Config{ diff --git a/builder/oracle/oci/artifact_test.go b/builder/oracle/oci/artifact_test.go index f7ab5d265..d6574f7f7 100644 --- a/builder/oracle/oci/artifact_test.go +++ b/builder/oracle/oci/artifact_test.go @@ -3,13 +3,13 @@ package oci import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifactImpl(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be artifact") } } diff --git a/builder/oracle/oci/builder.go b/builder/oracle/oci/builder.go index bc385e7f7..93caea3b5 100644 --- a/builder/oracle/oci/builder.go +++ b/builder/oracle/oci/builder.go @@ -39,7 +39,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { driver, err := NewDriverOCI(&b.config) if err != nil { return nil, err diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index a8f281cf8..d5b05252e 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -85,7 +85,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index bc0d442be..f7c607004 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -103,7 +103,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 999e75703..7a3d6d3a4 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -88,7 +88,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // clientConfig, err := b.config.Config() // if err != nil { // return nil, err diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 198ca19c8..b15441256 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -188,7 +188,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The outscale-chroot builder only works on Linux environments.") } diff --git a/builder/parallels/common/artifact.go b/builder/parallels/common/artifact.go index 2e95be358..63e74a473 100644 --- a/builder/parallels/common/artifact.go +++ b/builder/parallels/common/artifact.go @@ -6,7 +6,7 @@ import ( "path/filepath" "regexp" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // BuilderId is the common builder ID to all of these artifacts. @@ -29,7 +29,7 @@ type artifact struct { // NewArtifact returns a Parallels artifact containing the files // in the given directory. -func NewArtifact(dir string, generatedData map[string]interface{}) (packer.Artifact, error) { +func NewArtifact(dir string, generatedData map[string]interface{}) (packersdk.Artifact, error) { files := make([]string, 0, 5) visit := func(path string, info os.FileInfo, err error) error { if err != nil { diff --git a/builder/parallels/common/artifact_test.go b/builder/parallels/common/artifact_test.go index 398d39fb5..0666ddf5b 100644 --- a/builder/parallels/common/artifact_test.go +++ b/builder/parallels/common/artifact_test.go @@ -6,11 +6,11 @@ import ( "path/filepath" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(artifact) + var _ packersdk.Artifact = new(artifact) } func TestNewArtifact(t *testing.T) { diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index eafe8f14e..3c4cdd769 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -181,7 +181,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index c535d55d4..1235cc97b 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -32,9 +32,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a Parallels appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/profitbricks/artifact_test.go b/builder/profitbricks/artifact_test.go index a57746957..640c41e20 100644 --- a/builder/profitbricks/artifact_test.go +++ b/builder/profitbricks/artifact_test.go @@ -3,13 +3,13 @@ package profitbricks import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be artifact") } } diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index c89c805ee..aa805f978 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -30,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("config", &b.config) diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index b1cf07c4c..aeb675d22 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -28,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return b.config.Prepare(raws...) } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("clone-config", &b.config) diff --git a/builder/proxmox/common/artifact.go b/builder/proxmox/common/artifact.go index 059d8ed81..65b6fc6f9 100644 --- a/builder/proxmox/common/artifact.go +++ b/builder/proxmox/common/artifact.go @@ -6,7 +6,7 @@ import ( "strconv" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Artifact struct { @@ -19,8 +19,8 @@ type Artifact struct { StateData map[string]interface{} } -// Artifact implements packer.Artifact -var _ packer.Artifact = &Artifact{} +// Artifact implements packersdk.Artifact +var _ packersdk.Artifact = &Artifact{} func (a *Artifact) BuilderId() string { return a.builderID diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index 981c62576..b61be22e7 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -34,7 +34,7 @@ type Builder struct { vmCreator ProxmoxVMCreator } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook, state multistep.StateBag) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook, state multistep.StateBag) (packersdk.Artifact, error) { var err error tlsConfig := &tls.Config{ InsecureSkipVerify: b.config.SkipCertValidation, diff --git a/builder/proxmox/iso/builder.go b/builder/proxmox/iso/builder.go index b6b59abcc..da1050b2e 100644 --- a/builder/proxmox/iso/builder.go +++ b/builder/proxmox/iso/builder.go @@ -30,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { const downloadPathKey = "downloaded_iso_path" -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("iso-config", &b.config) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 3522ed59f..bf3482d2f 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -35,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Qemu driver, err := b.newDriver(b.config.QemuBinary) if err != nil { diff --git a/builder/scaleway/artifact_test.go b/builder/scaleway/artifact_test.go index 619e2ebc2..568d4f8b7 100644 --- a/builder/scaleway/artifact_test.go +++ b/builder/scaleway/artifact_test.go @@ -3,13 +3,13 @@ package scaleway import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be artifact") } } diff --git a/builder/scaleway/builder.go b/builder/scaleway/builder.go index bc78d5253..e05bc805f 100644 --- a/builder/scaleway/builder.go +++ b/builder/scaleway/builder.go @@ -36,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { scwZone, err := scw.ParseZone(b.config.Zone) if err != nil { ui.Error(err.Error()) diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 0a6baa017..4d2c2c653 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -65,7 +65,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { cvmClient, vpcClient, err := b.config.Client() if err != nil { return nil, err diff --git a/builder/triton/builder.go b/builder/triton/builder.go index 8ec1e8c5f..acbba7182 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -50,7 +50,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs.ErrorOrNil() } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { config := b.config driver, err := NewDriverTriton(ui, config) diff --git a/builder/ucloud/common/artifact_test.go b/builder/ucloud/common/artifact_test.go index a28fcb535..32cc2e8ca 100644 --- a/builder/ucloud/common/artifact_test.go +++ b/builder/ucloud/common/artifact_test.go @@ -4,11 +4,11 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { - var _ packer.Artifact = new(Artifact) + var _ packersdk.Artifact = new(Artifact) } func TestArtifactId(t *testing.T) { diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index 5430adb5c..c0d239dc7 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -68,7 +68,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/ucloud/uhost/builder_acc_test.go b/builder/ucloud/uhost/builder_acc_test.go index af52013a7..c4b5b2781 100644 --- a/builder/ucloud/uhost/builder_acc_test.go +++ b/builder/ucloud/uhost/builder_acc_test.go @@ -6,7 +6,7 @@ import ( "testing" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" builderT "github.com/hashicorp/packer/helper/builder/testing" @@ -124,7 +124,7 @@ func testBuilderAccRegionCopy(projectId string) string { } func checkRegionCopy(projectId string, imageDst []ucloudcommon.ImageDestination) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { return fmt.Errorf("more than 1 artifact") } diff --git a/builder/vagrant/artifact.go b/builder/vagrant/artifact.go index bfad668d3..8e36c4e53 100644 --- a/builder/vagrant/artifact.go +++ b/builder/vagrant/artifact.go @@ -4,7 +4,7 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This is the common builder ID to all of these artifacts. @@ -23,7 +23,7 @@ type artifact struct { } // NewArtifact returns a vagrant artifact containing the .box file -func NewArtifact(provider, dir string, generatedData map[string]interface{}) packer.Artifact { +func NewArtifact(provider, dir string, generatedData map[string]interface{}) packersdk.Artifact { return &artifact{ OutputDir: dir, BoxName: "package.box", diff --git a/builder/vagrant/artifact_test.go b/builder/vagrant/artifact_test.go index e96bdd38c..aacc3181c 100644 --- a/builder/vagrant/artifact_test.go +++ b/builder/vagrant/artifact_test.go @@ -5,14 +5,14 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_Impl(t *testing.T) { var raw interface{} = &artifact{} - if _, ok := raw.(packer.Artifact); !ok { - t.Fatalf("Artifact does not implement packer.Artifact") + if _, ok := raw.(packersdk.Artifact); !ok { + t.Fatalf("Artifact does not implement packersdk.Artifact") } } diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index eace841f6..2e2398268 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -272,9 +272,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox VagrantCWD, err := filepath.Abs(b.config.OutputDir) if err != nil { diff --git a/builder/virtualbox/common/artifact.go b/builder/virtualbox/common/artifact.go index 1f78a0b32..ddd2c0efd 100644 --- a/builder/virtualbox/common/artifact.go +++ b/builder/virtualbox/common/artifact.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This is the common builder ID to all of these artifacts. @@ -24,7 +24,7 @@ type artifact struct { // NewArtifact returns a VirtualBox artifact containing the files // in the given directory. -func NewArtifact(dir string, generatedData map[string]interface{}) (packer.Artifact, error) { +func NewArtifact(dir string, generatedData map[string]interface{}) (packersdk.Artifact, error) { files := make([]string, 0, 5) visit := func(path string, info os.FileInfo, err error) error { if err != nil { diff --git a/builder/virtualbox/common/artifact_test.go b/builder/virtualbox/common/artifact_test.go index 540b0d834..a6b9dcb27 100644 --- a/builder/virtualbox/common/artifact_test.go +++ b/builder/virtualbox/common/artifact_test.go @@ -6,11 +6,11 @@ import ( "path/filepath" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(artifact) + var _ packersdk.Artifact = new(artifact) } func TestNewArtifact(t *testing.T) { diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 0b9557a8f..d92a21bef 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -231,7 +231,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index c07152f18..6e0c311b0 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -32,9 +32,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/vm/builder.go b/builder/virtualbox/vm/builder.go index 9732e7c0f..61828aa89 100644 --- a/builder/virtualbox/vm/builder.go +++ b/builder/virtualbox/vm/builder.go @@ -32,9 +32,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/vmware/common/artifact.go b/builder/vmware/common/artifact.go index 39949716b..9ff3de78c 100644 --- a/builder/vmware/common/artifact.go +++ b/builder/vmware/common/artifact.go @@ -4,8 +4,8 @@ import ( "fmt" "strconv" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const ( @@ -62,7 +62,7 @@ func (a *artifact) Destroy() error { return nil } -func NewArtifact(remoteType string, format string, exportOutputPath string, vmName string, skipExport bool, keepRegistered bool, state multistep.StateBag) (packer.Artifact, error) { +func NewArtifact(remoteType string, format string, exportOutputPath string, vmName string, skipExport bool, keepRegistered bool, state multistep.StateBag) (packersdk.Artifact, error) { var files []string var dir OutputDir var err error diff --git a/builder/vmware/common/artifact_test.go b/builder/vmware/common/artifact_test.go index dd2c64b74..7d7a9d039 100644 --- a/builder/vmware/common/artifact_test.go +++ b/builder/vmware/common/artifact_test.go @@ -3,9 +3,9 @@ package common import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestLocalArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(artifact) + var _ packersdk.Artifact = new(artifact) } diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index fea117e93..20bc1b9e2 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -31,7 +31,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index c4d1d0bc7..c0542d3e4 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -34,9 +34,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -// Run executes a Packer build and returns a packer.Artifact representing +// Run executes a Packer build and returns a packersdk.Artifact representing // a VMware image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vsphere/clone/builder.go b/builder/vsphere/clone/builder.go index eea695d97..f9c993779 100644 --- a/builder/vsphere/clone/builder.go +++ b/builder/vsphere/clone/builder.go @@ -30,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/vsphere/clone/builder_acc_test.go b/builder/vsphere/clone/builder_acc_test.go index 22bb345ab..a5af88eb1 100644 --- a/builder/vsphere/clone/builder_acc_test.go +++ b/builder/vsphere/clone/builder_acc_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" commonT "github.com/hashicorp/packer/builder/vsphere/common/testing" builderT "github.com/hashicorp/packer/helper/builder/testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi/vim25/types" ) @@ -48,7 +48,7 @@ func defaultConfig() map[string]interface{} { } func checkDefault(t *testing.T, name string, host string, datastore string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -113,7 +113,7 @@ func TestCloneBuilderAcc_artifact(t *testing.T) { } func checkArtifact(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { if len(artifacts) > 1 { t.Fatal("more than 1 artifact") } @@ -144,7 +144,7 @@ func folderConfig() string { } func checkFolder(t *testing.T, folder string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -182,7 +182,7 @@ func resourcePoolConfig() string { } func checkResourcePool(t *testing.T, pool string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -221,7 +221,7 @@ func datastoreConfig() string { } func checkDatastore(t *testing.T, name string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -280,7 +280,7 @@ func fullCloneConfig() string { } func checkFullClone(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -313,7 +313,7 @@ func linkedCloneConfig() string { } func checkLinkedClone(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -349,7 +349,7 @@ func networkConfig() string { } func checkNetwork(t *testing.T, name string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -401,7 +401,7 @@ func hardwareConfig() string { } func checkHardware(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -483,7 +483,7 @@ func RAMReservationConfig() string { } func checkRAMReservation(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -518,7 +518,7 @@ func sshPasswordConfig() string { } func checkDefaultBootOrder(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -569,7 +569,7 @@ func snapshotConfig() string { } func checkSnapshot(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -603,7 +603,7 @@ func templateConfig() string { } func checkTemplate(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -641,7 +641,7 @@ func bootOrderConfig() string { } func checkBootOrder(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -676,7 +676,7 @@ func notesConfig() string { } func checkNotes(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) diff --git a/builder/vsphere/common/testing/utility.go b/builder/vsphere/common/testing/utility.go index e44f0533e..c9ca66424 100644 --- a/builder/vsphere/common/testing/utility.go +++ b/builder/vsphere/common/testing/utility.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func NewVMName() string { @@ -56,7 +56,7 @@ func TestConn(t *testing.T) driver.Driver { return d } -func GetVM(t *testing.T, d driver.Driver, artifacts []packer.Artifact) driver.VirtualMachine { +func GetVM(t *testing.T, d driver.Driver, artifacts []packersdk.Artifact) driver.VirtualMachine { artifactRaw := artifacts[0] artifact, _ := artifactRaw.(*common.Artifact) diff --git a/builder/vsphere/iso/builder.go b/builder/vsphere/iso/builder.go index 8b6ff497a..1bd53675e 100644 --- a/builder/vsphere/iso/builder.go +++ b/builder/vsphere/iso/builder.go @@ -29,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/vsphere/iso/builder_acc_test.go b/builder/vsphere/iso/builder_acc_test.go index 924938f41..8276258f0 100644 --- a/builder/vsphere/iso/builder_acc_test.go +++ b/builder/vsphere/iso/builder_acc_test.go @@ -8,7 +8,7 @@ import ( commonT "github.com/hashicorp/packer/builder/vsphere/common/testing" builderT "github.com/hashicorp/packer/helper/builder/testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/vmware/govmomi/vim25/types" ) @@ -54,7 +54,7 @@ func defaultConfig() map[string]interface{} { } func checkDefault(t *testing.T, name string, host string, datastore string) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -129,7 +129,7 @@ func notesConfig() string { } func checkNotes(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -171,7 +171,7 @@ func hardwareConfig() string { } func checkHardware(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -261,7 +261,7 @@ func limitConfig() string { } func checkLimit(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -295,7 +295,7 @@ func sataConfig() string { } func checkSata(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -347,7 +347,7 @@ func networkCardConfig() string { } func checkNetworkCard(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -473,7 +473,7 @@ func fullConfig() map[string]interface{} { } func checkFull(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) @@ -515,7 +515,7 @@ func TestISOBuilderAcc_bootOrder(t *testing.T) { } func checkBootOrder(t *testing.T) builderT.TestCheckFunc { - return func(artifacts []packer.Artifact) error { + return func(artifacts []packersdk.Artifact) error { d := commonT.TestConn(t) vm := commonT.GetVM(t, d, artifacts) diff --git a/builder/yandex/artifact_test.go b/builder/yandex/artifact_test.go index 7cc5301be..28ded1178 100644 --- a/builder/yandex/artifact_test.go +++ b/builder/yandex/artifact_test.go @@ -3,13 +3,13 @@ package yandex import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" ) func TestArtifact_impl(t *testing.T) { - var _ packer.Artifact = new(Artifact) + var _ packersdk.Artifact = new(Artifact) } func TestArtifact_Id(t *testing.T) { diff --git a/builder/yandex/builder.go b/builder/yandex/builder.go index c04479e3f..be09ab378 100644 --- a/builder/yandex/builder.go +++ b/builder/yandex/builder.go @@ -48,9 +48,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warnings, nil } -// Run executes a yandex Packer build and returns a packer.Artifact +// Run executes a yandex Packer build and returns a packersdk.Artifact // representing a Yandex.Cloud compute image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { driver, err := NewDriverYC(ui, &b.config.AccessConfig) ctx = requestid.ContextWithClientTraceID(ctx, uuid.New().String()) diff --git a/command/build.go b/command/build.go index e5acbdec9..2ed0f319d 100644 --- a/command/build.go +++ b/command/build.go @@ -215,8 +215,8 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int var wg sync.WaitGroup var artifacts = struct { sync.RWMutex - m map[string][]packer.Artifact - }{m: make(map[string][]packer.Artifact)} + m map[string][]packersdk.Artifact + }{m: make(map[string][]packersdk.Artifact)} // Get the builds we care about var errors = struct { sync.RWMutex diff --git a/command/build_parallel_test.go b/command/build_parallel_test.go index 175cd6a02..27fc23272 100644 --- a/command/build_parallel_test.go +++ b/command/build_parallel_test.go @@ -37,7 +37,7 @@ func (b *ParallelTestBuilder) Prepare(raws ...interface{}) ([]string, []string, return nil, nil, nil } -func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { ui.Say("building") b.wg.Done() return nil, nil @@ -52,7 +52,7 @@ func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) return nil, nil, nil } -func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { ui.Say("locking build") select { case <-b.unlock: diff --git a/hcl2template/internal/mock.go b/hcl2template/internal/mock.go index 8a419ed5d..f55ce6fb7 100644 --- a/hcl2template/internal/mock.go +++ b/hcl2template/internal/mock.go @@ -78,7 +78,7 @@ func (b *MockBuilder) Prepare(raws ...interface{}) ([]string, []string, error) { return []string{"ID"}, nil, b.Config.Prepare(raws...) } -func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { return nil, nil } @@ -122,7 +122,7 @@ func (b *MockPostProcessor) Configure(raws ...interface{}) error { return b.Config.Prepare(raws...) } -func (b *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (b *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { return nil, false, false, nil } diff --git a/hcl2template/types.hcl_post-processor.go b/hcl2template/types.hcl_post-processor.go index d74366e7a..43e35a021 100644 --- a/hcl2template/types.hcl_post-processor.go +++ b/hcl2template/types.hcl_post-processor.go @@ -63,7 +63,7 @@ func (p *HCL2PostProcessor) Configure(args ...interface{}) error { return p.PostProcessor.Configure(args...) } -func (p *HCL2PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *HCL2PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { generatedData := make(map[string]interface{}) if artifactStateData, ok := artifact.State("generated_data").(map[interface{}]interface{}); ok { for k, v := range artifactStateData { diff --git a/helper/builder/testing/testing.go b/helper/builder/testing/testing.go index dc4129e74..a1a4f256b 100644 --- a/helper/builder/testing/testing.go +++ b/helper/builder/testing/testing.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" ) @@ -49,7 +50,7 @@ type TestCase struct { } // TestCheckFunc is the callback used for Check in TestStep. -type TestCheckFunc func([]packer.Artifact) error +type TestCheckFunc func([]packersdk.Artifact) error // TestTeardownFunc is the callback used for Teardown in TestCase. type TestTeardownFunc func() error diff --git a/packer/artifact.go b/packer-plugin-sdk/packer/artifact.go similarity index 100% rename from packer/artifact.go rename to packer-plugin-sdk/packer/artifact.go diff --git a/packer/artifact_mock.go b/packer-plugin-sdk/packer/artifact_mock.go similarity index 100% rename from packer/artifact_mock.go rename to packer-plugin-sdk/packer/artifact_mock.go diff --git a/packer/artifact_test.go b/packer-plugin-sdk/packer/artifact_test.go similarity index 100% rename from packer/artifact_test.go rename to packer-plugin-sdk/packer/artifact_test.go diff --git a/packer/build.go b/packer/build.go index 289b7c9f3..ba6ee5419 100644 --- a/packer/build.go +++ b/packer/build.go @@ -64,7 +64,7 @@ type Build interface { // Run runs the actual builder, returning an artifact implementation // of what is built. If anything goes wrong, an error is returned. // Run can be context cancelled. - Run(context.Context, packersdk.Ui) ([]Artifact, error) + Run(context.Context, packersdk.Ui) ([]packersdk.Artifact, error) // SetDebug will enable/disable debug mode. Debug mode is always // enabled by adding the additional key "packer_debug" to boolean @@ -232,7 +232,7 @@ func (b *CoreBuild) Prepare() (warn []string, err error) { } // Runs the actual build. Prepare must be called prior to running this. -func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]Artifact, error) { +func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packersdk.Artifact, error) { if !b.prepareCalled { panic("Prepare must be called first") } @@ -288,7 +288,7 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]Artifac } hook := &DispatchHook{Mapping: hooks} - artifacts := make([]Artifact, 0, 1) + artifacts := make([]packersdk.Artifact, 0, 1) // The builder just has a normal Ui, but targeted builderUi := &TargetedUI{ diff --git a/packer/builder.go b/packer/builder.go index 9c0296632..b189dd6e8 100644 --- a/packer/builder.go +++ b/packer/builder.go @@ -37,5 +37,5 @@ type Builder interface { Prepare(...interface{}) ([]string, []string, error) // Run is where the actual build should take place. It takes a Build and a Ui. - Run(context.Context, packersdk.Ui, Hook) (Artifact, error) + Run(context.Context, packersdk.Ui, Hook) (packersdk.Artifact, error) } diff --git a/packer/builder_mock.go b/packer/builder_mock.go index e3585fd95..7802d8d3b 100644 --- a/packer/builder_mock.go +++ b/packer/builder_mock.go @@ -40,7 +40,7 @@ func (tb *MockBuilder) Prepare(config ...interface{}) ([]string, []string, error return tb.GeneratedVars, tb.PrepareWarnings, nil } -func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (Artifact, error) { +func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (packersdk.Artifact, error) { tb.RunCalled = true tb.RunHook = h tb.RunUi = ui @@ -62,7 +62,7 @@ func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (Artifa } } - return &MockArtifact{ + return &packersdk.MockArtifact{ IdValue: tb.ArtifactId, }, nil } diff --git a/packer/builder_mock.hcl2spec.go b/packer/builder_mock.hcl2spec.go index 61687b14c..e7c7f85ba 100644 --- a/packer/builder_mock.hcl2spec.go +++ b/packer/builder_mock.hcl2spec.go @@ -112,16 +112,16 @@ func (*FlatMockCommunicator) HCL2Spec() map[string]hcldec.Spec { // FlatMockPostProcessor is an auto-generated flat version of MockPostProcessor. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatMockPostProcessor struct { - ArtifactId *string `cty:"artifact_id" hcl:"artifact_id"` - Keep *bool `cty:"keep" hcl:"keep"` - ForceOverride *bool `cty:"force_override" hcl:"force_override"` - Error error `cty:"error" hcl:"error"` - ConfigureCalled *bool `cty:"configure_called" hcl:"configure_called"` - ConfigureConfigs []interface{} `cty:"configure_configs" hcl:"configure_configs"` - ConfigureError error `cty:"configure_error" hcl:"configure_error"` - PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` - PostProcessArtifact Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` - PostProcessUi packersdk.Ui `cty:"post_process_ui" hcl:"post_process_ui"` + ArtifactId *string `cty:"artifact_id" hcl:"artifact_id"` + Keep *bool `cty:"keep" hcl:"keep"` + ForceOverride *bool `cty:"force_override" hcl:"force_override"` + Error error `cty:"error" hcl:"error"` + ConfigureCalled *bool `cty:"configure_called" hcl:"configure_called"` + ConfigureConfigs []interface{} `cty:"configure_configs" hcl:"configure_configs"` + ConfigureError error `cty:"configure_error" hcl:"configure_error"` + PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` + PostProcessArtifact packersdk.Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` + PostProcessUi packersdk.Ui `cty:"post_process_ui" hcl:"post_process_ui"` } // FlatMapstructure returns a new FlatMockPostProcessor. diff --git a/packer/plugin/builder.go b/packer/plugin/builder.go index 95ee181eb..5ec142d6d 100644 --- a/packer/plugin/builder.go +++ b/packer/plugin/builder.go @@ -32,7 +32,7 @@ func (b *cmdBuilder) Prepare(config ...interface{}) ([]string, []string, error) return b.builder.Prepare(config...) } -func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { defer func() { r := recover() b.checkExit(r, nil) diff --git a/packer/plugin/post_processor.go b/packer/plugin/post_processor.go index 1d9877081..fa98ebaf0 100644 --- a/packer/plugin/post_processor.go +++ b/packer/plugin/post_processor.go @@ -32,7 +32,7 @@ func (c *cmdPostProcessor) Configure(config ...interface{}) error { return c.p.Configure(config...) } -func (c *cmdPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (c *cmdPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/plugin/post_processor_test.go b/packer/plugin/post_processor_test.go index 5c72d8f45..af67d4003 100644 --- a/packer/plugin/post_processor_test.go +++ b/packer/plugin/post_processor_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -18,7 +17,7 @@ func (helperPostProcessor) Configure(...interface{}) error { return nil } -func (helperPostProcessor) PostProcess(context.Context, packersdk.Ui, packer.Artifact) (packer.Artifact, bool, bool, error) { +func (helperPostProcessor) PostProcess(context.Context, packersdk.Ui, packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { return nil, false, false, nil } diff --git a/packer/post_processor.go b/packer/post_processor.go index b1f32382c..32fe23f1f 100644 --- a/packer/post_processor.go +++ b/packer/post_processor.go @@ -26,5 +26,5 @@ type PostProcessor interface { // user input for keep_input_artifact is ignored and the artifact is either // kept or discarded according to the value set in `keep`. // PostProcess is cancellable using context - PostProcess(context.Context, packersdk.Ui, Artifact) (a Artifact, keep bool, forceOverride bool, err error) + PostProcess(context.Context, packersdk.Ui, packersdk.Artifact) (a packersdk.Artifact, keep bool, forceOverride bool, err error) } diff --git a/packer/post_processor_mock.go b/packer/post_processor_mock.go index 87284e819..4208cea07 100644 --- a/packer/post_processor_mock.go +++ b/packer/post_processor_mock.go @@ -20,7 +20,7 @@ type MockPostProcessor struct { ConfigureError error PostProcessCalled bool - PostProcessArtifact Artifact + PostProcessArtifact packersdk.Artifact PostProcessUi packersdk.Ui } @@ -32,12 +32,12 @@ func (t *MockPostProcessor) Configure(configs ...interface{}) error { return t.ConfigureError } -func (t *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a Artifact) (Artifact, bool, bool, error) { +func (t *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { t.PostProcessCalled = true t.PostProcessArtifact = a t.PostProcessUi = ui - return &MockArtifact{ + return &packersdk.MockArtifact{ IdValue: t.ArtifactId, }, t.Keep, t.ForceOverride, t.Error } diff --git a/packer/rpc/artifact.go b/packer/rpc/artifact.go index ff64920bc..e8e7b3310 100644 --- a/packer/rpc/artifact.go +++ b/packer/rpc/artifact.go @@ -1,19 +1,19 @@ package rpc import ( - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.Artifact where the artifact is actually +// An implementation of packersdk.Artifact where the artifact is actually // available over an RPC connection. type artifact struct { commonClient } -// ArtifactServer wraps a packer.Artifact implementation and makes it +// ArtifactServer wraps a packersdk.Artifact implementation and makes it // exportable as part of a Golang RPC server. type ArtifactServer struct { - artifact packer.Artifact + artifact packersdk.Artifact } func (a *artifact) BuilderId() (result string) { diff --git a/packer/rpc/artifact_test.go b/packer/rpc/artifact_test.go index 2a0e7dab9..ebdec01fe 100644 --- a/packer/rpc/artifact_test.go +++ b/packer/rpc/artifact_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifactRPC(t *testing.T) { @@ -38,5 +39,5 @@ func TestArtifactRPC(t *testing.T) { } func TestArtifact_Implements(t *testing.T) { - var _ packer.Artifact = new(artifact) + var _ packersdk.Artifact = new(artifact) } diff --git a/packer/rpc/build.go b/packer/rpc/build.go index 58fa0e3d7..5cc530ced 100644 --- a/packer/rpc/build.go +++ b/packer/rpc/build.go @@ -47,7 +47,7 @@ func (b *build) Prepare() ([]string, error) { return resp.Warnings, err } -func (b *build) Run(ctx context.Context, ui packersdk.Ui) ([]packer.Artifact, error) { +func (b *build) Run(ctx context.Context, ui packersdk.Ui) ([]packersdk.Artifact, error) { nextId := b.mux.NextId() server := newServerWithMux(b.mux, nextId) server.RegisterUi(ui) @@ -71,7 +71,7 @@ func (b *build) Run(ctx context.Context, ui packersdk.Ui) ([]packer.Artifact, er return nil, err } - artifacts := make([]packer.Artifact, len(result)) + artifacts := make([]packersdk.Artifact, len(result)) for i, streamId := range result { client, err := newClientWithMux(b.mux, streamId) if err != nil { diff --git a/packer/rpc/build_test.go b/packer/rpc/build_test.go index ea4d4b22d..a2fd0ac93 100644 --- a/packer/rpc/build_test.go +++ b/packer/rpc/build_test.go @@ -36,7 +36,7 @@ func (b *testBuild) Prepare() ([]string, error) { return b.prepareWarnings, nil } -func (b *testBuild) Run(ctx context.Context, ui packersdk.Ui) ([]packer.Artifact, error) { +func (b *testBuild) Run(ctx context.Context, ui packersdk.Ui) ([]packersdk.Artifact, error) { b.runCalled = true b.runUi = ui @@ -47,7 +47,7 @@ func (b *testBuild) Run(ctx context.Context, ui packersdk.Ui) ([]packer.Artifact if b.errRunResult { return nil, errors.New("foo") } else { - return []packer.Artifact{testBuildArtifact}, nil + return []packersdk.Artifact{testBuildArtifact}, nil } } diff --git a/packer/rpc/builder.go b/packer/rpc/builder.go index 4e321dee0..8f6d5ed6b 100644 --- a/packer/rpc/builder.go +++ b/packer/rpc/builder.go @@ -52,7 +52,7 @@ func (b *builder) Prepare(config ...interface{}) ([]string, []string, error) { return resp.GeneratedVars, resp.Warnings, err } -func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packer.Artifact, error) { +func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { nextId := b.mux.NextId() server := newServerWithMux(b.mux, nextId) server.RegisterHook(hook) diff --git a/packer/rpc/client.go b/packer/rpc/client.go index ea2919c4b..5bf4e4c94 100644 --- a/packer/rpc/client.go +++ b/packer/rpc/client.go @@ -70,7 +70,7 @@ func (c *Client) Close() error { return nil } -func (c *Client) Artifact() packer.Artifact { +func (c *Client) Artifact() packersdk.Artifact { return &artifact{ commonClient: commonClient{ endpoint: DefaultArtifactEndpoint, diff --git a/packer/rpc/post_processor.go b/packer/rpc/post_processor.go index 9a5037796..92818b730 100644 --- a/packer/rpc/post_processor.go +++ b/packer/rpc/post_processor.go @@ -44,7 +44,7 @@ func (p *postProcessor) Configure(raw ...interface{}) error { return p.client.Call(p.endpoint+".Configure", args, new(interface{})) } -func (p *postProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *postProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { nextId := p.mux.NextId() server := newServerWithMux(p.mux, nextId) server.RegisterArtifact(a) diff --git a/packer/rpc/post_processor_test.go b/packer/rpc/post_processor_test.go index d4b5a01f2..2cccb017c 100644 --- a/packer/rpc/post_processor_test.go +++ b/packer/rpc/post_processor_test.go @@ -16,7 +16,7 @@ type TestPostProcessor struct { configCalled bool configVal []interface{} ppCalled bool - ppArtifact packer.Artifact + ppArtifact packersdk.Artifact ppArtifactId string ppUi packersdk.Ui @@ -31,7 +31,7 @@ func (pp *TestPostProcessor) Configure(v ...interface{}) error { return nil } -func (pp *TestPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (pp *TestPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { pp.ppCalled = true pp.ppArtifact = a pp.ppArtifactId = a.Id() diff --git a/packer/rpc/server.go b/packer/rpc/server.go index 5dea62ce6..48a37ab49 100644 --- a/packer/rpc/server.go +++ b/packer/rpc/server.go @@ -64,7 +64,7 @@ func (s *Server) Close() error { return nil } -func (s *Server) RegisterArtifact(a packer.Artifact) error { +func (s *Server) RegisterArtifact(a packersdk.Artifact) error { return s.server.RegisterName(DefaultArtifactEndpoint, &ArtifactServer{ artifact: a, }) diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index 8979be0a0..5d9a4a7f1 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -165,7 +165,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index a8b85d3f9..4931e2968 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -131,7 +131,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/artifice/post-processor.go b/post-processor/artifice/post-processor.go index ee4d7737d..5936e0d6a 100644 --- a/post-processor/artifice/post-processor.go +++ b/post-processor/artifice/post-processor.go @@ -8,7 +8,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -56,7 +55,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { if len(artifact.Files()) > 0 { ui.Say(fmt.Sprintf("Discarding files from artifact: %s", strings.Join(artifact.Files(), ", "))) } diff --git a/post-processor/checksum/post-processor.go b/post-processor/checksum/post-processor.go index ff5e58cc3..9143b330d 100644 --- a/post-processor/checksum/post-processor.go +++ b/post-processor/checksum/post-processor.go @@ -15,7 +15,6 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -96,7 +95,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { files := artifact.Files() var h hash.Hash diff --git a/post-processor/checksum/post-processor_test.go b/post-processor/checksum/post-processor_test.go index 2c41b5ac9..c54da0148 100644 --- a/post-processor/checksum/post-processor_test.go +++ b/post-processor/checksum/post-processor_test.go @@ -45,7 +45,7 @@ func TestChecksumSHA1(t *testing.T) { // Test Helpers -func setup(t *testing.T) (packersdk.Ui, packer.Artifact, error) { +func setup(t *testing.T) (packersdk.Ui, packersdk.Artifact, error) { // Create fake UI and Cache ui := packer.TestUi(t) @@ -77,7 +77,7 @@ func setup(t *testing.T) (packersdk.Ui, packer.Artifact, error) { return ui, artifact, err } -func testChecksum(t *testing.T, config string) packer.Artifact { +func testChecksum(t *testing.T, config string) packersdk.Artifact { ui, artifact, err := setup(t) if err != nil { t.Fatalf("Error bootstrapping test: %s", err) diff --git a/post-processor/compress/artifact_test.go b/post-processor/compress/artifact_test.go index ed39f4a73..86ee6c664 100644 --- a/post-processor/compress/artifact_test.go +++ b/post-processor/compress/artifact_test.go @@ -3,13 +3,13 @@ package compress import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_ImplementsArtifact(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be a Artifact!") } } diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index e30c723e0..c4edbfe42 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -15,7 +15,6 @@ import ( "github.com/biogo/hts/bgzf" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -109,8 +108,8 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { func (p *PostProcessor) PostProcess( ctx context.Context, ui packersdk.Ui, - artifact packer.Artifact, -) (packer.Artifact, bool, bool, error) { + artifact packersdk.Artifact, +) (packersdk.Artifact, bool, bool, error) { var generatedData map[interface{}]interface{} stateData := artifact.State("generated_data") if stateData != nil { diff --git a/post-processor/compress/post-processor_test.go b/post-processor/compress/post-processor_test.go index 15fa64f11..577ff2de6 100644 --- a/post-processor/compress/post-processor_test.go +++ b/post-processor/compress/post-processor_test.go @@ -185,7 +185,7 @@ func TestCompressInterpolation(t *testing.T) { // Test Helpers -func setup(t *testing.T) (packersdk.Ui, packer.Artifact, error) { +func setup(t *testing.T) (packersdk.Ui, packersdk.Artifact, error) { // Create fake UI and Cache ui := packer.TestUi(t) @@ -217,7 +217,7 @@ func setup(t *testing.T) (packersdk.Ui, packer.Artifact, error) { return ui, artifact, err } -func testArchive(t *testing.T, config string) packer.Artifact { +func testArchive(t *testing.T, config string) packersdk.Artifact { ui, artifact, err := setup(t) if err != nil { t.Fatalf("Error bootstrapping test: %s", err) diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index 9fb14ba6c..93666fd99 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -149,7 +149,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/docker-import/post-processor.go b/post-processor/docker-import/post-processor.go index cfce7a6a8..7eef23e69 100644 --- a/post-processor/docker-import/post-processor.go +++ b/post-processor/docker-import/post-processor.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -51,7 +50,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { switch artifact.BuilderId() { case docker.BuilderId, artifice.BuilderId: break diff --git a/post-processor/docker-push/post-processor.go b/post-processor/docker-push/post-processor.go index 723320752..c8d46d3d7 100644 --- a/post-processor/docker-push/post-processor.go +++ b/post-processor/docker-push/post-processor.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -59,7 +58,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { if artifact.BuilderId() != dockerimport.BuilderId && artifact.BuilderId() != dockertag.BuilderId { err := fmt.Errorf( diff --git a/post-processor/docker-push/post-processor_test.go b/post-processor/docker-push/post-processor_test.go index a1ef89aaa..79710333b 100644 --- a/post-processor/docker-push/post-processor_test.go +++ b/post-processor/docker-push/post-processor_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" ) @@ -30,7 +31,7 @@ func TestPostProcessor_PostProcess(t *testing.T) { } result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packer.Artifact); !ok { + if _, ok := result.(packersdk.Artifact); !ok { t.Fatal("should be instance of Artifact") } if !keep { @@ -63,7 +64,7 @@ func TestPostProcessor_PostProcess_portInName(t *testing.T) { } result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packer.Artifact); !ok { + if _, ok := result.(packersdk.Artifact); !ok { t.Fatal("should be instance of Artifact") } if !keep { @@ -96,7 +97,7 @@ func TestPostProcessor_PostProcess_tags(t *testing.T) { } result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packer.Artifact); !ok { + if _, ok := result.(packersdk.Artifact); !ok { t.Fatal("should be instance of Artifact") } if !keep { diff --git a/post-processor/docker-save/post-processor.go b/post-processor/docker-save/post-processor.go index a15c7221e..e3a7a3d7c 100644 --- a/post-processor/docker-save/post-processor.go +++ b/post-processor/docker-save/post-processor.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -53,7 +52,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { if artifact.BuilderId() != dockerimport.BuilderId && artifact.BuilderId() != dockertag.BuilderId { err := fmt.Errorf( diff --git a/post-processor/docker-tag/post-processor.go b/post-processor/docker-tag/post-processor.go index 21c8de182..8344c6e6a 100644 --- a/post-processor/docker-tag/post-processor.go +++ b/post-processor/docker-tag/post-processor.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -61,7 +60,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { if len(p.config.Tag) > 0 { ui.Say("Deprecation warning: \"tag\" option has been replaced with " + "\"tags\". In future versions of Packer, this configuration may " + diff --git a/post-processor/docker-tag/post-processor_test.go b/post-processor/docker-tag/post-processor_test.go index 19d12c555..e61489bf1 100644 --- a/post-processor/docker-tag/post-processor_test.go +++ b/post-processor/docker-tag/post-processor_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" "github.com/stretchr/testify/assert" ) @@ -51,7 +52,7 @@ func TestPostProcessor_PostProcess(t *testing.T) { } result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packer.Artifact); !ok { + if _, ok := result.(packersdk.Artifact); !ok { t.Fatal("should be instance of Artifact") } if !keep { @@ -99,7 +100,7 @@ func TestPostProcessor_PostProcess_Force(t *testing.T) { } result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packer.Artifact); !ok { + if _, ok := result.(packersdk.Artifact); !ok { t.Fatal("should be instance of Artifact") } if !keep { @@ -141,7 +142,7 @@ func TestPostProcessor_PostProcess_NoTag(t *testing.T) { artifact := &packer.MockArtifact{BuilderIdValue: dockerimport.BuilderId, IdValue: "1234567890abcdef"} result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packer.Artifact); !ok { + if _, ok := result.(packersdk.Artifact); !ok { t.Fatal("should be instance of Artifact") } if !keep { diff --git a/post-processor/exoscale-import/post-processor.go b/post-processor/exoscale-import/post-processor.go index 7ff1fb4f8..679eeb0f1 100644 --- a/post-processor/exoscale-import/post-processor.go +++ b/post-processor/exoscale-import/post-processor.go @@ -106,7 +106,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { switch a.BuilderId() { case qemu.BuilderId, file.BuilderId, artifice.BuilderId: break @@ -140,7 +140,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a pack return &Artifact{id}, false, false, nil } -func (p *PostProcessor) uploadImage(ctx context.Context, ui packersdk.Ui, a packer.Artifact) (string, string, error) { +func (p *PostProcessor) uploadImage(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) (string, string, error) { var ( imageFile = a.Files()[0] bucketFile = filepath.Base(imageFile) @@ -189,7 +189,7 @@ func (p *PostProcessor) uploadImage(ctx context.Context, ui packersdk.Ui, a pack return output.Location, fmt.Sprintf("%x", hash.Sum(nil)), nil } -func (p *PostProcessor) deleteImage(ctx context.Context, ui packersdk.Ui, a packer.Artifact) error { +func (p *PostProcessor) deleteImage(ctx context.Context, ui packersdk.Ui, a packersdk.Artifact) error { var ( imageFile = a.Files()[0] bucketFile = filepath.Base(imageFile) diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index 9c69d93e1..29c51aecf 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/googlecompute" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -119,7 +118,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { switch artifact.BuilderId() { case googlecompute.BuilderId, artifice.BuilderId: break diff --git a/post-processor/googlecompute-import/artifact_test.go b/post-processor/googlecompute-import/artifact_test.go index 9d53c0b07..d27f24aa3 100644 --- a/post-processor/googlecompute-import/artifact_test.go +++ b/post-processor/googlecompute-import/artifact_test.go @@ -3,13 +3,13 @@ package googlecomputeimport import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_ImplementsArtifact(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be a Artifact") } } diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index d96157702..ea114eeb8 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -20,7 +20,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/googlecompute" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -144,7 +143,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { generatedData := artifact.State("generated_data") if generatedData == nil { // Make sure it's not a nil map so we can assign to it later. @@ -260,7 +259,7 @@ func CreateShieldedVMStateConfig(imageGuestOsFeatures []string, imagePlatformKey return shieldedVMStateConfig, nil } -func UploadToBucket(opts option.ClientOption, ui packersdk.Ui, artifact packer.Artifact, bucket string, gcsObjectName string) (string, error) { +func UploadToBucket(opts option.ClientOption, ui packersdk.Ui, artifact packersdk.Artifact, bucket string, gcsObjectName string) (string, error) { service, err := storage.NewService(context.TODO(), opts) if err != nil { return "", err @@ -296,7 +295,11 @@ func UploadToBucket(opts option.ClientOption, ui packersdk.Ui, artifact packer.A return storageObject.SelfLink, nil } +<<<<<<< HEAD func CreateGceImage(opts option.ClientOption, ui packersdk.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string, shieldedVMStateConfig *compute.InitialStateConfig) (packer.Artifact, error) { +======= +func CreateGceImage(opts option.ClientOption, ui packersdk.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string) (packersdk.Artifact, error) { +>>>>>>> move Artifact and artifact mock to the sdk service, err := compute.NewService(context.TODO(), opts) if err != nil { diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index ce6308294..48c266f5b 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -14,7 +14,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -74,7 +73,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { generatedData := source.State("generated_data") if generatedData == nil { // Make sure it's not a nil map so we can assign to it later. diff --git a/post-processor/shell-local/post-processor.go b/post-processor/shell-local/post-processor.go index 574e97a7d..3909cbb0c 100644 --- a/post-processor/shell-local/post-processor.go +++ b/post-processor/shell-local/post-processor.go @@ -4,7 +4,6 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" ) @@ -41,7 +40,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return sl.Validate(&p.config) } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { generatedData := make(map[string]interface{}) artifactStateData := artifact.State("generated_data") if artifactStateData != nil { diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index b11ef97a9..bead1f18a 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -155,7 +155,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { var err error generatedData := artifact.State("generated_data") diff --git a/post-processor/vagrant-cloud/artifact_test.go b/post-processor/vagrant-cloud/artifact_test.go index 6c633ea84..2a3d5c735 100644 --- a/post-processor/vagrant-cloud/artifact_test.go +++ b/post-processor/vagrant-cloud/artifact_test.go @@ -3,13 +3,13 @@ package vagrantcloud import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_ImplementsArtifact(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be a Artifact") } } diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index 34a3cf2d1..4b87f0c4b 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -19,7 +19,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -130,7 +129,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { if _, ok := builtins[artifact.BuilderId()]; !ok { return nil, false, false, fmt.Errorf( "Unknown artifact type: this post-processor requires an input artifact from the artifice post-processor, vagrant post-processor, or vagrant builder: %s", artifact.BuilderId()) diff --git a/post-processor/vagrant/artifact_test.go b/post-processor/vagrant/artifact_test.go index 7b087d963..10c91a859 100644 --- a/post-processor/vagrant/artifact_test.go +++ b/post-processor/vagrant/artifact_test.go @@ -3,13 +3,13 @@ package vagrant import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_ImplementsArtifact(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be a Artifact") } } diff --git a/post-processor/vagrant/aws.go b/post-processor/vagrant/aws.go index dac7ecc06..bce500935 100644 --- a/post-processor/vagrant/aws.go +++ b/post-processor/vagrant/aws.go @@ -6,7 +6,6 @@ import ( "strings" "text/template" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -16,7 +15,7 @@ func (p *AWSProvider) KeepInputArtifact() bool { return true } -func (p *AWSProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *AWSProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "aws"} diff --git a/post-processor/vagrant/azure.go b/post-processor/vagrant/azure.go index 55bb016a7..15887aed8 100644 --- a/post-processor/vagrant/azure.go +++ b/post-processor/vagrant/azure.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -14,7 +13,7 @@ func (p *AzureProvider) KeepInputArtifact() bool { return true } -func (p *AzureProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *AzureProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "azure"} diff --git a/post-processor/vagrant/digitalocean.go b/post-processor/vagrant/digitalocean.go index 28bbd7a63..8e218b974 100644 --- a/post-processor/vagrant/digitalocean.go +++ b/post-processor/vagrant/digitalocean.go @@ -6,7 +6,6 @@ import ( "strings" "text/template" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -21,7 +20,7 @@ func (p *DigitalOceanProvider) KeepInputArtifact() bool { return true } -func (p *DigitalOceanProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *DigitalOceanProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "digital_ocean"} diff --git a/post-processor/vagrant/docker.go b/post-processor/vagrant/docker.go index a4ab0b85c..4156833ae 100644 --- a/post-processor/vagrant/docker.go +++ b/post-processor/vagrant/docker.go @@ -3,7 +3,6 @@ package vagrant import ( "fmt" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -13,7 +12,7 @@ func (p *DockerProvider) KeepInputArtifact() bool { return false } -func (p *DockerProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *DockerProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "docker"} diff --git a/post-processor/vagrant/google.go b/post-processor/vagrant/google.go index fb14d55b6..14ff46afe 100644 --- a/post-processor/vagrant/google.go +++ b/post-processor/vagrant/google.go @@ -4,7 +4,6 @@ import ( "bytes" "text/template" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -18,7 +17,7 @@ func (p *GoogleProvider) KeepInputArtifact() bool { return true } -func (p *GoogleProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *GoogleProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "google"} diff --git a/post-processor/vagrant/hyperv.go b/post-processor/vagrant/hyperv.go index 9058aa54a..49ebb4ecd 100644 --- a/post-processor/vagrant/hyperv.go +++ b/post-processor/vagrant/hyperv.go @@ -6,7 +6,6 @@ import ( "path/filepath" "strings" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -16,7 +15,7 @@ func (p *HypervProvider) KeepInputArtifact() bool { return false } -func (p *HypervProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *HypervProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "hyperv"} diff --git a/post-processor/vagrant/libvirt.go b/post-processor/vagrant/libvirt.go index 085935210..679a15e96 100644 --- a/post-processor/vagrant/libvirt.go +++ b/post-processor/vagrant/libvirt.go @@ -6,7 +6,6 @@ import ( "strconv" "strings" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -64,7 +63,7 @@ type LibVirtProvider struct{} func (p *LibVirtProvider) KeepInputArtifact() bool { return false } -func (p *LibVirtProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *LibVirtProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { diskName := artifact.State("diskName").(string) // Copy the disk image into the temporary directory (as box.img) diff --git a/post-processor/vagrant/lxc.go b/post-processor/vagrant/lxc.go index d5955df7d..26eb5106c 100644 --- a/post-processor/vagrant/lxc.go +++ b/post-processor/vagrant/lxc.go @@ -4,7 +4,6 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -14,7 +13,7 @@ func (p *LXCProvider) KeepInputArtifact() bool { return false } -func (p *LXCProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *LXCProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{ "provider": "lxc", diff --git a/post-processor/vagrant/parallels.go b/post-processor/vagrant/parallels.go index c84bc832b..f98be6d7d 100644 --- a/post-processor/vagrant/parallels.go +++ b/post-processor/vagrant/parallels.go @@ -5,7 +5,6 @@ import ( "path/filepath" "regexp" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -19,7 +18,7 @@ func (p *ParallelsProvider) KeepInputArtifact() bool { return false } -func (p *ParallelsProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *ParallelsProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "parallels"} diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index bd8e61f45..e73739989 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -16,7 +16,6 @@ import ( "text/template" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -105,7 +104,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) { +func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, error) { config, err := p.specificConfig(name) if err != nil { return nil, false, err @@ -205,7 +204,7 @@ func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui p return NewArtifact(name, outputPath), provider.KeepInputArtifact(), nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { name := p.config.ProviderOverride if name == "" { n, ok := builtins[artifact.BuilderId()] diff --git a/post-processor/vagrant/provider.go b/post-processor/vagrant/provider.go index 28d11bbe1..35e4d85cb 100644 --- a/post-processor/vagrant/provider.go +++ b/post-processor/vagrant/provider.go @@ -1,7 +1,6 @@ package vagrant import ( - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -19,5 +18,5 @@ type Provider interface { // The Provider should return the contents for the Vagrantfile, // any metadata (including the provider type in that), and an error // if any. - Process(packersdk.Ui, packer.Artifact, string) (vagrantfile string, metadata map[string]interface{}, err error) + Process(packersdk.Ui, packersdk.Artifact, string) (vagrantfile string, metadata map[string]interface{}, err error) } diff --git a/post-processor/vagrant/scaleway.go b/post-processor/vagrant/scaleway.go index 9a6ec7087..6277c6c2b 100644 --- a/post-processor/vagrant/scaleway.go +++ b/post-processor/vagrant/scaleway.go @@ -6,7 +6,6 @@ import ( "strings" "text/template" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -21,7 +20,7 @@ func (p *ScalewayProvider) KeepInputArtifact() bool { return true } -func (p *ScalewayProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *ScalewayProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "scaleway"} diff --git a/post-processor/vagrant/virtualbox.go b/post-processor/vagrant/virtualbox.go index afcbeb29c..834b3a82b 100644 --- a/post-processor/vagrant/virtualbox.go +++ b/post-processor/vagrant/virtualbox.go @@ -11,7 +11,6 @@ import ( "path/filepath" "regexp" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -21,7 +20,7 @@ func (p *VBoxProvider) KeepInputArtifact() bool { return false } -func (p *VBoxProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *VBoxProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "virtualbox"} diff --git a/post-processor/vagrant/vmware.go b/post-processor/vagrant/vmware.go index 83db1964b..3d775a2b0 100644 --- a/post-processor/vagrant/vmware.go +++ b/post-processor/vagrant/vmware.go @@ -4,7 +4,6 @@ import ( "fmt" "path/filepath" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -14,7 +13,7 @@ func (p *VMwareProvider) KeepInputArtifact() bool { return false } -func (p *VMwareProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { +func (p *VMwareProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { // Create the metadata metadata = map[string]interface{}{"provider": "vmware_desktop"} diff --git a/post-processor/vsphere-template/post-processor.go b/post-processor/vsphere-template/post-processor.go index fdb451ba9..1967e3735 100644 --- a/post-processor/vsphere-template/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" vsphere "github.com/hashicorp/packer/builder/vsphere/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -104,7 +103,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { if _, ok := builtins[artifact.BuilderId()]; !ok { return nil, false, false, fmt.Errorf("The Packer vSphere Template post-processor "+ "can only take an artifact from the VMware-iso builder, built on "+ diff --git a/post-processor/vsphere-template/step_create_snapshot.go b/post-processor/vsphere-template/step_create_snapshot.go index 302091e82..11d977e73 100644 --- a/post-processor/vsphere-template/step_create_snapshot.go +++ b/post-processor/vsphere-template/step_create_snapshot.go @@ -4,7 +4,6 @@ import ( "context" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/post-processor/vsphere" @@ -19,7 +18,7 @@ type stepCreateSnapshot struct { SnapshotEnable bool } -func NewStepCreateSnapshot(artifact packer.Artifact, p *PostProcessor) *stepCreateSnapshot { +func NewStepCreateSnapshot(artifact packersdk.Artifact, p *PostProcessor) *stepCreateSnapshot { remoteFolder := "Discovered virtual machine" vmname := artifact.Id() diff --git a/post-processor/vsphere-template/step_mark_as_template.go b/post-processor/vsphere-template/step_mark_as_template.go index 87df4b008..76228cae2 100644 --- a/post-processor/vsphere-template/step_mark_as_template.go +++ b/post-processor/vsphere-template/step_mark_as_template.go @@ -7,7 +7,6 @@ import ( "regexp" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -23,7 +22,7 @@ type stepMarkAsTemplate struct { ReregisterVM config.Trilean } -func NewStepMarkAsTemplate(artifact packer.Artifact, p *PostProcessor) *stepMarkAsTemplate { +func NewStepMarkAsTemplate(artifact packersdk.Artifact, p *PostProcessor) *stepMarkAsTemplate { remoteFolder := "Discovered virtual machine" vmname := artifact.Id() diff --git a/post-processor/vsphere/artifact_test.go b/post-processor/vsphere/artifact_test.go index f6d0d54be..f1b57508e 100644 --- a/post-processor/vsphere/artifact_test.go +++ b/post-processor/vsphere/artifact_test.go @@ -3,13 +3,13 @@ package vsphere import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifact_ImplementsArtifact(t *testing.T) { var raw interface{} raw = &Artifact{} - if _, ok := raw.(packer.Artifact); !ok { + if _, ok := raw.(packersdk.Artifact); !ok { t.Fatalf("Artifact should be a Artifact") } } diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index 1136e765e..6d0198437 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -156,7 +156,7 @@ func getEncodedPassword(u *url.URL) (string, bool) { return password, false } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { source := "" for _, path := range artifact.Files() { if strings.HasSuffix(path, ".vmx") || strings.HasSuffix(path, ".ovf") || strings.HasSuffix(path, ".ova") { diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index b0a7c6f81..69a0b4c6b 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/yandex" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -128,7 +127,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { switch artifact.BuilderId() { case yandex.BuilderID, artifice.BuilderId: break diff --git a/post-processor/yandex-import/post-processor.go b/post-processor/yandex-import/post-processor.go index a346e20a7..58445c1d4 100644 --- a/post-processor/yandex-import/post-processor.go +++ b/post-processor/yandex-import/post-processor.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/builder/yandex" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -122,7 +121,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return nil } -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) { +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { var imageSrc cloudImageSource var fileSource bool var err error @@ -229,7 +228,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa }, false, false, nil } -func chooseSource(a packer.Artifact) (cloudImageSource, error) { +func chooseSource(a packersdk.Artifact) (cloudImageSource, error) { st := a.State("source_type").(string) if st == "" { return nil, fmt.Errorf("could not determine source type of yandex-import artifact: %v", a) diff --git a/post-processor/yandex-import/utils.go b/post-processor/yandex-import/utils.go index f6978af34..d9a10844b 100644 --- a/post-processor/yandex-import/utils.go +++ b/post-processor/yandex-import/utils.go @@ -9,12 +9,11 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" "github.com/hashicorp/packer/builder/yandex" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1" ) -func uploadToBucket(s3conn *s3.S3, ui packersdk.Ui, artifact packer.Artifact, bucket string, objectName string) (cloudImageSource, error) { +func uploadToBucket(s3conn *s3.S3, ui packersdk.Ui, artifact packersdk.Artifact, bucket string, objectName string) (cloudImageSource, error) { ui.Say("Looking for qcow2 file in list of artifacts...") source := "" for _, path := range artifact.Files() { From a6fdeca099f3c13c9e6749896ed26952abb6335f Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Nov 2020 14:03:11 -0800 Subject: [PATCH 04/10] move logsecretfilter into packer sdk --- builder/alicloud/ecs/builder.go | 2 +- builder/amazon/chroot/builder.go | 2 +- builder/amazon/common/step_get_password.go | 3 +- builder/amazon/ebs/builder.go | 2 +- builder/amazon/ebssurrogate/builder.go | 2 +- builder/amazon/ebsvolume/builder.go | 2 +- builder/amazon/instance/builder.go | 2 +- builder/azure/arm/config.go | 3 +- builder/azure/chroot/builder.go | 2 +- builder/azure/dtl/config.go | 3 +- builder/azure/dtl/step_save_winrm_password.go | 4 +-- builder/digitalocean/config.go | 3 +- .../step_create_windows_password.go | 5 ++- builder/hcloud/config.go | 3 +- builder/hyperone/config.go | 3 +- builder/jdcloud/builder.go | 2 +- builder/linode/config.go | 3 +- builder/oneandone/config.go | 3 +- builder/openstack/builder.go | 2 +- builder/openstack/step_get_password.go | 3 +- .../oci/step_get_default_credentials.go | 3 +- builder/osc/bsu/builder.go | 2 +- builder/osc/bsusurrogate/builder.go | 2 +- builder/osc/bsuvolume/builder.go | 2 +- builder/osc/chroot/builder.go | 2 +- builder/osc/common/step_get_password.go | 3 +- builder/profitbricks/config.go | 3 +- builder/proxmox/common/config.go | 3 +- builder/scaleway/config.go | 5 ++- builder/tencentcloud/cvm/builder.go | 2 +- builder/ucloud/uhost/builder.go | 2 +- builder/yandex/access_config.go | 4 +-- hcl2template/parser.go | 3 +- main.go | 8 ++--- {packer => packer-plugin-sdk/packer}/logs.go | 12 +++++++ .../shell-local/localexec/run_and_stream.go | 3 +- packer/core.go | 3 +- packer/core_test.go | 5 +-- packer/ui.go | 32 +++++-------------- .../alicloud-import/post-processor.go | 3 +- .../amazon-import/post-processor.go | 3 +- .../digitalocean-import/post-processor.go | 3 +- .../exoscale-import/post-processor.go | 3 +- .../ucloud-import/post-processor.go | 3 +- post-processor/vsphere/post-processor.go | 2 +- 45 files changed, 74 insertions(+), 96 deletions(-) rename {packer => packer-plugin-sdk/packer}/logs.go (72%) diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 160fd734a..106ac4287 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -77,7 +77,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.AlicloudAccessKey, b.config.AlicloudSecretKey) + packersdk.LogSecretFilter.Set(b.config.AlicloudAccessKey, b.config.AlicloudSecretKey) return nil, nil, nil } diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 5fdb9f315..79a99c43f 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -339,7 +339,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) generatedData := awscommon.GetGeneratedDataList() generatedData = append(generatedData, "Device", "MountPath") diff --git a/builder/amazon/common/step_get_password.go b/builder/amazon/common/step_get_password.go index f1e1410cc..b35de86cd 100644 --- a/builder/amazon/common/step_get_password.go +++ b/builder/amazon/common/step_get_password.go @@ -13,7 +13,6 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -92,7 +91,7 @@ WaitLoop: } // store so that we can access this later during provisioning state.Put("winrm_password", s.Comm.WinRMPassword) - packer.LogSecretFilter.Set(s.Comm.WinRMPassword) + packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword) return multistep.ActionContinue } diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 5831b7648..17edd4744 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -145,7 +145,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) generatedData := awscommon.GetGeneratedDataList() return generatedData, warns, nil diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 93ffa92dd..030255413 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -168,7 +168,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) generatedData := awscommon.GetGeneratedDataList() return generatedData, warns, nil diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index ac6bd8250..b7e872ad9 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) generatedData := awscommon.GetGeneratedDataList() return generatedData, warns, nil diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index f5b263bdd..a06fd4656 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -228,7 +228,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { if errs != nil && len(errs.Errors) > 0 { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) generatedData := awscommon.GetGeneratedDataList() return generatedData, warns, nil diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index ee050f9e5..b193ea099 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -29,7 +29,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/pkcs12" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -690,7 +689,7 @@ func setRuntimeValues(c *Config) { c.tmpAdminPassword = tempName.AdminPassword // store so that we can access this later during provisioning - packer.LogSecretFilter.Set(c.tmpAdminPassword) + packersdk.LogSecretFilter.Set(c.tmpAdminPassword) c.tmpCertificatePassword = tempName.CertificatePassword if c.TempComputeName == "" { diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index 23a7f6092..ab3b74346 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -359,7 +359,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.ClientConfig.ClientSecret, b.config.ClientConfig.ClientJWT) + packersdk.LogSecretFilter.Set(b.config.ClientConfig.ClientSecret, b.config.ClientConfig.ClientJWT) return nil, warns, nil } diff --git a/builder/azure/dtl/config.go b/builder/azure/dtl/config.go index aa49c7ccb..de4ed8138 100644 --- a/builder/azure/dtl/config.go +++ b/builder/azure/dtl/config.go @@ -25,7 +25,6 @@ import ( "github.com/hashicorp/packer/builder/azure/pkcs12" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -492,7 +491,7 @@ func setRuntimeValues(c *Config) { var tempName = NewTempName(c) c.tmpAdminPassword = tempName.AdminPassword - packer.LogSecretFilter.Set(c.tmpAdminPassword) + packersdk.LogSecretFilter.Set(c.tmpAdminPassword) c.tmpCertificatePassword = tempName.CertificatePassword c.tmpComputeName = tempName.ComputeName diff --git a/builder/azure/dtl/step_save_winrm_password.go b/builder/azure/dtl/step_save_winrm_password.go index ab81bcc80..569f82557 100644 --- a/builder/azure/dtl/step_save_winrm_password.go +++ b/builder/azure/dtl/step_save_winrm_password.go @@ -3,8 +3,8 @@ package dtl import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type StepSaveWinRMPassword struct { @@ -15,7 +15,7 @@ type StepSaveWinRMPassword struct { func (s *StepSaveWinRMPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // store so that we can access this later during provisioning state.Put("winrm_password", s.Password) - packer.LogSecretFilter.Set(s.Password) + packersdk.LogSecretFilter.Set(s.Password) return multistep.ActionContinue } diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index 529ee481f..3f372783c 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -11,7 +11,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -214,6 +213,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, errs } - packer.LogSecretFilter.Set(c.APIToken) + packersdk.LogSecretFilter.Set(c.APIToken) return nil, nil } diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index 54d6f75e5..3c012a2f3 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -13,7 +13,6 @@ import ( "os" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -33,7 +32,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta if c.Comm.WinRMPassword != "" { state.Put("winrm_password", c.Comm.WinRMPassword) - packer.LogSecretFilter.Set(c.Comm.WinRMPassword) + packersdk.LogSecretFilter.Set(c.Comm.WinRMPassword) return multistep.ActionContinue } @@ -119,7 +118,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta } state.Put("winrm_password", data.password) - packer.LogSecretFilter.Set(data.password) + packersdk.LogSecretFilter.Set(data.password) return multistep.ActionContinue } diff --git a/builder/hcloud/config.go b/builder/hcloud/config.go index 3dae727a3..023448dc3 100644 --- a/builder/hcloud/config.go +++ b/builder/hcloud/config.go @@ -9,7 +9,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -144,7 +143,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, errs } - packer.LogSecretFilter.Set(c.HCloudToken) + packersdk.LogSecretFilter.Set(c.HCloudToken) return nil, nil } diff --git a/builder/hyperone/config.go b/builder/hyperone/config.go index b8fca7937..65ed2e577 100644 --- a/builder/hyperone/config.go +++ b/builder/hyperone/config.go @@ -11,7 +11,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/json" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -308,7 +307,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, errs } - packer.LogSecretFilter.Set(c.Token) + packersdk.LogSecretFilter.Set(c.Token) return nil, nil } diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index fbbb9881e..dee0cd225 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -38,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey) return nil, nil, nil } diff --git a/builder/linode/config.go b/builder/linode/config.go index 0c84ffdcc..947fd8271 100644 --- a/builder/linode/config.go +++ b/builder/linode/config.go @@ -12,7 +12,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -144,6 +143,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return nil, errs } - packer.LogSecretFilter.Set(c.PersonalAccessToken) + packersdk.LogSecretFilter.Set(c.PersonalAccessToken) return nil, nil } diff --git a/builder/oneandone/config.go b/builder/oneandone/config.go index ebe1ccaed..283a78e8d 100644 --- a/builder/oneandone/config.go +++ b/builder/oneandone/config.go @@ -9,7 +9,6 @@ import ( "github.com/1and1/oneandone-cloudserver-sdk-go" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -109,6 +108,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if errs != nil && len(errs.Errors) > 0 { return nil, errs } - packer.LogSecretFilter.Set(c.Token) + packersdk.LogSecretFilter.Set(c.Token) return nil, nil } diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 206f6146f..17ee636a3 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -69,7 +69,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.InstanceName = b.config.ImageName } - packer.LogSecretFilter.Set(b.config.Password) + packersdk.LogSecretFilter.Set(b.config.Password) return nil, nil, nil } diff --git a/builder/openstack/step_get_password.go b/builder/openstack/step_get_password.go index 6d77bbb71..34737fedb 100644 --- a/builder/openstack/step_get_password.go +++ b/builder/openstack/step_get_password.go @@ -9,7 +9,6 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" @@ -78,7 +77,7 @@ func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) mul "Password (since debug is enabled) \"%s\"", s.Comm.WinRMPassword)) } - packer.LogSecretFilter.Set(s.Comm.WinRMPassword) + packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword) return multistep.ActionContinue } diff --git a/builder/oracle/oci/step_get_default_credentials.go b/builder/oracle/oci/step_get_default_credentials.go index 902f8c050..62b79a48c 100644 --- a/builder/oracle/oci/step_get_default_credentials.go +++ b/builder/oracle/oci/step_get_default_credentials.go @@ -6,7 +6,6 @@ import ( "log" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -53,7 +52,7 @@ func (s *stepGetDefaultCredentials) Run(ctx context.Context, state multistep.Sta // store so that we can access this later during provisioning state.Put("winrm_password", s.Comm.WinRMPassword) - packer.LogSecretFilter.Set(s.Comm.WinRMPassword) + packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword) return multistep.ActionContinue } diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index d5b05252e..8498936e1 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -81,7 +81,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) return nil, nil, nil } diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index f7c607004..f3877cc06 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -98,7 +98,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) return nil, nil, nil } diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 7a3d6d3a4..9509be632 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -84,7 +84,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) return nil, nil, nil } diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index b15441256..7a72943d7 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -184,7 +184,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, errs } - packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) + packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token) return nil, warns, nil } diff --git a/builder/osc/common/step_get_password.go b/builder/osc/common/step_get_password.go index c68570601..f3f3694b1 100644 --- a/builder/osc/common/step_get_password.go +++ b/builder/osc/common/step_get_password.go @@ -13,7 +13,6 @@ import ( "github.com/antihax/optional" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/outscale/osc-sdk-go/osc" @@ -96,7 +95,7 @@ WaitLoop: "Password (since debug is enabled): %s", s.Comm.WinRMPassword)) } // store so that we can access this later during provisioning - packer.LogSecretFilter.Set(s.Comm.WinRMPassword) + packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword) return multistep.ActionContinue } diff --git a/builder/profitbricks/config.go b/builder/profitbricks/config.go index a086e64db..20bd7e99e 100644 --- a/builder/profitbricks/config.go +++ b/builder/profitbricks/config.go @@ -7,7 +7,6 @@ import ( "os" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -123,7 +122,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if errs != nil && len(errs.Errors) > 0 { return nil, errs } - packer.LogSecretFilter.Set(c.PBUsername) + packersdk.LogSecretFilter.Set(c.PBUsername) return nil, nil } diff --git a/builder/proxmox/common/config.go b/builder/proxmox/common/config.go index 6ed893dbd..83e3c3433 100644 --- a/builder/proxmox/common/config.go +++ b/builder/proxmox/common/config.go @@ -12,7 +12,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -123,7 +122,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st var errs *packersdk.MultiError var warnings []string - packer.LogSecretFilter.Set(c.Password) + packersdk.LogSecretFilter.Set(c.Password) // Defaults if c.ProxmoxURLRaw == "" { diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index d65c37ea6..914796ff1 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/packer/builder/scaleway/version" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -260,7 +259,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { return warnings, errs } - packer.LogSecretFilter.Set(c.Token) - packer.LogSecretFilter.Set(c.SecretKey) + packersdk.LogSecretFilter.Set(c.Token) + packersdk.LogSecretFilter.Set(c.SecretKey) return warnings, nil } diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 4d2c2c653..2f2a8acb0 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -60,7 +60,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.SecretId, b.config.SecretKey) + packersdk.LogSecretFilter.Set(b.config.SecretId, b.config.SecretKey) return nil, nil, nil } diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index c0d239dc7..02a9da6cd 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -64,7 +64,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs } - packer.LogSecretFilter.Set(b.config.PublicKey, b.config.PrivateKey) + packersdk.LogSecretFilter.Set(b.config.PublicKey, b.config.PrivateKey) return nil, nil, nil } diff --git a/builder/yandex/access_config.go b/builder/yandex/access_config.go index 9554d0b83..413e4e617 100644 --- a/builder/yandex/access_config.go +++ b/builder/yandex/access_config.go @@ -7,7 +7,7 @@ import ( "fmt" "os" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/yandex-cloud/go-sdk/iamkey" ) @@ -52,7 +52,7 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error { } if c.Token != "" { - packer.LogSecretFilter.Set(c.Token) + packersdk.LogSecretFilter.Set(c.Token) } if c.ServiceAccountKeyFile != "" { diff --git a/hcl2template/parser.go b/hcl2template/parser.go index 2a856a16f..32c437a61 100644 --- a/hcl2template/parser.go +++ b/hcl2template/parser.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/hcl/v2/ext/dynblock" "github.com/hashicorp/hcl/v2/hclparse" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -260,7 +261,7 @@ func (cfg *PackerConfig) Initialize() hcl.Diagnostics { value, _ := variable.Value() _ = cty.Walk(value, func(_ cty.Path, nested cty.Value) (bool, error) { if nested.IsWhollyKnown() && !nested.IsNull() && nested.Type().Equals(cty.String) { - packer.LogSecretFilter.Set(nested.AsString()) + packersdk.LogSecretFilter.Set(nested.AsString()) } return true, nil }) diff --git a/main.go b/main.go index 3041a22e5..91e84db13 100644 --- a/main.go +++ b/main.go @@ -65,7 +65,7 @@ func realMain() int { logWriter = ioutil.Discard } - packer.LogSecretFilter.SetOutput(logWriter) + packersdk.LogSecretFilter.SetOutput(logWriter) // Disable logging here log.SetOutput(ioutil.Discard) @@ -99,7 +99,7 @@ func realMain() int { // Create the configuration for panicwrap and wrap our executable wrapConfig.Handler = panicHandler(logTempFile) - wrapConfig.Writer = io.MultiWriter(logTempFile, &packer.LogSecretFilter) + wrapConfig.Writer = io.MultiWriter(logTempFile, &packersdk.LogSecretFilter) wrapConfig.Stdout = outW wrapConfig.DetectDuration = 500 * time.Millisecond wrapConfig.ForwardSignals = []os.Signal{syscall.SIGTERM} @@ -135,8 +135,8 @@ func wrappedMain() int { runtime.GOMAXPROCS(runtime.NumCPU()) } - packer.LogSecretFilter.SetOutput(os.Stderr) - log.SetOutput(&packer.LogSecretFilter) + packersdk.LogSecretFilter.SetOutput(os.Stderr) + log.SetOutput(&packersdk.LogSecretFilter) inPlugin := inPlugin() if inPlugin { diff --git a/packer/logs.go b/packer-plugin-sdk/packer/logs.go similarity index 72% rename from packer/logs.go rename to packer-plugin-sdk/packer/logs.go index e510fd069..209b66ca3 100644 --- a/packer/logs.go +++ b/packer-plugin-sdk/packer/logs.go @@ -3,6 +3,7 @@ package packer import ( "bytes" "io" + "strings" "sync" ) @@ -35,6 +36,17 @@ func (l *secretFilter) Write(p []byte) (n int, err error) { return l.w.Write(p) } +// FilterString will overwrite any senstitive variables in a string, returning +// the filtered string. +func (l *secretFilter) FilterString(message string) string { + for s := range l.s { + if s != "" { + message = strings.Replace(message, s, "", -1) + } + } + return message +} + func (l *secretFilter) get() (s []string) { l.m.Lock() defer l.m.Unlock() diff --git a/packer-plugin-sdk/shell-local/localexec/run_and_stream.go b/packer-plugin-sdk/shell-local/localexec/run_and_stream.go index c5f932015..9555d2660 100644 --- a/packer-plugin-sdk/shell-local/localexec/run_and_stream.go +++ b/packer-plugin-sdk/shell-local/localexec/run_and_stream.go @@ -10,7 +10,6 @@ import ( "sync" "syscall" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/iochan" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -26,7 +25,7 @@ func RunAndStream(cmd *exec.Cmd, ui packersdk.Ui, sensitive []string) error { defer stderr_w.Close() // Scrub any sensitive values from being printed to Packer ui. - packer.LogSecretFilter.Set(sensitive...) + packersdk.LogSecretFilter.Set(sensitive...) args := make([]string, len(cmd.Args)-1) copy(args, cmd.Args[1:]) diff --git a/packer/core.go b/packer/core.go index 218c764a8..0c2759f01 100644 --- a/packer/core.go +++ b/packer/core.go @@ -15,6 +15,7 @@ import ( multierror "github.com/hashicorp/go-multierror" version "github.com/hashicorp/go-version" "github.com/hashicorp/hcl/v2" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -113,7 +114,7 @@ func (core *Core) Initialize() error { return err } for _, secret := range core.secrets { - LogSecretFilter.Set(secret) + packersdk.LogSecretFilter.Set(secret) } // Go through and interpolate all the build names. We should be able diff --git a/packer/core_test.go b/packer/core_test.go index 2c5c70aa7..0b27ffb27 100644 --- a/packer/core_test.go +++ b/packer/core_test.go @@ -8,6 +8,7 @@ import ( "reflect" "testing" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" configHelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -679,13 +680,13 @@ func TestSensitiveVars(t *testing.T) { if (err != nil) != tc.Err { t.Fatalf("err: %s\n\n%s", tc.File, err) } - filtered := LogSecretFilter.get() + filtered := packersdk.LogSecretFilter.get() if filtered[0] != tc.Expected && len(filtered) != 1 { t.Fatalf("not filtering sensitive vars; filtered is %#v", filtered) } // clear filter so it doesn't break other tests - LogSecretFilter.s = make(map[string]struct{}) + packersdk.LogSecretFilter.s = make(map[string]struct{}) } } diff --git a/packer/ui.go b/packer/ui.go index 820992d57..52db011fa 100644 --- a/packer/ui.go +++ b/packer/ui.go @@ -237,12 +237,8 @@ func (rw *BasicUi) Say(message string) { rw.l.Lock() defer rw.l.Unlock() - // Use LogSecretFilter to scrub out sensitive variables - for s := range LogSecretFilter.s { - if s != "" { - message = strings.Replace(message, s, "", -1) - } - } + // Use packersdk.LogSecretFilter to scrub out sensitive variables + message = packersdk.LogSecretFilter.FilterString(message) log.Printf("ui: %s", message) _, err := fmt.Fprint(rw.Writer, message+"\n") @@ -255,12 +251,8 @@ func (rw *BasicUi) Message(message string) { rw.l.Lock() defer rw.l.Unlock() - // Use LogSecretFilter to scrub out sensitive variables - for s := range LogSecretFilter.s { - if s != "" { - message = strings.Replace(message, s, "", -1) - } - } + // Use packersdk.LogSecretFilter to scrub out sensitive variables + message = packersdk.LogSecretFilter.FilterString(message) log.Printf("ui: %s", message) _, err := fmt.Fprint(rw.Writer, message+"\n") @@ -278,12 +270,8 @@ func (rw *BasicUi) Error(message string) { writer = rw.Writer } - // Use LogSecretFilter to scrub out sensitive variables - for s := range LogSecretFilter.s { - if s != "" { - message = strings.Replace(message, s, "", -1) - } - } + // Use packersdk.LogSecretFilter to scrub out sensitive variables + message = packersdk.LogSecretFilter.FilterString(message) log.Printf("ui error: %s", message) _, err := fmt.Fprint(writer, message+"\n") @@ -338,12 +326,8 @@ func (u *MachineReadableUi) Machine(category string, args ...string) { // Prepare the args for i, v := range args { - // Use LogSecretFilter to scrub out sensitive variables - for s := range LogSecretFilter.s { - if s != "" { - args[i] = strings.Replace(args[i], s, "", -1) - } - } + // Use packersdk.LogSecretFilter to scrub out sensitive variables + args[i] = packersdk.LogSecretFilter.FilterString(args[i]) args[i] = strings.Replace(v, ",", "%!(PACKER_COMMA)", -1) args[i] = strings.Replace(args[i], "\r", "\\r", -1) args[i] = strings.Replace(args[i], "\n", "\\n", -1) diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index 5d9a4a7f1..e3f673071 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -19,7 +19,6 @@ import ( "github.com/aliyun/aliyun-oss-go-sdk/oss" "github.com/hashicorp/hcl/v2/hcldec" packerecs "github.com/hashicorp/packer/builder/alicloud/ecs" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -160,7 +159,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return errs } - packer.LogSecretFilter.Set(p.config.AlicloudAccessKey, p.config.AlicloudSecretKey) + packersdk.LogSecretFilter.Set(p.config.AlicloudAccessKey, p.config.AlicloudSecretKey) log.Println(p.config) return nil } diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index 4931e2968..4bfc5d38c 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -16,7 +16,6 @@ import ( "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -126,7 +125,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } p.config.PollingConfig.LogEnvOverrideWarnings() - packer.LogSecretFilter.Set(p.config.AccessKey, p.config.SecretKey, p.config.Token) + packersdk.LogSecretFilter.Set(p.config.AccessKey, p.config.SecretKey, p.config.Token) log.Println(p.config) return nil } diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index 93666fd99..42ff238bf 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/digitalocean" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -144,7 +143,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return errs } - packer.LogSecretFilter.Set(p.config.SpacesKey, p.config.SpacesSecret, p.config.APIToken) + packersdk.LogSecretFilter.Set(p.config.SpacesKey, p.config.SpacesSecret, p.config.APIToken) log.Println(p.config) return nil } diff --git a/post-processor/exoscale-import/post-processor.go b/post-processor/exoscale-import/post-processor.go index 679eeb0f1..ed088398b 100644 --- a/post-processor/exoscale-import/post-processor.go +++ b/post-processor/exoscale-import/post-processor.go @@ -20,7 +20,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/builder/qemu" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -101,7 +100,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return errs } - packer.LogSecretFilter.Set(p.config.APIKey, p.config.APISecret) + packersdk.LogSecretFilter.Set(p.config.APIKey, p.config.APISecret) return nil } diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index bead1f18a..1380afaf9 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -150,7 +149,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { return errs } - packer.LogSecretFilter.Set(p.config.PublicKey, p.config.PrivateKey) + packersdk.LogSecretFilter.Set(p.config.PublicKey, p.config.PrivateKey) log.Println(p.config) return nil } diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index 6d0198437..0c15aa400 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -175,7 +175,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa } encodedPassword, isSet := getEncodedPassword(ovftool_uri) if isSet { - packer.LogSecretFilter.Set(encodedPassword) + packersdk.LogSecretFilter.Set(encodedPassword) } args, err := p.BuildArgs(source, ovftool_uri.String()) From 56a45b04ab08dac654edfe19e448277feb04356a Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Nov 2020 15:10:00 -0800 Subject: [PATCH 05/10] Move hook and communicator definitions to packer-plugin-sdk --- builder/alicloud/ecs/builder.go | 3 +- builder/amazon/chroot/builder.go | 3 +- builder/amazon/ebs/builder.go | 3 +- builder/amazon/ebssurrogate/builder.go | 3 +- builder/amazon/ebsvolume/builder.go | 3 +- builder/amazon/instance/builder.go | 3 +- builder/amazon/instance/step_bundle_volume.go | 5 +- builder/amazon/instance/step_upload_bundle.go | 5 +- .../amazon/instance/step_upload_x509_cert.go | 5 +- builder/azure/arm/builder.go | 3 +- builder/azure/chroot/builder.go | 2 +- builder/azure/dtl/builder.go | 3 +- builder/cloudstack/builder.go | 3 +- builder/digitalocean/builder.go | 3 +- builder/docker/builder.go | 3 +- builder/docker/communicator.go | 8 +- builder/docker/communicator_test.go | 19 +-- .../docker/windows_container_communicator.go | 8 +- builder/file/builder.go | 5 +- builder/googlecompute/builder.go | 3 +- builder/hcloud/builder.go | 3 +- builder/hyperone/builder.go | 3 +- builder/hyperone/chroot_communicator.go | 6 +- builder/hyperone/step_chroot_provision.go | 4 +- builder/hyperone/utils.go | 9 +- builder/hyperv/common/step_shutdown.go | 7 +- builder/hyperv/iso/builder.go | 3 +- builder/hyperv/vmcx/builder.go | 3 +- builder/jdcloud/builder.go | 3 +- builder/linode/builder.go | 3 +- builder/lxc/builder.go | 3 +- builder/lxc/communicator.go | 4 +- builder/lxc/communicator_test.go | 4 +- builder/lxc/step_provision.go | 5 +- builder/lxd/builder.go | 3 +- builder/lxd/communicator.go | 6 +- builder/lxd/communicator_test.go | 4 +- builder/lxd/step_provision.go | 5 +- builder/ncloud/builder.go | 3 +- builder/null/builder.go | 3 +- builder/oneandone/builder.go | 3 +- builder/openstack/builder.go | 3 +- builder/oracle/classic/builder.go | 3 +- builder/oracle/classic/step_upload_image.go | 5 +- builder/oracle/oci/builder.go | 3 +- builder/osc/bsu/builder.go | 3 +- builder/osc/bsusurrogate/builder.go | 3 +- builder/osc/bsuvolume/builder.go | 3 +- builder/osc/chroot/builder.go | 3 +- builder/osc/chroot/communicator.go | 4 +- builder/osc/chroot/communicator_test.go | 4 +- builder/osc/chroot/run_local_commands.go | 3 +- builder/osc/chroot/step_chroot_provision.go | 5 +- builder/parallels/common/step_shutdown.go | 7 +- .../common/step_upload_parallels_tools.go | 7 +- .../parallels/common/step_upload_version.go | 5 +- builder/parallels/iso/builder.go | 3 +- builder/parallels/pvm/builder.go | 3 +- builder/profitbricks/builder.go | 3 +- builder/proxmox/clone/builder.go | 2 +- builder/proxmox/common/builder.go | 3 +- builder/proxmox/iso/builder.go | 2 +- builder/qemu/builder.go | 3 +- builder/qemu/step_shutdown.go | 7 +- builder/scaleway/builder.go | 3 +- builder/tencentcloud/cvm/builder.go | 3 +- builder/triton/builder.go | 3 +- builder/ucloud/uhost/builder.go | 3 +- builder/vagrant/builder.go | 3 +- builder/virtualbox/common/step_shutdown.go | 7 +- .../common/step_upload_guest_additions.go | 3 +- .../virtualbox/common/step_upload_version.go | 3 +- builder/virtualbox/iso/builder.go | 3 +- builder/virtualbox/ovf/builder.go | 3 +- builder/virtualbox/vm/builder.go | 3 +- builder/vmware/common/driver_esx5.go | 5 +- builder/vmware/common/step_shutdown.go | 7 +- builder/vmware/common/step_upload_tools.go | 3 +- builder/vmware/iso/builder.go | 3 +- builder/vmware/iso/step_create_vmx_test.go | 3 +- builder/vmware/vmx/builder.go | 3 +- builder/vsphere/clone/builder.go | 3 +- builder/vsphere/common/step_shutdown.go | 5 +- builder/vsphere/iso/builder.go | 3 +- builder/yandex/builder.go | 3 +- command/build_parallel_test.go | 4 +- config.go | 5 +- hcl2template/internal/mock.go | 8 +- hcl2template/types.hcl_provisioner.go | 2 +- helper/communicator/config.go | 5 +- helper/communicator/step_connect_ssh.go | 6 +- helper/communicator/step_connect_winrm.go | 11 +- packer-plugin-sdk/adapter/adapter.go | 9 +- packer-plugin-sdk/adapter/adapter_test.go | 3 +- packer-plugin-sdk/adapter/scp.go | 8 +- packer-plugin-sdk/chroot/communicator.go | 4 +- packer-plugin-sdk/chroot/communicator_test.go | 4 +- .../chroot/run_local_commands.go | 3 +- .../chroot/step_chroot_provision.go | 5 +- packer-plugin-sdk/guestexec/elevated.go | 4 +- .../commonsteps/step_cleanup_temp_keys.go | 7 +- .../multistep/commonsteps/step_provision.go | 27 ++-- .../packer}/communicator.go | 3 +- .../packer}/communicator_mock.go | 0 .../packer}/communicator_mock_test.go | 0 .../packer}/communicator_test.go | 0 .../packer}/hcl2spec.go | 0 {packer => packer-plugin-sdk/packer}/hook.go | 6 +- .../packer}/hook_mock.go | 6 +- .../packer}/hook_test.go | 4 +- .../communicator/none/communicator.go | 6 +- .../communicator/none/communicator_test.go | 4 +- .../communicator/ssh/communicator.go | 8 +- .../communicator/ssh/communicator_test.go | 6 +- .../communicator/winrm/communicator.go | 6 +- .../communicator/winrm/communicator_test.go | 4 +- packer-plugin-sdk/shell-local/communicator.go | 4 +- .../shell-local/communicator_test.go | 6 +- packer-plugin-sdk/shell-local/run.go | 3 +- packer/build.go | 16 +-- packer/builder.go | 4 +- packer/builder_mock.go | 6 +- packer/builder_mock.hcl2spec.go | 130 +++--------------- packer/core.go | 2 +- packer/plugin/builder.go | 2 +- packer/plugin/client.go | 3 +- packer/plugin/hook.go | 5 +- packer/plugin/provisioner.go | 2 +- packer/post_processor.go | 2 +- packer/provisioner.go | 12 +- packer/provisioner_mock.go | 6 +- packer/provisioner_timeout.go | 2 +- packer/rpc/builder.go | 2 +- packer/rpc/client.go | 4 +- packer/rpc/communicator.go | 12 +- packer/rpc/communicator_test.go | 5 +- packer/rpc/hook.go | 9 +- packer/rpc/hook_test.go | 3 +- packer/rpc/provisioner.go | 2 +- packer/rpc/server.go | 4 +- post-processor/vsphere/post-processor.go | 3 +- .../ansible-local/communicator_mock.go | 4 +- provisioner/ansible-local/provisioner.go | 29 ++-- provisioner/ansible-local/provisioner_test.go | 7 +- provisioner/ansible/mock_ansible.go | 5 +- provisioner/ansible/provisioner.go | 14 +- provisioner/azure-dtlartifact/provisioner.go | 7 +- provisioner/breakpoint/provisioner.go | 3 +- provisioner/chef-client/provisioner.go | 40 +++--- provisioner/chef-solo/provisioner.go | 25 ++-- provisioner/converge/provisioner.go | 13 +- provisioner/file/provisioner.go | 7 +- provisioner/inspec/provisioner.go | 4 +- provisioner/powershell/provisioner.go | 13 +- provisioner/puppet-masterless/provisioner.go | 25 ++-- provisioner/puppet-server/provisioner.go | 21 ++- provisioner/salt-masterless/provisioner.go | 29 ++-- provisioner/shell-local/provisioner.go | 3 +- provisioner/shell/provisioner.go | 21 ++- provisioner/sleep/provisioner.go | 2 +- provisioner/windows-restart/provisioner.go | 23 ++-- .../windows-restart/provisioner_test.go | 5 +- provisioner/windows-shell/provisioner.go | 7 +- 163 files changed, 443 insertions(+), 623 deletions(-) rename {packer => packer-plugin-sdk/packer}/communicator.go (98%) rename {packer => packer-plugin-sdk/packer}/communicator_mock.go (100%) rename {packer => packer-plugin-sdk/packer}/communicator_mock_test.go (100%) rename {packer => packer-plugin-sdk/packer}/communicator_test.go (100%) rename {packer => packer-plugin-sdk/packer}/hcl2spec.go (100%) rename {packer => packer-plugin-sdk/packer}/hook.go (88%) rename {packer => packer-plugin-sdk/packer}/hook_mock.go (66%) rename {packer => packer-plugin-sdk/packer}/hook_test.go (88%) diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 106ac4287..d0ab061bb 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -81,7 +80,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 79a99c43f..cf3ed4dae 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -15,7 +15,6 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/chroot" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -346,7 +345,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The amazon-chroot builder only works on Linux environments.") } diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 17edd4744..72a22c291 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -151,7 +150,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 030255413..565cd6875 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -174,7 +173,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index b7e872ad9..fce769a0a 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -165,7 +164,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index a06fd4656..278eed4f9 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -234,7 +233,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/instance/step_bundle_volume.go b/builder/amazon/instance/step_bundle_volume.go index 043f4f096..e4721d06c 100644 --- a/builder/amazon/instance/step_bundle_volume.go +++ b/builder/amazon/instance/step_bundle_volume.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -26,7 +25,7 @@ type StepBundleVolume struct { } func (s *StepBundleVolume) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) instance := state.Get("instance").(*ec2.Instance) ui := state.Get("ui").(packersdk.Ui) @@ -53,7 +52,7 @@ func (s *StepBundleVolume) Run(ctx context.Context, state multistep.StateBag) mu } ui.Say("Bundling the volume...") - cmd := new(packer.RemoteCmd) + cmd := new(packersdk.RemoteCmd) cmd.Command = config.BundleVolCommand if s.Debug { diff --git a/builder/amazon/instance/step_upload_bundle.go b/builder/amazon/instance/step_upload_bundle.go index 6a8dd3186..dd278df49 100644 --- a/builder/amazon/instance/step_upload_bundle.go +++ b/builder/amazon/instance/step_upload_bundle.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -25,7 +24,7 @@ type StepUploadBundle struct { } func (s *StepUploadBundle) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) manifestName := state.Get("manifest_name").(string) manifestPath := state.Get("manifest_path").(string) @@ -64,7 +63,7 @@ func (s *StepUploadBundle) Run(ctx context.Context, state multistep.StateBag) mu } ui.Say("Uploading the bundle...") - cmd := &packer.RemoteCmd{Command: config.BundleUploadCommand} + cmd := &packersdk.RemoteCmd{Command: config.BundleUploadCommand} if s.Debug { ui.Say(fmt.Sprintf("Running: %s", config.BundleUploadCommand)) diff --git a/builder/amazon/instance/step_upload_x509_cert.go b/builder/amazon/instance/step_upload_x509_cert.go index a46eb024f..9eda67877 100644 --- a/builder/amazon/instance/step_upload_x509_cert.go +++ b/builder/amazon/instance/step_upload_x509_cert.go @@ -5,7 +5,6 @@ import ( "fmt" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -13,7 +12,7 @@ import ( type StepUploadX509Cert struct{} func (s *StepUploadX509Cert) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) ui := state.Get("ui").(packersdk.Ui) @@ -41,7 +40,7 @@ func (s *StepUploadX509Cert) Run(ctx context.Context, state multistep.StateBag) func (s *StepUploadX509Cert) Cleanup(multistep.StateBag) {} -func (s *StepUploadX509Cert) uploadSingle(comm packer.Communicator, dst, src string) error { +func (s *StepUploadX509Cert) uploadSingle(comm packersdk.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return err diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index aef35af43..505df319e 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/common/lin" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -52,7 +51,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("Running builder ...") diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index ab3b74346..e546bb08f 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -393,7 +393,7 @@ func checkHyperVGeneration(s string) interface{} { s, compute.PossibleHyperVGenerationValues()) } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { switch runtime.GOOS { case "linux", "freebsd": break diff --git a/builder/azure/dtl/builder.go b/builder/azure/dtl/builder.go index 28303b8c2..fd21634f0 100644 --- a/builder/azure/dtl/builder.go +++ b/builder/azure/dtl/builder.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/common/lin" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -52,7 +51,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("Running builder ...") diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index 2850dec13..f60354e44 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run implements the packer.Builder interface. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { b.ui = ui // Create a CloudStack API client. diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index f9ac5fd5b..366980f7c 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -12,7 +12,6 @@ import ( "github.com/digitalocean/godo" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -38,7 +37,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { client := godo.NewClient(oauth2.NewClient(context.TODO(), &apiTokenSource{ AccessToken: b.config.APIToken, })) diff --git a/builder/docker/builder.go b/builder/docker/builder.go index 7e785cbcc..d77e7c9d1 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { }, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver := &DockerDriver{Ctx: &b.config.ctx, Ui: ui} if err := driver.Verify(); err != nil { return nil, err diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 0b612e25f..360ac92d3 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -15,7 +15,7 @@ import ( "syscall" "github.com/hashicorp/go-version" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Communicator struct { @@ -29,9 +29,9 @@ type Communicator struct { EntryPoint []string } -var _ packer.Communicator = new(Communicator) +var _ packersdk.Communicator = new(Communicator) -func (c *Communicator) Start(ctx context.Context, remote *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, remote *packersdk.RemoteCmd) error { dockerArgs := []string{ "exec", "-i", @@ -274,7 +274,7 @@ func (c *Communicator) DownloadDir(src string, dst string, exclude []string) err } // Runs the given command and blocks until completion -func (c *Communicator) run(cmd *exec.Cmd, remote *packer.RemoteCmd, stdin io.WriteCloser, stdout, stderr io.ReadCloser) { +func (c *Communicator) run(cmd *exec.Cmd, remote *packersdk.RemoteCmd, stdin io.WriteCloser, stdout, stderr io.ReadCloser) { // For Docker, remote communication must be serialized since it // only supports single execution. c.lock.Lock() diff --git a/builder/docker/communicator_test.go b/builder/docker/communicator_test.go index 6abba8cd5..fefbc7f54 100644 --- a/builder/docker/communicator_test.go +++ b/builder/docker/communicator_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/provisioner/file" "github.com/hashicorp/packer/provisioner/shell" @@ -60,10 +61,10 @@ func TestUploadDownload(t *testing.T) { defer os.Remove("my-strawberry-cake") // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: upload, Config: nil, TypeName: ""}, {Provisioner: download, Config: nil, TypeName: ""}, }, @@ -148,10 +149,10 @@ func TestLargeDownload(t *testing.T) { defer os.Remove("bigcake") // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: shell, Config: nil, TypeName: ""}, {Provisioner: downloadCupcake, Config: nil, TypeName: ""}, {Provisioner: downloadBigcake, Config: nil, TypeName: ""}, @@ -256,10 +257,10 @@ func TestFixUploadOwner(t *testing.T) { } // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: fileProvisioner, Config: nil, TypeName: ""}, {Provisioner: dirProvisioner, Config: nil, TypeName: ""}, {Provisioner: shellProvisioner, Config: nil, TypeName: ""}, diff --git a/builder/docker/windows_container_communicator.go b/builder/docker/windows_container_communicator.go index c12177e34..ee4fd5dbb 100644 --- a/builder/docker/windows_container_communicator.go +++ b/builder/docker/windows_container_communicator.go @@ -10,7 +10,7 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Windows containers are a special beast in Docker; you can't use docker cp @@ -46,7 +46,7 @@ func (c *WindowsContainerCommunicator) Upload(dst string, src io.Reader, fi *os. // Copy the file into place by copying the temporary file we put // into the shared folder into the proper location in the container - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("Copy-Item -Path %s/%s -Destination %s", c.ContainerDir, filepath.Base(tempfile.Name()), dst), } @@ -132,7 +132,7 @@ func (c *WindowsContainerCommunicator) UploadDir(dst string, src string, exclude } // Make the directory, then copy into it - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("Copy-Item %s -Destination %s -Recurse", containerSrc, containerDst), } @@ -156,7 +156,7 @@ func (c *WindowsContainerCommunicator) Download(src string, dst io.Writer) error log.Printf("Downloading file from container: %s:%s", c.ContainerID, src) // Copy file onto temp file on mounted volume inside container var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("Copy-Item -Path %s -Destination %s/%s", src, c.ContainerDir, filepath.Base(src)), Stdout: &stdout, diff --git a/builder/file/builder.go b/builder/file/builder.go index 62561abea..062557389 100644 --- a/builder/file/builder.go +++ b/builder/file/builder.go @@ -14,7 +14,6 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -38,7 +37,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run is where the actual build should take place. It takes a Build and a Ui. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { artifact := new(FileArtifact) // Create all directories leading to target @@ -81,7 +80,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (p } if hook != nil { - if err := hook.Run(ctx, packer.HookProvision, ui, new(packer.MockCommunicator), nil); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, new(packersdk.MockCommunicator), nil); err != nil { return nil, err } } diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index 9cd7e557b..4d3f4d605 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a googlecompute Packer build and returns a packersdk.Artifact // representing a GCE machine image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { cfg := GCEDriverConfig{ Ui: ui, ProjectId: b.config.ProjectId, diff --git a/builder/hcloud/builder.go b/builder/hcloud/builder.go index 413451755..f2b0d5a83 100644 --- a/builder/hcloud/builder.go +++ b/builder/hcloud/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -35,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { opts := []hcloud.ClientOption{ hcloud.WithToken(b.config.HCloudToken), hcloud.WithEndpoint(b.config.Endpoint), diff --git a/builder/hyperone/builder.go b/builder/hyperone/builder.go index f123a19c5..8b33308ce 100644 --- a/builder/hyperone/builder.go +++ b/builder/hyperone/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -52,7 +51,7 @@ type wrappedCommandTemplate struct { Command string } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { ictx := b.config.ctx ictx.Data = &wrappedCommandTemplate{Command: command} diff --git a/builder/hyperone/chroot_communicator.go b/builder/hyperone/chroot_communicator.go index a8c64f377..de63f0fc8 100644 --- a/builder/hyperone/chroot_communicator.go +++ b/builder/hyperone/chroot_communicator.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strconv" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type CommandWrapper func(string) (string, error) @@ -18,10 +18,10 @@ type CommandWrapper func(string) (string, error) type ChrootCommunicator struct { Chroot string CmdWrapper CommandWrapper - Wrapped packer.Communicator + Wrapped packersdk.Communicator } -func (c *ChrootCommunicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *ChrootCommunicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { command := strconv.Quote(cmd.Command) chrootCommand, err := c.CmdWrapper( fmt.Sprintf("sudo chroot %s /bin/sh -c %s", c.Chroot, command)) diff --git a/builder/hyperone/step_chroot_provision.go b/builder/hyperone/step_chroot_provision.go index 7efa606ed..6f353d96f 100644 --- a/builder/hyperone/step_chroot_provision.go +++ b/builder/hyperone/step_chroot_provision.go @@ -3,9 +3,9 @@ package hyperone import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepChrootProvision struct{} @@ -13,7 +13,7 @@ type stepChrootProvision struct{} func (s *stepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) - sshCommunicator := state.Get("communicator").(packer.Communicator) + sshCommunicator := state.Get("communicator").(packersdk.Communicator) comm := &ChrootCommunicator{ Chroot: config.ChrootMountPath, diff --git a/builder/hyperone/utils.go b/builder/hyperone/utils.go index a2526e1cd..fa6e9df46 100644 --- a/builder/hyperone/utils.go +++ b/builder/hyperone/utils.go @@ -7,7 +7,6 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -27,7 +26,7 @@ func runCommands(commands []string, ictx interpolate.Context, state multistep.St ctx := context.TODO() ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) for _, rawCmd := range commands { intCmd, err := interpolate.Render(rawCmd, &ictx) @@ -40,7 +39,7 @@ func runCommands(commands []string, ictx interpolate.Context, state multistep.St return fmt.Errorf("error wrapping command: %s", err) } - remoteCmd := &packer.RemoteCmd{ + remoteCmd := &packersdk.RemoteCmd{ Command: command, } @@ -63,10 +62,10 @@ func runCommands(commands []string, ictx interpolate.Context, state multistep.St func captureOutput(command string, state multistep.StateBag) (string, error) { ctx := context.TODO() - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) var stdout bytes.Buffer - remoteCmd := &packer.RemoteCmd{ + remoteCmd := &packersdk.RemoteCmd{ Command: command, Stdout: &stdout, } diff --git a/builder/hyperv/common/step_shutdown.go b/builder/hyperv/common/step_shutdown.go index 9a9dfef54..4033be990 100644 --- a/builder/hyperv/common/step_shutdown.go +++ b/builder/hyperv/common/step_shutdown.go @@ -8,7 +8,6 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,7 +16,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui // vmName string @@ -31,7 +30,7 @@ type StepShutdown struct { func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) @@ -41,7 +40,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Executing shutdown command: %s", s.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 41b7e3c2e..a3e1a7f39 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -177,7 +176,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 80f6ea3e7..cf09d2811 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -14,7 +14,6 @@ import ( hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" powershell "github.com/hashicorp/packer/builder/hyperv/common/powershell" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -217,7 +216,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index dee0cd225..25e0c7df1 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -43,7 +42,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("hook", hook) diff --git a/builder/linode/builder.go b/builder/linode/builder.go index 2ae84f3c9..e89c7cf8f 100644 --- a/builder/linode/builder.go +++ b/builder/linode/builder.go @@ -12,7 +12,6 @@ import ( "github.com/linode/linodego" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -37,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (ret packersdk.Artifact, err error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (ret packersdk.Artifact, err error) { ui.Say("Running builder ...") client := newLinodeClient(b.config.PersonalAccessToken) diff --git a/builder/lxc/builder.go b/builder/lxc/builder.go index 3a350effc..b2f6fadb8 100644 --- a/builder/lxc/builder.go +++ b/builder/lxc/builder.go @@ -6,7 +6,6 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxc/communicator.go b/builder/lxc/communicator.go index b91d811d0..809c5b3cf 100644 --- a/builder/lxc/communicator.go +++ b/builder/lxc/communicator.go @@ -12,7 +12,7 @@ import ( "strings" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -23,7 +23,7 @@ type LxcAttachCommunicator struct { CmdWrapper CommandWrapper } -func (c *LxcAttachCommunicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *LxcAttachCommunicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { localCmd, err := c.Execute(cmd.Command) if err != nil { diff --git a/builder/lxc/communicator_test.go b/builder/lxc/communicator_test.go index 4a81a36a7..cf555fd5c 100644 --- a/builder/lxc/communicator_test.go +++ b/builder/lxc/communicator_test.go @@ -3,13 +3,13 @@ package lxc import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &LxcAttachCommunicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/builder/lxc/step_provision.go b/builder/lxc/step_provision.go index c9ca5c812..a98283394 100644 --- a/builder/lxc/step_provision.go +++ b/builder/lxc/step_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -14,7 +13,7 @@ import ( type StepProvision struct{} func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packersdk.Ui) @@ -37,7 +36,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/builder/lxd/builder.go b/builder/lxd/builder.go index 8306f4bca..9fc618d50 100644 --- a/builder/lxd/builder.go +++ b/builder/lxd/builder.go @@ -4,7 +4,6 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxd/communicator.go b/builder/lxd/communicator.go index db118bcaa..d505e534f 100644 --- a/builder/lxd/communicator.go +++ b/builder/lxd/communicator.go @@ -10,7 +10,7 @@ import ( "path/filepath" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Communicator struct { @@ -18,7 +18,7 @@ type Communicator struct { CmdWrapper CommandWrapper } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { localCmd, err := c.Execute(cmd.Command) if err != nil { @@ -61,7 +61,7 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error { fileDestination := filepath.Join(c.ContainerName, dst) // find out if the place we are pushing to is a directory testDirectoryCommand := fmt.Sprintf(`test -d "%s"`, dst) - cmd := &packer.RemoteCmd{Command: testDirectoryCommand} + cmd := &packersdk.RemoteCmd{Command: testDirectoryCommand} err := c.Start(ctx, cmd) if err != nil { diff --git a/builder/lxd/communicator_test.go b/builder/lxd/communicator_test.go index 972a5dc18..2eaf87122 100644 --- a/builder/lxd/communicator_test.go +++ b/builder/lxd/communicator_test.go @@ -3,13 +3,13 @@ package lxd import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &Communicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/builder/lxd/step_provision.go b/builder/lxd/step_provision.go index 5670dfbaf..a4d2f0d21 100644 --- a/builder/lxd/step_provision.go +++ b/builder/lxd/step_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -14,7 +13,7 @@ import ( type StepProvision struct{} func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) config := state.Get("config").(*Config) ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) @@ -34,7 +33,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/builder/ncloud/builder.go b/builder/ncloud/builder.go index a690230f5..c3cabe03a 100644 --- a/builder/ncloud/builder.go +++ b/builder/ncloud/builder.go @@ -6,7 +6,6 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -32,7 +31,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Message("Creating Naver Cloud Platform Connection ...") config := Config{ AccessKey: b.config.AccessKey, diff --git a/builder/null/builder.go b/builder/null/builder.go index cc4f9ea9c..762277f1a 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -5,7 +5,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -29,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { steps := []multistep.Step{} steps = append(steps, diff --git a/builder/oneandone/builder.go b/builder/oneandone/builder.go index f6a67ff7e..30ad23338 100644 --- a/builder/oneandone/builder.go +++ b/builder/oneandone/builder.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -31,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 17ee636a3..08ce7ad20 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -73,7 +72,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { if b.config.PackerDebug { b.config.enableDebug(ui) } diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index f927259ff..52aaf7cb1 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ocommon "github.com/hashicorp/packer/builder/oracle/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -46,7 +45,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { loggingEnabled := os.Getenv("PACKER_OCI_CLASSIC_LOGGING") != "" httpClient := cleanhttp.DefaultClient() config := &opc.Config{ diff --git a/builder/oracle/classic/step_upload_image.go b/builder/oracle/classic/step_upload_image.go index a8519462a..061c28d38 100644 --- a/builder/oracle/classic/step_upload_image.go +++ b/builder/oracle/classic/step_upload_image.go @@ -6,7 +6,6 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -27,7 +26,7 @@ type uploadCmdData struct { func (s *stepUploadImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packersdk.Ui) - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) runID := state.Get("run_id").(string) @@ -64,7 +63,7 @@ func (s *stepUploadImage) Run(ctx context.Context, state multistep.StateBag) mul dest := "/tmp/create-packer-diskimage.sh" comm.Upload(dest, strings.NewReader(command), nil) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("sudo /bin/sh %s", dest), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { diff --git a/builder/oracle/oci/builder.go b/builder/oracle/oci/builder.go index 93caea3b5..8bab1f151 100644 --- a/builder/oracle/oci/builder.go +++ b/builder/oracle/oci/builder.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ocommon "github.com/hashicorp/packer/builder/oracle/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -39,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := NewDriverOCI(&b.config) if err != nil { return nil, err diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index 8498936e1..2694c5697 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -85,7 +84,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index f3877cc06..bb3379a61 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -103,7 +102,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 9509be632..76ed194e9 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -88,7 +87,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // clientConfig, err := b.config.Config() // if err != nil { // return nil, err diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 7a72943d7..3aa0715ee 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -188,7 +187,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The outscale-chroot builder only works on Linux environments.") } diff --git a/builder/osc/chroot/communicator.go b/builder/osc/chroot/communicator.go index 8fc79163e..0389c55cf 100644 --- a/builder/osc/chroot/communicator.go +++ b/builder/osc/chroot/communicator.go @@ -13,7 +13,7 @@ import ( "strings" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -24,7 +24,7 @@ type Communicator struct { CmdWrapper CommandWrapper } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { // need extra escapes for the command since we're wrapping it in quotes cmd.Command = strconv.Quote(cmd.Command) command, err := c.CmdWrapper( diff --git a/builder/osc/chroot/communicator_test.go b/builder/osc/chroot/communicator_test.go index 43995b79a..284782eb0 100644 --- a/builder/osc/chroot/communicator_test.go +++ b/builder/osc/chroot/communicator_test.go @@ -3,13 +3,13 @@ package chroot import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &Communicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/builder/osc/chroot/run_local_commands.go b/builder/osc/chroot/run_local_commands.go index 0220db88d..fb96e1eb3 100644 --- a/builder/osc/chroot/run_local_commands.go +++ b/builder/osc/chroot/run_local_commands.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -27,7 +26,7 @@ func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx int comm := &sl.Communicator{ ExecuteCommand: []string{"sh", "-c", command}, } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Error executing command: %s", err) } diff --git a/builder/osc/chroot/step_chroot_provision.go b/builder/osc/chroot/step_chroot_provision.go index 607c68306..68fc8d5f0 100644 --- a/builder/osc/chroot/step_chroot_provision.go +++ b/builder/osc/chroot/step_chroot_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -15,7 +14,7 @@ type StepChrootProvision struct { } func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) @@ -35,7 +34,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/builder/parallels/common/step_shutdown.go b/builder/parallels/common/step_shutdown.go index 20c06a39a..7f6666e18 100644 --- a/builder/parallels/common/step_shutdown.go +++ b/builder/parallels/common/step_shutdown.go @@ -8,7 +8,6 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,7 +16,7 @@ import ( // so gracefully, but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui // vmName string @@ -31,7 +30,7 @@ type StepShutdown struct { // Run shuts down the VM. func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) @@ -41,7 +40,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Executing shutdown command: %s", s.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/parallels/common/step_upload_parallels_tools.go b/builder/parallels/common/step_upload_parallels_tools.go index e50ca8923..3a6d93563 100644 --- a/builder/parallels/common/step_upload_parallels_tools.go +++ b/builder/parallels/common/step_upload_parallels_tools.go @@ -6,7 +6,6 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -15,7 +14,7 @@ import ( // This step uploads the Parallels Tools ISO to the virtual machine. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // parallels_tools_path string // ui packersdk.Ui // @@ -28,7 +27,7 @@ type toolsPathTemplate struct { // to the VM. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // parallels_tools_path string // ui packersdk.Ui type StepUploadParallelsTools struct { @@ -40,7 +39,7 @@ type StepUploadParallelsTools struct { // Run uploads the Parallels Tools ISO to the VM. func (s *StepUploadParallelsTools) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) ui := state.Get("ui").(packersdk.Ui) // If we're attaching then don't do this, since we attached. diff --git a/builder/parallels/common/step_upload_version.go b/builder/parallels/common/step_upload_version.go index a42d6257d..d32480a3d 100644 --- a/builder/parallels/common/step_upload_version.go +++ b/builder/parallels/common/step_upload_version.go @@ -6,7 +6,6 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -15,7 +14,7 @@ import ( // Parallels Desktop, which can be useful for various provisioning reasons. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui type StepUploadVersion struct { @@ -24,7 +23,7 @@ type StepUploadVersion struct { // Run uploads a file containing the version of Parallels Desktop. func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 3c4cdd769..f724bc9ff 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -181,7 +180,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 1235cc97b..6e9aad514 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a Parallels appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index aa805f978..8f5585a04 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -30,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("config", &b.config) diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index aeb675d22..45be41a9d 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -28,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return b.config.Prepare(raws...) } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("clone-config", &b.config) diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index b61be22e7..467ce0def 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -8,7 +8,6 @@ import ( "github.com/Telmate/proxmox-api-go/proxmox" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ type Builder struct { vmCreator ProxmoxVMCreator } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook, state multistep.StateBag) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook, state multistep.StateBag) (packersdk.Artifact, error) { var err error tlsConfig := &tls.Config{ InsecureSkipVerify: b.config.SkipCertValidation, diff --git a/builder/proxmox/iso/builder.go b/builder/proxmox/iso/builder.go index da1050b2e..3eadef1f1 100644 --- a/builder/proxmox/iso/builder.go +++ b/builder/proxmox/iso/builder.go @@ -30,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { const downloadPathKey = "downloaded_iso_path" -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("iso-config", &b.config) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index bf3482d2f..b810e5339 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -35,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Qemu driver, err := b.newDriver(b.config.QemuBinary) if err != nil { diff --git a/builder/qemu/step_shutdown.go b/builder/qemu/step_shutdown.go index 594c8b3ff..862071b1a 100644 --- a/builder/qemu/step_shutdown.go +++ b/builder/qemu/step_shutdown.go @@ -8,7 +8,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,7 +16,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // config *config // driver Driver // ui packersdk.Ui @@ -53,10 +52,10 @@ func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multis } if s.ShutdownCommand != "" { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) ui.Say("Gracefully halting virtual machine...") log.Printf("Executing shutdown command: %s", s.ShutdownCommand) - cmd := &packer.RemoteCmd{Command: s.ShutdownCommand} + cmd := &packersdk.RemoteCmd{Command: s.ShutdownCommand} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { err := fmt.Errorf("Failed to send shutdown command: %s", err) state.Put("error", err) diff --git a/builder/scaleway/builder.go b/builder/scaleway/builder.go index e05bc805f..960aba889 100644 --- a/builder/scaleway/builder.go +++ b/builder/scaleway/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { scwZone, err := scw.ParseZone(b.config.Zone) if err != nil { ui.Error(err.Error()) diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 2f2a8acb0..de94e04a7 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -65,7 +64,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { cvmClient, vpcClient, err := b.config.Client() if err != nil { return nil, err diff --git a/builder/triton/builder.go b/builder/triton/builder.go index acbba7182..5aa6987fb 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/go-multierror" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -50,7 +49,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs.ErrorOrNil() } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { config := b.config driver, err := NewDriverTriton(ui, config) diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index 02a9da6cd..491f1e76d 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -68,7 +67,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 2e2398268..9499f0df7 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -274,7 +273,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox VagrantCWD, err := filepath.Abs(b.config.OutputDir) if err != nil { diff --git a/builder/virtualbox/common/step_shutdown.go b/builder/virtualbox/common/step_shutdown.go index ce980847f..1c36b53cb 100644 --- a/builder/virtualbox/common/step_shutdown.go +++ b/builder/virtualbox/common/step_shutdown.go @@ -7,7 +7,6 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -16,7 +15,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui // vmName string @@ -32,7 +31,7 @@ type StepShutdown struct { } func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) @@ -49,7 +48,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis if s.Command != "" { ui.Say("Gracefully halting virtual machine...") log.Printf("Executing shutdown command: %s", s.Command) - cmd := &packer.RemoteCmd{Command: s.Command} + cmd := &packersdk.RemoteCmd{Command: s.Command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { err := fmt.Errorf("Failed to send shutdown command: %s", err) state.Put("error", err) diff --git a/builder/virtualbox/common/step_upload_guest_additions.go b/builder/virtualbox/common/step_upload_guest_additions.go index ea7b6ef37..3dc2fbad7 100644 --- a/builder/virtualbox/common/step_upload_guest_additions.go +++ b/builder/virtualbox/common/step_upload_guest_additions.go @@ -6,7 +6,6 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -24,7 +23,7 @@ type StepUploadGuestAdditions struct { } func (s *StepUploadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/virtualbox/common/step_upload_version.go b/builder/virtualbox/common/step_upload_version.go index 46da0e6f1..7f2aa3860 100644 --- a/builder/virtualbox/common/step_upload_version.go +++ b/builder/virtualbox/common/step_upload_version.go @@ -6,7 +6,6 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -18,7 +17,7 @@ type StepUploadVersion struct { } func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index d92a21bef..b284e0600 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -231,7 +230,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index 6e0c311b0..098570d3e 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/vm/builder.go b/builder/virtualbox/vm/builder.go index 61828aa89..8e5f9ef71 100644 --- a/builder/virtualbox/vm/builder.go +++ b/builder/virtualbox/vm/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/vmware/common/driver_esx5.go b/builder/vmware/common/driver_esx5.go index 448698987..f40b496e9 100644 --- a/builder/vmware/common/driver_esx5.go +++ b/builder/vmware/common/driver_esx5.go @@ -30,7 +30,6 @@ import ( "github.com/hashicorp/go-getter/v2" "github.com/hashicorp/packer/helper/communicator" helperssh "github.com/hashicorp/packer/helper/communicator/ssh" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh" @@ -57,7 +56,7 @@ type ESX5Driver struct { client *govmomi.Client finder *find.Finder - comm packer.Communicator + comm packersdk.Communicator outputDir string vmId string } @@ -865,7 +864,7 @@ func (d *ESX5Driver) ssh(command string, stdin io.Reader) (*bytes.Buffer, error) ctx := context.TODO() var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/vmware/common/step_shutdown.go b/builder/vmware/common/step_shutdown.go index b1187672f..b78e355eb 100644 --- a/builder/vmware/common/step_shutdown.go +++ b/builder/vmware/common/step_shutdown.go @@ -10,7 +10,6 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -19,7 +18,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // dir OutputDir // driver Driver // ui packersdk.Ui @@ -36,7 +35,7 @@ type StepShutdown struct { } func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) dir := state.Get("dir").(OutputDir) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) @@ -47,7 +46,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Executing shutdown command: %s", s.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/vmware/common/step_upload_tools.go b/builder/vmware/common/step_upload_tools.go index bd5063625..8fafa6193 100644 --- a/builder/vmware/common/step_upload_tools.go +++ b/builder/vmware/common/step_upload_tools.go @@ -5,7 +5,6 @@ import ( "fmt" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -36,7 +35,7 @@ func (c *StepUploadTools) Run(ctx context.Context, state multistep.StateBag) mul return multistep.ActionContinue } - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) tools_source := state.Get("tools_upload_source").(string) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 20bc1b9e2..4de29eb15 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -31,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vmware/iso/step_create_vmx_test.go b/builder/vmware/iso/step_create_vmx_test.go index 9982998f8..80a216ad0 100644 --- a/builder/vmware/iso/step_create_vmx_test.go +++ b/builder/vmware/iso/step_create_vmx_test.go @@ -16,6 +16,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/provisioner/shell" ) @@ -140,7 +141,7 @@ func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisioner BuilderStore: packer.MapOfBuilder{ "vmware-iso": func() (packer.Builder, error) { return &Builder{}, nil }, }, - Hook: func(n string) (packer.Hook, error) { + Hook: func(n string) (packersdk.Hook, error) { return &packer.DispatchHook{}, nil }, ProvisionerStore: packer.MapOfProvisioner{ diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index c0542d3e4..e36c2711b 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VMware image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vsphere/clone/builder.go b/builder/vsphere/clone/builder.go index f9c993779..7f06a27f8 100644 --- a/builder/vsphere/clone/builder.go +++ b/builder/vsphere/clone/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -30,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/vsphere/common/step_shutdown.go b/builder/vsphere/common/step_shutdown.go index 73f8594b7..501c71b59 100644 --- a/builder/vsphere/common/step_shutdown.go +++ b/builder/vsphere/common/step_shutdown.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -62,7 +61,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis return multistep.ActionContinue } - comm, _ := state.Get("communicator").(packer.Communicator) + comm, _ := state.Get("communicator").(packersdk.Communicator) if comm == nil { msg := fmt.Sprintf("Please shutdown virtual machine within %s.", s.Config.Timeout) @@ -77,7 +76,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Shutdown command: %s", s.Config.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Config.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/vsphere/iso/builder.go b/builder/vsphere/iso/builder.go index 1bd53675e..2a0fcf88b 100644 --- a/builder/vsphere/iso/builder.go +++ b/builder/vsphere/iso/builder.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -29,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/yandex/builder.go b/builder/yandex/builder.go index be09ab378..88a13e372 100644 --- a/builder/yandex/builder.go +++ b/builder/yandex/builder.go @@ -7,7 +7,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -50,7 +49,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a yandex Packer build and returns a packersdk.Artifact // representing a Yandex.Cloud compute image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := NewDriverYC(ui, &b.config.AccessConfig) ctx = requestid.ContextWithClientTraceID(ctx, uuid.New().String()) diff --git a/command/build_parallel_test.go b/command/build_parallel_test.go index 27fc23272..16980b234 100644 --- a/command/build_parallel_test.go +++ b/command/build_parallel_test.go @@ -37,7 +37,7 @@ func (b *ParallelTestBuilder) Prepare(raws ...interface{}) ([]string, []string, return nil, nil, nil } -func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("building") b.wg.Done() return nil, nil @@ -52,7 +52,7 @@ func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) return nil, nil, nil } -func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("locking build") select { case <-b.unlock: diff --git a/config.go b/config.go index 5ca68a193..5c54f8e80 100644 --- a/config.go +++ b/config.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/command" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer/plugin" ) @@ -187,8 +188,8 @@ func (c *config) StartBuilder(name string) (packer.Builder, error) { } // This is a proper implementation of packer.HookFunc that can be used -// to load packer.Hook implementations from the defined plugins. -func (c *config) StarHook(name string) (packer.Hook, error) { +// to load packersdk.Hook implementations from the defined plugins. +func (c *config) StarHook(name string) (packersdk.Hook, error) { log.Printf("Loading hook: %s\n", name) return c.pluginClient(name).Hook() } diff --git a/hcl2template/internal/mock.go b/hcl2template/internal/mock.go index f55ce6fb7..0bc620e54 100644 --- a/hcl2template/internal/mock.go +++ b/hcl2template/internal/mock.go @@ -78,7 +78,7 @@ func (b *MockBuilder) Prepare(raws ...interface{}) ([]string, []string, error) { return []string{"ID"}, nil, b.Config.Prepare(raws...) } -func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { return nil, nil } @@ -100,7 +100,7 @@ func (b *MockProvisioner) Prepare(raws ...interface{}) error { return b.Config.Prepare(raws...) } -func (b *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (b *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { return nil } @@ -132,10 +132,10 @@ func (b *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a type MockCommunicator struct { Config MockConfig - packer.Communicator + packersdk.Communicator } -var _ packer.ConfigurableCommunicator = new(MockCommunicator) +var _ packersdk.ConfigurableCommunicator = new(MockCommunicator) func (b *MockCommunicator) ConfigSpec() hcldec.ObjectSpec { return b.Config.FlatMapstructure().HCL2Spec() diff --git a/hcl2template/types.hcl_provisioner.go b/hcl2template/types.hcl_provisioner.go index dff9b31b5..d7cfcbd80 100644 --- a/hcl2template/types.hcl_provisioner.go +++ b/hcl2template/types.hcl_provisioner.go @@ -67,7 +67,7 @@ func (p *HCL2Provisioner) Prepare(args ...interface{}) error { return p.Provisioner.Prepare(args...) } -func (p *HCL2Provisioner) Provision(ctx context.Context, ui packersdk.Ui, c packer.Communicator, vars map[string]interface{}) error { +func (p *HCL2Provisioner) Provision(ctx context.Context, ui packersdk.Ui, c packersdk.Communicator, vars map[string]interface{}) error { err := p.HCL2Prepare(vars) if err != nil { return err diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 0dcc21bbc..5a61b8482 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -15,6 +15,7 @@ import ( helperssh "github.com/hashicorp/packer/helper/communicator/ssh" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" packerssh "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -257,8 +258,8 @@ func (c *WinRM) Configure(raws ...interface{}) ([]string, error) { } var ( - _ packer.ConfigurableCommunicator = new(SSH) - _ packer.ConfigurableCommunicator = new(WinRM) + _ packersdk.ConfigurableCommunicator = new(SSH) + _ packersdk.ConfigurableCommunicator = new(WinRM) ) type SSHInterface struct { diff --git a/helper/communicator/step_connect_ssh.go b/helper/communicator/step_connect_ssh.go index 4b9e6b8c4..74ae42b32 100644 --- a/helper/communicator/step_connect_ssh.go +++ b/helper/communicator/step_connect_ssh.go @@ -37,7 +37,7 @@ type StepConnectSSH struct { func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packersdk.Ui) - var comm packer.Communicator + var comm packersdk.Communicator var err error subCtx, cancel := context.WithCancel(ctx) @@ -85,7 +85,7 @@ func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) mult func (s *StepConnectSSH) Cleanup(multistep.StateBag) { } -func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Context) (packer.Communicator, error) { +func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Context) (packersdk.Communicator, error) { // Determine if we're using a bastion host, and if so, retrieve // that configuration. This configuration doesn't change so we // do this one before entering the retry loop. @@ -118,7 +118,7 @@ func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Contex handshakeAttempts := 0 - var comm packer.Communicator + var comm packersdk.Communicator first := true for { // Don't check for cancel or wait on first iteration diff --git a/helper/communicator/step_connect_winrm.go b/helper/communicator/step_connect_winrm.go index 7452687b3..36630894a 100644 --- a/helper/communicator/step_connect_winrm.go +++ b/helper/communicator/step_connect_winrm.go @@ -13,7 +13,6 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/winrm" @@ -29,7 +28,7 @@ import ( // ui packersdk.Ui // // Produces: -// communicator packer.Communicator +// communicator packersdk.Communicator type StepConnectWinRM struct { // All the fields below are documented on StepConnect Config *Config @@ -41,7 +40,7 @@ type StepConnectWinRM struct { func (s *StepConnectWinRM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packersdk.Ui) - var comm packer.Communicator + var comm packersdk.Communicator var err error subCtx, cancel := context.WithCancel(ctx) @@ -88,8 +87,8 @@ func (s *StepConnectWinRM) Run(ctx context.Context, state multistep.StateBag) mu func (s *StepConnectWinRM) Cleanup(multistep.StateBag) { } -func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Context) (packer.Communicator, error) { - var comm packer.Communicator +func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Context) (packersdk.Communicator, error) { + var comm packersdk.Communicator first := true for { // Don't check for cancel or wait on first iteration @@ -170,7 +169,7 @@ func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Co var retryableSleep = 5 * time.Second // run an "echo" command to make sure that the winrm is connected for { - cmd := &packer.RemoteCmd{Command: connectCheckCommand} + cmd := &packersdk.RemoteCmd{Command: connectCheckCommand} var buf, buf2 bytes.Buffer cmd.Stdout = &buf cmd.Stdout = io.MultiWriter(cmd.Stdout, &buf2) diff --git a/packer-plugin-sdk/adapter/adapter.go b/packer-plugin-sdk/adapter/adapter.go index 230ffd34a..84c102ebf 100644 --- a/packer-plugin-sdk/adapter/adapter.go +++ b/packer-plugin-sdk/adapter/adapter.go @@ -12,23 +12,22 @@ import ( "strings" "github.com/google/shlex" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) // An adapter satisfies SSH requests (from an Ansible client) by delegating SSH -// exec and subsystem commands to a packer.Communicator. +// exec and subsystem commands to a packersdk.Communicator. type Adapter struct { done <-chan struct{} l net.Listener config *ssh.ServerConfig sftpCmd string ui packersdk.Ui - comm packer.Communicator + comm packersdk.Communicator } -func NewAdapter(done <-chan struct{}, l net.Listener, config *ssh.ServerConfig, sftpCmd string, ui packersdk.Ui, comm packer.Communicator) *Adapter { +func NewAdapter(done <-chan struct{}, l net.Listener, config *ssh.ServerConfig, sftpCmd string, ui packersdk.Ui, comm packersdk.Communicator) *Adapter { return &Adapter{ done: done, l: l, @@ -229,7 +228,7 @@ func (c *Adapter) scpExec(args string, in io.Reader, out io.Writer) error { } func (c *Adapter) remoteExec(command string, in io.Reader, out io.Writer, err io.Writer) int { - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Stdin: in, Stdout: out, Stderr: err, diff --git a/packer-plugin-sdk/adapter/adapter_test.go b/packer-plugin-sdk/adapter/adapter_test.go index bc3c03e4b..bfc3e7d3d 100644 --- a/packer-plugin-sdk/adapter/adapter_test.go +++ b/packer-plugin-sdk/adapter/adapter_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -96,7 +97,7 @@ func (a addr) String() string { type communicator struct{} -func (c communicator) Start(context.Context, *packer.RemoteCmd) error { +func (c communicator) Start(context.Context, *packersdk.RemoteCmd) error { return errors.New("communicator not supported") } diff --git a/packer-plugin-sdk/adapter/scp.go b/packer-plugin-sdk/adapter/scp.go index 5fe6e45b2..100270aef 100644 --- a/packer-plugin-sdk/adapter/scp.go +++ b/packer-plugin-sdk/adapter/scp.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -36,7 +36,7 @@ well. send a 0 byte after file contents. */ -func scpUploadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packer.Communicator) error { +func scpUploadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packersdk.Communicator) error { rest = strings.TrimSpace(rest) if len(rest) == 0 { fmt.Fprintf(out, scpEmptyError) @@ -61,7 +61,7 @@ func scpUploadSession(opts []byte, rest string, in io.Reader, out io.Writer, com return state.Protocol(bufio.NewReader(in), out) } -func scpDownloadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packer.Communicator) error { +func scpDownloadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packersdk.Communicator) error { rest = strings.TrimSpace(rest) if len(rest) == 0 { fmt.Fprintf(out, scpEmptyError) @@ -121,7 +121,7 @@ func (state *scpDownloadState) FileProtocol(path string, info os.FileInfo, in *b } type scpUploadState struct { - comm packer.Communicator + comm packersdk.Communicator target string // target is the directory on the target srcRoot string // srcRoot is the directory on the host mtime time.Time diff --git a/packer-plugin-sdk/chroot/communicator.go b/packer-plugin-sdk/chroot/communicator.go index 33a6c4598..24ccc4277 100644 --- a/packer-plugin-sdk/chroot/communicator.go +++ b/packer-plugin-sdk/chroot/communicator.go @@ -13,8 +13,8 @@ import ( "strings" "syscall" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -25,7 +25,7 @@ type Communicator struct { CmdWrapper common.CommandWrapper } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { // need extra escapes for the command since we're wrapping it in quotes cmd.Command = strconv.Quote(cmd.Command) command, err := c.CmdWrapper( diff --git a/packer-plugin-sdk/chroot/communicator_test.go b/packer-plugin-sdk/chroot/communicator_test.go index 43995b79a..284782eb0 100644 --- a/packer-plugin-sdk/chroot/communicator_test.go +++ b/packer-plugin-sdk/chroot/communicator_test.go @@ -3,13 +3,13 @@ package chroot import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &Communicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/packer-plugin-sdk/chroot/run_local_commands.go b/packer-plugin-sdk/chroot/run_local_commands.go index fce3d5154..e8b34a78d 100644 --- a/packer-plugin-sdk/chroot/run_local_commands.go +++ b/packer-plugin-sdk/chroot/run_local_commands.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" @@ -28,7 +27,7 @@ func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, i comm := &sl.Communicator{ ExecuteCommand: []string{"sh", "-c", command}, } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Error executing command: %s", err) } diff --git a/packer-plugin-sdk/chroot/step_chroot_provision.go b/packer-plugin-sdk/chroot/step_chroot_provision.go index 60f2c3a17..b22fefa04 100644 --- a/packer-plugin-sdk/chroot/step_chroot_provision.go +++ b/packer-plugin-sdk/chroot/step_chroot_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -16,7 +15,7 @@ type StepChrootProvision struct { } func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) @@ -36,7 +35,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/packer-plugin-sdk/guestexec/elevated.go b/packer-plugin-sdk/guestexec/elevated.go index 4abfc99af..9dca69717 100644 --- a/packer-plugin-sdk/guestexec/elevated.go +++ b/packer-plugin-sdk/guestexec/elevated.go @@ -8,12 +8,12 @@ import ( "strings" "text/template" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) type ElevatedProvisioner interface { - Communicator() packer.Communicator + Communicator() packersdk.Communicator ElevatedUser() string ElevatedPassword() string } diff --git a/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go b/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go index aa9924797..207515e5c 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go @@ -6,7 +6,6 @@ import ( "log" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -32,10 +31,10 @@ func (s *StepCleanupTempKeys) Run(ctx context.Context, state multistep.StateBag) return multistep.ActionContinue } - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) ui := state.Get("ui").(packersdk.Ui) - cmd := new(packer.RemoteCmd) + cmd := new(packersdk.RemoteCmd) ui.Say("Trying to remove ephemeral keys from authorized_keys files") @@ -60,7 +59,7 @@ func (s *StepCleanupTempKeys) Run(ctx context.Context, state multistep.StateBag) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { log.Printf("Error cleaning up ~/.ssh/authorized_keys; please clean up keys manually: %s", err) } - cmd = new(packer.RemoteCmd) + cmd = new(packersdk.RemoteCmd) cmd.Command = fmt.Sprintf("sudo sed -i.bak '/ %s$/d' /root/.ssh/authorized_keys; sudo rm /root/.ssh/authorized_keys.bak", s.Comm.SSHTemporaryKeyPairName) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { log.Printf("Error cleaning up /root/.ssh/authorized_keys; please clean up keys manually: %s", err) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_provision.go b/packer-plugin-sdk/multistep/commonsteps/step_provision.go index a7118b84c..3a78d5d73 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_provision.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_provision.go @@ -9,7 +9,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,8 +16,8 @@ import ( // StepProvision runs the provisioners. // // Uses: -// communicator packer.Communicator -// hook packer.Hook +// communicator packersdk.Communicator +// hook packersdk.Hook // ui packersdk.Ui // // Produces: @@ -96,20 +95,20 @@ func PopulateProvisionHookData(state multistep.StateBag) map[string]interface{} } type StepProvision struct { - Comm packer.Communicator + Comm packersdk.Communicator } func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBag, hooktype string) multistep.StepAction { - // hooktype will be either packer.HookProvision or packer.HookCleanupProvision + // hooktype will be either packersdk.HookProvision or packersdk.HookCleanupProvision comm := s.Comm if comm == nil { - raw, ok := state.Get("communicator").(packer.Communicator) + raw, ok := state.Get("communicator").(packersdk.Communicator) if ok { - comm = raw.(packer.Communicator) + comm = raw.(packersdk.Communicator) } } - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) ui := state.Get("ui").(packersdk.Ui) hookData := PopulateProvisionHookData(state) @@ -120,9 +119,9 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa // Run the provisioner in a goroutine so we can continually check // for cancellations... - if hooktype == packer.HookProvision { + if hooktype == packersdk.HookProvision { log.Println("Running the provision hook") - } else if hooktype == packer.HookCleanupProvision { + } else if hooktype == packersdk.HookCleanupProvision { ui.Say("Provisioning step had errors: Running the cleanup provisioner, if present...") } errCh := make(chan error, 1) @@ -134,11 +133,11 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa select { case err := <-errCh: if err != nil { - if hooktype == packer.HookProvision { + if hooktype == packersdk.HookProvision { // We don't overwrite the error if it's a cleanup // provisioner being run. state.Put("error", err) - } else if hooktype == packer.HookCleanupProvision { + } else if hooktype == packersdk.HookCleanupProvision { origErr := state.Get("error").(error) state.Put("error", fmt.Errorf("Cleanup failed: %s. "+ "Original Provisioning error: %s", err, origErr)) @@ -160,7 +159,7 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa } func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - return s.runWithHook(ctx, state, packer.HookProvision) + return s.runWithHook(ctx, state, packersdk.HookProvision) } func (s *StepProvision) Cleanup(state multistep.StateBag) { @@ -168,6 +167,6 @@ func (s *StepProvision) Cleanup(state multistep.StateBag) { // which we only call if there's an error during the provision run and // the "error-cleanup-provisioner" is defined. if _, ok := state.GetOk("error"); ok { - s.runWithHook(context.Background(), state, packer.HookCleanupProvision) + s.runWithHook(context.Background(), state, packersdk.HookCleanupProvision) } } diff --git a/packer/communicator.go b/packer-plugin-sdk/packer/communicator.go similarity index 98% rename from packer/communicator.go rename to packer-plugin-sdk/packer/communicator.go index 6bf76e86a..026737d4b 100644 --- a/packer/communicator.go +++ b/packer-plugin-sdk/packer/communicator.go @@ -8,7 +8,6 @@ import ( "sync" "unicode" - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/mitchellh/iochan" ) @@ -89,7 +88,7 @@ type ConfigurableCommunicator interface { // RunWithUi runs the remote command and streams the output to any configured // Writers for stdout/stderr, while also writing each line as it comes to a Ui. // RunWithUi will not return until the command finishes or is cancelled. -func (r *RemoteCmd) RunWithUi(ctx context.Context, c Communicator, ui packersdk.Ui) error { +func (r *RemoteCmd) RunWithUi(ctx context.Context, c Communicator, ui Ui) error { r.initchan() stdout_r, stdout_w := io.Pipe() diff --git a/packer/communicator_mock.go b/packer-plugin-sdk/packer/communicator_mock.go similarity index 100% rename from packer/communicator_mock.go rename to packer-plugin-sdk/packer/communicator_mock.go diff --git a/packer/communicator_mock_test.go b/packer-plugin-sdk/packer/communicator_mock_test.go similarity index 100% rename from packer/communicator_mock_test.go rename to packer-plugin-sdk/packer/communicator_mock_test.go diff --git a/packer/communicator_test.go b/packer-plugin-sdk/packer/communicator_test.go similarity index 100% rename from packer/communicator_test.go rename to packer-plugin-sdk/packer/communicator_test.go diff --git a/packer/hcl2spec.go b/packer-plugin-sdk/packer/hcl2spec.go similarity index 100% rename from packer/hcl2spec.go rename to packer-plugin-sdk/packer/hcl2spec.go diff --git a/packer/hook.go b/packer-plugin-sdk/packer/hook.go similarity index 88% rename from packer/hook.go rename to packer-plugin-sdk/packer/hook.go index 583fcb706..ee8104ac9 100644 --- a/packer/hook.go +++ b/packer-plugin-sdk/packer/hook.go @@ -2,8 +2,6 @@ package packer import ( "context" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This is the hook that should be fired for provisioners to run. @@ -24,7 +22,7 @@ const HookCleanupProvision = "packer_cleanup_provision" // must be race-free. Cancel should attempt to cancel the hook in the quickest, // safest way possible. type Hook interface { - Run(context.Context, string, packersdk.Ui, Communicator, interface{}) error + Run(context.Context, string, Ui, Communicator, interface{}) error } // A Hook implementation that dispatches based on an internal mapping. @@ -35,7 +33,7 @@ type DispatchHook struct { // Runs the hook with the given name by dispatching it to the proper // hooks if a mapping exists. If a mapping doesn't exist, then nothing // happens. -func (h *DispatchHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { +func (h *DispatchHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { hooks, ok := h.Mapping[name] if !ok { // No hooks for that name. No problem. diff --git a/packer/hook_mock.go b/packer-plugin-sdk/packer/hook_mock.go similarity index 66% rename from packer/hook_mock.go rename to packer-plugin-sdk/packer/hook_mock.go index f6243f988..16571f1fe 100644 --- a/packer/hook_mock.go +++ b/packer-plugin-sdk/packer/hook_mock.go @@ -2,8 +2,6 @@ package packer import ( "context" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MockHook is an implementation of Hook that can be used for tests. @@ -14,10 +12,10 @@ type MockHook struct { RunComm Communicator RunData interface{} RunName string - RunUi packersdk.Ui + RunUi Ui } -func (t *MockHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { +func (t *MockHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { t.RunCalled = true t.RunComm = comm diff --git a/packer/hook_test.go b/packer-plugin-sdk/packer/hook_test.go similarity index 88% rename from packer/hook_test.go rename to packer-plugin-sdk/packer/hook_test.go index 8bbbb943e..efe0f0fd0 100644 --- a/packer/hook_test.go +++ b/packer-plugin-sdk/packer/hook_test.go @@ -3,8 +3,6 @@ package packer import ( "context" "testing" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestDispatchHook_Implements(t *testing.T) { @@ -42,7 +40,7 @@ type CancelHook struct { cancel func() } -func (h *CancelHook) Run(ctx context.Context, _ string, _ packersdk.Ui, _ Communicator, _ interface{}) error { +func (h *CancelHook) Run(ctx context.Context, _ string, _ Ui, _ Communicator, _ interface{}) error { h.cancel() <-ctx.Done() return ctx.Err() diff --git a/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go b/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go index ac8fb1c12..63780ac5a 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go +++ b/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go @@ -6,14 +6,14 @@ import ( "io" "os" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type comm struct { config string } -// Creates a null packer.Communicator implementation. This takes +// Creates a null packersdk.Communicator implementation. This takes // an already existing configuration. func New(config string) (result *comm, err error) { // Establish an initial connection and connect @@ -24,7 +24,7 @@ func New(config string) (result *comm, err error) { return } -func (c *comm) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { +func (c *comm) Start(ctx context.Context, cmd *packersdk.RemoteCmd) (err error) { cmd.SetExited(0) return } diff --git a/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go b/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go index 081fbfe77..1c22a08ec 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go +++ b/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go @@ -3,13 +3,13 @@ package none import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommIsCommunicator(t *testing.T) { var raw interface{} raw = &comm{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("comm must be a communicator") } } diff --git a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go index 03250953d..c351fd0c0 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go +++ b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go @@ -16,7 +16,7 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" @@ -86,7 +86,7 @@ type Config struct { Tunnels []TunnelSpec } -// Creates a new packer.Communicator implementation over SSH. This takes +// Creates a new packersdk.Communicator implementation over SSH. This takes // an already existing TCP connection and SSH configuration. func New(address string, config *Config) (result *comm, err error) { // Establish an initial connection and connect @@ -103,7 +103,7 @@ func New(address string, config *Config) (result *comm, err error) { return } -func (c *comm) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { +func (c *comm) Start(ctx context.Context, cmd *packersdk.RemoteCmd) (err error) { session, err := c.newSession() if err != nil { return @@ -161,7 +161,7 @@ func (c *comm) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { log.Printf("[ERROR] Remote command exited with '%d': %s", exitStatus, cmd.Command) case *ssh.ExitMissingError: log.Printf("[ERROR] Remote command exited without exit status or exit signal.") - exitStatus = packer.CmdDisconnect + exitStatus = packersdk.CmdDisconnect default: log.Printf("[ERROR] Error occurred waiting for ssh session: %s", err.Error()) } diff --git a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go index c985d6082..d84097567 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go +++ b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -122,7 +122,7 @@ func newMockBrokenServer(t *testing.T) string { func TestCommIsCommunicator(t *testing.T) { var raw interface{} raw = &comm{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("comm must be a communicator") } } @@ -184,7 +184,7 @@ func TestStart(t *testing.T) { t.Fatalf("error connecting to SSH: %s", err) } - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: "echo foo", Stdout: new(bytes.Buffer), } diff --git a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go index 1e543dceb..6739e1957 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go +++ b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go @@ -12,7 +12,7 @@ import ( "strings" "sync" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/masterzen/winrm" "github.com/packer-community/winrmcp/winrmcp" ) @@ -75,7 +75,7 @@ func New(config *Config) (*Communicator, error) { } // Start implementation of communicator.Communicator interface -func (c *Communicator) Start(ctx context.Context, rc *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, rc *packersdk.RemoteCmd) error { shell, err := c.client.CreateShell() if err != nil { return err @@ -91,7 +91,7 @@ func (c *Communicator) Start(ctx context.Context, rc *packer.RemoteCmd) error { return nil } -func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) { +func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packersdk.RemoteCmd) { defer shell.Close() var wg sync.WaitGroup diff --git a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go index b7bc78304..061cef724 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go +++ b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/dylanmei/winrmtest" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const PAYLOAD = "stuff" @@ -74,7 +74,7 @@ func TestStart(t *testing.T) { t.Fatalf("error creating communicator: %s", err) } - var cmd packer.RemoteCmd + var cmd packersdk.RemoteCmd stdout := new(bytes.Buffer) cmd.Command = "echo foo" cmd.Stdout = stdout diff --git a/packer-plugin-sdk/shell-local/communicator.go b/packer-plugin-sdk/shell-local/communicator.go index 9b99b38bb..bc4e66e5b 100644 --- a/packer-plugin-sdk/shell-local/communicator.go +++ b/packer-plugin-sdk/shell-local/communicator.go @@ -9,14 +9,14 @@ import ( "os/exec" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Communicator struct { ExecuteCommand []string } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { if len(c.ExecuteCommand) == 0 { return fmt.Errorf("Error launching command via shell-local communicator: No ExecuteCommand provided") } diff --git a/packer-plugin-sdk/shell-local/communicator_test.go b/packer-plugin-sdk/shell-local/communicator_test.go index bc544a2ca..1e62a0c3b 100644 --- a/packer-plugin-sdk/shell-local/communicator_test.go +++ b/packer-plugin-sdk/shell-local/communicator_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_impl(t *testing.T) { - var _ packer.Communicator = new(Communicator) + var _ packersdk.Communicator = new(Communicator) } func TestCommunicator(t *testing.T) { @@ -25,7 +25,7 @@ func TestCommunicator(t *testing.T) { } var buf bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Stdout: &buf, } diff --git a/packer-plugin-sdk/shell-local/run.go b/packer-plugin-sdk/shell-local/run.go index 9b7a0b961..eae6dedfa 100644 --- a/packer-plugin-sdk/shell-local/run.go +++ b/packer-plugin-sdk/shell-local/run.go @@ -11,7 +11,6 @@ import ( "sort" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -97,7 +96,7 @@ func Run(ctx context.Context, ui packersdk.Ui, config *Config, generatedData map // the other communicators; ultimately, this command is just used for // buffers and for reading the final exit status. flattenedCmd := strings.Join(interpolatedCmds, " ") - cmd := &packer.RemoteCmd{Command: flattenedCmd} + cmd := &packersdk.RemoteCmd{Command: flattenedCmd} log.Printf("[INFO] (shell-local): starting local command: %s", flattenedCmd) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return false, fmt.Errorf( diff --git a/packer/build.go b/packer/build.go index ba6ee5419..5eb4213db 100644 --- a/packer/build.go +++ b/packer/build.go @@ -98,7 +98,7 @@ type CoreBuild struct { Builder Builder BuilderConfig interface{} BuilderType string - hooks map[string][]Hook + hooks map[string][]packersdk.Hook Provisioners []CoreBuildProvisioner PostProcessors [][]CoreBuildPostProcessor CleanupProvisioner CoreBuildProvisioner @@ -238,9 +238,9 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers } // Copy the hooks - hooks := make(map[string][]Hook) + hooks := make(map[string][]packersdk.Hook) for hookName, hookList := range b.hooks { - hooks[hookName] = make([]Hook, len(hookList)) + hooks[hookName] = make([]packersdk.Hook, len(hookList)) copy(hooks[hookName], hookList) } @@ -267,11 +267,11 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers } } - if _, ok := hooks[HookProvision]; !ok { - hooks[HookProvision] = make([]Hook, 0, 1) + if _, ok := hooks[packersdk.HookProvision]; !ok { + hooks[packersdk.HookProvision] = make([]packersdk.Hook, 0, 1) } - hooks[HookProvision] = append(hooks[HookProvision], &ProvisionHook{ + hooks[packersdk.HookProvision] = append(hooks[packersdk.HookProvision], &ProvisionHook{ Provisioners: hookedProvisioners, }) } @@ -282,12 +282,12 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers b.CleanupProvisioner.config, b.CleanupProvisioner.PType, } - hooks[HookCleanupProvision] = []Hook{&ProvisionHook{ + hooks[packersdk.HookCleanupProvision] = []packersdk.Hook{&ProvisionHook{ Provisioners: []*HookedProvisioner{hookedCleanupProvisioner}, }} } - hook := &DispatchHook{Mapping: hooks} + hook := &packersdk.DispatchHook{Mapping: hooks} artifacts := make([]packersdk.Artifact, 0, 1) // The builder just has a normal Ui, but targeted diff --git a/packer/builder.go b/packer/builder.go index b189dd6e8..586ae4a4e 100644 --- a/packer/builder.go +++ b/packer/builder.go @@ -17,7 +17,7 @@ import ( // parallelism is strictly disabled, so it is safe to request input from // stdin and so on. type Builder interface { - HCL2Speccer + packersdk.HCL2Speccer // Prepare is responsible for configuring the builder and validating // that configuration. Any setup should be done in this method. Note that @@ -37,5 +37,5 @@ type Builder interface { Prepare(...interface{}) ([]string, []string, error) // Run is where the actual build should take place. It takes a Build and a Ui. - Run(context.Context, packersdk.Ui, Hook) (packersdk.Artifact, error) + Run(context.Context, packersdk.Ui, packersdk.Hook) (packersdk.Artifact, error) } diff --git a/packer/builder_mock.go b/packer/builder_mock.go index 7802d8d3b..6a7f03c7d 100644 --- a/packer/builder_mock.go +++ b/packer/builder_mock.go @@ -22,7 +22,7 @@ type MockBuilder struct { PrepareCalled bool PrepareConfig []interface{} RunCalled bool - RunHook Hook + RunHook packersdk.Hook RunUi packersdk.Ui CancelCalled bool RunFn func(ctx context.Context) @@ -40,7 +40,7 @@ func (tb *MockBuilder) Prepare(config ...interface{}) ([]string, []string, error return tb.GeneratedVars, tb.PrepareWarnings, nil } -func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (packersdk.Artifact, error) { +func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h packersdk.Hook) (packersdk.Artifact, error) { tb.RunCalled = true tb.RunHook = h tb.RunUi = ui @@ -57,7 +57,7 @@ func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (packer } if h != nil { - if err := h.Run(ctx, HookProvision, ui, new(MockCommunicator), nil); err != nil { + if err := h.Run(ctx, packersdk.HookProvision, ui, new(packersdk.MockCommunicator), nil); err != nil { return nil, err } } diff --git a/packer/builder_mock.hcl2spec.go b/packer/builder_mock.hcl2spec.go index e7c7f85ba..0dfe58a08 100644 --- a/packer/builder_mock.hcl2spec.go +++ b/packer/builder_mock.hcl2spec.go @@ -2,10 +2,8 @@ package packer import ( - "io" - "github.com/hashicorp/hcl/v2/hcldec" - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" + "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -19,8 +17,8 @@ type FlatMockBuilder struct { PrepareCalled *bool `cty:"prepare_called" hcl:"prepare_called"` PrepareConfig []interface{} `cty:"prepare_config" hcl:"prepare_config"` RunCalled *bool `cty:"run_called" hcl:"run_called"` - RunHook Hook `cty:"run_hook" hcl:"run_hook"` - RunUi packersdk.Ui `cty:"run_ui" hcl:"run_ui"` + RunHook packer.Hook `cty:"run_hook" hcl:"run_hook"` + RunUi packer.Ui `cty:"run_ui" hcl:"run_ui"` CancelCalled *bool `cty:"cancel_called" hcl:"cancel_called"` GeneratedVars []string `cty:"generated_vars" hcl:"generated_vars"` } @@ -52,76 +50,19 @@ func (*FlatMockBuilder) HCL2Spec() map[string]hcldec.Spec { return s } -// FlatMockCommunicator is an auto-generated flat version of MockCommunicator. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatMockCommunicator struct { - StartCalled *bool `cty:"start_called" hcl:"start_called"` - StartCmd *FlatRemoteCmd `cty:"start_cmd" hcl:"start_cmd"` - StartStderr *string `cty:"start_stderr" hcl:"start_stderr"` - StartStdout *string `cty:"start_stdout" hcl:"start_stdout"` - StartStdin *string `cty:"start_stdin" hcl:"start_stdin"` - StartExitStatus *int `cty:"start_exit_status" hcl:"start_exit_status"` - UploadCalled *bool `cty:"upload_called" hcl:"upload_called"` - UploadPath *string `cty:"upload_path" hcl:"upload_path"` - UploadData *string `cty:"upload_data" hcl:"upload_data"` - UploadDirDst *string `cty:"upload_dir_dst" hcl:"upload_dir_dst"` - UploadDirSrc *string `cty:"upload_dir_src" hcl:"upload_dir_src"` - UploadDirExclude []string `cty:"upload_dir_exclude" hcl:"upload_dir_exclude"` - DownloadDirDst *string `cty:"download_dir_dst" hcl:"download_dir_dst"` - DownloadDirSrc *string `cty:"download_dir_src" hcl:"download_dir_src"` - DownloadDirExclude []string `cty:"download_dir_exclude" hcl:"download_dir_exclude"` - DownloadCalled *bool `cty:"download_called" hcl:"download_called"` - DownloadPath *string `cty:"download_path" hcl:"download_path"` - DownloadData *string `cty:"download_data" hcl:"download_data"` -} - -// FlatMapstructure returns a new FlatMockCommunicator. -// FlatMockCommunicator is an auto-generated flat version of MockCommunicator. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*MockCommunicator) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatMockCommunicator) -} - -// HCL2Spec returns the hcl spec of a MockCommunicator. -// This spec is used by HCL to read the fields of MockCommunicator. -// The decoded values from this spec will then be applied to a FlatMockCommunicator. -func (*FlatMockCommunicator) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "start_called": &hcldec.AttrSpec{Name: "start_called", Type: cty.Bool, Required: false}, - "start_cmd": &hcldec.BlockSpec{TypeName: "start_cmd", Nested: hcldec.ObjectSpec((*FlatRemoteCmd)(nil).HCL2Spec())}, - "start_stderr": &hcldec.AttrSpec{Name: "start_stderr", Type: cty.String, Required: false}, - "start_stdout": &hcldec.AttrSpec{Name: "start_stdout", Type: cty.String, Required: false}, - "start_stdin": &hcldec.AttrSpec{Name: "start_stdin", Type: cty.String, Required: false}, - "start_exit_status": &hcldec.AttrSpec{Name: "start_exit_status", Type: cty.Number, Required: false}, - "upload_called": &hcldec.AttrSpec{Name: "upload_called", Type: cty.Bool, Required: false}, - "upload_path": &hcldec.AttrSpec{Name: "upload_path", Type: cty.String, Required: false}, - "upload_data": &hcldec.AttrSpec{Name: "upload_data", Type: cty.String, Required: false}, - "upload_dir_dst": &hcldec.AttrSpec{Name: "upload_dir_dst", Type: cty.String, Required: false}, - "upload_dir_src": &hcldec.AttrSpec{Name: "upload_dir_src", Type: cty.String, Required: false}, - "upload_dir_exclude": &hcldec.AttrSpec{Name: "upload_dir_exclude", Type: cty.List(cty.String), Required: false}, - "download_dir_dst": &hcldec.AttrSpec{Name: "download_dir_dst", Type: cty.String, Required: false}, - "download_dir_src": &hcldec.AttrSpec{Name: "download_dir_src", Type: cty.String, Required: false}, - "download_dir_exclude": &hcldec.AttrSpec{Name: "download_dir_exclude", Type: cty.List(cty.String), Required: false}, - "download_called": &hcldec.AttrSpec{Name: "download_called", Type: cty.Bool, Required: false}, - "download_path": &hcldec.AttrSpec{Name: "download_path", Type: cty.String, Required: false}, - "download_data": &hcldec.AttrSpec{Name: "download_data", Type: cty.String, Required: false}, - } - return s -} - // FlatMockPostProcessor is an auto-generated flat version of MockPostProcessor. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatMockPostProcessor struct { - ArtifactId *string `cty:"artifact_id" hcl:"artifact_id"` - Keep *bool `cty:"keep" hcl:"keep"` - ForceOverride *bool `cty:"force_override" hcl:"force_override"` - Error error `cty:"error" hcl:"error"` - ConfigureCalled *bool `cty:"configure_called" hcl:"configure_called"` - ConfigureConfigs []interface{} `cty:"configure_configs" hcl:"configure_configs"` - ConfigureError error `cty:"configure_error" hcl:"configure_error"` - PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` - PostProcessArtifact packersdk.Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` - PostProcessUi packersdk.Ui `cty:"post_process_ui" hcl:"post_process_ui"` + ArtifactId *string `cty:"artifact_id" hcl:"artifact_id"` + Keep *bool `cty:"keep" hcl:"keep"` + ForceOverride *bool `cty:"force_override" hcl:"force_override"` + Error error `cty:"error" hcl:"error"` + ConfigureCalled *bool `cty:"configure_called" hcl:"configure_called"` + ConfigureConfigs []interface{} `cty:"configure_configs" hcl:"configure_configs"` + ConfigureError error `cty:"configure_error" hcl:"configure_error"` + PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` + PostProcessArtifact packer.Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` + PostProcessUi packer.Ui `cty:"post_process_ui" hcl:"post_process_ui"` } // FlatMapstructure returns a new FlatMockPostProcessor. @@ -153,12 +94,12 @@ func (*FlatMockPostProcessor) HCL2Spec() map[string]hcldec.Spec { // FlatMockProvisioner is an auto-generated flat version of MockProvisioner. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatMockProvisioner struct { - PrepCalled *bool `cty:"prep_called" hcl:"prep_called"` - PrepConfigs []interface{} `cty:"prep_configs" hcl:"prep_configs"` - ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` - ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` - ProvCommunicator Communicator `cty:"prov_communicator" hcl:"prov_communicator"` - ProvUi packersdk.Ui `cty:"prov_ui" hcl:"prov_ui"` + PrepCalled *bool `cty:"prep_called" hcl:"prep_called"` + PrepConfigs []interface{} `cty:"prep_configs" hcl:"prep_configs"` + ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` + ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` + ProvCommunicator *packer.Communicator `cty:"prov_communicator" hcl:"prov_communicator"` + ProvUi packer.Ui `cty:"prov_ui" hcl:"prov_ui"` } // FlatMapstructure returns a new FlatMockProvisioner. @@ -177,37 +118,8 @@ func (*FlatMockProvisioner) HCL2Spec() map[string]hcldec.Spec { "prep_configs": &hcldec.AttrSpec{Name: "prep_configs", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ "prov_called": &hcldec.AttrSpec{Name: "prov_called", Type: cty.Bool, Required: false}, "prov_retried": &hcldec.AttrSpec{Name: "prov_retried", Type: cty.Bool, Required: false}, - "prov_communicator": &hcldec.AttrSpec{Name: "prov_communicator", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - "prov_ui": &hcldec.AttrSpec{Name: "prov_ui", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - } - return s -} - -// FlatRemoteCmd is an auto-generated flat version of RemoteCmd. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatRemoteCmd struct { - Command *string `cty:"command" hcl:"command"` - Stdin io.Reader `cty:"stdin" hcl:"stdin"` - Stdout io.Writer `cty:"stdout" hcl:"stdout"` - Stderr io.Writer `cty:"stderr" hcl:"stderr"` -} - -// FlatMapstructure returns a new FlatRemoteCmd. -// FlatRemoteCmd is an auto-generated flat version of RemoteCmd. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*RemoteCmd) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatRemoteCmd) -} - -// HCL2Spec returns the hcl spec of a RemoteCmd. -// This spec is used by HCL to read the fields of RemoteCmd. -// The decoded values from this spec will then be applied to a FlatRemoteCmd. -func (*FlatRemoteCmd) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "command": &hcldec.AttrSpec{Name: "command", Type: cty.String, Required: false}, - "stdin": &hcldec.AttrSpec{Name: "stdin", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - "stdout": &hcldec.AttrSpec{Name: "stdout", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - "stderr": &hcldec.AttrSpec{Name: "stderr", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ + "prov_communicator": &hcldec.AttrSpec{Name: "prov_communicator", Type: cty.String, Required: false}, + "prov_ui": &hcldec.AttrSpec{Name: "prov_ui", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ } return s } diff --git a/packer/core.go b/packer/core.go index 0c2759f01..07d0841d1 100644 --- a/packer/core.go +++ b/packer/core.go @@ -53,7 +53,7 @@ type CoreConfig struct { type BuilderFunc func(name string) (Builder, error) // The function type used to lookup Hook implementations. -type HookFunc func(name string) (Hook, error) +type HookFunc func(name string) (packersdk.Hook, error) // The function type used to lookup PostProcessor implementations. type PostProcessorFunc func(name string) (PostProcessor, error) diff --git a/packer/plugin/builder.go b/packer/plugin/builder.go index 5ec142d6d..9778b58fa 100644 --- a/packer/plugin/builder.go +++ b/packer/plugin/builder.go @@ -32,7 +32,7 @@ func (b *cmdBuilder) Prepare(config ...interface{}) ([]string, []string, error) return b.builder.Prepare(config...) } -func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { defer func() { r := recover() b.checkExit(r, nil) diff --git a/packer/plugin/client.go b/packer/plugin/client.go index 33fcf7f75..a8b1f8b1a 100644 --- a/packer/plugin/client.go +++ b/packer/plugin/client.go @@ -17,6 +17,7 @@ import ( "unicode" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" packrpc "github.com/hashicorp/packer/packer/rpc" ) @@ -141,7 +142,7 @@ func (c *Client) Builder() (packer.Builder, error) { // Returns a hook implementation that is communicating over this // client. If the client hasn't been started, this will start it. -func (c *Client) Hook() (packer.Hook, error) { +func (c *Client) Hook() (packersdk.Hook, error) { client, err := c.packrpcClient() if err != nil { return nil, err diff --git a/packer/plugin/hook.go b/packer/plugin/hook.go index 92da9cb18..808b67f75 100644 --- a/packer/plugin/hook.go +++ b/packer/plugin/hook.go @@ -4,16 +4,15 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdHook struct { - hook packer.Hook + hook packersdk.Hook client *Client } -func (c *cmdHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packer.Communicator, data interface{}) error { +func (c *cmdHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/plugin/provisioner.go b/packer/plugin/provisioner.go index 8602b7ad1..9d502b9ff 100644 --- a/packer/plugin/provisioner.go +++ b/packer/plugin/provisioner.go @@ -32,7 +32,7 @@ func (c *cmdProvisioner) Prepare(configs ...interface{}) error { return c.p.Prepare(configs...) } -func (c *cmdProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (c *cmdProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/post_processor.go b/packer/post_processor.go index 32fe23f1f..cd47e297c 100644 --- a/packer/post_processor.go +++ b/packer/post_processor.go @@ -12,7 +12,7 @@ import ( // the result of a build, compresses it, and returns a new artifact containing // a single file of the prior artifact compressed. type PostProcessor interface { - HCL2Speccer + packersdk.HCL2Speccer // Configure is responsible for setting up configuration, storing // the state for later, and returning and errors, such as validation diff --git a/packer/provisioner.go b/packer/provisioner.go index 0fa22fb42..b1ac9c005 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -15,7 +15,7 @@ import ( // A provisioner is responsible for installing and configuring software // on a machine prior to building the actual image. type Provisioner interface { - HCL2Speccer + packersdk.HCL2Speccer // Prepare is called with a set of configurations to setup the // internal state of the provisioner. The multiple configurations @@ -26,7 +26,7 @@ type Provisioner interface { // given for cancellation, a UI is given to communicate with the user, and // a communicator is given that is guaranteed to be connected to some // machine so that provisioning can be done. - Provision(context.Context, packersdk.Ui, Communicator, map[string]interface{}) error + Provision(context.Context, packersdk.Ui, packersdk.Communicator, map[string]interface{}) error } // A HookedProvisioner represents a provisioner and information describing it @@ -120,7 +120,7 @@ func CastDataToMap(data interface{}) map[string]interface{} { } // Runs the provisioners in order. -func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { +func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error { // Shortcut if len(h.Provisioners) == 0 { return nil @@ -160,7 +160,7 @@ func (p *PausedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { // Use a select to determine if we get cancelled during the wait ui.Say(fmt.Sprintf("Pausing %s before the next provisioner...", p.PauseBefore)) @@ -186,7 +186,7 @@ func (r *RetriedProvisioner) Prepare(raws ...interface{}) error { return r.Provisioner.Prepare(raws...) } -func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if ctx.Err() != nil { // context was cancelled return ctx.Err() } @@ -231,7 +231,7 @@ func (p *DebuggedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *DebuggedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *DebuggedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { // Use a select to determine if we get cancelled during the wait message := "Pausing before the next provisioner . Press enter to continue." diff --git a/packer/provisioner_mock.go b/packer/provisioner_mock.go index 1353c0d49..b4fc829b8 100644 --- a/packer/provisioner_mock.go +++ b/packer/provisioner_mock.go @@ -16,7 +16,7 @@ type MockProvisioner struct { PrepConfigs []interface{} ProvCalled bool ProvRetried bool - ProvCommunicator Communicator + ProvCommunicator packersdk.Communicator ProvUi packersdk.Ui } @@ -30,7 +30,7 @@ func (t *MockProvisioner) Prepare(configs ...interface{}) error { return nil } -func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if t.ProvCalled { t.ProvRetried = true return nil @@ -47,7 +47,7 @@ func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm C return t.ProvFunc(ctx) } -func (t *MockProvisioner) Communicator() Communicator { +func (t *MockProvisioner) Communicator() packersdk.Communicator { return t.ProvCommunicator } diff --git a/packer/provisioner_timeout.go b/packer/provisioner_timeout.go index 14050a52d..6b2b5649c 100644 --- a/packer/provisioner_timeout.go +++ b/packer/provisioner_timeout.go @@ -15,7 +15,7 @@ type TimeoutProvisioner struct { Timeout time.Duration } -func (p *TimeoutProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *TimeoutProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ctx, cancel := context.WithTimeout(ctx, p.Timeout) defer cancel() diff --git a/packer/rpc/builder.go b/packer/rpc/builder.go index 8f6d5ed6b..dc962675f 100644 --- a/packer/rpc/builder.go +++ b/packer/rpc/builder.go @@ -52,7 +52,7 @@ func (b *builder) Prepare(config ...interface{}) ([]string, []string, error) { return resp.GeneratedVars, resp.Warnings, err } -func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { nextId := b.mux.NextId() server := newServerWithMux(b.mux, nextId) server.RegisterHook(hook) diff --git a/packer/rpc/client.go b/packer/rpc/client.go index 5bf4e4c94..93bf76fd6 100644 --- a/packer/rpc/client.go +++ b/packer/rpc/client.go @@ -99,7 +99,7 @@ func (c *Client) Builder() packer.Builder { } } -func (c *Client) Communicator() packer.Communicator { +func (c *Client) Communicator() packersdk.Communicator { return &communicator{ commonClient: commonClient{ endpoint: DefaultCommunicatorEndpoint, @@ -109,7 +109,7 @@ func (c *Client) Communicator() packer.Communicator { } } -func (c *Client) Hook() packer.Hook { +func (c *Client) Hook() packersdk.Hook { return &hook{ commonClient: commonClient{ endpoint: DefaultHookEndpoint, diff --git a/packer/rpc/communicator.go b/packer/rpc/communicator.go index 55da58f24..062708c24 100644 --- a/packer/rpc/communicator.go +++ b/packer/rpc/communicator.go @@ -9,20 +9,20 @@ import ( "os" "sync" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.Communicator where the communicator is actually +// An implementation of packersdk.Communicator where the communicator is actually // executed over an RPC connection. type communicator struct { commonClient } -// CommunicatorServer wraps a packer.Communicator implementation and makes +// CommunicatorServer wraps a packersdk.Communicator implementation and makes // it exportable as part of a Golang RPC server. type CommunicatorServer struct { commonServer - c packer.Communicator + c packersdk.Communicator } type CommandFinished struct { @@ -69,7 +69,7 @@ func Communicator(client *rpc.Client) *communicator { } } -func (c *communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { +func (c *communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) (err error) { var args CommunicatorStartArgs args.Command = cmd.Command @@ -210,7 +210,7 @@ func (c *CommunicatorServer) Start(args *CommunicatorStartArgs, reply *interface // Build the RemoteCmd on this side so that it all pipes over // to the remote side. - var cmd packer.RemoteCmd + var cmd packersdk.RemoteCmd cmd.Command = args.Command // Create a channel to signal we're done so that we can close diff --git a/packer/rpc/communicator_test.go b/packer/rpc/communicator_test.go index a109a1a4d..9e8f298d6 100644 --- a/packer/rpc/communicator_test.go +++ b/packer/rpc/communicator_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicatorRPC(t *testing.T) { @@ -26,7 +27,7 @@ func TestCommunicatorRPC(t *testing.T) { stdout_r, stdout_w := io.Pipe() stderr_r, stderr_w := io.Pipe() - var cmd packer.RemoteCmd + var cmd packersdk.RemoteCmd cmd.Command = "foo" cmd.Stdin = stdin_r cmd.Stdout = stdout_w @@ -163,7 +164,7 @@ func TestCommunicatorRPC(t *testing.T) { func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = Communicator(nil) - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatal("should be a Communicator") } } diff --git a/packer/rpc/hook.go b/packer/rpc/hook.go index 55de54a91..a670a8902 100644 --- a/packer/rpc/hook.go +++ b/packer/rpc/hook.go @@ -5,23 +5,22 @@ import ( "log" "sync" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.Hook where the hook is actually executed +// An implementation of packersdk.Hook where the hook is actually executed // over an RPC connection. type hook struct { commonClient } -// HookServer wraps a packer.Hook implementation and makes it exportable +// HookServer wraps a packersdk.Hook implementation and makes it exportable // as part of a Golang RPC server. type HookServer struct { context context.Context contextCancel func() - hook packer.Hook + hook packersdk.Hook lock sync.Mutex mux *muxBroker } @@ -32,7 +31,7 @@ type HookRunArgs struct { StreamId uint32 } -func (h *hook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packer.Communicator, data interface{}) error { +func (h *hook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error { nextId := h.mux.NextId() server := newServerWithMux(h.mux, nextId) server.RegisterCommunicator(comm) diff --git a/packer/rpc/hook_test.go b/packer/rpc/hook_test.go index 700feda65..ef28eeb4c 100644 --- a/packer/rpc/hook_test.go +++ b/packer/rpc/hook_test.go @@ -5,10 +5,11 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestHook_Implements(t *testing.T) { - var _ packer.Hook = new(hook) + var _ packersdk.Hook = new(hook) } func TestHook_cancelWhileRun(t *testing.T) { diff --git a/packer/rpc/provisioner.go b/packer/rpc/provisioner.go index f1de8e0fc..8337cf6db 100644 --- a/packer/rpc/provisioner.go +++ b/packer/rpc/provisioner.go @@ -42,7 +42,7 @@ type ProvisionerProvisionArgs struct { StreamID uint32 } -func (p *provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { nextId := p.mux.NextId() server := newServerWithMux(p.mux, nextId) server.RegisterCommunicator(comm) diff --git a/packer/rpc/server.go b/packer/rpc/server.go index 48a37ab49..07ebf70f9 100644 --- a/packer/rpc/server.go +++ b/packer/rpc/server.go @@ -87,7 +87,7 @@ func (s *Server) RegisterBuilder(b packer.Builder) error { }) } -func (s *Server) RegisterCommunicator(c packer.Communicator) error { +func (s *Server) RegisterCommunicator(c packersdk.Communicator) error { return s.server.RegisterName(DefaultCommunicatorEndpoint, &CommunicatorServer{ c: c, commonServer: commonServer{ @@ -96,7 +96,7 @@ func (s *Server) RegisterCommunicator(c packer.Communicator) error { }) } -func (s *Server) RegisterHook(h packer.Hook) error { +func (s *Server) RegisterHook(h packersdk.Hook) error { return s.server.RegisterName(DefaultHookEndpoint, &HookServer{ hook: h, mux: s.mux, diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index 0c15aa400..e0102b5cb 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -15,7 +15,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" shelllocal "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" @@ -201,7 +200,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa ExecuteCommand: commandAndArgs, } flattenedCmd := strings.Join(commandAndArgs, " ") - cmd := &packer.RemoteCmd{Command: flattenedCmd} + cmd := &packersdk.RemoteCmd{Command: flattenedCmd} log.Printf("[INFO] (vsphere): starting ovftool command: %s", flattenedCmd) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return nil, false, false, fmt.Errorf( diff --git a/provisioner/ansible-local/communicator_mock.go b/provisioner/ansible-local/communicator_mock.go index 8ba3a9195..054b76b02 100644 --- a/provisioner/ansible-local/communicator_mock.go +++ b/provisioner/ansible-local/communicator_mock.go @@ -5,7 +5,7 @@ import ( "io" "os" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type communicatorMock struct { @@ -13,7 +13,7 @@ type communicatorMock struct { uploadDestination []string } -func (c *communicatorMock) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *communicatorMock) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { c.startCommand = append(c.startCommand, cmd.Command) cmd.SetExited(0) return nil diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index 2e44ffbb6..0dd55c9bf 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -194,7 +193,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Ansible...") p.generatedData = generatedData @@ -318,7 +317,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packersdk.Communicator) error { var playbookDir string if p.config.PlaybookDir != "" { var err error @@ -339,7 +338,7 @@ func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packer.Commun return nil } -func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packer.Communicator, playbookFile string) error { +func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packersdk.Communicator, playbookFile string) error { ui.Message(fmt.Sprintf("Uploading playbook file: %s", playbookFile)) remoteDir := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Dir(playbookFile))) @@ -356,7 +355,7 @@ func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packer.Communi return nil } -func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packersdk.Communicator) error { ctx := context.TODO() rolesDir := filepath.ToSlash(filepath.Join(p.config.StagingDir, "roles")) galaxyFile := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.GalaxyFile))) @@ -365,7 +364,7 @@ func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) e command := fmt.Sprintf("cd %s && %s install -r %s -p %s", p.config.StagingDir, p.config.GalaxyCommand, galaxyFile, rolesDir) ui.Message(fmt.Sprintf("Executing Ansible Galaxy: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -378,7 +377,7 @@ func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) e return nil } -func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator) error { inventory := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.InventoryFile))) extraArgs := fmt.Sprintf(" --extra-vars \"packer_build_name=%s packer_builder_type=%s packer_http_addr=%s -o IdentitiesOnly=yes\" ", @@ -411,14 +410,14 @@ func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator) } func (p *Provisioner) executeAnsiblePlaybook( - ui packersdk.Ui, comm packer.Communicator, playbookFile, extraArgs, inventory string, + ui packersdk.Ui, comm packersdk.Communicator, playbookFile, extraArgs, inventory string, ) error { ctx := context.TODO() command := fmt.Sprintf("cd %s && %s %s%s -c local -i %s", p.config.StagingDir, p.config.Command, playbookFile, extraArgs, inventory, ) ui.Message(fmt.Sprintf("Executing Ansible: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -461,7 +460,7 @@ func validateFileConfig(name string, config string, req bool) error { return nil } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return fmt.Errorf("Error opening: %s", err) @@ -474,9 +473,9 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, return nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("mkdir -p '%s'", dir), } @@ -491,9 +490,9 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("rm -rf '%s'", dir), } @@ -508,7 +507,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packersdk.Communicator, dst, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index 9d55d549d..a1785df73 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/provisioner/file" ) @@ -364,10 +365,10 @@ func testProvisionerProvisionDockerWithPlaybookFiles(t *testing.T, templateStrin } // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: ansible, Config: nil, TypeName: ""}, {Provisioner: download, Config: nil, TypeName: ""}, }, diff --git a/provisioner/ansible/mock_ansible.go b/provisioner/ansible/mock_ansible.go index db1a57ba6..c17668dcb 100644 --- a/provisioner/ansible/mock_ansible.go +++ b/provisioner/ansible/mock_ansible.go @@ -5,7 +5,6 @@ package ansible import ( "fmt" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -15,7 +14,7 @@ type provisionLogicTracker struct { happyPath bool } -func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { l.setupAdapterCalled = true if l.happyPath { return "fakeKeyString", nil @@ -23,7 +22,7 @@ func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packer.Commun return "", fmt.Errorf("chose sadpath") } -func (l *provisionLogicTracker) executeAnsible(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { +func (l *provisionLogicTracker) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error { l.executeAnsibleCalled = true if l.happyPath { return fmt.Errorf("Chose sadpath") diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index c58c99b51..b1568fe51 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -215,8 +215,8 @@ type Provisioner struct { ansibleMajVersion uint generatedData map[string]interface{} - setupAdapterFunc func(ui packersdk.Ui, comm packer.Communicator) (string, error) - executeAnsibleFunc func(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error + setupAdapterFunc func(ui packersdk.Ui, comm packersdk.Communicator) (string, error) + executeAnsibleFunc func(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error } func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } @@ -362,7 +362,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) setupAdapter(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) setupAdapter(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Setting up proxy adapter for Ansible....") k, err := newUserKey(p.config.SSHAuthorizedKeyFile) @@ -503,7 +503,7 @@ func (p *Provisioner) createInventoryFile() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Ansible...") // Interpolate env vars to check for generated values like password and port p.generatedData = generatedData @@ -628,7 +628,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packersdk.Communicator) error { galaxyFile := filepath.ToSlash(p.config.GalaxyFile) // ansible-galaxy install -r requirements.yml @@ -677,7 +677,7 @@ func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) e } // Intended to be invoked from p.executeGalaxy depending on the Ansible Galaxy parameters passed to Packer -func (p *Provisioner) invokeGalaxyCommand(args []string, ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) invokeGalaxyCommand(args []string, ui packersdk.Ui, comm packersdk.Communicator) error { ui.Message(fmt.Sprintf("Executing Ansible Galaxy")) cmd := exec.Command(p.config.GalaxyCommand, args...) @@ -782,7 +782,7 @@ func (p *Provisioner) createCmdArgs(httpAddr, inventory, playbook, privKeyFile s return args, envVars } -func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { +func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error { playbook, _ := filepath.Abs(p.config.PlaybookFile) inventory := p.config.InventoryFile httpAddr := p.generatedData["PackerHTTPAddr"].(string) diff --git a/provisioner/azure-dtlartifact/provisioner.go b/provisioner/azure-dtlartifact/provisioner.go index 612e24b01..1f9ca812d 100644 --- a/provisioner/azure-dtlartifact/provisioner.go +++ b/provisioner/azure-dtlartifact/provisioner.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/client" dtlBuilder "github.com/hashicorp/packer/builder/azure/dtl" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" @@ -63,7 +62,7 @@ type Config struct { type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator } func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } @@ -93,11 +92,11 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { p.communicator = comm diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index a31f68e27..ebbdd3a11 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -9,7 +9,6 @@ import ( "golang.org/x/sync/errgroup" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -47,7 +46,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { if p.config.Disable { if p.config.Note != "" { ui.Say(fmt.Sprintf( diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index 87167e6e6..b275ce5ec 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -85,7 +85,7 @@ type Config struct { type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator guestOSTypeConfig guestOSTypeConfig guestCommands *guestexec.GuestCommands generatedData map[string]interface{} @@ -241,7 +241,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { p.generatedData = generatedData p.communicator = comm @@ -349,7 +349,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, remotePath string, localPath string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, remotePath string, localPath string) error { ui.Message(fmt.Sprintf("Uploading %s...", localPath)) f, err := os.Open(localPath) @@ -363,7 +363,7 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, remo func (p *Provisioner) createConfig( ui packersdk.Ui, - comm packer.Communicator, + comm packersdk.Communicator, nodeName string, serverUrl string, clientKey string, @@ -424,7 +424,7 @@ func (p *Provisioner) createConfig( return remotePath, nil } -func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packer.Communicator, nodeName string, serverUrl string, clientKey string, sslVerifyMode string, trustedCertsDir string) (string, error) { +func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packersdk.Communicator, nodeName string, serverUrl string, clientKey string, sslVerifyMode string, trustedCertsDir string) (string, error) { ui.Message("Creating configuration file 'knife.rb'") // Read the template @@ -451,7 +451,7 @@ func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packer.Communicato return remotePath, nil } -func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) createJson(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Creating JSON attribute file") jsonData := make(map[string]interface{}) @@ -480,11 +480,11 @@ func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (str return remotePath, nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Creating directory: %s", dir)) - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -493,7 +493,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -504,7 +504,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { +func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packersdk.Communicator, node string, knifeConfigPath string) error { ui.Say("Cleaning up chef node...") args := []string{"node", "delete", node} if err := p.knifeExec(ui, comm, node, knifeConfigPath, args); err != nil { @@ -514,7 +514,7 @@ func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packer.Communicator, node return nil } -func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { +func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packersdk.Communicator, node string, knifeConfigPath string) error { ui.Say("Cleaning up chef client...") args := []string{"client", "delete", node} if err := p.knifeExec(ui, comm, node, knifeConfigPath, args); err != nil { @@ -524,7 +524,7 @@ func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packer.Communicator, nod return nil } -func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string, args []string) error { +func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packersdk.Communicator, node string, knifeConfigPath string, args []string) error { flags := []string{ "-y", "-c", knifeConfigPath, @@ -542,7 +542,7 @@ func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node return err } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -556,11 +556,11 @@ func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Removing directory: %s", dir)) ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -568,7 +568,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, config string, json string) error { +func (p *Provisioner) executeChef(ui packersdk.Ui, comm packersdk.Communicator, config string, json string) error { p.config.ctx.Data = &ExecuteTemplate{ ConfigPath: config, JsonPath: json, @@ -590,7 +590,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con ui.Message(fmt.Sprintf("Executing Chef: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } @@ -605,7 +605,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con return nil } -func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, version string) error { +func (p *Provisioner) installChef(ui packersdk.Ui, comm packersdk.Communicator, version string) error { ui.Message("Installing Chef...") ctx := context.TODO() @@ -620,7 +620,7 @@ func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, ver ui.Message(command) - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -715,7 +715,7 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) { return result, nil } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 0bb4bcec1..cfc049e99 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -16,7 +16,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -243,7 +242,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { ui.Say("Provisioning with chef-solo") if !p.config.SkipInstall { @@ -315,7 +314,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -329,7 +328,7 @@ func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { f, err := os.Open(src) if err != nil { return err @@ -339,7 +338,7 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst return comm.Upload(dst, f, nil) } -func (p *Provisioner) createConfig(ui packersdk.Ui, comm packer.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string, chefLicense string) (string, error) { +func (p *Provisioner) createConfig(ui packersdk.Ui, comm packersdk.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string, chefLicense string) (string, error) { ui.Message("Creating configuration file 'solo.rb'") cookbook_paths := make([]string, len(p.config.RemoteCookbookPaths)+len(localCookbooks)) @@ -395,7 +394,7 @@ func (p *Provisioner) createConfig(ui packersdk.Ui, comm packer.Communicator, lo return remotePath, nil } -func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) createJson(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Creating JSON attribute file") jsonData := make(map[string]interface{}) @@ -424,11 +423,11 @@ func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (str return remotePath, nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -437,7 +436,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -448,7 +447,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, config string, json string) error { +func (p *Provisioner) executeChef(ui packersdk.Ui, comm packersdk.Communicator, config string, json string) error { p.config.ctx.Data = &ExecuteTemplate{ ConfigPath: config, JsonPath: json, @@ -461,7 +460,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con ui.Message(fmt.Sprintf("Executing Chef: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } ctx := context.TODO() @@ -476,7 +475,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con return nil } -func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, version string) error { +func (p *Provisioner) installChef(ui packersdk.Ui, comm packersdk.Communicator, version string) error { ui.Message("Installing Chef...") ctx := context.TODO() @@ -489,7 +488,7 @@ func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, ver return err } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index d179cb1bb..73b690c42 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -16,7 +16,6 @@ import ( "encoding/json" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -112,7 +111,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } // Provision node somehow. TODO: actual docs -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { ui.Say("Provisioning with Converge") // bootstrapping @@ -133,7 +132,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packersdk.Communicator) error { ctx := context.TODO() if !p.config.Bootstrap { return nil @@ -153,7 +152,7 @@ func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) } var out, outErr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, Stdin: nil, Stdout: &out, @@ -175,7 +174,7 @@ func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) return nil } -func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packersdk.Communicator) error { for _, dir := range p.config.ModuleDirs { if err := comm.UploadDir(dir.Destination, dir.Source, dir.Exclude); err != nil { return fmt.Errorf("Could not upload %q: %s", dir.Source, err) @@ -186,7 +185,7 @@ func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packer.Communi return nil } -func (p *Provisioner) applyModules(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) applyModules(ui packersdk.Ui, comm packersdk.Communicator) error { ctx := context.TODO() // create params JSON file params, err := json.Marshal(p.config.Params) @@ -210,7 +209,7 @@ func (p *Provisioner) applyModules(ui packersdk.Ui, comm packer.Communicator) er // run Converge in the specified directory var runOut, runErr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, Stdin: nil, Stdout: &runOut, diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index b7f493a74..cd4088146 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -13,7 +13,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -120,7 +119,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if generatedData == nil { generatedData = make(map[string]interface{}) } @@ -133,7 +132,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } } -func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packersdk.Communicator) error { dst, err := interpolate.Render(p.config.Destination, &p.config.ctx) if err != nil { return fmt.Errorf("Error interpolating destination: %s", err) @@ -182,7 +181,7 @@ func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packer.Communicato return nil } -func (p *Provisioner) ProvisionUpload(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) ProvisionUpload(ui packersdk.Ui, comm packersdk.Communicator) error { dst, err := interpolate.Render(p.config.Destination, &p.config.ctx) if err != nil { return fmt.Errorf("Error interpolating destination: %s", err) diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index 8897f8a95..0c7ab0492 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -191,7 +191,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Inspec...") p.config.ctx.Data = generatedData @@ -342,7 +342,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) executeInspec(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { +func (p *Provisioner) executeInspec(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error { var envvars []string args := []string{p.config.SubCommand, p.config.Profile} diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index d6ea048de..6d33afa1e 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -17,7 +17,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -93,7 +92,7 @@ type Config struct { type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator generatedData map[string]interface{} } @@ -258,7 +257,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say(fmt.Sprintf("Provisioning with Powershell...")) p.communicator = comm p.generatedData = generatedData @@ -305,7 +304,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // single retryable function so that we don't end up with the case // that the upload succeeded, a restart is initiated, and then the // command is executed but the file doesn't exist any longer. - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := f.Seek(0, 0); err != nil { return err @@ -314,7 +313,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return fmt.Errorf("Error uploading script: %s", err) } - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) if err != nil { @@ -344,7 +343,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return err } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) if err != nil { @@ -531,7 +530,7 @@ func (p *Provisioner) createCommandTextPrivileged() (command string, err error) return command, err } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index 46aa413e9..d0477912c 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -13,7 +13,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -128,7 +127,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator guestOSTypeConfig guestOSTypeConfig guestCommands *guestexec.GuestCommands generatedData map[string]interface{} @@ -258,7 +257,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Puppet...") p.communicator = comm p.generatedData = generatedData @@ -345,7 +344,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } } - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } @@ -367,7 +366,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Uploading hiera configuration...") f, err := os.Open(p.config.HieraConfigPath) if err != nil { @@ -383,7 +382,7 @@ func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packer.Communicato return path, nil } -func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { // Create the remote manifests directory... ui.Message("Uploading manifests...") remoteManifestsPath := fmt.Sprintf("%s/manifests", p.config.StagingDir) @@ -429,10 +428,10 @@ func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packer.Communicator) return remoteManifestFile, nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} ctx := context.TODO() if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -444,7 +443,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -455,10 +454,10 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -470,7 +469,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -484,7 +483,7 @@ func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index fa9004a59..891e606db 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -12,7 +12,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -123,7 +122,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator guestOSTypeConfig guestOSTypeConfig guestCommands *guestexec.GuestCommands generatedData map[string]interface{} @@ -228,7 +227,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Puppet...") p.communicator = comm p.generatedData = generatedData @@ -298,7 +297,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } } - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } @@ -320,11 +319,11 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -333,7 +332,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -344,10 +343,10 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -359,7 +358,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -373,7 +372,7 @@ func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index 2346ac263..ed7488aeb 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/go-getter/v2" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -240,7 +239,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { var err error var src, dst string var formulas []string @@ -275,7 +274,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe ui.Say("Provisioning with Salt...") if !p.config.SkipBootstrap { - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ // Fallback on wget if curl failed for any reason (such as not being installed) Command: fmt.Sprintf(p.guestOSTypeConfig.bootstrapFetchCmd), } @@ -283,7 +282,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe if err = cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Unable to download Salt: %s", err) } - cmd = &packer.RemoteCmd{ + cmd = &packersdk.RemoteCmd{ Command: fmt.Sprintf("%s %s", p.sudo(p.guestOSTypeConfig.bootstrapRunCmd), p.config.BootstrapArgs), } ui.Message(fmt.Sprintf("Installing Salt with command %s", cmd.Command)) @@ -452,7 +451,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } ui.Message(fmt.Sprintf("Running: salt-call --local %s", p.config.CmdArgs)) - cmd := &packer.RemoteCmd{Command: p.sudo(fmt.Sprintf("%s --local %s", filepath.Join(p.config.SaltBinDir, "salt-call"), p.config.CmdArgs))} + cmd := &packersdk.RemoteCmd{Command: p.sudo(fmt.Sprintf("%s --local %s", filepath.Join(p.config.SaltBinDir, "salt-call"), p.config.CmdArgs))} if err = cmd.RunWithUi(ctx, comm, ui); (err != nil || cmd.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd.ExitStatus()) @@ -515,7 +514,7 @@ func hasValidFormulaURLs(s []string) bool { return true } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return fmt.Errorf("Error opening: %s", err) @@ -536,11 +535,11 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, return nil } -func (p *Provisioner) moveFile(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) moveFile(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Moving %s to %s", src, dst)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.sudo(p.guestCommands.MovePath(src, dst)), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil || cmd.ExitStatus() != 0 { @@ -553,9 +552,9 @@ func (p *Provisioner) moveFile(ui packersdk.Ui, comm packer.Communicator, dst st return nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.guestCommands.CreateDir(dir), } ctx := context.TODO() @@ -568,10 +567,10 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) statPath(ui packersdk.Ui, comm packer.Communicator, path string) error { +func (p *Provisioner) statPath(ui packersdk.Ui, comm packersdk.Communicator, path string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Verifying Path: %s", path)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.guestCommands.StatPath(path), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -583,10 +582,10 @@ func (p *Provisioner) statPath(ui packersdk.Ui, comm packer.Communicator, path s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Removing directory: %s", dir)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.guestCommands.RemoveDir(dir), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -598,7 +597,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packer.Communicator, dst, src string, ignore []string) error { +func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packersdk.Communicator, dst, src string, ignore []string) error { _, temp_dst := filepath.Split(dst) if err := comm.UploadDir(temp_dst, src, ignore); err != nil { return err diff --git a/provisioner/shell-local/provisioner.go b/provisioner/shell-local/provisioner.go index aecf871cb..1047a9bd6 100644 --- a/provisioner/shell-local/provisioner.go +++ b/provisioner/shell-local/provisioner.go @@ -4,7 +4,6 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" ) @@ -29,7 +28,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, _ packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, _ packersdk.Communicator, generatedData map[string]interface{}) error { _, retErr := sl.Run(ctx, ui, &p.config, generatedData) return retErr diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 6f0d0ce6d..16e705d22 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -18,7 +18,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -178,7 +177,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if generatedData == nil { generatedData = make(map[string]interface{}) } @@ -240,7 +239,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe p.config.envVarFile = tf.Name() // upload the var file - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := tf.Seek(0, 0); err != nil { return err @@ -257,7 +256,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } tf.Close() - cmd = &packer.RemoteCmd{ + cmd = &packersdk.RemoteCmd{ Command: fmt.Sprintf("chmod 0600 %s", remoteVFName), } if err := comm.Start(ctx, cmd); err != nil { @@ -302,7 +301,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // the case that the upload succeeded, a restart is initiated, // and then the command is executed but the file doesn't exist // any longer. - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := f.Seek(0, 0); err != nil { return err @@ -317,7 +316,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return fmt.Errorf("Error uploading script: %s", err) } - cmd = &packer.RemoteCmd{ + cmd = &packersdk.RemoteCmd{ Command: fmt.Sprintf("chmod 0755 %s", p.config.RemotePath), } if err := comm.Start(ctx, cmd); err != nil { @@ -327,7 +326,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } cmd.Wait() - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) @@ -337,7 +336,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // If the exit code indicates a remote disconnect, fail unless // we were expecting it. - if cmd.ExitStatus() == packer.CmdDisconnect { + if cmd.ExitStatus() == packersdk.CmdDisconnect { if !p.config.ExpectDisconnect { return fmt.Errorf("Script disconnected unexpectedly. " + "If you expected your script to disconnect, i.e. from a " + @@ -379,10 +378,10 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) cleanupRemoteFile(path string, comm packer.Communicator) error { +func (p *Provisioner) cleanupRemoteFile(path string, comm packersdk.Communicator) error { ctx := context.TODO() err := retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("rm -f %s", path), } if err := comm.Start(ctx, cmd); err != nil { @@ -392,7 +391,7 @@ func (p *Provisioner) cleanupRemoteFile(path string, comm packer.Communicator) e } cmd.Wait() // treat disconnects as retryable by returning an error - if cmd.ExitStatus() == packer.CmdDisconnect { + if cmd.ExitStatus() == packersdk.CmdDisconnect { return fmt.Errorf("Disconnect while removing temporary script.") } if cmd.ExitStatus() != 0 { diff --git a/provisioner/sleep/provisioner.go b/provisioner/sleep/provisioner.go index 4e01e808e..8c3de5dd8 100644 --- a/provisioner/sleep/provisioner.go +++ b/provisioner/sleep/provisioner.go @@ -26,7 +26,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return config.Decode(&p, &config.DecodeOpts{}, raws...) } -func (p *Provisioner) Provision(ctx context.Context, _ packersdk.Ui, _ packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, _ packersdk.Ui, _ packersdk.Communicator, _ map[string]interface{}) error { select { case <-ctx.Done(): return ctx.Err() diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index d3c6bdd92..e3afa1aa4 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -14,7 +14,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -59,7 +58,7 @@ type Config struct { type Provisioner struct { config Config - comm packer.Communicator + comm packersdk.Communicator ui packersdk.Ui cancel chan struct{} cancelLock sync.Mutex @@ -101,7 +100,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { p.cancelLock.Lock() p.cancel = make(chan struct{}) p.cancelLock.Unlock() @@ -110,10 +109,10 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe p.comm = comm p.ui = ui - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd command := p.config.RestartCommand err := retry.Config{StartTimeout: p.config.RestartTimeout}.Run(ctx, func(context.Context) error { - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) @@ -128,7 +127,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return waitForRestart(ctx, p, comm) } -var waitForRestart = func(ctx context.Context, p *Provisioner, comm packer.Communicator) error { +var waitForRestart = func(ctx context.Context, p *Provisioner, comm packersdk.Communicator) error { ui := p.ui ui.Say("Waiting for machine to restart...") waitDone := make(chan bool, 1) @@ -136,14 +135,14 @@ var waitForRestart = func(ctx context.Context, p *Provisioner, comm packer.Commu var err error p.comm = comm - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd trycommand := TryCheckReboot abortcommand := AbortReboot // Stolen from Vagrant reboot checker for { log.Printf("Check if machine is rebooting...") - cmd = &packer.RemoteCmd{Command: trycommand} + cmd = &packersdk.RemoteCmd{Command: trycommand} err = cmd.RunWithUi(ctx, comm, ui) if err != nil { // Couldn't execute, we assume machine is rebooting already @@ -161,7 +160,7 @@ var waitForRestart = func(ctx context.Context, p *Provisioner, comm packer.Commu } if cmd.ExitStatus() == 0 { // Cancel reboot we created to test if machine was already rebooting - cmd = &packer.RemoteCmd{Command: abortcommand} + cmd = &packersdk.RemoteCmd{Command: abortcommand} cmd.RunWithUi(ctx, comm, ui) break } @@ -212,7 +211,7 @@ var waitForCommunicator = func(ctx context.Context, p *Provisioner) error { // vm has met their necessary criteria for having restarted. If the // user doesn't set a special restart command, we just run the // default as cmdModuleLoad below. - cmdRestartCheck := &packer.RemoteCmd{Command: p.config.RestartCheckCommand} + cmdRestartCheck := &packersdk.RemoteCmd{Command: p.config.RestartCheckCommand} log.Printf("Checking that communicator is connected with: '%s'", cmdRestartCheck.Command) for { @@ -241,7 +240,7 @@ var waitForCommunicator = func(ctx context.Context, p *Provisioner) error { // provisioning before powershell is actually ready. // In this next check, we parse stdout to make sure that the command is // actually running as expected. - cmdModuleLoad := &packer.RemoteCmd{Command: DefaultRestartCheckCommand} + cmdModuleLoad := &packersdk.RemoteCmd{Command: DefaultRestartCheckCommand} var buf, buf2 bytes.Buffer cmdModuleLoad.Stdout = &buf cmdModuleLoad.Stdout = io.MultiWriter(cmdModuleLoad.Stdout, &buf2) @@ -259,7 +258,7 @@ var waitForCommunicator = func(ctx context.Context, p *Provisioner) error { shouldContinue := false for _, RegKey := range p.config.RegistryKeys { KeyTestCommand := winrm.Powershell(fmt.Sprintf(`Test-Path "%s"`, RegKey)) - cmdKeyCheck := &packer.RemoteCmd{Command: KeyTestCommand} + cmdKeyCheck := &packersdk.RemoteCmd{Command: KeyTestCommand} log.Printf("Checking registry for pending reboots") var buf, buf2 bytes.Buffer cmdKeyCheck.Stdout = &buf diff --git a/provisioner/windows-restart/provisioner_test.go b/provisioner/windows-restart/provisioner_test.go index 391068457..ac44db001 100644 --- a/provisioner/windows-restart/provisioner_test.go +++ b/provisioner/windows-restart/provisioner_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -101,7 +102,7 @@ func TestProvisionerProvision_Success(t *testing.T) { return nil } waitForRestartOld := waitForRestart - waitForRestart = func(context.Context, *Provisioner, packer.Communicator) error { + waitForRestart = func(context.Context, *Provisioner, packersdk.Communicator) error { return nil } err := p.Provision(context.Background(), ui, comm, make(map[string]interface{})) @@ -137,7 +138,7 @@ func TestProvisionerProvision_CustomCommand(t *testing.T) { return nil } waitForRestartOld := waitForRestart - waitForRestart = func(context.Context, *Provisioner, packer.Communicator) error { + waitForRestart = func(context.Context, *Provisioner, packersdk.Communicator) error { return nil } err := p.Provision(context.Background(), ui, comm, make(map[string]interface{})) diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index 0a46d7833..8d1e1c4b9 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -16,7 +16,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -160,7 +159,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with windows-shell...") scripts := make([]string, len(p.config.Scripts)) copy(scripts, p.config.Scripts) @@ -204,7 +203,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // the case that the upload succeeded, a restart is initiated, // and then the command is executed but the file doesn't exist // any longer. - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := f.Seek(0, 0); err != nil { return err @@ -214,7 +213,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return fmt.Errorf("Error uploading script: %s", err) } - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) if err != nil { From f81ed344a2e75f14e7b1cfe4bfae0a28189ebe19 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Nov 2020 15:16:52 -0800 Subject: [PATCH 06/10] regenerate code --- packer/builder_mock.hcl2spec.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packer/builder_mock.hcl2spec.go b/packer/builder_mock.hcl2spec.go index 0dfe58a08..4807918dd 100644 --- a/packer/builder_mock.hcl2spec.go +++ b/packer/builder_mock.hcl2spec.go @@ -94,12 +94,12 @@ func (*FlatMockPostProcessor) HCL2Spec() map[string]hcldec.Spec { // FlatMockProvisioner is an auto-generated flat version of MockProvisioner. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatMockProvisioner struct { - PrepCalled *bool `cty:"prep_called" hcl:"prep_called"` - PrepConfigs []interface{} `cty:"prep_configs" hcl:"prep_configs"` - ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` - ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` - ProvCommunicator *packer.Communicator `cty:"prov_communicator" hcl:"prov_communicator"` - ProvUi packer.Ui `cty:"prov_ui" hcl:"prov_ui"` + PrepCalled *bool `cty:"prep_called" hcl:"prep_called"` + PrepConfigs []interface{} `cty:"prep_configs" hcl:"prep_configs"` + ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` + ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` + ProvCommunicator packer.Communicator `cty:"prov_communicator" hcl:"prov_communicator"` + ProvUi packer.Ui `cty:"prov_ui" hcl:"prov_ui"` } // FlatMapstructure returns a new FlatMockProvisioner. @@ -118,8 +118,8 @@ func (*FlatMockProvisioner) HCL2Spec() map[string]hcldec.Spec { "prep_configs": &hcldec.AttrSpec{Name: "prep_configs", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ "prov_called": &hcldec.AttrSpec{Name: "prov_called", Type: cty.Bool, Required: false}, "prov_retried": &hcldec.AttrSpec{Name: "prov_retried", Type: cty.Bool, Required: false}, - "prov_communicator": &hcldec.AttrSpec{Name: "prov_communicator", Type: cty.String, Required: false}, - "prov_ui": &hcldec.AttrSpec{Name: "prov_ui", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ + "prov_communicator": &hcldec.AttrSpec{Name: "prov_communicator", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ + "prov_ui": &hcldec.AttrSpec{Name: "prov_ui", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ } return s } From d5971ca25e0a28fa0207285c37b6d81384712781 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 20 Nov 2020 10:21:29 -0800 Subject: [PATCH 07/10] fix tests by moving mock hooks and communicators, and BasicUi definition, into SDK --- .../common/step_ami_region_copy_test.go | 4 +- .../common/step_run_spot_instance_test.go | 3 +- .../arm/step_certificate_in_keyvault_test.go | 6 +- builder/azure/chroot/packerui_test.go | 3 +- builder/azure/chroot/step_attach_disk_test.go | 4 +- builder/docker/communicator_test.go | 12 +- builder/docker/step_test.go | 6 +- builder/googlecompute/step_test.go | 6 +- builder/hyperv/common/step_test.go | 4 +- builder/hyperv/iso/builder_test.go | 2 +- builder/hyperv/vmcx/builder_test.go | 2 +- builder/openstack/step_key_pair_test.go | 4 +- builder/oracle/oci/step_instance_info_test.go | 6 +- builder/oracle/oci/step_test.go | 6 +- .../parallels/common/step_shutdown_test.go | 8 +- builder/parallels/common/step_test.go | 4 +- .../step_upload_parallels_tools_test.go | 8 +- .../common/step_upload_version_test.go | 6 +- builder/parallels/pvm/step_test.go | 4 +- builder/qemu/step_http_ip_discover_test.go | 4 +- builder/qemu/step_test.go | 4 +- builder/scaleway/step_pre_validate_test.go | 4 +- builder/triton/step_test.go | 6 +- .../virtualbox/common/step_shutdown_test.go | 12 +- builder/virtualbox/common/step_test.go | 4 +- .../common/step_upload_version_test.go | 6 +- builder/virtualbox/ovf/step_test.go | 4 +- builder/vmware/common/step_shutdown_test.go | 10 +- builder/vmware/common/step_test.go | 4 +- builder/vmware/iso/step_create_vmx_test.go | 2 +- builder/vmware/vmx/step_test.go | 4 +- builder/vsphere/common/cleanup_vm_test.go | 4 +- builder/vsphere/common/common_test.go | 4 +- builder/vsphere/iso/common_test.go | 4 +- builder/vsphere/iso/step_create_test.go | 4 +- builder/yandex/step_create_instance_test.go | 6 +- command/build_parallel_test.go | 2 +- command/build_test.go | 3 +- command/build_timeout_test.go | 3 +- command/command_test.go | 7 +- command/exec_test.go | 3 +- command/fix_test.go | 4 +- helper/builder/testing/testing.go | 2 +- helper/communicator/step_connect_test.go | 6 +- helper/tests/core.go | 3 +- main.go | 2 +- .../chroot/step_copy_files_test.go | 3 +- packer-plugin-sdk/guestexec/elevated_test.go | 3 +- .../commonsteps/step_create_cdrom_test.go | 4 +- .../commonsteps/step_create_floppy_test.go | 4 +- .../commonsteps/step_download_test.go | 3 +- .../commonsteps/step_output_dir_test.go | 3 +- packer-plugin-sdk/packer/ui.go | 138 +++++++++++++++++- packer-plugin-sdk/packer/ui_mock.go | 114 +++++++++++++++ packer/build.go | 2 +- packer/build_test.go | 9 +- packer/core_test.go | 16 +- packer/plugin/plugin_test.go | 3 +- packer/provisioner_test.go | 26 ++-- packer/rpc/artifact_test.go | 3 +- packer/rpc/build_test.go | 6 +- packer/rpc/builder_test.go | 11 +- packer/rpc/communicator_test.go | 3 +- packer/rpc/hook_test.go | 3 +- packer/rpc/post_processor_test.go | 6 +- packer/rpc/provisioner_test.go | 3 +- packer/test-fixtures/sensitive-variables.json | 2 +- packer/testing.go | 2 +- packer/tty.go | 6 - packer/ui.go | 119 --------------- packer/ui_test.go | 22 +-- .../docker-push/post-processor_test.go | 10 +- .../docker-tag/post-processor_test.go | 10 +- .../vagrant-cloud/post-processor_test.go | 15 +- post-processor/vagrant/aws_test.go | 4 +- post-processor/vagrant/azure_test.go | 6 +- post-processor/vagrant/digitalocean_test.go | 4 +- post-processor/vagrant/google_test.go | 4 +- post-processor/vagrant/post-processor_test.go | 9 +- provisioner/ansible-local/provisioner_test.go | 4 +- provisioner/ansible/provisioner_test.go | 9 +- provisioner/chef-client/provisioner_test.go | 9 +- provisioner/file/provisioner_test.go | 21 +-- .../powershell/provisioner_acc_test.go | 3 +- provisioner/powershell/provisioner_test.go | 27 ++-- .../puppet-masterless/provisioner_test.go | 3 +- .../shell-local/provisioner_acc_test.go | 3 +- provisioner/shell/provisioner_acc_test.go | 3 +- .../windows-restart/provisioner_test.go | 20 +-- provisioner/windows-shell/provisioner_test.go | 11 +- 90 files changed, 527 insertions(+), 381 deletions(-) create mode 100644 packer-plugin-sdk/packer/ui_mock.go delete mode 100644 packer/tty.go diff --git a/builder/amazon/common/step_ami_region_copy_test.go b/builder/amazon/common/step_ami_region_copy_test.go index a9f511a61..da386cec6 100644 --- a/builder/amazon/common/step_ami_region_copy_test.go +++ b/builder/amazon/common/step_ami_region_copy_test.go @@ -11,8 +11,8 @@ import ( "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2/ec2iface" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" ) @@ -87,7 +87,7 @@ func getMockConn(config *AccessConfig, target string) (ec2iface.EC2API, error) { // Create statebag for running test func tState() multistep.StateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/amazon/common/step_run_spot_instance_test.go b/builder/amazon/common/step_run_spot_instance_test.go index 5df8070f1..e0c1f2819 100644 --- a/builder/amazon/common/step_run_spot_instance_test.go +++ b/builder/amazon/common/step_run_spot_instance_test.go @@ -12,12 +12,13 @@ import ( "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Create statebag for running test func tStateSpot() multistep.StateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/azure/arm/step_certificate_in_keyvault_test.go b/builder/azure/arm/step_certificate_in_keyvault_test.go index ce0dcfa79..4549658a7 100644 --- a/builder/azure/arm/step_certificate_in_keyvault_test.go +++ b/builder/azure/arm/step_certificate_in_keyvault_test.go @@ -7,13 +7,13 @@ import ( azcommon "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestNewStepCertificateInKeyVault(t *testing.T) { cli := azcommon.MockAZVaultClient{} - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } @@ -46,7 +46,7 @@ func TestNewStepCertificateInKeyVault_error(t *testing.T) { cli := azcommon.MockAZVaultClient{} cli.IsError = true - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } diff --git a/builder/azure/chroot/packerui_test.go b/builder/azure/chroot/packerui_test.go index fb2435a18..c14fdf6ec 100644 --- a/builder/azure/chroot/packerui_test.go +++ b/builder/azure/chroot/packerui_test.go @@ -4,14 +4,13 @@ import ( "io/ioutil" "strings" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // testUI returns a test ui plus a function to retrieve the errors written to the ui func testUI() (packersdk.Ui, func() string) { errorBuffer := &strings.Builder{} - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: strings.NewReader(""), Writer: ioutil.Discard, ErrorWriter: errorBuffer, diff --git a/builder/azure/chroot/step_attach_disk_test.go b/builder/azure/chroot/step_attach_disk_test.go index 69261b298..8425f5f2e 100644 --- a/builder/azure/chroot/step_attach_disk_test.go +++ b/builder/azure/chroot/step_attach_disk_test.go @@ -12,8 +12,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest" "github.com/hashicorp/packer/builder/azure/common/client" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepAttachDisk_Run(t *testing.T) { @@ -69,7 +69,7 @@ func TestStepAttachDisk_Run(t *testing.T) { }) errorBuffer := &strings.Builder{} - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: strings.NewReader(""), Writer: ioutil.Discard, ErrorWriter: errorBuffer, diff --git a/builder/docker/communicator_test.go b/builder/docker/communicator_test.go index fefbc7f54..b97f000b5 100644 --- a/builder/docker/communicator_test.go +++ b/builder/docker/communicator_test.go @@ -64,13 +64,13 @@ func TestUploadDownload(t *testing.T) { hooks := map[string][]packersdk.Hook{} hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packersdk.HookedProvisioner{ + Provisioners: []*packer.HookedProvisioner{ {Provisioner: upload, Config: nil, TypeName: ""}, {Provisioner: download, Config: nil, TypeName: ""}, }, }, } - hook := &packer.DispatchHook{Mapping: hooks} + hook := &packersdk.DispatchHook{Mapping: hooks} // Run things artifact, err := builder.Run(context.Background(), ui, hook) @@ -152,14 +152,14 @@ func TestLargeDownload(t *testing.T) { hooks := map[string][]packersdk.Hook{} hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packersdk.HookedProvisioner{ + Provisioners: []*packer.HookedProvisioner{ {Provisioner: shell, Config: nil, TypeName: ""}, {Provisioner: downloadCupcake, Config: nil, TypeName: ""}, {Provisioner: downloadBigcake, Config: nil, TypeName: ""}, }, }, } - hook := &packer.DispatchHook{Mapping: hooks} + hook := &packersdk.DispatchHook{Mapping: hooks} // Run things artifact, err := builder.Run(context.Background(), ui, hook) @@ -260,7 +260,7 @@ func TestFixUploadOwner(t *testing.T) { hooks := map[string][]packersdk.Hook{} hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packersdk.HookedProvisioner{ + Provisioners: []*packer.HookedProvisioner{ {Provisioner: fileProvisioner, Config: nil, TypeName: ""}, {Provisioner: dirProvisioner, Config: nil, TypeName: ""}, {Provisioner: shellProvisioner, Config: nil, TypeName: ""}, @@ -268,7 +268,7 @@ func TestFixUploadOwner(t *testing.T) { }, }, } - hook := &packer.DispatchHook{Mapping: hooks} + hook := &packersdk.DispatchHook{Mapping: hooks} artifact, err := builder.Run(context.Background(), ui, hook) if err != nil { diff --git a/builder/docker/step_test.go b/builder/docker/step_test.go index b048c3f6e..565a3d805 100644 --- a/builder/docker/step_test.go +++ b/builder/docker/step_test.go @@ -4,16 +4,16 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("config", testConfigStruct(t)) state.Put("driver", &MockDriver{}) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/googlecompute/step_test.go b/builder/googlecompute/step_test.go index db9ff3dab..c43c2730a 100644 --- a/builder/googlecompute/step_test.go +++ b/builder/googlecompute/step_test.go @@ -4,16 +4,16 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("config", testConfigStruct(t)) state.Put("driver", &DriverMock{}) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/hyperv/common/step_test.go b/builder/hyperv/common/step_test.go index 30691fa20..966b1e2f8 100644 --- a/builder/hyperv/common/step_test.go +++ b/builder/hyperv/common/step_test.go @@ -6,15 +6,15 @@ import ( "path/filepath" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/hyperv/iso/builder_test.go b/builder/hyperv/iso/builder_test.go index 43790ebb2..2cbddd8eb 100644 --- a/builder/hyperv/iso/builder_test.go +++ b/builder/hyperv/iso/builder_test.go @@ -603,7 +603,7 @@ func TestUserVariablesInBootCommand(t *testing.T) { } ui := packer.TestUi(t) - hook := &packer.MockHook{} + hook := &packersdk.MockHook{} driver := &hypervcommon.DriverMock{} // Set up the state. diff --git a/builder/hyperv/vmcx/builder_test.go b/builder/hyperv/vmcx/builder_test.go index e67f9f5a1..58e7bc4dc 100644 --- a/builder/hyperv/vmcx/builder_test.go +++ b/builder/hyperv/vmcx/builder_test.go @@ -495,7 +495,7 @@ func TestUserVariablesInBootCommand(t *testing.T) { } ui := packer.TestUi(t) - hook := &packer.MockHook{} + hook := &packersdk.MockHook{} driver := &hypervcommon.DriverMock{} // Set up the state. diff --git a/builder/openstack/step_key_pair_test.go b/builder/openstack/step_key_pair_test.go index c204eec03..c002c3d16 100644 --- a/builder/openstack/step_key_pair_test.go +++ b/builder/openstack/step_key_pair_test.go @@ -5,7 +5,7 @@ import ( "os/exec" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -76,7 +76,7 @@ func TestBerToDer(t *testing.T) { } msg := new(bytes.Buffer) - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: msg, } diff --git a/builder/oracle/oci/step_instance_info_test.go b/builder/oracle/oci/step_instance_info_test.go index 6b13cc1a7..d5b9f0b3d 100644 --- a/builder/oracle/oci/step_instance_info_test.go +++ b/builder/oracle/oci/step_instance_info_test.go @@ -6,8 +6,8 @@ import ( "errors" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestInstanceInfo(t *testing.T) { @@ -37,8 +37,8 @@ func TestInstanceInfoPrivateIP(t *testing.T) { state := new(multistep.BasicStateBag) state.Put("config", baseTestConfig) state.Put("driver", &driverMock{cfg: baseTestConfig}) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/oracle/oci/step_test.go b/builder/oracle/oci/step_test.go index 1c95870fd..a7d0a1ea1 100644 --- a/builder/oracle/oci/step_test.go +++ b/builder/oracle/oci/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // TODO(apryde): It would be good not to have to write a key file to disk to @@ -55,8 +55,8 @@ func testState() multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("config", baseTestConfig) state.Put("driver", &driverMock{cfg: baseTestConfig}) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/parallels/common/step_shutdown_test.go b/builder/parallels/common/step_shutdown_test.go index 861be6cd7..3012e7ae0 100644 --- a/builder/parallels/common/step_shutdown_test.go +++ b/builder/parallels/common/step_shutdown_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepShutdown_impl(t *testing.T) { @@ -17,7 +17,7 @@ func TestStepShutdown_noShutdownCommand(t *testing.T) { state := testState(t) step := new(StepShutdown) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") @@ -46,7 +46,7 @@ func TestStepShutdown_shutdownCommand(t *testing.T) { step.Command = "poweroff" step.Timeout = 1 * time.Second - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") @@ -83,7 +83,7 @@ func TestStepShutdown_shutdownTimeout(t *testing.T) { step.Command = "poweroff" step.Timeout = 1 * time.Second - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") diff --git a/builder/parallels/common/step_test.go b/builder/parallels/common/step_test.go index 4dc7bd18b..922a3b704 100644 --- a/builder/parallels/common/step_test.go +++ b/builder/parallels/common/step_test.go @@ -4,15 +4,15 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("debug", false) state.Put("driver", new(DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/parallels/common/step_upload_parallels_tools_test.go b/builder/parallels/common/step_upload_parallels_tools_test.go index 5e8b3f8d7..de35b2120 100644 --- a/builder/parallels/common/step_upload_parallels_tools_test.go +++ b/builder/parallels/common/step_upload_parallels_tools_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepUploadParallelsTools_impl(t *testing.T) { @@ -20,7 +20,7 @@ func TestStepUploadParallelsTools(t *testing.T) { step.ParallelsToolsGuestPath = "/tmp/prl-lin.iso" step.ParallelsToolsFlavor = "lin" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) // Test the run @@ -45,7 +45,7 @@ func TestStepUploadParallelsTools_interpolate(t *testing.T) { step.ParallelsToolsGuestPath = "/tmp/prl-{{ .Flavor }}.iso" step.ParallelsToolsFlavor = "win" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) // Test the run @@ -70,7 +70,7 @@ func TestStepUploadParallelsTools_attach(t *testing.T) { step.ParallelsToolsGuestPath = "/tmp/prl-lin.iso" step.ParallelsToolsFlavor = "lin" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) // Test the run diff --git a/builder/parallels/common/step_upload_version_test.go b/builder/parallels/common/step_upload_version_test.go index ddce60e3c..45f6b78a5 100644 --- a/builder/parallels/common/step_upload_version_test.go +++ b/builder/parallels/common/step_upload_version_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepUploadVersion_impl(t *testing.T) { @@ -17,7 +17,7 @@ func TestStepUploadVersion(t *testing.T) { step := new(StepUploadVersion) step.Path = "foopath" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) driver := state.Get("driver").(*DriverMock) @@ -45,7 +45,7 @@ func TestStepUploadVersion_noPath(t *testing.T) { step := new(StepUploadVersion) step.Path = "" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) // Test the run diff --git a/builder/parallels/pvm/step_test.go b/builder/parallels/pvm/step_test.go index 6c9983a82..40be30b05 100644 --- a/builder/parallels/pvm/step_test.go +++ b/builder/parallels/pvm/step_test.go @@ -5,14 +5,14 @@ import ( "testing" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(parallelscommon.DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/qemu/step_http_ip_discover_test.go b/builder/qemu/step_http_ip_discover_test.go index 263bcb752..2e60e0261 100644 --- a/builder/qemu/step_http_ip_discover_test.go +++ b/builder/qemu/step_http_ip_discover_test.go @@ -5,13 +5,13 @@ import ( "context" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepHTTPIPDiscover_Run(t *testing.T) { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/qemu/step_test.go b/builder/qemu/step_test.go index ff015f747..7b4b40a2c 100644 --- a/builder/qemu/step_test.go +++ b/builder/qemu/step_test.go @@ -4,14 +4,14 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/scaleway/step_pre_validate_test.go b/builder/scaleway/step_pre_validate_test.go index fb40998ab..d447281db 100644 --- a/builder/scaleway/step_pre_validate_test.go +++ b/builder/scaleway/step_pre_validate_test.go @@ -10,8 +10,8 @@ import ( "strconv" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -70,7 +70,7 @@ func setup(t *testing.T, fakeImgNames []string, fakeSnapNames []string) (*multis } state := multistep.BasicStateBag{} - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/triton/step_test.go b/builder/triton/step_test.go index 448a33a8f..ef5b5bf24 100644 --- a/builder/triton/step_test.go +++ b/builder/triton/step_test.go @@ -4,16 +4,16 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("config", testConfig(t)) state.Put("driver", &DriverMock{}) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/virtualbox/common/step_shutdown_test.go b/builder/virtualbox/common/step_shutdown_test.go index 001195bbb..b0225bf5d 100644 --- a/builder/virtualbox/common/step_shutdown_test.go +++ b/builder/virtualbox/common/step_shutdown_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepShutdown_impl(t *testing.T) { @@ -19,7 +19,7 @@ func TestStepShutdown_noShutdownCommand(t *testing.T) { step.DisableShutdown = false step.ACPIShutdown = false - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") @@ -50,7 +50,7 @@ func TestStepShutdown_shutdownCommand(t *testing.T) { step.DisableShutdown = false step.ACPIShutdown = false - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") @@ -89,7 +89,7 @@ func TestStepShutdown_shutdownTimeout(t *testing.T) { step.DisableShutdown = false step.ACPIShutdown = false - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") @@ -119,7 +119,7 @@ func TestStepShutdown_DisableShutdown(t *testing.T) { step.ACPIShutdown = false step.Timeout = 2 * time.Second - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") @@ -148,7 +148,7 @@ func TestStepShutdown_ACPIShutdown(t *testing.T) { step.ACPIShutdown = true step.Timeout = 2 * time.Second - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) state.Put("vmName", "foo") diff --git a/builder/virtualbox/common/step_test.go b/builder/virtualbox/common/step_test.go index 7cb9dd45e..17116b361 100644 --- a/builder/virtualbox/common/step_test.go +++ b/builder/virtualbox/common/step_test.go @@ -4,14 +4,14 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/virtualbox/common/step_upload_version_test.go b/builder/virtualbox/common/step_upload_version_test.go index ddce60e3c..45f6b78a5 100644 --- a/builder/virtualbox/common/step_upload_version_test.go +++ b/builder/virtualbox/common/step_upload_version_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepUploadVersion_impl(t *testing.T) { @@ -17,7 +17,7 @@ func TestStepUploadVersion(t *testing.T) { step := new(StepUploadVersion) step.Path = "foopath" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) driver := state.Get("driver").(*DriverMock) @@ -45,7 +45,7 @@ func TestStepUploadVersion_noPath(t *testing.T) { step := new(StepUploadVersion) step.Path = "" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) state.Put("communicator", comm) // Test the run diff --git a/builder/virtualbox/ovf/step_test.go b/builder/virtualbox/ovf/step_test.go index 59b251a99..f54a47b4a 100644 --- a/builder/virtualbox/ovf/step_test.go +++ b/builder/virtualbox/ovf/step_test.go @@ -5,14 +5,14 @@ import ( "testing" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(vboxcommon.DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/vmware/common/step_shutdown_test.go b/builder/vmware/common/step_shutdown_test.go index 707de7012..2d451914e 100644 --- a/builder/vmware/common/step_shutdown_test.go +++ b/builder/vmware/common/step_shutdown_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testLocalOutputDir(t *testing.T) *LocalOutputDir { @@ -31,7 +31,7 @@ func testStepShutdownState(t *testing.T) multistep.StateBag { } state := testState(t) - state.Put("communicator", new(packer.MockCommunicator)) + state.Put("communicator", new(packersdk.MockCommunicator)) state.Put("dir", dir) state.Put("vmx_path", "foo") return state @@ -48,7 +48,7 @@ func TestStepShutdown_command(t *testing.T) { step.Timeout = 10 * time.Second step.Testing = true - comm := state.Get("communicator").(*packer.MockCommunicator) + comm := state.Get("communicator").(*packersdk.MockCommunicator) driver := state.Get("driver").(*DriverMock) driver.IsRunningResult = true @@ -109,7 +109,7 @@ func TestStepShutdown_noCommand(t *testing.T) { state := testStepShutdownState(t) step := new(StepShutdown) - comm := state.Get("communicator").(*packer.MockCommunicator) + comm := state.Get("communicator").(*packersdk.MockCommunicator) driver := state.Get("driver").(*DriverMock) // Test the run @@ -149,7 +149,7 @@ func TestStepShutdown_locks(t *testing.T) { step.Testing = true dir := state.Get("dir").(*LocalOutputDir) - comm := state.Get("communicator").(*packer.MockCommunicator) + comm := state.Get("communicator").(*packersdk.MockCommunicator) driver := state.Get("driver").(*DriverMock) // Create some lock files diff --git a/builder/vmware/common/step_test.go b/builder/vmware/common/step_test.go index 56ba540c3..cd46de03d 100644 --- a/builder/vmware/common/step_test.go +++ b/builder/vmware/common/step_test.go @@ -4,14 +4,14 @@ import ( "bytes" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/vmware/iso/step_create_vmx_test.go b/builder/vmware/iso/step_create_vmx_test.go index 80a216ad0..dad326b2a 100644 --- a/builder/vmware/iso/step_create_vmx_test.go +++ b/builder/vmware/iso/step_create_vmx_test.go @@ -142,7 +142,7 @@ func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisioner "vmware-iso": func() (packer.Builder, error) { return &Builder{}, nil }, }, Hook: func(n string) (packersdk.Hook, error) { - return &packer.DispatchHook{}, nil + return &packersdk.DispatchHook{}, nil }, ProvisionerStore: packer.MapOfProvisioner{ "shell": func() (packer.Provisioner, error) { return &shell.Provisioner{}, nil }, diff --git a/builder/vmware/vmx/step_test.go b/builder/vmware/vmx/step_test.go index a30b06418..0d51de2a0 100644 --- a/builder/vmware/vmx/step_test.go +++ b/builder/vmware/vmx/step_test.go @@ -5,14 +5,14 @@ import ( "testing" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("driver", new(vmwcommon.DriverMock)) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/vsphere/common/cleanup_vm_test.go b/builder/vsphere/common/cleanup_vm_test.go index ad6bb3b02..00775bbb2 100644 --- a/builder/vsphere/common/cleanup_vm_test.go +++ b/builder/vsphere/common/cleanup_vm_test.go @@ -5,14 +5,14 @@ import ( "testing" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func cleanupTestState(mockVM driver.VirtualMachine) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("vm", mockVM) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/vsphere/common/common_test.go b/builder/vsphere/common/common_test.go index e96110ef7..000310299 100644 --- a/builder/vsphere/common/common_test.go +++ b/builder/vsphere/common/common_test.go @@ -4,13 +4,13 @@ import ( "bytes" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func basicStateBag(errorBuffer *strings.Builder) *multistep.BasicStateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), ErrorWriter: errorBuffer, diff --git a/builder/vsphere/iso/common_test.go b/builder/vsphere/iso/common_test.go index 531e9dd73..da65dfd1a 100644 --- a/builder/vsphere/iso/common_test.go +++ b/builder/vsphere/iso/common_test.go @@ -3,13 +3,13 @@ package iso import ( "bytes" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func basicStateBag() *multistep.BasicStateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/builder/vsphere/iso/step_create_test.go b/builder/vsphere/iso/step_create_test.go index cd0b4fa57..db07af670 100644 --- a/builder/vsphere/iso/step_create_test.go +++ b/builder/vsphere/iso/step_create_test.go @@ -11,8 +11,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCreateConfig_Prepare(t *testing.T) { @@ -307,7 +307,7 @@ func TestStepCreateVM_Cleanup(t *testing.T) { // Destroy fail errorBuffer := &strings.Builder{} - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: strings.NewReader(""), Writer: ioutil.Discard, ErrorWriter: errorBuffer, diff --git a/builder/yandex/step_create_instance_test.go b/builder/yandex/step_create_instance_test.go index b0f9cf6d7..2aaf6a08a 100644 --- a/builder/yandex/step_create_instance_test.go +++ b/builder/yandex/step_create_instance_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -116,8 +116,8 @@ func TestCreateInstanceMetadata_fromNotExistFile(t *testing.T) { func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) state.Put("config", testConfigStruct(t)) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/command/build_parallel_test.go b/command/build_parallel_test.go index 16980b234..815350375 100644 --- a/command/build_parallel_test.go +++ b/command/build_parallel_test.go @@ -78,7 +78,7 @@ func testMetaParallel(t *testing.T, builder *ParallelTestBuilder, locked *Locked }, }, }, - Ui: &packer.BasicUi{ + Ui: &packersdk.BasicUi{ Writer: &out, ErrorWriter: &err, }, diff --git a/command/build_test.go b/command/build_test.go index 60660ff09..c67505ad7 100644 --- a/command/build_test.go +++ b/command/build_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/builder/null" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/post-processor/manifest" shell_local_pp "github.com/hashicorp/packer/post-processor/shell-local" filep "github.com/hashicorp/packer/provisioner/file" @@ -859,7 +860,7 @@ func testMetaFile(t *testing.T) Meta { var out, err bytes.Buffer return Meta{ CoreConfig: testCoreConfigBuilder(t), - Ui: &packer.BasicUi{ + Ui: &packersdk.BasicUi{ Writer: &out, ErrorWriter: &err, }, diff --git a/command/build_timeout_test.go b/command/build_timeout_test.go index 5657a37b0..4fde04aea 100644 --- a/command/build_timeout_test.go +++ b/command/build_timeout_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" shell_local "github.com/hashicorp/packer/provisioner/shell-local" "github.com/hashicorp/packer/provisioner/sleep" ) @@ -33,7 +34,7 @@ func testMetaSleepFile(t *testing.T) Meta { var out, err bytes.Buffer return Meta{ CoreConfig: testCoreConfigSleepBuilder(t), - Ui: &packer.BasicUi{ + Ui: &packersdk.BasicUi{ Writer: &out, ErrorWriter: &err, }, diff --git a/command/command_test.go b/command/command_test.go index 6d571b1eb..833fe4074 100644 --- a/command/command_test.go +++ b/command/command_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const fixturesDir = "./test-fixtures" func fatalCommand(t *testing.T, m Meta) { - ui := m.Ui.(*packer.BasicUi) + ui := m.Ui.(*packersdk.BasicUi) out := ui.Writer.(*bytes.Buffer) err := ui.ErrorWriter.(*bytes.Buffer) t.Fatalf( @@ -22,7 +23,7 @@ func fatalCommand(t *testing.T, m Meta) { } func outputCommand(t *testing.T, m Meta) (string, string) { - ui := m.Ui.(*packer.BasicUi) + ui := m.Ui.(*packersdk.BasicUi) out := ui.Writer.(*bytes.Buffer) err := ui.ErrorWriter.(*bytes.Buffer) return out.String(), err.String() @@ -48,7 +49,7 @@ func testMeta(t *testing.T) Meta { return Meta{ CoreConfig: packer.TestCoreConfig(t), - Ui: &packer.BasicUi{ + Ui: &packersdk.BasicUi{ Writer: &out, ErrorWriter: &err, }, diff --git a/command/exec_test.go b/command/exec_test.go index 7ecb264b3..8a13b5e76 100644 --- a/command/exec_test.go +++ b/command/exec_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/builder/null" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/post-processor/manifest" shell_local_pp "github.com/hashicorp/packer/post-processor/shell-local" filep "github.com/hashicorp/packer/provisioner/file" @@ -99,7 +100,7 @@ func TestHelperProcess(*testing.T) { } func commandMeta() Meta { - basicUi := &packer.BasicUi{ + basicUi := &packersdk.BasicUi{ Reader: os.Stdin, Writer: os.Stdout, ErrorWriter: os.Stdout, diff --git a/command/fix_test.go b/command/fix_test.go index 966367c71..fcc8ddd88 100644 --- a/command/fix_test.go +++ b/command/fix_test.go @@ -5,13 +5,13 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" ) func TestFix(t *testing.T) { s := &strings.Builder{} - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Writer: s, } c := &FixCommand{ diff --git a/helper/builder/testing/testing.go b/helper/builder/testing/testing.go index a1a4f256b..37089c158 100644 --- a/helper/builder/testing/testing.go +++ b/helper/builder/testing/testing.go @@ -157,7 +157,7 @@ func Test(t TestT, c TestCase) { // Run it! We use a temporary directory for caching and discard // any UI output. We discard since it shows up in logs anyways. log.Printf("[DEBUG] Running 'test' build") - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: os.Stdin, Writer: ioutil.Discard, ErrorWriter: ioutil.Discard, diff --git a/helper/communicator/step_connect_test.go b/helper/communicator/step_connect_test.go index e31741b86..c8a522a9f 100644 --- a/helper/communicator/step_connect_test.go +++ b/helper/communicator/step_connect_test.go @@ -5,8 +5,8 @@ import ( "context" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepConnect_impl(t *testing.T) { @@ -31,8 +31,8 @@ func TestStepConnect_none(t *testing.T) { func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) - state.Put("hook", &packer.MockHook{}) - state.Put("ui", &packer.BasicUi{ + state.Put("hook", &packersdk.MockHook{}) + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/helper/tests/core.go b/helper/tests/core.go index 29cdd776f..88e6e6b49 100644 --- a/helper/tests/core.go +++ b/helper/tests/core.go @@ -8,6 +8,7 @@ import ( amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs" "github.com/hashicorp/packer/command" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" fileprovisioner "github.com/hashicorp/packer/provisioner/file" "github.com/hashicorp/packer/provisioner/shell" ) @@ -43,7 +44,7 @@ func TestMetaFile(t *testing.T) command.Meta { var out, err bytes.Buffer return command.Meta{ CoreConfig: testCoreConfigBuilder(t), - Ui: &packer.BasicUi{ + Ui: &packersdk.BasicUi{ Writer: &out, ErrorWriter: &err, }, diff --git a/main.go b/main.go index 91e84db13..f2ced1ed1 100644 --- a/main.go +++ b/main.go @@ -195,7 +195,7 @@ func wrappedMain() int { return 1 } } else { - basicUi := &packer.BasicUi{ + basicUi := &packersdk.BasicUi{ Reader: os.Stdin, Writer: os.Stdout, ErrorWriter: os.Stdout, diff --git a/packer-plugin-sdk/chroot/step_copy_files_test.go b/packer-plugin-sdk/chroot/step_copy_files_test.go index fc257188e..362fecde7 100644 --- a/packer-plugin-sdk/chroot/step_copy_files_test.go +++ b/packer-plugin-sdk/chroot/step_copy_files_test.go @@ -10,7 +10,6 @@ import ( "testing" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -19,7 +18,7 @@ import ( // testUI returns a test ui plus a function to retrieve the errors written to the ui func testUI() (packersdk.Ui, func() string) { errorBuffer := &strings.Builder{} - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: strings.NewReader(""), Writer: ioutil.Discard, ErrorWriter: errorBuffer, diff --git a/packer-plugin-sdk/guestexec/elevated_test.go b/packer-plugin-sdk/guestexec/elevated_test.go index c9d44e817..1be624036 100644 --- a/packer-plugin-sdk/guestexec/elevated_test.go +++ b/packer-plugin-sdk/guestexec/elevated_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -19,7 +20,7 @@ func TestProvisioner_GenerateElevatedRunner(t *testing.T) { config := testConfig() p := new(packer.MockProvisioner) p.Prepare(config) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.ProvCommunicator = comm path, err := GenerateElevatedRunner("whoami", p) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom_test.go b/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom_test.go index efec6b9fc..a639cbf69 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom_test.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_create_cdrom_test.go @@ -8,8 +8,8 @@ import ( "path" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestStepCreateCD_Impl(t *testing.T) { @@ -22,7 +22,7 @@ func TestStepCreateCD_Impl(t *testing.T) { func testStepCreateCDState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_create_floppy_test.go b/packer-plugin-sdk/multistep/commonsteps/step_create_floppy_test.go index d4cde0c94..c70ad3979 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_create_floppy_test.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_create_floppy_test.go @@ -12,8 +12,8 @@ import ( "strconv" "testing" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const TestFixtures = "test-fixtures" @@ -28,7 +28,7 @@ func TestStepCreateFloppy_Impl(t *testing.T) { func testStepCreateFloppyState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), }) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_download_test.go b/packer-plugin-sdk/multistep/commonsteps/step_download_test.go index 77ae98a68..460100731 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_download_test.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_download_test.go @@ -19,6 +19,7 @@ import ( urlhelper "github.com/hashicorp/go-getter/v2/helper/url" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -242,7 +243,7 @@ func TestStepDownload_download(t *testing.T) { ResultKey: "iso_path", Url: nil, } - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), PB: &packer.NoopProgressTracker{}, diff --git a/packer-plugin-sdk/multistep/commonsteps/step_output_dir_test.go b/packer-plugin-sdk/multistep/commonsteps/step_output_dir_test.go index f10e2ddd3..66b37f033 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_output_dir_test.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_output_dir_test.go @@ -9,11 +9,12 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testState(t *testing.T) multistep.StateBag { state := new(multistep.BasicStateBag) - state.Put("ui", &packer.BasicUi{ + state.Put("ui", &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), PB: &packer.NoopProgressTracker{}, diff --git a/packer-plugin-sdk/packer/ui.go b/packer-plugin-sdk/packer/ui.go index 1bc1b4591..894abfd44 100644 --- a/packer-plugin-sdk/packer/ui.go +++ b/packer-plugin-sdk/packer/ui.go @@ -1,6 +1,23 @@ package packer -import "github.com/hashicorp/go-getter" +import ( + "errors" + "fmt" + "io" + "log" + "os" + "os/signal" + "strings" + "sync" + "syscall" + + "github.com/hashicorp/go-getter" +) + +type TTY interface { + ReadString() (string, error) + Close() error +} // The Ui interface handles all communication for Packer with the outside // world. This sort of control allows us to strictly control how output @@ -14,3 +31,122 @@ type Ui interface { // TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) getter.ProgressTracker } + +var ErrInterrupted = errors.New("interrupted") + +// BasicUI is an implementation of Ui that reads and writes from a standard Go +// reader and writer. It is safe to be called from multiple goroutines. Machine +// readable output is simply logged for this UI. +type BasicUi struct { + Reader io.Reader + Writer io.Writer + ErrorWriter io.Writer + l sync.Mutex + interrupted bool + TTY TTY + PB getter.ProgressTracker +} + +var _ Ui = new(BasicUi) + +func (rw *BasicUi) Ask(query string) (string, error) { + rw.l.Lock() + defer rw.l.Unlock() + + if rw.interrupted { + return "", ErrInterrupted + } + + if rw.TTY == nil { + return "", errors.New("no available tty") + } + sigCh := make(chan os.Signal, 1) + signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) + defer signal.Stop(sigCh) + + log.Printf("ui: ask: %s", query) + if query != "" { + if _, err := fmt.Fprint(rw.Writer, query+" "); err != nil { + return "", err + } + } + + result := make(chan string, 1) + go func() { + line, err := rw.TTY.ReadString() + if err != nil { + log.Printf("ui: scan err: %s", err) + return + } + result <- strings.TrimSpace(line) + }() + + select { + case line := <-result: + return line, nil + case <-sigCh: + // Print a newline so that any further output starts properly + // on a new line. + fmt.Fprintln(rw.Writer) + + // Mark that we were interrupted so future Ask calls fail. + rw.interrupted = true + + return "", ErrInterrupted + } +} + +func (rw *BasicUi) Say(message string) { + rw.l.Lock() + defer rw.l.Unlock() + + // Use LogSecretFilter to scrub out sensitive variables + message = LogSecretFilter.FilterString(message) + + log.Printf("ui: %s", message) + _, err := fmt.Fprint(rw.Writer, message+"\n") + if err != nil { + log.Printf("[ERR] Failed to write to UI: %s", err) + } +} + +func (rw *BasicUi) Message(message string) { + rw.l.Lock() + defer rw.l.Unlock() + + // Use LogSecretFilter to scrub out sensitive variables + message = LogSecretFilter.FilterString(message) + + log.Printf("ui: %s", message) + _, err := fmt.Fprint(rw.Writer, message+"\n") + if err != nil { + log.Printf("[ERR] Failed to write to UI: %s", err) + } +} + +func (rw *BasicUi) Error(message string) { + rw.l.Lock() + defer rw.l.Unlock() + + writer := rw.ErrorWriter + if writer == nil { + writer = rw.Writer + } + + // Use LogSecretFilter to scrub out sensitive variables + message = LogSecretFilter.FilterString(message) + + log.Printf("ui error: %s", message) + _, err := fmt.Fprint(writer, message+"\n") + if err != nil { + log.Printf("[ERR] Failed to write to UI: %s", err) + } +} + +func (rw *BasicUi) Machine(t string, args ...string) { + log.Printf("machine readable: %s %#v", t, args) +} + +func (rw *BasicUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) { + return rw.PB.TrackProgress(src, currentSize, totalSize, stream) +} diff --git a/packer-plugin-sdk/packer/ui_mock.go b/packer-plugin-sdk/packer/ui_mock.go new file mode 100644 index 000000000..2e67ffe8b --- /dev/null +++ b/packer-plugin-sdk/packer/ui_mock.go @@ -0,0 +1,114 @@ +package packer + +import ( + "errors" + "io" + "log" + "strings" +) + +// TestUi is a UI that only outputs unformatted output to the given writer. +type TestUi struct { + Writer io.Writer +} + +var _ Ui = new(TestUi) + +func (u *TestUi) Ask(query string) (string, error) { + return "", errors.New("Test UI can't ask") +} + +func (u *TestUi) Say(message string) { + log.Printf(message) +} + +func (u *TestUi) Message(message string) { + log.Printf(message) +} + +func (u *TestUi) Error(message string) { + log.Printf(message) +} + +func (u *TestUi) Machine(message string, args ...string) { + log.Printf("%s, %s", message, strings.Join(args, ", ")) +} + +func (u *TestUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) { + return &readCloser{ + read: func(p []byte) (int, error) { + return stream.Read(p) + }, + close: func() error { + return stream.Close() + }, + } +} + +type MockUi struct { + AskCalled bool + AskQuery string + ErrorCalled bool + ErrorMessage string + MachineCalled bool + MachineType string + MachineArgs []string + MessageCalled bool + MessageMessage string + SayCalled bool + SayMessage string + + TrackProgressCalled bool + ProgressBarAddCalled bool + ProgressBarCloseCalled bool +} + +func (u *MockUi) Ask(query string) (string, error) { + u.AskCalled = true + u.AskQuery = query + return "foo", nil +} + +func (u *MockUi) Error(message string) { + u.ErrorCalled = true + u.ErrorMessage = message +} + +func (u *MockUi) Machine(t string, args ...string) { + u.MachineCalled = true + u.MachineType = t + u.MachineArgs = args +} + +func (u *MockUi) Message(message string) { + u.MessageCalled = true + u.MessageMessage = message +} + +func (u *MockUi) Say(message string) { + u.SayCalled = true + u.SayMessage = message +} + +func (u *MockUi) TrackProgress(_ string, _, _ int64, stream io.ReadCloser) (body io.ReadCloser) { + u.TrackProgressCalled = true + + return &readCloser{ + read: func(p []byte) (int, error) { + u.ProgressBarAddCalled = true + return stream.Read(p) + }, + close: func() error { + u.ProgressBarCloseCalled = true + return stream.Close() + }, + } +} + +type readCloser struct { + read func([]byte) (int, error) + close func() error +} + +func (c *readCloser) Close() error { return c.close() } +func (c *readCloser) Read(p []byte) (int, error) { return c.read(p) } diff --git a/packer/build.go b/packer/build.go index 5eb4213db..551f8af3e 100644 --- a/packer/build.go +++ b/packer/build.go @@ -412,7 +412,7 @@ PostProcessorRunSeqLoop: } if len(errors) > 0 { - err = &packersdk.MultiError{errors} + err = &packersdk.MultiError{Errors: errors} } return artifacts, err diff --git a/packer/build_test.go b/packer/build_test.go index 49ff68f68..12a70f138 100644 --- a/packer/build_test.go +++ b/packer/build_test.go @@ -5,6 +5,7 @@ import ( "reflect" "testing" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" "github.com/hashicorp/packer/version" ) @@ -19,8 +20,8 @@ func testBuild() *CoreBuild { Builder: &MockBuilder{ArtifactId: "b"}, BuilderConfig: 42, BuilderType: "foo", - hooks: map[string][]Hook{ - "foo": {&MockHook{}}, + hooks: map[string][]packersdk.Hook{ + "foo": {&packersdk.MockHook{}}, }, Provisioners: []CoreBuildProvisioner{ { @@ -246,7 +247,7 @@ func TestBuild_Run(t *testing.T) { dispatchHook := builder.RunHook dispatchHook.Run(ctx, "foo", nil, nil, 42) - hook := build.hooks["foo"][0].(*MockHook) + hook := build.hooks["foo"][0].(*packersdk.MockHook) if !hook.RunCalled { t.Fatal("should be called") } @@ -255,7 +256,7 @@ func TestBuild_Run(t *testing.T) { } // Verify provisioners run - dispatchHook.Run(ctx, HookProvision, nil, new(MockCommunicator), 42) + dispatchHook.Run(ctx, packersdk.HookProvision, nil, new(packersdk.MockCommunicator), 42) prov := build.Provisioners[0].Provisioner.(*MockProvisioner) if !prov.ProvCalled { t.Fatal("should be called") diff --git a/packer/core_test.go b/packer/core_test.go index 0b27ffb27..1099d6790 100644 --- a/packer/core_test.go +++ b/packer/core_test.go @@ -642,18 +642,18 @@ func TestSensitiveVars(t *testing.T) { // hardcoded { "sensitive-variables.json", - map[string]string{"foo": "bar"}, + map[string]string{"foo": "bar_extra_sensitive_probably_a_password"}, []string{"foo"}, - "bar", + "the foo jumped over the ", false, }, // interpolated { "sensitive-variables.json", - map[string]string{"foo": "bar", + map[string]string{"foo": "bar_extra_sensitive_probably_a_password", "bang": "{{ user `foo`}}"}, []string{"bang"}, - "bar", + "the foo jumped over the ", false, }, } @@ -680,13 +680,11 @@ func TestSensitiveVars(t *testing.T) { if (err != nil) != tc.Err { t.Fatalf("err: %s\n\n%s", tc.File, err) } - filtered := packersdk.LogSecretFilter.get() - if filtered[0] != tc.Expected && len(filtered) != 1 { + // Check that filter correctly manipulates strings: + filtered := packersdk.LogSecretFilter.FilterString("the foo jumped over the bar_extra_sensitive_probably_a_password") + if filtered != tc.Expected { t.Fatalf("not filtering sensitive vars; filtered is %#v", filtered) } - - // clear filter so it doesn't break other tests - packersdk.LogSecretFilter.s = make(map[string]struct{}) } } diff --git a/packer/plugin/plugin_test.go b/packer/plugin/plugin_test.go index d5867148b..bb38a348a 100644 --- a/packer/plugin/plugin_test.go +++ b/packer/plugin/plugin_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func helperProcess(s ...string) *exec.Cmd { @@ -68,7 +69,7 @@ func TestHelperProcess(*testing.T) { log.Printf("[ERR] %s", err) os.Exit(1) } - server.RegisterHook(new(packer.MockHook)) + server.RegisterHook(new(packersdk.MockHook)) server.Serve() case "invalid-rpc-address": fmt.Println("lolinvalid") diff --git a/packer/provisioner_test.go b/packer/provisioner_test.go index 47addda71..b50be279d 100644 --- a/packer/provisioner_test.go +++ b/packer/provisioner_test.go @@ -6,12 +6,14 @@ import ( "fmt" "testing" "time" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestProvisionHook_Impl(t *testing.T) { var raw interface{} raw = &ProvisionHook{} - if _, ok := raw.(Hook); !ok { + if _, ok := raw.(packersdk.Hook); !ok { t.Fatalf("must be a Hook") } } @@ -21,7 +23,7 @@ func TestProvisionHook(t *testing.T) { pB := &MockProvisioner{} ui := testUi() - var comm Communicator = new(MockCommunicator) + var comm packersdk.Communicator = new(packersdk.MockCommunicator) var data interface{} = nil hook := &ProvisionHook{ @@ -47,7 +49,7 @@ func TestProvisionHook_nilComm(t *testing.T) { pB := &MockProvisioner{} ui := testUi() - var comm Communicator = nil + var comm packersdk.Communicator = nil var data interface{} = nil hook := &ProvisionHook{ @@ -80,7 +82,7 @@ func TestProvisionHook_cancel(t *testing.T) { }, } - err := hook.Run(topCtx, "foo", nil, new(MockCommunicator), nil) + err := hook.Run(topCtx, "foo", nil, new(packersdk.MockCommunicator), nil) if err == nil { t.Fatal("should have err") } @@ -114,7 +116,7 @@ func TestPausedProvisionerProvision(t *testing.T) { } ui := testUi() - comm := new(MockCommunicator) + comm := new(packersdk.MockCommunicator) prov.Provision(context.Background(), ui, comm, make(map[string]interface{})) if !mock.ProvCalled { t.Fatal("prov should be called") @@ -144,7 +146,7 @@ func TestPausedProvisionerProvision_waits(t *testing.T) { }, } - err := prov.Provision(context.Background(), testUi(), new(MockCommunicator), make(map[string]interface{})) + err := prov.Provision(context.Background(), testUi(), new(packersdk.MockCommunicator), make(map[string]interface{})) if err != nil { t.Fatalf("prov failed: %v", err) @@ -165,7 +167,7 @@ func TestPausedProvisionerCancel(t *testing.T) { return ctx.Err() } - err := prov.Provision(topCtx, testUi(), new(MockCommunicator), make(map[string]interface{})) + err := prov.Provision(topCtx, testUi(), new(packersdk.MockCommunicator), make(map[string]interface{})) if err == nil { t.Fatal("should have err") } @@ -197,7 +199,7 @@ func TestDebuggedProvisionerProvision(t *testing.T) { } ui := testUi() - comm := new(MockCommunicator) + comm := new(packersdk.MockCommunicator) writeReader(ui, "\n") prov.Provision(context.Background(), ui, comm, make(map[string]interface{})) if !mock.ProvCalled { @@ -225,7 +227,7 @@ func TestDebuggedProvisionerCancel(t *testing.T) { return ctx.Err() } - err := prov.Provision(topCtx, testUi(), new(MockCommunicator), make(map[string]interface{})) + err := prov.Provision(topCtx, testUi(), new(packersdk.MockCommunicator), make(map[string]interface{})) if err == nil { t.Fatal("should have error") } @@ -266,7 +268,7 @@ func TestRetriedProvisionerProvision(t *testing.T) { } ui := testUi() - comm := new(MockCommunicator) + comm := new(packersdk.MockCommunicator) err := prov.Provision(context.Background(), ui, comm, make(map[string]interface{})) if err != nil { t.Fatal("should not have errored") @@ -303,7 +305,7 @@ func TestRetriedProvisionerCancelledProvision(t *testing.T) { } ui := testUi() - comm := new(MockCommunicator) + comm := new(packersdk.MockCommunicator) err := prov.Provision(ctx, ui, comm, make(map[string]interface{})) if err == nil { t.Fatal("should have errored") @@ -336,7 +338,7 @@ func TestRetriedProvisionerCancel(t *testing.T) { return ctx.Err() } - err := prov.Provision(topCtx, testUi(), new(MockCommunicator), make(map[string]interface{})) + err := prov.Provision(topCtx, testUi(), new(packersdk.MockCommunicator), make(map[string]interface{})) if err == nil { t.Fatal("should have err") } diff --git a/packer/rpc/artifact_test.go b/packer/rpc/artifact_test.go index ebdec01fe..8778030d6 100644 --- a/packer/rpc/artifact_test.go +++ b/packer/rpc/artifact_test.go @@ -4,13 +4,12 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestArtifactRPC(t *testing.T) { // Create the interface to test - a := new(packer.MockArtifact) + a := new(packersdk.MockArtifact) // Start the server client, server := testClientServer(t) diff --git a/packer/rpc/build_test.go b/packer/rpc/build_test.go index a2fd0ac93..1535572b4 100644 --- a/packer/rpc/build_test.go +++ b/packer/rpc/build_test.go @@ -10,7 +10,7 @@ import ( packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -var testBuildArtifact = &packer.MockArtifact{} +var testBuildArtifact = &packersdk.MockArtifact{} type testBuild struct { nameCalled bool @@ -86,7 +86,7 @@ func TestBuild(t *testing.T) { } // Test Run - ui := new(testUi) + ui := new(packersdk.MockUi) artifacts, err := bClient.Run(ctx, ui) if !b.runCalled { t.Fatal("run should be called") @@ -150,7 +150,7 @@ func TestBuild_cancel(t *testing.T) { bClient.Prepare() - ui := new(testUi) + ui := new(packersdk.MockUi) bClient.Run(topCtx, ui) // if context cancellation is not propagated, this will timeout diff --git a/packer/rpc/builder_test.go b/packer/rpc/builder_test.go index 75d442865..d57ca4411 100644 --- a/packer/rpc/builder_test.go +++ b/packer/rpc/builder_test.go @@ -6,9 +6,10 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -var testBuilderArtifact = &packer.MockArtifact{} +var testBuilderArtifact = &packersdk.MockArtifact{} func TestBuilderPrepare(t *testing.T) { b := new(packer.MockBuilder) @@ -68,7 +69,7 @@ func TestBuilderRun(t *testing.T) { bClient := client.Builder() // Test Run - hook := &packer.MockHook{} + hook := &packersdk.MockHook{} ui := &testUi{} artifact, err := bClient.Run(context.Background(), ui, hook) if err != nil { @@ -94,7 +95,7 @@ func TestBuilderRun_nilResult(t *testing.T) { server.RegisterBuilder(b) bClient := client.Builder() - hook := &packer.MockHook{} + hook := &packersdk.MockHook{} ui := &testUi{} artifact, err := bClient.Run(context.Background(), ui, hook) if artifact != nil { @@ -115,7 +116,7 @@ func TestBuilderRun_ErrResult(t *testing.T) { b.RunErrResult = true - hook := &packer.MockHook{} + hook := &packersdk.MockHook{} ui := &testUi{} artifact, err := bClient.Run(context.Background(), ui, hook) if artifact != nil { @@ -143,7 +144,7 @@ func TestBuilderCancel(t *testing.T) { server.RegisterBuilder(b) bClient := client.Builder() - bClient.Run(topCtx, new(testUi), new(packer.MockHook)) + bClient.Run(topCtx, new(testUi), new(packersdk.MockHook)) if !cancelled { t.Fatal("context should have been cancelled") diff --git a/packer/rpc/communicator_test.go b/packer/rpc/communicator_test.go index 9e8f298d6..92aeae100 100644 --- a/packer/rpc/communicator_test.go +++ b/packer/rpc/communicator_test.go @@ -7,13 +7,12 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicatorRPC(t *testing.T) { // Create the interface to test - c := new(packer.MockCommunicator) + c := new(packersdk.MockCommunicator) // Start the server client, server := testClientServer(t) diff --git a/packer/rpc/hook_test.go b/packer/rpc/hook_test.go index ef28eeb4c..dadd1ff50 100644 --- a/packer/rpc/hook_test.go +++ b/packer/rpc/hook_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -15,7 +14,7 @@ func TestHook_Implements(t *testing.T) { func TestHook_cancelWhileRun(t *testing.T) { topCtx, cancelTopCtx := context.WithCancel(context.Background()) - h := &packer.MockHook{ + h := &packersdk.MockHook{ RunFunc: func(ctx context.Context) error { cancelTopCtx() <-ctx.Done() diff --git a/packer/rpc/post_processor_test.go b/packer/rpc/post_processor_test.go index 2cccb017c..25507bfa5 100644 --- a/packer/rpc/post_processor_test.go +++ b/packer/rpc/post_processor_test.go @@ -10,7 +10,7 @@ import ( packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -var testPostProcessorArtifact = new(packer.MockArtifact) +var testPostProcessorArtifact = new(packersdk.MockArtifact) type TestPostProcessor struct { configCalled bool @@ -71,7 +71,7 @@ func TestPostProcessorRPC(t *testing.T) { } // Test PostProcess - a := &packer.MockArtifact{ + a := &packersdk.MockArtifact{ IdValue: "ppTestId", } ui := new(testUi) @@ -121,7 +121,7 @@ func TestPostProcessorRPC_cancel(t *testing.T) { } // Test PostProcess - a := &packer.MockArtifact{ + a := &packersdk.MockArtifact{ IdValue: "ppTestId", } ui := new(testUi) diff --git a/packer/rpc/provisioner_test.go b/packer/rpc/provisioner_test.go index f70e09dad..5b3d8844a 100644 --- a/packer/rpc/provisioner_test.go +++ b/packer/rpc/provisioner_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestProvisionerRPC(t *testing.T) { @@ -38,7 +39,7 @@ func TestProvisionerRPC(t *testing.T) { // Test Provision ui := &testUi{} - comm := &packer.MockCommunicator{} + comm := &packersdk.MockCommunicator{} if err := pClient.Provision(topCtx, ui, comm, make(map[string]interface{})); err == nil { t.Fatalf("Provison should have err") } diff --git a/packer/test-fixtures/sensitive-variables.json b/packer/test-fixtures/sensitive-variables.json index 1052740bb..7052ec4cd 100644 --- a/packer/test-fixtures/sensitive-variables.json +++ b/packer/test-fixtures/sensitive-variables.json @@ -1,6 +1,6 @@ { "variables": { - "foo": "bar" + "foo": "bar_extra_sensitive_probably_a_password" }, "sensitive-variables": [ "foo" diff --git a/packer/testing.go b/packer/testing.go index bf5e81a82..29875ed16 100644 --- a/packer/testing.go +++ b/packer/testing.go @@ -33,7 +33,7 @@ func TestCore(t *testing.T, c *CoreConfig) *Core { func TestUi(t *testing.T) packersdk.Ui { var buf bytes.Buffer - return &BasicUi{ + return &packersdk.BasicUi{ Reader: &buf, Writer: ioutil.Discard, ErrorWriter: ioutil.Discard, diff --git a/packer/tty.go b/packer/tty.go deleted file mode 100644 index 61b559d46..000000000 --- a/packer/tty.go +++ /dev/null @@ -1,6 +0,0 @@ -package packer - -type TTY interface { - ReadString() (string, error) - Close() error -} diff --git a/packer/ui.go b/packer/ui.go index 52db011fa..dd70b6d02 100644 --- a/packer/ui.go +++ b/packer/ui.go @@ -7,10 +7,8 @@ import ( "io" "log" "os" - "os/signal" "runtime" "strings" - "sync" "syscall" "time" "unicode" @@ -171,123 +169,6 @@ func (u *TargetedUI) TrackProgress(src string, currentSize, totalSize int64, str return u.Ui.TrackProgress(u.prefixLines(false, src), currentSize, totalSize, stream) } -// The BasicUI is a UI that reads and writes from a standard Go reader -// and writer. It is safe to be called from multiple goroutines. Machine -// readable output is simply logged for this UI. -type BasicUi struct { - Reader io.Reader - Writer io.Writer - ErrorWriter io.Writer - l sync.Mutex - interrupted bool - TTY TTY - PB getter.ProgressTracker -} - -var _ packersdk.Ui = new(BasicUi) - -func (rw *BasicUi) Ask(query string) (string, error) { - rw.l.Lock() - defer rw.l.Unlock() - - if rw.interrupted { - return "", ErrInterrupted - } - - if rw.TTY == nil { - return "", errors.New("no available tty") - } - sigCh := make(chan os.Signal, 1) - signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) - defer signal.Stop(sigCh) - - log.Printf("ui: ask: %s", query) - if query != "" { - if _, err := fmt.Fprint(rw.Writer, query+" "); err != nil { - return "", err - } - } - - result := make(chan string, 1) - go func() { - line, err := rw.TTY.ReadString() - if err != nil { - log.Printf("ui: scan err: %s", err) - return - } - result <- strings.TrimSpace(line) - }() - - select { - case line := <-result: - return line, nil - case <-sigCh: - // Print a newline so that any further output starts properly - // on a new line. - fmt.Fprintln(rw.Writer) - - // Mark that we were interrupted so future Ask calls fail. - rw.interrupted = true - - return "", ErrInterrupted - } -} - -func (rw *BasicUi) Say(message string) { - rw.l.Lock() - defer rw.l.Unlock() - - // Use packersdk.LogSecretFilter to scrub out sensitive variables - message = packersdk.LogSecretFilter.FilterString(message) - - log.Printf("ui: %s", message) - _, err := fmt.Fprint(rw.Writer, message+"\n") - if err != nil { - log.Printf("[ERR] Failed to write to UI: %s", err) - } -} - -func (rw *BasicUi) Message(message string) { - rw.l.Lock() - defer rw.l.Unlock() - - // Use packersdk.LogSecretFilter to scrub out sensitive variables - message = packersdk.LogSecretFilter.FilterString(message) - - log.Printf("ui: %s", message) - _, err := fmt.Fprint(rw.Writer, message+"\n") - if err != nil { - log.Printf("[ERR] Failed to write to UI: %s", err) - } -} - -func (rw *BasicUi) Error(message string) { - rw.l.Lock() - defer rw.l.Unlock() - - writer := rw.ErrorWriter - if writer == nil { - writer = rw.Writer - } - - // Use packersdk.LogSecretFilter to scrub out sensitive variables - message = packersdk.LogSecretFilter.FilterString(message) - - log.Printf("ui error: %s", message) - _, err := fmt.Fprint(writer, message+"\n") - if err != nil { - log.Printf("[ERR] Failed to write to UI: %s", err) - } -} - -func (rw *BasicUi) Machine(t string, args ...string) { - log.Printf("machine readable: %s %#v", t, args) -} - -func (rw *BasicUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) { - return rw.PB.TrackProgress(src, currentSize, totalSize, stream) -} - // MachineReadableUi is a UI that only outputs machine-readable output // to the given Writer. type MachineReadableUi struct { diff --git a/packer/ui_test.go b/packer/ui_test.go index 9684aaf34..201a57aca 100644 --- a/packer/ui_test.go +++ b/packer/ui_test.go @@ -5,11 +5,13 @@ import ( "os" "strings" "testing" + + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This reads the output from the bytes.Buffer in our test object // and then resets the buffer. -func readWriter(ui *BasicUi) (result string) { +func readWriter(ui *packersdk.BasicUi) (result string) { buffer := ui.Writer.(*bytes.Buffer) result = buffer.String() buffer.Reset() @@ -17,20 +19,20 @@ func readWriter(ui *BasicUi) (result string) { } // Reset the input Reader than add some input to it. -func writeReader(ui *BasicUi, input string) { +func writeReader(ui *packersdk.BasicUi, input string) { buffer := ui.Reader.(*bytes.Buffer) buffer.WriteString(input) } -func readErrorWriter(ui *BasicUi) (result string) { +func readErrorWriter(ui *packersdk.BasicUi) (result string) { buffer := ui.ErrorWriter.(*bytes.Buffer) result = buffer.String() buffer.Reset() return } -func testUi() *BasicUi { - return &BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), ErrorWriter: new(bytes.Buffer), @@ -147,7 +149,7 @@ func TestTargetedUI(t *testing.T) { func TestColoredUi_ImplUi(t *testing.T) { var raw interface{} raw = &ColoredUi{} - if _, ok := raw.(Ui); !ok { + if _, ok := raw.(packersdk.Ui); !ok { t.Fatalf("ColoredUi must implement Ui") } } @@ -155,15 +157,15 @@ func TestColoredUi_ImplUi(t *testing.T) { func TestTargetedUI_ImplUi(t *testing.T) { var raw interface{} raw = &TargetedUI{} - if _, ok := raw.(Ui); !ok { + if _, ok := raw.(packersdk.Ui); !ok { t.Fatalf("TargetedUI must implement Ui") } } func TestBasicUi_ImplUi(t *testing.T) { var raw interface{} - raw = &BasicUi{} - if _, ok := raw.(Ui); !ok { + raw = &packersdk.BasicUi{} + if _, ok := raw.(packersdk.Ui); !ok { t.Fatalf("BasicUi must implement Ui") } } @@ -250,7 +252,7 @@ func TestBasicUi_Ask(t *testing.T) { func TestMachineReadableUi_ImplUi(t *testing.T) { var raw interface{} raw = &MachineReadableUi{} - if _, ok := raw.(Ui); !ok { + if _, ok := raw.(packersdk.Ui); !ok { t.Fatalf("MachineReadableUi must implement Ui") } } diff --git a/post-processor/docker-push/post-processor_test.go b/post-processor/docker-push/post-processor_test.go index 79710333b..ba9d84d93 100644 --- a/post-processor/docker-push/post-processor_test.go +++ b/post-processor/docker-push/post-processor_test.go @@ -11,8 +11,8 @@ import ( dockerimport "github.com/hashicorp/packer/post-processor/docker-import" ) -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } @@ -25,7 +25,7 @@ func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { func TestPostProcessor_PostProcess(t *testing.T) { driver := &docker.MockDriver{} p := &PostProcessor{Driver: driver} - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: dockerimport.BuilderId, IdValue: "foo/bar", } @@ -58,7 +58,7 @@ func TestPostProcessor_PostProcess(t *testing.T) { func TestPostProcessor_PostProcess_portInName(t *testing.T) { driver := &docker.MockDriver{} p := &PostProcessor{Driver: driver} - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: dockerimport.BuilderId, IdValue: "localhost:5000/foo/bar", } @@ -91,7 +91,7 @@ func TestPostProcessor_PostProcess_portInName(t *testing.T) { func TestPostProcessor_PostProcess_tags(t *testing.T) { driver := &docker.MockDriver{} p := &PostProcessor{Driver: driver} - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: dockerimport.BuilderId, IdValue: "hashicorp/ubuntu:precise", } diff --git a/post-processor/docker-tag/post-processor_test.go b/post-processor/docker-tag/post-processor_test.go index e61489bf1..2d6fc0562 100644 --- a/post-processor/docker-tag/post-processor_test.go +++ b/post-processor/docker-tag/post-processor_test.go @@ -28,8 +28,8 @@ func testPP(t *testing.T) *PostProcessor { return &p } -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } @@ -46,7 +46,7 @@ func TestPostProcessor_PostProcess(t *testing.T) { t.Fatalf("err: %s", err) } - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: dockerimport.BuilderId, IdValue: "1234567890abcdef", } @@ -94,7 +94,7 @@ func TestPostProcessor_PostProcess_Force(t *testing.T) { t.Fatalf("err: %s", err) } - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: dockerimport.BuilderId, IdValue: "1234567890abcdef", } @@ -139,7 +139,7 @@ func TestPostProcessor_PostProcess_NoTag(t *testing.T) { t.Fatalf("err %s", err) } - artifact := &packer.MockArtifact{BuilderIdValue: dockerimport.BuilderId, IdValue: "1234567890abcdef"} + artifact := &packersdk.MockArtifact{BuilderIdValue: dockerimport.BuilderId, IdValue: "1234567890abcdef"} result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) if _, ok := result.(packersdk.Artifact); !ok { diff --git a/post-processor/vagrant-cloud/post-processor_test.go b/post-processor/vagrant-cloud/post-processor_test.go index 52f68c535..56e2b8006 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -14,6 +14,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" ) @@ -229,7 +230,7 @@ func TestPostProcessor_Configure_checkAccessTokenIsNotRequiredForOverridenVagran } func TestPostProcessor_PostProcess_checkArtifactType(t *testing.T) { - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: "invalid.builder", } @@ -247,7 +248,7 @@ func TestPostProcessor_PostProcess_checkArtifactType(t *testing.T) { } func TestPostProcessor_PostProcess_checkArtifactFileIsBox(t *testing.T) { - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: "mitchellh.post-processor.vagrant", // good FilesValue: []string{"invalid.boxfile"}, // should have .box extension } @@ -278,7 +279,7 @@ func TestPostProcessor_PostProcess_uploadsAndReleases(t *testing.T) { } defer os.Remove(boxfile.Name()) - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: "mitchellh.post-processor.vagrant", FilesValue: []string{boxfile.Name()}, } @@ -325,7 +326,7 @@ func TestPostProcessor_PostProcess_uploadsAndNoRelease(t *testing.T) { } defer os.Remove(boxfile.Name()) - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: "mitchellh.post-processor.vagrant", FilesValue: []string{boxfile.Name()}, } @@ -373,7 +374,7 @@ func TestPostProcessor_PostProcess_uploadsDirectAndReleases(t *testing.T) { } defer os.Remove(boxfile.Name()) - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: "mitchellh.post-processor.vagrant", FilesValue: []string{boxfile.Name()}, } @@ -416,8 +417,8 @@ func TestPostProcessor_PostProcess_uploadsDirectAndReleases(t *testing.T) { } } -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } diff --git a/post-processor/vagrant/aws_test.go b/post-processor/vagrant/aws_test.go index d242985d1..df8fce2e3 100644 --- a/post-processor/vagrant/aws_test.go +++ b/post-processor/vagrant/aws_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestAWSProvider_impl(t *testing.T) { @@ -22,7 +22,7 @@ func TestAWSProvider_KeepInputArtifact(t *testing.T) { func TestAWSProvider_ArtifactId(t *testing.T) { p := new(AWSProvider) ui := testUi() - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ IdValue: "us-east-1:ami-1234", } diff --git a/post-processor/vagrant/azure_test.go b/post-processor/vagrant/azure_test.go index 7521f4405..25c1acd88 100644 --- a/post-processor/vagrant/azure_test.go +++ b/post-processor/vagrant/azure_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestAzureProvider_impl(t *testing.T) { @@ -22,7 +22,7 @@ func TestAzureProvider_KeepInputArtifact(t *testing.T) { func TestAzureProvider_ManagedImage(t *testing.T) { p := new(AzureProvider) ui := testUi() - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ StringValue: `Azure.ResourceManagement.VMImage: OSType: Linux @@ -58,7 +58,7 @@ ManagedImageLocation: westus`, func TestAzureProvider_VHD(t *testing.T) { p := new(AzureProvider) ui := testUi() - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ IdValue: "https://packerbuildswest.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.96ed2120-591d-4900-95b0-ee8e985f2213.vhd", StringValue: `Azure.ResourceManagement.VMImage: diff --git a/post-processor/vagrant/digitalocean_test.go b/post-processor/vagrant/digitalocean_test.go index c666b06a3..2dab71859 100644 --- a/post-processor/vagrant/digitalocean_test.go +++ b/post-processor/vagrant/digitalocean_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestDigitalOceanProvider_impl(t *testing.T) { @@ -22,7 +22,7 @@ func TestDigitalOceanProvider_KeepInputArtifact(t *testing.T) { func TestDigitalOceanProvider_ArtifactId(t *testing.T) { p := new(DigitalOceanProvider) ui := testUi() - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ IdValue: "San Francisco:42", } diff --git a/post-processor/vagrant/google_test.go b/post-processor/vagrant/google_test.go index 22eab0c77..ffb1e64e6 100644 --- a/post-processor/vagrant/google_test.go +++ b/post-processor/vagrant/google_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestGoogleProvider_impl(t *testing.T) { @@ -22,7 +22,7 @@ func TestGoogleProvider_KeepInputArtifact(t *testing.T) { func TestGoogleProvider_ArtifactId(t *testing.T) { p := new(GoogleProvider) ui := testUi() - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ IdValue: "packer-1234", } diff --git a/post-processor/vagrant/post-processor_test.go b/post-processor/vagrant/post-processor_test.go index 2a86821c4..3be292f99 100644 --- a/post-processor/vagrant/post-processor_test.go +++ b/post-processor/vagrant/post-processor_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -25,8 +26,8 @@ func testPP(t *testing.T) *PostProcessor { return &p } -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } @@ -183,7 +184,7 @@ func TestPostProcessorPrepare_ProviderOverrideExists(t *testing.T) { } func TestPostProcessorPostProcess_badId(t *testing.T) { - artifact := &packer.MockArtifact{ + artifact := &packersdk.MockArtifact{ BuilderIdValue: "invalid.packer", } @@ -214,7 +215,7 @@ func TestPostProcessorPostProcess_vagrantfileUserVariable(t *testing.T) { t.Fatalf("err: %s", err) } - a := &packer.MockArtifact{ + a := &packersdk.MockArtifact{ BuilderIdValue: "packer.parallels", } a2, _, _, err := p.PostProcess(context.Background(), testUi(), a) diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index a1785df73..225854f87 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -368,13 +368,13 @@ func testProvisionerProvisionDockerWithPlaybookFiles(t *testing.T, templateStrin hooks := map[string][]packersdk.Hook{} hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packersdk.HookedProvisioner{ + Provisioners: []*packer.HookedProvisioner{ {Provisioner: ansible, Config: nil, TypeName: ""}, {Provisioner: download, Config: nil, TypeName: ""}, }, }, } - hook := &packer.DispatchHook{Mapping: hooks} + hook := &packersdk.DispatchHook{Mapping: hooks} artifact, err := builder.Run(context.Background(), ui, hook) if err != nil { diff --git a/provisioner/ansible/provisioner_test.go b/provisioner/ansible/provisioner_test.go index b73e5c543..83f4d6960 100644 --- a/provisioner/ansible/provisioner_test.go +++ b/provisioner/ansible/provisioner_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" confighelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/stretchr/testify/assert" ) @@ -346,8 +347,8 @@ func TestAnsibleLongMessages(t *testing.T) { t.Fatalf("err: %s", err) } - comm := &packer.MockCommunicator{} - ui := &packer.BasicUi{ + comm := &packersdk.MockCommunicator{} + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } @@ -766,8 +767,8 @@ func TestUseProxy(t *testing.T) { p.setupAdapterFunc = l.setupAdapter p.executeAnsibleFunc = l.executeAnsible ctx := context.TODO() - comm := new(packer.MockCommunicator) - ui := &packer.BasicUi{ + comm := new(packersdk.MockCommunicator) + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } diff --git a/provisioner/chef-client/provisioner_test.go b/provisioner/chef-client/provisioner_test.go index 271726f3e..40aca6988 100644 --- a/provisioner/chef-client/provisioner_test.go +++ b/provisioner/chef-client/provisioner_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -241,8 +242,8 @@ func TestProvisioner_createDir(t *testing.T) { config["prevent_sudo"] = !sudo p := &Provisioner{} - comm := &packer.MockCommunicator{} - ui := &packer.BasicUi{ + comm := &packersdk.MockCommunicator{} + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } @@ -272,8 +273,8 @@ func TestProvisioner_removeDir(t *testing.T) { config["prevent_sudo"] = !sudo p := &Provisioner{} - comm := &packer.MockCommunicator{} - ui := &packer.BasicUi{ + comm := &packersdk.MockCommunicator{} + ui := &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), } diff --git a/provisioner/file/provisioner_test.go b/provisioner/file/provisioner_test.go index dd1d0325c..e0c5166ad 100644 --- a/provisioner/file/provisioner_test.go +++ b/provisioner/file/provisioner_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -124,11 +125,11 @@ func TestProvisionerProvision_SendsFile(t *testing.T) { } b := bytes.NewBuffer(nil) - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Writer: b, PB: &packer.NoopProgressTracker{}, } - comm := &packer.MockCommunicator{} + comm := &packersdk.MockCommunicator{} err = p.Provision(context.Background(), ui, comm, make(map[string]interface{})) if err != nil { t.Fatalf("should successfully provision: %s", err) @@ -183,11 +184,11 @@ func TestProvisionerProvision_SendsFileMultipleFiles(t *testing.T) { } b := bytes.NewBuffer(nil) - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Writer: b, PB: &packer.NoopProgressTracker{}, } - comm := &packer.MockCommunicator{} + comm := &packersdk.MockCommunicator{} err = p.Provision(context.Background(), ui, comm, make(map[string]interface{})) if err != nil { t.Fatalf("should successfully provision: %s", err) @@ -253,11 +254,11 @@ func TestProvisionerProvision_SendsFileMultipleDirs(t *testing.T) { } b := bytes.NewBuffer(nil) - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Writer: b, PB: &packer.NoopProgressTracker{}, } - comm := &packer.MockCommunicator{} + comm := &packersdk.MockCommunicator{} err = p.Provision(context.Background(), ui, comm, make(map[string]interface{})) if err != nil { t.Fatalf("should successfully provision: %s", err) @@ -305,11 +306,11 @@ func TestProvisionerProvision_SendsFileMultipleFilesToFolder(t *testing.T) { } b := bytes.NewBuffer(nil) - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Writer: b, PB: &packer.NoopProgressTracker{}, } - comm := &packer.MockCommunicator{} + comm := &packersdk.MockCommunicator{} err = p.Provision(context.Background(), ui, comm, make(map[string]interface{})) if err != nil { t.Fatalf("should successfully provision: %s", err) @@ -363,11 +364,11 @@ func TestProvisionDownloadMkdirAll(t *testing.T) { t.Fatalf("err: %s", err) } b := bytes.NewBuffer(nil) - ui := &packer.BasicUi{ + ui := &packersdk.BasicUi{ Writer: b, PB: &packer.NoopProgressTracker{}, } - comm := &packer.MockCommunicator{} + comm := &packersdk.MockCommunicator{} err = p.ProvisionDownload(ui, comm) if err != nil { t.Fatalf("should successfully provision: %s", err) diff --git a/provisioner/powershell/provisioner_acc_test.go b/provisioner/powershell/provisioner_acc_test.go index 846ab0c3d..3e485a055 100644 --- a/provisioner/powershell/provisioner_acc_test.go +++ b/provisioner/powershell/provisioner_acc_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/command" "github.com/hashicorp/packer/helper/tests/acc" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/provisioner/powershell" windowsshellprovisioner "github.com/hashicorp/packer/provisioner/windows-shell" ) @@ -81,7 +82,7 @@ func (s *PowershellProvisionerAccTest) RunTest(c *command.BuildCommand, args []s } if code := c.Run(args); code != 0 { - ui := c.Meta.Ui.(*packer.BasicUi) + ui := c.Meta.Ui.(*packersdk.BasicUi) out := ui.Writer.(*bytes.Buffer) err := ui.ErrorWriter.(*bytes.Buffer) return fmt.Errorf( diff --git a/provisioner/powershell/provisioner_test.go b/provisioner/powershell/provisioner_test.go index e5611385b..7fb8f355e 100644 --- a/provisioner/powershell/provisioner_test.go +++ b/provisioner/powershell/provisioner_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" ) @@ -349,8 +350,8 @@ func TestProvisionerQuote_EnvironmentVars(t *testing.T) { } } -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), ErrorWriter: new(bytes.Buffer), @@ -371,7 +372,7 @@ func TestProvisionerProvision_ValidExitCodes(t *testing.T) { p.config.PackerBuildName = "vmware" p.config.PackerBuilderType = "iso" p.config.ValidExitCodes = []int{0, 200} - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) comm.StartExitStatus = 200 p.Prepare(config) err := p.Provision(context.Background(), ui, comm, generatedData()) @@ -394,7 +395,7 @@ func TestProvisionerProvision_InvalidExitCodes(t *testing.T) { p.config.PackerBuildName = "vmware" p.config.PackerBuilderType = "iso" p.config.ValidExitCodes = []int{0, 200} - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) comm.StartExitStatus = 201 // Invalid! p.Prepare(config) err := p.Provision(context.Background(), ui, comm, generatedData()) @@ -417,7 +418,7 @@ func TestProvisionerProvision_Inline(t *testing.T) { // Defaults provided by Packer - env vars should not appear in cmd p.config.PackerBuildName = "vmware" p.config.PackerBuilderType = "iso" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) _ = p.Prepare(config) err := p.Provision(context.Background(), ui, comm, generatedData()) @@ -468,7 +469,7 @@ func TestProvisionerProvision_Scripts(t *testing.T) { ui := testUi() p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) err := p.Provision(context.Background(), ui, comm, generatedData()) if err != nil { @@ -505,7 +506,7 @@ func TestProvisionerProvision_ScriptsWithEnvVars(t *testing.T) { config["remote_path"] = "c:/Windows/Temp/script.ps1" p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) err := p.Provision(context.Background(), ui, comm, generatedData()) if err != nil { @@ -550,7 +551,7 @@ func TestProvisionerProvision_SkipClean(t *testing.T) { tc := tc p := new(Provisioner) ui := testUi() - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) config["skip_clean"] = tc.SkipClean if err := p.Prepare(config); err != nil { @@ -577,14 +578,14 @@ func TestProvisionerProvision_UploadFails(t *testing.T) { ui := testUi() p := new(Provisioner) - comm := new(packer.ScriptUploadErrorMockCommunicator) + comm := new(packersdk.ScriptUploadErrorMockCommunicator) p.Prepare(config) p.config.StartRetryTimeout = 1 * time.Second err := p.Provision(context.Background(), ui, comm, generatedData()) - if !strings.Contains(err.Error(), packer.ScriptUploadErrorMockCommunicatorError.Error()) { + if !strings.Contains(err.Error(), packersdk.ScriptUploadErrorMockCommunicatorError.Error()) { t.Fatalf("expected Provision() error %q to contain %q", err.Error(), - packer.ScriptUploadErrorMockCommunicatorError.Error()) + packersdk.ScriptUploadErrorMockCommunicatorError.Error()) } } @@ -790,7 +791,7 @@ func TestProvision_createCommandText(t *testing.T) { config := testConfig() config["remote_path"] = "c:/Windows/Temp/script.ps1" p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.communicator = comm _ = p.Prepare(config) @@ -821,7 +822,7 @@ func TestProvision_createCommandText(t *testing.T) { func TestProvision_uploadEnvVars(t *testing.T) { p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.communicator = comm flattenedEnvVars := `$env:PACKER_BUILDER_TYPE="footype"; $env:PACKER_BUILD_NAME="foobuild";` diff --git a/provisioner/puppet-masterless/provisioner_test.go b/provisioner/puppet-masterless/provisioner_test.go index 2a9b21e6b..ebaee2dd3 100644 --- a/provisioner/puppet-masterless/provisioner_test.go +++ b/provisioner/puppet-masterless/provisioner_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/stretchr/testify/assert" ) @@ -479,7 +480,7 @@ func TestProvisionerProvision_extraArguments(t *testing.T) { ui := &packer.MachineReadableUi{ Writer: ioutil.Discard, } - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) extraArguments := []string{ "--some-arg=yup", diff --git a/provisioner/shell-local/provisioner_acc_test.go b/provisioner/shell-local/provisioner_acc_test.go index e9e7d4f31..a23ceb3c5 100644 --- a/provisioner/shell-local/provisioner_acc_test.go +++ b/provisioner/shell-local/provisioner_acc_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/provisioner/shell" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/command" ) @@ -51,7 +52,7 @@ func (s *ShellLocalProvisionerAccTest) IsCompatible(builder string, vmOS string) func (s *ShellLocalProvisionerAccTest) RunTest(c *command.BuildCommand, args []string) error { if code := c.Run(args); code != 0 { - ui := c.Meta.Ui.(*packer.BasicUi) + ui := c.Meta.Ui.(*packersdk.BasicUi) out := ui.Writer.(*bytes.Buffer) err := ui.ErrorWriter.(*bytes.Buffer) return fmt.Errorf( diff --git a/provisioner/shell/provisioner_acc_test.go b/provisioner/shell/provisioner_acc_test.go index 4529c82a7..faf785a0a 100644 --- a/provisioner/shell/provisioner_acc_test.go +++ b/provisioner/shell/provisioner_acc_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/provisioner/shell" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/go-uuid" "github.com/hashicorp/packer/command" @@ -64,7 +65,7 @@ func (s *ShellProvisionerAccTest) RunTest(c *command.BuildCommand, args []string defer testshelper.CleanupFiles(file) if code := c.Run(args); code != 0 { - ui := c.Meta.Ui.(*packer.BasicUi) + ui := c.Meta.Ui.(*packersdk.BasicUi) out := ui.Writer.(*bytes.Buffer) err := ui.ErrorWriter.(*bytes.Buffer) return fmt.Errorf( diff --git a/provisioner/windows-restart/provisioner_test.go b/provisioner/windows-restart/provisioner_test.go index ac44db001..6d87216c2 100644 --- a/provisioner/windows-restart/provisioner_test.go +++ b/provisioner/windows-restart/provisioner_test.go @@ -79,8 +79,8 @@ func TestProvisionerPrepare_InvalidKey(t *testing.T) { } } -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), ErrorWriter: new(bytes.Buffer), @@ -95,7 +95,7 @@ func TestProvisionerProvision_Success(t *testing.T) { p := new(Provisioner) // Defaults provided by Packer - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) waitForCommunicatorOld := waitForCommunicator waitForCommunicator = func(context.Context, *Provisioner) error { @@ -131,7 +131,7 @@ func TestProvisionerProvision_CustomCommand(t *testing.T) { config["restart_command"] = expectedCommand // Defaults provided by Packer - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) waitForCommunicatorOld := waitForCommunicator waitForCommunicator = func(context.Context, *Provisioner) error { @@ -159,7 +159,7 @@ func TestProvisionerProvision_RestartCommandFail(t *testing.T) { config := testConfig() ui := testUi() p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) comm.StartStderr = "WinRM terminated" comm.StartExitStatus = 1 @@ -177,7 +177,7 @@ func TestProvisionerProvision_WaitForRestartFail(t *testing.T) { p := new(Provisioner) // Defaults provided by Packer - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) waitForCommunicatorOld := waitForCommunicator waitForCommunicator = func(context.Context, *Provisioner) error { @@ -198,7 +198,7 @@ func TestProvision_waitForRestartTimeout(t *testing.T) { config["restart_timeout"] = "1ms" ui := testUi() p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) var err error p.Prepare(config) @@ -239,7 +239,7 @@ func TestProvision_waitForCommunicator(t *testing.T) { p := new(Provisioner) // Defaults provided by Packer - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.comm = comm p.ui = ui comm.StartStderr = "WinRM terminated" @@ -268,7 +268,7 @@ func TestProvision_waitForCommunicatorWithCancel(t *testing.T) { p := new(Provisioner) // Defaults provided by Packer - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.comm = comm p.ui = ui retryableSleep = 5 * time.Second @@ -312,7 +312,7 @@ func TestProvision_Cancel(t *testing.T) { ui := testUi() p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) done := make(chan error) diff --git a/provisioner/windows-shell/provisioner_test.go b/provisioner/windows-shell/provisioner_test.go index 1e33eb639..b523721a2 100644 --- a/provisioner/windows-shell/provisioner_test.go +++ b/provisioner/windows-shell/provisioner_test.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -265,8 +266,8 @@ func TestProvisionerQuote_EnvironmentVars(t *testing.T) { } -func testUi() *packer.BasicUi { - return &packer.BasicUi{ +func testUi() *packersdk.BasicUi { + return &packersdk.BasicUi{ Reader: new(bytes.Buffer), Writer: new(bytes.Buffer), ErrorWriter: new(bytes.Buffer), @@ -286,7 +287,7 @@ func TestProvisionerProvision_Inline(t *testing.T) { // Defaults provided by Packer p.config.PackerBuildName = "vmware" p.config.PackerBuilderType = "iso" - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) err := p.Provision(context.Background(), ui, comm, generatedData()) @@ -337,7 +338,7 @@ func TestProvisionerProvision_Scripts(t *testing.T) { ui := testUi() p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) err = p.Provision(context.Background(), ui, comm, generatedData()) if err != nil { @@ -376,7 +377,7 @@ func TestProvisionerProvision_ScriptsWithEnvVars(t *testing.T) { config["environment_vars"] = envVars p := new(Provisioner) - comm := new(packer.MockCommunicator) + comm := new(packersdk.MockCommunicator) p.Prepare(config) err = p.Provision(context.Background(), ui, comm, generatedData()) if err != nil { From 0eff73293a947c01ac60e640a9b30305aa479ff1 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 20 Nov 2020 10:53:16 -0800 Subject: [PATCH 08/10] fix imports, vendoring, and linting --- builder/azure/arm/config.go | 1 + builder/azure/common/client/config.go | 1 + builder/digitalocean/config.go | 2 +- builder/googlecompute/config.go | 4 +- builder/hyperv/iso/builder.go | 2 +- builder/hyperv/vmcx/builder.go | 2 +- builder/oracle/classic/config.go | 13 +- builder/virtualbox/iso/builder.go | 20 +- builder/virtualbox/ovf/config.go | 29 +- builder/virtualbox/vm/config.go | 27 +- packer-plugin-sdk/packer/ui.go | 2 +- packer/build_test.go | 5 +- packer/plugin/plugin_test.go | 6 +- packer/rpc/builder_test.go | 5 +- tty_solaris.go | 4 +- vendor/github.com/hashicorp/go-getter/LICENSE | 354 +++++++++++++++++ .../github.com/hashicorp/go-getter/README.md | 362 ++++++++++++++++++ .../hashicorp/go-getter/appveyor.yml | 16 + .../hashicorp/go-getter/checksum.go | 314 +++++++++++++++ .../github.com/hashicorp/go-getter/client.go | 298 ++++++++++++++ .../hashicorp/go-getter/client_mode.go | 24 ++ .../hashicorp/go-getter/client_option.go | 46 +++ .../go-getter/client_option_progress.go | 38 ++ .../github.com/hashicorp/go-getter/common.go | 14 + .../hashicorp/go-getter/copy_dir.go | 78 ++++ .../hashicorp/go-getter/decompress.go | 58 +++ .../hashicorp/go-getter/decompress_bzip2.go | 45 +++ .../hashicorp/go-getter/decompress_gzip.go | 49 +++ .../hashicorp/go-getter/decompress_tar.go | 160 ++++++++ .../hashicorp/go-getter/decompress_tbz2.go | 33 ++ .../hashicorp/go-getter/decompress_testing.go | 171 +++++++++ .../hashicorp/go-getter/decompress_tgz.go | 39 ++ .../hashicorp/go-getter/decompress_txz.go | 39 ++ .../hashicorp/go-getter/decompress_xz.go | 49 +++ .../hashicorp/go-getter/decompress_zip.go | 101 +++++ .../github.com/hashicorp/go-getter/detect.go | 105 +++++ .../hashicorp/go-getter/detect_bitbucket.go | 66 ++++ .../hashicorp/go-getter/detect_file.go | 67 ++++ .../hashicorp/go-getter/detect_gcs.go | 43 +++ .../hashicorp/go-getter/detect_git.go | 26 ++ .../hashicorp/go-getter/detect_github.go | 47 +++ .../hashicorp/go-getter/detect_s3.go | 61 +++ .../hashicorp/go-getter/detect_ssh.go | 49 +++ .../hashicorp/go-getter/folder_storage.go | 65 ++++ vendor/github.com/hashicorp/go-getter/get.go | 152 ++++++++ .../hashicorp/go-getter/get_base.go | 20 + .../hashicorp/go-getter/get_file.go | 36 ++ .../hashicorp/go-getter/get_file_copy.go | 29 ++ .../hashicorp/go-getter/get_file_unix.go | 103 +++++ .../hashicorp/go-getter/get_file_windows.go | 136 +++++++ .../github.com/hashicorp/go-getter/get_gcs.go | 172 +++++++++ .../github.com/hashicorp/go-getter/get_git.go | 313 +++++++++++++++ .../github.com/hashicorp/go-getter/get_hg.go | 135 +++++++ .../hashicorp/go-getter/get_http.go | 328 ++++++++++++++++ .../hashicorp/go-getter/get_mock.go | 54 +++ .../github.com/hashicorp/go-getter/get_s3.go | 275 +++++++++++++ vendor/github.com/hashicorp/go-getter/go.mod | 23 ++ vendor/github.com/hashicorp/go-getter/go.sum | 162 ++++++++ .../hashicorp/go-getter/helper/url/url.go | 14 + .../go-getter/helper/url/url_unix.go | 11 + .../go-getter/helper/url/url_windows.go | 39 ++ .../github.com/hashicorp/go-getter/netrc.go | 67 ++++ .../github.com/hashicorp/go-getter/source.go | 75 ++++ .../github.com/hashicorp/go-getter/storage.go | 13 + vendor/modules.txt | 3 + 65 files changed, 5043 insertions(+), 57 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-getter/LICENSE create mode 100644 vendor/github.com/hashicorp/go-getter/README.md create mode 100644 vendor/github.com/hashicorp/go-getter/appveyor.yml create mode 100644 vendor/github.com/hashicorp/go-getter/checksum.go create mode 100644 vendor/github.com/hashicorp/go-getter/client.go create mode 100644 vendor/github.com/hashicorp/go-getter/client_mode.go create mode 100644 vendor/github.com/hashicorp/go-getter/client_option.go create mode 100644 vendor/github.com/hashicorp/go-getter/client_option_progress.go create mode 100644 vendor/github.com/hashicorp/go-getter/common.go create mode 100644 vendor/github.com/hashicorp/go-getter/copy_dir.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_bzip2.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_gzip.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_tar.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_tbz2.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_testing.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_tgz.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_txz.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_xz.go create mode 100644 vendor/github.com/hashicorp/go-getter/decompress_zip.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_bitbucket.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_file.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_gcs.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_git.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_github.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_s3.go create mode 100644 vendor/github.com/hashicorp/go-getter/detect_ssh.go create mode 100644 vendor/github.com/hashicorp/go-getter/folder_storage.go create mode 100644 vendor/github.com/hashicorp/go-getter/get.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_base.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_file.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_file_copy.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_file_unix.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_file_windows.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_gcs.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_git.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_hg.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_http.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_mock.go create mode 100644 vendor/github.com/hashicorp/go-getter/get_s3.go create mode 100644 vendor/github.com/hashicorp/go-getter/go.mod create mode 100644 vendor/github.com/hashicorp/go-getter/go.sum create mode 100644 vendor/github.com/hashicorp/go-getter/helper/url/url.go create mode 100644 vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go create mode 100644 vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go create mode 100644 vendor/github.com/hashicorp/go-getter/netrc.go create mode 100644 vendor/github.com/hashicorp/go-getter/source.go create mode 100644 vendor/github.com/hashicorp/go-getter/storage.go diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index b193ea099..d9d6f029a 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -810,6 +810,7 @@ func assertTagProperties(c *Config, errs *packersdk.MultiError) { } } +//nolint:ineffassign //this triggers a false positive because errs is passed by reference func assertRequiredParametersSet(c *Config, errs *packersdk.MultiError) { c.ClientConfig.Validate(errs) diff --git a/builder/azure/common/client/config.go b/builder/azure/common/client/config.go index 264a36b14..e34a3f620 100644 --- a/builder/azure/common/client/config.go +++ b/builder/azure/common/client/config.go @@ -120,6 +120,7 @@ func (c *Config) setCloudEnvironment() error { return err } +//nolint:ineffassign //this triggers a false positive because errs is passed by reference func (c Config) Validate(errs *packersdk.MultiError) { ///////////////////////////////////////////// // Authentication via OAUTH diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index 3f372783c..5e3878411 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -191,7 +191,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { for _, t := range c.Tags { if !tagRe.MatchString(t) { - errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf("invalid tag: %s", t))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("invalid tag: %s", t)) } } diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index bdee0be10..d844ecb61 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -382,7 +382,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } if !validImageName.MatchString(c.ImageName) { - errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "name", c.ImageName))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(imageErrorText, "name", c.ImageName)) } if len(c.ImageFamily) > 63 { @@ -392,7 +392,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { if c.ImageFamily != "" { if !validImageName.MatchString(c.ImageFamily) { - errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "family", c.ImageFamily))) + errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(imageErrorText, "family", c.ImageFamily)) } } diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index a3e1a7f39..c38c895df 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -118,7 +118,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) commonErrs, commonWarns := b.config.CommonConfig.Prepare(&b.config.ctx, &b.config.PackerConfig) - packersdk.MultiErrorAppend(errs, commonErrs...) + errs = packersdk.MultiErrorAppend(errs, commonErrs...) warnings = append(warnings, commonWarns...) if len(b.config.ISOConfig.ISOUrls) < 1 || diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index cf09d2811..bf8084327 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -113,7 +113,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) commonErrs, commonWarns := b.config.CommonConfig.Prepare(&b.config.ctx, &b.config.PackerConfig) - packersdk.MultiErrorAppend(errs, commonErrs...) + errs = packersdk.MultiErrorAppend(errs, commonErrs...) warnings = append(warnings, commonWarns...) if b.config.Cpu < 1 { diff --git a/builder/oracle/classic/config.go b/builder/oracle/classic/config.go index 86b4bf177..d7a53916f 100644 --- a/builder/oracle/classic/config.go +++ b/builder/oracle/classic/config.go @@ -123,10 +123,6 @@ func (c *Config) Prepare(raws ...interface{}) error { errs = packersdk.MultiErrorAppend(errs, es...) } - if errs != nil && len(errs.Errors) > 0 { - return errs - } - // unpack attributes from json into config var data map[string]interface{} @@ -134,23 +130,26 @@ func (c *Config) Prepare(raws ...interface{}) error { err := json.Unmarshal([]byte(c.Attributes), &data) if err != nil { err = fmt.Errorf("Problem parsing json from attributes: %s", err) - packersdk.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } c.attribs = data } else if c.AttributesFile != "" { fidata, err := ioutil.ReadFile(c.AttributesFile) if err != nil { err = fmt.Errorf("Problem reading attributes_file: %s", err) - packersdk.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } err = json.Unmarshal(fidata, &data) c.attribs = data if err != nil { err = fmt.Errorf("Problem parsing json from attributes_file: %s", err) - packersdk.MultiErrorAppend(errs, err) + errs = packersdk.MultiErrorAppend(errs, err) } c.attribs = data } + if errs != nil && len(errs.Errors) > 0 { + return errs + } return nil } diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index b284e0600..b0343c979 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -149,16 +149,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { errs = packersdk.MultiErrorAppend(errs, b.config.CDConfig.Prepare(&b.config.ctx)...) errs = packersdk.MultiErrorAppend( errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.CommConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.HWConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.VBoxBundleConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.VBoxManageConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.VBoxVersionConfig.Prepare(b.config.CommConfig.Comm.Type)...) - errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) - errs = packer.MultiErrorAppend(errs, b.config.GuestAdditionsConfig.Prepare(b.config.CommConfig.Comm.Type)...) + errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.CommConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.HWConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.VBoxBundleConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.VBoxManageConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.VBoxVersionConfig.Prepare(b.config.CommConfig.Comm.Type)...) + errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...) + errs = packersdk.MultiErrorAppend(errs, b.config.GuestAdditionsConfig.Prepare(b.config.CommConfig.Comm.Type)...) if b.config.DiskSize == 0 { b.config.DiskSize = 40000 diff --git a/builder/virtualbox/ovf/config.go b/builder/virtualbox/ovf/config.go index 84894027f..c4bf0ebb9 100644 --- a/builder/virtualbox/ovf/config.go +++ b/builder/virtualbox/ovf/config.go @@ -7,7 +7,6 @@ import ( "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -108,20 +107,20 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // Prepare the errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, c.RunConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CommConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VBoxManageConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.CommConfig.Comm.Type)...) - errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.RunConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CommConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VBoxManageConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.CommConfig.Comm.Type)...) + errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...) if c.SourcePath == "" { errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required")) diff --git a/builder/virtualbox/vm/config.go b/builder/virtualbox/vm/config.go index f587b54d3..c41a4bc76 100644 --- a/builder/virtualbox/vm/config.go +++ b/builder/virtualbox/vm/config.go @@ -9,7 +9,6 @@ import ( "time" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -91,19 +90,19 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { } // Prepare the errors - var errs *packer.MultiError - errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) - errs = packer.MultiErrorAppend(errs, c.RunConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.CommConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VBoxManageConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.CommConfig.Comm.Type)...) - errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) - errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...) + var errs *packersdk.MultiError + errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...) + errs = packersdk.MultiErrorAppend(errs, c.RunConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.CommConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VBoxManageConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.CommConfig.Comm.Type)...) + errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) + errs = packersdk.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...) if c.GuestAdditionsInterface == "" { c.GuestAdditionsInterface = "ide" } diff --git a/packer-plugin-sdk/packer/ui.go b/packer-plugin-sdk/packer/ui.go index 894abfd44..7731d75f0 100644 --- a/packer-plugin-sdk/packer/ui.go +++ b/packer-plugin-sdk/packer/ui.go @@ -11,7 +11,7 @@ import ( "sync" "syscall" - "github.com/hashicorp/go-getter" + getter "github.com/hashicorp/go-getter" ) type TTY interface { diff --git a/packer/build_test.go b/packer/build_test.go index 12a70f138..ce680c9d5 100644 --- a/packer/build_test.go +++ b/packer/build_test.go @@ -256,7 +256,10 @@ func TestBuild_Run(t *testing.T) { } // Verify provisioners run - dispatchHook.Run(ctx, packersdk.HookProvision, nil, new(packersdk.MockCommunicator), 42) + err = dispatchHook.Run(ctx, packersdk.HookProvision, nil, new(packersdk.MockCommunicator), 42) + if err != nil { + t.Fatalf("should not have errored") + } prov := build.Provisioners[0].Provisioner.(*MockProvisioner) if !prov.ProvCalled { t.Fatal("should be called") diff --git a/packer/plugin/plugin_test.go b/packer/plugin/plugin_test.go index bb38a348a..ade34aac6 100644 --- a/packer/plugin/plugin_test.go +++ b/packer/plugin/plugin_test.go @@ -69,7 +69,11 @@ func TestHelperProcess(*testing.T) { log.Printf("[ERR] %s", err) os.Exit(1) } - server.RegisterHook(new(packersdk.MockHook)) + err = server.RegisterHook(new(packersdk.MockHook)) + if err != nil { + log.Printf("[ERR] %s", err) + os.Exit(1) + } server.Serve() case "invalid-rpc-address": fmt.Println("lolinvalid") diff --git a/packer/rpc/builder_test.go b/packer/rpc/builder_test.go index d57ca4411..eca0f9ea6 100644 --- a/packer/rpc/builder_test.go +++ b/packer/rpc/builder_test.go @@ -144,7 +144,10 @@ func TestBuilderCancel(t *testing.T) { server.RegisterBuilder(b) bClient := client.Builder() - bClient.Run(topCtx, new(testUi), new(packersdk.MockHook)) + _, err := bClient.Run(topCtx, new(testUi), new(packersdk.MockHook)) + if err != nil { + t.Fatalf("mock shouldnt retun run error for cancellation") + } if !cancelled { t.Fatal("context should have been cancelled") diff --git a/tty_solaris.go b/tty_solaris.go index 1dd63f044..4706e77d2 100644 --- a/tty_solaris.go +++ b/tty_solaris.go @@ -3,9 +3,9 @@ package main import ( "fmt" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -func openTTY() (packer.TTY, error) { +func openTTY() (packersdk.TTY, error) { return nil, fmt.Errorf("no TTY available on solaris") } diff --git a/vendor/github.com/hashicorp/go-getter/LICENSE b/vendor/github.com/hashicorp/go-getter/LICENSE new file mode 100644 index 000000000..c33dcc7c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/LICENSE @@ -0,0 +1,354 @@ +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/vendor/github.com/hashicorp/go-getter/README.md b/vendor/github.com/hashicorp/go-getter/README.md new file mode 100644 index 000000000..bbcd15de9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/README.md @@ -0,0 +1,362 @@ +# go-getter + +[![CircleCI](https://circleci.com/gh/hashicorp/go-getter/tree/master.svg?style=svg)][circleci] +[![Build status](https://ci.appveyor.com/api/projects/status/ulq3qr43n62croyq/branch/master?svg=true)][appveyor] +[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs] + +[circleci]: https://circleci.com/gh/hashicorp/go-getter/tree/master +[godocs]: http://godoc.org/github.com/hashicorp/go-getter +[appveyor]: https://ci.appveyor.com/project/hashicorp/go-getter/branch/master + +go-getter is a library for Go (golang) for downloading files or directories +from various sources using a URL as the primary form of input. + +The power of this library is being flexible in being able to download +from a number of different sources (file paths, Git, HTTP, Mercurial, etc.) +using a single string as input. This removes the burden of knowing how to +download from a variety of sources from the implementer. + +The concept of a _detector_ automatically turns invalid URLs into proper +URLs. For example: "github.com/hashicorp/go-getter" would turn into a +Git URL. Or "./foo" would turn into a file URL. These are extensible. + +This library is used by [Terraform](https://terraform.io) for +downloading modules and [Nomad](https://nomadproject.io) for downloading +binaries. + +## Installation and Usage + +Package documentation can be found on +[GoDoc](http://godoc.org/github.com/hashicorp/go-getter). + +Installation can be done with a normal `go get`: + +``` +$ go get github.com/hashicorp/go-getter +``` + +go-getter also has a command you can use to test URL strings: + +``` +$ go install github.com/hashicorp/go-getter/cmd/go-getter +... + +$ go-getter github.com/foo/bar ./foo +... +``` + +The command is useful for verifying URL structures. + +## URL Format + +go-getter uses a single string URL as input to download from a variety of +protocols. go-getter has various "tricks" with this URL to do certain things. +This section documents the URL format. + +### Supported Protocols and Detectors + +**Protocols** are used to download files/directories using a specific +mechanism. Example protocols are Git and HTTP. + +**Detectors** are used to transform a valid or invalid URL into another +URL if it matches a certain pattern. Example: "github.com/user/repo" is +automatically transformed into a fully valid Git URL. This allows go-getter +to be very user friendly. + +go-getter out of the box supports the following protocols. Additional protocols +can be augmented at runtime by implementing the `Getter` interface. + + * Local files + * Git + * Mercurial + * HTTP + * Amazon S3 + * Google GCP + +In addition to the above protocols, go-getter has what are called "detectors." +These take a URL and attempt to automatically choose the best protocol for +it, which might involve even changing the protocol. The following detection +is built-in by default: + + * File paths such as "./foo" are automatically changed to absolute + file URLs. + * GitHub URLs, such as "github.com/mitchellh/vagrant" are automatically + changed to Git protocol over HTTP. + * BitBucket URLs, such as "bitbucket.org/mitchellh/vagrant" are automatically + changed to a Git or mercurial protocol using the BitBucket API. + +### Forced Protocol + +In some cases, the protocol to use is ambiguous depending on the source +URL. For example, "http://github.com/mitchellh/vagrant.git" could reference +an HTTP URL or a Git URL. Forced protocol syntax is used to disambiguate this +URL. + +Forced protocol can be done by prefixing the URL with the protocol followed +by double colons. For example: `git::http://github.com/mitchellh/vagrant.git` +would download the given HTTP URL using the Git protocol. + +Forced protocols will also override any detectors. + +In the absence of a forced protocol, detectors may be run on the URL, transforming +the protocol anyways. The above example would've used the Git protocol either +way since the Git detector would've detected it was a GitHub URL. + +### Protocol-Specific Options + +Each protocol can support protocol-specific options to configure that +protocol. For example, the `git` protocol supports specifying a `ref` +query parameter that tells it what ref to checkout for that Git +repository. + +The options are specified as query parameters on the URL (or URL-like string) +given to go-getter. Using the Git example above, the URL below is a valid +input to go-getter: + + github.com/hashicorp/go-getter?ref=abcd1234 + +The protocol-specific options are documented below the URL format +section. But because they are part of the URL, we point it out here so +you know they exist. + +### Subdirectories + +If you want to download only a specific subdirectory from a downloaded +directory, you can specify a subdirectory after a double-slash `//`. +go-getter will first download the URL specified _before_ the double-slash +(as if you didn't specify a double-slash), but will then copy the +path after the double slash into the target directory. + +For example, if you're downloading this GitHub repository, but you only +want to download the `testdata` directory, you can do the following: + +``` +https://github.com/hashicorp/go-getter.git//testdata +``` + +If you downloaded this to the `/tmp` directory, then the file +`/tmp/archive.gz` would exist. Notice that this file is in the `testdata` +directory in this repository, but because we specified a subdirectory, +go-getter automatically copied only that directory contents. + +Subdirectory paths may contain may also use filesystem glob patterns. +The path must match _exactly one_ entry or go-getter will return an error. +This is useful if you're not sure the exact directory name but it follows +a predictable naming structure. + +For example, the following URL would also work: + +``` +https://github.com/hashicorp/go-getter.git//test-* +``` + +### Checksumming + +For file downloads of any protocol, go-getter can automatically verify +a checksum for you. Note that checksumming only works for downloading files, +not directories, but checksumming will work for any protocol. + +To checksum a file, append a `checksum` query parameter to the URL. go-getter +will parse out this query parameter automatically and use it to verify the +checksum. The parameter value can be in the format of `type:value` or just +`value`, where type is "md5", "sha1", "sha256", "sha512" or "file" . The +"value" should be the actual checksum value or download URL for "file". When +`type` part is omitted, type will be guessed based on the length of the +checksum string. Examples: + +``` +./foo.txt?checksum=md5:b7d96c89d09d9e204f5fedc4d5d55b21 +``` + +``` +./foo.txt?checksum=b7d96c89d09d9e204f5fedc4d5d55b21 +``` + +``` +./foo.txt?checksum=file:./foo.txt.sha256sum +``` + +When checksumming from a file - ex: with `checksum=file:url` - go-getter will +get the file linked in the URL after `file:` using the same configuration. For +example, in `file:http://releases.ubuntu.com/cosmic/MD5SUMS` go-getter will +download a checksum file under the aforementioned url using the http protocol. +All protocols supported by go-getter can be used. The checksum file will be +downloaded in a temporary file then parsed. The destination of the temporary +file can be changed by setting system specific environment variables: `TMPDIR` +for unix; `TMP`, `TEMP` or `USERPROFILE` on windows. Read godoc of +[os.TempDir](https://golang.org/pkg/os/#TempDir) for more information on the +temporary directory selection. Content of files are expected to be BSD or GNU +style. Once go-getter is done with the checksum file; it is deleted. + +The checksum query parameter is never sent to the backend protocol +implementation. It is used at a higher level by go-getter itself. + +If the destination file exists and the checksums match: download +will be skipped. + +### Unarchiving + +go-getter will automatically unarchive files into a file or directory +based on the extension of the file being requested (over any protocol). +This works for both file and directory downloads. + +go-getter looks for an `archive` query parameter to specify the format of +the archive. If this isn't specified, go-getter will use the extension of +the path to see if it appears archived. Unarchiving can be explicitly +disabled by setting the `archive` query parameter to `false`. + +The following archive formats are supported: + + * `tar.gz` and `tgz` + * `tar.bz2` and `tbz2` + * `tar.xz` and `txz` + * `zip` + * `gz` + * `bz2` + * `xz` + +For example, an example URL is shown below: + +``` +./foo.zip +``` + +This will automatically be inferred to be a ZIP file and will be extracted. +You can also be explicit about the archive type: + +``` +./some/other/path?archive=zip +``` + +And finally, you can disable archiving completely: + +``` +./some/path?archive=false +``` + +You can combine unarchiving with the other features of go-getter such +as checksumming. The special `archive` query parameter will be removed +from the URL before going to the final protocol downloader. + +## Protocol-Specific Options + +This section documents the protocol-specific options that can be specified for +go-getter. These options should be appended to the input as normal query +parameters ([HTTP headers](#headers) are an exception to this, however). +Depending on the usage of go-getter, applications may provide alternate ways of +inputting options. For example, [Nomad](https://www.nomadproject.io) provides a +nice options block for specifying options rather than in the URL. + +## General (All Protocols) + +The options below are available to all protocols: + + * `archive` - The archive format to use to unarchive this file, or "" (empty + string) to disable unarchiving. For more details, see the complete section + on archive support above. + + * `checksum` - Checksum to verify the downloaded file or archive. See + the entire section on checksumming above for format and more details. + + * `filename` - When in file download mode, allows specifying the name of the + downloaded file on disk. Has no effect in directory mode. + +### Local Files (`file`) + +None + +### Git (`git`) + + * `ref` - The Git ref to checkout. This is a ref, so it can point to + a commit SHA, a branch name, etc. If it is a named ref such as a branch + name, go-getter will update it to the latest on each get. + + * `sshkey` - An SSH private key to use during clones. The provided key must + be a base64-encoded string. For example, to generate a suitable `sshkey` + from a private key file on disk, you would run `base64 -w0 `. + + **Note**: Git 2.3+ is required to use this feature. + + * `depth` - The Git clone depth. The provided number specifies the last `n` + revisions to clone from the repository. + + +The `git` getter accepts both URL-style SSH addresses like +`git::ssh://git@example.com/foo/bar`, and "scp-style" addresses like +`git::git@example.com/foo/bar`. In the latter case, omitting the `git::` +force prefix is allowed if the username prefix is exactly `git@`. + +The "scp-style" addresses _cannot_ be used in conjunction with the `ssh://` +scheme prefix, because in that case the colon is used to mark an optional +port number to connect on, rather than to delimit the path from the host. + +### Mercurial (`hg`) + + * `rev` - The Mercurial revision to checkout. + +### HTTP (`http`) + +#### Basic Authentication + +To use HTTP basic authentication with go-getter, simply prepend `username:password@` to the +hostname in the URL such as `https://Aladdin:OpenSesame@www.example.com/index.html`. All special +characters, including the username and password, must be URL encoded. + +#### Headers + +Optional request headers can be added by supplying them in a custom +[`HttpGetter`](https://godoc.org/github.com/hashicorp/go-getter#HttpGetter) +(_not_ as query parameters like most other options). These headers will be sent +out on every request the getter in question makes. + +### S3 (`s3`) + +S3 takes various access configurations in the URL. Note that it will also +read these from standard AWS environment variables if they're set. S3 compliant servers like Minio +are also supported. If the query parameters are present, these take priority. + + * `aws_access_key_id` - AWS access key. + * `aws_access_key_secret` - AWS access key secret. + * `aws_access_token` - AWS access token if this is being used. + +#### Using IAM Instance Profiles with S3 + +If you use go-getter and want to use an EC2 IAM Instance Profile to avoid +using credentials, then just omit these and the profile, if available will +be used automatically. + +### Using S3 with Minio + If you use go-gitter for Minio support, you must consider the following: + + * `aws_access_key_id` (required) - Minio access key. + * `aws_access_key_secret` (required) - Minio access key secret. + * `region` (optional - defaults to us-east-1) - Region identifier to use. + * `version` (optional - defaults to Minio default) - Configuration file format. + +#### S3 Bucket Examples + +S3 has several addressing schemes used to reference your bucket. These are +listed here: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro + +Some examples for these addressing schemes: +- s3::https://s3.amazonaws.com/bucket/foo +- s3::https://s3-eu-west-1.amazonaws.com/bucket/foo +- bucket.s3.amazonaws.com/foo +- bucket.s3-eu-west-1.amazonaws.com/foo/bar +- "s3::http://127.0.0.1:9000/test-bucket/hello.txt?aws_access_key_id=KEYID&aws_access_key_secret=SECRETKEY®ion=us-east-2" + +### GCS (`gcs`) + +#### GCS Authentication + +In order to access to GCS, authentication credentials should be provided. More information can be found [here](https://cloud.google.com/docs/authentication/getting-started) + +#### GCS Bucket Examples + +- gcs::https://www.googleapis.com/storage/v1/bucket +- gcs::https://www.googleapis.com/storage/v1/bucket/foo.zip +- www.googleapis.com/storage/v1/bucket/foo + +#### GCS Testing + +The tests for `get_gcs.go` require you to have GCP credentials set in your environment. These credentials can have any level of permissions to any project, they just need to exist. This means setting `GOOGLE_APPLICATION_CREDENTIALS="~/path/to/credentials.json"` or `GOOGLE_CREDENTIALS="{stringified-credentials-json}"`. Due to this configuration, `get_gcs_test.go` will fail for external contributors in CircleCI. diff --git a/vendor/github.com/hashicorp/go-getter/appveyor.yml b/vendor/github.com/hashicorp/go-getter/appveyor.yml new file mode 100644 index 000000000..1e8718e17 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/appveyor.yml @@ -0,0 +1,16 @@ +version: "build-{branch}-{build}" +image: Visual Studio 2017 +clone_folder: c:\gopath\github.com\hashicorp\go-getter +environment: + GOPATH: c:\gopath +install: +- cmd: >- + echo %Path% + + go version + + go env + + go get -d -v -t ./... +build_script: +- cmd: go test ./... diff --git a/vendor/github.com/hashicorp/go-getter/checksum.go b/vendor/github.com/hashicorp/go-getter/checksum.go new file mode 100644 index 000000000..eeccfea9d --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/checksum.go @@ -0,0 +1,314 @@ +package getter + +import ( + "bufio" + "bytes" + "crypto/md5" + "crypto/sha1" + "crypto/sha256" + "crypto/sha512" + "encoding/hex" + "fmt" + "hash" + "io" + "net/url" + "os" + "path/filepath" + "strings" + + urlhelper "github.com/hashicorp/go-getter/helper/url" +) + +// FileChecksum helps verifying the checksum for a file. +type FileChecksum struct { + Type string + Hash hash.Hash + Value []byte + Filename string +} + +// A ChecksumError is returned when a checksum differs +type ChecksumError struct { + Hash hash.Hash + Actual []byte + Expected []byte + File string +} + +func (cerr *ChecksumError) Error() string { + if cerr == nil { + return "" + } + return fmt.Sprintf( + "Checksums did not match for %s.\nExpected: %s\nGot: %s\n%T", + cerr.File, + hex.EncodeToString(cerr.Expected), + hex.EncodeToString(cerr.Actual), + cerr.Hash, // ex: *sha256.digest + ) +} + +// checksum is a simple method to compute the checksum of a source file +// and compare it to the given expected value. +func (c *FileChecksum) checksum(source string) error { + f, err := os.Open(source) + if err != nil { + return fmt.Errorf("Failed to open file for checksum: %s", err) + } + defer f.Close() + + c.Hash.Reset() + if _, err := io.Copy(c.Hash, f); err != nil { + return fmt.Errorf("Failed to hash: %s", err) + } + + if actual := c.Hash.Sum(nil); !bytes.Equal(actual, c.Value) { + return &ChecksumError{ + Hash: c.Hash, + Actual: actual, + Expected: c.Value, + File: source, + } + } + + return nil +} + +// extractChecksum will return a FileChecksum based on the 'checksum' +// parameter of u. +// ex: +// http://hashicorp.com/terraform?checksum= +// http://hashicorp.com/terraform?checksum=: +// http://hashicorp.com/terraform?checksum=file: +// when checksumming from a file, extractChecksum will go get checksum_url +// in a temporary directory, parse the content of the file then delete it. +// Content of files are expected to be BSD style or GNU style. +// +// BSD-style checksum: +// MD5 (file1) = +// MD5 (file2) = +// +// GNU-style: +// file1 +// *file2 +// +// see parseChecksumLine for more detail on checksum file parsing +func (c *Client) extractChecksum(u *url.URL) (*FileChecksum, error) { + q := u.Query() + v := q.Get("checksum") + + if v == "" { + return nil, nil + } + + vs := strings.SplitN(v, ":", 2) + switch len(vs) { + case 2: + break // good + default: + // here, we try to guess the checksum from it's length + // if the type was not passed + return newChecksumFromValue(v, filepath.Base(u.EscapedPath())) + } + + checksumType, checksumValue := vs[0], vs[1] + + switch checksumType { + case "file": + return c.ChecksumFromFile(checksumValue, u) + default: + return newChecksumFromType(checksumType, checksumValue, filepath.Base(u.EscapedPath())) + } +} + +func newChecksum(checksumValue, filename string) (*FileChecksum, error) { + c := &FileChecksum{ + Filename: filename, + } + var err error + c.Value, err = hex.DecodeString(checksumValue) + if err != nil { + return nil, fmt.Errorf("invalid checksum: %s", err) + } + return c, nil +} + +func newChecksumFromType(checksumType, checksumValue, filename string) (*FileChecksum, error) { + c, err := newChecksum(checksumValue, filename) + if err != nil { + return nil, err + } + + c.Type = strings.ToLower(checksumType) + switch c.Type { + case "md5": + c.Hash = md5.New() + case "sha1": + c.Hash = sha1.New() + case "sha256": + c.Hash = sha256.New() + case "sha512": + c.Hash = sha512.New() + default: + return nil, fmt.Errorf( + "unsupported checksum type: %s", checksumType) + } + + return c, nil +} + +func newChecksumFromValue(checksumValue, filename string) (*FileChecksum, error) { + c, err := newChecksum(checksumValue, filename) + if err != nil { + return nil, err + } + + switch len(c.Value) { + case md5.Size: + c.Hash = md5.New() + c.Type = "md5" + case sha1.Size: + c.Hash = sha1.New() + c.Type = "sha1" + case sha256.Size: + c.Hash = sha256.New() + c.Type = "sha256" + case sha512.Size: + c.Hash = sha512.New() + c.Type = "sha512" + default: + return nil, fmt.Errorf("Unknown type for checksum %s", checksumValue) + } + + return c, nil +} + +// ChecksumFromFile will return all the FileChecksums found in file +// +// ChecksumFromFile will try to guess the hashing algorithm based on content +// of checksum file +// +// ChecksumFromFile will only return checksums for files that match file +// behind src +func (c *Client) ChecksumFromFile(checksumFile string, src *url.URL) (*FileChecksum, error) { + checksumFileURL, err := urlhelper.Parse(checksumFile) + if err != nil { + return nil, err + } + + tempfile, err := tmpFile("", filepath.Base(checksumFileURL.Path)) + if err != nil { + return nil, err + } + defer os.Remove(tempfile) + + c2 := &Client{ + Ctx: c.Ctx, + Getters: c.Getters, + Decompressors: c.Decompressors, + Detectors: c.Detectors, + Pwd: c.Pwd, + Dir: false, + Src: checksumFile, + Dst: tempfile, + ProgressListener: c.ProgressListener, + } + if err = c2.Get(); err != nil { + return nil, fmt.Errorf( + "Error downloading checksum file: %s", err) + } + + filename := filepath.Base(src.Path) + absPath, err := filepath.Abs(src.Path) + if err != nil { + return nil, err + } + checksumFileDir := filepath.Dir(checksumFileURL.Path) + relpath, err := filepath.Rel(checksumFileDir, absPath) + switch { + case err == nil || + err.Error() == "Rel: can't make "+absPath+" relative to "+checksumFileDir: + // ex: on windows C:\gopath\...\content.txt cannot be relative to \ + // which is okay, may be another expected path will work. + break + default: + return nil, err + } + + // possible file identifiers: + options := []string{ + filename, // ubuntu-14.04.1-server-amd64.iso + "*" + filename, // *ubuntu-14.04.1-server-amd64.iso Standard checksum + "?" + filename, // ?ubuntu-14.04.1-server-amd64.iso shasum -p + relpath, // dir/ubuntu-14.04.1-server-amd64.iso + "./" + relpath, // ./dir/ubuntu-14.04.1-server-amd64.iso + absPath, // fullpath; set if local + } + + f, err := os.Open(tempfile) + if err != nil { + return nil, fmt.Errorf( + "Error opening downloaded file: %s", err) + } + defer f.Close() + rd := bufio.NewReader(f) + for { + line, err := rd.ReadString('\n') + if err != nil { + if err != io.EOF { + return nil, fmt.Errorf( + "Error reading checksum file: %s", err) + } + break + } + checksum, err := parseChecksumLine(line) + if err != nil || checksum == nil { + continue + } + if checksum.Filename == "" { + // filename not sure, let's try + return checksum, nil + } + // make sure the checksum is for the right file + for _, option := range options { + if option != "" && checksum.Filename == option { + // any checksum will work so we return the first one + return checksum, nil + } + } + } + return nil, fmt.Errorf("no checksum found in: %s", checksumFile) +} + +// parseChecksumLine takes a line from a checksum file and returns +// checksumType, checksumValue and filename parseChecksumLine guesses the style +// of the checksum BSD vs GNU by splitting the line and by counting the parts. +// of a line. +// for BSD type sums parseChecksumLine guesses the hashing algorithm +// by checking the length of the checksum. +func parseChecksumLine(line string) (*FileChecksum, error) { + parts := strings.Fields(line) + + switch len(parts) { + case 4: + // BSD-style checksum: + // MD5 (file1) = + // MD5 (file2) = + if len(parts[1]) <= 2 || + parts[1][0] != '(' || parts[1][len(parts[1])-1] != ')' { + return nil, fmt.Errorf( + "Unexpected BSD-style-checksum filename format: %s", line) + } + filename := parts[1][1 : len(parts[1])-1] + return newChecksumFromType(parts[0], parts[3], filename) + case 2: + // GNU-style: + // file1 + // *file2 + return newChecksumFromValue(parts[0], parts[1]) + case 0: + return nil, nil // empty line + default: + return newChecksumFromValue(parts[0], "") + } +} diff --git a/vendor/github.com/hashicorp/go-getter/client.go b/vendor/github.com/hashicorp/go-getter/client.go new file mode 100644 index 000000000..38fb43b8f --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/client.go @@ -0,0 +1,298 @@ +package getter + +import ( + "context" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strconv" + "strings" + + urlhelper "github.com/hashicorp/go-getter/helper/url" + safetemp "github.com/hashicorp/go-safetemp" +) + +// Client is a client for downloading things. +// +// Top-level functions such as Get are shortcuts for interacting with a client. +// Using a client directly allows more fine-grained control over how downloading +// is done, as well as customizing the protocols supported. +type Client struct { + // Ctx for cancellation + Ctx context.Context + + // Src is the source URL to get. + // + // Dst is the path to save the downloaded thing as. If Dir is set to + // true, then this should be a directory. If the directory doesn't exist, + // it will be created for you. + // + // Pwd is the working directory for detection. If this isn't set, some + // detection may fail. Client will not default pwd to the current + // working directory for security reasons. + Src string + Dst string + Pwd string + + // Mode is the method of download the client will use. See ClientMode + // for documentation. + Mode ClientMode + + // Detectors is the list of detectors that are tried on the source. + // If this is nil, then the default Detectors will be used. + Detectors []Detector + + // Decompressors is the map of decompressors supported by this client. + // If this is nil, then the default value is the Decompressors global. + Decompressors map[string]Decompressor + + // Getters is the map of protocols supported by this client. If this + // is nil, then the default Getters variable will be used. + Getters map[string]Getter + + // Dir, if true, tells the Client it is downloading a directory (versus + // a single file). This distinction is necessary since filenames and + // directory names follow the same format so disambiguating is impossible + // without knowing ahead of time. + // + // WARNING: deprecated. If Mode is set, that will take precedence. + Dir bool + + // ProgressListener allows to track file downloads. + // By default a no op progress listener is used. + ProgressListener ProgressTracker + + Options []ClientOption +} + +// Get downloads the configured source to the destination. +func (c *Client) Get() error { + if err := c.Configure(c.Options...); err != nil { + return err + } + + // Store this locally since there are cases we swap this + mode := c.Mode + if mode == ClientModeInvalid { + if c.Dir { + mode = ClientModeDir + } else { + mode = ClientModeFile + } + } + + src, err := Detect(c.Src, c.Pwd, c.Detectors) + if err != nil { + return err + } + + // Determine if we have a forced protocol, i.e. "git::http://..." + force, src := getForcedGetter(src) + + // If there is a subdir component, then we download the root separately + // and then copy over the proper subdir. + var realDst string + dst := c.Dst + src, subDir := SourceDirSubdir(src) + if subDir != "" { + td, tdcloser, err := safetemp.Dir("", "getter") + if err != nil { + return err + } + defer tdcloser.Close() + + realDst = dst + dst = td + } + + u, err := urlhelper.Parse(src) + if err != nil { + return err + } + if force == "" { + force = u.Scheme + } + + g, ok := c.Getters[force] + if !ok { + return fmt.Errorf( + "download not supported for scheme '%s'", force) + } + + // We have magic query parameters that we use to signal different features + q := u.Query() + + // Determine if we have an archive type + archiveV := q.Get("archive") + if archiveV != "" { + // Delete the paramter since it is a magic parameter we don't + // want to pass on to the Getter + q.Del("archive") + u.RawQuery = q.Encode() + + // If we can parse the value as a bool and it is false, then + // set the archive to "-" which should never map to a decompressor + if b, err := strconv.ParseBool(archiveV); err == nil && !b { + archiveV = "-" + } + } + if archiveV == "" { + // We don't appear to... but is it part of the filename? + matchingLen := 0 + for k := range c.Decompressors { + if strings.HasSuffix(u.Path, "."+k) && len(k) > matchingLen { + archiveV = k + matchingLen = len(k) + } + } + } + + // If we have a decompressor, then we need to change the destination + // to download to a temporary path. We unarchive this into the final, + // real path. + var decompressDst string + var decompressDir bool + decompressor := c.Decompressors[archiveV] + if decompressor != nil { + // Create a temporary directory to store our archive. We delete + // this at the end of everything. + td, err := ioutil.TempDir("", "getter") + if err != nil { + return fmt.Errorf( + "Error creating temporary directory for archive: %s", err) + } + defer os.RemoveAll(td) + + // Swap the download directory to be our temporary path and + // store the old values. + decompressDst = dst + decompressDir = mode != ClientModeFile + dst = filepath.Join(td, "archive") + mode = ClientModeFile + } + + // Determine checksum if we have one + checksum, err := c.extractChecksum(u) + if err != nil { + return fmt.Errorf("invalid checksum: %s", err) + } + + // Delete the query parameter if we have it. + q.Del("checksum") + u.RawQuery = q.Encode() + + if mode == ClientModeAny { + // Ask the getter which client mode to use + mode, err = g.ClientMode(u) + if err != nil { + return err + } + + // Destination is the base name of the URL path in "any" mode when + // a file source is detected. + if mode == ClientModeFile { + filename := filepath.Base(u.Path) + + // Determine if we have a custom file name + if v := q.Get("filename"); v != "" { + // Delete the query parameter if we have it. + q.Del("filename") + u.RawQuery = q.Encode() + + filename = v + } + + dst = filepath.Join(dst, filename) + } + } + + // If we're not downloading a directory, then just download the file + // and return. + if mode == ClientModeFile { + getFile := true + if checksum != nil { + if err := checksum.checksum(dst); err == nil { + // don't get the file if the checksum of dst is correct + getFile = false + } + } + if getFile { + err := g.GetFile(dst, u) + if err != nil { + return err + } + + if checksum != nil { + if err := checksum.checksum(dst); err != nil { + return err + } + } + } + + if decompressor != nil { + // We have a decompressor, so decompress the current destination + // into the final destination with the proper mode. + err := decompressor.Decompress(decompressDst, dst, decompressDir) + if err != nil { + return err + } + + // Swap the information back + dst = decompressDst + if decompressDir { + mode = ClientModeAny + } else { + mode = ClientModeFile + } + } + + // We check the dir value again because it can be switched back + // if we were unarchiving. If we're still only Get-ing a file, then + // we're done. + if mode == ClientModeFile { + return nil + } + } + + // If we're at this point we're either downloading a directory or we've + // downloaded and unarchived a directory and we're just checking subdir. + // In the case we have a decompressor we don't Get because it was Get + // above. + if decompressor == nil { + // If we're getting a directory, then this is an error. You cannot + // checksum a directory. TODO: test + if checksum != nil { + return fmt.Errorf( + "checksum cannot be specified for directory download") + } + + // We're downloading a directory, which might require a bit more work + // if we're specifying a subdir. + err := g.Get(dst, u) + if err != nil { + err = fmt.Errorf("error downloading '%s': %s", src, err) + return err + } + } + + // If we have a subdir, copy that over + if subDir != "" { + if err := os.RemoveAll(realDst); err != nil { + return err + } + if err := os.MkdirAll(realDst, 0755); err != nil { + return err + } + + // Process any globs + subDir, err := SubdirGlob(dst, subDir) + if err != nil { + return err + } + + return copyDir(c.Ctx, realDst, subDir, false) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-getter/client_mode.go b/vendor/github.com/hashicorp/go-getter/client_mode.go new file mode 100644 index 000000000..7f02509a7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/client_mode.go @@ -0,0 +1,24 @@ +package getter + +// ClientMode is the mode that the client operates in. +type ClientMode uint + +const ( + ClientModeInvalid ClientMode = iota + + // ClientModeAny downloads anything it can. In this mode, dst must + // be a directory. If src is a file, it is saved into the directory + // with the basename of the URL. If src is a directory or archive, + // it is unpacked directly into dst. + ClientModeAny + + // ClientModeFile downloads a single file. In this mode, dst must + // be a file path (doesn't have to exist). src must point to a single + // file. It is saved as dst. + ClientModeFile + + // ClientModeDir downloads a directory. In this mode, dst must be + // a directory path (doesn't have to exist). src must point to an + // archive or directory (such as in s3). + ClientModeDir +) diff --git a/vendor/github.com/hashicorp/go-getter/client_option.go b/vendor/github.com/hashicorp/go-getter/client_option.go new file mode 100644 index 000000000..c1ee413b0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/client_option.go @@ -0,0 +1,46 @@ +package getter + +import "context" + +// A ClientOption allows to configure a client +type ClientOption func(*Client) error + +// Configure configures a client with options. +func (c *Client) Configure(opts ...ClientOption) error { + if c.Ctx == nil { + c.Ctx = context.Background() + } + c.Options = opts + for _, opt := range opts { + err := opt(c) + if err != nil { + return err + } + } + // Default decompressor values + if c.Decompressors == nil { + c.Decompressors = Decompressors + } + // Default detector values + if c.Detectors == nil { + c.Detectors = Detectors + } + // Default getter values + if c.Getters == nil { + c.Getters = Getters + } + + for _, getter := range c.Getters { + getter.SetClient(c) + } + return nil +} + +// WithContext allows to pass a context to operation +// in order to be able to cancel a download in progress. +func WithContext(ctx context.Context) func(*Client) error { + return func(c *Client) error { + c.Ctx = ctx + return nil + } +} diff --git a/vendor/github.com/hashicorp/go-getter/client_option_progress.go b/vendor/github.com/hashicorp/go-getter/client_option_progress.go new file mode 100644 index 000000000..9b185f71d --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/client_option_progress.go @@ -0,0 +1,38 @@ +package getter + +import ( + "io" +) + +// WithProgress allows for a user to track +// the progress of a download. +// For example by displaying a progress bar with +// current download. +// Not all getters have progress support yet. +func WithProgress(pl ProgressTracker) func(*Client) error { + return func(c *Client) error { + c.ProgressListener = pl + return nil + } +} + +// ProgressTracker allows to track the progress of downloads. +type ProgressTracker interface { + // TrackProgress should be called when + // a new object is being downloaded. + // src is the location the file is + // downloaded from. + // currentSize is the current size of + // the file in case it is a partial + // download. + // totalSize is the total size in bytes, + // size can be zero if the file size + // is not known. + // stream is the file being downloaded, every + // written byte will add up to processed size. + // + // TrackProgress returns a ReadCloser that wraps the + // download in progress ( stream ). + // When the download is finished, body shall be closed. + TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) +} diff --git a/vendor/github.com/hashicorp/go-getter/common.go b/vendor/github.com/hashicorp/go-getter/common.go new file mode 100644 index 000000000..d2afd8ad8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/common.go @@ -0,0 +1,14 @@ +package getter + +import ( + "io/ioutil" +) + +func tmpFile(dir, pattern string) (string, error) { + f, err := ioutil.TempFile(dir, pattern) + if err != nil { + return "", err + } + f.Close() + return f.Name(), nil +} diff --git a/vendor/github.com/hashicorp/go-getter/copy_dir.go b/vendor/github.com/hashicorp/go-getter/copy_dir.go new file mode 100644 index 000000000..641fe6d0f --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/copy_dir.go @@ -0,0 +1,78 @@ +package getter + +import ( + "context" + "os" + "path/filepath" + "strings" +) + +// copyDir copies the src directory contents into dst. Both directories +// should already exist. +// +// If ignoreDot is set to true, then dot-prefixed files/folders are ignored. +func copyDir(ctx context.Context, dst string, src string, ignoreDot bool) error { + src, err := filepath.EvalSymlinks(src) + if err != nil { + return err + } + + walkFn := func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if path == src { + return nil + } + + if ignoreDot && strings.HasPrefix(filepath.Base(path), ".") { + // Skip any dot files + if info.IsDir() { + return filepath.SkipDir + } else { + return nil + } + } + + // The "path" has the src prefixed to it. We need to join our + // destination with the path without the src on it. + dstPath := filepath.Join(dst, path[len(src):]) + + // If we have a directory, make that subdirectory, then continue + // the walk. + if info.IsDir() { + if path == filepath.Join(src, dst) { + // dst is in src; don't walk it. + return nil + } + + if err := os.MkdirAll(dstPath, 0755); err != nil { + return err + } + + return nil + } + + // If we have a file, copy the contents. + srcF, err := os.Open(path) + if err != nil { + return err + } + defer srcF.Close() + + dstF, err := os.Create(dstPath) + if err != nil { + return err + } + defer dstF.Close() + + if _, err := Copy(ctx, dstF, srcF); err != nil { + return err + } + + // Chmod it + return os.Chmod(dstPath, info.Mode()) + } + + return filepath.Walk(src, walkFn) +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress.go b/vendor/github.com/hashicorp/go-getter/decompress.go new file mode 100644 index 000000000..198bb0edd --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress.go @@ -0,0 +1,58 @@ +package getter + +import ( + "strings" +) + +// Decompressor defines the interface that must be implemented to add +// support for decompressing a type. +// +// Important: if you're implementing a decompressor, please use the +// containsDotDot helper in this file to ensure that files can't be +// decompressed outside of the specified directory. +type Decompressor interface { + // Decompress should decompress src to dst. dir specifies whether dst + // is a directory or single file. src is guaranteed to be a single file + // that exists. dst is not guaranteed to exist already. + Decompress(dst, src string, dir bool) error +} + +// Decompressors is the mapping of extension to the Decompressor implementation +// that will decompress that extension/type. +var Decompressors map[string]Decompressor + +func init() { + tbzDecompressor := new(TarBzip2Decompressor) + tgzDecompressor := new(TarGzipDecompressor) + txzDecompressor := new(TarXzDecompressor) + + Decompressors = map[string]Decompressor{ + "bz2": new(Bzip2Decompressor), + "gz": new(GzipDecompressor), + "xz": new(XzDecompressor), + "tar.bz2": tbzDecompressor, + "tar.gz": tgzDecompressor, + "tar.xz": txzDecompressor, + "tbz2": tbzDecompressor, + "tgz": tgzDecompressor, + "txz": txzDecompressor, + "zip": new(ZipDecompressor), + } +} + +// containsDotDot checks if the filepath value v contains a ".." entry. +// This will check filepath components by splitting along / or \. This +// function is copied directly from the Go net/http implementation. +func containsDotDot(v string) bool { + if !strings.Contains(v, "..") { + return false + } + for _, ent := range strings.FieldsFunc(v, isSlashRune) { + if ent == ".." { + return true + } + } + return false +} + +func isSlashRune(r rune) bool { return r == '/' || r == '\\' } diff --git a/vendor/github.com/hashicorp/go-getter/decompress_bzip2.go b/vendor/github.com/hashicorp/go-getter/decompress_bzip2.go new file mode 100644 index 000000000..339f4cf7a --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_bzip2.go @@ -0,0 +1,45 @@ +package getter + +import ( + "compress/bzip2" + "fmt" + "io" + "os" + "path/filepath" +) + +// Bzip2Decompressor is an implementation of Decompressor that can +// decompress bz2 files. +type Bzip2Decompressor struct{} + +func (d *Bzip2Decompressor) Decompress(dst, src string, dir bool) error { + // Directory isn't supported at all + if dir { + return fmt.Errorf("bzip2-compressed files can only unarchive to a single file") + } + + // If we're going into a directory we should make that first + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + // Bzip2 compression is second + bzipR := bzip2.NewReader(f) + + // Copy it out + dstF, err := os.Create(dst) + if err != nil { + return err + } + defer dstF.Close() + + _, err = io.Copy(dstF, bzipR) + return err +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_gzip.go b/vendor/github.com/hashicorp/go-getter/decompress_gzip.go new file mode 100644 index 000000000..5ebf709b4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_gzip.go @@ -0,0 +1,49 @@ +package getter + +import ( + "compress/gzip" + "fmt" + "io" + "os" + "path/filepath" +) + +// GzipDecompressor is an implementation of Decompressor that can +// decompress gzip files. +type GzipDecompressor struct{} + +func (d *GzipDecompressor) Decompress(dst, src string, dir bool) error { + // Directory isn't supported at all + if dir { + return fmt.Errorf("gzip-compressed files can only unarchive to a single file") + } + + // If we're going into a directory we should make that first + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + // gzip compression is second + gzipR, err := gzip.NewReader(f) + if err != nil { + return err + } + defer gzipR.Close() + + // Copy it out + dstF, err := os.Create(dst) + if err != nil { + return err + } + defer dstF.Close() + + _, err = io.Copy(dstF, gzipR) + return err +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_tar.go b/vendor/github.com/hashicorp/go-getter/decompress_tar.go new file mode 100644 index 000000000..b6986a25a --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_tar.go @@ -0,0 +1,160 @@ +package getter + +import ( + "archive/tar" + "fmt" + "io" + "os" + "path/filepath" + "time" +) + +// untar is a shared helper for untarring an archive. The reader should provide +// an uncompressed view of the tar archive. +func untar(input io.Reader, dst, src string, dir bool) error { + tarR := tar.NewReader(input) + done := false + dirHdrs := []*tar.Header{} + now := time.Now() + for { + hdr, err := tarR.Next() + if err == io.EOF { + if !done { + // Empty archive + return fmt.Errorf("empty archive: %s", src) + } + + break + } + if err != nil { + return err + } + + if hdr.Typeflag == tar.TypeXGlobalHeader || hdr.Typeflag == tar.TypeXHeader { + // don't unpack extended headers as files + continue + } + + path := dst + if dir { + // Disallow parent traversal + if containsDotDot(hdr.Name) { + return fmt.Errorf("entry contains '..': %s", hdr.Name) + } + + path = filepath.Join(path, hdr.Name) + } + + if hdr.FileInfo().IsDir() { + if !dir { + return fmt.Errorf("expected a single file: %s", src) + } + + // A directory, just make the directory and continue unarchiving... + if err := os.MkdirAll(path, 0755); err != nil { + return err + } + + // Record the directory information so that we may set its attributes + // after all files have been extracted + dirHdrs = append(dirHdrs, hdr) + + continue + } else { + // There is no ordering guarantee that a file in a directory is + // listed before the directory + dstPath := filepath.Dir(path) + + // Check that the directory exists, otherwise create it + if _, err := os.Stat(dstPath); os.IsNotExist(err) { + if err := os.MkdirAll(dstPath, 0755); err != nil { + return err + } + } + } + + // We have a file. If we already decoded, then it is an error + if !dir && done { + return fmt.Errorf("expected a single file, got multiple: %s", src) + } + + // Mark that we're done so future in single file mode errors + done = true + + // Open the file for writing + dstF, err := os.Create(path) + if err != nil { + return err + } + _, err = io.Copy(dstF, tarR) + dstF.Close() + if err != nil { + return err + } + + // Chmod the file + if err := os.Chmod(path, hdr.FileInfo().Mode()); err != nil { + return err + } + + // Set the access and modification time if valid, otherwise default to current time + aTime := now + mTime := now + if hdr.AccessTime.Unix() > 0 { + aTime = hdr.AccessTime + } + if hdr.ModTime.Unix() > 0 { + mTime = hdr.ModTime + } + if err := os.Chtimes(path, aTime, mTime); err != nil { + return err + } + } + + // Perform a final pass over extracted directories to update metadata + for _, dirHdr := range dirHdrs { + path := filepath.Join(dst, dirHdr.Name) + // Chmod the directory since they might be created before we know the mode flags + if err := os.Chmod(path, dirHdr.FileInfo().Mode()); err != nil { + return err + } + // Set the mtime/atime attributes since they would have been changed during extraction + aTime := now + mTime := now + if dirHdr.AccessTime.Unix() > 0 { + aTime = dirHdr.AccessTime + } + if dirHdr.ModTime.Unix() > 0 { + mTime = dirHdr.ModTime + } + if err := os.Chtimes(path, aTime, mTime); err != nil { + return err + } + } + + return nil +} + +// tarDecompressor is an implementation of Decompressor that can +// unpack tar files. +type tarDecompressor struct{} + +func (d *tarDecompressor) Decompress(dst, src string, dir bool) error { + // If we're going into a directory we should make that first + mkdir := dst + if !dir { + mkdir = filepath.Dir(dst) + } + if err := os.MkdirAll(mkdir, 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + return untar(f, dst, src, dir) +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_tbz2.go b/vendor/github.com/hashicorp/go-getter/decompress_tbz2.go new file mode 100644 index 000000000..5391b5c8c --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_tbz2.go @@ -0,0 +1,33 @@ +package getter + +import ( + "compress/bzip2" + "os" + "path/filepath" +) + +// TarBzip2Decompressor is an implementation of Decompressor that can +// decompress tar.bz2 files. +type TarBzip2Decompressor struct{} + +func (d *TarBzip2Decompressor) Decompress(dst, src string, dir bool) error { + // If we're going into a directory we should make that first + mkdir := dst + if !dir { + mkdir = filepath.Dir(dst) + } + if err := os.MkdirAll(mkdir, 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + // Bzip2 compression is second + bzipR := bzip2.NewReader(f) + return untar(bzipR, dst, src, dir) +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_testing.go b/vendor/github.com/hashicorp/go-getter/decompress_testing.go new file mode 100644 index 000000000..b2f662a89 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_testing.go @@ -0,0 +1,171 @@ +package getter + +import ( + "crypto/md5" + "encoding/hex" + "io" + "io/ioutil" + "os" + "path/filepath" + "reflect" + "runtime" + "sort" + "strings" + "time" + + "github.com/mitchellh/go-testing-interface" +) + +// TestDecompressCase is a single test case for testing decompressors +type TestDecompressCase struct { + Input string // Input is the complete path to the input file + Dir bool // Dir is whether or not we're testing directory mode + Err bool // Err is whether we expect an error or not + DirList []string // DirList is the list of files for Dir mode + FileMD5 string // FileMD5 is the expected MD5 for a single file + Mtime *time.Time // Mtime is the optionally expected mtime for a single file (or all files if in Dir mode) +} + +// TestDecompressor is a helper function for testing generic decompressors. +func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) { + t.Helper() + + for _, tc := range cases { + t.Logf("Testing: %s", tc.Input) + + // Temporary dir to store stuff + td, err := ioutil.TempDir("", "getter") + if err != nil { + t.Fatalf("err: %s", err) + } + + // Destination is always joining result so that we have a new path + dst := filepath.Join(td, "subdir", "result") + + // We use a function so defers work + func() { + defer os.RemoveAll(td) + + // Decompress + err := d.Decompress(dst, tc.Input, tc.Dir) + if (err != nil) != tc.Err { + t.Fatalf("err %s: %s", tc.Input, err) + } + if tc.Err { + return + } + + // If it isn't a directory, then check for a single file + if !tc.Dir { + fi, err := os.Stat(dst) + if err != nil { + t.Fatalf("err %s: %s", tc.Input, err) + } + if fi.IsDir() { + t.Fatalf("err %s: expected file, got directory", tc.Input) + } + if tc.FileMD5 != "" { + actual := testMD5(t, dst) + expected := tc.FileMD5 + if actual != expected { + t.Fatalf("err %s: expected MD5 %s, got %s", tc.Input, expected, actual) + } + } + + if tc.Mtime != nil { + actual := fi.ModTime() + if tc.Mtime.Unix() > 0 { + expected := *tc.Mtime + if actual != expected { + t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), dst, actual.String()) + } + } else if actual.Unix() <= 0 { + t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String()) + } + } + + return + } + + // Convert expected for windows + expected := tc.DirList + if runtime.GOOS == "windows" { + for i, v := range expected { + expected[i] = strings.Replace(v, "/", "\\", -1) + } + } + + // Directory, check for the correct contents + actual := testListDir(t, dst) + if !reflect.DeepEqual(actual, expected) { + t.Fatalf("bad %s\n\n%#v\n\n%#v", tc.Input, actual, expected) + } + // Check for correct atime/mtime + for _, dir := range actual { + path := filepath.Join(dst, dir) + if tc.Mtime != nil { + fi, err := os.Stat(path) + if err != nil { + t.Fatalf("err: %s", err) + } + actual := fi.ModTime() + if tc.Mtime.Unix() > 0 { + expected := *tc.Mtime + if actual != expected { + t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), path, actual.String()) + } + } else if actual.Unix() < 0 { + t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String()) + } + + } + } + }() + } +} + +func testListDir(t testing.T, path string) []string { + var result []string + err := filepath.Walk(path, func(sub string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + sub = strings.TrimPrefix(sub, path) + if sub == "" { + return nil + } + sub = sub[1:] // Trim the leading path sep. + + // If it is a dir, add trailing sep + if info.IsDir() { + sub += string(os.PathSeparator) + } + + result = append(result, sub) + return nil + }) + if err != nil { + t.Fatalf("err: %s", err) + } + + sort.Strings(result) + return result +} + +func testMD5(t testing.T, path string) string { + f, err := os.Open(path) + if err != nil { + t.Fatalf("err: %s", err) + } + defer f.Close() + + h := md5.New() + _, err = io.Copy(h, f) + if err != nil { + t.Fatalf("err: %s", err) + } + + result := h.Sum(nil) + return hex.EncodeToString(result) +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_tgz.go b/vendor/github.com/hashicorp/go-getter/decompress_tgz.go new file mode 100644 index 000000000..65eb70dd2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_tgz.go @@ -0,0 +1,39 @@ +package getter + +import ( + "compress/gzip" + "fmt" + "os" + "path/filepath" +) + +// TarGzipDecompressor is an implementation of Decompressor that can +// decompress tar.gzip files. +type TarGzipDecompressor struct{} + +func (d *TarGzipDecompressor) Decompress(dst, src string, dir bool) error { + // If we're going into a directory we should make that first + mkdir := dst + if !dir { + mkdir = filepath.Dir(dst) + } + if err := os.MkdirAll(mkdir, 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + // Gzip compression is second + gzipR, err := gzip.NewReader(f) + if err != nil { + return fmt.Errorf("Error opening a gzip reader for %s: %s", src, err) + } + defer gzipR.Close() + + return untar(gzipR, dst, src, dir) +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_txz.go b/vendor/github.com/hashicorp/go-getter/decompress_txz.go new file mode 100644 index 000000000..5e151c127 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_txz.go @@ -0,0 +1,39 @@ +package getter + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/ulikunitz/xz" +) + +// TarXzDecompressor is an implementation of Decompressor that can +// decompress tar.xz files. +type TarXzDecompressor struct{} + +func (d *TarXzDecompressor) Decompress(dst, src string, dir bool) error { + // If we're going into a directory we should make that first + mkdir := dst + if !dir { + mkdir = filepath.Dir(dst) + } + if err := os.MkdirAll(mkdir, 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + // xz compression is second + txzR, err := xz.NewReader(f) + if err != nil { + return fmt.Errorf("Error opening an xz reader for %s: %s", src, err) + } + + return untar(txzR, dst, src, dir) +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_xz.go b/vendor/github.com/hashicorp/go-getter/decompress_xz.go new file mode 100644 index 000000000..4e37abab1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_xz.go @@ -0,0 +1,49 @@ +package getter + +import ( + "fmt" + "io" + "os" + "path/filepath" + + "github.com/ulikunitz/xz" +) + +// XzDecompressor is an implementation of Decompressor that can +// decompress xz files. +type XzDecompressor struct{} + +func (d *XzDecompressor) Decompress(dst, src string, dir bool) error { + // Directory isn't supported at all + if dir { + return fmt.Errorf("xz-compressed files can only unarchive to a single file") + } + + // If we're going into a directory we should make that first + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + // File first + f, err := os.Open(src) + if err != nil { + return err + } + defer f.Close() + + // xz compression is second + xzR, err := xz.NewReader(f) + if err != nil { + return err + } + + // Copy it out + dstF, err := os.Create(dst) + if err != nil { + return err + } + defer dstF.Close() + + _, err = io.Copy(dstF, xzR) + return err +} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_zip.go b/vendor/github.com/hashicorp/go-getter/decompress_zip.go new file mode 100644 index 000000000..0830f7914 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_zip.go @@ -0,0 +1,101 @@ +package getter + +import ( + "archive/zip" + "fmt" + "io" + "os" + "path/filepath" +) + +// ZipDecompressor is an implementation of Decompressor that can +// decompress zip files. +type ZipDecompressor struct{} + +func (d *ZipDecompressor) Decompress(dst, src string, dir bool) error { + // If we're going into a directory we should make that first + mkdir := dst + if !dir { + mkdir = filepath.Dir(dst) + } + if err := os.MkdirAll(mkdir, 0755); err != nil { + return err + } + + // Open the zip + zipR, err := zip.OpenReader(src) + if err != nil { + return err + } + defer zipR.Close() + + // Check the zip integrity + if len(zipR.File) == 0 { + // Empty archive + return fmt.Errorf("empty archive: %s", src) + } + if !dir && len(zipR.File) > 1 { + return fmt.Errorf("expected a single file: %s", src) + } + + // Go through and unarchive + for _, f := range zipR.File { + path := dst + if dir { + // Disallow parent traversal + if containsDotDot(f.Name) { + return fmt.Errorf("entry contains '..': %s", f.Name) + } + + path = filepath.Join(path, f.Name) + } + + if f.FileInfo().IsDir() { + if !dir { + return fmt.Errorf("expected a single file: %s", src) + } + + // A directory, just make the directory and continue unarchiving... + if err := os.MkdirAll(path, 0755); err != nil { + return err + } + + continue + } + + // Create the enclosing directories if we must. ZIP files aren't + // required to contain entries for just the directories so this + // can happen. + if dir { + if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { + return err + } + } + + // Open the file for reading + srcF, err := f.Open() + if err != nil { + return err + } + + // Open the file for writing + dstF, err := os.Create(path) + if err != nil { + srcF.Close() + return err + } + _, err = io.Copy(dstF, srcF) + srcF.Close() + dstF.Close() + if err != nil { + return err + } + + // Chmod the file + if err := os.Chmod(path, f.Mode()); err != nil { + return err + } + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-getter/detect.go b/vendor/github.com/hashicorp/go-getter/detect.go new file mode 100644 index 000000000..5bb750c9f --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect.go @@ -0,0 +1,105 @@ +package getter + +import ( + "fmt" + "path/filepath" + + "github.com/hashicorp/go-getter/helper/url" +) + +// Detector defines the interface that an invalid URL or a URL with a blank +// scheme is passed through in order to determine if its shorthand for +// something else well-known. +type Detector interface { + // Detect will detect whether the string matches a known pattern to + // turn it into a proper URL. + Detect(string, string) (string, bool, error) +} + +// Detectors is the list of detectors that are tried on an invalid URL. +// This is also the order they're tried (index 0 is first). +var Detectors []Detector + +func init() { + Detectors = []Detector{ + new(GitHubDetector), + new(GitDetector), + new(BitBucketDetector), + new(S3Detector), + new(GCSDetector), + new(FileDetector), + } +} + +// Detect turns a source string into another source string if it is +// detected to be of a known pattern. +// +// The third parameter should be the list of detectors to use in the +// order to try them. If you don't want to configure this, just use +// the global Detectors variable. +// +// This is safe to be called with an already valid source string: Detect +// will just return it. +func Detect(src string, pwd string, ds []Detector) (string, error) { + getForce, getSrc := getForcedGetter(src) + + // Separate out the subdir if there is one, we don't pass that to detect + getSrc, subDir := SourceDirSubdir(getSrc) + + u, err := url.Parse(getSrc) + if err == nil && u.Scheme != "" { + // Valid URL + return src, nil + } + + for _, d := range ds { + result, ok, err := d.Detect(getSrc, pwd) + if err != nil { + return "", err + } + if !ok { + continue + } + + var detectForce string + detectForce, result = getForcedGetter(result) + result, detectSubdir := SourceDirSubdir(result) + + // If we have a subdir from the detection, then prepend it to our + // requested subdir. + if detectSubdir != "" { + if subDir != "" { + subDir = filepath.Join(detectSubdir, subDir) + } else { + subDir = detectSubdir + } + } + + if subDir != "" { + u, err := url.Parse(result) + if err != nil { + return "", fmt.Errorf("Error parsing URL: %s", err) + } + u.Path += "//" + subDir + + // a subdir may contain wildcards, but in order to support them we + // have to ensure the path isn't escaped. + u.RawPath = u.Path + + result = u.String() + } + + // Preserve the forced getter if it exists. We try to use the + // original set force first, followed by any force set by the + // detector. + if getForce != "" { + result = fmt.Sprintf("%s::%s", getForce, result) + } else if detectForce != "" { + result = fmt.Sprintf("%s::%s", detectForce, result) + } + + return result, nil + } + + return "", fmt.Errorf("invalid source string: %s", src) +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go b/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go new file mode 100644 index 000000000..19047eb19 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go @@ -0,0 +1,66 @@ +package getter + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" +) + +// BitBucketDetector implements Detector to detect BitBucket URLs and turn +// them into URLs that the Git or Hg Getter can understand. +type BitBucketDetector struct{} + +func (d *BitBucketDetector) Detect(src, _ string) (string, bool, error) { + if len(src) == 0 { + return "", false, nil + } + + if strings.HasPrefix(src, "bitbucket.org/") { + return d.detectHTTP(src) + } + + return "", false, nil +} + +func (d *BitBucketDetector) detectHTTP(src string) (string, bool, error) { + u, err := url.Parse("https://" + src) + if err != nil { + return "", true, fmt.Errorf("error parsing BitBucket URL: %s", err) + } + + // We need to get info on this BitBucket repository to determine whether + // it is Git or Hg. + var info struct { + SCM string `json:"scm"` + } + infoUrl := "https://api.bitbucket.org/2.0/repositories" + u.Path + resp, err := http.Get(infoUrl) + if err != nil { + return "", true, fmt.Errorf("error looking up BitBucket URL: %s", err) + } + if resp.StatusCode == 403 { + // A private repo + return "", true, fmt.Errorf( + "shorthand BitBucket URL can't be used for private repos, " + + "please use a full URL") + } + dec := json.NewDecoder(resp.Body) + if err := dec.Decode(&info); err != nil { + return "", true, fmt.Errorf("error looking up BitBucket URL: %s", err) + } + + switch info.SCM { + case "git": + if !strings.HasSuffix(u.Path, ".git") { + u.Path += ".git" + } + + return "git::" + u.String(), true, nil + case "hg": + return "hg::" + u.String(), true, nil + default: + return "", true, fmt.Errorf("unknown BitBucket SCM type: %s", info.SCM) + } +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_file.go b/vendor/github.com/hashicorp/go-getter/detect_file.go new file mode 100644 index 000000000..4ef41ea73 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_file.go @@ -0,0 +1,67 @@ +package getter + +import ( + "fmt" + "os" + "path/filepath" + "runtime" +) + +// FileDetector implements Detector to detect file paths. +type FileDetector struct{} + +func (d *FileDetector) Detect(src, pwd string) (string, bool, error) { + if len(src) == 0 { + return "", false, nil + } + + if !filepath.IsAbs(src) { + if pwd == "" { + return "", true, fmt.Errorf( + "relative paths require a module with a pwd") + } + + // Stat the pwd to determine if its a symbolic link. If it is, + // then the pwd becomes the original directory. Otherwise, + // `filepath.Join` below does some weird stuff. + // + // We just ignore if the pwd doesn't exist. That error will be + // caught later when we try to use the URL. + if fi, err := os.Lstat(pwd); !os.IsNotExist(err) { + if err != nil { + return "", true, err + } + if fi.Mode()&os.ModeSymlink != 0 { + pwd, err = filepath.EvalSymlinks(pwd) + if err != nil { + return "", true, err + } + + // The symlink itself might be a relative path, so we have to + // resolve this to have a correctly rooted URL. + pwd, err = filepath.Abs(pwd) + if err != nil { + return "", true, err + } + } + } + + src = filepath.Join(pwd, src) + } + + return fmtFileURL(src), true, nil +} + +func fmtFileURL(path string) string { + if runtime.GOOS == "windows" { + // Make sure we're using "/" on Windows. URLs are "/"-based. + path = filepath.ToSlash(path) + return fmt.Sprintf("file://%s", path) + } + + // Make sure that we don't start with "/" since we add that below. + if path[0] == '/' { + path = path[1:] + } + return fmt.Sprintf("file:///%s", path) +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_gcs.go b/vendor/github.com/hashicorp/go-getter/detect_gcs.go new file mode 100644 index 000000000..11363737c --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_gcs.go @@ -0,0 +1,43 @@ +package getter + +import ( + "fmt" + "net/url" + "strings" +) + +// GCSDetector implements Detector to detect GCS URLs and turn +// them into URLs that the GCSGetter can understand. +type GCSDetector struct{} + +func (d *GCSDetector) Detect(src, _ string) (string, bool, error) { + if len(src) == 0 { + return "", false, nil + } + + if strings.Contains(src, "googleapis.com/") { + return d.detectHTTP(src) + } + + return "", false, nil +} + +func (d *GCSDetector) detectHTTP(src string) (string, bool, error) { + + parts := strings.Split(src, "/") + if len(parts) < 5 { + return "", false, fmt.Errorf( + "URL is not a valid GCS URL") + } + version := parts[2] + bucket := parts[3] + object := strings.Join(parts[4:], "/") + + url, err := url.Parse(fmt.Sprintf("https://www.googleapis.com/storage/%s/%s/%s", + version, bucket, object)) + if err != nil { + return "", false, fmt.Errorf("error parsing GCS URL: %s", err) + } + + return "gcs::" + url.String(), true, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_git.go b/vendor/github.com/hashicorp/go-getter/detect_git.go new file mode 100644 index 000000000..eeb8a04c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_git.go @@ -0,0 +1,26 @@ +package getter + +// GitDetector implements Detector to detect Git SSH URLs such as +// git@host.com:dir1/dir2 and converts them to proper URLs. +type GitDetector struct{} + +func (d *GitDetector) Detect(src, _ string) (string, bool, error) { + if len(src) == 0 { + return "", false, nil + } + + u, err := detectSSH(src) + if err != nil { + return "", true, err + } + if u == nil { + return "", false, nil + } + + // We require the username to be "git" to assume that this is a Git URL + if u.User.Username() != "git" { + return "", false, nil + } + + return "git::" + u.String(), true, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_github.go b/vendor/github.com/hashicorp/go-getter/detect_github.go new file mode 100644 index 000000000..4bf4daf23 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_github.go @@ -0,0 +1,47 @@ +package getter + +import ( + "fmt" + "net/url" + "strings" +) + +// GitHubDetector implements Detector to detect GitHub URLs and turn +// them into URLs that the Git Getter can understand. +type GitHubDetector struct{} + +func (d *GitHubDetector) Detect(src, _ string) (string, bool, error) { + if len(src) == 0 { + return "", false, nil + } + + if strings.HasPrefix(src, "github.com/") { + return d.detectHTTP(src) + } + + return "", false, nil +} + +func (d *GitHubDetector) detectHTTP(src string) (string, bool, error) { + parts := strings.Split(src, "/") + if len(parts) < 3 { + return "", false, fmt.Errorf( + "GitHub URLs should be github.com/username/repo") + } + + urlStr := fmt.Sprintf("https://%s", strings.Join(parts[:3], "/")) + url, err := url.Parse(urlStr) + if err != nil { + return "", true, fmt.Errorf("error parsing GitHub URL: %s", err) + } + + if !strings.HasSuffix(url.Path, ".git") { + url.Path += ".git" + } + + if len(parts) > 3 { + url.Path += "//" + strings.Join(parts[3:], "/") + } + + return "git::" + url.String(), true, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_s3.go b/vendor/github.com/hashicorp/go-getter/detect_s3.go new file mode 100644 index 000000000..8e0f4a03b --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_s3.go @@ -0,0 +1,61 @@ +package getter + +import ( + "fmt" + "net/url" + "strings" +) + +// S3Detector implements Detector to detect S3 URLs and turn +// them into URLs that the S3 getter can understand. +type S3Detector struct{} + +func (d *S3Detector) Detect(src, _ string) (string, bool, error) { + if len(src) == 0 { + return "", false, nil + } + + if strings.Contains(src, ".amazonaws.com/") { + return d.detectHTTP(src) + } + + return "", false, nil +} + +func (d *S3Detector) detectHTTP(src string) (string, bool, error) { + parts := strings.Split(src, "/") + if len(parts) < 2 { + return "", false, fmt.Errorf( + "URL is not a valid S3 URL") + } + + hostParts := strings.Split(parts[0], ".") + if len(hostParts) == 3 { + return d.detectPathStyle(hostParts[0], parts[1:]) + } else if len(hostParts) == 4 { + return d.detectVhostStyle(hostParts[1], hostParts[0], parts[1:]) + } else { + return "", false, fmt.Errorf( + "URL is not a valid S3 URL") + } +} + +func (d *S3Detector) detectPathStyle(region string, parts []string) (string, bool, error) { + urlStr := fmt.Sprintf("https://%s.amazonaws.com/%s", region, strings.Join(parts, "/")) + url, err := url.Parse(urlStr) + if err != nil { + return "", false, fmt.Errorf("error parsing S3 URL: %s", err) + } + + return "s3::" + url.String(), true, nil +} + +func (d *S3Detector) detectVhostStyle(region, bucket string, parts []string) (string, bool, error) { + urlStr := fmt.Sprintf("https://%s.amazonaws.com/%s/%s", region, bucket, strings.Join(parts, "/")) + url, err := url.Parse(urlStr) + if err != nil { + return "", false, fmt.Errorf("error parsing S3 URL: %s", err) + } + + return "s3::" + url.String(), true, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/detect_ssh.go b/vendor/github.com/hashicorp/go-getter/detect_ssh.go new file mode 100644 index 000000000..c0dbe9d47 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/detect_ssh.go @@ -0,0 +1,49 @@ +package getter + +import ( + "fmt" + "net/url" + "regexp" + "strings" +) + +// Note that we do not have an SSH-getter currently so this file serves +// only to hold the detectSSH helper that is used by other detectors. + +// sshPattern matches SCP-like SSH patterns (user@host:path) +var sshPattern = regexp.MustCompile("^(?:([^@]+)@)?([^:]+):/?(.+)$") + +// detectSSH determines if the src string matches an SSH-like URL and +// converts it into a net.URL compatible string. This returns nil if the +// string doesn't match the SSH pattern. +// +// This function is tested indirectly via detect_git_test.go +func detectSSH(src string) (*url.URL, error) { + matched := sshPattern.FindStringSubmatch(src) + if matched == nil { + return nil, nil + } + + user := matched[1] + host := matched[2] + path := matched[3] + qidx := strings.Index(path, "?") + if qidx == -1 { + qidx = len(path) + } + + var u url.URL + u.Scheme = "ssh" + u.User = url.User(user) + u.Host = host + u.Path = path[0:qidx] + if qidx < len(path) { + q, err := url.ParseQuery(path[qidx+1:]) + if err != nil { + return nil, fmt.Errorf("error parsing GitHub SSH URL: %s", err) + } + u.RawQuery = q.Encode() + } + + return &u, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/folder_storage.go b/vendor/github.com/hashicorp/go-getter/folder_storage.go new file mode 100644 index 000000000..647ccf459 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/folder_storage.go @@ -0,0 +1,65 @@ +package getter + +import ( + "crypto/md5" + "encoding/hex" + "fmt" + "os" + "path/filepath" +) + +// FolderStorage is an implementation of the Storage interface that manages +// modules on the disk. +type FolderStorage struct { + // StorageDir is the directory where the modules will be stored. + StorageDir string +} + +// Dir implements Storage.Dir +func (s *FolderStorage) Dir(key string) (d string, e bool, err error) { + d = s.dir(key) + _, err = os.Stat(d) + if err == nil { + // Directory exists + e = true + return + } + if os.IsNotExist(err) { + // Directory doesn't exist + d = "" + e = false + err = nil + return + } + + // An error + d = "" + e = false + return +} + +// Get implements Storage.Get +func (s *FolderStorage) Get(key string, source string, update bool) error { + dir := s.dir(key) + if !update { + if _, err := os.Stat(dir); err == nil { + // If the directory already exists, then we're done since + // we're not updating. + return nil + } else if !os.IsNotExist(err) { + // If the error we got wasn't a file-not-exist error, then + // something went wrong and we should report it. + return fmt.Errorf("Error reading module directory: %s", err) + } + } + + // Get the source. This always forces an update. + return Get(dir, source) +} + +// dir returns the directory name internally that we'll use to map to +// internally. +func (s *FolderStorage) dir(key string) string { + sum := md5.Sum([]byte(key)) + return filepath.Join(s.StorageDir, hex.EncodeToString(sum[:])) +} diff --git a/vendor/github.com/hashicorp/go-getter/get.go b/vendor/github.com/hashicorp/go-getter/get.go new file mode 100644 index 000000000..c233763c6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get.go @@ -0,0 +1,152 @@ +// getter is a package for downloading files or directories from a variety of +// protocols. +// +// getter is unique in its ability to download both directories and files. +// It also detects certain source strings to be protocol-specific URLs. For +// example, "github.com/hashicorp/go-getter" would turn into a Git URL and +// use the Git protocol. +// +// Protocols and detectors are extensible. +// +// To get started, see Client. +package getter + +import ( + "bytes" + "fmt" + "net/url" + "os/exec" + "regexp" + "syscall" + + cleanhttp "github.com/hashicorp/go-cleanhttp" +) + +// Getter defines the interface that schemes must implement to download +// things. +type Getter interface { + // Get downloads the given URL into the given directory. This always + // assumes that we're updating and gets the latest version that it can. + // + // The directory may already exist (if we're updating). If it is in a + // format that isn't understood, an error should be returned. Get shouldn't + // simply nuke the directory. + Get(string, *url.URL) error + + // GetFile downloads the give URL into the given path. The URL must + // reference a single file. If possible, the Getter should check if + // the remote end contains the same file and no-op this operation. + GetFile(string, *url.URL) error + + // ClientMode returns the mode based on the given URL. This is used to + // allow clients to let the getters decide which mode to use. + ClientMode(*url.URL) (ClientMode, error) + + // SetClient allows a getter to know it's client + // in order to access client's Get functions or + // progress tracking. + SetClient(*Client) +} + +// Getters is the mapping of scheme to the Getter implementation that will +// be used to get a dependency. +var Getters map[string]Getter + +// forcedRegexp is the regular expression that finds forced getters. This +// syntax is schema::url, example: git::https://foo.com +var forcedRegexp = regexp.MustCompile(`^([A-Za-z0-9]+)::(.+)$`) + +// httpClient is the default client to be used by HttpGetters. +var httpClient = cleanhttp.DefaultClient() + +func init() { + httpGetter := &HttpGetter{ + Netrc: true, + } + + Getters = map[string]Getter{ + "file": new(FileGetter), + "git": new(GitGetter), + "gcs": new(GCSGetter), + "hg": new(HgGetter), + "s3": new(S3Getter), + "http": httpGetter, + "https": httpGetter, + } +} + +// Get downloads the directory specified by src into the folder specified by +// dst. If dst already exists, Get will attempt to update it. +// +// src is a URL, whereas dst is always just a file path to a folder. This +// folder doesn't need to exist. It will be created if it doesn't exist. +func Get(dst, src string, opts ...ClientOption) error { + return (&Client{ + Src: src, + Dst: dst, + Dir: true, + Options: opts, + }).Get() +} + +// GetAny downloads a URL into the given destination. Unlike Get or +// GetFile, both directories and files are supported. +// +// dst must be a directory. If src is a file, it will be downloaded +// into dst with the basename of the URL. If src is a directory or +// archive, it will be unpacked directly into dst. +func GetAny(dst, src string, opts ...ClientOption) error { + return (&Client{ + Src: src, + Dst: dst, + Mode: ClientModeAny, + Options: opts, + }).Get() +} + +// GetFile downloads the file specified by src into the path specified by +// dst. +func GetFile(dst, src string, opts ...ClientOption) error { + return (&Client{ + Src: src, + Dst: dst, + Dir: false, + Options: opts, + }).Get() +} + +// getRunCommand is a helper that will run a command and capture the output +// in the case an error happens. +func getRunCommand(cmd *exec.Cmd) error { + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + err := cmd.Run() + if err == nil { + return nil + } + if exiterr, ok := err.(*exec.ExitError); ok { + // The program has exited with an exit code != 0 + if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { + return fmt.Errorf( + "%s exited with %d: %s", + cmd.Path, + status.ExitStatus(), + buf.String()) + } + } + + return fmt.Errorf("error running %s: %s", cmd.Path, buf.String()) +} + +// getForcedGetter takes a source and returns the tuple of the forced +// getter and the raw URL (without the force syntax). +func getForcedGetter(src string) (string, string) { + var forced string + if ms := forcedRegexp.FindStringSubmatch(src); ms != nil { + forced = ms[1] + src = ms[2] + } + + return forced, src +} diff --git a/vendor/github.com/hashicorp/go-getter/get_base.go b/vendor/github.com/hashicorp/go-getter/get_base.go new file mode 100644 index 000000000..09e9b6313 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_base.go @@ -0,0 +1,20 @@ +package getter + +import "context" + +// getter is our base getter; it regroups +// fields all getters have in common. +type getter struct { + client *Client +} + +func (g *getter) SetClient(c *Client) { g.client = c } + +// Context tries to returns the Contex from the getter's +// client. otherwise context.Background() is returned. +func (g *getter) Context() context.Context { + if g == nil || g.client == nil { + return context.Background() + } + return g.client.Ctx +} diff --git a/vendor/github.com/hashicorp/go-getter/get_file.go b/vendor/github.com/hashicorp/go-getter/get_file.go new file mode 100644 index 000000000..78660839a --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_file.go @@ -0,0 +1,36 @@ +package getter + +import ( + "net/url" + "os" +) + +// FileGetter is a Getter implementation that will download a module from +// a file scheme. +type FileGetter struct { + getter + + // Copy, if set to true, will copy data instead of using a symlink. If + // false, attempts to symlink to speed up the operation and to lower the + // disk space usage. If the symlink fails, may attempt to copy on windows. + Copy bool +} + +func (g *FileGetter) ClientMode(u *url.URL) (ClientMode, error) { + path := u.Path + if u.RawPath != "" { + path = u.RawPath + } + + fi, err := os.Stat(path) + if err != nil { + return 0, err + } + + // Check if the source is a directory. + if fi.IsDir() { + return ClientModeDir, nil + } + + return ClientModeFile, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/get_file_copy.go b/vendor/github.com/hashicorp/go-getter/get_file_copy.go new file mode 100644 index 000000000..d70fb4951 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_file_copy.go @@ -0,0 +1,29 @@ +package getter + +import ( + "context" + "io" +) + +// readerFunc is syntactic sugar for read interface. +type readerFunc func(p []byte) (n int, err error) + +func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) } + +// Copy is a io.Copy cancellable by context +func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) { + // Copy will call the Reader and Writer interface multiple time, in order + // to copy by chunk (avoiding loading the whole file in memory). + return io.Copy(dst, readerFunc(func(p []byte) (int, error) { + + select { + case <-ctx.Done(): + // context has been canceled + // stop process and propagate "context canceled" error + return 0, ctx.Err() + default: + // otherwise just run default io.Reader implementation + return src.Read(p) + } + })) +} diff --git a/vendor/github.com/hashicorp/go-getter/get_file_unix.go b/vendor/github.com/hashicorp/go-getter/get_file_unix.go new file mode 100644 index 000000000..c3b28ae51 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_file_unix.go @@ -0,0 +1,103 @@ +// +build !windows + +package getter + +import ( + "fmt" + "net/url" + "os" + "path/filepath" +) + +func (g *FileGetter) Get(dst string, u *url.URL) error { + path := u.Path + if u.RawPath != "" { + path = u.RawPath + } + + // The source path must exist and be a directory to be usable. + if fi, err := os.Stat(path); err != nil { + return fmt.Errorf("source path error: %s", err) + } else if !fi.IsDir() { + return fmt.Errorf("source path must be a directory") + } + + fi, err := os.Lstat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + + // If the destination already exists, it must be a symlink + if err == nil { + mode := fi.Mode() + if mode&os.ModeSymlink == 0 { + return fmt.Errorf("destination exists and is not a symlink") + } + + // Remove the destination + if err := os.Remove(dst); err != nil { + return err + } + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + return os.Symlink(path, dst) +} + +func (g *FileGetter) GetFile(dst string, u *url.URL) error { + ctx := g.Context() + path := u.Path + if u.RawPath != "" { + path = u.RawPath + } + + // The source path must exist and be a file to be usable. + if fi, err := os.Stat(path); err != nil { + return fmt.Errorf("source path error: %s", err) + } else if fi.IsDir() { + return fmt.Errorf("source path must be a file") + } + + _, err := os.Lstat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + + // If the destination already exists, it must be a symlink + if err == nil { + // Remove the destination + if err := os.Remove(dst); err != nil { + return err + } + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + // If we're not copying, just symlink and we're done + if !g.Copy { + return os.Symlink(path, dst) + } + + // Copy + srcF, err := os.Open(path) + if err != nil { + return err + } + defer srcF.Close() + + dstF, err := os.Create(dst) + if err != nil { + return err + } + defer dstF.Close() + + _, err = Copy(ctx, dstF, srcF) + return err +} diff --git a/vendor/github.com/hashicorp/go-getter/get_file_windows.go b/vendor/github.com/hashicorp/go-getter/get_file_windows.go new file mode 100644 index 000000000..24f1acb17 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_file_windows.go @@ -0,0 +1,136 @@ +// +build windows + +package getter + +import ( + "fmt" + "net/url" + "os" + "os/exec" + "path/filepath" + "strings" + "syscall" +) + +func (g *FileGetter) Get(dst string, u *url.URL) error { + ctx := g.Context() + path := u.Path + if u.RawPath != "" { + path = u.RawPath + } + + // The source path must exist and be a directory to be usable. + if fi, err := os.Stat(path); err != nil { + return fmt.Errorf("source path error: %s", err) + } else if !fi.IsDir() { + return fmt.Errorf("source path must be a directory") + } + + fi, err := os.Lstat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + + // If the destination already exists, it must be a symlink + if err == nil { + mode := fi.Mode() + if mode&os.ModeSymlink == 0 { + return fmt.Errorf("destination exists and is not a symlink") + } + + // Remove the destination + if err := os.Remove(dst); err != nil { + return err + } + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + sourcePath := toBackslash(path) + + // Use mklink to create a junction point + output, err := exec.CommandContext(ctx, "cmd", "/c", "mklink", "/J", dst, sourcePath).CombinedOutput() + if err != nil { + return fmt.Errorf("failed to run mklink %v %v: %v %q", dst, sourcePath, err, output) + } + + return nil +} + +func (g *FileGetter) GetFile(dst string, u *url.URL) error { + ctx := g.Context() + path := u.Path + if u.RawPath != "" { + path = u.RawPath + } + + // The source path must exist and be a directory to be usable. + if fi, err := os.Stat(path); err != nil { + return fmt.Errorf("source path error: %s", err) + } else if fi.IsDir() { + return fmt.Errorf("source path must be a file") + } + + _, err := os.Lstat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + + // If the destination already exists, it must be a symlink + if err == nil { + // Remove the destination + if err := os.Remove(dst); err != nil { + return err + } + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + // If we're not copying, just symlink and we're done + if !g.Copy { + if err = os.Symlink(path, dst); err == nil { + return err + } + lerr, ok := err.(*os.LinkError) + if !ok { + return err + } + switch lerr.Err { + case syscall.ERROR_PRIVILEGE_NOT_HELD: + // no symlink privilege, let's + // fallback to a copy to avoid an error. + break + default: + return err + } + } + + // Copy + srcF, err := os.Open(path) + if err != nil { + return err + } + defer srcF.Close() + + dstF, err := os.Create(dst) + if err != nil { + return err + } + defer dstF.Close() + + _, err = Copy(ctx, dstF, srcF) + return err +} + +// toBackslash returns the result of replacing each slash character +// in path with a backslash ('\') character. Multiple separators are +// replaced by multiple backslashes. +func toBackslash(path string) string { + return strings.Replace(path, "/", "\\", -1) +} diff --git a/vendor/github.com/hashicorp/go-getter/get_gcs.go b/vendor/github.com/hashicorp/go-getter/get_gcs.go new file mode 100644 index 000000000..6faa70f4f --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_gcs.go @@ -0,0 +1,172 @@ +package getter + +import ( + "context" + "fmt" + "net/url" + "os" + "path/filepath" + "strings" + + "cloud.google.com/go/storage" + "google.golang.org/api/iterator" +) + +// GCSGetter is a Getter implementation that will download a module from +// a GCS bucket. +type GCSGetter struct { + getter +} + +func (g *GCSGetter) ClientMode(u *url.URL) (ClientMode, error) { + ctx := g.Context() + + // Parse URL + bucket, object, err := g.parseURL(u) + if err != nil { + return 0, err + } + + client, err := storage.NewClient(ctx) + if err != nil { + return 0, err + } + iter := client.Bucket(bucket).Objects(ctx, &storage.Query{Prefix: object}) + for { + obj, err := iter.Next() + if err != nil && err != iterator.Done { + return 0, err + } + + if err == iterator.Done { + break + } + if strings.HasSuffix(obj.Name, "/") { + // A directory matched the prefix search, so this must be a directory + return ClientModeDir, nil + } else if obj.Name != object { + // A file matched the prefix search and doesn't have the same name + // as the query, so this must be a directory + return ClientModeDir, nil + } + } + // There are no directories or subdirectories, and if a match was returned, + // it was exactly equal to the prefix search. So return File mode + return ClientModeFile, nil +} + +func (g *GCSGetter) Get(dst string, u *url.URL) error { + ctx := g.Context() + + // Parse URL + bucket, object, err := g.parseURL(u) + if err != nil { + return err + } + + // Remove destination if it already exists + _, err = os.Stat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + if err == nil { + // Remove the destination + if err := os.RemoveAll(dst); err != nil { + return err + } + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + client, err := storage.NewClient(ctx) + if err != nil { + return err + } + + // Iterate through all matching objects. + iter := client.Bucket(bucket).Objects(ctx, &storage.Query{Prefix: object}) + for { + obj, err := iter.Next() + if err != nil && err != iterator.Done { + return err + } + if err == iterator.Done { + break + } + + if !strings.HasSuffix(obj.Name, "/") { + // Get the object destination path + objDst, err := filepath.Rel(object, obj.Name) + if err != nil { + return err + } + objDst = filepath.Join(dst, objDst) + // Download the matching object. + err = g.getObject(ctx, client, objDst, bucket, obj.Name) + if err != nil { + return err + } + } + } + return nil +} + +func (g *GCSGetter) GetFile(dst string, u *url.URL) error { + ctx := g.Context() + + // Parse URL + bucket, object, err := g.parseURL(u) + if err != nil { + return err + } + + client, err := storage.NewClient(ctx) + if err != nil { + return err + } + return g.getObject(ctx, client, dst, bucket, object) +} + +func (g *GCSGetter) getObject(ctx context.Context, client *storage.Client, dst, bucket, object string) error { + rc, err := client.Bucket(bucket).Object(object).NewReader(ctx) + if err != nil { + return err + } + defer rc.Close() + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + f, err := os.Create(dst) + if err != nil { + return err + } + defer f.Close() + + _, err = Copy(ctx, f, rc) + return err +} + +func (g *GCSGetter) parseURL(u *url.URL) (bucket, path string, err error) { + if strings.Contains(u.Host, "googleapis.com") { + hostParts := strings.Split(u.Host, ".") + if len(hostParts) != 3 { + err = fmt.Errorf("URL is not a valid GCS URL") + return + } + + pathParts := strings.SplitN(u.Path, "/", 5) + if len(pathParts) != 5 { + err = fmt.Errorf("URL is not a valid GCS URL") + return + } + bucket = pathParts[3] + path = pathParts[4] + } + return +} diff --git a/vendor/github.com/hashicorp/go-getter/get_git.go b/vendor/github.com/hashicorp/go-getter/get_git.go new file mode 100644 index 000000000..1b9f4be81 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_git.go @@ -0,0 +1,313 @@ +package getter + +import ( + "bytes" + "context" + "encoding/base64" + "fmt" + "io/ioutil" + "net/url" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + + urlhelper "github.com/hashicorp/go-getter/helper/url" + safetemp "github.com/hashicorp/go-safetemp" + version "github.com/hashicorp/go-version" +) + +// GitGetter is a Getter implementation that will download a module from +// a git repository. +type GitGetter struct { + getter +} + +var defaultBranchRegexp = regexp.MustCompile(`\s->\sorigin/(.*)`) + +func (g *GitGetter) ClientMode(_ *url.URL) (ClientMode, error) { + return ClientModeDir, nil +} + +func (g *GitGetter) Get(dst string, u *url.URL) error { + ctx := g.Context() + if _, err := exec.LookPath("git"); err != nil { + return fmt.Errorf("git must be available and on the PATH") + } + + // The port number must be parseable as an integer. If not, the user + // was probably trying to use a scp-style address, in which case the + // ssh:// prefix must be removed to indicate that. + // + // This is not necessary in versions of Go which have patched + // CVE-2019-14809 (e.g. Go 1.12.8+) + if portStr := u.Port(); portStr != "" { + if _, err := strconv.ParseUint(portStr, 10, 16); err != nil { + return fmt.Errorf("invalid port number %q; if using the \"scp-like\" git address scheme where a colon introduces the path instead, remove the ssh:// portion and use just the git:: prefix", portStr) + } + } + + // Extract some query parameters we use + var ref, sshKey string + var depth int + q := u.Query() + if len(q) > 0 { + ref = q.Get("ref") + q.Del("ref") + + sshKey = q.Get("sshkey") + q.Del("sshkey") + + if n, err := strconv.Atoi(q.Get("depth")); err == nil { + depth = n + } + q.Del("depth") + + // Copy the URL + var newU url.URL = *u + u = &newU + u.RawQuery = q.Encode() + } + + var sshKeyFile string + if sshKey != "" { + // Check that the git version is sufficiently new. + if err := checkGitVersion("2.3"); err != nil { + return fmt.Errorf("Error using ssh key: %v", err) + } + + // We have an SSH key - decode it. + raw, err := base64.StdEncoding.DecodeString(sshKey) + if err != nil { + return err + } + + // Create a temp file for the key and ensure it is removed. + fh, err := ioutil.TempFile("", "go-getter") + if err != nil { + return err + } + sshKeyFile = fh.Name() + defer os.Remove(sshKeyFile) + + // Set the permissions prior to writing the key material. + if err := os.Chmod(sshKeyFile, 0600); err != nil { + return err + } + + // Write the raw key into the temp file. + _, err = fh.Write(raw) + fh.Close() + if err != nil { + return err + } + } + + // Clone or update the repository + _, err := os.Stat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + if err == nil { + err = g.update(ctx, dst, sshKeyFile, ref, depth) + } else { + err = g.clone(ctx, dst, sshKeyFile, u, depth) + } + if err != nil { + return err + } + + // Next: check out the proper tag/branch if it is specified, and checkout + if ref != "" { + if err := g.checkout(dst, ref); err != nil { + return err + } + } + + // Lastly, download any/all submodules. + return g.fetchSubmodules(ctx, dst, sshKeyFile, depth) +} + +// GetFile for Git doesn't support updating at this time. It will download +// the file every time. +func (g *GitGetter) GetFile(dst string, u *url.URL) error { + td, tdcloser, err := safetemp.Dir("", "getter") + if err != nil { + return err + } + defer tdcloser.Close() + + // Get the filename, and strip the filename from the URL so we can + // just get the repository directly. + filename := filepath.Base(u.Path) + u.Path = filepath.Dir(u.Path) + + // Get the full repository + if err := g.Get(td, u); err != nil { + return err + } + + // Copy the single file + u, err = urlhelper.Parse(fmtFileURL(filepath.Join(td, filename))) + if err != nil { + return err + } + + fg := &FileGetter{Copy: true} + return fg.GetFile(dst, u) +} + +func (g *GitGetter) checkout(dst string, ref string) error { + cmd := exec.Command("git", "checkout", ref) + cmd.Dir = dst + return getRunCommand(cmd) +} + +func (g *GitGetter) clone(ctx context.Context, dst, sshKeyFile string, u *url.URL, depth int) error { + args := []string{"clone"} + + if depth > 0 { + args = append(args, "--depth", strconv.Itoa(depth)) + } + + args = append(args, u.String(), dst) + cmd := exec.CommandContext(ctx, "git", args...) + setupGitEnv(cmd, sshKeyFile) + return getRunCommand(cmd) +} + +func (g *GitGetter) update(ctx context.Context, dst, sshKeyFile, ref string, depth int) error { + // Determine if we're a branch. If we're NOT a branch, then we just + // switch to master prior to checking out + cmd := exec.CommandContext(ctx, "git", "show-ref", "-q", "--verify", "refs/heads/"+ref) + cmd.Dir = dst + + if getRunCommand(cmd) != nil { + // Not a branch, switch to default branch. This will also catch + // non-existent branches, in which case we want to switch to default + // and then checkout the proper branch later. + ref = findDefaultBranch(dst) + } + + // We have to be on a branch to pull + if err := g.checkout(dst, ref); err != nil { + return err + } + + if depth > 0 { + cmd = exec.Command("git", "pull", "--depth", strconv.Itoa(depth), "--ff-only") + } else { + cmd = exec.Command("git", "pull", "--ff-only") + } + + cmd.Dir = dst + setupGitEnv(cmd, sshKeyFile) + return getRunCommand(cmd) +} + +// fetchSubmodules downloads any configured submodules recursively. +func (g *GitGetter) fetchSubmodules(ctx context.Context, dst, sshKeyFile string, depth int) error { + args := []string{"submodule", "update", "--init", "--recursive"} + if depth > 0 { + args = append(args, "--depth", strconv.Itoa(depth)) + } + cmd := exec.CommandContext(ctx, "git", args...) + cmd.Dir = dst + setupGitEnv(cmd, sshKeyFile) + return getRunCommand(cmd) +} + +// findDefaultBranch checks the repo's origin remote for its default branch +// (generally "master"). "master" is returned if an origin default branch +// can't be determined. +func findDefaultBranch(dst string) string { + var stdoutbuf bytes.Buffer + cmd := exec.Command("git", "branch", "-r", "--points-at", "refs/remotes/origin/HEAD") + cmd.Dir = dst + cmd.Stdout = &stdoutbuf + err := cmd.Run() + matches := defaultBranchRegexp.FindStringSubmatch(stdoutbuf.String()) + if err != nil || matches == nil { + return "master" + } + return matches[len(matches)-1] +} + +// setupGitEnv sets up the environment for the given command. This is used to +// pass configuration data to git and ssh and enables advanced cloning methods. +func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) { + const gitSSHCommand = "GIT_SSH_COMMAND=" + var sshCmd []string + + // If we have an existing GIT_SSH_COMMAND, we need to append our options. + // We will also remove our old entry to make sure the behavior is the same + // with versions of Go < 1.9. + env := os.Environ() + for i, v := range env { + if strings.HasPrefix(v, gitSSHCommand) && len(v) > len(gitSSHCommand) { + sshCmd = []string{v} + + env[i], env[len(env)-1] = env[len(env)-1], env[i] + env = env[:len(env)-1] + break + } + } + + if len(sshCmd) == 0 { + sshCmd = []string{gitSSHCommand + "ssh"} + } + + if sshKeyFile != "" { + // We have an SSH key temp file configured, tell ssh about this. + if runtime.GOOS == "windows" { + sshKeyFile = strings.Replace(sshKeyFile, `\`, `/`, -1) + } + sshCmd = append(sshCmd, "-i", sshKeyFile) + } + + env = append(env, strings.Join(sshCmd, " ")) + cmd.Env = env +} + +// checkGitVersion is used to check the version of git installed on the system +// against a known minimum version. Returns an error if the installed version +// is older than the given minimum. +func checkGitVersion(min string) error { + want, err := version.NewVersion(min) + if err != nil { + return err + } + + out, err := exec.Command("git", "version").Output() + if err != nil { + return err + } + + fields := strings.Fields(string(out)) + if len(fields) < 3 { + return fmt.Errorf("Unexpected 'git version' output: %q", string(out)) + } + v := fields[2] + if runtime.GOOS == "windows" && strings.Contains(v, ".windows.") { + // on windows, git version will return for example: + // git version 2.20.1.windows.1 + // Which does not follow the semantic versionning specs + // https://semver.org. We remove that part in order for + // go-version to not error. + v = v[:strings.Index(v, ".windows.")] + } + + have, err := version.NewVersion(v) + if err != nil { + return err + } + + if have.LessThan(want) { + return fmt.Errorf("Required git version = %s, have %s", want, have) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-getter/get_hg.go b/vendor/github.com/hashicorp/go-getter/get_hg.go new file mode 100644 index 000000000..290649c91 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_hg.go @@ -0,0 +1,135 @@ +package getter + +import ( + "context" + "fmt" + "net/url" + "os" + "os/exec" + "path/filepath" + "runtime" + + urlhelper "github.com/hashicorp/go-getter/helper/url" + safetemp "github.com/hashicorp/go-safetemp" +) + +// HgGetter is a Getter implementation that will download a module from +// a Mercurial repository. +type HgGetter struct { + getter +} + +func (g *HgGetter) ClientMode(_ *url.URL) (ClientMode, error) { + return ClientModeDir, nil +} + +func (g *HgGetter) Get(dst string, u *url.URL) error { + ctx := g.Context() + if _, err := exec.LookPath("hg"); err != nil { + return fmt.Errorf("hg must be available and on the PATH") + } + + newURL, err := urlhelper.Parse(u.String()) + if err != nil { + return err + } + if fixWindowsDrivePath(newURL) { + // See valid file path form on http://www.selenic.com/hg/help/urls + newURL.Path = fmt.Sprintf("/%s", newURL.Path) + } + + // Extract some query parameters we use + var rev string + q := newURL.Query() + if len(q) > 0 { + rev = q.Get("rev") + q.Del("rev") + + newURL.RawQuery = q.Encode() + } + + _, err = os.Stat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + if err != nil { + if err := g.clone(dst, newURL); err != nil { + return err + } + } + + if err := g.pull(dst, newURL); err != nil { + return err + } + + return g.update(ctx, dst, newURL, rev) +} + +// GetFile for Hg doesn't support updating at this time. It will download +// the file every time. +func (g *HgGetter) GetFile(dst string, u *url.URL) error { + // Create a temporary directory to store the full source. This has to be + // a non-existent directory. + td, tdcloser, err := safetemp.Dir("", "getter") + if err != nil { + return err + } + defer tdcloser.Close() + + // Get the filename, and strip the filename from the URL so we can + // just get the repository directly. + filename := filepath.Base(u.Path) + u.Path = filepath.ToSlash(filepath.Dir(u.Path)) + + // If we're on Windows, we need to set the host to "localhost" for hg + if runtime.GOOS == "windows" { + u.Host = "localhost" + } + + // Get the full repository + if err := g.Get(td, u); err != nil { + return err + } + + // Copy the single file + u, err = urlhelper.Parse(fmtFileURL(filepath.Join(td, filename))) + if err != nil { + return err + } + + fg := &FileGetter{Copy: true, getter: g.getter} + return fg.GetFile(dst, u) +} + +func (g *HgGetter) clone(dst string, u *url.URL) error { + cmd := exec.Command("hg", "clone", "-U", u.String(), dst) + return getRunCommand(cmd) +} + +func (g *HgGetter) pull(dst string, u *url.URL) error { + cmd := exec.Command("hg", "pull") + cmd.Dir = dst + return getRunCommand(cmd) +} + +func (g *HgGetter) update(ctx context.Context, dst string, u *url.URL, rev string) error { + args := []string{"update"} + if rev != "" { + args = append(args, rev) + } + + cmd := exec.CommandContext(ctx, "hg", args...) + cmd.Dir = dst + return getRunCommand(cmd) +} + +func fixWindowsDrivePath(u *url.URL) bool { + // hg assumes a file:/// prefix for Windows drive letter file paths. + // (e.g. file:///c:/foo/bar) + // If the URL Path does not begin with a '/' character, the resulting URL + // path will have a file:// prefix. (e.g. file://c:/foo/bar) + // See http://www.selenic.com/hg/help/urls and the examples listed in + // http://selenic.com/repo/hg-stable/file/1265a3a71d75/mercurial/util.py#l1936 + return runtime.GOOS == "windows" && u.Scheme == "file" && + len(u.Path) > 1 && u.Path[0] != '/' && u.Path[1] == ':' +} diff --git a/vendor/github.com/hashicorp/go-getter/get_http.go b/vendor/github.com/hashicorp/go-getter/get_http.go new file mode 100644 index 000000000..618a411f9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_http.go @@ -0,0 +1,328 @@ +package getter + +import ( + "context" + "encoding/xml" + "fmt" + "io" + "net/http" + "net/url" + "os" + "path/filepath" + "strings" + + safetemp "github.com/hashicorp/go-safetemp" +) + +// HttpGetter is a Getter implementation that will download from an HTTP +// endpoint. +// +// For file downloads, HTTP is used directly. +// +// The protocol for downloading a directory from an HTTP endpoint is as follows: +// +// An HTTP GET request is made to the URL with the additional GET parameter +// "terraform-get=1". This lets you handle that scenario specially if you +// wish. The response must be a 2xx. +// +// First, a header is looked for "X-Terraform-Get" which should contain +// a source URL to download. +// +// If the header is not present, then a meta tag is searched for named +// "terraform-get" and the content should be a source URL. +// +// The source URL, whether from the header or meta tag, must be a fully +// formed URL. The shorthand syntax of "github.com/foo/bar" or relative +// paths are not allowed. +type HttpGetter struct { + getter + + // Netrc, if true, will lookup and use auth information found + // in the user's netrc file if available. + Netrc bool + + // Client is the http.Client to use for Get requests. + // This defaults to a cleanhttp.DefaultClient if left unset. + Client *http.Client + + // Header contains optional request header fields that should be included + // with every HTTP request. Note that the zero value of this field is nil, + // and as such it needs to be initialized before use, via something like + // make(http.Header). + Header http.Header +} + +func (g *HttpGetter) ClientMode(u *url.URL) (ClientMode, error) { + if strings.HasSuffix(u.Path, "/") { + return ClientModeDir, nil + } + return ClientModeFile, nil +} + +func (g *HttpGetter) Get(dst string, u *url.URL) error { + ctx := g.Context() + // Copy the URL so we can modify it + var newU url.URL = *u + u = &newU + + if g.Netrc { + // Add auth from netrc if we can + if err := addAuthFromNetrc(u); err != nil { + return err + } + } + + if g.Client == nil { + g.Client = httpClient + } + + // Add terraform-get to the parameter. + q := u.Query() + q.Add("terraform-get", "1") + u.RawQuery = q.Encode() + + // Get the URL + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return err + } + + if g.Header != nil { + req.Header = g.Header.Clone() + } + + resp, err := g.Client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return fmt.Errorf("bad response code: %d", resp.StatusCode) + } + + // Extract the source URL + var source string + if v := resp.Header.Get("X-Terraform-Get"); v != "" { + source = v + } else { + source, err = g.parseMeta(resp.Body) + if err != nil { + return err + } + } + if source == "" { + return fmt.Errorf("no source URL was returned") + } + + // If there is a subdir component, then we download the root separately + // into a temporary directory, then copy over the proper subdir. + source, subDir := SourceDirSubdir(source) + if subDir == "" { + var opts []ClientOption + if g.client != nil { + opts = g.client.Options + } + return Get(dst, source, opts...) + } + + // We have a subdir, time to jump some hoops + return g.getSubdir(ctx, dst, source, subDir) +} + +// GetFile fetches the file from src and stores it at dst. +// If the server supports Accept-Range, HttpGetter will attempt a range +// request. This means it is the caller's responsibility to ensure that an +// older version of the destination file does not exist, else it will be either +// falsely identified as being replaced, or corrupted with extra bytes +// appended. +func (g *HttpGetter) GetFile(dst string, src *url.URL) error { + ctx := g.Context() + if g.Netrc { + // Add auth from netrc if we can + if err := addAuthFromNetrc(src); err != nil { + return err + } + } + // Create all the parent directories if needed + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + f, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, os.FileMode(0666)) + if err != nil { + return err + } + defer f.Close() + + if g.Client == nil { + g.Client = httpClient + } + + var currentFileSize int64 + + // We first make a HEAD request so we can check + // if the server supports range queries. If the server/URL doesn't + // support HEAD requests, we just fall back to GET. + req, err := http.NewRequest("HEAD", src.String(), nil) + if err != nil { + return err + } + if g.Header != nil { + req.Header = g.Header.Clone() + } + headResp, err := g.Client.Do(req) + if err == nil { + headResp.Body.Close() + if headResp.StatusCode == 200 { + // If the HEAD request succeeded, then attempt to set the range + // query if we can. + if headResp.Header.Get("Accept-Ranges") == "bytes" && headResp.ContentLength >= 0 { + if fi, err := f.Stat(); err == nil { + if _, err = f.Seek(0, io.SeekEnd); err == nil { + currentFileSize = fi.Size() + req.Header.Set("Range", fmt.Sprintf("bytes=%d-", currentFileSize)) + if currentFileSize >= headResp.ContentLength { + // file already present + return nil + } + } + } + } + } + } + req.Method = "GET" + + resp, err := g.Client.Do(req) + if err != nil { + return err + } + switch resp.StatusCode { + case http.StatusOK, http.StatusPartialContent: + // all good + default: + resp.Body.Close() + return fmt.Errorf("bad response code: %d", resp.StatusCode) + } + + body := resp.Body + + if g.client != nil && g.client.ProgressListener != nil { + // track download + fn := filepath.Base(src.EscapedPath()) + body = g.client.ProgressListener.TrackProgress(fn, currentFileSize, currentFileSize+resp.ContentLength, resp.Body) + } + defer body.Close() + + n, err := Copy(ctx, f, body) + if err == nil && n < resp.ContentLength { + err = io.ErrShortWrite + } + return err +} + +// getSubdir downloads the source into the destination, but with +// the proper subdir. +func (g *HttpGetter) getSubdir(ctx context.Context, dst, source, subDir string) error { + // Create a temporary directory to store the full source. This has to be + // a non-existent directory. + td, tdcloser, err := safetemp.Dir("", "getter") + if err != nil { + return err + } + defer tdcloser.Close() + + var opts []ClientOption + if g.client != nil { + opts = g.client.Options + } + // Download that into the given directory + if err := Get(td, source, opts...); err != nil { + return err + } + + // Process any globbing + sourcePath, err := SubdirGlob(td, subDir) + if err != nil { + return err + } + + // Make sure the subdir path actually exists + if _, err := os.Stat(sourcePath); err != nil { + return fmt.Errorf( + "Error downloading %s: %s", source, err) + } + + // Copy the subdirectory into our actual destination. + if err := os.RemoveAll(dst); err != nil { + return err + } + + // Make the final destination + if err := os.MkdirAll(dst, 0755); err != nil { + return err + } + + return copyDir(ctx, dst, sourcePath, false) +} + +// parseMeta looks for the first meta tag in the given reader that +// will give us the source URL. +func (g *HttpGetter) parseMeta(r io.Reader) (string, error) { + d := xml.NewDecoder(r) + d.CharsetReader = charsetReader + d.Strict = false + var err error + var t xml.Token + for { + t, err = d.Token() + if err != nil { + if err == io.EOF { + err = nil + } + return "", err + } + if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { + return "", nil + } + if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { + return "", nil + } + e, ok := t.(xml.StartElement) + if !ok || !strings.EqualFold(e.Name.Local, "meta") { + continue + } + if attrValue(e.Attr, "name") != "terraform-get" { + continue + } + if f := attrValue(e.Attr, "content"); f != "" { + return f, nil + } + } +} + +// attrValue returns the attribute value for the case-insensitive key +// `name', or the empty string if nothing is found. +func attrValue(attrs []xml.Attr, name string) string { + for _, a := range attrs { + if strings.EqualFold(a.Name.Local, name) { + return a.Value + } + } + return "" +} + +// charsetReader returns a reader for the given charset. Currently +// it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful +// error which is printed by go get, so the user can find why the package +// wasn't downloaded if the encoding is not supported. Note that, in +// order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters +// greater than 0x7f are not rejected). +func charsetReader(charset string, input io.Reader) (io.Reader, error) { + switch strings.ToLower(charset) { + case "ascii": + return input, nil + default: + return nil, fmt.Errorf("can't decode XML document using charset %q", charset) + } +} diff --git a/vendor/github.com/hashicorp/go-getter/get_mock.go b/vendor/github.com/hashicorp/go-getter/get_mock.go new file mode 100644 index 000000000..e2a98ea28 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_mock.go @@ -0,0 +1,54 @@ +package getter + +import ( + "net/url" +) + +// MockGetter is an implementation of Getter that can be used for tests. +type MockGetter struct { + getter + + // Proxy, if set, will be called after recording the calls below. + // If it isn't set, then the *Err values will be returned. + Proxy Getter + + GetCalled bool + GetDst string + GetURL *url.URL + GetErr error + + GetFileCalled bool + GetFileDst string + GetFileURL *url.URL + GetFileErr error +} + +func (g *MockGetter) Get(dst string, u *url.URL) error { + g.GetCalled = true + g.GetDst = dst + g.GetURL = u + + if g.Proxy != nil { + return g.Proxy.Get(dst, u) + } + + return g.GetErr +} + +func (g *MockGetter) GetFile(dst string, u *url.URL) error { + g.GetFileCalled = true + g.GetFileDst = dst + g.GetFileURL = u + + if g.Proxy != nil { + return g.Proxy.GetFile(dst, u) + } + return g.GetFileErr +} + +func (g *MockGetter) ClientMode(u *url.URL) (ClientMode, error) { + if l := len(u.Path); l > 0 && u.Path[l-1:] == "/" { + return ClientModeDir, nil + } + return ClientModeFile, nil +} diff --git a/vendor/github.com/hashicorp/go-getter/get_s3.go b/vendor/github.com/hashicorp/go-getter/get_s3.go new file mode 100644 index 000000000..93eeb0b81 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/get_s3.go @@ -0,0 +1,275 @@ +package getter + +import ( + "context" + "fmt" + "net/url" + "os" + "path/filepath" + "strings" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" + "github.com/aws/aws-sdk-go/aws/ec2metadata" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/s3" +) + +// S3Getter is a Getter implementation that will download a module from +// a S3 bucket. +type S3Getter struct { + getter +} + +func (g *S3Getter) ClientMode(u *url.URL) (ClientMode, error) { + // Parse URL + region, bucket, path, _, creds, err := g.parseUrl(u) + if err != nil { + return 0, err + } + + // Create client config + config := g.getAWSConfig(region, u, creds) + sess := session.New(config) + client := s3.New(sess) + + // List the object(s) at the given prefix + req := &s3.ListObjectsInput{ + Bucket: aws.String(bucket), + Prefix: aws.String(path), + } + resp, err := client.ListObjects(req) + if err != nil { + return 0, err + } + + for _, o := range resp.Contents { + // Use file mode on exact match. + if *o.Key == path { + return ClientModeFile, nil + } + + // Use dir mode if child keys are found. + if strings.HasPrefix(*o.Key, path+"/") { + return ClientModeDir, nil + } + } + + // There was no match, so just return file mode. The download is going + // to fail but we will let S3 return the proper error later. + return ClientModeFile, nil +} + +func (g *S3Getter) Get(dst string, u *url.URL) error { + ctx := g.Context() + + // Parse URL + region, bucket, path, _, creds, err := g.parseUrl(u) + if err != nil { + return err + } + + // Remove destination if it already exists + _, err = os.Stat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + + if err == nil { + // Remove the destination + if err := os.RemoveAll(dst); err != nil { + return err + } + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + config := g.getAWSConfig(region, u, creds) + sess := session.New(config) + client := s3.New(sess) + + // List files in path, keep listing until no more objects are found + lastMarker := "" + hasMore := true + for hasMore { + req := &s3.ListObjectsInput{ + Bucket: aws.String(bucket), + Prefix: aws.String(path), + } + if lastMarker != "" { + req.Marker = aws.String(lastMarker) + } + + resp, err := client.ListObjects(req) + if err != nil { + return err + } + + hasMore = aws.BoolValue(resp.IsTruncated) + + // Get each object storing each file relative to the destination path + for _, object := range resp.Contents { + lastMarker = aws.StringValue(object.Key) + objPath := aws.StringValue(object.Key) + + // If the key ends with a backslash assume it is a directory and ignore + if strings.HasSuffix(objPath, "/") { + continue + } + + // Get the object destination path + objDst, err := filepath.Rel(path, objPath) + if err != nil { + return err + } + objDst = filepath.Join(dst, objDst) + + if err := g.getObject(ctx, client, objDst, bucket, objPath, ""); err != nil { + return err + } + } + } + + return nil +} + +func (g *S3Getter) GetFile(dst string, u *url.URL) error { + ctx := g.Context() + region, bucket, path, version, creds, err := g.parseUrl(u) + if err != nil { + return err + } + + config := g.getAWSConfig(region, u, creds) + sess := session.New(config) + client := s3.New(sess) + return g.getObject(ctx, client, dst, bucket, path, version) +} + +func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, key, version string) error { + req := &s3.GetObjectInput{ + Bucket: aws.String(bucket), + Key: aws.String(key), + } + if version != "" { + req.VersionId = aws.String(version) + } + + resp, err := client.GetObject(req) + if err != nil { + return err + } + + // Create all the parent directories + if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { + return err + } + + f, err := os.Create(dst) + if err != nil { + return err + } + defer f.Close() + + _, err = Copy(ctx, f, resp.Body) + return err +} + +func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config { + conf := &aws.Config{} + if creds == nil { + // Grab the metadata URL + metadataURL := os.Getenv("AWS_METADATA_URL") + if metadataURL == "" { + metadataURL = "http://169.254.169.254:80/latest" + } + + creds = credentials.NewChainCredentials( + []credentials.Provider{ + &credentials.EnvProvider{}, + &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, + &ec2rolecreds.EC2RoleProvider{ + Client: ec2metadata.New(session.New(&aws.Config{ + Endpoint: aws.String(metadataURL), + })), + }, + }) + } + + if creds != nil { + conf.Endpoint = &url.Host + conf.S3ForcePathStyle = aws.Bool(true) + if url.Scheme == "http" { + conf.DisableSSL = aws.Bool(true) + } + } + + conf.Credentials = creds + if region != "" { + conf.Region = aws.String(region) + } + + return conf +} + +func (g *S3Getter) parseUrl(u *url.URL) (region, bucket, path, version string, creds *credentials.Credentials, err error) { + // This just check whether we are dealing with S3 or + // any other S3 compliant service. S3 has a predictable + // url as others do not + if strings.Contains(u.Host, "amazonaws.com") { + // Expected host style: s3.amazonaws.com. They always have 3 parts, + // although the first may differ if we're accessing a specific region. + hostParts := strings.Split(u.Host, ".") + if len(hostParts) != 3 { + err = fmt.Errorf("URL is not a valid S3 URL") + return + } + + // Parse the region out of the first part of the host + region = strings.TrimPrefix(strings.TrimPrefix(hostParts[0], "s3-"), "s3") + if region == "" { + region = "us-east-1" + } + + pathParts := strings.SplitN(u.Path, "/", 3) + if len(pathParts) != 3 { + err = fmt.Errorf("URL is not a valid S3 URL") + return + } + + bucket = pathParts[1] + path = pathParts[2] + version = u.Query().Get("version") + + } else { + pathParts := strings.SplitN(u.Path, "/", 3) + if len(pathParts) != 3 { + err = fmt.Errorf("URL is not a valid S3 complaint URL") + return + } + bucket = pathParts[1] + path = pathParts[2] + version = u.Query().Get("version") + region = u.Query().Get("region") + if region == "" { + region = "us-east-1" + } + } + + _, hasAwsId := u.Query()["aws_access_key_id"] + _, hasAwsSecret := u.Query()["aws_access_key_secret"] + _, hasAwsToken := u.Query()["aws_access_token"] + if hasAwsId || hasAwsSecret || hasAwsToken { + creds = credentials.NewStaticCredentials( + u.Query().Get("aws_access_key_id"), + u.Query().Get("aws_access_key_secret"), + u.Query().Get("aws_access_token"), + ) + } + + return +} diff --git a/vendor/github.com/hashicorp/go-getter/go.mod b/vendor/github.com/hashicorp/go-getter/go.mod new file mode 100644 index 000000000..a869e8f80 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/go.mod @@ -0,0 +1,23 @@ +module github.com/hashicorp/go-getter + +require ( + cloud.google.com/go v0.45.1 + github.com/aws/aws-sdk-go v1.15.78 + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d + github.com/cheggaaa/pb v1.0.27 + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fatih/color v1.7.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.0 + github.com/hashicorp/go-safetemp v1.0.0 + github.com/hashicorp/go-version v1.1.0 + github.com/mattn/go-colorable v0.0.9 // indirect + github.com/mattn/go-isatty v0.0.4 // indirect + github.com/mattn/go-runewidth v0.0.4 // indirect + github.com/mitchellh/go-homedir v1.0.0 + github.com/mitchellh/go-testing-interface v1.0.0 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.2.2 // indirect + github.com/ulikunitz/xz v0.5.5 + google.golang.org/api v0.9.0 + gopkg.in/cheggaaa/pb.v1 v1.0.27 // indirect +) diff --git a/vendor/github.com/hashicorp/go-getter/go.sum b/vendor/github.com/hashicorp/go-getter/go.sum new file mode 100644 index 000000000..b88c747ce --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/go.sum @@ -0,0 +1,162 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1 h1:lRi0CHyU+ytlvylOlFKKq0af6JncuyoRh1J+QJBqQx0= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/aws/aws-sdk-go v1.15.78 h1:LaXy6lWR0YK7LKyuU0QWy2ws/LWTPfYV/UgfiBu4tvY= +github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= +github.com/cheggaaa/pb v1.0.27 h1:wIkZHkNfC7R6GI5w7l/PdAdzXzlrbcI3p8OAlnkTsnc= +github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= +github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= +github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 h1:12VvqtR6Aowv3l/EQUlocDHW2Cp4G9WJVH7uyH8QFJE= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok= +github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +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 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0 h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/cheggaaa/pb.v1 v1.0.27 h1:kJdccidYzt3CaHD1crCFTS1hxyhSi059NhOFUf03YFo= +gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url.go b/vendor/github.com/hashicorp/go-getter/helper/url/url.go new file mode 100644 index 000000000..02497c254 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/helper/url/url.go @@ -0,0 +1,14 @@ +package url + +import ( + "net/url" +) + +// Parse parses rawURL into a URL structure. +// The rawURL may be relative or absolute. +// +// Parse is a wrapper for the Go stdlib net/url Parse function, but returns +// Windows "safe" URLs on Windows platforms. +func Parse(rawURL string) (*url.URL, error) { + return parse(rawURL) +} diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go b/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go new file mode 100644 index 000000000..ed1352a91 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go @@ -0,0 +1,11 @@ +// +build !windows + +package url + +import ( + "net/url" +) + +func parse(rawURL string) (*url.URL, error) { + return url.Parse(rawURL) +} diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go b/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go new file mode 100644 index 000000000..4280ec59a --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go @@ -0,0 +1,39 @@ +package url + +import ( + "fmt" + "net/url" + "path/filepath" + "strings" +) + +func parse(rawURL string) (*url.URL, error) { + // Make sure we're using "/" since URLs are "/"-based. + rawURL = filepath.ToSlash(rawURL) + + if len(rawURL) > 1 && rawURL[1] == ':' { + // Assume we're dealing with a drive letter. In which case we + // force the 'file' scheme to avoid "net/url" URL.String() prepending + // our url with "./". + rawURL = "file://" + rawURL + } + + u, err := url.Parse(rawURL) + if err != nil { + return nil, err + } + + if len(u.Host) > 1 && u.Host[1] == ':' && strings.HasPrefix(rawURL, "file://") { + // Assume we're dealing with a drive letter file path where the drive + // letter has been parsed into the URL Host. + u.Path = fmt.Sprintf("%s%s", u.Host, u.Path) + u.Host = "" + } + + // Remove leading slash for absolute file paths. + if len(u.Path) > 2 && u.Path[0] == '/' && u.Path[2] == ':' { + u.Path = u.Path[1:] + } + + return u, err +} diff --git a/vendor/github.com/hashicorp/go-getter/netrc.go b/vendor/github.com/hashicorp/go-getter/netrc.go new file mode 100644 index 000000000..c7f6a3fb3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/netrc.go @@ -0,0 +1,67 @@ +package getter + +import ( + "fmt" + "net/url" + "os" + "runtime" + + "github.com/bgentry/go-netrc/netrc" + "github.com/mitchellh/go-homedir" +) + +// addAuthFromNetrc adds auth information to the URL from the user's +// netrc file if it can be found. This will only add the auth info +// if the URL doesn't already have auth info specified and the +// the username is blank. +func addAuthFromNetrc(u *url.URL) error { + // If the URL already has auth information, do nothing + if u.User != nil && u.User.Username() != "" { + return nil + } + + // Get the netrc file path + path := os.Getenv("NETRC") + if path == "" { + filename := ".netrc" + if runtime.GOOS == "windows" { + filename = "_netrc" + } + + var err error + path, err = homedir.Expand("~/" + filename) + if err != nil { + return err + } + } + + // If the file is not a file, then do nothing + if fi, err := os.Stat(path); err != nil { + // File doesn't exist, do nothing + if os.IsNotExist(err) { + return nil + } + + // Some other error! + return err + } else if fi.IsDir() { + // File is directory, ignore + return nil + } + + // Load up the netrc file + net, err := netrc.ParseFile(path) + if err != nil { + return fmt.Errorf("Error parsing netrc file at %q: %s", path, err) + } + + machine := net.FindMachine(u.Host) + if machine == nil { + // Machine not found, no problem + return nil + } + + // Set the user info + u.User = url.UserPassword(machine.Login, machine.Password) + return nil +} diff --git a/vendor/github.com/hashicorp/go-getter/source.go b/vendor/github.com/hashicorp/go-getter/source.go new file mode 100644 index 000000000..dab6d400c --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/source.go @@ -0,0 +1,75 @@ +package getter + +import ( + "fmt" + "path/filepath" + "strings" +) + +// SourceDirSubdir takes a source URL and returns a tuple of the URL without +// the subdir and the subdir. +// +// ex: +// dom.com/path/?q=p => dom.com/path/?q=p, "" +// proto://dom.com/path//*?q=p => proto://dom.com/path?q=p, "*" +// proto://dom.com/path//path2?q=p => proto://dom.com/path?q=p, "path2" +// +func SourceDirSubdir(src string) (string, string) { + + // URL might contains another url in query parameters + stop := len(src) + if idx := strings.Index(src, "?"); idx > -1 { + stop = idx + } + + // Calculate an offset to avoid accidentally marking the scheme + // as the dir. + var offset int + if idx := strings.Index(src[:stop], "://"); idx > -1 { + offset = idx + 3 + } + + // First see if we even have an explicit subdir + idx := strings.Index(src[offset:stop], "//") + if idx == -1 { + return src, "" + } + + idx += offset + subdir := src[idx+2:] + src = src[:idx] + + // Next, check if we have query parameters and push them onto the + // URL. + if idx = strings.Index(subdir, "?"); idx > -1 { + query := subdir[idx:] + subdir = subdir[:idx] + src += query + } + + return src, subdir +} + +// SubdirGlob returns the actual subdir with globbing processed. +// +// dst should be a destination directory that is already populated (the +// download is complete) and subDir should be the set subDir. If subDir +// is an empty string, this returns an empty string. +// +// The returned path is the full absolute path. +func SubdirGlob(dst, subDir string) (string, error) { + matches, err := filepath.Glob(filepath.Join(dst, subDir)) + if err != nil { + return "", err + } + + if len(matches) == 0 { + return "", fmt.Errorf("subdir %q not found", subDir) + } + + if len(matches) > 1 { + return "", fmt.Errorf("subdir %q matches multiple paths", subDir) + } + + return matches[0], nil +} diff --git a/vendor/github.com/hashicorp/go-getter/storage.go b/vendor/github.com/hashicorp/go-getter/storage.go new file mode 100644 index 000000000..2bc6b9ec3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/storage.go @@ -0,0 +1,13 @@ +package getter + +// Storage is an interface that knows how to lookup downloaded directories +// as well as download and update directories from their sources into the +// proper location. +type Storage interface { + // Dir returns the directory on local disk where the directory source + // can be loaded from. + Dir(string) (string, bool, error) + + // Get will download and optionally update the given directory. + Get(string, string, bool) error +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 425e03269..79fffc518 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -307,6 +307,9 @@ github.com/hashicorp/go-cty-funcs/crypto github.com/hashicorp/go-cty-funcs/encoding github.com/hashicorp/go-cty-funcs/filesystem github.com/hashicorp/go-cty-funcs/uuid +# github.com/hashicorp/go-getter v1.4.1 +github.com/hashicorp/go-getter +github.com/hashicorp/go-getter/helper/url # github.com/hashicorp/go-getter/gcs/v2 v2.0.0-20200604122502-a6995fa1edad github.com/hashicorp/go-getter/gcs/v2 # github.com/hashicorp/go-getter/s3/v2 v2.0.0-20200604122502-a6995fa1edad From 19bdc8b49e92486500f216bd730a7e743fc0deda Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Mon, 30 Nov 2020 14:34:20 -0800 Subject: [PATCH 09/10] fix conflicts --- builder/digitalocean/config.go | 4 ++-- builder/oracle/oci/config.go | 2 +- post-processor/googlecompute-import/post-processor.go | 6 +----- provisioner/salt-masterless/provisioner.go | 10 +++++----- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index 5e3878411..0eff8d789 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -198,14 +198,14 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { // Check if the PrivateNetworking is enabled by user before use VPC UUID if c.VPCUUID != "" { if c.PrivateNetworking != true { - errs = packer.MultiErrorAppend(errs, errors.New("private networking should be enabled to use vpc_uuid")) + errs = packersdk.MultiErrorAppend(errs, errors.New("private networking should be enabled to use vpc_uuid")) } } // Check if the PrivateNetworking is enabled by user before use ConnectWithPrivateIP if c.ConnectWithPrivateIP == true { if c.PrivateNetworking != true { - errs = packer.MultiErrorAppend(errs, errors.New("private networking should be enabled to use connect_with_private_ip")) + errs = packersdk.MultiErrorAppend(errs, errors.New("private networking should be enabled to use connect_with_private_ip")) } } diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index ac214ae04..c4f588855 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -285,7 +285,7 @@ func (c *Config) Prepare(raws ...interface{}) error { if c.CreateVnicDetails.SubnetId == nil { c.CreateVnicDetails.SubnetId = &c.SubnetID } else if (*c.CreateVnicDetails.SubnetId != c.SubnetID) && (c.SubnetID != "") { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("'create_vnic_details[subnet]' must match 'subnet_ocid' if both are specified")) } diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index ea114eeb8..83e5aeeeb 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -295,11 +295,7 @@ func UploadToBucket(opts option.ClientOption, ui packersdk.Ui, artifact packersd return storageObject.SelfLink, nil } -<<<<<<< HEAD -func CreateGceImage(opts option.ClientOption, ui packersdk.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string, shieldedVMStateConfig *compute.InitialStateConfig) (packer.Artifact, error) { -======= -func CreateGceImage(opts option.ClientOption, ui packersdk.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string) (packersdk.Artifact, error) { ->>>>>>> move Artifact and artifact mock to the sdk +func CreateGceImage(opts option.ClientOption, ui packersdk.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string, shieldedVMStateConfig *compute.InitialStateConfig) (packersdk.Artifact, error) { service, err := compute.NewService(context.TODO(), opts) if err != nil { diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index ed7488aeb..dd94ef650 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -400,7 +400,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe if p.config.GuestOSType == guestexec.WindowsOSType { ui.Message("Downloading Git for Windows") - cmd1 := &packer.RemoteCmd{Command: fmt.Sprintf("powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.28.0.windows.1/Git-2.28.0-64-bit.exe -OutFile $env:TEMP/Git.exe")} + cmd1 := &packersdk.RemoteCmd{Command: fmt.Sprintf("powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.28.0.windows.1/Git-2.28.0-64-bit.exe -OutFile $env:TEMP/Git.exe")} if err = cmd1.RunWithUi(ctx, comm, ui); (err != nil || cmd1.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd1.ExitStatus()) @@ -410,7 +410,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } ui.Message("Installing Git for Windows") - cmd2 := &packer.RemoteCmd{Command: fmt.Sprintf("powershell Start-Process -FilePath $env:TEMP/Git.exe /SILENT -Wait")} + cmd2 := &packersdk.RemoteCmd{Command: fmt.Sprintf("powershell Start-Process -FilePath $env:TEMP/Git.exe /SILENT -Wait")} if err = cmd2.RunWithUi(ctx, comm, ui); (err != nil || cmd2.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd2.ExitStatus()) @@ -420,7 +420,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } ui.Message("Cleaning Up After Git for Windows") - cmd3 := &packer.RemoteCmd{Command: fmt.Sprintf("powershell Remove-Item $env:TEMP/Git.exe")} + cmd3 := &packersdk.RemoteCmd{Command: fmt.Sprintf("powershell Remove-Item $env:TEMP/Git.exe")} if err = cmd3.RunWithUi(ctx, comm, ui); (err != nil || cmd3.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd3.ExitStatus()) @@ -430,7 +430,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } ui.Message("Running salt-call --local winrepo.update_git_repos") - cmd4 := &packer.RemoteCmd{Command: fmt.Sprintf("%s --local winrepo.update_git_repos", filepath.Join(p.config.SaltBinDir, "salt-call"))} + cmd4 := &packersdk.RemoteCmd{Command: fmt.Sprintf("%s --local winrepo.update_git_repos", filepath.Join(p.config.SaltBinDir, "salt-call"))} if err = cmd4.RunWithUi(ctx, comm, ui); (err != nil || cmd4.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd4.ExitStatus()) @@ -440,7 +440,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } ui.Message("Running salt-call --local pkg.refresh_db") - cmd5 := &packer.RemoteCmd{Command: fmt.Sprintf("%s --local pkg.refresh_db", filepath.Join(p.config.SaltBinDir, "salt-call"))} + cmd5 := &packersdk.RemoteCmd{Command: fmt.Sprintf("%s --local pkg.refresh_db", filepath.Join(p.config.SaltBinDir, "salt-call"))} if err = cmd5.RunWithUi(ctx, comm, ui); (err != nil || cmd5.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd5.ExitStatus()) From edbd4839171b00dfee5cb3c35b0513f9535592ad Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 1 Dec 2020 10:59:08 -0800 Subject: [PATCH 10/10] fix go-getter imports --- go.mod | 2 - go.sum | 7 - packer-plugin-sdk/packer/ui.go | 2 +- vendor/github.com/hashicorp/go-getter/LICENSE | 354 ----------------- .../github.com/hashicorp/go-getter/README.md | 362 ------------------ .../hashicorp/go-getter/appveyor.yml | 16 - .../hashicorp/go-getter/checksum.go | 314 --------------- .../github.com/hashicorp/go-getter/client.go | 298 -------------- .../hashicorp/go-getter/client_mode.go | 24 -- .../hashicorp/go-getter/client_option.go | 46 --- .../go-getter/client_option_progress.go | 38 -- .../github.com/hashicorp/go-getter/common.go | 14 - .../hashicorp/go-getter/copy_dir.go | 78 ---- .../hashicorp/go-getter/decompress.go | 58 --- .../hashicorp/go-getter/decompress_bzip2.go | 45 --- .../hashicorp/go-getter/decompress_gzip.go | 49 --- .../hashicorp/go-getter/decompress_tar.go | 160 -------- .../hashicorp/go-getter/decompress_tbz2.go | 33 -- .../hashicorp/go-getter/decompress_testing.go | 171 --------- .../hashicorp/go-getter/decompress_tgz.go | 39 -- .../hashicorp/go-getter/decompress_txz.go | 39 -- .../hashicorp/go-getter/decompress_xz.go | 49 --- .../hashicorp/go-getter/decompress_zip.go | 101 ----- .../github.com/hashicorp/go-getter/detect.go | 105 ----- .../hashicorp/go-getter/detect_bitbucket.go | 66 ---- .../hashicorp/go-getter/detect_file.go | 67 ---- .../hashicorp/go-getter/detect_gcs.go | 43 --- .../hashicorp/go-getter/detect_git.go | 26 -- .../hashicorp/go-getter/detect_github.go | 47 --- .../hashicorp/go-getter/detect_s3.go | 61 --- .../hashicorp/go-getter/detect_ssh.go | 49 --- .../hashicorp/go-getter/folder_storage.go | 65 ---- vendor/github.com/hashicorp/go-getter/get.go | 152 -------- .../hashicorp/go-getter/get_base.go | 20 - .../hashicorp/go-getter/get_file.go | 36 -- .../hashicorp/go-getter/get_file_copy.go | 29 -- .../hashicorp/go-getter/get_file_unix.go | 103 ----- .../hashicorp/go-getter/get_file_windows.go | 136 ------- .../github.com/hashicorp/go-getter/get_gcs.go | 172 --------- .../github.com/hashicorp/go-getter/get_git.go | 313 --------------- .../github.com/hashicorp/go-getter/get_hg.go | 135 ------- .../hashicorp/go-getter/get_http.go | 328 ---------------- .../hashicorp/go-getter/get_mock.go | 54 --- .../github.com/hashicorp/go-getter/get_s3.go | 275 ------------- vendor/github.com/hashicorp/go-getter/go.mod | 23 -- vendor/github.com/hashicorp/go-getter/go.sum | 162 -------- .../hashicorp/go-getter/helper/url/url.go | 14 - .../go-getter/helper/url/url_unix.go | 11 - .../go-getter/helper/url/url_windows.go | 39 -- .../github.com/hashicorp/go-getter/netrc.go | 67 ---- .../github.com/hashicorp/go-getter/source.go | 75 ---- .../github.com/hashicorp/go-getter/storage.go | 13 - vendor/modules.txt | 3 - 53 files changed, 1 insertion(+), 4987 deletions(-) delete mode 100644 vendor/github.com/hashicorp/go-getter/LICENSE delete mode 100644 vendor/github.com/hashicorp/go-getter/README.md delete mode 100644 vendor/github.com/hashicorp/go-getter/appveyor.yml delete mode 100644 vendor/github.com/hashicorp/go-getter/checksum.go delete mode 100644 vendor/github.com/hashicorp/go-getter/client.go delete mode 100644 vendor/github.com/hashicorp/go-getter/client_mode.go delete mode 100644 vendor/github.com/hashicorp/go-getter/client_option.go delete mode 100644 vendor/github.com/hashicorp/go-getter/client_option_progress.go delete mode 100644 vendor/github.com/hashicorp/go-getter/common.go delete mode 100644 vendor/github.com/hashicorp/go-getter/copy_dir.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_bzip2.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_gzip.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_tar.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_tbz2.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_testing.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_tgz.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_txz.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_xz.go delete mode 100644 vendor/github.com/hashicorp/go-getter/decompress_zip.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_bitbucket.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_file.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_gcs.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_git.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_github.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_s3.go delete mode 100644 vendor/github.com/hashicorp/go-getter/detect_ssh.go delete mode 100644 vendor/github.com/hashicorp/go-getter/folder_storage.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_base.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_file.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_file_copy.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_file_unix.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_file_windows.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_gcs.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_git.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_hg.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_http.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_mock.go delete mode 100644 vendor/github.com/hashicorp/go-getter/get_s3.go delete mode 100644 vendor/github.com/hashicorp/go-getter/go.mod delete mode 100644 vendor/github.com/hashicorp/go-getter/go.sum delete mode 100644 vendor/github.com/hashicorp/go-getter/helper/url/url.go delete mode 100644 vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go delete mode 100644 vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go delete mode 100644 vendor/github.com/hashicorp/go-getter/netrc.go delete mode 100644 vendor/github.com/hashicorp/go-getter/source.go delete mode 100644 vendor/github.com/hashicorp/go-getter/storage.go diff --git a/go.mod b/go.mod index da0ef6825..cf76d5690 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,6 @@ require ( github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-cty-funcs v0.0.0-20200930094925-2721b1e36840 - github.com/hashicorp/go-getter v1.4.1 github.com/hashicorp/go-getter/gcs/v2 v2.0.0-20200604122502-a6995fa1edad github.com/hashicorp/go-getter/s3/v2 v2.0.0-20200604122502-a6995fa1edad github.com/hashicorp/go-getter/v2 v2.0.0-20200604122502-a6995fa1edad @@ -95,7 +94,6 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-testing-interface v1.0.3 // indirect github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed - github.com/mitchellh/gox v1.0.1 // indirect github.com/mitchellh/iochan v1.0.0 github.com/mitchellh/mapstructure v1.2.3 github.com/mitchellh/panicwrap v1.0.0 diff --git a/go.sum b/go.sum index bbf61b351..2150402df 100644 --- a/go.sum +++ b/go.sum @@ -376,7 +376,6 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= @@ -511,8 +510,6 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= -github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -820,8 +817,6 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200918174421-af09f7315aff h1:1CPUrky56AcgSpxz/KfgzQWzfG09u5YOL8MvPYBlrL8= -golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -882,8 +877,6 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200828161849-5deb26317202/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20200915173823-2db8f0ff891c/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20200918232735-d647fc253266 h1:k7tVuG0g1JwmD3Jh8oAl1vQ1C3jb4Hi/dUl1wWDBJpQ= -golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201111133315-69daaf961d65 h1:cuDLV0fZoIC/Oj72hGUKPhXR2AvbvJoQKPmSeE5nH4Q= golang.org/x/tools v0.0.0-20201111133315-69daaf961d65/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/packer-plugin-sdk/packer/ui.go b/packer-plugin-sdk/packer/ui.go index 7731d75f0..16ad5d9e6 100644 --- a/packer-plugin-sdk/packer/ui.go +++ b/packer-plugin-sdk/packer/ui.go @@ -11,7 +11,7 @@ import ( "sync" "syscall" - getter "github.com/hashicorp/go-getter" + getter "github.com/hashicorp/go-getter/v2" ) type TTY interface { diff --git a/vendor/github.com/hashicorp/go-getter/LICENSE b/vendor/github.com/hashicorp/go-getter/LICENSE deleted file mode 100644 index c33dcc7c9..000000000 --- a/vendor/github.com/hashicorp/go-getter/LICENSE +++ /dev/null @@ -1,354 +0,0 @@ -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/vendor/github.com/hashicorp/go-getter/README.md b/vendor/github.com/hashicorp/go-getter/README.md deleted file mode 100644 index bbcd15de9..000000000 --- a/vendor/github.com/hashicorp/go-getter/README.md +++ /dev/null @@ -1,362 +0,0 @@ -# go-getter - -[![CircleCI](https://circleci.com/gh/hashicorp/go-getter/tree/master.svg?style=svg)][circleci] -[![Build status](https://ci.appveyor.com/api/projects/status/ulq3qr43n62croyq/branch/master?svg=true)][appveyor] -[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs] - -[circleci]: https://circleci.com/gh/hashicorp/go-getter/tree/master -[godocs]: http://godoc.org/github.com/hashicorp/go-getter -[appveyor]: https://ci.appveyor.com/project/hashicorp/go-getter/branch/master - -go-getter is a library for Go (golang) for downloading files or directories -from various sources using a URL as the primary form of input. - -The power of this library is being flexible in being able to download -from a number of different sources (file paths, Git, HTTP, Mercurial, etc.) -using a single string as input. This removes the burden of knowing how to -download from a variety of sources from the implementer. - -The concept of a _detector_ automatically turns invalid URLs into proper -URLs. For example: "github.com/hashicorp/go-getter" would turn into a -Git URL. Or "./foo" would turn into a file URL. These are extensible. - -This library is used by [Terraform](https://terraform.io) for -downloading modules and [Nomad](https://nomadproject.io) for downloading -binaries. - -## Installation and Usage - -Package documentation can be found on -[GoDoc](http://godoc.org/github.com/hashicorp/go-getter). - -Installation can be done with a normal `go get`: - -``` -$ go get github.com/hashicorp/go-getter -``` - -go-getter also has a command you can use to test URL strings: - -``` -$ go install github.com/hashicorp/go-getter/cmd/go-getter -... - -$ go-getter github.com/foo/bar ./foo -... -``` - -The command is useful for verifying URL structures. - -## URL Format - -go-getter uses a single string URL as input to download from a variety of -protocols. go-getter has various "tricks" with this URL to do certain things. -This section documents the URL format. - -### Supported Protocols and Detectors - -**Protocols** are used to download files/directories using a specific -mechanism. Example protocols are Git and HTTP. - -**Detectors** are used to transform a valid or invalid URL into another -URL if it matches a certain pattern. Example: "github.com/user/repo" is -automatically transformed into a fully valid Git URL. This allows go-getter -to be very user friendly. - -go-getter out of the box supports the following protocols. Additional protocols -can be augmented at runtime by implementing the `Getter` interface. - - * Local files - * Git - * Mercurial - * HTTP - * Amazon S3 - * Google GCP - -In addition to the above protocols, go-getter has what are called "detectors." -These take a URL and attempt to automatically choose the best protocol for -it, which might involve even changing the protocol. The following detection -is built-in by default: - - * File paths such as "./foo" are automatically changed to absolute - file URLs. - * GitHub URLs, such as "github.com/mitchellh/vagrant" are automatically - changed to Git protocol over HTTP. - * BitBucket URLs, such as "bitbucket.org/mitchellh/vagrant" are automatically - changed to a Git or mercurial protocol using the BitBucket API. - -### Forced Protocol - -In some cases, the protocol to use is ambiguous depending on the source -URL. For example, "http://github.com/mitchellh/vagrant.git" could reference -an HTTP URL or a Git URL. Forced protocol syntax is used to disambiguate this -URL. - -Forced protocol can be done by prefixing the URL with the protocol followed -by double colons. For example: `git::http://github.com/mitchellh/vagrant.git` -would download the given HTTP URL using the Git protocol. - -Forced protocols will also override any detectors. - -In the absence of a forced protocol, detectors may be run on the URL, transforming -the protocol anyways. The above example would've used the Git protocol either -way since the Git detector would've detected it was a GitHub URL. - -### Protocol-Specific Options - -Each protocol can support protocol-specific options to configure that -protocol. For example, the `git` protocol supports specifying a `ref` -query parameter that tells it what ref to checkout for that Git -repository. - -The options are specified as query parameters on the URL (or URL-like string) -given to go-getter. Using the Git example above, the URL below is a valid -input to go-getter: - - github.com/hashicorp/go-getter?ref=abcd1234 - -The protocol-specific options are documented below the URL format -section. But because they are part of the URL, we point it out here so -you know they exist. - -### Subdirectories - -If you want to download only a specific subdirectory from a downloaded -directory, you can specify a subdirectory after a double-slash `//`. -go-getter will first download the URL specified _before_ the double-slash -(as if you didn't specify a double-slash), but will then copy the -path after the double slash into the target directory. - -For example, if you're downloading this GitHub repository, but you only -want to download the `testdata` directory, you can do the following: - -``` -https://github.com/hashicorp/go-getter.git//testdata -``` - -If you downloaded this to the `/tmp` directory, then the file -`/tmp/archive.gz` would exist. Notice that this file is in the `testdata` -directory in this repository, but because we specified a subdirectory, -go-getter automatically copied only that directory contents. - -Subdirectory paths may contain may also use filesystem glob patterns. -The path must match _exactly one_ entry or go-getter will return an error. -This is useful if you're not sure the exact directory name but it follows -a predictable naming structure. - -For example, the following URL would also work: - -``` -https://github.com/hashicorp/go-getter.git//test-* -``` - -### Checksumming - -For file downloads of any protocol, go-getter can automatically verify -a checksum for you. Note that checksumming only works for downloading files, -not directories, but checksumming will work for any protocol. - -To checksum a file, append a `checksum` query parameter to the URL. go-getter -will parse out this query parameter automatically and use it to verify the -checksum. The parameter value can be in the format of `type:value` or just -`value`, where type is "md5", "sha1", "sha256", "sha512" or "file" . The -"value" should be the actual checksum value or download URL for "file". When -`type` part is omitted, type will be guessed based on the length of the -checksum string. Examples: - -``` -./foo.txt?checksum=md5:b7d96c89d09d9e204f5fedc4d5d55b21 -``` - -``` -./foo.txt?checksum=b7d96c89d09d9e204f5fedc4d5d55b21 -``` - -``` -./foo.txt?checksum=file:./foo.txt.sha256sum -``` - -When checksumming from a file - ex: with `checksum=file:url` - go-getter will -get the file linked in the URL after `file:` using the same configuration. For -example, in `file:http://releases.ubuntu.com/cosmic/MD5SUMS` go-getter will -download a checksum file under the aforementioned url using the http protocol. -All protocols supported by go-getter can be used. The checksum file will be -downloaded in a temporary file then parsed. The destination of the temporary -file can be changed by setting system specific environment variables: `TMPDIR` -for unix; `TMP`, `TEMP` or `USERPROFILE` on windows. Read godoc of -[os.TempDir](https://golang.org/pkg/os/#TempDir) for more information on the -temporary directory selection. Content of files are expected to be BSD or GNU -style. Once go-getter is done with the checksum file; it is deleted. - -The checksum query parameter is never sent to the backend protocol -implementation. It is used at a higher level by go-getter itself. - -If the destination file exists and the checksums match: download -will be skipped. - -### Unarchiving - -go-getter will automatically unarchive files into a file or directory -based on the extension of the file being requested (over any protocol). -This works for both file and directory downloads. - -go-getter looks for an `archive` query parameter to specify the format of -the archive. If this isn't specified, go-getter will use the extension of -the path to see if it appears archived. Unarchiving can be explicitly -disabled by setting the `archive` query parameter to `false`. - -The following archive formats are supported: - - * `tar.gz` and `tgz` - * `tar.bz2` and `tbz2` - * `tar.xz` and `txz` - * `zip` - * `gz` - * `bz2` - * `xz` - -For example, an example URL is shown below: - -``` -./foo.zip -``` - -This will automatically be inferred to be a ZIP file and will be extracted. -You can also be explicit about the archive type: - -``` -./some/other/path?archive=zip -``` - -And finally, you can disable archiving completely: - -``` -./some/path?archive=false -``` - -You can combine unarchiving with the other features of go-getter such -as checksumming. The special `archive` query parameter will be removed -from the URL before going to the final protocol downloader. - -## Protocol-Specific Options - -This section documents the protocol-specific options that can be specified for -go-getter. These options should be appended to the input as normal query -parameters ([HTTP headers](#headers) are an exception to this, however). -Depending on the usage of go-getter, applications may provide alternate ways of -inputting options. For example, [Nomad](https://www.nomadproject.io) provides a -nice options block for specifying options rather than in the URL. - -## General (All Protocols) - -The options below are available to all protocols: - - * `archive` - The archive format to use to unarchive this file, or "" (empty - string) to disable unarchiving. For more details, see the complete section - on archive support above. - - * `checksum` - Checksum to verify the downloaded file or archive. See - the entire section on checksumming above for format and more details. - - * `filename` - When in file download mode, allows specifying the name of the - downloaded file on disk. Has no effect in directory mode. - -### Local Files (`file`) - -None - -### Git (`git`) - - * `ref` - The Git ref to checkout. This is a ref, so it can point to - a commit SHA, a branch name, etc. If it is a named ref such as a branch - name, go-getter will update it to the latest on each get. - - * `sshkey` - An SSH private key to use during clones. The provided key must - be a base64-encoded string. For example, to generate a suitable `sshkey` - from a private key file on disk, you would run `base64 -w0 `. - - **Note**: Git 2.3+ is required to use this feature. - - * `depth` - The Git clone depth. The provided number specifies the last `n` - revisions to clone from the repository. - - -The `git` getter accepts both URL-style SSH addresses like -`git::ssh://git@example.com/foo/bar`, and "scp-style" addresses like -`git::git@example.com/foo/bar`. In the latter case, omitting the `git::` -force prefix is allowed if the username prefix is exactly `git@`. - -The "scp-style" addresses _cannot_ be used in conjunction with the `ssh://` -scheme prefix, because in that case the colon is used to mark an optional -port number to connect on, rather than to delimit the path from the host. - -### Mercurial (`hg`) - - * `rev` - The Mercurial revision to checkout. - -### HTTP (`http`) - -#### Basic Authentication - -To use HTTP basic authentication with go-getter, simply prepend `username:password@` to the -hostname in the URL such as `https://Aladdin:OpenSesame@www.example.com/index.html`. All special -characters, including the username and password, must be URL encoded. - -#### Headers - -Optional request headers can be added by supplying them in a custom -[`HttpGetter`](https://godoc.org/github.com/hashicorp/go-getter#HttpGetter) -(_not_ as query parameters like most other options). These headers will be sent -out on every request the getter in question makes. - -### S3 (`s3`) - -S3 takes various access configurations in the URL. Note that it will also -read these from standard AWS environment variables if they're set. S3 compliant servers like Minio -are also supported. If the query parameters are present, these take priority. - - * `aws_access_key_id` - AWS access key. - * `aws_access_key_secret` - AWS access key secret. - * `aws_access_token` - AWS access token if this is being used. - -#### Using IAM Instance Profiles with S3 - -If you use go-getter and want to use an EC2 IAM Instance Profile to avoid -using credentials, then just omit these and the profile, if available will -be used automatically. - -### Using S3 with Minio - If you use go-gitter for Minio support, you must consider the following: - - * `aws_access_key_id` (required) - Minio access key. - * `aws_access_key_secret` (required) - Minio access key secret. - * `region` (optional - defaults to us-east-1) - Region identifier to use. - * `version` (optional - defaults to Minio default) - Configuration file format. - -#### S3 Bucket Examples - -S3 has several addressing schemes used to reference your bucket. These are -listed here: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro - -Some examples for these addressing schemes: -- s3::https://s3.amazonaws.com/bucket/foo -- s3::https://s3-eu-west-1.amazonaws.com/bucket/foo -- bucket.s3.amazonaws.com/foo -- bucket.s3-eu-west-1.amazonaws.com/foo/bar -- "s3::http://127.0.0.1:9000/test-bucket/hello.txt?aws_access_key_id=KEYID&aws_access_key_secret=SECRETKEY®ion=us-east-2" - -### GCS (`gcs`) - -#### GCS Authentication - -In order to access to GCS, authentication credentials should be provided. More information can be found [here](https://cloud.google.com/docs/authentication/getting-started) - -#### GCS Bucket Examples - -- gcs::https://www.googleapis.com/storage/v1/bucket -- gcs::https://www.googleapis.com/storage/v1/bucket/foo.zip -- www.googleapis.com/storage/v1/bucket/foo - -#### GCS Testing - -The tests for `get_gcs.go` require you to have GCP credentials set in your environment. These credentials can have any level of permissions to any project, they just need to exist. This means setting `GOOGLE_APPLICATION_CREDENTIALS="~/path/to/credentials.json"` or `GOOGLE_CREDENTIALS="{stringified-credentials-json}"`. Due to this configuration, `get_gcs_test.go` will fail for external contributors in CircleCI. diff --git a/vendor/github.com/hashicorp/go-getter/appveyor.yml b/vendor/github.com/hashicorp/go-getter/appveyor.yml deleted file mode 100644 index 1e8718e17..000000000 --- a/vendor/github.com/hashicorp/go-getter/appveyor.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: "build-{branch}-{build}" -image: Visual Studio 2017 -clone_folder: c:\gopath\github.com\hashicorp\go-getter -environment: - GOPATH: c:\gopath -install: -- cmd: >- - echo %Path% - - go version - - go env - - go get -d -v -t ./... -build_script: -- cmd: go test ./... diff --git a/vendor/github.com/hashicorp/go-getter/checksum.go b/vendor/github.com/hashicorp/go-getter/checksum.go deleted file mode 100644 index eeccfea9d..000000000 --- a/vendor/github.com/hashicorp/go-getter/checksum.go +++ /dev/null @@ -1,314 +0,0 @@ -package getter - -import ( - "bufio" - "bytes" - "crypto/md5" - "crypto/sha1" - "crypto/sha256" - "crypto/sha512" - "encoding/hex" - "fmt" - "hash" - "io" - "net/url" - "os" - "path/filepath" - "strings" - - urlhelper "github.com/hashicorp/go-getter/helper/url" -) - -// FileChecksum helps verifying the checksum for a file. -type FileChecksum struct { - Type string - Hash hash.Hash - Value []byte - Filename string -} - -// A ChecksumError is returned when a checksum differs -type ChecksumError struct { - Hash hash.Hash - Actual []byte - Expected []byte - File string -} - -func (cerr *ChecksumError) Error() string { - if cerr == nil { - return "" - } - return fmt.Sprintf( - "Checksums did not match for %s.\nExpected: %s\nGot: %s\n%T", - cerr.File, - hex.EncodeToString(cerr.Expected), - hex.EncodeToString(cerr.Actual), - cerr.Hash, // ex: *sha256.digest - ) -} - -// checksum is a simple method to compute the checksum of a source file -// and compare it to the given expected value. -func (c *FileChecksum) checksum(source string) error { - f, err := os.Open(source) - if err != nil { - return fmt.Errorf("Failed to open file for checksum: %s", err) - } - defer f.Close() - - c.Hash.Reset() - if _, err := io.Copy(c.Hash, f); err != nil { - return fmt.Errorf("Failed to hash: %s", err) - } - - if actual := c.Hash.Sum(nil); !bytes.Equal(actual, c.Value) { - return &ChecksumError{ - Hash: c.Hash, - Actual: actual, - Expected: c.Value, - File: source, - } - } - - return nil -} - -// extractChecksum will return a FileChecksum based on the 'checksum' -// parameter of u. -// ex: -// http://hashicorp.com/terraform?checksum= -// http://hashicorp.com/terraform?checksum=: -// http://hashicorp.com/terraform?checksum=file: -// when checksumming from a file, extractChecksum will go get checksum_url -// in a temporary directory, parse the content of the file then delete it. -// Content of files are expected to be BSD style or GNU style. -// -// BSD-style checksum: -// MD5 (file1) = -// MD5 (file2) = -// -// GNU-style: -// file1 -// *file2 -// -// see parseChecksumLine for more detail on checksum file parsing -func (c *Client) extractChecksum(u *url.URL) (*FileChecksum, error) { - q := u.Query() - v := q.Get("checksum") - - if v == "" { - return nil, nil - } - - vs := strings.SplitN(v, ":", 2) - switch len(vs) { - case 2: - break // good - default: - // here, we try to guess the checksum from it's length - // if the type was not passed - return newChecksumFromValue(v, filepath.Base(u.EscapedPath())) - } - - checksumType, checksumValue := vs[0], vs[1] - - switch checksumType { - case "file": - return c.ChecksumFromFile(checksumValue, u) - default: - return newChecksumFromType(checksumType, checksumValue, filepath.Base(u.EscapedPath())) - } -} - -func newChecksum(checksumValue, filename string) (*FileChecksum, error) { - c := &FileChecksum{ - Filename: filename, - } - var err error - c.Value, err = hex.DecodeString(checksumValue) - if err != nil { - return nil, fmt.Errorf("invalid checksum: %s", err) - } - return c, nil -} - -func newChecksumFromType(checksumType, checksumValue, filename string) (*FileChecksum, error) { - c, err := newChecksum(checksumValue, filename) - if err != nil { - return nil, err - } - - c.Type = strings.ToLower(checksumType) - switch c.Type { - case "md5": - c.Hash = md5.New() - case "sha1": - c.Hash = sha1.New() - case "sha256": - c.Hash = sha256.New() - case "sha512": - c.Hash = sha512.New() - default: - return nil, fmt.Errorf( - "unsupported checksum type: %s", checksumType) - } - - return c, nil -} - -func newChecksumFromValue(checksumValue, filename string) (*FileChecksum, error) { - c, err := newChecksum(checksumValue, filename) - if err != nil { - return nil, err - } - - switch len(c.Value) { - case md5.Size: - c.Hash = md5.New() - c.Type = "md5" - case sha1.Size: - c.Hash = sha1.New() - c.Type = "sha1" - case sha256.Size: - c.Hash = sha256.New() - c.Type = "sha256" - case sha512.Size: - c.Hash = sha512.New() - c.Type = "sha512" - default: - return nil, fmt.Errorf("Unknown type for checksum %s", checksumValue) - } - - return c, nil -} - -// ChecksumFromFile will return all the FileChecksums found in file -// -// ChecksumFromFile will try to guess the hashing algorithm based on content -// of checksum file -// -// ChecksumFromFile will only return checksums for files that match file -// behind src -func (c *Client) ChecksumFromFile(checksumFile string, src *url.URL) (*FileChecksum, error) { - checksumFileURL, err := urlhelper.Parse(checksumFile) - if err != nil { - return nil, err - } - - tempfile, err := tmpFile("", filepath.Base(checksumFileURL.Path)) - if err != nil { - return nil, err - } - defer os.Remove(tempfile) - - c2 := &Client{ - Ctx: c.Ctx, - Getters: c.Getters, - Decompressors: c.Decompressors, - Detectors: c.Detectors, - Pwd: c.Pwd, - Dir: false, - Src: checksumFile, - Dst: tempfile, - ProgressListener: c.ProgressListener, - } - if err = c2.Get(); err != nil { - return nil, fmt.Errorf( - "Error downloading checksum file: %s", err) - } - - filename := filepath.Base(src.Path) - absPath, err := filepath.Abs(src.Path) - if err != nil { - return nil, err - } - checksumFileDir := filepath.Dir(checksumFileURL.Path) - relpath, err := filepath.Rel(checksumFileDir, absPath) - switch { - case err == nil || - err.Error() == "Rel: can't make "+absPath+" relative to "+checksumFileDir: - // ex: on windows C:\gopath\...\content.txt cannot be relative to \ - // which is okay, may be another expected path will work. - break - default: - return nil, err - } - - // possible file identifiers: - options := []string{ - filename, // ubuntu-14.04.1-server-amd64.iso - "*" + filename, // *ubuntu-14.04.1-server-amd64.iso Standard checksum - "?" + filename, // ?ubuntu-14.04.1-server-amd64.iso shasum -p - relpath, // dir/ubuntu-14.04.1-server-amd64.iso - "./" + relpath, // ./dir/ubuntu-14.04.1-server-amd64.iso - absPath, // fullpath; set if local - } - - f, err := os.Open(tempfile) - if err != nil { - return nil, fmt.Errorf( - "Error opening downloaded file: %s", err) - } - defer f.Close() - rd := bufio.NewReader(f) - for { - line, err := rd.ReadString('\n') - if err != nil { - if err != io.EOF { - return nil, fmt.Errorf( - "Error reading checksum file: %s", err) - } - break - } - checksum, err := parseChecksumLine(line) - if err != nil || checksum == nil { - continue - } - if checksum.Filename == "" { - // filename not sure, let's try - return checksum, nil - } - // make sure the checksum is for the right file - for _, option := range options { - if option != "" && checksum.Filename == option { - // any checksum will work so we return the first one - return checksum, nil - } - } - } - return nil, fmt.Errorf("no checksum found in: %s", checksumFile) -} - -// parseChecksumLine takes a line from a checksum file and returns -// checksumType, checksumValue and filename parseChecksumLine guesses the style -// of the checksum BSD vs GNU by splitting the line and by counting the parts. -// of a line. -// for BSD type sums parseChecksumLine guesses the hashing algorithm -// by checking the length of the checksum. -func parseChecksumLine(line string) (*FileChecksum, error) { - parts := strings.Fields(line) - - switch len(parts) { - case 4: - // BSD-style checksum: - // MD5 (file1) = - // MD5 (file2) = - if len(parts[1]) <= 2 || - parts[1][0] != '(' || parts[1][len(parts[1])-1] != ')' { - return nil, fmt.Errorf( - "Unexpected BSD-style-checksum filename format: %s", line) - } - filename := parts[1][1 : len(parts[1])-1] - return newChecksumFromType(parts[0], parts[3], filename) - case 2: - // GNU-style: - // file1 - // *file2 - return newChecksumFromValue(parts[0], parts[1]) - case 0: - return nil, nil // empty line - default: - return newChecksumFromValue(parts[0], "") - } -} diff --git a/vendor/github.com/hashicorp/go-getter/client.go b/vendor/github.com/hashicorp/go-getter/client.go deleted file mode 100644 index 38fb43b8f..000000000 --- a/vendor/github.com/hashicorp/go-getter/client.go +++ /dev/null @@ -1,298 +0,0 @@ -package getter - -import ( - "context" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strconv" - "strings" - - urlhelper "github.com/hashicorp/go-getter/helper/url" - safetemp "github.com/hashicorp/go-safetemp" -) - -// Client is a client for downloading things. -// -// Top-level functions such as Get are shortcuts for interacting with a client. -// Using a client directly allows more fine-grained control over how downloading -// is done, as well as customizing the protocols supported. -type Client struct { - // Ctx for cancellation - Ctx context.Context - - // Src is the source URL to get. - // - // Dst is the path to save the downloaded thing as. If Dir is set to - // true, then this should be a directory. If the directory doesn't exist, - // it will be created for you. - // - // Pwd is the working directory for detection. If this isn't set, some - // detection may fail. Client will not default pwd to the current - // working directory for security reasons. - Src string - Dst string - Pwd string - - // Mode is the method of download the client will use. See ClientMode - // for documentation. - Mode ClientMode - - // Detectors is the list of detectors that are tried on the source. - // If this is nil, then the default Detectors will be used. - Detectors []Detector - - // Decompressors is the map of decompressors supported by this client. - // If this is nil, then the default value is the Decompressors global. - Decompressors map[string]Decompressor - - // Getters is the map of protocols supported by this client. If this - // is nil, then the default Getters variable will be used. - Getters map[string]Getter - - // Dir, if true, tells the Client it is downloading a directory (versus - // a single file). This distinction is necessary since filenames and - // directory names follow the same format so disambiguating is impossible - // without knowing ahead of time. - // - // WARNING: deprecated. If Mode is set, that will take precedence. - Dir bool - - // ProgressListener allows to track file downloads. - // By default a no op progress listener is used. - ProgressListener ProgressTracker - - Options []ClientOption -} - -// Get downloads the configured source to the destination. -func (c *Client) Get() error { - if err := c.Configure(c.Options...); err != nil { - return err - } - - // Store this locally since there are cases we swap this - mode := c.Mode - if mode == ClientModeInvalid { - if c.Dir { - mode = ClientModeDir - } else { - mode = ClientModeFile - } - } - - src, err := Detect(c.Src, c.Pwd, c.Detectors) - if err != nil { - return err - } - - // Determine if we have a forced protocol, i.e. "git::http://..." - force, src := getForcedGetter(src) - - // If there is a subdir component, then we download the root separately - // and then copy over the proper subdir. - var realDst string - dst := c.Dst - src, subDir := SourceDirSubdir(src) - if subDir != "" { - td, tdcloser, err := safetemp.Dir("", "getter") - if err != nil { - return err - } - defer tdcloser.Close() - - realDst = dst - dst = td - } - - u, err := urlhelper.Parse(src) - if err != nil { - return err - } - if force == "" { - force = u.Scheme - } - - g, ok := c.Getters[force] - if !ok { - return fmt.Errorf( - "download not supported for scheme '%s'", force) - } - - // We have magic query parameters that we use to signal different features - q := u.Query() - - // Determine if we have an archive type - archiveV := q.Get("archive") - if archiveV != "" { - // Delete the paramter since it is a magic parameter we don't - // want to pass on to the Getter - q.Del("archive") - u.RawQuery = q.Encode() - - // If we can parse the value as a bool and it is false, then - // set the archive to "-" which should never map to a decompressor - if b, err := strconv.ParseBool(archiveV); err == nil && !b { - archiveV = "-" - } - } - if archiveV == "" { - // We don't appear to... but is it part of the filename? - matchingLen := 0 - for k := range c.Decompressors { - if strings.HasSuffix(u.Path, "."+k) && len(k) > matchingLen { - archiveV = k - matchingLen = len(k) - } - } - } - - // If we have a decompressor, then we need to change the destination - // to download to a temporary path. We unarchive this into the final, - // real path. - var decompressDst string - var decompressDir bool - decompressor := c.Decompressors[archiveV] - if decompressor != nil { - // Create a temporary directory to store our archive. We delete - // this at the end of everything. - td, err := ioutil.TempDir("", "getter") - if err != nil { - return fmt.Errorf( - "Error creating temporary directory for archive: %s", err) - } - defer os.RemoveAll(td) - - // Swap the download directory to be our temporary path and - // store the old values. - decompressDst = dst - decompressDir = mode != ClientModeFile - dst = filepath.Join(td, "archive") - mode = ClientModeFile - } - - // Determine checksum if we have one - checksum, err := c.extractChecksum(u) - if err != nil { - return fmt.Errorf("invalid checksum: %s", err) - } - - // Delete the query parameter if we have it. - q.Del("checksum") - u.RawQuery = q.Encode() - - if mode == ClientModeAny { - // Ask the getter which client mode to use - mode, err = g.ClientMode(u) - if err != nil { - return err - } - - // Destination is the base name of the URL path in "any" mode when - // a file source is detected. - if mode == ClientModeFile { - filename := filepath.Base(u.Path) - - // Determine if we have a custom file name - if v := q.Get("filename"); v != "" { - // Delete the query parameter if we have it. - q.Del("filename") - u.RawQuery = q.Encode() - - filename = v - } - - dst = filepath.Join(dst, filename) - } - } - - // If we're not downloading a directory, then just download the file - // and return. - if mode == ClientModeFile { - getFile := true - if checksum != nil { - if err := checksum.checksum(dst); err == nil { - // don't get the file if the checksum of dst is correct - getFile = false - } - } - if getFile { - err := g.GetFile(dst, u) - if err != nil { - return err - } - - if checksum != nil { - if err := checksum.checksum(dst); err != nil { - return err - } - } - } - - if decompressor != nil { - // We have a decompressor, so decompress the current destination - // into the final destination with the proper mode. - err := decompressor.Decompress(decompressDst, dst, decompressDir) - if err != nil { - return err - } - - // Swap the information back - dst = decompressDst - if decompressDir { - mode = ClientModeAny - } else { - mode = ClientModeFile - } - } - - // We check the dir value again because it can be switched back - // if we were unarchiving. If we're still only Get-ing a file, then - // we're done. - if mode == ClientModeFile { - return nil - } - } - - // If we're at this point we're either downloading a directory or we've - // downloaded and unarchived a directory and we're just checking subdir. - // In the case we have a decompressor we don't Get because it was Get - // above. - if decompressor == nil { - // If we're getting a directory, then this is an error. You cannot - // checksum a directory. TODO: test - if checksum != nil { - return fmt.Errorf( - "checksum cannot be specified for directory download") - } - - // We're downloading a directory, which might require a bit more work - // if we're specifying a subdir. - err := g.Get(dst, u) - if err != nil { - err = fmt.Errorf("error downloading '%s': %s", src, err) - return err - } - } - - // If we have a subdir, copy that over - if subDir != "" { - if err := os.RemoveAll(realDst); err != nil { - return err - } - if err := os.MkdirAll(realDst, 0755); err != nil { - return err - } - - // Process any globs - subDir, err := SubdirGlob(dst, subDir) - if err != nil { - return err - } - - return copyDir(c.Ctx, realDst, subDir, false) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-getter/client_mode.go b/vendor/github.com/hashicorp/go-getter/client_mode.go deleted file mode 100644 index 7f02509a7..000000000 --- a/vendor/github.com/hashicorp/go-getter/client_mode.go +++ /dev/null @@ -1,24 +0,0 @@ -package getter - -// ClientMode is the mode that the client operates in. -type ClientMode uint - -const ( - ClientModeInvalid ClientMode = iota - - // ClientModeAny downloads anything it can. In this mode, dst must - // be a directory. If src is a file, it is saved into the directory - // with the basename of the URL. If src is a directory or archive, - // it is unpacked directly into dst. - ClientModeAny - - // ClientModeFile downloads a single file. In this mode, dst must - // be a file path (doesn't have to exist). src must point to a single - // file. It is saved as dst. - ClientModeFile - - // ClientModeDir downloads a directory. In this mode, dst must be - // a directory path (doesn't have to exist). src must point to an - // archive or directory (such as in s3). - ClientModeDir -) diff --git a/vendor/github.com/hashicorp/go-getter/client_option.go b/vendor/github.com/hashicorp/go-getter/client_option.go deleted file mode 100644 index c1ee413b0..000000000 --- a/vendor/github.com/hashicorp/go-getter/client_option.go +++ /dev/null @@ -1,46 +0,0 @@ -package getter - -import "context" - -// A ClientOption allows to configure a client -type ClientOption func(*Client) error - -// Configure configures a client with options. -func (c *Client) Configure(opts ...ClientOption) error { - if c.Ctx == nil { - c.Ctx = context.Background() - } - c.Options = opts - for _, opt := range opts { - err := opt(c) - if err != nil { - return err - } - } - // Default decompressor values - if c.Decompressors == nil { - c.Decompressors = Decompressors - } - // Default detector values - if c.Detectors == nil { - c.Detectors = Detectors - } - // Default getter values - if c.Getters == nil { - c.Getters = Getters - } - - for _, getter := range c.Getters { - getter.SetClient(c) - } - return nil -} - -// WithContext allows to pass a context to operation -// in order to be able to cancel a download in progress. -func WithContext(ctx context.Context) func(*Client) error { - return func(c *Client) error { - c.Ctx = ctx - return nil - } -} diff --git a/vendor/github.com/hashicorp/go-getter/client_option_progress.go b/vendor/github.com/hashicorp/go-getter/client_option_progress.go deleted file mode 100644 index 9b185f71d..000000000 --- a/vendor/github.com/hashicorp/go-getter/client_option_progress.go +++ /dev/null @@ -1,38 +0,0 @@ -package getter - -import ( - "io" -) - -// WithProgress allows for a user to track -// the progress of a download. -// For example by displaying a progress bar with -// current download. -// Not all getters have progress support yet. -func WithProgress(pl ProgressTracker) func(*Client) error { - return func(c *Client) error { - c.ProgressListener = pl - return nil - } -} - -// ProgressTracker allows to track the progress of downloads. -type ProgressTracker interface { - // TrackProgress should be called when - // a new object is being downloaded. - // src is the location the file is - // downloaded from. - // currentSize is the current size of - // the file in case it is a partial - // download. - // totalSize is the total size in bytes, - // size can be zero if the file size - // is not known. - // stream is the file being downloaded, every - // written byte will add up to processed size. - // - // TrackProgress returns a ReadCloser that wraps the - // download in progress ( stream ). - // When the download is finished, body shall be closed. - TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) -} diff --git a/vendor/github.com/hashicorp/go-getter/common.go b/vendor/github.com/hashicorp/go-getter/common.go deleted file mode 100644 index d2afd8ad8..000000000 --- a/vendor/github.com/hashicorp/go-getter/common.go +++ /dev/null @@ -1,14 +0,0 @@ -package getter - -import ( - "io/ioutil" -) - -func tmpFile(dir, pattern string) (string, error) { - f, err := ioutil.TempFile(dir, pattern) - if err != nil { - return "", err - } - f.Close() - return f.Name(), nil -} diff --git a/vendor/github.com/hashicorp/go-getter/copy_dir.go b/vendor/github.com/hashicorp/go-getter/copy_dir.go deleted file mode 100644 index 641fe6d0f..000000000 --- a/vendor/github.com/hashicorp/go-getter/copy_dir.go +++ /dev/null @@ -1,78 +0,0 @@ -package getter - -import ( - "context" - "os" - "path/filepath" - "strings" -) - -// copyDir copies the src directory contents into dst. Both directories -// should already exist. -// -// If ignoreDot is set to true, then dot-prefixed files/folders are ignored. -func copyDir(ctx context.Context, dst string, src string, ignoreDot bool) error { - src, err := filepath.EvalSymlinks(src) - if err != nil { - return err - } - - walkFn := func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if path == src { - return nil - } - - if ignoreDot && strings.HasPrefix(filepath.Base(path), ".") { - // Skip any dot files - if info.IsDir() { - return filepath.SkipDir - } else { - return nil - } - } - - // The "path" has the src prefixed to it. We need to join our - // destination with the path without the src on it. - dstPath := filepath.Join(dst, path[len(src):]) - - // If we have a directory, make that subdirectory, then continue - // the walk. - if info.IsDir() { - if path == filepath.Join(src, dst) { - // dst is in src; don't walk it. - return nil - } - - if err := os.MkdirAll(dstPath, 0755); err != nil { - return err - } - - return nil - } - - // If we have a file, copy the contents. - srcF, err := os.Open(path) - if err != nil { - return err - } - defer srcF.Close() - - dstF, err := os.Create(dstPath) - if err != nil { - return err - } - defer dstF.Close() - - if _, err := Copy(ctx, dstF, srcF); err != nil { - return err - } - - // Chmod it - return os.Chmod(dstPath, info.Mode()) - } - - return filepath.Walk(src, walkFn) -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress.go b/vendor/github.com/hashicorp/go-getter/decompress.go deleted file mode 100644 index 198bb0edd..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress.go +++ /dev/null @@ -1,58 +0,0 @@ -package getter - -import ( - "strings" -) - -// Decompressor defines the interface that must be implemented to add -// support for decompressing a type. -// -// Important: if you're implementing a decompressor, please use the -// containsDotDot helper in this file to ensure that files can't be -// decompressed outside of the specified directory. -type Decompressor interface { - // Decompress should decompress src to dst. dir specifies whether dst - // is a directory or single file. src is guaranteed to be a single file - // that exists. dst is not guaranteed to exist already. - Decompress(dst, src string, dir bool) error -} - -// Decompressors is the mapping of extension to the Decompressor implementation -// that will decompress that extension/type. -var Decompressors map[string]Decompressor - -func init() { - tbzDecompressor := new(TarBzip2Decompressor) - tgzDecompressor := new(TarGzipDecompressor) - txzDecompressor := new(TarXzDecompressor) - - Decompressors = map[string]Decompressor{ - "bz2": new(Bzip2Decompressor), - "gz": new(GzipDecompressor), - "xz": new(XzDecompressor), - "tar.bz2": tbzDecompressor, - "tar.gz": tgzDecompressor, - "tar.xz": txzDecompressor, - "tbz2": tbzDecompressor, - "tgz": tgzDecompressor, - "txz": txzDecompressor, - "zip": new(ZipDecompressor), - } -} - -// containsDotDot checks if the filepath value v contains a ".." entry. -// This will check filepath components by splitting along / or \. This -// function is copied directly from the Go net/http implementation. -func containsDotDot(v string) bool { - if !strings.Contains(v, "..") { - return false - } - for _, ent := range strings.FieldsFunc(v, isSlashRune) { - if ent == ".." { - return true - } - } - return false -} - -func isSlashRune(r rune) bool { return r == '/' || r == '\\' } diff --git a/vendor/github.com/hashicorp/go-getter/decompress_bzip2.go b/vendor/github.com/hashicorp/go-getter/decompress_bzip2.go deleted file mode 100644 index 339f4cf7a..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_bzip2.go +++ /dev/null @@ -1,45 +0,0 @@ -package getter - -import ( - "compress/bzip2" - "fmt" - "io" - "os" - "path/filepath" -) - -// Bzip2Decompressor is an implementation of Decompressor that can -// decompress bz2 files. -type Bzip2Decompressor struct{} - -func (d *Bzip2Decompressor) Decompress(dst, src string, dir bool) error { - // Directory isn't supported at all - if dir { - return fmt.Errorf("bzip2-compressed files can only unarchive to a single file") - } - - // If we're going into a directory we should make that first - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - // Bzip2 compression is second - bzipR := bzip2.NewReader(f) - - // Copy it out - dstF, err := os.Create(dst) - if err != nil { - return err - } - defer dstF.Close() - - _, err = io.Copy(dstF, bzipR) - return err -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_gzip.go b/vendor/github.com/hashicorp/go-getter/decompress_gzip.go deleted file mode 100644 index 5ebf709b4..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_gzip.go +++ /dev/null @@ -1,49 +0,0 @@ -package getter - -import ( - "compress/gzip" - "fmt" - "io" - "os" - "path/filepath" -) - -// GzipDecompressor is an implementation of Decompressor that can -// decompress gzip files. -type GzipDecompressor struct{} - -func (d *GzipDecompressor) Decompress(dst, src string, dir bool) error { - // Directory isn't supported at all - if dir { - return fmt.Errorf("gzip-compressed files can only unarchive to a single file") - } - - // If we're going into a directory we should make that first - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - // gzip compression is second - gzipR, err := gzip.NewReader(f) - if err != nil { - return err - } - defer gzipR.Close() - - // Copy it out - dstF, err := os.Create(dst) - if err != nil { - return err - } - defer dstF.Close() - - _, err = io.Copy(dstF, gzipR) - return err -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_tar.go b/vendor/github.com/hashicorp/go-getter/decompress_tar.go deleted file mode 100644 index b6986a25a..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_tar.go +++ /dev/null @@ -1,160 +0,0 @@ -package getter - -import ( - "archive/tar" - "fmt" - "io" - "os" - "path/filepath" - "time" -) - -// untar is a shared helper for untarring an archive. The reader should provide -// an uncompressed view of the tar archive. -func untar(input io.Reader, dst, src string, dir bool) error { - tarR := tar.NewReader(input) - done := false - dirHdrs := []*tar.Header{} - now := time.Now() - for { - hdr, err := tarR.Next() - if err == io.EOF { - if !done { - // Empty archive - return fmt.Errorf("empty archive: %s", src) - } - - break - } - if err != nil { - return err - } - - if hdr.Typeflag == tar.TypeXGlobalHeader || hdr.Typeflag == tar.TypeXHeader { - // don't unpack extended headers as files - continue - } - - path := dst - if dir { - // Disallow parent traversal - if containsDotDot(hdr.Name) { - return fmt.Errorf("entry contains '..': %s", hdr.Name) - } - - path = filepath.Join(path, hdr.Name) - } - - if hdr.FileInfo().IsDir() { - if !dir { - return fmt.Errorf("expected a single file: %s", src) - } - - // A directory, just make the directory and continue unarchiving... - if err := os.MkdirAll(path, 0755); err != nil { - return err - } - - // Record the directory information so that we may set its attributes - // after all files have been extracted - dirHdrs = append(dirHdrs, hdr) - - continue - } else { - // There is no ordering guarantee that a file in a directory is - // listed before the directory - dstPath := filepath.Dir(path) - - // Check that the directory exists, otherwise create it - if _, err := os.Stat(dstPath); os.IsNotExist(err) { - if err := os.MkdirAll(dstPath, 0755); err != nil { - return err - } - } - } - - // We have a file. If we already decoded, then it is an error - if !dir && done { - return fmt.Errorf("expected a single file, got multiple: %s", src) - } - - // Mark that we're done so future in single file mode errors - done = true - - // Open the file for writing - dstF, err := os.Create(path) - if err != nil { - return err - } - _, err = io.Copy(dstF, tarR) - dstF.Close() - if err != nil { - return err - } - - // Chmod the file - if err := os.Chmod(path, hdr.FileInfo().Mode()); err != nil { - return err - } - - // Set the access and modification time if valid, otherwise default to current time - aTime := now - mTime := now - if hdr.AccessTime.Unix() > 0 { - aTime = hdr.AccessTime - } - if hdr.ModTime.Unix() > 0 { - mTime = hdr.ModTime - } - if err := os.Chtimes(path, aTime, mTime); err != nil { - return err - } - } - - // Perform a final pass over extracted directories to update metadata - for _, dirHdr := range dirHdrs { - path := filepath.Join(dst, dirHdr.Name) - // Chmod the directory since they might be created before we know the mode flags - if err := os.Chmod(path, dirHdr.FileInfo().Mode()); err != nil { - return err - } - // Set the mtime/atime attributes since they would have been changed during extraction - aTime := now - mTime := now - if dirHdr.AccessTime.Unix() > 0 { - aTime = dirHdr.AccessTime - } - if dirHdr.ModTime.Unix() > 0 { - mTime = dirHdr.ModTime - } - if err := os.Chtimes(path, aTime, mTime); err != nil { - return err - } - } - - return nil -} - -// tarDecompressor is an implementation of Decompressor that can -// unpack tar files. -type tarDecompressor struct{} - -func (d *tarDecompressor) Decompress(dst, src string, dir bool) error { - // If we're going into a directory we should make that first - mkdir := dst - if !dir { - mkdir = filepath.Dir(dst) - } - if err := os.MkdirAll(mkdir, 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - return untar(f, dst, src, dir) -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_tbz2.go b/vendor/github.com/hashicorp/go-getter/decompress_tbz2.go deleted file mode 100644 index 5391b5c8c..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_tbz2.go +++ /dev/null @@ -1,33 +0,0 @@ -package getter - -import ( - "compress/bzip2" - "os" - "path/filepath" -) - -// TarBzip2Decompressor is an implementation of Decompressor that can -// decompress tar.bz2 files. -type TarBzip2Decompressor struct{} - -func (d *TarBzip2Decompressor) Decompress(dst, src string, dir bool) error { - // If we're going into a directory we should make that first - mkdir := dst - if !dir { - mkdir = filepath.Dir(dst) - } - if err := os.MkdirAll(mkdir, 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - // Bzip2 compression is second - bzipR := bzip2.NewReader(f) - return untar(bzipR, dst, src, dir) -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_testing.go b/vendor/github.com/hashicorp/go-getter/decompress_testing.go deleted file mode 100644 index b2f662a89..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_testing.go +++ /dev/null @@ -1,171 +0,0 @@ -package getter - -import ( - "crypto/md5" - "encoding/hex" - "io" - "io/ioutil" - "os" - "path/filepath" - "reflect" - "runtime" - "sort" - "strings" - "time" - - "github.com/mitchellh/go-testing-interface" -) - -// TestDecompressCase is a single test case for testing decompressors -type TestDecompressCase struct { - Input string // Input is the complete path to the input file - Dir bool // Dir is whether or not we're testing directory mode - Err bool // Err is whether we expect an error or not - DirList []string // DirList is the list of files for Dir mode - FileMD5 string // FileMD5 is the expected MD5 for a single file - Mtime *time.Time // Mtime is the optionally expected mtime for a single file (or all files if in Dir mode) -} - -// TestDecompressor is a helper function for testing generic decompressors. -func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) { - t.Helper() - - for _, tc := range cases { - t.Logf("Testing: %s", tc.Input) - - // Temporary dir to store stuff - td, err := ioutil.TempDir("", "getter") - if err != nil { - t.Fatalf("err: %s", err) - } - - // Destination is always joining result so that we have a new path - dst := filepath.Join(td, "subdir", "result") - - // We use a function so defers work - func() { - defer os.RemoveAll(td) - - // Decompress - err := d.Decompress(dst, tc.Input, tc.Dir) - if (err != nil) != tc.Err { - t.Fatalf("err %s: %s", tc.Input, err) - } - if tc.Err { - return - } - - // If it isn't a directory, then check for a single file - if !tc.Dir { - fi, err := os.Stat(dst) - if err != nil { - t.Fatalf("err %s: %s", tc.Input, err) - } - if fi.IsDir() { - t.Fatalf("err %s: expected file, got directory", tc.Input) - } - if tc.FileMD5 != "" { - actual := testMD5(t, dst) - expected := tc.FileMD5 - if actual != expected { - t.Fatalf("err %s: expected MD5 %s, got %s", tc.Input, expected, actual) - } - } - - if tc.Mtime != nil { - actual := fi.ModTime() - if tc.Mtime.Unix() > 0 { - expected := *tc.Mtime - if actual != expected { - t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), dst, actual.String()) - } - } else if actual.Unix() <= 0 { - t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String()) - } - } - - return - } - - // Convert expected for windows - expected := tc.DirList - if runtime.GOOS == "windows" { - for i, v := range expected { - expected[i] = strings.Replace(v, "/", "\\", -1) - } - } - - // Directory, check for the correct contents - actual := testListDir(t, dst) - if !reflect.DeepEqual(actual, expected) { - t.Fatalf("bad %s\n\n%#v\n\n%#v", tc.Input, actual, expected) - } - // Check for correct atime/mtime - for _, dir := range actual { - path := filepath.Join(dst, dir) - if tc.Mtime != nil { - fi, err := os.Stat(path) - if err != nil { - t.Fatalf("err: %s", err) - } - actual := fi.ModTime() - if tc.Mtime.Unix() > 0 { - expected := *tc.Mtime - if actual != expected { - t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), path, actual.String()) - } - } else if actual.Unix() < 0 { - t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String()) - } - - } - } - }() - } -} - -func testListDir(t testing.T, path string) []string { - var result []string - err := filepath.Walk(path, func(sub string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - sub = strings.TrimPrefix(sub, path) - if sub == "" { - return nil - } - sub = sub[1:] // Trim the leading path sep. - - // If it is a dir, add trailing sep - if info.IsDir() { - sub += string(os.PathSeparator) - } - - result = append(result, sub) - return nil - }) - if err != nil { - t.Fatalf("err: %s", err) - } - - sort.Strings(result) - return result -} - -func testMD5(t testing.T, path string) string { - f, err := os.Open(path) - if err != nil { - t.Fatalf("err: %s", err) - } - defer f.Close() - - h := md5.New() - _, err = io.Copy(h, f) - if err != nil { - t.Fatalf("err: %s", err) - } - - result := h.Sum(nil) - return hex.EncodeToString(result) -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_tgz.go b/vendor/github.com/hashicorp/go-getter/decompress_tgz.go deleted file mode 100644 index 65eb70dd2..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_tgz.go +++ /dev/null @@ -1,39 +0,0 @@ -package getter - -import ( - "compress/gzip" - "fmt" - "os" - "path/filepath" -) - -// TarGzipDecompressor is an implementation of Decompressor that can -// decompress tar.gzip files. -type TarGzipDecompressor struct{} - -func (d *TarGzipDecompressor) Decompress(dst, src string, dir bool) error { - // If we're going into a directory we should make that first - mkdir := dst - if !dir { - mkdir = filepath.Dir(dst) - } - if err := os.MkdirAll(mkdir, 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - // Gzip compression is second - gzipR, err := gzip.NewReader(f) - if err != nil { - return fmt.Errorf("Error opening a gzip reader for %s: %s", src, err) - } - defer gzipR.Close() - - return untar(gzipR, dst, src, dir) -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_txz.go b/vendor/github.com/hashicorp/go-getter/decompress_txz.go deleted file mode 100644 index 5e151c127..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_txz.go +++ /dev/null @@ -1,39 +0,0 @@ -package getter - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/ulikunitz/xz" -) - -// TarXzDecompressor is an implementation of Decompressor that can -// decompress tar.xz files. -type TarXzDecompressor struct{} - -func (d *TarXzDecompressor) Decompress(dst, src string, dir bool) error { - // If we're going into a directory we should make that first - mkdir := dst - if !dir { - mkdir = filepath.Dir(dst) - } - if err := os.MkdirAll(mkdir, 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - // xz compression is second - txzR, err := xz.NewReader(f) - if err != nil { - return fmt.Errorf("Error opening an xz reader for %s: %s", src, err) - } - - return untar(txzR, dst, src, dir) -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_xz.go b/vendor/github.com/hashicorp/go-getter/decompress_xz.go deleted file mode 100644 index 4e37abab1..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_xz.go +++ /dev/null @@ -1,49 +0,0 @@ -package getter - -import ( - "fmt" - "io" - "os" - "path/filepath" - - "github.com/ulikunitz/xz" -) - -// XzDecompressor is an implementation of Decompressor that can -// decompress xz files. -type XzDecompressor struct{} - -func (d *XzDecompressor) Decompress(dst, src string, dir bool) error { - // Directory isn't supported at all - if dir { - return fmt.Errorf("xz-compressed files can only unarchive to a single file") - } - - // If we're going into a directory we should make that first - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - // File first - f, err := os.Open(src) - if err != nil { - return err - } - defer f.Close() - - // xz compression is second - xzR, err := xz.NewReader(f) - if err != nil { - return err - } - - // Copy it out - dstF, err := os.Create(dst) - if err != nil { - return err - } - defer dstF.Close() - - _, err = io.Copy(dstF, xzR) - return err -} diff --git a/vendor/github.com/hashicorp/go-getter/decompress_zip.go b/vendor/github.com/hashicorp/go-getter/decompress_zip.go deleted file mode 100644 index 0830f7914..000000000 --- a/vendor/github.com/hashicorp/go-getter/decompress_zip.go +++ /dev/null @@ -1,101 +0,0 @@ -package getter - -import ( - "archive/zip" - "fmt" - "io" - "os" - "path/filepath" -) - -// ZipDecompressor is an implementation of Decompressor that can -// decompress zip files. -type ZipDecompressor struct{} - -func (d *ZipDecompressor) Decompress(dst, src string, dir bool) error { - // If we're going into a directory we should make that first - mkdir := dst - if !dir { - mkdir = filepath.Dir(dst) - } - if err := os.MkdirAll(mkdir, 0755); err != nil { - return err - } - - // Open the zip - zipR, err := zip.OpenReader(src) - if err != nil { - return err - } - defer zipR.Close() - - // Check the zip integrity - if len(zipR.File) == 0 { - // Empty archive - return fmt.Errorf("empty archive: %s", src) - } - if !dir && len(zipR.File) > 1 { - return fmt.Errorf("expected a single file: %s", src) - } - - // Go through and unarchive - for _, f := range zipR.File { - path := dst - if dir { - // Disallow parent traversal - if containsDotDot(f.Name) { - return fmt.Errorf("entry contains '..': %s", f.Name) - } - - path = filepath.Join(path, f.Name) - } - - if f.FileInfo().IsDir() { - if !dir { - return fmt.Errorf("expected a single file: %s", src) - } - - // A directory, just make the directory and continue unarchiving... - if err := os.MkdirAll(path, 0755); err != nil { - return err - } - - continue - } - - // Create the enclosing directories if we must. ZIP files aren't - // required to contain entries for just the directories so this - // can happen. - if dir { - if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { - return err - } - } - - // Open the file for reading - srcF, err := f.Open() - if err != nil { - return err - } - - // Open the file for writing - dstF, err := os.Create(path) - if err != nil { - srcF.Close() - return err - } - _, err = io.Copy(dstF, srcF) - srcF.Close() - dstF.Close() - if err != nil { - return err - } - - // Chmod the file - if err := os.Chmod(path, f.Mode()); err != nil { - return err - } - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-getter/detect.go b/vendor/github.com/hashicorp/go-getter/detect.go deleted file mode 100644 index 5bb750c9f..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect.go +++ /dev/null @@ -1,105 +0,0 @@ -package getter - -import ( - "fmt" - "path/filepath" - - "github.com/hashicorp/go-getter/helper/url" -) - -// Detector defines the interface that an invalid URL or a URL with a blank -// scheme is passed through in order to determine if its shorthand for -// something else well-known. -type Detector interface { - // Detect will detect whether the string matches a known pattern to - // turn it into a proper URL. - Detect(string, string) (string, bool, error) -} - -// Detectors is the list of detectors that are tried on an invalid URL. -// This is also the order they're tried (index 0 is first). -var Detectors []Detector - -func init() { - Detectors = []Detector{ - new(GitHubDetector), - new(GitDetector), - new(BitBucketDetector), - new(S3Detector), - new(GCSDetector), - new(FileDetector), - } -} - -// Detect turns a source string into another source string if it is -// detected to be of a known pattern. -// -// The third parameter should be the list of detectors to use in the -// order to try them. If you don't want to configure this, just use -// the global Detectors variable. -// -// This is safe to be called with an already valid source string: Detect -// will just return it. -func Detect(src string, pwd string, ds []Detector) (string, error) { - getForce, getSrc := getForcedGetter(src) - - // Separate out the subdir if there is one, we don't pass that to detect - getSrc, subDir := SourceDirSubdir(getSrc) - - u, err := url.Parse(getSrc) - if err == nil && u.Scheme != "" { - // Valid URL - return src, nil - } - - for _, d := range ds { - result, ok, err := d.Detect(getSrc, pwd) - if err != nil { - return "", err - } - if !ok { - continue - } - - var detectForce string - detectForce, result = getForcedGetter(result) - result, detectSubdir := SourceDirSubdir(result) - - // If we have a subdir from the detection, then prepend it to our - // requested subdir. - if detectSubdir != "" { - if subDir != "" { - subDir = filepath.Join(detectSubdir, subDir) - } else { - subDir = detectSubdir - } - } - - if subDir != "" { - u, err := url.Parse(result) - if err != nil { - return "", fmt.Errorf("Error parsing URL: %s", err) - } - u.Path += "//" + subDir - - // a subdir may contain wildcards, but in order to support them we - // have to ensure the path isn't escaped. - u.RawPath = u.Path - - result = u.String() - } - - // Preserve the forced getter if it exists. We try to use the - // original set force first, followed by any force set by the - // detector. - if getForce != "" { - result = fmt.Sprintf("%s::%s", getForce, result) - } else if detectForce != "" { - result = fmt.Sprintf("%s::%s", detectForce, result) - } - - return result, nil - } - - return "", fmt.Errorf("invalid source string: %s", src) -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go b/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go deleted file mode 100644 index 19047eb19..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_bitbucket.go +++ /dev/null @@ -1,66 +0,0 @@ -package getter - -import ( - "encoding/json" - "fmt" - "net/http" - "net/url" - "strings" -) - -// BitBucketDetector implements Detector to detect BitBucket URLs and turn -// them into URLs that the Git or Hg Getter can understand. -type BitBucketDetector struct{} - -func (d *BitBucketDetector) Detect(src, _ string) (string, bool, error) { - if len(src) == 0 { - return "", false, nil - } - - if strings.HasPrefix(src, "bitbucket.org/") { - return d.detectHTTP(src) - } - - return "", false, nil -} - -func (d *BitBucketDetector) detectHTTP(src string) (string, bool, error) { - u, err := url.Parse("https://" + src) - if err != nil { - return "", true, fmt.Errorf("error parsing BitBucket URL: %s", err) - } - - // We need to get info on this BitBucket repository to determine whether - // it is Git or Hg. - var info struct { - SCM string `json:"scm"` - } - infoUrl := "https://api.bitbucket.org/2.0/repositories" + u.Path - resp, err := http.Get(infoUrl) - if err != nil { - return "", true, fmt.Errorf("error looking up BitBucket URL: %s", err) - } - if resp.StatusCode == 403 { - // A private repo - return "", true, fmt.Errorf( - "shorthand BitBucket URL can't be used for private repos, " + - "please use a full URL") - } - dec := json.NewDecoder(resp.Body) - if err := dec.Decode(&info); err != nil { - return "", true, fmt.Errorf("error looking up BitBucket URL: %s", err) - } - - switch info.SCM { - case "git": - if !strings.HasSuffix(u.Path, ".git") { - u.Path += ".git" - } - - return "git::" + u.String(), true, nil - case "hg": - return "hg::" + u.String(), true, nil - default: - return "", true, fmt.Errorf("unknown BitBucket SCM type: %s", info.SCM) - } -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_file.go b/vendor/github.com/hashicorp/go-getter/detect_file.go deleted file mode 100644 index 4ef41ea73..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_file.go +++ /dev/null @@ -1,67 +0,0 @@ -package getter - -import ( - "fmt" - "os" - "path/filepath" - "runtime" -) - -// FileDetector implements Detector to detect file paths. -type FileDetector struct{} - -func (d *FileDetector) Detect(src, pwd string) (string, bool, error) { - if len(src) == 0 { - return "", false, nil - } - - if !filepath.IsAbs(src) { - if pwd == "" { - return "", true, fmt.Errorf( - "relative paths require a module with a pwd") - } - - // Stat the pwd to determine if its a symbolic link. If it is, - // then the pwd becomes the original directory. Otherwise, - // `filepath.Join` below does some weird stuff. - // - // We just ignore if the pwd doesn't exist. That error will be - // caught later when we try to use the URL. - if fi, err := os.Lstat(pwd); !os.IsNotExist(err) { - if err != nil { - return "", true, err - } - if fi.Mode()&os.ModeSymlink != 0 { - pwd, err = filepath.EvalSymlinks(pwd) - if err != nil { - return "", true, err - } - - // The symlink itself might be a relative path, so we have to - // resolve this to have a correctly rooted URL. - pwd, err = filepath.Abs(pwd) - if err != nil { - return "", true, err - } - } - } - - src = filepath.Join(pwd, src) - } - - return fmtFileURL(src), true, nil -} - -func fmtFileURL(path string) string { - if runtime.GOOS == "windows" { - // Make sure we're using "/" on Windows. URLs are "/"-based. - path = filepath.ToSlash(path) - return fmt.Sprintf("file://%s", path) - } - - // Make sure that we don't start with "/" since we add that below. - if path[0] == '/' { - path = path[1:] - } - return fmt.Sprintf("file:///%s", path) -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_gcs.go b/vendor/github.com/hashicorp/go-getter/detect_gcs.go deleted file mode 100644 index 11363737c..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_gcs.go +++ /dev/null @@ -1,43 +0,0 @@ -package getter - -import ( - "fmt" - "net/url" - "strings" -) - -// GCSDetector implements Detector to detect GCS URLs and turn -// them into URLs that the GCSGetter can understand. -type GCSDetector struct{} - -func (d *GCSDetector) Detect(src, _ string) (string, bool, error) { - if len(src) == 0 { - return "", false, nil - } - - if strings.Contains(src, "googleapis.com/") { - return d.detectHTTP(src) - } - - return "", false, nil -} - -func (d *GCSDetector) detectHTTP(src string) (string, bool, error) { - - parts := strings.Split(src, "/") - if len(parts) < 5 { - return "", false, fmt.Errorf( - "URL is not a valid GCS URL") - } - version := parts[2] - bucket := parts[3] - object := strings.Join(parts[4:], "/") - - url, err := url.Parse(fmt.Sprintf("https://www.googleapis.com/storage/%s/%s/%s", - version, bucket, object)) - if err != nil { - return "", false, fmt.Errorf("error parsing GCS URL: %s", err) - } - - return "gcs::" + url.String(), true, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_git.go b/vendor/github.com/hashicorp/go-getter/detect_git.go deleted file mode 100644 index eeb8a04c5..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_git.go +++ /dev/null @@ -1,26 +0,0 @@ -package getter - -// GitDetector implements Detector to detect Git SSH URLs such as -// git@host.com:dir1/dir2 and converts them to proper URLs. -type GitDetector struct{} - -func (d *GitDetector) Detect(src, _ string) (string, bool, error) { - if len(src) == 0 { - return "", false, nil - } - - u, err := detectSSH(src) - if err != nil { - return "", true, err - } - if u == nil { - return "", false, nil - } - - // We require the username to be "git" to assume that this is a Git URL - if u.User.Username() != "git" { - return "", false, nil - } - - return "git::" + u.String(), true, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_github.go b/vendor/github.com/hashicorp/go-getter/detect_github.go deleted file mode 100644 index 4bf4daf23..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_github.go +++ /dev/null @@ -1,47 +0,0 @@ -package getter - -import ( - "fmt" - "net/url" - "strings" -) - -// GitHubDetector implements Detector to detect GitHub URLs and turn -// them into URLs that the Git Getter can understand. -type GitHubDetector struct{} - -func (d *GitHubDetector) Detect(src, _ string) (string, bool, error) { - if len(src) == 0 { - return "", false, nil - } - - if strings.HasPrefix(src, "github.com/") { - return d.detectHTTP(src) - } - - return "", false, nil -} - -func (d *GitHubDetector) detectHTTP(src string) (string, bool, error) { - parts := strings.Split(src, "/") - if len(parts) < 3 { - return "", false, fmt.Errorf( - "GitHub URLs should be github.com/username/repo") - } - - urlStr := fmt.Sprintf("https://%s", strings.Join(parts[:3], "/")) - url, err := url.Parse(urlStr) - if err != nil { - return "", true, fmt.Errorf("error parsing GitHub URL: %s", err) - } - - if !strings.HasSuffix(url.Path, ".git") { - url.Path += ".git" - } - - if len(parts) > 3 { - url.Path += "//" + strings.Join(parts[3:], "/") - } - - return "git::" + url.String(), true, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_s3.go b/vendor/github.com/hashicorp/go-getter/detect_s3.go deleted file mode 100644 index 8e0f4a03b..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_s3.go +++ /dev/null @@ -1,61 +0,0 @@ -package getter - -import ( - "fmt" - "net/url" - "strings" -) - -// S3Detector implements Detector to detect S3 URLs and turn -// them into URLs that the S3 getter can understand. -type S3Detector struct{} - -func (d *S3Detector) Detect(src, _ string) (string, bool, error) { - if len(src) == 0 { - return "", false, nil - } - - if strings.Contains(src, ".amazonaws.com/") { - return d.detectHTTP(src) - } - - return "", false, nil -} - -func (d *S3Detector) detectHTTP(src string) (string, bool, error) { - parts := strings.Split(src, "/") - if len(parts) < 2 { - return "", false, fmt.Errorf( - "URL is not a valid S3 URL") - } - - hostParts := strings.Split(parts[0], ".") - if len(hostParts) == 3 { - return d.detectPathStyle(hostParts[0], parts[1:]) - } else if len(hostParts) == 4 { - return d.detectVhostStyle(hostParts[1], hostParts[0], parts[1:]) - } else { - return "", false, fmt.Errorf( - "URL is not a valid S3 URL") - } -} - -func (d *S3Detector) detectPathStyle(region string, parts []string) (string, bool, error) { - urlStr := fmt.Sprintf("https://%s.amazonaws.com/%s", region, strings.Join(parts, "/")) - url, err := url.Parse(urlStr) - if err != nil { - return "", false, fmt.Errorf("error parsing S3 URL: %s", err) - } - - return "s3::" + url.String(), true, nil -} - -func (d *S3Detector) detectVhostStyle(region, bucket string, parts []string) (string, bool, error) { - urlStr := fmt.Sprintf("https://%s.amazonaws.com/%s/%s", region, bucket, strings.Join(parts, "/")) - url, err := url.Parse(urlStr) - if err != nil { - return "", false, fmt.Errorf("error parsing S3 URL: %s", err) - } - - return "s3::" + url.String(), true, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/detect_ssh.go b/vendor/github.com/hashicorp/go-getter/detect_ssh.go deleted file mode 100644 index c0dbe9d47..000000000 --- a/vendor/github.com/hashicorp/go-getter/detect_ssh.go +++ /dev/null @@ -1,49 +0,0 @@ -package getter - -import ( - "fmt" - "net/url" - "regexp" - "strings" -) - -// Note that we do not have an SSH-getter currently so this file serves -// only to hold the detectSSH helper that is used by other detectors. - -// sshPattern matches SCP-like SSH patterns (user@host:path) -var sshPattern = regexp.MustCompile("^(?:([^@]+)@)?([^:]+):/?(.+)$") - -// detectSSH determines if the src string matches an SSH-like URL and -// converts it into a net.URL compatible string. This returns nil if the -// string doesn't match the SSH pattern. -// -// This function is tested indirectly via detect_git_test.go -func detectSSH(src string) (*url.URL, error) { - matched := sshPattern.FindStringSubmatch(src) - if matched == nil { - return nil, nil - } - - user := matched[1] - host := matched[2] - path := matched[3] - qidx := strings.Index(path, "?") - if qidx == -1 { - qidx = len(path) - } - - var u url.URL - u.Scheme = "ssh" - u.User = url.User(user) - u.Host = host - u.Path = path[0:qidx] - if qidx < len(path) { - q, err := url.ParseQuery(path[qidx+1:]) - if err != nil { - return nil, fmt.Errorf("error parsing GitHub SSH URL: %s", err) - } - u.RawQuery = q.Encode() - } - - return &u, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/folder_storage.go b/vendor/github.com/hashicorp/go-getter/folder_storage.go deleted file mode 100644 index 647ccf459..000000000 --- a/vendor/github.com/hashicorp/go-getter/folder_storage.go +++ /dev/null @@ -1,65 +0,0 @@ -package getter - -import ( - "crypto/md5" - "encoding/hex" - "fmt" - "os" - "path/filepath" -) - -// FolderStorage is an implementation of the Storage interface that manages -// modules on the disk. -type FolderStorage struct { - // StorageDir is the directory where the modules will be stored. - StorageDir string -} - -// Dir implements Storage.Dir -func (s *FolderStorage) Dir(key string) (d string, e bool, err error) { - d = s.dir(key) - _, err = os.Stat(d) - if err == nil { - // Directory exists - e = true - return - } - if os.IsNotExist(err) { - // Directory doesn't exist - d = "" - e = false - err = nil - return - } - - // An error - d = "" - e = false - return -} - -// Get implements Storage.Get -func (s *FolderStorage) Get(key string, source string, update bool) error { - dir := s.dir(key) - if !update { - if _, err := os.Stat(dir); err == nil { - // If the directory already exists, then we're done since - // we're not updating. - return nil - } else if !os.IsNotExist(err) { - // If the error we got wasn't a file-not-exist error, then - // something went wrong and we should report it. - return fmt.Errorf("Error reading module directory: %s", err) - } - } - - // Get the source. This always forces an update. - return Get(dir, source) -} - -// dir returns the directory name internally that we'll use to map to -// internally. -func (s *FolderStorage) dir(key string) string { - sum := md5.Sum([]byte(key)) - return filepath.Join(s.StorageDir, hex.EncodeToString(sum[:])) -} diff --git a/vendor/github.com/hashicorp/go-getter/get.go b/vendor/github.com/hashicorp/go-getter/get.go deleted file mode 100644 index c233763c6..000000000 --- a/vendor/github.com/hashicorp/go-getter/get.go +++ /dev/null @@ -1,152 +0,0 @@ -// getter is a package for downloading files or directories from a variety of -// protocols. -// -// getter is unique in its ability to download both directories and files. -// It also detects certain source strings to be protocol-specific URLs. For -// example, "github.com/hashicorp/go-getter" would turn into a Git URL and -// use the Git protocol. -// -// Protocols and detectors are extensible. -// -// To get started, see Client. -package getter - -import ( - "bytes" - "fmt" - "net/url" - "os/exec" - "regexp" - "syscall" - - cleanhttp "github.com/hashicorp/go-cleanhttp" -) - -// Getter defines the interface that schemes must implement to download -// things. -type Getter interface { - // Get downloads the given URL into the given directory. This always - // assumes that we're updating and gets the latest version that it can. - // - // The directory may already exist (if we're updating). If it is in a - // format that isn't understood, an error should be returned. Get shouldn't - // simply nuke the directory. - Get(string, *url.URL) error - - // GetFile downloads the give URL into the given path. The URL must - // reference a single file. If possible, the Getter should check if - // the remote end contains the same file and no-op this operation. - GetFile(string, *url.URL) error - - // ClientMode returns the mode based on the given URL. This is used to - // allow clients to let the getters decide which mode to use. - ClientMode(*url.URL) (ClientMode, error) - - // SetClient allows a getter to know it's client - // in order to access client's Get functions or - // progress tracking. - SetClient(*Client) -} - -// Getters is the mapping of scheme to the Getter implementation that will -// be used to get a dependency. -var Getters map[string]Getter - -// forcedRegexp is the regular expression that finds forced getters. This -// syntax is schema::url, example: git::https://foo.com -var forcedRegexp = regexp.MustCompile(`^([A-Za-z0-9]+)::(.+)$`) - -// httpClient is the default client to be used by HttpGetters. -var httpClient = cleanhttp.DefaultClient() - -func init() { - httpGetter := &HttpGetter{ - Netrc: true, - } - - Getters = map[string]Getter{ - "file": new(FileGetter), - "git": new(GitGetter), - "gcs": new(GCSGetter), - "hg": new(HgGetter), - "s3": new(S3Getter), - "http": httpGetter, - "https": httpGetter, - } -} - -// Get downloads the directory specified by src into the folder specified by -// dst. If dst already exists, Get will attempt to update it. -// -// src is a URL, whereas dst is always just a file path to a folder. This -// folder doesn't need to exist. It will be created if it doesn't exist. -func Get(dst, src string, opts ...ClientOption) error { - return (&Client{ - Src: src, - Dst: dst, - Dir: true, - Options: opts, - }).Get() -} - -// GetAny downloads a URL into the given destination. Unlike Get or -// GetFile, both directories and files are supported. -// -// dst must be a directory. If src is a file, it will be downloaded -// into dst with the basename of the URL. If src is a directory or -// archive, it will be unpacked directly into dst. -func GetAny(dst, src string, opts ...ClientOption) error { - return (&Client{ - Src: src, - Dst: dst, - Mode: ClientModeAny, - Options: opts, - }).Get() -} - -// GetFile downloads the file specified by src into the path specified by -// dst. -func GetFile(dst, src string, opts ...ClientOption) error { - return (&Client{ - Src: src, - Dst: dst, - Dir: false, - Options: opts, - }).Get() -} - -// getRunCommand is a helper that will run a command and capture the output -// in the case an error happens. -func getRunCommand(cmd *exec.Cmd) error { - var buf bytes.Buffer - cmd.Stdout = &buf - cmd.Stderr = &buf - err := cmd.Run() - if err == nil { - return nil - } - if exiterr, ok := err.(*exec.ExitError); ok { - // The program has exited with an exit code != 0 - if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { - return fmt.Errorf( - "%s exited with %d: %s", - cmd.Path, - status.ExitStatus(), - buf.String()) - } - } - - return fmt.Errorf("error running %s: %s", cmd.Path, buf.String()) -} - -// getForcedGetter takes a source and returns the tuple of the forced -// getter and the raw URL (without the force syntax). -func getForcedGetter(src string) (string, string) { - var forced string - if ms := forcedRegexp.FindStringSubmatch(src); ms != nil { - forced = ms[1] - src = ms[2] - } - - return forced, src -} diff --git a/vendor/github.com/hashicorp/go-getter/get_base.go b/vendor/github.com/hashicorp/go-getter/get_base.go deleted file mode 100644 index 09e9b6313..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_base.go +++ /dev/null @@ -1,20 +0,0 @@ -package getter - -import "context" - -// getter is our base getter; it regroups -// fields all getters have in common. -type getter struct { - client *Client -} - -func (g *getter) SetClient(c *Client) { g.client = c } - -// Context tries to returns the Contex from the getter's -// client. otherwise context.Background() is returned. -func (g *getter) Context() context.Context { - if g == nil || g.client == nil { - return context.Background() - } - return g.client.Ctx -} diff --git a/vendor/github.com/hashicorp/go-getter/get_file.go b/vendor/github.com/hashicorp/go-getter/get_file.go deleted file mode 100644 index 78660839a..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_file.go +++ /dev/null @@ -1,36 +0,0 @@ -package getter - -import ( - "net/url" - "os" -) - -// FileGetter is a Getter implementation that will download a module from -// a file scheme. -type FileGetter struct { - getter - - // Copy, if set to true, will copy data instead of using a symlink. If - // false, attempts to symlink to speed up the operation and to lower the - // disk space usage. If the symlink fails, may attempt to copy on windows. - Copy bool -} - -func (g *FileGetter) ClientMode(u *url.URL) (ClientMode, error) { - path := u.Path - if u.RawPath != "" { - path = u.RawPath - } - - fi, err := os.Stat(path) - if err != nil { - return 0, err - } - - // Check if the source is a directory. - if fi.IsDir() { - return ClientModeDir, nil - } - - return ClientModeFile, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/get_file_copy.go b/vendor/github.com/hashicorp/go-getter/get_file_copy.go deleted file mode 100644 index d70fb4951..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_file_copy.go +++ /dev/null @@ -1,29 +0,0 @@ -package getter - -import ( - "context" - "io" -) - -// readerFunc is syntactic sugar for read interface. -type readerFunc func(p []byte) (n int, err error) - -func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) } - -// Copy is a io.Copy cancellable by context -func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) { - // Copy will call the Reader and Writer interface multiple time, in order - // to copy by chunk (avoiding loading the whole file in memory). - return io.Copy(dst, readerFunc(func(p []byte) (int, error) { - - select { - case <-ctx.Done(): - // context has been canceled - // stop process and propagate "context canceled" error - return 0, ctx.Err() - default: - // otherwise just run default io.Reader implementation - return src.Read(p) - } - })) -} diff --git a/vendor/github.com/hashicorp/go-getter/get_file_unix.go b/vendor/github.com/hashicorp/go-getter/get_file_unix.go deleted file mode 100644 index c3b28ae51..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_file_unix.go +++ /dev/null @@ -1,103 +0,0 @@ -// +build !windows - -package getter - -import ( - "fmt" - "net/url" - "os" - "path/filepath" -) - -func (g *FileGetter) Get(dst string, u *url.URL) error { - path := u.Path - if u.RawPath != "" { - path = u.RawPath - } - - // The source path must exist and be a directory to be usable. - if fi, err := os.Stat(path); err != nil { - return fmt.Errorf("source path error: %s", err) - } else if !fi.IsDir() { - return fmt.Errorf("source path must be a directory") - } - - fi, err := os.Lstat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - - // If the destination already exists, it must be a symlink - if err == nil { - mode := fi.Mode() - if mode&os.ModeSymlink == 0 { - return fmt.Errorf("destination exists and is not a symlink") - } - - // Remove the destination - if err := os.Remove(dst); err != nil { - return err - } - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - return os.Symlink(path, dst) -} - -func (g *FileGetter) GetFile(dst string, u *url.URL) error { - ctx := g.Context() - path := u.Path - if u.RawPath != "" { - path = u.RawPath - } - - // The source path must exist and be a file to be usable. - if fi, err := os.Stat(path); err != nil { - return fmt.Errorf("source path error: %s", err) - } else if fi.IsDir() { - return fmt.Errorf("source path must be a file") - } - - _, err := os.Lstat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - - // If the destination already exists, it must be a symlink - if err == nil { - // Remove the destination - if err := os.Remove(dst); err != nil { - return err - } - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - // If we're not copying, just symlink and we're done - if !g.Copy { - return os.Symlink(path, dst) - } - - // Copy - srcF, err := os.Open(path) - if err != nil { - return err - } - defer srcF.Close() - - dstF, err := os.Create(dst) - if err != nil { - return err - } - defer dstF.Close() - - _, err = Copy(ctx, dstF, srcF) - return err -} diff --git a/vendor/github.com/hashicorp/go-getter/get_file_windows.go b/vendor/github.com/hashicorp/go-getter/get_file_windows.go deleted file mode 100644 index 24f1acb17..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_file_windows.go +++ /dev/null @@ -1,136 +0,0 @@ -// +build windows - -package getter - -import ( - "fmt" - "net/url" - "os" - "os/exec" - "path/filepath" - "strings" - "syscall" -) - -func (g *FileGetter) Get(dst string, u *url.URL) error { - ctx := g.Context() - path := u.Path - if u.RawPath != "" { - path = u.RawPath - } - - // The source path must exist and be a directory to be usable. - if fi, err := os.Stat(path); err != nil { - return fmt.Errorf("source path error: %s", err) - } else if !fi.IsDir() { - return fmt.Errorf("source path must be a directory") - } - - fi, err := os.Lstat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - - // If the destination already exists, it must be a symlink - if err == nil { - mode := fi.Mode() - if mode&os.ModeSymlink == 0 { - return fmt.Errorf("destination exists and is not a symlink") - } - - // Remove the destination - if err := os.Remove(dst); err != nil { - return err - } - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - sourcePath := toBackslash(path) - - // Use mklink to create a junction point - output, err := exec.CommandContext(ctx, "cmd", "/c", "mklink", "/J", dst, sourcePath).CombinedOutput() - if err != nil { - return fmt.Errorf("failed to run mklink %v %v: %v %q", dst, sourcePath, err, output) - } - - return nil -} - -func (g *FileGetter) GetFile(dst string, u *url.URL) error { - ctx := g.Context() - path := u.Path - if u.RawPath != "" { - path = u.RawPath - } - - // The source path must exist and be a directory to be usable. - if fi, err := os.Stat(path); err != nil { - return fmt.Errorf("source path error: %s", err) - } else if fi.IsDir() { - return fmt.Errorf("source path must be a file") - } - - _, err := os.Lstat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - - // If the destination already exists, it must be a symlink - if err == nil { - // Remove the destination - if err := os.Remove(dst); err != nil { - return err - } - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - // If we're not copying, just symlink and we're done - if !g.Copy { - if err = os.Symlink(path, dst); err == nil { - return err - } - lerr, ok := err.(*os.LinkError) - if !ok { - return err - } - switch lerr.Err { - case syscall.ERROR_PRIVILEGE_NOT_HELD: - // no symlink privilege, let's - // fallback to a copy to avoid an error. - break - default: - return err - } - } - - // Copy - srcF, err := os.Open(path) - if err != nil { - return err - } - defer srcF.Close() - - dstF, err := os.Create(dst) - if err != nil { - return err - } - defer dstF.Close() - - _, err = Copy(ctx, dstF, srcF) - return err -} - -// toBackslash returns the result of replacing each slash character -// in path with a backslash ('\') character. Multiple separators are -// replaced by multiple backslashes. -func toBackslash(path string) string { - return strings.Replace(path, "/", "\\", -1) -} diff --git a/vendor/github.com/hashicorp/go-getter/get_gcs.go b/vendor/github.com/hashicorp/go-getter/get_gcs.go deleted file mode 100644 index 6faa70f4f..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_gcs.go +++ /dev/null @@ -1,172 +0,0 @@ -package getter - -import ( - "context" - "fmt" - "net/url" - "os" - "path/filepath" - "strings" - - "cloud.google.com/go/storage" - "google.golang.org/api/iterator" -) - -// GCSGetter is a Getter implementation that will download a module from -// a GCS bucket. -type GCSGetter struct { - getter -} - -func (g *GCSGetter) ClientMode(u *url.URL) (ClientMode, error) { - ctx := g.Context() - - // Parse URL - bucket, object, err := g.parseURL(u) - if err != nil { - return 0, err - } - - client, err := storage.NewClient(ctx) - if err != nil { - return 0, err - } - iter := client.Bucket(bucket).Objects(ctx, &storage.Query{Prefix: object}) - for { - obj, err := iter.Next() - if err != nil && err != iterator.Done { - return 0, err - } - - if err == iterator.Done { - break - } - if strings.HasSuffix(obj.Name, "/") { - // A directory matched the prefix search, so this must be a directory - return ClientModeDir, nil - } else if obj.Name != object { - // A file matched the prefix search and doesn't have the same name - // as the query, so this must be a directory - return ClientModeDir, nil - } - } - // There are no directories or subdirectories, and if a match was returned, - // it was exactly equal to the prefix search. So return File mode - return ClientModeFile, nil -} - -func (g *GCSGetter) Get(dst string, u *url.URL) error { - ctx := g.Context() - - // Parse URL - bucket, object, err := g.parseURL(u) - if err != nil { - return err - } - - // Remove destination if it already exists - _, err = os.Stat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - if err == nil { - // Remove the destination - if err := os.RemoveAll(dst); err != nil { - return err - } - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - client, err := storage.NewClient(ctx) - if err != nil { - return err - } - - // Iterate through all matching objects. - iter := client.Bucket(bucket).Objects(ctx, &storage.Query{Prefix: object}) - for { - obj, err := iter.Next() - if err != nil && err != iterator.Done { - return err - } - if err == iterator.Done { - break - } - - if !strings.HasSuffix(obj.Name, "/") { - // Get the object destination path - objDst, err := filepath.Rel(object, obj.Name) - if err != nil { - return err - } - objDst = filepath.Join(dst, objDst) - // Download the matching object. - err = g.getObject(ctx, client, objDst, bucket, obj.Name) - if err != nil { - return err - } - } - } - return nil -} - -func (g *GCSGetter) GetFile(dst string, u *url.URL) error { - ctx := g.Context() - - // Parse URL - bucket, object, err := g.parseURL(u) - if err != nil { - return err - } - - client, err := storage.NewClient(ctx) - if err != nil { - return err - } - return g.getObject(ctx, client, dst, bucket, object) -} - -func (g *GCSGetter) getObject(ctx context.Context, client *storage.Client, dst, bucket, object string) error { - rc, err := client.Bucket(bucket).Object(object).NewReader(ctx) - if err != nil { - return err - } - defer rc.Close() - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - f, err := os.Create(dst) - if err != nil { - return err - } - defer f.Close() - - _, err = Copy(ctx, f, rc) - return err -} - -func (g *GCSGetter) parseURL(u *url.URL) (bucket, path string, err error) { - if strings.Contains(u.Host, "googleapis.com") { - hostParts := strings.Split(u.Host, ".") - if len(hostParts) != 3 { - err = fmt.Errorf("URL is not a valid GCS URL") - return - } - - pathParts := strings.SplitN(u.Path, "/", 5) - if len(pathParts) != 5 { - err = fmt.Errorf("URL is not a valid GCS URL") - return - } - bucket = pathParts[3] - path = pathParts[4] - } - return -} diff --git a/vendor/github.com/hashicorp/go-getter/get_git.go b/vendor/github.com/hashicorp/go-getter/get_git.go deleted file mode 100644 index 1b9f4be81..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_git.go +++ /dev/null @@ -1,313 +0,0 @@ -package getter - -import ( - "bytes" - "context" - "encoding/base64" - "fmt" - "io/ioutil" - "net/url" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "strconv" - "strings" - - urlhelper "github.com/hashicorp/go-getter/helper/url" - safetemp "github.com/hashicorp/go-safetemp" - version "github.com/hashicorp/go-version" -) - -// GitGetter is a Getter implementation that will download a module from -// a git repository. -type GitGetter struct { - getter -} - -var defaultBranchRegexp = regexp.MustCompile(`\s->\sorigin/(.*)`) - -func (g *GitGetter) ClientMode(_ *url.URL) (ClientMode, error) { - return ClientModeDir, nil -} - -func (g *GitGetter) Get(dst string, u *url.URL) error { - ctx := g.Context() - if _, err := exec.LookPath("git"); err != nil { - return fmt.Errorf("git must be available and on the PATH") - } - - // The port number must be parseable as an integer. If not, the user - // was probably trying to use a scp-style address, in which case the - // ssh:// prefix must be removed to indicate that. - // - // This is not necessary in versions of Go which have patched - // CVE-2019-14809 (e.g. Go 1.12.8+) - if portStr := u.Port(); portStr != "" { - if _, err := strconv.ParseUint(portStr, 10, 16); err != nil { - return fmt.Errorf("invalid port number %q; if using the \"scp-like\" git address scheme where a colon introduces the path instead, remove the ssh:// portion and use just the git:: prefix", portStr) - } - } - - // Extract some query parameters we use - var ref, sshKey string - var depth int - q := u.Query() - if len(q) > 0 { - ref = q.Get("ref") - q.Del("ref") - - sshKey = q.Get("sshkey") - q.Del("sshkey") - - if n, err := strconv.Atoi(q.Get("depth")); err == nil { - depth = n - } - q.Del("depth") - - // Copy the URL - var newU url.URL = *u - u = &newU - u.RawQuery = q.Encode() - } - - var sshKeyFile string - if sshKey != "" { - // Check that the git version is sufficiently new. - if err := checkGitVersion("2.3"); err != nil { - return fmt.Errorf("Error using ssh key: %v", err) - } - - // We have an SSH key - decode it. - raw, err := base64.StdEncoding.DecodeString(sshKey) - if err != nil { - return err - } - - // Create a temp file for the key and ensure it is removed. - fh, err := ioutil.TempFile("", "go-getter") - if err != nil { - return err - } - sshKeyFile = fh.Name() - defer os.Remove(sshKeyFile) - - // Set the permissions prior to writing the key material. - if err := os.Chmod(sshKeyFile, 0600); err != nil { - return err - } - - // Write the raw key into the temp file. - _, err = fh.Write(raw) - fh.Close() - if err != nil { - return err - } - } - - // Clone or update the repository - _, err := os.Stat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - if err == nil { - err = g.update(ctx, dst, sshKeyFile, ref, depth) - } else { - err = g.clone(ctx, dst, sshKeyFile, u, depth) - } - if err != nil { - return err - } - - // Next: check out the proper tag/branch if it is specified, and checkout - if ref != "" { - if err := g.checkout(dst, ref); err != nil { - return err - } - } - - // Lastly, download any/all submodules. - return g.fetchSubmodules(ctx, dst, sshKeyFile, depth) -} - -// GetFile for Git doesn't support updating at this time. It will download -// the file every time. -func (g *GitGetter) GetFile(dst string, u *url.URL) error { - td, tdcloser, err := safetemp.Dir("", "getter") - if err != nil { - return err - } - defer tdcloser.Close() - - // Get the filename, and strip the filename from the URL so we can - // just get the repository directly. - filename := filepath.Base(u.Path) - u.Path = filepath.Dir(u.Path) - - // Get the full repository - if err := g.Get(td, u); err != nil { - return err - } - - // Copy the single file - u, err = urlhelper.Parse(fmtFileURL(filepath.Join(td, filename))) - if err != nil { - return err - } - - fg := &FileGetter{Copy: true} - return fg.GetFile(dst, u) -} - -func (g *GitGetter) checkout(dst string, ref string) error { - cmd := exec.Command("git", "checkout", ref) - cmd.Dir = dst - return getRunCommand(cmd) -} - -func (g *GitGetter) clone(ctx context.Context, dst, sshKeyFile string, u *url.URL, depth int) error { - args := []string{"clone"} - - if depth > 0 { - args = append(args, "--depth", strconv.Itoa(depth)) - } - - args = append(args, u.String(), dst) - cmd := exec.CommandContext(ctx, "git", args...) - setupGitEnv(cmd, sshKeyFile) - return getRunCommand(cmd) -} - -func (g *GitGetter) update(ctx context.Context, dst, sshKeyFile, ref string, depth int) error { - // Determine if we're a branch. If we're NOT a branch, then we just - // switch to master prior to checking out - cmd := exec.CommandContext(ctx, "git", "show-ref", "-q", "--verify", "refs/heads/"+ref) - cmd.Dir = dst - - if getRunCommand(cmd) != nil { - // Not a branch, switch to default branch. This will also catch - // non-existent branches, in which case we want to switch to default - // and then checkout the proper branch later. - ref = findDefaultBranch(dst) - } - - // We have to be on a branch to pull - if err := g.checkout(dst, ref); err != nil { - return err - } - - if depth > 0 { - cmd = exec.Command("git", "pull", "--depth", strconv.Itoa(depth), "--ff-only") - } else { - cmd = exec.Command("git", "pull", "--ff-only") - } - - cmd.Dir = dst - setupGitEnv(cmd, sshKeyFile) - return getRunCommand(cmd) -} - -// fetchSubmodules downloads any configured submodules recursively. -func (g *GitGetter) fetchSubmodules(ctx context.Context, dst, sshKeyFile string, depth int) error { - args := []string{"submodule", "update", "--init", "--recursive"} - if depth > 0 { - args = append(args, "--depth", strconv.Itoa(depth)) - } - cmd := exec.CommandContext(ctx, "git", args...) - cmd.Dir = dst - setupGitEnv(cmd, sshKeyFile) - return getRunCommand(cmd) -} - -// findDefaultBranch checks the repo's origin remote for its default branch -// (generally "master"). "master" is returned if an origin default branch -// can't be determined. -func findDefaultBranch(dst string) string { - var stdoutbuf bytes.Buffer - cmd := exec.Command("git", "branch", "-r", "--points-at", "refs/remotes/origin/HEAD") - cmd.Dir = dst - cmd.Stdout = &stdoutbuf - err := cmd.Run() - matches := defaultBranchRegexp.FindStringSubmatch(stdoutbuf.String()) - if err != nil || matches == nil { - return "master" - } - return matches[len(matches)-1] -} - -// setupGitEnv sets up the environment for the given command. This is used to -// pass configuration data to git and ssh and enables advanced cloning methods. -func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) { - const gitSSHCommand = "GIT_SSH_COMMAND=" - var sshCmd []string - - // If we have an existing GIT_SSH_COMMAND, we need to append our options. - // We will also remove our old entry to make sure the behavior is the same - // with versions of Go < 1.9. - env := os.Environ() - for i, v := range env { - if strings.HasPrefix(v, gitSSHCommand) && len(v) > len(gitSSHCommand) { - sshCmd = []string{v} - - env[i], env[len(env)-1] = env[len(env)-1], env[i] - env = env[:len(env)-1] - break - } - } - - if len(sshCmd) == 0 { - sshCmd = []string{gitSSHCommand + "ssh"} - } - - if sshKeyFile != "" { - // We have an SSH key temp file configured, tell ssh about this. - if runtime.GOOS == "windows" { - sshKeyFile = strings.Replace(sshKeyFile, `\`, `/`, -1) - } - sshCmd = append(sshCmd, "-i", sshKeyFile) - } - - env = append(env, strings.Join(sshCmd, " ")) - cmd.Env = env -} - -// checkGitVersion is used to check the version of git installed on the system -// against a known minimum version. Returns an error if the installed version -// is older than the given minimum. -func checkGitVersion(min string) error { - want, err := version.NewVersion(min) - if err != nil { - return err - } - - out, err := exec.Command("git", "version").Output() - if err != nil { - return err - } - - fields := strings.Fields(string(out)) - if len(fields) < 3 { - return fmt.Errorf("Unexpected 'git version' output: %q", string(out)) - } - v := fields[2] - if runtime.GOOS == "windows" && strings.Contains(v, ".windows.") { - // on windows, git version will return for example: - // git version 2.20.1.windows.1 - // Which does not follow the semantic versionning specs - // https://semver.org. We remove that part in order for - // go-version to not error. - v = v[:strings.Index(v, ".windows.")] - } - - have, err := version.NewVersion(v) - if err != nil { - return err - } - - if have.LessThan(want) { - return fmt.Errorf("Required git version = %s, have %s", want, have) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-getter/get_hg.go b/vendor/github.com/hashicorp/go-getter/get_hg.go deleted file mode 100644 index 290649c91..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_hg.go +++ /dev/null @@ -1,135 +0,0 @@ -package getter - -import ( - "context" - "fmt" - "net/url" - "os" - "os/exec" - "path/filepath" - "runtime" - - urlhelper "github.com/hashicorp/go-getter/helper/url" - safetemp "github.com/hashicorp/go-safetemp" -) - -// HgGetter is a Getter implementation that will download a module from -// a Mercurial repository. -type HgGetter struct { - getter -} - -func (g *HgGetter) ClientMode(_ *url.URL) (ClientMode, error) { - return ClientModeDir, nil -} - -func (g *HgGetter) Get(dst string, u *url.URL) error { - ctx := g.Context() - if _, err := exec.LookPath("hg"); err != nil { - return fmt.Errorf("hg must be available and on the PATH") - } - - newURL, err := urlhelper.Parse(u.String()) - if err != nil { - return err - } - if fixWindowsDrivePath(newURL) { - // See valid file path form on http://www.selenic.com/hg/help/urls - newURL.Path = fmt.Sprintf("/%s", newURL.Path) - } - - // Extract some query parameters we use - var rev string - q := newURL.Query() - if len(q) > 0 { - rev = q.Get("rev") - q.Del("rev") - - newURL.RawQuery = q.Encode() - } - - _, err = os.Stat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - if err != nil { - if err := g.clone(dst, newURL); err != nil { - return err - } - } - - if err := g.pull(dst, newURL); err != nil { - return err - } - - return g.update(ctx, dst, newURL, rev) -} - -// GetFile for Hg doesn't support updating at this time. It will download -// the file every time. -func (g *HgGetter) GetFile(dst string, u *url.URL) error { - // Create a temporary directory to store the full source. This has to be - // a non-existent directory. - td, tdcloser, err := safetemp.Dir("", "getter") - if err != nil { - return err - } - defer tdcloser.Close() - - // Get the filename, and strip the filename from the URL so we can - // just get the repository directly. - filename := filepath.Base(u.Path) - u.Path = filepath.ToSlash(filepath.Dir(u.Path)) - - // If we're on Windows, we need to set the host to "localhost" for hg - if runtime.GOOS == "windows" { - u.Host = "localhost" - } - - // Get the full repository - if err := g.Get(td, u); err != nil { - return err - } - - // Copy the single file - u, err = urlhelper.Parse(fmtFileURL(filepath.Join(td, filename))) - if err != nil { - return err - } - - fg := &FileGetter{Copy: true, getter: g.getter} - return fg.GetFile(dst, u) -} - -func (g *HgGetter) clone(dst string, u *url.URL) error { - cmd := exec.Command("hg", "clone", "-U", u.String(), dst) - return getRunCommand(cmd) -} - -func (g *HgGetter) pull(dst string, u *url.URL) error { - cmd := exec.Command("hg", "pull") - cmd.Dir = dst - return getRunCommand(cmd) -} - -func (g *HgGetter) update(ctx context.Context, dst string, u *url.URL, rev string) error { - args := []string{"update"} - if rev != "" { - args = append(args, rev) - } - - cmd := exec.CommandContext(ctx, "hg", args...) - cmd.Dir = dst - return getRunCommand(cmd) -} - -func fixWindowsDrivePath(u *url.URL) bool { - // hg assumes a file:/// prefix for Windows drive letter file paths. - // (e.g. file:///c:/foo/bar) - // If the URL Path does not begin with a '/' character, the resulting URL - // path will have a file:// prefix. (e.g. file://c:/foo/bar) - // See http://www.selenic.com/hg/help/urls and the examples listed in - // http://selenic.com/repo/hg-stable/file/1265a3a71d75/mercurial/util.py#l1936 - return runtime.GOOS == "windows" && u.Scheme == "file" && - len(u.Path) > 1 && u.Path[0] != '/' && u.Path[1] == ':' -} diff --git a/vendor/github.com/hashicorp/go-getter/get_http.go b/vendor/github.com/hashicorp/go-getter/get_http.go deleted file mode 100644 index 618a411f9..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_http.go +++ /dev/null @@ -1,328 +0,0 @@ -package getter - -import ( - "context" - "encoding/xml" - "fmt" - "io" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - - safetemp "github.com/hashicorp/go-safetemp" -) - -// HttpGetter is a Getter implementation that will download from an HTTP -// endpoint. -// -// For file downloads, HTTP is used directly. -// -// The protocol for downloading a directory from an HTTP endpoint is as follows: -// -// An HTTP GET request is made to the URL with the additional GET parameter -// "terraform-get=1". This lets you handle that scenario specially if you -// wish. The response must be a 2xx. -// -// First, a header is looked for "X-Terraform-Get" which should contain -// a source URL to download. -// -// If the header is not present, then a meta tag is searched for named -// "terraform-get" and the content should be a source URL. -// -// The source URL, whether from the header or meta tag, must be a fully -// formed URL. The shorthand syntax of "github.com/foo/bar" or relative -// paths are not allowed. -type HttpGetter struct { - getter - - // Netrc, if true, will lookup and use auth information found - // in the user's netrc file if available. - Netrc bool - - // Client is the http.Client to use for Get requests. - // This defaults to a cleanhttp.DefaultClient if left unset. - Client *http.Client - - // Header contains optional request header fields that should be included - // with every HTTP request. Note that the zero value of this field is nil, - // and as such it needs to be initialized before use, via something like - // make(http.Header). - Header http.Header -} - -func (g *HttpGetter) ClientMode(u *url.URL) (ClientMode, error) { - if strings.HasSuffix(u.Path, "/") { - return ClientModeDir, nil - } - return ClientModeFile, nil -} - -func (g *HttpGetter) Get(dst string, u *url.URL) error { - ctx := g.Context() - // Copy the URL so we can modify it - var newU url.URL = *u - u = &newU - - if g.Netrc { - // Add auth from netrc if we can - if err := addAuthFromNetrc(u); err != nil { - return err - } - } - - if g.Client == nil { - g.Client = httpClient - } - - // Add terraform-get to the parameter. - q := u.Query() - q.Add("terraform-get", "1") - u.RawQuery = q.Encode() - - // Get the URL - req, err := http.NewRequest("GET", u.String(), nil) - if err != nil { - return err - } - - if g.Header != nil { - req.Header = g.Header.Clone() - } - - resp, err := g.Client.Do(req) - if err != nil { - return err - } - - defer resp.Body.Close() - if resp.StatusCode < 200 || resp.StatusCode >= 300 { - return fmt.Errorf("bad response code: %d", resp.StatusCode) - } - - // Extract the source URL - var source string - if v := resp.Header.Get("X-Terraform-Get"); v != "" { - source = v - } else { - source, err = g.parseMeta(resp.Body) - if err != nil { - return err - } - } - if source == "" { - return fmt.Errorf("no source URL was returned") - } - - // If there is a subdir component, then we download the root separately - // into a temporary directory, then copy over the proper subdir. - source, subDir := SourceDirSubdir(source) - if subDir == "" { - var opts []ClientOption - if g.client != nil { - opts = g.client.Options - } - return Get(dst, source, opts...) - } - - // We have a subdir, time to jump some hoops - return g.getSubdir(ctx, dst, source, subDir) -} - -// GetFile fetches the file from src and stores it at dst. -// If the server supports Accept-Range, HttpGetter will attempt a range -// request. This means it is the caller's responsibility to ensure that an -// older version of the destination file does not exist, else it will be either -// falsely identified as being replaced, or corrupted with extra bytes -// appended. -func (g *HttpGetter) GetFile(dst string, src *url.URL) error { - ctx := g.Context() - if g.Netrc { - // Add auth from netrc if we can - if err := addAuthFromNetrc(src); err != nil { - return err - } - } - // Create all the parent directories if needed - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - f, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, os.FileMode(0666)) - if err != nil { - return err - } - defer f.Close() - - if g.Client == nil { - g.Client = httpClient - } - - var currentFileSize int64 - - // We first make a HEAD request so we can check - // if the server supports range queries. If the server/URL doesn't - // support HEAD requests, we just fall back to GET. - req, err := http.NewRequest("HEAD", src.String(), nil) - if err != nil { - return err - } - if g.Header != nil { - req.Header = g.Header.Clone() - } - headResp, err := g.Client.Do(req) - if err == nil { - headResp.Body.Close() - if headResp.StatusCode == 200 { - // If the HEAD request succeeded, then attempt to set the range - // query if we can. - if headResp.Header.Get("Accept-Ranges") == "bytes" && headResp.ContentLength >= 0 { - if fi, err := f.Stat(); err == nil { - if _, err = f.Seek(0, io.SeekEnd); err == nil { - currentFileSize = fi.Size() - req.Header.Set("Range", fmt.Sprintf("bytes=%d-", currentFileSize)) - if currentFileSize >= headResp.ContentLength { - // file already present - return nil - } - } - } - } - } - } - req.Method = "GET" - - resp, err := g.Client.Do(req) - if err != nil { - return err - } - switch resp.StatusCode { - case http.StatusOK, http.StatusPartialContent: - // all good - default: - resp.Body.Close() - return fmt.Errorf("bad response code: %d", resp.StatusCode) - } - - body := resp.Body - - if g.client != nil && g.client.ProgressListener != nil { - // track download - fn := filepath.Base(src.EscapedPath()) - body = g.client.ProgressListener.TrackProgress(fn, currentFileSize, currentFileSize+resp.ContentLength, resp.Body) - } - defer body.Close() - - n, err := Copy(ctx, f, body) - if err == nil && n < resp.ContentLength { - err = io.ErrShortWrite - } - return err -} - -// getSubdir downloads the source into the destination, but with -// the proper subdir. -func (g *HttpGetter) getSubdir(ctx context.Context, dst, source, subDir string) error { - // Create a temporary directory to store the full source. This has to be - // a non-existent directory. - td, tdcloser, err := safetemp.Dir("", "getter") - if err != nil { - return err - } - defer tdcloser.Close() - - var opts []ClientOption - if g.client != nil { - opts = g.client.Options - } - // Download that into the given directory - if err := Get(td, source, opts...); err != nil { - return err - } - - // Process any globbing - sourcePath, err := SubdirGlob(td, subDir) - if err != nil { - return err - } - - // Make sure the subdir path actually exists - if _, err := os.Stat(sourcePath); err != nil { - return fmt.Errorf( - "Error downloading %s: %s", source, err) - } - - // Copy the subdirectory into our actual destination. - if err := os.RemoveAll(dst); err != nil { - return err - } - - // Make the final destination - if err := os.MkdirAll(dst, 0755); err != nil { - return err - } - - return copyDir(ctx, dst, sourcePath, false) -} - -// parseMeta looks for the first meta tag in the given reader that -// will give us the source URL. -func (g *HttpGetter) parseMeta(r io.Reader) (string, error) { - d := xml.NewDecoder(r) - d.CharsetReader = charsetReader - d.Strict = false - var err error - var t xml.Token - for { - t, err = d.Token() - if err != nil { - if err == io.EOF { - err = nil - } - return "", err - } - if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { - return "", nil - } - if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { - return "", nil - } - e, ok := t.(xml.StartElement) - if !ok || !strings.EqualFold(e.Name.Local, "meta") { - continue - } - if attrValue(e.Attr, "name") != "terraform-get" { - continue - } - if f := attrValue(e.Attr, "content"); f != "" { - return f, nil - } - } -} - -// attrValue returns the attribute value for the case-insensitive key -// `name', or the empty string if nothing is found. -func attrValue(attrs []xml.Attr, name string) string { - for _, a := range attrs { - if strings.EqualFold(a.Name.Local, name) { - return a.Value - } - } - return "" -} - -// charsetReader returns a reader for the given charset. Currently -// it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful -// error which is printed by go get, so the user can find why the package -// wasn't downloaded if the encoding is not supported. Note that, in -// order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters -// greater than 0x7f are not rejected). -func charsetReader(charset string, input io.Reader) (io.Reader, error) { - switch strings.ToLower(charset) { - case "ascii": - return input, nil - default: - return nil, fmt.Errorf("can't decode XML document using charset %q", charset) - } -} diff --git a/vendor/github.com/hashicorp/go-getter/get_mock.go b/vendor/github.com/hashicorp/go-getter/get_mock.go deleted file mode 100644 index e2a98ea28..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_mock.go +++ /dev/null @@ -1,54 +0,0 @@ -package getter - -import ( - "net/url" -) - -// MockGetter is an implementation of Getter that can be used for tests. -type MockGetter struct { - getter - - // Proxy, if set, will be called after recording the calls below. - // If it isn't set, then the *Err values will be returned. - Proxy Getter - - GetCalled bool - GetDst string - GetURL *url.URL - GetErr error - - GetFileCalled bool - GetFileDst string - GetFileURL *url.URL - GetFileErr error -} - -func (g *MockGetter) Get(dst string, u *url.URL) error { - g.GetCalled = true - g.GetDst = dst - g.GetURL = u - - if g.Proxy != nil { - return g.Proxy.Get(dst, u) - } - - return g.GetErr -} - -func (g *MockGetter) GetFile(dst string, u *url.URL) error { - g.GetFileCalled = true - g.GetFileDst = dst - g.GetFileURL = u - - if g.Proxy != nil { - return g.Proxy.GetFile(dst, u) - } - return g.GetFileErr -} - -func (g *MockGetter) ClientMode(u *url.URL) (ClientMode, error) { - if l := len(u.Path); l > 0 && u.Path[l-1:] == "/" { - return ClientModeDir, nil - } - return ClientModeFile, nil -} diff --git a/vendor/github.com/hashicorp/go-getter/get_s3.go b/vendor/github.com/hashicorp/go-getter/get_s3.go deleted file mode 100644 index 93eeb0b81..000000000 --- a/vendor/github.com/hashicorp/go-getter/get_s3.go +++ /dev/null @@ -1,275 +0,0 @@ -package getter - -import ( - "context" - "fmt" - "net/url" - "os" - "path/filepath" - "strings" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" - "github.com/aws/aws-sdk-go/aws/ec2metadata" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/s3" -) - -// S3Getter is a Getter implementation that will download a module from -// a S3 bucket. -type S3Getter struct { - getter -} - -func (g *S3Getter) ClientMode(u *url.URL) (ClientMode, error) { - // Parse URL - region, bucket, path, _, creds, err := g.parseUrl(u) - if err != nil { - return 0, err - } - - // Create client config - config := g.getAWSConfig(region, u, creds) - sess := session.New(config) - client := s3.New(sess) - - // List the object(s) at the given prefix - req := &s3.ListObjectsInput{ - Bucket: aws.String(bucket), - Prefix: aws.String(path), - } - resp, err := client.ListObjects(req) - if err != nil { - return 0, err - } - - for _, o := range resp.Contents { - // Use file mode on exact match. - if *o.Key == path { - return ClientModeFile, nil - } - - // Use dir mode if child keys are found. - if strings.HasPrefix(*o.Key, path+"/") { - return ClientModeDir, nil - } - } - - // There was no match, so just return file mode. The download is going - // to fail but we will let S3 return the proper error later. - return ClientModeFile, nil -} - -func (g *S3Getter) Get(dst string, u *url.URL) error { - ctx := g.Context() - - // Parse URL - region, bucket, path, _, creds, err := g.parseUrl(u) - if err != nil { - return err - } - - // Remove destination if it already exists - _, err = os.Stat(dst) - if err != nil && !os.IsNotExist(err) { - return err - } - - if err == nil { - // Remove the destination - if err := os.RemoveAll(dst); err != nil { - return err - } - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - config := g.getAWSConfig(region, u, creds) - sess := session.New(config) - client := s3.New(sess) - - // List files in path, keep listing until no more objects are found - lastMarker := "" - hasMore := true - for hasMore { - req := &s3.ListObjectsInput{ - Bucket: aws.String(bucket), - Prefix: aws.String(path), - } - if lastMarker != "" { - req.Marker = aws.String(lastMarker) - } - - resp, err := client.ListObjects(req) - if err != nil { - return err - } - - hasMore = aws.BoolValue(resp.IsTruncated) - - // Get each object storing each file relative to the destination path - for _, object := range resp.Contents { - lastMarker = aws.StringValue(object.Key) - objPath := aws.StringValue(object.Key) - - // If the key ends with a backslash assume it is a directory and ignore - if strings.HasSuffix(objPath, "/") { - continue - } - - // Get the object destination path - objDst, err := filepath.Rel(path, objPath) - if err != nil { - return err - } - objDst = filepath.Join(dst, objDst) - - if err := g.getObject(ctx, client, objDst, bucket, objPath, ""); err != nil { - return err - } - } - } - - return nil -} - -func (g *S3Getter) GetFile(dst string, u *url.URL) error { - ctx := g.Context() - region, bucket, path, version, creds, err := g.parseUrl(u) - if err != nil { - return err - } - - config := g.getAWSConfig(region, u, creds) - sess := session.New(config) - client := s3.New(sess) - return g.getObject(ctx, client, dst, bucket, path, version) -} - -func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, key, version string) error { - req := &s3.GetObjectInput{ - Bucket: aws.String(bucket), - Key: aws.String(key), - } - if version != "" { - req.VersionId = aws.String(version) - } - - resp, err := client.GetObject(req) - if err != nil { - return err - } - - // Create all the parent directories - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - - f, err := os.Create(dst) - if err != nil { - return err - } - defer f.Close() - - _, err = Copy(ctx, f, resp.Body) - return err -} - -func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config { - conf := &aws.Config{} - if creds == nil { - // Grab the metadata URL - metadataURL := os.Getenv("AWS_METADATA_URL") - if metadataURL == "" { - metadataURL = "http://169.254.169.254:80/latest" - } - - creds = credentials.NewChainCredentials( - []credentials.Provider{ - &credentials.EnvProvider{}, - &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, - &ec2rolecreds.EC2RoleProvider{ - Client: ec2metadata.New(session.New(&aws.Config{ - Endpoint: aws.String(metadataURL), - })), - }, - }) - } - - if creds != nil { - conf.Endpoint = &url.Host - conf.S3ForcePathStyle = aws.Bool(true) - if url.Scheme == "http" { - conf.DisableSSL = aws.Bool(true) - } - } - - conf.Credentials = creds - if region != "" { - conf.Region = aws.String(region) - } - - return conf -} - -func (g *S3Getter) parseUrl(u *url.URL) (region, bucket, path, version string, creds *credentials.Credentials, err error) { - // This just check whether we are dealing with S3 or - // any other S3 compliant service. S3 has a predictable - // url as others do not - if strings.Contains(u.Host, "amazonaws.com") { - // Expected host style: s3.amazonaws.com. They always have 3 parts, - // although the first may differ if we're accessing a specific region. - hostParts := strings.Split(u.Host, ".") - if len(hostParts) != 3 { - err = fmt.Errorf("URL is not a valid S3 URL") - return - } - - // Parse the region out of the first part of the host - region = strings.TrimPrefix(strings.TrimPrefix(hostParts[0], "s3-"), "s3") - if region == "" { - region = "us-east-1" - } - - pathParts := strings.SplitN(u.Path, "/", 3) - if len(pathParts) != 3 { - err = fmt.Errorf("URL is not a valid S3 URL") - return - } - - bucket = pathParts[1] - path = pathParts[2] - version = u.Query().Get("version") - - } else { - pathParts := strings.SplitN(u.Path, "/", 3) - if len(pathParts) != 3 { - err = fmt.Errorf("URL is not a valid S3 complaint URL") - return - } - bucket = pathParts[1] - path = pathParts[2] - version = u.Query().Get("version") - region = u.Query().Get("region") - if region == "" { - region = "us-east-1" - } - } - - _, hasAwsId := u.Query()["aws_access_key_id"] - _, hasAwsSecret := u.Query()["aws_access_key_secret"] - _, hasAwsToken := u.Query()["aws_access_token"] - if hasAwsId || hasAwsSecret || hasAwsToken { - creds = credentials.NewStaticCredentials( - u.Query().Get("aws_access_key_id"), - u.Query().Get("aws_access_key_secret"), - u.Query().Get("aws_access_token"), - ) - } - - return -} diff --git a/vendor/github.com/hashicorp/go-getter/go.mod b/vendor/github.com/hashicorp/go-getter/go.mod deleted file mode 100644 index a869e8f80..000000000 --- a/vendor/github.com/hashicorp/go-getter/go.mod +++ /dev/null @@ -1,23 +0,0 @@ -module github.com/hashicorp/go-getter - -require ( - cloud.google.com/go v0.45.1 - github.com/aws/aws-sdk-go v1.15.78 - github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d - github.com/cheggaaa/pb v1.0.27 - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.7.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.0 - github.com/hashicorp/go-safetemp v1.0.0 - github.com/hashicorp/go-version v1.1.0 - github.com/mattn/go-colorable v0.0.9 // indirect - github.com/mattn/go-isatty v0.0.4 // indirect - github.com/mattn/go-runewidth v0.0.4 // indirect - github.com/mitchellh/go-homedir v1.0.0 - github.com/mitchellh/go-testing-interface v1.0.0 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 // indirect - github.com/ulikunitz/xz v0.5.5 - google.golang.org/api v0.9.0 - gopkg.in/cheggaaa/pb.v1 v1.0.27 // indirect -) diff --git a/vendor/github.com/hashicorp/go-getter/go.sum b/vendor/github.com/hashicorp/go-getter/go.sum deleted file mode 100644 index b88c747ce..000000000 --- a/vendor/github.com/hashicorp/go-getter/go.sum +++ /dev/null @@ -1,162 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1 h1:lRi0CHyU+ytlvylOlFKKq0af6JncuyoRh1J+QJBqQx0= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/aws/aws-sdk-go v1.15.78 h1:LaXy6lWR0YK7LKyuU0QWy2ws/LWTPfYV/UgfiBu4tvY= -github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= -github.com/cheggaaa/pb v1.0.27 h1:wIkZHkNfC7R6GI5w7l/PdAdzXzlrbcI3p8OAlnkTsnc= -github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= -github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= -github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 h1:12VvqtR6Aowv3l/EQUlocDHW2Cp4G9WJVH7uyH8QFJE= -github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok= -github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -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 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0 h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -gopkg.in/cheggaaa/pb.v1 v1.0.27 h1:kJdccidYzt3CaHD1crCFTS1hxyhSi059NhOFUf03YFo= -gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url.go b/vendor/github.com/hashicorp/go-getter/helper/url/url.go deleted file mode 100644 index 02497c254..000000000 --- a/vendor/github.com/hashicorp/go-getter/helper/url/url.go +++ /dev/null @@ -1,14 +0,0 @@ -package url - -import ( - "net/url" -) - -// Parse parses rawURL into a URL structure. -// The rawURL may be relative or absolute. -// -// Parse is a wrapper for the Go stdlib net/url Parse function, but returns -// Windows "safe" URLs on Windows platforms. -func Parse(rawURL string) (*url.URL, error) { - return parse(rawURL) -} diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go b/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go deleted file mode 100644 index ed1352a91..000000000 --- a/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !windows - -package url - -import ( - "net/url" -) - -func parse(rawURL string) (*url.URL, error) { - return url.Parse(rawURL) -} diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go b/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go deleted file mode 100644 index 4280ec59a..000000000 --- a/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go +++ /dev/null @@ -1,39 +0,0 @@ -package url - -import ( - "fmt" - "net/url" - "path/filepath" - "strings" -) - -func parse(rawURL string) (*url.URL, error) { - // Make sure we're using "/" since URLs are "/"-based. - rawURL = filepath.ToSlash(rawURL) - - if len(rawURL) > 1 && rawURL[1] == ':' { - // Assume we're dealing with a drive letter. In which case we - // force the 'file' scheme to avoid "net/url" URL.String() prepending - // our url with "./". - rawURL = "file://" + rawURL - } - - u, err := url.Parse(rawURL) - if err != nil { - return nil, err - } - - if len(u.Host) > 1 && u.Host[1] == ':' && strings.HasPrefix(rawURL, "file://") { - // Assume we're dealing with a drive letter file path where the drive - // letter has been parsed into the URL Host. - u.Path = fmt.Sprintf("%s%s", u.Host, u.Path) - u.Host = "" - } - - // Remove leading slash for absolute file paths. - if len(u.Path) > 2 && u.Path[0] == '/' && u.Path[2] == ':' { - u.Path = u.Path[1:] - } - - return u, err -} diff --git a/vendor/github.com/hashicorp/go-getter/netrc.go b/vendor/github.com/hashicorp/go-getter/netrc.go deleted file mode 100644 index c7f6a3fb3..000000000 --- a/vendor/github.com/hashicorp/go-getter/netrc.go +++ /dev/null @@ -1,67 +0,0 @@ -package getter - -import ( - "fmt" - "net/url" - "os" - "runtime" - - "github.com/bgentry/go-netrc/netrc" - "github.com/mitchellh/go-homedir" -) - -// addAuthFromNetrc adds auth information to the URL from the user's -// netrc file if it can be found. This will only add the auth info -// if the URL doesn't already have auth info specified and the -// the username is blank. -func addAuthFromNetrc(u *url.URL) error { - // If the URL already has auth information, do nothing - if u.User != nil && u.User.Username() != "" { - return nil - } - - // Get the netrc file path - path := os.Getenv("NETRC") - if path == "" { - filename := ".netrc" - if runtime.GOOS == "windows" { - filename = "_netrc" - } - - var err error - path, err = homedir.Expand("~/" + filename) - if err != nil { - return err - } - } - - // If the file is not a file, then do nothing - if fi, err := os.Stat(path); err != nil { - // File doesn't exist, do nothing - if os.IsNotExist(err) { - return nil - } - - // Some other error! - return err - } else if fi.IsDir() { - // File is directory, ignore - return nil - } - - // Load up the netrc file - net, err := netrc.ParseFile(path) - if err != nil { - return fmt.Errorf("Error parsing netrc file at %q: %s", path, err) - } - - machine := net.FindMachine(u.Host) - if machine == nil { - // Machine not found, no problem - return nil - } - - // Set the user info - u.User = url.UserPassword(machine.Login, machine.Password) - return nil -} diff --git a/vendor/github.com/hashicorp/go-getter/source.go b/vendor/github.com/hashicorp/go-getter/source.go deleted file mode 100644 index dab6d400c..000000000 --- a/vendor/github.com/hashicorp/go-getter/source.go +++ /dev/null @@ -1,75 +0,0 @@ -package getter - -import ( - "fmt" - "path/filepath" - "strings" -) - -// SourceDirSubdir takes a source URL and returns a tuple of the URL without -// the subdir and the subdir. -// -// ex: -// dom.com/path/?q=p => dom.com/path/?q=p, "" -// proto://dom.com/path//*?q=p => proto://dom.com/path?q=p, "*" -// proto://dom.com/path//path2?q=p => proto://dom.com/path?q=p, "path2" -// -func SourceDirSubdir(src string) (string, string) { - - // URL might contains another url in query parameters - stop := len(src) - if idx := strings.Index(src, "?"); idx > -1 { - stop = idx - } - - // Calculate an offset to avoid accidentally marking the scheme - // as the dir. - var offset int - if idx := strings.Index(src[:stop], "://"); idx > -1 { - offset = idx + 3 - } - - // First see if we even have an explicit subdir - idx := strings.Index(src[offset:stop], "//") - if idx == -1 { - return src, "" - } - - idx += offset - subdir := src[idx+2:] - src = src[:idx] - - // Next, check if we have query parameters and push them onto the - // URL. - if idx = strings.Index(subdir, "?"); idx > -1 { - query := subdir[idx:] - subdir = subdir[:idx] - src += query - } - - return src, subdir -} - -// SubdirGlob returns the actual subdir with globbing processed. -// -// dst should be a destination directory that is already populated (the -// download is complete) and subDir should be the set subDir. If subDir -// is an empty string, this returns an empty string. -// -// The returned path is the full absolute path. -func SubdirGlob(dst, subDir string) (string, error) { - matches, err := filepath.Glob(filepath.Join(dst, subDir)) - if err != nil { - return "", err - } - - if len(matches) == 0 { - return "", fmt.Errorf("subdir %q not found", subDir) - } - - if len(matches) > 1 { - return "", fmt.Errorf("subdir %q matches multiple paths", subDir) - } - - return matches[0], nil -} diff --git a/vendor/github.com/hashicorp/go-getter/storage.go b/vendor/github.com/hashicorp/go-getter/storage.go deleted file mode 100644 index 2bc6b9ec3..000000000 --- a/vendor/github.com/hashicorp/go-getter/storage.go +++ /dev/null @@ -1,13 +0,0 @@ -package getter - -// Storage is an interface that knows how to lookup downloaded directories -// as well as download and update directories from their sources into the -// proper location. -type Storage interface { - // Dir returns the directory on local disk where the directory source - // can be loaded from. - Dir(string) (string, bool, error) - - // Get will download and optionally update the given directory. - Get(string, string, bool) error -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 79fffc518..425e03269 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -307,9 +307,6 @@ github.com/hashicorp/go-cty-funcs/crypto github.com/hashicorp/go-cty-funcs/encoding github.com/hashicorp/go-cty-funcs/filesystem github.com/hashicorp/go-cty-funcs/uuid -# github.com/hashicorp/go-getter v1.4.1 -github.com/hashicorp/go-getter -github.com/hashicorp/go-getter/helper/url # github.com/hashicorp/go-getter/gcs/v2 v2.0.0-20200604122502-a6995fa1edad github.com/hashicorp/go-getter/gcs/v2 # github.com/hashicorp/go-getter/s3/v2 v2.0.0-20200604122502-a6995fa1edad