github.phpd.cn/hashicorp/packer@v1.3.2/fix/fixer_parallels_headless.go (about) 1 package fix 2 3 import ( 4 "github.com/mitchellh/mapstructure" 5 ) 6 7 // FixerParallelsHeadless removes "headless" from a template in a Parallels builder 8 type FixerParallelsHeadless struct{} 9 10 func (FixerParallelsHeadless) 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 != "parallels-iso" && builderType != "parallels-pvm" { 34 continue 35 } 36 37 _, ok = builder["headless"] 38 if !ok { 39 continue 40 } 41 42 delete(builder, "headless") 43 } 44 45 input["builders"] = tpl.Builders 46 return input, nil 47 } 48 49 func (FixerParallelsHeadless) Synopsis() string { 50 return `Removes unused "headless" from Parallels builders` 51 }