diff --git a/Gopkg.lock b/Gopkg.lock index 921dfa7472a..51e24921b1c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -777,17 +777,6 @@ pruneopts = "NUT" revision = "66487607e2081c7c2af2281c62c14ee000d5024b" -[[projects]] - branch = "master" - digest = "1:da4baf48e12c5766130e8ec8ae5058cb3b5e8b533606c75340f7fb59604a4018" - name = "golang.org/x/xerrors" - packages = [ - ".", - "internal", - ] - pruneopts = "NUT" - revision = "a985d3407aa71f30cf86696ee0a2f409709f22e1" - [[projects]] branch = "master" digest = "1:ef0144000c413fdaab3f94116a11e6a2e3994fcb085b052ecf01fcb312e99a13" @@ -1380,7 +1369,6 @@ "go.uber.org/zap/zaptest", "go.uber.org/zap/zaptest/observer", "golang.org/x/oauth2", - "golang.org/x/xerrors", "k8s.io/api/apps/v1", "k8s.io/api/core/v1", "k8s.io/api/rbac/v1beta1", diff --git a/cmd/entrypoint/waiter.go b/cmd/entrypoint/waiter.go index 7b263238a28..deb5051c683 100644 --- a/cmd/entrypoint/waiter.go +++ b/cmd/entrypoint/waiter.go @@ -1,11 +1,11 @@ package main import ( + "fmt" "os" "time" "github.com/tektoncd/pipeline/pkg/entrypoint" - "golang.org/x/xerrors" ) // realWaiter actually waits for files, by polling. @@ -32,7 +32,7 @@ func (*realWaiter) Wait(file string, expectContent bool) error { return nil } } else if !os.IsNotExist(err) { - return xerrors.Errorf("Waiting for %q: %w", file, err) + return fmt.Errorf("Waiting for %q: %w", file, err) } if _, err := os.Stat(file + ".err"); err == nil { return skipError("error file present, bail and skip the step") diff --git a/pkg/apis/pipeline/v1alpha1/build_gcs_resource.go b/pkg/apis/pipeline/v1alpha1/build_gcs_resource.go index 4b6ef54179e..cf42eb0f0c4 100644 --- a/pkg/apis/pipeline/v1alpha1/build_gcs_resource.go +++ b/pkg/apis/pipeline/v1alpha1/build_gcs_resource.go @@ -22,7 +22,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -72,10 +71,10 @@ type BuildGCSResource struct { // NewBuildGCSResource creates a new BuildGCS resource to pass to a Task. func NewBuildGCSResource(images pipeline.Images, r *PipelineResource) (*BuildGCSResource, error) { if r.Spec.Type != PipelineResourceTypeStorage { - return nil, xerrors.Errorf("BuildGCSResource: Cannot create a BuildGCS resource from a %s Pipeline Resource", r.Spec.Type) + return nil, fmt.Errorf("BuildGCSResource: Cannot create a BuildGCS resource from a %s Pipeline Resource", r.Spec.Type) } if r.Spec.SecretParams != nil { - return nil, xerrors.Errorf("BuildGCSResource: %s cannot support artifacts on private bucket", r.Name) + return nil, fmt.Errorf("BuildGCSResource: %s cannot support artifacts on private bucket", r.Name) } var location string var aType GCSArtifactType @@ -87,15 +86,15 @@ func NewBuildGCSResource(images pipeline.Images, r *PipelineResource) (*BuildGCS var err error aType, err = getArtifactType(param.Value) if err != nil { - return nil, xerrors.Errorf("BuildGCSResource %s : %w", r.Name, err) + return nil, fmt.Errorf("BuildGCSResource %s : %w", r.Name, err) } } } if location == "" { - return nil, xerrors.Errorf("BuildGCSResource: Need Location to be specified in order to create BuildGCS resource %s", r.Name) + return nil, fmt.Errorf("BuildGCSResource: Need Location to be specified in order to create BuildGCS resource %s", r.Name) } if aType == GCSArtifactType("") { - return nil, xerrors.Errorf("BuildGCSResource: Need ArtifactType to be specified to create BuildGCS resource %s", r.Name) + return nil, fmt.Errorf("BuildGCSResource: Need ArtifactType to be specified to create BuildGCS resource %s", r.Name) } return &BuildGCSResource{ Name: r.Name, @@ -162,5 +161,5 @@ func getArtifactType(val string) (GCSArtifactType, error) { return a, nil } } - return "", xerrors.Errorf("Invalid ArtifactType %s. Should be one of %s", val, validArtifactTypes) + return "", fmt.Errorf("Invalid ArtifactType %s. Should be one of %s", val, validArtifactTypes) } diff --git a/pkg/apis/pipeline/v1alpha1/cluster_resource.go b/pkg/apis/pipeline/v1alpha1/cluster_resource.go index eba532489f9..efb6c7b4499 100644 --- a/pkg/apis/pipeline/v1alpha1/cluster_resource.go +++ b/pkg/apis/pipeline/v1alpha1/cluster_resource.go @@ -19,11 +19,11 @@ package v1alpha1 import ( b64 "encoding/base64" "encoding/json" + "fmt" "strconv" "strings" "github.com/tektoncd/pipeline/pkg/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -57,7 +57,7 @@ type ClusterResource struct { // NewClusterResource create a new k8s cluster resource to pass to a pipeline task func NewClusterResource(kubeconfigWriterImage string, r *PipelineResource) (*ClusterResource, error) { if r.Spec.Type != PipelineResourceTypeCluster { - return nil, xerrors.Errorf("ClusterResource: Cannot create a Cluster resource from a %s Pipeline Resource", r.Spec.Type) + return nil, fmt.Errorf("ClusterResource: Cannot create a Cluster resource from a %s Pipeline Resource", r.Spec.Type) } clusterResource := ClusterResource{ Type: r.Spec.Type, diff --git a/pkg/apis/pipeline/v1alpha1/gcs_resource.go b/pkg/apis/pipeline/v1alpha1/gcs_resource.go index 2cbe7aecfd8..bc00a4c6340 100644 --- a/pkg/apis/pipeline/v1alpha1/gcs_resource.go +++ b/pkg/apis/pipeline/v1alpha1/gcs_resource.go @@ -23,7 +23,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -48,7 +47,7 @@ type GCSResource struct { // NewGCSResource creates a new GCS resource to pass to a Task func NewGCSResource(images pipeline.Images, r *PipelineResource) (*GCSResource, error) { if r.Spec.Type != PipelineResourceTypeStorage { - return nil, xerrors.Errorf("GCSResource: Cannot create a GCS resource from a %s Pipeline Resource", r.Spec.Type) + return nil, fmt.Errorf("GCSResource: Cannot create a GCS resource from a %s Pipeline Resource", r.Spec.Type) } var location string var locationSpecified, dir bool @@ -66,7 +65,7 @@ func NewGCSResource(images pipeline.Images, r *PipelineResource) (*GCSResource, } if !locationSpecified { - return nil, xerrors.Errorf("GCSResource: Need Location to be specified in order to create GCS resource %s", r.Name) + return nil, fmt.Errorf("GCSResource: Need Location to be specified in order to create GCS resource %s", r.Name) } return &GCSResource{ Name: r.Name, @@ -132,7 +131,7 @@ func (s *GCSResource) GetOutputTaskModifier(ts *TaskSpec, path string) (TaskModi // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. func (s *GCSResource) GetInputTaskModifier(ts *TaskSpec, path string) (TaskModifier, error) { if path == "" { - return nil, xerrors.Errorf("GCSResource: Expect Destination Directory param to be set %s", s.Name) + return nil, fmt.Errorf("GCSResource: Expect Destination Directory param to be set %s", s.Name) } var args []string if s.TypeDir { diff --git a/pkg/apis/pipeline/v1alpha1/git_resource.go b/pkg/apis/pipeline/v1alpha1/git_resource.go index ef336824106..2f47dd2076b 100644 --- a/pkg/apis/pipeline/v1alpha1/git_resource.go +++ b/pkg/apis/pipeline/v1alpha1/git_resource.go @@ -17,10 +17,10 @@ limitations under the License. package v1alpha1 import ( + "fmt" "strings" "github.com/tektoncd/pipeline/pkg/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -48,7 +48,7 @@ type GitResource struct { // NewGitResource creates a new git resource to pass to a Task func NewGitResource(gitImage string, r *PipelineResource) (*GitResource, error) { if r.Spec.Type != PipelineResourceTypeGit { - return nil, xerrors.Errorf("GitResource: Cannot create a Git resource from a %s Pipeline Resource", r.Spec.Type) + return nil, fmt.Errorf("GitResource: Cannot create a Git resource from a %s Pipeline Resource", r.Spec.Type) } gitResource := GitResource{ Name: r.Name, diff --git a/pkg/apis/pipeline/v1alpha1/image_resource.go b/pkg/apis/pipeline/v1alpha1/image_resource.go index a28923b1c6f..61ac2e76dcf 100644 --- a/pkg/apis/pipeline/v1alpha1/image_resource.go +++ b/pkg/apis/pipeline/v1alpha1/image_resource.go @@ -18,15 +18,14 @@ package v1alpha1 import ( "encoding/json" + "fmt" "strings" - - "golang.org/x/xerrors" ) // NewImageResource creates a new ImageResource from a PipelineResource. func NewImageResource(r *PipelineResource) (*ImageResource, error) { if r.Spec.Type != PipelineResourceTypeImage { - return nil, xerrors.Errorf("ImageResource: Cannot create an Image resource from a %s Pipeline Resource", r.Spec.Type) + return nil, fmt.Errorf("ImageResource: Cannot create an Image resource from a %s Pipeline Resource", r.Spec.Type) } ir := &ImageResource{ Name: r.Name, diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_validation.go b/pkg/apis/pipeline/v1alpha1/pipeline_validation.go index 62b27e2ab74..c57476e56fb 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_validation.go @@ -25,7 +25,6 @@ import ( "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" "github.com/tektoncd/pipeline/pkg/substitution" - "golang.org/x/xerrors" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/util/validation" "knative.dev/pkg/apis" @@ -67,7 +66,7 @@ func validateDeclaredResources(ps *PipelineSpec) error { } missing := list.DiffLeft(required, provided) if len(missing) > 0 { - return xerrors.Errorf("Pipeline declared resources didn't match usage in Tasks: Didn't provide required values: %s", missing) + return fmt.Errorf("Pipeline declared resources didn't match usage in Tasks: Didn't provide required values: %s", missing) } return nil } @@ -99,10 +98,10 @@ func validateFrom(tasks []PipelineTask) error { for _, pb := range rd.From { outputs, found := taskOutputs[pb] if !found { - return xerrors.Errorf("expected resource %s to be from task %s, but task %s doesn't exist", rd.Resource, pb, pb) + return fmt.Errorf("expected resource %s to be from task %s, but task %s doesn't exist", rd.Resource, pb, pb) } if !isOutput(outputs, rd.Resource) { - return xerrors.Errorf("the resource %s from %s must be an output but is an input", rd.Resource, pb) + return fmt.Errorf("the resource %s from %s must be an output but is an input", rd.Resource, pb) } } } diff --git a/pkg/apis/pipeline/v1alpha1/resource_types.go b/pkg/apis/pipeline/v1alpha1/resource_types.go index 321cd5303e7..546fe0c04cb 100644 --- a/pkg/apis/pipeline/v1alpha1/resource_types.go +++ b/pkg/apis/pipeline/v1alpha1/resource_types.go @@ -17,10 +17,11 @@ limitations under the License. package v1alpha1 import ( + "fmt" + "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2" - "golang.org/x/xerrors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -82,7 +83,7 @@ type InternalTaskModifier = v1alpha2.InternalTaskModifier func checkStepNotAlreadyAdded(s Step, steps []Step) error { for _, step := range steps { if s.Name == step.Name { - return xerrors.Errorf("Step %s cannot be added again", step.Name) + return fmt.Errorf("Step %s cannot be added again", step.Name) } } return nil @@ -117,7 +118,7 @@ func ApplyTaskModifier(ts *TaskSpec, tm TaskModifier) error { if volume.Name == v.Name { // If a Volume with the same name but different contents has already been added, we can't add both if d := cmp.Diff(volume, v); d != "" { - return xerrors.Errorf("Tried to add volume %s already added but with different contents", volume.Name) + return fmt.Errorf("Tried to add volume %s already added but with different contents", volume.Name) } // If an identical Volume has already been added, don't add it again alreadyAdded = true @@ -225,5 +226,5 @@ func ResourceFromType(r *PipelineResource, images pipeline.Images) (PipelineReso case PipelineResourceTypeCloudEvent: return NewCloudEventResource(r) } - return nil, xerrors.Errorf("%s is an invalid or unimplemented PipelineResource", r.Spec.Type) + return nil, fmt.Errorf("%s is an invalid or unimplemented PipelineResource", r.Spec.Type) } diff --git a/pkg/apis/pipeline/v1alpha1/storage_resource.go b/pkg/apis/pipeline/v1alpha1/storage_resource.go index 7b22f1f31e3..f1f0cac20b1 100644 --- a/pkg/apis/pipeline/v1alpha1/storage_resource.go +++ b/pkg/apis/pipeline/v1alpha1/storage_resource.go @@ -21,7 +21,6 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -48,7 +47,7 @@ type PipelineStorageResourceInterface interface { // to add input and output steps and volumes to an executing pod. func NewStorageResource(images pipeline.Images, r *PipelineResource) (PipelineStorageResourceInterface, error) { if r.Spec.Type != PipelineResourceTypeStorage { - return nil, xerrors.Errorf("StoreResource: Cannot create a storage resource from a %s Pipeline Resource", r.Spec.Type) + return nil, fmt.Errorf("StoreResource: Cannot create a storage resource from a %s Pipeline Resource", r.Spec.Type) } for _, param := range r.Spec.Params { @@ -59,11 +58,11 @@ func NewStorageResource(images pipeline.Images, r *PipelineResource) (PipelineSt case strings.EqualFold(param.Value, string(PipelineResourceTypeBuildGCS)): return NewBuildGCSResource(images, r) default: - return nil, xerrors.Errorf("%s is an invalid or unimplemented PipelineStorageResource", param.Value) + return nil, fmt.Errorf("%s is an invalid or unimplemented PipelineStorageResource", param.Value) } } } - return nil, xerrors.Errorf("StoreResource: Cannot create a storage resource without type %s in spec", r.Name) + return nil, fmt.Errorf("StoreResource: Cannot create a storage resource without type %s in spec", r.Name) } func getStorageVolumeSpec(s PipelineStorageResourceInterface, spec TaskSpec) []corev1.Volume { diff --git a/pkg/apis/pipeline/v1alpha2/resource_types.go b/pkg/apis/pipeline/v1alpha2/resource_types.go index 92bd202adea..4fcd6b80bf9 100644 --- a/pkg/apis/pipeline/v1alpha2/resource_types.go +++ b/pkg/apis/pipeline/v1alpha2/resource_types.go @@ -17,8 +17,9 @@ limitations under the License. package v1alpha2 import ( + "fmt" + "github.com/google/go-cmp/cmp" - "golang.org/x/xerrors" v1 "k8s.io/api/core/v1" ) @@ -152,7 +153,7 @@ func ApplyTaskModifier(ts *TaskSpec, tm TaskModifier) error { if volume.Name == v.Name { // If a Volume with the same name but different contents has already been added, we can't add both if d := cmp.Diff(volume, v); d != "" { - return xerrors.Errorf("Tried to add volume %s already added but with different contents", volume.Name) + return fmt.Errorf("Tried to add volume %s already added but with different contents", volume.Name) } // If an identical Volume has already been added, don't add it again alreadyAdded = true @@ -169,7 +170,7 @@ func ApplyTaskModifier(ts *TaskSpec, tm TaskModifier) error { func checkStepNotAlreadyAdded(s Step, steps []Step) error { for _, step := range steps { if s.Name == step.Name { - return xerrors.Errorf("Step %s cannot be added again", step.Name) + return fmt.Errorf("Step %s cannot be added again", step.Name) } } return nil diff --git a/pkg/artifacts/artifacts_storage.go b/pkg/artifacts/artifacts_storage.go index 05b9e1b3491..ba17b9639a5 100644 --- a/pkg/artifacts/artifacts_storage.go +++ b/pkg/artifacts/artifacts_storage.go @@ -24,7 +24,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/system" "go.uber.org/zap" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" @@ -180,7 +179,7 @@ func ConfigMapNeedsPVC(configMap *corev1.ConfigMap, err error, logger *zap.Sugar if errors.IsNotFound(err) { return true, nil } - return false, xerrors.Errorf("couldn't determine if PVC was needed from config map: %w", err) + return false, fmt.Errorf("couldn't determine if PVC was needed from config map: %w", err) } if configMap == nil { return true, nil @@ -206,7 +205,7 @@ func GetArtifactStorage(images pipeline.Images, prName string, c kubernetes.Inte configMap, err := c.CoreV1().ConfigMaps(system.GetNamespace()).Get(BucketConfigName, metav1.GetOptions{}) pvc, err := ConfigMapNeedsPVC(configMap, err, logger) if err != nil { - return nil, xerrors.Errorf("couldn't determine if PVC was needed from config map: %w", err) + return nil, fmt.Errorf("couldn't determine if PVC was needed from config map: %w", err) } if pvc { return &v1alpha1.ArtifactPVC{Name: prName, ShellImage: images.ShellImage}, nil @@ -252,7 +251,7 @@ func createPVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) (*corev1.Persis configMap, err := c.CoreV1().ConfigMaps(system.GetNamespace()).Get(PvcConfigName, metav1.GetOptions{}) if err != nil && !errors.IsNotFound(err) { - return nil, xerrors.Errorf("failed to get PVC ConfigMap %s for %q due to error: %w", PvcConfigName, pr.Name, err) + return nil, fmt.Errorf("failed to get PVC ConfigMap %s for %q due to error: %w", PvcConfigName, pr.Name, err) } var pvcSizeStr string var pvcStorageClassNameStr string @@ -265,7 +264,7 @@ func createPVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) (*corev1.Persis } pvcSize, err := resource.ParseQuantity(pvcSizeStr) if err != nil { - return nil, xerrors.Errorf("failed to create Persistent Volume spec for %q due to error: %w", pr.Name, err) + return nil, fmt.Errorf("failed to create Persistent Volume spec for %q due to error: %w", pr.Name, err) } var pvcStorageClassName *string if pvcStorageClassNameStr == "" { @@ -277,11 +276,11 @@ func createPVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) (*corev1.Persis pvcSpec := GetPVCSpec(pr, pvcSize, pvcStorageClassName) pvc, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Create(pvcSpec) if err != nil { - return nil, xerrors.Errorf("failed to claim Persistent Volume %q due to error: %w", pr.Name, err) + return nil, fmt.Errorf("failed to claim Persistent Volume %q due to error: %w", pr.Name, err) } return pvc, nil } - return nil, xerrors.Errorf("failed to get claim Persistent Volume %q due to error: %w", pr.Name, err) + return nil, fmt.Errorf("failed to get claim Persistent Volume %q due to error: %w", pr.Name, err) } return nil, nil } @@ -289,10 +288,10 @@ func createPVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) (*corev1.Persis func deletePVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) error { if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(GetPVCName(pr), metav1.GetOptions{}); err != nil { if !errors.IsNotFound(err) { - return xerrors.Errorf("failed to get Persistent Volume %q due to error: %w", GetPVCName(pr), err) + return fmt.Errorf("failed to get Persistent Volume %q due to error: %w", GetPVCName(pr), err) } } else if err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Delete(GetPVCName(pr), &metav1.DeleteOptions{}); err != nil { - return xerrors.Errorf("failed to delete Persistent Volume %q due to error: %w", pr.Name, err) + return fmt.Errorf("failed to delete Persistent Volume %q due to error: %w", pr.Name, err) } return nil } diff --git a/pkg/credentials/dockercreds/creds.go b/pkg/credentials/dockercreds/creds.go index f4aedcc4186..98c820868b8 100644 --- a/pkg/credentials/dockercreds/creds.go +++ b/pkg/credentials/dockercreds/creds.go @@ -26,7 +26,6 @@ import ( "path/filepath" "strings" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "github.com/tektoncd/pipeline/pkg/credentials" @@ -70,13 +69,13 @@ func (dc *basicDocker) String() string { func (dc *basicDocker) Set(value string) error { parts := strings.Split(value, "=") if len(parts) != 2 { - return xerrors.Errorf("Expect entries of the form secret=url, got: %v", value) + return fmt.Errorf("Expect entries of the form secret=url, got: %v", value) } secret := parts[0] url := parts[1] if _, ok := dc.Entries[url]; ok { - return xerrors.Errorf("Multiple entries for url: %v", url) + return fmt.Errorf("Multiple entries for url: %v", url) } e, err := newEntry(secret) diff --git a/pkg/credentials/gitcreds/basic.go b/pkg/credentials/gitcreds/basic.go index cd4330dc933..65ca0b40d11 100644 --- a/pkg/credentials/gitcreds/basic.go +++ b/pkg/credentials/gitcreds/basic.go @@ -24,7 +24,6 @@ import ( "path/filepath" "strings" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "github.com/tektoncd/pipeline/pkg/credentials" @@ -54,13 +53,13 @@ func (dc *basicGitConfig) String() string { func (dc *basicGitConfig) Set(value string) error { parts := strings.Split(value, "=") if len(parts) != 2 { - return xerrors.Errorf("Expect entries of the form secret=url, got: %v", value) + return fmt.Errorf("Expect entries of the form secret=url, got: %v", value) } secret := parts[0] url := parts[1] if _, ok := dc.entries[url]; ok { - return xerrors.Errorf("Multiple entries for url: %v", url) + return fmt.Errorf("Multiple entries for url: %v", url) } e, err := newBasicEntry(url, secret) diff --git a/pkg/credentials/gitcreds/ssh.go b/pkg/credentials/gitcreds/ssh.go index b3f96517de6..84e54bfc016 100644 --- a/pkg/credentials/gitcreds/ssh.go +++ b/pkg/credentials/gitcreds/ssh.go @@ -27,7 +27,6 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/credentials" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -58,7 +57,7 @@ func (dc *sshGitConfig) String() string { func (dc *sshGitConfig) Set(value string) error { parts := strings.Split(value, "=") if len(parts) != 2 { - return xerrors.Errorf("Expect entries of the form secret=url, got: %v", value) + return fmt.Errorf("Expect entries of the form secret=url, got: %v", value) } secretName := parts[0] url := parts[1] diff --git a/pkg/entrypoint/entrypointer_test.go b/pkg/entrypoint/entrypointer_test.go index bed8b099308..db2442d7cb4 100644 --- a/pkg/entrypoint/entrypointer_test.go +++ b/pkg/entrypoint/entrypointer_test.go @@ -17,11 +17,11 @@ limitations under the License. package entrypoint import ( + "errors" "reflect" "testing" "github.com/google/go-cmp/cmp" - "golang.org/x/xerrors" ) func TestEntrypointerFailures(t *testing.T) { @@ -199,12 +199,12 @@ type fakeErrorWaiter struct{ waited *string } func (f *fakeErrorWaiter) Wait(file string, expectContent bool) error { f.waited = &file - return xerrors.New("waiter failed") + return errors.New("waiter failed") } type fakeErrorRunner struct{ args *[]string } func (f *fakeErrorRunner) Run(args ...string) error { f.args = &args - return xerrors.New("runner failed") + return errors.New("runner failed") } diff --git a/pkg/git/git.go b/pkg/git/git.go index 6d7a19bd1ab..dd78c1eb9b0 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -17,13 +17,13 @@ package git import ( "bytes" + "fmt" "os" "os/exec" "strings" homedir "github.com/mitchellh/go-homedir" "go.uber.org/zap" - "golang.org/x/xerrors" ) func run(logger *zap.SugaredLogger, dir string, args ...string) (string, error) { @@ -57,7 +57,7 @@ func Fetch(logger *zap.SugaredLogger, revision, path, url string) error { return err } if err := os.Chdir(path); err != nil { - return xerrors.Errorf("Failed to change directory with path %s; err: %w", path, err) + return fmt.Errorf("Failed to change directory with path %s; err: %w", path, err) } } else if _, err := run(logger, "", "init"); err != nil { return err @@ -97,7 +97,7 @@ func SubmoduleFetch(logger *zap.SugaredLogger, path string) error { if path != "" { if err := os.Chdir(path); err != nil { - return xerrors.Errorf("Failed to change directory with path %s; err: %w", path, err) + return fmt.Errorf("Failed to change directory with path %s; err: %w", path, err) } } if _, err := run(logger, "", "submodule", "init"); err != nil { diff --git a/pkg/list/diff.go b/pkg/list/diff.go index 049fd91c315..a26c7631984 100644 --- a/pkg/list/diff.go +++ b/pkg/list/diff.go @@ -16,7 +16,7 @@ limitations under the License. package list -import "golang.org/x/xerrors" +import "fmt" // IsSame will return an error indicating if there are extra or missing strings // between the required and provided strings, or will return no error if the two @@ -24,11 +24,11 @@ import "golang.org/x/xerrors" func IsSame(required, provided []string) error { missing := DiffLeft(required, provided) if len(missing) > 0 { - return xerrors.Errorf("Didn't provide required values: %s", missing) + return fmt.Errorf("Didn't provide required values: %s", missing) } extra := DiffLeft(provided, required) if len(extra) > 0 { - return xerrors.Errorf("Provided extra values: %s", extra) + return fmt.Errorf("Provided extra values: %s", extra) } return nil } diff --git a/pkg/pullrequest/api.go b/pkg/pullrequest/api.go index f5724866aaf..f11b6b76393 100644 --- a/pkg/pullrequest/api.go +++ b/pkg/pullrequest/api.go @@ -18,11 +18,10 @@ package pullrequest import ( "context" + "fmt" "io/ioutil" "strconv" - "golang.org/x/xerrors" - "github.com/hashicorp/go-multierror" "github.com/jenkins-x/go-scm/scm" "go.uber.org/zap" @@ -55,7 +54,7 @@ func (h *Handler) Download(ctx context.Context) (*Resource, error) { h.logger.Info("finding pr") pr, _, err := h.client.PullRequests.Find(ctx, h.repo, h.prNum) if err != nil { - return nil, xerrors.Errorf("finding pr: %s", h.prNum, err) + return nil, fmt.Errorf("finding pr %d: %w", h.prNum, err) } // Statuses @@ -65,7 +64,7 @@ func (h *Handler) Download(ctx context.Context) (*Resource, error) { body, _ := ioutil.ReadAll(out.Body) defer out.Body.Close() h.logger.Warnf("%v: %s", err, string(body)) - return nil, xerrors.Errorf("finding combined status: %s", h.prNum, err) + return nil, fmt.Errorf("finding combined status for pr %d: %w", h.prNum, err) } // Comments @@ -73,13 +72,13 @@ func (h *Handler) Download(ctx context.Context) (*Resource, error) { h.logger.Info("finding comments: %v", h) comments, _, err := h.client.PullRequests.ListComments(ctx, h.repo, h.prNum, scm.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("finding comments: %s", h.prNum, err) + return nil, fmt.Errorf("finding comments for pr %d: %w", h.prNum, err) } h.logger.Info("found comments: %v", comments) labels, _, err := h.client.PullRequests.ListLabels(ctx, h.repo, h.prNum, scm.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("finding labels: %s", h.prNum, err) + return nil, fmt.Errorf("finding labels for pr %d: %w", h.prNum, err) } pr.Labels = labels @@ -143,7 +142,7 @@ func (h *Handler) uploadLabels(ctx context.Context, manifest Manifest, raw []*sc // which labels are new and should not be modified. currentLabels, _, err := h.client.PullRequests.ListLabels(ctx, h.repo, h.prNum, scm.ListOptions{}) if err != nil { - return xerrors.Errorf("listing labels %s: %w", h.prNum, err) + return fmt.Errorf("listing labels for pr %d: %w", h.prNum, err) } current := make(map[string]bool) for _, l := range currentLabels { @@ -163,7 +162,7 @@ func (h *Handler) uploadLabels(ctx context.Context, manifest Manifest, raw []*sc h.logger.Debugf("Creating labels %v for PR %d", create, h.prNum) for _, l := range create { if _, err := h.client.PullRequests.AddLabel(ctx, h.repo, h.prNum, l); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("adding label %s: %w", l, err)) + merr = multierror.Append(merr, fmt.Errorf("adding label %s: %w", l, err)) } } @@ -173,7 +172,7 @@ func (h *Handler) uploadLabels(ctx context.Context, manifest Manifest, raw []*sc if !labels[l] && manifest[l] { h.logger.Debugf("Removing label %s for PR %d", l, h.prNum) if _, err := h.client.PullRequests.DeleteLabel(ctx, h.repo, h.prNum, l); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("finding pr %s: %w", h.prNum, err)) + merr = multierror.Append(merr, fmt.Errorf("finding pr %d: %w", h.prNum, err)) } } } @@ -198,11 +197,11 @@ func (h *Handler) uploadComments(ctx context.Context, manifest Manifest, comment var merr error if err := h.maybeDeleteComments(ctx, manifest, existingComments); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("deleting comments: %s", existingComments, err)) + merr = multierror.Append(merr, fmt.Errorf("deleting comments %v: %w", existingComments, err)) } if err := h.createNewComments(ctx, newComments); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("creating comments: %s", newComments, err)) + merr = multierror.Append(merr, fmt.Errorf("creating comments %v: %s", newComments, err)) } return merr @@ -239,7 +238,7 @@ func (h *Handler) maybeDeleteComments(ctx context.Context, manifest Manifest, co // upstream source. h.logger.Infof("Deleting comment %d for PR %d", ec.ID, h.prNum) if _, err := h.client.PullRequests.DeleteComment(ctx, h.repo, h.prNum, ec.ID); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("deleting comment: %s", ec.ID, err)) + merr = multierror.Append(merr, fmt.Errorf("deleting comment %d: %w", ec.ID, err)) continue } } @@ -254,7 +253,7 @@ func (h *Handler) createNewComments(ctx context.Context, comments []*scm.Comment } h.logger.Infof("Creating comment %s for PR %d", c.Body, h.prNum) if _, _, err := h.client.PullRequests.CreateComment(ctx, h.repo, h.prNum, c); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("creating comment: %s", c, err)) + merr = multierror.Append(merr, fmt.Errorf("creating comment %v: %w", c, err)) } } return merr @@ -294,7 +293,7 @@ func (h *Handler) uploadStatuses(ctx context.Context, statuses []*scm.Status, sh } h.logger.Infof("Creating status %s on %s", si.Label, sha) if _, _, err := h.client.Repositories.CreateStatus(ctx, h.repo, sha, si); err != nil { - merr = multierror.Append(merr, xerrors.Errorf("creating status: %s", si.Label, err)) + merr = multierror.Append(merr, fmt.Errorf("creating status %q: %w", si.Label, err)) continue } } diff --git a/pkg/reconciler/pipeline/dag/dag.go b/pkg/reconciler/pipeline/dag/dag.go index d0e601d77b0..28b57161bd2 100644 --- a/pkg/reconciler/pipeline/dag/dag.go +++ b/pkg/reconciler/pipeline/dag/dag.go @@ -17,10 +17,11 @@ limitations under the License. package dag import ( + "errors" + "fmt" "strings" "github.com/tektoncd/pipeline/pkg/list" - "golang.org/x/xerrors" ) type Task interface { @@ -55,7 +56,7 @@ func newGraph() *Graph { func (g *Graph) addPipelineTask(t Task) (*Node, error) { if _, ok := g.Nodes[t.HashKey()]; ok { - return nil, xerrors.New("duplicate pipeline task") + return nil, errors.New("duplicate pipeline task") } newNode := &Node{ Task: t, @@ -72,7 +73,7 @@ func Build(tasks Tasks) (*Graph, error) { // Add all Tasks mentioned in the `PipelineSpec` for _, pt := range tasks.Items() { if _, err := d.addPipelineTask(pt); err != nil { - return nil, xerrors.Errorf("task %s is already present in Graph, can't add it again: %w", pt.HashKey(), err) + return nil, fmt.Errorf("task %s is already present in Graph, can't add it again: %w", pt.HashKey(), err) } deps[pt.HashKey()] = pt.Deps() } @@ -80,7 +81,7 @@ func Build(tasks Tasks) (*Graph, error) { for pt, taskDeps := range deps { for _, previousTask := range taskDeps { if err := addLink(pt, previousTask, d.Nodes); err != nil { - return nil, xerrors.Errorf("couldn't add link between %s and %s: %w", pt, previousTask, err) + return nil, fmt.Errorf("couldn't add link between %s and %s: %w", pt, previousTask, err) } } } @@ -112,7 +113,7 @@ func GetSchedulable(g *Graph, doneTasks ...string) (map[string]struct{}, error) notVisited := list.DiffLeft(doneTasks, visitedNames) if len(notVisited) > 0 { - return map[string]struct{}{}, xerrors.Errorf("invalid list of done tasks; some tasks were indicated completed without ancestors being done: %v", notVisited) + return map[string]struct{}{}, fmt.Errorf("invalid list of done tasks; some tasks were indicated completed without ancestors being done: %v", notVisited) } return d, nil @@ -121,13 +122,13 @@ func GetSchedulable(g *Graph, doneTasks ...string) (map[string]struct{}, error) func linkPipelineTasks(prev *Node, next *Node) error { // Check for self cycle if prev.Task.HashKey() == next.Task.HashKey() { - return xerrors.Errorf("cycle detected; task %q depends on itself", next.Task.HashKey()) + return fmt.Errorf("cycle detected; task %q depends on itself", next.Task.HashKey()) } // Check if we are adding cycles. visited := map[string]bool{prev.Task.HashKey(): true, next.Task.HashKey(): true} path := []string{next.Task.HashKey(), prev.Task.HashKey()} if err := visit(next.Task.HashKey(), prev.Prev, path, visited); err != nil { - return xerrors.Errorf("cycle detected: %w", err) + return fmt.Errorf("cycle detected: %w", err) } next.Prev = append(next.Prev, prev) prev.Next = append(prev.Next, next) @@ -138,7 +139,7 @@ func visit(currentName string, nodes []*Node, path []string, visited map[string] for _, n := range nodes { path = append(path, n.Task.HashKey()) if _, ok := visited[n.Task.HashKey()]; ok { - return xerrors.New(getVisitedPath(path)) + return errors.New(getVisitedPath(path)) } visited[currentName+"."+n.Task.HashKey()] = true if err := visit(n.Task.HashKey(), n.Prev, path, visited); err != nil { @@ -160,11 +161,11 @@ func getVisitedPath(path []string) string { func addLink(pt string, previousTask string, nodes map[string]*Node) error { prev, ok := nodes[previousTask] if !ok { - return xerrors.Errorf("Task %s depends on %s but %s wasn't present in Pipeline", pt, previousTask, previousTask) + return fmt.Errorf("Task %s depends on %s but %s wasn't present in Pipeline", pt, previousTask, previousTask) } next := nodes[pt] if err := linkPipelineTasks(prev, next); err != nil { - return xerrors.Errorf("Couldn't create link from %s to %s: %w", prev.Task.HashKey(), next.Task.HashKey(), err) + return fmt.Errorf("Couldn't create link from %s to %s: %w", prev.Task.HashKey(), next.Task.HashKey(), err) } return nil } diff --git a/pkg/reconciler/pipelinerun/cancel.go b/pkg/reconciler/pipelinerun/cancel.go index cbe4bb4020c..993d8d6a180 100644 --- a/pkg/reconciler/pipelinerun/cancel.go +++ b/pkg/reconciler/pipelinerun/cancel.go @@ -24,7 +24,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -55,7 +54,7 @@ func cancelPipelineRun(pr *v1alpha1.PipelineRun, pipelineState []*resources.Reso } } if len(errs) > 0 { - return xerrors.Errorf("Error cancelled PipelineRun's TaskRun(s): %s", strings.Join(errs, "\n")) + return fmt.Errorf("Error cancelled PipelineRun's TaskRun(s): %s", strings.Join(errs, "\n")) } return nil } diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index ea71fda57ee..fa369abb8ee 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -34,7 +34,6 @@ import ( "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun" "go.uber.org/zap" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" @@ -431,14 +430,14 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) er rprt.TaskRun, err = c.createTaskRun(rprt, pr, as.StorageBasePath(pr)) if err != nil { c.Recorder.Eventf(pr, corev1.EventTypeWarning, "TaskRunCreationFailed", "Failed to create TaskRun %q: %v", rprt.TaskRunName, err) - return xerrors.Errorf("error creating TaskRun called %s for PipelineTask %s from PipelineRun %s: %w", rprt.TaskRunName, rprt.PipelineTask.Name, pr.Name, err) + return fmt.Errorf("error creating TaskRun called %s for PipelineTask %s from PipelineRun %s: %w", rprt.TaskRunName, rprt.PipelineTask.Name, pr.Name, err) } } else if !rprt.ResolvedConditionChecks.HasStarted() { for _, rcc := range rprt.ResolvedConditionChecks { rcc.ConditionCheck, err = c.makeConditionCheckContainer(rprt, rcc, pr) if err != nil { c.Recorder.Eventf(pr, corev1.EventTypeWarning, "ConditionCheckCreationFailed", "Failed to create TaskRun %q: %v", rcc.ConditionCheckName, err) - return xerrors.Errorf("error creating ConditionCheck container called %s for PipelineTask %s from PipelineRun %s: %w", rcc.ConditionCheckName, rprt.PipelineTask.Name, pr.Name, err) + return fmt.Errorf("error creating ConditionCheck container called %s for PipelineTask %s from PipelineRun %s: %w", rcc.ConditionCheckName, rprt.PipelineTask.Name, pr.Name, err) } } } @@ -511,7 +510,7 @@ func (c *Reconciler) updateTaskRunsStatusDirectly(pr *v1alpha1.PipelineRun) erro if err != nil { // If the TaskRun isn't found, it just means it won't be run if !errors.IsNotFound(err) { - return xerrors.Errorf("error retrieving TaskRun %s: %w", taskRunName, err) + return fmt.Errorf("error retrieving TaskRun %s: %w", taskRunName, err) } } else { prtrs.Status = &tr.Status @@ -623,7 +622,7 @@ func getTaskRunTimeout(pr *v1alpha1.PipelineRun) *metav1.Duration { func (c *Reconciler) updateStatus(pr *v1alpha1.PipelineRun) (*v1alpha1.PipelineRun, error) { newPr, err := c.pipelineRunLister.PipelineRuns(pr.Namespace).Get(pr.Name) if err != nil { - return nil, xerrors.Errorf("Error getting PipelineRun %s when updating status: %w", pr.Name, err) + return nil, fmt.Errorf("Error getting PipelineRun %s when updating status: %w", pr.Name, err) } succeeded := pr.Status.GetCondition(apis.ConditionSucceeded) if succeeded.Status == corev1.ConditionFalse || succeeded.Status == corev1.ConditionTrue { @@ -641,7 +640,7 @@ func (c *Reconciler) updateStatus(pr *v1alpha1.PipelineRun) (*v1alpha1.PipelineR func (c *Reconciler) updateLabelsAndAnnotations(pr *v1alpha1.PipelineRun) (*v1alpha1.PipelineRun, error) { newPr, err := c.pipelineRunLister.PipelineRuns(pr.Namespace).Get(pr.Name) if err != nil { - return nil, xerrors.Errorf("Error getting PipelineRun %s when updating labels/annotations: %w", pr.Name, err) + return nil, fmt.Errorf("Error getting PipelineRun %s when updating labels/annotations: %w", pr.Name, err) } if !reflect.DeepEqual(pr.ObjectMeta.Labels, newPr.ObjectMeta.Labels) || !reflect.DeepEqual(pr.ObjectMeta.Annotations, newPr.ObjectMeta.Annotations) { newPr.ObjectMeta.Labels = pr.ObjectMeta.Labels @@ -657,7 +656,7 @@ func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelin taskSpec, err := rcc.ConditionToTaskSpec() if err != nil { - return nil, xerrors.Errorf("Failed to get TaskSpec from Condition: %w", err) + return nil, fmt.Errorf("Failed to get TaskSpec from Condition: %w", err) } tr := &v1alpha1.TaskRun{ diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution.go b/pkg/reconciler/pipelinerun/resources/conditionresolution.go index b6396039a8e..9a869979ee3 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution.go @@ -22,7 +22,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -114,7 +113,7 @@ func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1alpha1.TaskSpec, er err := ApplyResourceSubstitution(&t.Steps[0], rcc.ResolvedResources, rcc.Condition.Spec.Resources, rcc.images) if err != nil { - return nil, xerrors.Errorf("Failed to replace resource template strings %w", err) + return nil, fmt.Errorf("Failed to replace resource template strings %w", err) } return t, nil @@ -138,7 +137,7 @@ func ApplyResourceSubstitution(step *v1alpha1.Step, resolvedResources map[string if rSpec, ok := resolvedResources[cr.Name]; ok { r, err := v1alpha1.ResourceFromType(rSpec, images) if err != nil { - return xerrors.Errorf("Error trying to create resource: %w", err) + return fmt.Errorf("Error trying to create resource: %w", err) } for k, v := range r.Replacements() { replacements[fmt.Sprintf("resources.%s.%s", cr.Name, k)] = v diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index 587216ec56c..343ad394b73 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -21,7 +21,6 @@ import ( "reflect" "go.uber.org/zap" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "knative.dev/pkg/apis" @@ -178,7 +177,7 @@ func GetResourcesFromBindings(pr *v1alpha1.PipelineRun, getResource resources.Ge for _, resource := range pr.Spec.Resources { r, err := resources.GetResourceFromBinding(&resource, getResource) if err != nil { - return rs, xerrors.Errorf("Error following resource reference for %s: %w", resource.Name, err) + return rs, fmt.Errorf("Error following resource reference for %s: %w", resource.Name, err) } rs[resource.Name] = r } @@ -196,7 +195,7 @@ func ValidateResourceBindings(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun provided = append(provided, resource.Name) } if err := list.IsSame(required, provided); err != nil { - return xerrors.Errorf("PipelineRun bound resources didn't match Pipeline: %w", err) + return fmt.Errorf("PipelineRun bound resources didn't match Pipeline: %w", err) } return nil } @@ -261,7 +260,7 @@ func ResolvePipelineRun( spec := t.TaskSpec() rtr, err := ResolvePipelineTaskResources(pt, &spec, t.TaskMetadata().Name, pt.TaskRef.Kind, providedResources) if err != nil { - return nil, xerrors.Errorf("couldn't match referenced resources with declared resources: %w", err) + return nil, fmt.Errorf("couldn't match referenced resources with declared resources: %w", err) } rprt.ResolvedTaskResources = rtr @@ -269,7 +268,7 @@ func ResolvePipelineRun( taskRun, err := getTaskRun(rprt.TaskRunName) if err != nil { if !errors.IsNotFound(err) { - return nil, xerrors.Errorf("error retrieving TaskRun %s: %w", rprt.TaskRunName, err) + return nil, fmt.Errorf("error retrieving TaskRun %s: %w", rprt.TaskRunName, err) } } if taskRun != nil { @@ -422,14 +421,14 @@ func resolveConditionChecks(pt *v1alpha1.PipelineTask, taskRunStatus map[string] cctr, err := getTaskRun(conditionCheckName) if err != nil { if !errors.IsNotFound(err) { - return nil, xerrors.Errorf("error retrieving ConditionCheck %s for taskRun name %s : %w", conditionCheckName, taskRunName, err) + return nil, fmt.Errorf("error retrieving ConditionCheck %s for taskRun name %s : %w", conditionCheckName, taskRunName, err) } } conditionResources := map[string]*v1alpha1.PipelineResource{} for _, declared := range ptc.Resources { r, ok := providedResources[declared.Resource] if !ok { - return nil, xerrors.Errorf("resources %s missing for condition %s in pipeline task %s", declared.Resource, cName, pt.Name) + return nil, fmt.Errorf("resources %s missing for condition %s in pipeline task %s", declared.Resource, cName, pt.Name) } conditionResources[declared.Name] = r } @@ -461,14 +460,14 @@ func ResolvePipelineTaskResources(pt v1alpha1.PipelineTask, ts *v1alpha1.TaskSpe for _, taskInput := range pt.Resources.Inputs { resource, ok := providedResources[taskInput.Resource] if !ok { - return nil, xerrors.Errorf("pipelineTask tried to use input resource %s not present in declared resources", taskInput.Resource) + return nil, fmt.Errorf("pipelineTask tried to use input resource %s not present in declared resources", taskInput.Resource) } rtr.Inputs[taskInput.Name] = resource } for _, taskOutput := range pt.Resources.Outputs { resource, ok := providedResources[taskOutput.Resource] if !ok { - return nil, xerrors.Errorf("pipelineTask tried to use output resource %s not present in declared resources", taskOutput.Resource) + return nil, fmt.Errorf("pipelineTask tried to use output resource %s not present in declared resources", taskOutput.Resource) } rtr.Outputs[taskOutput.Name] = resource } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index b9ebd69176f..05a7412b3c6 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -17,6 +17,7 @@ limitations under the License. package resources import ( + "errors" "fmt" "testing" @@ -28,9 +29,8 @@ import ( tb "github.com/tektoncd/pipeline/test/builder" "github.com/tektoncd/pipeline/test/names" "go.uber.org/zap" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" + kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" @@ -1096,7 +1096,7 @@ func TestGetResourcesFromBindings_ErrorGettingResource(t *testing.T) { tb.PipelineRunResourceBinding("git-resource", tb.PipelineResourceBindingRef("sweet-resource")), )) getResource := func(name string) (*v1alpha1.PipelineResource, error) { - return nil, xerrors.Errorf("IT HAS ALL GONE WRONG") + return nil, fmt.Errorf("IT HAS ALL GONE WRONG") } _, err := GetResourcesFromBindings(pr, getResource) if err == nil { @@ -1240,14 +1240,14 @@ func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { // Return an error when the Task is retrieved, as if it didn't exist getTask := func(name string) (v1alpha1.TaskInterface, error) { - return nil, errors.NewNotFound(v1alpha1.Resource("task"), name) + return nil, kerrors.NewNotFound(v1alpha1.Resource("task"), name) } getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { - return nil, errors.NewNotFound(v1alpha1.Resource("clustertask"), name) + return nil, kerrors.NewNotFound(v1alpha1.Resource("clustertask"), name) } getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { - return nil, errors.NewNotFound(v1alpha1.Resource("taskrun"), name) + return nil, kerrors.NewNotFound(v1alpha1.Resource("taskrun"), name) } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil @@ -1396,7 +1396,7 @@ func TestResolveConditionChecks(t *testing.T) { providedResources := map[string]*v1alpha1.PipelineResource{} getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("should not get called") } + getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } pr := v1alpha1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ @@ -1418,7 +1418,7 @@ func TestResolveConditionChecks(t *testing.T) { case "pipelinerun-mytask1-9l9zj": return &trs[0], nil default: - return nil, xerrors.Errorf("getTaskRun called with unexpected name %s", name) + return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) } }, expectedConditionCheck: TaskConditionCheckState{{ @@ -1437,7 +1437,7 @@ func TestResolveConditionChecks(t *testing.T) { } else if name == "pipelinerun-mytask1-mssqb" { return &trs[0], nil } - return nil, xerrors.Errorf("getTaskRun called with unexpected name %s", name) + return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) }, expectedConditionCheck: TaskConditionCheckState{{ ConditionCheckName: "pipelinerun-mytask1-mssqb-always-true-78c5n", @@ -1497,7 +1497,7 @@ func TestResolveConditionChecks_MultipleConditions(t *testing.T) { providedResources := map[string]*v1alpha1.PipelineResource{} getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("should not get called") } + getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } pr := v1alpha1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ @@ -1521,7 +1521,7 @@ func TestResolveConditionChecks_MultipleConditions(t *testing.T) { case "pipelinerun-mytask1-9l9zj-always-true-mssqb": return cc2, nil } - return nil, xerrors.Errorf("getTaskRun called with unexpected name %s", name) + return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) }, expectedConditionCheck: TaskConditionCheckState{{ ConditionCheckName: "pipelinerun-mytask1-9l9zj-always-true-mz4c7", @@ -1569,15 +1569,15 @@ func TestResolveConditionChecks_ConditionDoesNotExist(t *testing.T) { getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { if name == ccName { - return nil, xerrors.Errorf("should not be called") + return nil, fmt.Errorf("should not be called") } else if name == trName { return &trs[0], nil } - return nil, xerrors.Errorf("getTaskRun called with unexpected name %s", name) + return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("should not get called") } + getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { - return nil, errors.NewNotFound(v1alpha1.Resource("condition"), name) + return nil, kerrors.NewNotFound(v1alpha1.Resource("condition"), name) } pr := v1alpha1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ @@ -1628,9 +1628,9 @@ func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { } else if name == trName { return &trs[0], nil } - return nil, xerrors.Errorf("getTaskRun called with unexpected name %s", name) + return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("should not get called") } + getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } ccStatus := make(map[string]*v1alpha1.PipelineRunConditionCheckStatus) @@ -1695,7 +1695,7 @@ func TestResolvedConditionCheck_WithResources(t *testing.T) { getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return nil, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("should not get called") } + getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } // This err result is required to satisfy the type alias on this function, but it triggers // a false positive in the linter: https://github.com/mvdan/unparam/issues/40 diff --git a/pkg/reconciler/pipelinerun/resources/pipelinespec.go b/pkg/reconciler/pipelinerun/resources/pipelinespec.go index 70a362b9899..fa2fc2076a4 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinespec.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinespec.go @@ -17,8 +17,9 @@ limitations under the License. package resources import ( + "fmt" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -36,7 +37,7 @@ func GetPipelineData(pipelineRun *v1alpha1.PipelineRun, getPipeline GetPipeline) // Get related pipeline for pipelinerun t, err := getPipeline(pipelineRun.Spec.PipelineRef.Name) if err != nil { - return nil, nil, xerrors.Errorf("error when listing pipelines for pipelineRun %s: %w", pipelineRun.Name, err) + return nil, nil, fmt.Errorf("error when listing pipelines for pipelineRun %s: %w", pipelineRun.Name, err) } pipelineMeta = t.PipelineMetadata() pipelineSpec = t.PipelineSpec() @@ -44,7 +45,7 @@ func GetPipelineData(pipelineRun *v1alpha1.PipelineRun, getPipeline GetPipeline) pipelineMeta = pipelineRun.ObjectMeta pipelineSpec = *pipelineRun.Spec.PipelineSpec default: - return nil, nil, xerrors.Errorf("PipelineRun %s not providing PipelineRef or PipelineSpec", pipelineRun.Name) + return nil, nil, fmt.Errorf("PipelineRun %s not providing PipelineRef or PipelineSpec", pipelineRun.Name) } return &pipelineMeta, &pipelineSpec, nil } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go b/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go index 2caf9725c26..8aa8a35ee72 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go @@ -17,10 +17,10 @@ limitations under the License. package resources import ( + "errors" "testing" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -80,7 +80,7 @@ func TestGetPipelineSpec_Embedded(t *testing.T) { }, }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, xerrors.New("shouldn't be called") } + gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, errors.New("shouldn't be called") } pipelineMeta, pipelineSpec, err := GetPipelineData(pr, gt) if err != nil { @@ -102,7 +102,7 @@ func TestGetPipelineSpec_Invalid(t *testing.T) { Name: "mypipelinerun", }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, xerrors.New("shouldn't be called") } + gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, errors.New("shouldn't be called") } _, _, err := GetPipelineData(tr, gt) if err == nil { t.Fatalf("Expected error resolving spec with no embedded or referenced pipeline spec but didn't get error") @@ -120,7 +120,7 @@ func TestGetPipelineSpec_Error(t *testing.T) { }, }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, xerrors.New("something went wrong") } + gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, errors.New("something went wrong") } _, _, err := GetPipelineData(tr, gt) if err == nil { t.Fatalf("Expected error when unable to find referenced Pipeline but got none") diff --git a/pkg/reconciler/pipelinerun/resources/validate_params.go b/pkg/reconciler/pipelinerun/resources/validate_params.go index 2055a45d85b..00b0a30e96a 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params.go @@ -17,8 +17,9 @@ limitations under the License. package resources import ( + "fmt" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" ) // Validate that parameters in PipelineRun override corresponding parameters in Pipeline of the same type. @@ -41,7 +42,7 @@ func ValidateParamTypesMatching(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineR // Return an error with the misconfigured parameters' names, or return nil if there are none. if len(wrongTypeParamNames) != 0 { - return xerrors.Errorf("parameters have inconsistent types : %s", wrongTypeParamNames) + return fmt.Errorf("parameters have inconsistent types : %s", wrongTypeParamNames) } return nil } diff --git a/pkg/reconciler/taskrun/resources/image_exporter.go b/pkg/reconciler/taskrun/resources/image_exporter.go index e568c20ac34..aac984edf6d 100644 --- a/pkg/reconciler/taskrun/resources/image_exporter.go +++ b/pkg/reconciler/taskrun/resources/image_exporter.go @@ -18,11 +18,11 @@ package resources import ( "encoding/json" + "fmt" "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" ) @@ -41,17 +41,17 @@ func AddOutputImageDigestExporter( for _, trb := range tr.Spec.Outputs.Resources { boundResource, err := getBoundResource(trb.Name, tr.Spec.Outputs.Resources) if err != nil { - return xerrors.Errorf("Failed to get bound resource: %w while adding output image digest exporter", err) + return fmt.Errorf("Failed to get bound resource: %w while adding output image digest exporter", err) } resource, err := GetResourceFromBinding(&boundResource.PipelineResourceBinding, gr) if err != nil { - return xerrors.Errorf("Failed to get output pipeline Resource for taskRun %q resource %v; error: %w while adding output image digest exporter", tr.Name, boundResource, err) + return fmt.Errorf("Failed to get output pipeline Resource for taskRun %q resource %v; error: %w while adding output image digest exporter", tr.Name, boundResource, err) } if resource.Spec.Type == v1alpha1.PipelineResourceTypeImage { imageResource, err := v1alpha1.NewImageResource(resource) if err != nil { - return xerrors.Errorf("Invalid Image Resource for taskRun %q resource %v; error: %w", tr.Name, boundResource, err) + return fmt.Errorf("Invalid Image Resource for taskRun %q resource %v; error: %w", tr.Name, boundResource, err) } for _, o := range taskSpec.Outputs.Resources { if o.Name == boundResource.Name { @@ -71,7 +71,7 @@ func AddOutputImageDigestExporter( augmentedSteps := []v1alpha1.Step{} imagesJSON, err := json.Marshal(output) if err != nil { - return xerrors.Errorf("Failed to format image resource data for output image exporter: %w", err) + return fmt.Errorf("Failed to format image resource data for output image exporter: %w", err) } augmentedSteps = append(augmentedSteps, taskSpec.Steps...) diff --git a/pkg/reconciler/taskrun/resources/input_resources.go b/pkg/reconciler/taskrun/resources/input_resources.go index d3cfdcf99af..89efc19e9ee 100644 --- a/pkg/reconciler/taskrun/resources/input_resources.go +++ b/pkg/reconciler/taskrun/resources/input_resources.go @@ -17,13 +17,13 @@ limitations under the License. package resources import ( + "fmt" "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/artifacts" "go.uber.org/zap" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" ) @@ -34,7 +34,7 @@ func getBoundResource(resourceName string, boundResources []v1alpha1.TaskResourc return &br, nil } } - return nil, xerrors.Errorf("couldnt find resource named %q in bound resources %v", resourceName, boundResources) + return nil, fmt.Errorf("couldnt find resource named %q in bound resources %v", resourceName, boundResources) } // AddInputResource reads the inputs resources and adds the corresponding container steps @@ -76,11 +76,11 @@ func AddInputResource( input := taskSpec.Inputs.Resources[i] boundResource, err := getBoundResource(input.Name, taskRun.Spec.Inputs.Resources) if err != nil { - return nil, xerrors.Errorf("failed to get bound resource: %w", err) + return nil, fmt.Errorf("failed to get bound resource: %w", err) } resource, ok := inputResources[boundResource.Name] if !ok || resource == nil { - return nil, xerrors.Errorf("failed to Get Pipeline Resource for task %s with boundResource %v", taskName, boundResource) + return nil, fmt.Errorf("failed to Get Pipeline Resource for task %s with boundResource %v", taskName, boundResource) } var copyStepsFromPrevTasks []v1alpha1.Step dPath := destinationPath(input.Name, input.TargetPath) @@ -114,7 +114,7 @@ func AddInputResource( return nil, err } if err := v1alpha1.ApplyTaskModifier(taskSpec, modifier); err != nil { - return nil, xerrors.Errorf("Unabled to apply Resource %s: %w", boundResource.Name, err) + return nil, fmt.Errorf("Unabled to apply Resource %s: %w", boundResource.Name, err) } } } diff --git a/pkg/reconciler/taskrun/resources/output_resource.go b/pkg/reconciler/taskrun/resources/output_resource.go index aa6e9a0ac45..4a4ec40f945 100644 --- a/pkg/reconciler/taskrun/resources/output_resource.go +++ b/pkg/reconciler/taskrun/resources/output_resource.go @@ -17,13 +17,13 @@ limitations under the License. package resources import ( + "fmt" "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/artifacts" "go.uber.org/zap" - "golang.org/x/xerrors" "k8s.io/client-go/kubernetes" ) @@ -68,12 +68,12 @@ func AddOutputResources( for _, output := range taskSpec.Outputs.Resources { boundResource, err := getBoundResource(output.Name, taskRun.Spec.Outputs.Resources) if err != nil { - return nil, xerrors.Errorf("failed to get bound resource: %w", err) + return nil, fmt.Errorf("failed to get bound resource: %w", err) } resource, ok := outputResources[boundResource.Name] if !ok || resource == nil { - return nil, xerrors.Errorf("failed to get output pipeline Resource for task %q resource %v", taskName, boundResource) + return nil, fmt.Errorf("failed to get output pipeline Resource for task %q resource %v", taskName, boundResource) } var sourcePath string @@ -103,7 +103,7 @@ func AddOutputResources( return nil, err } if err := v1alpha1.ApplyTaskModifier(taskSpec, modifier); err != nil { - return nil, xerrors.Errorf("Unabled to apply Resource %s: %w", boundResource.Name, err) + return nil, fmt.Errorf("Unabled to apply Resource %s: %w", boundResource.Name, err) } } // Attach the PVC that will be used for `from` copying. diff --git a/pkg/reconciler/taskrun/resources/taskresourceresolution.go b/pkg/reconciler/taskrun/resources/taskresourceresolution.go index ad50ab216bb..880490a19c1 100644 --- a/pkg/reconciler/taskrun/resources/taskresourceresolution.go +++ b/pkg/reconciler/taskrun/resources/taskresourceresolution.go @@ -17,8 +17,10 @@ limitations under the License. package resources import ( + "errors" + "fmt" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -54,7 +56,7 @@ func ResolveTaskResources(ts *v1alpha1.TaskSpec, taskName string, kind v1alpha1. for _, r := range inputs { rr, err := GetResourceFromBinding(&r.PipelineResourceBinding, gr) if err != nil { - return nil, xerrors.Errorf("couldn't retrieve referenced input PipelineResource: %w", err) + return nil, fmt.Errorf("couldn't retrieve referenced input PipelineResource: %w", err) } rtr.Inputs[r.Name] = rr @@ -64,7 +66,7 @@ func ResolveTaskResources(ts *v1alpha1.TaskSpec, taskName string, kind v1alpha1. rr, err := GetResourceFromBinding(&r.PipelineResourceBinding, gr) if err != nil { - return nil, xerrors.Errorf("couldn't retrieve referenced output PipelineResource: %w", err) + return nil, fmt.Errorf("couldn't retrieve referenced output PipelineResource: %w", err) } rtr.Outputs[r.Name] = rr @@ -76,7 +78,7 @@ func ResolveTaskResources(ts *v1alpha1.TaskSpec, taskName string, kind v1alpha1. // instantiating it from the embedded spec. func GetResourceFromBinding(r *v1alpha1.PipelineResourceBinding, getter GetResource) (*v1alpha1.PipelineResource, error) { if (r.ResourceRef != nil && r.ResourceRef.Name != "") && r.ResourceSpec != nil { - return nil, xerrors.New("Both ResourseRef and ResourceSpec are defined. Expected only one") + return nil, errors.New("Both ResourseRef and ResourceSpec are defined. Expected only one") } if r.ResourceRef != nil && r.ResourceRef.Name != "" { return getter(r.ResourceRef.Name) @@ -89,5 +91,5 @@ func GetResourceFromBinding(r *v1alpha1.PipelineResourceBinding, getter GetResou Spec: *r.ResourceSpec, }, nil } - return nil, xerrors.New("Neither ResourseRef nor ResourceSpec is defined") + return nil, errors.New("Neither ResourseRef nor ResourceSpec is defined") } diff --git a/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go b/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go index 2bd42e468db..36e387fb3b3 100644 --- a/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go +++ b/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go @@ -17,11 +17,11 @@ limitations under the License. package resources import ( + "errors" "fmt" "testing" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -173,7 +173,7 @@ func TestResolveTaskRun_missingOutput(t *testing.T) { }, }}} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return nil, xerrors.New("nope") } + gr := func(n string) (*v1alpha1.PipelineResource, error) { return nil, errors.New("nope") } _, err := ResolveTaskResources(&v1alpha1.TaskSpec{}, "orchestrate", v1alpha1.NamespacedTaskKind, []v1alpha1.TaskResourceBinding{}, outputs, gr) if err == nil { t.Fatalf("Expected to get error because output resource couldn't be resolved") @@ -188,7 +188,7 @@ func TestResolveTaskRun_missingInput(t *testing.T) { Name: "git-repo", }, }}} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return nil, xerrors.New("nope") } + gr := func(n string) (*v1alpha1.PipelineResource, error) { return nil, errors.New("nope") } _, err := ResolveTaskResources(&v1alpha1.TaskSpec{}, "orchestrate", v1alpha1.NamespacedTaskKind, inputs, []v1alpha1.TaskResourceBinding{}, gr) if err == nil { diff --git a/pkg/reconciler/taskrun/resources/taskspec.go b/pkg/reconciler/taskrun/resources/taskspec.go index 90ddb795a26..4375fd403dc 100644 --- a/pkg/reconciler/taskrun/resources/taskspec.go +++ b/pkg/reconciler/taskrun/resources/taskspec.go @@ -17,8 +17,9 @@ limitations under the License. package resources import ( + "fmt" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -40,7 +41,7 @@ func GetTaskData(taskRun *v1alpha1.TaskRun, getTask GetTask) (*metav1.ObjectMeta // Get related task for taskrun t, err := getTask(taskRun.Spec.TaskRef.Name) if err != nil { - return nil, nil, xerrors.Errorf("error when listing tasks for taskRun %s: %w", taskRun.Name, err) + return nil, nil, fmt.Errorf("error when listing tasks for taskRun %s: %w", taskRun.Name, err) } taskMeta = t.TaskMetadata() taskSpec = t.TaskSpec() @@ -48,7 +49,7 @@ func GetTaskData(taskRun *v1alpha1.TaskRun, getTask GetTask) (*metav1.ObjectMeta taskMeta = taskRun.ObjectMeta taskSpec = *taskRun.Spec.TaskSpec default: - return nil, nil, xerrors.Errorf("TaskRun %s not providing TaskRef or TaskSpec", taskRun.Name) + return nil, nil, fmt.Errorf("TaskRun %s not providing TaskRef or TaskSpec", taskRun.Name) } return &taskMeta, &taskSpec, nil } diff --git a/pkg/reconciler/taskrun/resources/taskspec_test.go b/pkg/reconciler/taskrun/resources/taskspec_test.go index 5524a842ff6..e902da2b7d6 100644 --- a/pkg/reconciler/taskrun/resources/taskspec_test.go +++ b/pkg/reconciler/taskrun/resources/taskspec_test.go @@ -17,10 +17,10 @@ limitations under the License. package resources import ( + "errors" "testing" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -75,7 +75,7 @@ func TestGetTaskSpec_Embedded(t *testing.T) { }, }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("shouldn't be called") } + gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, errors.New("shouldn't be called") } taskMeta, taskSpec, err := GetTaskData(tr, gt) if err != nil { @@ -97,7 +97,7 @@ func TestGetTaskSpec_Invalid(t *testing.T) { Name: "mytaskrun", }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("shouldn't be called") } + gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, errors.New("shouldn't be called") } _, _, err := GetTaskData(tr, gt) if err == nil { t.Fatalf("Expected error resolving spec with no embedded or referenced task spec but didn't get error") @@ -115,7 +115,7 @@ func TestGetTaskSpec_Error(t *testing.T) { }, }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, xerrors.New("something went wrong") } + gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, errors.New("something went wrong") } _, _, err := GetTaskData(tr, gt) if err == nil { t.Fatalf("Expected error when unable to find referenced Task but got none") diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index 407ba6719a7..4fde0e2cd6c 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -34,7 +34,6 @@ import ( "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources/cloudevent" "go.uber.org/zap" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" @@ -411,7 +410,7 @@ func updateTaskRunResourceResult(taskRun *v1alpha1.TaskRun, pod *corev1.Pod, log func updateTaskRunStatusWithResourceResult(taskRun *v1alpha1.TaskRun, logContent []byte) error { results := []v1alpha1.PipelineResourceResult{} if err := json.Unmarshal(logContent, &results); err != nil { - return xerrors.Errorf("Failed to unmarshal output image exporter JSON output: %w", err) + return fmt.Errorf("Failed to unmarshal output image exporter JSON output: %w", err) } taskRun.Status.ResourcesResult = append(taskRun.Status.ResourcesResult, results...) return nil @@ -420,7 +419,7 @@ func updateTaskRunStatusWithResourceResult(taskRun *v1alpha1.TaskRun, logContent func (c *Reconciler) updateStatus(taskrun *v1alpha1.TaskRun) (*v1alpha1.TaskRun, error) { newtaskrun, err := c.taskRunLister.TaskRuns(taskrun.Namespace).Get(taskrun.Name) if err != nil { - return nil, xerrors.Errorf("Error getting TaskRun %s when updating status: %w", taskrun.Name, err) + return nil, fmt.Errorf("Error getting TaskRun %s when updating status: %w", taskrun.Name, err) } if !reflect.DeepEqual(taskrun.Status, newtaskrun.Status) { newtaskrun.Status = taskrun.Status @@ -432,7 +431,7 @@ func (c *Reconciler) updateStatus(taskrun *v1alpha1.TaskRun) (*v1alpha1.TaskRun, func (c *Reconciler) updateLabelsAndAnnotations(tr *v1alpha1.TaskRun) (*v1alpha1.TaskRun, error) { newTr, err := c.taskRunLister.TaskRuns(tr.Namespace).Get(tr.Name) if err != nil { - return nil, xerrors.Errorf("Error getting TaskRun %s when updating labels/annotations: %w", tr.Name, err) + return nil, fmt.Errorf("Error getting TaskRun %s when updating labels/annotations: %w", tr.Name, err) } if !reflect.DeepEqual(tr.ObjectMeta.Labels, newTr.ObjectMeta.Labels) || !reflect.DeepEqual(tr.ObjectMeta.Annotations, newTr.ObjectMeta.Annotations) { newTr.ObjectMeta.Labels = tr.ObjectMeta.Labels @@ -490,7 +489,7 @@ func (c *Reconciler) createPod(tr *v1alpha1.TaskRun, rtr *resources.ResolvedTask pod, err := podconvert.MakePod(c.Images, tr, *ts, c.KubeClientSet, c.entrypointCache) if err != nil { - return nil, xerrors.Errorf("translating Build to Pod: %w", err) + return nil, fmt.Errorf("translating Build to Pod: %w", err) } return c.KubeClientSet.CoreV1().Pods(tr.Namespace).Create(pod) @@ -533,7 +532,7 @@ func resourceImplBinding(resources map[string]*v1alpha1.PipelineResource, images for rName, r := range resources { i, err := v1alpha1.ResourceFromType(r, images) if err != nil { - return nil, xerrors.Errorf("failed to create resource %s : %v with error: %w", rName, r, err) + return nil, fmt.Errorf("failed to create resource %s : %v with error: %w", rName, r, err) } p[rName] = i } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index 5620f336e34..5754e9733c4 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -36,7 +36,6 @@ import ( "github.com/tektoncd/pipeline/test" tb "github.com/tektoncd/pipeline/test/builder" "github.com/tektoncd/pipeline/test/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" k8sapierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" @@ -1098,7 +1097,7 @@ func TestReconcilePodFetchError(t *testing.T) { clients := testAssets.Clients clients.Kube.PrependReactor("get", "pods", func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { - return true, nil, xerrors.New("induce failure fetching pods") + return true, nil, errors.New("induce failure fetching pods") }) if err := c.Reconciler.Reconcile(context.Background(), fmt.Sprintf("%s/%s", taskRun.Namespace, taskRun.Name)); err == nil { diff --git a/pkg/reconciler/taskrun/validate_resources.go b/pkg/reconciler/taskrun/validate_resources.go index defd3a391a2..b4ca29300bf 100644 --- a/pkg/reconciler/taskrun/validate_resources.go +++ b/pkg/reconciler/taskrun/validate_resources.go @@ -17,10 +17,11 @@ limitations under the License. package taskrun import ( + "fmt" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" - "golang.org/x/xerrors" ) func validateInputResources(inputs *v1alpha1.Inputs, providedResources map[string]*v1alpha1.PipelineResource) error { @@ -48,16 +49,16 @@ func validateResources(requiredResources []v1alpha1.TaskResource, providedResour } err := list.IsSame(required, provided) if err != nil { - return xerrors.Errorf("TaskRun's declared resources didn't match usage in Task: %w", err) + return fmt.Errorf("TaskRun's declared resources didn't match usage in Task: %w", err) } for _, resource := range requiredResources { r := providedResources[resource.Name] if r == nil { // This case should never be hit due to the check for missing resources at the beginning of the function - return xerrors.Errorf("resource %q is missing", resource.Name) + return fmt.Errorf("resource %q is missing", resource.Name) } if resource.Type != r.Spec.Type { - return xerrors.Errorf("resource %q should be type %q but was %q", resource.Name, r.Spec.Type, resource.Type) + return fmt.Errorf("resource %q should be type %q but was %q", resource.Name, r.Spec.Type, resource.Type) } } return nil @@ -87,11 +88,11 @@ func validateParams(inputs *v1alpha1.Inputs, params []v1alpha1.Param) error { } } if len(missingParamsNoDefaults) > 0 { - return xerrors.Errorf("missing values for these params which have no default values: %s", missingParamsNoDefaults) + return fmt.Errorf("missing values for these params which have no default values: %s", missingParamsNoDefaults) } extraParams := list.DiffLeft(providedParams, neededParams) if len(extraParams) != 0 { - return xerrors.Errorf("didn't need these params but they were provided anyway: %s", extraParams) + return fmt.Errorf("didn't need these params but they were provided anyway: %s", extraParams) } // Now that we have checked against missing/extra params, make sure each param's actual type matches @@ -103,7 +104,7 @@ func validateParams(inputs *v1alpha1.Inputs, params []v1alpha1.Param) error { } } if len(wrongTypeParamNames) != 0 { - return xerrors.Errorf("param types don't match the user-specified type: %s", wrongTypeParamNames) + return fmt.Errorf("param types don't match the user-specified type: %s", wrongTypeParamNames) } return nil @@ -112,13 +113,13 @@ func validateParams(inputs *v1alpha1.Inputs, params []v1alpha1.Param) error { // ValidateResolvedTaskResources validates task inputs, params and output matches taskrun func ValidateResolvedTaskResources(params []v1alpha1.Param, rtr *resources.ResolvedTaskResources) error { if err := validateParams(rtr.TaskSpec.Inputs, params); err != nil { - return xerrors.Errorf("invalid input params: %w", err) + return fmt.Errorf("invalid input params: %w", err) } if err := validateInputResources(rtr.TaskSpec.Inputs, rtr.Inputs); err != nil { - return xerrors.Errorf("invalid input resources: %w", err) + return fmt.Errorf("invalid input resources: %w", err) } if err := validateOutputResources(rtr.TaskSpec.Outputs, rtr.Outputs); err != nil { - return xerrors.Errorf("invalid output resources: %w", err) + return fmt.Errorf("invalid output resources: %w", err) } return nil diff --git a/pkg/reconciler/timeout_handler_test.go b/pkg/reconciler/timeout_handler_test.go index adc4f705571..2f55a0e0947 100644 --- a/pkg/reconciler/timeout_handler_test.go +++ b/pkg/reconciler/timeout_handler_test.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "fmt" "sync" "testing" "time" @@ -28,7 +29,6 @@ import ( tb "github.com/tektoncd/pipeline/test/builder" "go.uber.org/zap" "go.uber.org/zap/zaptest/observer" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -146,7 +146,7 @@ func TestTaskRunCheckTimeouts(t *testing.T) { } // not expecting callback if _, ok := gotCallback.Load(tc.taskRun.Name); ok { - return false, xerrors.Errorf("did not expect call back for %s why", tc.taskRun.Name) + return false, fmt.Errorf("did not expect call back for %s why", tc.taskRun.Name) } return true, nil }); err != nil { @@ -271,7 +271,7 @@ func TestPipelinRunCheckTimeouts(t *testing.T) { } // not expecting callback if _, ok := gotCallback.Load(tc.pr.Name); ok { - return false, xerrors.Errorf("did not expect call back for %s why", tc.pr.Name) + return false, fmt.Errorf("did not expect call back for %s why", tc.pr.Name) } return true, nil }); err != nil { diff --git a/test/cancel_test.go b/test/cancel_test.go index d23b216a6cc..c2b449b8e55 100644 --- a/test/cancel_test.go +++ b/test/cancel_test.go @@ -19,12 +19,13 @@ limitations under the License. package test import ( + "errors" + "fmt" "sync" "testing" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -94,7 +95,7 @@ func TestTaskRunPipelineRunCancel(t *testing.T) { c := pr.Status.GetCondition(apis.ConditionSucceeded) if c != nil { if c.Status == corev1.ConditionTrue || c.Status == corev1.ConditionFalse { - return true, xerrors.Errorf("pipelineRun %s already finished", "pear") + return true, errors.New(`pipelineRun "pear" already finished`) } else if c.Status == corev1.ConditionUnknown && (c.Reason == "Running" || c.Reason == "Pending") { return true, nil } @@ -120,7 +121,7 @@ func TestTaskRunPipelineRunCancel(t *testing.T) { err := WaitForTaskRunState(c, name, func(tr *v1alpha1.TaskRun) (bool, error) { if c := tr.Status.GetCondition(apis.ConditionSucceeded); c != nil { if c.IsTrue() || c.IsFalse() { - return true, xerrors.Errorf("taskRun %s already finished!", name) + return true, fmt.Errorf("taskRun %q already finished!", name) } else if c.IsUnknown() && (c.Reason == "Running" || c.Reason == "Pending") { return true, nil } @@ -151,9 +152,9 @@ func TestTaskRunPipelineRunCancel(t *testing.T) { if c.Reason == "PipelineRunCancelled" { return true, nil } - return true, xerrors.Errorf("pipelineRun %s completed with the wrong reason: %s", "pear", c.Reason) + return true, fmt.Errorf(`pipelineRun "pear" completed with the wrong reason: %s`, c.Reason) } else if c.IsTrue() { - return true, xerrors.Errorf("pipelineRun %s completed successfully, should have been cancelled", "pear") + return true, errors.New(`pipelineRun "pear" completed successfully, should have been cancelled`) } } return false, nil @@ -172,9 +173,9 @@ func TestTaskRunPipelineRunCancel(t *testing.T) { if c.Reason == "TaskRunCancelled" { return true, nil } - return true, xerrors.Errorf("taskRun %s completed with the wrong reason: %s", name, c.Reason) + return true, fmt.Errorf("taskRun %q completed with the wrong reason: %s", name, c.Reason) } else if c.IsTrue() { - return true, xerrors.Errorf("taskRun %s completed successfully, should have been cancelled", name) + return true, fmt.Errorf("taskRun %q completed successfully, should have been cancelled", name) } } return false, nil diff --git a/test/helm_task_test.go b/test/helm_task_test.go index b375cd3f341..f602c4744b3 100644 --- a/test/helm_task_test.go +++ b/test/helm_task_test.go @@ -27,7 +27,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" tb "github.com/tektoncd/pipeline/test/builder" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1beta1" "k8s.io/apimachinery/pkg/api/errors" @@ -125,7 +124,7 @@ func TestHelmDeployPipelineRun(t *testing.T) { return false, nil } if resp != nil && resp.StatusCode != http.StatusOK { - return true, xerrors.Errorf("Expected 200 but received %d response code from service at http://%s:8080", resp.StatusCode, serviceIP) + return true, fmt.Errorf("Expected 200 but received %d response code from service at http://%s:8080", resp.StatusCode, serviceIP) } return true, nil }) diff --git a/test/init_test.go b/test/init_test.go index 1c7ad102cf4..736535fc168 100644 --- a/test/init_test.go +++ b/test/init_test.go @@ -30,7 +30,6 @@ import ( "github.com/ghodss/yaml" "github.com/tektoncd/pipeline/pkg/names" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -163,7 +162,7 @@ func getCRDYaml(cs *clients, ns string) ([]byte, error) { ps, err := cs.PipelineClient.List(metav1.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("could not get pipeline: %w", err) + return nil, fmt.Errorf("could not get pipeline: %w", err) } for _, i := range ps.Items { printOrAdd(i) @@ -171,7 +170,7 @@ func getCRDYaml(cs *clients, ns string) ([]byte, error) { prs, err := cs.PipelineResourceClient.List(metav1.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("could not get pipelinerun resource: %w", err) + return nil, fmt.Errorf("could not get pipelinerun resource: %w", err) } for _, i := range prs.Items { printOrAdd(i) @@ -179,7 +178,7 @@ func getCRDYaml(cs *clients, ns string) ([]byte, error) { prrs, err := cs.PipelineRunClient.List(metav1.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("could not get pipelinerun: %w", err) + return nil, fmt.Errorf("could not get pipelinerun: %w", err) } for _, i := range prrs.Items { printOrAdd(i) @@ -187,14 +186,14 @@ func getCRDYaml(cs *clients, ns string) ([]byte, error) { ts, err := cs.TaskClient.List(metav1.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("could not get tasks: %w", err) + return nil, fmt.Errorf("could not get tasks: %w", err) } for _, i := range ts.Items { printOrAdd(i) } trs, err := cs.TaskRunClient.List(metav1.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("could not get taskrun: %w", err) + return nil, fmt.Errorf("could not get taskrun: %w", err) } for _, i := range trs.Items { printOrAdd(i) @@ -202,7 +201,7 @@ func getCRDYaml(cs *clients, ns string) ([]byte, error) { pods, err := cs.KubeClient.Kube.CoreV1().Pods(ns).List(metav1.ListOptions{}) if err != nil { - return nil, xerrors.Errorf("could not get pods: %w", err) + return nil, fmt.Errorf("could not get pods: %w", err) } for _, i := range pods.Items { printOrAdd(i) diff --git a/test/ko_test.go b/test/ko_test.go index f4e51b58688..8fd393fd600 100644 --- a/test/ko_test.go +++ b/test/ko_test.go @@ -19,11 +19,10 @@ limitations under the License. package test import ( + "errors" "fmt" "os" "testing" - - "golang.org/x/xerrors" ) var ( @@ -48,7 +47,7 @@ func getDockerRepo() (string, error) { // it is used here to dynamically get the docker registry to push the image to dockerRepo := os.Getenv("KO_DOCKER_REPO") if dockerRepo == "" { - return "", xerrors.New("KO_DOCKER_REPO env variable is required") + return "", errors.New("KO_DOCKER_REPO env variable is required") } return fmt.Sprintf("%s/kanikotasktest", dockerRepo), nil } diff --git a/test/secret.go b/test/secret.go index 63985c903c2..37ea00c080a 100644 --- a/test/secret.go +++ b/test/secret.go @@ -19,11 +19,11 @@ limitations under the License. package test import ( + "fmt" "io/ioutil" "os" "testing" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" knativetest "knative.dev/pkg/test" @@ -50,7 +50,7 @@ func CreateGCPServiceAccountSecret(t *testing.T, c *knativetest.KubeClient, name bs, err := ioutil.ReadFile(file) if err != nil { - return false, xerrors.Errorf("couldn't read secret json from %s: %w", file, err) + return false, fmt.Errorf("couldn't read secret json from %s: %w", file, err) } sec.Data = map[string][]byte{ diff --git a/test/timeout_test.go b/test/timeout_test.go index f9ea9cdb346..194f50ba7c9 100644 --- a/test/timeout_test.go +++ b/test/timeout_test.go @@ -27,7 +27,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" tb "github.com/tektoncd/pipeline/test/builder" - "golang.org/x/xerrors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -69,7 +68,7 @@ func TestPipelineRunTimeout(t *testing.T) { c := pr.Status.GetCondition(apis.ConditionSucceeded) if c != nil { if c.Status == corev1.ConditionTrue || c.Status == corev1.ConditionFalse { - return true, xerrors.Errorf("pipelineRun %s already finished!", pipelineRun.Name) + return true, fmt.Errorf("pipelineRun %q already finished!", pipelineRun.Name) } else if c.Status == corev1.ConditionUnknown && (c.Reason == "Running" || c.Reason == "Pending") { return true, nil } @@ -94,7 +93,7 @@ func TestPipelineRunTimeout(t *testing.T) { c := tr.Status.GetCondition(apis.ConditionSucceeded) if c != nil { if c.Status == corev1.ConditionTrue || c.Status == corev1.ConditionFalse { - return true, xerrors.Errorf("taskRun %s already finished!", name) + return true, fmt.Errorf("taskRun %q already finished!", name) } else if c.Status == corev1.ConditionUnknown && (c.Reason == "Running" || c.Reason == "Pending") { return true, nil } @@ -123,9 +122,9 @@ func TestPipelineRunTimeout(t *testing.T) { if c.Reason == resources.ReasonTimedOut { return true, nil } - return true, xerrors.Errorf("pipelineRun %s completed with the wrong reason: %s", pipelineRun.Name, c.Reason) + return true, fmt.Errorf("pipelineRun %q completed with the wrong reason: %s", pipelineRun.Name, c.Reason) } else if c.Status == corev1.ConditionTrue { - return true, xerrors.Errorf("pipelineRun %s completed successfully, should have been timed out", pipelineRun.Name) + return true, fmt.Errorf("pipelineRun %q completed successfully, should have been timed out", pipelineRun.Name) } } return false, nil @@ -146,9 +145,9 @@ func TestPipelineRunTimeout(t *testing.T) { if cond.Reason == "TaskRunTimeout" { return true, nil } - return true, xerrors.Errorf("taskRun %s completed with the wrong reason: %s", task.Name, cond.Reason) + return true, fmt.Errorf("taskRun %q completed with the wrong reason: %s", task.Name, cond.Reason) } else if cond.Status == corev1.ConditionTrue { - return true, xerrors.Errorf("taskRun %s completed successfully, should have been timed out", name) + return true, fmt.Errorf("taskRun %q completed successfully, should have been timed out", name) } } return false, nil @@ -262,9 +261,9 @@ func TestTaskRunTimeout(t *testing.T) { if cond.Reason == "TaskRunTimeout" { return true, nil } - return true, xerrors.Errorf("taskRun %s completed with the wrong reason: %s", "run-giraffe", cond.Reason) + return true, fmt.Errorf("taskRun %q completed with the wrong reason: %s", "run-giraffe", cond.Reason) } else if cond.Status == corev1.ConditionTrue { - return true, xerrors.Errorf("taskRun %s completed successfully, should have been timed out", "run-giraffe") + return true, fmt.Errorf("taskRun %q completed successfully, should have been timed out", "run-giraffe") } } diff --git a/test/wait.go b/test/wait.go index 4289302695d..3d1a366b1a8 100644 --- a/test/wait.go +++ b/test/wait.go @@ -50,7 +50,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "go.opencensus.io/trace" - "golang.org/x/xerrors" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -168,7 +167,7 @@ func TaskRunSucceed(name string) TaskRunStateFn { if c.Status == corev1.ConditionTrue { return true, nil } else if c.Status == corev1.ConditionFalse { - return true, xerrors.Errorf("task run %s failed!", name) + return true, fmt.Errorf("task run %q failed!", name) } } return false, nil @@ -182,7 +181,7 @@ func TaskRunFailed(name string) TaskRunStateFn { c := tr.Status.GetCondition(apis.ConditionSucceeded) if c != nil { if c.Status == corev1.ConditionTrue { - return true, xerrors.Errorf("task run %s succeeded!", name) + return true, fmt.Errorf("task run %q succeeded!", name) } else if c.Status == corev1.ConditionFalse { return true, nil } @@ -200,7 +199,7 @@ func PipelineRunSucceed(name string) PipelineRunStateFn { if c.Status == corev1.ConditionTrue { return true, nil } else if c.Status == corev1.ConditionFalse { - return true, xerrors.Errorf("pipeline run %s failed!", name) + return true, fmt.Errorf("pipeline run %q failed!", name) } } return false, nil @@ -214,7 +213,7 @@ func PipelineRunFailed(name string) PipelineRunStateFn { c := tr.Status.GetCondition(apis.ConditionSucceeded) if c != nil { if c.Status == corev1.ConditionTrue { - return true, xerrors.Errorf("task run %s succeeded!", name) + return true, fmt.Errorf("task run %q succeeded!", name) } else if c.Status == corev1.ConditionFalse { return true, nil } diff --git a/third_party/VENDOR-LICENSE b/third_party/VENDOR-LICENSE index 178089bd2bd..f3470b0588d 100644 --- a/third_party/VENDOR-LICENSE +++ b/third_party/VENDOR-LICENSE @@ -6628,39 +6628,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -=========================================================== -Import: github.com/tektoncd/pipeline/vendor/golang.org/x/xerrors - -Copyright (c) 2019 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - =========================================================== Import: github.com/tektoncd/pipeline/vendor/google.golang.org/api diff --git a/vendor/golang.org/x/xerrors/LICENSE b/vendor/golang.org/x/xerrors/LICENSE deleted file mode 100644 index e4a47e17f14..00000000000 --- a/vendor/golang.org/x/xerrors/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2019 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/xerrors/PATENTS b/vendor/golang.org/x/xerrors/PATENTS deleted file mode 100644 index 733099041f8..00000000000 --- a/vendor/golang.org/x/xerrors/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/xerrors/adaptor.go b/vendor/golang.org/x/xerrors/adaptor.go deleted file mode 100644 index 4317f248331..00000000000 --- a/vendor/golang.org/x/xerrors/adaptor.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xerrors - -import ( - "bytes" - "fmt" - "io" - "reflect" - "strconv" -) - -// FormatError calls the FormatError method of f with an errors.Printer -// configured according to s and verb, and writes the result to s. -func FormatError(f Formatter, s fmt.State, verb rune) { - // Assuming this function is only called from the Format method, and given - // that FormatError takes precedence over Format, it cannot be called from - // any package that supports errors.Formatter. It is therefore safe to - // disregard that State may be a specific printer implementation and use one - // of our choice instead. - - // limitations: does not support printing error as Go struct. - - var ( - sep = " " // separator before next error - p = &state{State: s} - direct = true - ) - - var err error = f - - switch verb { - // Note that this switch must match the preference order - // for ordinary string printing (%#v before %+v, and so on). - - case 'v': - if s.Flag('#') { - if stringer, ok := err.(fmt.GoStringer); ok { - io.WriteString(&p.buf, stringer.GoString()) - goto exit - } - // proceed as if it were %v - } else if s.Flag('+') { - p.printDetail = true - sep = "\n - " - } - case 's': - case 'q', 'x', 'X': - // Use an intermediate buffer in the rare cases that precision, - // truncation, or one of the alternative verbs (q, x, and X) are - // specified. - direct = false - - default: - p.buf.WriteString("%!") - p.buf.WriteRune(verb) - p.buf.WriteByte('(') - switch { - case err != nil: - p.buf.WriteString(reflect.TypeOf(f).String()) - default: - p.buf.WriteString("") - } - p.buf.WriteByte(')') - io.Copy(s, &p.buf) - return - } - -loop: - for { - switch v := err.(type) { - case Formatter: - err = v.FormatError((*printer)(p)) - case fmt.Formatter: - v.Format(p, 'v') - break loop - default: - io.WriteString(&p.buf, v.Error()) - break loop - } - if err == nil { - break - } - if p.needColon || !p.printDetail { - p.buf.WriteByte(':') - p.needColon = false - } - p.buf.WriteString(sep) - p.inDetail = false - p.needNewline = false - } - -exit: - width, okW := s.Width() - prec, okP := s.Precision() - - if !direct || (okW && width > 0) || okP { - // Construct format string from State s. - format := []byte{'%'} - if s.Flag('-') { - format = append(format, '-') - } - if s.Flag('+') { - format = append(format, '+') - } - if s.Flag(' ') { - format = append(format, ' ') - } - if okW { - format = strconv.AppendInt(format, int64(width), 10) - } - if okP { - format = append(format, '.') - format = strconv.AppendInt(format, int64(prec), 10) - } - format = append(format, string(verb)...) - fmt.Fprintf(s, string(format), p.buf.String()) - } else { - io.Copy(s, &p.buf) - } -} - -var detailSep = []byte("\n ") - -// state tracks error printing state. It implements fmt.State. -type state struct { - fmt.State - buf bytes.Buffer - - printDetail bool - inDetail bool - needColon bool - needNewline bool -} - -func (s *state) Write(b []byte) (n int, err error) { - if s.printDetail { - if len(b) == 0 { - return 0, nil - } - if s.inDetail && s.needColon { - s.needNewline = true - if b[0] == '\n' { - b = b[1:] - } - } - k := 0 - for i, c := range b { - if s.needNewline { - if s.inDetail && s.needColon { - s.buf.WriteByte(':') - s.needColon = false - } - s.buf.Write(detailSep) - s.needNewline = false - } - if c == '\n' { - s.buf.Write(b[k:i]) - k = i + 1 - s.needNewline = true - } - } - s.buf.Write(b[k:]) - if !s.inDetail { - s.needColon = true - } - } else if !s.inDetail { - s.buf.Write(b) - } - return len(b), nil -} - -// printer wraps a state to implement an xerrors.Printer. -type printer state - -func (s *printer) Print(args ...interface{}) { - if !s.inDetail || s.printDetail { - fmt.Fprint((*state)(s), args...) - } -} - -func (s *printer) Printf(format string, args ...interface{}) { - if !s.inDetail || s.printDetail { - fmt.Fprintf((*state)(s), format, args...) - } -} - -func (s *printer) Detail() bool { - s.inDetail = true - return s.printDetail -} diff --git a/vendor/golang.org/x/xerrors/doc.go b/vendor/golang.org/x/xerrors/doc.go deleted file mode 100644 index 1ad48f50b5b..00000000000 --- a/vendor/golang.org/x/xerrors/doc.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package xerrors implements functions to manipulate errors. -// -// This package supports transitioning to the Go 2 proposal for error values: -// https://golang.org/design/29934-error-values -// -// Most of the functions and types in this package will be incorporated into the -// standard library's errors package in Go 1.13; the behavior of this package's -// Errorf function will be incorporated into the standard library's fmt.Errorf. -// Use this package to get equivalent behavior in all supported Go versions. For -// example, create errors using -// -// xerrors.New("write failed") -// -// or -// -// xerrors.Errorf("while reading: %v", err) -// -// If you want your error type to participate in the new formatting -// implementation for %v and %+v, provide it with a Format method that calls -// xerrors.FormatError, as shown in the example for FormatError. -package xerrors // import "golang.org/x/xerrors" diff --git a/vendor/golang.org/x/xerrors/errors.go b/vendor/golang.org/x/xerrors/errors.go deleted file mode 100644 index e88d3772d86..00000000000 --- a/vendor/golang.org/x/xerrors/errors.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xerrors - -import "fmt" - -// errorString is a trivial implementation of error. -type errorString struct { - s string - frame Frame -} - -// New returns an error that formats as the given text. -// -// The returned error contains a Frame set to the caller's location and -// implements Formatter to show this information when printed with details. -func New(text string) error { - return &errorString{text, Caller(1)} -} - -func (e *errorString) Error() string { - return e.s -} - -func (e *errorString) Format(s fmt.State, v rune) { FormatError(e, s, v) } - -func (e *errorString) FormatError(p Printer) (next error) { - p.Print(e.s) - e.frame.Format(p) - return nil -} diff --git a/vendor/golang.org/x/xerrors/fmt.go b/vendor/golang.org/x/xerrors/fmt.go deleted file mode 100644 index 74c1c93ec9c..00000000000 --- a/vendor/golang.org/x/xerrors/fmt.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xerrors - -import ( - "fmt" - "strings" - - "golang.org/x/xerrors/internal" -) - -// Errorf formats according to a format specifier and returns the string as a -// value that satisfies error. -// -// The returned error includes the file and line number of the caller when -// formatted with additional detail enabled. If the last argument is an error -// the returned error's Format method will return it if the format string ends -// with ": %s", ": %v", or ": %w". If the last argument is an error and the -// format string ends with ": %w", the returned error implements Wrapper -// with an Unwrap method returning it. -func Errorf(format string, a ...interface{}) error { - err, wrap := lastError(format, a) - format = formatPlusW(format) - if err == nil { - return &noWrapError{fmt.Sprintf(format, a...), nil, Caller(1)} - } - - // TODO: this is not entirely correct. The error value could be - // printed elsewhere in format if it mixes numbered with unnumbered - // substitutions. With relatively small changes to doPrintf we can - // have it optionally ignore extra arguments and pass the argument - // list in its entirety. - msg := fmt.Sprintf(format[:len(format)-len(": %s")], a[:len(a)-1]...) - frame := Frame{} - if internal.EnableTrace { - frame = Caller(1) - } - if wrap { - return &wrapError{msg, err, frame} - } - return &noWrapError{msg, err, frame} -} - -// formatPlusW is used to avoid the vet check that will barf at %w. -func formatPlusW(s string) string { - return s -} - -func lastError(format string, a []interface{}) (err error, wrap bool) { - wrap = strings.HasSuffix(format, ": %w") - if !wrap && - !strings.HasSuffix(format, ": %s") && - !strings.HasSuffix(format, ": %v") { - return nil, false - } - - if len(a) == 0 { - return nil, false - } - - err, ok := a[len(a)-1].(error) - if !ok { - return nil, false - } - - return err, wrap -} - -type noWrapError struct { - msg string - err error - frame Frame -} - -func (e *noWrapError) Error() string { - return fmt.Sprint(e) -} - -func (e *noWrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) } - -func (e *noWrapError) FormatError(p Printer) (next error) { - p.Print(e.msg) - e.frame.Format(p) - return e.err -} - -type wrapError struct { - msg string - err error - frame Frame -} - -func (e *wrapError) Error() string { - return fmt.Sprint(e) -} - -func (e *wrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) } - -func (e *wrapError) FormatError(p Printer) (next error) { - p.Print(e.msg) - e.frame.Format(p) - return e.err -} - -func (e *wrapError) Unwrap() error { - return e.err -} diff --git a/vendor/golang.org/x/xerrors/format.go b/vendor/golang.org/x/xerrors/format.go deleted file mode 100644 index 1bc9c26b97f..00000000000 --- a/vendor/golang.org/x/xerrors/format.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xerrors - -// A Formatter formats error messages. -type Formatter interface { - error - - // FormatError prints the receiver's first error and returns the next error in - // the error chain, if any. - FormatError(p Printer) (next error) -} - -// A Printer formats error messages. -// -// The most common implementation of Printer is the one provided by package fmt -// during Printf (as of Go 1.13). Localization packages such as golang.org/x/text/message -// typically provide their own implementations. -type Printer interface { - // Print appends args to the message output. - Print(args ...interface{}) - - // Printf writes a formatted string. - Printf(format string, args ...interface{}) - - // Detail reports whether error detail is requested. - // After the first call to Detail, all text written to the Printer - // is formatted as additional detail, or ignored when - // detail has not been requested. - // If Detail returns false, the caller can avoid printing the detail at all. - Detail() bool -} diff --git a/vendor/golang.org/x/xerrors/frame.go b/vendor/golang.org/x/xerrors/frame.go deleted file mode 100644 index 0de628ec501..00000000000 --- a/vendor/golang.org/x/xerrors/frame.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xerrors - -import ( - "runtime" -) - -// A Frame contains part of a call stack. -type Frame struct { - // Make room for three PCs: the one we were asked for, what it called, - // and possibly a PC for skipPleaseUseCallersFrames. See: - // https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169 - frames [3]uintptr -} - -// Caller returns a Frame that describes a frame on the caller's stack. -// The argument skip is the number of frames to skip over. -// Caller(0) returns the frame for the caller of Caller. -func Caller(skip int) Frame { - var s Frame - runtime.Callers(skip+1, s.frames[:]) - return s -} - -// location reports the file, line, and function of a frame. -// -// The returned function may be "" even if file and line are not. -func (f Frame) location() (function, file string, line int) { - frames := runtime.CallersFrames(f.frames[:]) - if _, ok := frames.Next(); !ok { - return "", "", 0 - } - fr, ok := frames.Next() - if !ok { - return "", "", 0 - } - return fr.Function, fr.File, fr.Line -} - -// Format prints the stack as error detail. -// It should be called from an error's Format implementation -// after printing any other error detail. -func (f Frame) Format(p Printer) { - if p.Detail() { - function, file, line := f.location() - if function != "" { - p.Printf("%s\n ", function) - } - if file != "" { - p.Printf("%s:%d\n", file, line) - } - } -} diff --git a/vendor/golang.org/x/xerrors/internal/internal.go b/vendor/golang.org/x/xerrors/internal/internal.go deleted file mode 100644 index 89f4eca5df7..00000000000 --- a/vendor/golang.org/x/xerrors/internal/internal.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package internal - -// EnableTrace indicates whether stack information should be recorded in errors. -var EnableTrace = true diff --git a/vendor/golang.org/x/xerrors/wrap.go b/vendor/golang.org/x/xerrors/wrap.go deleted file mode 100644 index 9a3b510374e..00000000000 --- a/vendor/golang.org/x/xerrors/wrap.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xerrors - -import ( - "reflect" -) - -// A Wrapper provides context around another error. -type Wrapper interface { - // Unwrap returns the next error in the error chain. - // If there is no next error, Unwrap returns nil. - Unwrap() error -} - -// Opaque returns an error with the same error formatting as err -// but that does not match err and cannot be unwrapped. -func Opaque(err error) error { - return noWrapper{err} -} - -type noWrapper struct { - error -} - -func (e noWrapper) FormatError(p Printer) (next error) { - if f, ok := e.error.(Formatter); ok { - return f.FormatError(p) - } - p.Print(e.error) - return nil -} - -// Unwrap returns the result of calling the Unwrap method on err, if err implements -// Unwrap. Otherwise, Unwrap returns nil. -func Unwrap(err error) error { - u, ok := err.(Wrapper) - if !ok { - return nil - } - return u.Unwrap() -} - -// Is reports whether any error in err's chain matches target. -// -// An error is considered to match a target if it is equal to that target or if -// it implements a method Is(error) bool such that Is(target) returns true. -func Is(err, target error) bool { - if target == nil { - return err == target - } - - isComparable := reflect.TypeOf(target).Comparable() - for { - if isComparable && err == target { - return true - } - if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) { - return true - } - // TODO: consider supporing target.Is(err). This would allow - // user-definable predicates, but also may allow for coping with sloppy - // APIs, thereby making it easier to get away with them. - if err = Unwrap(err); err == nil { - return false - } - } -} - -// As finds the first error in err's chain that matches the type to which target -// points, and if so, sets the target to its value and returns true. An error -// matches a type if it is assignable to the target type, or if it has a method -// As(interface{}) bool such that As(target) returns true. As will panic if target -// is not a non-nil pointer to a type which implements error or is of interface type. -// -// The As method should set the target to its value and return true if err -// matches the type to which target points. -func As(err error, target interface{}) bool { - if target == nil { - panic("errors: target cannot be nil") - } - val := reflect.ValueOf(target) - typ := val.Type() - if typ.Kind() != reflect.Ptr || val.IsNil() { - panic("errors: target must be a non-nil pointer") - } - if e := typ.Elem(); e.Kind() != reflect.Interface && !e.Implements(errorType) { - panic("errors: *target must be interface or implement error") - } - targetType := typ.Elem() - for err != nil { - if reflect.TypeOf(err).AssignableTo(targetType) { - val.Elem().Set(reflect.ValueOf(err)) - return true - } - if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) { - return true - } - err = Unwrap(err) - } - return false -} - -var errorType = reflect.TypeOf((*error)(nil)).Elem()