feat: NetBox insights, host tools and configurable TUI
Test / test (pull_request) Successful in 4m15s
Test / test (pull_request) Successful in 4m15s
- info/open/whois: NetBox details (site, nested locations, rack units, role, platform, tenant, IPs per interface), web page, reverse IP lookup - cache status, site, role, platform, tenant, location chain and rack; ask before connecting to hosts in ssh.warn_status (--force skips) - ssh rules and command restrictions match site/role/platform/tenant/status - tui.columns selects what the TUI shows; optional TCP reachability column; detail view (Ctrl+L), NetBox page (Ctrl+G), status/location filters - resolver.fallback tries other strategies' addresses when unreachable - copy-id, known-hosts reset and address-change notices - export ansible (YAML/INI) and export ssh-config - token: keyring stores NetBox tokens in the system keyring - fix stale menu number in testenv configure test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5bde9c61f
commit
1660bb3098
39 files changed
+4868
-96
No files matched your search
+28
-6
@@ -262,22 +262,36 @@ func editRule(rule config.SSHRule, sources []config.NetBoxConfig) (config.SSHRul
|
||||
Title("Kind").
|
||||
Options(huh.NewOption("(any)", ""), huh.NewOption("device", "device"), huh.NewOption("vm", "vm")).
|
||||
Value(&match.Kind),
|
||||
huh.NewInput().
|
||||
Title("Site").
|
||||
Description("NetBox site name or slug, e.g. fsn1").
|
||||
Value(&match.Site),
|
||||
huh.NewInput().
|
||||
Title("Role").
|
||||
Description("NetBox device/VM role name or slug, e.g. core-switch").
|
||||
Value(&match.Role),
|
||||
huh.NewInput().
|
||||
Title("Platform").
|
||||
Description("NetBox platform name or slug, e.g. junos").
|
||||
Value(&match.Platform),
|
||||
huh.NewInput().
|
||||
Title("Status").
|
||||
Description("NetBox status value, e.g. active").
|
||||
Value(&match.Status),
|
||||
huh.NewInput().
|
||||
Title("Name pattern").
|
||||
Description("Shell-style glob without instance prefix, e.g. *.dmz.example.com").
|
||||
Value(&match.Name).
|
||||
Validate(func(s string) error {
|
||||
candidate := match
|
||||
candidate.Tag = strings.TrimSpace(candidate.Tag)
|
||||
candidate.Name = strings.TrimSpace(s)
|
||||
return candidate.Validate("rule")
|
||||
candidate.Name = s
|
||||
return trimMatch(candidate).Validate("rule")
|
||||
}),
|
||||
).Title("Rule match")).Run()
|
||||
if err != nil {
|
||||
return rule, err
|
||||
}
|
||||
match.Tag = strings.TrimSpace(match.Tag)
|
||||
match.Name = strings.TrimSpace(match.Name)
|
||||
match = trimMatch(match)
|
||||
|
||||
options, err := editSSHOptions("SSH options for rule "+describeMatch(match), rule.SSHOptions)
|
||||
if err != nil {
|
||||
@@ -288,10 +302,18 @@ func editRule(rule config.SSHRule, sources []config.NetBoxConfig) (config.SSHRul
|
||||
|
||||
func describeMatch(m config.SSHMatch) string {
|
||||
var parts []string
|
||||
for _, field := range [][2]string{{"tag", m.Tag}, {"instance", m.Instance}, {"kind", m.Kind}, {"name", m.Name}} {
|
||||
for _, field := range matchFields(m) {
|
||||
if field[1] != "" {
|
||||
parts = append(parts, field[0]+"="+field[1])
|
||||
}
|
||||
}
|
||||
return "[" + strings.Join(parts, " ") + "]"
|
||||
}
|
||||
|
||||
// trimMatch removes surrounding spaces from every selector.
|
||||
func trimMatch(m config.SSHMatch) config.SSHMatch {
|
||||
for _, field := range []*string{&m.Tag, &m.Instance, &m.Kind, &m.Name, &m.Site, &m.Role, &m.Platform, &m.Tenant, &m.Status} {
|
||||
*field = strings.TrimSpace(*field)
|
||||
}
|
||||
return m
|
||||
}
|
||||
Reference in new issue
Block a user