Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect use of format strings with the conditions package. #598

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions internal/controller/imagepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (r *ImagePolicyReconciler) reconcile(ctx context.Context, sp *patch.SerialP
// watched by this reconciler, like the namespace that ImageRepository
// allows access from.
e := fmt.Errorf("failed to get the referred ImageRepository: %w", err)
conditions.MarkFalse(obj, meta.ReadyCondition, reason, e.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, reason, "%s", e)
result, retErr = ctrl.Result{}, e
return
}
Expand All @@ -296,19 +296,19 @@ func (r *ImagePolicyReconciler) reconcile(ctx context.Context, sp *patch.SerialP
if err != nil {
// Stall if it's an invalid policy.
if _, ok := err.(errInvalidPolicy); ok {
conditions.MarkStalled(obj, "InvalidPolicy", err.Error())
conditions.MarkStalled(obj, "InvalidPolicy", "%s", err)
result, retErr = ctrl.Result{}, nil
return
}

// If there's no tag in the database, mark not ready and retry.
if err == errNoTagsInDatabase {
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.DependencyNotReadyReason, err.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.DependencyNotReadyReason, "%s", err)
result, retErr = ctrl.Result{}, err
return
}

conditions.MarkFalse(obj, meta.ReadyCondition, metav1.StatusFailure, err.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, metav1.StatusFailure, "%s", err)
result, retErr = ctrl.Result{}, err
return
}
Expand All @@ -330,7 +330,7 @@ func (r *ImagePolicyReconciler) reconcile(ctx context.Context, sp *patch.SerialP
prevRef, err := name.NewTag(obj.Status.ObservedPreviousImage)
if err != nil {
e := fmt.Errorf("failed to parse previous image '%s': %w", obj.Status.ObservedPreviousImage, err)
conditions.MarkFalse(obj, meta.ReadyCondition, meta.FailedReason, e.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, meta.FailedReason, "%s", e)
result, retErr = ctrl.Result{}, e
}
previousTag = prevRef.TagStr()
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/imagerepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
// Parse image reference.
ref, err := parseImageReference(obj.Spec.Image, obj.Spec.Insecure)
if err != nil {
conditions.MarkStalled(obj, imagev1.ImageURLInvalidReason, err.Error())
conditions.MarkStalled(obj, imagev1.ImageURLInvalidReason, "%s", err)
result, retErr = ctrl.Result{}, nil
return
}
Expand All @@ -260,7 +260,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
opts, err := r.setAuthOptions(ctx, obj, ref)
if err != nil {
e := fmt.Errorf("failed to configure authentication options: %w", err)
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.AuthenticationFailedReason, e.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.AuthenticationFailedReason, "%s", e)
result, retErr = ctrl.Result{}, e
return
}
Expand All @@ -269,7 +269,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
ok, when, reasonMsg, err := r.shouldScan(*obj, startTime)
if err != nil {
e := fmt.Errorf("failed to determine if it's scan time: %w", err)
conditions.MarkFalse(obj, meta.ReadyCondition, metav1.StatusFailure, e.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, metav1.StatusFailure, "%s", e)
result, retErr = ctrl.Result{}, e
return
}
Expand All @@ -286,7 +286,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
tags, err := r.scan(ctx, obj, ref, opts)
if err != nil {
e := fmt.Errorf("scan failed: %w", err)
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.ReadOperationFailedReason, e.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.ReadOperationFailedReason, "%s", e)
result, retErr = ctrl.Result{}, e
return
}
Expand Down