From feb1187d55a00a36dad78d45471c221d15d9c14a Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Sun, 10 Sep 2017 22:20:34 -0700 Subject: [PATCH] fix(device): set system.ips to satisfy heartbeat requirement --- pkg/device/builder/builder.go | 18 +++++++++++------- pkg/types/types.go | 2 ++ pkg/watch/pod/pod.go | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/device/builder/builder.go b/pkg/device/builder/builder.go index ea07cf324..a8ba71a06 100644 --- a/pkg/device/builder/builder.go +++ b/pkg/device/builder/builder.go @@ -33,19 +33,23 @@ func (b *Builder) CollectorID(id int32) types.DeviceOption { // SystemCategories implements types.DeviceBuilder. func (b *Builder) SystemCategories(categories string) types.DeviceOption { - return func(device *lm.RestDevice) { - device.CustomProperties = append(device.CustomProperties, lm.NameAndValue{ - Name: "system.categories", - Value: categories, - }) - } + return setProperty("system.categories", categories) } // Auto implements types.DeviceBuilder. func (b *Builder) Auto(name, value string) types.DeviceOption { + return setProperty("auto."+name, value) +} + +// System implements types.DeviceBuilder. +func (b *Builder) System(name, value string) types.DeviceOption { + return setProperty("system."+name, value) +} + +func setProperty(name, value string) types.DeviceOption { return func(device *lm.RestDevice) { device.CustomProperties = append(device.CustomProperties, lm.NameAndValue{ - Name: "auto." + name, + Name: name, Value: value, }) } diff --git a/pkg/types/types.go b/pkg/types/types.go index 9c516458f..19e8bdad8 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -74,4 +74,6 @@ type DeviceBuilder interface { SystemCategories(string) DeviceOption // Auto adds an auto property to the device. Auto(string, string) DeviceOption + // System adds a system property to the device. + System(string, string) DeviceOption } diff --git a/pkg/watch/pod/pod.go b/pkg/watch/pod/pod.go index 564f2d58b..f9fc3d589 100644 --- a/pkg/watch/pod/pod.go +++ b/pkg/watch/pod/pod.go @@ -128,6 +128,6 @@ func (w *Watcher) args(pod *v1.Pod, category string) []types.DeviceOption { w.Auto("nodename", pod.Spec.NodeName), w.Auto("selflink", pod.SelfLink), w.Auto("uid", string(pod.UID)), - w.Auto("ip", pod.Status.PodIP), + w.System("ips", pod.Status.PodIP), } }