Skip to content

Commit 50419d7

Browse files
Merge pull request #445 from zhangtbj/refine_error_message
Change error messages start with a lower case letter
2 parents 5d391cd + 2359fd8 commit 50419d7

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

pkg/controller/build/build_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler) error
7070
if oldAnnot[build.AnnotationBuildRunDeletion] != newAnnot[build.AnnotationBuildRunDeletion] {
7171
ctxlog.Debug(
7272
ctx,
73-
"Updating predicated passed, the annotation was modified.",
73+
"updating predicated passed, the annotation was modified.",
7474
namespace,
7575
e.MetaNew.GetNamespace(),
7676
name,
@@ -172,7 +172,7 @@ func (r *ReconcileBuild) Reconcile(request reconcile.Request) (reconcile.Result,
172172
updateErr := r.client.Status().Update(ctx, b)
173173
return reconcile.Result{}, fmt.Errorf("errors: %v %v", err, updateErr)
174174
}
175-
ctxlog.Info(ctx, "build strategy found", namespace, b.Namespace, name, b.Name, "strategy", b.Spec.StrategyRef.Name)
175+
ctxlog.Info(ctx, "buildStrategy found", namespace, b.Namespace, name, b.Name, "strategy", b.Spec.StrategyRef.Name)
176176
}
177177

178178
// validate if "spec.runtime" attributes are valid
@@ -220,7 +220,7 @@ func (r *ReconcileBuild) validateStrategyRef(ctx context.Context, s *build.Strat
220220
return fmt.Errorf("unknown strategy %v", *s.Kind)
221221
}
222222
} else {
223-
ctxlog.Info(ctx, "BuildStrategy kind is nil, use default NamespacedBuildStrategyKind")
223+
ctxlog.Info(ctx, "buildStrategy kind is nil, use default NamespacedBuildStrategyKind")
224224
if err := r.validateBuildStrategy(ctx, s.Name, ns); err != nil {
225225
return err
226226
}
@@ -245,7 +245,7 @@ func (r *ReconcileBuild) validateBuildStrategy(ctx context.Context, n string, ns
245245
return nil
246246
}
247247
}
248-
return fmt.Errorf("BuildStrategy %s does not exist in namespace %s", n, ns)
248+
return fmt.Errorf("buildStrategy %s does not exist in namespace %s", n, ns)
249249
}
250250
return nil
251251
}

pkg/controller/build/build_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,13 @@ var _ = Describe("Reconcile Build", func() {
404404
return nil
405405
})
406406

407-
statusCall := ctl.StubFunc(corev1.ConditionFalse, fmt.Sprintf("BuildStrategy %s does not exist in namespace %s", buildStrategyName, namespace))
407+
statusCall := ctl.StubFunc(corev1.ConditionFalse, fmt.Sprintf("buildStrategy %s does not exist in namespace %s", buildStrategyName, namespace))
408408
statusWriter.UpdateCalls(statusCall)
409409

410410
_, err := reconciler.Reconcile(request)
411411
Expect(err).To(HaveOccurred())
412412
Expect(statusWriter.UpdateCallCount()).To(Equal(1))
413-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("BuildStrategy %s does not exist in namespace %s", buildStrategyName, namespace)))
413+
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("buildStrategy %s does not exist in namespace %s", buildStrategyName, namespace)))
414414
})
415415
It("succeed when the strategy exists", func() {
416416

@@ -483,13 +483,13 @@ var _ = Describe("Reconcile Build", func() {
483483
return nil
484484
})
485485

486-
statusCall := ctl.StubFunc(corev1.ConditionFalse, fmt.Sprintf("BuildStrategy %s does not exist in namespace %s", buildStrategyName, namespace))
486+
statusCall := ctl.StubFunc(corev1.ConditionFalse, fmt.Sprintf("buildStrategy %s does not exist in namespace %s", buildStrategyName, namespace))
487487
statusWriter.UpdateCalls(statusCall)
488488

489489
_, err := reconciler.Reconcile(request)
490490
Expect(err).To(HaveOccurred())
491491
Expect(statusWriter.UpdateCallCount()).To(Equal(1))
492-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("BuildStrategy %s does not exist in namespace %s", buildStrategyName, namespace)))
492+
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("buildStrategy %s does not exist in namespace %s", buildStrategyName, namespace)))
493493

494494
})
495495
It("default to BuildStrategy and succeed if the strategy exists", func() {

pkg/controller/buildrun/buildrun_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ func handleError(message string, listOfErrors ...error) error {
187187
// ValidateBuildRegistration verifies that a referenced Build is properly registered
188188
func (r *ReconcileBuildRun) ValidateBuildRegistration(ctx context.Context, build *buildv1alpha1.Build, buildRun *buildv1alpha1.BuildRun) error {
189189
if build.Status.Registered == "" {
190-
err := fmt.Errorf("The Build is not yet validated, build: %s", build.Name)
190+
err := fmt.Errorf("the Build is not yet validated, build: %s", build.Name)
191191
return err
192192
}
193193
if build.Status.Registered != corev1.ConditionTrue {
194-
err := fmt.Errorf("The Build is not registered correctly, build: %s, registered status: %s, reason: %s", build.Name, build.Status.Registered, build.Status.Reason)
194+
err := fmt.Errorf("the Build is not registered correctly, build: %s, registered status: %s, reason: %s", build.Name, build.Status.Registered, build.Status.Reason)
195195
updateErr := r.updateBuildRunErrorStatus(ctx, buildRun, err.Error())
196196
return handleError("Build is not ready", err, updateErr)
197197
}
@@ -324,7 +324,7 @@ func (r *ReconcileBuildRun) Reconcile(request reconcile.Request) (reconcile.Resu
324324
return reconcile.Result{}, err
325325
}
326326
} else {
327-
ctxlog.Info(ctx, "TaskRun already exists", namespace, request.Namespace, name, request.Name)
327+
ctxlog.Info(ctx, "taskRun already exists", namespace, request.Namespace, name, request.Name)
328328

329329
err = r.GetBuildRunObject(ctx, lastTaskRun.Labels[buildv1alpha1.LabelBuildRun], request.Namespace, buildRun)
330330
if err != nil && !apierrors.IsNotFound(err) {
@@ -338,7 +338,7 @@ func (r *ReconcileBuildRun) Reconcile(request reconcile.Request) (reconcile.Resu
338338
// finishes which would be missed otherwise. But, if the TaskRun was already completed and the status
339339
// synchronized into the BuildRun, then yet another reconciliation is not necessary.
340340
if buildRun.Status.CompletionTime != nil {
341-
ctxlog.Info(ctx, "BuildRun already marked completed", namespace, request.Namespace, name, request.Name)
341+
ctxlog.Info(ctx, "buildRun already marked completed", namespace, request.Namespace, name, request.Name)
342342
return reconcile.Result{}, nil
343343
}
344344

@@ -461,7 +461,7 @@ func (r *ReconcileBuildRun) retrieveServiceAccount(ctx context.Context, build *b
461461
if err != nil {
462462
return nil, err
463463
}
464-
ctxlog.Debug(ctx, "Automatic generation of service account", namespace, serviceAccount.Namespace, name, serviceAccount.Name, "Operation", op)
464+
ctxlog.Debug(ctx, "automatic generation of service account", namespace, serviceAccount.Namespace, name, serviceAccount.Name, "Operation", op)
465465
} else {
466466
// If ServiceAccount or the name of ServiceAccount in buildRun is nil, use pipeline serviceaccount
467467
if buildRun.Spec.ServiceAccount == nil || buildRun.Spec.ServiceAccount.Name == nil {
@@ -560,7 +560,7 @@ func (r *ReconcileBuildRun) createTaskRun(ctx context.Context, build *buildv1alp
560560
// Set OwnerReference for BuildRun and TaskRun
561561
if err := r.setOwnerReferenceFunc(buildRun, generatedTaskRun, r.scheme); err != nil {
562562
updateErr := r.updateBuildRunErrorStatus(ctx, buildRun, err.Error())
563-
return nil, handleError("Failed to set OwnerReference for BuildRun and TaskRun", err, updateErr)
563+
return nil, handleError("failed to set OwnerReference for BuildRun and TaskRun", err, updateErr)
564564
}
565565

566566
return generatedTaskRun, nil

pkg/controller/buildrun/buildrun_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ var _ = Describe("Reconcile BuildRun", func() {
648648

649649
_, err := reconciler.Reconcile(buildRunRequest)
650650
Expect(err).To(HaveOccurred())
651-
Expect(err.Error()).To(Equal(fmt.Sprintf("The Build is not yet validated, build: %s", buildName)))
651+
Expect(err.Error()).To(Equal(fmt.Sprintf("the Build is not yet validated, build: %s", buildName)))
652652
Expect(client.StatusCallCount()).To(Equal(0))
653653
})
654654

test/integration/build_to_buildruns_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ var _ = Describe("Integration tests Build and BuildRuns", func() {
221221
br, err := tb.GetBRTillCompletion(buildRunObject.Name)
222222
Expect(err).To(BeNil())
223223

224-
Expect(br.Status.Reason).To(Equal(fmt.Sprintf("The Build is not registered correctly, build: %s, registered status: False, reason: secret fake-secret does not exist", BUILD+tb.Namespace)))
224+
Expect(br.Status.Reason).To(Equal(fmt.Sprintf("the Build is not registered correctly, build: %s, registered status: False, reason: secret fake-secret does not exist", BUILD+tb.Namespace)))
225225
})
226226
})
227227

0 commit comments

Comments
 (0)