Replace %q in messages with '%s'

Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
Hidde Beydals 2021-08-03 12:20:19 +02:00
parent e34f79203d
commit f1de98faf0
2 changed files with 17 additions and 17 deletions

View File

@ -292,7 +292,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
}) })
if err != nil { if err != nil {
conditions.MarkTrue(obj, sourcev1.CheckoutFailedCondition, sourcev1.AuthenticationFailedReason, conditions.MarkTrue(obj, sourcev1.CheckoutFailedCondition, sourcev1.AuthenticationFailedReason,
"Failed to get auth strategy for Git implementation %q: %s", obj.Spec.GitImplementation, err) "Failed to get auth strategy for Git implementation '%s': %s", obj.Spec.GitImplementation, err)
// Do not return error as recovery without changes is impossible // Do not return error as recovery without changes is impossible
return ctrl.Result{}, nil return ctrl.Result{}, nil
} }
@ -316,9 +316,9 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
auth, err = authStrategy.Method(secret) auth, err = authStrategy.Method(secret)
if err != nil { if err != nil {
conditions.MarkTrue(obj, sourcev1.CheckoutFailedCondition, sourcev1.AuthenticationFailedReason, conditions.MarkTrue(obj, sourcev1.CheckoutFailedCondition, sourcev1.AuthenticationFailedReason,
"Failed to configure auth strategy for Git implementation %q: %s", obj.Spec.GitImplementation, err) "Failed to configure auth strategy for Git implementation '%s': %s", obj.Spec.GitImplementation, err)
r.Eventf(ctx, obj, events.EventSeverityError, sourcev1.AuthenticationFailedReason, r.Eventf(ctx, obj, events.EventSeverityError, sourcev1.AuthenticationFailedReason,
"Failed to configure auth strategy for Git implementation %q: %s", obj.Spec.GitImplementation, err) "Failed to configure auth strategy for Git implementation '%s': %s", obj.Spec.GitImplementation, err)
// Return error as the contents of the secret may change // Return error as the contents of the secret may change
return ctrl.Result{}, err return ctrl.Result{}, err
} }
@ -331,7 +331,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
}) })
if err != nil { if err != nil {
conditions.MarkTrue(obj, sourcev1.CheckoutFailedCondition, sourcev1.GitOperationFailedReason, conditions.MarkTrue(obj, sourcev1.CheckoutFailedCondition, sourcev1.GitOperationFailedReason,
"Failed to configure checkout strategy for Git implementation %q: %s", obj.Spec.GitImplementation, err) "Failed to configure checkout strategy for Git implementation '%s': %s", obj.Spec.GitImplementation, err)
// Do not return err as recovery without changes is impossible // Do not return err as recovery without changes is impossible
return ctrl.Result{}, nil return ctrl.Result{}, nil
} }
@ -471,7 +471,7 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, obj *sou
toPath, err := securejoin.SecureJoin(dir, incl.GetToPath()) toPath, err := securejoin.SecureJoin(dir, incl.GetToPath())
if err != nil { if err != nil {
conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "IllegalPath", conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "IllegalPath",
"Path calculation for include %q failed: %s", incl.GitRepositoryRef.Name, err.Error()) "Path calculation for include '%s' failed: %s", incl.GitRepositoryRef.Name, err.Error())
return ctrl.Result{}, err return ctrl.Result{}, err
} }
@ -479,23 +479,23 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, obj *sou
dep := &sourcev1.GitRepository{} dep := &sourcev1.GitRepository{}
if err := r.Get(ctx, types.NamespacedName{Namespace: obj.Namespace, Name: incl.GitRepositoryRef.Name}, dep); err != nil { if err := r.Get(ctx, types.NamespacedName{Namespace: obj.Namespace, Name: incl.GitRepositoryRef.Name}, dep); err != nil {
conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "NotFound", conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "NotFound",
"Could not get resource for include %q: %s", incl.GitRepositoryRef.Name, err.Error()) "Could not get resource for include '%s': %s", incl.GitRepositoryRef.Name, err.Error())
return ctrl.Result{}, err return ctrl.Result{}, err
} }
// Confirm include has an artifact // Confirm include has an artifact
if dep.GetArtifact() == nil { if dep.GetArtifact() == nil {
conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "NoArtifact", conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "NoArtifact",
"No artifact available for include %q", incl.GitRepositoryRef.Name) "No artifact available for include '%s'", incl.GitRepositoryRef.Name)
return ctrl.Result{}, nil return ctrl.Result{}, nil
} }
// Copy artifact (sub)contents to configured directory // Copy artifact (sub)contents to configured directory
if err := r.Storage.CopyToPath(dep.GetArtifact(), incl.GetFromPath(), toPath); err != nil { if err := r.Storage.CopyToPath(dep.GetArtifact(), incl.GetFromPath(), toPath); err != nil {
conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "CopyFailure", conditions.MarkTrue(obj, sourcev1.IncludeUnavailableCondition, "CopyFailure",
"Failed to copy %q include from %s to %s: %s", incl.GitRepositoryRef.Name, incl.GetFromPath(), incl.GetToPath(), err.Error()) "Failed to copy '%s' include from %s to %s: %s", incl.GitRepositoryRef.Name, incl.GetFromPath(), incl.GetToPath(), err.Error())
r.Eventf(ctx, obj, events.EventSeverityError, sourcev1.IncludeUnavailableCondition, r.Eventf(ctx, obj, events.EventSeverityError, sourcev1.IncludeUnavailableCondition,
"Failed to copy %q include from %s to %s: %s", incl.GitRepositoryRef.Name, incl.GetFromPath(), incl.GetToPath(), err.Error()) "Failed to copy '%s' include from %s to %s: %s", incl.GitRepositoryRef.Name, incl.GetFromPath(), incl.GetToPath(), err.Error())
return ctrl.Result{}, err return ctrl.Result{}, err
} }
artifacts[i] = dep.GetArtifact().DeepCopy() artifacts[i] = dep.GetArtifact().DeepCopy()
@ -549,14 +549,14 @@ func (r *GitRepositoryReconciler) verifyCommitSignature(ctx context.Context, obj
// Verify commit with GPG data from secret // Verify commit with GPG data from secret
if err := commit.Verify(secret); err != nil { if err := commit.Verify(secret); err != nil {
conditions.MarkFalse(obj, sourcev1.SourceVerifiedCondition, meta.FailedReason, "Signature verification of commit %q failed: %s", commit.Hash(), err) conditions.MarkFalse(obj, sourcev1.SourceVerifiedCondition, meta.FailedReason, "Signature verification of commit '%s' failed: %s", commit.Hash(), err)
r.Eventf(ctx, obj, events.EventSeverityError, "InvalidCommitSignature", "Signature verification of commit %q failed: %s", commit.Hash(), err) r.Eventf(ctx, obj, events.EventSeverityError, "InvalidCommitSignature", "Signature verification of commit '%s' failed: %s", commit.Hash(), err)
// Return error in the hope the secret changes // Return error in the hope the secret changes
return ctrl.Result{}, err return ctrl.Result{}, err
} }
conditions.MarkTrue(obj, sourcev1.SourceVerifiedCondition, meta.SucceededReason, "Verified signature of commit %q", commit.Hash()) conditions.MarkTrue(obj, sourcev1.SourceVerifiedCondition, meta.SucceededReason, "Verified signature of commit '%s'", commit.Hash())
r.Eventf(ctx, obj, events.EventSeverityInfo, "VerifiedCommit", "Verified signature of commit %q", commit.Hash()) r.Eventf(ctx, obj, events.EventSeverityInfo, "VerifiedCommit", "Verified signature of commit '%s'", commit.Hash())
return ctrl.Result{RequeueAfter: obj.Spec.Interval.Duration}, nil return ctrl.Result{RequeueAfter: obj.Spec.Interval.Duration}, nil
} }

View File

@ -703,7 +703,7 @@ func TestGitRepositoryReconciler_reconcileInclude(t *testing.T) {
}, },
wantErr: true, wantErr: true,
assertConditions: []metav1.Condition{ assertConditions: []metav1.Condition{
*conditions.TrueCondition(sourcev1.IncludeUnavailableCondition, "NotFound", "Could not get resource for include \"a\": gitrepositories.source.toolkit.fluxcd.io \"a\" not found"), *conditions.TrueCondition(sourcev1.IncludeUnavailableCondition, "NotFound", "Could not get resource for include 'a': gitrepositories.source.toolkit.fluxcd.io \"a\" not found"),
}, },
}, },
{ {
@ -721,7 +721,7 @@ func TestGitRepositoryReconciler_reconcileInclude(t *testing.T) {
{name: "a", toPath: "a/"}, {name: "a", toPath: "a/"},
}, },
assertConditions: []metav1.Condition{ assertConditions: []metav1.Condition{
*conditions.TrueCondition(sourcev1.IncludeUnavailableCondition, "NoArtifact", "No artifact available for include \"a\""), *conditions.TrueCondition(sourcev1.IncludeUnavailableCondition, "NoArtifact", "No artifact available for include 'a'"),
}, },
}, },
{ {
@ -898,7 +898,7 @@ func TestGitRepositoryReconciler_verifyCommitSignature(t *testing.T) {
}, },
want: ctrl.Result{RequeueAfter: interval}, want: ctrl.Result{RequeueAfter: interval},
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'"),
}, },
}, },
{ {
@ -920,7 +920,7 @@ func TestGitRepositoryReconciler_verifyCommitSignature(t *testing.T) {
}, },
wantErr: true, wantErr: true,
assertConditions: []metav1.Condition{ assertConditions: []metav1.Condition{
*conditions.FalseCondition(sourcev1.SourceVerifiedCondition, meta.FailedReason, "Signature verification of commit \"shasum\" failed: invalid signature"), *conditions.FalseCondition(sourcev1.SourceVerifiedCondition, meta.FailedReason, "Signature verification of commit 'shasum' failed: invalid signature"),
}, },
}, },
{ {