Skip to content

Commit 40c1851

Browse files
committed
Add verification failed reason
1 parent 440c70d commit 40c1851

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

api/v1alpha1/condition_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,8 @@ const (
6565
// AuthenticationFailedReason represents the fact that a given secret does not
6666
// have the required fields or the provided credentials do not match.
6767
AuthenticationFailedReason string = "AuthenticationFailed"
68+
69+
// VerificationFailedReason represents the fact that the cryptographic provenance
70+
// verification for the source failed.
71+
VerificationFailedReason string = "VerificationFailed"
6872
)

api/v1alpha1/gitrepository_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type GitRepositoryVerification struct {
8080
SecretRef corev1.LocalObjectReference `json:"secretRef,omitempty"`
8181
}
8282

83-
// GitRepositoryStatus defines the observed state of Git repository.
83+
// GitRepositoryStatus defines the observed state of a Git repository.
8484
type GitRepositoryStatus struct {
8585
// +optional
8686
Conditions []SourceCondition `json:"conditions,omitempty"`

config/crd/bases/source.fluxcd.io_gitrepositories.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ spec:
8787
pattern: ^(http|https|ssh)://
8888
type: string
8989
verify:
90-
description: Verify PGP signature for the commit that HEAD points to.
90+
description: Verify OpenPGP signature for the commit that HEAD points
91+
to.
9192
properties:
9293
mode:
93-
description: Mode describes what git object should be verified.
94+
description: Mode describes what git object should be verified,
95+
currently ('head').
9496
enum:
9597
- head
9698
type: string
@@ -111,7 +113,7 @@ spec:
111113
- url
112114
type: object
113115
status:
114-
description: GitRepositoryStatus defines the observed state of the GitRepository.
116+
description: GitRepositoryStatus defines the observed state of a Git repository.
115117
properties:
116118
artifact:
117119
description: Artifact represents the output of the last successful repository

controllers/gitrepository_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (r *GitRepositoryReconciler) sync(ctx context.Context, repository sourcev1.
271271

272272
if commit.PGPSignature == "" {
273273
err = fmt.Errorf("PGP signature not found for commit '%s'", ref.Hash())
274-
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
274+
return sourcev1.GitRepositoryNotReady(repository, sourcev1.VerificationFailedReason, err.Error()), err
275275
}
276276

277277
name := types.NamespacedName{
@@ -283,7 +283,7 @@ func (r *GitRepositoryReconciler) sync(ctx context.Context, repository sourcev1.
283283
err = r.Client.Get(ctx, name, &secret)
284284
if err != nil {
285285
err = fmt.Errorf("PGP public keys secret error: %w", err)
286-
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
286+
return sourcev1.GitRepositoryNotReady(repository, sourcev1.VerificationFailedReason, err.Error()), err
287287
}
288288

289289
var verified bool
@@ -296,7 +296,7 @@ func (r *GitRepositoryReconciler) sync(ctx context.Context, repository sourcev1.
296296

297297
if !verified {
298298
err = fmt.Errorf("PGP signature of '%s' can't be verified", commit.Author)
299-
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
299+
return sourcev1.GitRepositoryNotReady(repository, sourcev1.VerificationFailedReason, err.Error()), err
300300
}
301301
}
302302

0 commit comments

Comments
 (0)