Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
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),
}
}