Skip to content

Commit c159d26

Browse files
committed
Add verification key to repository verified status
This adds the ID of the key that was successful to the verified status for GitRepository resources. Signed-off-by: Kevin McDermott <[email protected]>
1 parent 01ced04 commit c159d26

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

internal/controller/gitrepository_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
903903
keyRings = append(keyRings, string(v))
904904
}
905905
// Verify commit with GPG data from secret
906-
if _, err := commit.Verify(keyRings...); err != nil {
906+
entity, err := commit.Verify(keyRings...)
907+
if err != nil {
907908
e := serror.NewGeneric(
908909
fmt.Errorf("signature verification of commit '%s' failed: %w", commit.Hash.String(), err),
909910
"InvalidCommitSignature",
@@ -914,9 +915,9 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
914915
}
915916

916917
conditions.MarkTrue(obj, sourcev1.SourceVerifiedCondition, meta.SucceededReason,
917-
"verified signature of commit '%s'", commit.Hash.String())
918+
"verified signature of commit '%s' with key '%s'", commit.Hash.String(), entity)
918919
r.eventLogf(ctx, obj, eventv1.EventTypeTrace, "VerifiedCommit",
919-
"verified signature of commit '%s'", commit.Hash.String())
920+
"verified signature of commit '%s' with key '%s'", commit.Hash.String(), entity)
920921
return sreconcile.ResultSuccess, nil
921922
}
922923

internal/controller/gitrepository_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ func TestGitRepositoryReconciler_verifyCommitSignature(t *testing.T) {
15191519
},
15201520
want: sreconcile.ResultSuccess,
15211521
assertConditions: []metav1.Condition{
1522-
*conditions.TrueCondition(sourcev1.SourceVerifiedCondition, meta.SucceededReason, "verified signature of commit 'shasum'"),
1522+
*conditions.TrueCondition(sourcev1.SourceVerifiedCondition, meta.SucceededReason, "verified signature of commit 'shasum' with key '3299AEB0E4085BAF'"),
15231523
},
15241524
},
15251525
{

0 commit comments

Comments
 (0)