Skip to content

Commit

Permalink
Always respect EDGEDB_CLOUD_PROFILE
Browse files Browse the repository at this point in the history
Cloud instances, unlike local instances, do not represent local
configuration, so `EDGEDB_CLOUD_PROFILE` should always be respected
when connecting to such instances regardless of how compound
connection options have been specified.
  • Loading branch information
elprans committed Oct 30, 2023
1 parent 9ba86e8 commit 3b2f0f8
Showing 1 changed file with 9 additions and 8 deletions.
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

0 comments on commit 3b2f0f8

Please sign in to comment.