SEBA-797 fix.
Try to resolve hostnames in cordctl config as k8s doesn't like hostname.
This is to avoid subsequent grpc dial to xos-core fails with hostname:port
on cordctl commands.
Change-Id: Ibc5563307cc90e3e4a2b926db4a030e59c6251c2
diff --git a/commands/command.go b/commands/command.go
index 91d44a9..ef28d54 100644
--- a/commands/command.go
+++ b/commands/command.go
@@ -29,6 +29,7 @@
"os"
"strings"
"time"
+ "net"
)
type OutputType uint8
@@ -191,6 +192,12 @@
if GlobalConfig.Password == "" {
log.Fatal("Password is not set. Please update config file or use the -p option")
}
+ //Try to resolve hostname if provided for the server
+ if host, port, err := net.SplitHostPort(GlobalConfig.Server); err == nil {
+ if addrs, err := net.LookupHost(host); err == nil {
+ GlobalConfig.Server = net.JoinHostPort(addrs[0], port)
+ }
+ }
}
func NewConnection() (*grpc.ClientConn, error) {