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

Set IP and Hostname on Machine object properly #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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