Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To date, the [Go CLI](https://github.com/svix) has lived in its own repo and has received infrequent updates, failing to track our APIs as they change. In an effort to improve on this, this diff adds new Rust version of the CLI here in the webhooks repo. The idea is to release the CLI along with the libs as a part of the same process (svix/monorepo-private#9620). Modules in the source tree under `cli_types/` and `cmds/api/` (excluding the `mod.rs`) are largely produced via our new codegen tooling (h/t @svix-jplatte). Other modules under `cmds/` are written by hand, the most involved being `listen` which depends on greenfield code under `relay/`. The relay code was largely inspired by the code seen in the Go CLI, but the overall shape of it has changed to account for GC vs borrow checker. Future work sound be planned to do a design pass now that the pieces are working together since breaking things apart to satisfy rustc left things in an odd shape. ## Differences Comparing the Go and Rust CLIs, there are some differences. The list of features added in the Rust version that are lacking in Go's is long thanks to the new codegen. It'll be more useful to focus on what _isn't here_. ### `--data-*` flags In the Go CLI we exposed flags named `--data-foo` where `foo` would be a field in the expected JSON body sent with the request. These flags have not been carried forward. Instead users will be required to write out the full JSON body as a command-line argument. Serde will give some feedback if the body fails to parse given the expected schema even before the request is made to the server. Future work is planned to include an example body for each place we accept JSON in the long help. ### Import/Export `svix import` and `svix export` have been left behind. For import, users are encouraged to leverage `svix event-type import-openapi` which should fill the same need. For export, I think the best alternative is using `svix event-type list` and handling the responses as needed. ### Server URL no longer mandatory The GO CLI required users to set the URL for the API server they wanted to interact with. In the new Rust CLI, we will default to the issuer of the auth token. Typically this is going to be the safest default since manually specifying a Server URL should only be necessary when doing local development or talking to a non-production-SaaS server. The impacted group for this change would be enterprise customers and Svix employees and the fix is to do what they'd have needed to do all along: set the URL explicitly. ## Verification Reviewers will note that there's a dramatic lack of unit tests 😇 To this, I assure you there's technically more coverage on _this CLI_ than there is on the Go one 🤣. The majority of the verification for this has been manual testing. If you have specific concerns, pitch a test and I can run through the scenario for you (or you can try it yourself!) ## OSS Reviews There are several new-to-us crates included in this diff. I'll call each out in the comments below, looking for 👍🏻 from the security team.
- Loading branch information