Skip to content

Commit e2f5814

Browse files
committed
Make gcp option infallible if the env vars are missing
1 parent 6c667f3 commit e2f5814

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/cast/bin/cmd/wallet/list.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clap::Parser;
22
use eyre::Result;
3+
use std::env;
34

45
use foundry_common::fs;
56
use foundry_config::Config;
@@ -54,7 +55,7 @@ impl ListArgs {
5455
.mnemonic_indexes(Some(vec![0]))
5556
.trezor(self.trezor || self.all)
5657
.aws(self.aws || self.all)
57-
.gcp(self.gcp || self.all)
58+
.gcp(self.gcp || (self.all && gcp_env_vars_set()))
5859
.interactives(0)
5960
.build()
6061
.expect("build multi wallet");
@@ -114,3 +115,10 @@ impl ListArgs {
114115
Ok(())
115116
}
116117
}
118+
119+
fn gcp_env_vars_set() -> bool {
120+
let required_vars =
121+
["GCP_PROJECT_ID", "GCP_LOCATION", "GCP_KEY_RING", "GCP_KEY_NAME", "GCP_KEY_VERSION"];
122+
123+
required_vars.iter().all(|&var| env::var(var).is_ok())
124+
}

0 commit comments

Comments
 (0)