feat: search multiple NetBox instances with isolated host identities
Release / release (push) Successful in 5m16s

This commit is contained in:
Sebastian Unterschütz committed 2026-10-27 23:14:42 +01:00
1 parent a2a6dd7591
commit 7f53b90266
26 files changed
+1299 -115

No files matched your search

+19
View File
@@ -1,5 +1,7 @@
package netbox
import "strings"
// SearchOptions filters a Search or SearchAll query.
// Zero value means no filtering (return all kinds, no tag filter).
type SearchOptions struct {
@@ -9,6 +11,7 @@ type SearchOptions struct {
// HostEntry is a unified model for both devices and virtual machines from NetBox.
type HostEntry struct {
Source string // named NetBox instance; empty for the legacy single-instance config
ID int
Name string
Kind string // "device" | "vm"
@@ -58,3 +61,19 @@ type netboxIPListResponse struct {
} `json:"assigned_object"`
} `json:"results"`
}
// Target returns an unambiguous selector for cache, completion, and SSH.
func (h HostEntry) Target() string {
if h.Source == "" {
return h.Name
}
return h.Source + "/" + h.Name
}
// SplitTarget separates an optional instance prefix from a hostname.
func SplitTarget(target string) (source, name string) {
if source, name, ok := strings.Cut(target, "/"); ok {
return strings.ToLower(source), name
}
return "", target
}