summaryrefslogtreecommitdiff
path: root/vendor/github.com
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/containers/image/v5/copy/copy.go11
-rw-r--r--vendor/github.com/containers/image/v5/docker/docker_client.go1
-rw-r--r--vendor/github.com/containers/image/v5/internal/pkg/platform/platform_matcher.go6
-rw-r--r--vendor/github.com/containers/image/v5/manifest/docker_schema2.go7
-rw-r--r--vendor/github.com/containers/image/v5/openshift/openshift-copies.go4
-rw-r--r--vendor/github.com/containers/image/v5/types/types.go1
-rw-r--r--vendor/github.com/containers/image/v5/version/version.go4
-rw-r--r--vendor/github.com/containers/ocicrypt/CODE-OF-CONDUCT.md3
-rw-r--r--vendor/github.com/containers/ocicrypt/LICENSE189
-rw-r--r--vendor/github.com/containers/ocicrypt/README.md7
-rw-r--r--vendor/github.com/containers/ocicrypt/encryption.go7
-rw-r--r--vendor/github.com/containers/ocicrypt/go.mod1
-rw-r--r--vendor/github.com/containers/ocicrypt/go.sum10
-rw-r--r--vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go4
-rw-r--r--vendor/github.com/containers/ocicrypt/keywrap/keywrap.go8
-rw-r--r--vendor/github.com/containers/ocicrypt/keywrap/pgp/keywrapper_gpg.go4
-rw-r--r--vendor/github.com/containers/ocicrypt/keywrap/pkcs7/keywrapper_pkcs7.go4
-rw-r--r--vendor/github.com/containers/storage/VERSION2
-rw-r--r--vendor/github.com/containers/storage/go.mod2
-rw-r--r--vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go2
-rw-r--r--vendor/github.com/gogo/protobuf/proto/encode.go2
-rw-r--r--vendor/github.com/gogo/protobuf/proto/lib.go20
-rw-r--r--vendor/github.com/gogo/protobuf/proto/properties.go71
-rw-r--r--vendor/github.com/gogo/protobuf/proto/table_marshal.go17
-rw-r--r--vendor/github.com/gogo/protobuf/proto/table_merge.go19
-rw-r--r--vendor/github.com/gogo/protobuf/proto/table_unmarshal.go22
-rw-r--r--vendor/github.com/gogo/protobuf/proto/text.go6
-rw-r--r--vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor.pb.go10
-rw-r--r--vendor/github.com/imdario/mergo/.deepsource.toml12
-rw-r--r--vendor/github.com/imdario/mergo/map.go7
-rw-r--r--vendor/github.com/imdario/mergo/merge.go233
-rw-r--r--vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go88
-rw-r--r--vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go14
-rw-r--r--vendor/github.com/vbauerster/mpb/v4/go.mod10
-rw-r--r--vendor/github.com/vbauerster/mpb/v4/proxyreader.go41
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/.gitignore (renamed from vendor/github.com/vbauerster/mpb/v4/.gitignore)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/.travis.yml (renamed from vendor/github.com/vbauerster/mpb/v4/.travis.yml)6
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/README.md (renamed from vendor/github.com/vbauerster/mpb/v4/README.md)20
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/UNLICENSE (renamed from vendor/github.com/vbauerster/mpb/v4/UNLICENSE)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/bar.go (renamed from vendor/github.com/vbauerster/mpb/v4/bar.go)193
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/bar_filler.go (renamed from vendor/github.com/vbauerster/mpb/v4/bar_filler.go)8
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/bar_option.go (renamed from vendor/github.com/vbauerster/mpb/v4/bar_option.go)48
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer.go (renamed from vendor/github.com/vbauerster/mpb/v4/cwriter/writer.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go (renamed from vendor/github.com/vbauerster/mpb/v4/cwriter/writer_posix.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go (renamed from vendor/github.com/vbauerster/mpb/v4/cwriter/writer_windows.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/any.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/any.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/counters.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/counters.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/decorator.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/decorator.go)26
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/doc.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/doc.go)2
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/elapsed.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/elapsed.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/eta.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/eta.go)18
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/merge.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/merge.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/moving_average.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/moving_average.go)7
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/name.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/name.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/on_complete.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/on_complete.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/percentage.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/percentage.go)2
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/size_type.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/size_type.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/sizeb1000_string.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/sizeb1000_string.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/sizeb1024_string.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/sizeb1024_string.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/speed.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/speed.go)18
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/spinner.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/spinner.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/doc.go (renamed from vendor/github.com/vbauerster/mpb/v4/doc.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/go.mod10
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/go.sum (renamed from vendor/github.com/vbauerster/mpb/v4/go.sum)8
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/internal/percentage.go (renamed from vendor/github.com/vbauerster/mpb/v4/internal/percentage.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/options.go (renamed from vendor/github.com/vbauerster/mpb/v4/options.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/priority_queue.go (renamed from vendor/github.com/vbauerster/mpb/v4/priority_queue.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/progress.go (renamed from vendor/github.com/vbauerster/mpb/v4/progress.go)17
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/proxyreader.go90
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/spinner_filler.go (renamed from vendor/github.com/vbauerster/mpb/v4/spinner_filler.go)6
-rw-r--r--vendor/github.com/xeipuuv/gojsonschema/.travis.yml2
-rw-r--r--vendor/github.com/xeipuuv/gojsonschema/draft.go5
-rw-r--r--vendor/github.com/xeipuuv/gojsonschema/jsonLoader.go7
73 files changed, 885 insertions, 457 deletions
diff --git a/vendor/github.com/containers/image/v5/copy/copy.go b/vendor/github.com/containers/image/v5/copy/copy.go
index 0b0fbc004..e8610254c 100644
--- a/vendor/github.com/containers/image/v5/copy/copy.go
+++ b/vendor/github.com/containers/image/v5/copy/copy.go
@@ -27,8 +27,8 @@ import (
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "github.com/vbauerster/mpb/v4"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5"
+ "github.com/vbauerster/mpb/v5/decor"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/sync/semaphore"
)
@@ -484,6 +484,9 @@ func (c *copier) copyMultipleImages(ctx context.Context, policyContext *signatur
return nil, "", errors.Errorf("Error: manifest list must be converted to type %q to be written to destination, but that would invalidate signatures", thisListType)
}
logrus.Debugf("Manifest list has been updated")
+ } else {
+ // We can just use the original value, so use it instead of the one we just rebuilt, so that we don't change the digest.
+ attemptedManifestList = manifestList
}
// Save the manifest list.
@@ -976,7 +979,7 @@ func (c *copier) createProgressBar(pool *mpb.Progress, info types.BlobInfo, kind
var bar *mpb.Bar
if info.Size > 0 {
bar = pool.AddBar(info.Size,
- mpb.BarClearOnComplete(),
+ mpb.BarFillerClearOnComplete(),
mpb.PrependDecorators(
decor.OnComplete(decor.Name(prefix), onComplete),
),
@@ -987,7 +990,7 @@ func (c *copier) createProgressBar(pool *mpb.Progress, info types.BlobInfo, kind
} else {
bar = pool.AddSpinner(info.Size,
mpb.SpinnerOnLeft,
- mpb.BarClearOnComplete(),
+ mpb.BarFillerClearOnComplete(),
mpb.SpinnerStyle([]string{".", "..", "...", "....", ""}),
mpb.PrependDecorators(
decor.OnComplete(decor.Name(prefix), onComplete),
diff --git a/vendor/github.com/containers/image/v5/docker/docker_client.go b/vendor/github.com/containers/image/v5/docker/docker_client.go
index c316bdeec..c5c49b90b 100644
--- a/vendor/github.com/containers/image/v5/docker/docker_client.go
+++ b/vendor/github.com/containers/image/v5/docker/docker_client.go
@@ -610,6 +610,7 @@ func (c *dockerClient) getBearerTokenOAuth2(ctx context.Context, challenge chall
}
params.Add("grant_type", "refresh_token")
params.Add("refresh_token", c.auth.IdentityToken)
+ params.Add("client_id", "containers/image")
authReq.Body = ioutil.NopCloser(bytes.NewBufferString(params.Encode()))
authReq.Header.Add("Content-Type", "application/x-www-form-urlencoded")
diff --git a/vendor/github.com/containers/image/v5/internal/pkg/platform/platform_matcher.go b/vendor/github.com/containers/image/v5/internal/pkg/platform/platform_matcher.go
index 1f6c4fa71..c23457642 100644
--- a/vendor/github.com/containers/image/v5/internal/pkg/platform/platform_matcher.go
+++ b/vendor/github.com/containers/image/v5/internal/pkg/platform/platform_matcher.go
@@ -62,11 +62,11 @@ func getCPUInfo(pattern string) (info string, err error) {
return "", fmt.Errorf("getCPUInfo for pattern: %s not found", pattern)
}
-func getCPUVariantWindows() string {
+func getCPUVariantWindows(arch string) string {
// Windows only supports v7 for ARM32 and v8 for ARM64 and so we can use
// runtime.GOARCH to determine the variants
var variant string
- switch runtime.GOARCH {
+ switch arch {
case "arm64":
variant = "v8"
case "arm":
@@ -107,7 +107,7 @@ func getCPUVariantArm() string {
func getCPUVariant(os string, arch string) string {
if os == "windows" {
- return getCPUVariantWindows()
+ return getCPUVariantWindows(arch)
}
if arch == "arm" || arch == "arm64" {
return getCPUVariantArm()
diff --git a/vendor/github.com/containers/image/v5/manifest/docker_schema2.go b/vendor/github.com/containers/image/v5/manifest/docker_schema2.go
index d768d6e11..ff0780fe3 100644
--- a/vendor/github.com/containers/image/v5/manifest/docker_schema2.go
+++ b/vendor/github.com/containers/image/v5/manifest/docker_schema2.go
@@ -118,9 +118,11 @@ type Schema2V1Image struct {
Author string `json:"author,omitempty"`
// Config is the configuration of the container received from the client
Config *Schema2Config `json:"config,omitempty"`
- // Architecture is the hardware that the image is build and runs on
+ // Architecture is the hardware that the image is built and runs on
Architecture string `json:"architecture,omitempty"`
- // OS is the operating system used to build and run the image
+ // Variant is a variant of the CPU that the image is built and runs on
+ Variant string `json:"variant,omitempty"`
+ // OS is the operating system used to built and run the image
OS string `json:"os,omitempty"`
// Size is the total size of the image including all layers it is composed of
Size int64 `json:",omitempty"`
@@ -330,6 +332,7 @@ func (m *Schema2) Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*t
Created: &s2.Created,
DockerVersion: s2.DockerVersion,
Architecture: s2.Architecture,
+ Variant: s2.Variant,
Os: s2.OS,
Layers: layerInfosToStrings(m.LayerInfos()),
}
diff --git a/vendor/github.com/containers/image/v5/openshift/openshift-copies.go b/vendor/github.com/containers/image/v5/openshift/openshift-copies.go
index 38244926f..4b081bb29 100644
--- a/vendor/github.com/containers/image/v5/openshift/openshift-copies.go
+++ b/vendor/github.com/containers/image/v5/openshift/openshift-copies.go
@@ -16,12 +16,12 @@ import (
"strings"
"time"
+ "github.com/containers/storage/pkg/homedir"
"github.com/ghodss/yaml"
"github.com/imdario/mergo"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/http2"
- "k8s.io/client-go/util/homedir"
)
// restTLSClientConfig is a modified copy of k8s.io/kubernets/pkg/client/restclient.TLSClientConfig.
@@ -90,7 +90,7 @@ func defaultClientConfig() clientConfig {
return clientConfig
}
-var recommendedHomeFile = path.Join(homedir.HomeDir(), ".kube/config")
+var recommendedHomeFile = path.Join(homedir.Get(), ".kube/config")
// newOpenShiftClientConfigLoadingRules is a modified copy of openshift/origin/pkg/cmd/cli/config.NewOpenShiftClientConfigLoadingRules.
// NewOpenShiftClientConfigLoadingRules returns file priority loading rules for OpenShift.
diff --git a/vendor/github.com/containers/image/v5/types/types.go b/vendor/github.com/containers/image/v5/types/types.go
index 40556d007..d469e03b5 100644
--- a/vendor/github.com/containers/image/v5/types/types.go
+++ b/vendor/github.com/containers/image/v5/types/types.go
@@ -444,6 +444,7 @@ type ImageInspectInfo struct {
DockerVersion string
Labels map[string]string
Architecture string
+ Variant string
Os string
Layers []string
Env []string
diff --git a/vendor/github.com/containers/image/v5/version/version.go b/vendor/github.com/containers/image/v5/version/version.go
index 4b04d56fc..717c2b1b3 100644
--- a/vendor/github.com/containers/image/v5/version/version.go
+++ b/vendor/github.com/containers/image/v5/version/version.go
@@ -6,9 +6,9 @@ const (
// VersionMajor is for an API incompatible changes
VersionMajor = 5
// VersionMinor is for functionality in a backwards-compatible manner
- VersionMinor = 3
+ VersionMinor = 4
// VersionPatch is for backwards-compatible bug fixes
- VersionPatch = 1
+ VersionPatch = 3
// VersionDev indicates development branch. Releases will be empty string.
VersionDev = ""
diff --git a/vendor/github.com/containers/ocicrypt/CODE-OF-CONDUCT.md b/vendor/github.com/containers/ocicrypt/CODE-OF-CONDUCT.md
new file mode 100644
index 000000000..5131b5a37
--- /dev/null
+++ b/vendor/github.com/containers/ocicrypt/CODE-OF-CONDUCT.md
@@ -0,0 +1,3 @@
+## The OCIcrypt Library Project Community Code of Conduct
+
+The OCIcrypt Library project follows the [Containers Community Code of Conduct](https://github.com/containers/common/blob/master/CODE-OF-CONDUCT.md).
diff --git a/vendor/github.com/containers/ocicrypt/LICENSE b/vendor/github.com/containers/ocicrypt/LICENSE
new file mode 100644
index 000000000..953563530
--- /dev/null
+++ b/vendor/github.com/containers/ocicrypt/LICENSE
@@ -0,0 +1,189 @@
+
+ Apache License
+ Version 2.0, January 2004
+ https://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
+
+ 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
+
+ https://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/containers/ocicrypt/README.md b/vendor/github.com/containers/ocicrypt/README.md
index ec5ae5b35..9f64bddcc 100644
--- a/vendor/github.com/containers/ocicrypt/README.md
+++ b/vendor/github.com/containers/ocicrypt/README.md
@@ -2,6 +2,13 @@
The `ocicrypt` library is the OCI image spec implementation of container image encryption. More details of the spec can be seen in the [OCI repository](https://github.com/opencontainers/image-spec/pull/775). The purpose of this library is to encode spec structures and consts in code, as well as provide a consistent implementation of image encryption across container runtimes and build tools.
+Consumers of OCIcrypt:
+
+- [containerd/imgcrypt](https://github.com/containerd/imgcrypt)
+- [cri-o](https://github.com/cri-o/cri-o)
+- [skopeo](https://github.com/containers/skopeo)
+
+
## Usage
There are various levels of usage for this library. The main consumers of these would be runtime/buil tools, and a more specific use would be in the ability to extend cryptographic function.
diff --git a/vendor/github.com/containers/ocicrypt/encryption.go b/vendor/github.com/containers/ocicrypt/encryption.go
index 139ff5f93..3153b63d7 100644
--- a/vendor/github.com/containers/ocicrypt/encryption.go
+++ b/vendor/github.com/containers/ocicrypt/encryption.go
@@ -196,10 +196,13 @@ func decryptLayerKeyOptsData(dc *config.DecryptConfig, desc ocispec.Descriptor)
if b64Annotation != "" {
keywrapper := GetKeyWrapper(scheme)
- if len(keywrapper.GetPrivateKeys(dc.Parameters)) == 0 {
+ if keywrapper.NoPossibleKeys(dc.Parameters) {
continue
}
- privKeyGiven = true
+
+ if len(keywrapper.GetPrivateKeys(dc.Parameters)) > 0 {
+ privKeyGiven = true
+ }
optsData, err := preUnwrapKey(keywrapper, dc, b64Annotation)
if err != nil {
diff --git a/vendor/github.com/containers/ocicrypt/go.mod b/vendor/github.com/containers/ocicrypt/go.mod
index 214496e05..002a526b5 100644
--- a/vendor/github.com/containers/ocicrypt/go.mod
+++ b/vendor/github.com/containers/ocicrypt/go.mod
@@ -10,7 +10,6 @@ require (
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/stretchr/testify v1.3.0 // indirect
- github.com/urfave/cli v1.22.1
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
google.golang.org/grpc v1.24.0 // indirect
gopkg.in/square/go-jose.v2 v2.3.1
diff --git a/vendor/github.com/containers/ocicrypt/go.sum b/vendor/github.com/containers/ocicrypt/go.sum
index d4c40e3ae..935d373d2 100644
--- a/vendor/github.com/containers/ocicrypt/go.sum
+++ b/vendor/github.com/containers/ocicrypt/go.sum
@@ -3,8 +3,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/containerd/containerd v1.2.10 h1:liQDhXqIn7y6cJ/7qBgOaZsiTZJc56/wkkhDBiDBRDw=
github.com/containerd/containerd v1.2.10/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
-github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
-github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -28,10 +26,6 @@ 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/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
-github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
-github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
-github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -64,10 +56,8 @@ 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.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s=
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go b/vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go
index 5d1dde241..41d0f1b3a 100644
--- a/vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go
+++ b/vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go
@@ -91,6 +91,10 @@ func (kw *jweKeyWrapper) UnwrapKey(dc *config.DecryptConfig, jweString []byte) (
return nil, errors.New("JWE: No suitable private key found for decryption")
}
+func (kw *jweKeyWrapper) NoPossibleKeys(dcparameters map[string][][]byte) bool {
+ return len(kw.GetPrivateKeys(dcparameters)) == 0
+}
+
func (kw *jweKeyWrapper) GetPrivateKeys(dcparameters map[string][][]byte) [][]byte {
return dcparameters["privkeys"]
}
diff --git a/vendor/github.com/containers/ocicrypt/keywrap/keywrap.go b/vendor/github.com/containers/ocicrypt/keywrap/keywrap.go
index 75fdf6886..ed25e7dac 100644
--- a/vendor/github.com/containers/ocicrypt/keywrap/keywrap.go
+++ b/vendor/github.com/containers/ocicrypt/keywrap/keywrap.go
@@ -26,15 +26,23 @@ type KeyWrapper interface {
WrapKeys(ec *config.EncryptConfig, optsData []byte) ([]byte, error)
UnwrapKey(dc *config.DecryptConfig, annotation []byte) ([]byte, error)
GetAnnotationID() string
+
+ // NoPossibleKeys returns true if there is no possibility of performing
+ // decryption for parameters provided.
+ NoPossibleKeys(dcparameters map[string][][]byte) bool
+
// GetPrivateKeys (optional) gets the array of private keys. It is an optional implementation
// as in some key services, a private key may not be exportable (i.e. HSM)
+ // If not implemented, return nil
GetPrivateKeys(dcparameters map[string][][]byte) [][]byte
// GetKeyIdsFromPacket (optional) gets a list of key IDs. This is optional as some encryption
// schemes may not have a notion of key IDs
+ // If not implemented, return the nil slice
GetKeyIdsFromPacket(packet string) ([]uint64, error)
// GetRecipients (optional) gets a list of recipients. It is optional due to the validity of
// recipients in a particular encryptiong scheme
+ // If not implemented, return the nil slice
GetRecipients(packet string) ([]string, error)
}
diff --git a/vendor/github.com/containers/ocicrypt/keywrap/pgp/keywrapper_gpg.go b/vendor/github.com/containers/ocicrypt/keywrap/pgp/keywrapper_gpg.go
index ff70c2d65..275a3d8b9 100644
--- a/vendor/github.com/containers/ocicrypt/keywrap/pgp/keywrapper_gpg.go
+++ b/vendor/github.com/containers/ocicrypt/keywrap/pgp/keywrapper_gpg.go
@@ -191,6 +191,10 @@ func (kw *gpgKeyWrapper) GetRecipients(b64pgpPackets string) ([]string, error) {
return array, nil
}
+func (kw *gpgKeyWrapper) NoPossibleKeys(dcparameters map[string][][]byte) bool {
+ return len(kw.GetPrivateKeys(dcparameters)) == 0
+}
+
func (kw *gpgKeyWrapper) GetPrivateKeys(dcparameters map[string][][]byte) [][]byte {
return dcparameters["gpg-privatekeys"]
}
diff --git a/vendor/github.com/containers/ocicrypt/keywrap/pkcs7/keywrapper_pkcs7.go b/vendor/github.com/containers/ocicrypt/keywrap/pkcs7/keywrapper_pkcs7.go
index 2762b9777..eeba64748 100644
--- a/vendor/github.com/containers/ocicrypt/keywrap/pkcs7/keywrapper_pkcs7.go
+++ b/vendor/github.com/containers/ocicrypt/keywrap/pkcs7/keywrapper_pkcs7.go
@@ -70,6 +70,10 @@ func collectX509s(x509s [][]byte) ([]*x509.Certificate, error) {
return x509Certs, nil
}
+func (kw *pkcs7KeyWrapper) NoPossibleKeys(dcparameters map[string][][]byte) bool {
+ return len(kw.GetPrivateKeys(dcparameters)) == 0
+}
+
func (kw *pkcs7KeyWrapper) GetPrivateKeys(dcparameters map[string][][]byte) [][]byte {
return dcparameters["privkeys"]
}
diff --git a/vendor/github.com/containers/storage/VERSION b/vendor/github.com/containers/storage/VERSION
index ec6d649be..b57fc7228 100644
--- a/vendor/github.com/containers/storage/VERSION
+++ b/vendor/github.com/containers/storage/VERSION
@@ -1 +1 @@
-1.18.1
+1.18.2
diff --git a/vendor/github.com/containers/storage/go.mod b/vendor/github.com/containers/storage/go.mod
index b2426c9f9..f18f84f2f 100644
--- a/vendor/github.com/containers/storage/go.mod
+++ b/vendor/github.com/containers/storage/go.mod
@@ -16,7 +16,7 @@ require (
github.com/opencontainers/selinux v1.4.0
github.com/pkg/errors v0.9.1
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7
- github.com/sirupsen/logrus v1.5.0
+ github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.5.1
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2
github.com/tchap/go-patricia v2.3.0+incompatible
diff --git a/vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go b/vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
index e352808b9..1e91766ae 100644
--- a/vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
+++ b/vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
@@ -19,7 +19,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil),
diff --git a/vendor/github.com/gogo/protobuf/proto/encode.go b/vendor/github.com/gogo/protobuf/proto/encode.go
index 3abfed2cf..9581ccd30 100644
--- a/vendor/github.com/gogo/protobuf/proto/encode.go
+++ b/vendor/github.com/gogo/protobuf/proto/encode.go
@@ -189,6 +189,8 @@ type Marshaler interface {
// prefixed by a varint-encoded length.
func (p *Buffer) EncodeMessage(pb Message) error {
siz := Size(pb)
+ sizVar := SizeVarint(uint64(siz))
+ p.grow(siz + sizVar)
p.EncodeVarint(uint64(siz))
return p.Marshal(pb)
}
diff --git a/vendor/github.com/gogo/protobuf/proto/lib.go b/vendor/github.com/gogo/protobuf/proto/lib.go
index d17f80209..80db1c155 100644
--- a/vendor/github.com/gogo/protobuf/proto/lib.go
+++ b/vendor/github.com/gogo/protobuf/proto/lib.go
@@ -948,13 +948,19 @@ func isProto3Zero(v reflect.Value) bool {
return false
}
-// ProtoPackageIsVersion2 is referenced from generated protocol buffer files
-// to assert that that code is compatible with this version of the proto package.
-const GoGoProtoPackageIsVersion2 = true
-
-// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
-// to assert that that code is compatible with this version of the proto package.
-const GoGoProtoPackageIsVersion1 = true
+const (
+ // ProtoPackageIsVersion3 is referenced from generated protocol buffer files
+ // to assert that that code is compatible with this version of the proto package.
+ GoGoProtoPackageIsVersion3 = true
+
+ // ProtoPackageIsVersion2 is referenced from generated protocol buffer files
+ // to assert that that code is compatible with this version of the proto package.
+ GoGoProtoPackageIsVersion2 = true
+
+ // ProtoPackageIsVersion1 is referenced from generated protocol buffer files
+ // to assert that that code is compatible with this version of the proto package.
+ GoGoProtoPackageIsVersion1 = true
+)
// InternalMessageInfo is a type used internally by generated .pb.go files.
// This type is not intended to be used by non-generated code.
diff --git a/vendor/github.com/gogo/protobuf/proto/properties.go b/vendor/github.com/gogo/protobuf/proto/properties.go
index c9e5fa020..28da1475f 100644
--- a/vendor/github.com/gogo/protobuf/proto/properties.go
+++ b/vendor/github.com/gogo/protobuf/proto/properties.go
@@ -43,7 +43,6 @@ package proto
import (
"fmt"
"log"
- "os"
"reflect"
"sort"
"strconv"
@@ -205,7 +204,7 @@ func (p *Properties) Parse(s string) {
// "bytes,49,opt,name=foo,def=hello!"
fields := strings.Split(s, ",") // breaks def=, but handled below.
if len(fields) < 2 {
- fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s)
+ log.Printf("proto: tag has too few fields: %q", s)
return
}
@@ -225,7 +224,7 @@ func (p *Properties) Parse(s string) {
p.WireType = WireBytes
// no numeric converter for non-numeric types
default:
- fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s)
+ log.Printf("proto: tag has unknown wire type: %q", s)
return
}
@@ -400,6 +399,15 @@ func GetProperties(t reflect.Type) *StructProperties {
return sprop
}
+type (
+ oneofFuncsIface interface {
+ XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
+ }
+ oneofWrappersIface interface {
+ XXX_OneofWrappers() []interface{}
+ }
+)
+
// getPropertiesLocked requires that propertiesMu is held.
func getPropertiesLocked(t reflect.Type) *StructProperties {
if prop, ok := propertiesMap[t]; ok {
@@ -441,37 +449,40 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
// Re-order prop.order.
sort.Sort(prop)
- type oneofMessage interface {
- XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
- }
- if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
+ if isOneofMessage {
var oots []interface{}
- _, _, _, oots = om.XXX_OneofFuncs()
-
- // Interpret oneof metadata.
- prop.OneofTypes = make(map[string]*OneofProperties)
- for _, oot := range oots {
- oop := &OneofProperties{
- Type: reflect.ValueOf(oot).Type(), // *T
- Prop: new(Properties),
- }
- sft := oop.Type.Elem().Field(0)
- oop.Prop.Name = sft.Name
- oop.Prop.Parse(sft.Tag.Get("protobuf"))
- // There will be exactly one interface field that
- // this new value is assignable to.
- for i := 0; i < t.NumField(); i++ {
- f := t.Field(i)
- if f.Type.Kind() != reflect.Interface {
- continue
+ switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
+ case oneofFuncsIface:
+ _, _, _, oots = m.XXX_OneofFuncs()
+ case oneofWrappersIface:
+ oots = m.XXX_OneofWrappers()
+ }
+ if len(oots) > 0 {
+ // Interpret oneof metadata.
+ prop.OneofTypes = make(map[string]*OneofProperties)
+ for _, oot := range oots {
+ oop := &OneofProperties{
+ Type: reflect.ValueOf(oot).Type(), // *T
+ Prop: new(Properties),
}
- if !oop.Type.AssignableTo(f.Type) {
- continue
+ sft := oop.Type.Elem().Field(0)
+ oop.Prop.Name = sft.Name
+ oop.Prop.Parse(sft.Tag.Get("protobuf"))
+ // There will be exactly one interface field that
+ // this new value is assignable to.
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ if f.Type.Kind() != reflect.Interface {
+ continue
+ }
+ if !oop.Type.AssignableTo(f.Type) {
+ continue
+ }
+ oop.Field = i
+ break
}
- oop.Field = i
- break
+ prop.OneofTypes[oop.Prop.OrigName] = oop
}
- prop.OneofTypes[oop.Prop.OrigName] = oop
}
}
diff --git a/vendor/github.com/gogo/protobuf/proto/table_marshal.go b/vendor/github.com/gogo/protobuf/proto/table_marshal.go
index 9b1538d05..f8babdefa 100644
--- a/vendor/github.com/gogo/protobuf/proto/table_marshal.go
+++ b/vendor/github.com/gogo/protobuf/proto/table_marshal.go
@@ -389,8 +389,13 @@ func (u *marshalInfo) computeMarshalInfo() {
// get oneof implementers
var oneofImplementers []interface{}
// gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler
- if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok && isOneofMessage {
- _, _, _, oneofImplementers = m.XXX_OneofFuncs()
+ if isOneofMessage {
+ switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
+ case oneofFuncsIface:
+ _, _, _, oneofImplementers = m.XXX_OneofFuncs()
+ case oneofWrappersIface:
+ oneofImplementers = m.XXX_OneofWrappers()
+ }
}
// normal fields
@@ -519,10 +524,6 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI
}
}
-type oneofMessage interface {
- XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
-}
-
// wiretype returns the wire encoding of the type.
func wiretype(encoding string) uint64 {
switch encoding {
@@ -2968,7 +2969,9 @@ func (p *Buffer) Marshal(pb Message) error {
if m, ok := pb.(newMarshaler); ok {
siz := m.XXX_Size()
p.grow(siz) // make sure buf has enough capacity
- p.buf, err = m.XXX_Marshal(p.buf, p.deterministic)
+ pp := p.buf[len(p.buf) : len(p.buf) : len(p.buf)+siz]
+ pp, err = m.XXX_Marshal(pp, p.deterministic)
+ p.buf = append(p.buf, pp...)
return err
}
if m, ok := pb.(Marshaler); ok {
diff --git a/vendor/github.com/gogo/protobuf/proto/table_merge.go b/vendor/github.com/gogo/protobuf/proto/table_merge.go
index f520106e0..60dcf70d1 100644
--- a/vendor/github.com/gogo/protobuf/proto/table_merge.go
+++ b/vendor/github.com/gogo/protobuf/proto/table_merge.go
@@ -530,6 +530,25 @@ func (mi *mergeInfo) computeMergeInfo() {
}
case reflect.Struct:
switch {
+ case isSlice && !isPointer: // E.g. []pb.T
+ mergeInfo := getMergeInfo(tf)
+ zero := reflect.Zero(tf)
+ mfi.merge = func(dst, src pointer) {
+ // TODO: Make this faster?
+ dstsp := dst.asPointerTo(f.Type)
+ dsts := dstsp.Elem()
+ srcs := src.asPointerTo(f.Type).Elem()
+ for i := 0; i < srcs.Len(); i++ {
+ dsts = reflect.Append(dsts, zero)
+ srcElement := srcs.Index(i).Addr()
+ dstElement := dsts.Index(dsts.Len() - 1).Addr()
+ mergeInfo.merge(valToPointer(dstElement), valToPointer(srcElement))
+ }
+ if dsts.IsNil() {
+ dsts = reflect.MakeSlice(f.Type, 0, 0)
+ }
+ dstsp.Elem().Set(dsts)
+ }
case !isPointer:
mergeInfo := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) {
diff --git a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go
index bb2622f28..937229386 100644
--- a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go
+++ b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go
@@ -371,15 +371,18 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
}
// Find any types associated with oneof fields.
- // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it?
- fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs")
// gogo: len(oneofFields) > 0 is needed for embedded oneof messages, without a marshaler and unmarshaler
- if fn.IsValid() && len(oneofFields) > 0 {
- res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{}
- for i := res.Len() - 1; i >= 0; i-- {
- v := res.Index(i) // interface{}
- tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X
- typ := tptr.Elem() // Msg_X
+ if len(oneofFields) > 0 {
+ var oneofImplementers []interface{}
+ switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
+ case oneofFuncsIface:
+ _, _, _, oneofImplementers = m.XXX_OneofFuncs()
+ case oneofWrappersIface:
+ oneofImplementers = m.XXX_OneofWrappers()
+ }
+ for _, v := range oneofImplementers {
+ tptr := reflect.TypeOf(v) // *Msg_X
+ typ := tptr.Elem() // Msg_X
f := typ.Field(0) // oneof implementers have one field
baseUnmarshal := fieldUnmarshaler(&f)
@@ -407,11 +410,12 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
u.setTag(fieldNum, of.field, unmarshal, 0, name)
}
}
+
}
}
// Get extension ranges, if any.
- fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray")
+ fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray")
if fn.IsValid() {
if !u.extensions.IsValid() && !u.oldExtensions.IsValid() && !u.bytesExtensions.IsValid() {
panic("a message with extensions, but no extensions field in " + t.Name())
diff --git a/vendor/github.com/gogo/protobuf/proto/text.go b/vendor/github.com/gogo/protobuf/proto/text.go
index 0407ba85d..87416afe9 100644
--- a/vendor/github.com/gogo/protobuf/proto/text.go
+++ b/vendor/github.com/gogo/protobuf/proto/text.go
@@ -476,6 +476,8 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return nil
}
+var textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
+
// writeAny writes an arbitrary field.
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
@@ -589,8 +591,8 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
// mutating this value.
v = v.Addr()
}
- if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
- text, err := etm.MarshalText()
+ if v.Type().Implements(textMarshalerType) {
+ text, err := v.Interface().(encoding.TextMarshaler).MarshalText()
if err != nil {
return err
}
diff --git a/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor.pb.go b/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor.pb.go
index cacfa3923..18b2a3318 100644
--- a/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor.pb.go
+++ b/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor.pb.go
@@ -18,7 +18,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type FieldDescriptorProto_Type int32
@@ -1364,8 +1364,8 @@ type FileOptions struct {
// determining the namespace.
PhpNamespace *string `protobuf:"bytes,41,opt,name=php_namespace,json=phpNamespace" json:"php_namespace,omitempty"`
// Use this option to change the namespace of php generated metadata classes.
- // Default is empty. When this option is empty, the proto file name will be used
- // for determining the namespace.
+ // Default is empty. When this option is empty, the proto file name will be
+ // used for determining the namespace.
PhpMetadataNamespace *string `protobuf:"bytes,44,opt,name=php_metadata_namespace,json=phpMetadataNamespace" json:"php_metadata_namespace,omitempty"`
// Use this option to change the package of ruby generated classes. Default
// is empty. When this option is not set, the package name will be used for
@@ -1615,7 +1615,7 @@ type MessageOptions struct {
//
// Implementations may choose not to generate the map_entry=true message, but
// use a native map in the target language to hold the keys and values.
- // The reflection APIs in such implementions still need to work as
+ // The reflection APIs in such implementations still need to work as
// if the field is a repeated message field.
//
// NOTE: Do not set the option in .proto files. Always use the maps syntax
@@ -2363,7 +2363,7 @@ type SourceCodeInfo struct {
// beginning of the "extend" block and is shared by all extensions within
// the block.
// - Just because a location's span is a subset of some other location's span
- // does not mean that it is a descendent. For example, a "group" defines
+ // does not mean that it is a descendant. For example, a "group" defines
// both a type and a field in a single declaration. Thus, the locations
// corresponding to the type and field and their components will overlap.
// - Code which tries to interpret locations should probably be designed to
diff --git a/vendor/github.com/imdario/mergo/.deepsource.toml b/vendor/github.com/imdario/mergo/.deepsource.toml
new file mode 100644
index 000000000..8a0681af8
--- /dev/null
+++ b/vendor/github.com/imdario/mergo/.deepsource.toml
@@ -0,0 +1,12 @@
+version = 1
+
+test_patterns = [
+ "*_test.go"
+]
+
+[[analyzers]]
+name = "go"
+enabled = true
+
+ [analyzers.meta]
+ import_path = "github.com/imdario/mergo" \ No newline at end of file
diff --git a/vendor/github.com/imdario/mergo/map.go b/vendor/github.com/imdario/mergo/map.go
index 3f5afa83a..d83258b4d 100644
--- a/vendor/github.com/imdario/mergo/map.go
+++ b/vendor/github.com/imdario/mergo/map.go
@@ -99,11 +99,11 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
continue
}
if srcKind == dstKind {
- if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
+ if _, err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
return
}
} else if dstKind == reflect.Interface && dstElement.Kind() == reflect.Interface {
- if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
+ if _, err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
return
}
} else if srcKind == reflect.Map {
@@ -157,7 +157,8 @@ func _map(dst, src interface{}, opts ...func(*Config)) error {
// To be friction-less, we redirect equal-type arguments
// to deepMerge. Only because arguments can be anything.
if vSrc.Kind() == vDst.Kind() {
- return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ _, err := deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ return err
}
switch vSrc.Kind() {
case reflect.Struct:
diff --git a/vendor/github.com/imdario/mergo/merge.go b/vendor/github.com/imdario/mergo/merge.go
index 3fb6c64d0..3332c9c2a 100644
--- a/vendor/github.com/imdario/mergo/merge.go
+++ b/vendor/github.com/imdario/mergo/merge.go
@@ -11,20 +11,32 @@ package mergo
import (
"fmt"
"reflect"
+ "unsafe"
)
func hasExportedField(dst reflect.Value) (exported bool) {
for i, n := 0, dst.NumField(); i < n; i++ {
field := dst.Type().Field(i)
- if field.Anonymous && dst.Field(i).Kind() == reflect.Struct {
- exported = exported || hasExportedField(dst.Field(i))
- } else {
- exported = exported || len(field.PkgPath) == 0
+ if isExportedComponent(&field) {
+ return true
}
}
return
}
+func isExportedComponent(field *reflect.StructField) bool {
+ name := field.Name
+ pkgPath := field.PkgPath
+ if len(pkgPath) > 0 {
+ return false
+ }
+ c := name[0]
+ if 'a' <= c && c <= 'z' || c == '_' {
+ return false
+ }
+ return true
+}
+
type Config struct {
Overwrite bool
AppendSlice bool
@@ -41,16 +53,17 @@ type Transformers interface {
// Traverses recursively both values, assigning src's fields values to dst.
// The map argument tracks comparisons that have already been seen, which allows
// short circuiting on recursive types.
-func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
+func deepMerge(dstIn, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (dst reflect.Value, err error) {
+ dst = dstIn
overwrite := config.Overwrite
typeCheck := config.TypeCheck
overwriteWithEmptySrc := config.overwriteWithEmptyValue
overwriteSliceWithEmptySrc := config.overwriteSliceWithEmptyValue
- config.overwriteWithEmptyValue = false
if !src.IsValid() {
return
}
+
if dst.CanAddr() {
addr := dst.UnsafeAddr()
h := 17 * addr
@@ -58,7 +71,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
typ := dst.Type()
for p := seen; p != nil; p = p.next {
if p.ptr == addr && p.typ == typ {
- return nil
+ return dst, nil
}
}
// Remember, remember...
@@ -72,114 +85,124 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
}
}
+ if dst.IsValid() && src.IsValid() && src.Type() != dst.Type() {
+ err = fmt.Errorf("cannot append two different types (%s, %s)", src.Kind(), dst.Kind())
+ return
+ }
+
switch dst.Kind() {
case reflect.Struct:
if hasExportedField(dst) {
+ dstCp := reflect.New(dst.Type()).Elem()
for i, n := 0, dst.NumField(); i < n; i++ {
- if err = deepMerge(dst.Field(i), src.Field(i), visited, depth+1, config); err != nil {
+ dstField := dst.Field(i)
+ structField := dst.Type().Field(i)
+ // copy un-exported struct fields
+ if !isExportedComponent(&structField) {
+ rf := dstCp.Field(i)
+ rf = reflect.NewAt(rf.Type(), unsafe.Pointer(rf.UnsafeAddr())).Elem() //nolint:gosec
+ dstRF := dst.Field(i)
+ if !dst.Field(i).CanAddr() {
+ continue
+ }
+
+ dstRF = reflect.NewAt(dstRF.Type(), unsafe.Pointer(dstRF.UnsafeAddr())).Elem() //nolint:gosec
+ rf.Set(dstRF)
+ continue
+ }
+ dstField, err = deepMerge(dstField, src.Field(i), visited, depth+1, config)
+ if err != nil {
return
}
+ dstCp.Field(i).Set(dstField)
+ }
+
+ if dst.CanSet() {
+ dst.Set(dstCp)
+ } else {
+ dst = dstCp
}
+ return
} else {
- if dst.CanSet() && (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst)) {
- dst.Set(src)
+ if (isReflectNil(dst) || overwrite) && (!isEmptyValue(src) || overwriteWithEmptySrc) {
+ dst = src
}
}
+
case reflect.Map:
if dst.IsNil() && !src.IsNil() {
- dst.Set(reflect.MakeMap(dst.Type()))
+ if dst.CanSet() {
+ dst.Set(reflect.MakeMap(dst.Type()))
+ } else {
+ dst = src
+ return
+ }
}
for _, key := range src.MapKeys() {
srcElement := src.MapIndex(key)
+ dstElement := dst.MapIndex(key)
if !srcElement.IsValid() {
continue
}
- dstElement := dst.MapIndex(key)
- switch srcElement.Kind() {
- case reflect.Chan, reflect.Func, reflect.Map, reflect.Interface, reflect.Slice:
- if srcElement.IsNil() {
- continue
- }
- fallthrough
- default:
- if !srcElement.CanInterface() {
- continue
- }
- switch reflect.TypeOf(srcElement.Interface()).Kind() {
- case reflect.Struct:
- fallthrough
- case reflect.Ptr:
- fallthrough
- case reflect.Map:
- srcMapElm := srcElement
- dstMapElm := dstElement
- if srcMapElm.CanInterface() {
- srcMapElm = reflect.ValueOf(srcMapElm.Interface())
- if dstMapElm.IsValid() {
- dstMapElm = reflect.ValueOf(dstMapElm.Interface())
- }
- }
- if err = deepMerge(dstMapElm, srcMapElm, visited, depth+1, config); err != nil {
- return
- }
- case reflect.Slice:
- srcSlice := reflect.ValueOf(srcElement.Interface())
-
- var dstSlice reflect.Value
- if !dstElement.IsValid() || dstElement.IsNil() {
- dstSlice = reflect.MakeSlice(srcSlice.Type(), 0, srcSlice.Len())
- } else {
- dstSlice = reflect.ValueOf(dstElement.Interface())
- }
-
- if (!isEmptyValue(src) || overwriteWithEmptySrc || overwriteSliceWithEmptySrc) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
- if typeCheck && srcSlice.Type() != dstSlice.Type() {
- return fmt.Errorf("cannot override two slices with different type (%s, %s)", srcSlice.Type(), dstSlice.Type())
- }
- dstSlice = srcSlice
- } else if config.AppendSlice {
- if srcSlice.Type() != dstSlice.Type() {
- return fmt.Errorf("cannot append two slices with different type (%s, %s)", srcSlice.Type(), dstSlice.Type())
- }
- dstSlice = reflect.AppendSlice(dstSlice, srcSlice)
- }
- dst.SetMapIndex(key, dstSlice)
+ if dst.MapIndex(key).IsValid() {
+ k := dstElement.Interface()
+ dstElement = reflect.ValueOf(k)
+ }
+ if isReflectNil(srcElement) {
+ if overwrite || isReflectNil(dstElement) {
+ dst.SetMapIndex(key, srcElement)
}
+ continue
}
- if dstElement.IsValid() && !isEmptyValue(dstElement) && (reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Map || reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Slice) {
+ if !srcElement.CanInterface() {
continue
}
- if srcElement.IsValid() && ((srcElement.Kind() != reflect.Ptr && overwrite) || !dstElement.IsValid() || isEmptyValue(dstElement)) {
- if dst.IsNil() {
- dst.Set(reflect.MakeMap(dst.Type()))
+ if srcElement.CanInterface() {
+ srcElement = reflect.ValueOf(srcElement.Interface())
+ if dstElement.IsValid() {
+ dstElement = reflect.ValueOf(dstElement.Interface())
}
- dst.SetMapIndex(key, srcElement)
}
+ dstElement, err = deepMerge(dstElement, srcElement, visited, depth+1, config)
+ if err != nil {
+ return
+ }
+ dst.SetMapIndex(key, dstElement)
+
}
case reflect.Slice:
- if !dst.CanSet() {
- break
- }
+ newSlice := dst
if (!isEmptyValue(src) || overwriteWithEmptySrc || overwriteSliceWithEmptySrc) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
- dst.Set(src)
+ if typeCheck && src.Type() != dst.Type() {
+ return dst, fmt.Errorf("cannot override two slices with different type (%s, %s)", src.Type(), dst.Type())
+ }
+ newSlice = src
} else if config.AppendSlice {
- if src.Type() != dst.Type() {
- return fmt.Errorf("cannot append two slice with different type (%s, %s)", src.Type(), dst.Type())
+ if typeCheck && src.Type() != dst.Type() {
+ err = fmt.Errorf("cannot append two slice with different type (%s, %s)", src.Type(), dst.Type())
+ return
}
- dst.Set(reflect.AppendSlice(dst, src))
+ newSlice = reflect.AppendSlice(dst, src)
}
- case reflect.Ptr:
- fallthrough
- case reflect.Interface:
- if src.IsNil() {
+ if dst.CanSet() {
+ dst.Set(newSlice)
+ } else {
+ dst = newSlice
+ }
+ case reflect.Ptr, reflect.Interface:
+ if isReflectNil(src) {
break
}
if dst.Kind() != reflect.Ptr && src.Type().AssignableTo(dst.Type()) {
if dst.IsNil() || overwrite {
- if dst.CanSet() && (overwrite || isEmptyValue(dst)) {
- dst.Set(src)
+ if overwrite || isEmptyValue(dst) {
+ if dst.CanSet() {
+ dst.Set(src)
+ } else {
+ dst = src
+ }
}
}
break
@@ -191,28 +214,38 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
dst.Set(src)
}
} else if src.Kind() == reflect.Ptr {
- if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
+ if dst, err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
return
}
+ dst = dst.Addr()
} else if dst.Elem().Type() == src.Type() {
- if err = deepMerge(dst.Elem(), src, visited, depth+1, config); err != nil {
+ if dst, err = deepMerge(dst.Elem(), src, visited, depth+1, config); err != nil {
return
}
} else {
- return ErrDifferentArgumentsTypes
+ return dst, ErrDifferentArgumentsTypes
}
break
}
if dst.IsNil() || overwrite {
- if dst.CanSet() && (overwrite || isEmptyValue(dst)) {
- dst.Set(src)
+ if (overwrite || isEmptyValue(dst)) && (overwriteWithEmptySrc || !isEmptyValue(src)) {
+ if dst.CanSet() {
+ dst.Set(src)
+ } else {
+ dst = src
+ }
}
- } else if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
+ } else if _, err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
return
}
default:
- if dst.CanSet() && (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst)) {
- dst.Set(src)
+ overwriteFull := (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst))
+ if overwriteFull {
+ if dst.CanSet() {
+ dst.Set(src)
+ } else {
+ dst = src
+ }
}
}
@@ -246,7 +279,12 @@ func WithOverride(config *Config) {
config.Overwrite = true
}
-// WithOverride will make merge override empty dst slice with empty src slice.
+// WithOverwriteWithEmptyValue will make merge override non empty dst attributes with empty src attributes values.
+func WithOverwriteWithEmptyValue(config *Config) {
+ config.overwriteWithEmptyValue = true
+}
+
+// WithOverrideEmptySlice will make merge override empty dst slice with empty src slice.
func WithOverrideEmptySlice(config *Config) {
config.overwriteSliceWithEmptyValue = true
}
@@ -276,8 +314,25 @@ func merge(dst, src interface{}, opts ...func(*Config)) error {
if vDst, vSrc, err = resolveValues(dst, src); err != nil {
return err
}
+ if !vDst.CanSet() {
+ return fmt.Errorf("cannot set dst, needs reference")
+ }
if vDst.Type() != vSrc.Type() {
return ErrDifferentArgumentsTypes
}
- return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ _, err = deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ return err
+}
+
+// IsReflectNil is the reflect value provided nil
+func isReflectNil(v reflect.Value) bool {
+ k := v.Kind()
+ switch k {
+ case reflect.Interface, reflect.Slice, reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr:
+ // Both interface and slice are nil if first word is 0.
+ // Both are always bigger than a word; assume flagIndir.
+ return v.IsNil()
+ default:
+ return false
+ }
}
diff --git a/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go b/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
index 599bdb6e2..9c979e5e2 100644
--- a/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
+++ b/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
@@ -31,6 +31,7 @@ const (
// Disabled constant to indicate SELinux is disabled
Disabled = -1
+ contextFile = "/usr/share/containers/selinux/contexts"
selinuxDir = "/etc/selinux/"
selinuxConfig = selinuxDir + "config"
selinuxfsMount = "/sys/fs/selinux"
@@ -684,23 +685,26 @@ func ROFileLabel() string {
return roFileLabel
}
-/*
-ContainerLabels returns an allocated processLabel and fileLabel to be used for
-container labeling by the calling process.
-*/
-func ContainerLabels() (processLabel string, fileLabel string) {
+func openContextFile() (*os.File, error) {
+ if f, err := os.Open(contextFile); err == nil {
+ return f, nil
+ }
+ lxcPath := filepath.Join(getSELinuxPolicyRoot(), "/contexts/lxc_contexts")
+ return os.Open(lxcPath)
+}
+
+var labels = loadLabels()
+
+func loadLabels() map[string]string {
var (
val, key string
bufin *bufio.Reader
)
- if !GetEnabled() {
- return "", ""
- }
- lxcPath := fmt.Sprintf("%s/contexts/lxc_contexts", getSELinuxPolicyRoot())
- in, err := os.Open(lxcPath)
+ labels := make(map[string]string)
+ in, err := openContextFile()
if err != nil {
- return "", ""
+ return labels
}
defer in.Close()
@@ -712,7 +716,7 @@ func ContainerLabels() (processLabel string, fileLabel string) {
if err == io.EOF {
done = true
} else {
- goto exit
+ break
}
}
line = strings.TrimSpace(line)
@@ -726,26 +730,64 @@ func ContainerLabels() (processLabel string, fileLabel string) {
}
if groups := assignRegex.FindStringSubmatch(line); groups != nil {
key, val = strings.TrimSpace(groups[1]), strings.TrimSpace(groups[2])
- if key == "process" {
- processLabel = strings.Trim(val, "\"")
- }
- if key == "file" {
- fileLabel = strings.Trim(val, "\"")
- }
- if key == "ro_file" {
- roFileLabel = strings.Trim(val, "\"")
- }
+ labels[key] = strings.Trim(val, "\"")
}
}
- if processLabel == "" || fileLabel == "" {
+ return labels
+}
+
+/*
+KVMContainerLabels returns the default processLabel and mountLabel to be used
+for kvm containers by the calling process.
+*/
+func KVMContainerLabels() (string, string) {
+ processLabel := labels["kvm_process"]
+ if processLabel == "" {
+ processLabel = labels["process"]
+ }
+
+ return addMcs(processLabel, labels["file"])
+}
+
+/*
+InitContainerLabels returns the default processLabel and file labels to be
+used for containers running an init system like systemd by the calling process.
+*/
+func InitContainerLabels() (string, string) {
+ processLabel := labels["init_process"]
+ if processLabel == "" {
+ processLabel = labels["process"]
+ }
+
+ return addMcs(processLabel, labels["file"])
+}
+
+/*
+ContainerLabels returns an allocated processLabel and fileLabel to be used for
+container labeling by the calling process.
+*/
+func ContainerLabels() (processLabel string, fileLabel string) {
+ if !GetEnabled() {
return "", ""
}
+ processLabel = labels["process"]
+ fileLabel = labels["file"]
+ roFileLabel = labels["ro_file"]
+
+ if processLabel == "" || fileLabel == "" {
+ return "", fileLabel
+ }
+
if roFileLabel == "" {
roFileLabel = fileLabel
}
-exit:
+
+ return addMcs(processLabel, fileLabel)
+}
+
+func addMcs(processLabel, fileLabel string) (string, string) {
scon, _ := NewContext(processLabel)
if scon["level"] != "" {
mcs := uniqMcs(1024)
diff --git a/vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go b/vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
index f349513d9..f9f5e2061 100644
--- a/vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
+++ b/vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
@@ -113,7 +113,7 @@ SetTaskLabel sets the SELinux label for the current thread, or an error.
This requires the dyntransition permission.
*/
func SetTaskLabel(label string) error {
- return nil
+ return nil
}
/*
@@ -201,6 +201,18 @@ func ROFileLabel() string {
return ""
}
+// KVMContainerLabels returns the default processLabel and mountLabel to be used
+// for kvm containers by the calling process.
+func KVMContainerLabels() (string, string) {
+ return "", ""
+}
+
+// InitContainerLabels returns the default processLabel and file labels to be
+// used for containers running an init system like systemd by the calling
+func InitContainerLabels() (string, string) {
+ return "", ""
+}
+
/*
ContainerLabels returns an allocated processLabel and fileLabel to be used for
container labeling by the calling process.
diff --git a/vendor/github.com/vbauerster/mpb/v4/go.mod b/vendor/github.com/vbauerster/mpb/v4/go.mod
deleted file mode 100644
index 43b42d496..000000000
--- a/vendor/github.com/vbauerster/mpb/v4/go.mod
+++ /dev/null
@@ -1,10 +0,0 @@
-module github.com/vbauerster/mpb/v4
-
-require (
- github.com/VividCortex/ewma v1.1.1
- github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
- golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6
- golang.org/x/sys v0.0.0-20200217220822-9197077df867 // indirect
-)
-
-go 1.13
diff --git a/vendor/github.com/vbauerster/mpb/v4/proxyreader.go b/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
deleted file mode 100644
index 0e4b51f09..000000000
--- a/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package mpb
-
-import (
- "io"
- "time"
-)
-
-type proxyReader struct {
- io.ReadCloser
- bar *Bar
- iT time.Time
-}
-
-func (prox *proxyReader) Read(p []byte) (n int, err error) {
- n, err = prox.ReadCloser.Read(p)
- if n > 0 {
- prox.bar.IncrBy(n, time.Since(prox.iT))
- prox.iT = time.Now()
- }
- if err == io.EOF {
- go prox.bar.SetTotal(0, true)
- }
- return
-}
-
-type proxyWriterTo struct {
- *proxyReader
- wt io.WriterTo
-}
-
-func (prox *proxyWriterTo) WriteTo(w io.Writer) (n int64, err error) {
- n, err = prox.wt.WriteTo(w)
- if n > 0 {
- prox.bar.IncrInt64(n, time.Since(prox.iT))
- prox.iT = time.Now()
- }
- if err == io.EOF {
- go prox.bar.SetTotal(0, true)
- }
- return
-}
diff --git a/vendor/github.com/vbauerster/mpb/v4/.gitignore b/vendor/github.com/vbauerster/mpb/v5/.gitignore
index 63bd91672..63bd91672 100644
--- a/vendor/github.com/vbauerster/mpb/v4/.gitignore
+++ b/vendor/github.com/vbauerster/mpb/v5/.gitignore
diff --git a/vendor/github.com/vbauerster/mpb/v4/.travis.yml b/vendor/github.com/vbauerster/mpb/v5/.travis.yml
index 997ae32d6..0eb0f2f20 100644
--- a/vendor/github.com/vbauerster/mpb/v4/.travis.yml
+++ b/vendor/github.com/vbauerster/mpb/v5/.travis.yml
@@ -1,11 +1,7 @@
language: go
go:
- - 1.12.x
- - 1.13.x
-
-env:
- - GO111MODULE=on
+ - 1.14.x
script:
- go test -race ./...
diff --git a/vendor/github.com/vbauerster/mpb/v4/README.md b/vendor/github.com/vbauerster/mpb/v5/README.md
index 003fb5987..bfb0c4d18 100644
--- a/vendor/github.com/vbauerster/mpb/v4/README.md
+++ b/vendor/github.com/vbauerster/mpb/v5/README.md
@@ -25,8 +25,8 @@ import (
"math/rand"
"time"
- "github.com/vbauerster/mpb/v4"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5"
+ "github.com/vbauerster/mpb/v5/decor"
)
func main() {
@@ -44,8 +44,7 @@ func main() {
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
// replace ETA decorator with "done" message, OnComplete event
decor.OnComplete(
- // ETA decorator with ewma age of 60, and width reservation of 4
- decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WC{W: 4}), "done",
+ decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
),
),
mpb.AppendDecorators(decor.Percentage()),
@@ -53,17 +52,15 @@ func main() {
// simulating some work
max := 100 * time.Millisecond
for i := 0; i < total; i++ {
- start := time.Now()
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
- // since ewma decorator is used, we need to pass time.Since(start)
- bar.Increment(time.Since(start))
+ bar.Increment()
}
// wait for our bar to complete and flush
p.Wait()
}
```
-#### [Rendering multiple bars](_examples/multiBars//main.go)
+#### [Rendering multiple bars](_examples/multiBars/main.go)
```go
var wg sync.WaitGroup
// pass &wg (optional), so p will wait for it eventually
@@ -94,10 +91,13 @@ func main() {
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
max := 100 * time.Millisecond
for i := 0; i < total; i++ {
+ // start variable is solely for EWMA calculation
+ // EWMA's unit of measure is an iteration's duration
start := time.Now()
time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10)
- // since ewma decorator is used, we need to pass time.Since(start)
- bar.Increment(time.Since(start))
+ bar.Increment()
+ // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
+ bar.DecoratorEwmaUpdate(time.Since(start))
}
}()
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/UNLICENSE b/vendor/github.com/vbauerster/mpb/v5/UNLICENSE
index 68a49daad..68a49daad 100644
--- a/vendor/github.com/vbauerster/mpb/v4/UNLICENSE
+++ b/vendor/github.com/vbauerster/mpb/v5/UNLICENSE
diff --git a/vendor/github.com/vbauerster/mpb/v4/bar.go b/vendor/github.com/vbauerster/mpb/v5/bar.go
index 1828e67a6..1a4c66fe1 100644
--- a/vendor/github.com/vbauerster/mpb/v4/bar.go
+++ b/vendor/github.com/vbauerster/mpb/v5/bar.go
@@ -5,51 +5,43 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"log"
"strings"
"time"
"unicode/utf8"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/decor"
)
-// Filler interface.
-// Bar renders by calling Filler's Fill method. You can literally have
-// any bar kind, by implementing this interface and passing it to the
-// *Progress.Add method.
-type Filler interface {
+// BarFiller interface.
+// Bar renders itself by calling BarFiller's Fill method. You can
+// literally have any bar kind, by implementing this interface and
+// passing it to the *Progress.Add(...) *Bar method.
+type BarFiller interface {
Fill(w io.Writer, width int, stat *decor.Statistics)
}
-// FillerFunc is function type adapter to convert function into Filler.
-type FillerFunc func(w io.Writer, width int, stat *decor.Statistics)
+// BarFillerFunc is function type adapter to convert function into Filler.
+type BarFillerFunc func(w io.Writer, width int, stat *decor.Statistics)
-func (f FillerFunc) Fill(w io.Writer, width int, stat *decor.Statistics) {
+func (f BarFillerFunc) Fill(w io.Writer, width int, stat *decor.Statistics) {
f(w, width, stat)
}
-// WrapFiller interface.
-// If you're implementing custom Filler by wrapping a built-in one,
-// it is necessary to implement this interface to retain functionality
-// of built-in Filler.
-type WrapFiller interface {
- Base() Filler
-}
-
// Bar represents a progress Bar.
type Bar struct {
priority int // used by heap
index int // used by heap
- extendedLines int
- toShutdown bool
- toDrop bool
- noPop bool
- operateState chan func(*bState)
- frameCh chan io.Reader
- syncTableCh chan [][]chan int
- completed chan bool
+ extendedLines int
+ toShutdown bool
+ toDrop bool
+ noPop bool
+ hasEwmaDecorators bool
+ operateState chan func(*bState)
+ frameCh chan io.Reader
+ syncTableCh chan [][]chan int
+ completed chan bool
// cancel is called either by user or on complete event
cancel func()
@@ -66,21 +58,23 @@ type Bar struct {
type extFunc func(in io.Reader, tw int, st *decor.Statistics) (out io.Reader, lines int)
type bState struct {
- baseF Filler
- filler Filler
+ baseF BarFiller
+ filler BarFiller
id int
width int
total int64
current int64
+ lastN int64
+ iterated bool
trimSpace bool
toComplete bool
completeFlushed bool
noPop bool
aDecorators []decor.Decorator
pDecorators []decor.Decorator
- amountReceivers []decor.AmountReceiver
+ averageDecorators []decor.AverageDecorator
+ ewmaDecorators []decor.EwmaDecorator
shutdownListeners []decor.ShutdownListener
- averageAdjusters []decor.AverageAdjuster
bufP, bufB, bufA *bytes.Buffer
extender extFunc
@@ -116,36 +110,13 @@ func newBar(container *Progress, bs *bState) *Bar {
return bar
}
-// RemoveAllPrependers removes all prepend functions.
-func (b *Bar) RemoveAllPrependers() {
- select {
- case b.operateState <- func(s *bState) { s.pDecorators = nil }:
- case <-b.done:
- }
-}
-
-// RemoveAllAppenders removes all append functions.
-func (b *Bar) RemoveAllAppenders() {
- select {
- case b.operateState <- func(s *bState) { s.aDecorators = nil }:
- case <-b.done:
- }
-}
-
// ProxyReader wraps r with metrics required for progress tracking.
+// Panics if r is nil.
func (b *Bar) ProxyReader(r io.Reader) io.ReadCloser {
if r == nil {
- return nil
- }
- rc, ok := r.(io.ReadCloser)
- if !ok {
- rc = ioutil.NopCloser(r)
+ panic("expected non nil io.Reader")
}
- prox := &proxyReader{rc, b, time.Now()}
- if wt, ok := r.(io.WriterTo); ok {
- return &proxyWriterTo{prox, wt}
- }
- return prox
+ return newProxyReader(r, b)
}
// ID returs id of the bar.
@@ -170,8 +141,9 @@ func (b *Bar) Current() int64 {
}
}
-// SetRefill sets refill, if supported by underlying Filler.
-// Useful for resume-able tasks.
+// SetRefill fills bar with refill rune up to amount argument.
+// Given default bar style is "[=>-]<+", refill rune is '+'.
+// To set bar style use mpb.BarStyle(string) BarOption.
func (b *Bar) SetRefill(amount int64) {
type refiller interface {
SetRefill(int64)
@@ -183,18 +155,8 @@ func (b *Bar) SetRefill(amount int64) {
}
}
-// AdjustAverageDecorators updates start time of all average decorators.
-// Useful for resume-able tasks.
-func (b *Bar) AdjustAverageDecorators(startTime time.Time) {
- b.operateState <- func(s *bState) {
- for _, adjuster := range s.averageAdjusters {
- adjuster.AverageAdjust(startTime)
- }
- }
-}
-
// TraverseDecorators traverses all available decorators and calls cb func on each.
-func (b *Bar) TraverseDecorators(cb decor.CBFunc) {
+func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
b.operateState <- func(s *bState) {
for _, decorators := range [...][]decor.Decorator{
s.pDecorators,
@@ -208,7 +170,8 @@ func (b *Bar) TraverseDecorators(cb decor.CBFunc) {
}
// SetTotal sets total dynamically.
-// Set complete to true, to trigger bar complete event now.
+// If total is less or equal to zero it takes progress' current value.
+// If complete is true, complete event will be triggered.
func (b *Bar) SetTotal(total int64, complete bool) {
select {
case b.operateState <- func(s *bState) {
@@ -227,13 +190,12 @@ func (b *Bar) SetTotal(total int64, complete bool) {
}
}
-// SetCurrent sets progress' current to arbitrary amount.
-func (b *Bar) SetCurrent(current int64, wdd ...time.Duration) {
+// SetCurrent sets progress' current to an arbitrary value.
+func (b *Bar) SetCurrent(current int64) {
select {
case b.operateState <- func(s *bState) {
- for _, ar := range s.amountReceivers {
- ar.NextAmount(current-s.current, wdd...)
- }
+ s.iterated = true
+ s.lastN = current - s.current
s.current = current
if s.total > 0 && s.current >= s.total {
s.current = s.total
@@ -245,25 +207,22 @@ func (b *Bar) SetCurrent(current int64, wdd ...time.Duration) {
}
}
-// Increment is a shorthand for b.IncrInt64(1, wdd...).
-func (b *Bar) Increment(wdd ...time.Duration) {
- b.IncrInt64(1, wdd...)
+// Increment is a shorthand for b.IncrInt64(1).
+func (b *Bar) Increment() {
+ b.IncrInt64(1)
}
-// IncrBy is a shorthand for b.IncrInt64(int64(n), wdd...).
-func (b *Bar) IncrBy(n int, wdd ...time.Duration) {
- b.IncrInt64(int64(n), wdd...)
+// IncrBy is a shorthand for b.IncrInt64(int64(n)).
+func (b *Bar) IncrBy(n int) {
+ b.IncrInt64(int64(n))
}
-// IncrInt64 increments progress bar by amount of n. wdd is an optional
-// work duration i.e. time.Since(start), which expected to be passed,
-// if any ewma based decorator is used.
-func (b *Bar) IncrInt64(n int64, wdd ...time.Duration) {
+// IncrInt64 increments progress by amount of n.
+func (b *Bar) IncrInt64(n int64) {
select {
case b.operateState <- func(s *bState) {
- for _, ar := range s.amountReceivers {
- ar.NextAmount(n, wdd...)
- }
+ s.iterated = true
+ s.lastN = n
s.current += n
if s.total > 0 && s.current >= s.total {
s.current = s.total
@@ -275,6 +234,34 @@ func (b *Bar) IncrInt64(n int64, wdd ...time.Duration) {
}
}
+// DecoratorEwmaUpdate updates all EWMA based decorators. Should be
+// called on each iteration, because EWMA's unit of measure is an
+// iteration's duration. Panics if called before *Bar.Incr... family
+// methods.
+func (b *Bar) DecoratorEwmaUpdate(dur time.Duration) {
+ select {
+ case b.operateState <- func(s *bState) {
+ ewmaIterationUpdate(false, s, dur)
+ }:
+ case <-b.done:
+ ewmaIterationUpdate(true, b.cacheState, dur)
+ }
+}
+
+// DecoratorAverageAdjust adjusts all average based decorators. Call
+// if you need to adjust start time of all average based decorators
+// or after progress resume.
+func (b *Bar) DecoratorAverageAdjust(start time.Time) {
+ select {
+ case b.operateState <- func(s *bState) {
+ for _, d := range s.averageDecorators {
+ d.AverageAdjust(start)
+ }
+ }:
+ case <-b.done:
+ }
+}
+
// SetPriority changes bar's order among multiple bars. Zero is highest
// priority, i.e. bar will be on top. If you don't need to set priority
// dynamically, better use BarPriority option.
@@ -368,25 +355,26 @@ func (b *Bar) panicToFrame(termWidth int) io.Reader {
}
func (b *Bar) subscribeDecorators() {
- var amountReceivers []decor.AmountReceiver
+ var averageDecorators []decor.AverageDecorator
+ var ewmaDecorators []decor.EwmaDecorator
var shutdownListeners []decor.ShutdownListener
- var averageAdjusters []decor.AverageAdjuster
b.TraverseDecorators(func(d decor.Decorator) {
- if d, ok := d.(decor.AmountReceiver); ok {
- amountReceivers = append(amountReceivers, d)
+ if d, ok := d.(decor.AverageDecorator); ok {
+ averageDecorators = append(averageDecorators, d)
+ }
+ if d, ok := d.(decor.EwmaDecorator); ok {
+ ewmaDecorators = append(ewmaDecorators, d)
}
if d, ok := d.(decor.ShutdownListener); ok {
shutdownListeners = append(shutdownListeners, d)
}
- if d, ok := d.(decor.AverageAdjuster); ok {
- averageAdjusters = append(averageAdjusters, d)
- }
})
b.operateState <- func(s *bState) {
- s.amountReceivers = amountReceivers
+ s.averageDecorators = averageDecorators
+ s.ewmaDecorators = ewmaDecorators
s.shutdownListeners = shutdownListeners
- s.averageAdjusters = averageAdjusters
}
+ b.hasEwmaDecorators = len(ewmaDecorators) != 0
}
func (b *Bar) refreshTillShutdown() {
@@ -475,3 +463,14 @@ func extractBaseDecorator(d decor.Decorator) decor.Decorator {
}
return d
}
+
+func ewmaIterationUpdate(done bool, s *bState, dur time.Duration) {
+ if !done && !s.iterated {
+ panic("increment required before ewma iteration update")
+ } else {
+ s.iterated = false
+ }
+ for _, d := range s.ewmaDecorators {
+ d.EwmaUpdate(s.lastN, dur)
+ }
+}
diff --git a/vendor/github.com/vbauerster/mpb/v4/bar_filler.go b/vendor/github.com/vbauerster/mpb/v5/bar_filler.go
index fab4aa229..00bf0a494 100644
--- a/vendor/github.com/vbauerster/mpb/v4/bar_filler.go
+++ b/vendor/github.com/vbauerster/mpb/v5/bar_filler.go
@@ -4,8 +4,8 @@ import (
"io"
"unicode/utf8"
- "github.com/vbauerster/mpb/v4/decor"
- "github.com/vbauerster/mpb/v4/internal"
+ "github.com/vbauerster/mpb/v5/decor"
+ "github.com/vbauerster/mpb/v5/internal"
)
const (
@@ -45,8 +45,8 @@ type barFiller struct {
flush func(w io.Writer, bb [][]byte)
}
-// NewBarFiller constucts mpb.Filler, to be used with *Progress.Add(...) *Bar method.
-func NewBarFiller(style string, reverse bool) Filler {
+// NewBarFiller constucts mpb.BarFiller, to be used with *Progress.Add(...) *Bar method.
+func NewBarFiller(style string, reverse bool) BarFiller {
if style == "" {
style = DefaultBarStyle
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/bar_option.go b/vendor/github.com/vbauerster/mpb/v5/bar_option.go
index be0c36215..76f2050f1 100644
--- a/vendor/github.com/vbauerster/mpb/v4/bar_option.go
+++ b/vendor/github.com/vbauerster/mpb/v5/bar_option.go
@@ -4,7 +4,7 @@ import (
"bytes"
"io"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/decor"
)
// BarOption is a function option which changes the default behavior of a bar.
@@ -50,14 +50,9 @@ func BarWidth(width int) BarOption {
}
}
-// BarReplaceOnComplete is deprecated. Use BarParkTo instead.
-func BarReplaceOnComplete(runningBar *Bar) BarOption {
- return BarParkTo(runningBar)
-}
-
-// BarParkTo parks constructed bar into the runningBar. In other words,
-// constructed bar will replace runningBar after it has been completed.
-func BarParkTo(runningBar *Bar) BarOption {
+// BarQueueAfter queues this (being constructed) bar to relplace
+// runningBar after it has been completed.
+func BarQueueAfter(runningBar *Bar) BarOption {
if runningBar == nil {
return nil
}
@@ -66,28 +61,29 @@ func BarParkTo(runningBar *Bar) BarOption {
}
}
-// BarRemoveOnComplete removes bar filler and decorators if any, on
-// complete event.
+// BarRemoveOnComplete removes both bar's filler and its decorators
+// on complete event.
func BarRemoveOnComplete() BarOption {
return func(s *bState) {
s.dropOnComplete = true
}
}
-// BarClearOnComplete clears bar filler only, on complete event.
-func BarClearOnComplete() BarOption {
- return BarOnComplete("")
+// BarFillerClearOnComplete clears bar's filler on complete event.
+// It's shortcut for BarFillerOnComplete("").
+func BarFillerClearOnComplete() BarOption {
+ return BarFillerOnComplete("")
}
-// BarOnComplete replaces bar filler with message, on complete event.
-func BarOnComplete(message string) BarOption {
+// BarFillerOnComplete replaces bar's filler with message, on complete event.
+func BarFillerOnComplete(message string) BarOption {
return func(s *bState) {
- s.filler = makeBarOnCompleteFiller(s.baseF, message)
+ s.filler = makeBarFillerOnComplete(s.baseF, message)
}
}
-func makeBarOnCompleteFiller(filler Filler, message string) Filler {
- return FillerFunc(func(w io.Writer, width int, st *decor.Statistics) {
+func makeBarFillerOnComplete(filler BarFiller, message string) BarFiller {
+ return BarFillerFunc(func(w io.Writer, width int, st *decor.Statistics) {
if st.Completed {
io.WriteString(w, message)
} else {
@@ -107,7 +103,7 @@ func BarPriority(priority int) BarOption {
// BarExtender is an option to extend bar to the next new line, with
// arbitrary output.
-func BarExtender(extender Filler) BarOption {
+func BarExtender(extender BarFiller) BarOption {
if extender == nil {
return nil
}
@@ -116,7 +112,7 @@ func BarExtender(extender Filler) BarOption {
}
}
-func makeExtFunc(extender Filler) extFunc {
+func makeExtFunc(extender BarFiller) extFunc {
buf := new(bytes.Buffer)
nl := []byte("\n")
return func(r io.Reader, tw int, st *decor.Statistics) (io.Reader, int) {
@@ -132,9 +128,9 @@ func TrimSpace() BarOption {
}
}
-// BarStyle overrides mpb.DefaultBarStyle, for example BarStyle("╢▌▌░╟").
-// If you need to override `reverse tip` and `refill rune` set 6th and
-// 7th rune respectively, for example BarStyle("[=>-]<+").
+// BarStyle overrides mpb.DefaultBarStyle which is "[=>-]<+".
+// It's ok to pass string containing just 5 runes, for example "╢▌▌░╟",
+// if you don't need to override '<' (reverse tip) and '+' (refill rune).
func BarStyle(style string) BarOption {
if style == "" {
return nil
@@ -175,7 +171,7 @@ func SpinnerStyle(frames []string) BarOption {
if len(frames) == 0 {
return nil
}
- chk := func(filler Filler) (interface{}, bool) {
+ chk := func(filler BarFiller) (interface{}, bool) {
t, ok := filler.(*spinnerFiller)
return t, ok
}
@@ -189,7 +185,7 @@ func SpinnerStyle(frames []string) BarOption {
// actual type. If you implement your own Filler, so most probably
// you'll need this. See BarStyle or SpinnerStyle for example.
func MakeFillerTypeSpecificBarOption(
- typeChecker func(Filler) (interface{}, bool),
+ typeChecker func(BarFiller) (interface{}, bool),
cb func(interface{}),
) BarOption {
return func(s *bState) {
diff --git a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer.go
index 9ec1ec66b..9ec1ec66b 100644
--- a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_posix.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
index 3fb8b7d75..3fb8b7d75 100644
--- a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_posix.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_windows.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go
index 712528900..712528900 100644
--- a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_windows.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/any.go b/vendor/github.com/vbauerster/mpb/v5/decor/any.go
index bf9cf51a5..bf9cf51a5 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/any.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/any.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/counters.go b/vendor/github.com/vbauerster/mpb/v5/decor/counters.go
index 297bf937b..297bf937b 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/counters.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/counters.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/decorator.go b/vendor/github.com/vbauerster/mpb/v5/decor/decorator.go
index 01b67802c..5bca63d52 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/decorator.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/decorator.go
@@ -84,10 +84,17 @@ type Wrapper interface {
Base() Decorator
}
-// AmountReceiver interface.
-// EWMA based decorators need to implement this one.
-type AmountReceiver interface {
- NextAmount(int64, ...time.Duration)
+// EwmaDecorator interface.
+// EWMA based decorators should implement this one.
+type EwmaDecorator interface {
+ EwmaUpdate(int64, time.Duration)
+}
+
+// AverageDecorator interface.
+// Average decorators should implement this interface to provide start
+// time adjustment facility, for resume-able tasks.
+type AverageDecorator interface {
+ AverageAdjust(time.Time)
}
// ShutdownListener interface.
@@ -97,17 +104,8 @@ type ShutdownListener interface {
Shutdown()
}
-// AverageAdjuster interface.
-// Average decorators should implement this interface to provide start
-// time adjustment facility, for resume-able tasks.
-type AverageAdjuster interface {
- AverageAdjust(time.Time)
-}
-
-// CBFunc convenience call back func type.
-type CBFunc func(Decorator)
-
// Global convenience instances of WC with sync width bit set.
+// To be used with multiple bars only, i.e. not effective for single bar usage.
var (
WCSyncWidth = WC{C: DSyncWidth}
WCSyncWidthR = WC{C: DSyncWidthR}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/doc.go b/vendor/github.com/vbauerster/mpb/v5/decor/doc.go
index b595e8015..6d2614451 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/doc.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/doc.go
@@ -1,5 +1,5 @@
/*
- Package decor provides common decorators for "github.com/vbauerster/mpb/v4" module.
+ Package decor provides common decorators for "github.com/vbauerster/mpb/v5" module.
Some decorators returned by this package might have a closure state. It is ok to use
decorators concurrently, unless you share the same decorator among multiple
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/elapsed.go b/vendor/github.com/vbauerster/mpb/v5/decor/elapsed.go
index c9999a3b5..c9999a3b5 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/elapsed.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/elapsed.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/eta.go b/vendor/github.com/vbauerster/mpb/v5/decor/eta.go
index e875e96fa..6cb27a247 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/eta.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/eta.go
@@ -23,11 +23,11 @@ func (f TimeNormalizerFunc) Normalize(src time.Duration) time.Duration {
}
// EwmaETA exponential-weighted-moving-average based ETA decorator.
-// Note that it's necessary to supply bar.Incr* methods with incremental
-// work duration as second argument, in order for this decorator to
-// work correctly. This decorator is a wrapper of MovingAverageETA.
+// For this decorator to work correctly you have to measure each
+// iteration's duration and pass it to the
+// *Bar.DecoratorEwmaUpdate(time.Duration) method after each increment.
func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
- var average MovingAverage
+ var average ewma.MovingAverage
if age == 0 {
average = ewma.NewMovingAverage()
} else {
@@ -46,7 +46,7 @@ func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
//
// `wcc` optional WC config
//
-func MovingAverageETA(style TimeStyle, average MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
+func MovingAverageETA(style TimeStyle, average ewma.MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
d := &movingAverageETA{
WC: initWC(wcc...),
average: average,
@@ -72,12 +72,8 @@ func (d *movingAverageETA) Decor(s *Statistics) string {
return d.FormatMsg(d.producer(remaining))
}
-func (d *movingAverageETA) NextAmount(n int64, wdd ...time.Duration) {
- var workDuration time.Duration
- for _, wd := range wdd {
- workDuration = wd
- }
- durPerItem := float64(workDuration) / float64(n)
+func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) {
+ durPerItem := float64(dur) / float64(n)
if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
return
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/merge.go b/vendor/github.com/vbauerster/mpb/v5/decor/merge.go
index 520f13a7f..520f13a7f 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/merge.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/merge.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/moving_average.go b/vendor/github.com/vbauerster/mpb/v5/decor/moving_average.go
index 6acdb4ace..50ac9c393 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/moving_average.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/moving_average.go
@@ -7,11 +7,6 @@ import (
"github.com/VividCortex/ewma"
)
-// MovingAverage is the interface that computes a moving average over
-// a time-series stream of numbers. The average may be over a window
-// or exponentially decaying.
-type MovingAverage = ewma.MovingAverage
-
type threadSafeMovingAverage struct {
ewma.MovingAverage
mu sync.Mutex
@@ -68,6 +63,6 @@ func (s *medianWindow) Set(value float64) {
}
// NewMedian is fixed last 3 samples median MovingAverage.
-func NewMedian() MovingAverage {
+func NewMedian() ewma.MovingAverage {
return NewThreadSafeMovingAverage(new(medianWindow))
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/name.go b/vendor/github.com/vbauerster/mpb/v5/decor/name.go
index a7d477e07..a7d477e07 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/name.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/name.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/on_complete.go b/vendor/github.com/vbauerster/mpb/v5/decor/on_complete.go
index 0a1526bf5..0a1526bf5 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/on_complete.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/on_complete.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/percentage.go b/vendor/github.com/vbauerster/mpb/v5/decor/percentage.go
index efb2f3ef5..65ca7d318 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/percentage.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/percentage.go
@@ -5,7 +5,7 @@ import (
"io"
"strconv"
- "github.com/vbauerster/mpb/v4/internal"
+ "github.com/vbauerster/mpb/v5/internal"
)
type percentageType float64
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/size_type.go b/vendor/github.com/vbauerster/mpb/v5/decor/size_type.go
index e4b974058..e4b974058 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/size_type.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/size_type.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1000_string.go b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1000_string.go
index 3f32ef715..3f32ef715 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1000_string.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1000_string.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1024_string.go b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1024_string.go
index 9fca66cc7..9fca66cc7 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1024_string.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1024_string.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/speed.go b/vendor/github.com/vbauerster/mpb/v5/decor/speed.go
index 93f5763e1..8a48e3f52 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/speed.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/speed.go
@@ -28,11 +28,11 @@ func (self *speedFormatter) Format(st fmt.State, verb rune) {
}
// EwmaSpeed exponential-weighted-moving-average based speed decorator.
-// Note that it's necessary to supply bar.Incr* methods with incremental
-// work duration as second argument, in order for this decorator to
-// work correctly. This decorator is a wrapper of MovingAverageSpeed.
+// For this decorator to work correctly you have to measure each
+// iteration's duration and pass it to the
+// *Bar.DecoratorEwmaUpdate(time.Duration) method after each increment.
func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
- var average MovingAverage
+ var average ewma.MovingAverage
if age == 0 {
average = ewma.NewMovingAverage()
} else {
@@ -59,7 +59,7 @@ func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
// unit=UnitKB, format="%.1f" output: "1.0MB/s"
// unit=UnitKB, format="% .1f" output: "1.0 MB/s"
//
-func MovingAverageSpeed(unit int, format string, average MovingAverage, wcc ...WC) Decorator {
+func MovingAverageSpeed(unit int, format string, average ewma.MovingAverage, wcc ...WC) Decorator {
if format == "" {
format = "%.0f"
}
@@ -89,12 +89,8 @@ func (d *movingAverageSpeed) Decor(s *Statistics) string {
return d.FormatMsg(d.msg)
}
-func (d *movingAverageSpeed) NextAmount(n int64, wdd ...time.Duration) {
- var workDuration time.Duration
- for _, wd := range wdd {
- workDuration = wd
- }
- durPerByte := float64(workDuration) / float64(n)
+func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) {
+ durPerByte := float64(dur) / float64(n)
if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
return
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/spinner.go b/vendor/github.com/vbauerster/mpb/v5/decor/spinner.go
index abfb2f76c..abfb2f76c 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/spinner.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/spinner.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/doc.go b/vendor/github.com/vbauerster/mpb/v5/doc.go
index 5ada71774..5ada71774 100644
--- a/vendor/github.com/vbauerster/mpb/v4/doc.go
+++ b/vendor/github.com/vbauerster/mpb/v5/doc.go
diff --git a/vendor/github.com/vbauerster/mpb/v5/go.mod b/vendor/github.com/vbauerster/mpb/v5/go.mod
new file mode 100644
index 000000000..672191fc8
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v5/go.mod
@@ -0,0 +1,10 @@
+module github.com/vbauerster/mpb/v5
+
+require (
+ github.com/VividCortex/ewma v1.1.1
+ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
+ golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4
+ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
+)
+
+go 1.14
diff --git a/vendor/github.com/vbauerster/mpb/v4/go.sum b/vendor/github.com/vbauerster/mpb/v5/go.sum
index 3d6d33a5c..9a411976a 100644
--- a/vendor/github.com/vbauerster/mpb/v4/go.sum
+++ b/vendor/github.com/vbauerster/mpb/v5/go.sum
@@ -3,11 +3,11 @@ github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmx
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg=
-golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZABEali68eoMFhTZpCjYVA=
+golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200217220822-9197077df867 h1:JoRuNIf+rpHl+VhScRQQvzbHed86tKkqwPMV34T8myw=
-golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
diff --git a/vendor/github.com/vbauerster/mpb/v4/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go
index 7e261cb22..7e261cb22 100644
--- a/vendor/github.com/vbauerster/mpb/v4/internal/percentage.go
+++ b/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/options.go b/vendor/github.com/vbauerster/mpb/v5/options.go
index 048870284..048870284 100644
--- a/vendor/github.com/vbauerster/mpb/v4/options.go
+++ b/vendor/github.com/vbauerster/mpb/v5/options.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/priority_queue.go b/vendor/github.com/vbauerster/mpb/v5/priority_queue.go
index 29d9bd5a8..29d9bd5a8 100644
--- a/vendor/github.com/vbauerster/mpb/v4/priority_queue.go
+++ b/vendor/github.com/vbauerster/mpb/v5/priority_queue.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/progress.go b/vendor/github.com/vbauerster/mpb/v5/progress.go
index c9b72b0e7..a366b9295 100644
--- a/vendor/github.com/vbauerster/mpb/v4/progress.go
+++ b/vendor/github.com/vbauerster/mpb/v5/progress.go
@@ -12,8 +12,8 @@ import (
"sync"
"time"
- "github.com/vbauerster/mpb/v4/cwriter"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/cwriter"
+ "github.com/vbauerster/mpb/v5/decor"
)
const (
@@ -111,7 +111,7 @@ func (p *Progress) AddSpinner(total int64, alignment SpinnerAlignment, options .
// Add creates a bar which renders itself by provided filler.
// Set total to 0, if you plan to update it later.
// Panics if *Progress instance is done, i.e. called after *Progress.Wait().
-func (p *Progress) Add(total int64, filler Filler, options ...BarOption) *Bar {
+func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar {
if filler == nil {
filler = NewBarFiller(DefaultBarStyle, false)
}
@@ -166,7 +166,7 @@ func (p *Progress) setBarPriority(b *Bar, priority int) {
}
}
-// UpdateBarPriority same as *Bar.SetPriority.
+// UpdateBarPriority same as *Bar.SetPriority(int).
func (p *Progress) UpdateBarPriority(b *Bar, priority int) {
p.setBarPriority(b, priority)
}
@@ -340,7 +340,7 @@ func (s *pState) updateSyncMatrix() {
}
}
-func (s *pState) makeBarState(total int64, filler Filler, options ...BarOption) *bState {
+func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {
bs := &bState{
total: total,
baseF: extractBaseFiller(filler),
@@ -388,8 +388,11 @@ func syncWidth(matrix map[int][]chan int) {
}
}
-func extractBaseFiller(f Filler) Filler {
- if f, ok := f.(WrapFiller); ok {
+func extractBaseFiller(f BarFiller) BarFiller {
+ type wrapper interface {
+ Base() BarFiller
+ }
+ if f, ok := f.(wrapper); ok {
return extractBaseFiller(f.Base())
}
return f
diff --git a/vendor/github.com/vbauerster/mpb/v5/proxyreader.go b/vendor/github.com/vbauerster/mpb/v5/proxyreader.go
new file mode 100644
index 000000000..316f438d7
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v5/proxyreader.go
@@ -0,0 +1,90 @@
+package mpb
+
+import (
+ "io"
+ "io/ioutil"
+ "time"
+)
+
+type proxyReader struct {
+ io.ReadCloser
+ bar *Bar
+}
+
+func (x *proxyReader) Read(p []byte) (int, error) {
+ n, err := x.ReadCloser.Read(p)
+ x.bar.IncrBy(n)
+ if err == io.EOF {
+ go x.bar.SetTotal(0, true)
+ }
+ return n, err
+}
+
+type proxyWriterTo struct {
+ io.ReadCloser // *proxyReader
+ wt io.WriterTo
+ bar *Bar
+}
+
+func (x *proxyWriterTo) WriteTo(w io.Writer) (int64, error) {
+ n, err := x.wt.WriteTo(w)
+ x.bar.IncrInt64(n)
+ if err == io.EOF {
+ go x.bar.SetTotal(0, true)
+ }
+ return n, err
+}
+
+type ewmaProxyReader struct {
+ io.ReadCloser // *proxyReader
+ bar *Bar
+ iT time.Time
+}
+
+func (x *ewmaProxyReader) Read(p []byte) (int, error) {
+ n, err := x.ReadCloser.Read(p)
+ if n > 0 {
+ x.bar.DecoratorEwmaUpdate(time.Since(x.iT))
+ x.iT = time.Now()
+ }
+ return n, err
+}
+
+type ewmaProxyWriterTo struct {
+ io.ReadCloser // *ewmaProxyReader
+ wt io.WriterTo // *proxyWriterTo
+ bar *Bar
+ iT time.Time
+}
+
+func (x *ewmaProxyWriterTo) WriteTo(w io.Writer) (int64, error) {
+ n, err := x.wt.WriteTo(w)
+ if n > 0 {
+ x.bar.DecoratorEwmaUpdate(time.Since(x.iT))
+ x.iT = time.Now()
+ }
+ return n, err
+}
+
+func newProxyReader(r io.Reader, bar *Bar) io.ReadCloser {
+ rc := toReadCloser(r)
+ rc = &proxyReader{rc, bar}
+
+ if wt, isWriterTo := r.(io.WriterTo); bar.hasEwmaDecorators {
+ now := time.Now()
+ rc = &ewmaProxyReader{rc, bar, now}
+ if isWriterTo {
+ rc = &ewmaProxyWriterTo{rc, wt, bar, now}
+ }
+ } else if isWriterTo {
+ rc = &proxyWriterTo{rc, wt, bar}
+ }
+ return rc
+}
+
+func toReadCloser(r io.Reader) io.ReadCloser {
+ if rc, ok := r.(io.ReadCloser); ok {
+ return rc
+ }
+ return ioutil.NopCloser(r)
+}
diff --git a/vendor/github.com/vbauerster/mpb/v4/spinner_filler.go b/vendor/github.com/vbauerster/mpb/v5/spinner_filler.go
index f855be44e..517725fbf 100644
--- a/vendor/github.com/vbauerster/mpb/v4/spinner_filler.go
+++ b/vendor/github.com/vbauerster/mpb/v5/spinner_filler.go
@@ -5,7 +5,7 @@ import (
"strings"
"unicode/utf8"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/decor"
)
// SpinnerAlignment enum.
@@ -27,8 +27,8 @@ type spinnerFiller struct {
alignment SpinnerAlignment
}
-// NewSpinnerFiller constucts mpb.Filler, to be used with *Progress.Add(...) *Bar method.
-func NewSpinnerFiller(style []string, alignment SpinnerAlignment) Filler {
+// NewSpinnerFiller constucts mpb.BarFiller, to be used with *Progress.Add(...) *Bar method.
+func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller {
if len(style) == 0 {
style = DefaultSpinnerStyle
}
diff --git a/vendor/github.com/xeipuuv/gojsonschema/.travis.yml b/vendor/github.com/xeipuuv/gojsonschema/.travis.yml
index 36155164d..3289001cd 100644
--- a/vendor/github.com/xeipuuv/gojsonschema/.travis.yml
+++ b/vendor/github.com/xeipuuv/gojsonschema/.travis.yml
@@ -1,8 +1,8 @@
language: go
go:
- - "1.10"
- "1.11"
- "1.12"
+ - "1.13"
before_install:
- go get github.com/xeipuuv/gojsonreference
- go get github.com/xeipuuv/gojsonpointer
diff --git a/vendor/github.com/xeipuuv/gojsonschema/draft.go b/vendor/github.com/xeipuuv/gojsonschema/draft.go
index 7a0123cc7..61298e7aa 100644
--- a/vendor/github.com/xeipuuv/gojsonschema/draft.go
+++ b/vendor/github.com/xeipuuv/gojsonschema/draft.go
@@ -92,6 +92,11 @@ func parseSchemaURL(documentNode interface{}) (string, *Draft, error) {
if isKind(documentNode, reflect.Bool) {
return "", nil, nil
}
+
+ if !isKind(documentNode, reflect.Map) {
+ return "", nil, errors.New("schema is invalid")
+ }
+
m := documentNode.(map[string]interface{})
if existsMapKey(m, KEY_SCHEMA) {
diff --git a/vendor/github.com/xeipuuv/gojsonschema/jsonLoader.go b/vendor/github.com/xeipuuv/gojsonschema/jsonLoader.go
index 4f57ff789..5d88af263 100644
--- a/vendor/github.com/xeipuuv/gojsonschema/jsonLoader.go
+++ b/vendor/github.com/xeipuuv/gojsonschema/jsonLoader.go
@@ -33,6 +33,7 @@ import (
"io"
"io/ioutil"
"net/http"
+ "net/url"
"os"
"path/filepath"
"runtime"
@@ -145,6 +146,12 @@ func (l *jsonReferenceLoader) LoadJSON() (interface{}, error) {
if reference.HasFileScheme {
filename := strings.TrimPrefix(refToURL.String(), "file://")
+ filename, err = url.QueryUnescape(filename)
+
+ if err != nil {
+ return nil, err
+ }
+
if runtime.GOOS == "windows" {
// on Windows, a file URL may have an extra leading slash, use slashes
// instead of backslashes, and have spaces escaped