Remove github.com/pkg/errors with appropriate replacements (#3172)

* errors.Wrap* removal

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* remove errors.Errorf

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Remove remaining calls

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Few more errors

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Fix golint errors

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

---------

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2025-02-20 08:58:37 +05:30
committed by GitHub
parent 2fd44174ce
commit caffed92f4
113 changed files with 585 additions and 588 deletions
+6 -6
View File
@@ -17,10 +17,10 @@ limitations under the License.
package canaryconfig
import (
"errors"
"fmt"
"time"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fv1 "github.com/fission/fission/pkg/apis/core/v1"
@@ -57,7 +57,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
_, fnNs, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
if err != nil {
return errors.Wrap(err, "error in creating canaryconfig")
return fmt.Errorf("error in creating canaryconfig: %w", err)
}
incrementStep := input.Int(flagkey.CanaryWeightIncrement)
failureThreshold := input.Int(flagkey.CanaryFailureThreshold)
@@ -66,13 +66,13 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
// check for time parsing
_, err = time.ParseDuration(incrementInterval)
if err != nil {
return errors.Wrap(err, "error parsing time duration")
return fmt.Errorf("error parsing time duration: %w", err)
}
// check that the trigger exists in the same namespace.
htTrigger, err := opts.Client().FissionClientSet.CoreV1().HTTPTriggers(fnNs).Get(input.Context(), ht, metav1.GetOptions{})
if err != nil {
return errors.Wrap(err, "error finding http trigger referenced in the canary config")
return fmt.Errorf("error finding http trigger referenced in the canary config: %w", err)
}
// check that the trigger has function reference type function weights
@@ -95,7 +95,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
fnList := []string{newFunc, oldFunc}
err = util.CheckFunctionExistence(input.Context(), opts.Client(), fnList, fnNs)
if err != nil {
return errors.Wrap(err, "error checking functions existence")
return fmt.Errorf("error checking functions existence: %w", err)
}
// finally create canaryCfg in the same namespace as the functions referenced
@@ -124,7 +124,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
func (opts *CreateSubCommand) run(input cli.Input) error {
_, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.canary.ObjectMeta.Namespace).Create(input.Context(), opts.canary, metav1.CreateOptions{})
if err != nil {
return errors.Wrap(err, "error creating canary config")
return fmt.Errorf("error creating canary config: %w", err)
}
fmt.Printf("canary config '%s' created\n", opts.canary.ObjectMeta.Name)
+2 -3
View File
@@ -19,7 +19,6 @@ package canaryconfig
import (
"fmt"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
@@ -39,7 +38,7 @@ func Delete(input cli.Input) error {
func (opts *DeleteSubCommand) run(input cli.Input) (err error) {
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
if err != nil {
return errors.Wrap(err, "error in deleting canaryConfig ")
return fmt.Errorf("error in deleting canaryConfig: %w", err)
}
err = opts.Client().FissionClientSet.CoreV1().CanaryConfigs(namespace).Delete(input.Context(), input.String(flagkey.CanaryName), metav1.DeleteOptions{})
@@ -47,7 +46,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) (err error) {
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
return nil
}
return errors.Wrap(err, "error deleting canary config")
return fmt.Errorf("error deleting canary config: %w", err)
}
fmt.Printf("canaryconfig '%v.%v' deleted\n", input.String(flagkey.CanaryName), namespace)
+2 -3
View File
@@ -21,7 +21,6 @@ import (
"os"
"text/tabwriter"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
@@ -41,12 +40,12 @@ func (opts *GetSubCommand) run(input cli.Input) (err error) {
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
if err != nil {
return errors.Wrap(err, "error getting canary config")
return fmt.Errorf("error getting canary config: %w", err)
}
canaryCfg, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(namespace).Get(input.Context(), input.String(flagkey.CanaryName), metav1.GetOptions{})
if err != nil {
return errors.Wrap(err, "error getting canary config")
return fmt.Errorf("error getting canary config: %w", err)
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
+2 -3
View File
@@ -21,7 +21,6 @@ import (
"os"
"text/tabwriter"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
@@ -49,7 +48,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
func (opts *ListSubCommand) complete(input cli.Input) (err error) {
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
if err != nil {
return errors.Wrap(err, "error in listing canary config ")
return fmt.Errorf("error in listing canary config: %w", err)
}
return nil
}
@@ -62,7 +61,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
canaryCfgs, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.namespace).List(input.Context(), metav1.ListOptions{})
if err != nil {
return errors.Wrap(err, "error listing canary config")
return fmt.Errorf("error listing canary config: %w", err)
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
+4 -5
View File
@@ -20,7 +20,6 @@ import (
"fmt"
"time"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fv1 "github.com/fission/fission/pkg/apis/core/v1"
@@ -50,7 +49,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
// get the current config
_, ns, err := opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
if err != nil {
return errors.Wrap(err, "error updating canary config")
return fmt.Errorf("error updating canary config: %w", err)
}
incrementStep := input.Int(flagkey.CanaryWeightIncrement)
failureThreshold := input.Int(flagkey.CanaryFailureThreshold)
@@ -59,12 +58,12 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
// check for time parsing
_, err = time.ParseDuration(incrementInterval)
if err != nil {
return errors.Wrap(err, "error parsing time duration")
return fmt.Errorf("error parsing time duration: %w", err)
}
canaryCfg, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(ns).Get(input.Context(), input.String(flagkey.CanaryName), metav1.GetOptions{})
if err != nil {
return errors.Wrap(err, "error getting canary config")
return fmt.Errorf("error getting canary config: %w", err)
}
var updateNeeded bool
@@ -93,7 +92,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
func (opts *UpdateSubCommand) run(input cli.Input) error {
_, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.canary.ObjectMeta.Namespace).Update(input.Context(), opts.canary, metav1.UpdateOptions{})
if err != nil {
return errors.Wrap(err, "error updating canary config")
return fmt.Errorf("error updating canary config: %w", err)
}
fmt.Printf("canary config '%v' updated\n", opts.canary.ObjectMeta.Name)
return nil