From ceb42d09389c92be3c50859f4ae1df898e8cefcd Mon Sep 17 00:00:00 2001 From: vivian-xu Date: Wed, 23 Jun 2021 10:14:19 +0800 Subject: [PATCH] Update github.com/pkg/errors with go native errors pkg --- test/e2e/windows/gmsa_full.go | 13 ++++++------- test/e2e/windows/utils.go | 7 +++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/e2e/windows/gmsa_full.go b/test/e2e/windows/gmsa_full.go index 7e287c0e28d..b1b76c48824 100644 --- a/test/e2e/windows/gmsa_full.go +++ b/test/e2e/windows/gmsa_full.go @@ -58,7 +58,6 @@ import ( "github.com/onsi/ginkgo" "github.com/onsi/gomega" - "github.com/pkg/errors" ) const ( @@ -248,7 +247,7 @@ func deployGmsaWebhook(f *framework.Framework, deployScriptPath string) (func(), tempDir, err := ioutil.TempDir("", "") if err != nil { - return cleanUpFunc, errors.Wrapf(err, "unable to create temp dir") + return cleanUpFunc, fmt.Errorf("unable to create temp dir: %w", err) } manifestsFile := path.Join(tempDir, "manifests.yml") @@ -275,7 +274,7 @@ func deployGmsaWebhook(f *framework.Framework, deployScriptPath string) (func(), if err == nil { framework.Logf("GMSA webhook successfully deployed, output:\n%s", string(output)) } else { - err = errors.Wrapf(err, "unable to deploy GMSA webhook, output:\n%s", string(output)) + err = fmt.Errorf("unable to deploy GMSA webhook, output:\n%s: %w", string(output), err) } return cleanUpFunc, err @@ -290,7 +289,7 @@ func createGmsaCustomResource(ns string, crdManifestContents string) (func(), er tempFile, err := ioutil.TempFile("", "") if err != nil { - return cleanUpFunc, errors.Wrapf(err, "unable to create temp file") + return cleanUpFunc, fmt.Errorf("unable to create temp file: %w", err) } defer tempFile.Close() @@ -301,13 +300,13 @@ func createGmsaCustomResource(ns string, crdManifestContents string) (func(), er _, err = tempFile.WriteString(crdManifestContents) if err != nil { - err = errors.Wrapf(err, "unable to write GMSA contents to %q", tempFile.Name()) + err = fmt.Errorf("unable to write GMSA contents to %q: %w", tempFile.Name(), err) return cleanUpFunc, err } output, err := framework.RunKubectl(ns, "apply", "--filename", tempFile.Name()) if err != nil { - err = errors.Wrapf(err, "unable to create custom resource, output:\n%s", output) + err = fmt.Errorf("unable to create custom resource, output:\n%s: %w", output, err) } return cleanUpFunc, err @@ -339,7 +338,7 @@ func createRBACRoleForGmsa(f *framework.Framework) (string, func(), error) { _, err := f.ClientSet.RbacV1().ClusterRoles().Create(context.TODO(), role, metav1.CreateOptions{}) if err != nil { - err = errors.Wrapf(err, "unable to create RBAC cluster role %q", roleName) + err = fmt.Errorf("unable to create RBAC cluster role %q: %w", roleName, err) } return roleName, cleanUpFunc, err diff --git a/test/e2e/windows/utils.go b/test/e2e/windows/utils.go index c89c9d00ae2..2726ba43760 100644 --- a/test/e2e/windows/utils.go +++ b/test/e2e/windows/utils.go @@ -17,11 +17,10 @@ limitations under the License. package windows import ( + "fmt" "io" "io/ioutil" "net/http" - - "github.com/pkg/errors" ) // downloadFile saves a remote URL to a local temp file, and returns its path. @@ -29,13 +28,13 @@ import ( func downloadFile(url string) (string, error) { response, err := http.Get(url) if err != nil { - return "", errors.Wrapf(err, "unable to download from %q", url) + return "", fmt.Errorf("unable to download from %q: %w", url, err) } defer response.Body.Close() tempFile, err := ioutil.TempFile("", "") if err != nil { - return "", errors.Wrapf(err, "unable to create temp file") + return "", fmt.Errorf("unable to create temp file: %w", err) } defer tempFile.Close()