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 <kevin@weave.works>
This commit is contained in:
parent
01ced04389
commit
c159d260db
|
@ -903,7 +903,8 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
|
||||||
keyRings = append(keyRings, string(v))
|
keyRings = append(keyRings, string(v))
|
||||||
}
|
}
|
||||||
// Verify commit with GPG data from secret
|
// 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(
|
e := serror.NewGeneric(
|
||||||
fmt.Errorf("signature verification of commit '%s' failed: %w", commit.Hash.String(), err),
|
fmt.Errorf("signature verification of commit '%s' failed: %w", commit.Hash.String(), err),
|
||||||
"InvalidCommitSignature",
|
"InvalidCommitSignature",
|
||||||
|
@ -914,9 +915,9 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
|
||||||
}
|
}
|
||||||
|
|
||||||
conditions.MarkTrue(obj, sourcev1.SourceVerifiedCondition, meta.SucceededReason,
|
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",
|
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
|
return sreconcile.ResultSuccess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ func TestGitRepositoryReconciler_verifyCommitSignature(t *testing.T) {
|
||||||
},
|
},
|
||||||
want: sreconcile.ResultSuccess,
|
want: sreconcile.ResultSuccess,
|
||||||
assertConditions: []metav1.Condition{
|
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'"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue