github.com/hashicorp/packer@v1.14.3/fix/helpers.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package fix 5 6 // PP is a convenient way to interact with the post-processors within a fixer 7 type PP struct { 8 PostProcessors []interface{} `mapstructure:"post-processors"` 9 } 10 11 // postProcessors converts the variable structure of the template to a list 12 func (pp *PP) ppList() []map[string]interface{} { 13 pps := make([]map[string]interface{}, 0, len(pp.PostProcessors)) 14 for _, rawPP := range pp.PostProcessors { 15 switch pp := rawPP.(type) { 16 case string: 17 case map[string]interface{}: 18 pps = append(pps, pp) 19 case []interface{}: 20 for _, innerRawPP := range pp { 21 if innerPP, ok := innerRawPP.(map[string]interface{}); ok { 22 pps = append(pps, innerPP) 23 } 24 } 25 } 26 } 27 return pps 28 }