|
| 1 | +defmodule Hyper.Cfg.Dirs do |
| 2 | + @moduledoc """ |
| 3 | + The node's work directory and every directory derived from it. |
| 4 | +
|
| 5 | + `work_dir` is the single configurable root (`config.toml`-only, shared with the |
| 6 | + setuid helper); everything else is a fixed sub-path so the node and helper |
| 7 | + agree on layout without a second key to keep in sync. |
| 8 | + """ |
| 9 | + |
| 10 | + import Hyper.Cfg, only: [get_cfg: 1] |
| 11 | + |
| 12 | + @doc "Root work directory for this node. config.toml `work_dir`, default `/srv/hyper`." |
| 13 | + @spec work_dir :: Path.t() |
| 14 | + def work_dir, do: get_cfg(toml: "work_dir", default: "/srv/hyper") |
| 15 | + |
| 16 | + @doc "Read-only image layer store (`<work_dir>/layers`)." |
| 17 | + @spec layer_dir :: Path.t() |
| 18 | + def layer_dir, do: Path.join(work_dir(), "layers") |
| 19 | + |
| 20 | + @doc "Per-VM control/gRPC sockets (`<work_dir>/socks`)." |
| 21 | + @spec socket_dir :: Path.t() |
| 22 | + def socket_dir, do: Path.join(work_dir(), "socks") |
| 23 | + |
| 24 | + @doc "Per-VM copy-on-write writable layers (`<work_dir>/scratch`)." |
| 25 | + @spec scratch_dir :: Path.t() |
| 26 | + def scratch_dir, do: Path.join(work_dir(), "scratch") |
| 27 | + |
| 28 | + @doc "Per-VM chroot directories (`<work_dir>/jails`)." |
| 29 | + @spec chroot_base :: Path.t() |
| 30 | + def chroot_base, do: Path.join(work_dir(), "jails") |
| 31 | + |
| 32 | + @doc "Node-downloaded binaries (`<work_dir>/redist`)." |
| 33 | + @spec redist_dir :: Path.t() |
| 34 | + def redist_dir, do: Path.join(work_dir(), "redist") |
| 35 | + |
| 36 | + @doc "Where guest kernels install (`<work_dir>/redist/vmlinux`)." |
| 37 | + @spec vmlinux_install_dir :: Path.t() |
| 38 | + def vmlinux_install_dir, do: Path.join(redist_dir(), "vmlinux") |
| 39 | + |
| 40 | + @doc "Where the default umoci installs (`<work_dir>/redist/umoci`)." |
| 41 | + @spec umoci_install_dir :: Path.t() |
| 42 | + def umoci_install_dir, do: Path.join(redist_dir(), "umoci") |
| 43 | + |
| 44 | + @doc "Where a node-downloaded firecracker installs (`<work_dir>/redist/firecracker`)." |
| 45 | + @spec firecracker_install_dir :: Path.t() |
| 46 | + def firecracker_install_dir, do: Path.join(redist_dir(), "firecracker") |
| 47 | +end |
0 commit comments