aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DISTRO_PACKAGE.md101
-rw-r--r--Makefile16
-rw-r--r--RELEASE_PROCESS.md6
-rw-r--r--cmd/podman/common/create_opts.go2
-rw-r--r--cmd/podman/machine/rm.go4
-rw-r--r--cmd/podman/play/kube.go9
-rwxr-xr-xcontrib/cirrus/runner.sh15
-rwxr-xr-xcontrib/cirrus/setup_environment.sh13
-rw-r--r--docs/source/markdown/podman-machine-rm.1.md8
-rw-r--r--docs/source/markdown/podman-play-kube.1.md8
-rw-r--r--go.mod10
-rw-r--r--go.sum16
-rwxr-xr-xhack/install_golangci.sh2
-rw-r--r--libpod/networking_linux.go90
-rw-r--r--pkg/api/handlers/compat/exec.go2
-rw-r--r--pkg/domain/entities/play.go2
-rw-r--r--pkg/domain/infra/abi/play.go29
-rw-r--r--pkg/machine/config.go3
-rw-r--r--pkg/machine/ignition.go28
-rw-r--r--pkg/machine/pull.go4
-rw-r--r--pkg/machine/qemu/config.go7
-rw-r--r--pkg/machine/qemu/machine.go70
-rw-r--r--pkg/machine/qemu/options_darwin_arm64.go1
-rw-r--r--pkg/specgen/generate/oci.go6
-rw-r--r--test/apiv2/12-imagesMore.at5
-rw-r--r--test/apiv2/20-containers.at3
-rw-r--r--test/apiv2/python/conftest.py8
-rw-r--r--test/apiv2/python/requirements.txt5
-rwxr-xr-xtest/apiv2/test-apiv219
-rw-r--r--test/e2e/build/Containerfile.with-multiple-secret (renamed from test/e2e/build/Dockerfile.with-multiple-secret)0
-rw-r--r--test/e2e/build/Containerfile.with-secret (renamed from test/e2e/build/Dockerfile.with-secret)0
-rw-r--r--test/e2e/build/Dockerfile.test-cp-root-dir2
-rw-r--r--test/e2e/build/secret-verify-leak/Containerfile.with-secret-verify-leak (renamed from test/e2e/build/Dockerfile.with-secret-verify-leak)0
-rw-r--r--test/e2e/build_test.go6
-rw-r--r--test/e2e/play_kube_test.go20
-rw-r--r--test/e2e/run_device_test.go5
-rw-r--r--test/e2e/run_networking_test.go155
-rw-r--r--test/e2e/system_service_test.go2
-rw-r--r--test/system/700-play.bats52
-rw-r--r--troubleshooting.md27
-rw-r--r--vendor/github.com/docker/distribution/.mailmap3
-rw-r--r--vendor/github.com/docker/distribution/Dockerfile8
-rw-r--r--vendor/github.com/docker/distribution/README.md2
-rw-r--r--vendor/github.com/docker/distribution/docker-bake.hcl18
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/.gitignore5
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/.travis.yml11
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/README.md120
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/UNLICENSE24
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/bar.go492
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/bar_filler.go31
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/bar_filler_bar.go191
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go65
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/bar_option.go153
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/container_option.go112
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/doc.go2
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/util_bsd.go7
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/util_linux.go7
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/util_solaris.go7
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/writer.go84
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/writer_posix.go26
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/cwriter/writer_windows.go73
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/any.go21
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/counters.go243
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/decorator.go191
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/doc.go20
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/elapsed.go35
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/eta.go203
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/merge.go107
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/moving_average.go68
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/name.go12
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/on_complete.go37
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/percentage.go58
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/size_type.go109
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/sizeb1000_string.go41
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/sizeb1024_string.go41
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/speed.go171
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/decor/spinner.go21
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/doc.go2
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/go.mod11
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/go.sum11
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/internal/percentage.go19
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/internal/predicate.go6
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/internal/width.go10
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/priority_queue.go32
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/progress.go412
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/proxyreader.go90
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/bar.go313
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go25
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/bar_option.go13
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go2
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/decor/decorator.go2
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/decor/optimistic_string_writer.go10
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/decor/percentage.go7
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/decor/size_type.go14
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/decor/speed.go2
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/go.mod2
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/go.sum4
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/progress.go197
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/proxyreader.go10
-rw-r--r--vendor/golang.org/x/sys/unix/mkerrors.sh1
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_linux.go49
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_linux_alarm.go14
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux.go20
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_386.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go13
-rw-r--r--vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go13
-rw-r--r--vendor/golang.org/x/sys/unix/ztypes_linux.go5
-rw-r--r--vendor/modules.txt15
116 files changed, 1201 insertions, 3813 deletions
diff --git a/DISTRO_PACKAGE.md b/DISTRO_PACKAGE.md
new file mode 100644
index 000000000..133c62d23
--- /dev/null
+++ b/DISTRO_PACKAGE.md
@@ -0,0 +1,101 @@
+# Podman Packaging
+
+This document is currently written with Fedora as a reference, intended for use
+by packagers of other distros as well as package users.
+
+## Fedora Users
+Podman v4 is available as an official Fedora package on Fedora 36 and rawhide.
+This version of Podman brings with it a new container stack called
+Netavark which serves as a replacement for CNI plugins
+(containernetworking-plugins on Fedora), as well as Aardvark-dns, the
+authoritative DNS server for container records.
+
+Both Netavark and Aardvark-dns are available as official Fedora packages on
+Fedora 35 and newer versions and form the default network stack for new
+installations of Podman 4.0.
+
+On Fedora 36 and newer, fresh installations of Podman v4 will
+automatically install Aardvark-dns along with Netavark.
+
+To install Podman v4:
+
+```console
+$ sudo dnf install podman
+```
+
+To update Podman from an older version to v4:
+
+```console
+$ sudo dnf update podman
+```
+
+**NOTE:** Fedora 35 users will not be able to install Podman v4 using the default yum
+repositories and are recommended to use the COPR repo below:
+
+```console
+$ sudo dnf copr enable rhcontainerbot/podman4
+
+# install or update per your needs
+$ sudo dnf install podman
+```
+
+After installation, if you would like to migrate all your containers to use
+Netavark, you will need to set `network_backend = "netavark"` under
+the `[network]` section in your containers.conf, typically located at:
+`/usr/share/containers/containers.conf`
+
+### Testing the latest development version`
+
+If you would like to test the latest unreleased upstream code, try the
+podman-next COPR
+
+```console
+$ sudo dnf copr enable rhcontainerbot/podman-next
+
+$ sudo dnf install podman
+```
+
+**CAUTION:** The podman-next COPR provides the latest unreleased sources of Podman,
+Netavark and Aardvark-dns as rpms which would override the versions provided by
+the official packages.
+
+## Distro Packagers
+
+The Fedora packaging sources for Podman are available at the [Podman
+dist-git](https://src.fedoraproject.org/rpms/podman).
+
+The main `podman` package no longer explicitly depends on
+containernetworking-plugins. The network stack dependencies are now handled in
+the [containers-common](https://src.fedoraproject.org/rpms/containers-common)
+package which allows for a single point of dependency maintenance for Podman
+and Buildah.
+
+- containers-common
+```
+Requires: container-network-stack
+Recommends: netavark
+```
+
+- netavark
+```
+Provides: container-network-stack = 2
+```
+
+- containernetworking-plugins
+```
+Provides: container-network-stack = 1
+```
+
+This configuration ensures:
+- New installations of Podman will always install netavark by default.
+- The containernetworking-plugins package will not conflict with netavark and
+users can install them together.
+
+## Listing bundled dependencies
+If you need to list the bundled dependencies in your packaging sources, you can
+process the `go.mod` file in the upstream source.
+For example, Fedora's packaging source uses:
+
+```
+$ awk '{print "Provides: bundled(golang("$1")) = "$2}' go.mod | sort | uniq | sed -e 's/-/_/g' -e '/bundled(golang())/d' -e '/bundled(golang(go\|module\|replace\|require))/d'
+```
diff --git a/Makefile b/Makefile
index e45a3ba12..2924eb32b 100644
--- a/Makefile
+++ b/Makefile
@@ -542,7 +542,7 @@ validate.completions:
run-docker-py-tests:
touch test/__init__.py
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf pytest --disable-warnings test/python/docker/
- -rm test/__init__.py
+ rm -f test/__init__.py
.PHONY: localunit
localunit: test/goecho/goecho test/version/version
@@ -623,9 +623,15 @@ remotesystem:
.PHONY: localapiv2
localapiv2:
- env PODMAN=./bin/podman ./test/apiv2/test-apiv2
- env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman ${PYTHON} -m unittest discover -v ./test/apiv2/python
- env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman ${PYTHON} -m unittest discover -v ./test/python/docker
+ # Order is important running python tests first causes the bash tests to fail, see 12-imagesMore
+ # FIXME order of tests should not matter
+ env PODMAN=./bin/podman stdbuf -o0 -e0 ./test/apiv2/test-apiv2
+ env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \
+ pytest --disable-warnings ./test/apiv2/python
+ touch test/__init__.py
+ env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \
+ pytest --disable-warnings ./test/python/docker
+ rm -f test/__init__.py
.PHONY: remoteapiv2
remoteapiv2:
@@ -949,5 +955,5 @@ clean: clean-binaries ## Clean all make artifacts
libpod/pod_easyjson.go \
.install.goimports \
docs/build \
- venv
+ .venv
make -C docs clean
diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md
index bc2e4c01f..3f63e5466 100644
--- a/RELEASE_PROCESS.md
+++ b/RELEASE_PROCESS.md
@@ -241,7 +241,11 @@ spelled with complete minutiae.
```shell
$ git checkout vX.Y.Z
- $ make podman-remote-release-darwin_amd64.zip podman-remote-release-darwin_arm64.zip podman-remote-release-windows_amd64.zip podman.msi podman-remote-static
+ $ make podman-remote-release-darwin_amd64.zip \
+ podman-remote-release-darwin_arm64.zip \
+ podman-remote-release-windows_amd64.zip \
+ podman.msi \
+ podman-remote-static
$ mv podman-* bin/
$ cd bin/
$ tar -cvzf podman-remote-static.tar.gz podman-remote-static
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index a4f94616c..b110b3d85 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -117,7 +117,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
case mount.TypeTmpfs:
if m.TmpfsOptions != nil {
addField(&builder, "tmpfs-size", strconv.FormatInt(m.TmpfsOptions.SizeBytes, 10))
- addField(&builder, "tmpfs-mode", strconv.FormatUint(uint64(m.TmpfsOptions.Mode), 10))
+ addField(&builder, "tmpfs-mode", strconv.FormatUint(uint64(m.TmpfsOptions.Mode), 8))
}
case mount.TypeVolume:
// All current VolumeOpts are handled above
diff --git a/cmd/podman/machine/rm.go b/cmd/podman/machine/rm.go
index 38873084a..3e5d5fb0b 100644
--- a/cmd/podman/machine/rm.go
+++ b/cmd/podman/machine/rm.go
@@ -37,7 +37,7 @@ func init() {
flags := rmCmd.Flags()
formatFlagName := "force"
- flags.BoolVar(&destoryOptions.Force, formatFlagName, false, "Do not prompt before rming")
+ flags.BoolVarP(&destoryOptions.Force, formatFlagName, "f", false, "Stop and do not prompt before rming")
keysFlagName := "save-keys"
flags.BoolVar(&destoryOptions.SaveKeys, keysFlagName, false, "Do not delete SSH keys")
@@ -64,7 +64,7 @@ func rm(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- confirmationMessage, remove, err := vm.Remove(vmName, machine.RemoveOptions{})
+ confirmationMessage, remove, err := vm.Remove(vmName, destoryOptions)
if err != nil {
return err
}
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index 1a430f2dc..563a6251c 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -119,9 +119,11 @@ func init() {
buildFlagName := "build"
flags.BoolVar(&kubeOptions.BuildCLI, buildFlagName, false, "Build all images in a YAML (given Containerfiles exist)")
- }
- if !registry.IsRemote() {
+ contextDirFlagName := "context-dir"
+ flags.StringVar(&kubeOptions.ContextDir, contextDirFlagName, "", "Path to top level of context directory")
+ _ = kubeCmd.RegisterFlagCompletionFunc(contextDirFlagName, completion.AutocompleteDefault)
+
flags.StringVar(&kubeOptions.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
_ = flags.MarkHidden("signature-policy")
@@ -147,6 +149,9 @@ func kube(cmd *cobra.Command, args []string) error {
return err
}
}
+ if kubeOptions.ContextDir != "" && kubeOptions.Build != types.OptionalBoolTrue {
+ return errors.New("--build must be specified when using --context-dir option")
+ }
if kubeOptions.CredentialsCLI != "" {
creds, err := util.ParseRegistryCreds(kubeOptions.CredentialsCLI)
if err != nil {
diff --git a/contrib/cirrus/runner.sh b/contrib/cirrus/runner.sh
index 3aa69183e..d1d87ad04 100755
--- a/contrib/cirrus/runner.sh
+++ b/contrib/cirrus/runner.sh
@@ -55,11 +55,8 @@ function _run_unit() {
}
function _run_apiv2() {
- local m="Testing of API was performed using the **PODMAN*** client"
- warn "$m"
- if ! make localapiv2 |& logformatter; then
- die "$m"
- fi
+ source .venv/requests/bin/activate
+ make localapiv2 |& logformatter
}
function _run_compose() {
@@ -100,12 +97,8 @@ function _run_bindings() {
}
function _run_docker-py() {
- m="Testing of API was performed using the **DOCKER** client"
- warn "$m"
- source venv/bin/activate
- if ! make run-docker-py-tests; then
- die "$m"
- fi
+ source .venv/docker-py/bin/activate
+ make run-docker-py-tests
}
function _run_endpoint() {
diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh
index 93f085983..696560166 100755
--- a/contrib/cirrus/setup_environment.sh
+++ b/contrib/cirrus/setup_environment.sh
@@ -265,14 +265,21 @@ case "$TEST_FLAVOR" in
msg "Installing previously downloaded/cached packages"
dnf install -y $PACKAGE_DOWNLOAD_DIR/python3*.rpm
- virtualenv venv
- source venv/bin/activate
+ virtualenv .venv/docker-py
+ source .venv/docker-py/bin/activate
pip install --upgrade pip
pip install --requirement $GOSRC/test/python/requirements.txt
;;
build) make clean ;;
unit) ;;
- apiv2) ;& # use next item
+ apiv2)
+ msg "Installing previously downloaded/cached packages"
+ dnf install -y $PACKAGE_DOWNLOAD_DIR/python3*.rpm
+ virtualenv .venv/requests
+ source .venv/requests/bin/activate
+ pip install --upgrade pip
+ pip install --requirement $GOSRC/test/apiv2/python/requirements.txt
+ ;& # continue with next item
compose)
rpm -ivh $PACKAGE_DOWNLOAD_DIR/podman-docker*
;& # continue with next item
diff --git a/docs/source/markdown/podman-machine-rm.1.md b/docs/source/markdown/podman-machine-rm.1.md
index 7c9eb65c5..4eea1d2e4 100644
--- a/docs/source/markdown/podman-machine-rm.1.md
+++ b/docs/source/markdown/podman-machine-rm.1.md
@@ -23,9 +23,9 @@ is used.
Print usage statement.
-#### **--force**
+#### **--force**, **-f**
-Delete without confirmation
+Stop and delete without confirmation
#### **--save-ignition**
@@ -58,6 +58,10 @@ The following files will be deleted:
Are you sure you want to continue? [y/N] y
```
+```
+$ podman machine rm -f test1
+$
+```
## SEE ALSO
**[podman(1)](podman.1.md)**, **[podman-machine(1)](podman-machine.1.md)**
diff --git a/docs/source/markdown/podman-play-kube.1.md b/docs/source/markdown/podman-play-kube.1.md
index 389affc3a..328210d34 100644
--- a/docs/source/markdown/podman-play-kube.1.md
+++ b/docs/source/markdown/podman-play-kube.1.md
@@ -115,7 +115,7 @@ environment variable. `export REGISTRY_AUTH_FILE=path`
#### **--build**
-Build images even if they are found in the local storage. Use `--build=false` to completely disable builds.
+Build images even if they are found in the local storage. Use `--build=false` to completely disable builds. (This option is not available with the remote Podman client)
#### **--cert-dir**=*path*
@@ -124,10 +124,14 @@ Please refer to containers-certs.d(5) for details. (This option is not available
#### **--configmap**=*path*
-Use Kubernetes configmap YAML at path to provide a source for environment variable values within the containers of the pod.
+Use Kubernetes configmap YAML at path to provide a source for environment variable values within the containers of the pod. (This option is not available with the remote Podman client)
Note: The *--configmap* option can be used multiple times or a comma-separated list of paths can be used to pass multiple Kubernetes configmap YAMLs.
+#### **--context-dir**=*path*
+
+Use *path* as the build context directory for each image. Requires --build option be true. (This option is not available with the remote Podman client)
+
#### **--creds**
The [username[:password]] to use to authenticate with the registry if required.
diff --git a/go.mod b/go.mod
index bb4942500..57347acea 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
github.com/checkpoint-restore/go-criu/v5 v5.3.0
github.com/container-orchestrated-devices/container-device-interface v0.3.0
github.com/containernetworking/cni v1.0.1
- github.com/containernetworking/plugins v1.1.0
+ github.com/containernetworking/plugins v1.1.1
github.com/containers/buildah v1.24.2
github.com/containers/common v0.47.5-0.20220228211119-9880eb424fde
github.com/containers/conmon v2.0.20+incompatible
@@ -23,7 +23,7 @@ require (
github.com/cyphar/filepath-securejoin v0.2.3
github.com/davecgh/go-spew v1.1.1
github.com/digitalocean/go-qemu v0.0.0-20210326154740-ac9e0b687001
- github.com/docker/distribution v2.8.0+incompatible
+ github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker v20.10.12+incompatible
github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11
github.com/docker/go-plugins-helpers v0.0.0-20211224144127-6eecb7beb651
@@ -61,15 +61,15 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/ulikunitz/xz v0.5.10
- github.com/vbauerster/mpb/v6 v6.0.4
+ github.com/vbauerster/mpb/v7 v7.4.1
github.com/vishvananda/netlink v1.1.1-0.20220115184804-dd687eb2f2d4
go.etcd.io/bbolt v1.3.6
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
- golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27
+ golang.org/x/sys v0.0.0-20220209214540-3681064d5158
golang.org/x/text v0.3.7
google.golang.org/protobuf v1.27.1
- gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
+ gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.22.5
k8s.io/apimachinery v0.22.5
)
diff --git a/go.sum b/go.sum
index 37a3eb977..8785bf7c3 100644
--- a/go.sum
+++ b/go.sum
@@ -348,8 +348,9 @@ github.com/containernetworking/cni v1.0.1/go.mod h1:AKuhXbN5EzmD4yTNtfSsX3tPcmtr
github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM=
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE=
-github.com/containernetworking/plugins v1.1.0 h1:kTIldaDo9SlbQsjhUKvDx0v9q7zyIFJH/Rm9F4xRBro=
github.com/containernetworking/plugins v1.1.0/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19sZPp3ry5uHSkI4LPxV8=
+github.com/containernetworking/plugins v1.1.1 h1:+AGfFigZ5TiQH00vhR8qPeSatj53eNGz0C1d3wVYlHE=
+github.com/containernetworking/plugins v1.1.1/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19sZPp3ry5uHSkI4LPxV8=
github.com/containers/buildah v1.24.2 h1:B+3Drs0oDnaDogZXT75Ktim+P0Yo0O1Da6kuAWX8ID4=
github.com/containers/buildah v1.24.2/go.mod h1:iA7OJjcSuRhd9+YqHvvnmwUokNnwerXQOA2kt8ARDVw=
github.com/containers/common v0.47.4/go.mod h1:HgX0mFXyB0Tbe2REEIp9x9CxET6iSzmHfwR6S/t2LZc=
@@ -436,8 +437,9 @@ github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop
github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
-github.com/docker/distribution v2.8.0+incompatible h1:l9EaZDICImO1ngI+uTifW+ZYvvz7fKISBAKpg+MbWbY=
github.com/docker/distribution v2.8.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
+github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
+github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.3-0.20220208084023-a5c757555091+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.12+incompatible h1:CEeNmFM0QZIsJCZKMkZx0ZcahTiewkrgiwfYD+dfl1U=
@@ -940,7 +942,6 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
-github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
@@ -1188,7 +1189,6 @@ github.com/quasilyte/go-ruleguard/dsl v0.3.10/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQ
github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc=
github.com/quasilyte/go-ruleguard/rules v0.0.0-20210428214800-545e0d2e0bf7/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50=
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0=
-github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
@@ -1348,10 +1348,9 @@ github.com/valyala/quicktemplate v1.7.0/go.mod h1:sqKJnoaOF88V07vkO+9FL8fb9uZg/V
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/vbatts/tar-split v0.11.2 h1:Via6XqJr0hceW4wff3QRzD5gAk/tatMw/4ZA7cTlIME=
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
-github.com/vbauerster/mpb/v6 v6.0.4 h1:h6J5zM/2wimP5Hj00unQuV8qbo5EPcj6wbkCqgj7KcY=
-github.com/vbauerster/mpb/v6 v6.0.4/go.mod h1:a/+JT57gqh6Du0Ay5jSR+uBMfXGdlR7VQlGP52fJxLM=
-github.com/vbauerster/mpb/v7 v7.3.2 h1:tCuxMy8G9cLdjb61b6wO7I1vRT/LyMEzRbr3xCC0JPU=
github.com/vbauerster/mpb/v7 v7.3.2/go.mod h1:wfxIZcOJq/bG1/lAtfzMXcOiSvbqVi/5GX5WCSi+IsA=
+github.com/vbauerster/mpb/v7 v7.4.1 h1:NhLMWQ3gNg2KJR8oeA9lO8Xvq+eNPmixDmB6JEQOUdA=
+github.com/vbauerster/mpb/v7 v7.4.1/go.mod h1:Ygg2mV9Vj9sQBWqsK2m2pidcf9H3s6bNKtqd3/M4gBo=
github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE=
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
@@ -1757,8 +1756,9 @@ golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
+golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
diff --git a/hack/install_golangci.sh b/hack/install_golangci.sh
index 41cf90ddc..4ef6bc83b 100755
--- a/hack/install_golangci.sh
+++ b/hack/install_golangci.sh
@@ -6,7 +6,7 @@ die() { echo "${1:-No error message given} (from $(basename $0))"; exit 1; }
function install() {
echo "Installing golangci-lint v$VERSION into $BIN"
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ./bin v$VERSION
+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$VERSION
}
BIN="./bin/golangci-lint"
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 29b9941fe..7fd80927b 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -30,6 +30,7 @@ import (
"github.com/containers/podman/v4/pkg/util"
"github.com/containers/podman/v4/utils"
"github.com/containers/storage/pkg/lockfile"
+ spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -990,8 +991,20 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
return nil, err
}
- // We can't do more if the network is down.
if c.state.NetNS == nil {
+ if networkNSPath := c.joinedNetworkNSPath(); networkNSPath != "" {
+ if result, err := c.inspectJoinedNetworkNS(networkNSPath); err == nil {
+ if basicConfig, err := resultToBasicNetworkConfig(result); err == nil {
+ // fallback to dummy configuration
+ settings.InspectBasicNetworkConfig = basicConfig
+ return settings, nil
+ }
+ }
+ // do not propagate error inspecting a joined network ns
+ logrus.Errorf("Error inspecting network namespace: %s of container %s: %v", networkNSPath, c.ID(), err)
+ }
+ // We can't do more if the network is down.
+
// We still want to make dummy configurations for each CNI net
// the container joined.
if len(networks) > 0 {
@@ -1065,11 +1078,84 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
return settings, nil
}
+func (c *Container) joinedNetworkNSPath() string {
+ for _, namespace := range c.config.Spec.Linux.Namespaces {
+ if namespace.Type == spec.NetworkNamespace {
+ return namespace.Path
+ }
+ }
+ return ""
+}
+
+func (c *Container) inspectJoinedNetworkNS(networkns string) (q types.StatusBlock, retErr error) {
+ var result types.StatusBlock
+ err := ns.WithNetNSPath(networkns, func(_ ns.NetNS) error {
+ ifaces, err := net.Interfaces()
+ if err != nil {
+ return err
+ }
+ routes, err := netlink.RouteList(nil, netlink.FAMILY_ALL)
+ if err != nil {
+ return err
+ }
+ var gateway net.IP
+ for _, route := range routes {
+ // default gateway
+ if route.Dst == nil {
+ gateway = route.Gw
+ }
+ }
+ result.Interfaces = make(map[string]types.NetInterface)
+ for _, iface := range ifaces {
+ if iface.Flags&net.FlagLoopback != 0 {
+ continue
+ }
+ addrs, err := iface.Addrs()
+ if err != nil {
+ continue
+ }
+ if len(addrs) == 0 {
+ continue
+ }
+ subnets := make([]types.NetAddress, 0, len(addrs))
+ for _, address := range addrs {
+ if ipnet, ok := address.(*net.IPNet); ok {
+ if ipnet.IP.IsLinkLocalMulticast() || ipnet.IP.IsLinkLocalUnicast() {
+ continue
+ }
+ subnet := types.NetAddress{
+ IPNet: types.IPNet{
+ IPNet: *ipnet,
+ },
+ }
+ if ipnet.Contains(gateway) {
+ subnet.Gateway = gateway
+ }
+ subnets = append(subnets, subnet)
+ }
+ }
+ result.Interfaces[iface.Name] = types.NetInterface{
+ Subnets: subnets,
+ MacAddress: types.HardwareAddr(iface.HardwareAddr),
+ }
+ }
+ return nil
+ })
+ return result, err
+}
+
// resultToBasicNetworkConfig produces an InspectBasicNetworkConfig from a CNI
// result
func resultToBasicNetworkConfig(result types.StatusBlock) (define.InspectBasicNetworkConfig, error) {
config := define.InspectBasicNetworkConfig{}
- for _, netInt := range result.Interfaces {
+ interfaceNames := make([]string, len(result.Interfaces))
+ for interfaceName := range result.Interfaces {
+ interfaceNames = append(interfaceNames, interfaceName)
+ }
+ // ensure consistent inspect results by sorting
+ sort.Strings(interfaceNames)
+ for _, interfaceName := range interfaceNames {
+ netInt := result.Interfaces[interfaceName]
for _, netAddress := range netInt.Subnets {
size, _ := netAddress.IPNet.Mask.Size()
if netAddress.IPNet.IP.To4() != nil {
diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go
index c6f7e0318..def16d1b5 100644
--- a/pkg/api/handlers/compat/exec.go
+++ b/pkg/api/handlers/compat/exec.go
@@ -73,7 +73,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) {
// Run the exit command after 5 minutes, to mimic Docker's exec cleanup
// behavior.
- libpodConfig.ExitCommandDelay = 5 * 60
+ libpodConfig.ExitCommandDelay = runtimeConfig.Engine.ExitCommandDelay
sessID, err := ctr.ExecCreate(libpodConfig)
if err != nil {
diff --git a/pkg/domain/entities/play.go b/pkg/domain/entities/play.go
index 43fa3a712..7614a4012 100644
--- a/pkg/domain/entities/play.go
+++ b/pkg/domain/entities/play.go
@@ -14,6 +14,8 @@ type PlayKubeOptions struct {
Build types.OptionalBool
// CertDir - to a directory containing TLS certifications and keys.
CertDir string
+ // ContextDir - directory containing image contexts used for Build
+ ContextDir string
// Down indicates whether to bring contents of a yaml file "down"
// as in stop
Down bool
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 8cbf5da9a..155b06105 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -28,7 +28,7 @@ import (
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- yamlv3 "gopkg.in/yaml.v3"
+ yamlv2 "gopkg.in/yaml.v2"
v1apps "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
)
@@ -354,12 +354,24 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
containers := make([]*libpod.Container, 0, len(podYAML.Spec.Containers))
initContainers := make([]*libpod.Container, 0, len(podYAML.Spec.InitContainers))
- cwd, err := os.Getwd()
- if err != nil {
- return nil, err
+
+ var cwd string
+ if options.ContextDir != "" {
+ cwd = options.ContextDir
+ } else {
+ cwd, err = os.Getwd()
+ if err != nil {
+ return nil, err
+ }
}
+ ctrNames := make(map[string]string)
for _, initCtr := range podYAML.Spec.InitContainers {
+ // Error out if same name is used for more than one container
+ if _, ok := ctrNames[initCtr.Name]; ok {
+ return nil, errors.Errorf("the pod %q is invalid; duplicate container name %q detected", podName, initCtr.Name)
+ }
+ ctrNames[initCtr.Name] = ""
// Init containers cannot have either of lifecycle, livenessProbe, readinessProbe, or startupProbe set
if initCtr.Lifecycle != nil || initCtr.LivenessProbe != nil || initCtr.ReadinessProbe != nil || initCtr.StartupProbe != nil {
return nil, errors.Errorf("cannot create an init container that has either of lifecycle, livenessProbe, readinessProbe, or startupProbe set")
@@ -408,6 +420,11 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
}
for _, container := range podYAML.Spec.Containers {
if !strings.Contains("infra", container.Name) {
+ // Error out if the same name is used for more than one container
+ if _, ok := ctrNames[container.Name]; ok {
+ return nil, errors.Errorf("the pod %q is invalid; duplicate container name %q detected", podName, container.Name)
+ }
+ ctrNames[container.Name] = ""
pulledImage, labels, err := ic.getImageAndLabelInfo(ctx, cwd, annotations, writer, container, options)
if err != nil {
return nil, err
@@ -644,7 +661,7 @@ func readConfigMapFromFile(r io.Reader) (v1.ConfigMap, error) {
func splitMultiDocYAML(yamlContent []byte) ([][]byte, error) {
var documentList [][]byte
- d := yamlv3.NewDecoder(bytes.NewReader(yamlContent))
+ d := yamlv2.NewDecoder(bytes.NewReader(yamlContent))
for {
var o interface{}
// read individual document
@@ -658,7 +675,7 @@ func splitMultiDocYAML(yamlContent []byte) ([][]byte, error) {
if o != nil {
// back to bytes
- document, err := yamlv3.Marshal(o)
+ document, err := yamlv2.Marshal(o)
if err != nil {
return nil, errors.Wrapf(err, "individual doc yaml could not be marshalled")
}
diff --git a/pkg/machine/config.go b/pkg/machine/config.go
index efb1eda15..b3b105150 100644
--- a/pkg/machine/config.go
+++ b/pkg/machine/config.go
@@ -1,3 +1,4 @@
+//go:build amd64 || arm64
// +build amd64 arm64
package machine
@@ -28,6 +29,8 @@ type InitOptions struct {
Username string
ReExec bool
Rootful bool
+ // The numberical userid of the user that called machine
+ UID string
}
type QemuMachineStatus = string
diff --git a/pkg/machine/ignition.go b/pkg/machine/ignition.go
index 47b1836f0..b2dabb689 100644
--- a/pkg/machine/ignition.go
+++ b/pkg/machine/ignition.go
@@ -51,6 +51,7 @@ type DynamicIgnition struct {
Name string
Key string
TimeZone string
+ UID int
VMName string
WritePath string
}
@@ -63,12 +64,13 @@ func NewIgnitionFile(ign DynamicIgnition) error {
ignVersion := Ignition{
Version: "3.2.0",
}
-
ignPassword := Passwd{
Users: []PasswdUser{
{
Name: ign.Name,
SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
+ // Set the UID of the core user inside the machine
+ UID: intToPtr(ign.UID),
},
{
Name: "root",
@@ -289,9 +291,7 @@ func getDirs(usrName string) []Directory {
}
func getFiles(usrName string) []File {
- var (
- files []File
- )
+ files := make([]File, 0)
lingerExample := `[Unit]
Description=A systemd user unit demo
@@ -310,6 +310,7 @@ machine_enabled=true
delegateConf := `[Service]
Delegate=memory pids cpu io
`
+ subUID := `%s:100000:1000000`
// Add a fake systemd service to get the user socket rolling
files = append(files, File{
@@ -344,6 +345,25 @@ Delegate=memory pids cpu io
},
})
+ // Setup /etc/subuid and /etc/subgid
+ for _, sub := range []string{"/etc/subuid", "/etc/subgid"} {
+ files = append(files, File{
+ Node: Node{
+ Group: getNodeGrp("root"),
+ Path: sub,
+ User: getNodeUsr("root"),
+ Overwrite: boolToPtr(true),
+ },
+ FileEmbedded1: FileEmbedded1{
+ Append: nil,
+ Contents: Resource{
+ Source: encodeDataURLPtr(fmt.Sprintf(subUID, usrName)),
+ },
+ Mode: intToPtr(0744),
+ },
+ })
+ }
+
// Set delegate.conf so cpu,io subsystem is delegated to non-root users as well for cgroupv2
// by default
files = append(files, File{
diff --git a/pkg/machine/pull.go b/pkg/machine/pull.go
index 280b47f96..cf1e708b1 100644
--- a/pkg/machine/pull.go
+++ b/pkg/machine/pull.go
@@ -19,8 +19,8 @@ import (
"github.com/containers/storage/pkg/archive"
"github.com/sirupsen/logrus"
"github.com/ulikunitz/xz"
- "github.com/vbauerster/mpb/v6"
- "github.com/vbauerster/mpb/v6/decor"
+ "github.com/vbauerster/mpb/v7"
+ "github.com/vbauerster/mpb/v7/decor"
)
// GenericDownload is used when a user provides a URL
diff --git a/pkg/machine/qemu/config.go b/pkg/machine/qemu/config.go
index c619b7dd4..b39334be0 100644
--- a/pkg/machine/qemu/config.go
+++ b/pkg/machine/qemu/config.go
@@ -1,8 +1,11 @@
+//go:build (amd64 && !windows) || (arm64 && !windows)
// +build amd64,!windows arm64,!windows
package qemu
-import "time"
+import (
+ "time"
+)
type Provider struct{}
@@ -35,6 +38,8 @@ type MachineVM struct {
RemoteUsername string
// Whether this machine should run in a rootful or rootless manner
Rootful bool
+ // UID is the numerical id of the user that called machine
+ UID int
}
type Mount struct {
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 9beec2173..3b4548c17 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -88,11 +88,16 @@ func (p *Provider) NewMachine(opts machine.InitOptions) (machine.VM, error) {
vm.Memory = opts.Memory
vm.DiskSize = opts.DiskSize
- // Look up the executable
- execPath, err := exec.LookPath(QemuCommand)
+ // Find the qemu executable
+ cfg, err := config.Default()
+ if err != nil {
+ return nil, err
+ }
+ execPath, err := cfg.FindHelperBinary(QemuCommand, true)
if err != nil {
return nil, err
}
+
cmd := append([]string{execPath})
// Add memory
cmd = append(cmd, []string{"-m", strconv.Itoa(int(vm.Memory))}...)
@@ -245,12 +250,13 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
}
}
v.Mounts = mounts
+ v.UID = os.Getuid()
// Add location of bootable image
v.CmdLine = append(v.CmdLine, "-drive", "if=virtio,file="+v.ImagePath)
// This kind of stinks but no other way around this r/n
if len(opts.IgnitionPath) < 1 {
- uri := machine.SSHRemoteConnection.MakeSSHURL("localhost", "/run/user/1000/podman/podman.sock", strconv.Itoa(v.Port), v.RemoteUsername)
+ uri := machine.SSHRemoteConnection.MakeSSHURL("localhost", fmt.Sprintf("/run/user/%d/podman/podman.sock", v.UID), strconv.Itoa(v.Port), v.RemoteUsername)
uriRoot := machine.SSHRemoteConnection.MakeSSHURL("localhost", "/run/podman/podman.sock", strconv.Itoa(v.Port), "root")
identity := filepath.Join(sshDir, v.Name)
@@ -296,7 +302,16 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
// only if the virtualdisk size is less than
// the given disk size
if opts.DiskSize<<(10*3) > originalDiskSize {
- resize := exec.Command("qemu-img", []string{"resize", v.ImagePath, strconv.Itoa(int(opts.DiskSize)) + "G"}...)
+ // Find the qemu executable
+ cfg, err := config.Default()
+ if err != nil {
+ return false, err
+ }
+ resizePath, err := cfg.FindHelperBinary("qemu-img", true)
+ if err != nil {
+ return false, err
+ }
+ resize := exec.Command(resizePath, []string{"resize", v.ImagePath, strconv.Itoa(int(opts.DiskSize)) + "G"}...)
resize.Stdout = os.Stdout
resize.Stderr = os.Stderr
if err := resize.Run(); err != nil {
@@ -319,6 +334,7 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
VMName: v.Name,
TimeZone: opts.TimeZone,
WritePath: v.IgnitionFilePath,
+ UID: v.UID,
}
err = machine.NewIgnitionFile(ign)
return err == nil, err
@@ -459,7 +475,17 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
for _, mount := range v.Mounts {
fmt.Printf("Mounting volume... %s:%s\n", mount.Source, mount.Target)
// create mountpoint directory if it doesn't exist
- err = v.SSH(name, machine.SSHOptions{Args: []string{"-q", "--", "sudo", "mkdir", "-p", mount.Target}})
+ // because / is immutable, we have to monkey around with permissions
+ // if we dont mount in /home or /mnt
+ args := []string{"-q", "--"}
+ if !strings.HasPrefix(mount.Target, "/home") || !strings.HasPrefix(mount.Target, "/mnt") {
+ args = append(args, "sudo", "chattr", "-i", "/", ";")
+ }
+ args = append(args, "sudo", "mkdir", "-p", mount.Target)
+ if !strings.HasPrefix(mount.Target, "/home") || !strings.HasPrefix(mount.Target, "/mnt") {
+ args = append(args, ";", "sudo", "chattr", "+i", "/", ";")
+ }
+ err = v.SSH(name, machine.SSHOptions{Args: args})
if err != nil {
return err
}
@@ -653,7 +679,7 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
if err != nil {
return "", nil, err
}
- if running {
+ if running && !opts.Force {
return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name)
}
@@ -667,6 +693,11 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
if !opts.SaveImage {
files = append(files, v.ImagePath)
}
+ socketPath, err := v.getForwardSocketPath()
+ if err != nil {
+ logrus.Error(err)
+ }
+ files = append(files, socketPath)
files = append(files, v.archRemovalFiles()...)
if err := machine.RemoveConnection(v.Name); err != nil {
@@ -790,7 +821,16 @@ func (v *MachineVM) SSH(name string, opts machine.SSHOptions) error {
// executes qemu-image info to get the virtual disk size
// of the diskimage
func getDiskSize(path string) (uint64, error) {
- diskInfo := exec.Command("qemu-img", "info", "--output", "json", path)
+ // Find the qemu executable
+ cfg, err := config.Default()
+ if err != nil {
+ return 0, err
+ }
+ qemuPathDir, err := cfg.FindHelperBinary("qemu-img", true)
+ if err != nil {
+ return 0, err
+ }
+ diskInfo := exec.Command(qemuPathDir, "info", "--output", "json", path)
stdout, err := diskInfo.StdoutPipe()
if err != nil {
return 0, err
@@ -952,7 +992,7 @@ func (v *MachineVM) setupAPIForwarding(cmd []string) ([]string, string, apiForwa
return cmd, "", noForwarding
}
- destSock := "/run/user/1000/podman/podman.sock"
+ destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", v.UID)
forwardUser := "core"
if v.Rootful {
@@ -1064,16 +1104,15 @@ func waitAndPingAPI(sock string) {
func waitAPIAndPrintInfo(forwardState apiForwardingState, forwardSock string, rootFul bool, name string) {
if forwardState != noForwarding {
+ suffix := ""
+ if name != machine.DefaultMachineName {
+ suffix = " " + name
+ }
waitAndPingAPI(forwardSock)
if !rootFul {
fmt.Printf("\nThis machine is currently configured in rootless mode. If your containers\n")
fmt.Printf("require root permissions (e.g. ports < 1024), or if you run into compatibility\n")
fmt.Printf("issues with non-podman clients, you can switch using the following command: \n")
-
- suffix := ""
- if name != machine.DefaultMachineName {
- suffix = " " + name
- }
fmt.Printf("\n\tpodman machine set --rootful%s\n\n", suffix)
}
@@ -1087,8 +1126,9 @@ func waitAPIAndPrintInfo(forwardState apiForwardingState, forwardSock string, ro
fmt.Printf("\nThe system helper service is not installed; the default Docker API socket\n")
fmt.Printf("address can't be used by podman. ")
if helper := findClaimHelper(); len(helper) > 0 {
- fmt.Printf("If you would like to install it run the\nfollowing command:\n")
- fmt.Printf("\n\tsudo %s install\n\n", helper)
+ fmt.Printf("If you would like to install it run the\nfollowing commands:\n")
+ fmt.Printf("\n\tsudo %s install\n", helper)
+ fmt.Printf("\tpodman machine stop%s; podman machine start%s\n\n", suffix, suffix)
}
case machineLocal:
fmt.Printf("\nAnother process was listening on the default Docker API socket address.\n")
diff --git a/pkg/machine/qemu/options_darwin_arm64.go b/pkg/machine/qemu/options_darwin_arm64.go
index 727a275d2..5b6cdc86d 100644
--- a/pkg/machine/qemu/options_darwin_arm64.go
+++ b/pkg/machine/qemu/options_darwin_arm64.go
@@ -45,6 +45,7 @@ func getOvmfDir(imagePath, vmName string) string {
*/
func getEdk2CodeFd(name string) string {
dirs := []string{
+ "/opt/homebrew/opt/podman/libexec/share/qemu",
"/usr/local/share/qemu",
"/opt/homebrew/share/qemu",
}
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index 8b3550e36..1cc3a463f 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -332,6 +332,11 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
}
// Devices
+ // set the default rule at the beginning of device configuration
+ if !inUserNS && !s.Privileged {
+ g.AddLinuxResourcesDevice(false, "", nil, nil, "rwm")
+ }
+
var userDevices []spec.LinuxDevice
if s.Privileged {
// If privileged, we need to add all the host devices to the
@@ -363,7 +368,6 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
// set the devices cgroup when not running in a user namespace
if !inUserNS && !s.Privileged {
- g.AddLinuxResourcesDevice(false, "", nil, nil, "rwm")
for _, dev := range s.DeviceCgroupRule {
g.AddLinuxResourcesDevice(true, dev.Type, dev.Major, dev.Minor, dev.Access)
}
diff --git a/test/apiv2/12-imagesMore.at b/test/apiv2/12-imagesMore.at
index 96eba1db5..67b4f1c79 100644
--- a/test/apiv2/12-imagesMore.at
+++ b/test/apiv2/12-imagesMore.at
@@ -26,7 +26,8 @@ t GET libpod/images/$IMAGE/json 200 \
.RepoTags[1]=localhost:5000/myrepo:mytag
# Run registry container
-podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml
+# FIXME this fails if python tests have been run first...
+podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.7 /entrypoint.sh /etc/docker/registry/config.yml
wait_for_port localhost 5000
# Push to local registry and check output
@@ -58,7 +59,7 @@ t DELETE libpod/containers/registry?force=true 200
# Remove images
t DELETE libpod/images/$IMAGE 200 \
.ExitCode=0
-t DELETE libpod/images/quay.io/libpod/registry:2.6 200 \
+t DELETE libpod/images/quay.io/libpod/registry:2.7 200 \
.ExitCode=0
if [ -z "${GOT_DIGEST}" ] ; then
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index cc5eda88e..49f8fb3fc 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -394,7 +394,8 @@ t GET containers/$cid/json 200 \
.Config.Healthcheck.Retries=3
# compat api: Test for mount options support
-payload='{"Mounts":[{"Type":"tmpfs","Target":"/mnt/scratch","TmpfsOptions":{"SizeBytes":1024,"Mode":755}}]}'
+# Sigh, JSON can't handle octal. 0755(octal) = 493(decimal)
+payload='{"Mounts":[{"Type":"tmpfs","Target":"/mnt/scratch","TmpfsOptions":{"SizeBytes":1024,"Mode":493}}]}'
t POST containers/create Image=$IMAGE HostConfig="$payload" 201 .Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
t GET containers/$cid/json 200 \
diff --git a/test/apiv2/python/conftest.py b/test/apiv2/python/conftest.py
new file mode 100644
index 000000000..54a267049
--- /dev/null
+++ b/test/apiv2/python/conftest.py
@@ -0,0 +1,8 @@
+"""
+Configure pytest
+"""
+
+
+def pytest_report_header(config):
+ """Add header to report."""
+ return "python client -- requests library"
diff --git a/test/apiv2/python/requirements.txt b/test/apiv2/python/requirements.txt
new file mode 100644
index 000000000..d9cfc687a
--- /dev/null
+++ b/test/apiv2/python/requirements.txt
@@ -0,0 +1,5 @@
+requests-mock~=1.9.3
+requests~=2.20.0
+setuptools~=50.3.2
+python-dateutil~=2.8.1
+PyYAML~=5.4.1
diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2
index bd728e130..ff328cfc8 100755
--- a/test/apiv2/test-apiv2
+++ b/test/apiv2/test-apiv2
@@ -368,7 +368,7 @@ function start_service() {
die "Cannot start service on non-localhost ($HOST)"
fi
- echo $WORKDIR
+ echo "rootdir: "$WORKDIR
# Some tests use shortnames; force registry override to work around
# docker.io throttling.
# FIXME esm revisit pulling expected images re: shortnames caused tests to fail
@@ -376,7 +376,7 @@ function start_service() {
$PODMAN_BIN \
--root $WORKDIR/server_root --syslog=true \
system service \
- --time 15 \
+ --time 0 \
tcp:127.0.0.1:$PORT \
&> $WORKDIR/server.log &
service_pid=$!
@@ -443,7 +443,7 @@ function start_registry() {
-e REGISTRY_HTTP_TLS_KEY=/auth/domain.key \
${REGISTRY_IMAGE}
- wait_for_port localhost $REGISTRY_PORT
+ wait_for_port localhost $REGISTRY_PORT 10
}
function stop_registry() {
@@ -492,13 +492,16 @@ function wait_for_port() {
local port=$2 # Numeric port
local _timeout=${3:-5} # Optional; default to 5 seconds
+ local path=/dev/tcp/$host/$port
+
# Wait
- while [ $_timeout -gt 0 ]; do
+ local i=$_timeout
+ while [ $i -gt 0 ]; do
{ exec 3<> /dev/tcp/$host/$port; } &>/dev/null && return
sleep 1
- _timeout=$(( $_timeout - 1 ))
+ i=$(( $i - 1 ))
done
- die "Timed out waiting for service"
+ die "Timed out (${_timeout}s) waiting for service ($path)"
}
############
@@ -543,6 +546,9 @@ done
###############################################################################
# BEGIN entry handler (subtest invoker)
+echo '============================= test session starts =============================='
+echo "podman client -- $(curl --version)"
+
# Identify the tests to run. If called with args, use those as globs.
tests_to_run=()
if [ -n "$*" ]; then
@@ -558,6 +564,7 @@ if [ -n "$*" ]; then
else
tests_to_run=($TESTS_DIR/*.at)
fi
+echo -e "collected ${#tests_to_run[@]} items\n"
start_service
diff --git a/test/e2e/build/Dockerfile.with-multiple-secret b/test/e2e/build/Containerfile.with-multiple-secret
index f3478914f..f3478914f 100644
--- a/test/e2e/build/Dockerfile.with-multiple-secret
+++ b/test/e2e/build/Containerfile.with-multiple-secret
diff --git a/test/e2e/build/Dockerfile.with-secret b/test/e2e/build/Containerfile.with-secret
index 920663a92..920663a92 100644
--- a/test/e2e/build/Dockerfile.with-secret
+++ b/test/e2e/build/Containerfile.with-secret
diff --git a/test/e2e/build/Dockerfile.test-cp-root-dir b/test/e2e/build/Dockerfile.test-cp-root-dir
deleted file mode 100644
index 9f7de7c32..000000000
--- a/test/e2e/build/Dockerfile.test-cp-root-dir
+++ /dev/null
@@ -1,2 +0,0 @@
-FROM scratch
-COPY Dockerfile.test-cp-root-dir /
diff --git a/test/e2e/build/Dockerfile.with-secret-verify-leak b/test/e2e/build/secret-verify-leak/Containerfile.with-secret-verify-leak
index 0957ac6a6..0957ac6a6 100644
--- a/test/e2e/build/Dockerfile.with-secret-verify-leak
+++ b/test/e2e/build/secret-verify-leak/Containerfile.with-secret-verify-leak
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go
index 14fa12fa2..c5903f037 100644
--- a/test/e2e/build_test.go
+++ b/test/e2e/build_test.go
@@ -60,7 +60,7 @@ var _ = Describe("Podman build", func() {
})
It("podman build with a secret from file", func() {
- session := podmanTest.Podman([]string{"build", "-f", "build/Dockerfile.with-secret", "-t", "secret-test", "--secret", "id=mysecret,src=build/secret.txt", "build/"})
+ session := podmanTest.Podman([]string{"build", "-f", "build/Containerfile.with-secret", "-t", "secret-test", "--secret", "id=mysecret,src=build/secret.txt", "build/"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("somesecret"))
@@ -71,7 +71,7 @@ var _ = Describe("Podman build", func() {
})
It("podman build with multiple secrets from files", func() {
- session := podmanTest.Podman([]string{"build", "-f", "build/Dockerfile.with-multiple-secret", "-t", "multiple-secret-test", "--secret", "id=mysecret,src=build/secret.txt", "--secret", "id=mysecret2,src=build/anothersecret.txt", "build/"})
+ session := podmanTest.Podman([]string{"build", "-f", "build/Containerfile.with-multiple-secret", "-t", "multiple-secret-test", "--secret", "id=mysecret,src=build/secret.txt", "--secret", "id=mysecret2,src=build/anothersecret.txt", "build/"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("somesecret"))
@@ -83,7 +83,7 @@ var _ = Describe("Podman build", func() {
})
It("podman build with a secret from file and verify if secret file is not leaked into image", func() {
- session := podmanTest.Podman([]string{"build", "-f", "build/Dockerfile.with-secret-verify-leak", "-t", "secret-test-leak", "--secret", "id=mysecret,src=build/secret.txt", "build/"})
+ session := podmanTest.Podman([]string{"build", "-f", "build/secret-verify-leak/Containerfile.with-secret-verify-leak", "-t", "secret-test-leak", "--secret", "id=mysecret,src=build/secret.txt", "build/"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("somesecret"))
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 9b1e0c74b..6a4083565 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -1888,6 +1888,26 @@ var _ = Describe("Podman play kube", func() {
Expect(kube).Should(Exit(0))
})
+ It("podman play kube test duplicate container name", func() {
+ p := getPod(withCtr(getCtr(withName("testctr"), withCmd([]string{"echo", "hello"}))), withCtr(getCtr(withName("testctr"), withCmd([]string{"echo", "world"}))))
+
+ err := generateKubeYaml("pod", p, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube).To(ExitWithError())
+
+ p = getPod(withPodInitCtr(getCtr(withImage(ALPINE), withCmd([]string{"echo", "hello"}), withInitCtr(), withName("initctr"))), withCtr(getCtr(withImage(ALPINE), withName("initctr"), withCmd([]string{"top"}))))
+
+ err = generateKubeYaml("pod", p, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube = podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube).To(ExitWithError())
+ })
+
It("podman play kube test hostname", func() {
pod := getPod()
err := generateKubeYaml("pod", pod, kubeYaml)
diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go
index b8bdc84f8..479837dda 100644
--- a/test/e2e/run_device_test.go
+++ b/test/e2e/run_device_test.go
@@ -44,6 +44,11 @@ var _ = Describe("Podman run device", func() {
session := podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "/dev/kmsg", ALPINE, "test", "-c", "/dev/kmsg"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
+ if !isRootless() {
+ session = podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "/dev/kmsg", "--cap-add", "SYS_ADMIN", ALPINE, "head", "-n", "1", "/dev/kmsg"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ }
})
It("podman run device rename test", func() {
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index aa1887f84..2202cadd8 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -2,15 +2,19 @@ package integration
import (
"fmt"
+ "net"
"os"
"strings"
+ "syscall"
+ "github.com/containernetworking/plugins/pkg/ns"
. "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/uber/jaeger-client-go/utils"
+ "github.com/vishvananda/netlink"
)
var _ = Describe("Podman run networking", func() {
@@ -694,6 +698,157 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(session.OutputToString()).To(ContainSubstring("11.11.11.11"))
})
+ addAddr := func(cidr string, containerInterface netlink.Link) error {
+ _, ipnet, err := net.ParseCIDR(cidr)
+ Expect(err).To(BeNil())
+ addr := &netlink.Addr{IPNet: ipnet, Label: ""}
+ if err := netlink.AddrAdd(containerInterface, addr); err != nil && err != syscall.EEXIST {
+ return err
+ }
+ return nil
+ }
+
+ loopbackup := func() {
+ lo, err := netlink.LinkByName("lo")
+ Expect(err).To(BeNil())
+ err = netlink.LinkSetUp(lo)
+ Expect(err).To(BeNil())
+ }
+
+ linkup := func(name string, mac string, addresses []string) {
+ linkAttr := netlink.NewLinkAttrs()
+ linkAttr.Name = name
+ m, err := net.ParseMAC(mac)
+ Expect(err).To(BeNil())
+ linkAttr.HardwareAddr = net.HardwareAddr(m)
+ eth := &netlink.Dummy{LinkAttrs: linkAttr}
+ err = netlink.LinkAdd(eth)
+ Expect(err).To(BeNil())
+ err = netlink.LinkSetUp(eth)
+ Expect(err).To(BeNil())
+ for _, address := range addresses {
+ err := addAddr(address, eth)
+ Expect(err).To(BeNil())
+ }
+ }
+
+ routeAdd := func(gateway string) {
+ gw := net.ParseIP(gateway)
+ route := &netlink.Route{Dst: nil, Gw: gw}
+ netlink.RouteAdd(route)
+ }
+
+ setupNetworkNs := func(networkNSName string) {
+ ns.WithNetNSPath("/run/netns/"+networkNSName, func(_ ns.NetNS) error {
+ loopbackup()
+ linkup("eth0", "46:7f:45:6e:4f:c8", []string{"10.25.40.0/24", "fd04:3e42:4a4e:3381::/64"})
+ linkup("eth1", "56:6e:35:5d:3e:a8", []string{"10.88.0.0/16"})
+
+ routeAdd("10.25.40.0")
+ return nil
+ })
+ }
+
+ checkNetworkNsInspect := func(name string) {
+ inspectOut := podmanTest.InspectContainer(name)
+ Expect(inspectOut[0].NetworkSettings.IPAddress).To(Equal("10.25.40.0"))
+ Expect(inspectOut[0].NetworkSettings.IPPrefixLen).To(Equal(24))
+ Expect(len(inspectOut[0].NetworkSettings.SecondaryIPAddresses)).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0].Addr).To(Equal("10.88.0.0"))
+ Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0].PrefixLength).To(Equal(16))
+ Expect(inspectOut[0].NetworkSettings.GlobalIPv6Address).To(Equal("fd04:3e42:4a4e:3381::"))
+ Expect(inspectOut[0].NetworkSettings.GlobalIPv6PrefixLen).To(Equal(64))
+ Expect(len(inspectOut[0].NetworkSettings.SecondaryIPv6Addresses)).To(Equal(0))
+ Expect(inspectOut[0].NetworkSettings.MacAddress).To(Equal("46:7f:45:6e:4f:c8"))
+ Expect(len(inspectOut[0].NetworkSettings.AdditionalMacAddresses)).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses[0]).To(Equal("56:6e:35:5d:3e:a8"))
+ Expect(inspectOut[0].NetworkSettings.Gateway).To(Equal("10.25.40.0"))
+
+ }
+
+ It("podman run newtork inspect fails gracefully on non-reachable network ns", func() {
+ SkipIfRootless("ip netns is not supported for rootless users")
+
+ networkNSName := RandomString(12)
+ addNamedNetwork := SystemExec("ip", []string{"netns", "add", networkNSName})
+ Expect(addNamedNetwork).Should(Exit(0))
+
+ setupNetworkNs(networkNSName)
+
+ name := RandomString(12)
+ session := podmanTest.Podman([]string{"run", "-d", "--name", name, "--net", "ns:/run/netns/" + networkNSName, ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+
+ // delete the named network ns before inspect
+ delNetworkNamespace := SystemExec("ip", []string{"netns", "delete", networkNSName})
+ Expect(delNetworkNamespace).Should(Exit(0))
+
+ inspectOut := podmanTest.InspectContainer(name)
+ Expect(inspectOut[0].NetworkSettings.IPAddress).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Networks)).To(Equal(0))
+ })
+
+ It("podman inspect can handle joined network ns with multiple interfaces", func() {
+ SkipIfRootless("ip netns is not supported for rootless users")
+
+ networkNSName := RandomString(12)
+ addNamedNetwork := SystemExec("ip", []string{"netns", "add", networkNSName})
+ Expect(addNamedNetwork).Should(Exit(0))
+ defer func() {
+ delNetworkNamespace := SystemExec("ip", []string{"netns", "delete", networkNSName})
+ Expect(delNetworkNamespace).Should(Exit(0))
+ }()
+ setupNetworkNs(networkNSName)
+
+ name := RandomString(12)
+ session := podmanTest.Podman([]string{"run", "--name", name, "--net", "ns:/run/netns/" + networkNSName, ALPINE})
+ session.WaitWithDefaultTimeout()
+
+ session = podmanTest.Podman([]string{"container", "rm", name})
+ session.WaitWithDefaultTimeout()
+
+ // no network teardown should touch joined network ns interfaces
+ session = podmanTest.Podman([]string{"run", "-d", "--replace", "--name", name, "--net", "ns:/run/netns/" + networkNSName, ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+
+ checkNetworkNsInspect(name)
+ })
+
+ It("podman do not tamper with joined network ns interfaces", func() {
+ SkipIfRootless("ip netns is not supported for rootless users")
+
+ networkNSName := RandomString(12)
+ addNamedNetwork := SystemExec("ip", []string{"netns", "add", networkNSName})
+ Expect(addNamedNetwork).Should(Exit(0))
+ defer func() {
+ delNetworkNamespace := SystemExec("ip", []string{"netns", "delete", networkNSName})
+ Expect(delNetworkNamespace).Should(Exit(0))
+ }()
+
+ setupNetworkNs(networkNSName)
+
+ name := RandomString(12)
+ session := podmanTest.Podman([]string{"run", "--name", name, "--net", "ns:/run/netns/" + networkNSName, ALPINE})
+ session.WaitWithDefaultTimeout()
+
+ checkNetworkNsInspect(name)
+
+ name = RandomString(12)
+ session = podmanTest.Podman([]string{"run", "--name", name, "--net", "ns:/run/netns/" + networkNSName, ALPINE})
+ session.WaitWithDefaultTimeout()
+
+ checkNetworkNsInspect(name)
+
+ // delete container, the network inspect should not change
+ session = podmanTest.Podman([]string{"container", "rm", name})
+ session.WaitWithDefaultTimeout()
+
+ session = podmanTest.Podman([]string{"run", "-d", "--replace", "--name", name, "--net", "ns:/run/netns/" + networkNSName, ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+
+ checkNetworkNsInspect(name)
+ })
+
It("podman run network in bogus user created network namespace", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--net", "ns:/run/netns/xxy", ALPINE, "wget", "www.podman.io"})
session.Wait(90)
diff --git a/test/e2e/system_service_test.go b/test/e2e/system_service_test.go
index dcf5e03b2..2bc7756d6 100644
--- a/test/e2e/system_service_test.go
+++ b/test/e2e/system_service_test.go
@@ -58,6 +58,7 @@ var _ = Describe("podman system service", func() {
const magicComment = "pprof service listening on"
It("are available", func() {
+ Skip("FIXME: Test is too flaky (#12624)")
SkipIfRemote("service subcommand not supported remotely")
address := url.URL{
@@ -97,6 +98,7 @@ var _ = Describe("podman system service", func() {
})
It("are not available", func() {
+ Skip("FIXME: Test is too flaky (#12624)")
SkipIfRemote("service subcommand not supported remotely")
address := url.URL{
diff --git a/test/system/700-play.bats b/test/system/700-play.bats
index 88c7cad87..07c5d124f 100644
--- a/test/system/700-play.bats
+++ b/test/system/700-play.bats
@@ -168,3 +168,55 @@ _EOF
run_podman pod rm -t 0 -f test_pod
run_podman rmi -f userimage:latest
}
+
+@test "podman play --build --context-dir" {
+ skip_if_remote "--build is not supported in context remote"
+ testUserYaml="
+apiVersion: v1
+kind: Pod
+metadata:
+ labels:
+ app: test
+ name: test_pod
+spec:
+ containers:
+ - command:
+ - id
+ env:
+ - name: PATH
+ value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ - name: TERM
+ value: xterm
+ - name: container
+ value: podman
+ image: quay.io/libpod/userimage
+ name: test
+ resources: {}
+status: {}
+"
+
+mkdir -p $PODMAN_TMPDIR/userimage
+cat > $PODMAN_TMPDIR/userimage/Containerfile << _EOF
+from $IMAGE
+USER bin
+_EOF
+
+ echo "$testUserYaml" > $PODMAN_TMPDIR/test.yaml
+ run_podman 125 play kube --build --start=false $PODMAN_TMPDIR/test.yaml
+ run_podman play kube --replace --context-dir=$PODMAN_TMPDIR --build --start=false $PODMAN_TMPDIR/test.yaml
+ run_podman inspect --format "{{ .Config.User }}" test_pod-test
+ is "$output" bin "expect container within pod to run as the bin user"
+
+ run_podman stop -a -t 0
+ run_podman pod rm -t 0 -f test_pod
+ run_podman rmi -f userimage:latest
+
+ cd $PODMAN_TMPDIR
+ run_podman play kube --replace --build --start=false $PODMAN_TMPDIR/test.yaml
+ run_podman inspect --format "{{ .Config.User }}" test_pod-test
+ is "$output" bin "expect container within pod to run as the bin user"
+
+ run_podman stop -a -t 0
+ run_podman pod rm -t 0 -f test_pod
+ run_podman rmi -f userimage:latest
+}
diff --git a/troubleshooting.md b/troubleshooting.md
index 8bce8e50f..32f14c1ee 100644
--- a/troubleshooting.md
+++ b/troubleshooting.md
@@ -42,7 +42,7 @@ $ podman run -v ~/mycontent:/content:Z fedora touch /content/file
Make sure the content is private for the container. Do not relabel system directories and content.
Relabeling system content might cause other confined services on your machine to fail. For these
-types of containers we recommend that disable SELinux separation. The option `--security-opt label=disable`
+types of containers we recommend having SELinux separation disabled. The option `--security-opt label=disable`
will disable SELinux separation for the container.
$ podman run --security-opt label=disable -v ~:/home/user fedora touch /home/user/file
@@ -157,7 +157,7 @@ When rootless Podman attempts to execute a container on a non exec home director
#### Symptom
If you are running Podman or Buildah on a home directory that is mounted noexec,
-then they will fail. With a message like:
+then they will fail with a message like:
```
podman run centos:7
@@ -166,7 +166,7 @@ standard_init_linux.go:203: exec user process caused "permission denied"
#### Solution
-Since the administrator of the system setup your home directory to be noexec, you will not be allowed to execute containers from storage in your home directory. It is possible to work around this by manually specifying a container storage path that is not on a noexec mount. Simply copy the file /etc/containers/storage.conf to ~/.config/containers/ (creating the directory if necessary). Specify a graphroot directory which is not on a noexec mount point and to which you have read/write privileges. You will need to modify other fields to writable directories as well.
+Since the administrator of the system set up your home directory to be noexec, you will not be allowed to execute containers from storage in your home directory. It is possible to work around this by manually specifying a container storage path that is not on a noexec mount. Simply copy the file /etc/containers/storage.conf to ~/.config/containers/ (creating the directory if necessary). Specify a graphroot directory which is not on a noexec mount point and to which you have read/write privileges. You will need to modify other fields to writable directories as well.
For example
@@ -229,7 +229,7 @@ Rootless Podman requires the user running it to have a range of UIDs listed in /
#### Symptom
-An user, either via --user or through the default configured for the image, is not mapped inside the namespace.
+A user, either via --user or through the default configured for the image, is not mapped inside the namespace.
```
podman run --rm -ti --user 1000000 alpine echo hi
@@ -279,7 +279,7 @@ grep johndoe /etc/subuid /etc/subgid
### 11) Changing the location of the Graphroot leads to permission denied
When I change the graphroot storage location in storage.conf, the next time I
-run Podman I get an error like:
+run Podman, I get an error like:
```
# podman run -p 5000:5000 -it centos bash
@@ -323,7 +323,7 @@ Pulling an anonymous image that doesn't require authentication can result in an
#### Symptom
If you pull an anonymous image, one that should not require credentials, you can receive
-and `invalid username/password` error if you have credentials established in the
+an `invalid username/password` error if you have credentials established in the
authentication file for the target container registry that are no longer valid.
```
@@ -991,12 +991,15 @@ less: dir1/a: Permission denied
#### Solution
-If you want to read or remove such a file, you can do so by entering a user namespace.
-Instead of running commands such as `less dir1/a` or `rm dir1/a`, you would need to
-prepend the command-line with `podman unshare`, i.e.,
-`podman unshare less dir1/a` or `podman unshare rm dir1/a`. To be able to use Bash
-features, such as variable expansion and globbing, you need to wrap the command with
-`bash -c`, e.g. `podman unshare bash -c 'ls $HOME/dir1/a*'`.
+If you want to read, chown, or remove such a file, enter a user
+namespace. Instead of running commands such as `less dir1/a` or `rm dir1/a`, you
+need to prepend the command-line with `podman unshare`, i.e.,
+`podman unshare less dir1/a` or `podman unshare rm dir1/a`. To change the ownership
+of the file _dir1/a_ to your regular user's UID and GID, run `podman unshare chown 0:0 dir1/a`.
+A file having the ownership _0:0_ in the user namespace is owned by the regular
+user on the host. To use Bash features, such as variable expansion and
+globbing, you need to wrap the command with `bash -c`, e.g.
+`podman unshare bash -c 'ls $HOME/dir1/a*'`.
Would it have been possible to run Podman in another way so that your regular
user would have become the owner of the file? Yes, you can use the options
diff --git a/vendor/github.com/docker/distribution/.mailmap b/vendor/github.com/docker/distribution/.mailmap
index 34421a4ec..8f3738f3d 100644
--- a/vendor/github.com/docker/distribution/.mailmap
+++ b/vendor/github.com/docker/distribution/.mailmap
@@ -44,3 +44,6 @@ Thomas Berger <loki@lokis-chaos.de> Thomas Berger <tbe@users.noreply.github.com>
Samuel Karp <skarp@amazon.com> Samuel Karp <samuelkarp@users.noreply.github.com>
Justin Cormack <justin.cormack@docker.com>
sayboras <sayboras@yahoo.com>
+CrazyMax <github@crazymax.dev>
+CrazyMax <github@crazymax.dev> <1951866+crazy-max@users.noreply.github.com>
+CrazyMax <github@crazymax.dev> <crazy-max@users.noreply.github.com>
diff --git a/vendor/github.com/docker/distribution/Dockerfile b/vendor/github.com/docker/distribution/Dockerfile
index 9d30d3771..ae8c040c7 100644
--- a/vendor/github.com/docker/distribution/Dockerfile
+++ b/vendor/github.com/docker/distribution/Dockerfile
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.3
-ARG GO_VERSION=1.16
+ARG GO_VERSION=1.16.15
ARG GORELEASER_XX_VERSION=1.2.5
FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
@@ -12,6 +12,10 @@ WORKDIR /go/src/github.com/docker/distribution
FROM base AS build
ENV GO111MODULE=auto
ENV CGO_ENABLED=0
+# GIT_REF is used by goreleaser-xx to handle the proper git ref when available.
+# It will fallback to the working tree info if empty and use "git tag --points-at"
+# or "git describe" to define the version info.
+ARG GIT_REF
ARG TARGETPLATFORM
ARG PKG="github.com/distribution/distribution"
ARG BUILDTAGS="include_oss include_gcs"
@@ -28,7 +32,7 @@ RUN --mount=type=bind,rw \
--files="LICENSE" \
--files="README.md"
-FROM scratch AS artifacts
+FROM scratch AS artifact
COPY --from=build /out/*.tar.gz /
COPY --from=build /out/*.zip /
COPY --from=build /out/*.sha256 /
diff --git a/vendor/github.com/docker/distribution/README.md b/vendor/github.com/docker/distribution/README.md
index 998878850..e513c18e9 100644
--- a/vendor/github.com/docker/distribution/README.md
+++ b/vendor/github.com/docker/distribution/README.md
@@ -2,7 +2,7 @@
The Docker toolset to pack, ship, store, and deliver content.
-This repository's main product is the Docker Registry 2.0 implementation
+This repository provides the Docker Registry 2.0 implementation
for storing and distributing Docker images. It supersedes the
[docker/docker-registry](https://github.com/docker/docker-registry)
project with a new API design, focused around security and performance.
diff --git a/vendor/github.com/docker/distribution/docker-bake.hcl b/vendor/github.com/docker/distribution/docker-bake.hcl
index e1457bb81..4dd5a100c 100644
--- a/vendor/github.com/docker/distribution/docker-bake.hcl
+++ b/vendor/github.com/docker/distribution/docker-bake.hcl
@@ -1,3 +1,15 @@
+// GITHUB_REF is the actual ref that triggers the workflow
+// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
+variable "GITHUB_REF" {
+ default = ""
+}
+
+target "_common" {
+ args = {
+ GIT_REF = GITHUB_REF
+ }
+}
+
group "default" {
targets = ["image-local"]
}
@@ -8,12 +20,14 @@ target "docker-metadata-action" {
}
target "binary" {
+ inherits = ["_common"]
target = "binary"
output = ["./bin"]
}
target "artifact" {
- target = "artifacts"
+ inherits = ["_common"]
+ target = "artifact"
output = ["./bin"]
}
@@ -30,7 +44,7 @@ target "artifact-all" {
}
target "image" {
- inherits = ["docker-metadata-action"]
+ inherits = ["_common", "docker-metadata-action"]
}
target "image-local" {
diff --git a/vendor/github.com/vbauerster/mpb/v6/.gitignore b/vendor/github.com/vbauerster/mpb/v6/.gitignore
deleted file mode 100644
index 63bd91672..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-# Test binary, build with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
diff --git a/vendor/github.com/vbauerster/mpb/v6/.travis.yml b/vendor/github.com/vbauerster/mpb/v6/.travis.yml
deleted file mode 100644
index 9a203a67d..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: go
-arch:
- - amd64
- - ppc64le
-
-go:
- - 1.14.x
-
-script:
- - go test -race ./...
- - for i in _examples/*/; do go build $i/*.go || exit 1; done
diff --git a/vendor/github.com/vbauerster/mpb/v6/README.md b/vendor/github.com/vbauerster/mpb/v6/README.md
deleted file mode 100644
index a87786d72..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/README.md
+++ /dev/null
@@ -1,120 +0,0 @@
-# Multi Progress Bar
-
-[![GoDoc](https://pkg.go.dev/badge/github.com/vbauerster/mpb)](https://pkg.go.dev/github.com/vbauerster/mpb/v6)
-[![Build Status](https://travis-ci.org/vbauerster/mpb.svg?branch=master)](https://travis-ci.org/vbauerster/mpb)
-[![Go Report Card](https://goreportcard.com/badge/github.com/vbauerster/mpb)](https://goreportcard.com/report/github.com/vbauerster/mpb)
-
-**mpb** is a Go lib for rendering progress bars in terminal applications.
-
-## Features
-
-- **Multiple Bars**: Multiple progress bars are supported
-- **Dynamic Total**: Set total while bar is running
-- **Dynamic Add/Remove**: Dynamically add or remove bars
-- **Cancellation**: Cancel whole rendering process
-- **Predefined Decorators**: Elapsed time, [ewma](https://github.com/VividCortex/ewma) based ETA, Percentage, Bytes counter
-- **Decorator's width sync**: Synchronized decorator's width among multiple bars
-
-## Usage
-
-#### [Rendering single bar](_examples/singleBar/main.go)
-
-```go
-package main
-
-import (
- "math/rand"
- "time"
-
- "github.com/vbauerster/mpb/v6"
- "github.com/vbauerster/mpb/v6/decor"
-)
-
-func main() {
- // initialize progress container, with custom width
- p := mpb.New(mpb.WithWidth(64))
-
- total := 100
- name := "Single Bar:"
- // adding a single bar, which will inherit container's width
- bar := p.Add(int64(total),
- // progress bar filler with customized style
- mpb.NewBarFiller("╢▌▌░╟"),
- mpb.PrependDecorators(
- // display our name with one space on the right
- decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
- // replace ETA decorator with "done" message, OnComplete event
- decor.OnComplete(
- decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
- ),
- ),
- mpb.AppendDecorators(decor.Percentage()),
- )
- // simulating some work
- max := 100 * time.Millisecond
- for i := 0; i < total; i++ {
- time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
- bar.Increment()
- }
- // wait for our bar to complete and flush
- p.Wait()
-}
-```
-
-#### [Rendering multiple bars](_examples/multiBars/main.go)
-
-```go
- var wg sync.WaitGroup
- // pass &wg (optional), so p will wait for it eventually
- p := mpb.New(mpb.WithWaitGroup(&wg))
- total, numBars := 100, 3
- wg.Add(numBars)
-
- for i := 0; i < numBars; i++ {
- name := fmt.Sprintf("Bar#%d:", i)
- bar := p.AddBar(int64(total),
- mpb.PrependDecorators(
- // simple name decorator
- decor.Name(name),
- // decor.DSyncWidth bit enables column width synchronization
- decor.Percentage(decor.WCSyncSpace),
- ),
- mpb.AppendDecorators(
- // replace ETA decorator with "done" message, OnComplete event
- decor.OnComplete(
- // ETA decorator with ewma age of 60
- decor.EwmaETA(decor.ET_STYLE_GO, 60), "done",
- ),
- ),
- )
- // simulating some work
- go func() {
- defer wg.Done()
- 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)
- bar.Increment()
- // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
- bar.DecoratorEwmaUpdate(time.Since(start))
- }
- }()
- }
- // Waiting for passed &wg and for all bars to complete and flush
- p.Wait()
-```
-
-#### [Dynamic total](_examples/dynTotal/main.go)
-
-![dynamic total](_svg/godEMrCZmJkHYH1X9dN4Nm0U7.svg)
-
-#### [Complex example](_examples/complex/main.go)
-
-![complex](_svg/wHzf1M7sd7B3zVa2scBMnjqRf.svg)
-
-#### [Bytes counters](_examples/io/main.go)
-
-![byte counters](_svg/hIpTa3A5rQz65ssiVuRJu87X6.svg)
diff --git a/vendor/github.com/vbauerster/mpb/v6/UNLICENSE b/vendor/github.com/vbauerster/mpb/v6/UNLICENSE
deleted file mode 100644
index 68a49daad..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/UNLICENSE
+++ /dev/null
@@ -1,24 +0,0 @@
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
diff --git a/vendor/github.com/vbauerster/mpb/v6/bar.go b/vendor/github.com/vbauerster/mpb/v6/bar.go
deleted file mode 100644
index f18ef967f..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/bar.go
+++ /dev/null
@@ -1,492 +0,0 @@
-package mpb
-
-import (
- "bytes"
- "context"
- "fmt"
- "io"
- "log"
- "runtime/debug"
- "strings"
- "time"
-
- "github.com/acarl005/stripansi"
- "github.com/mattn/go-runewidth"
- "github.com/vbauerster/mpb/v6/decor"
-)
-
-// 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
- 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()
- // done is closed after cacheState is assigned
- done chan struct{}
- // cacheState is populated, right after close(shutdown)
- cacheState *bState
-
- container *Progress
- dlogger *log.Logger
- recoveredPanic interface{}
-}
-
-type extenderFunc func(in io.Reader, reqWidth int, st decor.Statistics) (out io.Reader, lines int)
-
-// bState is actual bar state. It gets passed to *Bar.serve(...) monitor
-// goroutine.
-type bState struct {
- id int
- priority int
- reqWidth int
- total int64
- current int64
- refill int64
- lastN int64
- iterated bool
- trimSpace bool
- completed bool
- completeFlushed bool
- triggerComplete bool
- dropOnComplete bool
- noPop bool
- aDecorators []decor.Decorator
- pDecorators []decor.Decorator
- averageDecorators []decor.AverageDecorator
- ewmaDecorators []decor.EwmaDecorator
- shutdownListeners []decor.ShutdownListener
- bufP, bufB, bufA *bytes.Buffer
- filler BarFiller
- middleware func(BarFiller) BarFiller
- extender extenderFunc
-
- // runningBar is a key for *pState.parkedBars
- runningBar *Bar
-
- debugOut io.Writer
-}
-
-func newBar(container *Progress, bs *bState) *Bar {
- logPrefix := fmt.Sprintf("%sbar#%02d ", container.dlogger.Prefix(), bs.id)
- ctx, cancel := context.WithCancel(container.ctx)
-
- bar := &Bar{
- container: container,
- priority: bs.priority,
- toDrop: bs.dropOnComplete,
- noPop: bs.noPop,
- operateState: make(chan func(*bState)),
- frameCh: make(chan io.Reader, 1),
- syncTableCh: make(chan [][]chan int, 1),
- completed: make(chan bool, 1),
- done: make(chan struct{}),
- cancel: cancel,
- dlogger: log.New(bs.debugOut, logPrefix, log.Lshortfile),
- }
-
- go bar.serve(ctx, bs)
- return bar
-}
-
-// 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 {
- panic("expected non nil io.Reader")
- }
- return newProxyReader(r, b)
-}
-
-// ID returs id of the bar.
-func (b *Bar) ID() int {
- result := make(chan int)
- select {
- case b.operateState <- func(s *bState) { result <- s.id }:
- return <-result
- case <-b.done:
- return b.cacheState.id
- }
-}
-
-// Current returns bar's current number, in other words sum of all increments.
-func (b *Bar) Current() int64 {
- result := make(chan int64)
- select {
- case b.operateState <- func(s *bState) { result <- s.current }:
- return <-result
- case <-b.done:
- return b.cacheState.current
- }
-}
-
-// SetRefill sets refill flag with specified amount.
-// The underlying BarFiller will change its visual representation, to
-// indicate refill event. Refill event may be referred to some retry
-// operation for example.
-func (b *Bar) SetRefill(amount int64) {
- select {
- case b.operateState <- func(s *bState) {
- s.refill = amount
- }:
- case <-b.done:
- }
-}
-
-// TraverseDecorators traverses all available decorators and calls cb func on each.
-func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
- select {
- case b.operateState <- func(s *bState) {
- for _, decorators := range [...][]decor.Decorator{
- s.pDecorators,
- s.aDecorators,
- } {
- for _, d := range decorators {
- cb(extractBaseDecorator(d))
- }
- }
- }:
- case <-b.done:
- }
-}
-
-// SetTotal sets total dynamically.
-// If total is less than or equal to zero it takes progress' current value.
-func (b *Bar) SetTotal(total int64, triggerComplete bool) {
- select {
- case b.operateState <- func(s *bState) {
- s.triggerComplete = triggerComplete
- if total <= 0 {
- s.total = s.current
- } else {
- s.total = total
- }
- if s.triggerComplete && !s.completed {
- s.current = s.total
- s.completed = true
- go b.refreshTillShutdown()
- }
- }:
- case <-b.done:
- }
-}
-
-// SetCurrent sets progress' current to an arbitrary value.
-// Setting a negative value will cause a panic.
-func (b *Bar) SetCurrent(current int64) {
- select {
- case b.operateState <- func(s *bState) {
- s.iterated = true
- s.lastN = current - s.current
- s.current = current
- if s.triggerComplete && s.current >= s.total {
- s.current = s.total
- s.completed = true
- go b.refreshTillShutdown()
- }
- }:
- case <-b.done:
- }
-}
-
-// Increment is a shorthand for b.IncrInt64(1).
-func (b *Bar) Increment() {
- b.IncrInt64(1)
-}
-
-// IncrBy is a shorthand for b.IncrInt64(int64(n)).
-func (b *Bar) IncrBy(n int) {
- b.IncrInt64(int64(n))
-}
-
-// IncrInt64 increments progress by amount of n.
-func (b *Bar) IncrInt64(n int64) {
- select {
- case b.operateState <- func(s *bState) {
- s.iterated = true
- s.lastN = n
- s.current += n
- if s.triggerComplete && s.current >= s.total {
- s.current = s.total
- s.completed = true
- go b.refreshTillShutdown()
- }
- }:
- case <-b.done:
- }
-}
-
-// 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.
-func (b *Bar) SetPriority(priority int) {
- select {
- case <-b.done:
- default:
- b.container.setBarPriority(b, priority)
- }
-}
-
-// Abort interrupts bar's running goroutine. Call this, if you'd like
-// to stop/remove bar before completion event. It has no effect after
-// completion event. If drop is true bar will be removed as well.
-func (b *Bar) Abort(drop bool) {
- select {
- case <-b.done:
- default:
- if drop {
- b.container.dropBar(b)
- }
- b.cancel()
- }
-}
-
-// Completed reports whether the bar is in completed state.
-func (b *Bar) Completed() bool {
- select {
- case b.operateState <- func(s *bState) { b.completed <- s.completed }:
- return <-b.completed
- case <-b.done:
- return true
- }
-}
-
-func (b *Bar) serve(ctx context.Context, s *bState) {
- defer b.container.bwg.Done()
- for {
- select {
- case op := <-b.operateState:
- op(s)
- case <-ctx.Done():
- b.cacheState = s
- close(b.done)
- // Notifying decorators about shutdown event
- for _, sl := range s.shutdownListeners {
- sl.Shutdown()
- }
- return
- }
- }
-}
-
-func (b *Bar) render(tw int) {
- select {
- case b.operateState <- func(s *bState) {
- stat := newStatistics(tw, s)
- defer func() {
- // recovering if user defined decorator panics for example
- if p := recover(); p != nil {
- if b.recoveredPanic == nil {
- s.extender = makePanicExtender(p)
- b.toShutdown = !b.toShutdown
- b.recoveredPanic = p
- }
- frame, lines := s.extender(nil, s.reqWidth, stat)
- b.extendedLines = lines
- b.frameCh <- frame
- b.dlogger.Println(p)
- }
- s.completeFlushed = s.completed
- }()
- frame, lines := s.extender(s.draw(stat), s.reqWidth, stat)
- b.extendedLines = lines
- b.toShutdown = s.completed && !s.completeFlushed
- b.frameCh <- frame
- }:
- case <-b.done:
- s := b.cacheState
- stat := newStatistics(tw, s)
- var r io.Reader
- if b.recoveredPanic == nil {
- r = s.draw(stat)
- }
- frame, lines := s.extender(r, s.reqWidth, stat)
- b.extendedLines = lines
- b.frameCh <- frame
- }
-}
-
-func (b *Bar) subscribeDecorators() {
- var averageDecorators []decor.AverageDecorator
- var ewmaDecorators []decor.EwmaDecorator
- var shutdownListeners []decor.ShutdownListener
- b.TraverseDecorators(func(d decor.Decorator) {
- 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)
- }
- })
- select {
- case b.operateState <- func(s *bState) {
- s.averageDecorators = averageDecorators
- s.ewmaDecorators = ewmaDecorators
- s.shutdownListeners = shutdownListeners
- }:
- b.hasEwmaDecorators = len(ewmaDecorators) != 0
- case <-b.done:
- }
-}
-
-func (b *Bar) refreshTillShutdown() {
- for {
- select {
- case b.container.refreshCh <- time.Now():
- case <-b.done:
- return
- }
- }
-}
-
-func (b *Bar) wSyncTable() [][]chan int {
- select {
- case b.operateState <- func(s *bState) { b.syncTableCh <- s.wSyncTable() }:
- return <-b.syncTableCh
- case <-b.done:
- return b.cacheState.wSyncTable()
- }
-}
-
-func (s *bState) draw(stat decor.Statistics) io.Reader {
- if !s.trimSpace {
- stat.AvailableWidth -= 2
- s.bufB.WriteByte(' ')
- defer s.bufB.WriteByte(' ')
- }
-
- nlr := strings.NewReader("\n")
- tw := stat.AvailableWidth
- for _, d := range s.pDecorators {
- str := d.Decor(stat)
- stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str))
- s.bufP.WriteString(str)
- }
- if stat.AvailableWidth <= 0 {
- trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(s.bufP.String()), tw, "…"))
- s.bufP.Reset()
- return io.MultiReader(trunc, s.bufB, nlr)
- }
-
- tw = stat.AvailableWidth
- for _, d := range s.aDecorators {
- str := d.Decor(stat)
- stat.AvailableWidth -= runewidth.StringWidth(stripansi.Strip(str))
- s.bufA.WriteString(str)
- }
- if stat.AvailableWidth <= 0 {
- trunc := strings.NewReader(runewidth.Truncate(stripansi.Strip(s.bufA.String()), tw, "…"))
- s.bufA.Reset()
- return io.MultiReader(s.bufP, s.bufB, trunc, nlr)
- }
-
- s.filler.Fill(s.bufB, s.reqWidth, stat)
-
- return io.MultiReader(s.bufP, s.bufB, s.bufA, nlr)
-}
-
-func (s *bState) wSyncTable() [][]chan int {
- columns := make([]chan int, 0, len(s.pDecorators)+len(s.aDecorators))
- var pCount int
- for _, d := range s.pDecorators {
- if ch, ok := d.Sync(); ok {
- columns = append(columns, ch)
- pCount++
- }
- }
- var aCount int
- for _, d := range s.aDecorators {
- if ch, ok := d.Sync(); ok {
- columns = append(columns, ch)
- aCount++
- }
- }
- table := make([][]chan int, 2)
- table[0] = columns[0:pCount]
- table[1] = columns[pCount : pCount+aCount : pCount+aCount]
- return table
-}
-
-func newStatistics(tw int, s *bState) decor.Statistics {
- return decor.Statistics{
- ID: s.id,
- AvailableWidth: tw,
- Total: s.total,
- Current: s.current,
- Refill: s.refill,
- Completed: s.completeFlushed,
- }
-}
-
-func extractBaseDecorator(d decor.Decorator) decor.Decorator {
- if d, ok := d.(decor.Wrapper); ok {
- return extractBaseDecorator(d.Base())
- }
- 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)
- }
-}
-
-func makePanicExtender(p interface{}) extenderFunc {
- pstr := fmt.Sprint(p)
- stack := debug.Stack()
- stackLines := bytes.Count(stack, []byte("\n"))
- return func(_ io.Reader, _ int, st decor.Statistics) (io.Reader, int) {
- mr := io.MultiReader(
- strings.NewReader(runewidth.Truncate(pstr, st.AvailableWidth, "…")),
- strings.NewReader(fmt.Sprintf("\n%#v\n", st)),
- bytes.NewReader(stack),
- )
- return mr, stackLines + 1
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/bar_filler.go b/vendor/github.com/vbauerster/mpb/v6/bar_filler.go
deleted file mode 100644
index c8cedaa4a..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/bar_filler.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package mpb
-
-import (
- "io"
-
- "github.com/vbauerster/mpb/v6/decor"
-)
-
-// BarFiller interface.
-// Bar (without decorators) renders itself by calling BarFiller's Fill method.
-//
-// reqWidth is requested width, set by `func WithWidth(int) ContainerOption`.
-// If not set, it defaults to terminal width.
-//
-// Default implementations can be obtained via:
-//
-// func NewBarFiller(style string) BarFiller
-// func NewBarFillerRev(style string) BarFiller
-// func NewBarFillerPick(style string, rev bool) BarFiller
-// func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller
-//
-type BarFiller interface {
- Fill(w io.Writer, reqWidth int, stat decor.Statistics)
-}
-
-// BarFillerFunc is function type adapter to convert function into BarFiller.
-type BarFillerFunc func(w io.Writer, reqWidth int, stat decor.Statistics)
-
-func (f BarFillerFunc) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
- f(w, reqWidth, stat)
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/bar_filler_bar.go b/vendor/github.com/vbauerster/mpb/v6/bar_filler_bar.go
deleted file mode 100644
index 1c339e91d..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/bar_filler_bar.go
+++ /dev/null
@@ -1,191 +0,0 @@
-package mpb
-
-import (
- "bytes"
- "io"
- "unicode/utf8"
-
- "github.com/mattn/go-runewidth"
- "github.com/rivo/uniseg"
- "github.com/vbauerster/mpb/v6/decor"
- "github.com/vbauerster/mpb/v6/internal"
-)
-
-const (
- rLeft = iota
- rFill
- rTip
- rSpace
- rRight
- rRevTip
- rRefill
-)
-
-// BarDefaultStyle is a style for rendering a progress bar.
-// It consist of 7 ordered runes:
-//
-// '1st rune' stands for left boundary rune
-//
-// '2nd rune' stands for fill rune
-//
-// '3rd rune' stands for tip rune
-//
-// '4th rune' stands for space rune
-//
-// '5th rune' stands for right boundary rune
-//
-// '6th rune' stands for reverse tip rune
-//
-// '7th rune' stands for refill rune
-//
-const BarDefaultStyle string = "[=>-]<+"
-
-type barFiller struct {
- format [][]byte
- rwidth []int
- tip []byte
- refill int64
- reverse bool
- flush func(io.Writer, *space, [][]byte)
-}
-
-type space struct {
- space []byte
- rwidth int
- count int
-}
-
-// NewBarFiller returns a BarFiller implementation which renders a
-// progress bar in regular direction. If style is empty string,
-// BarDefaultStyle is applied. To be used with `*Progress.Add(...)
-// *Bar` method.
-func NewBarFiller(style string) BarFiller {
- return newBarFiller(style, false)
-}
-
-// NewBarFillerRev returns a BarFiller implementation which renders a
-// progress bar in reverse direction. If style is empty string,
-// BarDefaultStyle is applied. To be used with `*Progress.Add(...)
-// *Bar` method.
-func NewBarFillerRev(style string) BarFiller {
- return newBarFiller(style, true)
-}
-
-// NewBarFillerPick pick between regular and reverse BarFiller implementation
-// based on rev param. To be used with `*Progress.Add(...) *Bar` method.
-func NewBarFillerPick(style string, rev bool) BarFiller {
- return newBarFiller(style, rev)
-}
-
-func newBarFiller(style string, rev bool) BarFiller {
- bf := &barFiller{
- format: make([][]byte, len(BarDefaultStyle)),
- rwidth: make([]int, len(BarDefaultStyle)),
- reverse: rev,
- }
- bf.parse(BarDefaultStyle)
- if style != "" && style != BarDefaultStyle {
- bf.parse(style)
- }
- return bf
-}
-
-func (s *barFiller) parse(style string) {
- if !utf8.ValidString(style) {
- panic("invalid bar style")
- }
- srcFormat := make([][]byte, len(BarDefaultStyle))
- srcRwidth := make([]int, len(BarDefaultStyle))
- i := 0
- for gr := uniseg.NewGraphemes(style); i < len(BarDefaultStyle) && gr.Next(); i++ {
- srcFormat[i] = gr.Bytes()
- srcRwidth[i] = runewidth.StringWidth(gr.Str())
- }
- copy(s.format, srcFormat[:i])
- copy(s.rwidth, srcRwidth[:i])
- if s.reverse {
- s.tip = s.format[rRevTip]
- s.flush = reverseFlush
- } else {
- s.tip = s.format[rTip]
- s.flush = regularFlush
- }
-}
-
-func (s *barFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
- width := internal.CheckRequestedWidth(reqWidth, stat.AvailableWidth)
- brackets := s.rwidth[rLeft] + s.rwidth[rRight]
- if width < brackets {
- return
- }
- // don't count brackets as progress
- width -= brackets
-
- w.Write(s.format[rLeft])
- defer w.Write(s.format[rRight])
-
- cwidth := int(internal.PercentageRound(stat.Total, stat.Current, width))
- space := &space{
- space: s.format[rSpace],
- rwidth: s.rwidth[rSpace],
- count: width - cwidth,
- }
-
- index, refill := 0, 0
- bb := make([][]byte, cwidth)
-
- if cwidth > 0 && cwidth != width {
- bb[index] = s.tip
- cwidth -= s.rwidth[rTip]
- index++
- }
-
- if stat.Refill > 0 {
- refill = int(internal.PercentageRound(stat.Total, int64(stat.Refill), width))
- if refill > cwidth {
- refill = cwidth
- }
- cwidth -= refill
- }
-
- for cwidth > 0 {
- bb[index] = s.format[rFill]
- cwidth -= s.rwidth[rFill]
- index++
- }
-
- for refill > 0 {
- bb[index] = s.format[rRefill]
- refill -= s.rwidth[rRefill]
- index++
- }
-
- if cwidth+refill < 0 || space.rwidth > 1 {
- buf := new(bytes.Buffer)
- s.flush(buf, space, bb[:index])
- io.WriteString(w, runewidth.Truncate(buf.String(), width, "…"))
- return
- }
-
- s.flush(w, space, bb)
-}
-
-func regularFlush(w io.Writer, space *space, bb [][]byte) {
- for i := len(bb) - 1; i >= 0; i-- {
- w.Write(bb[i])
- }
- for space.count > 0 {
- w.Write(space.space)
- space.count -= space.rwidth
- }
-}
-
-func reverseFlush(w io.Writer, space *space, bb [][]byte) {
- for space.count > 0 {
- w.Write(space.space)
- space.count -= space.rwidth
- }
- for i := 0; i < len(bb); i++ {
- w.Write(bb[i])
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go b/vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go
deleted file mode 100644
index 0817b19ec..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package mpb
-
-import (
- "io"
- "strings"
-
- "github.com/mattn/go-runewidth"
- "github.com/vbauerster/mpb/v6/decor"
- "github.com/vbauerster/mpb/v6/internal"
-)
-
-// SpinnerAlignment enum.
-type SpinnerAlignment int
-
-// SpinnerAlignment kinds.
-const (
- SpinnerOnLeft SpinnerAlignment = iota
- SpinnerOnMiddle
- SpinnerOnRight
-)
-
-// SpinnerDefaultStyle is a style for rendering a spinner.
-var SpinnerDefaultStyle = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
-
-type spinnerFiller struct {
- frames []string
- count uint
- alignment SpinnerAlignment
-}
-
-// NewSpinnerFiller returns a BarFiller implementation which renders
-// a spinner. If style is nil or zero length, SpinnerDefaultStyle is
-// applied. To be used with `*Progress.Add(...) *Bar` method.
-func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller {
- if len(style) == 0 {
- style = SpinnerDefaultStyle
- }
- filler := &spinnerFiller{
- frames: style,
- alignment: alignment,
- }
- return filler
-}
-
-func (s *spinnerFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
- width := internal.CheckRequestedWidth(reqWidth, stat.AvailableWidth)
-
- frame := s.frames[s.count%uint(len(s.frames))]
- frameWidth := runewidth.StringWidth(frame)
-
- if width < frameWidth {
- return
- }
-
- switch rest := width - frameWidth; s.alignment {
- case SpinnerOnLeft:
- io.WriteString(w, frame+strings.Repeat(" ", rest))
- case SpinnerOnMiddle:
- str := strings.Repeat(" ", rest/2) + frame + strings.Repeat(" ", rest/2+rest%2)
- io.WriteString(w, str)
- case SpinnerOnRight:
- io.WriteString(w, strings.Repeat(" ", rest)+frame)
- }
- s.count++
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/bar_option.go b/vendor/github.com/vbauerster/mpb/v6/bar_option.go
deleted file mode 100644
index e359c110c..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/bar_option.go
+++ /dev/null
@@ -1,153 +0,0 @@
-package mpb
-
-import (
- "bytes"
- "io"
-
- "github.com/vbauerster/mpb/v6/decor"
- "github.com/vbauerster/mpb/v6/internal"
-)
-
-// BarOption is a func option to alter default behavior of a bar.
-type BarOption func(*bState)
-
-func (s *bState) addDecorators(dest *[]decor.Decorator, decorators ...decor.Decorator) {
- type mergeWrapper interface {
- MergeUnwrap() []decor.Decorator
- }
- for _, decorator := range decorators {
- if mw, ok := decorator.(mergeWrapper); ok {
- *dest = append(*dest, mw.MergeUnwrap()...)
- }
- *dest = append(*dest, decorator)
- }
-}
-
-// AppendDecorators let you inject decorators to the bar's right side.
-func AppendDecorators(decorators ...decor.Decorator) BarOption {
- return func(s *bState) {
- s.addDecorators(&s.aDecorators, decorators...)
- }
-}
-
-// PrependDecorators let you inject decorators to the bar's left side.
-func PrependDecorators(decorators ...decor.Decorator) BarOption {
- return func(s *bState) {
- s.addDecorators(&s.pDecorators, decorators...)
- }
-}
-
-// BarID sets bar id.
-func BarID(id int) BarOption {
- return func(s *bState) {
- s.id = id
- }
-}
-
-// BarWidth sets bar width independent of the container.
-func BarWidth(width int) BarOption {
- return func(s *bState) {
- s.reqWidth = width
- }
-}
-
-// BarQueueAfter queues this (being constructed) bar to relplace
-// runningBar after it has been completed.
-func BarQueueAfter(runningBar *Bar) BarOption {
- if runningBar == nil {
- return nil
- }
- return func(s *bState) {
- s.runningBar = runningBar
- }
-}
-
-// BarRemoveOnComplete removes both bar's filler and its decorators
-// on complete event.
-func BarRemoveOnComplete() BarOption {
- return func(s *bState) {
- s.dropOnComplete = true
- }
-}
-
-// BarFillerClearOnComplete clears bar's filler on complete event.
-// It's shortcut for BarFillerOnComplete("").
-func BarFillerClearOnComplete() BarOption {
- return BarFillerOnComplete("")
-}
-
-// BarFillerOnComplete replaces bar's filler with message, on complete event.
-func BarFillerOnComplete(message string) BarOption {
- return BarFillerMiddleware(func(base BarFiller) BarFiller {
- return BarFillerFunc(func(w io.Writer, reqWidth int, st decor.Statistics) {
- if st.Completed {
- io.WriteString(w, message)
- } else {
- base.Fill(w, reqWidth, st)
- }
- })
- })
-}
-
-// BarFillerMiddleware provides a way to augment the underlying BarFiller.
-func BarFillerMiddleware(middle func(BarFiller) BarFiller) BarOption {
- return func(s *bState) {
- s.middleware = middle
- }
-}
-
-// BarPriority sets bar's priority. Zero is highest priority, i.e. bar
-// will be on top. If `BarReplaceOnComplete` option is supplied, this
-// option is ignored.
-func BarPriority(priority int) BarOption {
- return func(s *bState) {
- s.priority = priority
- }
-}
-
-// BarExtender provides a way to extend bar to the next new line.
-func BarExtender(filler BarFiller) BarOption {
- if filler == nil {
- return nil
- }
- return func(s *bState) {
- s.extender = makeExtenderFunc(filler)
- }
-}
-
-func makeExtenderFunc(filler BarFiller) extenderFunc {
- buf := new(bytes.Buffer)
- return func(r io.Reader, reqWidth int, st decor.Statistics) (io.Reader, int) {
- filler.Fill(buf, reqWidth, st)
- return io.MultiReader(r, buf), bytes.Count(buf.Bytes(), []byte("\n"))
- }
-}
-
-// BarFillerTrim removes leading and trailing space around the underlying BarFiller.
-func BarFillerTrim() BarOption {
- return func(s *bState) {
- s.trimSpace = true
- }
-}
-
-// BarNoPop disables bar pop out of container. Effective when
-// PopCompletedMode of container is enabled.
-func BarNoPop() BarOption {
- return func(s *bState) {
- s.noPop = true
- }
-}
-
-// BarOptional will invoke provided option only when pick is true.
-func BarOptional(option BarOption, pick bool) BarOption {
- return BarOptOn(option, internal.Predicate(pick))
-}
-
-// BarOptOn will invoke provided option only when higher order predicate
-// evaluates to true.
-func BarOptOn(option BarOption, predicate func() bool) BarOption {
- if predicate() {
- return option
- }
- return nil
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/container_option.go b/vendor/github.com/vbauerster/mpb/v6/container_option.go
deleted file mode 100644
index b92c7578c..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/container_option.go
+++ /dev/null
@@ -1,112 +0,0 @@
-package mpb
-
-import (
- "io"
- "io/ioutil"
- "sync"
- "time"
-
- "github.com/vbauerster/mpb/v6/internal"
-)
-
-// ContainerOption is a func option to alter default behavior of a bar
-// container. Container term refers to a Progress struct which can
-// hold one or more Bars.
-type ContainerOption func(*pState)
-
-// WithWaitGroup provides means to have a single joint point. If
-// *sync.WaitGroup is provided, you can safely call just p.Wait()
-// without calling Wait() on provided *sync.WaitGroup. Makes sense
-// when there are more than one bar to render.
-func WithWaitGroup(wg *sync.WaitGroup) ContainerOption {
- return func(s *pState) {
- s.uwg = wg
- }
-}
-
-// WithWidth sets container width. If not set it defaults to terminal
-// width. A bar added to the container will inherit its width, unless
-// overridden by `func BarWidth(int) BarOption`.
-func WithWidth(width int) ContainerOption {
- return func(s *pState) {
- s.reqWidth = width
- }
-}
-
-// WithRefreshRate overrides default 120ms refresh rate.
-func WithRefreshRate(d time.Duration) ContainerOption {
- return func(s *pState) {
- s.rr = d
- }
-}
-
-// WithManualRefresh disables internal auto refresh time.Ticker.
-// Refresh will occur upon receive value from provided ch.
-func WithManualRefresh(ch <-chan interface{}) ContainerOption {
- return func(s *pState) {
- s.externalRefresh = ch
- }
-}
-
-// WithRenderDelay delays rendering. By default rendering starts as
-// soon as bar is added, with this option it's possible to delay
-// rendering process by keeping provided chan unclosed. In other words
-// rendering will start as soon as provided chan is closed.
-func WithRenderDelay(ch <-chan struct{}) ContainerOption {
- return func(s *pState) {
- s.renderDelay = ch
- }
-}
-
-// WithShutdownNotifier provided chanel will be closed, after all bars
-// have been rendered.
-func WithShutdownNotifier(ch chan struct{}) ContainerOption {
- return func(s *pState) {
- s.shutdownNotifier = ch
- }
-}
-
-// WithOutput overrides default os.Stdout output. Setting it to nil
-// will effectively disable auto refresh rate and discard any output,
-// useful if you want to disable progress bars with little overhead.
-func WithOutput(w io.Writer) ContainerOption {
- return func(s *pState) {
- if w == nil {
- s.output = ioutil.Discard
- s.outputDiscarded = true
- return
- }
- s.output = w
- }
-}
-
-// WithDebugOutput sets debug output.
-func WithDebugOutput(w io.Writer) ContainerOption {
- if w == nil {
- return nil
- }
- return func(s *pState) {
- s.debugOut = w
- }
-}
-
-// PopCompletedMode will pop and stop rendering completed bars.
-func PopCompletedMode() ContainerOption {
- return func(s *pState) {
- s.popCompleted = true
- }
-}
-
-// ContainerOptional will invoke provided option only when pick is true.
-func ContainerOptional(option ContainerOption, pick bool) ContainerOption {
- return ContainerOptOn(option, internal.Predicate(pick))
-}
-
-// ContainerOptOn will invoke provided option only when higher order
-// predicate evaluates to true.
-func ContainerOptOn(option ContainerOption, predicate func() bool) ContainerOption {
- if predicate() {
- return option
- }
- return nil
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/doc.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/doc.go
deleted file mode 100644
index 93c8f8268..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package cwriter is a console writer abstraction for the underlying OS.
-package cwriter
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/util_bsd.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/util_bsd.go
deleted file mode 100644
index 4e3564ece..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/util_bsd.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build darwin dragonfly freebsd netbsd openbsd
-
-package cwriter
-
-import "golang.org/x/sys/unix"
-
-const ioctlReadTermios = unix.TIOCGETA
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/util_linux.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/util_linux.go
deleted file mode 100644
index 253f12dd2..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/util_linux.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build aix linux
-
-package cwriter
-
-import "golang.org/x/sys/unix"
-
-const ioctlReadTermios = unix.TCGETS
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/util_solaris.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/util_solaris.go
deleted file mode 100644
index 4b29ff5c0..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/util_solaris.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build solaris
-
-package cwriter
-
-import "golang.org/x/sys/unix"
-
-const ioctlReadTermios = unix.TCGETA
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/writer.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/writer.go
deleted file mode 100644
index 1ade54761..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/writer.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package cwriter
-
-import (
- "bytes"
- "errors"
- "io"
- "os"
- "strconv"
-)
-
-// ErrNotTTY not a TeleTYpewriter error.
-var ErrNotTTY = errors.New("not a terminal")
-
-// http://ascii-table.com/ansi-escape-sequences.php
-const (
- escOpen = "\x1b["
- cuuAndEd = "A\x1b[J"
-)
-
-// Writer is a buffered the writer that updates the terminal. The
-// contents of writer will be flushed when Flush is called.
-type Writer struct {
- out io.Writer
- buf bytes.Buffer
- lineCount int
- fd int
- isTerminal bool
-}
-
-// New returns a new Writer with defaults.
-func New(out io.Writer) *Writer {
- w := &Writer{out: out}
- if f, ok := out.(*os.File); ok {
- w.fd = int(f.Fd())
- w.isTerminal = IsTerminal(w.fd)
- }
- return w
-}
-
-// Flush flushes the underlying buffer.
-func (w *Writer) Flush(lineCount int) (err error) {
- // some terminals interpret 'cursor up 0' as 'cursor up 1'
- if w.lineCount > 0 {
- err = w.clearLines()
- if err != nil {
- return
- }
- }
- w.lineCount = lineCount
- _, err = w.buf.WriteTo(w.out)
- return
-}
-
-// Write appends the contents of p to the underlying buffer.
-func (w *Writer) Write(p []byte) (n int, err error) {
- return w.buf.Write(p)
-}
-
-// WriteString writes string to the underlying buffer.
-func (w *Writer) WriteString(s string) (n int, err error) {
- return w.buf.WriteString(s)
-}
-
-// ReadFrom reads from the provided io.Reader and writes to the
-// underlying buffer.
-func (w *Writer) ReadFrom(r io.Reader) (n int64, err error) {
- return w.buf.ReadFrom(r)
-}
-
-// GetWidth returns width of underlying terminal.
-func (w *Writer) GetWidth() (int, error) {
- if !w.isTerminal {
- return -1, ErrNotTTY
- }
- tw, _, err := GetSize(w.fd)
- return tw, err
-}
-
-func (w *Writer) ansiCuuAndEd() (err error) {
- buf := make([]byte, 8)
- buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lineCount), 10)
- _, err = w.out.Write(append(buf, cuuAndEd...))
- return
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/writer_posix.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/writer_posix.go
deleted file mode 100644
index f54a5d06b..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/writer_posix.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// +build !windows
-
-package cwriter
-
-import (
- "golang.org/x/sys/unix"
-)
-
-func (w *Writer) clearLines() error {
- return w.ansiCuuAndEd()
-}
-
-// GetSize returns the dimensions of the given terminal.
-func GetSize(fd int) (width, height int, err error) {
- ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
- if err != nil {
- return -1, -1, err
- }
- return int(ws.Col), int(ws.Row), nil
-}
-
-// IsTerminal returns whether the given file descriptor is a terminal.
-func IsTerminal(fd int) bool {
- _, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
- return err == nil
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/cwriter/writer_windows.go b/vendor/github.com/vbauerster/mpb/v6/cwriter/writer_windows.go
deleted file mode 100644
index 1a69c81ac..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/cwriter/writer_windows.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// +build windows
-
-package cwriter
-
-import (
- "unsafe"
-
- "golang.org/x/sys/windows"
-)
-
-var kernel32 = windows.NewLazySystemDLL("kernel32.dll")
-
-var (
- procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
- procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
-)
-
-func (w *Writer) clearLines() error {
- if !w.isTerminal {
- // hope it's cygwin or similar
- return w.ansiCuuAndEd()
- }
-
- var info windows.ConsoleScreenBufferInfo
- if err := windows.GetConsoleScreenBufferInfo(windows.Handle(w.fd), &info); err != nil {
- return err
- }
-
- info.CursorPosition.Y -= int16(w.lineCount)
- if info.CursorPosition.Y < 0 {
- info.CursorPosition.Y = 0
- }
- _, _, _ = procSetConsoleCursorPosition.Call(
- uintptr(w.fd),
- uintptr(uint32(uint16(info.CursorPosition.Y))<<16|uint32(uint16(info.CursorPosition.X))),
- )
-
- // clear the lines
- cursor := &windows.Coord{
- X: info.Window.Left,
- Y: info.CursorPosition.Y,
- }
- count := uint32(info.Size.X) * uint32(w.lineCount)
- _, _, _ = procFillConsoleOutputCharacter.Call(
- uintptr(w.fd),
- uintptr(' '),
- uintptr(count),
- *(*uintptr)(unsafe.Pointer(cursor)),
- uintptr(unsafe.Pointer(new(uint32))),
- )
- return nil
-}
-
-// GetSize returns the visible dimensions of the given terminal.
-//
-// These dimensions don't include any scrollback buffer height.
-func GetSize(fd int) (width, height int, err error) {
- var info windows.ConsoleScreenBufferInfo
- if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
- return 0, 0, err
- }
- // terminal.GetSize from crypto/ssh adds "+ 1" to both width and height:
- // https://go.googlesource.com/crypto/+/refs/heads/release-branch.go1.14/ssh/terminal/util_windows.go#75
- // but looks like this is a root cause of issue #66, so removing both "+ 1" have fixed it.
- return int(info.Window.Right - info.Window.Left), int(info.Window.Bottom - info.Window.Top), nil
-}
-
-// IsTerminal returns whether the given file descriptor is a terminal.
-func IsTerminal(fd int) bool {
- var st uint32
- err := windows.GetConsoleMode(windows.Handle(fd), &st)
- return err == nil
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/any.go b/vendor/github.com/vbauerster/mpb/v6/decor/any.go
deleted file mode 100644
index 39518f594..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/any.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package decor
-
-// Any decorator displays text, that can be changed during decorator's
-// lifetime via provided DecorFunc.
-//
-// `fn` DecorFunc callback
-//
-// `wcc` optional WC config
-//
-func Any(fn DecorFunc, wcc ...WC) Decorator {
- return &any{initWC(wcc...), fn}
-}
-
-type any struct {
- WC
- fn DecorFunc
-}
-
-func (d *any) Decor(s Statistics) string {
- return d.FormatMsg(d.fn(s))
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/counters.go b/vendor/github.com/vbauerster/mpb/v6/decor/counters.go
deleted file mode 100644
index 4a5343d41..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/counters.go
+++ /dev/null
@@ -1,243 +0,0 @@
-package decor
-
-import (
- "fmt"
- "strings"
-)
-
-const (
- _ = iota
- UnitKiB
- UnitKB
-)
-
-// CountersNoUnit is a wrapper around Counters with no unit param.
-func CountersNoUnit(pairFmt string, wcc ...WC) Decorator {
- return Counters(0, pairFmt, wcc...)
-}
-
-// CountersKibiByte is a wrapper around Counters with predefined unit
-// UnitKiB (bytes/1024).
-func CountersKibiByte(pairFmt string, wcc ...WC) Decorator {
- return Counters(UnitKiB, pairFmt, wcc...)
-}
-
-// CountersKiloByte is a wrapper around Counters with predefined unit
-// UnitKB (bytes/1000).
-func CountersKiloByte(pairFmt string, wcc ...WC) Decorator {
- return Counters(UnitKB, pairFmt, wcc...)
-}
-
-// Counters decorator with dynamic unit measure adjustment.
-//
-// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
-//
-// `pairFmt` printf compatible verbs for current and total pair
-//
-// `wcc` optional WC config
-//
-// pairFmt example if unit=UnitKB:
-//
-// pairFmt="%.1f / %.1f" output: "1.0MB / 12.0MB"
-// pairFmt="% .1f / % .1f" output: "1.0 MB / 12.0 MB"
-// pairFmt="%d / %d" output: "1MB / 12MB"
-// pairFmt="% d / % d" output: "1 MB / 12 MB"
-//
-func Counters(unit int, pairFmt string, wcc ...WC) Decorator {
- producer := func(unit int, pairFmt string) DecorFunc {
- if pairFmt == "" {
- pairFmt = "%d / %d"
- } else if strings.Count(pairFmt, "%") != 2 {
- panic("expected pairFmt with exactly 2 verbs")
- }
- switch unit {
- case UnitKiB:
- return func(s Statistics) string {
- return fmt.Sprintf(pairFmt, SizeB1024(s.Current), SizeB1024(s.Total))
- }
- case UnitKB:
- return func(s Statistics) string {
- return fmt.Sprintf(pairFmt, SizeB1000(s.Current), SizeB1000(s.Total))
- }
- default:
- return func(s Statistics) string {
- return fmt.Sprintf(pairFmt, s.Current, s.Total)
- }
- }
- }
- return Any(producer(unit, pairFmt), wcc...)
-}
-
-// TotalNoUnit is a wrapper around Total with no unit param.
-func TotalNoUnit(format string, wcc ...WC) Decorator {
- return Total(0, format, wcc...)
-}
-
-// TotalKibiByte is a wrapper around Total with predefined unit
-// UnitKiB (bytes/1024).
-func TotalKibiByte(format string, wcc ...WC) Decorator {
- return Total(UnitKiB, format, wcc...)
-}
-
-// TotalKiloByte is a wrapper around Total with predefined unit
-// UnitKB (bytes/1000).
-func TotalKiloByte(format string, wcc ...WC) Decorator {
- return Total(UnitKB, format, wcc...)
-}
-
-// Total decorator with dynamic unit measure adjustment.
-//
-// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
-//
-// `format` printf compatible verb for Total
-//
-// `wcc` optional WC config
-//
-// format example if unit=UnitKiB:
-//
-// format="%.1f" output: "12.0MiB"
-// format="% .1f" output: "12.0 MiB"
-// format="%d" output: "12MiB"
-// format="% d" output: "12 MiB"
-//
-func Total(unit int, format string, wcc ...WC) Decorator {
- producer := func(unit int, format string) DecorFunc {
- if format == "" {
- format = "%d"
- } else if strings.Count(format, "%") != 1 {
- panic("expected format with exactly 1 verb")
- }
-
- switch unit {
- case UnitKiB:
- return func(s Statistics) string {
- return fmt.Sprintf(format, SizeB1024(s.Total))
- }
- case UnitKB:
- return func(s Statistics) string {
- return fmt.Sprintf(format, SizeB1000(s.Total))
- }
- default:
- return func(s Statistics) string {
- return fmt.Sprintf(format, s.Total)
- }
- }
- }
- return Any(producer(unit, format), wcc...)
-}
-
-// CurrentNoUnit is a wrapper around Current with no unit param.
-func CurrentNoUnit(format string, wcc ...WC) Decorator {
- return Current(0, format, wcc...)
-}
-
-// CurrentKibiByte is a wrapper around Current with predefined unit
-// UnitKiB (bytes/1024).
-func CurrentKibiByte(format string, wcc ...WC) Decorator {
- return Current(UnitKiB, format, wcc...)
-}
-
-// CurrentKiloByte is a wrapper around Current with predefined unit
-// UnitKB (bytes/1000).
-func CurrentKiloByte(format string, wcc ...WC) Decorator {
- return Current(UnitKB, format, wcc...)
-}
-
-// Current decorator with dynamic unit measure adjustment.
-//
-// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
-//
-// `format` printf compatible verb for Current
-//
-// `wcc` optional WC config
-//
-// format example if unit=UnitKiB:
-//
-// format="%.1f" output: "12.0MiB"
-// format="% .1f" output: "12.0 MiB"
-// format="%d" output: "12MiB"
-// format="% d" output: "12 MiB"
-//
-func Current(unit int, format string, wcc ...WC) Decorator {
- producer := func(unit int, format string) DecorFunc {
- if format == "" {
- format = "%d"
- } else if strings.Count(format, "%") != 1 {
- panic("expected format with exactly 1 verb")
- }
-
- switch unit {
- case UnitKiB:
- return func(s Statistics) string {
- return fmt.Sprintf(format, SizeB1024(s.Current))
- }
- case UnitKB:
- return func(s Statistics) string {
- return fmt.Sprintf(format, SizeB1000(s.Current))
- }
- default:
- return func(s Statistics) string {
- return fmt.Sprintf(format, s.Current)
- }
- }
- }
- return Any(producer(unit, format), wcc...)
-}
-
-// InvertedCurrentNoUnit is a wrapper around InvertedCurrent with no unit param.
-func InvertedCurrentNoUnit(format string, wcc ...WC) Decorator {
- return InvertedCurrent(0, format, wcc...)
-}
-
-// InvertedCurrentKibiByte is a wrapper around InvertedCurrent with predefined unit
-// UnitKiB (bytes/1024).
-func InvertedCurrentKibiByte(format string, wcc ...WC) Decorator {
- return InvertedCurrent(UnitKiB, format, wcc...)
-}
-
-// InvertedCurrentKiloByte is a wrapper around InvertedCurrent with predefined unit
-// UnitKB (bytes/1000).
-func InvertedCurrentKiloByte(format string, wcc ...WC) Decorator {
- return InvertedCurrent(UnitKB, format, wcc...)
-}
-
-// InvertedCurrent decorator with dynamic unit measure adjustment.
-//
-// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
-//
-// `format` printf compatible verb for InvertedCurrent
-//
-// `wcc` optional WC config
-//
-// format example if unit=UnitKiB:
-//
-// format="%.1f" output: "12.0MiB"
-// format="% .1f" output: "12.0 MiB"
-// format="%d" output: "12MiB"
-// format="% d" output: "12 MiB"
-//
-func InvertedCurrent(unit int, format string, wcc ...WC) Decorator {
- producer := func(unit int, format string) DecorFunc {
- if format == "" {
- format = "%d"
- } else if strings.Count(format, "%") != 1 {
- panic("expected format with exactly 1 verb")
- }
-
- switch unit {
- case UnitKiB:
- return func(s Statistics) string {
- return fmt.Sprintf(format, SizeB1024(s.Total-s.Current))
- }
- case UnitKB:
- return func(s Statistics) string {
- return fmt.Sprintf(format, SizeB1000(s.Total-s.Current))
- }
- default:
- return func(s Statistics) string {
- return fmt.Sprintf(format, s.Total-s.Current)
- }
- }
- }
- return Any(producer(unit, format), wcc...)
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/decorator.go b/vendor/github.com/vbauerster/mpb/v6/decor/decorator.go
deleted file mode 100644
index e81fae367..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/decorator.go
+++ /dev/null
@@ -1,191 +0,0 @@
-package decor
-
-import (
- "fmt"
- "time"
-
- "github.com/acarl005/stripansi"
- "github.com/mattn/go-runewidth"
-)
-
-const (
- // DidentRight bit specifies identation direction.
- // |foo |b | With DidentRight
- // | foo| b| Without DidentRight
- DidentRight = 1 << iota
-
- // DextraSpace bit adds extra space, makes sense with DSyncWidth only.
- // When DidentRight bit set, the space will be added to the right,
- // otherwise to the left.
- DextraSpace
-
- // DSyncWidth bit enables same column width synchronization.
- // Effective with multiple bars only.
- DSyncWidth
-
- // DSyncWidthR is shortcut for DSyncWidth|DidentRight
- DSyncWidthR = DSyncWidth | DidentRight
-
- // DSyncSpace is shortcut for DSyncWidth|DextraSpace
- DSyncSpace = DSyncWidth | DextraSpace
-
- // DSyncSpaceR is shortcut for DSyncWidth|DextraSpace|DidentRight
- DSyncSpaceR = DSyncWidth | DextraSpace | DidentRight
-)
-
-// TimeStyle enum.
-type TimeStyle int
-
-// TimeStyle kinds.
-const (
- ET_STYLE_GO TimeStyle = iota
- ET_STYLE_HHMMSS
- ET_STYLE_HHMM
- ET_STYLE_MMSS
-)
-
-// Statistics consists of progress related statistics, that Decorator
-// may need.
-type Statistics struct {
- ID int
- AvailableWidth int
- Total int64
- Current int64
- Refill int64
- Completed bool
-}
-
-// Decorator interface.
-// Most of the time there is no need to implement this interface
-// manually, as decor package already provides a wide range of decorators
-// which implement this interface. If however built-in decorators don't
-// meet your needs, you're free to implement your own one by implementing
-// this particular interface. The easy way to go is to convert a
-// `DecorFunc` into a `Decorator` interface by using provided
-// `func Any(DecorFunc, ...WC) Decorator`.
-type Decorator interface {
- Configurator
- Synchronizer
- Decor(Statistics) string
-}
-
-// DecorFunc func type.
-// To be used with `func Any`(DecorFunc, ...WC) Decorator`.
-type DecorFunc func(Statistics) string
-
-// Synchronizer interface.
-// All decorators implement this interface implicitly. Its Sync
-// method exposes width sync channel, if DSyncWidth bit is set.
-type Synchronizer interface {
- Sync() (chan int, bool)
-}
-
-// Configurator interface.
-type Configurator interface {
- GetConf() WC
- SetConf(WC)
-}
-
-// Wrapper interface.
-// If you're implementing custom Decorator by wrapping a built-in one,
-// it is necessary to implement this interface to retain functionality
-// of built-in Decorator.
-type Wrapper interface {
- Base() Decorator
-}
-
-// 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.
-// If decorator needs to be notified once upon bar shutdown event, so
-// this is the right interface to implement.
-type ShutdownListener interface {
- Shutdown()
-}
-
-// 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}
- WCSyncSpace = WC{C: DSyncSpace}
- WCSyncSpaceR = WC{C: DSyncSpaceR}
-)
-
-// WC is a struct with two public fields W and C, both of int type.
-// W represents width and C represents bit set of width related config.
-// A decorator should embed WC, to enable width synchronization.
-type WC struct {
- W int
- C int
- fill func(s string, w int) string
- wsync chan int
-}
-
-// FormatMsg formats final message according to WC.W and WC.C.
-// Should be called by any Decorator implementation.
-func (wc *WC) FormatMsg(msg string) string {
- pureWidth := runewidth.StringWidth(msg)
- stripWidth := runewidth.StringWidth(stripansi.Strip(msg))
- maxCell := wc.W
- if (wc.C & DSyncWidth) != 0 {
- cellCount := stripWidth
- if (wc.C & DextraSpace) != 0 {
- cellCount++
- }
- wc.wsync <- cellCount
- maxCell = <-wc.wsync
- }
- return wc.fill(msg, maxCell+(pureWidth-stripWidth))
-}
-
-// Init initializes width related config.
-func (wc *WC) Init() WC {
- wc.fill = runewidth.FillLeft
- if (wc.C & DidentRight) != 0 {
- wc.fill = runewidth.FillRight
- }
- if (wc.C & DSyncWidth) != 0 {
- // it's deliberate choice to override wsync on each Init() call,
- // this way globals like WCSyncSpace can be reused
- wc.wsync = make(chan int)
- }
- return *wc
-}
-
-// Sync is implementation of Synchronizer interface.
-func (wc *WC) Sync() (chan int, bool) {
- if (wc.C&DSyncWidth) != 0 && wc.wsync == nil {
- panic(fmt.Sprintf("%T is not initialized", wc))
- }
- return wc.wsync, (wc.C & DSyncWidth) != 0
-}
-
-// GetConf is implementation of Configurator interface.
-func (wc *WC) GetConf() WC {
- return *wc
-}
-
-// SetConf is implementation of Configurator interface.
-func (wc *WC) SetConf(conf WC) {
- *wc = conf.Init()
-}
-
-func initWC(wcc ...WC) WC {
- var wc WC
- for _, nwc := range wcc {
- wc = nwc
- }
- return wc.Init()
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/doc.go b/vendor/github.com/vbauerster/mpb/v6/decor/doc.go
deleted file mode 100644
index bfbb82e11..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/doc.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Package decor provides common decorators for "github.com/vbauerster/mpb/v6" 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
- *mpb.Bar instances. To avoid data races, create new decorator per *mpb.Bar instance.
-
- Don't:
-
- p := mpb.New()
- name := decor.Name("bar")
- p.AddBar(100, mpb.AppendDecorators(name))
- p.AddBar(100, mpb.AppendDecorators(name))
-
- Do:
-
- p := mpb.New()
- p.AddBar(100, mpb.AppendDecorators(decor.Name("bar1")))
- p.AddBar(100, mpb.AppendDecorators(decor.Name("bar2")))
-*/
-package decor
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/elapsed.go b/vendor/github.com/vbauerster/mpb/v6/decor/elapsed.go
deleted file mode 100644
index e389f1581..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/elapsed.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package decor
-
-import (
- "time"
-)
-
-// Elapsed decorator. It's wrapper of NewElapsed.
-//
-// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
-//
-// `wcc` optional WC config
-//
-func Elapsed(style TimeStyle, wcc ...WC) Decorator {
- return NewElapsed(style, time.Now(), wcc...)
-}
-
-// NewElapsed returns elapsed time decorator.
-//
-// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
-//
-// `startTime` start time
-//
-// `wcc` optional WC config
-//
-func NewElapsed(style TimeStyle, startTime time.Time, wcc ...WC) Decorator {
- var msg string
- producer := chooseTimeProducer(style)
- fn := func(s Statistics) string {
- if !s.Completed {
- msg = producer(time.Since(startTime))
- }
- return msg
- }
- return Any(fn, wcc...)
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/eta.go b/vendor/github.com/vbauerster/mpb/v6/decor/eta.go
deleted file mode 100644
index d03caa735..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/eta.go
+++ /dev/null
@@ -1,203 +0,0 @@
-package decor
-
-import (
- "fmt"
- "math"
- "time"
-
- "github.com/VividCortex/ewma"
-)
-
-// TimeNormalizer interface. Implementors could be passed into
-// MovingAverageETA, in order to affect i.e. normalize its output.
-type TimeNormalizer interface {
- Normalize(time.Duration) time.Duration
-}
-
-// TimeNormalizerFunc is function type adapter to convert function
-// into TimeNormalizer.
-type TimeNormalizerFunc func(time.Duration) time.Duration
-
-func (f TimeNormalizerFunc) Normalize(src time.Duration) time.Duration {
- return f(src)
-}
-
-// EwmaETA exponential-weighted-moving-average based ETA decorator.
-// 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 ewma.MovingAverage
- if age == 0 {
- average = ewma.NewMovingAverage()
- } else {
- average = ewma.NewMovingAverage(age)
- }
- return MovingAverageETA(style, NewThreadSafeMovingAverage(average), nil, wcc...)
-}
-
-// MovingAverageETA decorator relies on MovingAverage implementation to calculate its average.
-//
-// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
-//
-// `average` implementation of MovingAverage interface
-//
-// `normalizer` available implementations are [FixedIntervalTimeNormalizer|MaxTolerateTimeNormalizer]
-//
-// `wcc` optional WC config
-//
-func MovingAverageETA(style TimeStyle, average ewma.MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
- d := &movingAverageETA{
- WC: initWC(wcc...),
- average: average,
- normalizer: normalizer,
- producer: chooseTimeProducer(style),
- }
- return d
-}
-
-type movingAverageETA struct {
- WC
- average ewma.MovingAverage
- normalizer TimeNormalizer
- producer func(time.Duration) string
-}
-
-func (d *movingAverageETA) Decor(s Statistics) string {
- v := math.Round(d.average.Value())
- remaining := time.Duration((s.Total - s.Current) * int64(v))
- if d.normalizer != nil {
- remaining = d.normalizer.Normalize(remaining)
- }
- return d.FormatMsg(d.producer(remaining))
-}
-
-func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) {
- durPerItem := float64(dur) / float64(n)
- if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
- return
- }
- d.average.Add(durPerItem)
-}
-
-// AverageETA decorator. It's wrapper of NewAverageETA.
-//
-// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
-//
-// `wcc` optional WC config
-//
-func AverageETA(style TimeStyle, wcc ...WC) Decorator {
- return NewAverageETA(style, time.Now(), nil, wcc...)
-}
-
-// NewAverageETA decorator with user provided start time.
-//
-// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
-//
-// `startTime` start time
-//
-// `normalizer` available implementations are [FixedIntervalTimeNormalizer|MaxTolerateTimeNormalizer]
-//
-// `wcc` optional WC config
-//
-func NewAverageETA(style TimeStyle, startTime time.Time, normalizer TimeNormalizer, wcc ...WC) Decorator {
- d := &averageETA{
- WC: initWC(wcc...),
- startTime: startTime,
- normalizer: normalizer,
- producer: chooseTimeProducer(style),
- }
- return d
-}
-
-type averageETA struct {
- WC
- startTime time.Time
- normalizer TimeNormalizer
- producer func(time.Duration) string
-}
-
-func (d *averageETA) Decor(s Statistics) string {
- var remaining time.Duration
- if s.Current != 0 {
- durPerItem := float64(time.Since(d.startTime)) / float64(s.Current)
- durPerItem = math.Round(durPerItem)
- remaining = time.Duration((s.Total - s.Current) * int64(durPerItem))
- if d.normalizer != nil {
- remaining = d.normalizer.Normalize(remaining)
- }
- }
- return d.FormatMsg(d.producer(remaining))
-}
-
-func (d *averageETA) AverageAdjust(startTime time.Time) {
- d.startTime = startTime
-}
-
-// MaxTolerateTimeNormalizer returns implementation of TimeNormalizer.
-func MaxTolerateTimeNormalizer(maxTolerate time.Duration) TimeNormalizer {
- var normalized time.Duration
- var lastCall time.Time
- return TimeNormalizerFunc(func(remaining time.Duration) time.Duration {
- if diff := normalized - remaining; diff <= 0 || diff > maxTolerate || remaining < time.Minute {
- normalized = remaining
- lastCall = time.Now()
- return remaining
- }
- normalized -= time.Since(lastCall)
- lastCall = time.Now()
- return normalized
- })
-}
-
-// FixedIntervalTimeNormalizer returns implementation of TimeNormalizer.
-func FixedIntervalTimeNormalizer(updInterval int) TimeNormalizer {
- var normalized time.Duration
- var lastCall time.Time
- var count int
- return TimeNormalizerFunc(func(remaining time.Duration) time.Duration {
- if count == 0 || remaining < time.Minute {
- count = updInterval
- normalized = remaining
- lastCall = time.Now()
- return remaining
- }
- count--
- normalized -= time.Since(lastCall)
- lastCall = time.Now()
- return normalized
- })
-}
-
-func chooseTimeProducer(style TimeStyle) func(time.Duration) string {
- switch style {
- case ET_STYLE_HHMMSS:
- return func(remaining time.Duration) string {
- hours := int64(remaining/time.Hour) % 60
- minutes := int64(remaining/time.Minute) % 60
- seconds := int64(remaining/time.Second) % 60
- return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
- }
- case ET_STYLE_HHMM:
- return func(remaining time.Duration) string {
- hours := int64(remaining/time.Hour) % 60
- minutes := int64(remaining/time.Minute) % 60
- return fmt.Sprintf("%02d:%02d", hours, minutes)
- }
- case ET_STYLE_MMSS:
- return func(remaining time.Duration) string {
- hours := int64(remaining/time.Hour) % 60
- minutes := int64(remaining/time.Minute) % 60
- seconds := int64(remaining/time.Second) % 60
- if hours > 0 {
- return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
- }
- return fmt.Sprintf("%02d:%02d", minutes, seconds)
- }
- default:
- return func(remaining time.Duration) string {
- // strip off nanoseconds
- return ((remaining / time.Second) * time.Second).String()
- }
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/merge.go b/vendor/github.com/vbauerster/mpb/v6/decor/merge.go
deleted file mode 100644
index e41406a64..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/merge.go
+++ /dev/null
@@ -1,107 +0,0 @@
-package decor
-
-import (
- "strings"
-
- "github.com/acarl005/stripansi"
- "github.com/mattn/go-runewidth"
-)
-
-// Merge wraps its decorator argument with intention to sync width
-// with several decorators of another bar. Visual example:
-//
-// +----+--------+---------+--------+
-// | B1 | MERGE(D, P1, Pn) |
-// +----+--------+---------+--------+
-// | B2 | D0 | D1 | Dn |
-// +----+--------+---------+--------+
-//
-func Merge(decorator Decorator, placeholders ...WC) Decorator {
- if _, ok := decorator.Sync(); !ok || len(placeholders) == 0 {
- return decorator
- }
- md := &mergeDecorator{
- Decorator: decorator,
- wc: decorator.GetConf(),
- placeHolders: make([]*placeHolderDecorator, len(placeholders)),
- }
- decorator.SetConf(WC{})
- for i, wc := range placeholders {
- if (wc.C & DSyncWidth) == 0 {
- return decorator
- }
- md.placeHolders[i] = &placeHolderDecorator{wc.Init()}
- }
- return md
-}
-
-type mergeDecorator struct {
- Decorator
- wc WC
- placeHolders []*placeHolderDecorator
-}
-
-func (d *mergeDecorator) GetConf() WC {
- return d.wc
-}
-
-func (d *mergeDecorator) SetConf(conf WC) {
- d.wc = conf.Init()
-}
-
-func (d *mergeDecorator) MergeUnwrap() []Decorator {
- decorators := make([]Decorator, len(d.placeHolders))
- for i, ph := range d.placeHolders {
- decorators[i] = ph
- }
- return decorators
-}
-
-func (d *mergeDecorator) Sync() (chan int, bool) {
- return d.wc.Sync()
-}
-
-func (d *mergeDecorator) Base() Decorator {
- return d.Decorator
-}
-
-func (d *mergeDecorator) Decor(s Statistics) string {
- msg := d.Decorator.Decor(s)
- pureWidth := runewidth.StringWidth(msg)
- stripWidth := runewidth.StringWidth(stripansi.Strip(msg))
- cellCount := stripWidth
- if (d.wc.C & DextraSpace) != 0 {
- cellCount++
- }
-
- total := runewidth.StringWidth(d.placeHolders[0].FormatMsg(""))
- pw := (cellCount - total) / len(d.placeHolders)
- rem := (cellCount - total) % len(d.placeHolders)
-
- var diff int
- for i := 1; i < len(d.placeHolders); i++ {
- ph := d.placeHolders[i]
- width := pw - diff
- if (ph.WC.C & DextraSpace) != 0 {
- width--
- if width < 0 {
- width = 0
- }
- }
- max := runewidth.StringWidth(ph.FormatMsg(strings.Repeat(" ", width)))
- total += max
- diff = max - pw
- }
-
- d.wc.wsync <- pw + rem
- max := <-d.wc.wsync
- return d.wc.fill(msg, max+total+(pureWidth-stripWidth))
-}
-
-type placeHolderDecorator struct {
- WC
-}
-
-func (d *placeHolderDecorator) Decor(Statistics) string {
- return ""
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/moving_average.go b/vendor/github.com/vbauerster/mpb/v6/decor/moving_average.go
deleted file mode 100644
index 50ac9c393..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/moving_average.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package decor
-
-import (
- "sort"
- "sync"
-
- "github.com/VividCortex/ewma"
-)
-
-type threadSafeMovingAverage struct {
- ewma.MovingAverage
- mu sync.Mutex
-}
-
-func (s *threadSafeMovingAverage) Add(value float64) {
- s.mu.Lock()
- s.MovingAverage.Add(value)
- s.mu.Unlock()
-}
-
-func (s *threadSafeMovingAverage) Value() float64 {
- s.mu.Lock()
- defer s.mu.Unlock()
- return s.MovingAverage.Value()
-}
-
-func (s *threadSafeMovingAverage) Set(value float64) {
- s.mu.Lock()
- s.MovingAverage.Set(value)
- s.mu.Unlock()
-}
-
-// NewThreadSafeMovingAverage converts provided ewma.MovingAverage
-// into thread safe ewma.MovingAverage.
-func NewThreadSafeMovingAverage(average ewma.MovingAverage) ewma.MovingAverage {
- if tsma, ok := average.(*threadSafeMovingAverage); ok {
- return tsma
- }
- return &threadSafeMovingAverage{MovingAverage: average}
-}
-
-type medianWindow [3]float64
-
-func (s *medianWindow) Len() int { return len(s) }
-func (s *medianWindow) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-func (s *medianWindow) Less(i, j int) bool { return s[i] < s[j] }
-
-func (s *medianWindow) Add(value float64) {
- s[0], s[1] = s[1], s[2]
- s[2] = value
-}
-
-func (s *medianWindow) Value() float64 {
- tmp := *s
- sort.Sort(&tmp)
- return tmp[1]
-}
-
-func (s *medianWindow) Set(value float64) {
- for i := 0; i < len(s); i++ {
- s[i] = value
- }
-}
-
-// NewMedian is fixed last 3 samples median MovingAverage.
-func NewMedian() ewma.MovingAverage {
- return NewThreadSafeMovingAverage(new(medianWindow))
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/name.go b/vendor/github.com/vbauerster/mpb/v6/decor/name.go
deleted file mode 100644
index 3af311254..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/name.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package decor
-
-// Name decorator displays text that is set once and can't be changed
-// during decorator's lifetime.
-//
-// `str` string to display
-//
-// `wcc` optional WC config
-//
-func Name(str string, wcc ...WC) Decorator {
- return Any(func(Statistics) string { return str }, wcc...)
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/on_complete.go b/vendor/github.com/vbauerster/mpb/v6/decor/on_complete.go
deleted file mode 100644
index f46b19aba..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/on_complete.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package decor
-
-// OnComplete returns decorator, which wraps provided decorator, with
-// sole purpose to display provided message on complete event.
-//
-// `decorator` Decorator to wrap
-//
-// `message` message to display on complete event
-//
-func OnComplete(decorator Decorator, message string) Decorator {
- d := &onCompleteWrapper{
- Decorator: decorator,
- msg: message,
- }
- if md, ok := decorator.(*mergeDecorator); ok {
- d.Decorator, md.Decorator = md.Decorator, d
- return md
- }
- return d
-}
-
-type onCompleteWrapper struct {
- Decorator
- msg string
-}
-
-func (d *onCompleteWrapper) Decor(s Statistics) string {
- if s.Completed {
- wc := d.GetConf()
- return wc.FormatMsg(d.msg)
- }
- return d.Decorator.Decor(s)
-}
-
-func (d *onCompleteWrapper) Base() Decorator {
- return d.Decorator
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/percentage.go b/vendor/github.com/vbauerster/mpb/v6/decor/percentage.go
deleted file mode 100644
index f4922bb52..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/percentage.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package decor
-
-import (
- "fmt"
- "io"
- "strconv"
-
- "github.com/vbauerster/mpb/v6/internal"
-)
-
-type percentageType float64
-
-func (s percentageType) Format(st fmt.State, verb rune) {
- var prec int
- switch verb {
- case 'd':
- case 's':
- prec = -1
- default:
- if p, ok := st.Precision(); ok {
- prec = p
- } else {
- prec = 6
- }
- }
-
- io.WriteString(st, strconv.FormatFloat(float64(s), 'f', prec, 64))
-
- if st.Flag(' ') {
- io.WriteString(st, " ")
- }
- io.WriteString(st, "%")
-}
-
-// Percentage returns percentage decorator. It's a wrapper of NewPercentage.
-func Percentage(wcc ...WC) Decorator {
- return NewPercentage("% d", wcc...)
-}
-
-// NewPercentage percentage decorator with custom format string.
-//
-// format examples:
-//
-// format="%.1f" output: "1.0%"
-// format="% .1f" output: "1.0 %"
-// format="%d" output: "1%"
-// format="% d" output: "1 %"
-//
-func NewPercentage(format string, wcc ...WC) Decorator {
- if format == "" {
- format = "% d"
- }
- f := func(s Statistics) string {
- p := internal.Percentage(s.Total, s.Current, 100)
- return fmt.Sprintf(format, percentageType(p))
- }
- return Any(f, wcc...)
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/size_type.go b/vendor/github.com/vbauerster/mpb/v6/decor/size_type.go
deleted file mode 100644
index e4b974058..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/size_type.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package decor
-
-import (
- "fmt"
- "io"
- "math"
- "strconv"
-)
-
-//go:generate stringer -type=SizeB1024 -trimprefix=_i
-//go:generate stringer -type=SizeB1000 -trimprefix=_
-
-const (
- _ib SizeB1024 = iota + 1
- _iKiB SizeB1024 = 1 << (iota * 10)
- _iMiB
- _iGiB
- _iTiB
-)
-
-// SizeB1024 named type, which implements fmt.Formatter interface. It
-// adjusts its value according to byte size multiple by 1024 and appends
-// appropriate size marker (KiB, MiB, GiB, TiB).
-type SizeB1024 int64
-
-func (self SizeB1024) Format(st fmt.State, verb rune) {
- var prec int
- switch verb {
- case 'd':
- case 's':
- prec = -1
- default:
- if p, ok := st.Precision(); ok {
- prec = p
- } else {
- prec = 6
- }
- }
-
- var unit SizeB1024
- switch {
- case self < _iKiB:
- unit = _ib
- case self < _iMiB:
- unit = _iKiB
- case self < _iGiB:
- unit = _iMiB
- case self < _iTiB:
- unit = _iGiB
- case self <= math.MaxInt64:
- unit = _iTiB
- }
-
- io.WriteString(st, strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
-
- if st.Flag(' ') {
- io.WriteString(st, " ")
- }
- io.WriteString(st, unit.String())
-}
-
-const (
- _b SizeB1000 = 1
- _KB SizeB1000 = _b * 1000
- _MB SizeB1000 = _KB * 1000
- _GB SizeB1000 = _MB * 1000
- _TB SizeB1000 = _GB * 1000
-)
-
-// SizeB1000 named type, which implements fmt.Formatter interface. It
-// adjusts its value according to byte size multiple by 1000 and appends
-// appropriate size marker (KB, MB, GB, TB).
-type SizeB1000 int64
-
-func (self SizeB1000) Format(st fmt.State, verb rune) {
- var prec int
- switch verb {
- case 'd':
- case 's':
- prec = -1
- default:
- if p, ok := st.Precision(); ok {
- prec = p
- } else {
- prec = 6
- }
- }
-
- var unit SizeB1000
- switch {
- case self < _KB:
- unit = _b
- case self < _MB:
- unit = _KB
- case self < _GB:
- unit = _MB
- case self < _TB:
- unit = _GB
- case self <= math.MaxInt64:
- unit = _TB
- }
-
- io.WriteString(st, strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
-
- if st.Flag(' ') {
- io.WriteString(st, " ")
- }
- io.WriteString(st, unit.String())
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/sizeb1000_string.go b/vendor/github.com/vbauerster/mpb/v6/decor/sizeb1000_string.go
deleted file mode 100644
index 3f32ef715..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/sizeb1000_string.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Code generated by "stringer -type=SizeB1000 -trimprefix=_"; DO NOT EDIT.
-
-package decor
-
-import "strconv"
-
-func _() {
- // An "invalid array index" compiler error signifies that the constant values have changed.
- // Re-run the stringer command to generate them again.
- var x [1]struct{}
- _ = x[_b-1]
- _ = x[_KB-1000]
- _ = x[_MB-1000000]
- _ = x[_GB-1000000000]
- _ = x[_TB-1000000000000]
-}
-
-const (
- _SizeB1000_name_0 = "b"
- _SizeB1000_name_1 = "KB"
- _SizeB1000_name_2 = "MB"
- _SizeB1000_name_3 = "GB"
- _SizeB1000_name_4 = "TB"
-)
-
-func (i SizeB1000) String() string {
- switch {
- case i == 1:
- return _SizeB1000_name_0
- case i == 1000:
- return _SizeB1000_name_1
- case i == 1000000:
- return _SizeB1000_name_2
- case i == 1000000000:
- return _SizeB1000_name_3
- case i == 1000000000000:
- return _SizeB1000_name_4
- default:
- return "SizeB1000(" + strconv.FormatInt(int64(i), 10) + ")"
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/sizeb1024_string.go b/vendor/github.com/vbauerster/mpb/v6/decor/sizeb1024_string.go
deleted file mode 100644
index 9fca66cc7..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/sizeb1024_string.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Code generated by "stringer -type=SizeB1024 -trimprefix=_i"; DO NOT EDIT.
-
-package decor
-
-import "strconv"
-
-func _() {
- // An "invalid array index" compiler error signifies that the constant values have changed.
- // Re-run the stringer command to generate them again.
- var x [1]struct{}
- _ = x[_ib-1]
- _ = x[_iKiB-1024]
- _ = x[_iMiB-1048576]
- _ = x[_iGiB-1073741824]
- _ = x[_iTiB-1099511627776]
-}
-
-const (
- _SizeB1024_name_0 = "b"
- _SizeB1024_name_1 = "KiB"
- _SizeB1024_name_2 = "MiB"
- _SizeB1024_name_3 = "GiB"
- _SizeB1024_name_4 = "TiB"
-)
-
-func (i SizeB1024) String() string {
- switch {
- case i == 1:
- return _SizeB1024_name_0
- case i == 1024:
- return _SizeB1024_name_1
- case i == 1048576:
- return _SizeB1024_name_2
- case i == 1073741824:
- return _SizeB1024_name_3
- case i == 1099511627776:
- return _SizeB1024_name_4
- default:
- return "SizeB1024(" + strconv.FormatInt(int64(i), 10) + ")"
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/speed.go b/vendor/github.com/vbauerster/mpb/v6/decor/speed.go
deleted file mode 100644
index 634edabfd..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/speed.go
+++ /dev/null
@@ -1,171 +0,0 @@
-package decor
-
-import (
- "fmt"
- "io"
- "math"
- "time"
-
- "github.com/VividCortex/ewma"
-)
-
-// FmtAsSpeed adds "/s" to the end of the input formatter. To be
-// used with SizeB1000 or SizeB1024 types, for example:
-//
-// fmt.Printf("%.1f", FmtAsSpeed(SizeB1024(2048)))
-//
-func FmtAsSpeed(input fmt.Formatter) fmt.Formatter {
- return &speedFormatter{input}
-}
-
-type speedFormatter struct {
- fmt.Formatter
-}
-
-func (self *speedFormatter) Format(st fmt.State, verb rune) {
- self.Formatter.Format(st, verb)
- io.WriteString(st, "/s")
-}
-
-// EwmaSpeed exponential-weighted-moving-average based speed decorator.
-// 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 ewma.MovingAverage
- if age == 0 {
- average = ewma.NewMovingAverage()
- } else {
- average = ewma.NewMovingAverage(age)
- }
- return MovingAverageSpeed(unit, format, NewThreadSafeMovingAverage(average), wcc...)
-}
-
-// MovingAverageSpeed decorator relies on MovingAverage implementation
-// to calculate its average.
-//
-// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
-//
-// `format` printf compatible verb for value, like "%f" or "%d"
-//
-// `average` MovingAverage implementation
-//
-// `wcc` optional WC config
-//
-// format examples:
-//
-// unit=UnitKiB, format="%.1f" output: "1.0MiB/s"
-// unit=UnitKiB, format="% .1f" output: "1.0 MiB/s"
-// unit=UnitKB, format="%.1f" output: "1.0MB/s"
-// unit=UnitKB, format="% .1f" output: "1.0 MB/s"
-//
-func MovingAverageSpeed(unit int, format string, average ewma.MovingAverage, wcc ...WC) Decorator {
- if format == "" {
- format = "%.0f"
- }
- d := &movingAverageSpeed{
- WC: initWC(wcc...),
- average: average,
- producer: chooseSpeedProducer(unit, format),
- }
- return d
-}
-
-type movingAverageSpeed struct {
- WC
- producer func(float64) string
- average ewma.MovingAverage
- msg string
-}
-
-func (d *movingAverageSpeed) Decor(s Statistics) string {
- if !s.Completed {
- var speed float64
- if v := d.average.Value(); v > 0 {
- speed = 1 / v
- }
- d.msg = d.producer(speed * 1e9)
- }
- return d.FormatMsg(d.msg)
-}
-
-func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) {
- durPerByte := float64(dur) / float64(n)
- if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
- return
- }
- d.average.Add(durPerByte)
-}
-
-// AverageSpeed decorator with dynamic unit measure adjustment. It's
-// a wrapper of NewAverageSpeed.
-func AverageSpeed(unit int, format string, wcc ...WC) Decorator {
- return NewAverageSpeed(unit, format, time.Now(), wcc...)
-}
-
-// NewAverageSpeed decorator with dynamic unit measure adjustment and
-// user provided start time.
-//
-// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
-//
-// `format` printf compatible verb for value, like "%f" or "%d"
-//
-// `startTime` start time
-//
-// `wcc` optional WC config
-//
-// format examples:
-//
-// unit=UnitKiB, format="%.1f" output: "1.0MiB/s"
-// unit=UnitKiB, format="% .1f" output: "1.0 MiB/s"
-// unit=UnitKB, format="%.1f" output: "1.0MB/s"
-// unit=UnitKB, format="% .1f" output: "1.0 MB/s"
-//
-func NewAverageSpeed(unit int, format string, startTime time.Time, wcc ...WC) Decorator {
- if format == "" {
- format = "%.0f"
- }
- d := &averageSpeed{
- WC: initWC(wcc...),
- startTime: startTime,
- producer: chooseSpeedProducer(unit, format),
- }
- return d
-}
-
-type averageSpeed struct {
- WC
- startTime time.Time
- producer func(float64) string
- msg string
-}
-
-func (d *averageSpeed) Decor(s Statistics) string {
- if !s.Completed {
- speed := float64(s.Current) / float64(time.Since(d.startTime))
- d.msg = d.producer(speed * 1e9)
- }
-
- return d.FormatMsg(d.msg)
-}
-
-func (d *averageSpeed) AverageAdjust(startTime time.Time) {
- d.startTime = startTime
-}
-
-func chooseSpeedProducer(unit int, format string) func(float64) string {
- switch unit {
- case UnitKiB:
- return func(speed float64) string {
- return fmt.Sprintf(format, FmtAsSpeed(SizeB1024(math.Round(speed))))
- }
- case UnitKB:
- return func(speed float64) string {
- return fmt.Sprintf(format, FmtAsSpeed(SizeB1000(math.Round(speed))))
- }
- default:
- return func(speed float64) string {
- return fmt.Sprintf(format, speed)
- }
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/decor/spinner.go b/vendor/github.com/vbauerster/mpb/v6/decor/spinner.go
deleted file mode 100644
index 6871639db..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/decor/spinner.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package decor
-
-var defaultSpinnerStyle = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
-
-// Spinner returns spinner decorator.
-//
-// `frames` spinner frames, if nil or len==0, default is used
-//
-// `wcc` optional WC config
-func Spinner(frames []string, wcc ...WC) Decorator {
- if len(frames) == 0 {
- frames = defaultSpinnerStyle
- }
- var count uint
- f := func(s Statistics) string {
- frame := frames[count%uint(len(frames))]
- count++
- return frame
- }
- return Any(f, wcc...)
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/doc.go b/vendor/github.com/vbauerster/mpb/v6/doc.go
deleted file mode 100644
index 5ada71774..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package mpb is a library for rendering progress bars in terminal applications.
-package mpb
diff --git a/vendor/github.com/vbauerster/mpb/v6/go.mod b/vendor/github.com/vbauerster/mpb/v6/go.mod
deleted file mode 100644
index d9dad966e..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/go.mod
+++ /dev/null
@@ -1,11 +0,0 @@
-module github.com/vbauerster/mpb/v6
-
-require (
- github.com/VividCortex/ewma v1.2.0
- github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
- github.com/mattn/go-runewidth v0.0.12
- github.com/rivo/uniseg v0.2.0
- golang.org/x/sys v0.0.0-20210514084401-e8d321eab015
-)
-
-go 1.14
diff --git a/vendor/github.com/vbauerster/mpb/v6/go.sum b/vendor/github.com/vbauerster/mpb/v6/go.sum
deleted file mode 100644
index 08ee82f4e..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/go.sum
+++ /dev/null
@@ -1,11 +0,0 @@
-github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
-github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
-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=
-github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
-github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
-github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
-github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
-golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/vbauerster/mpb/v6/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v6/internal/percentage.go
deleted file mode 100644
index a8ef8be12..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/internal/percentage.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package internal
-
-import "math"
-
-// Percentage is a helper function, to calculate percentage.
-func Percentage(total, current int64, width int) float64 {
- if total <= 0 {
- return 0
- }
- if current >= total {
- return float64(width)
- }
- return float64(int64(width)*current) / float64(total)
-}
-
-// PercentageRound same as Percentage but with math.Round.
-func PercentageRound(total, current int64, width int) float64 {
- return math.Round(Percentage(total, current, width))
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/internal/predicate.go b/vendor/github.com/vbauerster/mpb/v6/internal/predicate.go
deleted file mode 100644
index 1e4dd24d9..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/internal/predicate.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package internal
-
-// Predicate helper for internal use.
-func Predicate(pick bool) func() bool {
- return func() bool { return pick }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/internal/width.go b/vendor/github.com/vbauerster/mpb/v6/internal/width.go
deleted file mode 100644
index 216320f24..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/internal/width.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package internal
-
-// CheckRequestedWidth checks that requested width doesn't overflow
-// available width
-func CheckRequestedWidth(requested, available int) int {
- if requested <= 0 || requested >= available {
- return available
- }
- return requested
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/priority_queue.go b/vendor/github.com/vbauerster/mpb/v6/priority_queue.go
deleted file mode 100644
index 29d9bd5a8..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/priority_queue.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package mpb
-
-// A priorityQueue implements heap.Interface
-type priorityQueue []*Bar
-
-func (pq priorityQueue) Len() int { return len(pq) }
-
-func (pq priorityQueue) Less(i, j int) bool {
- return pq[i].priority < pq[j].priority
-}
-
-func (pq priorityQueue) Swap(i, j int) {
- pq[i], pq[j] = pq[j], pq[i]
- pq[i].index = i
- pq[j].index = j
-}
-
-func (pq *priorityQueue) Push(x interface{}) {
- s := *pq
- bar := x.(*Bar)
- bar.index = len(s)
- s = append(s, bar)
- *pq = s
-}
-
-func (pq *priorityQueue) Pop() interface{} {
- s := *pq
- *pq = s[0 : len(s)-1]
- bar := s[len(s)-1]
- bar.index = -1 // for safety
- return bar
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/progress.go b/vendor/github.com/vbauerster/mpb/v6/progress.go
deleted file mode 100644
index 5a3f96243..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/progress.go
+++ /dev/null
@@ -1,412 +0,0 @@
-package mpb
-
-import (
- "bytes"
- "container/heap"
- "context"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "math"
- "os"
- "sync"
- "time"
-
- "github.com/vbauerster/mpb/v6/cwriter"
- "github.com/vbauerster/mpb/v6/decor"
-)
-
-const (
- // default RefreshRate
- prr = 120 * time.Millisecond
-)
-
-// Progress represents a container that renders one or more progress
-// bars.
-type Progress struct {
- ctx context.Context
- uwg *sync.WaitGroup
- cwg *sync.WaitGroup
- bwg *sync.WaitGroup
- operateState chan func(*pState)
- done chan struct{}
- refreshCh chan time.Time
- once sync.Once
- dlogger *log.Logger
-}
-
-// pState holds bars in its priorityQueue. It gets passed to
-// *Progress.serve(...) monitor goroutine.
-type pState struct {
- bHeap priorityQueue
- heapUpdated bool
- pMatrix map[int][]chan int
- aMatrix map[int][]chan int
- barShutdownQueue []*Bar
-
- // following are provided/overrided by user
- idCount int
- reqWidth int
- popCompleted bool
- outputDiscarded bool
- rr time.Duration
- uwg *sync.WaitGroup
- externalRefresh <-chan interface{}
- renderDelay <-chan struct{}
- shutdownNotifier chan struct{}
- parkedBars map[*Bar]*Bar
- output io.Writer
- debugOut io.Writer
-}
-
-// New creates new Progress container instance. It's not possible to
-// reuse instance after *Progress.Wait() method has been called.
-func New(options ...ContainerOption) *Progress {
- return NewWithContext(context.Background(), options...)
-}
-
-// NewWithContext creates new Progress container instance with provided
-// context. It's not possible to reuse instance after *Progress.Wait()
-// method has been called.
-func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
- s := &pState{
- bHeap: priorityQueue{},
- rr: prr,
- parkedBars: make(map[*Bar]*Bar),
- output: os.Stdout,
- debugOut: ioutil.Discard,
- }
-
- for _, opt := range options {
- if opt != nil {
- opt(s)
- }
- }
-
- p := &Progress{
- ctx: ctx,
- uwg: s.uwg,
- cwg: new(sync.WaitGroup),
- bwg: new(sync.WaitGroup),
- operateState: make(chan func(*pState)),
- done: make(chan struct{}),
- dlogger: log.New(s.debugOut, "[mpb] ", log.Lshortfile),
- }
-
- p.cwg.Add(1)
- go p.serve(s, cwriter.New(s.output))
- return p
-}
-
-// AddBar creates a bar with default bar filler. Different filler can
-// be choosen and applied via `*Progress.Add(...) *Bar` method.
-func (p *Progress) AddBar(total int64, options ...BarOption) *Bar {
- return p.Add(total, NewBarFiller(BarDefaultStyle), options...)
-}
-
-// AddSpinner creates a bar with default spinner filler. Different
-// filler can be choosen and applied via `*Progress.Add(...) *Bar`
-// method.
-func (p *Progress) AddSpinner(total int64, alignment SpinnerAlignment, options ...BarOption) *Bar {
- return p.Add(total, NewSpinnerFiller(SpinnerDefaultStyle, alignment), options...)
-}
-
-// Add creates a bar which renders itself by provided filler.
-// If `total <= 0` trigger complete event is disabled until reset with *bar.SetTotal(int64, bool).
-// Panics if *Progress instance is done, i.e. called after *Progress.Wait().
-func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar {
- if filler == nil {
- filler = BarFillerFunc(func(io.Writer, int, decor.Statistics) {})
- }
- p.bwg.Add(1)
- result := make(chan *Bar)
- select {
- case p.operateState <- func(ps *pState) {
- bs := ps.makeBarState(total, filler, options...)
- bar := newBar(p, bs)
- if bs.runningBar != nil {
- bs.runningBar.noPop = true
- ps.parkedBars[bs.runningBar] = bar
- } else {
- heap.Push(&ps.bHeap, bar)
- ps.heapUpdated = true
- }
- ps.idCount++
- result <- bar
- }:
- bar := <-result
- bar.subscribeDecorators()
- return bar
- case <-p.done:
- p.bwg.Done()
- panic(fmt.Sprintf("%T instance can't be reused after it's done!", p))
- }
-}
-
-func (p *Progress) dropBar(b *Bar) {
- select {
- case p.operateState <- func(s *pState) {
- if b.index < 0 {
- return
- }
- heap.Remove(&s.bHeap, b.index)
- s.heapUpdated = true
- }:
- case <-p.done:
- }
-}
-
-func (p *Progress) setBarPriority(b *Bar, priority int) {
- select {
- case p.operateState <- func(s *pState) {
- if b.index < 0 {
- return
- }
- b.priority = priority
- heap.Fix(&s.bHeap, b.index)
- }:
- case <-p.done:
- }
-}
-
-// UpdateBarPriority same as *Bar.SetPriority(int).
-func (p *Progress) UpdateBarPriority(b *Bar, priority int) {
- p.setBarPriority(b, priority)
-}
-
-// BarCount returns bars count.
-func (p *Progress) BarCount() int {
- result := make(chan int, 1)
- select {
- case p.operateState <- func(s *pState) { result <- s.bHeap.Len() }:
- return <-result
- case <-p.done:
- return 0
- }
-}
-
-// Wait waits for all bars to complete and finally shutdowns container.
-// After this method has been called, there is no way to reuse *Progress
-// instance.
-func (p *Progress) Wait() {
- if p.uwg != nil {
- // wait for user wg
- p.uwg.Wait()
- }
-
- // wait for bars to quit, if any
- p.bwg.Wait()
-
- p.once.Do(p.shutdown)
-
- // wait for container to quit
- p.cwg.Wait()
-}
-
-func (p *Progress) shutdown() {
- close(p.done)
-}
-
-func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
- defer p.cwg.Done()
-
- p.refreshCh = s.newTicker(p.done)
-
- for {
- select {
- case op := <-p.operateState:
- op(s)
- case <-p.refreshCh:
- if err := s.render(cw); err != nil {
- p.dlogger.Println(err)
- }
- case <-s.shutdownNotifier:
- if s.heapUpdated {
- if err := s.render(cw); err != nil {
- p.dlogger.Println(err)
- }
- }
- return
- }
- }
-}
-
-func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
- ch := make(chan time.Time)
- if s.shutdownNotifier == nil {
- s.shutdownNotifier = make(chan struct{})
- }
- go func() {
- if s.renderDelay != nil {
- <-s.renderDelay
- }
- var internalRefresh <-chan time.Time
- if !s.outputDiscarded {
- if s.externalRefresh == nil {
- ticker := time.NewTicker(s.rr)
- defer ticker.Stop()
- internalRefresh = ticker.C
- }
- } else {
- s.externalRefresh = nil
- }
- for {
- select {
- case t := <-internalRefresh:
- ch <- t
- case x := <-s.externalRefresh:
- if t, ok := x.(time.Time); ok {
- ch <- t
- } else {
- ch <- time.Now()
- }
- case <-done:
- close(s.shutdownNotifier)
- return
- }
- }
- }()
- return ch
-}
-
-func (s *pState) render(cw *cwriter.Writer) error {
- if s.heapUpdated {
- s.updateSyncMatrix()
- s.heapUpdated = false
- }
- syncWidth(s.pMatrix)
- syncWidth(s.aMatrix)
-
- tw, err := cw.GetWidth()
- if err != nil {
- tw = s.reqWidth
- }
- for i := 0; i < s.bHeap.Len(); i++ {
- bar := s.bHeap[i]
- go bar.render(tw)
- }
-
- return s.flush(cw)
-}
-
-func (s *pState) flush(cw *cwriter.Writer) error {
- var lineCount int
- bm := make(map[*Bar]struct{}, s.bHeap.Len())
- for s.bHeap.Len() > 0 {
- b := heap.Pop(&s.bHeap).(*Bar)
- cw.ReadFrom(<-b.frameCh)
- if b.toShutdown {
- if b.recoveredPanic != nil {
- s.barShutdownQueue = append(s.barShutdownQueue, b)
- b.toShutdown = false
- } else {
- // shutdown at next flush
- // this ensures no bar ends up with less than 100% rendered
- defer func() {
- s.barShutdownQueue = append(s.barShutdownQueue, b)
- }()
- }
- }
- lineCount += b.extendedLines + 1
- bm[b] = struct{}{}
- }
-
- for _, b := range s.barShutdownQueue {
- if parkedBar := s.parkedBars[b]; parkedBar != nil {
- parkedBar.priority = b.priority
- heap.Push(&s.bHeap, parkedBar)
- delete(s.parkedBars, b)
- b.toDrop = true
- }
- if s.popCompleted && !b.noPop {
- lineCount -= b.extendedLines + 1
- b.toDrop = true
- }
- if b.toDrop {
- delete(bm, b)
- s.heapUpdated = true
- }
- b.cancel()
- }
- s.barShutdownQueue = s.barShutdownQueue[0:0]
-
- for b := range bm {
- heap.Push(&s.bHeap, b)
- }
-
- return cw.Flush(lineCount)
-}
-
-func (s *pState) updateSyncMatrix() {
- s.pMatrix = make(map[int][]chan int)
- s.aMatrix = make(map[int][]chan int)
- for i := 0; i < s.bHeap.Len(); i++ {
- bar := s.bHeap[i]
- table := bar.wSyncTable()
- pRow, aRow := table[0], table[1]
-
- for i, ch := range pRow {
- s.pMatrix[i] = append(s.pMatrix[i], ch)
- }
-
- for i, ch := range aRow {
- s.aMatrix[i] = append(s.aMatrix[i], ch)
- }
- }
-}
-
-func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {
- bs := &bState{
- id: s.idCount,
- priority: s.idCount,
- reqWidth: s.reqWidth,
- total: total,
- filler: filler,
- extender: func(r io.Reader, _ int, _ decor.Statistics) (io.Reader, int) { return r, 0 },
- debugOut: s.debugOut,
- }
-
- if total > 0 {
- bs.triggerComplete = true
- }
-
- for _, opt := range options {
- if opt != nil {
- opt(bs)
- }
- }
-
- if bs.middleware != nil {
- bs.filler = bs.middleware(filler)
- bs.middleware = nil
- }
-
- if s.popCompleted && !bs.noPop {
- bs.priority = -(math.MaxInt32 - s.idCount)
- }
-
- bs.bufP = bytes.NewBuffer(make([]byte, 0, 128))
- bs.bufB = bytes.NewBuffer(make([]byte, 0, 256))
- bs.bufA = bytes.NewBuffer(make([]byte, 0, 128))
-
- return bs
-}
-
-func syncWidth(matrix map[int][]chan int) {
- for _, column := range matrix {
- go maxWidthDistributor(column)
- }
-}
-
-var maxWidthDistributor = func(column []chan int) {
- var maxWidth int
- for _, ch := range column {
- if w := <-ch; w > maxWidth {
- maxWidth = w
- }
- }
- for _, ch := range column {
- ch <- maxWidth
- }
-}
diff --git a/vendor/github.com/vbauerster/mpb/v6/proxyreader.go b/vendor/github.com/vbauerster/mpb/v6/proxyreader.go
deleted file mode 100644
index 316f438d7..000000000
--- a/vendor/github.com/vbauerster/mpb/v6/proxyreader.go
+++ /dev/null
@@ -1,90 +0,0 @@
-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/v7/bar.go b/vendor/github.com/vbauerster/mpb/v7/bar.go
index 646cb471a..4991f4f15 100644
--- a/vendor/github.com/vbauerster/mpb/v7/bar.go
+++ b/vendor/github.com/vbauerster/mpb/v7/bar.go
@@ -17,31 +17,21 @@ import (
// Bar represents a progress bar.
type Bar struct {
- priority int // used by heap
- index int // used by heap
-
- toShutdown bool
- toDrop bool
- noPop bool
- hasEwmaDecorators bool
- operateState chan func(*bState)
- frameCh chan *frame
-
- // cancel is called either by user or on complete event
- cancel func()
- // done is closed after cacheState is assigned
- done chan struct{}
- // cacheState is populated, right after close(b.done)
- cacheState *bState
-
+ index int // used by heap
+ priority int // used by heap
+ hasEwma bool
+ frameCh chan *renderFrame
+ operateState chan func(*bState)
+ done chan struct{}
container *Progress
+ bs *bState
+ cancel func()
recoveredPanic interface{}
}
type extenderFunc func(in io.Reader, reqWidth int, st decor.Statistics) (out io.Reader, lines int)
-// bState is actual bar state. It gets passed to *Bar.serve(...) monitor
-// goroutine.
+// bState is actual bar's state.
type bState struct {
id int
priority int
@@ -52,7 +42,6 @@ type bState struct {
lastIncrement int64
trimSpace bool
completed bool
- completeFlushed bool
aborted bool
triggerComplete bool
dropOnComplete bool
@@ -66,29 +55,28 @@ type bState struct {
filler BarFiller
middleware func(BarFiller) BarFiller
extender extenderFunc
+ debugOut io.Writer
- // runningBar is a key for *pState.parkedBars
- runningBar *Bar
-
- debugOut io.Writer
+ afterBar *Bar // key for (*pState).queueBars
+ sync bool
}
-type frame struct {
- reader io.Reader
- lines int
+type renderFrame struct {
+ reader io.Reader
+ lines int
+ shutdown bool
}
func newBar(container *Progress, bs *bState) *Bar {
ctx, cancel := context.WithCancel(container.ctx)
bar := &Bar{
- container: container,
priority: bs.priority,
- toDrop: bs.dropOnComplete,
- noPop: bs.noPop,
+ hasEwma: len(bs.ewmaDecorators) != 0,
+ frameCh: make(chan *renderFrame, 1),
operateState: make(chan func(*bState)),
- frameCh: make(chan *frame, 1),
done: make(chan struct{}),
+ container: container,
cancel: cancel,
}
@@ -97,12 +85,20 @@ func newBar(container *Progress, bs *bState) *Bar {
}
// ProxyReader wraps r with metrics required for progress tracking.
-// Panics if r is nil.
+// If r is 'unknown total/size' reader it's mandatory to call
+// (*Bar).SetTotal(-1, true) method after (Reader).Read returns io.EOF.
+// Panics if r is nil. If bar is already completed or aborted, returns
+// nil.
func (b *Bar) ProxyReader(r io.Reader) io.ReadCloser {
if r == nil {
panic("expected non nil io.Reader")
}
- return b.newProxyReader(r)
+ select {
+ case <-b.done:
+ return nil
+ default:
+ return b.newProxyReader(r)
+ }
}
// ID returs id of the bar.
@@ -112,18 +108,18 @@ func (b *Bar) ID() int {
case b.operateState <- func(s *bState) { result <- s.id }:
return <-result
case <-b.done:
- return b.cacheState.id
+ return b.bs.id
}
}
-// Current returns bar's current number, in other words sum of all increments.
+// Current returns bar's current value, in other words sum of all increments.
func (b *Bar) Current() int64 {
result := make(chan int64)
select {
case b.operateState <- func(s *bState) { result <- s.current }:
return <-result
case <-b.done:
- return b.cacheState.current
+ return b.bs.current
}
}
@@ -142,7 +138,7 @@ func (b *Bar) SetRefill(amount int64) {
// TraverseDecorators traverses all available decorators and calls cb func on each.
func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
- done := make(chan struct{})
+ sync := make(chan struct{})
select {
case b.operateState <- func(s *bState) {
for _, decorators := range [...][]decor.Decorator{
@@ -153,28 +149,56 @@ func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
cb(extractBaseDecorator(d))
}
}
- close(done)
+ close(sync)
+ }:
+ <-sync
+ case <-b.done:
+ }
+}
+
+// EnableTriggerComplete enables triggering complete event. It's
+// effective only for bar which was constructed with `total <= 0` and
+// after total has been set with (*Bar).SetTotal(int64, false). If bar
+// has been incremented to the total, complete event is triggered right
+// away.
+func (b *Bar) EnableTriggerComplete() {
+ select {
+ case b.operateState <- func(s *bState) {
+ if s.triggerComplete || s.total <= 0 {
+ return
+ }
+ if s.current >= s.total {
+ s.current = s.total
+ s.completed = true
+ go b.forceRefresh()
+ } else {
+ s.triggerComplete = true
+ }
}:
- <-done
case <-b.done:
}
}
-// SetTotal sets total dynamically.
-// If total is negative it takes progress' current value.
-func (b *Bar) SetTotal(total int64, triggerComplete bool) {
+// SetTotal sets total to an arbitrary value. It's effective only for
+// bar which was constructed with `total <= 0`. Setting total to negative
+// value is equivalent to (*Bar).SetTotal((*Bar).Current(), bool).
+// If triggerCompleteNow is true, total value is set to current and
+// complete event is triggered right away.
+func (b *Bar) SetTotal(total int64, triggerCompleteNow bool) {
select {
case b.operateState <- func(s *bState) {
- s.triggerComplete = triggerComplete
+ if s.triggerComplete {
+ return
+ }
if total < 0 {
s.total = s.current
} else {
s.total = total
}
- if s.triggerComplete && !s.completed {
+ if triggerCompleteNow {
s.current = s.total
s.completed = true
- go b.forceRefreshIfLastUncompleted()
+ go b.forceRefresh()
}
}:
case <-b.done:
@@ -191,7 +215,7 @@ func (b *Bar) SetCurrent(current int64) {
if s.triggerComplete && s.current >= s.total {
s.current = s.total
s.completed = true
- go b.forceRefreshIfLastUncompleted()
+ go b.forceRefresh()
}
}:
case <-b.done:
@@ -220,7 +244,7 @@ func (b *Bar) IncrInt64(n int64) {
if s.triggerComplete && s.current >= s.total {
s.current = s.total
s.completed = true
- go b.forceRefreshIfLastUncompleted()
+ go b.forceRefresh()
}
}:
case <-b.done:
@@ -242,9 +266,9 @@ func (b *Bar) DecoratorEwmaUpdate(dur time.Duration) {
}
}:
case <-b.done:
- if b.cacheState.lastIncrement > 0 {
- b.cacheState.decoratorEwmaUpdate(dur)
- b.cacheState.lastIncrement = 0
+ if b.bs.lastIncrement > 0 {
+ b.bs.decoratorEwmaUpdate(dur)
+ b.bs.lastIncrement = 0
}
}
}
@@ -270,44 +294,33 @@ func (b *Bar) SetPriority(priority int) {
// Abort interrupts bar's running goroutine. Abort won't be engaged
// if bar is already in complete state. If drop is true bar will be
-// removed as well.
+// removed as well. To make sure that bar has been removed call
+// (*Bar).Wait method.
func (b *Bar) Abort(drop bool) {
- done := make(chan struct{})
select {
case b.operateState <- func(s *bState) {
- if s.completed {
- close(done)
+ if s.completed || s.aborted {
return
}
s.aborted = true
- b.cancel()
- // container must be run during lifetime of this inner goroutine
- // we control this by done channel declared above
- go func() {
- if drop {
- b.container.dropBar(b)
- } else {
- var uncompleted int
- b.container.traverseBars(func(bar *Bar) bool {
- if b != bar && !bar.Completed() {
- uncompleted++
- return false
- }
- return true
- })
- if uncompleted == 0 {
- b.container.refreshCh <- time.Now()
- }
- }
- close(done) // release hold of Abort
- }()
+ s.dropOnComplete = drop
+ go b.forceRefresh()
}:
- // guarantee: container is alive during lifetime of this hold
- <-done
case <-b.done:
}
}
+// Aborted reports whether the bar is in aborted state.
+func (b *Bar) Aborted() bool {
+ result := make(chan bool)
+ select {
+ case b.operateState <- func(s *bState) { result <- s.aborted }:
+ return <-result
+ case <-b.done:
+ return b.bs.aborted
+ }
+}
+
// Completed reports whether the bar is in completed state.
func (b *Bar) Completed() bool {
result := make(chan bool)
@@ -315,19 +328,28 @@ func (b *Bar) Completed() bool {
case b.operateState <- func(s *bState) { result <- s.completed }:
return <-result
case <-b.done:
- return true
+ return b.bs.completed
}
}
-func (b *Bar) serve(ctx context.Context, s *bState) {
+// Wait blocks until bar is completed or aborted.
+func (b *Bar) Wait() {
+ <-b.done
+}
+
+func (b *Bar) serve(ctx context.Context, bs *bState) {
defer b.container.bwg.Done()
+ if bs.afterBar != nil && bs.sync {
+ bs.afterBar.Wait()
+ }
for {
select {
case op := <-b.operateState:
- op(s)
+ op(bs)
case <-ctx.Done():
- s.decoratorShutdownNotify()
- b.cacheState = s
+ bs.aborted = !bs.completed
+ bs.decoratorShutdownNotify()
+ b.bs = bs
close(b.done)
return
}
@@ -337,79 +359,62 @@ func (b *Bar) serve(ctx context.Context, s *bState) {
func (b *Bar) render(tw int) {
select {
case b.operateState <- func(s *bState) {
+ var reader io.Reader
+ var lines int
stat := newStatistics(tw, s)
defer func() {
// recovering if user defined decorator panics for example
if p := recover(); p != nil {
- if b.recoveredPanic == nil {
- if s.debugOut != nil {
- fmt.Fprintln(s.debugOut, p)
- _, _ = s.debugOut.Write(debug.Stack())
- }
- s.extender = makePanicExtender(p)
- b.toShutdown = !b.toShutdown
- b.recoveredPanic = p
+ if s.debugOut != nil {
+ fmt.Fprintln(s.debugOut, p)
+ _, _ = s.debugOut.Write(debug.Stack())
}
- reader, lines := s.extender(nil, s.reqWidth, stat)
- b.frameCh <- &frame{reader, lines + 1}
+ s.aborted = !s.completed
+ s.extender = makePanicExtender(p)
+ reader, lines = s.extender(nil, s.reqWidth, stat)
+ b.recoveredPanic = p
+ }
+ frame := renderFrame{
+ reader: reader,
+ lines: lines + 1,
+ shutdown: s.completed || s.aborted,
}
- s.completeFlushed = s.completed
+ if frame.shutdown {
+ b.cancel()
+ }
+ b.frameCh <- &frame
}()
- reader, lines := s.extender(s.draw(stat), s.reqWidth, stat)
- b.toShutdown = s.completed && !s.completeFlushed
- b.frameCh <- &frame{reader, lines + 1}
+ if b.recoveredPanic == nil {
+ reader = s.draw(stat)
+ }
+ reader, lines = s.extender(reader, s.reqWidth, stat)
}:
case <-b.done:
- s := b.cacheState
- stat := newStatistics(tw, s)
- var r io.Reader
+ var reader io.Reader
+ var lines int
+ stat, s := newStatistics(tw, b.bs), b.bs
if b.recoveredPanic == nil {
- r = s.draw(stat)
- }
- reader, lines := s.extender(r, s.reqWidth, stat)
- b.frameCh <- &frame{reader, lines + 1}
- }
-}
-
-func (b *Bar) subscribeDecorators() {
- var averageDecorators []decor.AverageDecorator
- var ewmaDecorators []decor.EwmaDecorator
- var shutdownListeners []decor.ShutdownListener
- b.TraverseDecorators(func(d decor.Decorator) {
- if d, ok := d.(decor.AverageDecorator); ok {
- averageDecorators = append(averageDecorators, d)
- }
- if d, ok := d.(decor.EwmaDecorator); ok {
- ewmaDecorators = append(ewmaDecorators, d)
+ reader = s.draw(stat)
}
- if d, ok := d.(decor.ShutdownListener); ok {
- shutdownListeners = append(shutdownListeners, d)
+ reader, lines = s.extender(reader, s.reqWidth, stat)
+ b.frameCh <- &renderFrame{
+ reader: reader,
+ lines: lines + 1,
}
- })
- b.hasEwmaDecorators = len(ewmaDecorators) != 0
- select {
- case b.operateState <- func(s *bState) {
- s.averageDecorators = averageDecorators
- s.ewmaDecorators = ewmaDecorators
- s.shutdownListeners = shutdownListeners
- }:
- case <-b.done:
}
}
-func (b *Bar) forceRefreshIfLastUncompleted() {
- var uncompleted int
+func (b *Bar) forceRefresh() {
+ var anyOtherRunning bool
b.container.traverseBars(func(bar *Bar) bool {
- if b != bar && !bar.Completed() {
- uncompleted++
- return false
- }
- return true
+ anyOtherRunning = b != bar && bar.isRunning()
+ return !anyOtherRunning
})
- if uncompleted == 0 {
+ if !anyOtherRunning {
for {
select {
case b.container.refreshCh <- time.Now():
+ time.Sleep(prr)
case <-b.done:
return
}
@@ -417,13 +422,25 @@ func (b *Bar) forceRefreshIfLastUncompleted() {
}
}
+func (b *Bar) isRunning() bool {
+ result := make(chan bool)
+ select {
+ case b.operateState <- func(s *bState) {
+ result <- !s.completed && !s.aborted
+ }:
+ return <-result
+ case <-b.done:
+ return false
+ }
+}
+
func (b *Bar) wSyncTable() [][]chan int {
result := make(chan [][]chan int)
select {
case b.operateState <- func(s *bState) { result <- s.wSyncTable() }:
return <-result
case <-b.done:
- return b.cacheState.wSyncTable()
+ return b.bs.wSyncTable()
}
}
@@ -487,6 +504,26 @@ func (s *bState) wSyncTable() [][]chan int {
return table
}
+func (s *bState) subscribeDecorators() {
+ for _, decorators := range [...][]decor.Decorator{
+ s.pDecorators,
+ s.aDecorators,
+ } {
+ for _, d := range decorators {
+ d = extractBaseDecorator(d)
+ if d, ok := d.(decor.AverageDecorator); ok {
+ s.averageDecorators = append(s.averageDecorators, d)
+ }
+ if d, ok := d.(decor.EwmaDecorator); ok {
+ s.ewmaDecorators = append(s.ewmaDecorators, d)
+ }
+ if d, ok := d.(decor.ShutdownListener); ok {
+ s.shutdownListeners = append(s.shutdownListeners, d)
+ }
+ }
+ }
+}
+
func (s bState) decoratorEwmaUpdate(dur time.Duration) {
wg := new(sync.WaitGroup)
for i := 0; i < len(s.ewmaDecorators); i++ {
@@ -540,12 +577,12 @@ func (s bState) decoratorShutdownNotify() {
func newStatistics(tw int, s *bState) decor.Statistics {
return decor.Statistics{
- ID: s.id,
AvailableWidth: tw,
+ ID: s.id,
Total: s.total,
Current: s.current,
Refill: s.refill,
- Completed: s.completeFlushed,
+ Completed: s.completed,
Aborted: s.aborted,
}
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go b/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go
index 54b7bfd6f..d8bf90a4a 100644
--- a/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go
+++ b/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go
@@ -157,9 +157,8 @@ func (s *bFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
return
}
- ow := optimisticWriter(w)
- ow(s.components[iLbound].bytes)
- defer ow(s.components[iRbound].bytes)
+ mustWrite(w, s.components[iLbound].bytes)
+ defer mustWrite(w, s.components[iRbound].bytes)
if width == 0 {
return
@@ -231,26 +230,24 @@ func (s *bFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
}
if s.rev {
- flush(ow, padding, filling)
+ flush(w, padding, filling)
} else {
- flush(ow, filling, padding)
+ flush(w, filling, padding)
}
}
-func flush(ow func([]byte), filling, padding [][]byte) {
+func flush(w io.Writer, filling, padding [][]byte) {
for i := len(filling) - 1; i >= 0; i-- {
- ow(filling[i])
+ mustWrite(w, filling[i])
}
for i := 0; i < len(padding); i++ {
- ow(padding[i])
+ mustWrite(w, padding[i])
}
}
-func optimisticWriter(w io.Writer) func([]byte) {
- return func(p []byte) {
- _, err := w.Write(p)
- if err != nil {
- panic(err)
- }
+func mustWrite(w io.Writer, p []byte) {
+ _, err := w.Write(p)
+ if err != nil {
+ panic(err)
}
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/bar_option.go b/vendor/github.com/vbauerster/mpb/v7/bar_option.go
index 4ba490505..8599f0a57 100644
--- a/vendor/github.com/vbauerster/mpb/v7/bar_option.go
+++ b/vendor/github.com/vbauerster/mpb/v7/bar_option.go
@@ -59,14 +59,17 @@ func BarWidth(width int) BarOption {
}
}
-// BarQueueAfter queues this (being constructed) bar to relplace
-// runningBar after it has been completed.
-func BarQueueAfter(runningBar *Bar) BarOption {
- if runningBar == nil {
+// BarQueueAfter puts this (being constructed) bar into the queue.
+// When argument bar completes or aborts queued bar replaces its place.
+// If sync is true queued bar is suspended until argument bar completes
+// or aborts.
+func BarQueueAfter(bar *Bar, sync bool) BarOption {
+ if bar == nil {
return nil
}
return func(s *bState) {
- s.runningBar = runningBar
+ s.afterBar = bar
+ s.sync = sync
}
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go b/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go
index eaf541cb7..fac15b3bc 100644
--- a/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go
+++ b/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go
@@ -11,7 +11,7 @@ import (
// ErrNotTTY not a TeleTYpewriter error.
var ErrNotTTY = errors.New("not a terminal")
-// http://ascii-table.com/ansi-escape-sequences.php
+// https://github.com/dylanaraps/pure-sh-bible#cursor-movement
const (
escOpen = "\x1b["
cuuAndEd = "A\x1b[J"
diff --git a/vendor/github.com/vbauerster/mpb/v7/decor/decorator.go b/vendor/github.com/vbauerster/mpb/v7/decor/decorator.go
index 9fec57b15..aad7709c0 100644
--- a/vendor/github.com/vbauerster/mpb/v7/decor/decorator.go
+++ b/vendor/github.com/vbauerster/mpb/v7/decor/decorator.go
@@ -47,8 +47,8 @@ const (
// Statistics consists of progress related statistics, that Decorator
// may need.
type Statistics struct {
- ID int
AvailableWidth int
+ ID int
Total int64
Current int64
Refill int64
diff --git a/vendor/github.com/vbauerster/mpb/v7/decor/optimistic_string_writer.go b/vendor/github.com/vbauerster/mpb/v7/decor/optimistic_string_writer.go
index ea9fda79d..c6a34384e 100644
--- a/vendor/github.com/vbauerster/mpb/v7/decor/optimistic_string_writer.go
+++ b/vendor/github.com/vbauerster/mpb/v7/decor/optimistic_string_writer.go
@@ -2,11 +2,9 @@ package decor
import "io"
-func optimisticStringWriter(w io.Writer) func(string) {
- return func(s string) {
- _, err := io.WriteString(w, s)
- if err != nil {
- panic(err)
- }
+func mustWriteString(w io.Writer, s string) {
+ _, err := io.WriteString(w, s)
+ if err != nil {
+ panic(err)
}
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/decor/percentage.go b/vendor/github.com/vbauerster/mpb/v7/decor/percentage.go
index 6e7f5c6ed..e72668993 100644
--- a/vendor/github.com/vbauerster/mpb/v7/decor/percentage.go
+++ b/vendor/github.com/vbauerster/mpb/v7/decor/percentage.go
@@ -23,12 +23,11 @@ func (s percentageType) Format(st fmt.State, verb rune) {
}
}
- osw := optimisticStringWriter(st)
- osw(strconv.FormatFloat(float64(s), 'f', prec, 64))
+ mustWriteString(st, strconv.FormatFloat(float64(s), 'f', prec, 64))
if st.Flag(' ') {
- osw(" ")
+ mustWriteString(st, " ")
}
- osw("%")
+ mustWriteString(st, "%")
}
// Percentage returns percentage decorator. It's a wrapper of NewPercentage.
diff --git a/vendor/github.com/vbauerster/mpb/v7/decor/size_type.go b/vendor/github.com/vbauerster/mpb/v7/decor/size_type.go
index 12879b8f1..09ecc23f8 100644
--- a/vendor/github.com/vbauerster/mpb/v7/decor/size_type.go
+++ b/vendor/github.com/vbauerster/mpb/v7/decor/size_type.go
@@ -49,12 +49,11 @@ func (self SizeB1024) Format(st fmt.State, verb rune) {
unit = _iTiB
}
- osw := optimisticStringWriter(st)
- osw(strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
+ mustWriteString(st, strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
if st.Flag(' ') {
- osw(" ")
+ mustWriteString(st, " ")
}
- osw(unit.String())
+ mustWriteString(st, unit.String())
}
const (
@@ -98,10 +97,9 @@ func (self SizeB1000) Format(st fmt.State, verb rune) {
unit = _TB
}
- osw := optimisticStringWriter(st)
- osw(strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
+ mustWriteString(st, strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
if st.Flag(' ') {
- osw(" ")
+ mustWriteString(st, " ")
}
- osw(unit.String())
+ mustWriteString(st, unit.String())
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/decor/speed.go b/vendor/github.com/vbauerster/mpb/v7/decor/speed.go
index 99cfde2bf..f052352fc 100644
--- a/vendor/github.com/vbauerster/mpb/v7/decor/speed.go
+++ b/vendor/github.com/vbauerster/mpb/v7/decor/speed.go
@@ -23,7 +23,7 @@ type speedFormatter struct {
func (self *speedFormatter) Format(st fmt.State, verb rune) {
self.Formatter.Format(st, verb)
- optimisticStringWriter(st)("/s")
+ mustWriteString(st, "/s")
}
// EwmaSpeed exponential-weighted-moving-average based speed decorator.
diff --git a/vendor/github.com/vbauerster/mpb/v7/go.mod b/vendor/github.com/vbauerster/mpb/v7/go.mod
index 8fa790dc7..db1457e35 100644
--- a/vendor/github.com/vbauerster/mpb/v7/go.mod
+++ b/vendor/github.com/vbauerster/mpb/v7/go.mod
@@ -4,7 +4,7 @@ require (
github.com/VividCortex/ewma v1.2.0
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/mattn/go-runewidth v0.0.13
- golang.org/x/sys v0.0.0-20220114195835-da31bd327af9
+ golang.org/x/sys v0.0.0-20220209214540-3681064d5158
)
go 1.14
diff --git a/vendor/github.com/vbauerster/mpb/v7/go.sum b/vendor/github.com/vbauerster/mpb/v7/go.sum
index aebe4d9d2..f36888be9 100644
--- a/vendor/github.com/vbauerster/mpb/v7/go.sum
+++ b/vendor/github.com/vbauerster/mpb/v7/go.sum
@@ -6,5 +6,5 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
-golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
+golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/vbauerster/mpb/v7/progress.go b/vendor/github.com/vbauerster/mpb/v7/progress.go
index 123af17cf..1d9a53e5c 100644
--- a/vendor/github.com/vbauerster/mpb/v7/progress.go
+++ b/vendor/github.com/vbauerster/mpb/v7/progress.go
@@ -16,12 +16,10 @@ import (
)
const (
- // default RefreshRate
- prr = 150 * time.Millisecond
+ prr = 150 * time.Millisecond // default RefreshRate
)
-// Progress represents a container that renders one or more progress
-// bars.
+// Progress represents a container that renders one or more progress bars.
type Progress struct {
ctx context.Context
uwg *sync.WaitGroup
@@ -33,14 +31,12 @@ type Progress struct {
once sync.Once
}
-// pState holds bars in its priorityQueue. It gets passed to
-// *Progress.serve(...) monitor goroutine.
+// pState holds bars in its priorityQueue, it gets passed to (*Progress).serve monitor goroutine.
type pState struct {
- bHeap priorityQueue
- heapUpdated bool
- pMatrix map[int][]chan int
- aMatrix map[int][]chan int
- barShutdownQueue []*Bar
+ bHeap priorityQueue
+ heapUpdated bool
+ pMatrix map[int][]chan int
+ aMatrix map[int][]chan int
// following are provided/overrided by user
idCount int
@@ -52,26 +48,26 @@ type pState struct {
externalRefresh <-chan interface{}
renderDelay <-chan struct{}
shutdownNotifier chan struct{}
- parkedBars map[*Bar]*Bar
+ queueBars map[*Bar]*Bar
output io.Writer
debugOut io.Writer
}
// New creates new Progress container instance. It's not possible to
-// reuse instance after *Progress.Wait() method has been called.
+// reuse instance after (*Progress).Wait method has been called.
func New(options ...ContainerOption) *Progress {
return NewWithContext(context.Background(), options...)
}
// NewWithContext creates new Progress container instance with provided
-// context. It's not possible to reuse instance after *Progress.Wait()
+// context. It's not possible to reuse instance after (*Progress).Wait
// method has been called.
func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
s := &pState{
- bHeap: priorityQueue{},
- rr: prr,
- parkedBars: make(map[*Bar]*Bar),
- output: os.Stdout,
+ bHeap: priorityQueue{},
+ rr: prr,
+ queueBars: make(map[*Bar]*Bar),
+ output: os.Stdout,
}
for _, opt := range options {
@@ -110,8 +106,8 @@ func (p *Progress) New(total int64, builder BarFillerBuilder, options ...BarOpti
}
// Add creates a bar which renders itself by provided filler.
-// If `total <= 0` trigger complete event is disabled until reset with *bar.SetTotal(int64, bool).
-// Panics if *Progress instance is done, i.e. called after *Progress.Wait().
+// If `total <= 0` triggering complete event by increment methods is disabled.
+// Panics if *Progress instance is done, i.e. called after (*Progress).Wait().
func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar {
if filler == nil {
filler = NopStyle().Build()
@@ -122,9 +118,8 @@ func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar
case p.operateState <- func(ps *pState) {
bs := ps.makeBarState(total, filler, options...)
bar := newBar(p, bs)
- if bs.runningBar != nil {
- bs.runningBar.noPop = true
- ps.parkedBars[bs.runningBar] = bar
+ if bs.afterBar != nil {
+ ps.queueBars[bs.afterBar] = bar
} else {
heap.Push(&ps.bHeap, bar)
ps.heapUpdated = true
@@ -133,7 +128,6 @@ func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar
result <- bar
}:
bar := <-result
- bar.subscribeDecorators()
return bar
case <-p.done:
p.bwg.Done()
@@ -141,21 +135,8 @@ func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar
}
}
-func (p *Progress) dropBar(b *Bar) {
- select {
- case p.operateState <- func(s *pState) {
- if b.index < 0 {
- return
- }
- heap.Remove(&s.bHeap, b.index)
- s.heapUpdated = true
- }:
- case <-p.done:
- }
-}
-
func (p *Progress) traverseBars(cb func(b *Bar) bool) {
- done := make(chan struct{})
+ sync := make(chan struct{})
select {
case p.operateState <- func(s *pState) {
for i := 0; i < s.bHeap.Len(); i++ {
@@ -164,9 +145,9 @@ func (p *Progress) traverseBars(cb func(b *Bar) bool) {
break
}
}
- close(done)
+ close(sync)
}:
- <-done
+ <-sync
case <-p.done:
}
}
@@ -200,8 +181,8 @@ func (p *Progress) BarCount() int {
// After this method has been called, there is no way to reuse *Progress
// instance.
func (p *Progress) Wait() {
+ // wait for user wg, if any
if p.uwg != nil {
- // wait for user wg
p.uwg.Wait()
}
@@ -256,6 +237,64 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
}
}
+func (s *pState) render(cw *cwriter.Writer) error {
+ if s.heapUpdated {
+ s.updateSyncMatrix()
+ s.heapUpdated = false
+ }
+ syncWidth(s.pMatrix)
+ syncWidth(s.aMatrix)
+
+ tw, err := cw.GetWidth()
+ if err != nil {
+ tw = s.reqWidth
+ }
+ for i := 0; i < s.bHeap.Len(); i++ {
+ bar := s.bHeap[i]
+ go bar.render(tw)
+ }
+
+ return s.flush(cw)
+}
+
+func (s *pState) flush(cw *cwriter.Writer) error {
+ var lines int
+ pool := make([]*Bar, 0, s.bHeap.Len())
+ for s.bHeap.Len() > 0 {
+ b := heap.Pop(&s.bHeap).(*Bar)
+ frame := <-b.frameCh
+ lines += frame.lines
+ _, err := cw.ReadFrom(frame.reader)
+ if err != nil {
+ return err
+ }
+ if frame.shutdown {
+ b.Wait() // waiting for b.done, so it's safe to read b.bs
+ var toDrop bool
+ if qb, ok := s.queueBars[b]; ok {
+ delete(s.queueBars, b)
+ qb.priority = b.priority
+ pool = append(pool, qb)
+ toDrop = true
+ } else if s.popCompleted && !b.bs.noPop {
+ lines -= frame.lines
+ toDrop = true
+ }
+ if toDrop || b.bs.dropOnComplete {
+ s.heapUpdated = true
+ continue
+ }
+ }
+ pool = append(pool, b)
+ }
+
+ for _, b := range pool {
+ heap.Push(&s.bHeap, b)
+ }
+
+ return cw.Flush(lines)
+}
+
func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
ch := make(chan time.Time)
if s.shutdownNotifier == nil {
@@ -294,78 +333,6 @@ func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
return ch
}
-func (s *pState) render(cw *cwriter.Writer) error {
- if s.heapUpdated {
- s.updateSyncMatrix()
- s.heapUpdated = false
- }
- syncWidth(s.pMatrix)
- syncWidth(s.aMatrix)
-
- tw, err := cw.GetWidth()
- if err != nil {
- tw = s.reqWidth
- }
- for i := 0; i < s.bHeap.Len(); i++ {
- bar := s.bHeap[i]
- go bar.render(tw)
- }
-
- return s.flush(cw)
-}
-
-func (s *pState) flush(cw *cwriter.Writer) error {
- var totalLines int
- bm := make(map[*Bar]int, s.bHeap.Len())
- for s.bHeap.Len() > 0 {
- b := heap.Pop(&s.bHeap).(*Bar)
- frame := <-b.frameCh
- _, err := cw.ReadFrom(frame.reader)
- if err != nil {
- return err
- }
- if b.toShutdown {
- if b.recoveredPanic != nil {
- s.barShutdownQueue = append(s.barShutdownQueue, b)
- b.toShutdown = false
- } else {
- // shutdown at next flush
- // this ensures no bar ends up with less than 100% rendered
- defer func() {
- s.barShutdownQueue = append(s.barShutdownQueue, b)
- }()
- }
- }
- bm[b] = frame.lines
- totalLines += frame.lines
- }
-
- for _, b := range s.barShutdownQueue {
- if parkedBar := s.parkedBars[b]; parkedBar != nil {
- parkedBar.priority = b.priority
- heap.Push(&s.bHeap, parkedBar)
- delete(s.parkedBars, b)
- b.toDrop = true
- }
- if s.popCompleted && !b.noPop {
- totalLines -= bm[b]
- b.toDrop = true
- }
- if b.toDrop {
- delete(bm, b)
- s.heapUpdated = true
- }
- b.cancel()
- }
- s.barShutdownQueue = s.barShutdownQueue[0:0]
-
- for b := range bm {
- heap.Push(&s.bHeap, b)
- }
-
- return cw.Flush(totalLines)
-}
-
func (s *pState) updateSyncMatrix() {
s.pMatrix = make(map[int][]chan int)
s.aMatrix = make(map[int][]chan int)
@@ -418,6 +385,8 @@ func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOptio
bs.buffers[i] = bytes.NewBuffer(make([]byte, 0, 512))
}
+ bs.subscribeDecorators()
+
return bs
}
@@ -427,7 +396,7 @@ func syncWidth(matrix map[int][]chan int) {
}
}
-var maxWidthDistributor = func(column []chan int) {
+func maxWidthDistributor(column []chan int) {
var maxWidth int
for _, ch := range column {
if w := <-ch; w > maxWidth {
diff --git a/vendor/github.com/vbauerster/mpb/v7/proxyreader.go b/vendor/github.com/vbauerster/mpb/v7/proxyreader.go
index 25f195bb8..b0dd89d45 100644
--- a/vendor/github.com/vbauerster/mpb/v7/proxyreader.go
+++ b/vendor/github.com/vbauerster/mpb/v7/proxyreader.go
@@ -14,9 +14,6 @@ type proxyReader struct {
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(-1, true)
- }
return n, err
}
@@ -28,9 +25,6 @@ type proxyWriterTo struct {
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(-1, true)
- }
return n, err
}
@@ -65,12 +59,12 @@ func (b *Bar) newProxyReader(r io.Reader) (rc io.ReadCloser) {
pr := proxyReader{toReadCloser(r), b}
if wt, ok := r.(io.WriterTo); ok {
pw := proxyWriterTo{pr, wt}
- if b.hasEwmaDecorators {
+ if b.hasEwma {
rc = ewmaProxyWriterTo{ewmaProxyReader{pr}, pw}
} else {
rc = pw
}
- } else if b.hasEwmaDecorators {
+ } else if b.hasEwma {
rc = ewmaProxyReader{pr}
} else {
rc = pr
diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh
index a47b035f9..e92ddea00 100644
--- a/vendor/golang.org/x/sys/unix/mkerrors.sh
+++ b/vendor/golang.org/x/sys/unix/mkerrors.sh
@@ -597,6 +597,7 @@ ccflags="$@"
$2 ~ /^DEVLINK_/ ||
$2 ~ /^ETHTOOL_/ ||
$2 ~ /^LWTUNNEL_IP/ ||
+ $2 ~ /^ITIMER_/ ||
$2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ ||
$2 ~/^PPPIOC/ ||
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go
index f432b0684..f5915e234 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux.go
@@ -14,6 +14,7 @@ package unix
import (
"encoding/binary"
"syscall"
+ "time"
"unsafe"
)
@@ -2314,11 +2315,56 @@ type RemoteIovec struct {
//sys shmdt(addr uintptr) (err error)
//sys shmget(key int, size int, flag int) (id int, err error)
+//sys getitimer(which int, currValue *Itimerval) (err error)
+//sys setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error)
+
+// MakeItimerval creates an Itimerval from interval and value durations.
+func MakeItimerval(interval, value time.Duration) Itimerval {
+ return Itimerval{
+ Interval: NsecToTimeval(interval.Nanoseconds()),
+ Value: NsecToTimeval(value.Nanoseconds()),
+ }
+}
+
+// A value which may be passed to the which parameter for Getitimer and
+// Setitimer.
+type ItimerWhich int
+
+// Possible which values for Getitimer and Setitimer.
+const (
+ ItimerReal ItimerWhich = ITIMER_REAL
+ ItimerVirtual ItimerWhich = ITIMER_VIRTUAL
+ ItimerProf ItimerWhich = ITIMER_PROF
+)
+
+// Getitimer wraps getitimer(2) to return the current value of the timer
+// specified by which.
+func Getitimer(which ItimerWhich) (Itimerval, error) {
+ var it Itimerval
+ if err := getitimer(int(which), &it); err != nil {
+ return Itimerval{}, err
+ }
+
+ return it, nil
+}
+
+// Setitimer wraps setitimer(2) to arm or disarm the timer specified by which.
+// It returns the previous value of the timer.
+//
+// If the Itimerval argument is the zero value, the timer will be disarmed.
+func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) {
+ var prev Itimerval
+ if err := setitimer(int(which), &it, &prev); err != nil {
+ return Itimerval{}, err
+ }
+
+ return prev, nil
+}
+
/*
* Unimplemented
*/
// AfsSyscall
-// Alarm
// ArchPrctl
// Brk
// ClockNanosleep
@@ -2334,7 +2380,6 @@ type RemoteIovec struct {
// GetMempolicy
// GetRobustList
// GetThreadArea
-// Getitimer
// Getpmsg
// IoCancel
// IoDestroy
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go b/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go
new file mode 100644
index 000000000..08086ac6a
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go
@@ -0,0 +1,14 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64)
+// +build linux
+// +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64
+
+package unix
+
+// SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH
+// values.
+
+//sys Alarm(seconds uint) (remaining uint, err error)
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go
index 4e5420586..664db640a 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go
@@ -38,7 +38,8 @@ const (
AF_KEY = 0xf
AF_LLC = 0x1a
AF_LOCAL = 0x1
- AF_MAX = 0x2d
+ AF_MAX = 0x2e
+ AF_MCTP = 0x2d
AF_MPLS = 0x1c
AF_NETBEUI = 0xd
AF_NETLINK = 0x10
@@ -1267,6 +1268,9 @@ const (
IP_XFRM_POLICY = 0x11
ISOFS_SUPER_MAGIC = 0x9660
ISTRIP = 0x20
+ ITIMER_PROF = 0x2
+ ITIMER_REAL = 0x0
+ ITIMER_VIRTUAL = 0x1
IUTF8 = 0x4000
IXANY = 0x800
JFFS2_SUPER_MAGIC = 0x72b6
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go
index 93edda4c4..30fa4055e 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go
@@ -2032,3 +2032,23 @@ func shmget(key int, size int, flag int) (id int, err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getitimer(which int, currValue *Itimerval) (err error) {
+ _, _, e1 := Syscall(SYS_GETITIMER, uintptr(which), uintptr(unsafe.Pointer(currValue)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error) {
+ _, _, e1 := Syscall(SYS_SETITIMER, uintptr(which), uintptr(unsafe.Pointer(newValue)), uintptr(unsafe.Pointer(oldValue)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
index ff90c81e7..2fc6271f4 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go
+// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && 386
@@ -524,3 +524,14 @@ func utimes(path string, times *[2]Timeval) (err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
index fa7d3dbe4..21fb85079 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go
+// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && amd64
@@ -691,3 +691,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
index 6d1552885..eab7ab9a4 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go
+// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mips
@@ -702,3 +702,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
index 1e20d72df..dc3f47f1c 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go
+// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mips64
@@ -696,3 +696,14 @@ func stat(path string, st *stat_t) (err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
index a0440c1d4..691f3de42 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go
+// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mipsle
@@ -702,3 +702,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go
index 5864b9ca6..5ce957c56 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go
+// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc
@@ -707,3 +707,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
index beeb49e34..82c5b6336 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go
+// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc64
@@ -753,3 +753,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
index 53139b82c..178847e35 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go
+// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc64le
@@ -753,3 +753,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
index 202add37d..9e462a96f 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go
+// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && s390x
@@ -533,3 +533,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
index 2ab268c34..ea7d7c29e 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
@@ -1,4 +1,4 @@
-// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go
+// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && sparc64
@@ -697,3 +697,14 @@ func utimes(path string, times *[2]Timeval) (err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Alarm(seconds uint) (remaining uint, err error) {
+ r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
+ remaining = uint(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go
index 66788f156..824cadb41 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go
@@ -24,6 +24,11 @@ type ItimerSpec struct {
Value Timespec
}
+type Itimerval struct {
+ Interval Timeval
+ Value Timeval
+}
+
const (
TIME_OK = 0x0
TIME_INS = 0x1
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 319a3592f..0b3b4c089 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -84,7 +84,7 @@ github.com/containernetworking/cni/pkg/types/create
github.com/containernetworking/cni/pkg/types/internal
github.com/containernetworking/cni/pkg/utils
github.com/containernetworking/cni/pkg/version
-# github.com/containernetworking/plugins v1.1.0
+# github.com/containernetworking/plugins v1.1.1
## explicit
github.com/containernetworking/plugins/pkg/ns
# github.com/containers/buildah v1.24.2
@@ -312,7 +312,7 @@ github.com/digitalocean/go-libvirt/internal/go-xdr/xdr2
github.com/digitalocean/go-qemu/qmp
# github.com/disiqueira/gotree/v3 v3.0.2
github.com/disiqueira/gotree/v3
-# github.com/docker/distribution v2.8.0+incompatible
+# github.com/docker/distribution v2.8.1+incompatible
## explicit
github.com/docker/distribution
github.com/docker/distribution/digestset
@@ -683,13 +683,8 @@ github.com/ulikunitz/xz/lzma
github.com/vbatts/tar-split/archive/tar
github.com/vbatts/tar-split/tar/asm
github.com/vbatts/tar-split/tar/storage
-# github.com/vbauerster/mpb/v6 v6.0.4
+# github.com/vbauerster/mpb/v7 v7.4.1
## explicit
-github.com/vbauerster/mpb/v6
-github.com/vbauerster/mpb/v6/cwriter
-github.com/vbauerster/mpb/v6/decor
-github.com/vbauerster/mpb/v6/internal
-# github.com/vbauerster/mpb/v7 v7.3.2
github.com/vbauerster/mpb/v7
github.com/vbauerster/mpb/v7/cwriter
github.com/vbauerster/mpb/v7/decor
@@ -755,7 +750,7 @@ golang.org/x/net/trace
## explicit
golang.org/x/sync/errgroup
golang.org/x/sync/semaphore
-# golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27
+# golang.org/x/sys v0.0.0-20220209214540-3681064d5158
## explicit
golang.org/x/sys/cpu
golang.org/x/sys/execabs
@@ -881,9 +876,9 @@ gopkg.in/square/go-jose.v2/json
# gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
gopkg.in/tomb.v1
# gopkg.in/yaml.v2 v2.4.0
+## explicit
gopkg.in/yaml.v2
# gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
-## explicit
gopkg.in/yaml.v3
# k8s.io/api v0.22.5
## explicit