Merge pull request #120397 from ty-dc/StaticCheck

cleanup: omit comparison with bool constants
This commit is contained in:
Kubernetes Prow Robot
2023-10-24 05:25:52 +02:00
committed by GitHub
33 changed files with 57 additions and 57 deletions

View File

@@ -726,7 +726,7 @@ func (v *podStartVerifier) Verify(event watch.Event) error {
}
if status := e2epod.FindContainerStatusInPod(pod, "blocked"); status != nil {
if (status.Started != nil && *status.Started == true) || status.LastTerminationState.Terminated != nil || status.State.Waiting == nil {
if (status.Started != nil && *status.Started) || status.LastTerminationState.Terminated != nil || status.State.Waiting == nil {
return fmt.Errorf("pod %s on node %s should not have started the blocked container: %#v", pod.Name, pod.Spec.NodeName, status)
}
}

View File

@@ -196,15 +196,15 @@ func verifyDiskFormat(ctx context.Context, client clientset.Interface, nodeName
}
isDiskFormatCorrect := false
if diskFormat == "eagerzeroedthick" {
if eagerlyScrub == true && thinProvisioned == false {
if eagerlyScrub && !thinProvisioned {
isDiskFormatCorrect = true
}
} else if diskFormat == "zeroedthick" {
if eagerlyScrub == false && thinProvisioned == false {
if !eagerlyScrub && !thinProvisioned {
isDiskFormatCorrect = true
}
} else if diskFormat == "thin" {
if eagerlyScrub == false && thinProvisioned == true {
if !eagerlyScrub && thinProvisioned {
isDiskFormatCorrect = true
}
}

View File

@@ -432,9 +432,9 @@ func TestMatchConditions(t *testing.T) {
for _, pod := range testcase.pods {
_, err := client.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, dryRunCreate)
if testcase.expectErrorPod == false && err != nil {
if !testcase.expectErrorPod && err != nil {
t.Fatalf("unexpected error creating test pod: %v", err)
} else if testcase.expectErrorPod == true && err == nil {
} else if testcase.expectErrorPod && err == nil {
t.Fatal("expected error creating pods")
}
}

View File

@@ -430,9 +430,9 @@ func TestEvictionWithFinalizers(t *testing.T) {
t.Fatalf("Failed to get the pod %q with error: %q", klog.KObj(pod), e)
}
_, cond := podutil.GetPodCondition(&updatedPod.Status, v1.PodConditionType(v1.DisruptionTarget))
if tc.wantDisruptionTargetCond == true && cond == nil {
if tc.wantDisruptionTargetCond && cond == nil {
t.Errorf("Pod %q does not have the expected condition: %q", klog.KObj(updatedPod), v1.DisruptionTarget)
} else if tc.wantDisruptionTargetCond == false && cond != nil {
} else if !tc.wantDisruptionTargetCond && cond != nil {
t.Errorf("Pod %q has an unexpected condition: %q", klog.KObj(updatedPod), v1.DisruptionTarget)
}
})

View File

@@ -163,9 +163,9 @@ func TestEvictionForNoExecuteTaintAddedByUser(t *testing.T) {
t.Fatalf("Test Failed: error: %q, while getting updated pod", err)
}
_, cond := podutil.GetPodCondition(&testPod.Status, v1.DisruptionTarget)
if test.enablePodDisruptionConditions == true && cond == nil {
if test.enablePodDisruptionConditions && cond == nil {
t.Errorf("Pod %q does not have the expected condition: %q", klog.KObj(testPod), v1.DisruptionTarget)
} else if test.enablePodDisruptionConditions == false && cond != nil {
} else if !test.enablePodDisruptionConditions && cond != nil {
t.Errorf("Pod %q has an unexpected condition: %q", klog.KObj(testPod), v1.DisruptionTarget)
}
})

View File

@@ -513,7 +513,7 @@ func TestPreemption(t *testing.T) {
t.Errorf("Error %v when getting the updated status for pod %v/%v ", err, p.Namespace, p.Name)
}
_, cond := podutil.GetPodCondition(&pod.Status, v1.DisruptionTarget)
if test.enablePodDisruptionConditions == true && cond == nil {
if test.enablePodDisruptionConditions && cond == nil {
t.Errorf("Pod %q does not have the expected condition: %q", klog.KObj(pod), v1.DisruptionTarget)
} else if test.enablePodDisruptionConditions == false && cond != nil {
t.Errorf("Pod %q has an unexpected condition: %q", klog.KObj(pod), v1.DisruptionTarget)

View File

@@ -111,7 +111,7 @@ func TestUnschedulableNodes(t *testing.T) {
// Nodes that are unschedulable or that are not ready or
// have their disk full (Node.Spec.Conditions) are excluded
// based on NodeConditionPredicate, a separate check
return node != nil && node.(*v1.Node).Spec.Unschedulable == true
return node != nil && node.(*v1.Node).Spec.Unschedulable
})
if err != nil {
t.Fatalf("Failed to observe reflected update for setting unschedulable=true: %v", err)

View File

@@ -79,9 +79,9 @@ func runTestAPICiphers(t *testing.T, testID int, kubePort int, clientCiphers []u
defer resp.Body.Close()
}
if expectedError == true && err == nil {
if expectedError && err == nil {
t.Fatalf("%d: expecting error for cipher test, client cipher is supported and it should't", testID)
} else if err != nil && expectedError == false {
} else if err != nil && !expectedError {
t.Fatalf("%d: not expecting error by client with cipher failed: %+v", testID, err)
}
}