Skip to content

Commit

Permalink
review: Simplify with ok_or_else()
Browse files Browse the repository at this point in the history
  • Loading branch information
viccuad committed May 24, 2022
1 parent 4e83b3e commit ba6c6ab
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/verify/verification_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,8 @@ impl VerificationConstraint for GitHubVerifier {
SigstoreError::VerificationConstraintError(format!("The certificate subject url doesn't seem a GitHub valid one, despite the issuer being the GitHub Action one: {}", signature_subject)))?;

// the certificate github_workflow_extension must be there and correctly constructed
let github_workflow_repository = match &certificate_signature.github_workflow_repository {
Some(workflow_repository) => workflow_repository,
None => return Err(SigstoreError::VerificationConstraintError(format!("The certificate is missing the github_workflow_repository extension despite being a GitHub Action one: {}", signature_subject))),
};
let github_workflow_repository = certificate_signature.github_workflow_repository.as_ref()
.ok_or_else(|| SigstoreError::VerificationConstraintError("The certificate is missing the github_workflow_repository extension despite being a GitHub Action one".to_string()))?;

let signature_repo = GitHubRepo::try_from(format!("https://github.com/{}", github_workflow_repository).as_str())
.map_err(|_|
Expand Down

0 comments on commit ba6c6ab

Please sign in to comment.