diff --git a/config.go b/config.go index a05966a5..54cf4888 100644 --- a/config.go +++ b/config.go @@ -1,9 +1,9 @@ package groot import ( + "fmt" "os" - "github.com/pkg/errors" yaml "gopkg.in/yaml.v2" ) @@ -26,11 +26,11 @@ func parseConfig(configFilePath string) (conf config, err error) { contents, err := os.ReadFile(configFilePath) if err != nil { - return config{}, errors.Wrap(err, "reading config file") + return config{}, fmt.Errorf("reading config file: %w", err) } if err := yaml.Unmarshal(contents, &conf); err != nil { - return config{}, errors.Wrap(err, "parsing config file") + return config{}, fmt.Errorf("parsing config file: %w", err) } return conf, nil diff --git a/create.go b/create.go index 89e91a0c..41c9c746 100644 --- a/create.go +++ b/create.go @@ -5,7 +5,6 @@ import ( "code.cloudfoundry.org/groot/imagepuller" runspec "github.com/opencontainers/runtime-spec/specs-go" - "github.com/pkg/errors" ) func (g *Groot) Create(handle string, diskLimit int64, excludeImageFromQuota bool) (runspec.Spec, error) { @@ -24,7 +23,7 @@ func (g *Groot) Create(handle string, diskLimit int64, excludeImageFromQuota boo image, err := g.ImagePuller.Pull(g.Logger, imageSpec) if err != nil { - return runspec.Spec{}, errors.Wrap(err, "pulling image") + return runspec.Spec{}, fmt.Errorf("pulling image: %w", err) } quota := diskLimit @@ -38,7 +37,7 @@ func (g *Groot) Create(handle string, diskLimit int64, excludeImageFromQuota boo bundle, err := g.Driver.Bundle(g.Logger.Session("bundle"), handle, image.ChainIDs, quota) if err != nil { - return runspec.Spec{}, errors.Wrap(err, "creating bundle") + return runspec.Spec{}, fmt.Errorf("creating bundle: %w", err) } if len(image.Config.Config.Env) > 0 { diff --git a/create_test.go b/create_test.go index 60def3a7..ec2622c4 100644 --- a/create_test.go +++ b/create_test.go @@ -2,6 +2,7 @@ package groot_test import ( "bytes" + "errors" "io" "code.cloudfoundry.org/groot" @@ -13,7 +14,6 @@ import ( . "github.com/onsi/gomega" imgspec "github.com/opencontainers/image-spec/specs-go/v1" specs "github.com/opencontainers/runtime-spec/specs-go" - errors "github.com/pkg/errors" ) var _ = Describe("Create", func() { diff --git a/delete_test.go b/delete_test.go index ff2ad3e5..32c91f48 100644 --- a/delete_test.go +++ b/delete_test.go @@ -1,12 +1,13 @@ package groot_test import ( + "errors" + "code.cloudfoundry.org/groot" "code.cloudfoundry.org/groot/grootfakes" "code.cloudfoundry.org/lager/v3/lagertest" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - errors "github.com/pkg/errors" ) var _ = Describe("Delete", func() { diff --git a/fetcher/filefetcher/file_fetcher.go b/fetcher/filefetcher/file_fetcher.go index 9f43792d..8ad49859 100644 --- a/fetcher/filefetcher/file_fetcher.go +++ b/fetcher/filefetcher/file_fetcher.go @@ -3,6 +3,7 @@ package filefetcher // import "code.cloudfoundry.org/groot/fetcher/filefetcher" import ( "crypto/sha256" "encoding/hex" + "errors" "fmt" "io" "net/url" @@ -10,7 +11,6 @@ import ( "code.cloudfoundry.org/groot/imagepuller" "code.cloudfoundry.org/lager/v3" - "github.com/pkg/errors" ) type FileFetcher struct { @@ -29,17 +29,17 @@ func (l *FileFetcher) StreamBlob(logger lager.Logger, layerInfo imagepuller.Laye defer logger.Info("ending") if _, err := os.Stat(l.imagePath); err != nil { - return nil, 0, errors.Wrapf(err, "local image not found in `%s`", l.imagePath) + return nil, 0, fmt.Errorf("local image not found in `%s`: %w", l.imagePath, err) } if err := l.validateImage(); err != nil { - return nil, 0, errors.Wrap(err, "invalid base image") + return nil, 0, fmt.Errorf("invalid base image: %w", err) } logger.Debug("opening-tar", lager.Data{"imagePath": l.imagePath}) stream, err := os.Open(l.imagePath) if err != nil { - return nil, 0, errors.Wrap(err, "reading local image") + return nil, 0, fmt.Errorf("reading local image: %w", err) } return stream, 0, nil @@ -54,7 +54,7 @@ func (l *FileFetcher) ImageInfo(logger lager.Logger) (imagepuller.ImageInfo, err stat, err := os.Stat(l.imagePath) if err != nil { return imagepuller.ImageInfo{}, - errors.Wrap(err, "fetching image timestamp") + fmt.Errorf("fetching image timestamp: %w", err) } return imagepuller.ImageInfo{ diff --git a/fetcher/layerfetcher/blob_reader.go b/fetcher/layerfetcher/blob_reader.go index 343df65b..7d6ea453 100644 --- a/fetcher/layerfetcher/blob_reader.go +++ b/fetcher/layerfetcher/blob_reader.go @@ -1,10 +1,9 @@ package layerfetcher // import "code.cloudfoundry.org/groot/fetcher/layerfetcher" import ( + "fmt" "io" "os" - - errorspkg "github.com/pkg/errors" ) type BlobReader struct { @@ -15,7 +14,7 @@ type BlobReader struct { func NewBlobReader(blobPath string) (*BlobReader, error) { reader, err := os.Open(blobPath) if err != nil { - return nil, errorspkg.Wrap(err, "failed to open blob") + return nil, fmt.Errorf("failed to open blob: %w", err) } return &BlobReader{ diff --git a/fetcher/layerfetcher/layer_fetcher.go b/fetcher/layerfetcher/layer_fetcher.go index 33a984e5..f079a319 100644 --- a/fetcher/layerfetcher/layer_fetcher.go +++ b/fetcher/layerfetcher/layer_fetcher.go @@ -13,7 +13,6 @@ import ( "github.com/containers/image/v5/types" imgspec "github.com/opencontainers/image-spec/specs-go/v1" - errorspkg "github.com/pkg/errors" ) //go:generate counterfeiter . Source @@ -79,7 +78,7 @@ func (f *LayerFetcher) StreamBlob(logger lager.Logger, layerInfo imagepuller.Lay blobReader, err := NewBlobReader(blobFilePath) if err != nil { logger.Error("blob-reader-failed", err) - return nil, 0, errorspkg.Wrap(err, "opening stream from temporary blob file") + return nil, 0, fmt.Errorf("opening stream from temporary blob file: %w", err) } return blobReader, size, nil diff --git a/fetcher/layerfetcher/source/layer_source.go b/fetcher/layerfetcher/source/layer_source.go index d108c07f..b0db4c11 100644 --- a/fetcher/layerfetcher/source/layer_source.go +++ b/fetcher/layerfetcher/source/layer_source.go @@ -5,6 +5,7 @@ import ( "context" "crypto/sha256" "encoding/hex" + "errors" "fmt" "hash" "io" @@ -25,7 +26,6 @@ import ( "github.com/containers/image/v5/transports" "github.com/containers/image/v5/types" digestpkg "github.com/opencontainers/go-digest" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -59,7 +59,7 @@ func (s *LayerSource) Manifest(logger lager.Logger) (types.Image, error) { img, err := s.getImageWithRetries(logger) if err != nil { logger.Error("fetching-image-reference-failed", err) - return nil, errors.Wrap(err, "fetching image reference") + return nil, fmt.Errorf("fetching image reference: %w", err) } img, err = s.convertImage(logger, img) @@ -79,7 +79,7 @@ func (s *LayerSource) Manifest(logger lager.Logger) (types.Image, error) { err = e } - return nil, errors.Wrap(err, "fetching image configuration") + return nil, fmt.Errorf("fetching image configuration: %w", err) } func (s *LayerSource) Blob(logger lager.Logger, layerInfo imagepuller.LayerInfo) (string, int64, error) { @@ -136,7 +136,7 @@ func (s *LayerSource) Blob(logger lager.Logger, layerInfo imagepuller.LayerInfo) digestReader, err = gzip.NewReader(digestReader) if err != nil { - return "", 0, errors.Wrapf(err, "expected blob to be of type %s", layerInfo.MediaType) + return "", 0, fmt.Errorf("expected blob to be of type %s: %w", layerInfo.MediaType, err) } defer digestReader.Close() @@ -152,16 +152,16 @@ func (s *LayerSource) Blob(logger lager.Logger, layerInfo imagepuller.LayerInfo) uncompressedSize, err := io.Copy(blobTempFile, digestReader) if err != nil { logger.Error("writing-blob-to-file", err) - return "", 0, errors.Wrap(err, "writing blob to tempfile") + return "", 0, fmt.Errorf("writing blob to tempfile: %w", err) } blobIDHex := strings.Split(layerInfo.BlobID, ":")[1] if err = s.checkCheckSum(logger, blobIDHash, blobIDHex, s.imageURL.Scheme); err != nil { - return "", 0, errors.Wrap(err, "layerID digest mismatch") + return "", 0, fmt.Errorf("layerID digest mismatch: %w", err) } if err = s.checkCheckSum(logger, diffIDHash, layerInfo.DiffID, s.imageURL.Scheme); err != nil { - return "", 0, errors.Wrap(err, "diffID digest mismatch") + return "", 0, fmt.Errorf("diffID digest mismatch: %w", err) } s.remainingImageQuota -= uncompressedSize @@ -219,7 +219,7 @@ func (s *LayerSource) checkCheckSum(logger lager.Logger, hash hash.Hash, digest "downloadedChecksum": blobContentsSha, }) if digest != blobContentsSha { - return errors.Errorf("expected: %s, actual: %s", digest, blobContentsSha) + return fmt.Errorf("expected: %s, actual: %s", digest, blobContentsSha) } return nil @@ -231,7 +231,7 @@ func (s *LayerSource) reference(logger lager.Logger) (types.ImageReference, erro transport := transports.Get(s.imageURL.Scheme) ref, err := transport.ParseReference(refString) if err != nil { - return nil, errors.Wrap(err, "parsing url failed") + return nil, fmt.Errorf("parsing url failed: %w", err) } return ref, nil @@ -268,7 +268,7 @@ func (s *LayerSource) getImageWithRetries(logger lager.Logger) (types.Image, err imgErr = err } - return nil, errors.Wrap(imgErr, "creating image") + return nil, fmt.Errorf("creating image: %w", imgErr) } func (s *LayerSource) getImageSource(logger lager.Logger) (types.ImageSource, error) { @@ -291,7 +291,7 @@ func (s *LayerSource) createImageSource(logger lager.Logger) (types.ImageSource, imgSrc, err := ref.NewImageSource(context.TODO(), &s.systemContext) if err != nil { - return nil, errors.Wrap(err, "creating image source") + return nil, fmt.Errorf("creating image source: %w", err) } return imgSrc, nil @@ -320,7 +320,7 @@ func (s *LayerSource) convertImage(logger lager.Logger, originalImage types.Imag for _, layer := range originalImage.LayerInfos() { diffID, err := s.v1DiffID(logger, layer, imgSrc) if err != nil { - return nil, errors.Wrap(err, "converting V1 schema failed") + return nil, fmt.Errorf("converting V1 schema failed: %w", err) } diffIDs = append(diffIDs, diffID) } @@ -339,18 +339,18 @@ func (s *LayerSource) convertImage(logger lager.Logger, originalImage types.Imag func (s *LayerSource) v1DiffID(logger lager.Logger, layer types.BlobInfo, imgSrc types.ImageSource) (digestpkg.Digest, error) { blob, _, err := s.getBlobWithRetries(logger, imgSrc, layer) if err != nil { - return "", errors.Wrap(err, "fetching V1 layer blob") + return "", fmt.Errorf("fetching V1 layer blob: %w", err) } defer blob.Close() gzipReader, err := gzip.NewReader(blob) if err != nil { - return "", errors.Wrap(err, "creating reader for V1 layer blob") + return "", fmt.Errorf("creating reader for V1 layer blob: %w", err) } data, err := io.ReadAll(gzipReader) if err != nil { - return "", errors.Wrap(err, "reading V1 layer blob") + return "", fmt.Errorf("reading V1 layer blob: %w", err) } sha := sha256.Sum256(data) diff --git a/go.mod b/go.mod index 3d0ffa27..723b17ed 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0 github.com/opencontainers/runtime-spec v1.2.0 - github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/urfave/cli v1.22.15 gopkg.in/yaml.v2 v2.4.0 diff --git a/imagepuller/image_puller.go b/imagepuller/image_puller.go index 3617e1fa..32c0dbd6 100644 --- a/imagepuller/image_puller.go +++ b/imagepuller/image_puller.go @@ -1,12 +1,12 @@ package imagepuller // import "code.cloudfoundry.org/groot/imagepuller" import ( + "fmt" "io" "code.cloudfoundry.org/groot/imagepuller/ondemand" "code.cloudfoundry.org/lager/v3" imgspec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" ) //go:generate counterfeiter . Fetcher @@ -71,7 +71,7 @@ func (p *ImagePuller) Pull(logger lager.Logger, spec ImageSpec) (Image, error) { imageInfo, err := p.fetcher.ImageInfo(logger) if err != nil { - return Image{}, errors.Wrap(err, "fetching list of layer infos") + return Image{}, fmt.Errorf("fetching list of layer infos: %w", err) } logger.Debug("fetched-layer-infos", lager.Data{"infos": imageInfo.LayerInfos}) @@ -118,7 +118,7 @@ func (p *ImagePuller) buildLayer(logger lager.Logger, layerInfo LayerInfo, paren Create: func() (io.ReadCloser, error) { stream, blobSize, err := p.fetcher.StreamBlob(logger, layerInfo) if err != nil { - return nil, errors.Wrapf(err, "opening stream for blob `%s`", layerInfo.BlobID) + return nil, fmt.Errorf("opening stream for blob `%s`: %w", layerInfo.BlobID, err) } logger.Debug("got-stream-for-blob", lager.Data{"size": blobSize}) @@ -145,7 +145,7 @@ func quotaExceeded(logger lager.Logger, layerInfos []LayerInfo, spec ImageSpec) totalSize := layersSize(layerInfos) if totalSize > spec.DiskLimit { - err := errors.Errorf("layers exceed disk quota %d/%d bytes", totalSize, spec.DiskLimit) + err := fmt.Errorf("layers exceed disk quota %d/%d bytes", totalSize, spec.DiskLimit) logger.Error("blob-manifest-size-check-failed", err, lager.Data{ "totalSize": totalSize, "diskLimit": spec.DiskLimit, diff --git a/pull.go b/pull.go index 15ae5864..a14e45d1 100644 --- a/pull.go +++ b/pull.go @@ -1,8 +1,9 @@ package groot import ( + "fmt" + "code.cloudfoundry.org/groot/imagepuller" - "github.com/pkg/errors" ) func (g *Groot) Pull() error { @@ -11,5 +12,5 @@ func (g *Groot) Pull() error { defer g.Logger.Debug("ending") _, err := g.ImagePuller.Pull(g.Logger, imagepuller.ImageSpec{}) - return errors.Wrap(err, "pulling image") + return fmt.Errorf("pulling image: %w", err) } diff --git a/pull_test.go b/pull_test.go index 0b02083b..d3706609 100644 --- a/pull_test.go +++ b/pull_test.go @@ -2,6 +2,7 @@ package groot_test import ( "bytes" + "errors" "io" "code.cloudfoundry.org/groot" @@ -11,7 +12,6 @@ import ( "code.cloudfoundry.org/lager/v3/lagertest" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - errors "github.com/pkg/errors" ) var _ = Describe("Pull", func() { diff --git a/stats_test.go b/stats_test.go index 803a6deb..60e34b41 100644 --- a/stats_test.go +++ b/stats_test.go @@ -1,12 +1,13 @@ package groot_test import ( + "errors" + "code.cloudfoundry.org/groot" "code.cloudfoundry.org/groot/grootfakes" "code.cloudfoundry.org/lager/v3/lagertest" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - errors "github.com/pkg/errors" ) var _ = Describe("Stats", func() { diff --git a/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore deleted file mode 100644 index daf913b1..00000000 --- a/vendor/github.com/pkg/errors/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml deleted file mode 100644 index 9159de03..00000000 --- a/vendor/github.com/pkg/errors/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: go -go_import_path: github.com/pkg/errors -go: - - 1.11.x - - 1.12.x - - 1.13.x - - tip - -script: - - make check diff --git a/vendor/github.com/pkg/errors/LICENSE b/vendor/github.com/pkg/errors/LICENSE deleted file mode 100644 index 835ba3e7..00000000 --- a/vendor/github.com/pkg/errors/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2015, Dave Cheney -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. - -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 HOLDER 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/github.com/pkg/errors/Makefile b/vendor/github.com/pkg/errors/Makefile deleted file mode 100644 index ce9d7cde..00000000 --- a/vendor/github.com/pkg/errors/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -PKGS := github.com/pkg/errors -SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) -GO := go - -check: test vet gofmt misspell unconvert staticcheck ineffassign unparam - -test: - $(GO) test $(PKGS) - -vet: | test - $(GO) vet $(PKGS) - -staticcheck: - $(GO) get honnef.co/go/tools/cmd/staticcheck - staticcheck -checks all $(PKGS) - -misspell: - $(GO) get github.com/client9/misspell/cmd/misspell - misspell \ - -locale GB \ - -error \ - *.md *.go - -unconvert: - $(GO) get github.com/mdempsky/unconvert - unconvert -v $(PKGS) - -ineffassign: - $(GO) get github.com/gordonklaus/ineffassign - find $(SRCDIRS) -name '*.go' | xargs ineffassign - -pedantic: check errcheck - -unparam: - $(GO) get mvdan.cc/unparam - unparam ./... - -errcheck: - $(GO) get github.com/kisielk/errcheck - errcheck $(PKGS) - -gofmt: - @echo Checking code is gofmted - @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md deleted file mode 100644 index 54dfdcb1..00000000 --- a/vendor/github.com/pkg/errors/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) - -Package errors provides simple error handling primitives. - -`go get github.com/pkg/errors` - -The traditional error handling idiom in Go is roughly akin to -```go -if err != nil { - return err -} -``` -which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. - -## Adding context to an error - -The errors.Wrap function returns a new error that adds context to the original error. For example -```go -_, err := ioutil.ReadAll(r) -if err != nil { - return errors.Wrap(err, "read failed") -} -``` -## Retrieving the cause of an error - -Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. -```go -type causer interface { - Cause() error -} -``` -`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: -```go -switch err := errors.Cause(err).(type) { -case *MyError: - // handle specifically -default: - // unknown error -} -``` - -[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). - -## Roadmap - -With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: - -- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) -- 1.0. Final release. - -## Contributing - -Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. - -Before sending a PR, please discuss your change by raising an issue. - -## License - -BSD-2-Clause diff --git a/vendor/github.com/pkg/errors/appveyor.yml b/vendor/github.com/pkg/errors/appveyor.yml deleted file mode 100644 index a932eade..00000000 --- a/vendor/github.com/pkg/errors/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\pkg\errors -shallow_clone: true # for startup speed - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -# http://www.appveyor.com/docs/installed-software -install: - # some helpful output for debugging builds - - go version - - go env - # pre-installed MinGW at C:\MinGW is 32bit only - # but MSYS2 at C:\msys64 has mingw64 - - set PATH=C:\msys64\mingw64\bin;%PATH% - - gcc --version - - g++ --version - -build_script: - - go install -v ./... - -test_script: - - set PATH=C:\gopath\bin;%PATH% - - go test -v ./... - -#artifacts: -# - path: '%GOPATH%\bin\*.exe' -deploy: off diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go deleted file mode 100644 index 161aea25..00000000 --- a/vendor/github.com/pkg/errors/errors.go +++ /dev/null @@ -1,288 +0,0 @@ -// Package errors provides simple error handling primitives. -// -// The traditional error handling idiom in Go is roughly akin to -// -// if err != nil { -// return err -// } -// -// which when applied recursively up the call stack results in error reports -// without context or debugging information. The errors package allows -// programmers to add context to the failure path in their code in a way -// that does not destroy the original value of the error. -// -// Adding context to an error -// -// The errors.Wrap function returns a new error that adds context to the -// original error by recording a stack trace at the point Wrap is called, -// together with the supplied message. For example -// -// _, err := ioutil.ReadAll(r) -// if err != nil { -// return errors.Wrap(err, "read failed") -// } -// -// If additional control is required, the errors.WithStack and -// errors.WithMessage functions destructure errors.Wrap into its component -// operations: annotating an error with a stack trace and with a message, -// respectively. -// -// Retrieving the cause of an error -// -// Using errors.Wrap constructs a stack of errors, adding context to the -// preceding error. Depending on the nature of the error it may be necessary -// to reverse the operation of errors.Wrap to retrieve the original error -// for inspection. Any error value which implements this interface -// -// type causer interface { -// Cause() error -// } -// -// can be inspected by errors.Cause. errors.Cause will recursively retrieve -// the topmost error that does not implement causer, which is assumed to be -// the original cause. For example: -// -// switch err := errors.Cause(err).(type) { -// case *MyError: -// // handle specifically -// default: -// // unknown error -// } -// -// Although the causer interface is not exported by this package, it is -// considered a part of its stable public interface. -// -// Formatted printing of errors -// -// All error values returned from this package implement fmt.Formatter and can -// be formatted by the fmt package. The following verbs are supported: -// -// %s print the error. If the error has a Cause it will be -// printed recursively. -// %v see %s -// %+v extended format. Each Frame of the error's StackTrace will -// be printed in detail. -// -// Retrieving the stack trace of an error or wrapper -// -// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are -// invoked. This information can be retrieved with the following interface: -// -// type stackTracer interface { -// StackTrace() errors.StackTrace -// } -// -// The returned errors.StackTrace type is defined as -// -// type StackTrace []Frame -// -// The Frame type represents a call site in the stack trace. Frame supports -// the fmt.Formatter interface that can be used for printing information about -// the stack trace of this error. For example: -// -// if err, ok := err.(stackTracer); ok { -// for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d\n", f, f) -// } -// } -// -// Although the stackTracer interface is not exported by this package, it is -// considered a part of its stable public interface. -// -// See the documentation for Frame.Format for more details. -package errors - -import ( - "fmt" - "io" -) - -// New returns an error with the supplied message. -// New also records the stack trace at the point it was called. -func New(message string) error { - return &fundamental{ - msg: message, - stack: callers(), - } -} - -// Errorf formats according to a format specifier and returns the string -// as a value that satisfies error. -// Errorf also records the stack trace at the point it was called. -func Errorf(format string, args ...interface{}) error { - return &fundamental{ - msg: fmt.Sprintf(format, args...), - stack: callers(), - } -} - -// fundamental is an error that has a message and a stack, but no caller. -type fundamental struct { - msg string - *stack -} - -func (f *fundamental) Error() string { return f.msg } - -func (f *fundamental) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - io.WriteString(s, f.msg) - f.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, f.msg) - case 'q': - fmt.Fprintf(s, "%q", f.msg) - } -} - -// WithStack annotates err with a stack trace at the point WithStack was called. -// If err is nil, WithStack returns nil. -func WithStack(err error) error { - if err == nil { - return nil - } - return &withStack{ - err, - callers(), - } -} - -type withStack struct { - error - *stack -} - -func (w *withStack) Cause() error { return w.error } - -// Unwrap provides compatibility for Go 1.13 error chains. -func (w *withStack) Unwrap() error { return w.error } - -func (w *withStack) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v", w.Cause()) - w.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, w.Error()) - case 'q': - fmt.Fprintf(s, "%q", w.Error()) - } -} - -// Wrap returns an error annotating err with a stack trace -// at the point Wrap is called, and the supplied message. -// If err is nil, Wrap returns nil. -func Wrap(err error, message string) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: message, - } - return &withStack{ - err, - callers(), - } -} - -// Wrapf returns an error annotating err with a stack trace -// at the point Wrapf is called, and the format specifier. -// If err is nil, Wrapf returns nil. -func Wrapf(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } - return &withStack{ - err, - callers(), - } -} - -// WithMessage annotates err with a new message. -// If err is nil, WithMessage returns nil. -func WithMessage(err error, message string) error { - if err == nil { - return nil - } - return &withMessage{ - cause: err, - msg: message, - } -} - -// WithMessagef annotates err with the format specifier. -// If err is nil, WithMessagef returns nil. -func WithMessagef(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - return &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } -} - -type withMessage struct { - cause error - msg string -} - -func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } -func (w *withMessage) Cause() error { return w.cause } - -// Unwrap provides compatibility for Go 1.13 error chains. -func (w *withMessage) Unwrap() error { return w.cause } - -func (w *withMessage) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v\n", w.Cause()) - io.WriteString(s, w.msg) - return - } - fallthrough - case 's', 'q': - io.WriteString(s, w.Error()) - } -} - -// Cause returns the underlying cause of the error, if possible. -// An error value has a cause if it implements the following -// interface: -// -// type causer interface { -// Cause() error -// } -// -// If the error does not implement Cause, the original error will -// be returned. If the error is nil, nil will be returned without further -// investigation. -func Cause(err error) error { - type causer interface { - Cause() error - } - - for err != nil { - cause, ok := err.(causer) - if !ok { - break - } - err = cause.Cause() - } - return err -} diff --git a/vendor/github.com/pkg/errors/go113.go b/vendor/github.com/pkg/errors/go113.go deleted file mode 100644 index be0d10d0..00000000 --- a/vendor/github.com/pkg/errors/go113.go +++ /dev/null @@ -1,38 +0,0 @@ -// +build go1.13 - -package errors - -import ( - stderrors "errors" -) - -// Is reports whether any error in err's chain matches target. -// -// The chain consists of err itself followed by the sequence of errors obtained by -// repeatedly calling Unwrap. -// -// 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 { return stderrors.Is(err, target) } - -// As finds the first error in err's chain that matches target, and if so, sets -// target to that error value and returns true. -// -// The chain consists of err itself followed by the sequence of errors obtained by -// repeatedly calling Unwrap. -// -// An error matches target if the error's concrete value is assignable to the value -// pointed to by target, or if the error has a method As(interface{}) bool such that -// As(target) returns true. In the latter case, the As method is responsible for -// setting target. -// -// As will panic if target is not a non-nil pointer to either a type that implements -// error, or to any interface type. As returns false if err is nil. -func As(err error, target interface{}) bool { return stderrors.As(err, target) } - -// Unwrap returns the result of calling the Unwrap method on err, if err's -// type contains an Unwrap method returning error. -// Otherwise, Unwrap returns nil. -func Unwrap(err error) error { - return stderrors.Unwrap(err) -} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go deleted file mode 100644 index 779a8348..00000000 --- a/vendor/github.com/pkg/errors/stack.go +++ /dev/null @@ -1,177 +0,0 @@ -package errors - -import ( - "fmt" - "io" - "path" - "runtime" - "strconv" - "strings" -) - -// Frame represents a program counter inside a stack frame. -// For historical reasons if Frame is interpreted as a uintptr -// its value represents the program counter + 1. -type Frame uintptr - -// pc returns the program counter for this frame; -// multiple frames may have the same PC value. -func (f Frame) pc() uintptr { return uintptr(f) - 1 } - -// file returns the full path to the file that contains the -// function for this Frame's pc. -func (f Frame) file() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - file, _ := fn.FileLine(f.pc()) - return file -} - -// line returns the line number of source code of the -// function for this Frame's pc. -func (f Frame) line() int { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return 0 - } - _, line := fn.FileLine(f.pc()) - return line -} - -// name returns the name of this function, if known. -func (f Frame) name() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - return fn.Name() -} - -// Format formats the frame according to the fmt.Formatter interface. -// -// %s source file -// %d source line -// %n function name -// %v equivalent to %s:%d -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+s function name and path of source file relative to the compile time -// GOPATH separated by \n\t (\n\t) -// %+v equivalent to %+s:%d -func (f Frame) Format(s fmt.State, verb rune) { - switch verb { - case 's': - switch { - case s.Flag('+'): - io.WriteString(s, f.name()) - io.WriteString(s, "\n\t") - io.WriteString(s, f.file()) - default: - io.WriteString(s, path.Base(f.file())) - } - case 'd': - io.WriteString(s, strconv.Itoa(f.line())) - case 'n': - io.WriteString(s, funcname(f.name())) - case 'v': - f.Format(s, 's') - io.WriteString(s, ":") - f.Format(s, 'd') - } -} - -// MarshalText formats a stacktrace Frame as a text string. The output is the -// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. -func (f Frame) MarshalText() ([]byte, error) { - name := f.name() - if name == "unknown" { - return []byte(name), nil - } - return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil -} - -// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). -type StackTrace []Frame - -// Format formats the stack of Frames according to the fmt.Formatter interface. -// -// %s lists source files for each Frame in the stack -// %v lists the source file and line number for each Frame in the stack -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+v Prints filename, function, and line number for each Frame in the stack. -func (st StackTrace) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case s.Flag('+'): - for _, f := range st { - io.WriteString(s, "\n") - f.Format(s, verb) - } - case s.Flag('#'): - fmt.Fprintf(s, "%#v", []Frame(st)) - default: - st.formatSlice(s, verb) - } - case 's': - st.formatSlice(s, verb) - } -} - -// formatSlice will format this StackTrace into the given buffer as a slice of -// Frame, only valid when called with '%s' or '%v'. -func (st StackTrace) formatSlice(s fmt.State, verb rune) { - io.WriteString(s, "[") - for i, f := range st { - if i > 0 { - io.WriteString(s, " ") - } - f.Format(s, verb) - } - io.WriteString(s, "]") -} - -// stack represents a stack of program counters. -type stack []uintptr - -func (s *stack) Format(st fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case st.Flag('+'): - for _, pc := range *s { - f := Frame(pc) - fmt.Fprintf(st, "\n%+v", f) - } - } - } -} - -func (s *stack) StackTrace() StackTrace { - f := make([]Frame, len(*s)) - for i := 0; i < len(f); i++ { - f[i] = Frame((*s)[i]) - } - return f -} - -func callers() *stack { - const depth = 32 - var pcs [depth]uintptr - n := runtime.Callers(3, pcs[:]) - var st stack = pcs[0:n] - return &st -} - -// funcname removes the path prefix component of a function's name reported by func.Name(). -func funcname(name string) string { - i := strings.LastIndex(name, "/") - name = name[i+1:] - i = strings.Index(name, ".") - return name[i+1:] -} diff --git a/vendor/modules.txt b/vendor/modules.txt index c1376534..da3cb34c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -169,9 +169,6 @@ github.com/opencontainers/runtime-spec/specs-go ## explicit; go 1.20 github.com/openzipkin/zipkin-go/idgenerator github.com/openzipkin/zipkin-go/model -# github.com/pkg/errors v0.9.1 -## explicit -github.com/pkg/errors # github.com/russross/blackfriday/v2 v2.1.0 ## explicit github.com/russross/blackfriday/v2