Skip to main content

isoloom_plan/
lib.rs

1//! The target-neutral plan of a lab: the authored spec lowered for a target ([`Lab`], [`lower`]),
2//! then planned into the [`Environment`] a backend renders (networks, machines, their addresses,
3//! routes, volumes and set-up steps), its checks resolved to positions and probes, and the
4//! requirements a backend must meet to render it.
5//!
6//! It sits between the spec (`isoloom-spec`, below) and the rendering layer and backends
7//! (`isoloom-render` and up), and is a functional core: every function here is pure over the
8//! spec, with no I/O, clock or environment, except [`Lab::problems_with_files`], which looks at
9//! the project folder it is given.
10//!
11//! # Example
12//!
13//! ```
14//! use isoloom_plan::{Environment, Lab, MachineShape};
15//! use isoloom_spec::model::Target;
16//!
17//! let lab = Lab::new(isoloom_spec::parse(
18//!     "version: 1
19//! name: hello
20//! networks: { lan: { cidr: 10.9.0.0/24 } }
21//! machines:
22//!   web: { networks: { lan: 10 }, ports: { site: 80 }, app: { image: nginx } }
23//! ",
24//! )?);
25//! assert!(lab.problems().is_empty());
26//! assert!(lab.possible().contains(&Target::Docker));
27//! let env = Environment::build(&lab.for_target(Target::Docker), Target::Docker, None);
28//! let web = env.machines.get("web").ok_or("web is planned")?;
29//! assert_eq!(web.shape, MachineShape::Container);
30//! assert_eq!(web.addresses.get("lan").map(ToString::to_string).as_deref(), Some("10.9.0.10"));
31//! # Ok::<(), Box<dyn std::error::Error>>(())
32//! ```
33
34pub mod addressing;
35pub mod ansible;
36pub mod boot;
37pub mod checks;
38pub mod configure;
39pub mod environment;
40mod error;
41pub mod hardware;
42pub mod images;
43pub mod ipv6;
44pub mod lab;
45pub mod lifecycle;
46pub mod links;
47pub mod lower;
48pub mod machine_files;
49pub mod more_addresses;
50pub mod outside;
51pub mod private_dns;
52pub mod process;
53pub mod requirements;
54pub mod routing;
55pub mod secrets;
56pub mod storage;
57#[cfg(test)]
58mod testing;
59
60pub use environment::{
61    Build, Controller, Environment, Image, MachinePlan, MachineShape, NetworkPlan, PublishedPort, Route, Settings, Size, Volume, VolumeKind,
62};
63pub use error::{Error, Result};
64pub use lab::{Lab, problems_in};
65pub use lifecycle::{MachineLifecycle, Step};
66pub use outside::{Join, OutsideAddress, OutsideNetwork};
67pub use private_dns::PrivateDns;
68pub use process::{Health, HealthTest, Process};
69pub use requirements::{Capabilities, Feature, Refusal, Requirement, refusal};
70pub use secrets::{SecretFile, ValueSource};
71pub use storage::{DataDisk, Lifetime};