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 {