Skip to content

Commit

Permalink
Address staticcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1queee committed Oct 19, 2020
1 parent 49f647c commit f3a32b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
10 changes: 3 additions & 7 deletions pkg/controller/buildrun/buildrun_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler) error

// The CreateFunc is also called when the controller is started and iterates over all objects. For those BuildRuns that have a TaskRun referenced already,
// we do not need to do a further reconciliation. BuildRun updates then only happen from the TaskRun.
if o.Status.LatestTaskRunRef != nil {
return false
}

return true
return o.Status.LatestTaskRunRef == nil
},
UpdateFunc: func(e event.UpdateEvent) bool {
// Ignore updates to CR status in which case metadata.Generation does not change
Expand Down Expand Up @@ -187,11 +183,11 @@ func handleError(message string, listOfErrors ...error) error {
// ValidateBuildRegistration verifies that a referenced Build is properly registered
func (r *ReconcileBuildRun) ValidateBuildRegistration(ctx context.Context, build *buildv1alpha1.Build, buildRun *buildv1alpha1.BuildRun) error {
if build.Status.Registered == "" {
err := fmt.Errorf("The Build is not yet validated, build: %s", build.Name)
err := fmt.Errorf("the Build is not yet validated, build: %s", build.Name)
return err
}
if build.Status.Registered != corev1.ConditionTrue {
err := fmt.Errorf("The Build is not registered correctly, build: %s, registered status: %s, reason: %s", build.Name, build.Status.Registered, build.Status.Reason)
err := fmt.Errorf("the Build is not registered correctly, build: %s, registered status: %s, reason: %s", build.Name, build.Status.Registered, build.Status.Reason)
updateErr := r.updateBuildRunErrorStatus(ctx, buildRun, err.Error())
return handleError("Build is not ready", err, updateErr)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/buildrun/buildrun_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ var _ = Describe("Reconcile BuildRun", func() {

_, err := reconciler.Reconcile(buildRunRequest)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("\"default\" not found, msg: Failed to choose a service account to use")))
Expect(err.Error()).To(ContainSubstring("\"default\" not found, msg: Failed to choose a service account to use"))
})

It("fails on a TaskRun creation due to missing namespaced buildstrategy", func() {
Expand Down Expand Up @@ -489,7 +489,7 @@ var _ = Describe("Reconcile BuildRun", func() {

_, err := reconciler.Reconcile(buildRunRequest)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf(" Unsupported BuildStrategy Kind")))
Expect(err.Error()).To(ContainSubstring(" Unsupported BuildStrategy Kind"))
})

It("only generates the service account once if the taskRun cannot be created", func() {
Expand Down
7 changes: 3 additions & 4 deletions test/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

. "github.com/onsi/gomega"
build "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -284,7 +283,7 @@ func (c *Catalog) StubBuildStatusReason(reason string) func(context context.Cont
switch object := object.(type) {
case *build.Build:
if object.Status.Reason != "" {
Expect(*&object.Status.Reason).To(Equal(reason))
Expect(object.Status.Reason).To(Equal(reason))
}
}
return nil
Expand Down Expand Up @@ -565,7 +564,7 @@ func (c *Catalog) BuildWithBuildRunDeletions(buildName string, strategyName stri
return &build.Build{
ObjectMeta: metav1.ObjectMeta{
Name: buildName,
Annotations: map[string]string{buildv1alpha1.AnnotationBuildRunDeletion: "true"},
Annotations: map[string]string{build.AnnotationBuildRunDeletion: "true"},
},
Spec: build.BuildSpec{
StrategyRef: &build.StrategyRef{
Expand All @@ -586,7 +585,7 @@ func (c *Catalog) BuildWithBuildRunDeletionsAndFakeNS(buildName string, strategy
ObjectMeta: metav1.ObjectMeta{
Name: buildName,
Namespace: "fakens",
Annotations: map[string]string{buildv1alpha1.AnnotationBuildRunDeletion: "true"},
Annotations: map[string]string{build.AnnotationBuildRunDeletion: "true"},
},
Spec: build.BuildSpec{
StrategyRef: &build.StrategyRef{
Expand Down

0 comments on commit f3a32b5

Please sign in to comment.