Tank.Host behaviour (Tank v0.1.0)

Copy Markdown View Source

The host-config seam: how Tank reads the host's network facts without owning them — the uplink a macvlan attaches to, and the DNS servers a container inherits.

Tank must share these without dragging in any host-networking dependency, so Tank.Host is a behaviour: an adapter contract. The adapter is chosen by config and reached through this module's facade — callers say Tank.Host.uplink() and never name the adapter:

config :tank, host: Tank.Host.Static   # the default

Adapters:

  • Tank.Host.Static — shipped here, the v1 default: uplink + DNS straight from config. Runs anywhere.
  • A consumer-provided adapter — lives in the consumer, never in Tank's deps: reads the host's own network manager. (later)
  • Tank.Host.Linx — auto-detect uplink + DNS from rtnetlink and /etc/resolv.conf; a zero-config default. (later)

The contract is intentionally just what Tank core consumes today: the uplink (resolving a NIC's parent: :auto) and the DNS list (the pod's /etc/resolv.conf when it declares no dns:). It will grow host IP facts and change-notifications when an adapter that has them needs them.

Summary

Callbacks

The host's DNS servers, as address strings (may be empty).

The uplink interface name a macvlan should attach to (parent: :auto).

Functions

The configured host adapter module (default Tank.Host.Static).

The host DNS servers via the configured adapter.

Resolve the host uplink via the configured adapter.

Callbacks

dns()

@callback dns() :: [String.t()]

The host's DNS servers, as address strings (may be empty).

uplink()

@callback uplink() :: {:ok, String.t()} | {:error, term()}

The uplink interface name a macvlan should attach to (parent: :auto).

Functions

adapter()

@spec adapter() :: module()

The configured host adapter module (default Tank.Host.Static).

dns()

@spec dns() :: [String.t()]

The host DNS servers via the configured adapter.

uplink()

@spec uplink() :: {:ok, String.t()} | {:error, term()}

Resolve the host uplink via the configured adapter.