clean-up: fix most clippy warnings

This commit is contained in:
Lewin Bormann
2022-04-08 23:35:15 -07:00
parent 986bda2465
commit bfe622eaaf
6 changed files with 8 additions and 12 deletions

View File

@@ -2,15 +2,11 @@ use crate::error::Error;
use crate::types::TokenInfo;
/// Provide options for the Application Default Credential Flow, mostly used for testing
#[derive(Default, Clone, Debug)]
pub struct ApplicationDefaultCredentialsFlowOpts {
/// Used as base to build the url during token request from GCP metadata server
pub metadata_url: Option<String>,
}
impl Default for ApplicationDefaultCredentialsFlowOpts {
fn default() -> Self {
Self { metadata_url: None }
}
}
pub struct ApplicationDefaultCredentialsFlow {
metadata_url: String,

View File

@@ -113,7 +113,7 @@ where
(Some(t), _) if !t.is_expired() && !force_refresh => {
// unexpired token found
log::debug!("found valid token in cache: {:?}", t);
Ok(t.into())
Ok(t)
}
(
Some(TokenInfo {

View File

@@ -10,7 +10,7 @@ use hyper::header;
use serde::{Deserialize, Serialize};
use url::form_urlencoded;
const TOKEN_URI: &'static str = "https://accounts.google.com/o/oauth2/token";
const TOKEN_URI: &str = "https://accounts.google.com/o/oauth2/token";
/// JSON schema of authorized user secret. You can obtain it by
/// running on the client: `gcloud auth application-default login`.

View File

@@ -82,7 +82,7 @@ impl DeviceFlow {
loop {
tokio::time::sleep(interval).await;
interval = match Self::poll_token(
&app_secret,
app_secret,
hyper_client,
&device_auth_resp.device_code,
grant_type,

View File

@@ -142,7 +142,7 @@ impl JWTSigner {
fn sign_claims(&self, claims: &Claims) -> Result<String, rustls::TLSError> {
let mut jwt_head = Self::encode_claims(claims);
let signature = self.signer.sign(jwt_head.as_bytes())?;
jwt_head.push_str(".");
jwt_head.push('.');
append_base64(&signature, &mut jwt_head);
Ok(jwt_head)
}
@@ -152,7 +152,7 @@ impl JWTSigner {
fn encode_claims(claims: &Claims) -> String {
let mut head = String::new();
append_base64(GOOGLE_RS256_HEAD, &mut head);
head.push_str(".");
head.push('.');
append_base64(&serde_json::to_string(&claims).unwrap(), &mut head);
head
}
@@ -190,7 +190,7 @@ impl ServiceAccountFlow {
T: AsRef<str>,
C: hyper::client::connect::Connect + Clone + Send + Sync + 'static,
{
let claims = Claims::new(&self.key, scopes, self.subject.as_ref().map(|x| x.as_str()));
let claims = Claims::new(&self.key, scopes, self.subject.as_deref());
let signed = self.signer.sign_claims(&claims).map_err(|_| {
Error::LowLevelError(io::Error::new(
io::ErrorKind::Other,

View File

@@ -343,7 +343,7 @@ impl JSONTokens {
hash,
filter,
};
entry.insert(json_token.clone());
entry.insert(json_token);
}
}
Ok(())