fix: interface_name strategy, instance hosts in sftp/scp, alias rewrites
Found by the new Docker test environment against a real NetBox 4.7: - The interface_name strategy filtered IP addresses with interface_name and vminterface_name, which NetBox ignores, so it returned the first address of the host instead of the named interface's. Use the real filters interface and vminterface; a missing interface (HTTP 400) falls through to the next strategy. - sftp and scp took instance-qualified hosts (prod/web01:/path) for local paths, because a "/" comes before the ":". Such arguments are remote when the prefix is a configured NetBox instance. - Shell aliases of instance-qualified hosts ran the shortcut rules on "instance/host", so anchored rewrite rules never matched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb6d2f3cfb
commit
b88a41f024
10 files changed
+144
-11
No files matched your search
@@ -59,6 +59,11 @@ func MakeNormalizer(cfg config.ShortcutsConfig) func(string) string {
|
||||
// It normalizes the name (strips configured domains, applies rewrites, optionally strips hyphens) then
|
||||
// replaces any remaining dots with underscores so the result is a valid identifier.
|
||||
func AliasName(name string, cfg config.ShortcutsConfig) string {
|
||||
s := Normalize(name, cfg)
|
||||
// Shorten only the hostname: anchored rewrite rules must not see "instance/".
|
||||
prefix := ""
|
||||
if source, host, ok := strings.Cut(name, "/"); ok {
|
||||
prefix, name = strings.ToLower(source)+"_", host
|
||||
}
|
||||
s := prefix + Normalize(name, cfg)
|
||||
return strings.NewReplacer(".", "_", "/", "_").Replace(s)
|
||||
}
|
||||
Reference in new issue
Block a user