mirror of
https://github.com/hashicorp/packer.git
synced 2026-04-24 07:37:22 -04:00
* Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at https://hashi.co/license-faq, and details of the license at www.hashicorp.com/bsl. * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package fix
|
|
|
|
import "github.com/mitchellh/mapstructure"
|
|
|
|
type FixerDockerEmail struct{}
|
|
|
|
func (FixerDockerEmail) DeprecatedOptions() map[string][]string {
|
|
return map[string][]string{
|
|
"packer.docker": []string{"login_email"},
|
|
"packer.post-processor.docker-import": []string{"login_email"},
|
|
}
|
|
|
|
}
|
|
|
|
func (FixerDockerEmail) Fix(input map[string]interface{}) (map[string]interface{}, error) {
|
|
if input["post-processors"] == nil {
|
|
return input, nil
|
|
}
|
|
|
|
// Our template type we'll use for this fixer only
|
|
type template struct {
|
|
Builders []map[string]interface{}
|
|
PP `mapstructure:",squash"`
|
|
}
|
|
|
|
// Decode the input into our structure, if we can
|
|
var tpl template
|
|
if err := mapstructure.Decode(input, &tpl); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Go through each builder and delete `docker_login` if present
|
|
for _, builder := range tpl.Builders {
|
|
_, ok := builder["login_email"]
|
|
if !ok {
|
|
continue
|
|
}
|
|
delete(builder, "login_email")
|
|
}
|
|
|
|
// Go through each post-processor and delete `docker_login` if present
|
|
pps := tpl.ppList()
|
|
|
|
for _, pp := range pps {
|
|
_, ok := pp["login_email"]
|
|
if !ok {
|
|
continue
|
|
}
|
|
delete(pp, "login_email")
|
|
}
|
|
|
|
input["builders"] = tpl.Builders
|
|
input["post-processors"] = tpl.PostProcessors
|
|
return input, nil
|
|
}
|
|
|
|
func (FixerDockerEmail) Synopsis() string {
|
|
return `Removes "login_email" from the Docker builder.`
|
|
}
|