Merge pull request #7336 from dkuntz2/make-private-ip-fixer-error-more-clearly

Make the amazon-private-ip fixer errors more visible
This commit is contained in:
Adrien Delorme 2019-02-26 09:47:31 +01:00 committed by GitHub
commit b32449cdcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -1,7 +1,7 @@
package fix package fix
import ( import (
"log" "fmt"
"strconv" "strconv"
"strings" "strings"
@ -53,8 +53,7 @@ func (FixerAmazonPrivateIP) Fix(input map[string]interface{}) (map[string]interf
var err error var err error
privateIP, err = strconv.ParseBool(privateIPi.(string)) privateIP, err = strconv.ParseBool(privateIPi.(string))
if err != nil { if err != nil {
log.Fatalf("Wrong type for ssh_private_ip") return nil, fmt.Errorf("ssh_private_ip is not a boolean, %s", err)
continue
} }
} }

View File

@ -75,3 +75,19 @@ func TestFixerAmazonPrivateIP(t *testing.T) {
} }
} }
} }
func TestFixerAmazonPrivateIPNonBoolean(t *testing.T) {
var f FixerAmazonPrivateIP
input := map[string]interface{}{
"builders": []map[string]interface{}{{
"type": "amazon-ebs",
"ssh_private_ip": "not-a-boolean-value",
}},
}
_, err := f.Fix(input)
if err == nil {
t.Fatal("should have errored")
}
}