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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//! The environment read as a configuration layer.
//!
//! This is a *layer*, not a set of per-command overrides: it parses into the same
//! shape a document parses into and is appended after the documents, so a setting
//! reached this way flows through every verb without any verb knowing it exists.
use crateEnvironment;
use ;
use ;
/// What every configuration variable's name begins with.
pub const ENVIRONMENT_PREFIX: &str = "ONETASKGRAPH_";
/// Variables that begin with [`ENVIRONMENT_PREFIX`] and are *not* settings.
///
/// `ONETASKGRAPH_SECRETS_FILE` points at the credentials file, which is read before
/// sources are resolved and is nowhere in the configuration document. Without this
/// list it would decode to a setting called `secrets_file` and be refused as an
/// unknown field — turning a documented variable into an error.
///
/// [`BIN_VARIABLE`] is the same case from outside: onepipeline names the plan-store binary
/// it drives in `ONETASKGRAPH_BIN` and passes its environment on to that binary, where it
/// would decode to a setting called `bin` and refuse every command. It says which binary
/// to run — settled before this binary starts — so no command's answer depends on it.
const RESERVED: & = &;
/// The variable a caller names this binary's own path in, which is not a setting.
const BIN_VARIABLE: &str = "ONETASKGRAPH_BIN";
/// A whole namespace under [`ENVIRONMENT_PREFIX`] that holds no settings at all.
///
/// `onetaskgraph-live` spells this repository's own live-test variables here:
/// `ONETASKGRAPH_LIVE_REQUIRED` says a live session is expected rather than optional,
/// and `ONETASKGRAPH_LIVE_SEAT_DIR` says where that session's seat goes. Neither is a
/// setting, and `.github/workflows/ci.yml` exports the first of them on the very step
/// that runs the SDK generator and the journeys — so without this reservation every
/// invocation of the binary on that step is refused for an unknown field called
/// `live_required`. That is the failure [`RESERVED`] exists to prevent, one namespace
/// wider.
///
/// A namespace rather than those two names, because the reservation has to hold for the
/// next variable that lane adds; `scripts/check-live-lane.sh` fails when a live variable
/// falls outside it, so the two cannot drift apart.
const RESERVED_NAMESPACE: &str = "ONETASKGRAPH_LIVE_";
/// The separator between path segments in a variable name.
const SEGMENT_SEPARATOR: &str = "__";
/// Whether a prefixed variable names something this layer must leave alone.
/// Every `ONETASKGRAPH_`-prefixed variable, as one configuration layer.
///
/// The rule, and its inverse. A variable's name is [`ENVIRONMENT_PREFIX`] followed by
/// the setting's path, each segment upper-cased with `-` replaced by `_`, segments
/// joined by [`SEGMENT_SEPARATOR`]. Decoding lower-cases each segment, and turns `_`
/// back into `-` in exactly one position: the segment naming a source, immediately
/// after `sources`. That is the only place a `-` can occur, because a
/// [`SourceName`](onetaskgraph_plugin_api::SourceName) may not contain `_` while
/// every other key in the document is `snake_case` — which is what makes the forward
/// mapping injective and this inverse exact rather than a guess.
///
/// # Errors
///
/// Returns [`ConfigError::Setting`] when a variable's name decodes to no path at all,
/// as `ONETASKGRAPH_` and `ONETASKGRAPH_SOURCES__` do, and when one of these variables
/// holds a value that is not valid Unicode — a setting this build cannot read is
/// refused by name rather than quietly left unset. A variable in [`RESERVED`] or under
/// [`RESERVED_NAMESPACE`] is neither, on either count: it is not a setting, so this
/// layer does not decode it and does not refuse it for a value it never reads.
/// Decode one variable name's suffix into the setting path it addresses.
/// One segment, lower-cased, with `_` restored to `-` where a source name sits.
/// The variable that sets `key`, for a message that tells a user what to export.