diff --git a/fix/fixer.go b/fix/fixer.go index af1587aa1..8e3ef76e0 100644 --- a/fix/fixer.go +++ b/fix/fixer.go @@ -2,6 +2,12 @@ package fix // A Fixer is something that can perform a fix operation on a template. type Fixer interface { + // DeprecatedOptions returns the name(s) of the option(s) being replaced in + // this fixer. It is used to generate a list of deprecated options that the + // template parser checks against to warn users that they need to call + // `packer fix` against their templates after upgrading. + DeprecatedOptions() []string + // Fix takes a raw map structure input, potentially transforms it // in some way, and returns the new, transformed structure. The // Fix method is allowed to mutate the input. diff --git a/fix/fixer_amazon_enhanced_networking.go b/fix/fixer_amazon_enhanced_networking.go index 7188da7f7..ce502ee37 100644 --- a/fix/fixer_amazon_enhanced_networking.go +++ b/fix/fixer_amazon_enhanced_networking.go @@ -10,6 +10,10 @@ import ( // with the clearer "ena_support". This disambiguates ena_support from sriov_support. type FixerAmazonEnhancedNetworking struct{} +func (FixerAmazonEnhancedNetworking) DeprecatedOptions() []string { + return []string{"enhanced_networking"} +} + func (FixerAmazonEnhancedNetworking) Fix(input map[string]interface{}) (map[string]interface{}, error) { // Our template type we'll use for this fixer only type template struct { diff --git a/fix/fixer_amazon_private_ip.go b/fix/fixer_amazon_private_ip.go index 5fd11d60a..7924f99e1 100644 --- a/fix/fixer_amazon_private_ip.go +++ b/fix/fixer_amazon_private_ip.go @@ -12,6 +12,10 @@ import ( // true` with `"ssh_interface": "private_ip"` type FixerAmazonPrivateIP struct{} +func (FixerAmazonPrivateIP) DeprecatedOptions() []string { + return []string{"ssh_private_ip"} +} + func (FixerAmazonPrivateIP) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Builders []map[string]interface{} diff --git a/fix/fixer_amazon_shutdown_behavior.go b/fix/fixer_amazon_shutdown_behavior.go index 686ef5119..04c52ab04 100644 --- a/fix/fixer_amazon_shutdown_behavior.go +++ b/fix/fixer_amazon_shutdown_behavior.go @@ -10,6 +10,10 @@ import ( // template in a Amazon builder type FixerAmazonShutdownBehavior struct{} +func (FixerAmazonShutdownBehavior) DeprecatedOptions() []string { + return []string{"shutdown_behaviour"} +} + func (FixerAmazonShutdownBehavior) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_amazon_spot_price_product.go b/fix/fixer_amazon_spot_price_product.go index 2ed961589..c1bd537b9 100644 --- a/fix/fixer_amazon_spot_price_product.go +++ b/fix/fixer_amazon_spot_price_product.go @@ -4,10 +4,14 @@ import ( "github.com/mitchellh/mapstructure" ) -// FixerAmazonSpotPriceProductDeprecation removes the deprecated "vhd_temp_path" setting +// FixerAmazonSpotPriceProductDeprecation removes the deprecated "spot_price_auto_product" setting // from Amazon builder templates type FixerAmazonSpotPriceProductDeprecation struct{} +func (FixerAmazonSpotPriceProductDeprecation) DeprecatedOptions() []string { + return []string{"spot_price_auto_product"} +} + func (FixerAmazonSpotPriceProductDeprecation) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_amazon_temporary_security_group_cidrs.go b/fix/fixer_amazon_temporary_security_group_cidrs.go index 0a420aecb..456f6faf5 100644 --- a/fix/fixer_amazon_temporary_security_group_cidrs.go +++ b/fix/fixer_amazon_temporary_security_group_cidrs.go @@ -8,6 +8,10 @@ import ( type FixerAmazonTemporarySecurityCIDRs struct{} +func (FixerAmazonTemporarySecurityCIDRs) DeprecatedOptions() []string { + return []string{} +} + func (FixerAmazonTemporarySecurityCIDRs) Fix(input map[string]interface{}) (map[string]interface{}, error) { // Our template type we'll use for this fixer only type template struct { diff --git a/fix/fixer_clean_image_name.go b/fix/fixer_clean_image_name.go index cbb85f894..f2880ff8c 100644 --- a/fix/fixer_clean_image_name.go +++ b/fix/fixer_clean_image_name.go @@ -11,6 +11,10 @@ import ( // calls with "clean_resource_name" type FixerCleanImageName struct{} +func (FixerCleanImageName) DeprecatedOptions() []string { + return []string{"clean_image_name", "clean_ami_name"} +} + func (FixerCleanImageName) Fix(input map[string]interface{}) (map[string]interface{}, error) { // Our template type we'll use for this fixer only type template struct { diff --git a/fix/fixer_comm_config.go b/fix/fixer_comm_config.go index d3bd44442..54c658970 100644 --- a/fix/fixer_comm_config.go +++ b/fix/fixer_comm_config.go @@ -10,6 +10,11 @@ import ( // for variables host_port_min, host_port_max, skip_nat_mapping type FixerCommConfig struct{} +func (FixerCommConfig) DeprecatedOptions() []string { + return []string{"ssh_host_port_min", "ssh_host_port_max", + "ssh_skip_nat_mapping"} +} + func (FixerCommConfig) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Builders []interface{} diff --git a/fix/fixer_createtime.go b/fix/fixer_createtime.go index 67bd12284..d4045a17a 100644 --- a/fix/fixer_createtime.go +++ b/fix/fixer_createtime.go @@ -10,6 +10,10 @@ import ( // calls with "{{timestamp}" type FixerCreateTime struct{} +func (FixerCreateTime) DeprecatedOptions() []string { + return []string{} +} + func (FixerCreateTime) Fix(input map[string]interface{}) (map[string]interface{}, error) { // Our template type we'll use for this fixer only type template struct { diff --git a/fix/fixer_docker_email.go b/fix/fixer_docker_email.go index 6db0cac60..f7984a871 100644 --- a/fix/fixer_docker_email.go +++ b/fix/fixer_docker_email.go @@ -4,6 +4,10 @@ import "github.com/mitchellh/mapstructure" type FixerDockerEmail struct{} +func (FixerDockerEmail) DeprecatedOptions() []string { + return []string{"login_email"} +} + func (FixerDockerEmail) Fix(input map[string]interface{}) (map[string]interface{}, error) { if input["post-processors"] == nil { return input, nil diff --git a/fix/fixer_galaxy_command.go b/fix/fixer_galaxy_command.go index 5e2ed8a37..8b455cf93 100644 --- a/fix/fixer_galaxy_command.go +++ b/fix/fixer_galaxy_command.go @@ -8,6 +8,10 @@ import ( // environment variables and replace galaxycommand with galaxy_command type FixerGalaxyCommand struct{} +func (FixerGalaxyCommand) DeprecatedOptions() []string { + return []string{"galaxycommand"} +} + func (FixerGalaxyCommand) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Provisioners []interface{} diff --git a/fix/fixer_hyperv_cpu_and_ram_naming.go b/fix/fixer_hyperv_cpu_and_ram_naming.go index 4caecc396..71567d298 100644 --- a/fix/fixer_hyperv_cpu_and_ram_naming.go +++ b/fix/fixer_hyperv_cpu_and_ram_naming.go @@ -8,6 +8,10 @@ import ( // it with "clone_from_vmcx_path" in Hyper-V VMCX builder templates type FizerHypervCPUandRAM struct{} +func (FizerHypervCPUandRAM) DeprecatedOptions() []string { + return []string{"cpu", "ram_size"} +} + func (FizerHypervCPUandRAM) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_hyperv_deprecations.go b/fix/fixer_hyperv_deprecations.go index 79a75d83d..09ad1e1de 100644 --- a/fix/fixer_hyperv_deprecations.go +++ b/fix/fixer_hyperv_deprecations.go @@ -8,6 +8,10 @@ import ( // from Hyper-V ISO builder templates type FixerHypervDeprecations struct{} +func (FixerHypervDeprecations) DeprecatedOptions() []string { + return []string{"vhd_temp_path"} +} + func (FixerHypervDeprecations) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_hyperv_vmxc_typo.go b/fix/fixer_hyperv_vmxc_typo.go index fbc057c54..939afca11 100644 --- a/fix/fixer_hyperv_vmxc_typo.go +++ b/fix/fixer_hyperv_vmxc_typo.go @@ -8,6 +8,10 @@ import ( // it with "clone_from_vmcx_path" in Hyper-V VMCX builder templates type FixerHypervVmxcTypo struct{} +func (FixerHypervVmxcTypo) DeprecatedOptions() []string { + return []string{"clone_from_vmxc_path"} +} + func (FixerHypervVmxcTypo) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_iso_checksum_type_and_url.go b/fix/fixer_iso_checksum_type_and_url.go index 3730e2871..82bdf4e0e 100644 --- a/fix/fixer_iso_checksum_type_and_url.go +++ b/fix/fixer_iso_checksum_type_and_url.go @@ -8,6 +8,10 @@ import ( // "iso_checksum_type" to put everything in the checksum field. type FixerISOChecksumTypeAndURL struct{} +func (FixerISOChecksumTypeAndURL) DeprecatedOptions() []string { + return []string{"iso_checksum_url", "iso_checksum_type"} +} + func (FixerISOChecksumTypeAndURL) Fix(input map[string]interface{}) (map[string]interface{}, error) { // Our template type we'll use for this fixer only type template struct { diff --git a/fix/fixer_iso_md5.go b/fix/fixer_iso_md5.go index 3d463e1b0..9a5d6e834 100644 --- a/fix/fixer_iso_md5.go +++ b/fix/fixer_iso_md5.go @@ -8,6 +8,10 @@ import ( // with the newer "iso_checksum" and "iso_checksum_type" within builders. type FixerISOMD5 struct{} +func (FixerISOMD5) DeprecatedOptions() []string { + return []string{"iso_md5"} +} + func (FixerISOMD5) Fix(input map[string]interface{}) (map[string]interface{}, error) { // Our template type we'll use for this fixer only type template struct { diff --git a/fix/fixer_parallels_deprecations.go b/fix/fixer_parallels_deprecations.go index 9afc22088..0323f8140 100644 --- a/fix/fixer_parallels_deprecations.go +++ b/fix/fixer_parallels_deprecations.go @@ -9,6 +9,10 @@ import ( // "guest_os_type", possibly overwriting any existing "guest_os_type" type FixerParallelsDeprecations struct{} +func (FixerParallelsDeprecations) DeprecatedOptions() []string { + return []string{"parallels_tools_host_path", "guest_os_distribution"} +} + func (FixerParallelsDeprecations) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_parallels_headless.go b/fix/fixer_parallels_headless.go index f7bc8874a..3611b6a2d 100644 --- a/fix/fixer_parallels_headless.go +++ b/fix/fixer_parallels_headless.go @@ -7,6 +7,10 @@ import ( // FixerParallelsHeadless removes "headless" from a template in a Parallels builder type FixerParallelsHeadless struct{} +func (FixerParallelsHeadless) DeprecatedOptions() []string { + return []string{"headless"} +} + func (FixerParallelsHeadless) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_powershell_escapes.go b/fix/fixer_powershell_escapes.go index e9e3b0033..bbc496b4b 100644 --- a/fix/fixer_powershell_escapes.go +++ b/fix/fixer_powershell_escapes.go @@ -10,6 +10,10 @@ import ( // environment variables and elevated username and password strings type FixerPowerShellEscapes struct{} +func (FixerPowerShellEscapes) DeprecatedOptions() []string { + return []string{} +} + func (FixerPowerShellEscapes) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Provisioners []interface{} diff --git a/fix/fixer_pp_docker_tag_tags.go b/fix/fixer_pp_docker_tag_tags.go index 20d90f144..6a7beb45f 100644 --- a/fix/fixer_pp_docker_tag_tags.go +++ b/fix/fixer_pp_docker_tag_tags.go @@ -9,6 +9,10 @@ import ( // FixerDockerTagtoTags renames tag to tags type FixerDockerTagtoTags struct{} +func (FixerDockerTagtoTags) DeprecatedOptions() []string { + return []string{"tag"} +} + func (FixerDockerTagtoTags) Fix(input map[string]interface{}) (map[string]interface{}, error) { if input["post-processors"] == nil { return input, nil diff --git a/fix/fixer_pp_manifest_filename.go b/fix/fixer_pp_manifest_filename.go index fd5e78ba7..25d131e59 100644 --- a/fix/fixer_pp_manifest_filename.go +++ b/fix/fixer_pp_manifest_filename.go @@ -7,6 +7,10 @@ import ( // FixerManifestFilename renames any Filename to Output type FixerManifestFilename struct{} +func (FixerManifestFilename) DeprecatedOptions() []string { + return []string{"filename"} +} + func (FixerManifestFilename) Fix(input map[string]interface{}) (map[string]interface{}, error) { if input["post-processors"] == nil { return input, nil diff --git a/fix/fixer_pp_vagrant_override.go b/fix/fixer_pp_vagrant_override.go index f3bd4693e..ebb80a5f3 100644 --- a/fix/fixer_pp_vagrant_override.go +++ b/fix/fixer_pp_vagrant_override.go @@ -7,6 +7,10 @@ import "github.com/mitchellh/mapstructure" // as part of Packer 0.5.0. type FixerVagrantPPOverride struct{} +func (FixerVagrantPPOverride) DeprecatedOptions() []string { + return []string{} +} + func (FixerVagrantPPOverride) Fix(input map[string]interface{}) (map[string]interface{}, error) { if input["post-processors"] == nil { return input, nil diff --git a/fix/fixer_qemu_disk_size.go b/fix/fixer_qemu_disk_size.go index 9a7f15165..706276d36 100644 --- a/fix/fixer_qemu_disk_size.go +++ b/fix/fixer_qemu_disk_size.go @@ -9,6 +9,10 @@ import ( // FixerQEMUDiskSize updates disk_size from a string to int for QEMU builders type FixerQEMUDiskSize struct{} +func (FixerQEMUDiskSize) DeprecatedOptions() []string { + return []string{} +} + func (FixerQEMUDiskSize) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Builders []map[string]interface{} diff --git a/fix/fixer_scaleway_access_key.go b/fix/fixer_scaleway_access_key.go index d134ac32d..3cbc13669 100644 --- a/fix/fixer_scaleway_access_key.go +++ b/fix/fixer_scaleway_access_key.go @@ -8,6 +8,10 @@ import ( // to "organization_id". type FixerScalewayAccessKey struct{} +func (FixerScalewayAccessKey) DeprecatedOptions() []string { + return []string{"access_key"} +} + func (FixerScalewayAccessKey) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_ssh_timeout.go b/fix/fixer_ssh_timeout.go index 91cf1e68d..3e9c3c2e9 100644 --- a/fix/fixer_ssh_timeout.go +++ b/fix/fixer_ssh_timeout.go @@ -7,6 +7,10 @@ import ( // FixerSSHTimout replaces ssh_wait_timeout with ssh_timeout type FixerSSHTimout struct{} +func (FixerSSHTimout) DeprecatedOptions() []string { + return []string{"ssh_wait_timeout"} +} + func (FixerSSHTimout) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Builders []interface{} diff --git a/fix/fixer_sshdisableagent.go b/fix/fixer_sshdisableagent.go index b399af52a..4cfc05aa6 100644 --- a/fix/fixer_sshdisableagent.go +++ b/fix/fixer_sshdisableagent.go @@ -8,6 +8,10 @@ import ( // to "ssh_disable_agent_forwarding". type FixerSSHDisableAgent struct{} +func (FixerSSHDisableAgent) DeprecatedOptions() []string { + return []string{"ssh_disable_agent"} +} + func (FixerSSHDisableAgent) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_sshkeypath.go b/fix/fixer_sshkeypath.go index b57cf762b..d624cc828 100644 --- a/fix/fixer_sshkeypath.go +++ b/fix/fixer_sshkeypath.go @@ -8,6 +8,10 @@ import ( // to "ssh_private_key_file". type FixerSSHKeyPath struct{} +func (FixerSSHKeyPath) DeprecatedOptions() []string { + return []string{"ssh_key_path"} +} + func (FixerSSHKeyPath) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_virtualbox_gaattach.go b/fix/fixer_virtualbox_gaattach.go index 0014018ed..dc46bf2fb 100644 --- a/fix/fixer_virtualbox_gaattach.go +++ b/fix/fixer_virtualbox_gaattach.go @@ -8,6 +8,10 @@ import ( // to "guest_additions_mode". type FixerVirtualBoxGAAttach struct{} +func (FixerVirtualBoxGAAttach) DeprecatedOptions() []string { + return []string{"guest_additions_attach"} +} + func (FixerVirtualBoxGAAttach) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_virtualbox_rename.go b/fix/fixer_virtualbox_rename.go index 34187ac2c..6e1698fa4 100644 --- a/fix/fixer_virtualbox_rename.go +++ b/fix/fixer_virtualbox_rename.go @@ -7,6 +7,10 @@ import ( // FixerVirtualBoxRename changes "virtualbox" builders to "virtualbox-iso" type FixerVirtualBoxRename struct{} +func (FixerVirtualBoxRename) DeprecatedOptions() []string { + return []string{} +} + func (FixerVirtualBoxRename) Fix(input map[string]interface{}) (map[string]interface{}, error) { type template struct { Builders []map[string]interface{} diff --git a/fix/fixer_vmware_compaction.go b/fix/fixer_vmware_compaction.go index 9a0cb1373..fcc2813fd 100644 --- a/fix/fixer_vmware_compaction.go +++ b/fix/fixer_vmware_compaction.go @@ -7,6 +7,10 @@ import ( // FixerVMwareCompaction adds "skip_compaction = true" to "vmware-iso" builders with incompatible disk_type_id type FixerVMwareCompaction struct{} +func (FixerVMwareCompaction) DeprecatedOptions() []string { + return []string{} +} + func (FixerVMwareCompaction) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_vmware_rename.go b/fix/fixer_vmware_rename.go index 7a7b7b920..165fb29b0 100644 --- a/fix/fixer_vmware_rename.go +++ b/fix/fixer_vmware_rename.go @@ -4,9 +4,13 @@ import ( "github.com/mitchellh/mapstructure" ) -// FixerVMwareRename changes "virtualbox" builders to "virtualbox-iso" +// FixerVMwareRename changes "vmware" builders to "vmware-iso" type FixerVMwareRename struct{} +func (FixerVMwareRename) DeprecatedOptions() []string { + return []string{} +} + func (FixerVMwareRename) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/fix/fixer_vsphere_network_storage.go b/fix/fixer_vsphere_network_storage.go index 21a953330..cfc252887 100644 --- a/fix/fixer_vsphere_network_storage.go +++ b/fix/fixer_vsphere_network_storage.go @@ -8,6 +8,10 @@ import ( // changes the disk_size, disk_thin_provisioned, and disk_eagerly_scrub into a storage adapter type FixerVSphereNetworkDisk struct{} +func (FixerVSphereNetworkDisk) DeprecatedOptions() []string { + return []string{"network_card", "network", "networkCard"} +} + func (FixerVSphereNetworkDisk) Fix(input map[string]interface{}) (map[string]interface{}, error) { // The type we'll decode into; we only care about builders type template struct { diff --git a/template/parse.go b/template/parse.go index 830a0ac8c..4f89738d2 100644 --- a/template/parse.go +++ b/template/parse.go @@ -377,6 +377,8 @@ func Parse(r io.Reader) (*Template, error) { rawTpl.Comments = append(rawTpl.Comments, comment) continue } + // Check for whether any of these keys are handled in a packer fix + // call. err = multierror.Append(err, fmt.Errorf( "Unknown root level key in template: '%s'", unused))