Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: remove deprecated auth command #550

Merged
merged 2 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions cargo-shuttle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ To initialize a shuttle project with boilerplates, run `cargo shuttle init [OPTI
Currently, `cargo shuttle init` supports the following frameworks:

- `--axum`: for [axum](https://github.com/tokio-rs/axum) framework
- `--actix-web`: for [actix web](https://actix.rs/) framework
- `--poem`: for [poem](https://github.com/poem-web/poem) framework
- `--rocket`: for [rocket](https://rocket.rs/) framework
- `--salvo`: for [salvo](https://salvo.rs/) framework
- `--serenity`: for [serenity](https://serenity.rs/) discord bot framework
- `--thruster`: for [thruster](https://github.com/thruster-rs/Thruster) framework
- `--tide`: for [tide](https://github.com/http-rs/tide) framework
- `--tower`: for [tower](https://github.com/tower-rs/tower) library
- `--warp`: for [warp](https://github.com/seanmonstar/warp) framework

For example, running the following command will initialize a project for [rocket](https://rocket.rs/):

Expand Down Expand Up @@ -177,14 +182,6 @@ Check the logs of your deployed shuttle project with:
$ cargo shuttle logs
```

### Subcommand: `auth`

Run the following to create user credentials for shuttle platform:

```sh
$ cargo shuttle auth your-desired-username
```

### Subcommand: `delete`

Once you are done with a deployment, you can delete it by running:
Expand Down
9 changes: 0 additions & 9 deletions cargo-shuttle/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ pub enum Command {
Delete,
/// manage secrets for this shuttle service
Secrets,
/// create user credentials for the shuttle platform
Auth(AuthArgs),
/// login to the shuttle platform
Login(LoginArgs),
/// run a shuttle service locally
Expand Down Expand Up @@ -128,13 +126,6 @@ pub struct LoginArgs {
pub api_key: Option<String>,
}

#[derive(Parser)]
pub struct AuthArgs {
/// the desired username for the shuttle platform
#[clap()]
pub username: String,
}

#[derive(Parser)]
pub struct DeployArgs {
/// allow dirty working directories to be packaged
Expand Down
12 changes: 1 addition & 11 deletions cargo-shuttle/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reqwest_middleware::{ClientBuilder, ClientWithMiddleware, RequestBuilder};
use reqwest_retry::policies::ExponentialBackoff;
use reqwest_retry::RetryTransientMiddleware;
use serde::Deserialize;
use shuttle_common::models::{deployment, project, secret, service, user, ToJson};
use shuttle_common::models::{deployment, project, secret, service, ToJson};
use shuttle_common::project::ProjectName;
use shuttle_common::{ApiKey, ApiUrl, LogItem};
use tokio::net::TcpStream;
Expand All @@ -33,16 +33,6 @@ impl Client {
self.api_key = Some(api_key);
}

pub async fn auth(&self, username: String) -> Result<user::Response> {
let path = format!("/users/{}", username);

self.post(path, Option::<String>::None)
.await
.context("failed to get API key from Shuttle server")?
.to_json()
.await
}

pub async fn deploy(
&self,
data: Vec<u8>,
Expand Down
13 changes: 0 additions & 13 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::net::{Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};

use anyhow::{anyhow, bail, Context, Result};
use args::AuthArgs;
pub use args::{Args, Command, DeployArgs, InitArgs, LoginArgs, ProjectArgs, RunArgs};
use cargo_metadata::Message;
use clap::CommandFactory;
Expand Down Expand Up @@ -94,7 +93,6 @@ impl Shuttle {
Command::Delete => self.delete(&client).await,
Command::Clean => self.clean(&client).await,
Command::Secrets => self.secrets(&client).await,
Command::Auth(auth_args) => self.auth(auth_args, &client).await,
Command::Project(ProjectCommand::New) => self.project_create(&client).await,
Command::Project(ProjectCommand::Status { follow }) => {
self.project_status(&client, follow).await
Expand Down Expand Up @@ -249,17 +247,6 @@ impl Shuttle {
Ok(())
}

async fn auth(&mut self, auth_args: AuthArgs, client: &Client) -> Result<()> {
let user = client.auth(auth_args.username).await?;

self.ctx.set_api_key(user.key)?;

println!("User authorized!!!");
println!("Run `cargo shuttle init --help` next");

Ok(())
}

async fn delete(&self, client: &Client) -> Result<()> {
let service = client.delete_service(self.ctx.project_name()).await?;

Expand Down