Merge pull request #6458 from devenney/hotfix/amazon-private-ip-string-value

Ensure amazon-private-ip fixes string values
This commit is contained in:
M. Marsh 2018-07-09 15:07:44 -07:00 committed by GitHub
commit a8ac969e0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package fix
import (
"log"
"strconv"
"strings"
"github.com/mitchellh/mapstructure"
@ -49,8 +50,12 @@ func (FixerAmazonPrivateIP) Fix(input map[string]interface{}) (map[string]interf
}
privateIP, ok := privateIPi.(bool)
if !ok {
log.Fatalf("Wrong type for ssh_private_ip")
continue
var err error
privateIP, err = strconv.ParseBool(privateIPi.(string))
if err != nil {
log.Fatalf("Wrong type for ssh_private_ip")
continue
}
}
delete(builder, "ssh_private_ip")

View File

@ -39,6 +39,19 @@ func TestFixerAmazonPrivateIP(t *testing.T) {
"ssh_interface": "private_ip",
},
},
// ssh_private_ip specified as string
{
Input: map[string]interface{}{
"type": "amazon-ebs",
"ssh_private_ip": "true",
},
Expected: map[string]interface{}{
"type": "amazon-ebs",
"ssh_interface": "private_ip",
},
},
}
for _, tc := range cases {