Skip to content

Commit

Permalink
fix: make it work with resource list and local run
Browse files Browse the repository at this point in the history
  • Loading branch information
oddgrd committed Jun 28, 2024
1 parent 8a151a3 commit 5ac9e8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
10 changes: 9 additions & 1 deletion cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,15 @@ impl Shuttle {

println!(
"{}",
get_resource_tables(&mocked_responses, service_name.as_str(), false, false, beta)
get_resource_tables(
&mocked_responses,
service_name.as_str(),
false,
false,
// Set beta to false to avoid breaking local run with beta changes.
// TODO: make local run compatible with --beta.
false
)
);

//
Expand Down
20 changes: 5 additions & 15 deletions common/src/models/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crossterm::style::Stylize;
use crate::{
resource::{Response, Type},
secrets::SecretStore,
DatabaseResource,
DatabaseInfoBeta, DatabaseResource,
};

pub fn get_resource_tables(
Expand Down Expand Up @@ -178,22 +178,12 @@ fn get_databases_table_beta(
]);
}

// TODO: add beta version that tries to parse databaseinfobeta?
for database in databases {
let connection_string = serde_json::from_value::<String>(database.data.clone())
.expect("resource data to be a valid database");

let conn_string = if let Ok(mut url) = connection_string.parse::<url::Url>() {
if url.password().is_some() && !show_secrets {
// ignore edge cases (if any)
let _ = url.set_password(Some("********"));
}
url.to_string()
} else {
connection_string
};
let connection_string = serde_json::from_value::<DatabaseInfoBeta>(database.data.clone())
.expect("resource data to be a valid database")
.connection_string(show_secrets);

table.add_row(vec![database.r#type.to_string(), conn_string]);
table.add_row(vec![database.r#type.to_string(), connection_string]);
}

let show_secret_hint = if databases.is_empty() || show_secrets {
Expand Down

0 comments on commit 5ac9e8e

Please sign in to comment.