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