Commit Graph

27 Commits

Author SHA1 Message Date
Zeyi (Rice) Fan
2c7092ce43 cli_rs: make edenfsctl useable on Windows
Summary: This was an oversight. With this edenfsctl should be able to run on Windows and talk with EdenFS daemon via UNIX domain socket.

Differential Revision: D30089140

fbshipit-source-id: abe12aeee06d91f7a7323a6042d2b69c31963bbb
2021-08-05 17:34:25 -07:00
David Tolnay
d4f337c889 Resolve bare_trait_objects warnings in path components
Reviewed By: quark-zju

Differential Revision: D28558352

fbshipit-source-id: d4b85716096c43eed8e6172ade3dfe40e277e670
2021-05-19 22:03:56 -07:00
Katie Mancini
4fe39e0a3a make widgets for top
Summary:
We are moving our skelton for eden top a bit further, by creating the view
structure for eden top. This creates the widget for the banner of eden top,
the help page and the main page as well as a couple sections of the main
page.

The main page is displayed on default and they are toggled with `h` for help
page and `esc` to return to the mage page. Visable and hidden widgets are not
implemented in termwiz yet so we have to do a bit of hacking to hide and
display widgets for our selves.

Each of the sections is stubed with place holder text for testing.

Reviewed By: xavierd

Differential Revision: D26892620

fbshipit-source-id: a7bb4d0e11f3a8968ef071e7f585d07a9c286880
2021-04-09 12:27:04 -07:00
Katie Mancini
ea96dbbc2f make input loop eden top
Summary:
This teaches eden top to read input from the command line which we will use to
switch between help and main page as well as manipulate the process table.

Similar to the python version of eden top q exits. For now we spit back out all
of the other input we get.

Reviewed By: fanzeyi

Differential Revision: D26892622

fbshipit-source-id: 30039d2c2475c036c500c6cb1055c0b2d739691a
2021-03-08 18:03:57 -08:00
Katie Mancini
b3dffd4a54 Add template for rust eden top
Summary:
This adds a subcommand to the rust cli for top command. This sets us up to
start moving over the eden top functionality.

Reviewed By: fanzeyi

Differential Revision: D26892621

fbshipit-source-id: 1d0525291fbad1e5ea97ca22691eacb3fe42ffaf
2021-03-08 18:03:57 -08:00
Chad Austin
400f8ecbff cli_rs: add debug subcommand, with clear-local-caches and compact-local-storage
Reviewed By: xavierd

Differential Revision: D26417356

fbshipit-source-id: 77d858b498e454a2439ee1853c244619c8aee22c
2021-02-26 19:43:19 -08:00
Chad Austin
8e76984ba0 cli_rs: remove more subcommand boilerplate
Summary:
Remove a bit of boilerplate in the definition of subcommands, and pave
the way for sub-sub commands.

Reviewed By: xavierd

Differential Revision: D26416574

fbshipit-source-id: 1477505cab6c3de2c7ac14fe862d366a707d155b
2021-02-26 19:43:18 -08:00
Zeyi (Rice) Fan
1cedccf6cf cli_rs: implement edenfsctl config
Summary: This diff implements `edenfsctl config` command in Rust.

Reviewed By: xavierd

Differential Revision: D26415383

fbshipit-source-id: 693d22204aa89e29f1a678667c324734da3e846a
2021-02-26 17:54:30 -08:00
Zeyi (Rice) Fan
c421697030 stack-config: allow customize merge function
Summary:
This diff allows the user to specify a merge function in the shape of `merge(&mut T, T);` to customizing merging behavior.

This is used in the next diff to merge the `HashMap` that catches all unknown fields.

Reviewed By: xavierd

Differential Revision: D26415382

fbshipit-source-id: 10801ddc7d41b82d8d165a8b63466aa9b92baaab
2021-02-26 17:54:30 -08:00
Zeyi (Rice) Fan
ac2230fa5e cli: handle concrete errors
Summary: With this diff we can start to handle concrete error types, return correct exit code for Thrift IO errors for example.

Reviewed By: xavierd

Differential Revision: D26412948

fbshipit-source-id: f598ed2d9187126509c149f9d6293025d0f39968
2021-02-26 17:54:30 -08:00
Chad Austin
735c031697 cli_rs: add the gc command
Reviewed By: xavierd

Differential Revision: D26412700

fbshipit-source-id: 0140250a2fa54a51fc1ef892cf20548807527615
2021-02-24 11:21:30 -08:00
Chad Austin
2e0e5ee0ea cli_rs: explicit annotation of subcommand help text
Summary:
Comments affecting runtime behavior disturbs me, so use explicit
structopt annotations on help text. And move those annotations to the
command implementations.

Reviewed By: fanzeyi

Differential Revision: D26412452

fbshipit-source-id: 066dfdd1c54254bae4bd2af65031487b7a1094da
2021-02-22 14:11:37 -08:00
Chad Austin
89ab1a37b7 cli_rs: enable help for subcommands and disable version flags
Summary: clap/structopt adds a -V flag to every subcommand by default. Disable that.

Reviewed By: fanzeyi

Differential Revision: D26412093

fbshipit-source-id: 03a0320fd15444f700b359f5ed0ca8c40b10ae1c
2021-02-22 14:11:37 -08:00
Chad Austin
02b024899e cli_rs: add an environment variable to avoid Python CLI bypass
Summary:
I don't want the fallback when testing, so add an environment variable
for bypassing it.

Reviewed By: fanzeyi

Differential Revision: D26411754

fbshipit-source-id: f2aea82bf3e79db11e72ad5f5ce33513cfc2f05b
2021-02-22 14:11:37 -08:00
Chad Austin
4c278e3278 cli_rs: allow returning errors from subcommands
Summary:
Rather than offloading dealing with unexpected errors to each
subcommand, allow them to propogate out. Subcommands can still be
responsible for handling expected "errors" like EdenFS not running.

Reviewed By: fanzeyi

Differential Revision: D26411186

fbshipit-source-id: 4e1c5fb1d7bed495e3e22cca44d3f84f7f4c7f14
2021-02-22 14:11:36 -08:00
Xavier Deguillard
6834785a45 cli_rs: add uptime
Summary: This implements the same logic as the `edenfsctl uptime`.

Reviewed By: fanzeyi

Differential Revision: D26412789

fbshipit-source-id: ebcf5f0b4767025ea210f7e9c69116b79436d5d0
2021-02-12 15:21:31 -08:00
Zeyi (Rice) Fan
5e5d334718 cli: one comma bug
Summary: comma_khan

Reviewed By: singhsrb

Differential Revision: D26408197

fbshipit-source-id: ccdf6d070069a870e3fa71b1d4f1b42239a7c203
2021-02-12 14:53:23 -08:00
Xavier Deguillard
621cadd6d6 cli_rs: add a default 3s connection timeout for health checks
Summary:
In Python, no passed in timeout means a 3s connection timeout, let's do the
same in Rust.

Reviewed By: chadaustin

Differential Revision: D26407991

fbshipit-source-id: ad2919e2cb72e5a113499d7e036ae285ecf9ae34
2021-02-12 14:38:22 -08:00
Zeyi (Rice) Fan
18b79205c8 cli: add get_config to EdenFsInstance
Summary: You can use `instance.get_config()` to get access to global EdenFS configurations

Reviewed By: chadaustin

Differential Revision: D26407350

fbshipit-source-id: 022cc59fd86b2711c15cfd781872465c6ada9081
2021-02-12 14:23:17 -08:00
Xavier Deguillard
b63f46c673 cli_rs: add pid command
Summary: This simply queries the pid from thrift.

Reviewed By: kmancini

Differential Revision: D26406797

fbshipit-source-id: 1d5d1b2d526e1de505d72747a5c903001b141d40
2021-02-12 13:47:48 -08:00
Zeyi (Rice) Fan
7de8d6a595 cli_rs: add edenfs-config for configuration loading
Summary:
This diff adds `edenfs-config` for loading EdenFS configurations from various
locations.

Reviewed By: xavierd

Differential Revision: D26391272

fbshipit-source-id: 3d34da98b2d530e13cdd831d3dc204e44304c486
2021-02-12 12:33:48 -08:00
Zeyi (Rice) Fan
8290ea3545 cli_rs: add stack config proc macro
Summary:
**Problem:** EdenFS has the classic hierarchical configuration design. We load from `/etc/eden/edenfs.rc` first, then `/etc/eden/conf.d/*` then `$HOME/.edenrc`. The latter can overwrite the former. At the end we have a complete view of the configurations.

`serde` is great, but it can't give us the information of whether it generated a field from `serde(default)` or from de-serialization. So we can't just deserialize then merge the configuration files. We need that information, and nor serde should give us that functionality.

`stack-config` is created to load configurations with serde. It automatically generates code with the intermediate data structure and taking care of merging of multiple configuration files. It derives a data type based on the original struct but wrap each field with `Option<T>` and mark it with Serde. Then it generates the code to merge and build the final concrete configuration data type.

It does not care what kind of data format the configuration file is, as long as it can deserialize into the generate optional type, it accepts it.

Example, say I have a file with this structure:

```
#[derive(StackConfig)]
struct Config {
  path: String,
}
```

Then this crate will generate:

```
mod __stack_config_private {
  #[derive(serde::Deserialize)]
  pub(super) struct ConfigOpt {
    path: Option<String>
  }

  ...
}

struct ConfigLoader {
  layers: Vec<__stack_config_private::ConfigOpt>,
}

impl ConfigLoader {
  fn new() { ... }
  fn load(&mut self, layer: __stack_config_private::ConfigOpt> { ... }
  fn build(self) -> Config { ... }
}
```

See `examples/parse.rs` for usage.

Reviewed By: xavierd

Differential Revision: D26377547

fbshipit-source-id: 1e07d9867742913fd76ed4f765160f0035a2f2a3
2021-02-12 12:33:47 -08:00
Zeyi (Rice) Fan
c601c6a46d cli_rs: set up debug logging
Summary: This diff sets up debug logging for EdenFS CLI with tracing.

Reviewed By: chadaustin

Differential Revision: D26354205

fbshipit-source-id: bcc89fe3eaf4c7ae7642b8c20fd74fd3ea6dd4ee
2021-02-12 12:33:47 -08:00
Zeyi (Rice) Fan
bd321ea0e3 cli_rs: reorganize Rust package structure
Summary: This diff splits edenfsctl binary target into several smaller crates.

Reviewed By: chadaustin

Differential Revision: D26349305

fbshipit-source-id: 8c506d50fd2bf8593a02a95ed2c839c0cbc62fb2
2021-02-12 12:33:46 -08:00
Zeyi (Rice) Fan
a3ddd302a5 cli_rs: implement status in Rust
Summary: This diff reimplements `edenfsctl status` in the Rust wrapper.

Reviewed By: chadaustin

Differential Revision: D25759315

fbshipit-source-id: 86ae4e89f74b41446cc52f106afd1e1e78c36d76
2021-02-12 12:33:46 -08:00
Zeyi (Rice) Fan
dc22fd8777 add a wrapper to combine both Python & Rust EdenFS CLI
Reviewed By: xavierd

Differential Revision: D25792324

fbshipit-source-id: 2e54f27caa830076168b7f178b6a95718eeb9f92
2021-02-10 16:52:07 -08:00
Zeyi (Rice) Fan
f55a022f89 cli: introduce Rust wrapper
Summary:
This diff adds a Rust wrapper that will forward any command it fails to parse
to the companion binary `edenfsctl.real` at the same directory. This will allow
us to rewrite some of the subcommands in Rust while keeps the original
functionality.

With `EDENFSCTL_SKIP_RUST` environment variable set, it will skip the argument
parsing process in case of any emergency situation.

Reviewed By: xavierd

Differential Revision: D25758959

fbshipit-source-id: 0fbc69d0e0733ad2608622417be93dc7db2d6fa6
2021-02-10 16:52:06 -08:00