Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
fix(device): set system.ips to satisfy heartbeat requirement (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Sep 11, 2017
1 parent 29ae9ca commit d123866
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
18 changes: 11 additions & 7 deletions pkg/device/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion pkg/watch/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

0 comments on commit d123866

Please sign in to comment.