Files
Sebastian Unterschütz 8ef4bbec16
Release / release (push) Failing after 51s
Add core modules (SSH args parser, cache, resolver, NetBox client) with tests
2026-05-23 12:38:41 +02:00

24 lines
569 B
Go

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
}