Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Set IP and Hostname on Machine object properly
Browse files Browse the repository at this point in the history
Set the IP from InternalIP and the MachineName from Hostname.
  • Loading branch information
bcrochet committed Apr 22, 2019
1 parent cc7df0e commit 2196a63
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions object/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Machine struct {
Version string
MachineIP string
MachineName string
Name string
Namespace string
ClusterName string
Expand All @@ -33,8 +34,13 @@ func ToMachine(obj interface{}) interface{} {
ClusterName: machine.ObjectMeta.GetClusterName(),
}

if len(machine.Status.Addresses) > 0 {
m.MachineIP = machine.Status.Addresses[0].Address
for _, addr := range machine.Status.Addresses {
if addr.Type == "InternalIP" {
m.MachineIP = addr.Address
}
if addr.Type == "Hostname" {
m.MachineName = addr.Address
}
}

t := machine.ObjectMeta.DeletionTimestamp
Expand Down

0 comments on commit 2196a63

Please sign in to comment.