From d4d0498d98b6c385ce0d1ba441a8372d139b9c0c Mon Sep 17 00:00:00 2001 From: Ian Kaneshiro Date: Wed, 7 Aug 2019 14:09:43 -0400 Subject: [PATCH] Use different packages for darwin vs linux This change creates two small files to split oci layer unpacking into a new function that allows for different behavior based on platform. NOTE: umoci v0.4.2 is used to prevent an a dependency issue with github.com/opencontainers/runtime-spec v1.0.0 not being backwards compatable Update #3921 to most recent master --- go.mod | 31 +- go.sum | 119 ++++++ .../pkg/build/sources/conveyorPacker_oci.go | 47 +-- .../pkg/build/sources/oci_unpack_darwin.go | 23 ++ .../pkg/build/sources/oci_unpack_linux.go | 72 ++++ vendor/github.com/apex/log/.gitignore | 1 + vendor/github.com/apex/log/History.md | 12 + vendor/github.com/apex/log/go.mod | 25 ++ vendor/github.com/apex/log/go.sum | 90 ++++ .../docker/go-metrics/CONTRIBUTING.md | 26 +- vendor/github.com/hashicorp/errwrap/README.md | 2 +- .../hashicorp/go-multierror/format.go | 6 +- .../hashicorp/go-multierror/sort.go | 16 - .../klauspost/compress/flate/crc32_amd64.go | 1 + .../klauspost/compress/flate/crc32_amd64.s | 1 + .../klauspost/compress/flate/crc32_noasm.go | 2 +- vendor/github.com/klauspost/cpuid/.travis.yml | 5 +- .../klauspost/cpuid/CONTRIBUTING.txt | 35 ++ vendor/github.com/klauspost/cpuid/cpuid.go | 14 +- vendor/github.com/klauspost/crc32/.gitignore | 24 -- vendor/github.com/klauspost/crc32/.travis.yml | 13 - vendor/github.com/klauspost/crc32/LICENSE | 28 -- vendor/github.com/klauspost/crc32/README.md | 87 ---- vendor/github.com/klauspost/crc32/crc32.go | 207 ---------- .../github.com/klauspost/crc32/crc32_amd64.go | 230 ----------- .../github.com/klauspost/crc32/crc32_amd64.s | 319 -------------- .../klauspost/crc32/crc32_amd64p32.go | 43 -- .../klauspost/crc32/crc32_amd64p32.s | 67 --- .../klauspost/crc32/crc32_generic.go | 89 ---- .../klauspost/crc32/crc32_otherarch.go | 15 - .../github.com/klauspost/crc32/crc32_s390x.go | 91 ---- .../github.com/klauspost/crc32/crc32_s390x.s | 249 ----------- vendor/github.com/klauspost/pgzip/.travis.yml | 6 +- vendor/github.com/klauspost/pgzip/README.md | 6 +- vendor/github.com/klauspost/pgzip/circle.yml | 7 - vendor/github.com/klauspost/pgzip/gunzip.go | 2 +- vendor/github.com/klauspost/pgzip/gzip.go | 2 +- vendor/github.com/mattn/go-colorable/go.mod | 2 +- .../mattn/go-isatty/isatty_android.go | 23 ++ .../mattn/go-isatty/isatty_others.go | 2 +- .../{isatty_linux.go => isatty_tcgets.go} | 3 +- vendor/github.com/openSUSE/umoci/.gitignore | 4 +- vendor/github.com/openSUSE/umoci/.travis.yml | 17 +- vendor/github.com/openSUSE/umoci/CHANGELOG.md | 24 +- .../openSUSE/umoci/CODE_OF_CONDUCT.md | 30 -- .../github.com/openSUSE/umoci/CONTRIBUTING.md | 17 +- vendor/github.com/openSUSE/umoci/Dockerfile | 9 +- .../github.com/openSUSE/umoci/GOVERNANCE.md | 18 - vendor/github.com/openSUSE/umoci/MAINTAINERS | 2 +- vendor/github.com/openSUSE/umoci/Makefile | 36 +- vendor/github.com/openSUSE/umoci/README.md | 2 +- vendor/github.com/openSUSE/umoci/VERSION | 2 +- vendor/github.com/openSUSE/umoci/go.mod | 35 -- vendor/github.com/openSUSE/umoci/go.sum | 62 --- .../openSUSE/umoci/oci/cas/dir/dir.go | 15 +- .../openSUSE/umoci/oci/casext/blob.go | 68 ++- .../umoci/oci/casext/verified_blob.go | 40 -- .../openSUSE/umoci/oci/layer/generate.go | 6 +- .../openSUSE/umoci/oci/layer/tar_extract.go | 15 +- .../openSUSE/umoci/oci/layer/tar_generate.go | 4 - .../openSUSE/umoci/oci/layer/unpack.go | 48 +-- .../openSUSE/umoci/oci/layer/utils.go | 1 - .../umoci/pkg/hardening/verified_reader.go | 176 -------- .../openSUSE/umoci/pkg/system/utime_linux.go | 16 +- .../openSUSE/umoci/pkg/unpriv/unpriv.go | 5 +- .../openSUSE/umoci/third_party/shared/util.go | 1 - .../openSUSE/umoci/third_party/user/user.go | 1 - vendor/github.com/openSUSE/umoci/utils.go | 18 +- vendor/github.com/openSUSE/umoci/vendor.conf | 36 ++ .../image-spec/schema/config-schema.json | 140 +++++++ .../image-spec/schema/content-descriptor.json | 33 ++ .../image-spec/schema/defs-descriptor.json | 27 ++ .../image-spec/schema/defs.json | 91 ++++ .../opencontainers/image-spec/schema/doc.go | 16 + .../opencontainers/image-spec/schema/error.go | 44 ++ .../opencontainers/image-spec/schema/fs.go | 323 +++++++++++++++ .../opencontainers/image-spec/schema/gen.go | 21 + .../image-spec/schema/image-index-schema.json | 89 ++++ .../schema/image-layout-schema.json | 18 + .../schema/image-manifest-schema.json | 34 ++ .../image-spec/schema/loader.go | 126 ++++++ .../image-spec/schema/schema.go | 75 ++++ .../image-spec/schema/validator.go | 224 ++++++++++ .../opencontainers/image-tools/LICENSE | 201 +++++++++ .../image-tools/image/autodetect.go | 69 ++++ .../image-tools/image/config.go | 120 ++++++ .../image-tools/image/descriptor.go | 144 +++++++ .../opencontainers/image-tools/image/doc.go | 16 + .../opencontainers/image-tools/image/image.go | 389 ++++++++++++++++++ .../opencontainers/image-tools/image/index.go | 71 ++++ .../image-tools/image/layout.go | 104 +++++ .../image-tools/image/manifest.go | 342 +++++++++++++++ .../image-tools/image/project.go | 21 + .../image-tools/image/walker.go | 333 +++++++++++++++ vendor/github.com/sirupsen/logrus/.travis.yml | 6 +- vendor/github.com/sirupsen/logrus/README.md | 60 ++- vendor/github.com/sirupsen/logrus/entry.go | 26 +- vendor/github.com/sirupsen/logrus/exported.go | 20 +- .../github.com/sirupsen/logrus/formatter.go | 20 +- .../sirupsen/logrus/json_formatter.go | 12 +- vendor/github.com/sirupsen/logrus/logger.go | 16 +- .../sirupsen/logrus/text_formatter.go | 31 +- vendor/github.com/urfave/cli/.travis.yml | 2 +- vendor/github.com/urfave/cli/CHANGELOG.md | 29 +- .../github.com/urfave/cli/CODE_OF_CONDUCT.md | 74 ++++ vendor/github.com/urfave/cli/CONTRIBUTING.md | 19 + vendor/github.com/urfave/cli/MAINTAINERS.md | 4 + vendor/github.com/urfave/cli/README.md | 233 +++++++++-- vendor/github.com/urfave/cli/app.go | 50 ++- vendor/github.com/urfave/cli/category.go | 2 +- vendor/github.com/urfave/cli/command.go | 197 ++++++--- vendor/github.com/urfave/cli/context.go | 72 +++- vendor/github.com/urfave/cli/flag.go | 343 ++++++++------- .../github.com/urfave/cli/flag_generated.go | 131 +++++- vendor/github.com/urfave/cli/funcs.go | 16 + .../github.com/urfave/cli/generate-flag-types | 7 + vendor/github.com/urfave/cli/go.mod | 8 + vendor/github.com/urfave/cli/go.sum | 6 + vendor/github.com/urfave/cli/help.go | 30 +- vendor/github.com/urfave/cli/sort.go | 29 ++ vendor/github.com/vbatts/go-mtree/.travis.yml | 9 +- vendor/github.com/vbatts/go-mtree/Makefile | 8 +- vendor/github.com/vbatts/go-mtree/README.md | 2 +- vendor/github.com/vbatts/go-mtree/compare.go | 2 - vendor/github.com/vbatts/go-mtree/entry.go | 39 +- .../xeipuuv/gojsonschema/validation.go | 4 +- vendor/go4.org/AUTHORS | 8 + vendor/go4.org/LICENSE | 202 +++++++++ vendor/go4.org/errorutil/highlight.go | 58 +++ vendor/golang.org/x/net/proxy/dial.go | 54 +++ vendor/golang.org/x/net/proxy/direct.go | 15 +- vendor/golang.org/x/net/proxy/per_host.go | 15 + vendor/golang.org/x/net/proxy/proxy.go | 24 +- vendor/golang.org/x/net/proxy/socks5.go | 10 +- vendor/modules.txt | 42 +- 135 files changed, 5162 insertions(+), 2595 deletions(-) create mode 100644 internal/pkg/build/sources/oci_unpack_darwin.go create mode 100644 internal/pkg/build/sources/oci_unpack_linux.go create mode 100644 vendor/github.com/apex/log/.gitignore create mode 100644 vendor/github.com/apex/log/History.md create mode 100644 vendor/github.com/apex/log/go.mod create mode 100644 vendor/github.com/apex/log/go.sum delete mode 100644 vendor/github.com/hashicorp/go-multierror/sort.go create mode 100644 vendor/github.com/klauspost/cpuid/CONTRIBUTING.txt delete mode 100644 vendor/github.com/klauspost/crc32/.gitignore delete mode 100644 vendor/github.com/klauspost/crc32/.travis.yml delete mode 100644 vendor/github.com/klauspost/crc32/LICENSE delete mode 100644 vendor/github.com/klauspost/crc32/README.md delete mode 100644 vendor/github.com/klauspost/crc32/crc32.go delete mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64.go delete mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64.s delete mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64p32.go delete mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64p32.s delete mode 100644 vendor/github.com/klauspost/crc32/crc32_generic.go delete mode 100644 vendor/github.com/klauspost/crc32/crc32_otherarch.go delete mode 100644 vendor/github.com/klauspost/crc32/crc32_s390x.go delete mode 100644 vendor/github.com/klauspost/crc32/crc32_s390x.s delete mode 100644 vendor/github.com/klauspost/pgzip/circle.yml create mode 100644 vendor/github.com/mattn/go-isatty/isatty_android.go rename vendor/github.com/mattn/go-isatty/{isatty_linux.go => isatty_tcgets.go} (91%) delete mode 100644 vendor/github.com/openSUSE/umoci/CODE_OF_CONDUCT.md delete mode 100644 vendor/github.com/openSUSE/umoci/GOVERNANCE.md delete mode 100644 vendor/github.com/openSUSE/umoci/go.mod delete mode 100644 vendor/github.com/openSUSE/umoci/go.sum delete mode 100644 vendor/github.com/openSUSE/umoci/oci/casext/verified_blob.go delete mode 100644 vendor/github.com/openSUSE/umoci/pkg/hardening/verified_reader.go create mode 100644 vendor/github.com/openSUSE/umoci/vendor.conf create mode 100644 vendor/github.com/opencontainers/image-spec/schema/config-schema.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/content-descriptor.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/defs-descriptor.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/defs.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/doc.go create mode 100644 vendor/github.com/opencontainers/image-spec/schema/error.go create mode 100644 vendor/github.com/opencontainers/image-spec/schema/fs.go create mode 100644 vendor/github.com/opencontainers/image-spec/schema/gen.go create mode 100644 vendor/github.com/opencontainers/image-spec/schema/image-index-schema.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/image-layout-schema.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/image-manifest-schema.json create mode 100644 vendor/github.com/opencontainers/image-spec/schema/loader.go create mode 100644 vendor/github.com/opencontainers/image-spec/schema/schema.go create mode 100644 vendor/github.com/opencontainers/image-spec/schema/validator.go create mode 100644 vendor/github.com/opencontainers/image-tools/LICENSE create mode 100644 vendor/github.com/opencontainers/image-tools/image/autodetect.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/config.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/descriptor.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/doc.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/image.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/index.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/layout.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/manifest.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/project.go create mode 100644 vendor/github.com/opencontainers/image-tools/image/walker.go create mode 100644 vendor/github.com/urfave/cli/CODE_OF_CONDUCT.md create mode 100644 vendor/github.com/urfave/cli/CONTRIBUTING.md create mode 100644 vendor/github.com/urfave/cli/MAINTAINERS.md create mode 100644 vendor/github.com/urfave/cli/go.mod create mode 100644 vendor/github.com/urfave/cli/go.sum create mode 100644 vendor/github.com/urfave/cli/sort.go create mode 100644 vendor/go4.org/AUTHORS create mode 100644 vendor/go4.org/LICENSE create mode 100644 vendor/go4.org/errorutil/highlight.go create mode 100644 vendor/golang.org/x/net/proxy/dial.go diff --git a/go.mod b/go.mod index 5de781cbd2..fd1fbab45a 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/Microsoft/hcsshim v0.8.6 // indirect github.com/Netflix/go-expect v0.0.0-20180928190340-9d1f4485533b github.com/alexflint/go-filemutex v0.0.0-20171028004239-d358565f3c3f // indirect + github.com/apex/log v1.1.1 // indirect github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect github.com/bitly/go-simplejson v0.5.0 // indirect github.com/blang/semver v3.5.1+incompatible @@ -24,6 +25,7 @@ require ( github.com/containers/storage v0.0.0-20180604200230-88d80428f9b1 // indirect github.com/coreos/go-iptables v0.3.0 // indirect github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 // indirect + github.com/cyphar/filepath-securejoin v0.2.2 // indirect github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c // indirect github.com/d2g/dhcp4client v0.0.0-20180611075603-e61299896203 // indirect github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5 // indirect @@ -34,7 +36,9 @@ require ( github.com/docker/docker-credential-helpers v0.6.0 // indirect github.com/docker/go-connections v0.3.0 // indirect github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916 // indirect + github.com/docker/go-units v0.3.3 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect + github.com/dsnet/compress v0.0.1 // indirect github.com/fatih/color v1.7.0 github.com/garyburd/redigo v1.6.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect @@ -45,27 +49,29 @@ require ( github.com/gorilla/mux v1.6.2 // indirect github.com/gorilla/websocket v1.4.0 github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect + github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect github.com/hashicorp/go-cleanhttp v0.5.1 // indirect + github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 // indirect github.com/imdario/mergo v0.3.7 // indirect github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56 // indirect github.com/juju/errors v0.0.0-20190207033735-e65537c515d7 // indirect github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect github.com/juju/testing v0.0.0-20190613124551-e81189438503 // indirect github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect + github.com/klauspost/pgzip v1.2.1 // indirect github.com/kr/pty v1.1.8 github.com/kubernetes-sigs/cri-o v0.0.0-20180917213123-8afc34092907 - github.com/mattn/go-colorable v0.1.1 // indirect github.com/mattn/go-runewidth v0.0.2 // indirect github.com/mattn/go-shellwords v1.0.3 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mtrmac/gpgme v0.0.0-20170102180018-b2432428689c // indirect github.com/onsi/ginkgo v1.8.0 // indirect - github.com/onsi/gomega v1.5.0 // indirect - github.com/openSUSE/umoci v0.4.4 + github.com/openSUSE/umoci v0.4.2 github.com/opencontainers/go-digest v1.0.0-rc1 - github.com/opencontainers/image-spec v1.0.0 + github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392 + github.com/opencontainers/image-tools v0.0.0-20180129025323-c95f76cbae74 github.com/opencontainers/runc v0.1.1 // indirect - github.com/opencontainers/runtime-spec v1.0.0 + github.com/opencontainers/runtime-spec v0.0.0-20180913141938-5806c3563733 github.com/opencontainers/runtime-tools v0.7.0 github.com/opencontainers/selinux v1.2.2 github.com/pelletier/go-toml v1.4.0 @@ -76,9 +82,11 @@ require ( github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5 // indirect github.com/prometheus/common v0.0.0-20180518154759-7600349dcfe1 // indirect github.com/prometheus/procfs v0.0.0-20180612222113-7d6f385de8be // indirect + github.com/rootless-containers/proto v0.1.0 // indirect github.com/safchain/ethtool v0.0.0-20180504150752-6e3f4faa84e1 // indirect github.com/satori/go.uuid v1.2.0 github.com/seccomp/libseccomp-golang v0.9.1 + github.com/sirupsen/logrus v1.0.5 // indirect github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.3 github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect @@ -87,13 +95,20 @@ require ( github.com/sylabs/scs-key-client v0.3.0-0.20190509220229-bce3b050c4ec github.com/sylabs/scs-library-client v0.3.0 github.com/sylabs/sif v1.0.7 + github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e // indirect + github.com/urfave/cli v1.21.0 // indirect + github.com/vbatts/go-mtree v0.4.4 // indirect github.com/vishvananda/netlink v1.0.1-0.20190618143317-99a56c251ae6 // indirect github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f // indirect github.com/xenolf/lego v2.5.0+incompatible // indirect github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect github.com/yvasiyarov/gorelic v0.0.6 // indirect github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 // indirect - golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 + go4.org v0.0.0-20180417224846-9599cf28b011 // indirect + golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect google.golang.org/grpc v1.20.0 // indirect @@ -109,8 +124,6 @@ require ( replace ( github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.0.5 - github.com/opencontainers/image-spec => github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392 - github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v0.0.0-20180913141938-5806c3563733 + github.com/opencontainers/image-tools => github.com/sylabs/image-tools v0.0.0-20181006203805-2814f4980568 golang.org/x/crypto => github.com/sylabs/golang-x-crypto v0.0.0-20181006204705-4bce89e8e9a9 - ) diff --git a/go.sum b/go.sum index 83f5011949..1d8d54c113 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Microsoft/go-winio v0.4.7 h1:vOvDiY/F1avSWlCWiKJjdYKz2jVjTK3pWPHndeG4OAY= github.com/Microsoft/go-winio v0.4.7/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= @@ -10,21 +11,34 @@ github.com/alexflint/go-filemutex v0.0.0-20171028004239-d358565f3c3f h1:tbgFqBK8 github.com/alexflint/go-filemutex v0.0.0-20171028004239-d358565f3c3f/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0= github.com/apex/log v1.1.0 h1:J5rld6WVFi6NxA6m8GJ1LJqu3+GiTFIt3mYv27gdQWI= github.com/apex/log v1.1.0/go.mod h1:yA770aXIDQrhVOIGurT/pVdfCpSq1GQV/auzMN5fzvY= +github.com/apex/log v1.1.1 h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA= +github.com/apex/log v1.1.1/go.mod h1:Ls949n1HFtXfbDcjiTTFQqkVUrte0puoIBfO3SVgwOA= +github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE= +github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/bshuster-repo/logrus-logstash-hook v0.4.1 h1:pgAtgj+A31JBVtEHu2uHuEx0n+2ukqUJnS2vVe5pQNA= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 h1:D21IyuvjDCshj1/qq+pCNd3VZOAEI9jy6Bi131YlXgI= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= +github.com/bugsnag/bugsnag-go v1.5.1 h1:NnfkWPiRGJlUg6s5mRlsbudWcW/B/eGFSad98JxitaU= github.com/bugsnag/bugsnag-go v1.5.1/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= +github.com/bugsnag/panicwrap v1.2.0 h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA= github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/containerd/cgroups v0.0.0-20181208203134-65ce98b3dfeb h1:NbTtlERiUsSc6Mbe02Cobgn7tjaSaF6okRFW7FCT0JY= github.com/containerd/cgroups v0.0.0-20181208203134-65ce98b3dfeb/go.mod h1:X9rLEHIqSf/wfK8NsPqxJmeZgW4pcfzdXITDrUSJ6uI= +github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601 h1:6xW3ogNpFIly0umJGEKzFfGDNUk5rXFE1lJ3/gBmz3U= +github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601/go.mod h1:X9rLEHIqSf/wfK8NsPqxJmeZgW4pcfzdXITDrUSJ6uI= github.com/containerd/containerd v1.2.6 h1:K38ZSAA9oKSrX3iFNY+4SddZ8hH1TCMCerc8NHfcKBQ= github.com/containerd/containerd v1.2.6/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/continuity v0.0.0-20180612233548-246e49050efd h1:AqPnRJG7BcXlRtISATdp/XsD4cwZK6MdeMxFQ2hGFdw= @@ -54,8 +68,12 @@ github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c h1:Xo2rK1pzOm0jO6abTPIQw github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= github.com/d2g/dhcp4client v0.0.0-20180611075603-e61299896203 h1:2/TaU1mJO2o4BTLnqz6KxJxe7ektbzoU11yqa8k6N9Y= github.com/d2g/dhcp4client v0.0.0-20180611075603-e61299896203/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= +github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5 h1:+CpLbZIeUn94m02LdEKPcgErLJ347NUwxPKs5u8ieiY= github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= +github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4 h1:itqmmf1PFpC4n5JW+j4BU7X4MTfVurhYRTjODoPb2Y8= github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deislabs/oras v0.4.0 h1:G/wxhm9Simecxlr7dsjWy5iL0UGPAQlnuFNRZsXVJfI= github.com/deislabs/oras v0.4.0/go.mod h1:SXwPnImOu69FofPWaqgB+cPKKQRBmao5i+9xQRdcOiM= @@ -73,17 +91,24 @@ github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= +github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= +github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo= +github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc= github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-log/log v0.1.0 h1:wudGTNsiGzrD5ZjgIkVZ517ugi2XRe9Q/xRCzwEO4/U= github.com/go-log/log v0.1.0/go.mod h1:4mBwpdRMFLiuXZDCwU2lKQFsoSCo72j3HqBK9d81N2M= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/godbus/dbus v4.1.0+incompatible h1:WqqLRTsQic3apZUK9qC5sGNfXthmPXzUZ7nQPrNITa4= github.com/godbus/dbus v4.1.0+incompatible/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= +github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= @@ -94,34 +119,48 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA= github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w+PflHoszQNLTUh4kaByUcEWM/9uin4= +github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357 h1:Rem2+U35z1QtPQc6r+WolF7yXiefXqDKyk+lN2pE164= github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 h1:em+tTnzgU7N22woTBMcSJAOW7tRHAkK597W+MD/CpK8= +github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0 h1:j30noezaCfvNLcdMYSvHLv81DxYRSt1grlpseG67vhU= github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= github.com/hashicorp/go-retryablehttp v0.5.3 h1:QlWt0KvWT0lq8MFppF9tsJGF+ynG7ztc2KIPhzRGk7s= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56 h1:742eGXur0715JMq73aD95/FU0XpVKXqNuTnEfXsLOYQ= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= github.com/juju/errors v0.0.0-20190207033735-e65537c515d7 h1:dMIPRDg6gi7CUp0Kj2+HxqJ5kTr1iAdzsXYIrLCNSmU= github.com/juju/errors v0.0.0-20190207033735-e65537c515d7/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI= github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/testing v0.0.0-20190613124551-e81189438503 h1:ZUgTbk8oHgP0jpMieifGC9Lv47mHn8Pb3mFX3/Ew4iY= github.com/juju/testing v0.0.0-20190613124551-e81189438503/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/klauspost/compress v1.4.0 h1:8nsMz3tWa9SWWPL60G1V6CUsf4lLjWLTNEtibhe8gh8= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= @@ -135,10 +174,19 @@ github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 h1:KAZ1BW2TCmT6PRi github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v0.0.0-20170402124221-0bf5dcad4ada h1:ZHhgRyr+9LYwfuWChpSTCCe/07V26LEElTKUXj+2fAg= github.com/klauspost/pgzip v0.0.0-20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= +github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM= +github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3 h1:/Um6a/ZmD5tF7peoOJ5oN5KMQ0DrGVQSXLNwyckutPk= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kubernetes-sigs/cri-o v0.0.0-20180917213123-8afc34092907 h1:vYZ9WIuOKL8VB+Foaspns++EJF+5qF17aZNiC7NAh98= github.com/kubernetes-sigs/cri-o v0.0.0-20180917213123-8afc34092907/go.mod h1:OU8KMZFn54AzPFUlmy3DiEnN/EkdTJDWVUy+gl3z8zE= @@ -147,33 +195,49 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.3 h1:K/VxK7SZ+cvuPgFSLKi5QPI9Vr/ipOf4C1gN+ntueUk= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb h1:e+l77LJOEqXTIQihQJVkA6ZxPOUmfPM5e4H7rcpgtSk= github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mtrmac/gpgme v0.0.0-20170102180018-b2432428689c h1:xa+eQWKuJ9MbB9FBL/eoNvDFvveAkz2LQoz8PzX7Q/4= github.com/mtrmac/gpgme v0.0.0-20170102180018-b2432428689c/go.mod h1:GhAqVMEWnTcW2dxoD/SO3n2enrgWl3y6Dnx4m59GvcA= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/openSUSE/umoci v0.4.2 h1:mTPbly5PZqFhb1FgWSIA6HpRFsWzu5njAnicimmwua0= +github.com/openSUSE/umoci v0.4.2/go.mod h1:FeYjqMzUOsc49joNE3Rndjk4bV3O3cG91RDUwCYaVd4= github.com/openSUSE/umoci v0.4.4 h1:CNwlje61gxLf8Yg8wvfFFURN2a9UtczO+6HQS9x+r+s= github.com/openSUSE/umoci v0.4.4/go.mod h1:WC0knmZfXsEOZyJUv/k3zDOCzjyaFTGMvooGTe4NzIw= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392 h1:rBwY4zl6Rvzh0RyFbELnswKxVfiq7xB/d2sfgy3PmHI= github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/image-spec v1.0.0 h1:jcw3cCH887bLKETGYpv8afogdYchbShR0eH6oD9d5PQ= +github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runtime-spec v0.0.0-20180913141938-5806c3563733 h1:3g+PhOUU7d+gimwdmJU++EIKFzWUASEviZHhpOt/Zvw= github.com/opencontainers/runtime-spec v0.0.0-20180913141938-5806c3563733/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/runtime-spec v1.0.0 h1:O6L965K88AilqnxeYPks/75HLpp4IG+FjeSCI3cVdRg= +github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/runtime-tools v0.6.0 h1:NYIDT9KoSAIfmXpMrulp/j+64c8OBb2l19u3vmOl4so= +github.com/opencontainers/runtime-tools v0.6.0/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= github.com/opencontainers/runtime-tools v0.7.0 h1:MIjqgwi4ZC+eVNGiYotCUYuTfs/oWDEcigK9Ra5ruHU= github.com/opencontainers/runtime-tools v0.7.0/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= github.com/opencontainers/selinux v1.0.0-rc1 h1:Q70KvmpJSrYzryl/d0tC3vWUiTn23cSdStKodlokEPs= @@ -182,9 +246,15 @@ github.com/opencontainers/selinux v1.2.2 h1:Kx9J6eDG5/24A6DtUquGSpJQ+m2MUTahn4Ft github.com/opencontainers/selinux v1.2.2/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pquerna/ffjson v0.0.0-20171002144729-d49c2bc1aa13 h1:AUK/hm/tPsiNNASdb3J8fySVRZoI7fnK5mlOvdFD43o= github.com/pquerna/ffjson v0.0.0-20171002144729-d49c2bc1aa13/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= @@ -196,6 +266,7 @@ github.com/prometheus/common v0.0.0-20180518154759-7600349dcfe1 h1:osmNoEW2SCW3L github.com/prometheus/common v0.0.0-20180518154759-7600349dcfe1/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180612222113-7d6f385de8be h1:MoyXp/VjXUwM0GyDcdwT7Ubea2gxOSHpPaFo3qV+Y2A= github.com/prometheus/procfs v0.0.0-20180612222113-7d6f385de8be/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rootless-containers/proto v0.1.0 h1:gS1JOMEtk1YDYHCzBAf/url+olMJbac7MTrgSeP6zh4= github.com/rootless-containers/proto v0.1.0/go.mod h1:vgkUFZbQd0gcE/K/ZwtE4MYjZPu0UNHLXIQxhyqAFh8= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= @@ -208,10 +279,16 @@ github.com/seccomp/libseccomp-golang v0.9.0 h1:S1pmhdFh5spQtVojA+4GUdWBqvI8ydYHx github.com/seccomp/libseccomp-golang v0.9.0/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/seccomp/libseccomp-golang v0.9.1 h1:NJjM5DNFOs0s3kYE1WUOr6G8V97sdt46rlXTMfXGWBo= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.0.5 h1:8c8b5uO0zS4X6RPl/sd1ENwSkIc0/H2PaHxE3udaE8I= github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6 h1:hcP1GmhGigz/O7h1WVUM5KklBp1JoNS9FggWKdj/j3s= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= +github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM= +github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= @@ -220,10 +297,17 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6 github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 h1:4bT0pPowCpQImewr+BjzfUKcuFW+KVyB8d1OF3b6oTI= github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50/go.mod h1:1pdIZTAHUz+HDKDVZ++5xg/duPlhKAIzw9qy42CWYp4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/sylabs/golang-x-crypto v0.0.0-20181006204705-4bce89e8e9a9 h1:OjtuUh4ZvQpHdwDHOgi8LM0skj8imSc2Hz6966oGxKY= github.com/sylabs/golang-x-crypto v0.0.0-20181006204705-4bce89e8e9a9/go.mod h1:Qf7xZmhvuwq9Hq4LdNLS4xabRQkPJSvEP3Bh4UFG0v4= +github.com/sylabs/image-tools v0.0.0-20181006203805-2814f4980568 h1:Bv8RD7DVhhvYw31BJbw2vhUie1jqHmRHjcypRtroG6k= +github.com/sylabs/image-tools v0.0.0-20181006203805-2814f4980568/go.mod h1:1CO+05HLIlepCW8AZHGumlYfh/6mOa6puEIt1Yv0aUM= github.com/sylabs/json-resp v0.5.0 h1:AWdKu6aS0WrkkltX1M0ex0lENrIcx5TISox902s2L2M= github.com/sylabs/json-resp v0.5.0/go.mod h1:anCzED2SGHHZQDubMuoVtwMuJZdpqQ+7iso8yDFm/nQ= github.com/sylabs/scs-build-client v0.0.4 h1:y1rer0Mq+GyAFPKn0szpayJfUSTD7SGgRB3Yh0dJo+g= @@ -238,11 +322,20 @@ github.com/sylabs/sif v1.0.7 h1:LhhPjQA1jbfsGwupnFd6IyE/8qCdCUFstbwK6ItEEAk= github.com/sylabs/sif v1.0.7/go.mod h1:/W42wtEREMjfQCNz1HhqD2PHW8ZPqjiU7Z2pZQXTRqI= github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e h1:QjF5rxNgRSLHJDwKUvfYP3qOx1vTDzUi/+oSC8FXnCI= github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= +github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0= +github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0= +github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= +github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.21.0 h1:wYSSj06510qPIzGSua9ZqsncMmWE3Zr55KBERygyrxE= +github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ= github.com/vbatts/go-mtree v0.4.3 h1:IC2s9EpogK3QzU+VsfuEdM7POkwnW43XDGAWO2Rb1Bo= github.com/vbatts/go-mtree v0.4.3/go.mod h1:3sazBqLG4bZYmgRTgdh9X3iKTzwBpp5CrREJDzrNSXY= +github.com/vbatts/go-mtree v0.4.4 h1:+CncqETnSpxBCCUhRnNQBvxhsjWXNuc+ExZsLSNaj5o= +github.com/vbatts/go-mtree v0.4.4/go.mod h1:3sazBqLG4bZYmgRTgdh9X3iKTzwBpp5CrREJDzrNSXY= github.com/vishvananda/netlink v1.0.1-0.20190618143317-99a56c251ae6 h1:YqlaLDyh/+jUHgh83iNy8KiCvD4LeqnSS5U5a9cgYqU= github.com/vishvananda/netlink v1.0.1-0.20190618143317-99a56c251ae6/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 h1:J9gO8RJCAFlln1jsvRba/CWVUnMHwObklfxxjErl1uk= @@ -251,18 +344,30 @@ github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f h1:mvXjJIHRZyhNuGassLTcXTwjiWq7NmjdavZsUnmFybQ= +github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xeipuuv/gojsonschema v0.0.0-20180719132039-b84684d0e066 h1:iBmpEMJZETMKCupjL9Q7X3Q5utIRnWGbls0TXTgD7JI= github.com/xeipuuv/gojsonschema v0.0.0-20180719132039-b84684d0e066/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= +github.com/xenolf/lego v2.5.0+incompatible h1:vjkBSqBww+pMeQgH/VjbVZPP+qccOmNE82TgC4CO8cI= github.com/xenolf/lego v2.5.0+incompatible/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 h1:p7OofyZ509h8DmPLh8Hn+EIIZm/xYhdZHJ9GnXHdr6U= github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= +github.com/yvasiyarov/gorelic v0.0.6 h1:qMJQYPNdtJ7UNYHjX38KXZtltKTqimMuoQjNnSVIuJg= github.com/yvasiyarov/gorelic v0.0.6/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= +github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 h1:AsFN8kXcCVkUFHyuzp1FtYbzp1nCO/H6+1uPSGEyPzM= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= +go4.org v0.0.0-20180417224846-9599cf28b011 h1:i0QTVNl3j6yciHiQIHxz+mnsSQqo/xi78EGN7yNpMVw= +go4.org v0.0.0-20180417224846-9599cf28b011/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= +go4.org v0.0.0-20190313082347-94abd6928b1d h1:JkRdGP3zvTtTbabWSAC6n67ka30y7gOzWAah4XYJSfw= +go4.org v0.0.0-20190313082347-94abd6928b1d/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= @@ -273,7 +378,11 @@ golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180810170437-e96c4e24768d/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -282,14 +391,22 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.20.0 h1:DlsSIrgEBuZAUFJcta2B5i/lzeHHbnfkNFAfFXLVFYQ= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25 h1:Ev7yu1/f6+d+b3pi5vPdRPc6nNtP1umSfcWiEfRqv6I= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= +gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= @@ -297,5 +414,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.3.0+incompatible h1:oTCKjb7ZuVfn37AQodk7UysjQQL/S5Dep3pzi59u1NQ= gotest.tools v2.3.0+incompatible/go.mod h1:R//lfYlUuTOTfblYI3lGoAAAebUdzjvbmQsuB7Ykd90= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/client-go v0.0.0-20181010045704-56e7a63b5e38 h1:KirVQhD3RM/NNQUJeinP5Bq4He0bv2RopF2RFxrC7Ck= k8s.io/client-go v0.0.0-20181010045704-56e7a63b5e38/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= +rsc.io/letsencrypt v0.0.1 h1:DV0d09Ne9E7UUa9ZqWktZ9L2VmybgTgfq7xlfFR/bbU= rsc.io/letsencrypt v0.0.1/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY= diff --git a/internal/pkg/build/sources/conveyorPacker_oci.go b/internal/pkg/build/sources/conveyorPacker_oci.go index 1c00dde687..ce51998222 100644 --- a/internal/pkg/build/sources/conveyorPacker_oci.go +++ b/internal/pkg/build/sources/conveyorPacker_oci.go @@ -27,9 +27,6 @@ import ( oci "github.com/containers/image/oci/layout" "github.com/containers/image/signature" "github.com/containers/image/types" - "github.com/openSUSE/umoci" - umocilayer "github.com/openSUSE/umoci/oci/layer" - "github.com/openSUSE/umoci/pkg/idtools" imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" ociclient "github.com/sylabs/singularity/internal/pkg/client/oci" "github.com/sylabs/singularity/internal/pkg/sylog" @@ -292,48 +289,8 @@ func (cp *OCIConveyorPacker) extractArchive(src string, dst string) error { } } -func (cp *OCIConveyorPacker) unpackTmpfs() (err error) { - var mapOptions umocilayer.MapOptions - - // Allow unpacking as non-root - if os.Geteuid() != 0 { - mapOptions.Rootless = true - - uidMap, err := idtools.ParseMapping(fmt.Sprintf("0:%d:1", os.Geteuid())) - if err != nil { - return fmt.Errorf("error parsing uidmap: %s", err) - } - mapOptions.UIDMappings = append(mapOptions.UIDMappings, uidMap) - - gidMap, err := idtools.ParseMapping(fmt.Sprintf("0:%d:1", os.Getegid())) - if err != nil { - return fmt.Errorf("error parsing gidmap: %s", err) - } - mapOptions.GIDMappings = append(mapOptions.GIDMappings, gidMap) - } - - engineExt, err := umoci.OpenLayout(cp.b.Path) - if err != nil { - return fmt.Errorf("error opening layout: %s", err) - } - - // Obtain the manifest - imageSource, err := cp.tmpfsRef.NewImageSource(context.Background(), cp.sysCtx) - if err != nil { - return fmt.Errorf("error creating image source: %s", err) - } - manifestData, mediaType, err := imageSource.GetManifest(context.Background(), nil) - if err != nil { - return fmt.Errorf("error obtaining manifest source: %s", err) - } - if mediaType != imgspecv1.MediaTypeImageManifest { - return fmt.Errorf("error verifying manifest media type: %s", mediaType) - } - var manifest imgspecv1.Manifest - json.Unmarshal(manifestData, &manifest) - - // Unpack root filesystem - return umocilayer.UnpackRootfs(context.Background(), engineExt, cp.b.Rootfs(), manifest, &mapOptions) +func (cp *OCIConveyorPacker) unpackTmpfs() error { + return unpackRootfs(cp.b, cp.tmpfsRef, cp.sysCtx) } func (cp *OCIConveyorPacker) insertBaseEnv() (err error) { diff --git a/internal/pkg/build/sources/oci_unpack_darwin.go b/internal/pkg/build/sources/oci_unpack_darwin.go new file mode 100644 index 0000000000..debf0ba871 --- /dev/null +++ b/internal/pkg/build/sources/oci_unpack_darwin.go @@ -0,0 +1,23 @@ +// Copyright (c) 2019, Sylabs Inc. All rights reserved. +// This software is licensed under a 3-clause BSD license. Please consult the +// LICENSE.md file distributed with the sources of this project regarding your +// rights to use or distribute this software. + +// TODO(ian): The build package should be refactored to make each conveyorpacker +// its own separate package. With that change, this file should be grouped with the +// OCIConveyorPacker code + +package sources + +import ( + "github.com/containers/image/types" + imagetools "github.com/opencontainers/image-tools/image" + sytypes "github.com/sylabs/singularity/pkg/build/types" +) + +// unpackRootfs extracts all of the layers of the given image reference into the rootfs of the provided bundle +func unpackRootfs(b *sytypes.Bundle, _ types.ImageReference, _ *types.SystemContext) (err error) { + refs := []string{"name=tmp"} + err = imagetools.UnpackLayout(b.Path, b.Rootfs(), "amd64", refs) + return err +} diff --git a/internal/pkg/build/sources/oci_unpack_linux.go b/internal/pkg/build/sources/oci_unpack_linux.go new file mode 100644 index 0000000000..decbe585ee --- /dev/null +++ b/internal/pkg/build/sources/oci_unpack_linux.go @@ -0,0 +1,72 @@ +// Copyright (c) 2019, Sylabs Inc. All rights reserved. +// This software is licensed under a 3-clause BSD license. Please consult the +// LICENSE.md file distributed with the sources of this project regarding your +// rights to use or distribute this software. + +// TODO(ian): The build package should be refactored to make each conveyorpacker +// its own separate package. With that change, this file should be grouped with the +// OCIConveyorPacker code + +package sources + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/containers/image/types" + "github.com/openSUSE/umoci" + umocilayer "github.com/openSUSE/umoci/oci/layer" + "github.com/openSUSE/umoci/pkg/idtools" + imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" + sytypes "github.com/sylabs/singularity/pkg/build/types" +) + +// unpackRootfs extracts all of the layers of the given image reference into the rootfs of the provided bundle +func unpackRootfs(b *sytypes.Bundle, tmpfsRef types.ImageReference, sysCtx *types.SystemContext) (err error) { + var mapOptions umocilayer.MapOptions + + // Allow unpacking as non-root + if os.Geteuid() != 0 { + mapOptions.Rootless = true + + uidMap, err := idtools.ParseMapping(fmt.Sprintf("0:%d:1", os.Geteuid())) + if err != nil { + return fmt.Errorf("error parsing uidmap: %s", err) + } + mapOptions.UIDMappings = append(mapOptions.UIDMappings, uidMap) + + gidMap, err := idtools.ParseMapping(fmt.Sprintf("0:%d:1", os.Getegid())) + if err != nil { + return fmt.Errorf("error parsing gidmap: %s", err) + } + mapOptions.GIDMappings = append(mapOptions.GIDMappings, gidMap) + } + + engineExt, err := umoci.OpenLayout(b.Path) + if err != nil { + return fmt.Errorf("error opening layout: %s", err) + } + + // Obtain the manifest + imageSource, err := tmpfsRef.NewImageSource(context.Background(), sysCtx) + if err != nil { + return fmt.Errorf("error creating image source: %s", err) + } + manifestData, mediaType, err := imageSource.GetManifest(context.Background(), nil) + if err != nil { + return fmt.Errorf("error obtaining manifest source: %s", err) + } + if mediaType != imgspecv1.MediaTypeImageManifest { + return fmt.Errorf("error verifying manifest media type: %s", mediaType) + } + var manifest imgspecv1.Manifest + json.Unmarshal(manifestData, &manifest) + + // UnpackRootfs from umoci v0.4.2 expects a path to a non-existing directory + os.RemoveAll(b.Rootfs()) + + // Unpack root filesystem + return umocilayer.UnpackRootfs(context.Background(), engineExt, b.Rootfs(), manifest, &mapOptions) +} diff --git a/vendor/github.com/apex/log/.gitignore b/vendor/github.com/apex/log/.gitignore new file mode 100644 index 0000000000..7a6353d673 --- /dev/null +++ b/vendor/github.com/apex/log/.gitignore @@ -0,0 +1 @@ +.envrc diff --git a/vendor/github.com/apex/log/History.md b/vendor/github.com/apex/log/History.md new file mode 100644 index 0000000000..c88be39eb9 --- /dev/null +++ b/vendor/github.com/apex/log/History.md @@ -0,0 +1,12 @@ + +v1.1.1 / 2019-06-24 +=================== + + * add go.mod + * add rough pass at apexlogs handler + +v1.1.0 / 2018-10-11 +=================== + + * fix: cli handler to show non-string fields appropriately + * fix: cli using fatih/color to better support windows diff --git a/vendor/github.com/apex/log/go.mod b/vendor/github.com/apex/log/go.mod new file mode 100644 index 0000000000..efc674b8cd --- /dev/null +++ b/vendor/github.com/apex/log/go.mod @@ -0,0 +1,25 @@ +module github.com/apex/log + +go 1.12 + +require ( + github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a + github.com/aphistic/sweet v0.2.0 // indirect + github.com/aws/aws-sdk-go v1.20.6 + github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 + github.com/fatih/color v1.7.0 + github.com/go-logfmt/logfmt v0.4.0 + github.com/google/uuid v1.1.1 // indirect + github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 // indirect + github.com/mattn/go-colorable v0.1.2 + github.com/pkg/errors v0.8.1 + github.com/rogpeppe/fastuuid v1.1.0 + github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 // indirect + github.com/smartystreets/gunit v1.0.0 // indirect + github.com/stretchr/testify v1.3.0 + github.com/tj/assert v0.0.0-20171129193455-018094318fb0 + github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2 + github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b + github.com/tj/go-spin v1.1.0 + golang.org/x/net v0.0.0-20190620200207-3b0461eec859 // indirect +) diff --git a/vendor/github.com/apex/log/go.sum b/vendor/github.com/apex/log/go.sum new file mode 100644 index 0000000000..972a66dbcb --- /dev/null +++ b/vendor/github.com/apex/log/go.sum @@ -0,0 +1,90 @@ +github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a h1:2KLQMJ8msqoPHIPDufkxVcoTtcmE5+1sL9950m4R9Pk= +github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE= +github.com/aphistic/sweet v0.2.0 h1:I4z+fAUqvKfvZV/CHi5dV0QuwbmIvYYFDjG0Ss5QpAs= +github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= +github.com/aws/aws-sdk-go v1.20.6 h1:kmy4Gvdlyez1fV4kw5RYxZzWKVyuHZHgPWeU/YvRsV4= +github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 h1:WWB576BN5zNSZc/M9d/10pqEx5VHNhaQ/yOVAkmj5Yo= +github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 h1:K//n/AqR5HjG3qxbrBCL4vJPW0MVFSs9CPK1OOJdRME= +github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/fastuuid v1.1.0 h1:INyGLmTCMGFr6OVIb977ghJvABML2CMVjPoRfNDdYDo= +github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8= +github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= +github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 h1:hp2CYQUINdZMHdvTdXtPOY2ainKl4IoMcpAXEf2xj3Q= +github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM= +github.com/smartystreets/gunit v1.0.0 h1:RyPDUFcJbvtXlhJPk7v+wnxZRY2EUokhEYl2EJOPToI= +github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/tj/assert v0.0.0-20171129193455-018094318fb0 h1:Rw8kxzWo1mr6FSaYXjQELRe88y2KdfynXdnK72rdjtA= +github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0= +github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2 h1:eGaGNxrtoZf/mBURsnNQKDR7u50Klgcf2eFDQEnc8Bc= +github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0= +github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b h1:m74UWYy+HBs+jMFR9mdZU6shPewugMyH5+GV6LNgW8w= +github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= +github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= +github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/docker/go-metrics/CONTRIBUTING.md b/vendor/github.com/docker/go-metrics/CONTRIBUTING.md index 452d28eda8..b8a512c366 100644 --- a/vendor/github.com/docker/go-metrics/CONTRIBUTING.md +++ b/vendor/github.com/docker/go-metrics/CONTRIBUTING.md @@ -1,13 +1,23 @@ +# Contributing + +## Sign your work + +The sign-off is a simple line at the end of the explanation for the patch. Your +signature certifies that you wrote the patch or otherwise have the right to pass +it on as an open-source patch. The rules are pretty simple: if you can certify +the below (from [developercertificate.org](http://developercertificate.org/)): + +``` Developer Certificate of Origin Version 1.1 -Copyright (C) 2015- Klaus Post & Contributors. -Email: klauspost@gmail.com +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +660 York Street, Suite 102, +San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: @@ -33,3 +43,13 @@ By making a contribution to this project, I certify that: personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. +``` + +Then you just add a line to every git commit message: + + Signed-off-by: Joe Smith + +Use your real name (sorry, no pseudonyms or anonymous contributions.) + +If you set your `user.name` and `user.email` git configs, you can sign your +commit automatically with `git commit -s`. diff --git a/vendor/github.com/hashicorp/errwrap/README.md b/vendor/github.com/hashicorp/errwrap/README.md index 444df08f8e..1c95f59782 100644 --- a/vendor/github.com/hashicorp/errwrap/README.md +++ b/vendor/github.com/hashicorp/errwrap/README.md @@ -48,7 +48,7 @@ func main() { // We can use the Contains helpers to check if an error contains // another error. It is safe to do this with a nil error, or with // an error that doesn't even use the errwrap package. - if errwrap.Contains(err, "does not exist") { + if errwrap.Contains(err, ErrNotExist) { // Do something } if errwrap.ContainsType(err, new(os.PathError)) { diff --git a/vendor/github.com/hashicorp/go-multierror/format.go b/vendor/github.com/hashicorp/go-multierror/format.go index 47f13c49a6..6c7a3cc91d 100644 --- a/vendor/github.com/hashicorp/go-multierror/format.go +++ b/vendor/github.com/hashicorp/go-multierror/format.go @@ -13,7 +13,7 @@ type ErrorFormatFunc func([]error) string // that occurred along with a bullet point list of the errors. func ListFormatFunc(es []error) string { if len(es) == 1 { - return fmt.Sprintf("1 error occurred:\n\t* %s\n\n", es[0]) + return fmt.Sprintf("1 error occurred:\n\n* %s", es[0]) } points := make([]string, len(es)) @@ -22,6 +22,6 @@ func ListFormatFunc(es []error) string { } return fmt.Sprintf( - "%d errors occurred:\n\t%s\n\n", - len(es), strings.Join(points, "\n\t")) + "%d errors occurred:\n\n%s", + len(es), strings.Join(points, "\n")) } diff --git a/vendor/github.com/hashicorp/go-multierror/sort.go b/vendor/github.com/hashicorp/go-multierror/sort.go deleted file mode 100644 index fecb14e81c..0000000000 --- a/vendor/github.com/hashicorp/go-multierror/sort.go +++ /dev/null @@ -1,16 +0,0 @@ -package multierror - -// Len implements sort.Interface function for length -func (err Error) Len() int { - return len(err.Errors) -} - -// Swap implements sort.Interface function for swapping elements -func (err Error) Swap(i, j int) { - err.Errors[i], err.Errors[j] = err.Errors[j], err.Errors[i] -} - -// Less implements sort.Interface function for determining order -func (err Error) Less(i, j int) bool { - return err.Errors[i].Error() < err.Errors[j].Error() -} diff --git a/vendor/github.com/klauspost/compress/flate/crc32_amd64.go b/vendor/github.com/klauspost/compress/flate/crc32_amd64.go index 70a6095e60..8298d309ae 100644 --- a/vendor/github.com/klauspost/compress/flate/crc32_amd64.go +++ b/vendor/github.com/klauspost/compress/flate/crc32_amd64.go @@ -1,5 +1,6 @@ //+build !noasm //+build !appengine +//+build !gccgo // Copyright 2015, Klaus Post, see LICENSE for details. diff --git a/vendor/github.com/klauspost/compress/flate/crc32_amd64.s b/vendor/github.com/klauspost/compress/flate/crc32_amd64.s index 2fb2079b9d..a799437270 100644 --- a/vendor/github.com/klauspost/compress/flate/crc32_amd64.s +++ b/vendor/github.com/klauspost/compress/flate/crc32_amd64.s @@ -1,5 +1,6 @@ //+build !noasm //+build !appengine +//+build !gccgo // Copyright 2015, Klaus Post, see LICENSE for details. diff --git a/vendor/github.com/klauspost/compress/flate/crc32_noasm.go b/vendor/github.com/klauspost/compress/flate/crc32_noasm.go index bd98bd598f..dcf43bd50a 100644 --- a/vendor/github.com/klauspost/compress/flate/crc32_noasm.go +++ b/vendor/github.com/klauspost/compress/flate/crc32_noasm.go @@ -1,4 +1,4 @@ -//+build !amd64 noasm appengine +//+build !amd64 noasm appengine gccgo // Copyright 2015, Klaus Post, see LICENSE for details. diff --git a/vendor/github.com/klauspost/cpuid/.travis.yml b/vendor/github.com/klauspost/cpuid/.travis.yml index 2332ea6d70..630192d597 100644 --- a/vendor/github.com/klauspost/cpuid/.travis.yml +++ b/vendor/github.com/klauspost/cpuid/.travis.yml @@ -6,10 +6,9 @@ os: - linux - osx go: - - 1.5.x - - 1.6.x - - 1.7.x - 1.8.x + - 1.9.x + - 1.10.x - master script: diff --git a/vendor/github.com/klauspost/cpuid/CONTRIBUTING.txt b/vendor/github.com/klauspost/cpuid/CONTRIBUTING.txt new file mode 100644 index 0000000000..2ef4714f71 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/CONTRIBUTING.txt @@ -0,0 +1,35 @@ +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2015- Klaus Post & Contributors. +Email: klauspost@gmail.com + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. diff --git a/vendor/github.com/klauspost/cpuid/cpuid.go b/vendor/github.com/klauspost/cpuid/cpuid.go index 44e50946f3..60c681bed2 100644 --- a/vendor/github.com/klauspost/cpuid/cpuid.go +++ b/vendor/github.com/klauspost/cpuid/cpuid.go @@ -76,6 +76,8 @@ const ( RDTSCP // RDTSCP Instruction CX16 // CMPXCHG16B Instruction SGX // Software Guard Extensions + IBPB // Indirect Branch Restricted Speculation (IBRS) and Indirect Branch Predictor Barrier (IBPB) + STIBP // Single Thread Indirect Branch Predictors // Performance indicators SSE2SLOW // SSE2 is supported, but usually not faster @@ -131,6 +133,8 @@ var flagNames = map[Flags]string{ RDTSCP: "RDTSCP", // RDTSCP Instruction CX16: "CX16", // CMPXCHG16B Instruction SGX: "SGX", // Software Guard Extensions + IBPB: "IBPB", // Indirect Branch Restricted Speculation and Indirect Branch Predictor Barrier + STIBP: "STIBP", // Single Thread Indirect Branch Predictors // Performance indicators SSE2SLOW: "SSE2SLOW", // SSE2 supported, but usually not faster @@ -450,7 +454,7 @@ func (c CPUInfo) CX16() bool { // TSX is split into HLE (Hardware Lock Elision) and RTM (Restricted Transactional Memory) detection. // So TSX simply checks that. func (c CPUInfo) TSX() bool { - return c.Features&(MPX|RTM) == MPX|RTM + return c.Features&(HLE|RTM) == HLE|RTM } // Atom indicates an Atom processor @@ -854,7 +858,7 @@ func support() Flags { // Check AVX2, AVX2 requires OS support, but BMI1/2 don't. if mfi >= 7 { - _, ebx, ecx, _ := cpuidex(7, 0) + _, ebx, ecx, edx := cpuidex(7, 0) if (rval&AVX) != 0 && (ebx&0x00000020) != 0 { rval |= AVX2 } @@ -888,6 +892,12 @@ func support() Flags { if ebx&(1<<29) != 0 { rval |= SHA } + if edx&(1<<26) != 0 { + rval |= IBPB + } + if edx&(1<<27) != 0 { + rval |= STIBP + } // Only detect AVX-512 features if XGETBV is supported if c&((1<<26)|(1<<27)) == (1<<26)|(1<<27) { diff --git a/vendor/github.com/klauspost/crc32/.gitignore b/vendor/github.com/klauspost/crc32/.gitignore deleted file mode 100644 index daf913b1b3..0000000000 --- a/vendor/github.com/klauspost/crc32/.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/klauspost/crc32/.travis.yml b/vendor/github.com/klauspost/crc32/.travis.yml deleted file mode 100644 index de64ae491f..0000000000 --- a/vendor/github.com/klauspost/crc32/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go - -go: - - 1.3 - - 1.4 - - 1.5 - - 1.6 - - 1.7 - - tip - -script: - - go test -v . - - go test -v -race . diff --git a/vendor/github.com/klauspost/crc32/LICENSE b/vendor/github.com/klauspost/crc32/LICENSE deleted file mode 100644 index 4fd5963e39..0000000000 --- a/vendor/github.com/klauspost/crc32/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2012 The Go Authors. All rights reserved. -Copyright (c) 2015 Klaus Post - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/klauspost/crc32/README.md b/vendor/github.com/klauspost/crc32/README.md deleted file mode 100644 index 029625d360..0000000000 --- a/vendor/github.com/klauspost/crc32/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# crc32 -CRC32 hash with x64 optimizations - -This package is a drop-in replacement for the standard library `hash/crc32` package, that features SSE 4.2 optimizations on x64 platforms, for a 10x speedup. - -[![Build Status](https://travis-ci.org/klauspost/crc32.svg?branch=master)](https://travis-ci.org/klauspost/crc32) - -# usage - -Install using `go get github.com/klauspost/crc32`. This library is based on Go 1.5 code and requires Go 1.3 or newer. - -Replace `import "hash/crc32"` with `import "github.com/klauspost/crc32"` and you are good to go. - -# changes -* Oct 20, 2016: Changes have been merged to upstream Go. Package updated to match. -* Dec 4, 2015: Uses the "slice-by-8" trick more extensively, which gives a 1.5 to 2.5x speedup if assembler is unavailable. - - -# performance - -For *Go 1.7* performance is equivalent to the standard library. So if you use this package for Go 1.7 you can switch back. - - -For IEEE tables (the most common), there is approximately a factor 10 speedup with "CLMUL" (Carryless multiplication) instruction: -``` -benchmark old ns/op new ns/op delta -BenchmarkCrc32KB 99955 10258 -89.74% - -benchmark old MB/s new MB/s speedup -BenchmarkCrc32KB 327.83 3194.20 9.74x -``` - -For other tables and "CLMUL" capable machines the performance is the same as the standard library. - -Here are some detailed benchmarks, comparing to go 1.5 standard library with and without assembler enabled. - -``` -Std: Standard Go 1.5 library -Crc: Indicates IEEE type CRC. -40B: Size of each slice encoded. -NoAsm: Assembler was disabled (ie. not an AMD64 or SSE 4.2+ capable machine). -Castagnoli: Castagnoli CRC type. - -BenchmarkStdCrc40B-4 10000000 158 ns/op 252.88 MB/s -BenchmarkCrc40BNoAsm-4 20000000 105 ns/op 377.38 MB/s (slice8) -BenchmarkCrc40B-4 20000000 105 ns/op 378.77 MB/s (slice8) - -BenchmarkStdCrc1KB-4 500000 3604 ns/op 284.10 MB/s -BenchmarkCrc1KBNoAsm-4 1000000 1463 ns/op 699.79 MB/s (slice8) -BenchmarkCrc1KB-4 3000000 396 ns/op 2583.69 MB/s (asm) - -BenchmarkStdCrc8KB-4 200000 11417 ns/op 717.48 MB/s (slice8) -BenchmarkCrc8KBNoAsm-4 200000 11317 ns/op 723.85 MB/s (slice8) -BenchmarkCrc8KB-4 500000 2919 ns/op 2805.73 MB/s (asm) - -BenchmarkStdCrc32KB-4 30000 45749 ns/op 716.24 MB/s (slice8) -BenchmarkCrc32KBNoAsm-4 30000 45109 ns/op 726.42 MB/s (slice8) -BenchmarkCrc32KB-4 100000 11497 ns/op 2850.09 MB/s (asm) - -BenchmarkStdNoAsmCastagnol40B-4 10000000 161 ns/op 246.94 MB/s -BenchmarkStdCastagnoli40B-4 50000000 28.4 ns/op 1410.69 MB/s (asm) -BenchmarkCastagnoli40BNoAsm-4 20000000 100 ns/op 398.01 MB/s (slice8) -BenchmarkCastagnoli40B-4 50000000 28.2 ns/op 1419.54 MB/s (asm) - -BenchmarkStdNoAsmCastagnoli1KB-4 500000 3622 ns/op 282.67 MB/s -BenchmarkStdCastagnoli1KB-4 10000000 144 ns/op 7099.78 MB/s (asm) -BenchmarkCastagnoli1KBNoAsm-4 1000000 1475 ns/op 694.14 MB/s (slice8) -BenchmarkCastagnoli1KB-4 10000000 146 ns/op 6993.35 MB/s (asm) - -BenchmarkStdNoAsmCastagnoli8KB-4 50000 28781 ns/op 284.63 MB/s -BenchmarkStdCastagnoli8KB-4 1000000 1029 ns/op 7957.89 MB/s (asm) -BenchmarkCastagnoli8KBNoAsm-4 200000 11410 ns/op 717.94 MB/s (slice8) -BenchmarkCastagnoli8KB-4 1000000 1000 ns/op 8188.71 MB/s (asm) - -BenchmarkStdNoAsmCastagnoli32KB-4 10000 115426 ns/op 283.89 MB/s -BenchmarkStdCastagnoli32KB-4 300000 4065 ns/op 8059.13 MB/s (asm) -BenchmarkCastagnoli32KBNoAsm-4 30000 45171 ns/op 725.41 MB/s (slice8) -BenchmarkCastagnoli32KB-4 500000 4077 ns/op 8035.89 MB/s (asm) -``` - -The IEEE assembler optimizations has been submitted and will be part of the Go 1.6 standard library. - -However, the improved use of slice-by-8 has not, but will probably be submitted for Go 1.7. - -# license - -Standard Go license. Changes are Copyright (c) 2015 Klaus Post under same conditions. diff --git a/vendor/github.com/klauspost/crc32/crc32.go b/vendor/github.com/klauspost/crc32/crc32.go deleted file mode 100644 index 8aa91b17e9..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32.go +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, -// checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for -// information. -// -// Polynomials are represented in LSB-first form also known as reversed representation. -// -// See http://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks#Reversed_representations_and_reciprocal_polynomials -// for information. -package crc32 - -import ( - "hash" - "sync" -) - -// The size of a CRC-32 checksum in bytes. -const Size = 4 - -// Predefined polynomials. -const ( - // IEEE is by far and away the most common CRC-32 polynomial. - // Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, ... - IEEE = 0xedb88320 - - // Castagnoli's polynomial, used in iSCSI. - // Has better error detection characteristics than IEEE. - // http://dx.doi.org/10.1109/26.231911 - Castagnoli = 0x82f63b78 - - // Koopman's polynomial. - // Also has better error detection characteristics than IEEE. - // http://dx.doi.org/10.1109/DSN.2002.1028931 - Koopman = 0xeb31d82e -) - -// Table is a 256-word table representing the polynomial for efficient processing. -type Table [256]uint32 - -// This file makes use of functions implemented in architecture-specific files. -// The interface that they implement is as follows: -// -// // archAvailableIEEE reports whether an architecture-specific CRC32-IEEE -// // algorithm is available. -// archAvailableIEEE() bool -// -// // archInitIEEE initializes the architecture-specific CRC3-IEEE algorithm. -// // It can only be called if archAvailableIEEE() returns true. -// archInitIEEE() -// -// // archUpdateIEEE updates the given CRC32-IEEE. It can only be called if -// // archInitIEEE() was previously called. -// archUpdateIEEE(crc uint32, p []byte) uint32 -// -// // archAvailableCastagnoli reports whether an architecture-specific -// // CRC32-C algorithm is available. -// archAvailableCastagnoli() bool -// -// // archInitCastagnoli initializes the architecture-specific CRC32-C -// // algorithm. It can only be called if archAvailableCastagnoli() returns -// // true. -// archInitCastagnoli() -// -// // archUpdateCastagnoli updates the given CRC32-C. It can only be called -// // if archInitCastagnoli() was previously called. -// archUpdateCastagnoli(crc uint32, p []byte) uint32 - -// castagnoliTable points to a lazily initialized Table for the Castagnoli -// polynomial. MakeTable will always return this value when asked to make a -// Castagnoli table so we can compare against it to find when the caller is -// using this polynomial. -var castagnoliTable *Table -var castagnoliTable8 *slicing8Table -var castagnoliArchImpl bool -var updateCastagnoli func(crc uint32, p []byte) uint32 -var castagnoliOnce sync.Once - -func castagnoliInit() { - castagnoliTable = simpleMakeTable(Castagnoli) - castagnoliArchImpl = archAvailableCastagnoli() - - if castagnoliArchImpl { - archInitCastagnoli() - updateCastagnoli = archUpdateCastagnoli - } else { - // Initialize the slicing-by-8 table. - castagnoliTable8 = slicingMakeTable(Castagnoli) - updateCastagnoli = func(crc uint32, p []byte) uint32 { - return slicingUpdate(crc, castagnoliTable8, p) - } - } -} - -// IEEETable is the table for the IEEE polynomial. -var IEEETable = simpleMakeTable(IEEE) - -// ieeeTable8 is the slicing8Table for IEEE -var ieeeTable8 *slicing8Table -var ieeeArchImpl bool -var updateIEEE func(crc uint32, p []byte) uint32 -var ieeeOnce sync.Once - -func ieeeInit() { - ieeeArchImpl = archAvailableIEEE() - - if ieeeArchImpl { - archInitIEEE() - updateIEEE = archUpdateIEEE - } else { - // Initialize the slicing-by-8 table. - ieeeTable8 = slicingMakeTable(IEEE) - updateIEEE = func(crc uint32, p []byte) uint32 { - return slicingUpdate(crc, ieeeTable8, p) - } - } -} - -// MakeTable returns a Table constructed from the specified polynomial. -// The contents of this Table must not be modified. -func MakeTable(poly uint32) *Table { - switch poly { - case IEEE: - ieeeOnce.Do(ieeeInit) - return IEEETable - case Castagnoli: - castagnoliOnce.Do(castagnoliInit) - return castagnoliTable - } - return simpleMakeTable(poly) -} - -// digest represents the partial evaluation of a checksum. -type digest struct { - crc uint32 - tab *Table -} - -// New creates a new hash.Hash32 computing the CRC-32 checksum -// using the polynomial represented by the Table. -// Its Sum method will lay the value out in big-endian byte order. -func New(tab *Table) hash.Hash32 { - if tab == IEEETable { - ieeeOnce.Do(ieeeInit) - } - return &digest{0, tab} -} - -// NewIEEE creates a new hash.Hash32 computing the CRC-32 checksum -// using the IEEE polynomial. -// Its Sum method will lay the value out in big-endian byte order. -func NewIEEE() hash.Hash32 { return New(IEEETable) } - -func (d *digest) Size() int { return Size } - -func (d *digest) BlockSize() int { return 1 } - -func (d *digest) Reset() { d.crc = 0 } - -// Update returns the result of adding the bytes in p to the crc. -func Update(crc uint32, tab *Table, p []byte) uint32 { - switch tab { - case castagnoliTable: - return updateCastagnoli(crc, p) - case IEEETable: - // Unfortunately, because IEEETable is exported, IEEE may be used without a - // call to MakeTable. We have to make sure it gets initialized in that case. - ieeeOnce.Do(ieeeInit) - return updateIEEE(crc, p) - default: - return simpleUpdate(crc, tab, p) - } -} - -func (d *digest) Write(p []byte) (n int, err error) { - switch d.tab { - case castagnoliTable: - d.crc = updateCastagnoli(d.crc, p) - case IEEETable: - // We only create digest objects through New() which takes care of - // initialization in this case. - d.crc = updateIEEE(d.crc, p) - default: - d.crc = simpleUpdate(d.crc, d.tab, p) - } - return len(p), nil -} - -func (d *digest) Sum32() uint32 { return d.crc } - -func (d *digest) Sum(in []byte) []byte { - s := d.Sum32() - return append(in, byte(s>>24), byte(s>>16), byte(s>>8), byte(s)) -} - -// Checksum returns the CRC-32 checksum of data -// using the polynomial represented by the Table. -func Checksum(data []byte, tab *Table) uint32 { return Update(0, tab, data) } - -// ChecksumIEEE returns the CRC-32 checksum of data -// using the IEEE polynomial. -func ChecksumIEEE(data []byte) uint32 { - ieeeOnce.Do(ieeeInit) - return updateIEEE(0, data) -} diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64.go b/vendor/github.com/klauspost/crc32/crc32_amd64.go deleted file mode 100644 index af2a0b844b..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_amd64.go +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !appengine,!gccgo - -// AMD64-specific hardware-assisted CRC32 algorithms. See crc32.go for a -// description of the interface that each architecture-specific file -// implements. - -package crc32 - -import "unsafe" - -// This file contains the code to call the SSE 4.2 version of the Castagnoli -// and IEEE CRC. - -// haveSSE41/haveSSE42/haveCLMUL are defined in crc_amd64.s and use -// CPUID to test for SSE 4.1, 4.2 and CLMUL support. -func haveSSE41() bool -func haveSSE42() bool -func haveCLMUL() bool - -// castagnoliSSE42 is defined in crc32_amd64.s and uses the SSE4.2 CRC32 -// instruction. -//go:noescape -func castagnoliSSE42(crc uint32, p []byte) uint32 - -// castagnoliSSE42Triple is defined in crc32_amd64.s and uses the SSE4.2 CRC32 -// instruction. -//go:noescape -func castagnoliSSE42Triple( - crcA, crcB, crcC uint32, - a, b, c []byte, - rounds uint32, -) (retA uint32, retB uint32, retC uint32) - -// ieeeCLMUL is defined in crc_amd64.s and uses the PCLMULQDQ -// instruction as well as SSE 4.1. -//go:noescape -func ieeeCLMUL(crc uint32, p []byte) uint32 - -var sse42 = haveSSE42() -var useFastIEEE = haveCLMUL() && haveSSE41() - -const castagnoliK1 = 168 -const castagnoliK2 = 1344 - -type sse42Table [4]Table - -var castagnoliSSE42TableK1 *sse42Table -var castagnoliSSE42TableK2 *sse42Table - -func archAvailableCastagnoli() bool { - return sse42 -} - -func archInitCastagnoli() { - if !sse42 { - panic("arch-specific Castagnoli not available") - } - castagnoliSSE42TableK1 = new(sse42Table) - castagnoliSSE42TableK2 = new(sse42Table) - // See description in updateCastagnoli. - // t[0][i] = CRC(i000, O) - // t[1][i] = CRC(0i00, O) - // t[2][i] = CRC(00i0, O) - // t[3][i] = CRC(000i, O) - // where O is a sequence of K zeros. - var tmp [castagnoliK2]byte - for b := 0; b < 4; b++ { - for i := 0; i < 256; i++ { - val := uint32(i) << uint32(b*8) - castagnoliSSE42TableK1[b][i] = castagnoliSSE42(val, tmp[:castagnoliK1]) - castagnoliSSE42TableK2[b][i] = castagnoliSSE42(val, tmp[:]) - } - } -} - -// castagnoliShift computes the CRC32-C of K1 or K2 zeroes (depending on the -// table given) with the given initial crc value. This corresponds to -// CRC(crc, O) in the description in updateCastagnoli. -func castagnoliShift(table *sse42Table, crc uint32) uint32 { - return table[3][crc>>24] ^ - table[2][(crc>>16)&0xFF] ^ - table[1][(crc>>8)&0xFF] ^ - table[0][crc&0xFF] -} - -func archUpdateCastagnoli(crc uint32, p []byte) uint32 { - if !sse42 { - panic("not available") - } - - // This method is inspired from the algorithm in Intel's white paper: - // "Fast CRC Computation for iSCSI Polynomial Using CRC32 Instruction" - // The same strategy of splitting the buffer in three is used but the - // combining calculation is different; the complete derivation is explained - // below. - // - // -- The basic idea -- - // - // The CRC32 instruction (available in SSE4.2) can process 8 bytes at a - // time. In recent Intel architectures the instruction takes 3 cycles; - // however the processor can pipeline up to three instructions if they - // don't depend on each other. - // - // Roughly this means that we can process three buffers in about the same - // time we can process one buffer. - // - // The idea is then to split the buffer in three, CRC the three pieces - // separately and then combine the results. - // - // Combining the results requires precomputed tables, so we must choose a - // fixed buffer length to optimize. The longer the length, the faster; but - // only buffers longer than this length will use the optimization. We choose - // two cutoffs and compute tables for both: - // - one around 512: 168*3=504 - // - one around 4KB: 1344*3=4032 - // - // -- The nitty gritty -- - // - // Let CRC(I, X) be the non-inverted CRC32-C of the sequence X (with - // initial non-inverted CRC I). This function has the following properties: - // (a) CRC(I, AB) = CRC(CRC(I, A), B) - // (b) CRC(I, A xor B) = CRC(I, A) xor CRC(0, B) - // - // Say we want to compute CRC(I, ABC) where A, B, C are three sequences of - // K bytes each, where K is a fixed constant. Let O be the sequence of K zero - // bytes. - // - // CRC(I, ABC) = CRC(I, ABO xor C) - // = CRC(I, ABO) xor CRC(0, C) - // = CRC(CRC(I, AB), O) xor CRC(0, C) - // = CRC(CRC(I, AO xor B), O) xor CRC(0, C) - // = CRC(CRC(I, AO) xor CRC(0, B), O) xor CRC(0, C) - // = CRC(CRC(CRC(I, A), O) xor CRC(0, B), O) xor CRC(0, C) - // - // The castagnoliSSE42Triple function can compute CRC(I, A), CRC(0, B), - // and CRC(0, C) efficiently. We just need to find a way to quickly compute - // CRC(uvwx, O) given a 4-byte initial value uvwx. We can precompute these - // values; since we can't have a 32-bit table, we break it up into four - // 8-bit tables: - // - // CRC(uvwx, O) = CRC(u000, O) xor - // CRC(0v00, O) xor - // CRC(00w0, O) xor - // CRC(000x, O) - // - // We can compute tables corresponding to the four terms for all 8-bit - // values. - - crc = ^crc - - // If a buffer is long enough to use the optimization, process the first few - // bytes to align the buffer to an 8 byte boundary (if necessary). - if len(p) >= castagnoliK1*3 { - delta := int(uintptr(unsafe.Pointer(&p[0])) & 7) - if delta != 0 { - delta = 8 - delta - crc = castagnoliSSE42(crc, p[:delta]) - p = p[delta:] - } - } - - // Process 3*K2 at a time. - for len(p) >= castagnoliK2*3 { - // Compute CRC(I, A), CRC(0, B), and CRC(0, C). - crcA, crcB, crcC := castagnoliSSE42Triple( - crc, 0, 0, - p, p[castagnoliK2:], p[castagnoliK2*2:], - castagnoliK2/24) - - // CRC(I, AB) = CRC(CRC(I, A), O) xor CRC(0, B) - crcAB := castagnoliShift(castagnoliSSE42TableK2, crcA) ^ crcB - // CRC(I, ABC) = CRC(CRC(I, AB), O) xor CRC(0, C) - crc = castagnoliShift(castagnoliSSE42TableK2, crcAB) ^ crcC - p = p[castagnoliK2*3:] - } - - // Process 3*K1 at a time. - for len(p) >= castagnoliK1*3 { - // Compute CRC(I, A), CRC(0, B), and CRC(0, C). - crcA, crcB, crcC := castagnoliSSE42Triple( - crc, 0, 0, - p, p[castagnoliK1:], p[castagnoliK1*2:], - castagnoliK1/24) - - // CRC(I, AB) = CRC(CRC(I, A), O) xor CRC(0, B) - crcAB := castagnoliShift(castagnoliSSE42TableK1, crcA) ^ crcB - // CRC(I, ABC) = CRC(CRC(I, AB), O) xor CRC(0, C) - crc = castagnoliShift(castagnoliSSE42TableK1, crcAB) ^ crcC - p = p[castagnoliK1*3:] - } - - // Use the simple implementation for what's left. - crc = castagnoliSSE42(crc, p) - return ^crc -} - -func archAvailableIEEE() bool { - return useFastIEEE -} - -var archIeeeTable8 *slicing8Table - -func archInitIEEE() { - if !useFastIEEE { - panic("not available") - } - // We still use slicing-by-8 for small buffers. - archIeeeTable8 = slicingMakeTable(IEEE) -} - -func archUpdateIEEE(crc uint32, p []byte) uint32 { - if !useFastIEEE { - panic("not available") - } - - if len(p) >= 64 { - left := len(p) & 15 - do := len(p) - left - crc = ^ieeeCLMUL(^crc, p[:do]) - p = p[do:] - } - if len(p) == 0 { - return crc - } - return slicingUpdate(crc, archIeeeTable8, p) -} diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64.s b/vendor/github.com/klauspost/crc32/crc32_amd64.s deleted file mode 100644 index e8a7941ce7..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_amd64.s +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#define NOSPLIT 4 -#define RODATA 8 - -// castagnoliSSE42 updates the (non-inverted) crc with the given buffer. -// -// func castagnoliSSE42(crc uint32, p []byte) uint32 -TEXT ·castagnoliSSE42(SB), NOSPLIT, $0 - MOVL crc+0(FP), AX // CRC value - MOVQ p+8(FP), SI // data pointer - MOVQ p_len+16(FP), CX // len(p) - - // If there are fewer than 8 bytes to process, skip alignment. - CMPQ CX, $8 - JL less_than_8 - - MOVQ SI, BX - ANDQ $7, BX - JZ aligned - - // Process the first few bytes to 8-byte align the input. - - // BX = 8 - BX. We need to process this many bytes to align. - SUBQ $1, BX - XORQ $7, BX - - BTQ $0, BX - JNC align_2 - - CRC32B (SI), AX - DECQ CX - INCQ SI - -align_2: - BTQ $1, BX - JNC align_4 - - // CRC32W (SI), AX - BYTE $0x66; BYTE $0xf2; BYTE $0x0f; BYTE $0x38; BYTE $0xf1; BYTE $0x06 - - SUBQ $2, CX - ADDQ $2, SI - -align_4: - BTQ $2, BX - JNC aligned - - // CRC32L (SI), AX - BYTE $0xf2; BYTE $0x0f; BYTE $0x38; BYTE $0xf1; BYTE $0x06 - - SUBQ $4, CX - ADDQ $4, SI - -aligned: - // The input is now 8-byte aligned and we can process 8-byte chunks. - CMPQ CX, $8 - JL less_than_8 - - CRC32Q (SI), AX - ADDQ $8, SI - SUBQ $8, CX - JMP aligned - -less_than_8: - // We may have some bytes left over; process 4 bytes, then 2, then 1. - BTQ $2, CX - JNC less_than_4 - - // CRC32L (SI), AX - BYTE $0xf2; BYTE $0x0f; BYTE $0x38; BYTE $0xf1; BYTE $0x06 - ADDQ $4, SI - -less_than_4: - BTQ $1, CX - JNC less_than_2 - - // CRC32W (SI), AX - BYTE $0x66; BYTE $0xf2; BYTE $0x0f; BYTE $0x38; BYTE $0xf1; BYTE $0x06 - ADDQ $2, SI - -less_than_2: - BTQ $0, CX - JNC done - - CRC32B (SI), AX - -done: - MOVL AX, ret+32(FP) - RET - -// castagnoliSSE42Triple updates three (non-inverted) crcs with (24*rounds) -// bytes from each buffer. -// -// func castagnoliSSE42Triple( -// crc1, crc2, crc3 uint32, -// a, b, c []byte, -// rounds uint32, -// ) (retA uint32, retB uint32, retC uint32) -TEXT ·castagnoliSSE42Triple(SB), NOSPLIT, $0 - MOVL crcA+0(FP), AX - MOVL crcB+4(FP), CX - MOVL crcC+8(FP), DX - - MOVQ a+16(FP), R8 // data pointer - MOVQ b+40(FP), R9 // data pointer - MOVQ c+64(FP), R10 // data pointer - - MOVL rounds+88(FP), R11 - -loop: - CRC32Q (R8), AX - CRC32Q (R9), CX - CRC32Q (R10), DX - - CRC32Q 8(R8), AX - CRC32Q 8(R9), CX - CRC32Q 8(R10), DX - - CRC32Q 16(R8), AX - CRC32Q 16(R9), CX - CRC32Q 16(R10), DX - - ADDQ $24, R8 - ADDQ $24, R9 - ADDQ $24, R10 - - DECQ R11 - JNZ loop - - MOVL AX, retA+96(FP) - MOVL CX, retB+100(FP) - MOVL DX, retC+104(FP) - RET - -// func haveSSE42() bool -TEXT ·haveSSE42(SB), NOSPLIT, $0 - XORQ AX, AX - INCL AX - CPUID - SHRQ $20, CX - ANDQ $1, CX - MOVB CX, ret+0(FP) - RET - -// func haveCLMUL() bool -TEXT ·haveCLMUL(SB), NOSPLIT, $0 - XORQ AX, AX - INCL AX - CPUID - SHRQ $1, CX - ANDQ $1, CX - MOVB CX, ret+0(FP) - RET - -// func haveSSE41() bool -TEXT ·haveSSE41(SB), NOSPLIT, $0 - XORQ AX, AX - INCL AX - CPUID - SHRQ $19, CX - ANDQ $1, CX - MOVB CX, ret+0(FP) - RET - -// CRC32 polynomial data -// -// These constants are lifted from the -// Linux kernel, since they avoid the costly -// PSHUFB 16 byte reversal proposed in the -// original Intel paper. -DATA r2r1kp<>+0(SB)/8, $0x154442bd4 -DATA r2r1kp<>+8(SB)/8, $0x1c6e41596 -DATA r4r3kp<>+0(SB)/8, $0x1751997d0 -DATA r4r3kp<>+8(SB)/8, $0x0ccaa009e -DATA rupolykp<>+0(SB)/8, $0x1db710641 -DATA rupolykp<>+8(SB)/8, $0x1f7011641 -DATA r5kp<>+0(SB)/8, $0x163cd6124 - -GLOBL r2r1kp<>(SB), RODATA, $16 -GLOBL r4r3kp<>(SB), RODATA, $16 -GLOBL rupolykp<>(SB), RODATA, $16 -GLOBL r5kp<>(SB), RODATA, $8 - -// Based on http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf -// len(p) must be at least 64, and must be a multiple of 16. - -// func ieeeCLMUL(crc uint32, p []byte) uint32 -TEXT ·ieeeCLMUL(SB), NOSPLIT, $0 - MOVL crc+0(FP), X0 // Initial CRC value - MOVQ p+8(FP), SI // data pointer - MOVQ p_len+16(FP), CX // len(p) - - MOVOU (SI), X1 - MOVOU 16(SI), X2 - MOVOU 32(SI), X3 - MOVOU 48(SI), X4 - PXOR X0, X1 - ADDQ $64, SI // buf+=64 - SUBQ $64, CX // len-=64 - CMPQ CX, $64 // Less than 64 bytes left - JB remain64 - - MOVOA r2r1kp<>+0(SB), X0 - -loopback64: - MOVOA X1, X5 - MOVOA X2, X6 - MOVOA X3, X7 - MOVOA X4, X8 - - PCLMULQDQ $0, X0, X1 - PCLMULQDQ $0, X0, X2 - PCLMULQDQ $0, X0, X3 - PCLMULQDQ $0, X0, X4 - - // Load next early - MOVOU (SI), X11 - MOVOU 16(SI), X12 - MOVOU 32(SI), X13 - MOVOU 48(SI), X14 - - PCLMULQDQ $0x11, X0, X5 - PCLMULQDQ $0x11, X0, X6 - PCLMULQDQ $0x11, X0, X7 - PCLMULQDQ $0x11, X0, X8 - - PXOR X5, X1 - PXOR X6, X2 - PXOR X7, X3 - PXOR X8, X4 - - PXOR X11, X1 - PXOR X12, X2 - PXOR X13, X3 - PXOR X14, X4 - - ADDQ $0x40, DI - ADDQ $64, SI // buf+=64 - SUBQ $64, CX // len-=64 - CMPQ CX, $64 // Less than 64 bytes left? - JGE loopback64 - - // Fold result into a single register (X1) -remain64: - MOVOA r4r3kp<>+0(SB), X0 - - MOVOA X1, X5 - PCLMULQDQ $0, X0, X1 - PCLMULQDQ $0x11, X0, X5 - PXOR X5, X1 - PXOR X2, X1 - - MOVOA X1, X5 - PCLMULQDQ $0, X0, X1 - PCLMULQDQ $0x11, X0, X5 - PXOR X5, X1 - PXOR X3, X1 - - MOVOA X1, X5 - PCLMULQDQ $0, X0, X1 - PCLMULQDQ $0x11, X0, X5 - PXOR X5, X1 - PXOR X4, X1 - - // If there is less than 16 bytes left we are done - CMPQ CX, $16 - JB finish - - // Encode 16 bytes -remain16: - MOVOU (SI), X10 - MOVOA X1, X5 - PCLMULQDQ $0, X0, X1 - PCLMULQDQ $0x11, X0, X5 - PXOR X5, X1 - PXOR X10, X1 - SUBQ $16, CX - ADDQ $16, SI - CMPQ CX, $16 - JGE remain16 - -finish: - // Fold final result into 32 bits and return it - PCMPEQB X3, X3 - PCLMULQDQ $1, X1, X0 - PSRLDQ $8, X1 - PXOR X0, X1 - - MOVOA X1, X2 - MOVQ r5kp<>+0(SB), X0 - - // Creates 32 bit mask. Note that we don't care about upper half. - PSRLQ $32, X3 - - PSRLDQ $4, X2 - PAND X3, X1 - PCLMULQDQ $0, X0, X1 - PXOR X2, X1 - - MOVOA rupolykp<>+0(SB), X0 - - MOVOA X1, X2 - PAND X3, X1 - PCLMULQDQ $0x10, X0, X1 - PAND X3, X1 - PCLMULQDQ $0, X0, X1 - PXOR X2, X1 - - // PEXTRD $1, X1, AX (SSE 4.1) - BYTE $0x66; BYTE $0x0f; BYTE $0x3a - BYTE $0x16; BYTE $0xc8; BYTE $0x01 - MOVL AX, ret+32(FP) - - RET diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64p32.go b/vendor/github.com/klauspost/crc32/crc32_amd64p32.go deleted file mode 100644 index 3222b06a5a..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_amd64p32.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !appengine,!gccgo - -package crc32 - -// This file contains the code to call the SSE 4.2 version of the Castagnoli -// CRC. - -// haveSSE42 is defined in crc32_amd64p32.s and uses CPUID to test for SSE 4.2 -// support. -func haveSSE42() bool - -// castagnoliSSE42 is defined in crc32_amd64p32.s and uses the SSE4.2 CRC32 -// instruction. -//go:noescape -func castagnoliSSE42(crc uint32, p []byte) uint32 - -var sse42 = haveSSE42() - -func archAvailableCastagnoli() bool { - return sse42 -} - -func archInitCastagnoli() { - if !sse42 { - panic("not available") - } - // No initialization necessary. -} - -func archUpdateCastagnoli(crc uint32, p []byte) uint32 { - if !sse42 { - panic("not available") - } - return castagnoliSSE42(crc, p) -} - -func archAvailableIEEE() bool { return false } -func archInitIEEE() { panic("not available") } -func archUpdateIEEE(crc uint32, p []byte) uint32 { panic("not available") } diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64p32.s b/vendor/github.com/klauspost/crc32/crc32_amd64p32.s deleted file mode 100644 index a578d685cc..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_amd64p32.s +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#define NOSPLIT 4 -#define RODATA 8 - -// func castagnoliSSE42(crc uint32, p []byte) uint32 -TEXT ·castagnoliSSE42(SB), NOSPLIT, $0 - MOVL crc+0(FP), AX // CRC value - MOVL p+4(FP), SI // data pointer - MOVL p_len+8(FP), CX // len(p) - - NOTL AX - - // If there's less than 8 bytes to process, we do it byte-by-byte. - CMPQ CX, $8 - JL cleanup - - // Process individual bytes until the input is 8-byte aligned. -startup: - MOVQ SI, BX - ANDQ $7, BX - JZ aligned - - CRC32B (SI), AX - DECQ CX - INCQ SI - JMP startup - -aligned: - // The input is now 8-byte aligned and we can process 8-byte chunks. - CMPQ CX, $8 - JL cleanup - - CRC32Q (SI), AX - ADDQ $8, SI - SUBQ $8, CX - JMP aligned - -cleanup: - // We may have some bytes left over that we process one at a time. - CMPQ CX, $0 - JE done - - CRC32B (SI), AX - INCQ SI - DECQ CX - JMP cleanup - -done: - NOTL AX - MOVL AX, ret+16(FP) - RET - -// func haveSSE42() bool -TEXT ·haveSSE42(SB), NOSPLIT, $0 - XORQ AX, AX - INCL AX - CPUID - SHRQ $20, CX - ANDQ $1, CX - MOVB CX, ret+0(FP) - RET - diff --git a/vendor/github.com/klauspost/crc32/crc32_generic.go b/vendor/github.com/klauspost/crc32/crc32_generic.go deleted file mode 100644 index abacbb663d..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_generic.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains CRC32 algorithms that are not specific to any architecture -// and don't use hardware acceleration. -// -// The simple (and slow) CRC32 implementation only uses a 256*4 bytes table. -// -// The slicing-by-8 algorithm is a faster implementation that uses a bigger -// table (8*256*4 bytes). - -package crc32 - -// simpleMakeTable allocates and constructs a Table for the specified -// polynomial. The table is suitable for use with the simple algorithm -// (simpleUpdate). -func simpleMakeTable(poly uint32) *Table { - t := new(Table) - simplePopulateTable(poly, t) - return t -} - -// simplePopulateTable constructs a Table for the specified polynomial, suitable -// for use with simpleUpdate. -func simplePopulateTable(poly uint32, t *Table) { - for i := 0; i < 256; i++ { - crc := uint32(i) - for j := 0; j < 8; j++ { - if crc&1 == 1 { - crc = (crc >> 1) ^ poly - } else { - crc >>= 1 - } - } - t[i] = crc - } -} - -// simpleUpdate uses the simple algorithm to update the CRC, given a table that -// was previously computed using simpleMakeTable. -func simpleUpdate(crc uint32, tab *Table, p []byte) uint32 { - crc = ^crc - for _, v := range p { - crc = tab[byte(crc)^v] ^ (crc >> 8) - } - return ^crc -} - -// Use slicing-by-8 when payload >= this value. -const slicing8Cutoff = 16 - -// slicing8Table is array of 8 Tables, used by the slicing-by-8 algorithm. -type slicing8Table [8]Table - -// slicingMakeTable constructs a slicing8Table for the specified polynomial. The -// table is suitable for use with the slicing-by-8 algorithm (slicingUpdate). -func slicingMakeTable(poly uint32) *slicing8Table { - t := new(slicing8Table) - simplePopulateTable(poly, &t[0]) - for i := 0; i < 256; i++ { - crc := t[0][i] - for j := 1; j < 8; j++ { - crc = t[0][crc&0xFF] ^ (crc >> 8) - t[j][i] = crc - } - } - return t -} - -// slicingUpdate uses the slicing-by-8 algorithm to update the CRC, given a -// table that was previously computed using slicingMakeTable. -func slicingUpdate(crc uint32, tab *slicing8Table, p []byte) uint32 { - if len(p) >= slicing8Cutoff { - crc = ^crc - for len(p) > 8 { - crc ^= uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 - crc = tab[0][p[7]] ^ tab[1][p[6]] ^ tab[2][p[5]] ^ tab[3][p[4]] ^ - tab[4][crc>>24] ^ tab[5][(crc>>16)&0xFF] ^ - tab[6][(crc>>8)&0xFF] ^ tab[7][crc&0xFF] - p = p[8:] - } - crc = ^crc - } - if len(p) == 0 { - return crc - } - return simpleUpdate(crc, &tab[0], p) -} diff --git a/vendor/github.com/klauspost/crc32/crc32_otherarch.go b/vendor/github.com/klauspost/crc32/crc32_otherarch.go deleted file mode 100644 index cc960764bc..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_otherarch.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !amd64,!amd64p32,!s390x - -package crc32 - -func archAvailableIEEE() bool { return false } -func archInitIEEE() { panic("not available") } -func archUpdateIEEE(crc uint32, p []byte) uint32 { panic("not available") } - -func archAvailableCastagnoli() bool { return false } -func archInitCastagnoli() { panic("not available") } -func archUpdateCastagnoli(crc uint32, p []byte) uint32 { panic("not available") } diff --git a/vendor/github.com/klauspost/crc32/crc32_s390x.go b/vendor/github.com/klauspost/crc32/crc32_s390x.go deleted file mode 100644 index ce96f03281..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_s390x.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build s390x - -package crc32 - -const ( - vxMinLen = 64 - vxAlignMask = 15 // align to 16 bytes -) - -// hasVectorFacility reports whether the machine has the z/Architecture -// vector facility installed and enabled. -func hasVectorFacility() bool - -var hasVX = hasVectorFacility() - -// vectorizedCastagnoli implements CRC32 using vector instructions. -// It is defined in crc32_s390x.s. -//go:noescape -func vectorizedCastagnoli(crc uint32, p []byte) uint32 - -// vectorizedIEEE implements CRC32 using vector instructions. -// It is defined in crc32_s390x.s. -//go:noescape -func vectorizedIEEE(crc uint32, p []byte) uint32 - -func archAvailableCastagnoli() bool { - return hasVX -} - -var archCastagnoliTable8 *slicing8Table - -func archInitCastagnoli() { - if !hasVX { - panic("not available") - } - // We still use slicing-by-8 for small buffers. - archCastagnoliTable8 = slicingMakeTable(Castagnoli) -} - -// archUpdateCastagnoli calculates the checksum of p using -// vectorizedCastagnoli. -func archUpdateCastagnoli(crc uint32, p []byte) uint32 { - if !hasVX { - panic("not available") - } - // Use vectorized function if data length is above threshold. - if len(p) >= vxMinLen { - aligned := len(p) & ^vxAlignMask - crc = vectorizedCastagnoli(crc, p[:aligned]) - p = p[aligned:] - } - if len(p) == 0 { - return crc - } - return slicingUpdate(crc, archCastagnoliTable8, p) -} - -func archAvailableIEEE() bool { - return hasVX -} - -var archIeeeTable8 *slicing8Table - -func archInitIEEE() { - if !hasVX { - panic("not available") - } - // We still use slicing-by-8 for small buffers. - archIeeeTable8 = slicingMakeTable(IEEE) -} - -// archUpdateIEEE calculates the checksum of p using vectorizedIEEE. -func archUpdateIEEE(crc uint32, p []byte) uint32 { - if !hasVX { - panic("not available") - } - // Use vectorized function if data length is above threshold. - if len(p) >= vxMinLen { - aligned := len(p) & ^vxAlignMask - crc = vectorizedIEEE(crc, p[:aligned]) - p = p[aligned:] - } - if len(p) == 0 { - return crc - } - return slicingUpdate(crc, archIeeeTable8, p) -} diff --git a/vendor/github.com/klauspost/crc32/crc32_s390x.s b/vendor/github.com/klauspost/crc32/crc32_s390x.s deleted file mode 100644 index e980ca29d6..0000000000 --- a/vendor/github.com/klauspost/crc32/crc32_s390x.s +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build s390x - -#include "textflag.h" - -// Vector register range containing CRC-32 constants - -#define CONST_PERM_LE2BE V9 -#define CONST_R2R1 V10 -#define CONST_R4R3 V11 -#define CONST_R5 V12 -#define CONST_RU_POLY V13 -#define CONST_CRC_POLY V14 - -// The CRC-32 constant block contains reduction constants to fold and -// process particular chunks of the input data stream in parallel. -// -// Note that the constant definitions below are extended in order to compute -// intermediate results with a single VECTOR GALOIS FIELD MULTIPLY instruction. -// The rightmost doubleword can be 0 to prevent contribution to the result or -// can be multiplied by 1 to perform an XOR without the need for a separate -// VECTOR EXCLUSIVE OR instruction. -// -// The polynomials used are bit-reflected: -// -// IEEE: P'(x) = 0x0edb88320 -// Castagnoli: P'(x) = 0x082f63b78 - -// IEEE polynomial constants -DATA ·crcleconskp+0(SB)/8, $0x0F0E0D0C0B0A0908 // LE-to-BE mask -DATA ·crcleconskp+8(SB)/8, $0x0706050403020100 -DATA ·crcleconskp+16(SB)/8, $0x00000001c6e41596 // R2 -DATA ·crcleconskp+24(SB)/8, $0x0000000154442bd4 // R1 -DATA ·crcleconskp+32(SB)/8, $0x00000000ccaa009e // R4 -DATA ·crcleconskp+40(SB)/8, $0x00000001751997d0 // R3 -DATA ·crcleconskp+48(SB)/8, $0x0000000000000000 -DATA ·crcleconskp+56(SB)/8, $0x0000000163cd6124 // R5 -DATA ·crcleconskp+64(SB)/8, $0x0000000000000000 -DATA ·crcleconskp+72(SB)/8, $0x00000001F7011641 // u' -DATA ·crcleconskp+80(SB)/8, $0x0000000000000000 -DATA ·crcleconskp+88(SB)/8, $0x00000001DB710641 // P'(x) << 1 - -GLOBL ·crcleconskp(SB), RODATA, $144 - -// Castagonli Polynomial constants -DATA ·crccleconskp+0(SB)/8, $0x0F0E0D0C0B0A0908 // LE-to-BE mask -DATA ·crccleconskp+8(SB)/8, $0x0706050403020100 -DATA ·crccleconskp+16(SB)/8, $0x000000009e4addf8 // R2 -DATA ·crccleconskp+24(SB)/8, $0x00000000740eef02 // R1 -DATA ·crccleconskp+32(SB)/8, $0x000000014cd00bd6 // R4 -DATA ·crccleconskp+40(SB)/8, $0x00000000f20c0dfe // R3 -DATA ·crccleconskp+48(SB)/8, $0x0000000000000000 -DATA ·crccleconskp+56(SB)/8, $0x00000000dd45aab8 // R5 -DATA ·crccleconskp+64(SB)/8, $0x0000000000000000 -DATA ·crccleconskp+72(SB)/8, $0x00000000dea713f1 // u' -DATA ·crccleconskp+80(SB)/8, $0x0000000000000000 -DATA ·crccleconskp+88(SB)/8, $0x0000000105ec76f0 // P'(x) << 1 - -GLOBL ·crccleconskp(SB), RODATA, $144 - -// func hasVectorFacility() bool -TEXT ·hasVectorFacility(SB), NOSPLIT, $24-1 - MOVD $x-24(SP), R1 - XC $24, 0(R1), 0(R1) // clear the storage - MOVD $2, R0 // R0 is the number of double words stored -1 - WORD $0xB2B01000 // STFLE 0(R1) - XOR R0, R0 // reset the value of R0 - MOVBZ z-8(SP), R1 - AND $0x40, R1 - BEQ novector - -vectorinstalled: - // check if the vector instruction has been enabled - VLEIB $0, $0xF, V16 - VLGVB $0, V16, R1 - CMPBNE R1, $0xF, novector - MOVB $1, ret+0(FP) // have vx - RET - -novector: - MOVB $0, ret+0(FP) // no vx - RET - -// The CRC-32 function(s) use these calling conventions: -// -// Parameters: -// -// R2: Initial CRC value, typically ~0; and final CRC (return) value. -// R3: Input buffer pointer, performance might be improved if the -// buffer is on a doubleword boundary. -// R4: Length of the buffer, must be 64 bytes or greater. -// -// Register usage: -// -// R5: CRC-32 constant pool base pointer. -// V0: Initial CRC value and intermediate constants and results. -// V1..V4: Data for CRC computation. -// V5..V8: Next data chunks that are fetched from the input buffer. -// -// V9..V14: CRC-32 constants. - -// func vectorizedIEEE(crc uint32, p []byte) uint32 -TEXT ·vectorizedIEEE(SB), NOSPLIT, $0 - MOVWZ crc+0(FP), R2 // R2 stores the CRC value - MOVD p+8(FP), R3 // data pointer - MOVD p_len+16(FP), R4 // len(p) - - MOVD $·crcleconskp(SB), R5 - BR vectorizedBody<>(SB) - -// func vectorizedCastagnoli(crc uint32, p []byte) uint32 -TEXT ·vectorizedCastagnoli(SB), NOSPLIT, $0 - MOVWZ crc+0(FP), R2 // R2 stores the CRC value - MOVD p+8(FP), R3 // data pointer - MOVD p_len+16(FP), R4 // len(p) - - // R5: crc-32 constant pool base pointer, constant is used to reduce crc - MOVD $·crccleconskp(SB), R5 - BR vectorizedBody<>(SB) - -TEXT vectorizedBody<>(SB), NOSPLIT, $0 - XOR $0xffffffff, R2 // NOTW R2 - VLM 0(R5), CONST_PERM_LE2BE, CONST_CRC_POLY - - // Load the initial CRC value into the rightmost word of V0 - VZERO V0 - VLVGF $3, R2, V0 - - // Crash if the input size is less than 64-bytes. - CMP R4, $64 - BLT crash - - // Load a 64-byte data chunk and XOR with CRC - VLM 0(R3), V1, V4 // 64-bytes into V1..V4 - - // Reflect the data if the CRC operation is in the bit-reflected domain - VPERM V1, V1, CONST_PERM_LE2BE, V1 - VPERM V2, V2, CONST_PERM_LE2BE, V2 - VPERM V3, V3, CONST_PERM_LE2BE, V3 - VPERM V4, V4, CONST_PERM_LE2BE, V4 - - VX V0, V1, V1 // V1 ^= CRC - ADD $64, R3 // BUF = BUF + 64 - ADD $(-64), R4 - - // Check remaining buffer size and jump to proper folding method - CMP R4, $64 - BLT less_than_64bytes - -fold_64bytes_loop: - // Load the next 64-byte data chunk into V5 to V8 - VLM 0(R3), V5, V8 - VPERM V5, V5, CONST_PERM_LE2BE, V5 - VPERM V6, V6, CONST_PERM_LE2BE, V6 - VPERM V7, V7, CONST_PERM_LE2BE, V7 - VPERM V8, V8, CONST_PERM_LE2BE, V8 - - // Perform a GF(2) multiplication of the doublewords in V1 with - // the reduction constants in V0. The intermediate result is - // then folded (accumulated) with the next data chunk in V5 and - // stored in V1. Repeat this step for the register contents - // in V2, V3, and V4 respectively. - - VGFMAG CONST_R2R1, V1, V5, V1 - VGFMAG CONST_R2R1, V2, V6, V2 - VGFMAG CONST_R2R1, V3, V7, V3 - VGFMAG CONST_R2R1, V4, V8, V4 - - // Adjust buffer pointer and length for next loop - ADD $64, R3 // BUF = BUF + 64 - ADD $(-64), R4 // LEN = LEN - 64 - - CMP R4, $64 - BGE fold_64bytes_loop - -less_than_64bytes: - // Fold V1 to V4 into a single 128-bit value in V1 - VGFMAG CONST_R4R3, V1, V2, V1 - VGFMAG CONST_R4R3, V1, V3, V1 - VGFMAG CONST_R4R3, V1, V4, V1 - - // Check whether to continue with 64-bit folding - CMP R4, $16 - BLT final_fold - -fold_16bytes_loop: - VL 0(R3), V2 // Load next data chunk - VPERM V2, V2, CONST_PERM_LE2BE, V2 - - VGFMAG CONST_R4R3, V1, V2, V1 // Fold next data chunk - - // Adjust buffer pointer and size for folding next data chunk - ADD $16, R3 - ADD $-16, R4 - - // Process remaining data chunks - CMP R4, $16 - BGE fold_16bytes_loop - -final_fold: - VLEIB $7, $0x40, V9 - VSRLB V9, CONST_R4R3, V0 - VLEIG $0, $1, V0 - - VGFMG V0, V1, V1 - - VLEIB $7, $0x20, V9 // Shift by words - VSRLB V9, V1, V2 // Store remaining bits in V2 - VUPLLF V1, V1 // Split rightmost doubleword - VGFMAG CONST_R5, V1, V2, V1 // V1 = (V1 * R5) XOR V2 - - // The input values to the Barret reduction are the degree-63 polynomial - // in V1 (R(x)), degree-32 generator polynomial, and the reduction - // constant u. The Barret reduction result is the CRC value of R(x) mod - // P(x). - // - // The Barret reduction algorithm is defined as: - // - // 1. T1(x) = floor( R(x) / x^32 ) GF2MUL u - // 2. T2(x) = floor( T1(x) / x^32 ) GF2MUL P(x) - // 3. C(x) = R(x) XOR T2(x) mod x^32 - // - // Note: To compensate the division by x^32, use the vector unpack - // instruction to move the leftmost word into the leftmost doubleword - // of the vector register. The rightmost doubleword is multiplied - // with zero to not contribute to the intermedate results. - - // T1(x) = floor( R(x) / x^32 ) GF2MUL u - VUPLLF V1, V2 - VGFMG CONST_RU_POLY, V2, V2 - - // Compute the GF(2) product of the CRC polynomial in VO with T1(x) in - // V2 and XOR the intermediate result, T2(x), with the value in V1. - // The final result is in the rightmost word of V2. - - VUPLLF V2, V2 - VGFMAG CONST_CRC_POLY, V2, V1, V2 - -done: - VLGVF $2, V2, R2 - XOR $0xffffffff, R2 // NOTW R2 - MOVWZ R2, ret + 32(FP) - RET - -crash: - MOVD $0, (R0) // input size is less than 64-bytes diff --git a/vendor/github.com/klauspost/pgzip/.travis.yml b/vendor/github.com/klauspost/pgzip/.travis.yml index 18dacf4547..6e9fca0bac 100644 --- a/vendor/github.com/klauspost/pgzip/.travis.yml +++ b/vendor/github.com/klauspost/pgzip/.travis.yml @@ -7,10 +7,8 @@ os: - osx go: - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x + - 1.9.x + - 1.10.x - master script: diff --git a/vendor/github.com/klauspost/pgzip/README.md b/vendor/github.com/klauspost/pgzip/README.md index 97f5d16566..81000996c9 100644 --- a/vendor/github.com/klauspost/pgzip/README.md +++ b/vendor/github.com/klauspost/pgzip/README.md @@ -126,11 +126,11 @@ Decompressor | Time | Speedup [gzip](http://golang.org/pkg/compress/gzip) (golang) | 1m28.85s | 0% [pgzip](https://github.com/klauspost/pgzip) (golang) | 43.48s | 104% -But wait, since gzip decompression is inherently singlethreaded (aside from CRC calculation) how can it be more than 100% faster? Because pgzip due to its design also acts as a buffer. When using ubuffered gzip, you are also waiting for io when you are decompressing. If the gzip decoder can keep up, it will always have data ready for your reader, and you will not be waiting for input to the gzip decompressor to complete. +But wait, since gzip decompression is inherently singlethreaded (aside from CRC calculation) how can it be more than 100% faster? Because pgzip due to its design also acts as a buffer. When using unbuffered gzip, you are also waiting for io when you are decompressing. If the gzip decoder can keep up, it will always have data ready for your reader, and you will not be waiting for input to the gzip decompressor to complete. This is pretty much an optimal situation for pgzip, but it reflects most common usecases for CPU intensive gzip usage. -I haven't included [bgzf](https://godoc.org/github.com/biogo/hts/bgzf) in this comparision, since it only can decompress files created by a compatible encoder, and therefore cannot be considered a generic gzip decompressor. But if you are able to compress your files with a bgzf compatible program, you can expect it to scale beyond 100%. +I haven't included [bgzf](https://godoc.org/github.com/biogo/hts/bgzf) in this comparison, since it only can decompress files created by a compatible encoder, and therefore cannot be considered a generic gzip decompressor. But if you are able to compress your files with a bgzf compatible program, you can expect it to scale beyond 100%. -#License +# License This contains large portions of code from the go repository - see GO_LICENSE for more information. The changes are released under MIT License. See LICENSE for more information. diff --git a/vendor/github.com/klauspost/pgzip/circle.yml b/vendor/github.com/klauspost/pgzip/circle.yml deleted file mode 100644 index 67b2b1628f..0000000000 --- a/vendor/github.com/klauspost/pgzip/circle.yml +++ /dev/null @@ -1,7 +0,0 @@ -test: - pre: - - go vet ./... - - override: - - go test -v -cpu=1,2,4 . - - go test -v -cpu=2 -race -short . \ No newline at end of file diff --git a/vendor/github.com/klauspost/pgzip/gunzip.go b/vendor/github.com/klauspost/pgzip/gunzip.go index f0e8fcb3d8..93efec7148 100644 --- a/vendor/github.com/klauspost/pgzip/gunzip.go +++ b/vendor/github.com/klauspost/pgzip/gunzip.go @@ -18,12 +18,12 @@ import ( "bufio" "errors" "hash" + "hash/crc32" "io" "sync" "time" "github.com/klauspost/compress/flate" - "github.com/klauspost/crc32" ) const ( diff --git a/vendor/github.com/klauspost/pgzip/gzip.go b/vendor/github.com/klauspost/pgzip/gzip.go index 9b97a0f5a7..85d14e9cbc 100644 --- a/vendor/github.com/klauspost/pgzip/gzip.go +++ b/vendor/github.com/klauspost/pgzip/gzip.go @@ -9,12 +9,12 @@ import ( "errors" "fmt" "hash" + "hash/crc32" "io" "sync" "time" "github.com/klauspost/compress/flate" - "github.com/klauspost/crc32" ) const ( diff --git a/vendor/github.com/mattn/go-colorable/go.mod b/vendor/github.com/mattn/go-colorable/go.mod index 9d9f424854..ef3ca9d4c3 100644 --- a/vendor/github.com/mattn/go-colorable/go.mod +++ b/vendor/github.com/mattn/go-colorable/go.mod @@ -1,3 +1,3 @@ module github.com/mattn/go-colorable -require github.com/mattn/go-isatty v0.0.5 +require github.com/mattn/go-isatty v0.0.8 diff --git a/vendor/github.com/mattn/go-isatty/isatty_android.go b/vendor/github.com/mattn/go-isatty/isatty_android.go new file mode 100644 index 0000000000..d3567cb5bf --- /dev/null +++ b/vendor/github.com/mattn/go-isatty/isatty_android.go @@ -0,0 +1,23 @@ +// +build android + +package isatty + +import ( + "syscall" + "unsafe" +) + +const ioctlReadTermios = syscall.TCGETS + +// IsTerminal return true if the file descriptor is terminal. +func IsTerminal(fd uintptr) bool { + var termios syscall.Termios + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 +} + +// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 +// terminal. This is also always false on this environment. +func IsCygwinTerminal(fd uintptr) bool { + return false +} diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go index f02849c56f..ff714a3761 100644 --- a/vendor/github.com/mattn/go-isatty/isatty_others.go +++ b/vendor/github.com/mattn/go-isatty/isatty_others.go @@ -1,4 +1,4 @@ -// +build appengine js +// +build appengine js nacl package isatty diff --git a/vendor/github.com/mattn/go-isatty/isatty_linux.go b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go similarity index 91% rename from vendor/github.com/mattn/go-isatty/isatty_linux.go rename to vendor/github.com/mattn/go-isatty/isatty_tcgets.go index e004038ee7..453b025d0d 100644 --- a/vendor/github.com/mattn/go-isatty/isatty_linux.go +++ b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go @@ -1,5 +1,6 @@ -// +build linux +// +build linux aix // +build !appengine +// +build !android package isatty diff --git a/vendor/github.com/openSUSE/umoci/.gitignore b/vendor/github.com/openSUSE/umoci/.gitignore index 93b097e44e..d96416f4bf 100644 --- a/vendor/github.com/openSUSE/umoci/.gitignore +++ b/vendor/github.com/openSUSE/umoci/.gitignore @@ -1,4 +1,6 @@ /umoci /cache +/vendor/src +/vendor/pkg +/vendor/github.com/openSUSE/umoci /umoci.cov* -/release diff --git a/vendor/github.com/openSUSE/umoci/.travis.yml b/vendor/github.com/openSUSE/umoci/.travis.yml index fe5f1add1e..01cc349824 100644 --- a/vendor/github.com/openSUSE/umoci/.travis.yml +++ b/vendor/github.com/openSUSE/umoci/.travis.yml @@ -12,23 +12,16 @@ before_install: - sudo sh -c "apt-get -qq update && apt-get install -y gcc-multilib" - go get -u github.com/cpuguy83/go-md2man - go get -u github.com/vbatts/git-validation - - go get -u golang.org/x/lint/golint - - go get -u github.com/securego/gosec/cmd/gosec + - go get -u github.com/golang/lint/golint env: - - DOCKER_IMAGE="opensuse/leap:latest" - - DOCKER_IMAGE="centos:latest" - - DOCKER_IMAGE="debian:latest" - - DOCKER_IMAGE="ubuntu:latest" + - DOCKER_IMAGE="opensuse/amd64:42.3" - DOCKER_IMAGE="fedora:latest" - -matrix: - fast_finish: true - allow_failures: - - env: DOCKER_IMAGE="fedora:latest" + - DOCKER_IMAGE="debian:jessie" + - DOCKER_IMAGE="ubuntu:16.04" notifications: - email: false + email: false script: - chmod a+rwx . # Necessary to make Travis co-operate with Docker. diff --git a/vendor/github.com/openSUSE/umoci/CHANGELOG.md b/vendor/github.com/openSUSE/umoci/CHANGELOG.md index 66a2fae55d..d006524e5d 100644 --- a/vendor/github.com/openSUSE/umoci/CHANGELOG.md +++ b/vendor/github.com/openSUSE/umoci/CHANGELOG.md @@ -6,26 +6,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -## [0.4.4] - 2019-01-30 -## Added -- Full-stack verification of blob hashes and descriptor sizes is now done on - all operations, improving our hardening against bad blobs (we already did - some verification of layer DiffIDs but this is far more thorough). - openSUSE/umoci#278 openSUSE/umoci#280 openSUSE/umoci#282 - -## [0.4.3] - 2018-11-11 -## Added -- All umoci commands that had `--history.*` options can now decide to omit a - history entry with `--no-history`. Note that while this is supported for - commands that create layers (`umoci repack`, `umoci insert`, and `umoci raw - add-layer`) it is not recommended to use it for those commands since it can - cause other tools to become confused when inspecting the image history. The - primary usecase is to allow `umoci config --no-history` to leave no traces in - the history. See SUSE/kiwi#871. openSUSE/umoci#270 -- `umoci insert` now has a `--tag` option that allows you to non-destructively - insert files into an image. The semantics match `umoci config --tag`. - openSUSE/umoci#273 - ## [0.4.2] - 2018-09-11 ## Added - umoci now has an exposed Go API. At the moment it's unclear whether it will @@ -388,9 +368,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). + `repack` + `config` -[Unreleased]: https://github.com/openSUSE/umoci/compare/v0.4.4...HEAD -[0.4.4]: https://github.com/openSUSE/umoci/compare/v0.4.3...v0.4.4 -[0.4.3]: https://github.com/openSUSE/umoci/compare/v0.4.2...v0.4.3 +[Unreleased]: https://github.com/openSUSE/umoci/compare/v0.4.2...HEAD [0.4.2]: https://github.com/openSUSE/umoci/compare/v0.4.1...v0.4.2 [0.4.1]: https://github.com/openSUSE/umoci/compare/v0.4.0...v0.4.1 [0.4.0]: https://github.com/openSUSE/umoci/compare/v0.3.1...v0.4.0 diff --git a/vendor/github.com/openSUSE/umoci/CODE_OF_CONDUCT.md b/vendor/github.com/openSUSE/umoci/CODE_OF_CONDUCT.md deleted file mode 100644 index 3e513317ed..0000000000 --- a/vendor/github.com/openSUSE/umoci/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,30 +0,0 @@ -## Code of Conduct ## - -As umoci is part of the openSUSE project, we adopt the openSUSE Code of -Conduct. This is enshrined in the [openSUSE Guiding -Principles][openSUSE-principles], in particular: - -> [We value] respect for other persons and their contributions, for other -> opinions and beliefs. We listen to arguments and address problems in a -> constructive and open way. We believe that a diverse community based on -> mutual respect is the base for a creative and productive environment enabling -> the project to be truly successful. We don't tolerate social discrimination -> and aim at creating an environment where people feel accepted and safe from -> offense. - -In case of an violation of these principles (or any reasonable interpretation -of the above principles), you may report it [to the maintainers](/MAINTAINERS). -If the maintainers are unable to handle this situation (or one of the -maintainers is responsible for a code of conduct violation), then the issue can -be escalated to the [openSUSE Board][openSUSE-board] who will be able to deal -with the violation. - -Both the maintainers and the Board assume all necessary rights to handle -violations in a reasonable and proportionate manner. However, violations that -happen outside of the openSUSE project and community *may* be decided to be -outside the jurisdiction of this Code of Conduct (depending on the -circumstances -- and, as above, the Board can be escalated to in case of -disagreement). - -[openSUSE-principles]: https://en.opensuse.org/openSUSE:Guiding_principles -[openSUSE-board]: https://en.opensuse.org/openSUSE:Board diff --git a/vendor/github.com/openSUSE/umoci/CONTRIBUTING.md b/vendor/github.com/openSUSE/umoci/CONTRIBUTING.md index 6d24dbeaf9..68af34a322 100644 --- a/vendor/github.com/openSUSE/umoci/CONTRIBUTING.md +++ b/vendor/github.com/openSUSE/umoci/CONTRIBUTING.md @@ -8,14 +8,14 @@ requirements and rules-of-thumb for contributions. If you are reporting a security issue, do not create an issue or file a pull request on GitHub. Instead, disclose the issue responsibly by sending an email -to . If you feel it is necessary you may also encrypt -your email with [Pretty Good Privacy (PGP)][pgp] using the PGP key -[`6FA1B3E3F9A18CDCBE6A2CF54A7BE7BF70DE9B9F`][pgp-key]. *In future, the above -email will be replaced with a mailing list as part of our ongoing effort to -reduce the bus factor of this project.* +to . If you feel it is necessary you may also encrypt +your email with [Pretty Good Privacy (PGP)][pgp] using the PGP key [`5F36 C6C6 +1B54 6012 4A75 F5A6 9E18 AA26 7DDB 8DB4`][pgp-key]. *In future, the above email +will be replaced with a mailing list as part of our ongoing effort to reduce +the bus factor of this project.* [pgp]: https://en.wikipedia.org/wiki/Pretty_Good_Privacy -[pgp-key]: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6FA1B3E3F9A18CDCBE6A2CF54A7BE7BF70DE9B9F +[pgp-key]: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x9E18AA267DDB8DB4 ### Issues ### @@ -26,8 +26,7 @@ information to provide, feel free to add a follow-up comment (but avoid adding "me too" style comments as it distracts from discussion). If you couldn't find an existing report for your issue, feel free to [open a new issue][issue-new]. If you do not wish to use proprietary software to submit an issue, you may send -an email to and I will submit an issue on your -behalf. +an email to and I will submit an issue on your behalf. When reporting an issue, please provide the following information (to the best of your ability) so we can debug your issue far more easily: @@ -49,7 +48,7 @@ of your ability) so we can debug your issue far more easily: In order to submit a change, you may [create a pull request][pr-new]. If you do not wish to use proprietary software to submit an pull request, you may send -an email to and I will submit a pull request on your +an email to and I will submit a pull request on your behalf. All changes should be based off the latest commit of the master branch of this diff --git a/vendor/github.com/openSUSE/umoci/Dockerfile b/vendor/github.com/openSUSE/umoci/Dockerfile index 6a9e22b273..b88caf29c7 100644 --- a/vendor/github.com/openSUSE/umoci/Dockerfile +++ b/vendor/github.com/openSUSE/umoci/Dockerfile @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM opensuse/leap:latest +FROM opensuse/amd64:42.3 MAINTAINER "Aleksa Sarai " # We have to use out-of-tree repos because several packages haven't been merged @@ -24,7 +24,7 @@ RUN zypper ar -f -p 10 -g obs://Virtualization:containers obs-vc && \ RUN zypper -n in \ bats \ git \ - "go>=1.11" \ + go \ golang-github-cpuguy83-go-md2man \ go-mtree \ jq \ @@ -39,9 +39,8 @@ RUN zypper -n in \ ENV GOPATH /go ENV PATH $GOPATH/bin:$PATH -RUN go get -u golang.org/x/lint/golint && \ - go get -u github.com/vbatts/git-validation && \ - go get -u github.com/securego/gosec/cmd/gosec +RUN go get -u github.com/golang/lint/golint +RUN go get -u github.com/vbatts/git-validation && type git-validation ENV SOURCE_IMAGE=/opensuse SOURCE_TAG=latest ARG DOCKER_IMAGE=opensuse/amd64:tumbleweed diff --git a/vendor/github.com/openSUSE/umoci/GOVERNANCE.md b/vendor/github.com/openSUSE/umoci/GOVERNANCE.md deleted file mode 100644 index 6229df2b16..0000000000 --- a/vendor/github.com/openSUSE/umoci/GOVERNANCE.md +++ /dev/null @@ -1,18 +0,0 @@ -## Governance Model ## - -umoci currently operates under a BDFL (Benevolent Dictator for Life) model. All -final decisions are made by the project owner (who is currently Aleksa Sarai). - -When more maintainers join the project, the governance model will likely change -to some kind of consensus model -- but until such a change to the governance -model is made (and accepted by the BDFL), the BDFL will remain unchanged. - -As an openSUSE project, there is an "escape hatch" governance in the form of -the [openSUSE Board][openSUSE-board]. In incredibly rare (and extreme) cases -where a decision about this project is asked of the openSUSE Board, they can -override decisions made by the BDFL (with the understanding that the openSUSE -Board's main goal is to reduce friction between parties, not to act as a -general appellate court). This "escape hatch" is invalidated if umoci ceases to -be an openSUSE project. - -[openSUSE-board]: https://en.opensuse.org/openSUSE:Board diff --git a/vendor/github.com/openSUSE/umoci/MAINTAINERS b/vendor/github.com/openSUSE/umoci/MAINTAINERS index 1241335d92..32b792e816 100644 --- a/vendor/github.com/openSUSE/umoci/MAINTAINERS +++ b/vendor/github.com/openSUSE/umoci/MAINTAINERS @@ -1 +1 @@ -Aleksa Sarai (@cyphar) +Aleksa Sarai (@cyphar) diff --git a/vendor/github.com/openSUSE/umoci/Makefile b/vendor/github.com/openSUSE/umoci/Makefile index 0e516af419..1f83f90a01 100644 --- a/vendor/github.com/openSUSE/umoci/Makefile +++ b/vendor/github.com/openSUSE/umoci/Makefile @@ -19,7 +19,6 @@ SHELL = /bin/bash # Go tools. GO ?= go GO_MD2MAN ?= go-md2man -export GO111MODULE=off # Set up the ... lovely ... GOPATH hacks. PROJECT := github.com/openSUSE/umoci @@ -40,22 +39,15 @@ VERSION := $(shell cat ./VERSION) COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true) COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}") -# Basic build flags. BUILD_FLAGS ?= + BASE_FLAGS := ${BUILD_FLAGS} -tags "${BUILDTAGS}" BASE_LDFLAGS := -s -w -X main.gitCommit=${COMMIT} -X main.version=${VERSION} -# Specific build flags for build type. DYN_BUILD_FLAGS := ${BASE_FLAGS} -buildmode=pie -ldflags "${BASE_LDFLAGS}" TEST_BUILD_FLAGS := ${BASE_FLAGS} -buildmode=pie -ldflags "${BASE_LDFLAGS} -X ${PROJECT}/pkg/testutils.binaryType=test" STATIC_BUILD_FLAGS := ${BASE_FLAGS} -ldflags "${BASE_LDFLAGS} -extldflags '-static'" -# Installation directories. -DESTDIR ?= -PREFIX ?=/usr -BINDIR ?=$(PREFIX)/bin -MANDIR ?=$(PREFIX)/share/man - .DEFAULT: umoci GO_SRC = $(shell find . -name \*.go) @@ -76,19 +68,12 @@ release: hack/release.sh -S "$(GPG_KEYID)" -r release/$(VERSION) -v $(VERSION) .PHONY: install -install: umoci doc - install -D -m0755 umoci $(DESTDIR)/$(BINDIR)/umoci - -for man in $(MANPAGES); do \ - filename="$$(basename -- "$$man")"; \ - target="$(DESTDIR)/$(MANDIR)/man$${filename##*.}/$$filename"; \ - install -D -m0644 "$$man" "$$target"; \ - gzip -9f "$$target"; \ - done - -.PHONY: uninstall -uninstall: - rm -f $(DESTDIR)/$(BINDIR)/umoci - -rm -f $(DESTDIR)/$(MANDIR)/man*/umoci* +install: $(GO_SRC) + $(GO) install -v ${DYN_BUILD_FLAGS} ${CMD} + +.PHONY: install.static +install.static: $(GO_SRC) + $(GO) install -v ${STATIC_BUILD_FLAGS} ${CMD} .PHONY: clean clean: @@ -105,15 +90,12 @@ local-validate: local-validate-git local-validate-go local-validate-reproducible # TODO: Remove the special-case ignored system/* warnings. .PHONY: local-validate-go local-validate-go: - @type gofmt >/dev/null 2>/dev/null || (echo "ERROR: gofmt not found." && false) + @type gofmt >/dev/null 2>/dev/null || (echo "ERROR: gofmt not found." && false) test -z "$$(gofmt -s -l . | grep -vE '^vendor/|^third_party/' | tee /dev/stderr)" - @type golint >/dev/null 2>/dev/null || (echo "ERROR: golint not found." && false) + @type golint >/dev/null 2>/dev/null || (echo "ERROR: golint not found." && false) test -z "$$(golint $(PROJECT)/... | grep -vE '/vendor/|/third_party/' | tee /dev/stderr)" @go doc cmd/vet >/dev/null 2>/dev/null || (echo "ERROR: go vet not found." && false) test -z "$$($(GO) vet $$($(GO) list $(PROJECT)/... | grep -vE '/vendor/|/third_party/') 2>&1 | tee /dev/stderr)" - @type gosec >/dev/null 2>/dev/null || (echo "ERROR: gosec not found." && false) - test -z "$$(gosec -quiet -exclude=G301,G302,G304 $$GOPATH/$(PROJECT)/... | tee /dev/stderr)" - ./hack/test-vendor.sh EPOCH_COMMIT ?= 97ecdbd53dcb72b7a0d62196df281f131dc9eb2f .PHONY: local-validate-git diff --git a/vendor/github.com/openSUSE/umoci/README.md b/vendor/github.com/openSUSE/umoci/README.md index b37f3947b8..2bf23faf42 100644 --- a/vendor/github.com/openSUSE/umoci/README.md +++ b/vendor/github.com/openSUSE/umoci/README.md @@ -57,7 +57,7 @@ If you wish to build umoci from source, follow these steps to build in with ```bash GOPATH=$HOME go get -d github.com/openSUSE/umoci -cd $GOPATH/src/github.com/openSUSE/umoci +cd $GOPATH/github.com/openSUSE/umoci make install ``` diff --git a/vendor/github.com/openSUSE/umoci/VERSION b/vendor/github.com/openSUSE/umoci/VERSION index 6f2743d65d..2b7c5ae018 100644 --- a/vendor/github.com/openSUSE/umoci/VERSION +++ b/vendor/github.com/openSUSE/umoci/VERSION @@ -1 +1 @@ -0.4.4 +0.4.2 diff --git a/vendor/github.com/openSUSE/umoci/go.mod b/vendor/github.com/openSUSE/umoci/go.mod deleted file mode 100644 index 56e2955487..0000000000 --- a/vendor/github.com/openSUSE/umoci/go.mod +++ /dev/null @@ -1,35 +0,0 @@ -module github.com/openSUSE/umoci - -require ( - github.com/apex/log v1.1.0 - github.com/blang/semver v3.5.1+incompatible - github.com/cyphar/filepath-securejoin v0.2.2 - github.com/docker/go-units v0.3.3 - github.com/fatih/color v1.7.0 - github.com/golang/protobuf v1.2.0 - github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357 - github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0 - github.com/klauspost/compress v1.4.0 - github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 - github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 - github.com/klauspost/pgzip v0.0.0-20170402124221-0bf5dcad4ada - github.com/mattn/go-colorable v0.0.9 - github.com/mattn/go-isatty v0.0.3 - github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb - github.com/opencontainers/go-digest v1.0.0-rc1 - github.com/opencontainers/image-spec v1.0.0 - github.com/opencontainers/runtime-spec v1.0.0 - github.com/opencontainers/runtime-tools v0.7.0 - github.com/pkg/errors v0.8.0 - github.com/rootless-containers/proto v0.1.0 - github.com/sirupsen/logrus v1.0.6 - github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e - github.com/urfave/cli v1.20.0 - github.com/vbatts/go-mtree v0.4.3 - github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 - github.com/xeipuuv/gojsonschema v0.0.0-20180719132039-b84684d0e066 - golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb - golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a - golang.org/x/sys v0.0.0-20180801221139-3dc4335d56c7 -) diff --git a/vendor/github.com/openSUSE/umoci/go.sum b/vendor/github.com/openSUSE/umoci/go.sum deleted file mode 100644 index 7597e343c7..0000000000 --- a/vendor/github.com/openSUSE/umoci/go.sum +++ /dev/null @@ -1,62 +0,0 @@ -github.com/apex/log v1.1.0 h1:J5rld6WVFi6NxA6m8GJ1LJqu3+GiTFIt3mYv27gdQWI= -github.com/apex/log v1.1.0/go.mod h1:yA770aXIDQrhVOIGurT/pVdfCpSq1GQV/auzMN5fzvY= -github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= -github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg= -github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= -github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= -github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357 h1:Rem2+U35z1QtPQc6r+WolF7yXiefXqDKyk+lN2pE164= -github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0 h1:j30noezaCfvNLcdMYSvHLv81DxYRSt1grlpseG67vhU= -github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= -github.com/klauspost/compress v1.4.0 h1:8nsMz3tWa9SWWPL60G1V6CUsf4lLjWLTNEtibhe8gh8= -github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio= -github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 h1:KAZ1BW2TCmT6PRihDPpocIy1QTtsAsrx6TneU/4+CMg= -github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= -github.com/klauspost/pgzip v0.0.0-20170402124221-0bf5dcad4ada h1:ZHhgRyr+9LYwfuWChpSTCCe/07V26LEElTKUXj+2fAg= -github.com/klauspost/pgzip v0.0.0-20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb h1:e+l77LJOEqXTIQihQJVkA6ZxPOUmfPM5e4H7rcpgtSk= -github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/image-spec v1.0.0 h1:jcw3cCH887bLKETGYpv8afogdYchbShR0eH6oD9d5PQ= -github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runtime-spec v1.0.0 h1:O6L965K88AilqnxeYPks/75HLpp4IG+FjeSCI3cVdRg= -github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-tools v0.7.0 h1:MIjqgwi4ZC+eVNGiYotCUYuTfs/oWDEcigK9Ra5ruHU= -github.com/opencontainers/runtime-tools v0.7.0/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/rootless-containers/proto v0.1.0 h1:gS1JOMEtk1YDYHCzBAf/url+olMJbac7MTrgSeP6zh4= -github.com/rootless-containers/proto v0.1.0/go.mod h1:vgkUFZbQd0gcE/K/ZwtE4MYjZPu0UNHLXIQxhyqAFh8= -github.com/sirupsen/logrus v1.0.6 h1:hcP1GmhGigz/O7h1WVUM5KklBp1JoNS9FggWKdj/j3s= -github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= -github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e h1:QjF5rxNgRSLHJDwKUvfYP3qOx1vTDzUi/+oSC8FXnCI= -github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/vbatts/go-mtree v0.4.3 h1:IC2s9EpogK3QzU+VsfuEdM7POkwnW43XDGAWO2Rb1Bo= -github.com/vbatts/go-mtree v0.4.3/go.mod h1:3sazBqLG4bZYmgRTgdh9X3iKTzwBpp5CrREJDzrNSXY= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v0.0.0-20180719132039-b84684d0e066 h1:iBmpEMJZETMKCupjL9Q7X3Q5utIRnWGbls0TXTgD7JI= -github.com/xeipuuv/gojsonschema v0.0.0-20180719132039-b84684d0e066/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= -golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb h1:Ah9YqXLj6fEgeKqcmBuLCbAsrF3ScD7dJ/bYM0C6tXI= -golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a h1:8fCF9zjAir2SP3N+axz9xs+0r4V8dqPzqsWO10t8zoo= -golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sys v0.0.0-20180801221139-3dc4335d56c7 h1:tr8zzCvQ7aQaYQ5nOInKN9jN9ujD92ktUtiEpN/b+tE= -golang.org/x/sys v0.0.0-20180801221139-3dc4335d56c7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/vendor/github.com/openSUSE/umoci/oci/cas/dir/dir.go b/vendor/github.com/openSUSE/umoci/oci/cas/dir/dir.go index 7bcc9a5773..2012fe9e75 100644 --- a/vendor/github.com/openSUSE/umoci/oci/cas/dir/dir.go +++ b/vendor/github.com/openSUSE/umoci/oci/cas/dir/dir.go @@ -26,7 +26,6 @@ import ( "github.com/apex/log" "github.com/openSUSE/umoci/oci/cas" - "github.com/openSUSE/umoci/pkg/hardening" "github.com/opencontainers/go-digest" imeta "github.com/opencontainers/image-spec/specs-go" ispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -171,9 +170,7 @@ func (e *dirEngine) PutBlob(ctx context.Context, reader io.Reader) (digest.Diges if err != nil { return "", -1, errors.Wrap(err, "copy to temporary blob") } - if err := fh.Close(); err != nil { - return "", -1, errors.Wrap(err, "close temporary blob") - } + fh.Close() // Get the digest. path, err := blobPath(digester.Digest()) @@ -198,11 +195,7 @@ func (e *dirEngine) GetBlob(ctx context.Context, digest digest.Digest) (io.ReadC return nil, errors.Wrap(err, "compute blob path") } fh, err := os.Open(filepath.Join(e.path, path)) - return &hardening.VerifiedReadCloser{ - Reader: fh, - ExpectedDigest: digest, - ExpectedSize: int64(-1), // We don't know the expected size. - }, errors.Wrap(err, "open blob") + return fh, errors.Wrap(err, "open blob") } // PutIndex sets the index of the OCI image to the given index, replacing the @@ -227,9 +220,7 @@ func (e *dirEngine) PutIndex(ctx context.Context, index ispec.Index) error { if err := json.NewEncoder(fh).Encode(index); err != nil { return errors.Wrap(err, "write temporary index") } - if err := fh.Close(); err != nil { - return errors.Wrap(err, "close temporary index") - } + fh.Close() // Move the blob to its correct path. path := filepath.Join(e.path, indexFile) diff --git a/vendor/github.com/openSUSE/umoci/oci/casext/blob.go b/vendor/github.com/openSUSE/umoci/oci/casext/blob.go index 4c91a61307..423d7e917b 100644 --- a/vendor/github.com/openSUSE/umoci/oci/casext/blob.go +++ b/vendor/github.com/openSUSE/umoci/oci/casext/blob.go @@ -19,9 +19,11 @@ package casext import ( "encoding/json" + "fmt" "io" - "io/ioutil" + "github.com/openSUSE/umoci/oci/cas" + "github.com/opencontainers/go-digest" ispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "golang.org/x/net/context" @@ -30,9 +32,12 @@ import ( // Blob represents a "parsed" blob in an OCI image's blob store. MediaType // offers a type-safe way of checking what the type of Data is. type Blob struct { - // Descriptor is the {mediatype,digest,length} 3-tuple. Note that this - // isn't updated if the Data is modified. - Descriptor ispec.Descriptor + // MediaType is the OCI media type of Data. + MediaType string + + // Digest is the digest of the parsed image. Note that this does not update + // if Data is changed (it is the digest that this blob was parsed *from*). + Digest digest.Digest // Data is the "parsed" blob taken from the OCI image's blob store, and is // typed according to the media type. The mapping from MIME => type is as @@ -40,7 +45,7 @@ type Blob struct { // // ispec.MediaTypeDescriptor => ispec.Descriptor // ispec.MediaTypeImageManifest => ispec.Manifest - // ispec.MediaTypeImageIndex => ispec.Index + // ispec.MediaTypeImageManifestList => ispec.ManifestList // ispec.MediaTypeImageLayer => io.ReadCloser // ispec.MediaTypeImageLayerGzip => io.ReadCloser // ispec.MediaTypeImageLayerNonDistributable => io.ReadCloser @@ -50,33 +55,16 @@ type Blob struct { Data interface{} } -func (b *Blob) isParseable() bool { - return b.Descriptor.MediaType == ispec.MediaTypeDescriptor || - b.Descriptor.MediaType == ispec.MediaTypeImageManifest || - b.Descriptor.MediaType == ispec.MediaTypeImageIndex || - b.Descriptor.MediaType == ispec.MediaTypeImageConfig -} - -func (b *Blob) load(ctx context.Context, engine Engine) (Err error) { - reader, err := engine.GetVerifiedBlob(ctx, b.Descriptor) +func (b *Blob) load(ctx context.Context, engine cas.Engine) error { + reader, err := engine.GetBlob(ctx, b.Digest) if err != nil { return errors.Wrap(err, "get blob") } - if b.isParseable() { - defer func() { - if _, err := io.Copy(ioutil.Discard, reader); Err == nil { - Err = errors.Wrapf(err, "discard trailing %q blob", b.Descriptor.MediaType) - } - if err := reader.Close(); Err == nil { - Err = errors.Wrapf(err, "close %q blob", b.Descriptor.MediaType) - } - }() - } - - switch b.Descriptor.MediaType { + switch b.MediaType { // ispec.MediaTypeDescriptor => ispec.Descriptor case ispec.MediaTypeDescriptor: + defer reader.Close() parsed := ispec.Descriptor{} if err := json.NewDecoder(reader).Decode(&parsed); err != nil { return errors.Wrap(err, "parse MediaTypeDescriptor") @@ -85,6 +73,7 @@ func (b *Blob) load(ctx context.Context, engine Engine) (Err error) { // ispec.MediaTypeImageManifest => ispec.Manifest case ispec.MediaTypeImageManifest: + defer reader.Close() parsed := ispec.Manifest{} if err := json.NewDecoder(reader).Decode(&parsed); err != nil { return errors.Wrap(err, "parse MediaTypeImageManifest") @@ -93,6 +82,7 @@ func (b *Blob) load(ctx context.Context, engine Engine) (Err error) { // ispec.MediaTypeImageIndex => ispec.Index case ispec.MediaTypeImageIndex: + defer reader.Close() parsed := ispec.Index{} if err := json.NewDecoder(reader).Decode(&parsed); err != nil { return errors.Wrap(err, "parse MediaTypeImageIndex") @@ -101,15 +91,13 @@ func (b *Blob) load(ctx context.Context, engine Engine) (Err error) { // ispec.MediaTypeImageConfig => ispec.Image case ispec.MediaTypeImageConfig: + defer reader.Close() parsed := ispec.Image{} if err := json.NewDecoder(reader).Decode(&parsed); err != nil { return errors.Wrap(err, "parse MediaTypeImageConfig") } b.Data = parsed - // unknown => io.ReadCloser() - default: - fallthrough // ispec.MediaTypeImageLayer => io.ReadCloser // ispec.MediaTypeImageLayerGzip => io.ReadCloser // ispec.MediaTypeImageLayerNonDistributable => io.ReadCloser @@ -118,35 +106,43 @@ func (b *Blob) load(ctx context.Context, engine Engine) (Err error) { ispec.MediaTypeImageLayerGzip, ispec.MediaTypeImageLayerNonDistributableGzip: // There isn't anything else we can practically do here. b.Data = reader + return nil + + // unknown => io.ReadCloser() + default: + b.Data = reader + return nil } if b.Data == nil { - return errors.Errorf("[internal error] b.Data was nil after parsing") + return fmt.Errorf("[internal error] b.Data was nil after parsing") } + return nil } // Close cleans up all of the resources for the opened blob. -func (b *Blob) Close() error { - switch b.Descriptor.MediaType { +func (b *Blob) Close() { + switch b.MediaType { case ispec.MediaTypeImageLayer, ispec.MediaTypeImageLayerNonDistributable, ispec.MediaTypeImageLayerGzip, ispec.MediaTypeImageLayerNonDistributableGzip: if b.Data != nil { - return b.Data.(io.Closer).Close() + b.Data.(io.Closer).Close() } } - return nil } // FromDescriptor parses the blob referenced by the given descriptor. func (e Engine) FromDescriptor(ctx context.Context, descriptor ispec.Descriptor) (*Blob, error) { blob := &Blob{ - Descriptor: descriptor, - Data: nil, + MediaType: descriptor.MediaType, + Digest: descriptor.Digest, + Data: nil, } if err := blob.load(ctx, e); err != nil { return nil, errors.Wrap(err, "load") } + return blob, nil } diff --git a/vendor/github.com/openSUSE/umoci/oci/casext/verified_blob.go b/vendor/github.com/openSUSE/umoci/oci/casext/verified_blob.go deleted file mode 100644 index 622e03f65b..0000000000 --- a/vendor/github.com/openSUSE/umoci/oci/casext/verified_blob.go +++ /dev/null @@ -1,40 +0,0 @@ -/* - * umoci: Umoci Modifies Open Containers' Images - * Copyright (C) 2018 SUSE LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package casext - -import ( - "context" - "io" - - "github.com/openSUSE/umoci/pkg/hardening" - ispec "github.com/opencontainers/image-spec/specs-go/v1" -) - -// GetVerifiedBlob returns a VerifiedReadCloser for retrieving a blob from the -// image, which the caller must Close() *and* read-to-EOF (checking the error -// code of both). Returns ErrNotExist if the digest is not found, and -// ErrBlobDigestMismatch on a mismatched blob digest. In addition, the reader -// is limited to the descriptor.Size. -func (e Engine) GetVerifiedBlob(ctx context.Context, descriptor ispec.Descriptor) (io.ReadCloser, error) { - reader, err := e.GetBlob(ctx, descriptor.Digest) - return &hardening.VerifiedReadCloser{ - Reader: reader, - ExpectedDigest: descriptor.Digest, - ExpectedSize: descriptor.Size, - }, err -} diff --git a/vendor/github.com/openSUSE/umoci/oci/layer/generate.go b/vendor/github.com/openSUSE/umoci/oci/layer/generate.go index f3a180a070..2e69936392 100644 --- a/vendor/github.com/openSUSE/umoci/oci/layer/generate.go +++ b/vendor/github.com/openSUSE/umoci/oci/layer/generate.go @@ -54,8 +54,7 @@ func GenerateLayer(path string, deltas []mtree.InodeDelta, opt *MapOptions) (io. go func() (Err error) { // Close with the returned error. defer func() { - // #nosec G104 - _ = writer.CloseWithError(errors.Wrap(Err, "generate layer")) + writer.CloseWithError(errors.Wrap(Err, "generate layer")) }() // We can't just dump all of the file contents into a tar file. We need @@ -117,8 +116,7 @@ func GenerateInsertLayer(root string, target string, opaque bool, opt *MapOption go func() (Err error) { defer func() { - // #nosec G104 - _ = writer.CloseWithError(errors.Wrap(Err, "generate layer")) + writer.CloseWithError(errors.Wrap(Err, "generate layer")) }() tg := newTarGenerator(writer, mapOptions) diff --git a/vendor/github.com/openSUSE/umoci/oci/layer/tar_extract.go b/vendor/github.com/openSUSE/umoci/oci/layer/tar_extract.go index d265dd8511..9ac1377566 100644 --- a/vendor/github.com/openSUSE/umoci/oci/layer/tar_extract.go +++ b/vendor/github.com/openSUSE/umoci/oci/layer/tar_extract.go @@ -287,7 +287,6 @@ func (te *TarExtractor) UnpackEntry(root string, hdr *tar.Header, r io.Reader) ( // directory will be fixed by later archive entries. if dirFi, err := te.fsEval.Lstat(dir); err == nil && path != dir { // FIXME: This is really stupid. - // #nosec G104 link, _ := te.fsEval.Readlink(dir) dirHdr, err := tar.FileInfoHeader(dirFi, link) if err != nil { @@ -499,18 +498,14 @@ func (te *TarExtractor) UnpackEntry(root string, hdr *tar.Header, r io.Reader) ( defer fh.Close() // We need to make sure that we copy all of the bytes. - n, err := io.Copy(fh, r) - if int64(n) != hdr.Size { - err = io.ErrShortWrite - } - if err != nil { - return errors.Wrap(err, "unpack to regular file") + if n, err := io.Copy(fh, r); err != nil { + return err + } else if int64(n) != hdr.Size { + return errors.Wrap(io.ErrShortWrite, "unpack to regular file") } // Force close here so that we don't affect the metadata. - if err := fh.Close(); err != nil { - return errors.Wrap(err, "close unpacked regular file") - } + fh.Close() // directory case tar.TypeDir: diff --git a/vendor/github.com/openSUSE/umoci/oci/layer/tar_generate.go b/vendor/github.com/openSUSE/umoci/oci/layer/tar_generate.go index 1fd7dcd5ca..01318210bf 100644 --- a/vendor/github.com/openSUSE/umoci/oci/layer/tar_generate.go +++ b/vendor/github.com/openSUSE/umoci/oci/layer/tar_generate.go @@ -144,10 +144,6 @@ func (tg *tarGenerator) AddFile(name, path string) error { return errors.Wrap(err, "convert fi to hdr") } hdr.Xattrs = map[string]string{} - // Usually incorrect for containers and was added in Go 1.10 causing - // changes to our output on a compiler bump... - hdr.Uname = "" - hdr.Gname = "" name, err = normalise(name, fi.IsDir()) if err != nil { diff --git a/vendor/github.com/openSUSE/umoci/oci/layer/unpack.go b/vendor/github.com/openSUSE/umoci/oci/layer/unpack.go index af1c21e243..ebc33d47d4 100644 --- a/vendor/github.com/openSUSE/umoci/oci/layer/unpack.go +++ b/vendor/github.com/openSUSE/umoci/oci/layer/unpack.go @@ -125,18 +125,10 @@ func UnpackManifest(ctx context.Context, engine cas.Engine, bundle string, manif fsEval = fseval.RootlessFsEval } // It's too late to care about errors. - // #nosec G104 _ = fsEval.RemoveAll(rootfsPath) } }() - if _, err := os.Lstat(rootfsPath); !os.IsNotExist(err) { - if err == nil { - err = fmt.Errorf("%s already exists", rootfsPath) - } - return err - } - log.Infof("unpack rootfs: %s", rootfsPath) if err := UnpackRootfs(ctx, engine, rootfsPath, manifest, opt); err != nil { return errors.Wrap(err, "unpack rootfs") @@ -160,7 +152,14 @@ func UnpackManifest(ctx context.Context, engine cas.Engine, bundle string, manif func UnpackRootfs(ctx context.Context, engine cas.Engine, rootfsPath string, manifest ispec.Manifest, opt *MapOptions) (err error) { engineExt := casext.NewEngine(engine) - if err := os.Mkdir(rootfsPath, 0755); err != nil && !os.IsExist(err) { + if _, err := os.Lstat(rootfsPath); !os.IsNotExist(err) { + if err == nil { + err = fmt.Errorf("%s already exists", rootfsPath) + } + return err + } + + if err := os.Mkdir(rootfsPath, 0755); err != nil { return errors.Wrap(err, "mkdir rootfs") } @@ -174,7 +173,6 @@ func UnpackRootfs(ctx context.Context, engine cas.Engine, rootfsPath string, man fsEval = fseval.RootlessFsEval } // It's too late to care about errors. - // #nosec G104 _ = fsEval.RemoveAll(rootfsPath) } }() @@ -210,13 +208,13 @@ func UnpackRootfs(ctx context.Context, engine cas.Engine, rootfsPath string, man return errors.Wrap(err, "get config blob") } defer configBlob.Close() - if configBlob.Descriptor.MediaType != ispec.MediaTypeImageConfig { - return errors.Errorf("unpack rootfs: config blob is not correct mediatype %s: %s", ispec.MediaTypeImageConfig, configBlob.Descriptor.MediaType) + if configBlob.MediaType != ispec.MediaTypeImageConfig { + return errors.Errorf("unpack rootfs: config blob is not correct mediatype %s: %s", ispec.MediaTypeImageConfig, configBlob.MediaType) } config, ok := configBlob.Data.(ispec.Image) if !ok { // Should _never_ be reached. - return errors.Errorf("[internal error] unknown config blob type: %s", configBlob.Descriptor.MediaType) + return errors.Errorf("[internal error] unknown config blob type: %s", configBlob.MediaType) } // We can't understand non-layer images. @@ -234,8 +232,8 @@ func UnpackRootfs(ctx context.Context, engine cas.Engine, rootfsPath string, man return errors.Wrap(err, "get layer blob") } defer layerBlob.Close() - if !isLayerType(layerBlob.Descriptor.MediaType) { - return errors.Errorf("unpack rootfs: layer %s: blob is not correct mediatype: %s", layerBlob.Descriptor.Digest, layerBlob.Descriptor.MediaType) + if !isLayerType(layerBlob.MediaType) { + return errors.Errorf("unpack rootfs: layer %s: blob is not correct mediatype: %s", layerBlob.Digest, layerBlob.MediaType) } layerData, ok := layerBlob.Data.(io.ReadCloser) if !ok { @@ -244,7 +242,7 @@ func UnpackRootfs(ctx context.Context, engine cas.Engine, rootfsPath string, man } layerRaw := layerData - if needsGunzip(layerBlob.Descriptor.MediaType) { + if needsGunzip(layerBlob.MediaType) { // We have to extract a gzip'd version of the above layer. Also note // that we have to check the DiffID we're extracting (which is the // sha256 sum of the *uncompressed* layer). @@ -267,12 +265,9 @@ func UnpackRootfs(ctx context.Context, engine cas.Engine, rootfsPath string, man // in the later diff_id check failing because the digester didn't get // the whole uncompressed stream). Just blindly consume anything left // in the layer. - if _, err = io.Copy(ioutil.Discard, layer); err != nil { - return errors.Wrap(err, "discard trailing archive bits") - } - if err := layerData.Close(); err != nil { - return errors.Wrap(err, "close layer data") - } + _, _ = io.Copy(ioutil.Discard, layer) + // XXX: Is it possible this breaks in the error path? + layerData.Close() layerDigest := layerDigester.Digest() if layerDigest != layerDiffID { @@ -308,13 +303,13 @@ func UnpackRuntimeJSON(ctx context.Context, engine cas.Engine, configFile io.Wri return errors.Wrap(err, "get config blob") } defer configBlob.Close() - if configBlob.Descriptor.MediaType != ispec.MediaTypeImageConfig { - return errors.Errorf("unpack manifest: config blob is not correct mediatype %s: %s", ispec.MediaTypeImageConfig, configBlob.Descriptor.MediaType) + if configBlob.MediaType != ispec.MediaTypeImageConfig { + return errors.Errorf("unpack manifest: config blob is not correct mediatype %s: %s", ispec.MediaTypeImageConfig, configBlob.MediaType) } config, ok := configBlob.Data.(ispec.Image) if !ok { // Should _never_ be reached. - return errors.Errorf("[internal error] unknown config blob type: %s", configBlob.Descriptor.MediaType) + return errors.Errorf("[internal error] unknown config blob type: %s", configBlob.MediaType) } g, err := rgen.New(runtime.GOOS) @@ -327,8 +322,7 @@ func UnpackRuntimeJSON(ctx context.Context, engine cas.Engine, configFile io.Wri // Add UIDMapping / GIDMapping options. if len(mapOptions.UIDMappings) > 0 || len(mapOptions.GIDMappings) > 0 { - // #nosec G104 - _ = g.AddOrReplaceLinuxNamespace("user", "") + g.AddOrReplaceLinuxNamespace("user", "") } g.ClearLinuxUIDMappings() for _, m := range mapOptions.UIDMappings { diff --git a/vendor/github.com/openSUSE/umoci/oci/layer/utils.go b/vendor/github.com/openSUSE/umoci/oci/layer/utils.go index e2d75ce35e..c2f4a8288a 100644 --- a/vendor/github.com/openSUSE/umoci/oci/layer/utils.go +++ b/vendor/github.com/openSUSE/umoci/oci/layer/utils.go @@ -208,7 +208,6 @@ func CleanPath(path string) string { if !filepath.IsAbs(path) { path = filepath.Clean(string(os.PathSeparator) + path) // This can't fail, as (by definition) all paths are relative to root. - // #nosec G104 path, _ = filepath.Rel(string(os.PathSeparator), path) } diff --git a/vendor/github.com/openSUSE/umoci/pkg/hardening/verified_reader.go b/vendor/github.com/openSUSE/umoci/pkg/hardening/verified_reader.go deleted file mode 100644 index 7474358944..0000000000 --- a/vendor/github.com/openSUSE/umoci/pkg/hardening/verified_reader.go +++ /dev/null @@ -1,176 +0,0 @@ -/* - * umoci: Umoci Modifies Open Containers' Images - * Copyright (C) 2018 SUSE LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package hardening - -import ( - "io" - - "github.com/apex/log" - "github.com/opencontainers/go-digest" - "github.com/pkg/errors" -) - -// Exported errors for verification issues that occur during processing within -// VerifiedReadCloser. Note that you will need to use -// "github.com/pkg/errors".Cause to get these exported errors in most cases. -var ( - ErrDigestMismatch = errors.Errorf("verified reader digest mismatch") - ErrSizeMismatch = errors.Errorf("verified reader size mismatch") -) - -// VerifiedReadCloser is a basic io.ReadCloser which allows for simple -// verification that a stream matches an expected hash. The entire stream is -// hashed while being passed through this reader, and on EOF it will verify -// that the hash matches the expected hash. If not, an error is returned. Note -// that this means you need to read all input to EOF in order to find -// verification errors. -// -// If Reader is a VerifiedReadCloser (with the same ExpectedDigest), all of the -// methods are just piped to the underlying methods (with no verification in -// the upper layer). -type VerifiedReadCloser struct { - // Reader is the underlying reader. - Reader io.ReadCloser - - // ExpectedDigest is the expected digest. When the underlying reader - // returns an EOF, the entire stream's sum will be compared to this hash - // and an error will be returned if they don't match. - ExpectedDigest digest.Digest - - // ExpectedSize is the expected amount of data to be read overall. If the - // underlying reader hasn't returned an EOF by the time this value is - // exceeded, an error is returned and no further reads will occur. - ExpectedSize int64 - - // digester stores the current state of the stream's hash. - digester digest.Digester - - // currentSize is the number of bytes that have been read so far. - currentSize int64 -} - -func (v *VerifiedReadCloser) init() { - // Define digester if not already set. - if v.digester == nil { - alg := v.ExpectedDigest.Algorithm() - if !alg.Available() { - log.Fatalf("verified reader: unsupported hash algorithm %s", alg) - panic("verified reader: unreachable section") // should never be hit - } - v.digester = alg.Digester() - } -} - -func (v *VerifiedReadCloser) isNoop() bool { - innerV, ok := v.Reader.(*VerifiedReadCloser) - return ok && - innerV.ExpectedDigest == v.ExpectedDigest && - innerV.ExpectedSize == v.ExpectedSize -} - -func (v *VerifiedReadCloser) verify(nilErr error) error { - // Digest mismatch (always takes precedence)? - if actualDigest := v.digester.Digest(); actualDigest != v.ExpectedDigest { - return errors.Wrapf(ErrDigestMismatch, "expected %s not %s", v.ExpectedDigest, actualDigest) - } - // Do we need to check the size for mismatches? - if v.ExpectedSize >= 0 { - switch { - // Not enough bytes in the stream. - case v.currentSize < v.ExpectedSize: - return errors.Wrapf(ErrSizeMismatch, "expected %d bytes (only %d bytes in stream)", v.ExpectedSize, v.currentSize) - - // We don't read the entire blob, so the message needs to be slightly adjusted. - case v.currentSize > v.ExpectedSize: - return errors.Wrapf(ErrSizeMismatch, "expected %d bytes (extra bytes in stream)", v.ExpectedSize) - - } - } - // Forward the provided error. - return nilErr -} - -// Read is a wrapper around VerifiedReadCloser.Reader, with a digest check on -// EOF. Make sure that you always check for EOF and read-to-the-end for all -// files. -func (v *VerifiedReadCloser) Read(p []byte) (n int, err error) { - // Make sure we don't read after v.ExpectedSize has been passed. - err = io.EOF - left := v.ExpectedSize - v.currentSize - switch { - // ExpectedSize has been disabled. - case v.ExpectedSize < 0: - n, err = v.Reader.Read(p) - - // We still have something left to read. - case left > 0: - if int64(len(p)) > left { - p = p[:left] - } - // Piped to the underling read. - n, err = v.Reader.Read(p) - v.currentSize += int64(n) - - // We have either read everything, or just happened to land on a boundary - // (with potentially more things afterwards). So we must check if there is - // anything left by doing a 1-byte read (Go doesn't allow for zero-length - // Read()s to give EOFs). - case left == 0: - // We just want to know whether we read something (n>0). #nosec G104 - nTmp, _ := v.Reader.Read(make([]byte, 1)) - v.currentSize += int64(nTmp) - } - // Are we going to be a noop? - if v.isNoop() { - return n, err - } - // Make sure we're ready. - v.init() - // Forward it to the digester. - if n > 0 { - // hash.Hash guarantees Write() never fails and is never short. - nWrite, err := v.digester.Hash().Write(p[:n]) - if nWrite != n || err != nil { - log.Fatalf("verified reader: short write to %s Digester (err=%v)", v.ExpectedDigest.Algorithm(), err) - panic("verified reader: unreachable section") // should never be hit - } - } - // We have finished reading -- let's verify the state! - if errors.Cause(err) == io.EOF { - err = v.verify(err) - } - return n, err -} - -// Close is a wrapper around VerifiedReadCloser.Reader, but with a digest check -// which will return an error if the underlying Close() didn't. -func (v *VerifiedReadCloser) Close() error { - // Piped to underlying close. - err := v.Reader.Close() - if err != nil { - return err - } - // Are we going to be a noop? - if v.isNoop() { - return err - } - // Make sure we're ready. - v.init() - // Verify the state. - return v.verify(nil) -} diff --git a/vendor/github.com/openSUSE/umoci/pkg/system/utime_linux.go b/vendor/github.com/openSUSE/umoci/pkg/system/utime_linux.go index 592b82cc3f..125fec5c25 100644 --- a/vendor/github.com/openSUSE/umoci/pkg/system/utime_linux.go +++ b/vendor/github.com/openSUSE/umoci/pkg/system/utime_linux.go @@ -19,8 +19,10 @@ package system import ( "os" + "path/filepath" "time" + "github.com/pkg/errors" "golang.org/x/sys/unix" ) @@ -33,7 +35,19 @@ func Lutimes(path string, atime, mtime time.Time) error { unix.NsecToTimespec(mtime.UnixNano()), } - err := unix.UtimesNanoAt(unix.AT_FDCWD, path, times, unix.AT_SYMLINK_NOFOLLOW) + // Split up the path. + dir, file := filepath.Split(path) + dir = filepath.Clean(dir) + file = filepath.Clean(file) + + // Open the parent directory. + dirFile, err := os.OpenFile(filepath.Clean(dir), unix.O_RDONLY|unix.O_NOFOLLOW|unix.O_DIRECTORY, 0) + if err != nil { + return errors.Wrap(err, "lutimes: open parent directory") + } + defer dirFile.Close() + + err = unix.UtimesNanoAt(int(dirFile.Fd()), file, times, unix.AT_SYMLINK_NOFOLLOW) if err != nil { return &os.PathError{Op: "lutimes", Path: path, Err: err} } diff --git a/vendor/github.com/openSUSE/umoci/pkg/unpriv/unpriv.go b/vendor/github.com/openSUSE/umoci/pkg/unpriv/unpriv.go index 23fce1ae7b..18ab27a597 100644 --- a/vendor/github.com/openSUSE/umoci/pkg/unpriv/unpriv.go +++ b/vendor/github.com/openSUSE/umoci/pkg/unpriv/unpriv.go @@ -34,8 +34,6 @@ import ( // fiRestore restores the state given by an os.FileInfo instance at the given // path by ensuring that an Lstat(path) will return as-close-to the same // os.FileInfo. -// -// #nosec G104 func fiRestore(path string, fi os.FileInfo) { // archive/tar handles the OS-specific syscall stuff required to get atime // and mtime information for a file. @@ -332,8 +330,7 @@ func foreachSubpath(path string, wrapFn WrapFunc) error { // permissions because we're already in a context with filepath.Dir(path) // is at least a+rx. However, because we are calling wrapFn we need to // restore the original mode immediately. - // #nosec G104 - _ = os.Chmod(path, fi.Mode()|0444) + os.Chmod(path, fi.Mode()|0444) names, err := fd.Readdirnames(-1) fiRestore(path, fi) if err != nil { diff --git a/vendor/github.com/openSUSE/umoci/third_party/shared/util.go b/vendor/github.com/openSUSE/umoci/third_party/shared/util.go index fca447df7a..88cfe14303 100644 --- a/vendor/github.com/openSUSE/umoci/third_party/shared/util.go +++ b/vendor/github.com/openSUSE/umoci/third_party/shared/util.go @@ -46,7 +46,6 @@ func RunningInUserNS() bool { line := string(l) var a, b, c int64 - // #nosec G104 fmt.Sscanf(line, "%d %d %d", &a, &b, &c) if a == 0 && b == 0 && c == 4294967295 { return false diff --git a/vendor/github.com/openSUSE/umoci/third_party/user/user.go b/vendor/github.com/openSUSE/umoci/third_party/user/user.go index fc61ac5742..a49e74e77e 100644 --- a/vendor/github.com/openSUSE/umoci/third_party/user/user.go +++ b/vendor/github.com/openSUSE/umoci/third_party/user/user.go @@ -73,7 +73,6 @@ func parseLine(line string, v ...interface{}) { *e = p case *int: // "numbers", with conversion errors ignored because of some misbehaving configuration files. - // #nosec G104 *e, _ = strconv.Atoi(p) case *[]string: // Comma-separated lists. diff --git a/vendor/github.com/openSUSE/umoci/utils.go b/vendor/github.com/openSUSE/umoci/utils.go index cb5556c1fc..b55906dc54 100644 --- a/vendor/github.com/openSUSE/umoci/utils.go +++ b/vendor/github.com/openSUSE/umoci/utils.go @@ -165,9 +165,11 @@ func (ms ManifestStat) Format(w io.Writer) error { } // TODO: We need to truncate some of the fields. + fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n", layerID, created, createdBy, size, comment) } - return tw.Flush() + tw.Flush() + return nil } // historyStat contains information about a single entry in the history of a @@ -205,7 +207,7 @@ func Stat(ctx context.Context, engine casext.Engine, manifestDescriptor ispec.De manifest, ok := manifestBlob.Data.(ispec.Manifest) if !ok { // Should _never_ be reached. - return stat, errors.Errorf("[internal error] unknown manifest blob type: %s", manifestBlob.Descriptor.MediaType) + return stat, errors.Errorf("[internal error] unknown manifest blob type: %s", manifestBlob.MediaType) } // Now get the config. @@ -216,7 +218,7 @@ func Stat(ctx context.Context, engine casext.Engine, manifestDescriptor ispec.De config, ok := configBlob.Data.(ispec.Image) if !ok { // Should _never_ be reached. - return stat, errors.Errorf("[internal error] unknown config blob type: %s", configBlob.Descriptor.MediaType) + return stat, errors.Errorf("[internal error] unknown config blob type: %s", configBlob.MediaType) } // TODO: This should probably be moved into separate functions. @@ -288,16 +290,10 @@ func ParseIdmapOptions(meta *Meta, ctx *cli.Context) error { meta.MapOptions.Rootless = ctx.Bool("rootless") if meta.MapOptions.Rootless { if !ctx.IsSet("uid-map") { - if err := ctx.Set("uid-map", fmt.Sprintf("0:%d:1", os.Geteuid())); err != nil { - // Should _never_ be reached. - return errors.Wrap(err, "[internal error] failure auto-setting rootless --uid-map") - } + ctx.Set("uid-map", fmt.Sprintf("0:%d:1", os.Geteuid())) } if !ctx.IsSet("gid-map") { - if err := ctx.Set("gid-map", fmt.Sprintf("0:%d:1", os.Getegid())); err != nil { - // Should _never_ be reached. - return errors.Wrap(err, "[internal error] failure auto-setting rootless --gid-map") - } + ctx.Set("gid-map", fmt.Sprintf("0:%d:1", os.Getegid())) } } diff --git a/vendor/github.com/openSUSE/umoci/vendor.conf b/vendor/github.com/openSUSE/umoci/vendor.conf new file mode 100644 index 0000000000..df55e36bbf --- /dev/null +++ b/vendor/github.com/openSUSE/umoci/vendor.conf @@ -0,0 +1,36 @@ +golang.org/x/crypto c126467f60eb25f8f27e5a981f32a87e3965053f https://github.com/golang/crypto +golang.org/x/sys 3dc4335d56c789b04b0ba99b7a37249d9b614314 https://github.com/golang/sys +golang.org/x/net f4c29de78a2a91c00474a2e689954305c350adf9 https://github.com/golang/net + +github.com/opencontainers/go-digest v1.0.0-rc1 +github.com/opencontainers/image-spec v1.0.0 +github.com/opencontainers/runtime-spec v1.0.0 +github.com/opencontainers/runtime-tools v0.7.0 + github.com/syndtr/gocapability 33e07d32887e1e06b7c025f27ce52f62c7990bc0 +github.com/rootless-containers/proto v0.1.0 +github.com/urfave/cli v1.20.0 +github.com/cyphar/filepath-securejoin v0.2.2 +github.com/vbatts/go-mtree 1bcf4de08ff771c9b288e3a25348f195d404c17b + github.com/sirupsen/logrus v1.0.6 +github.com/docker/go-units v0.3.3 +github.com/pkg/errors v0.8.0 +github.com/apex/log 941dea75d3ebfbdd905a5d8b7b232965c5e5c684 + github.com/fatih/color v1.7.0 + github.com/mattn/go-colorable v0.0.9 + github.com/mattn/go-isatty v0.0.3 +github.com/golang/protobuf v1.1.0 +github.com/klauspost/pgzip v1.1 + github.com/klauspost/compress v1.4.0 + github.com/klauspost/crc32 v1.1 + github.com/klauspost/cpuid v1.1 + +# Only used for our tests. +github.com/mohae/deepcopy 491d3605edfb866af34a48075bd4355ac1bf46ca + +# Useless dependencies picked up by runtime-tools/validate. +github.com/blang/semver v3.5.1 +github.com/hashicorp/go-multierror 3d5d8f294aa03d8e98859feac328afbdf1ae0703 + github.com/hashicorp/errwrap d6c0cd88035724dd42e0f335ae30161c20575ecc +github.com/xeipuuv/gojsonschema b84684d0e066369f2a7a8a525f3080909ed4ea6b + github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b + github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6 diff --git a/vendor/github.com/opencontainers/image-spec/schema/config-schema.json b/vendor/github.com/opencontainers/image-spec/schema/config-schema.json new file mode 100644 index 0000000000..15bccd04e3 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/config-schema.json @@ -0,0 +1,140 @@ +{ + "description": "OpenContainer Config Specification", + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://opencontainers.org/schema/image/config", + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time" + }, + "author": { + "type": "string" + }, + "architecture": { + "type": "string" + }, + "os": { + "type": "string" + }, + "config": { + "type": "object", + "properties": { + "User": { + "type": "string" + }, + "ExposedPorts": { + "$ref": "defs.json#/definitions/mapStringObject" + }, + "Env": { + "type": "array", + "items": { + "type": "string" + } + }, + "Entrypoint": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ] + }, + "Cmd": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ] + }, + "Volumes": { + "oneOf": [ + { + "$ref": "defs.json#/definitions/mapStringObject" + }, + { + "type": "null" + } + ] + }, + "WorkingDir": { + "type": "string" + }, + "Labels": { + "oneOf": [ + { + "$ref": "defs.json#/definitions/mapStringString" + }, + { + "type": "null" + } + ] + }, + "StopSignal": { + "type": "string" + } + } + }, + "rootfs": { + "type": "object", + "properties": { + "diff_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "type": "string", + "enum": [ + "layers" + ] + } + }, + "required": [ + "diff_ids", + "type" + ] + }, + "history": { + "type": "array", + "items": { + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time" + }, + "author": { + "type": "string" + }, + "created_by": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "empty_layer": { + "type": "boolean" + } + } + } + } + }, + "required": [ + "architecture", + "os", + "rootfs" + ] +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/content-descriptor.json b/vendor/github.com/opencontainers/image-spec/schema/content-descriptor.json new file mode 100644 index 0000000000..69fcea92ec --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/content-descriptor.json @@ -0,0 +1,33 @@ +{ + "description": "OpenContainer Content Descriptor Specification", + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://opencontainers.org/schema/descriptor", + "type": "object", + "properties": { + "mediaType": { + "description": "the mediatype of the referenced object", + "$ref": "defs-descriptor.json#/definitions/mediaType" + }, + "size": { + "description": "the size in bytes of the referenced object", + "$ref": "defs.json#/definitions/int64" + }, + "digest": { + "description": "the cryptographic checksum digest of the object, in the pattern ':'", + "$ref": "defs-descriptor.json#/definitions/digest" + }, + "urls": { + "description": "a list of urls from which this object may be downloaded", + "$ref": "defs-descriptor.json#/definitions/urls" + }, + "annotations": { + "id": "https://opencontainers.org/schema/image/descriptor/annotations", + "$ref": "defs-descriptor.json#/definitions/annotations" + } + }, + "required": [ + "mediaType", + "size", + "digest" + ] +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/defs-descriptor.json b/vendor/github.com/opencontainers/image-spec/schema/defs-descriptor.json new file mode 100644 index 0000000000..feaea001bb --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/defs-descriptor.json @@ -0,0 +1,27 @@ +{ + "description": "Definitions particular to OpenContainer Descriptor Specification", + "definitions": { + "mediaType": { + "id": "https://opencontainers.org/schema/image/descriptor/mediaType", + "type": "string", + "pattern": "^[A-Za-z0-9][A-Za-z0-9!#$&-^_.+]{0,126}/[A-Za-z0-9][A-Za-z0-9!#$&-^_.+]{0,126}$" + }, + "digest": { + "description": "the cryptographic checksum digest of the object, in the pattern ':'", + "type": "string", + "pattern": "^[a-z0-9]+(?:[+._-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$" + }, + "urls": { + "description": "a list of urls from which this object may be downloaded", + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + }, + "annotations": { + "id": "https://opencontainers.org/schema/image/descriptor/annotations", + "$ref": "defs.json#/definitions/mapStringString" + } + } +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/defs.json b/vendor/github.com/opencontainers/image-spec/schema/defs.json new file mode 100644 index 0000000000..03cb495b86 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/defs.json @@ -0,0 +1,91 @@ +{ + "description": "Definitions used throughout the OpenContainer Specification", + "definitions": { + "int8": { + "type": "integer", + "minimum": -128, + "maximum": 127 + }, + "int16": { + "type": "integer", + "minimum": -32768, + "maximum": 32767 + }, + "int32": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "int64": { + "type": "integer", + "minimum": -9223372036854776000, + "maximum": 9223372036854776000 + }, + "uint8": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "uint16": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "uint32": { + "type": "integer", + "minimum": 0, + "maximum": 4294967295 + }, + "uint64": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709552000 + }, + "uint16Pointer": { + "oneOf": [ + { + "$ref": "#/definitions/uint16" + }, + { + "type": "null" + } + ] + }, + "uint64Pointer": { + "oneOf": [ + { + "$ref": "#/definitions/uint64" + }, + { + "type": "null" + } + ] + }, + "stringPointer": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "mapStringString": { + "type": "object", + "patternProperties": { + ".{1,}": { + "type": "string" + } + } + }, + "mapStringObject": { + "type": "object", + "patternProperties": { + ".{1,}": { + "type": "object" + } + } + } + } +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/doc.go b/vendor/github.com/opencontainers/image-spec/schema/doc.go new file mode 100644 index 0000000000..5ea5914d05 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/doc.go @@ -0,0 +1,16 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package schema defines the OCI image media types, schema definitions and validation functions. +package schema diff --git a/vendor/github.com/opencontainers/image-spec/schema/error.go b/vendor/github.com/opencontainers/image-spec/schema/error.go new file mode 100644 index 0000000000..8b0bfc2afc --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/error.go @@ -0,0 +1,44 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "encoding/json" + "io" + + "go4.org/errorutil" +) + +// A SyntaxError is a description of a JSON syntax error +// including line, column and offset in the JSON file. +type SyntaxError struct { + msg string + Line, Col int + Offset int64 +} + +func (e *SyntaxError) Error() string { return e.msg } + +// WrapSyntaxError checks whether the given error is a *json.SyntaxError +// and converts it into a *schema.SyntaxError containing line/col information using the given reader. +// If the given error is not a *json.SyntaxError it is returned unchanged. +func WrapSyntaxError(r io.Reader, err error) error { + if serr, ok := err.(*json.SyntaxError); ok { + line, col, _ := errorutil.HighlightBytePosition(r, serr.Offset) + return &SyntaxError{serr.Error(), line, col, serr.Offset} + } + + return err +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/fs.go b/vendor/github.com/opencontainers/image-spec/schema/fs.go new file mode 100644 index 0000000000..b18f765684 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/fs.go @@ -0,0 +1,323 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "esc -private -pkg=schema -include=.*\.json$ ."; DO NOT EDIT. + +package schema + +import ( + "bytes" + "compress/gzip" + "encoding/base64" + "io/ioutil" + "net/http" + "os" + "path" + "sync" + "time" +) + +type _escLocalFS struct{} + +var _escLocal _escLocalFS + +type _escStaticFS struct{} + +var _escStatic _escStaticFS + +type _escDirectory struct { + fs http.FileSystem + name string +} + +type _escFile struct { + compressed string + size int64 + modtime int64 + local string + isDir bool + + once sync.Once + data []byte + name string +} + +func (_escLocalFS) Open(name string) (http.File, error) { + f, present := _escData[path.Clean(name)] + if !present { + return nil, os.ErrNotExist + } + return os.Open(f.local) +} + +func (_escStaticFS) prepare(name string) (*_escFile, error) { + f, present := _escData[path.Clean(name)] + if !present { + return nil, os.ErrNotExist + } + var err error + f.once.Do(func() { + f.name = path.Base(name) + if f.size == 0 { + return + } + var gr *gzip.Reader + b64 := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(f.compressed)) + gr, err = gzip.NewReader(b64) + if err != nil { + return + } + f.data, err = ioutil.ReadAll(gr) + }) + if err != nil { + return nil, err + } + return f, nil +} + +func (fs _escStaticFS) Open(name string) (http.File, error) { + f, err := fs.prepare(name) + if err != nil { + return nil, err + } + return f.File() +} + +func (dir _escDirectory) Open(name string) (http.File, error) { + return dir.fs.Open(dir.name + name) +} + +func (f *_escFile) File() (http.File, error) { + type httpFile struct { + *bytes.Reader + *_escFile + } + return &httpFile{ + Reader: bytes.NewReader(f.data), + _escFile: f, + }, nil +} + +func (f *_escFile) Close() error { + return nil +} + +func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) { + return nil, nil +} + +func (f *_escFile) Stat() (os.FileInfo, error) { + return f, nil +} + +func (f *_escFile) Name() string { + return f.name +} + +func (f *_escFile) Size() int64 { + return f.size +} + +func (f *_escFile) Mode() os.FileMode { + return 0 +} + +func (f *_escFile) ModTime() time.Time { + return time.Unix(f.modtime, 0) +} + +func (f *_escFile) IsDir() bool { + return f.isDir +} + +func (f *_escFile) Sys() interface{} { + return f +} + +// _escFS returns a http.Filesystem for the embedded assets. If useLocal is true, +// the filesystem's contents are instead used. +func _escFS(useLocal bool) http.FileSystem { + if useLocal { + return _escLocal + } + return _escStatic +} + +// _escDir returns a http.Filesystem for the embedded assets on a given prefix dir. +// If useLocal is true, the filesystem's contents are instead used. +func _escDir(useLocal bool, name string) http.FileSystem { + if useLocal { + return _escDirectory{fs: _escLocal, name: name} + } + return _escDirectory{fs: _escStatic, name: name} +} + +// _escFSByte returns the named file from the embedded assets. If useLocal is +// true, the filesystem's contents are instead used. +func _escFSByte(useLocal bool, name string) ([]byte, error) { + if useLocal { + f, err := _escLocal.Open(name) + if err != nil { + return nil, err + } + b, err := ioutil.ReadAll(f) + _ = f.Close() + return b, err + } + f, err := _escStatic.prepare(name) + if err != nil { + return nil, err + } + return f.data, nil +} + +// _escFSMustByte is the same as _escFSByte, but panics if name is not present. +func _escFSMustByte(useLocal bool, name string) []byte { + b, err := _escFSByte(useLocal, name) + if err != nil { + panic(err) + } + return b +} + +// _escFSString is the string version of _escFSByte. +func _escFSString(useLocal bool, name string) (string, error) { + b, err := _escFSByte(useLocal, name) + return string(b), err +} + +// _escFSMustString is the string version of _escFSMustByte. +func _escFSMustString(useLocal bool, name string) string { + return string(_escFSMustByte(useLocal, name)) +} + +var _escData = map[string]*_escFile{ + + "/config-schema.json": { + local: "config-schema.json", + size: 2771, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/+RWQY/TPBC951dE2T22m+/wnXot3JCKVAGHFarcZNLOEnvMeIKIUP87itNCkjpp6apc +OEUaz7z35nns+EcUx0kOLmO0gmSSRZysLJglGVFogOMlmQJ38dpChgVmymfNmrJHl+1Bq6ZkL2IXafri +yMzb6BPxLs1ZFTL/7/+0jT20dZifStwiTcmCyU5szpe12SlqtYM08/xtpdQWmlravkAmbcwyWWBBcMki +btqJ4yRjUAL5r0Cn1AmjaeF8vCDWSpqVXAnMBTUkfu3QpiSqkj3xBFQ/m7M9CmRSMVxbQ+7azKMXgeyO +Iz4ecMXHPzjgXmSEscPqc95+t+Qgf08sblj/yFB4A6FwT80IPKQ5FGiwGRWXamXXHnnVagzjm29jshSz +qpNZdwkF9FDGRCNxfBghFa4toZEhNxlYNT099wj6dJMSJ2RekNqXO5A8qcJUZdlH6uJ8Dlqw1Pk/2/tH +KisN7sb+b536e3f1ifgLmt0bvOmcv1NbKO9tyTqw8fe0ZC1k17gzqrzakqj7PV2/TCSFe831m2NRbDB3 +f/+uO+ZPdd+jBVPpsx1PSlUDuyTseDRgTRi+Vsj+P/wc8GCoLuoinjzfoxPiOmR636yAUWPbM75BwbfD +Zbem3hGB8T5/U1ze1FlA42ZbvwKDtIazP98fAIC2Um/8RIyDbIlKUGZkPvunLDoynM9N/1n1+9nUP5dR +MzuH6GcAAAD//0pj2wvTCgAA +`, + }, + + "/content-descriptor.json": { + local: "content-descriptor.json", + size: 1085, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/5yTwW7UMBCG73mKUVqpl27NoeIQVb3AnQPcEAevPY6nbGwznlW1oL47mniXJoAo3Vsy ++r+Zz8n4RwfQe6yOqQjl1A/QfyiY3uUklhIy6BMmgffHUGb4WNBRIGdn4lpbXFYXcbKKR5EyGPNQc9q0 +6k3m0Xi2QTZvbk2rXTSO/AmpgzG5YHKnyXXGWtr4X9MbJ4eCSubtAzpptcK5IAth7QfQgwH0E3qyn1q4 +lf48r0SEOadNIQfQAmNAxuTQw2LGjF8yBuU8hrp5FrvRE18Yj4ESae9qnqfP7FNr0Vf6/pKPRoASbA+C +9ZVOfxGhJG9v1xKeRqzygobjQ5E8si2RHLiI7mvdT9DYk1ZzuVZdfS1WBDnB1Z3djZlJ4nQ/3OmP9ejv +r875jkfXlf+ed/Uf9hZ21BQ1CIHzBI+RXASJVI/OMNkDbBF8fky7bD36c+xmk5WbTSnLfDtWiv+77DTZ +ERcrb5b9zhBc4s2zO7r2jN/2xKhin3+/McttXS9NB/Cle+p+BgAA///HjexwPQQAAA== +`, + }, + + "/defs-descriptor.json": { + local: "defs-descriptor.json", + size: 922, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/6STX2/TMBTF3/spLl7FgDZN4QFp0Ria2DsP42lTV93ZN/Ed8R/ZrqYy9bsjJ1naFYFA +PCSyj67Pub8b52kCIBRFGdgndlZUIK6oZst5F8FjSCw3LQZIDr56sl+cTciWAlwNx1yAa0+Sa5bYecx7 +09FFVJBzAIQhxfht62mUAASrnKpT8rEqS+fJyueMuHChKaPUZLBkgw2Vakwt927zZ6/Ue4uYAttmr3tM +iUKHd3d7Wdxg8WNZnK32y1cn09fF3XoxWz0t5+8/fNyVf1c2FV3Erk8SihuK6ZDuaLhJE8iw9ck1Ab1m +CVKT/B43Bvqz4GrIRe7+gWSaA9tuOwDA6Tm2jQuctLmozvOoFKmL03+cwMA1e/O5up0t1sVqVN6+q/L6 +srhZFmef1sVqdkS4CW38Ax9Cyz1ELoQ6OAOPmqWGpDkOVGBwC/cEyj3a1qEi9Wv/GAJu9zInMoe5vycF +ELULBvNXEJvAYtB3LzDQWpfw5fX8n7t46Dc2PQ1UZz9FdVw8RGdPyoPfojTor7ve+/cw50l+dpOfAQAA +//8aH/C2mgMAAA== +`, + }, + + "/defs.json": { + local: "defs.json", + size: 1670, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/7STza6bMBCF9zzFyO2S9oJtbGDb7hMpy6oLSiaJq2AjY6RWEe9e8RNChFuJKneRgGc8 +3zmeMbcAgByxKa2qnTKa5EC+4klp1a8aaBs8grtY054vpnXgLgi7GvUXo12hNFo41FiqkyqLoTwceTOA +5NBLABClXTqvAIj7XWOvprTDM9qhckhUSquqrUgOn2KaPsLFrykcUzkEu3Amx2IrmlEpfPA+vsIzuhVP +Yy55ygT3aczJlZDgW4UyShmTNGIiTbiUIooij6Jn15N0+x/T8enQJFlxN8/GBxZJwtbozXPxoTnNeCYk +zdb8zePw8eOUcyE5jySTUZYk1Nf8WOxNz7VLQaNxdyI5fJsCMKeG9EeLfZZ8eFt8cG9Ty+eNXeivvp9G +t9frYvf09t3Ti1c6FPy1DhtnlT5vd3jXGOtf66kq6sOAHf99V8n8+Imle9ykunAOrd5bU6N1CptFEQD5 +fIvD7in0ryMEy+fK1G6UfmdTE+tvpoL+1wV/AgAA//96IpqyhgYAAA== +`, + }, + + "/image-index-schema.json": { + local: "image-index-schema.json", + size: 2993, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/6yWz0/jOhDH7/0rRgGJC5CnJ/QOFeLy9sJpD4v2suJg7EkybGNnx1Ogu+r/vrJN2qRJ +C4Te2rHnO5/vxL/+zAAyg14zNULOZnPIvjZo/3dWFFlkuK1ViXBrDb7AtwY1FaRVnHoeck+9rrBWIa8S +aeZ5/uidvUjRS8dlblgVcvHPVZ5iJymPTJvi53nuGrS6LeljWpqdUyifUyifEmXVYEh1D4+oJcUadg2y +EPpsDsESQJbyvyP7ZCuFh27vKvJQEC4M+GQPPUiFECtDrAxJDJ6SGigPygJZwRI5IkTlCZ7yPuZGqnU5 +qFGTpXpZZ3P4dxtTL20shtZpJKuVpQK9+K79Vlkxq1WHXbDuzvuwnbbYl9f2ui30+Fd7HWH8tSTGUOvH +Jhrg0ZC6C2nn3bCn3zsRQyV6yTah+474yMIYyPcHhgskrIU4O3gAV8TFwVggo9VoYGApipwyFiHbYOEv +zKYnl2F3nOQGC7IUKvh8S9JRWA9Nv4czTASy8LAS9JNYRwDJyn9X++Fe+/8ePM2rRlzJqqlIg65Q//TL +GpJCi5sYz4ON8LdRIsgWzq7VonRMUtU38+uwFg2am7Ppfd9dN7u+lrzwb7pSsKCEHqZDwa6G54p0BRLO +leQFarWCBwTjnu3CKYNmOnWk2svcLJQUjush98c280Znh3PvNj60leOYYl2RoJYl404eQOZ6nnp7+PA+ +HmoPxye7zw9Cd9rhhcmW2c6E9ZjNY+I5fxyoy6fBLXkMuI3scSALVOE7HLuFW90DmP3Lslt2cG2+2yTA ++k3bT4pJWRm3/EYPZ/v+9Y8MZa2T+KDznz01tgdX3lWdfNZ1RWZjXtpf696zZ9zRpNfZmI3PGAigEXN4 +VmZjL8HOE24GcD9bz/4GAAD//yCnv52xCwAA +`, + }, + + "/image-layout-schema.json": { + local: "image-layout-schema.json", + size: 439, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/2yPQUvEMBCF7/0VQ/Sg4DYVPOW6pwVhD4IX8VDTaTvLNonJVFik/12SaRXRU5g38+W9 +91kBqA6TjRSYvFMG1DGg23vHLTmMcJjaAeGxvfiZ4cmOOLXqLlPXSQYDamQORutT8m4nau3joLvY9rxr +HrRoV8JRtyHJaO0DOruZpYLJtaZsrM/FWEi+BMysfzuhXbUQfcDIhEkZyG2yQyYl8TPGJLVk97fth1yA +74FHhOP+8LvyDbmy8JZ2EgZ6OuNtsS8fbrESR3LDj45unpSBl3UGUPd1UzdqnV/Lu1QAS2kS8X2miN03 +8l+PKnNL9RUAAP//k31n5bcBAAA= +`, + }, + + "/image-manifest-schema.json": { + local: "image-manifest-schema.json", + size: 921, + modtime: 1515512099, + compressed: ` +H4sIAAAAAAAC/5ySMW8iMRCF+/0VI0MJ+O501bZXUZxSJEoTpXB2x7uDWNsZmygo4r9HtnHAkCKifTvv +zTdv/dEAiB59x+QCWSNaEHcOzT9rgiKDDOtJDQj/lSGNPsC9w440dSpNL6J97rsRJxWtYwiulXLjrVlm +dWV5kD0rHZa//sqszbKP+mLxrZTWoenKVp9seVpSJJDTkSB7w95hdNuXDXZHzbF1yIHQixbiYQAiRzwi ++3xclq9vfhjJgybc9uDzheghjAhpOZTlkPPgLQeC8qAMkAk4ICeKFH7bZbKG/Uort16tmcjQtJtEC39O +mnovWpIO+YvorNE0nDcwZ9QxNqKhCcvSiOVV/H+ism/VHtmf2wuVYlb7imkdcIqjv099HJVi/ul2gENF +oYyxIb28CuXGus/TFpet9Kj9JdRM9qjJULJU9qawJlLB+Lojxoj19N07rP9JXXED8Nwcms8AAAD//7u3 +Dj+ZAwAA +`, + }, + + "/": { + isDir: true, + local: "", + }, +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/gen.go b/vendor/github.com/opencontainers/image-spec/schema/gen.go new file mode 100644 index 0000000000..ae78604fd8 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/gen.go @@ -0,0 +1,21 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +// Generates an embbedded http.FileSystem for all schema files +// using esc (https://github.com/mjibson/esc). + +// This should generally be invoked with `make schema-fs` +//go:generate esc -private -pkg=schema -include=.*\.json$ . diff --git a/vendor/github.com/opencontainers/image-spec/schema/image-index-schema.json b/vendor/github.com/opencontainers/image-spec/schema/image-index-schema.json new file mode 100644 index 0000000000..8a962aab24 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/image-index-schema.json @@ -0,0 +1,89 @@ +{ + "description": "OpenContainer Image Index Specification", + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://opencontainers.org/schema/image/index", + "type": "object", + "properties": { + "schemaVersion": { + "description": "This field specifies the image index schema version as an integer", + "id": "https://opencontainers.org/schema/image/index/schemaVersion", + "type": "integer", + "minimum": 2, + "maximum": 2 + }, + "manifests": { + "type": "array", + "items": { + "id": "https://opencontainers.org/schema/image/manifestDescriptor", + "type": "object", + "required": [ + "mediaType", + "size", + "digest" + ], + "properties": { + "mediaType": { + "description": "the mediatype of the referenced object", + "$ref": "defs-descriptor.json#/definitions/mediaType" + }, + "size": { + "description": "the size in bytes of the referenced object", + "$ref": "defs.json#/definitions/int64" + }, + "digest": { + "description": "the cryptographic checksum digest of the object, in the pattern ':'", + "$ref": "defs-descriptor.json#/definitions/digest" + }, + "urls": { + "description": "a list of urls from which this object may be downloaded", + "$ref": "defs-descriptor.json#/definitions/urls" + }, + "platform": { + "id": "https://opencontainers.org/schema/image/platform", + "type": "object", + "required": [ + "architecture", + "os" + ], + "properties": { + "architecture": { + "id": "https://opencontainers.org/schema/image/platform/architecture", + "type": "string" + }, + "os": { + "id": "https://opencontainers.org/schema/image/platform/os", + "type": "string" + }, + "os.version": { + "id": "https://opencontainers.org/schema/image/platform/os.version", + "type": "string" + }, + "os.features": { + "id": "https://opencontainers.org/schema/image/platform/os.features", + "type": "array", + "items": { + "type": "string" + } + }, + "variant": { + "type": "string" + } + } + }, + "annotations": { + "id": "https://opencontainers.org/schema/image/descriptor/annotations", + "$ref": "defs-descriptor.json#/definitions/annotations" + } + } + } + }, + "annotations": { + "id": "https://opencontainers.org/schema/image/index/annotations", + "$ref": "defs-descriptor.json#/definitions/annotations" + } + }, + "required": [ + "schemaVersion", + "manifests" + ] +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/image-layout-schema.json b/vendor/github.com/opencontainers/image-spec/schema/image-layout-schema.json new file mode 100644 index 0000000000..874d2174c7 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/image-layout-schema.json @@ -0,0 +1,18 @@ +{ + "description": "OpenContainer Image Layout Schema", + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://opencontainers.org/schema/image/layout", + "type": "object", + "properties": { + "imageLayoutVersion": { + "description": "version of the OCI Image Layout (in the oci-layout file)", + "type": "string", + "enum": [ + "1.0.0" + ] + } + }, + "required": [ + "imageLayoutVersion" + ] +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/image-manifest-schema.json b/vendor/github.com/opencontainers/image-spec/schema/image-manifest-schema.json new file mode 100644 index 0000000000..ec00748e19 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/image-manifest-schema.json @@ -0,0 +1,34 @@ +{ + "description": "OpenContainer Image Manifest Specification", + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://opencontainers.org/schema/image/manifest", + "type": "object", + "properties": { + "schemaVersion": { + "description": "This field specifies the image manifest schema version as an integer", + "id": "https://opencontainers.org/schema/image/manifest/schemaVersion", + "type": "integer", + "minimum": 2, + "maximum": 2 + }, + "config": { + "$ref": "content-descriptor.json" + }, + "layers": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "content-descriptor.json" + } + }, + "annotations": { + "id": "https://opencontainers.org/schema/image/manifest/annotations", + "$ref": "defs-descriptor.json#/definitions/annotations" + } + }, + "required": [ + "schemaVersion", + "config", + "layers" + ] +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/loader.go b/vendor/github.com/opencontainers/image-spec/schema/loader.go new file mode 100644 index 0000000000..c6bde00482 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/loader.go @@ -0,0 +1,126 @@ +// Copyright 2018 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "strings" + + "github.com/xeipuuv/gojsonreference" + "github.com/xeipuuv/gojsonschema" +) + +// fsLoaderFactory implements gojsonschema.JSONLoaderFactory by reading files under the specified namespaces from the root of fs. +type fsLoaderFactory struct { + namespaces []string + fs http.FileSystem +} + +// newFSLoaderFactory returns a fsLoaderFactory reading files under the specified namespaces from the root of fs. +func newFSLoaderFactory(namespaces []string, fs http.FileSystem) *fsLoaderFactory { + return &fsLoaderFactory{ + namespaces: namespaces, + fs: fs, + } +} + +func (factory *fsLoaderFactory) New(source string) gojsonschema.JSONLoader { + return &fsLoader{ + factory: factory, + source: source, + } +} + +// refContents returns the contents of ref, if available in fsLoaderFactory. +func (factory *fsLoaderFactory) refContents(ref gojsonreference.JsonReference) ([]byte, error) { + refStr := ref.String() + path := "" + for _, ns := range factory.namespaces { + if strings.HasPrefix(refStr, ns) { + path = "/" + strings.TrimPrefix(refStr, ns) + break + } + } + if path == "" { + return nil, fmt.Errorf("Schema reference %#v unexpectedly not available in fsLoaderFactory with namespaces %#v", path, factory.namespaces) + } + + f, err := factory.fs.Open(path) + if err != nil { + return nil, err + } + defer f.Close() + + return ioutil.ReadAll(f) +} + +// fsLoader implements gojsonschema.JSONLoader by reading the document named by source from a fsLoaderFactory. +type fsLoader struct { + factory *fsLoaderFactory + source string +} + +// JsonSource implements gojsonschema.JSONLoader.JsonSource. The "Json" capitalization needs to be maintained to conform to the interface. +func (l *fsLoader) JsonSource() interface{} { // nolint: golint + return l.source +} + +func (l *fsLoader) LoadJSON() (interface{}, error) { + // Based on gojsonschema.jsonReferenceLoader.LoadJSON. + reference, err := gojsonreference.NewJsonReference(l.source) + if err != nil { + return nil, err + } + + refToURL := reference + refToURL.GetUrl().Fragment = "" + + body, err := l.factory.refContents(refToURL) + if err != nil { + return nil, err + } + + return decodeJSONUsingNumber(bytes.NewReader(body)) +} + +// decodeJSONUsingNumber returns JSON parsed from an io.Reader +func decodeJSONUsingNumber(r io.Reader) (interface{}, error) { + // Copied from gojsonschema. + var document interface{} + + decoder := json.NewDecoder(r) + decoder.UseNumber() + + err := decoder.Decode(&document) + if err != nil { + return nil, err + } + + return document, nil +} + +// JsonReference implements gojsonschema.JSONLoader.JsonReference. The "Json" capitalization needs to be maintained to conform to the interface. +func (l *fsLoader) JsonReference() (gojsonreference.JsonReference, error) { // nolint: golint + return gojsonreference.NewJsonReference(l.JsonSource().(string)) +} + +func (l *fsLoader) LoaderFactory() gojsonschema.JSONLoaderFactory { + return l.factory +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/schema.go b/vendor/github.com/opencontainers/image-spec/schema/schema.go new file mode 100644 index 0000000000..2a560552a8 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/schema.go @@ -0,0 +1,75 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "net/http" + + "github.com/opencontainers/image-spec/specs-go/v1" +) + +// Media types for the OCI image formats +const ( + ValidatorMediaTypeDescriptor Validator = v1.MediaTypeDescriptor + ValidatorMediaTypeLayoutHeader Validator = v1.MediaTypeLayoutHeader + ValidatorMediaTypeManifest Validator = v1.MediaTypeImageManifest + ValidatorMediaTypeImageIndex Validator = v1.MediaTypeImageIndex + ValidatorMediaTypeImageConfig Validator = v1.MediaTypeImageConfig + ValidatorMediaTypeImageLayer unimplemented = v1.MediaTypeImageLayer +) + +var ( + // fs stores the embedded http.FileSystem + // having the OCI JSON schema files in root "/". + fs = _escFS(false) + + // schemaNamespaces is a set of URI prefixes which are treated as containing the schema files of fs. + // This is necessary because *.json schema files in this directory use "id" and "$ref" attributes which evaluate to such URIs, e.g. + // ./image-manifest-schema.json URI contains + // "id": "https://opencontainers.org/schema/image/manifest", + // and + // "$ref": "content-descriptor.json" + // which evaluates as a link to https://opencontainers.org/schema/image/content-descriptor.json . + // + // To support such links without accessing the network (and trying to load content which is not hosted at these URIs), + // fsLoaderFactory accepts any URI starting with one of the schemaNamespaces below, + // and uses _escFS to load them from the root of its in-memory filesystem tree. + // + // (Note that this must contain subdirectories before its parent directories for fsLoaderFactory.refContents to work.) + schemaNamespaces = []string{ + "https://opencontainers.org/schema/image/descriptor/", + "https://opencontainers.org/schema/image/index/", + "https://opencontainers.org/schema/image/manifest/", + "https://opencontainers.org/schema/image/", + "https://opencontainers.org/schema/", + } + + // specs maps OCI schema media types to schema URIs. + // These URIs are expected to be used only by fsLoaderFactory (which trims schemaNamespaces defined above) + // and should never cause a network access. + specs = map[Validator]string{ + ValidatorMediaTypeDescriptor: "https://opencontainers.org/schema/content-descriptor.json", + ValidatorMediaTypeLayoutHeader: "https://opencontainers.org/schema/image/image-layout-schema.json", + ValidatorMediaTypeManifest: "https://opencontainers.org/schema/image/image-manifest-schema.json", + ValidatorMediaTypeImageIndex: "https://opencontainers.org/schema/image/image-index-schema.json", + ValidatorMediaTypeImageConfig: "https://opencontainers.org/schema/image/config-schema.json", + } +) + +// FileSystem returns an in-memory filesystem including the schema files. +// The schema files are located at the root directory. +func FileSystem() http.FileSystem { + return fs +} diff --git a/vendor/github.com/opencontainers/image-spec/schema/validator.go b/vendor/github.com/opencontainers/image-spec/schema/validator.go new file mode 100644 index 0000000000..029217c3b6 --- /dev/null +++ b/vendor/github.com/opencontainers/image-spec/schema/validator.go @@ -0,0 +1,224 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "regexp" + + digest "github.com/opencontainers/go-digest" + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" + "github.com/xeipuuv/gojsonschema" +) + +// Validator wraps a media type string identifier +// and implements validation against a JSON schema. +type Validator string + +type validateFunc func(r io.Reader) error + +var mapValidate = map[Validator]validateFunc{ + ValidatorMediaTypeImageConfig: validateConfig, + ValidatorMediaTypeDescriptor: validateDescriptor, + ValidatorMediaTypeImageIndex: validateIndex, + ValidatorMediaTypeManifest: validateManifest, +} + +// ValidationError contains all the errors that happened during validation. +type ValidationError struct { + Errs []error +} + +func (e ValidationError) Error() string { + return fmt.Sprintf("%v", e.Errs) +} + +// Validate validates the given reader against the schema of the wrapped media type. +func (v Validator) Validate(src io.Reader) error { + buf, err := ioutil.ReadAll(src) + if err != nil { + return errors.Wrap(err, "unable to read the document file") + } + + if f, ok := mapValidate[v]; ok { + if f == nil { + return fmt.Errorf("internal error: mapValidate[%q] is nil", v) + } + err = f(bytes.NewReader(buf)) + if err != nil { + return err + } + } + + sl := newFSLoaderFactory(schemaNamespaces, fs).New(specs[v]) + ml := gojsonschema.NewStringLoader(string(buf)) + + result, err := gojsonschema.Validate(sl, ml) + if err != nil { + return errors.Wrapf( + WrapSyntaxError(bytes.NewReader(buf), err), + "schema %s: unable to validate", v) + } + + if result.Valid() { + return nil + } + + errs := make([]error, 0, len(result.Errors())) + for _, desc := range result.Errors() { + errs = append(errs, fmt.Errorf("%s", desc)) + } + + return ValidationError{ + Errs: errs, + } +} + +type unimplemented string + +func (v unimplemented) Validate(src io.Reader) error { + return fmt.Errorf("%s: unimplemented", v) +} + +func validateManifest(r io.Reader) error { + header := v1.Manifest{} + + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "error reading the io stream") + } + + err = json.Unmarshal(buf, &header) + if err != nil { + return errors.Wrap(err, "manifest format mismatch") + } + + if header.Config.MediaType != string(v1.MediaTypeImageConfig) { + fmt.Printf("warning: config %s has an unknown media type: %s\n", header.Config.Digest, header.Config.MediaType) + } + + for _, layer := range header.Layers { + if layer.MediaType != string(v1.MediaTypeImageLayer) && + layer.MediaType != string(v1.MediaTypeImageLayerGzip) && + layer.MediaType != string(v1.MediaTypeImageLayerNonDistributable) && + layer.MediaType != string(v1.MediaTypeImageLayerNonDistributableGzip) { + fmt.Printf("warning: layer %s has an unknown media type: %s\n", layer.Digest, layer.MediaType) + } + } + return nil +} + +func validateDescriptor(r io.Reader) error { + header := v1.Descriptor{} + + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "error reading the io stream") + } + + err = json.Unmarshal(buf, &header) + if err != nil { + return errors.Wrap(err, "descriptor format mismatch") + } + + err = header.Digest.Validate() + if err == digest.ErrDigestUnsupported { + // we ignore unsupported algorithms + fmt.Printf("warning: unsupported digest: %q: %v\n", header.Digest, err) + return nil + } + return err +} + +func validateIndex(r io.Reader) error { + header := v1.Index{} + + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "error reading the io stream") + } + + err = json.Unmarshal(buf, &header) + if err != nil { + return errors.Wrap(err, "index format mismatch") + } + + for _, manifest := range header.Manifests { + if manifest.MediaType != string(v1.MediaTypeImageManifest) { + fmt.Printf("warning: manifest %s has an unknown media type: %s\n", manifest.Digest, manifest.MediaType) + } + if manifest.Platform != nil { + checkPlatform(manifest.Platform.OS, manifest.Platform.Architecture) + } + + } + + return nil +} + +func validateConfig(r io.Reader) error { + header := v1.Image{} + + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "error reading the io stream") + } + + err = json.Unmarshal(buf, &header) + if err != nil { + return errors.Wrap(err, "config format mismatch") + } + + checkPlatform(header.OS, header.Architecture) + + envRegexp := regexp.MustCompile(`^[^=]+=.*$`) + for _, e := range header.Config.Env { + if !envRegexp.MatchString(e) { + return errors.Errorf("unexpected env: %q", e) + } + } + + return nil +} + +func checkPlatform(OS string, Architecture string) { + validCombins := map[string][]string{ + "android": {"arm"}, + "darwin": {"386", "amd64", "arm", "arm64"}, + "dragonfly": {"amd64"}, + "freebsd": {"386", "amd64", "arm"}, + "linux": {"386", "amd64", "arm", "arm64", "ppc64", "ppc64le", "mips64", "mips64le", "s390x"}, + "netbsd": {"386", "amd64", "arm"}, + "openbsd": {"386", "amd64", "arm"}, + "plan9": {"386", "amd64"}, + "solaris": {"amd64"}, + "windows": {"386", "amd64"}} + for os, archs := range validCombins { + if os == OS { + for _, arch := range archs { + if arch == Architecture { + return + } + } + fmt.Printf("warning: combination of %q and %q is invalid.\n", OS, Architecture) + } + } + fmt.Printf("warning: operating system %q of the bundle is not supported yet.\n", OS) +} diff --git a/vendor/github.com/opencontainers/image-tools/LICENSE b/vendor/github.com/opencontainers/image-tools/LICENSE new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/image-tools/image/autodetect.go b/vendor/github.com/opencontainers/image-tools/image/autodetect.go new file mode 100644 index 0000000000..54abbcc6b8 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/autodetect.go @@ -0,0 +1,69 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "io" + "io/ioutil" + "net/http" + "os" + + "github.com/pkg/errors" +) + +// supported autodetection types +const ( + TypeImageLayout = "imageLayout" + TypeImage = "image" + TypeImageZip = "imageZip" + TypeManifest = "manifest" + TypeImageIndex = "imageIndex" + TypeConfig = "config" +) + +// Autodetect detects the validation type for the given path +// or an error if the validation type could not be resolved. +func Autodetect(path string) (string, error) { + fi, err := os.Stat(path) + if err != nil { + return "", errors.Wrapf(err, "unable to access path") // err from os.Stat includes path name + } + + if fi.IsDir() { + return TypeImageLayout, nil + } + + f, err := os.Open(path) + if err != nil { + return "", errors.Wrap(err, "unable to open file") // os.Open includes the filename + } + defer f.Close() + + buf, err := ioutil.ReadAll(io.LimitReader(f, 512)) // read some initial bytes to detect content + if err != nil { + return "", errors.Wrap(err, "unable to read") + } + + mimeType := http.DetectContentType(buf) + + switch mimeType { + case "application/x-gzip", "application/x-rar-compressed", "application/octet-stream": + return TypeImage, nil + case "application/zip": + return TypeImageZip, nil + } + + return "", errors.New("unknown file type") +} diff --git a/vendor/github.com/opencontainers/image-tools/image/config.go b/vendor/github.com/opencontainers/image-tools/image/config.go new file mode 100644 index 0000000000..45711990e4 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/config.go @@ -0,0 +1,120 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "path/filepath" + "strconv" + "strings" + + "github.com/opencontainers/image-spec/schema" + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/opencontainers/runtime-spec/specs-go" + "github.com/pkg/errors" +) + +func findConfig(w walker, d *v1.Descriptor) (*v1.Image, error) { + var c v1.Image + cpath := filepath.Join("blobs", string(d.Digest.Algorithm()), d.Digest.Hex()) + + switch err := w.find(cpath, func(path string, r io.Reader) error { + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "%s: error reading config", path) + } + + if err := schema.ValidatorMediaTypeImageConfig.Validate(bytes.NewReader(buf)); err != nil { + return errors.Wrapf(err, "%s: config validation failed", path) + } + + if err := json.Unmarshal(buf, &c); err != nil { + return err + } + + return errEOW + }); err { + case nil: + return nil, fmt.Errorf("%s: config not found", cpath) + case errEOW: + return &c, nil + default: + return nil, err + } +} + +func runtimeSpec(c *v1.Image, rootfs string) (*specs.Spec, error) { + if c.OS != "linux" { + return nil, fmt.Errorf("%s: unsupported OS", c.OS) + } + + var s specs.Spec + s.Version = specs.Version + // we should at least apply the default spec, otherwise this is totally useless + s.Root = &specs.Root{} + s.Root.Path = rootfs + + s.Process = &specs.Process{} + s.Process.Terminal = true + s.Process.Cwd = "/" + if c.Config.WorkingDir != "" { + s.Process.Cwd = c.Config.WorkingDir + } + s.Process.Env = append(s.Process.Env, c.Config.Env...) + s.Process.Args = append(s.Process.Args, c.Config.Entrypoint...) + s.Process.Args = append(s.Process.Args, c.Config.Cmd...) + + if len(s.Process.Args) == 0 { + s.Process.Args = append(s.Process.Args, "sh") + } + + if uid, err := strconv.Atoi(c.Config.User); err == nil { + s.Process.User.UID = uint32(uid) + } else if ug := strings.Split(c.Config.User, ":"); len(ug) == 2 { + uid, err := strconv.Atoi(ug[0]) + if err != nil { + return nil, errors.New("config.User: unsupported uid format") + } + + gid, err := strconv.Atoi(ug[1]) + if err != nil { + return nil, errors.New("config.User: unsupported gid format") + } + + s.Process.User.UID = uint32(uid) + s.Process.User.GID = uint32(gid) + } else if c.Config.User != "" { + return nil, errors.New("config.User: unsupported format") + } + + s.Linux = &specs.Linux{} + + for vol := range c.Config.Volumes { + s.Mounts = append( + s.Mounts, + specs.Mount{ + Destination: vol, + Type: "bind", + Options: []string{"rbind"}, + }, + ) + } + + return &s, nil +} diff --git a/vendor/github.com/opencontainers/image-tools/image/descriptor.go b/vendor/github.com/opencontainers/image-tools/image/descriptor.go new file mode 100644 index 0000000000..5bf19acf69 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/descriptor.go @@ -0,0 +1,144 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "encoding/json" + "fmt" + "io" + "os" + "path/filepath" + "strings" + + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" +) + +const indexPath = "index.json" + +func listReferences(w walker) ([]v1.Descriptor, error) { + var descs []v1.Descriptor + var index v1.Index + + if err := w.walk(func(path string, info os.FileInfo, r io.Reader) error { + if info.IsDir() || filepath.Clean(path) != indexPath { + return nil + } + + if err := json.NewDecoder(r).Decode(&index); err != nil { + return err + } + descs = index.Manifests + + return nil + }); err != nil { + return nil, err + } + + return descs, nil +} + +func findDescriptor(w walker, names []string) ([]v1.Descriptor, error) { + var descs []v1.Descriptor + var index v1.Index + dpath := "index.json" + + if err := w.find(dpath, func(path string, r io.Reader) error { + if err := json.NewDecoder(r).Decode(&index); err != nil { + return err + } + + descs = index.Manifests + for _, name := range names { + argsParts := strings.Split(name, "=") + if len(argsParts) != 2 { + return fmt.Errorf("each ref must contain two parts") + } + + switch argsParts[0] { + case "name": + for i := 0; i < len(descs); i++ { + if descs[i].Annotations[v1.AnnotationRefName] != argsParts[1] { + descs = append(descs[:i], descs[i+1:]...) + } + } + case "platform.os": + for i := 0; i < len(descs); i++ { + if descs[i].Platform != nil && index.Manifests[i].Platform.OS != argsParts[1] { + descs = append(descs[:i], descs[i+1:]...) + } + } + case "digest": + for i := 0; i < len(descs); i++ { + if string(descs[i].Digest) != argsParts[1] { + descs = append(descs[:i], descs[i+1:]...) + } + } + default: + return fmt.Errorf("criteria %q unimplemented", argsParts[0]) + } + } + + return nil + }); err != nil { + return nil, err + } + + if len(descs) == 0 { + return nil, fmt.Errorf("index.json: descriptor retrieved by refs %v is not match", names) + } else if len(descs) > 1 { + return nil, fmt.Errorf("index.json: descriptor retrieved by refs %v is not unique", names) + } + + return descs, nil +} + +func validateDescriptor(d *v1.Descriptor, w walker, mts []string) error { + var found bool + for _, mt := range mts { + if d.MediaType == mt { + found = true + break + } + } + if !found { + return fmt.Errorf("invalid descriptor MediaType %q", d.MediaType) + } + + if err := d.Digest.Validate(); err != nil { + return err + } + + // Copy the contents of the layer in to the verifier + verifier := d.Digest.Verifier() + numBytes, err := w.get(*d, verifier) + if err != nil { + return err + } + + if err != nil { + return errors.Wrap(err, "error generating hash") + } + + if numBytes != d.Size { + return errors.New("size mismatch") + } + + if !verifier.Verified() { + return errors.New("digest mismatch") + } + + return nil +} diff --git a/vendor/github.com/opencontainers/image-tools/image/doc.go b/vendor/github.com/opencontainers/image-tools/image/doc.go new file mode 100644 index 0000000000..de4163228d --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/doc.go @@ -0,0 +1,16 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package image defines methods for validating, unpacking OCI images and creating OCI runtime bundle. +package image diff --git a/vendor/github.com/opencontainers/image-tools/image/image.go b/vendor/github.com/opencontainers/image-tools/image/image.go new file mode 100644 index 0000000000..ba4b860f1d --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/image.go @@ -0,0 +1,389 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "encoding/json" + "fmt" + "io" + "log" + "os" + "path/filepath" + "strings" + + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" +) + +// ValidateLayout walks through the given file tree and validates the manifest +// pointed to by the given refs or returns an error if the validation failed. +func ValidateLayout(src string, refs []string, out *log.Logger) error { + return validate(newPathWalker(src), refs, out) +} + +// ValidateZip walks through the given file tree and validates the manifest +// pointed to by the given refs or returns an error if the validation failed. +func ValidateZip(src string, refs []string, out *log.Logger) error { + return validate(newZipWalker(src), refs, out) +} + +// ValidateFile opens the tar file given by the filename, then calls ValidateReader +func ValidateFile(tarFile string, refs []string, out *log.Logger) error { + f, err := os.Open(tarFile) + if err != nil { + return errors.Wrap(err, "unable to open file") + } + defer f.Close() + + return Validate(f, refs, out) +} + +// Validate walks through a tar stream and validates the manifest. +// * Check that all refs point to extant blobs +// * Checks that all referred blobs are valid +// * Checks that mime-types are correct +// returns error on validation failure +func Validate(r io.ReadSeeker, refs []string, out *log.Logger) error { + return validate(newTarWalker(r), refs, out) +} + +var validRefMediaTypes = []string{ + v1.MediaTypeImageManifest, + v1.MediaTypeImageIndex, +} + +func validate(w walker, refs []string, out *log.Logger) error { + var descs []v1.Descriptor + var err error + + if err = layoutValidate(w); err != nil { + return err + } + + if len(refs) == 0 { + out.Print("No ref specified, verify all refs") + descs, err = listReferences(w) + if err != nil { + return err + } + if len(descs) == 0 { + // TODO(runcom): ugly, we'll need a better way and library + // to express log levels. + // see https://github.com/opencontainers/image-spec/issues/288 + out.Print("WARNING: no descriptors found") + return nil + } + } else { + descs, err = findDescriptor(w, refs) + if err != nil { + return err + } + } + + for _, desc := range descs { + d := &desc + if err = validateDescriptor(d, w, validRefMediaTypes); err != nil { + return err + } + + if d.MediaType == validRefMediaTypes[0] { + m, err := findManifest(w, d) + if err != nil { + return err + } + + if err := validateManifest(m, w); err != nil { + return err + } + } + + if d.MediaType == validRefMediaTypes[1] { + index, err := findIndex(w, d) + if err != nil { + return err + } + + if err := validateIndex(index, w); err != nil { + return err + } + + if len(index.Manifests) == 0 { + fmt.Println("warning: no manifests found") + return nil + } + + for _, manifest := range index.Manifests { + m, err := findManifest(w, &manifest) + if err != nil { + return err + } + + if err := validateManifest(m, w); err != nil { + return err + } + } + } + } + + if out != nil && len(refs) > 0 { + out.Printf("reference %v: OK", refs) + } + + return nil +} + +// UnpackLayout walks through the file tree given by src and, using the layers +// specified in the manifest pointed to by the given ref, unpacks all layers in +// the given destination directory or returns an error if the unpacking failed. +func UnpackLayout(src, dest, platform string, refs []string) error { + return unpack(newPathWalker(src), dest, platform, refs) +} + +// UnpackZip opens and walks through the zip file given by src and, using the layers +// specified in the manifest pointed to by the given ref, unpacks all layers in +// the given destination directory or returns an error if the unpacking failed. +func UnpackZip(src, dest, platform string, refs []string) error { + return unpack(newZipWalker(src), dest, platform, refs) +} + +// UnpackFile opens the file pointed by tarFileName and calls Unpack on it. +func UnpackFile(tarFileName, dest, platform string, refs []string) error { + f, err := os.Open(tarFileName) + if err != nil { + return errors.Wrap(err, "unable to open file") + } + defer f.Close() + + return Unpack(f, dest, platform, refs) +} + +// Unpack walks through the tar stream and, using the layers specified in +// the manifest pointed to by the given ref, unpacks all layers in the given +// destination directory or returns an error if the unpacking failed. +// The destination will be created if it does not exist. +func Unpack(r io.ReadSeeker, dest, platform string, refs []string) error { + return unpack(newTarWalker(r), dest, platform, refs) +} + +func unpack(w walker, dest, platform string, refs []string) error { + if err := layoutValidate(w); err != nil { + return err + } + + descs, err := findDescriptor(w, refs) + if err != nil { + return err + } + + ref := &descs[0] + if err = validateDescriptor(ref, w, validRefMediaTypes); err != nil { + return err + } + + if ref.MediaType == validRefMediaTypes[0] { + m, err := findManifest(w, ref) + if err != nil { + return err + } + + if err := validateManifest(m, w); err != nil { + return err + } + + return unpackManifest(m, w, dest) + } + + if ref.MediaType == validRefMediaTypes[1] { + index, err := findIndex(w, ref) + if err != nil { + return err + } + + if err = validateIndex(index, w); err != nil { + return err + } + + manifests, err := filterManifest(w, index.Manifests, platform) + if err != nil { + return err + } + + for _, m := range manifests { + return unpackManifest(m, w, dest) + } + } + + return nil +} + +// CreateRuntimeBundleLayout walks through the file tree given by src and +// creates an OCI runtime bundle in the given destination dest +// or returns an error if the unpacking failed. +func CreateRuntimeBundleLayout(src, dest, root, platform string, refs []string) error { + return createRuntimeBundle(newPathWalker(src), dest, root, platform, refs) +} + +// CreateRuntimeBundleZip opens and walks through the zip file given by src +// and creates an OCI runtime bundle in the given destination dest +// or returns an error if the unpacking failed. +func CreateRuntimeBundleZip(src, dest, root, platform string, refs []string) error { + return createRuntimeBundle(newZipWalker(src), dest, root, platform, refs) +} + +// CreateRuntimeBundleFile opens the file pointed by tarFile and calls +// CreateRuntimeBundle. +func CreateRuntimeBundleFile(tarFile, dest, root, platform string, refs []string) error { + f, err := os.Open(tarFile) + if err != nil { + return errors.Wrap(err, "unable to open file") + } + defer f.Close() + + return createRuntimeBundle(newTarWalker(f), dest, root, platform, refs) +} + +// CreateRuntimeBundle walks through the given tar stream and +// creates an OCI runtime bundle in the given destination dest +// or returns an error if the unpacking failed. +func CreateRuntimeBundle(r io.ReadSeeker, dest, root, platform string, refs []string) error { + return createRuntimeBundle(newTarWalker(r), dest, root, platform, refs) +} + +func createRuntimeBundle(w walker, dest, rootfs, platform string, refs []string) error { + if err := layoutValidate(w); err != nil { + return err + } + + descs, err := findDescriptor(w, refs) + if err != nil { + return err + } + + ref := &descs[0] + if err = validateDescriptor(ref, w, validRefMediaTypes); err != nil { + return err + } + + if ref.MediaType == validRefMediaTypes[0] { + m, err := findManifest(w, ref) + if err != nil { + return err + } + + if err := validateManifest(m, w); err != nil { + return err + } + + return createBundle(w, m, dest, rootfs) + } + + if ref.MediaType == validRefMediaTypes[1] { + index, err := findIndex(w, ref) + if err != nil { + return err + } + + if err = validateIndex(index, w); err != nil { + return err + } + + manifests, err := filterManifest(w, index.Manifests, platform) + if err != nil { + return err + } + + for _, m := range manifests { + return createBundle(w, m, dest, rootfs) + } + } + + return nil +} + +func createBundle(w walker, m *v1.Manifest, dest, rootfs string) (retErr error) { + c, err := findConfig(w, &m.Config) + if err != nil { + return err + } + + if _, err = os.Stat(dest); err != nil { + if os.IsNotExist(err) { + if err2 := os.MkdirAll(dest, 0755); err2 != nil { + return err2 + } + defer func() { + if retErr != nil { + if err3 := os.RemoveAll(dest); err3 != nil { + fmt.Printf("Failed to clean up %q: %s\n", dest, err3.Error()) + } + } + }() + } else { + return err + } + } + + if err = unpackManifest(m, w, filepath.Join(dest, rootfs)); err != nil { + return err + } + + spec, err := runtimeSpec(c, rootfs) + if err != nil { + return err + } + + f, err := os.Create(filepath.Join(dest, "config.json")) + if err != nil { + return err + } + defer f.Close() + + return json.NewEncoder(f).Encode(spec) +} + +// filertManifest returns a filtered list of manifests +func filterManifest(w walker, Manifests []v1.Descriptor, platform string) ([]*v1.Manifest, error) { + var manifests []*v1.Manifest + + argsParts := strings.Split(platform, ":") + if len(argsParts) != 2 { + return manifests, fmt.Errorf("platform must have os and arch when reftype is index") + } + + if len(Manifests) == 0 { + fmt.Println("warning: no manifests found") + return manifests, nil + } + + for _, manifest := range Manifests { + m, err := findManifest(w, &manifest) + if err != nil { + return manifests, err + } + + if err := validateManifest(m, w); err != nil { + return manifests, err + } + if strings.EqualFold(manifest.Platform.OS, argsParts[0]) && strings.EqualFold(manifest.Platform.Architecture, argsParts[1]) { + manifests = append(manifests, m) + } + } + + if len(manifests) == 0 { + return manifests, fmt.Errorf("There is no matching manifest") + } + + return manifests, nil +} diff --git a/vendor/github.com/opencontainers/image-tools/image/index.go b/vendor/github.com/opencontainers/image-tools/image/index.go new file mode 100644 index 0000000000..f0c8d61fc6 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/index.go @@ -0,0 +1,71 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + + "github.com/opencontainers/image-spec/schema" + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" +) + +func findIndex(w walker, d *v1.Descriptor) (*v1.Index, error) { + var index v1.Index + ipath := filepath.Join("blobs", string(d.Digest.Algorithm()), d.Digest.Hex()) + + switch err := w.walk(func(path string, info os.FileInfo, r io.Reader) error { + if info.IsDir() || filepath.Clean(path) != ipath { + return nil + } + + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "%s: error reading index", path) + } + + if err := schema.ValidatorMediaTypeImageIndex.Validate(bytes.NewReader(buf)); err != nil { + return errors.Wrapf(err, "%s: index validation failed", path) + } + + if err := json.Unmarshal(buf, &index); err != nil { + return err + } + + return errEOW + }); err { + case errEOW: + return &index, nil + case nil: + return nil, fmt.Errorf("index not found") + default: + return nil, err + } +} + +func validateIndex(index *v1.Index, w walker) error { + for _, manifest := range index.Manifests { + if err := validateDescriptor(&manifest, w, []string{v1.MediaTypeImageManifest}); err != nil { + return errors.Wrap(err, "manifest validation failed") + } + } + return nil +} diff --git a/vendor/github.com/opencontainers/image-tools/image/layout.go b/vendor/github.com/opencontainers/image-tools/image/layout.go new file mode 100644 index 0000000000..352b1b95f7 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/layout.go @@ -0,0 +1,104 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + + "github.com/opencontainers/image-spec/schema" + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" +) + +func layoutValidate(w walker) error { + var blobsExist, indexExist, layoutExist bool + + if err := w.walk(func(path string, info os.FileInfo, r io.Reader) error { + if strings.EqualFold(filepath.Base(path), "blobs") { + blobsExist = true + if !info.IsDir() { + return fmt.Errorf("blobs is not a directory") + } + + return nil + } + + if strings.EqualFold(filepath.Base(path), "index.json") { + indexExist = true + if info.IsDir() { + return fmt.Errorf("index.json is a directory") + } + + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrap(err, "error reading index.json") + } + + if err := schema.ValidatorMediaTypeImageIndex.Validate(bytes.NewReader(buf)); err != nil { + return errors.Wrap(err, "index.json validation failed") + } + + return nil + } + + if strings.EqualFold(filepath.Base(path), "oci-layout") { + layoutExist = true + if info.IsDir() { + return fmt.Errorf("oci-layout is a directory") + } + + var imageLayout v1.ImageLayout + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrap(err, "error reading oci-layout") + } + + if err := schema.ValidatorMediaTypeLayoutHeader.Validate(bytes.NewReader(buf)); err != nil { + return errors.Wrap(err, "oci-layout validation failed") + } + + if err := json.Unmarshal(buf, &imageLayout); err != nil { + return errors.Wrap(err, "oci-layout format mismatch") + } + + return nil + } + + return nil + }); err != nil { + return err + } + + if !blobsExist { + return fmt.Errorf("image layout must contain blobs directory") + } + + if !indexExist { + return fmt.Errorf("image layout must contain index.json file") + } + + if !layoutExist { + return fmt.Errorf("image layout must contain oci-layout file") + } + + return nil +} diff --git a/vendor/github.com/opencontainers/image-tools/image/manifest.go b/vendor/github.com/opencontainers/image-tools/image/manifest.go new file mode 100644 index 0000000000..9400121ae9 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/manifest.go @@ -0,0 +1,342 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Modifications by: Sylabs Inc. +// Add u+w if we aren't root to allow extraction +// + +package image + +import ( + "archive/tar" + "bufio" + "bytes" + "compress/bzip2" + "compress/gzip" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" + + "github.com/opencontainers/image-spec/schema" + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" +) + +func findManifest(w walker, d *v1.Descriptor) (*v1.Manifest, error) { + var m v1.Manifest + mpath := filepath.Join("blobs", string(d.Digest.Algorithm()), d.Digest.Hex()) + + switch err := w.find(mpath, func(path string, r io.Reader) error { + buf, err := ioutil.ReadAll(r) + if err != nil { + return errors.Wrapf(err, "%s: error reading manifest", path) + } + + if err := schema.ValidatorMediaTypeManifest.Validate(bytes.NewReader(buf)); err != nil { + return errors.Wrapf(err, "%s: manifest validation failed", path) + } + + if err := json.Unmarshal(buf, &m); err != nil { + return err + } + + return errEOW + }); err { + case nil: + return nil, fmt.Errorf("%s: manifest not found", mpath) + case errEOW: + return &m, nil + default: + return nil, err + } +} + +func validateManifest(m *v1.Manifest, w walker) error { + if err := validateDescriptor(&m.Config, w, []string{v1.MediaTypeImageConfig}); err != nil { + return errors.Wrap(err, "config validation failed") + } + + validLayerMediaTypes := []string{ + v1.MediaTypeImageLayer, + v1.MediaTypeImageLayerGzip, + v1.MediaTypeImageLayerNonDistributable, + v1.MediaTypeImageLayerNonDistributableGzip, + } + + for _, d := range m.Layers { + if err := validateDescriptor(&d, w, validLayerMediaTypes); err != nil { + return errors.Wrap(err, "layer validation failed") + } + } + + return nil +} + +func unpackManifest(m *v1.Manifest, w walker, dest string) (retErr error) { + // error out if the dest directory is not empty + s, err := ioutil.ReadDir(dest) + if err != nil && !os.IsNotExist(err) { // We'll create the dir later + return errors.Wrap(err, "unpack: unable to open dest") // err contains dest + } + if len(s) > 0 { + return fmt.Errorf("%s is not empty", dest) + } + defer func() { + // if we encounter error during unpacking + // clean up the partially-unpacked destination + if retErr != nil { + if err := os.RemoveAll(dest); err != nil { + fmt.Printf("Error: failed to remove partially-unpacked destination %v", err) + } + } + }() + for _, d := range m.Layers { + lpath := filepath.Join("blobs", string(d.Digest.Algorithm()), d.Digest.Hex()) + switch err := w.find(lpath, func(path string, r io.Reader) error { + if err := unpackLayer(d.MediaType, path, dest, r); err != nil { + return errors.Wrap(err, "unpack: error extracting layer") + } + + return errEOW + }); err { + case nil: + return fmt.Errorf("%s: layer not found", dest) + case errEOW: + default: + return err + } + } + return nil +} + +func getReader(path, mediaType, comp string, buf io.Reader) (io.Reader, error) { + switch comp { + case "gzip": + if !strings.HasSuffix(mediaType, "+gzip") { + logrus.Debugf("%q: %s media type with non-%s file", path, comp, comp) + } + + return gzip.NewReader(buf) + case "bzip2": + if !strings.HasSuffix(mediaType, "+bzip2") { + logrus.Debugf("%q: %s media type with non-%s file", path, comp, comp) + } + + return bzip2.NewReader(buf), nil + case "xz": + return nil, errors.New("xz layers are not supported") + default: + if strings.Contains(mediaType, "+") { + logrus.Debugf("%q: %s media type with non-%s file", path, comp, comp) + } + + return buf, nil + } +} + +// DetectCompression detects the compression algorithm of the source. +func DetectCompression(r *bufio.Reader) (string, error) { + source, err := r.Peek(10) + if err != nil { + return "", err + } + + for compression, m := range map[string][]byte{ + "bzip2": {0x42, 0x5A, 0x68}, + "gzip": {0x1F, 0x8B, 0x08}, + // FIXME needs decompression support + // "xz": {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}, + } { + if len(source) < len(m) { + logrus.Debug("Len too short") + continue + } + if bytes.Equal(m, source[:len(m)]) { + return compression, nil + } + } + return "plain", nil +} + +func unpackLayer(mediaType, path, dest string, r io.Reader) error { + entries := make(map[string]bool) + + buf := bufio.NewReader(r) + + comp, err := DetectCompression(buf) + if err != nil { + return err + } + + reader, err := getReader(path, mediaType, comp, buf) + if err != nil { + return err + } + + var dirs []*tar.Header + tr := tar.NewReader(reader) + +loop: + for { + hdr, err := tr.Next() + switch err { + case io.EOF: + break loop + case nil: + // success, continue below + default: + return errors.Wrapf(err, "error advancing tar stream") + } + + var whiteout bool + whiteout, err = unpackLayerEntry(dest, hdr, tr, &entries) + if err != nil { + return err + } + if whiteout { + continue loop + } + + // Directory mtimes must be handled at the end to avoid further + // file creation in them to modify the directory mtime + if hdr.Typeflag == tar.TypeDir { + dirs = append(dirs, hdr) + } + } + for _, hdr := range dirs { + path := filepath.Join(dest, hdr.Name) + + finfo := hdr.FileInfo() + // I believe the old version was using time.Now().UTC() to overcome an + // invalid error from chtimes.....but here we lose hdr.AccessTime like this... + if err := os.Chtimes(path, time.Now().UTC(), finfo.ModTime()); err != nil { + return errors.Wrap(err, "error changing time") + } + } + return nil +} + +// unpackLayerEntry unpacks a single entry from a layer. +func unpackLayerEntry(dest string, header *tar.Header, reader io.Reader, entries *map[string]bool) (whiteout bool, err error) { + header.Name = filepath.Clean(header.Name) + if !strings.HasSuffix(header.Name, string(os.PathSeparator)) { + // Not the root directory, ensure that the parent directory exists + parent := filepath.Dir(header.Name) + parentPath := filepath.Join(dest, parent) + if _, err2 := os.Lstat(parentPath); err2 != nil && os.IsNotExist(err2) { + if err3 := os.MkdirAll(parentPath, 0755); err3 != nil { + return false, err3 + } + } + } + path := filepath.Join(dest, header.Name) + if (*entries)[path] { + return false, fmt.Errorf("duplicate entry for %s", path) + } + (*entries)[path] = true + rel, err := filepath.Rel(dest, path) + if err != nil { + return false, err + } + info := header.FileInfo() + if strings.HasPrefix(rel, ".."+string(os.PathSeparator)) { + return false, fmt.Errorf("%q is outside of %q", header.Name, dest) + } + + if strings.HasPrefix(info.Name(), ".wh.") { + path = strings.Replace(path, ".wh.", "", 1) + + if err = os.RemoveAll(path); err != nil { + return true, errors.Wrap(err, "unable to delete whiteout path") + } + + return true, nil + } + + if header.Typeflag != tar.TypeDir { + err = os.RemoveAll(path) + if err != nil && !os.IsNotExist(err) { + return false, err + } + } + + // SINGULARITY_PATCH + // Add u+w if we aren't root to allow extractions + extraPerms := os.FileMode(0000) + if os.Getuid() != 0 { + extraPerms = 0600 + } + + switch header.Typeflag { + case tar.TypeDir: + fi, err := os.Lstat(path) + if err != nil && !os.IsNotExist(err) { + return false, err + } + if os.IsNotExist(err) || !fi.IsDir() { + err = os.RemoveAll(path) + if err != nil && !os.IsNotExist(err) { + return false, err + } + err = os.MkdirAll(path, info.Mode()|extraPerms) + if err != nil { + return false, err + } + } + + case tar.TypeReg, tar.TypeRegA: + f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, info.Mode()|extraPerms) + if err != nil { + return false, errors.Wrap(err, "unable to open file") + } + + if _, err := io.Copy(f, reader); err != nil { + f.Close() + return false, errors.Wrap(err, "unable to copy") + } + f.Close() + + case tar.TypeLink: + target := filepath.Join(dest, header.Linkname) + + if !strings.HasPrefix(target, dest) { + return false, fmt.Errorf("invalid hardlink %q -> %q", target, header.Linkname) + } + + if err := os.Link(target, path); err != nil { + return false, err + } + + case tar.TypeSymlink: + target := filepath.Join(filepath.Dir(path), header.Linkname) + + if !strings.HasPrefix(target, dest) { + return false, fmt.Errorf("invalid symlink %q -> %q", path, header.Linkname) + } + + if err := os.Symlink(header.Linkname, path); err != nil { + return false, err + } + case tar.TypeXGlobalHeader: + return false, nil + } + + return false, nil +} diff --git a/vendor/github.com/opencontainers/image-tools/image/project.go b/vendor/github.com/opencontainers/image-tools/image/project.go new file mode 100644 index 0000000000..b87186f795 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/project.go @@ -0,0 +1,21 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +// SpecURL is the URL for the image-spec repository +var SpecURL = "https://github.com/opencontainers/image-spec" + +// IssuesURL is the URL for the issues of image-tools +var IssuesURL = "https://github.com/opencontainers/image-tools/issues" diff --git a/vendor/github.com/opencontainers/image-tools/image/walker.go b/vendor/github.com/opencontainers/image-tools/image/walker.go new file mode 100644 index 0000000000..88b01df838 --- /dev/null +++ b/vendor/github.com/opencontainers/image-tools/image/walker.go @@ -0,0 +1,333 @@ +// Copyright 2016 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package image + +import ( + "archive/tar" + "archive/zip" + "fmt" + "io" + "os" + "path/filepath" + "sync" + + "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" +) + +var ( + errEOW = fmt.Errorf("end of walk") // error to signal stop walking +) + +// walkFunc is a function type that gets called for each file or directory visited by the Walker. +type walkFunc func(path string, _ os.FileInfo, _ io.Reader) error + +type findFunc func(path string, r io.Reader) error + +// walker is the interface that defines how to access a given archival format +type walker interface { + + // walk calls walkfunc for every entity in the archive + walk(walkFunc) error + + // get will copy an arbitrary blob, defined by desc, in to dst. returns + // the number of bytes copied on success. + get(desc v1.Descriptor, dst io.Writer) (int64, error) + + // find calls findFunc for handling content of path + find(path string, ff findFunc) error +} + +// tarWalker exposes access to image layouts in a tar file. +type tarWalker struct { + r io.ReadSeeker + + // Synchronize use of the reader + mut sync.Mutex +} + +// newTarWalker returns a Walker that walks through .tar files. +func newTarWalker(r io.ReadSeeker) walker { + return &tarWalker{r: r} +} + +func (w *tarWalker) walk(f walkFunc) error { + w.mut.Lock() + defer w.mut.Unlock() + + if _, err := w.r.Seek(0, io.SeekStart); err != nil { + return errors.Wrapf(err, "unable to reset") + } + + tr := tar.NewReader(w.r) + +loop: + for { + hdr, err := tr.Next() + switch err { + case io.EOF: + break loop + case nil: + // success, continue below + default: + return errors.Wrapf(err, "error advancing tar stream") + } + + info := hdr.FileInfo() + if err := f(hdr.Name, info, tr); err != nil { + return err + } + } + + return nil +} + +func (w *tarWalker) get(desc v1.Descriptor, dst io.Writer) (int64, error) { + var bytes int64 + done := false + + expectedPath := filepath.Join("blobs", string(desc.Digest.Algorithm()), desc.Digest.Hex()) + + f := func(path string, info os.FileInfo, rdr io.Reader) error { + var err error + if done { + return nil + } + + if filepath.Clean(path) == expectedPath && !info.IsDir() { + if bytes, err = io.Copy(dst, rdr); err != nil { + return errors.Wrapf(err, "get failed: failed to copy blob to destination") + } + done = true + } + return nil + } + + if err := w.walk(f); err != nil { + return 0, errors.Wrapf(err, "get failed: unable to walk") + } + if !done { + return 0, os.ErrNotExist + } + + return bytes, nil +} + +func (w *tarWalker) find(path string, ff findFunc) error { + done := false + + f := func(relpath string, info os.FileInfo, rdr io.Reader) error { + var err error + if done { + return nil + } + + if filepath.Clean(relpath) == path && !info.IsDir() { + if err = ff(relpath, rdr); err != nil { + return err + } + done = true + } + return nil + } + + if err := w.walk(f); err != nil { + return errors.Wrapf(err, "find failed: unable to walk") + } + if !done { + return os.ErrNotExist + } + + return nil +} + +type eofReader struct{} + +func (eofReader) Read(_ []byte) (int, error) { + return 0, io.EOF +} + +type pathWalker struct { + root string +} + +// newPathWalker returns a Walker that walks through directories +// starting at the given root path. It does not follow symlinks. +func newPathWalker(root string) walker { + return &pathWalker{root} +} + +func (w *pathWalker) walk(f walkFunc) error { + return filepath.Walk(w.root, func(path string, info os.FileInfo, err error) error { + // MUST check error value, to make sure the `os.FileInfo` is available. + // Otherwise panic risk will exist. + if err != nil { + return errors.Wrap(err, "error walking path") + } + + rel, err := filepath.Rel(w.root, path) + if err != nil { + return errors.Wrap(err, "error walking path") // err from filepath.Walk includes path name + } + + if info.IsDir() { // behave like a tar reader for directories + return f(rel, info, eofReader{}) + } + + file, err := os.Open(path) + if err != nil { + return errors.Wrap(err, "unable to open file") // os.Open includes the path + } + defer file.Close() + + return f(rel, info, file) + }) +} + +func (w *pathWalker) get(desc v1.Descriptor, dst io.Writer) (int64, error) { + name := filepath.Join(w.root, "blobs", string(desc.Digest.Algorithm()), desc.Digest.Hex()) + + info, err := os.Stat(name) + if err != nil { + return 0, err + } + + if info.IsDir() { + return 0, fmt.Errorf("object is dir") + } + + fp, err := os.Open(name) + if err != nil { + return 0, errors.Wrapf(err, "get failed") + } + defer fp.Close() + + nbytes, err := io.Copy(dst, fp) + if err != nil { + return 0, errors.Wrapf(err, "get failed: failed to copy blob to destination") + } + return nbytes, nil +} + +func (w *pathWalker) find(path string, ff findFunc) error { + name := filepath.Join(w.root, path) + + info, err := os.Stat(name) + if err != nil { + return err + } + + if info.IsDir() { + return fmt.Errorf("object is dir") + } + + file, err := os.Open(name) + if err != nil { + return errors.Wrap(err, "unable to open file") // os.Open includes the path + } + defer file.Close() + + return ff(name, file) +} + +type zipWalker struct { + fileName string +} + +// newWalkWalker returns a Walker that walks through .zip files. +func newZipWalker(fileName string) walker { + return &zipWalker{fileName} +} + +func (w *zipWalker) walk(f walkFunc) error { + r, err := zip.OpenReader(w.fileName) + if err != nil { + return err + } + defer r.Close() + + for _, file := range r.File { + rc, err := file.Open() + if err != nil { + return err + } + defer rc.Close() + info := file.FileInfo() + if err := f(file.Name, info, rc); err != nil { + return err + } + } + + return nil +} + +func (w *zipWalker) get(desc v1.Descriptor, dst io.Writer) (int64, error) { + var bytes int64 + done := false + + expectedPath := filepath.Join("blobs", string(desc.Digest.Algorithm()), desc.Digest.Hex()) + + f := func(path string, info os.FileInfo, rdr io.Reader) error { + var err error + if done { + return nil + } + + if path == expectedPath && !info.IsDir() { + if bytes, err = io.Copy(dst, rdr); err != nil { + return errors.Wrapf(err, "get failed: failed to copy blob to destination") + } + done = true + } + return nil + } + + if err := w.walk(f); err != nil { + return 0, errors.Wrapf(err, "get failed: unable to walk") + } + if !done { + return 0, os.ErrNotExist + } + + return bytes, nil +} + +func (w *zipWalker) find(path string, ff findFunc) error { + done := false + + f := func(relpath string, info os.FileInfo, rdr io.Reader) error { + var err error + if done { + return nil + } + + if filepath.Clean(relpath) == path && !info.IsDir() { + if err = ff(relpath, rdr); err != nil { + return err + } + done = true + } + return nil + } + + if err := w.walk(f); err != nil { + return errors.Wrapf(err, "find failed: unable to walk") + } + if !done { + return os.ErrNotExist + } + + return nil +} diff --git a/vendor/github.com/sirupsen/logrus/.travis.yml b/vendor/github.com/sirupsen/logrus/.travis.yml index 2f19b4a757..a23296a53b 100644 --- a/vendor/github.com/sirupsen/logrus/.travis.yml +++ b/vendor/github.com/sirupsen/logrus/.travis.yml @@ -1,7 +1,9 @@ language: go go: - - 1.9.x - - 1.10.x + - 1.6.x + - 1.7.x + - 1.8.x + - tip env: - GOMAXPROCS=4 GORACE=halt_on_error=1 install: diff --git a/vendor/github.com/sirupsen/logrus/README.md b/vendor/github.com/sirupsen/logrus/README.md index 072e99be31..f77819b168 100644 --- a/vendor/github.com/sirupsen/logrus/README.md +++ b/vendor/github.com/sirupsen/logrus/README.md @@ -241,8 +241,60 @@ func init() { ``` Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md). -A list of currently known of service hook can be found in this wiki [page](https://github.com/sirupsen/logrus/wiki/Hooks) - +| Hook | Description | +| ----- | ----------- | +| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. | +| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. | +| [Amazon Kinesis](https://github.com/evalphobia/logrus_kinesis) | Hook for logging to [Amazon Kinesis](https://aws.amazon.com/kinesis/) | +| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) | +| [Application Insights](https://github.com/jjcollinge/logrus-appinsights) | Hook for logging to [Application Insights](https://azure.microsoft.com/en-us/services/application-insights/) +| [AzureTableHook](https://github.com/kpfaulkner/azuretablehook/) | Hook for logging to Azure Table Storage| +| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | +| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | +| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) | +| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch| +| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/) +| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | +| [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) | +| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | +| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | +| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | +| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | +| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) | +| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | +| [KafkaLogrus](https://github.com/tracer0tong/kafkalogrus) | Hook for logging to Kafka | +| [Kafka REST Proxy](https://github.com/Nordstrom/logrus-kafka-rest-proxy) | Hook for logging to [Kafka REST Proxy](https://docs.confluent.io/current/kafka-rest/docs) | +| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | +| [Logbeat](https://github.com/macandmia/logbeat) | Hook for logging to [Opbeat](https://opbeat.com/) | +| [Logentries](https://github.com/jcftang/logentriesrus) | Hook for logging to [Logentries](https://logentries.com/) | +| [Logentrus](https://github.com/puddingfactory/logentrus) | Hook for logging to [Logentries](https://logentries.com/) | +| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) | +| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | +| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) | +| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | +| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) | +| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | +| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) | +| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | +| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. | +| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) | +| [Promrus](https://github.com/weaveworks/promrus) | Expose number of log messages as [Prometheus](https://prometheus.io/) metrics | +| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) | +| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) | +| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) | +| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar | +| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)| +| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. | +| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | +| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) | +| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| +| [Syslog](https://github.com/sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | +| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. | +| [Telegram](https://github.com/rossmcdonald/telegram_hook) | Hook for logging errors to [Telegram](https://telegram.org/) | +| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) | +| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | +| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash | +| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) | #### Level logging @@ -320,8 +372,6 @@ The built-in logging formatters are: field to `true`. To force no colored output even if there is a TTY set the `DisableColors` field to `true`. For Windows, see [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable). - * When colors are enabled, levels are truncated to 4 characters by default. To disable - truncation set the `DisableLevelTruncation` field to `true`. * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter). * `logrus.JSONFormatter`. Logs fields as JSON. * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter). @@ -445,7 +495,7 @@ logrus.RegisterExitHandler(handler) #### Thread safety -By default, Logger is protected by a mutex for concurrent writes. The mutex is held when calling hooks and writing logs. +By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs. If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking. Situation when locking is not needed includes: diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go index 473bd1a0d3..778f4c9f0d 100644 --- a/vendor/github.com/sirupsen/logrus/entry.go +++ b/vendor/github.com/sirupsen/logrus/entry.go @@ -48,7 +48,7 @@ type Entry struct { func NewEntry(logger *Logger) *Entry { return &Entry{ Logger: logger, - // Default is five fields, give a little extra room + // Default is three fields, give a little extra room Data: make(Fields, 5), } } @@ -83,28 +83,14 @@ func (entry *Entry) WithFields(fields Fields) *Entry { for k, v := range fields { data[k] = v } - return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time} -} - -// Overrides the time of the Entry. -func (entry *Entry) WithTime(t time.Time) *Entry { - return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t} + return &Entry{Logger: entry.Logger, Data: data} } // This function is not declared with a pointer value because otherwise // race conditions will occur when using multiple goroutines func (entry Entry) log(level Level, msg string) { var buffer *bytes.Buffer - - // Default to now, but allow users to override if they want. - // - // We don't have to worry about polluting future calls to Entry#log() - // with this assignment because this function is declared with a - // non-pointer receiver. - if entry.Time.IsZero() { - entry.Time = time.Now() - } - + entry.Time = time.Now() entry.Level = level entry.Message = msg @@ -127,10 +113,12 @@ func (entry Entry) log(level Level, msg string) { } } -func (entry *Entry) fireHooks() { +// This function is not declared with a pointer value because otherwise +// race conditions will occur when using multiple goroutines +func (entry Entry) fireHooks() { entry.Logger.mu.Lock() defer entry.Logger.mu.Unlock() - err := entry.Logger.Hooks.Fire(entry.Level, entry) + err := entry.Logger.Hooks.Fire(entry.Level, &entry) if err != nil { fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) } diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go index eb612a6f3e..013183edab 100644 --- a/vendor/github.com/sirupsen/logrus/exported.go +++ b/vendor/github.com/sirupsen/logrus/exported.go @@ -2,7 +2,6 @@ package logrus import ( "io" - "time" ) var ( @@ -16,7 +15,9 @@ func StandardLogger() *Logger { // SetOutput sets the standard logger output. func SetOutput(out io.Writer) { - std.SetOutput(out) + std.mu.Lock() + defer std.mu.Unlock() + std.Out = out } // SetFormatter sets the standard logger formatter. @@ -71,15 +72,6 @@ func WithFields(fields Fields) *Entry { return std.WithFields(fields) } -// WithTime creats an entry from the standard logger and overrides the time of -// logs generated with it. -// -// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal -// or Panic on the Entry it returns. -func WithTime(t time.Time) *Entry { - return std.WithTime(t) -} - // Debug logs a message at level Debug on the standard logger. func Debug(args ...interface{}) { std.Debug(args...) @@ -115,7 +107,7 @@ func Panic(args ...interface{}) { std.Panic(args...) } -// Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1. +// Fatal logs a message at level Fatal on the standard logger. func Fatal(args ...interface{}) { std.Fatal(args...) } @@ -155,7 +147,7 @@ func Panicf(format string, args ...interface{}) { std.Panicf(format, args...) } -// Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1. +// Fatalf logs a message at level Fatal on the standard logger. func Fatalf(format string, args ...interface{}) { std.Fatalf(format, args...) } @@ -195,7 +187,7 @@ func Panicln(args ...interface{}) { std.Panicln(args...) } -// Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1. +// Fatalln logs a message at level Fatal on the standard logger. func Fatalln(args ...interface{}) { std.Fatalln(args...) } diff --git a/vendor/github.com/sirupsen/logrus/formatter.go b/vendor/github.com/sirupsen/logrus/formatter.go index 83c74947be..b183ff5b1d 100644 --- a/vendor/github.com/sirupsen/logrus/formatter.go +++ b/vendor/github.com/sirupsen/logrus/formatter.go @@ -30,22 +30,16 @@ type Formatter interface { // // It's not exported because it's still using Data in an opinionated way. It's to // avoid code duplication between the two default formatters. -func prefixFieldClashes(data Fields, fieldMap FieldMap) { - timeKey := fieldMap.resolve(FieldKeyTime) - if t, ok := data[timeKey]; ok { - data["fields."+timeKey] = t - delete(data, timeKey) +func prefixFieldClashes(data Fields) { + if t, ok := data["time"]; ok { + data["fields.time"] = t } - msgKey := fieldMap.resolve(FieldKeyMsg) - if m, ok := data[msgKey]; ok { - data["fields."+msgKey] = m - delete(data, msgKey) + if m, ok := data["msg"]; ok { + data["fields.msg"] = m } - levelKey := fieldMap.resolve(FieldKeyLevel) - if l, ok := data[levelKey]; ok { - data["fields."+levelKey] = l - delete(data, levelKey) + if l, ok := data["level"]; ok { + data["fields.level"] = l } } diff --git a/vendor/github.com/sirupsen/logrus/json_formatter.go b/vendor/github.com/sirupsen/logrus/json_formatter.go index dab17610f1..fb01c1b104 100644 --- a/vendor/github.com/sirupsen/logrus/json_formatter.go +++ b/vendor/github.com/sirupsen/logrus/json_formatter.go @@ -33,9 +33,6 @@ type JSONFormatter struct { // DisableTimestamp allows disabling automatic timestamps in output DisableTimestamp bool - // DataKey allows users to put all the log entry parameters into a nested dictionary at a given key. - DataKey string - // FieldMap allows users to customize the names of keys for default fields. // As an example: // formatter := &JSONFormatter{ @@ -61,14 +58,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data[k] = v } } - - if f.DataKey != "" { - newData := make(Fields, 4) - newData[f.DataKey] = data - data = newData - } - - prefixFieldClashes(data, f.FieldMap) + prefixFieldClashes(data) timestampFormat := f.TimestampFormat if timestampFormat == "" { diff --git a/vendor/github.com/sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go index 342f7977d8..fdaf8a6534 100644 --- a/vendor/github.com/sirupsen/logrus/logger.go +++ b/vendor/github.com/sirupsen/logrus/logger.go @@ -5,7 +5,6 @@ import ( "os" "sync" "sync/atomic" - "time" ) type Logger struct { @@ -89,7 +88,7 @@ func (logger *Logger) releaseEntry(entry *Entry) { } // Adds a field to the log entry, note that it doesn't log until you call -// Debug, Print, Info, Warn, Error, Fatal or Panic. It only creates a log entry. +// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. // If you want multiple fields, use `WithFields`. func (logger *Logger) WithField(key string, value interface{}) *Entry { entry := logger.newEntry() @@ -113,13 +112,6 @@ func (logger *Logger) WithError(err error) *Entry { return entry.WithError(err) } -// Overrides the time of the log entry. -func (logger *Logger) WithTime(t time.Time) *Entry { - entry := logger.newEntry() - defer logger.releaseEntry(entry) - return entry.WithTime(t) -} - func (logger *Logger) Debugf(format string, args ...interface{}) { if logger.level() >= DebugLevel { entry := logger.newEntry() @@ -324,12 +316,6 @@ func (logger *Logger) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) } -func (logger *Logger) SetOutput(out io.Writer) { - logger.mu.Lock() - defer logger.mu.Unlock() - logger.Out = out -} - func (logger *Logger) AddHook(hook Hook) { logger.mu.Lock() defer logger.mu.Unlock() diff --git a/vendor/github.com/sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go index 3e55040304..61b21caea4 100644 --- a/vendor/github.com/sirupsen/logrus/text_formatter.go +++ b/vendor/github.com/sirupsen/logrus/text_formatter.go @@ -20,7 +20,6 @@ const ( var ( baseTimestamp time.Time - emptyFieldMap FieldMap ) func init() { @@ -51,24 +50,12 @@ type TextFormatter struct { // be desired. DisableSorting bool - // Disables the truncation of the level text to 4 characters. - DisableLevelTruncation bool - // QuoteEmptyFields will wrap empty fields in quotes if true QuoteEmptyFields bool // Whether the logger's out is to a terminal isTerminal bool - // FieldMap allows users to customize the names of keys for default fields. - // As an example: - // formatter := &TextFormatter{ - // FieldMap: FieldMap{ - // FieldKeyTime: "@timestamp", - // FieldKeyLevel: "@level", - // FieldKeyMsg: "@message"}} - FieldMap FieldMap - sync.Once } @@ -80,8 +67,7 @@ func (f *TextFormatter) init(entry *Entry) { // Format renders a single log entry func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { - prefixFieldClashes(entry.Data, f.FieldMap) - + var b *bytes.Buffer keys := make([]string, 0, len(entry.Data)) for k := range entry.Data { keys = append(keys, k) @@ -90,14 +76,14 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { if !f.DisableSorting { sort.Strings(keys) } - - var b *bytes.Buffer if entry.Buffer != nil { b = entry.Buffer } else { b = &bytes.Buffer{} } + prefixFieldClashes(entry.Data) + f.Do(func() { f.init(entry) }) isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors @@ -110,11 +96,11 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { f.printColored(b, entry, keys, timestampFormat) } else { if !f.DisableTimestamp { - f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyTime), entry.Time.Format(timestampFormat)) + f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) } - f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyLevel), entry.Level.String()) + f.appendKeyValue(b, "level", entry.Level.String()) if entry.Message != "" { - f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyMsg), entry.Message) + f.appendKeyValue(b, "msg", entry.Message) } for _, key := range keys { f.appendKeyValue(b, key, entry.Data[key]) @@ -138,10 +124,7 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin levelColor = blue } - levelText := strings.ToUpper(entry.Level.String()) - if !f.DisableLevelTruncation { - levelText = levelText[0:4] - } + levelText := strings.ToUpper(entry.Level.String())[0:4] if f.DisableTimestamp { fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message) diff --git a/vendor/github.com/urfave/cli/.travis.yml b/vendor/github.com/urfave/cli/.travis.yml index cf8d0980dc..8bb0e9cb55 100644 --- a/vendor/github.com/urfave/cli/.travis.yml +++ b/vendor/github.com/urfave/cli/.travis.yml @@ -2,7 +2,7 @@ language: go sudo: false dist: trusty osx_image: xcode8.3 -go: 1.8.x +go: 1.11.x os: - linux diff --git a/vendor/github.com/urfave/cli/CHANGELOG.md b/vendor/github.com/urfave/cli/CHANGELOG.md index 401eae5a2c..1e49d54775 100644 --- a/vendor/github.com/urfave/cli/CHANGELOG.md +++ b/vendor/github.com/urfave/cli/CHANGELOG.md @@ -4,7 +4,28 @@ ## [Unreleased] -## 1.20.0 - 2017-08-10 +## [1.21.0] - 2019-08-02 + +### Fixed + +* Fix using "slice" flag types with `EnvVar` in [urfave/cli/pull/687](https://github.com/urfave/cli/pull/687) via [@joshuarubin](https://github.com/joshuarubin) +* Fix regression of `SkipFlagParsing` behavior in [urfave/cli/pull/697](https://github.com/urfave/cli/pull/697) via [@jszwedko](https://github.com/jszwedko) +* Fix handling `ShortOptions` and `SkipArgReorder` in [urfave/cli/pull/686](https://github.com/urfave/cli/pull/686) via [@baude](https://github.com/baude) +* Fix args reordering when bool flags are present in [urfave/cli/pull/712](https://github.com/urfave/cli/pull/712) via [@windler](https://github.com/windler) +* Fix parsing of short options in [urfave/cli/pull/758](https://github.com/urfave/cli/pull/758) via [@vrothberg](https://github.com/vrothberg) + +### Added / Changed + +* Added _"required flags"_ support in [urfave/cli/pull/819](https://github.com/urfave/cli/pull/819) via [@lynncyrin](https://github.com/lynncyrin/) +* Cleaned up help output in [urfave/cli/pull/664](https://github.com/urfave/cli/pull/664) via [@maguro](https://github.com/maguro) +* Case is now considered when sorting strings in [urfave/cli/pull/676](https://github.com/urfave/cli/pull/676) via [@rliebz](https://github.com/rliebz) +* Backport JSON `InputSource` to v1 in [urfave/cli/pull/598](https://github.com/urfave/cli/pull/598) via [@jszwedko](https://github.com/jszwedko) +* Allow more customization of flag help strings in [urfave/cli/pull/661](https://github.com/urfave/cli/pull/661) via [@rliebz](https://github.com/rliebz) +* Allow custom `ExitError` handler function in [urfave/cli/pull/628](https://github.com/urfave/cli/pull/628) via [@phinnaeus](https://github.com/phinnaeus) +* Allow loading a variable from a file in [urfave/cli/pull/675](https://github.com/urfave/cli/pull/675) via [@jmccann](https://github.com/jmccann) +* Allow combining short bool names in [urfave/cli/pull/684](https://github.com/urfave/cli/pull/684) via [@baude](https://github.com/baude) + +## [1.20.0] - 2017-08-10 ### Fixed @@ -407,7 +428,11 @@ signature of `func(*cli.Context) error`, as defined by `cli.ActionFunc`. ### Added - Initial implementation. -[Unreleased]: https://github.com/urfave/cli/compare/v1.18.0...HEAD +[Unreleased]: https://github.com/urfave/cli/compare/v1.21.0...HEAD +[1.21.0]: https://github.com/urfave/cli/compare/v1.20.0...v1.21.0 +[1.20.0]: https://github.com/urfave/cli/compare/v1.19.1...v1.20.0 +[1.19.1]: https://github.com/urfave/cli/compare/v1.19.0...v1.19.1 +[1.19.0]: https://github.com/urfave/cli/compare/v1.18.0...v1.19.0 [1.18.0]: https://github.com/urfave/cli/compare/v1.17.0...v1.18.0 [1.17.0]: https://github.com/urfave/cli/compare/v1.16.0...v1.17.0 [1.16.0]: https://github.com/urfave/cli/compare/v1.15.0...v1.16.0 diff --git a/vendor/github.com/urfave/cli/CODE_OF_CONDUCT.md b/vendor/github.com/urfave/cli/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..41ba294f6d --- /dev/null +++ b/vendor/github.com/urfave/cli/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting Dan Buch at dan@meatballhat.com. All complaints will be +reviewed and investigated and will result in a response that is deemed necessary +and appropriate to the circumstances. The project team is obligated to maintain +confidentiality with regard to the reporter of an incident. Further details of +specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + diff --git a/vendor/github.com/urfave/cli/CONTRIBUTING.md b/vendor/github.com/urfave/cli/CONTRIBUTING.md new file mode 100644 index 0000000000..329195eeec --- /dev/null +++ b/vendor/github.com/urfave/cli/CONTRIBUTING.md @@ -0,0 +1,19 @@ +## Contributing + +**NOTE**: the primary maintainer(s) may be found in +[./MAINTAINERS.md](./MAINTAINERS.md). + +Feel free to put up a pull request to fix a bug or maybe add a feature. I will +give it a code review and make sure that it does not break backwards +compatibility. If I or any other collaborators agree that it is in line with +the vision of the project, we will work with you to get the code into +a mergeable state and merge it into the master branch. + +If you have contributed something significant to the project, we will most +likely add you as a collaborator. As a collaborator you are given the ability +to merge others pull requests. It is very important that new code does not +break existing code, so be careful about what code you do choose to merge. + +If you feel like you have contributed to the project but have not yet been added +as a collaborator, we probably forgot to add you :sweat_smile:. Please open an +issue! diff --git a/vendor/github.com/urfave/cli/MAINTAINERS.md b/vendor/github.com/urfave/cli/MAINTAINERS.md new file mode 100644 index 0000000000..5b7a6ea858 --- /dev/null +++ b/vendor/github.com/urfave/cli/MAINTAINERS.md @@ -0,0 +1,4 @@ +- @meatballhat +- @lynncyrin +- @AudriusButkevicius +- @asahasrabuddhe diff --git a/vendor/github.com/urfave/cli/README.md b/vendor/github.com/urfave/cli/README.md index 2bbbd8ea97..9904334318 100644 --- a/vendor/github.com/urfave/cli/README.md +++ b/vendor/github.com/urfave/cli/README.md @@ -9,9 +9,9 @@ cli [![top level coverage](https://gocover.io/_badge/github.com/urfave/cli?0 "top level coverage")](http://gocover.io/github.com/urfave/cli) / [![altsrc coverage](https://gocover.io/_badge/github.com/urfave/cli/altsrc?0 "altsrc coverage")](http://gocover.io/github.com/urfave/cli/altsrc) -**Notice:** This is the library formerly known as -`github.com/codegangsta/cli` -- Github will automatically redirect requests -to this repository, but we recommend updating your references for clarity. +This is the library formerly known as `github.com/codegangsta/cli` -- Github +will automatically redirect requests to this repository, but we recommend +updating your references for clarity. cli is a simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line @@ -32,7 +32,9 @@ applications in an expressive way. + [Alternate Names](#alternate-names) + [Ordering](#ordering) + [Values from the Environment](#values-from-the-environment) + + [Values from files](#values-from-files) + [Values from alternate input sources (YAML, TOML, and others)](#values-from-alternate-input-sources-yaml-toml-and-others) + + [Precedence](#precedence) * [Subcommands](#subcommands) * [Subcommands categories](#subcommands-categories) * [Exit code](#exit-code) @@ -45,6 +47,7 @@ applications in an expressive way. * [Version Flag](#version-flag) + [Customization](#customization-2) + [Full API Example](#full-api-example) + * [Combining short Bool options](#combining-short-bool-options) - [Contribution Guidelines](#contribution-guidelines) @@ -138,13 +141,17 @@ discovery. So a cli app can be as little as one line of code in `main()`. package main import ( + "log" "os" "github.com/urfave/cli" ) func main() { - cli.NewApp().Run(os.Args) + err := cli.NewApp().Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -159,6 +166,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -173,7 +181,10 @@ func main() { return nil } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -197,6 +208,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -211,7 +223,10 @@ func main() { return nil } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -260,6 +275,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -273,7 +289,10 @@ func main() { return nil } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -289,6 +308,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -318,7 +338,10 @@ func main() { return nil } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -332,6 +355,7 @@ scanned. package main import ( + "log" "os" "fmt" @@ -365,7 +389,10 @@ func main() { return nil } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -386,6 +413,7 @@ For example this: package main import ( + "log" "os" "github.com/urfave/cli" @@ -401,7 +429,10 @@ func main() { }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -427,6 +458,7 @@ list for the `Name`. e.g. package main import ( + "log" "os" "github.com/urfave/cli" @@ -443,7 +475,10 @@ func main() { }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -467,6 +502,7 @@ For example this: package main import ( + "log" "os" "sort" @@ -510,7 +546,10 @@ func main() { sort.Sort(cli.FlagsByName(app.Flags)) sort.Sort(cli.CommandsByName(app.Commands)) - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -533,6 +572,7 @@ You can also have the default value set from the environment via `EnvVar`. e.g. package main import ( + "log" "os" "github.com/urfave/cli" @@ -550,7 +590,10 @@ func main() { }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -565,6 +608,7 @@ environment variable that resolves is used as the default. package main import ( + "log" "os" "github.com/urfave/cli" @@ -582,10 +626,52 @@ func main() { }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` +#### Values from files + +You can also have the default value set from file via `FilePath`. e.g. + + +``` go +package main + +import ( + "log" + "os" + + "github.com/urfave/cli" +) + +func main() { + app := cli.NewApp() + + app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "password, p", + Usage: "password for the mysql database", + FilePath: "/etc/mysql/password", + }, + } + + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } +} +``` + +Note that default values set from file (e.g. `FilePath`) take precedence over +default values set from the environment (e.g. `EnvVar`). + #### Values from alternate input sources (YAML, TOML, and others) There is a separate package altsrc that adds support for getting flag values @@ -615,9 +701,9 @@ the yaml input source for any flags that are defined on that command. As a note the "load" flag used would also have to be defined on the command flags in order for this code snipped to work. -Currently only the aboved specified formats are supported but developers can -add support for other input sources by implementing the -altsrc.InputSourceContext for their given sources. +Currently only YAML and JSON files are supported but developers can add support +for other input sources by implementing the altsrc.InputSourceContext for their +given sources. Here is a more complete sample of a command using YAML support: @@ -630,6 +716,7 @@ package notmain import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -652,10 +739,22 @@ func main() { app.Before = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("load")) app.Flags = flags - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` +#### Precedence + +The precedence for flag value sources is as follows (highest to lowest): + +0. Command line flag value from user +0. Environment variable (if specified) +0. Configuration file (if specified) +0. Default defined on the flag + ### Subcommands Subcommands can be defined for a more git-like command line app. @@ -669,6 +768,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -721,7 +821,10 @@ func main() { }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -737,6 +840,7 @@ E.g. package main import ( + "log" "os" "github.com/urfave/cli" @@ -751,15 +855,18 @@ func main() { }, { Name: "add", - Category: "template", + Category: "Template actions", }, { Name: "remove", - Category: "template", + Category: "Template actions", }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -767,7 +874,7 @@ Will include: ``` COMMANDS: - noop + noop Template actions: add @@ -785,6 +892,7 @@ may be set by returning a non-nil error that fulfills `cli.ExitCoder`, *or* a package main import ( + "log" "os" "github.com/urfave/cli" @@ -805,7 +913,10 @@ func main() { return nil } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -825,6 +936,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -856,7 +968,10 @@ func main() { }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -896,6 +1011,7 @@ The default bash completion flag (`--generate-bash-completion`) is defined as package main import ( + "log" "os" "github.com/urfave/cli" @@ -914,7 +1030,10 @@ func main() { Name: "wat", }, } - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -940,6 +1059,7 @@ package main import ( "fmt" + "log" "io" "os" @@ -983,7 +1103,10 @@ VERSION: fmt.Println("Ha HA. I pwnd the help!!1") } - cli.NewApp().Run(os.Args) + err := cli.NewApp().Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -998,6 +1121,7 @@ setting `cli.HelpFlag`, e.g.: package main import ( + "log" "os" "github.com/urfave/cli" @@ -1010,7 +1134,10 @@ func main() { EnvVar: "SHOW_HALP,HALPPLZ", } - cli.NewApp().Run(os.Args) + err := cli.NewApp().Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -1033,6 +1160,7 @@ setting `cli.VersionFlag`, e.g.: package main import ( + "log" "os" "github.com/urfave/cli" @@ -1047,7 +1175,10 @@ func main() { app := cli.NewApp() app.Name = "partay" app.Version = "19.99.0" - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -1062,6 +1193,7 @@ package main import ( "fmt" + "log" "os" "github.com/urfave/cli" @@ -1079,7 +1211,10 @@ func main() { app := cli.NewApp() app.Name = "partay" app.Version = "19.99.0" - app.Run(os.Args) + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } } ``` @@ -1341,7 +1476,7 @@ func main() { ec := cli.NewExitError("ohwell", 86) fmt.Fprintf(c.App.Writer, "%d", ec.ExitCode()) fmt.Printf("made it!\n") - return ec + return nil } if os.Getenv("HEXY") != "" { @@ -1355,7 +1490,9 @@ func main() { "whatever-values": 19.99, } - app.Run(os.Args) + + // ignore error so we don't exit non-zero and break gfmrun README example tests + _ = app.Run(os.Args) } func wopAction(c *cli.Context) error { @@ -1364,18 +1501,26 @@ func wopAction(c *cli.Context) error { } ``` -## Contribution Guidelines +### Combining short Bool options -Feel free to put up a pull request to fix a bug or maybe add a feature. I will -give it a code review and make sure that it does not break backwards -compatibility. If I or any other collaborators agree that it is in line with -the vision of the project, we will work with you to get the code into -a mergeable state and merge it into the master branch. +Traditional use of boolean options using their shortnames look like this: +``` +# cmd foobar -s -o +``` -If you have contributed something significant to the project, we will most -likely add you as a collaborator. As a collaborator you are given the ability -to merge others pull requests. It is very important that new code does not -break existing code, so be careful about what code you do choose to merge. +Suppose you want users to be able to combine your bool options with their shortname. This +can be done using the **UseShortOptionHandling** bool in your commands. Suppose your program +has a two bool flags such as *serve* and *option* with the short options of *-o* and +*-s* respectively. With **UseShortOptionHandling** set to *true*, a user can use a syntax +like: +``` +# cmd foobar -so +``` + +If you enable the **UseShortOptionHandling*, then you must not use any flags that have a single +leading *-* or this will result in failures. For example, **-option** can no longer be used. Flags +with two leading dashes (such as **--options**) are still valid. + +## Contribution Guidelines -If you feel like you have contributed to the project but have not yet been -added as a collaborator, we probably forgot to add you, please open an issue. +See [./CONTRIBUTING.md](./CONTRIBUTING.md) diff --git a/vendor/github.com/urfave/cli/app.go b/vendor/github.com/urfave/cli/app.go index 51fc45d878..9ed492f775 100644 --- a/vendor/github.com/urfave/cli/app.go +++ b/vendor/github.com/urfave/cli/app.go @@ -83,6 +83,9 @@ type App struct { Writer io.Writer // ErrWriter writes error output ErrWriter io.Writer + // Execute this function to handle ExitErrors. If not provided, HandleExitCoder is provided to + // function as a default, so this is optional. + ExitErrHandler ExitErrHandlerFunc // Other custom info Metadata map[string]interface{} // Carries a function which returns app specific info. @@ -207,7 +210,7 @@ func (a *App) Run(arguments []string) (err error) { if err != nil { if a.OnUsageError != nil { err := a.OnUsageError(context, err, false) - HandleExitCoder(err) + a.handleExitCoder(context, err) return err } fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error()) @@ -225,6 +228,12 @@ func (a *App) Run(arguments []string) (err error) { return nil } + cerr := checkRequiredFlags(a.Flags, context) + if cerr != nil { + ShowAppHelp(context) + return cerr + } + if a.After != nil { defer func() { if afterErr := a.After(context); afterErr != nil { @@ -240,8 +249,9 @@ func (a *App) Run(arguments []string) (err error) { if a.Before != nil { beforeErr := a.Before(context) if beforeErr != nil { + fmt.Fprintf(a.Writer, "%v\n\n", beforeErr) ShowAppHelp(context) - HandleExitCoder(beforeErr) + a.handleExitCoder(context, beforeErr) err = beforeErr return err } @@ -263,7 +273,7 @@ func (a *App) Run(arguments []string) (err error) { // Run default Action err = HandleAction(a.Action, context) - HandleExitCoder(err) + a.handleExitCoder(context, err) return err } @@ -330,7 +340,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) { if err != nil { if a.OnUsageError != nil { err = a.OnUsageError(context, err, true) - HandleExitCoder(err) + a.handleExitCoder(context, err) return err } fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error()) @@ -348,11 +358,17 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) { } } + cerr := checkRequiredFlags(a.Flags, context) + if cerr != nil { + ShowSubcommandHelp(context) + return cerr + } + if a.After != nil { defer func() { afterErr := a.After(context) if afterErr != nil { - HandleExitCoder(err) + a.handleExitCoder(context, err) if err != nil { err = NewMultiError(err, afterErr) } else { @@ -365,7 +381,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) { if a.Before != nil { beforeErr := a.Before(context) if beforeErr != nil { - HandleExitCoder(beforeErr) + a.handleExitCoder(context, beforeErr) err = beforeErr return err } @@ -383,7 +399,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) { // Run default Action err = HandleAction(a.Action, context) - HandleExitCoder(err) + a.handleExitCoder(context, err) return err } @@ -449,7 +465,6 @@ func (a *App) hasFlag(flag Flag) bool { } func (a *App) errWriter() io.Writer { - // When the app ErrWriter is nil use the package level one. if a.ErrWriter == nil { return ErrWriter @@ -464,6 +479,14 @@ func (a *App) appendFlag(flag Flag) { } } +func (a *App) handleExitCoder(context *Context, err error) { + if a.ExitErrHandler != nil { + a.ExitErrHandler(context, err) + } else { + HandleExitCoder(err) + } +} + // Author represents someone who has contributed to a cli project. type Author struct { Name string // The Authors name @@ -484,14 +507,15 @@ func (a Author) String() string { // it's an ActionFunc or a func with the legacy signature for Action, the func // is run! func HandleAction(action interface{}, context *Context) (err error) { - if a, ok := action.(ActionFunc); ok { + switch a := action.(type) { + case ActionFunc: return a(context) - } else if a, ok := action.(func(*Context) error); ok { + case func(*Context) error: return a(context) - } else if a, ok := action.(func(*Context)); ok { // deprecated function signature + case func(*Context): // deprecated function signature a(context) return nil - } else { - return errInvalidActionType } + + return errInvalidActionType } diff --git a/vendor/github.com/urfave/cli/category.go b/vendor/github.com/urfave/cli/category.go index 1a6055023e..bf3c73c55e 100644 --- a/vendor/github.com/urfave/cli/category.go +++ b/vendor/github.com/urfave/cli/category.go @@ -10,7 +10,7 @@ type CommandCategory struct { } func (c CommandCategories) Less(i, j int) bool { - return c[i].Name < c[j].Name + return lexicographicLess(c[i].Name, c[j].Name) } func (c CommandCategories) Len() int { diff --git a/vendor/github.com/urfave/cli/command.go b/vendor/github.com/urfave/cli/command.go index 23de2944be..f1ca02d929 100644 --- a/vendor/github.com/urfave/cli/command.go +++ b/vendor/github.com/urfave/cli/command.go @@ -1,6 +1,7 @@ package cli import ( + "flag" "fmt" "io/ioutil" "sort" @@ -55,6 +56,10 @@ type Command struct { HideHelp bool // Boolean to hide this command from help or completion Hidden bool + // Boolean to enable short-option handling so user can combine several + // single-character bool arguments into one + // i.e. foobar -o -v -> foobar -ov + UseShortOptionHandling bool // Full name of command for help, defaults to full command name, including parent commands. HelpName string @@ -73,7 +78,7 @@ func (c CommandsByName) Len() int { } func (c CommandsByName) Less(i, j int) bool { - return c[i].Name < c[j].Name + return lexicographicLess(c[i].Name, c[j].Name) } func (c CommandsByName) Swap(i, j int) { @@ -106,57 +111,7 @@ func (c Command) Run(ctx *Context) (err error) { ) } - set, err := flagSet(c.Name, c.Flags) - if err != nil { - return err - } - set.SetOutput(ioutil.Discard) - - if c.SkipFlagParsing { - err = set.Parse(append([]string{"--"}, ctx.Args().Tail()...)) - } else if !c.SkipArgReorder { - firstFlagIndex := -1 - terminatorIndex := -1 - for index, arg := range ctx.Args() { - if arg == "--" { - terminatorIndex = index - break - } else if arg == "-" { - // Do nothing. A dash alone is not really a flag. - continue - } else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 { - firstFlagIndex = index - } - } - - if firstFlagIndex > -1 { - args := ctx.Args() - regularArgs := make([]string, len(args[1:firstFlagIndex])) - copy(regularArgs, args[1:firstFlagIndex]) - - var flagArgs []string - if terminatorIndex > -1 { - flagArgs = args[firstFlagIndex:terminatorIndex] - regularArgs = append(regularArgs, args[terminatorIndex:]...) - } else { - flagArgs = args[firstFlagIndex:] - } - - err = set.Parse(append(flagArgs, regularArgs...)) - } else { - err = set.Parse(ctx.Args().Tail()) - } - } else { - err = set.Parse(ctx.Args().Tail()) - } - - nerr := normalizeFlags(c.Flags, set) - if nerr != nil { - fmt.Fprintln(ctx.App.Writer, nerr) - fmt.Fprintln(ctx.App.Writer) - ShowCommandHelp(ctx, c.Name) - return nerr - } + set, err := c.parseFlags(ctx.Args().Tail()) context := NewContext(ctx.App, set, ctx) context.Command = c @@ -167,7 +122,7 @@ func (c Command) Run(ctx *Context) (err error) { if err != nil { if c.OnUsageError != nil { err := c.OnUsageError(context, err, false) - HandleExitCoder(err) + context.App.handleExitCoder(context, err) return err } fmt.Fprintln(context.App.Writer, "Incorrect Usage:", err.Error()) @@ -180,11 +135,17 @@ func (c Command) Run(ctx *Context) (err error) { return nil } + cerr := checkRequiredFlags(c.Flags, context) + if cerr != nil { + ShowCommandHelp(context, c.Name) + return cerr + } + if c.After != nil { defer func() { afterErr := c.After(context) if afterErr != nil { - HandleExitCoder(err) + context.App.handleExitCoder(context, err) if err != nil { err = NewMultiError(err, afterErr) } else { @@ -198,7 +159,7 @@ func (c Command) Run(ctx *Context) (err error) { err = c.Before(context) if err != nil { ShowCommandHelp(context, c.Name) - HandleExitCoder(err) + context.App.handleExitCoder(context, err) return err } } @@ -210,11 +171,135 @@ func (c Command) Run(ctx *Context) (err error) { err = HandleAction(c.Action, context) if err != nil { - HandleExitCoder(err) + context.App.handleExitCoder(context, err) } return err } +func (c *Command) parseFlags(args Args) (*flag.FlagSet, error) { + set, err := flagSet(c.Name, c.Flags) + if err != nil { + return nil, err + } + set.SetOutput(ioutil.Discard) + + if c.SkipFlagParsing { + return set, set.Parse(append([]string{"--"}, args...)) + } + + if !c.SkipArgReorder { + args = reorderArgs(args) + } + +PARSE: + err = set.Parse(args) + if err != nil { + if c.UseShortOptionHandling { + // To enable short-option handling (e.g., "-it" vs "-i -t") + // we have to iteratively catch parsing errors. This way + // we achieve LR parsing without transforming any arguments. + // Otherwise, there is no way we can discriminate combined + // short options from common arguments that should be left + // untouched. + errStr := err.Error() + trimmed := strings.TrimPrefix(errStr, "flag provided but not defined: ") + if errStr == trimmed { + return nil, err + } + // regenerate the initial args with the split short opts + newArgs := Args{} + for i, arg := range args { + if arg != trimmed { + newArgs = append(newArgs, arg) + continue + } + shortOpts := translateShortOptions(set, Args{trimmed}) + if len(shortOpts) == 1 { + return nil, err + } + // add each short option and all remaining arguments + newArgs = append(newArgs, shortOpts...) + newArgs = append(newArgs, args[i+1:]...) + args = newArgs + // now reset the flagset parse again + set, err = flagSet(c.Name, c.Flags) + if err != nil { + return nil, err + } + set.SetOutput(ioutil.Discard) + goto PARSE + } + } + return nil, err + } + + err = normalizeFlags(c.Flags, set) + if err != nil { + return nil, err + } + + return set, nil +} + +// reorderArgs moves all flags before arguments as this is what flag expects +func reorderArgs(args []string) []string { + var nonflags, flags []string + + readFlagValue := false + for i, arg := range args { + if arg == "--" { + nonflags = append(nonflags, args[i:]...) + break + } + + if readFlagValue && !strings.HasPrefix(arg, "-") && !strings.HasPrefix(arg, "--") { + readFlagValue = false + flags = append(flags, arg) + continue + } + readFlagValue = false + + if arg != "-" && strings.HasPrefix(arg, "-") { + flags = append(flags, arg) + + readFlagValue = !strings.Contains(arg, "=") + } else { + nonflags = append(nonflags, arg) + } + } + + return append(flags, nonflags...) +} + +func translateShortOptions(set *flag.FlagSet, flagArgs Args) []string { + allCharsFlags := func (s string) bool { + for i := range s { + f := set.Lookup(string(s[i])) + if f == nil { + return false + } + } + return true + } + + // separate combined flags + var flagArgsSeparated []string + for _, flagArg := range flagArgs { + if strings.HasPrefix(flagArg, "-") && strings.HasPrefix(flagArg, "--") == false && len(flagArg) > 2 { + if !allCharsFlags(flagArg[1:]) { + flagArgsSeparated = append(flagArgsSeparated, flagArg) + continue + } + for _, flagChar := range flagArg[1:] { + flagArgsSeparated = append(flagArgsSeparated, "-"+string(flagChar)) + } + } else { + flagArgsSeparated = append(flagArgsSeparated, flagArg) + } + } + return flagArgsSeparated +} + // Names returns the names including short names and aliases. func (c Command) Names() []string { names := []string{c.Name} diff --git a/vendor/github.com/urfave/cli/context.go b/vendor/github.com/urfave/cli/context.go index db94191e2a..3e516c8abe 100644 --- a/vendor/github.com/urfave/cli/context.go +++ b/vendor/github.com/urfave/cli/context.go @@ -3,6 +3,8 @@ package cli import ( "errors" "flag" + "fmt" + "os" "reflect" "strings" "syscall" @@ -73,7 +75,7 @@ func (c *Context) IsSet(name string) bool { // change in version 2 to add `IsSet` to the Flag interface to push the // responsibility closer to where the information required to determine // whether a flag is set by non-standard means such as environment - // variables is avaliable. + // variables is available. // // See https://github.com/urfave/cli/issues/294 for additional discussion flags := c.Command.Flags @@ -93,18 +95,26 @@ func (c *Context) IsSet(name string) bool { val = val.Elem() } - envVarValue := val.FieldByName("EnvVar") - if !envVarValue.IsValid() { - return + filePathValue := val.FieldByName("FilePath") + if filePathValue.IsValid() { + eachName(filePathValue.String(), func(filePath string) { + if _, err := os.Stat(filePath); err == nil { + c.setFlags[name] = true + return + } + }) } - eachName(envVarValue.String(), func(envVar string) { - envVar = strings.TrimSpace(envVar) - if _, ok := syscall.Getenv(envVar); ok { - c.setFlags[name] = true - return - } - }) + envVarValue := val.FieldByName("EnvVar") + if envVarValue.IsValid() { + eachName(envVarValue.String(), func(envVar string) { + envVar = strings.TrimSpace(envVar) + if _, ok := syscall.Getenv(envVar); ok { + c.setFlags[name] = true + return + } + }) + } }) } } @@ -276,3 +286,43 @@ func normalizeFlags(flags []Flag, set *flag.FlagSet) error { } return nil } + +type requiredFlagsErr interface { + error + getMissingFlags() []string +} + +type errRequiredFlags struct { + missingFlags []string +} + +func (e *errRequiredFlags) Error() string { + numberOfMissingFlags := len(e.missingFlags) + if numberOfMissingFlags == 1 { + return fmt.Sprintf("Required flag %q not set", e.missingFlags[0]) + } + joinedMissingFlags := strings.Join(e.missingFlags, ", ") + return fmt.Sprintf("Required flags %q not set", joinedMissingFlags) +} + +func (e *errRequiredFlags) getMissingFlags() []string { + return e.missingFlags +} + +func checkRequiredFlags(flags []Flag, context *Context) requiredFlagsErr { + var missingFlags []string + for _, f := range flags { + if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() { + key := strings.Split(f.GetName(), ",")[0] + if !context.IsSet(key) { + missingFlags = append(missingFlags, key) + } + } + } + + if len(missingFlags) != 0 { + return &errRequiredFlags{missingFlags: missingFlags} + } + + return nil +} diff --git a/vendor/github.com/urfave/cli/flag.go b/vendor/github.com/urfave/cli/flag.go index 877ff3523d..d98c808b47 100644 --- a/vendor/github.com/urfave/cli/flag.go +++ b/vendor/github.com/urfave/cli/flag.go @@ -3,6 +3,7 @@ package cli import ( "flag" "fmt" + "io/ioutil" "reflect" "runtime" "strconv" @@ -37,6 +38,18 @@ var HelpFlag Flag = BoolFlag{ // to display a flag. var FlagStringer FlagStringFunc = stringifyFlag +// FlagNamePrefixer converts a full flag name and its placeholder into the help +// message flag prefix. This is used by the default FlagStringer. +var FlagNamePrefixer FlagNamePrefixFunc = prefixedNames + +// FlagEnvHinter annotates flag help message with the environment variable +// details. This is used by the default FlagStringer. +var FlagEnvHinter FlagEnvHintFunc = withEnvHint + +// FlagFileHinter annotates flag help message with the environment variable +// details. This is used by the default FlagStringer. +var FlagFileHinter FlagFileHintFunc = withFileHint + // FlagsByName is a slice of Flag. type FlagsByName []Flag @@ -45,7 +58,7 @@ func (f FlagsByName) Len() int { } func (f FlagsByName) Less(i, j int) bool { - return f[i].GetName() < f[j].GetName() + return lexicographicLess(f[i].GetName(), f[j].GetName()) } func (f FlagsByName) Swap(i, j int) { @@ -62,6 +75,14 @@ type Flag interface { GetName() string } +// RequiredFlag is an interface that allows us to mark flags as required +// it allows flags required flags to be backwards compatible with the Flag interface +type RequiredFlag interface { + Flag + + IsRequired() bool +} + // errorableFlag is an interface that allows us to return errors during apply // it allows flags defined in this library to return errors in a fashion backwards compatible // TODO remove in v2 and modify the existing Flag interface to return errors @@ -112,15 +133,9 @@ func (f GenericFlag) Apply(set *flag.FlagSet) { // provided by the user for parsing by the flag func (f GenericFlag) ApplyWithError(set *flag.FlagSet) error { val := f.Value - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - if err := val.Set(envVal); err != nil { - return fmt.Errorf("could not parse %s as value for flag %s: %s", envVal, f.Name, err) - } - break - } + if fileEnvVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + if err := val.Set(fileEnvVal); err != nil { + return fmt.Errorf("could not parse %s as value for flag %s: %s", fileEnvVal, f.Name, err) } } @@ -163,21 +178,19 @@ func (f StringSliceFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f StringSliceFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - newVal := &StringSlice{} - for _, s := range strings.Split(envVal, ",") { - s = strings.TrimSpace(s) - if err := newVal.Set(s); err != nil { - return fmt.Errorf("could not parse %s as string value for flag %s: %s", envVal, f.Name, err) - } - } - f.Value = newVal - break + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + newVal := &StringSlice{} + for _, s := range strings.Split(envVal, ",") { + s = strings.TrimSpace(s) + if err := newVal.Set(s); err != nil { + return fmt.Errorf("could not parse %s as string value for flag %s: %s", envVal, f.Name, err) } } + if f.Value == nil { + f.Value = newVal + } else { + *f.Value = *newVal + } } eachName(f.Name, func(name string) { @@ -226,21 +239,19 @@ func (f IntSliceFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f IntSliceFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - newVal := &IntSlice{} - for _, s := range strings.Split(envVal, ",") { - s = strings.TrimSpace(s) - if err := newVal.Set(s); err != nil { - return fmt.Errorf("could not parse %s as int slice value for flag %s: %s", envVal, f.Name, err) - } - } - f.Value = newVal - break + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + newVal := &IntSlice{} + for _, s := range strings.Split(envVal, ",") { + s = strings.TrimSpace(s) + if err := newVal.Set(s); err != nil { + return fmt.Errorf("could not parse %s as int slice value for flag %s: %s", envVal, f.Name, err) } } + if f.Value == nil { + f.Value = newVal + } else { + *f.Value = *newVal + } } eachName(f.Name, func(name string) { @@ -289,21 +300,19 @@ func (f Int64SliceFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - newVal := &Int64Slice{} - for _, s := range strings.Split(envVal, ",") { - s = strings.TrimSpace(s) - if err := newVal.Set(s); err != nil { - return fmt.Errorf("could not parse %s as int64 slice value for flag %s: %s", envVal, f.Name, err) - } - } - f.Value = newVal - break + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + newVal := &Int64Slice{} + for _, s := range strings.Split(envVal, ",") { + s = strings.TrimSpace(s) + if err := newVal.Set(s); err != nil { + return fmt.Errorf("could not parse %s as int64 slice value for flag %s: %s", envVal, f.Name, err) } } + if f.Value == nil { + f.Value = newVal + } else { + *f.Value = *newVal + } } eachName(f.Name, func(name string) { @@ -324,23 +333,15 @@ func (f BoolFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f BoolFlag) ApplyWithError(set *flag.FlagSet) error { val := false - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - if envVal == "" { - val = false - break - } - - envValBool, err := strconv.ParseBool(envVal) - if err != nil { - return fmt.Errorf("could not parse %s as bool value for flag %s: %s", envVal, f.Name, err) - } - - val = envValBool - break + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + if envVal == "" { + val = false + } else { + envValBool, err := strconv.ParseBool(envVal) + if err != nil { + return fmt.Errorf("could not parse %s as bool value for flag %s: %s", envVal, f.Name, err) } + val = envValBool } } @@ -364,23 +365,16 @@ func (f BoolTFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f BoolTFlag) ApplyWithError(set *flag.FlagSet) error { val := true - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - if envVal == "" { - val = false - break - } - - envValBool, err := strconv.ParseBool(envVal) - if err != nil { - return fmt.Errorf("could not parse %s as bool value for flag %s: %s", envVal, f.Name, err) - } - val = envValBool - break + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + if envVal == "" { + val = false + } else { + envValBool, err := strconv.ParseBool(envVal) + if err != nil { + return fmt.Errorf("could not parse %s as bool value for flag %s: %s", envVal, f.Name, err) } + val = envValBool } } @@ -403,14 +397,8 @@ func (f StringFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f StringFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - f.Value = envVal - break - } - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + f.Value = envVal } eachName(f.Name, func(name string) { @@ -432,18 +420,12 @@ func (f IntFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f IntFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseInt(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err) - } - f.Value = int(envValInt) - break - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + envValInt, err := strconv.ParseInt(envVal, 0, 64) + if err != nil { + return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err) } + f.Value = int(envValInt) } eachName(f.Name, func(name string) { @@ -465,19 +447,13 @@ func (f Int64Flag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f Int64Flag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseInt(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = envValInt - break - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + envValInt, err := strconv.ParseInt(envVal, 0, 64) + if err != nil { + return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err) } + + f.Value = envValInt } eachName(f.Name, func(name string) { @@ -499,19 +475,13 @@ func (f UintFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f UintFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseUint(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as uint value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = uint(envValInt) - break - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + envValInt, err := strconv.ParseUint(envVal, 0, 64) + if err != nil { + return fmt.Errorf("could not parse %s as uint value for flag %s: %s", envVal, f.Name, err) } + + f.Value = uint(envValInt) } eachName(f.Name, func(name string) { @@ -533,19 +503,13 @@ func (f Uint64Flag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f Uint64Flag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseUint(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as uint64 value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = uint64(envValInt) - break - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + envValInt, err := strconv.ParseUint(envVal, 0, 64) + if err != nil { + return fmt.Errorf("could not parse %s as uint64 value for flag %s: %s", envVal, f.Name, err) } + + f.Value = uint64(envValInt) } eachName(f.Name, func(name string) { @@ -567,19 +531,13 @@ func (f DurationFlag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f DurationFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValDuration, err := time.ParseDuration(envVal) - if err != nil { - return fmt.Errorf("could not parse %s as duration for flag %s: %s", envVal, f.Name, err) - } - - f.Value = envValDuration - break - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + envValDuration, err := time.ParseDuration(envVal) + if err != nil { + return fmt.Errorf("could not parse %s as duration for flag %s: %s", envVal, f.Name, err) } + + f.Value = envValDuration } eachName(f.Name, func(name string) { @@ -601,19 +559,13 @@ func (f Float64Flag) Apply(set *flag.FlagSet) { // ApplyWithError populates the flag given the flag set and environment func (f Float64Flag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValFloat, err := strconv.ParseFloat(envVal, 10) - if err != nil { - return fmt.Errorf("could not parse %s as float64 value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = float64(envValFloat) - break - } + if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { + envValFloat, err := strconv.ParseFloat(envVal, 10) + if err != nil { + return fmt.Errorf("could not parse %s as float64 value for flag %s: %s", envVal, f.Name, err) } + + f.Value = float64(envValFloat) } eachName(f.Name, func(name string) { @@ -692,11 +644,19 @@ func withEnvHint(envVar, str string) string { suffix = "%" sep = "%, %" } - envText = fmt.Sprintf(" [%s%s%s]", prefix, strings.Join(strings.Split(envVar, ","), sep), suffix) + envText = " [" + prefix + strings.Join(strings.Split(envVar, ","), sep) + suffix + "]" } return str + envText } +func withFileHint(filePath, str string) string { + fileText := "" + if filePath != "" { + fileText = fmt.Sprintf(" [%s]", filePath) + } + return str + fileText +} + func flagValue(f Flag) reflect.Value { fv := reflect.ValueOf(f) for fv.Kind() == reflect.Ptr { @@ -710,14 +670,29 @@ func stringifyFlag(f Flag) string { switch f.(type) { case IntSliceFlag: - return withEnvHint(fv.FieldByName("EnvVar").String(), - stringifyIntSliceFlag(f.(IntSliceFlag))) + return FlagFileHinter( + fv.FieldByName("FilePath").String(), + FlagEnvHinter( + fv.FieldByName("EnvVar").String(), + stringifyIntSliceFlag(f.(IntSliceFlag)), + ), + ) case Int64SliceFlag: - return withEnvHint(fv.FieldByName("EnvVar").String(), - stringifyInt64SliceFlag(f.(Int64SliceFlag))) + return FlagFileHinter( + fv.FieldByName("FilePath").String(), + FlagEnvHinter( + fv.FieldByName("EnvVar").String(), + stringifyInt64SliceFlag(f.(Int64SliceFlag)), + ), + ) case StringSliceFlag: - return withEnvHint(fv.FieldByName("EnvVar").String(), - stringifyStringSliceFlag(f.(StringSliceFlag))) + return FlagFileHinter( + fv.FieldByName("FilePath").String(), + FlagEnvHinter( + fv.FieldByName("EnvVar").String(), + stringifyStringSliceFlag(f.(StringSliceFlag)), + ), + ) } placeholder, usage := unquoteUsage(fv.FieldByName("Usage").String()) @@ -742,17 +717,22 @@ func stringifyFlag(f Flag) string { placeholder = defaultPlaceholder } - usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultValueString)) + usageWithDefault := strings.TrimSpace(usage + defaultValueString) - return withEnvHint(fv.FieldByName("EnvVar").String(), - fmt.Sprintf("%s\t%s", prefixedNames(fv.FieldByName("Name").String(), placeholder), usageWithDefault)) + return FlagFileHinter( + fv.FieldByName("FilePath").String(), + FlagEnvHinter( + fv.FieldByName("EnvVar").String(), + FlagNamePrefixer(fv.FieldByName("Name").String(), placeholder)+"\t"+usageWithDefault, + ), + ) } func stringifyIntSliceFlag(f IntSliceFlag) string { defaultVals := []string{} if f.Value != nil && len(f.Value.Value()) > 0 { for _, i := range f.Value.Value() { - defaultVals = append(defaultVals, fmt.Sprintf("%d", i)) + defaultVals = append(defaultVals, strconv.Itoa(i)) } } @@ -763,7 +743,7 @@ func stringifyInt64SliceFlag(f Int64SliceFlag) string { defaultVals := []string{} if f.Value != nil && len(f.Value.Value()) > 0 { for _, i := range f.Value.Value() { - defaultVals = append(defaultVals, fmt.Sprintf("%d", i)) + defaultVals = append(defaultVals, strconv.FormatInt(i, 10)) } } @@ -775,7 +755,7 @@ func stringifyStringSliceFlag(f StringSliceFlag) string { if f.Value != nil && len(f.Value.Value()) > 0 { for _, s := range f.Value.Value() { if len(s) > 0 { - defaultVals = append(defaultVals, fmt.Sprintf("%q", s)) + defaultVals = append(defaultVals, strconv.Quote(s)) } } } @@ -794,6 +774,21 @@ func stringifySliceFlag(usage, name string, defaultVals []string) string { defaultVal = fmt.Sprintf(" (default: %s)", strings.Join(defaultVals, ", ")) } - usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultVal)) - return fmt.Sprintf("%s\t%s", prefixedNames(name, placeholder), usageWithDefault) + usageWithDefault := strings.TrimSpace(usage + defaultVal) + return FlagNamePrefixer(name, placeholder) + "\t" + usageWithDefault +} + +func flagFromFileEnv(filePath, envName string) (val string, ok bool) { + for _, envVar := range strings.Split(envName, ",") { + envVar = strings.TrimSpace(envVar) + if envVal, ok := syscall.Getenv(envVar); ok { + return envVal, true + } + } + for _, fileVar := range strings.Split(filePath, ",") { + if data, err := ioutil.ReadFile(fileVar); err == nil { + return string(data), true + } + } + return "", false } diff --git a/vendor/github.com/urfave/cli/flag_generated.go b/vendor/github.com/urfave/cli/flag_generated.go index 491b61956c..a3e4d6e9d5 100644 --- a/vendor/github.com/urfave/cli/flag_generated.go +++ b/vendor/github.com/urfave/cli/flag_generated.go @@ -13,6 +13,8 @@ type BoolFlag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Destination *bool } @@ -28,6 +30,11 @@ func (f BoolFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f BoolFlag) IsRequired() bool { + return f.Required +} + // Bool looks up the value of a local BoolFlag, returns // false if not found func (c *Context) Bool(name string) bool { @@ -60,6 +67,8 @@ type BoolTFlag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Destination *bool } @@ -75,6 +84,11 @@ func (f BoolTFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f BoolTFlag) IsRequired() bool { + return f.Required +} + // BoolT looks up the value of a local BoolTFlag, returns // false if not found func (c *Context) BoolT(name string) bool { @@ -107,6 +121,8 @@ type DurationFlag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value time.Duration Destination *time.Duration @@ -123,6 +139,11 @@ func (f DurationFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f DurationFlag) IsRequired() bool { + return f.Required +} + // Duration looks up the value of a local DurationFlag, returns // 0 if not found func (c *Context) Duration(name string) time.Duration { @@ -155,6 +176,8 @@ type Float64Flag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value float64 Destination *float64 @@ -171,6 +194,11 @@ func (f Float64Flag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Float64Flag) IsRequired() bool { + return f.Required +} + // Float64 looks up the value of a local Float64Flag, returns // 0 if not found func (c *Context) Float64(name string) float64 { @@ -200,11 +228,13 @@ func lookupFloat64(name string, set *flag.FlagSet) float64 { // GenericFlag is a flag with type Generic type GenericFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value Generic + Name string + Usage string + EnvVar string + FilePath string + Required bool + Hidden bool + Value Generic } // String returns a readable representation of this value @@ -218,6 +248,11 @@ func (f GenericFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f GenericFlag) IsRequired() bool { + return f.Required +} + // Generic looks up the value of a local GenericFlag, returns // nil if not found func (c *Context) Generic(name string) interface{} { @@ -250,6 +285,8 @@ type Int64Flag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value int64 Destination *int64 @@ -266,6 +303,11 @@ func (f Int64Flag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Int64Flag) IsRequired() bool { + return f.Required +} + // Int64 looks up the value of a local Int64Flag, returns // 0 if not found func (c *Context) Int64(name string) int64 { @@ -298,6 +340,8 @@ type IntFlag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value int Destination *int @@ -314,6 +358,11 @@ func (f IntFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f IntFlag) IsRequired() bool { + return f.Required +} + // Int looks up the value of a local IntFlag, returns // 0 if not found func (c *Context) Int(name string) int { @@ -343,11 +392,13 @@ func lookupInt(name string, set *flag.FlagSet) int { // IntSliceFlag is a flag with type *IntSlice type IntSliceFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value *IntSlice + Name string + Usage string + EnvVar string + FilePath string + Required bool + Hidden bool + Value *IntSlice } // String returns a readable representation of this value @@ -361,6 +412,11 @@ func (f IntSliceFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f IntSliceFlag) IsRequired() bool { + return f.Required +} + // IntSlice looks up the value of a local IntSliceFlag, returns // nil if not found func (c *Context) IntSlice(name string) []int { @@ -390,11 +446,13 @@ func lookupIntSlice(name string, set *flag.FlagSet) []int { // Int64SliceFlag is a flag with type *Int64Slice type Int64SliceFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value *Int64Slice + Name string + Usage string + EnvVar string + FilePath string + Required bool + Hidden bool + Value *Int64Slice } // String returns a readable representation of this value @@ -408,6 +466,11 @@ func (f Int64SliceFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Int64SliceFlag) IsRequired() bool { + return f.Required +} + // Int64Slice looks up the value of a local Int64SliceFlag, returns // nil if not found func (c *Context) Int64Slice(name string) []int64 { @@ -440,6 +503,8 @@ type StringFlag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value string Destination *string @@ -456,6 +521,11 @@ func (f StringFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f StringFlag) IsRequired() bool { + return f.Required +} + // String looks up the value of a local StringFlag, returns // "" if not found func (c *Context) String(name string) string { @@ -485,11 +555,13 @@ func lookupString(name string, set *flag.FlagSet) string { // StringSliceFlag is a flag with type *StringSlice type StringSliceFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value *StringSlice + Name string + Usage string + EnvVar string + FilePath string + Required bool + Hidden bool + Value *StringSlice } // String returns a readable representation of this value @@ -503,6 +575,11 @@ func (f StringSliceFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f StringSliceFlag) IsRequired() bool { + return f.Required +} + // StringSlice looks up the value of a local StringSliceFlag, returns // nil if not found func (c *Context) StringSlice(name string) []string { @@ -535,6 +612,8 @@ type Uint64Flag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value uint64 Destination *uint64 @@ -551,6 +630,11 @@ func (f Uint64Flag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Uint64Flag) IsRequired() bool { + return f.Required +} + // Uint64 looks up the value of a local Uint64Flag, returns // 0 if not found func (c *Context) Uint64(name string) uint64 { @@ -583,6 +667,8 @@ type UintFlag struct { Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool Value uint Destination *uint @@ -599,6 +685,11 @@ func (f UintFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f UintFlag) IsRequired() bool { + return f.Required +} + // Uint looks up the value of a local UintFlag, returns // 0 if not found func (c *Context) Uint(name string) uint { diff --git a/vendor/github.com/urfave/cli/funcs.go b/vendor/github.com/urfave/cli/funcs.go index cba5e6cb0c..0036b1130a 100644 --- a/vendor/github.com/urfave/cli/funcs.go +++ b/vendor/github.com/urfave/cli/funcs.go @@ -23,6 +23,22 @@ type CommandNotFoundFunc func(*Context, string) // is displayed and the execution is interrupted. type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error +// ExitErrHandlerFunc is executed if provided in order to handle ExitError values +// returned by Actions and Before/After functions. +type ExitErrHandlerFunc func(context *Context, err error) + // FlagStringFunc is used by the help generation to display a flag, which is // expected to be a single line. type FlagStringFunc func(Flag) string + +// FlagNamePrefixFunc is used by the default FlagStringFunc to create prefix +// text for a flag's full name. +type FlagNamePrefixFunc func(fullName, placeholder string) string + +// FlagEnvHintFunc is used by the default FlagStringFunc to annotate flag help +// with the environment variable details. +type FlagEnvHintFunc func(envVar, str string) string + +// FlagFileHintFunc is used by the default FlagStringFunc to annotate flag help +// with the file path details. +type FlagFileHintFunc func(filePath, str string) string diff --git a/vendor/github.com/urfave/cli/generate-flag-types b/vendor/github.com/urfave/cli/generate-flag-types index 7147381ce3..e0b5aa15b6 100644 --- a/vendor/github.com/urfave/cli/generate-flag-types +++ b/vendor/github.com/urfave/cli/generate-flag-types @@ -142,6 +142,8 @@ def _write_cli_flag_types(outfile, types): Name string Usage string EnvVar string + FilePath string + Required bool Hidden bool """.format(**typedef)) @@ -169,6 +171,11 @@ def _write_cli_flag_types(outfile, types): return f.Name }} + // IsRequired returns the whether or not the flag is required + func (f {name}Flag) IsRequired() bool {{ + return f.Required + }} + // {name} looks up the value of a local {name}Flag, returns // {context_default} if not found func (c *Context) {name}(name string) {context_type} {{ diff --git a/vendor/github.com/urfave/cli/go.mod b/vendor/github.com/urfave/cli/go.mod new file mode 100644 index 0000000000..d5b55c460c --- /dev/null +++ b/vendor/github.com/urfave/cli/go.mod @@ -0,0 +1,8 @@ +module github.com/urfave/cli + +go 1.12 + +require ( + github.com/BurntSushi/toml v0.3.1 + gopkg.in/yaml.v2 v2.2.2 +) diff --git a/vendor/github.com/urfave/cli/go.sum b/vendor/github.com/urfave/cli/go.sum new file mode 100644 index 0000000000..a2ea70251e --- /dev/null +++ b/vendor/github.com/urfave/cli/go.sum @@ -0,0 +1,6 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/urfave/cli/help.go b/vendor/github.com/urfave/cli/help.go index 57ec98d58a..d611971465 100644 --- a/vendor/github.com/urfave/cli/help.go +++ b/vendor/github.com/urfave/cli/help.go @@ -29,8 +29,10 @@ AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}} COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{end}}{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} + + {{.Name}}:{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} GLOBAL OPTIONS: {{range $index, $option := .VisibleFlags}}{{if $index}} @@ -70,9 +72,11 @@ USAGE: {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}} COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{end}}{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}} -{{end}}{{if .VisibleFlags}} + + {{.Name}}:{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} + OPTIONS: {{range .VisibleFlags}}{{.}} {{end}}{{end}} @@ -157,8 +161,14 @@ func DefaultAppComplete(c *Context) { if command.Hidden { continue } - for _, name := range command.Names() { - fmt.Fprintln(c.App.Writer, name) + if os.Getenv("_CLI_ZSH_AUTOCOMPLETE_HACK") == "1" { + for _, name := range command.Names() { + fmt.Fprintf(c.App.Writer, "%s:%s\n", name, command.Usage) + } + } else { + for _, name := range command.Names() { + fmt.Fprintf(c.App.Writer, "%s\n", name) + } } } } @@ -230,10 +240,8 @@ func printHelpCustom(out io.Writer, templ string, data interface{}, customFunc m funcMap := template.FuncMap{ "join": strings.Join, } - if customFunc != nil { - for key, value := range customFunc { - funcMap[key] = value - } + for key, value := range customFunc { + funcMap[key] = value } w := tabwriter.NewWriter(out, 1, 8, 2, ' ', 0) diff --git a/vendor/github.com/urfave/cli/sort.go b/vendor/github.com/urfave/cli/sort.go new file mode 100644 index 0000000000..23d1c2f772 --- /dev/null +++ b/vendor/github.com/urfave/cli/sort.go @@ -0,0 +1,29 @@ +package cli + +import "unicode" + +// lexicographicLess compares strings alphabetically considering case. +func lexicographicLess(i, j string) bool { + iRunes := []rune(i) + jRunes := []rune(j) + + lenShared := len(iRunes) + if lenShared > len(jRunes) { + lenShared = len(jRunes) + } + + for index := 0; index < lenShared; index++ { + ir := iRunes[index] + jr := jRunes[index] + + if lir, ljr := unicode.ToLower(ir), unicode.ToLower(jr); lir != ljr { + return lir < ljr + } + + if ir != jr { + return ir < jr + } + } + + return i < j +} diff --git a/vendor/github.com/vbatts/go-mtree/.travis.yml b/vendor/github.com/vbatts/go-mtree/.travis.yml index 39020cc9e5..2f766860c2 100644 --- a/vendor/github.com/vbatts/go-mtree/.travis.yml +++ b/vendor/github.com/vbatts/go-mtree/.travis.yml @@ -1,9 +1,10 @@ language: go go: - - 1.x - - 1.10.x - - 1.9.x - - 1.8.x + - "1.x" + - "1.11.x" + - "1.10.x" + - "1.9.x" + - "1.8.x" sudo: false diff --git a/vendor/github.com/vbatts/go-mtree/Makefile b/vendor/github.com/vbatts/go-mtree/Makefile index a4ec422374..bd98334056 100644 --- a/vendor/github.com/vbatts/go-mtree/Makefile +++ b/vendor/github.com/vbatts/go-mtree/Makefile @@ -32,7 +32,11 @@ lint: .lint CLEAN_FILES += .lint .lint: $(SOURCE_FILES) - set -e ; for dir in $$(glide novendor) ; do golint -set_exit_status $$dir ; done && touch $@ + if [[ "$(go version |awk '{ print $3 }')" =~ ^go1\.11\. ]] ; then \ + set -e ; for dir in $$(glide novendor) ; do golint -set_exit_status $$dir ; done && touch $@ \ + else \ + touch $@ ; \ + fi .PHONY: vet vet: .vet .vet.tags @@ -64,7 +68,7 @@ $(BUILD): $(SOURCE_FILES) install.tools: go get -u -v github.com/Masterminds/glide - go get -u -v golang.org/x/lint/golint + if [[ "$(go version |awk '{ print $3 }')" =~ ^go1\.11\. ]] ; then go get -u golang.org/x/lint/golint ; fi ./bin: mkdir -p $@ diff --git a/vendor/github.com/vbatts/go-mtree/README.md b/vendor/github.com/vbatts/go-mtree/README.md index b285a6f063..ed2c1a63fc 100644 --- a/vendor/github.com/vbatts/go-mtree/README.md +++ b/vendor/github.com/vbatts/go-mtree/README.md @@ -1,6 +1,6 @@ # go-mtree -[![Go Report Card](https://goreportcard.com/badge/github.com/vbatts/go-mtree)](https://goreportcard.com/report/github.com/vbatts/go-mtree) +[![Build Status](https://travis-ci.org/vbatts/go-mtree.svg?branch=master)](https://travis-ci.org/vbatts/go-mtree) [![Go Report Card](https://goreportcard.com/badge/github.com/vbatts/go-mtree)](https://goreportcard.com/report/github.com/vbatts/go-mtree) `mtree` is a filesystem hierarchy validation tooling and format. This is a library and simple cli tool for [mtree(8)][mtree(8)] support. diff --git a/vendor/github.com/vbatts/go-mtree/compare.go b/vendor/github.com/vbatts/go-mtree/compare.go index 458df857ee..625a792fa5 100644 --- a/vendor/github.com/vbatts/go-mtree/compare.go +++ b/vendor/github.com/vbatts/go-mtree/compare.go @@ -350,7 +350,6 @@ func Compare(oldDh, newDh *DirectoryHierarchy, keys []Keyword) ([]InodeDelta, er if err != nil { return nil, err } - //fmt.Printf("new: %q\n", path) // Cannot take &kv because it's the iterator. cEntry := new(Entry) @@ -373,7 +372,6 @@ func Compare(oldDh, newDh *DirectoryHierarchy, keys []Keyword) ([]InodeDelta, er if err != nil { return nil, err } - //fmt.Printf("old: %q\n", path) // Cannot take &kv because it's the iterator. cEntry := new(Entry) diff --git a/vendor/github.com/vbatts/go-mtree/entry.go b/vendor/github.com/vbatts/go-mtree/entry.go index fc8c1c9d8d..366a15b480 100644 --- a/vendor/github.com/vbatts/go-mtree/entry.go +++ b/vendor/github.com/vbatts/go-mtree/entry.go @@ -2,6 +2,7 @@ package mtree import ( "fmt" + "os" "path/filepath" "strings" @@ -67,6 +68,39 @@ func (e Entry) Ascend() *Entry { return e.Parent } +// CleanPath makes a path safe for use with filepath.Join. This is done by not +// only cleaning the path, but also (if the path is relative) adding a leading +// '/' and cleaning it (then removing the leading '/'). This ensures that a +// path resulting from prepending another path will always resolve to lexically +// be a subdirectory of the prefixed path. This is all done lexically, so paths +// that include symlinks won't be safe as a result of using CleanPath. +// +// This code was copied from runc/libcontainer/utils/utils.go. It was +// originally written by myself, so I am dual-licensing it for the purpose of +// this project. +func CleanPath(path string) string { + // Deal with empty strings nicely. + if path == "" { + return "" + } + + // Ensure that all paths are cleaned (especially problematic ones like + // "/../../../../../" which can cause lots of issues). + path = filepath.Clean(path) + + // If the path isn't absolute, we need to do more processing to fix paths + // such as "../../../..//some/path". We also shouldn't convert absolute + // paths to relative ones. + if !filepath.IsAbs(path) { + path = filepath.Clean(string(os.PathSeparator) + path) + // This can't fail, as (by definition) all paths are relative to root. + path, _ = filepath.Rel(string(os.PathSeparator), path) + } + + // Clean the path again for good measure. + return filepath.Clean(path) +} + // Path provides the full path of the file, despite RelativeType or FullType. It // will be in Unvis'd form. func (e Entry) Path() (string, error) { @@ -74,14 +108,15 @@ func (e Entry) Path() (string, error) { if err != nil { return "", err } + decodedName = CleanPath(decodedName) if e.Parent == nil || e.Type == FullType { - return filepath.Clean(decodedName), nil + return decodedName, nil } parentName, err := e.Parent.Path() if err != nil { return "", err } - return filepath.Clean(filepath.Join(parentName, decodedName)), nil + return CleanPath(filepath.Join(parentName, decodedName)), nil } // String joins a file with its associated keywords. The file name will be the diff --git a/vendor/github.com/xeipuuv/gojsonschema/validation.go b/vendor/github.com/xeipuuv/gojsonschema/validation.go index 2f1e7df36c..63786d5f1e 100644 --- a/vendor/github.com/xeipuuv/gojsonschema/validation.go +++ b/vendor/github.com/xeipuuv/gojsonschema/validation.go @@ -747,7 +747,9 @@ func (v *subSchema) validatePatternProperty(currentSubSchema *subSchema, key str subContext := NewJsonContext(key, context) validationResult := pv.subValidateWithContext(value, subContext) result.mergeErrors(validationResult) - validatedkey = true + if validationResult.Valid() { + validatedkey = true + } } } diff --git a/vendor/go4.org/AUTHORS b/vendor/go4.org/AUTHORS new file mode 100644 index 0000000000..d1ad485f52 --- /dev/null +++ b/vendor/go4.org/AUTHORS @@ -0,0 +1,8 @@ +# This is the official list of go4 authors for copyright purposes. +# This is distinct from the CONTRIBUTORS file, which is the list of +# people who have contributed, even if they don't own the copyright on +# their work. + +Mathieu Lonjaret +Daniel Theophanes +Google diff --git a/vendor/go4.org/LICENSE b/vendor/go4.org/LICENSE new file mode 100644 index 0000000000..8f71f43fee --- /dev/null +++ b/vendor/go4.org/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/go4.org/errorutil/highlight.go b/vendor/go4.org/errorutil/highlight.go new file mode 100644 index 0000000000..1b1efb0f68 --- /dev/null +++ b/vendor/go4.org/errorutil/highlight.go @@ -0,0 +1,58 @@ +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package errorutil helps make better error messages. +package errorutil // import "go4.org/errorutil" + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strings" +) + +// HighlightBytePosition takes a reader and the location in bytes of a parse +// error (for instance, from json.SyntaxError.Offset) and returns the line, column, +// and pretty-printed context around the error with an arrow indicating the exact +// position of the syntax error. +func HighlightBytePosition(f io.Reader, pos int64) (line, col int, highlight string) { + line = 1 + br := bufio.NewReader(f) + lastLine := "" + thisLine := new(bytes.Buffer) + for n := int64(0); n < pos; n++ { + b, err := br.ReadByte() + if err != nil { + break + } + if b == '\n' { + lastLine = thisLine.String() + thisLine.Reset() + line++ + col = 1 + } else { + col++ + thisLine.WriteByte(b) + } + } + if line > 1 { + highlight += fmt.Sprintf("%5d: %s\n", line-1, lastLine) + } + highlight += fmt.Sprintf("%5d: %s\n", line, thisLine.String()) + highlight += fmt.Sprintf("%s^\n", strings.Repeat(" ", col+5)) + return +} diff --git a/vendor/golang.org/x/net/proxy/dial.go b/vendor/golang.org/x/net/proxy/dial.go new file mode 100644 index 0000000000..811c2e4e96 --- /dev/null +++ b/vendor/golang.org/x/net/proxy/dial.go @@ -0,0 +1,54 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proxy + +import ( + "context" + "net" +) + +// A ContextDialer dials using a context. +type ContextDialer interface { + DialContext(ctx context.Context, network, address string) (net.Conn, error) +} + +// Dial works like DialContext on net.Dialer but using a dialer returned by FromEnvironment. +// +// The passed ctx is only used for returning the Conn, not the lifetime of the Conn. +// +// Custom dialers (registered via RegisterDialerType) that do not implement ContextDialer +// can leak a goroutine for as long as it takes the underlying Dialer implementation to timeout. +// +// A Conn returned from a successful Dial after the context has been cancelled will be immediately closed. +func Dial(ctx context.Context, network, address string) (net.Conn, error) { + d := FromEnvironment() + if xd, ok := d.(ContextDialer); ok { + return xd.DialContext(ctx, network, address) + } + return dialContext(ctx, d, network, address) +} + +// WARNING: this can leak a goroutine for as long as the underlying Dialer implementation takes to timeout +// A Conn returned from a successful Dial after the context has been cancelled will be immediately closed. +func dialContext(ctx context.Context, d Dialer, network, address string) (net.Conn, error) { + var ( + conn net.Conn + done = make(chan struct{}, 1) + err error + ) + go func() { + conn, err = d.Dial(network, address) + close(done) + if conn != nil && ctx.Err() != nil { + conn.Close() + } + }() + select { + case <-ctx.Done(): + err = ctx.Err() + case <-done: + } + return conn, err +} diff --git a/vendor/golang.org/x/net/proxy/direct.go b/vendor/golang.org/x/net/proxy/direct.go index 4c5ad88b1e..3d66bdef9d 100644 --- a/vendor/golang.org/x/net/proxy/direct.go +++ b/vendor/golang.org/x/net/proxy/direct.go @@ -5,14 +5,27 @@ package proxy import ( + "context" "net" ) type direct struct{} -// Direct is a direct proxy: one that makes network connections directly. +// Direct implements Dialer by making network connections directly using net.Dial or net.DialContext. var Direct = direct{} +var ( + _ Dialer = Direct + _ ContextDialer = Direct +) + +// Dial directly invokes net.Dial with the supplied parameters. func (direct) Dial(network, addr string) (net.Conn, error) { return net.Dial(network, addr) } + +// DialContext instantiates a net.Dialer and invokes its DialContext receiver with the supplied parameters. +func (direct) DialContext(ctx context.Context, network, addr string) (net.Conn, error) { + var d net.Dialer + return d.DialContext(ctx, network, addr) +} diff --git a/vendor/golang.org/x/net/proxy/per_host.go b/vendor/golang.org/x/net/proxy/per_host.go index 0689bb6a70..573fe79e86 100644 --- a/vendor/golang.org/x/net/proxy/per_host.go +++ b/vendor/golang.org/x/net/proxy/per_host.go @@ -5,6 +5,7 @@ package proxy import ( + "context" "net" "strings" ) @@ -41,6 +42,20 @@ func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) { return p.dialerForRequest(host).Dial(network, addr) } +// DialContext connects to the address addr on the given network through either +// defaultDialer or bypass. +func (p *PerHost) DialContext(ctx context.Context, network, addr string) (c net.Conn, err error) { + host, _, err := net.SplitHostPort(addr) + if err != nil { + return nil, err + } + d := p.dialerForRequest(host) + if x, ok := d.(ContextDialer); ok { + return x.DialContext(ctx, network, addr) + } + return dialContext(ctx, d, network, addr) +} + func (p *PerHost) dialerForRequest(host string) Dialer { if ip := net.ParseIP(host); ip != nil { for _, net := range p.bypassNetworks { diff --git a/vendor/golang.org/x/net/proxy/proxy.go b/vendor/golang.org/x/net/proxy/proxy.go index f6026b902c..9ff4b9a776 100644 --- a/vendor/golang.org/x/net/proxy/proxy.go +++ b/vendor/golang.org/x/net/proxy/proxy.go @@ -15,6 +15,7 @@ import ( ) // A Dialer is a means to establish a connection. +// Custom dialers should also implement ContextDialer. type Dialer interface { // Dial connects to the given address via the proxy. Dial(network, addr string) (c net.Conn, err error) @@ -25,21 +26,30 @@ type Auth struct { User, Password string } -// FromEnvironment returns the dialer specified by the proxy related variables in -// the environment. +// FromEnvironment returns the dialer specified by the proxy-related +// variables in the environment and makes underlying connections +// directly. func FromEnvironment() Dialer { + return FromEnvironmentUsing(Direct) +} + +// FromEnvironmentUsing returns the dialer specify by the proxy-related +// variables in the environment and makes underlying connections +// using the provided forwarding Dialer (for instance, a *net.Dialer +// with desired configuration). +func FromEnvironmentUsing(forward Dialer) Dialer { allProxy := allProxyEnv.Get() if len(allProxy) == 0 { - return Direct + return forward } proxyURL, err := url.Parse(allProxy) if err != nil { - return Direct + return forward } - proxy, err := FromURL(proxyURL, Direct) + proxy, err := FromURL(proxyURL, forward) if err != nil { - return Direct + return forward } noProxy := noProxyEnv.Get() @@ -47,7 +57,7 @@ func FromEnvironment() Dialer { return proxy } - perHost := NewPerHost(proxy, Direct) + perHost := NewPerHost(proxy, forward) perHost.AddFromString(noProxy) return perHost } diff --git a/vendor/golang.org/x/net/proxy/socks5.go b/vendor/golang.org/x/net/proxy/socks5.go index 56345ec8b6..c91651f96d 100644 --- a/vendor/golang.org/x/net/proxy/socks5.go +++ b/vendor/golang.org/x/net/proxy/socks5.go @@ -17,8 +17,14 @@ import ( func SOCKS5(network, address string, auth *Auth, forward Dialer) (Dialer, error) { d := socks.NewDialer(network, address) if forward != nil { - d.ProxyDial = func(_ context.Context, network string, address string) (net.Conn, error) { - return forward.Dial(network, address) + if f, ok := forward.(ContextDialer); ok { + d.ProxyDial = func(ctx context.Context, network string, address string) (net.Conn, error) { + return f.DialContext(ctx, network, address) + } + } else { + d.ProxyDial = func(ctx context.Context, network string, address string) (net.Conn, error) { + return dialContext(ctx, forward, network, address) + } } } if auth != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 2685a6a9d2..45bb865aa1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -24,7 +24,7 @@ github.com/Microsoft/hcsshim/internal/safefile github.com/Netflix/go-expect # github.com/alexflint/go-filemutex v0.0.0-20171028004239-d358565f3c3f github.com/alexflint/go-filemutex -# github.com/apex/log v1.1.0 +# github.com/apex/log v1.1.1 github.com/apex/log # github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 github.com/beorn7/perks/quantile @@ -210,11 +210,11 @@ github.com/gorilla/context github.com/gorilla/mux # github.com/gorilla/websocket v1.4.0 github.com/gorilla/websocket -# github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357 +# github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce github.com/hashicorp/errwrap # github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-cleanhttp -# github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0 +# github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 github.com/hashicorp/go-multierror # github.com/hashicorp/go-retryablehttp v0.5.3 github.com/hashicorp/go-retryablehttp @@ -224,21 +224,19 @@ github.com/inconshreveable/mousetrap github.com/j-keck/arping # github.com/juju/errors v0.0.0-20190207033735-e65537c515d7 github.com/juju/errors -# github.com/klauspost/compress v1.4.0 +# github.com/klauspost/compress v1.4.1 github.com/klauspost/compress/flate -# github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 +# github.com/klauspost/cpuid v1.2.0 github.com/klauspost/cpuid -# github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 -github.com/klauspost/crc32 -# github.com/klauspost/pgzip v0.0.0-20170402124221-0bf5dcad4ada +# github.com/klauspost/pgzip v1.2.1 github.com/klauspost/pgzip # github.com/kr/pty v1.1.8 github.com/kr/pty # github.com/kubernetes-sigs/cri-o v0.0.0-20180917213123-8afc34092907 github.com/kubernetes-sigs/cri-o/pkg/seccomp -# github.com/mattn/go-colorable v0.1.1 +# github.com/mattn/go-colorable v0.1.2 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.5 +# github.com/mattn/go-isatty v0.0.8 github.com/mattn/go-isatty # github.com/mattn/go-runewidth v0.0.2 github.com/mattn/go-runewidth @@ -248,7 +246,7 @@ github.com/mattn/go-shellwords github.com/matttproud/golang_protobuf_extensions/pbutil # github.com/mtrmac/gpgme v0.0.0-20170102180018-b2432428689c github.com/mtrmac/gpgme -# github.com/openSUSE/umoci v0.4.4 +# github.com/openSUSE/umoci v0.4.2 github.com/openSUSE/umoci github.com/openSUSE/umoci/oci/layer github.com/openSUSE/umoci/pkg/idtools @@ -262,17 +260,19 @@ github.com/openSUSE/umoci/pkg/system github.com/openSUSE/umoci/pkg/testutils github.com/openSUSE/umoci/pkg/unpriv github.com/openSUSE/umoci/third_party/shared -github.com/openSUSE/umoci/pkg/hardening github.com/openSUSE/umoci/third_party/user # github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/go-digest -# github.com/opencontainers/image-spec v1.0.0 => github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392 +# github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392 github.com/opencontainers/image-spec/specs-go/v1 github.com/opencontainers/image-spec/specs-go +github.com/opencontainers/image-spec/schema +# github.com/opencontainers/image-tools v0.0.0-20180129025323-c95f76cbae74 => github.com/sylabs/image-tools v0.0.0-20181006203805-2814f4980568 +github.com/opencontainers/image-tools/image # github.com/opencontainers/runc v0.1.1 github.com/opencontainers/runc/libcontainer/system github.com/opencontainers/runc/libcontainer/user -# github.com/opencontainers/runtime-spec v1.0.0 => github.com/opencontainers/runtime-spec v0.0.0-20180913141938-5806c3563733 +# github.com/opencontainers/runtime-spec v0.0.0-20180913141938-5806c3563733 github.com/opencontainers/runtime-spec/specs-go # github.com/opencontainers/runtime-tools v0.7.0 github.com/opencontainers/runtime-tools/generate @@ -314,7 +314,7 @@ github.com/safchain/ethtool github.com/satori/go.uuid # github.com/seccomp/libseccomp-golang v0.9.1 github.com/seccomp/libseccomp-golang -# github.com/sirupsen/logrus v1.0.6 +# github.com/sirupsen/logrus v1.0.5 github.com/sirupsen/logrus # github.com/spf13/cobra v0.0.5 github.com/spf13/cobra @@ -335,9 +335,9 @@ github.com/sylabs/sif/pkg/sif github.com/sylabs/sif/internal/app/siftool # github.com/syndtr/gocapability v0.0.0-20180223013746-33e07d32887e github.com/syndtr/gocapability/capability -# github.com/urfave/cli v1.20.0 +# github.com/urfave/cli v1.21.0 github.com/urfave/cli -# github.com/vbatts/go-mtree v0.4.3 +# github.com/vbatts/go-mtree v0.4.4 github.com/vbatts/go-mtree github.com/vbatts/go-mtree/pkg/govis github.com/vbatts/go-mtree/xattr @@ -350,9 +350,11 @@ github.com/vishvananda/netns github.com/xeipuuv/gojsonpointer # github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 github.com/xeipuuv/gojsonreference -# github.com/xeipuuv/gojsonschema v0.0.0-20180719132039-b84684d0e066 +# github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f github.com/xeipuuv/gojsonschema -# golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 => github.com/sylabs/golang-x-crypto v0.0.0-20181006204705-4bce89e8e9a9 +# go4.org v0.0.0-20180417224846-9599cf28b011 +go4.org/errorutil +# golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 => github.com/sylabs/golang-x-crypto v0.0.0-20181006204705-4bce89e8e9a9 golang.org/x/crypto/ssh/terminal golang.org/x/crypto/openpgp golang.org/x/crypto/openpgp/clearsign @@ -363,7 +365,7 @@ golang.org/x/crypto/openpgp/s2k golang.org/x/crypto/cast5 golang.org/x/crypto/openpgp/elgamal golang.org/x/crypto/ripemd160 -# golang.org/x/net v0.0.0-20190311183353-d8887717615a +# golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/net/context/ctxhttp golang.org/x/net/context golang.org/x/net/proxy