Add core modules (SSH args parser, cache, resolver, NetBox client) with tests
Release / release (push) Failing after 51s
Release / release (push) Failing after 51s
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/netbox"
|
||||
)
|
||||
|
||||
// PrimaryIPStrategy returns the primary IP configured in NetBox.
|
||||
// Prefers IPv4, falls back to IPv6.
|
||||
type PrimaryIPStrategy struct{}
|
||||
|
||||
func (s *PrimaryIPStrategy) Name() string { return "primary_ip" }
|
||||
|
||||
func (s *PrimaryIPStrategy) Resolve(_ context.Context, entry *netbox.HostEntry, _ *netbox.Client) (string, error) {
|
||||
if entry.PrimaryIP4 != "" {
|
||||
return entry.PrimaryIP4, nil
|
||||
}
|
||||
if entry.PrimaryIP6 != "" {
|
||||
return entry.PrimaryIP6, nil
|
||||
}
|
||||
return "", ErrNoIP
|
||||
}
|
||||
Reference in New Issue
Block a user