Skip to content

Commit

Permalink
fix json snippets in config docs (#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
t4lz committed Jun 12, 2024
1 parent 45fdeb9 commit 4d2e6b8
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 59 deletions.
1 change: 1 addition & 0 deletions changelog.d/+fix-json-in-docs.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix json snippets in configuration docs by escaping backslashes and removing trailing commas.
20 changes: 10 additions & 10 deletions mirrord-schema.json

Large diffs are not rendered by default.

50 changes: 27 additions & 23 deletions mirrord/config/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ configuration file containing all fields.
},
"fs": {
"mode": "write",
"read_write": ".+\.json" ,
"read_only": [ ".+\.yaml", ".+important-file\.txt" ],
"local": [ ".+\.js", ".+\.mjs" ]
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ]
},
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "host: api\..+"
"header_filter": "host: api\\..+"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
Expand All @@ -108,7 +108,7 @@ configuration file containing all fields.
"copy_target": {
"scale_down": false
}
},
}
},
"operator": true,
"kubeconfig": "~/.kube/config",
Expand Down Expand Up @@ -239,7 +239,7 @@ We provide sane defaults for this option, so you don't have to set up anything h
"communication_timeout": 30,
"startup_timeout": 360,
"network_interface": "eth0",
"flush_connections": false,
"flush_connections": false
}
}
```
Expand Down Expand Up @@ -435,7 +435,7 @@ Complete setup:
{
"image": {
"registry": "internal.repo/images/mirrord",
"tag": "latest",
"tag": "latest"
}
}
```
Expand Down Expand Up @@ -534,15 +534,15 @@ have support for a shortened version, that you can see [here](#root-shortened).
},
"fs": {
"mode": "write",
"read_write": ".+\.json" ,
"read_only": [ ".+\.yaml", ".+important-file\.txt" ],
"local": [ ".+\.js", ".+\.mjs" ]
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ]
},
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "host: api\..+"
"header_filter": "host: api\\..+"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
Expand Down Expand Up @@ -623,10 +623,10 @@ For more information, check the file operations
"feature": {
"fs": {
"mode": "write",
"read_write": ".+\.json" ,
"read_only": [ ".+\.yaml", ".+important-file\.txt" ],
"local": [ ".+\.js", ".+\.mjs" ],
"not_found": [ "\.config/gcloud" ]
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ],
"not_found": [ "\\.config/gcloud" ]
}
}
}
Expand Down Expand Up @@ -746,7 +746,7 @@ for more details.
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "host: api\..+"
"header_filter": "host: api\\..+"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
Expand Down Expand Up @@ -837,7 +837,7 @@ Steal only traffic that matches the
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "host: api\..+"
"header_filter": "host: api\\..+"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
Expand Down Expand Up @@ -932,7 +932,7 @@ set as `"steal"`, ignored otherwise.
For example, to filter based on header:
```json
{
"header_filter": "host: api\..+",
"header_filter": "host: api\\..+"
}
```
Setting that filter will make mirrord only steal requests with the `host` header set to hosts
Expand All @@ -941,7 +941,7 @@ that start with "api", followed by a dot, and then at least one more character.
For example, to filter based on path:
```json
{
"path_filter": "^/api/",
"path_filter": "^/api/"
}
```
Setting this filter will make mirrord only steal requests to URIs starting with "/api/".
Expand All @@ -951,7 +951,7 @@ This can be useful for filtering out Kubernetes liveness, readiness and startup
For example, for avoiding stealing any probe sent by kubernetes, you can set this filter:
```json
{
"header_filter": "^User-Agent: (?!kube-probe)",
"header_filter": "^User-Agent: (?!kube-probe)"
}
```
Setting this filter will make mirrord only steal requests that **do** have a user agent that
Expand All @@ -960,7 +960,7 @@ Setting this filter will make mirrord only steal requests that **do** have a use
Similarly, you can exclude certain paths using a negative look-ahead:
```json
{
"path_filter": "^(?!/health/)",
"path_filter": "^(?!/health/)"
}
```
Setting this filter will make mirrord only steal requests to URIs that do not start with
Expand Down Expand Up @@ -1135,7 +1135,11 @@ This option is compatible only with deployment targets.
mirrord Experimental features.
This shouldn't be used unless someone from MetalBear/mirrord tells you to.

## experimental {#fexperimental-tcp_ping4_mock}
## _experimental_ readlink {#fexperimental-readlink}

Enables the `readlink` hook.

## _experimental_ tcp_ping4_mock {#fexperimental-tcp_ping4_mock}

<https://github.com/metalbear-co/mirrord/issues/2421#issuecomment-2093200904>

Expand All @@ -1150,7 +1154,7 @@ want to increase the timeouts a bit.
{
"internal_proxy": {
"start_idle_timeout": 30,
"idle_timeout": 5,
"idle_timeout": 5
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions mirrord/config/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl fmt::Display for LinuxCapability {
/// "communication_timeout": 30,
/// "startup_timeout": 360,
/// "network_interface": "eth0",
/// "flush_connections": false,
/// "flush_connections": false
/// }
/// }
/// ```
Expand Down Expand Up @@ -132,7 +132,7 @@ pub struct AgentConfig {
/// {
/// "image": {
/// "registry": "internal.repo/images/mirrord",
/// "tag": "latest",
/// "tag": "latest"
/// }
/// }
/// ```
Expand Down
8 changes: 4 additions & 4 deletions mirrord/config/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ pub mod network;
/// },
/// "fs": {
/// "mode": "write",
/// "read_write": ".+\.json" ,
/// "read_only": [ ".+\.yaml", ".+important-file\.txt" ],
/// "local": [ ".+\.js", ".+\.mjs" ]
/// "read_write": ".+\\.json" ,
/// "read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
/// "local": [ ".+\\.js", ".+\\.mjs" ]
/// },
/// "network": {
/// "incoming": {
/// "mode": "steal",
/// "http_filter": {
/// "header_filter": "host: api\..+"
/// "header_filter": "host: api\\..+"
/// },
/// "port_mapping": [[ 7777, 8888 ]],
/// "ignore_localhost": false,
Expand Down
6 changes: 3 additions & 3 deletions mirrord/config/src/feature/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ pub mod mode;
/// "feature": {
/// "fs": {
/// "mode": "write",
/// "read_write": ".+\.json" ,
/// "read_only": [ ".+\.yaml", ".+important-file\.txt" ],
/// "local": [ ".+\.js", ".+\.mjs" ]
/// "read_write": ".+\\.json" ,
/// "read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
/// "local": [ ".+\\.js", ".+\\.mjs" ]
/// }
/// }
/// }
Expand Down
8 changes: 4 additions & 4 deletions mirrord/config/src/feature/fs/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ use crate::{
/// "feature": {
/// "fs": {
/// "mode": "write",
/// "read_write": ".+\.json" ,
/// "read_only": [ ".+\.yaml", ".+important-file\.txt" ],
/// "local": [ ".+\.js", ".+\.mjs" ],
/// "not_found": [ "\.config/gcloud" ]
/// "read_write": ".+\\.json" ,
/// "read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
/// "local": [ ".+\\.js", ".+\\.mjs" ],
/// "not_found": [ "\\.config/gcloud" ]
/// }
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion mirrord/config/src/feature/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod outgoing;
/// "incoming": {
/// "mode": "steal",
/// "http_filter": {
/// "header_filter": "host: api\..+"
/// "header_filter": "host: api\\..+"
/// },
/// "port_mapping": [[ 7777, 8888 ]],
/// "ignore_localhost": false,
Expand Down
4 changes: 2 additions & 2 deletions mirrord/config/src/feature/network/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use http_filter::*;
/// "incoming": {
/// "mode": "steal",
/// "http_filter": {
/// "header_filter": "host: api\..+"
/// "header_filter": "host: api\\..+"
/// },
/// "port_mapping": [[ 7777, 8888 ]],
/// "ignore_localhost": false,
Expand Down Expand Up @@ -293,7 +293,7 @@ pub struct IncomingAdvancedFileConfig {
/// "incoming": {
/// "mode": "steal",
/// "http_filter": {
/// "header_filter": "host: api\..+"
/// "header_filter": "host: api\\..+"
/// },
/// "port_mapping": [[ 7777, 8888 ]],
/// "ignore_localhost": false,
Expand Down
8 changes: 4 additions & 4 deletions mirrord/config/src/feature/network/incoming/http_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
/// For example, to filter based on header:
/// ```json
/// {
/// "header_filter": "host: api\..+",
/// "header_filter": "host: api\\..+"
/// }
/// ```
/// Setting that filter will make mirrord only steal requests with the `host` header set to hosts
Expand All @@ -31,7 +31,7 @@ use crate::{
/// For example, to filter based on path:
/// ```json
/// {
/// "path_filter": "^/api/",
/// "path_filter": "^/api/"
/// }
/// ```
/// Setting this filter will make mirrord only steal requests to URIs starting with "/api/".
Expand All @@ -41,7 +41,7 @@ use crate::{
/// For example, for avoiding stealing any probe sent by kubernetes, you can set this filter:
/// ```json
/// {
/// "header_filter": "^User-Agent: (?!kube-probe)",
/// "header_filter": "^User-Agent: (?!kube-probe)"
/// }
/// ```
/// Setting this filter will make mirrord only steal requests that **do** have a user agent that
Expand All @@ -50,7 +50,7 @@ use crate::{
/// Similarly, you can exclude certain paths using a negative look-ahead:
/// ```json
/// {
/// "path_filter": "^(?!/health/)",
/// "path_filter": "^(?!/health/)"
/// }
/// ```
/// Setting this filter will make mirrord only steal requests to URIs that do not start with
Expand Down
2 changes: 1 addition & 1 deletion mirrord/config/src/internal_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::config::source::MirrordConfigSource;
/// {
/// "internal_proxy": {
/// "start_idle_timeout": 30,
/// "idle_timeout": 5,
/// "idle_timeout": 5
/// }
/// }
/// ```
Expand Down
10 changes: 5 additions & 5 deletions mirrord/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ use crate::{
/// },
/// "fs": {
/// "mode": "write",
/// "read_write": ".+\.json" ,
/// "read_only": [ ".+\.yaml", ".+important-file\.txt" ],
/// "local": [ ".+\.js", ".+\.mjs" ]
/// "read_write": ".+\\.json" ,
/// "read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
/// "local": [ ".+\\.js", ".+\\.mjs" ]
/// },
/// "network": {
/// "incoming": {
/// "mode": "steal",
/// "http_filter": {
/// "header_filter": "host: api\..+"
/// "header_filter": "host: api\\..+"
/// },
/// "port_mapping": [[ 7777, 8888 ]],
/// "ignore_localhost": false,
Expand All @@ -140,7 +140,7 @@ use crate::{
/// "copy_target": {
/// "scale_down": false
/// }
/// },
/// }
/// },
/// "operator": true,
/// "kubeconfig": "~/.kube/config",
Expand Down

0 comments on commit 4d2e6b8

Please sign in to comment.