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

chore: use errors.New to replace fmt.Errorf with no parameters will much better #28729

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/extended/deployments/deployments.go
Expand Up @@ -1547,7 +1547,7 @@ var _ = g.Describe("[sig-apps][Feature:DeploymentConfig] deploymentconfigs", fun
case appsv1.DeploymentStatusComplete:
return true, nil
case appsv1.DeploymentStatusFailed:
return true, fmt.Errorf("deployment #1 failed")
return true, errors.New("deployment #1 failed")
default:
return false, nil
}
Expand Down Expand Up @@ -1688,7 +1688,7 @@ var _ = g.Describe("[sig-apps][Feature:DeploymentConfig] deploymentconfigs", fun
e2e.Logf("wait: LatestVersion: %d", e.Object.(*appsv1.DeploymentConfig).Status.LatestVersion)
return evDC.Status.LatestVersion == 2 && evDC.Status.AvailableReplicas == evDC.Spec.Replicas, nil
case watch.Deleted:
return true, fmt.Errorf("dc deleted while waiting for latestVersion to be raised")
return true, errors.New("dc deleted while waiting for latestVersion to be raised")
case watch.Error:
return true, kerrors.FromObject(e.Object)
default:
Expand All @@ -1711,7 +1711,7 @@ var _ = g.Describe("[sig-apps][Feature:DeploymentConfig] deploymentconfigs", fun
evDC := e.Object.(*appsv1.DeploymentConfig)
return evDC.Status.AvailableReplicas == evDC.Spec.Replicas, nil
case watch.Deleted:
return true, fmt.Errorf("dc deleted while waiting for latestVersion to be raised")
return true, errors.New("dc deleted while waiting for latestVersion to be raised")
case watch.Error:
return true, kerrors.FromObject(e.Object)
default:
Expand Down
9 changes: 5 additions & 4 deletions test/extended/deployments/util.go
Expand Up @@ -2,6 +2,7 @@ package deployments

import (
"context"
"errors"
"fmt"
"io/ioutil"
"reflect"
Expand Down Expand Up @@ -240,7 +241,7 @@ func deploymentReachedCompletion(dc *appsv1.DeploymentConfig, rcs []*corev1.Repl
return false, fmt.Errorf("deployment is complete but doesn't have expected spec replicas: %d %d", *rc.Spec.Replicas, *expectedReplicas)
}
if expectedReplicas == nil {
return false, fmt.Errorf("expectedReplicas should not be nil")
return false, errors.New("expectedReplicas should not be nil")
}
if rc.Status.Replicas != *expectedReplicas {
e2e.Logf("POSSIBLE_ANOMALY: deployment is complete but doesn't have expected status replicas: %d %d", rc.Status.Replicas, *expectedReplicas)
Expand Down Expand Up @@ -426,7 +427,7 @@ func WaitForDeployerToComplete(oc *exutil.CLI, name string, timeout time.Duratio

func isControllerRefChange(controllee metav1.Object, old *metav1.OwnerReference) (bool, error) {
if old != nil && old.Controller != nil && *old.Controller == false {
return false, fmt.Errorf("old ownerReference is not a controllerRef")
return false, errors.New("old ownerReference is not a controllerRef")
}
return !reflect.DeepEqual(old, metav1.GetControllerOf(controllee)), nil
}
Expand All @@ -445,7 +446,7 @@ func rCConditionFromMeta(condition func(metav1.Object) (bool, error)) func(rc *c

func waitForRCChange(ctx context.Context, client corev1client.CoreV1Interface, namespace string, name string, resourceVersion string, condition func(rc *corev1.ReplicationController) (bool, error)) (*corev1.ReplicationController, error) {
if len(resourceVersion) == 0 {
return nil, fmt.Errorf("watch requires initial resource version")
return nil, errors.New("watch requires initial resource version")
}

w := &cache.ListWatch{
Expand Down Expand Up @@ -496,7 +497,7 @@ func waitForRCState(ctx context.Context, client corev1client.CoreV1Interface, na

func waitForDCModification(ctx context.Context, client appstypedclient.AppsV1Interface, namespace string, name string, resourceVersion string, condition func(dc *appsv1.DeploymentConfig) (bool, error)) (*appsv1.DeploymentConfig, error) {
if len(resourceVersion) == 0 {
return nil, fmt.Errorf("watch requires initial resource version")
return nil, errors.New("watch requires initial resource version")
}

w := &cache.ListWatch{
Expand Down
5 changes: 3 additions & 2 deletions test/extended/imageapis/imagesigning.go
Expand Up @@ -3,6 +3,7 @@ package imageapis
import (
"bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"reflect"
Expand Down Expand Up @@ -296,10 +297,10 @@ func compareSignatures(t g.GinkgoTInterface, a, b imagev1.ImageSignature) {
// joinImageSignatureName joins image name and custom signature name into one string with @ separator.
func joinImageSignatureName(imageName, signatureName string) (string, error) {
if len(imageName) == 0 {
return "", fmt.Errorf("imageName may not be empty")
return "", errors.New("imageName may not be empty")
}
if len(signatureName) == 0 {
return "", fmt.Errorf("signatureName may not be empty")
return "", errors.New("signatureName may not be empty")
}
if strings.Count(imageName, "@") > 0 || strings.Count(signatureName, "@") > 0 {
return "", fmt.Errorf("neither imageName nor signatureName can contain '@'")
Expand Down
3 changes: 2 additions & 1 deletion test/extended/networking/cnimigration.go
Expand Up @@ -2,6 +2,7 @@ package networking

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -145,7 +146,7 @@ func migrateCNI(ctx context.Context, c configv1client.Interface, config *restcli
if inProgress, err := isMigrationInProgressTrue(ctx, c); err != nil {
return err
} else if inProgress {
return fmt.Errorf("migration is already in-progress")
return errors.New("migration is already in-progress")
}
if isDeployed, err := isCNIDeployed(ctx, c, targetCNI); err != nil {
return err
Expand Down