feat: add host actions, lifecycle hooks and operational tools
This commit is contained in:
1 parent
8d4915543e
commit
e5bde9c61f
32 files changed
+2083
-64
No files matched your search
@@ -28,19 +28,24 @@ func New(cfg config.ResolverConfig) (*Chain, error) {
|
||||
}
|
||||
|
||||
func (c *Chain) Resolve(ctx context.Context, entry *netbox.HostEntry, client *netbox.Client) (string, error) {
|
||||
address, _, err := c.ResolveWithStrategy(ctx, entry, client)
|
||||
return address, err
|
||||
}
|
||||
|
||||
func (c *Chain) ResolveWithStrategy(ctx context.Context, entry *netbox.HostEntry, client *netbox.Client) (string, string, error) {
|
||||
for _, s := range c.strategies {
|
||||
ip, err := s.Resolve(ctx, entry, client)
|
||||
if err == nil {
|
||||
return ip, nil
|
||||
return ip, s.Name(), nil
|
||||
}
|
||||
// Only "this strategy has no address" moves on. After an API failure
|
||||
// the next strategy would connect to (and cache) a different address
|
||||
// than the configured order asks for.
|
||||
if !errors.Is(err, ErrNoIP) {
|
||||
return "", fmt.Errorf("resolver strategy %q for %q: %w", s.Name(), entry.Name, err)
|
||||
return "", "", fmt.Errorf("resolver strategy %q for %q: %w", s.Name(), entry.Name, err)
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("no strategy resolved an IP for %q", entry.Name)
|
||||
return "", "", fmt.Errorf("no strategy resolved an IP for %q", entry.Name)
|
||||
}
|
||||
|
||||
func newStrategy(name string, cfg config.ResolverConfig) (Strategy, error) {
|
||||
|
||||
Reference in new issue
Block a user