Skip to content

Commit 995276e

Browse files
authored
Merge pull request #2322 from stevenengler/serde-yaml-upgrade
Support yaml merge keys and extension fields
2 parents 3bc2986 + 924eab5 commit 995276e

File tree

6 files changed

+151
-173
lines changed

6 files changed

+151
-173
lines changed

docs/shadow_config_overview.md

+72
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,75 @@ Acceptable unit *prefixes* are:
7676
- tebi / Ti
7777

7878
Examples: `20 B`, `100 MB`, `100 megabyte`, `10 kibibytes`, `30 MiB`, `1024 Mbytes`
79+
80+
## YAML Extensions (Experimental)
81+
82+
Shadow has experimental support for extended YAML conventions. These can be
83+
enabled using the `--use-extended-yaml true` command line option.
84+
85+
### Merge/Override Mappings
86+
87+
To help reduce repeated configuration options, Shadow supports the YAML ["merge
88+
key (`<<`)"](https://yaml.org/type/merge.html) convention. This merges the keys
89+
of the child mapping into the parent mapping, and is useful when combined with
90+
[YAML anchors (`&` and `*`)](https://yaml.org/spec/1.2.2/#692-node-anchors).
91+
92+
Example:
93+
94+
```yaml
95+
general:
96+
# --snip--
97+
98+
network:
99+
# --snip--
100+
101+
hosts:
102+
server:
103+
# --snip--
104+
client-uk: &client
105+
network_node_id: 0
106+
processes:
107+
- path: /usr/bin/curl
108+
args: server --silent
109+
start_time: 5
110+
client-us:
111+
network_node_id: 1
112+
<<: *client
113+
```
114+
115+
For a longer example, see
116+
https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/.
117+
118+
### Extension Fields
119+
120+
When using the "merge key" feature above, putting common options in a separate
121+
configuration fragment may help make the configuration more readable. Shadow
122+
supports the "extension field" convention used by [Docker
123+
Compose](https://docs.docker.com/compose/compose-file/compose-file-v3/). Any
124+
top-level field containing a key that begins with `x-` will be ignored by
125+
Shadow.
126+
127+
Example:
128+
129+
```yaml
130+
x-client: &client-defaults
131+
processes:
132+
- path: /usr/bin/curl
133+
args: server --silent
134+
start_time: 5
135+
136+
general:
137+
# --snip--
138+
139+
network:
140+
# --snip--
141+
142+
hosts:
143+
server:
144+
# --snip--
145+
client-uk:
146+
network_node_id: 0
147+
<<: *client-defaults
148+
client-us:
149+
network_node_id: 1
150+
<<: *client-defaults

docs/shadow_config_spec.md

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ hosts:
8484
- [`experimental.use_cpu_pinning`](#experimentaluse_cpu_pinning)
8585
- [`experimental.use_dynamic_runahead`](#experimentaluse_dynamic_runahead)
8686
- [`experimental.use_explicit_block_message`](#experimentaluse_explicit_block_message)
87+
- [`experimental.use_extended_yaml`](#experimentaluse_extended_yaml)
8788
- [`experimental.use_legacy_working_dir`](#experimentaluse_legacy_working_dir)
8889
- [`experimental.use_libc_preload`](#experimentaluse_libc_preload)
8990
- [`experimental.use_memory_manager`](#experimentaluse_memory_manager)
@@ -480,6 +481,14 @@ Type: Bool
480481
Send message to managed process telling it to stop spinning when a syscall
481482
blocks.
482483

484+
#### `experimental.use_extended_yaml`
485+
486+
Default: false
487+
Type: Bool
488+
489+
Enable extended YAML conventions (merge keys and extension fields). Can only be
490+
enabled on the command line (enabling in the configuration file is a no-op).
491+
483492
#### `experimental.use_legacy_working_dir`
484493

485494
Default: false

src/Cargo.lock

+14-165
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)