-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
github-on-prem - auth_info retrieval from github app #14
Conversation
WalkthroughThe changes primarily focus on enhancing the functionality of the Changes
TipsChat with CodeRabbit Bot (
|
CodeRabbit review skipped By default, CodeRabbit only reviews PRs on the default branch. If you wish to have PRs reviewed on additional branches, you can configure that under the repository settings in the UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error handling requires fixing for the given functions
vibi-dpu/src/github/auth.rs
Outdated
let pem_data = match fs::read(pem_file_path) { | ||
Ok(data) => data, | ||
Err(e) => { | ||
println!("Error reading pem file: {}", e); | ||
return None; | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use match for anything except debugging. You should read the result of fs::read(pem_file) in a variable, check if that variable is_err(), print the error and return . if not, the rest of the code follows. This helps in keeping the code clean (separation of logic and error handling). For reference, you can see any function in gitops.rs, like - get_excluded_files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
vibi-dpu/src/github/auth.rs
Outdated
let encoding_key = match EncodingKey::from_rsa_pem(&pem_data) { | ||
Ok(key) => key, | ||
Err(e) => { | ||
println!("Error creating encoding key: {}", e); | ||
return None; | ||
}, | ||
}; | ||
match encode(&Header::new(Algorithm::RS256), &my_claims, &encoding_key) { | ||
Ok(token) => Some(token), | ||
Err(e) => { | ||
println!("Error encoding JWT: {}", e); | ||
None | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove match, same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yess yess!
vibi-dpu/src/github/auth.rs
Outdated
let pem_data = fs::read(pem_file_path)?; | ||
fn generate_jwt(github_app_id: &str) -> Option<String> { | ||
let pem_file_path = "/app/repoprofiler_private.pem"; | ||
let pem_data = fs::read(pem_file_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be pem_data_res
vibi-dpu/src/github/auth.rs
Outdated
println!("Error reading pem file: {:?}", pem_data_err); | ||
return None; | ||
} | ||
let pem_data_res = pem_data.expect("Error reading pem file"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be named pem_data, and then used further along
vibi-dpu/src/github/auth.rs
Outdated
println!("Error encoding JWT: {:?}", token_err); | ||
return None; | ||
}; | ||
let token_result = token.expect("Error encoding JWT"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did
SonarCloud Quality Gate failed. 0 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Summary by CodeRabbit
reqwest::Client
across the application, improving performance and resource usage.These updates aim to improve the software's usability, extend its functionality, and enhance its performance and reliability.