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
@@ -11,6 +11,12 @@ import (
|
||||
func editOperations(cfg *config.Config) error {
|
||||
history, days, entries := strconv.Itoa(cfg.TUI.HistoryLimit), strconv.Itoa(cfg.Activity.RetentionDays), strconv.Itoa(cfg.Activity.MaxEntries)
|
||||
enabled := cfg.Activity.Enabled
|
||||
columns := append([]string(nil), cfg.TUI.EffectiveColumns()...)
|
||||
timeout := strconv.Itoa(int(cfg.TUI.ReachabilityTimeoutDuration().Milliseconds()))
|
||||
columnOptions := make([]huh.Option[string], 0, len(config.TUIColumns))
|
||||
for _, column := range config.TUIColumns {
|
||||
columnOptions = append(columnOptions, huh.NewOption(columnLabels[column], column).Selected(contains(columns, column)))
|
||||
}
|
||||
valid := func(s string) error {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil || n < 0 {
|
||||
@@ -23,13 +29,56 @@ func editOperations(cfg *config.Config) error {
|
||||
huh.NewConfirm().Title("Record local action history?").Description("Stores host, command name, duration and exit code; no arguments or output.").Value(&enabled),
|
||||
huh.NewInput().Title("Retention in days").Description("0 = no age limit").Value(&days).Validate(valid),
|
||||
huh.NewInput().Title("Maximum recorded actions").Description("0 = no count limit").Value(&entries).Validate(valid),
|
||||
).Title("History & activity")).Run()
|
||||
).Title("History & activity"), huh.NewGroup(
|
||||
huh.NewMultiSelect[string]().Title("Shown in the TUI next to each host").
|
||||
Description("Reachability opens a TCP connection to every listed host's SSH port.").
|
||||
Options(columnOptions...).Value(&columns),
|
||||
huh.NewInput().Title("Reachability timeout (ms)").Description("300 by default").Value(&timeout).Validate(valid),
|
||||
).Title("TUI display")).Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.TUI.Columns = orderColumns(cfg.TUI.EffectiveColumns(), columns)
|
||||
if ms, _ := strconv.Atoi(timeout); ms != 300 {
|
||||
cfg.TUI.ReachabilityTimeout = ms
|
||||
} else {
|
||||
cfg.TUI.ReachabilityTimeout = 0
|
||||
}
|
||||
cfg.TUI.HistoryLimit, _ = strconv.Atoi(history)
|
||||
cfg.Activity.RetentionDays, _ = strconv.Atoi(days)
|
||||
cfg.Activity.MaxEntries, _ = strconv.Atoi(entries)
|
||||
cfg.Activity.Enabled = enabled
|
||||
return nil
|
||||
}
|
||||
|
||||
var columnLabels = map[string]string{
|
||||
"alias": "Shortcut alias", "ip": "IP address", "kind": "Kind (device/vm/static)", "source": "Source (live/cache/static)",
|
||||
"status": "NetBox status (if not active)", "site": "Site", "location": "Location (site › locations › rack › U)", "role": "Role", "platform": "Platform", "tenant": "Tenant",
|
||||
"cluster": "Cluster", "tags": "Tags", "reachability": "Reachability (TCP check ✓/✗)",
|
||||
}
|
||||
|
||||
func contains(list []string, value string) bool {
|
||||
for _, item := range list {
|
||||
if item == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// orderColumns keeps an existing custom order and appends new selections in
|
||||
// the canonical order; the multi-select itself does not preserve order.
|
||||
func orderColumns(previous, selected []string) []string {
|
||||
out := []string{}
|
||||
for _, column := range previous {
|
||||
if contains(selected, column) {
|
||||
out = append(out, column)
|
||||
}
|
||||
}
|
||||
for _, column := range config.TUIColumns {
|
||||
if contains(selected, column) && !contains(out, column) {
|
||||
out = append(out, column)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user