Skip to content

chore: use errors.New to replace fmt.Errorf with no parameters #12958

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiclient

import (
"context"
"errors"
"fmt"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -67,16 +68,16 @@ func NewClientFromOpts(opts Opts) (context.Context, Client, error) {
return newOfflineClient(opts.OfflineFiles)
}
if opts.ArgoServerOpts.URL != "" && opts.InstanceID != "" {
return nil, nil, fmt.Errorf("cannot use instance ID with Argo Server")
return nil, nil, errors.New("cannot use instance ID with Argo Server")
}
if opts.ArgoServerOpts.HTTP1 {
if opts.AuthSupplier == nil {
return nil, nil, fmt.Errorf("AuthSupplier cannot be empty when connecting to Argo Server")
return nil, nil, errors.New("AuthSupplier cannot be empty when connecting to Argo Server")
}
return newHTTP1Client(opts.ArgoServerOpts.GetURL(), opts.AuthSupplier(), opts.ArgoServerOpts.InsecureSkipVerify, opts.ArgoServerOpts.Headers, opts.ArgoServerOpts.HTTP1Client)
} else if opts.ArgoServerOpts.URL != "" {
if opts.AuthSupplier == nil {
return nil, nil, fmt.Errorf("AuthSupplier cannot be empty when connecting to Argo Server")
return nil, nil, errors.New("AuthSupplier cannot be empty when connecting to Argo Server")
}
return newArgoServerClient(opts.ArgoServerOpts, opts.AuthSupplier())
} else {
Expand Down
3 changes: 2 additions & 1 deletion pkg/apiclient/offline-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiclient

import (
"context"
"errors"
"fmt"

"github.com/argoproj/argo-workflows/v3/pkg/apiclient/clusterworkflowtemplate"
Expand Down Expand Up @@ -36,7 +37,7 @@ type offlineClient struct {
namespacedWorkflowTemplateGetterMap offlineWorkflowTemplateGetterMap
}

var OfflineErr = fmt.Errorf("not supported when you are in offline mode")
var OfflineErr = errors.New("not supported when you are in offline mode")

var _ Client = &offlineClient{}

Expand Down
9 changes: 5 additions & 4 deletions pkg/plugins/spec/plugin_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package spec

import (
"errors"
"fmt"

apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -33,16 +34,16 @@ type Sidecar struct {
func (s Sidecar) Validate() error {
c := s.Container
if len(c.Ports) < 1 {
return fmt.Errorf("at least one port is mandatory")
return errors.New("at least one port is mandatory")
}
if c.Resources.Requests == nil {
return fmt.Errorf("resources requests are mandatory")
return errors.New("resources requests are mandatory")
}
if c.Resources.Limits == nil {
return fmt.Errorf("resources limits are mandatory")
return errors.New("resources limits are mandatory")
}
if c.SecurityContext == nil {
return fmt.Errorf("security context is mandatory")
return errors.New("security context is mandatory")
}
return nil
}
Loading