Skip to content

Commit

Permalink
Remove all occurrences of github.com/pkg/errors in our code. (#6070)
Browse files Browse the repository at this point in the history
* Remove all occurrences of github.com/pkg/errors in our code.

* Fix error code flow.
  • Loading branch information
markusthoemmes authored and knative-prow-robot committed Nov 24, 2019
1 parent 1cb31d1 commit 78673fa
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 34 deletions.
1 change: 0 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"context"
"errors"
"flag"
"fmt"
"net"
Expand All @@ -31,7 +32,6 @@ import (
"time"

"github.com/kelseyhightower/envconfig"
"github.com/pkg/errors"
"go.opencensus.io/plugin/ochttp"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
Expand Down
2 changes: 1 addition & 1 deletion pkg/autoscaler/http_scrape_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package autoscaler

import (
"errors"
"fmt"
"io"
"net/http"

"github.com/pkg/errors"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/autoscaler/stats_scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ limitations under the License.
package autoscaler

import (
"errors"
"fmt"
"net/http"
"sync"
"time"

"github.com/pkg/errors"
"golang.org/x/sync/errgroup"

av1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1"
Expand Down
3 changes: 1 addition & 2 deletions pkg/queue/readiness/probe_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ package readiness

import (
"encoding/json"

"github.com/pkg/errors"
"errors"

corev1 "k8s.io/api/core/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
package e2e

import (
"errors"
"fmt"
"math"
"net/http"
Expand All @@ -27,7 +28,6 @@ import (
"testing"
"time"

"github.com/pkg/errors"
vegeta "github.com/tsenart/vegeta/lib"
"golang.org/x/sync/errgroup"
"knative.dev/pkg/system"
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/subroutes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"testing"
"time"

"github.com/pkg/errors"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"knative.dev/pkg/network"
Expand Down Expand Up @@ -389,7 +387,7 @@ func isTrafficClusterLocal(tt []v1alpha1.TrafficTarget, tag string) (bool, error
return strings.HasSuffix(traffic.TrafficTarget.URL.Host, network.GetClusterDomainName()), nil
}
}
return false, errors.Errorf("Unable to find traffic target with tag %s", tag)
return false, fmt.Errorf("Unable to find traffic target with tag %s", tag)
}

func isRouteClusterLocal(rs v1alpha1.RouteStatus) bool {
Expand Down
16 changes: 8 additions & 8 deletions test/v1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"testing"

"github.com/mattbaird/jsonpatch"
"github.com/pkg/errors"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -172,7 +171,7 @@ func UpdateServiceRouteSpec(t *testing.T, clients *test.Clients, names test.Reso
// before returning the name of the revision.
func WaitForServiceLatestRevision(clients *test.Clients, names test.ResourceNames) (string, error) {
var revisionName string
err := WaitForServiceState(clients.ServingClient, names.Service, func(s *v1.Service) (bool, error) {
if err := WaitForServiceState(clients.ServingClient, names.Service, func(s *v1.Service) (bool, error) {
if s.Status.LatestCreatedRevisionName != names.Revision {
revisionName = s.Status.LatestCreatedRevisionName
// We also check that the revision is pinned, meaning it's not a stale revision.
Expand All @@ -184,15 +183,16 @@ func WaitForServiceLatestRevision(clients *test.Clients, names test.ResourceName
return true, nil
}
return false, nil
}, "ServiceUpdatedWithRevision")
if err != nil {
return "", errors.Wrapf(err, "LatestCreatedRevisionName not updated")
}, "ServiceUpdatedWithRevision"); err != nil {
return "", fmt.Errorf("LatestCreatedRevisionName not updated: %w", err)
}
err = WaitForServiceState(clients.ServingClient, names.Service, func(s *v1.Service) (bool, error) {
if err := WaitForServiceState(clients.ServingClient, names.Service, func(s *v1.Service) (bool, error) {
return (s.Status.LatestReadyRevisionName == revisionName), nil
}, "ServiceReadyWithRevision")
}, "ServiceReadyWithRevision"); err != nil {
return "", fmt.Errorf("LatestReadyRevisionName not updated with %s: %w", revisionName, err)
}

return revisionName, errors.Wrapf(err, "LatestReadyRevisionName not updated with %s", revisionName)
return revisionName, nil
}

// Service returns a Service object in namespace with the name names.Service
Expand Down
16 changes: 8 additions & 8 deletions test/v1alpha1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
"knative.dev/pkg/test/spoof"

"github.com/mattbaird/jsonpatch"
perrors "github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -302,7 +301,7 @@ func PatchServiceTemplateMetadata(t *testing.T, clients *test.Clients, svc *v1al
// before returning the name of the revision.
func WaitForServiceLatestRevision(clients *test.Clients, names test.ResourceNames) (string, error) {
var revisionName string
err := WaitForServiceState(clients.ServingAlphaClient, names.Service, func(s *v1alpha1.Service) (bool, error) {
if err := WaitForServiceState(clients.ServingAlphaClient, names.Service, func(s *v1alpha1.Service) (bool, error) {
if s.Status.LatestCreatedRevisionName != names.Revision {
revisionName = s.Status.LatestCreatedRevisionName
// We also check that the revision is pinned, meaning it's not a stale revision.
Expand All @@ -314,15 +313,16 @@ func WaitForServiceLatestRevision(clients *test.Clients, names test.ResourceName
return true, nil
}
return false, nil
}, "ServiceUpdatedWithRevision")
if err != nil {
return "", perrors.Wrapf(err, "LatestCreatedRevisionName not updated")
}, "ServiceUpdatedWithRevision"); err != nil {
return "", fmt.Errorf("LatestCreatedRevisionName not updated: %w", err)
}
err = WaitForServiceState(clients.ServingAlphaClient, names.Service, func(s *v1alpha1.Service) (bool, error) {
if err := WaitForServiceState(clients.ServingAlphaClient, names.Service, func(s *v1alpha1.Service) (bool, error) {
return (s.Status.LatestReadyRevisionName == revisionName), nil
}, "ServiceReadyWithRevision")
}, "ServiceReadyWithRevision"); err != nil {
return "", fmt.Errorf("LatestReadyRevisionName not updated with %s: %w", revisionName, err)
}

return revisionName, perrors.Wrapf(err, "LatestReadyRevisionName not updated with %s", revisionName)
return revisionName, nil
}

// LatestService returns a Service object in namespace with the name names.Service
Expand Down
16 changes: 8 additions & 8 deletions test/v1beta1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"testing"

"github.com/mattbaird/jsonpatch"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -171,7 +170,7 @@ func UpdateServiceRouteSpec(t *testing.T, clients *test.Clients, names test.Reso
// before returning the name of the revision.
func WaitForServiceLatestRevision(clients *test.Clients, names test.ResourceNames) (string, error) {
var revisionName string
err := WaitForServiceState(clients.ServingBetaClient, names.Service, func(s *v1beta1.Service) (bool, error) {
if err := WaitForServiceState(clients.ServingBetaClient, names.Service, func(s *v1beta1.Service) (bool, error) {
if s.Status.LatestCreatedRevisionName != names.Revision {
revisionName = s.Status.LatestCreatedRevisionName
// We also check that the revision is pinned, meaning it's not a stale revision.
Expand All @@ -183,15 +182,16 @@ func WaitForServiceLatestRevision(clients *test.Clients, names test.ResourceName
return true, nil
}
return false, nil
}, "ServiceUpdatedWithRevision")
if err != nil {
return "", errors.Wrapf(err, "LatestCreatedRevisionName not updated")
}, "ServiceUpdatedWithRevision"); err != nil {
return "", fmt.Errorf("LatestCreatedRevisionName not updated: %w", err)
}
err = WaitForServiceState(clients.ServingBetaClient, names.Service, func(s *v1beta1.Service) (bool, error) {
if err := WaitForServiceState(clients.ServingBetaClient, names.Service, func(s *v1beta1.Service) (bool, error) {
return (s.Status.LatestReadyRevisionName == revisionName), nil
}, "ServiceReadyWithRevision")
}, "ServiceReadyWithRevision"); err != nil {
return "", fmt.Errorf("LatestReadyRevisionName not updated with %s: %w", revisionName, err)
}

return revisionName, errors.Wrapf(err, "LatestReadyRevisionName not updated with %s", revisionName)
return revisionName, nil
}

// Service returns a Service object in namespace with the name names.Service
Expand Down

0 comments on commit 78673fa

Please sign in to comment.