github.com/hashicorp/packer@v1.14.3/fix/fixer_vmware_rename.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package fix 5 6 import ( 7 "github.com/mitchellh/mapstructure" 8 ) 9 10 // FixerVMwareRename changes "vmware" builders to "vmware-iso" 11 type FixerVMwareRename struct{} 12 13 func (FixerVMwareRename) DeprecatedOptions() map[string][]string { 14 return map[string][]string{} 15 } 16 17 func (FixerVMwareRename) Fix(input map[string]interface{}) (map[string]interface{}, error) { 18 // The type we'll decode into; we only care about builders 19 type template struct { 20 Builders []map[string]interface{} 21 } 22 23 // Decode the input into our structure, if we can 24 var tpl template 25 if err := mapstructure.Decode(input, &tpl); err != nil { 26 return nil, err 27 } 28 29 for _, builder := range tpl.Builders { 30 builderTypeRaw, ok := builder["type"] 31 if !ok { 32 continue 33 } 34 35 builderType, ok := builderTypeRaw.(string) 36 if !ok { 37 continue 38 } 39 40 if builderType != "vmware" { 41 continue 42 } 43 44 builder["type"] = "vmware-iso" 45 } 46 47 input["builders"] = tpl.Builders 48 return input, nil 49 } 50 51 func (FixerVMwareRename) Synopsis() string { 52 return `Updates "vmware" builders to "vmware-iso"` 53 }