Skip to content

Commit

Permalink
Merge pull request #1136 from bigkevmcd/gitrepository-verification-key
Browse files Browse the repository at this point in the history
Add the verification key to the GitRepository verified status condition
  • Loading branch information
stefanprodan authored Jun 28, 2023
2 parents 01ced04 + c159d26 commit 5fd4079
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions internal/controller/gitrepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,8 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
keyRings = append(keyRings, string(v))
}
// Verify commit with GPG data from secret
if _, err := commit.Verify(keyRings...); err != nil {
entity, err := commit.Verify(keyRings...)
if err != nil {
e := serror.NewGeneric(
fmt.Errorf("signature verification of commit '%s' failed: %w", commit.Hash.String(), err),
"InvalidCommitSignature",
Expand All @@ -914,9 +915,9 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
}

conditions.MarkTrue(obj, sourcev1.SourceVerifiedCondition, meta.SucceededReason,
"verified signature of commit '%s'", commit.Hash.String())
"verified signature of commit '%s' with key '%s'", commit.Hash.String(), entity)
r.eventLogf(ctx, obj, eventv1.EventTypeTrace, "VerifiedCommit",
"verified signature of commit '%s'", commit.Hash.String())
"verified signature of commit '%s' with key '%s'", commit.Hash.String(), entity)
return sreconcile.ResultSuccess, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/gitrepository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ func TestGitRepositoryReconciler_verifyCommitSignature(t *testing.T) {
},
want: sreconcile.ResultSuccess,
assertConditions: []metav1.Condition{
*conditions.TrueCondition(sourcev1.SourceVerifiedCondition, meta.SucceededReason, "verified signature of commit 'shasum'"),
*conditions.TrueCondition(sourcev1.SourceVerifiedCondition, meta.SucceededReason, "verified signature of commit 'shasum' with key '3299AEB0E4085BAF'"),
},
},
{
Expand Down

0 comments on commit 5fd4079

Please # to comment.