From 49e65f31afbb1ec1b954e7fb9f69c71ade2da8cb Mon Sep 17 00:00:00 2001 From: jonaro00 <54029719+jonaro00@users.noreply.github.com> Date: Thu, 27 Apr 2023 18:06:36 +0200 Subject: [PATCH 1/2] fix: Project filtering is disabled Signed-off-by: jonaro00 <54029719+jonaro00@users.noreply.github.com> --- cargo-shuttle/src/client.rs | 16 ++++++++-------- cargo-shuttle/src/lib.rs | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cargo-shuttle/src/client.rs b/cargo-shuttle/src/client.rs index 38084b8ab..b6a725ab3 100644 --- a/cargo-shuttle/src/client.rs +++ b/cargo-shuttle/src/client.rs @@ -134,14 +134,14 @@ impl Client { self.get(path).await } - pub async fn get_projects_list_filtered( - &self, - filter: String, - ) -> Result> { - let path = format!("/projects/{filter}"); - - self.get(path).await - } + // pub async fn get_projects_list_filtered( + // &self, + // filter: String, + // ) -> Result> { + // let path = format!("/projects/{filter}"); + + // self.get(path).await + // } pub async fn delete_project(&self, project: &ProjectName) -> Result { let path = format!("/projects/{}", project.as_str()); diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index e3e31ac77..76540a9fc 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -989,10 +989,12 @@ impl Shuttle { async fn projects_list(&self, client: &Client, filter: Option) -> Result<()> { let projects = match filter { Some(filter) => { - if let Ok(filter) = State::from_str(filter.trim()) { - client - .get_projects_list_filtered(filter.to_string()) - .await? + if let Ok(_filter) = State::from_str(filter.trim()) { + // TODO: gateway/api -> get_projects_list_with_filter + bail!("Project status filtering is currently disabled."); + // client + // .get_projects_list_filtered(filter.to_string()) + // .await? } else { bail!("That's not a valid project status!"); } From ec7c2808f56c16eb9189932a737d32767c3ae315 Mon Sep 17 00:00:00 2001 From: jonaro00 <54029719+jonaro00@users.noreply.github.com> Date: Fri, 28 Apr 2023 18:28:45 +0200 Subject: [PATCH 2/2] remove filter flag --- cargo-shuttle/src/args.rs | 6 +----- cargo-shuttle/src/client.rs | 9 --------- cargo-shuttle/src/lib.rs | 24 ++++-------------------- gateway/src/api/latest.rs | 18 ------------------ 4 files changed, 5 insertions(+), 52 deletions(-) diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index aeaa148ea..9ee958fb2 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -176,11 +176,7 @@ pub enum ProjectCommand { idle_minutes: u64, }, /// List all projects belonging to the calling account - List { - #[arg(long)] - /// Return projects filtered by a given project status - filter: Option, - }, + List, } #[derive(Parser, Clone, Debug)] diff --git a/cargo-shuttle/src/client.rs b/cargo-shuttle/src/client.rs index b6a725ab3..e22e82bde 100644 --- a/cargo-shuttle/src/client.rs +++ b/cargo-shuttle/src/client.rs @@ -134,15 +134,6 @@ impl Client { self.get(path).await } - // pub async fn get_projects_list_filtered( - // &self, - // filter: String, - // ) -> Result> { - // let path = format!("/projects/{filter}"); - - // self.get(path).await - // } - pub async fn delete_project(&self, project: &ProjectName) -> Result { let path = format!("/projects/{}", project.as_str()); diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 76540a9fc..358d81266 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -7,7 +7,7 @@ mod provisioner_server; use indicatif::ProgressBar; use shuttle_common::claims::{ClaimService, InjectPropagation}; use shuttle_common::models::deployment::get_deployments_table; -use shuttle_common::models::project::{State, IDLE_MINUTES}; +use shuttle_common::models::project::IDLE_MINUTES; use shuttle_common::models::resource::get_resources_table; use shuttle_common::project::ProjectName; use shuttle_common::resource; @@ -127,9 +127,7 @@ impl Shuttle { Command::Project(ProjectCommand::Status { follow }) => { self.project_status(&self.client()?, follow).await } - Command::Project(ProjectCommand::List { filter }) => { - self.projects_list(&self.client()?, filter).await - } + Command::Project(ProjectCommand::List) => self.projects_list(&self.client()?).await, Command::Project(ProjectCommand::Stop) => self.project_delete(&self.client()?).await, } .map(|_| CommandOutcome::Ok) @@ -986,22 +984,8 @@ impl Shuttle { Ok(()) } - async fn projects_list(&self, client: &Client, filter: Option) -> Result<()> { - let projects = match filter { - Some(filter) => { - if let Ok(_filter) = State::from_str(filter.trim()) { - // TODO: gateway/api -> get_projects_list_with_filter - bail!("Project status filtering is currently disabled."); - // client - // .get_projects_list_filtered(filter.to_string()) - // .await? - } else { - bail!("That's not a valid project status!"); - } - } - None => client.get_projects_list().await?, - }; - + async fn projects_list(&self, client: &Client) -> Result<()> { + let projects = client.get_projects_list().await?; let projects_table = project::get_table(&projects); println!("{projects_table}"); diff --git a/gateway/src/api/latest.rs b/gateway/src/api/latest.rs index 1118e4077..42dbe550e 100644 --- a/gateway/src/api/latest.rs +++ b/gateway/src/api/latest.rs @@ -133,24 +133,6 @@ async fn get_projects_list( Ok(AxumJson(projects)) } -// async fn get_projects_list_with_filter( -// State(RouterState { service, .. }): State, -// User { name, .. }: User, -// Path(project_status): Path, -// ) -> Result>, Error> { -// let projects = service -// .iter_user_projects_detailed_filtered(name.clone(), project_status) -// .await? -// .into_iter() -// .map(|project| project::Response { -// name: project.0.to_string(), -// state: project.1.into(), -// }) -// .collect(); - -// Ok(AxumJson(projects)) -// } - #[instrument(skip_all, fields(%project))] #[utoipa::path( post,