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 f069285
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 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 All @@ -52,6 +58,7 @@ func (m *Machine) DeepCopyObject() runtime.Object {
m1 := &Machine{
Version: m.Version,
MachineIP: m.MachineIP,
MachineName: m.MachineName,
Name: m.Name,
Namespace: m.Namespace,
ClusterName: m.ClusterName,
Expand Down

0 comments on commit f069285

Please sign in to comment.