You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
terraform/communicator/shared/shared.go

18 lines
456 B

package shared
import (
"fmt"
"net"
)
// IpFormat formats the IP correctly, so we don't provide IPv6 address in an IPv4 format during node communication. We return the ip parameter as is if it's an IPv4 address or a hostname.
func IpFormat(ip string) string {
ipObj := net.ParseIP(ip)
// Return the ip/host as is if it's either a hostname or an IPv4 address.
if ipObj == nil || ipObj.To4() != nil {
return ip
}
return fmt.Sprintf("[%s]", ip)
}