Skip to content

Commit fe718d4

Browse files
committed
Fix interface bugs for mz-debug
- Added a section in `README.md` detailing how to run the `mz-debug` tool locally with an example command. - required_if_eq wasn't working for default values. Chaining required_unless_present fixes this - Makes 'dump-system-catalog' a global flag
1 parent dc43efa commit fe718d4

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/mz-debug/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
# `mz-debug`
22

33
This tool allows us to debug a user's self-managed environment.
4+
5+
## Run locally:
6+
To run locally, an example of a command is:
7+
8+
```bash
9+
./bin/bazel run \
10+
--run_under="cd $PWD &&" \
11+
//src/mz-debug:mz_debug self-managed -- \
12+
--k8s-namespace materialize \
13+
--k8s-namespace materialize-environment \
14+
--auto-port-forward false \
15+
--mz-connection-url 'postgres://[email protected]:6875/materialize?sslmode=disable'
16+
```

src/mz-debug/src/main.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ pub struct SelfManagedDebugMode {
4949
#[clap(long, default_value = "true", action = clap::ArgAction::Set)]
5050
dump_k8s: bool,
5151
/// A list of namespaces to dump.
52-
#[clap(long = "k8s-namespace", required_if_eq("dump_k8s", "true"), action = clap::ArgAction::Append)]
52+
#[clap(
53+
long = "k8s-namespace",
54+
required_unless_present = "dump_k8s",
55+
required_if_eq("dump_k8s", "true"),
56+
action = clap::ArgAction::Append
57+
)]
5358
k8s_namespaces: Vec<String>,
5459
/// The kubernetes context to use.
5560
#[clap(long, env = "KUBERNETES_CONTEXT")]
@@ -69,8 +74,7 @@ pub struct SelfManagedDebugMode {
6974
port_forward_local_port: i32,
7075
/// The URL of the Materialize SQL connection used to dump the system catalog.
7176
/// An example URL is `postgres://[email protected]:6875/materialize?sslmode=disable`.
72-
/// By default, we will create use the connection URL based on `port_forward_local_address` and `port_forward_local_port`.
73-
/// and port_forward_local_port.
77+
/// By default, we will create a connection URL based on `port_forward_local_address` and `port_forward_local_port`.
7478
// TODO(debug_tool3): Allow users to specify the pgconfig via separate variables
7579
#[clap(
7680
long,
@@ -86,7 +90,11 @@ pub struct EmulatorDebugMode {
8690
#[clap(long, default_value = "true", action = clap::ArgAction::Set)]
8791
dump_docker: bool,
8892
/// The ID of the docker container to dump.
89-
#[clap(long, required_if_eq("dump_docker", "true"))]
93+
#[clap(
94+
long,
95+
required_unless_present = "dump_docker",
96+
required_if_eq("dump_docker", "true")
97+
)]
9098
docker_container_id: Option<String>,
9199
/// The URL of the Materialize SQL connection used to dump the system catalog.
92100
/// An example URL is `postgres://[email protected]:6875/materialize?sslmode=disable`.
@@ -115,7 +123,7 @@ pub struct Args {
115123
#[clap(subcommand)]
116124
debug_mode: DebugMode,
117125
/// If true, the tool will dump the system catalog in Materialize.
118-
#[clap(long, default_value = "true", action = clap::ArgAction::Set)]
126+
#[clap(long, default_value = "true", action = clap::ArgAction::Set, global = true)]
119127
dump_system_catalog: bool,
120128
}
121129

0 commit comments

Comments
 (0)