github.phpd.cn/hashicorp/packer@v1.3.2/fix/fixer_docker_email.go (about) 1 package fix 2 3 import "github.com/mitchellh/mapstructure" 4 5 type FixerDockerEmail struct{} 6 7 func (FixerDockerEmail) Fix(input map[string]interface{}) (map[string]interface{}, error) { 8 if input["post-processors"] == nil { 9 return input, nil 10 } 11 12 // Our template type we'll use for this fixer only 13 type template struct { 14 Builders []map[string]interface{} 15 PP `mapstructure:",squash"` 16 } 17 18 // Decode the input into our structure, if we can 19 var tpl template 20 if err := mapstructure.Decode(input, &tpl); err != nil { 21 return nil, err 22 } 23 24 // Go through each builder and delete `docker_login` if present 25 for _, builder := range tpl.Builders { 26 _, ok := builder["login_email"] 27 if !ok { 28 continue 29 } 30 delete(builder, "login_email") 31 } 32 33 // Go through each post-processor and delete `docker_login` if present 34 pps := tpl.ppList() 35 36 for _, pp := range pps { 37 _, ok := pp["login_email"] 38 if !ok { 39 continue 40 } 41 delete(pp, "login_email") 42 } 43 44 input["builders"] = tpl.Builders 45 input["post-processors"] = tpl.PostProcessors 46 return input, nil 47 } 48 49 func (FixerDockerEmail) Synopsis() string { 50 return `Removes "login_email" from the Docker builder.` 51 }