Skip to content
New issue

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

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

Already on GitHub? # to your account

Always respect EDGEDB_CLOUD_PROFILE when connecting to cloud #235

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
17 changes: 9 additions & 8 deletions edgedb-tokio/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,13 +1046,10 @@ impl Builder {
}
}
}
async fn preliminary_env(&self, cfg: &mut ConfigInner,

async fn secret_key_env(&self, cfg: &mut ConfigInner,
errors: &mut Vec<Error>)
{
cfg.cloud_profile = self.cloud_profile.clone().or_else(|| {
get_env("EDGEDB_CLOUD_PROFILE")
.map_err(|e| errors.push(e)).ok().flatten()
});
cfg.secret_key = self.secret_key.clone().or_else(|| {
get_env("EDGEDB_SECRET_KEY")
.map_err(|e| errors.push(e)).ok().flatten()
Expand Down Expand Up @@ -1334,6 +1331,11 @@ impl Builder {
verifier: Arc::new(tls::NullVerifier),
};

cfg.cloud_profile = self.cloud_profile.clone().or_else(|| {
get_env("EDGEDB_CLOUD_PROFILE")
.map_err(|e| errors.push(e)).ok().flatten()
});

let complete = if self.host.is_some() ||
self.port.is_some() ||
self.unix_path.is_some() ||
Expand All @@ -1343,20 +1345,19 @@ impl Builder {
self.credentials_file.is_some()
{
cfg.secret_key = self.secret_key.clone();
cfg.cloud_profile = self.cloud_profile.clone();
self.compound_owned(&mut cfg, &mut errors).await;
self.granular_owned(&mut cfg, &mut errors).await;
true
} else if
COMPOUND_ENV_VARS.iter().any(|x| env::var_os(x).is_some()) ||
has_port_env()
{
self.preliminary_env(&mut cfg, &mut errors).await;
self.secret_key_env(&mut cfg, &mut errors).await;
self.compound_env(&mut cfg, &mut errors).await;
self.granular_env(&mut cfg, &mut errors).await;
true
} else {
self.preliminary_env(&mut cfg, &mut errors).await;
self.secret_key_env(&mut cfg, &mut errors).await;
let complete = self.read_project(&mut cfg, &mut errors).await;
self.granular_env(&mut cfg, &mut errors).await;
complete
Expand Down