Commit 65a9347b authored by James Nugent's avatar James Nugent

Fix potential nil pointer errors in ported code

This commit adds extra nil checks for some pointers which were not
necessary when using goamz
parent 33b4f5cc
......@@ -17,13 +17,13 @@ func SSHAddress(e *ec2.EC2, port int, private bool) func(multistep.StateBag) (st
for j := 0; j < 2; j++ {
var host string
i := state.Get("instance").(*ec2.Instance)
if *i.VPCID != "" {
if *i.PublicIPAddress != "" && !private {
if i.VPCID != nil && *i.VPCID != "" {
if i.PublicIPAddress != nil && *i.PublicIPAddress != "" && !private {
host = *i.PublicIPAddress
} else {
host = *i.PrivateIPAddress
}
} else if *i.PublicDNSName != "" {
} else if i.PublicDNSName != nil && *i.PublicDNSName != "" {
host = *i.PublicDNSName
}
......
......@@ -261,15 +261,15 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
}
if s.Debug {
if *s.instance.PublicDNSName != "" {
if s.instance.PublicDNSName != nil && *s.instance.PublicDNSName != "" {
ui.Message(fmt.Sprintf("Public DNS: %s", *s.instance.PublicDNSName))
}
if *s.instance.PublicIPAddress != "" {
if s.instance.PublicIPAddress != nil && *s.instance.PublicIPAddress != "" {
ui.Message(fmt.Sprintf("Public IP: %s", *s.instance.PublicIPAddress))
}
if *s.instance.PrivateIPAddress != "" {
if s.instance.PrivateIPAddress != nil && *s.instance.PrivateIPAddress != "" {
ui.Message(fmt.Sprintf("Private IP: %s", *s.instance.PrivateIPAddress))
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment