isoloom_spec/model/constraints.rs
1//! What the environment needs from where it runs: constraints, a proxy and mirrors.
2
3use indexmap::IndexMap;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7/// What the network an environment runs in imposes, applied on every target: images pulled
8/// through the customer's registry, packages through their mirrors, outbound HTTP through their
9/// proxy, time from their servers.
10#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
11#[serde(deny_unknown_fields)]
12pub struct Constraints {
13 /// The HTTP proxy outbound traffic goes through: set for the machines' containers (and their
14 /// builds) and on every Linux VM (shell, apt, dnf, Docker), never for Isoloom's own checks.
15 #[serde(default, skip_serializing_if = "Option::is_none")]
16 pub proxy: Option<Proxy>,
17 /// Registry mirrors, by the registry they stand for: `docker.io: registry.corp/dockerhub`
18 /// pulls `redis:7` as `registry.corp/dockerhub/library/redis:7`. Every image of the
19 /// environment is rewritten, Isoloom's own included; images built from the project aren't
20 /// pulled, so they stay as they are (their `FROM` lines are the Dockerfile's business).
21 #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
22 pub registries: IndexMap<String, String>,
23 /// Package mirrors the machines install from instead of the public archives: apt's for
24 /// Debian and Ubuntu VMs, and a Python package index.
25 #[serde(default, skip_serializing_if = "Option::is_none")]
26 pub mirrors: Option<Mirrors>,
27 /// The time servers (names or addresses) the Linux VMs synchronise their clocks with,
28 /// where the place forbids the public pools.
29 #[serde(default, skip_serializing_if = "Vec::is_empty")]
30 pub ntp: Vec<String>,
31}
32
33/// An HTTP proxy (see [`Constraints::proxy`]).
34#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
35#[serde(deny_unknown_fields)]
36pub struct Proxy {
37 /// The proxy for `http://` URLs, e.g. `http://proxy.corp:3128`.
38 #[serde(default, skip_serializing_if = "Option::is_none")]
39 pub http: Option<String>,
40 /// The proxy for `https://` URLs (default: `http`'s).
41 #[serde(default, skip_serializing_if = "Option::is_none")]
42 pub https: Option<String>,
43 /// Names, domains (`.corp`) and blocks reached directly. The environment's own machine
44 /// names and network blocks, and localhost, are always added.
45 #[serde(default, skip_serializing_if = "Vec::is_empty")]
46 pub no_proxy: Vec<String>,
47}
48
49/// Package mirrors (see [`Constraints::mirrors`]).
50#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
51#[serde(deny_unknown_fields)]
52pub struct Mirrors {
53 /// Replaces `deb.debian.org/debian` in the Debian VMs' apt sources (`debian-security`, a
54 /// separate archive, is left as it is).
55 #[serde(default, skip_serializing_if = "Option::is_none")]
56 pub debian: Option<String>,
57 /// Replaces `archive.ubuntu.com/ubuntu` (and its country and security hosts) in the Ubuntu
58 /// VMs' apt sources.
59 #[serde(default, skip_serializing_if = "Option::is_none")]
60 pub ubuntu: Option<String>,
61 /// A Python package index: `PIP_INDEX_URL` for the machines, `/etc/pip.conf` on the VMs.
62 #[serde(default, skip_serializing_if = "Option::is_none")]
63 pub pypi: Option<String>,
64 /// An npm registry: `NPM_CONFIG_REGISTRY` for the machines, `/etc/npmrc` on the VMs.
65 #[serde(default, skip_serializing_if = "Option::is_none")]
66 pub npm: Option<String>,
67}