feat: search multiple NetBox instances with isolated host identities
Release / release (push) Successful in 5m16s
Release / release (push) Successful in 5m16s
This commit is contained in:
1 parent
a2a6dd7591
commit
7f53b90266
26 files changed
+1299
-115
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/config"
|
||||
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/netbox"
|
||||
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/shortcuts"
|
||||
)
|
||||
|
||||
func newNetBoxClient(cfg *config.Config) *netbox.Client {
|
||||
if len(cfg.NetBoxes) > 0 {
|
||||
sources := make([]netbox.Source, 0, len(cfg.NetBoxes))
|
||||
for _, source := range cfg.NetBoxes {
|
||||
sources = append(sources, netbox.Source{Name: source.Name, URL: source.URL, Token: source.Token, TokenVersion: source.TokenVersion})
|
||||
}
|
||||
return netbox.NewMultiClient(sources)
|
||||
}
|
||||
if cfg.NetBox.URL == "" {
|
||||
return nil
|
||||
}
|
||||
return netbox.NewClient(cfg.NetBox.URL, cfg.NetBox.Token, cfg.NetBox.TokenVersion)
|
||||
}
|
||||
|
||||
func normalizeTarget(cfg config.ShortcutsConfig, qualified bool) func(string) string {
|
||||
return func(target string) string {
|
||||
source, name := netbox.SplitTarget(target)
|
||||
name = shortcuts.Normalize(name, cfg)
|
||||
if qualified && source != "" {
|
||||
return source + "/" + name
|
||||
}
|
||||
return name
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user