Skip to content

Commit

Permalink
refactor: use tuple match for token/scope handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jdockerty committed Aug 11, 2024
1 parent b36ca3b commit 55fc762
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/src/services/gcs/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,18 @@ static BACKOFF: Lazy<ExponentialBuilder> =

impl GcsCore {
async fn load_token(&self) -> Result<Option<GoogleToken>> {
if let Some(token) = &self.token {
if let Some(scope) = &self.scope {
return Ok(Some(GoogleToken::new(token, usize::MAX, scope)));
} else {
match (&self.token, &self.scope) {
(Some(token), Some(scope)) => {
return Ok(Some(GoogleToken::new(token, usize::MAX, scope)))
}
(Some(_), None) => {
return Err(Error::new(
ErrorKind::ConfigInvalid,
"Scope is required when token is set",
));
))
}
_ => {}
}

let cred = { || self.token_loader.load() }
.retry(&*BACKOFF)
.await
Expand Down

0 comments on commit 55fc762

Please sign in to comment.