order Ip Address, IPv4 first, cleanup
This commit is contained in:
parent
b4f5ed6618
commit
6ed79b7bb8
1 changed files with 10 additions and 8 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
survey "github.com/AlecAivazis/survey/v2"
|
survey "github.com/AlecAivazis/survey/v2"
|
||||||
|
@ -453,13 +454,14 @@ func nodesToPtables(
|
||||||
namespace = pterm.LightYellow(machine.Namespace.Name)
|
namespace = pterm.LightYellow(machine.Namespace.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
var IpAddresses string
|
var IpV4Address string
|
||||||
if netaddr.MustParseIP(machine.IpAddresses[0]).Is4() {
|
var IpV6Address string
|
||||||
IpAddresses = machine.IpAddresses[0]
|
for _, addr := range machine.IpAddresses {
|
||||||
IpAddresses += ", " + machine.IpAddresses[1]
|
if netaddr.MustParseIP(addr).Is4() {
|
||||||
} else {
|
IpV4Address = addr
|
||||||
IpAddresses = machine.IpAddresses[1]
|
} else {
|
||||||
IpAddresses += ", " + machine.IpAddresses[0]
|
IpV6Address = addr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData = append(
|
tableData = append(
|
||||||
|
@ -469,7 +471,7 @@ func nodesToPtables(
|
||||||
machine.Name,
|
machine.Name,
|
||||||
nodeKey.ShortString(),
|
nodeKey.ShortString(),
|
||||||
namespace,
|
namespace,
|
||||||
IpAddresses,
|
strings.Join([]string{IpV4Address, IpV6Address}, ", "),
|
||||||
strconv.FormatBool(ephemeral),
|
strconv.FormatBool(ephemeral),
|
||||||
lastSeenTime,
|
lastSeenTime,
|
||||||
online,
|
online,
|
||||||
|
|
Loading…
Reference in a new issue