1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Server-side runtime infrastructure context.
//!
//! [`InfraContext`] is the bundle of per-site connection data passed
//! through the service layer for every request: backend dispatcher,
//! API base URLs, TLS cert, optional vault/k8s URLs, SOCKS proxy.
//! It depends on `StaticBackendDispatcher`, which is server-only —
//! the CLI never instantiates this.
//!
//! ## Lifetime
//!
//! `InfraContext<'a>` borrows everything from `ServerState`:
//! the backend dispatcher, URLs, root cert bytes, etc. live for the
//! whole server lifetime, but the borrow is taken anew per request.
//! Handlers obtain a context via
//! `state.infra_context(&site_name)` (returning
//! [`Result<InfraContext<'_>, Error>`]), then pass it by reference
//! into the service layer:
//!
//! ```ignore
//! let infra = state.infra_context(&site_name)?;
//! service::group::get_groups(&infra, &token, ¶ms).await
//! ```
//!
//! The `_` lifetime is tied to the `state` borrow, so an
//! `InfraContext` cannot outlive the `Arc<ServerState>` that produced
//! it.
//!
//! ## Typical usage
//!
//! Service functions reach the backend through `infra.backend.*`
//! (calling the trait method belonging to the desired interface, e.g.
//! `infra.backend.get_bootparameters(...)`). When a function needs to
//! build a direct CSM HTTP client — e.g. for IMS customize jobs that
//! aren't routed through the dispatcher — it uses
//! `infra.shasta_base_url`, `infra.shasta_root_cert`, and
//! `infra.socks5_proxy` together. Vault- and k8s-dependent paths
//! gate on `infra.vault_base_url` / `infra.k8s_api_url` being
//! `Some`; when either is `None` the handler returns 501.
use crateStaticBackendDispatcher;
/// Infrastructure context needed by the service layer: backend
/// dispatcher, API endpoints, and TLS certificates.
///
/// Constructed per-request by `ServerState::infra_context(site_name)`
/// from the matching `[sites.X]` block in `server.toml`. The borrows
/// live for the duration of the handler call.