From cbea028aa6c9e5ee22dbec5d310d007aaa171e89 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 25 Mar 2020 08:50:48 -0400 Subject: [PATCH] Appease lint: unnecessary use of Sprintf and possible nil pointer dereference --- pkg/reconciler/pipelinerun/pipelinerun_test.go | 10 +++++----- pkg/reconciler/taskrun/taskrun.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index e49920ae973..5e9b1eebbe1 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -942,11 +942,11 @@ func TestReconcileWithTimeout(t *testing.T) { actual := clients.Pipeline.Actions()[0].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) if actual == nil { t.Errorf("Expected a TaskRun to be created, but it wasn't.") - } - - // The TaskRun timeout should be less than or equal to the PipelineRun timeout. - if actual.Spec.Timeout.Duration > prs[0].Spec.Timeout.Duration { - t.Errorf("TaskRun timeout %s should be less than or equal to PipelineRun timeout %s", actual.Spec.Timeout.Duration.String(), prs[0].Spec.Timeout.Duration.String()) + } else { + // The TaskRun timeout should be less than or equal to the PipelineRun timeout. + if actual.Spec.Timeout.Duration > prs[0].Spec.Timeout.Duration { + t.Errorf("TaskRun timeout %s should be less than or equal to PipelineRun timeout %s", actual.Spec.Timeout.Duration.String(), prs[0].Spec.Timeout.Duration.String()) + } } } diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index 0a75ca3e8e6..7e1211d3dec 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -431,7 +431,7 @@ func (c *Reconciler) handlePodCreationError(tr *v1alpha1.TaskRun, err error) { if tr.Spec.TaskRef != nil { msg = fmt.Sprintf("Missing or invalid Task %s/%s", tr.Namespace, tr.Spec.TaskRef.Name) } else { - msg = fmt.Sprintf("Invalid TaskSpec") + msg = "Invalid TaskSpec" } } tr.Status.SetCondition(&apis.Condition{