Debian

Available patches from Ubuntu

To see Ubuntu differences wrt. to Debian, write down a grep-dctrl query identifying the packages you're interested in:
grep-dctrl -n -sPackage Sources.Debian
(e.g. -FPackage linux-ntfs or linux-ntfs)

Modified packages are listed below:

Debian ( Changelog | PTS | Bugs ) Ubuntu ( Changelog | txt | LP | Bugs ) | Diff from Ubuntu

Source: docker.io

docker.io (18.09.8-0ubuntu3) eoan; urgency=medium * d/tests/docker-in-lxd: skip on eoan+/i386 as lxd images are no longer provided. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Thu, 18 Jul 2019 22:44:03 +1200 docker.io (18.09.8-0ubuntu2) eoan; urgency=medium * Remove extraneous start/stop of docker via init.d script from basic-smoke autopkgtest. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Thu, 18 Jul 2019 15:42:38 +1200 docker.io (18.09.8-0ubuntu1) eoan; urgency=medium [ Michael Hudson-Doyle ] * Version dependency on containerd. [ Tianon Gravi ] * Remove sysvinit and upstart scripts (LP: #1832819) * Update to 18.09.8 (CVE-2019-13509, LP: #1836987) -- Tianon Gravi <tianon@debian.org> Wed, 17 Jul 2019 18:26:58 -0700 docker.io (18.09.7-0ubuntu1) eoan; urgency=medium * Update to 18.09.7. (LP: #1834690) - Includes fix for CVE-2018-15664. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Fri, 28 Jun 2019 21:13:02 +0100 docker.io (18.09.5-0ubuntu1) disco; urgency=medium * Update to 18.09.5. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Fri, 12 Apr 2019 12:27:37 +1200 docker.io (18.09.3-0ubuntu1) disco; urgency=medium * Update to 18.09.3. - update d/upstream-version-commits - refresh d/patches/docker-prefix.patch to maintain dependence on docker-specific containerd daemon. - remove d/patches/0001-nsenter-clone-proc-self-exe-to-avoid-exposing-host-b.patch, now included upstream. * Stop bundling containerd and runc and instead depend on the containerd package from the archive. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Thu, 14 Mar 2019 11:22:11 +1300 docker.io (18.09.2-0ubuntu1) disco; urgency=medium * Update to 18.09.2, including fix for CVE-2019-5736. - Convert components/engine/git-bundles/CVE-2019-5736.bundle into d/patches/0001-nsenter-clone-proc-self-exe-to-avoid-exposing-host-b.patch. - Hard code RUNC_COMMIT in d/rules for now. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Tue, 12 Feb 2019 10:55:11 +1300 docker.io (18.09.1-0ubuntu2) disco; urgency=medium * Update "docker-prefix.patch" to also fix "docker.service" -- Tianon Gravi <tianon@debian.org> Fri, 08 Feb 2019 14:52:47 -0800 docker.io (18.09.1-0~ubuntu1) disco; urgency=medium [ Michael Hudson-Doyle ] * d/tests/docker-in-lxd: Increase timeout passed to lxd waitready. [ Tianon Gravi ] * Update to 18.09.1 upstream release [ Michael Hudson-Doyle ] * d/rules: Empty XDG_RUNTIME_DIR when smoke testing runc to avoid it doing silly things. * d/golang-github-docker-docker-dev.install: install some more go packages that other packages in the archive depend on. -- Tianon Gravi <tianon@debian.org> Thu, 17 Jan 2019 16:14:51 -0800 docker.io (18.06.1-0ubuntu2) disco; urgency=medium * Fix containerd/runc embedded commit values * Add "libsystemd-dev" to "Build-Depends" (LP: #1802979) -- Tianon Gravi <tianon@debian.org> Fri, 19 Oct 2018 13:06:35 -0700 docker.io (18.06.1-0ubuntu1) cosmic; urgency=medium * Update to 18.06.1 upstream release (LP: #1794396) - drop "fix-btrfs-constants.patch" (applied upstream) * Update debconf to prompt more aggressively (LP: #1784602) 1. does not prompt on initial install (but does start the daemon) 2. does prompt on every reinstall / upgrade (if the daemon is running) 3. does prompt during "dpkg-reconfigure docker.io" (but does _not_ [re]start the daemon) 4. works properly with DEBIAN_FRONTEND=noninteractive -- user's previous/stored answer to the question automatically applies with no prompt * Check if "docker" group exists before creating it (LP: #1769911) -- Tianon Gravi <tianon@debian.org> Mon, 24 Sep 2018 15:42:19 -0700 docker.io (17.12.1-0ubuntu6) cosmic; urgency=medium * d/tests/docker-in-lxd: Avoid startup race and drop lxd-client depends -- Stéphane Graber <stgraber@ubuntu.com> Sat, 15 Sep 2018 03:07:49 +0200 docker.io (17.12.1-0ubuntu5) cosmic; urgency=medium * Fix ftbfs by cherry-picking https://github.com/containerd/btrfs/pull/16. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Wed, 01 Aug 2018 11:40:05 +1200 docker.io (17.12.1-0ubuntu4) cosmic; urgency=medium * d/tests/docker-in-lxd: only setup network bridge if missing -- Stéphane Graber <stgraber@ubuntu.com> Tue, 05 Jun 2018 22:58:51 -0400 docker.io (17.12.1-0ubuntu3) cosmic; urgency=medium * d/tests/docker-in-lxd: switch to ubuntu-daily lxd remote and wait for cloud-init to finish before running commands in the container. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Tue, 22 May 2018 10:54:00 +1200 docker.io (17.12.1-0ubuntu2) cosmic; urgency=medium * Update btrfs dependencies to use the new libbtrfs-dev & btrfs-progs. -- Dimitri John Ledkov <xnox@ubuntu.com> Thu, 17 May 2018 09:27:15 +0100 docker.io (17.12.1-0ubuntu1) bionic; urgency=medium [ Tianon Gravi ] * Update to 17.12.1-ce upstream release - swap from github.com/docker/docker to .../docker/docker-ce - build separate components in a way that can be parallelized - remove older (unsupported) contrib/ bits from being shipped - drop a lot of unnecessary packaging bits from debian/ * Adjust debconf prompt: - ask during _every_ upgrade - default to not restarting [ Michael Hudson-Doyle ] * Switch to building with default version of Go. * Adjust debconf template to match change in behavior. -- Tianon Gravi <tianon@debian.org> Wed, 28 Feb 2018 09:46:05 -0800 docker.io (17.03.2-0ubuntu5) bionic; urgency=medium * d/control, d/rules: Fix FTBFS when built with golang 1.10 by build depending on golang-1.9-go. See https://github.com/moby/moby/pull/35739 for upstream discussion on golang 1.10 compatibility. -- Tyler Hicks <tyhicks@canonical.com> Tue, 20 Mar 2018 13:57:16 +0000 docker.io (17.03.2-0ubuntu4) bionic; urgency=medium * d/tests/docker-in-lxd: Fix failing test due to /etc/resolv.conf being a symlink in Bionic. The 'lxc file pull <path> -' command prints the symlink contents (the target path) to stdout, rather than the contents of the target file, so use 'lxc exec' to grep /etc/resolv.conf. Grep will follow the symlink in situations where /etc/resolv.conf is a symlink. -- Tyler Hicks <tyhicks@canonical.com> Mon, 19 Mar 2018 19:35:52 +0000 docker.io (17.03.2-0ubuntu3) bionic; urgency=medium * d/tests/docker-in-lxd: set DEBIAN_FRONTEND=noninteractive when installing docker in the lxd container -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Wed, 21 Feb 2018 10:49:58 +1300 docker.io (17.03.2-0ubuntu2) bionic; urgency=medium * Replace "--no-restart-on-upgrade" with "--no-start" and a debconf prompt - not restarting Docker causes many issues (LP: #1658691) - suggested methods for keeping containers up are to use a restart policy ("--restart=..." on "docker run"), Swarm Mode services, or rolling replacement of k8s workers * Backport 30519 for bashism (LP: #1744599) - https://github.com/docker/docker/pull/30519 -- Tianon Gravi <tianon@debian.org> Thu, 07 Dec 2017 09:42:53 -0800 docker.io (17.03.2-0ubuntu1) bionic; urgency=medium * Update to 17.03.2 upstream release -- Tianon Gravi <tianon@debian.org> Wed, 01 Nov 2017 12:30:17 -0700 docker.io (1.13.1-0ubuntu6) artful; urgency=medium * Add missing "runc" patches for LXD-enablement -- Tianon Gravi <tianon@debian.org> Wed, 11 Oct 2017 19:38:03 -0700 docker.io (1.13.1-0ubuntu5) artful; urgency=medium * Replace "runc" dependency with a multiorig copy of Docker's exact supported commit contents (installed as "/usr/bin/docker-runc" mirroring upstream's package) * Replace "containerd" in the same way (with the exact upstream-supported commit, binaries installed as "/usr/bin/docker-containerd*") -- Tianon Gravi <tianon@debian.org> Fri, 29 Sep 2017 13:22:39 -0700 docker.io (1.13.1-0ubuntu4) artful; urgency=medium * d/tests/docker-in-lxd: Better handle DNS with systemd-resolved. -- Stéphane Graber <stgraber@ubuntu.com> Thu, 21 Sep 2017 01:12:33 -0400 docker.io (1.13.1-0ubuntu3) artful; urgency=medium * d/tests/docker-in-lxd: check for network-up has a race condition when systemd-resolved is used. Add an additional check for a real DNS server in systemd-resolve --status. -- Steve Langasek <steve.langasek@ubuntu.com> Fri, 15 Sep 2017 23:32:16 -0700 docker.io (1.13.1-0ubuntu2) artful; urgency=medium * d/tests/docker-in-lxd: copy more apt config into container * d/golang-github-docker-docker-dev.install: install missing packages. (LP: #1714564) * d/control: Add Build-Depend on tzdata. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Mon, 04 Sep 2017 13:31:34 +1200 docker.io (1.13.1-0ubuntu1) artful; urgency=medium * Update to 1.13.1 upstream release - refresh patches (removing many that are applied upstream in 1.13+) - use dh_clean (via debian/clean) instead of explicit "rm" in rules - pull in explicit libnetwork sources for "docker-proxy" - drop unnecessary dh_golang usage (only used for Built-Using calculation) - update "upstream-version-gitcommits" with a more recent list of commits - add "tini" for building "docker-init" (used by "docker run --init") - prefer Go 1.7 explicitly if it's available -- Tianon Gravi <tianon@debian.org> Tue, 22 Aug 2017 09:30:24 -0700 docker.io (1.12.6-0ubuntu7) artful; urgency=medium * Make sure to set security.nesting for the LXD autopkgtest. -- Stéphane Graber <stgraber@ubuntu.com> Tue, 06 Jun 2017 14:55:34 -0600 docker.io (1.12.6-0ubuntu6) artful; urgency=medium * Fix FTBFS on Go 1.8. -- Stéphane Graber <stgraber@ubuntu.com> Mon, 05 Jun 2017 16:21:16 -0600 docker.io (1.12.6-0ubuntu5) artful; urgency=medium * Update LXD autopkgtest now that the "docker" profile is deprecated. -- Stéphane Graber <stgraber@ubuntu.com> Mon, 05 Jun 2017 15:59:18 -0600 docker.io (1.12.6-0ubuntu4) zesty; urgency=medium * Revert 1.12.6-0ubuntu2 as it does not achieve the stated goal on both s390x and armhf. And lxc/lxd adt runners are too restrictive to e.g. import an ubuntu-base container for a minimal functional test. -- Dimitri John Ledkov <xnox@ubuntu.com> Tue, 14 Mar 2017 09:41:30 +0000 docker.io (1.12.6-0ubuntu3) zesty; urgency=medium * debian/tests/docker-in-lxd: Fix a latent version comparison bug that was causing migration failures due to the script thinking it was dealing with an old LXD (< 2.2) when it was really dealing with a recent LXD (>= 2.10). The fix is to use `lxc info` to check if the network extension is supported, rather than trying to compare version strings. -- Tyler Hicks <tyhicks@canonical.com> Fri, 10 Mar 2017 17:40:22 +0000 docker.io (1.12.6-0ubuntu2) zesty; urgency=medium * Remove isolation-machine restriction from adt smoke-test testcase. Should pass on s390x lxd runners; will fails on armhf runners but that is not a regressions since previously all tests were simply skipped on armhf. LP: #1658150 -- Dimitri John Ledkov <xnox@ubuntu.com> Wed, 01 Feb 2017 10:08:00 +0000 docker.io (1.12.6-0ubuntu1) zesty; urgency=medium * Update to 1.12.6 upstream release (LP: #1655906) - add a few new privileged tests to "skip-privileged-unit-tests.patch" * Adjust runc Depends to ensure fix for CVE-2016-9962 is included -- Tianon Gravi <tianon@debian.org> Fri, 13 Jan 2017 11:57:24 +1300 docker.io (1.12.3-0ubuntu4) zesty; urgency=medium * Explicity depend on the version of runc that was built with seccomp support. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Mon, 12 Dec 2016 11:15:01 +1300 docker.io (1.12.3-0ubuntu3) zesty; urgency=medium [ Michael Hudson-Doyle ] * d/test/docker-in-lxd: make test for "is network up" more robust. [ Stefan Bader ] * Backport upstream 1.13 change to keep existing bridges untouched (LP: #1647376) - upstream-1.13-Vendor-libnetwork-51d88e9ae63f.patch -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Thu, 08 Dec 2016 11:53:36 +1300 docker.io (1.12.3-0ubuntu2) zesty; urgency=medium [ Tianon Gravi ] * Enable seccomp support (LP: #1639407) -- Steve Langasek <steve.langasek@ubuntu.com> Wed, 30 Nov 2016 12:34:22 -0800 docker.io (1.12.3-0ubuntu1) zesty; urgency=medium * Update to 1.12.3 upstream release - https://github.com/docker/docker/releases/tag/v1.12.2 - https://github.com/docker/docker/releases/tag/v1.12.3 -- Tianon Gravi <tianon@debian.org> Tue, 15 Nov 2016 15:50:32 -0800 docker.io (1.12.1-0ubuntu15) yakkety; urgency=medium * d/test/docker-in-lxd: use images:ubuntu/${suite}/${arch} instead of ubuntu-daily:${suite} because the former does not have cloud-init in it to rewrite /etc/apt/sources.list at unexpected times. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Mon, 10 Oct 2016 21:38:17 +1300 docker.io (1.12.1-0ubuntu14) yakkety; urgency=medium * d/test/docker-in-lxd: cope with changes in lxd 2.3. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Mon, 10 Oct 2016 15:30:42 +1300 docker.io (1.12.1-0ubuntu13) yakkety; urgency=medium * d/tests/docker-in-lxd: copy apt config from host to container rather than just enabling all of the -proposed pocket. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Tue, 27 Sep 2016 12:23:56 +1300 docker.io (1.12.1-0ubuntu12) yakkety; urgency=medium * Final(?) docker-in-lxd fix: of course, alpine:latest is only the name of the image on amd64. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Mon, 19 Sep 2016 20:34:59 +1200 docker.io (1.12.1-0ubuntu11) yakkety; urgency=medium * Even more docker-in-lxd fixes. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Mon, 19 Sep 2016 14:14:33 +1200 docker.io (1.12.1-0ubuntu10) yakkety; urgency=medium * Yet another docker-in-lxd fix. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Fri, 16 Sep 2016 19:02:41 +1200 docker.io (1.12.1-0ubuntu9) yakkety; urgency=medium * Proxy related fix for docker-in-lxd. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Fri, 16 Sep 2016 18:59:54 +1200 docker.io (1.12.1-0ubuntu8) yakkety; urgency=medium * Re-enable docker-in-lxd again after many fixes. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Fri, 16 Sep 2016 12:26:04 +1200 docker.io (1.12.1-0ubuntu7) yakkety; urgency=medium * d/tests/control: disable docker-in-lxd again, does not work in production infrastructure. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Thu, 08 Sep 2016 09:41:13 +1200 docker.io (1.12.1-0ubuntu6) yakkety; urgency=medium * d/tests/control: docker-in-lxd needs to depend on lxd-client as well. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Wed, 07 Sep 2016 21:18:18 +1200 docker.io (1.12.1-0ubuntu5) yakkety; urgency=medium * Ignore failure to set oom_score_adj, as happens in an unprivileged container. * Use $DOCKER_OPTS in service file again. * Add an autopkgtest to test docker-in-lxd. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Wed, 07 Sep 2016 15:36:50 +1200 docker.io (1.12.1-0ubuntu4) yakkety; urgency=medium * Fix service file. -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Wed, 07 Sep 2016 14:13:12 +1200 docker.io (1.12.1-0ubuntu3) yakkety; urgency=medium * Skip "TestOverlay50LayerRead" on "overlay" driver too (in "skip-privileged-unit-tests.patch") -- Tianon Gravi <tianon@debian.org> Mon, 29 Aug 2016 16:00:00 -0700 docker.io (1.12.1-0ubuntu2) yakkety; urgency=medium * Add new "overlay2" driver's tests to "skip-privileged-unit-tests.patch" (FTBFS fix) -- Tianon Gravi <tianon@debian.org> Fri, 26 Aug 2016 10:20:24 -0700 docker.io (1.12.1-0ubuntu1) yakkety; urgency=medium * Update to 1.12.1 upstream release (LP: #1602243) - refresh "cgroupfs-mount-convenience-copy.patch" - remove "fatal-error-old-kernels.patch"; applied upstream, https://github.com/docker/docker/commit/51b23d88422918c24291f5876df35f91b23a446a - refresh "change-system-unit-env-file.patch" - refresh "21491--systemd-tasksmax.patch" - remove "22000--ignore-invalid-host-header.patch"; applied upstream, https://github.com/docker/docker/pull/22000 https://github.com/docker/docker/pull/22888 https://github.com/docker/docker/pull/23046 - refresh "remove-docker-prefix.patch" - refresh "skip-privileged-unit-tests.patch"; add new privileged tests, + TestMakeRemoteContext + TestMakeSumTarContext + TestDispatch + TestEmptyDockerfile + TestDockerfileOutsideTheBuildContext + TestRealodNoOpts - replace "lxd--20902--docker-in-userns.patch" with the upstream-applied "lxd--25672--docker-in-userns.patch" - remove "lxd--runc-617.patch"; no longer necessary (due to kernel fixes), https://github.com/opencontainers/runc/pull/617#issuecomment-223654149 - remove "21714--no-aufs-in-userns.patch"; applied upstream, https://github.com/docker/docker/pull/21714 - add "man" to "DH_GOLANG_EXCLUDES" (has new "generate.go" which imports the non-vendored "github.com/spf13/cobra/doc", causing dh_golang to choke) - add "docker-proxy-vendor.patch" to account for "vendor/..." vs "vendor/src/..." - install new explicit "dockerd" and "docker-proxy" binaries - update containerd dependency (>= 0.2.3) - update runc dependency (>= 1.0.0-rc1) * Update "debian/watch" to use "uscan.tianon.xyz" so older versions are still easily fetchable without excess work outside uscan -- Tianon Gravi <tianon@debian.org> Wed, 24 Aug 2016 11:48:34 -0700 docker.io (1.11.2-0ubuntu6) yakkety; urgency=medium * Merge from Debian Unstable: - more README.Debian notes (including a fixed href) - new "docker-doc" package which contains the documentation - use "dh-golang" for building (generates appropriate Built-Using) - run upstream unit tests during dh_auto_test - convert upstream-discouraged "/etc/default/docker" to comments-only - utilize dh_install (w/dh-exec) more fully to simplify debian/rules - fix "/etc/docker" permissions for co-existence with docker-registry - remove "/var/lib/docker" on purge * Remaining Ubuntu delta: - non-pruned vendor/ (included in golang-github-docker-docker-dev) - Docker-in-userns patches * Changes from pending Debian upload: - build from within GOPATH so Go packages are resolved properly - split "dh_auto_build-arch" from "dh_auto_build-indep" - include vendor/ in golang-github-docker-docker-dev (since we don't necessarily have the appropriate packages for Depends on that package) -- Tianon Gravi <tianon@debian.org> Fri, 19 Aug 2016 10:15:14 -0700

Modifications :
  1. Download patch cli/cli/command/container/list_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/list_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/list_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ -package container - -import ( - "fmt" - "io/ioutil" - "testing" - - "github.com/docker/cli/cli/config/configfile" - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - // Import builders to get the builder function as package function - . "github.com/docker/cli/internal/test/builders" - "gotest.tools/assert" - "gotest.tools/golden" -) - -func TestContainerListErrors(t *testing.T) { - testCases := []struct { - args []string - flags map[string]string - containerListFunc func(types.ContainerListOptions) ([]types.Container, error) - expectedError string - }{ - { - flags: map[string]string{ - "format": "{{invalid}}", - }, - expectedError: `function "invalid" not defined`, - }, - { - flags: map[string]string{ - "format": "{{join}}", - }, - expectedError: `wrong number of args for join`, - }, - { - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return nil, fmt.Errorf("error listing containers") - }, - expectedError: "error listing containers", - }, - } - for _, tc := range testCases { - cmd := newListCommand( - test.NewFakeCli(&fakeClient{ - containerListFunc: tc.containerListFunc, - }), - ) - cmd.SetArgs(tc.args) - for key, value := range tc.flags { - cmd.Flags().Set(key, value) - } - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestContainerListWithoutFormat(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return []types.Container{ - *Container("c1"), - *Container("c2", WithName("foo")), - *Container("c3", WithPort(80, 80, TCP), WithPort(81, 81, TCP), WithPort(82, 82, TCP)), - *Container("c4", WithPort(81, 81, UDP)), - *Container("c5", WithPort(82, 82, IP("8.8.8.8"), TCP)), - }, nil - }, - }) - cmd := newListCommand(cli) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "container-list-without-format.golden") -} - -func TestContainerListNoTrunc(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return []types.Container{ - *Container("c1"), - *Container("c2", WithName("foo/bar")), - }, nil - }, - }) - cmd := newListCommand(cli) - cmd.Flags().Set("no-trunc", "true") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "container-list-without-format-no-trunc.golden") -} - -// Test for GitHub issue docker/docker#21772 -func TestContainerListNamesMultipleTime(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return []types.Container{ - *Container("c1"), - *Container("c2", WithName("foo/bar")), - }, nil - }, - }) - cmd := newListCommand(cli) - cmd.Flags().Set("format", "{{.Names}} {{.Names}}") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "container-list-format-name-name.golden") -} - -// Test for GitHub issue docker/docker#30291 -func TestContainerListFormatTemplateWithArg(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return []types.Container{ - *Container("c1", WithLabel("some.label", "value")), - *Container("c2", WithName("foo/bar"), WithLabel("foo", "bar")), - }, nil - }, - }) - cmd := newListCommand(cli) - cmd.Flags().Set("format", `{{.Names}} {{.Label "some.label"}}`) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "container-list-format-with-arg.golden") -} - -func TestContainerListFormatSizeSetsOption(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(options types.ContainerListOptions) ([]types.Container, error) { - assert.Check(t, options.Size) - return []types.Container{}, nil - }, - }) - cmd := newListCommand(cli) - cmd.Flags().Set("format", `{{.Size}}`) - assert.NilError(t, cmd.Execute()) -} - -func TestContainerListWithConfigFormat(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return []types.Container{ - *Container("c1", WithLabel("some.label", "value")), - *Container("c2", WithName("foo/bar"), WithLabel("foo", "bar")), - }, nil - }, - }) - cli.SetConfigFile(&configfile.ConfigFile{ - PsFormat: "{{ .Names }} {{ .Image }} {{ .Labels }}", - }) - cmd := newListCommand(cli) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "container-list-with-config-format.golden") -} - -func TestContainerListWithFormat(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: func(_ types.ContainerListOptions) ([]types.Container, error) { - return []types.Container{ - *Container("c1", WithLabel("some.label", "value")), - *Container("c2", WithName("foo/bar"), WithLabel("foo", "bar")), - }, nil - }, - }) - cmd := newListCommand(cli) - cmd.Flags().Set("format", "{{ .Names }} {{ .Image }} {{ .Labels }}") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "container-list-with-format.golden") -}
  2. Download patch cli/cli/command/config/create.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/create.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/create.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -package config - -import ( - "context" - "fmt" - "io" - "io/ioutil" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/opts" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/pkg/system" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type createOptions struct { - name string - templateDriver string - file string - labels opts.ListOpts -} - -func newConfigCreateCommand(dockerCli command.Cli) *cobra.Command { - createOpts := createOptions{ - labels: opts.NewListOpts(opts.ValidateEnv), - } - - cmd := &cobra.Command{ - Use: "create [OPTIONS] CONFIG file|-", - Short: "Create a config from a file or STDIN", - Args: cli.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - createOpts.name = args[0] - createOpts.file = args[1] - return runConfigCreate(dockerCli, createOpts) - }, - } - flags := cmd.Flags() - flags.VarP(&createOpts.labels, "label", "l", "Config labels") - flags.StringVar(&createOpts.templateDriver, "template-driver", "", "Template driver") - flags.SetAnnotation("template-driver", "version", []string{"1.37"}) - - return cmd -} - -func runConfigCreate(dockerCli command.Cli, options createOptions) error { - client := dockerCli.Client() - ctx := context.Background() - - var in io.Reader = dockerCli.In() - if options.file != "-" { - file, err := system.OpenSequential(options.file) - if err != nil { - return err - } - in = file - defer file.Close() - } - - configData, err := ioutil.ReadAll(in) - if err != nil { - return errors.Errorf("Error reading content from %q: %v", options.file, err) - } - - spec := swarm.ConfigSpec{ - Annotations: swarm.Annotations{ - Name: options.name, - Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()), - }, - Data: configData, - } - if options.templateDriver != "" { - spec.Templating = &swarm.Driver{ - Name: options.templateDriver, - } - } - r, err := client.ConfigCreate(ctx, spec) - if err != nil { - return err - } - - fmt.Fprintln(dockerCli.Out(), r.ID) - return nil -}
  3. Download patch cli/cli/command/checkpoint/remove_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/remove_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/remove_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -package checkpoint - -import ( - "io/ioutil" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestCheckpointRemoveErrors(t *testing.T) { - testCases := []struct { - args []string - checkpointDeleteFunc func(container string, options types.CheckpointDeleteOptions) error - expectedError string - }{ - { - args: []string{"too-few-arguments"}, - expectedError: "requires exactly 2 arguments", - }, - { - args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 2 arguments", - }, - { - args: []string{"foo", "bar"}, - checkpointDeleteFunc: func(container string, options types.CheckpointDeleteOptions) error { - return errors.Errorf("error deleting checkpoint") - }, - expectedError: "error deleting checkpoint", - }, - } - - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - checkpointDeleteFunc: tc.checkpointDeleteFunc, - }) - cmd := newRemoveCommand(cli) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestCheckpointRemoveWithOptions(t *testing.T) { - var containerID, checkpointID, checkpointDir string - cli := test.NewFakeCli(&fakeClient{ - checkpointDeleteFunc: func(container string, options types.CheckpointDeleteOptions) error { - containerID = container - checkpointID = options.CheckpointID - checkpointDir = options.CheckpointDir - return nil - }, - }) - cmd := newRemoveCommand(cli) - cmd.SetArgs([]string{"container-foo", "checkpoint-bar"}) - cmd.Flags().Set("checkpoint-dir", "/dir/foo") - assert.NilError(t, cmd.Execute()) - assert.Check(t, is.Equal("container-foo", containerID)) - assert.Check(t, is.Equal("checkpoint-bar", checkpointID)) - assert.Check(t, is.Equal("/dir/foo", checkpointDir)) -}
  4. Download patch cli/cli/command/container/stats_unit_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/stats_unit_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/stats_unit_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -package container - -import ( - "testing" - - "github.com/docker/docker/api/types" -) - -func TestCalculateBlockIO(t *testing.T) { - blkio := types.BlkioStats{ - IoServiceBytesRecursive: []types.BlkioStatEntry{ - {Major: 8, Minor: 0, Op: "read", Value: 1234}, - {Major: 8, Minor: 1, Op: "read", Value: 4567}, - {Major: 8, Minor: 0, Op: "write", Value: 123}, - {Major: 8, Minor: 1, Op: "write", Value: 456}, - }, - } - blkRead, blkWrite := calculateBlockIO(blkio) - if blkRead != 5801 { - t.Fatalf("blkRead = %d, want 5801", blkRead) - } - if blkWrite != 579 { - t.Fatalf("blkWrite = %d, want 579", blkWrite) - } -}
  5. Download patch cli/cli/command/container/stats_helpers_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/stats_helpers_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/stats_helpers_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -package container - -import ( - "fmt" - "testing" - - "github.com/docker/docker/api/types" - "gotest.tools/assert" -) - -func TestCalculateMemUsageUnixNoCache(t *testing.T) { - // Given - stats := types.MemoryStats{Usage: 500, Stats: map[string]uint64{"cache": 400}} - - // When - result := calculateMemUsageUnixNoCache(stats) - - // Then - assert.Assert(t, inDelta(100.0, result, 1e-6)) -} - -func TestCalculateMemPercentUnixNoCache(t *testing.T) { - // Given - someLimit := float64(100.0) - noLimit := float64(0.0) - used := float64(70.0) - - // When and Then - t.Run("Limit is set", func(t *testing.T) { - result := calculateMemPercentUnixNoCache(someLimit, used) - assert.Assert(t, inDelta(70.0, result, 1e-6)) - }) - t.Run("No limit, no cgroup data", func(t *testing.T) { - result := calculateMemPercentUnixNoCache(noLimit, used) - assert.Assert(t, inDelta(0.0, result, 1e-6)) - }) -} - -func inDelta(x, y, delta float64) func() (bool, string) { - return func() (bool, string) { - diff := x - y - if diff < -delta || diff > delta { - return false, fmt.Sprintf("%f != %f within %f", x, y, delta) - } - return true, "" - } -}
  6. Download patch cli/cli/command/container/opts_test.go
  7. Download patch cli/cli/command/container/exec_test.go
  8. Download patch cli/cli/command/config/testdata/config-inspect-without-format.single-config.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-inspect-without-format.single-config.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-inspect-without-format.single-config.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -[ - { - "ID": "ID-foo", - "Version": {}, - "CreatedAt": "0001-01-01T00:00:00Z", - "UpdatedAt": "0001-01-01T00:00:00Z", - "Spec": { - "Name": "foo", - "Labels": null - } - } -]
  9. Download patch cli/cli/command/config/testdata/config-inspect-with-format.json-template.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-inspect-with-format.json-template.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-inspect-with-format.json-template.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"label1":"label-foo"}
  10. Download patch cli/cli/command/container/export_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/export_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/export_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -package container - -import ( - "io" - "io/ioutil" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "gotest.tools/assert" - "gotest.tools/fs" -) - -func TestContainerExportOutputToFile(t *testing.T) { - dir := fs.NewDir(t, "export-test") - defer dir.Remove() - - cli := test.NewFakeCli(&fakeClient{ - containerExportFunc: func(container string) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader("bar")), nil - }, - }) - cmd := NewExportCommand(cli) - cmd.SetOutput(ioutil.Discard) - cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"}) - assert.NilError(t, cmd.Execute()) - - expected := fs.Expected(t, - fs.WithFile("foo", "bar", fs.MatchAnyFileMode), - ) - - assert.Assert(t, fs.Equal(dir.Path(), expected)) -}
  11. Download patch cli/cli/command/checkpoint/list_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/list_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/list_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -package checkpoint - -import ( - "io/ioutil" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" - "gotest.tools/golden" -) - -func TestCheckpointListErrors(t *testing.T) { - testCases := []struct { - args []string - checkpointListFunc func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) - expectedError string - }{ - { - args: []string{}, - expectedError: "requires exactly 1 argument", - }, - { - args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 1 argument", - }, - { - args: []string{"foo"}, - checkpointListFunc: func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { - return []types.Checkpoint{}, errors.Errorf("error getting checkpoints for container foo") - }, - expectedError: "error getting checkpoints for container foo", - }, - } - - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - checkpointListFunc: tc.checkpointListFunc, - }) - cmd := newListCommand(cli) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestCheckpointListWithOptions(t *testing.T) { - var containerID, checkpointDir string - cli := test.NewFakeCli(&fakeClient{ - checkpointListFunc: func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { - containerID = container - checkpointDir = options.CheckpointDir - return []types.Checkpoint{ - {Name: "checkpoint-foo"}, - }, nil - }, - }) - cmd := newListCommand(cli) - cmd.SetArgs([]string{"container-foo"}) - cmd.Flags().Set("checkpoint-dir", "/dir/foo") - assert.NilError(t, cmd.Execute()) - assert.Check(t, is.Equal("container-foo", containerID)) - assert.Check(t, is.Equal("/dir/foo", checkpointDir)) - golden.Assert(t, cli.OutBuffer().String(), "checkpoint-list-with-options.golden") -}
  12. Download patch cli/cli/command/container/exec.go
  13. Download patch cli/cli/command/container/run_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/run_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/run_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -package container - -import ( - "fmt" - "io/ioutil" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/cli/internal/test/notary" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestRunLabel(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - createContainerFunc: func(_ *container.Config, _ *container.HostConfig, _ *network.NetworkingConfig, _ string) (container.ContainerCreateCreatedBody, error) { - return container.ContainerCreateCreatedBody{ - ID: "id", - }, nil - }, - Version: "1.36", - }) - cmd := NewRunCommand(cli) - cmd.Flags().Set("detach", "true") - cmd.SetArgs([]string{"--label", "foo", "busybox"}) - assert.NilError(t, cmd.Execute()) -} - -func TestRunCommandWithContentTrustErrors(t *testing.T) { - testCases := []struct { - name string - args []string - expectedError string - notaryFunc test.NotaryClientFuncType - }{ - { - name: "offline-notary-server", - notaryFunc: notary.GetOfflineNotaryRepository, - expectedError: "client is offline", - args: []string{"image:tag"}, - }, - { - name: "uninitialized-notary-server", - notaryFunc: notary.GetUninitializedNotaryRepository, - expectedError: "remote trust data does not exist", - args: []string{"image:tag"}, - }, - { - name: "empty-notary-server", - notaryFunc: notary.GetEmptyTargetsNotaryRepository, - expectedError: "No valid trust data for tag", - args: []string{"image:tag"}, - }, - } - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - createContainerFunc: func(config *container.Config, - hostConfig *container.HostConfig, - networkingConfig *network.NetworkingConfig, - containerName string, - ) (container.ContainerCreateCreatedBody, error) { - return container.ContainerCreateCreatedBody{}, fmt.Errorf("shouldn't try to pull image") - }, - }, test.EnableContentTrust) - cli.SetNotaryClient(tc.notaryFunc) - cmd := NewRunCommand(cli) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - err := cmd.Execute() - assert.Assert(t, err != nil) - assert.Assert(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError)) - } -}
  14. Download patch cli/cli/command/checkpoint/remove.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/remove.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/remove.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -package checkpoint - -import ( - "context" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/spf13/cobra" -) - -type removeOptions struct { - checkpointDir string -} - -func newRemoveCommand(dockerCli command.Cli) *cobra.Command { - var opts removeOptions - - cmd := &cobra.Command{ - Use: "rm [OPTIONS] CONTAINER CHECKPOINT", - Aliases: []string{"remove"}, - Short: "Remove a checkpoint", - Args: cli.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - return runRemove(dockerCli, args[0], args[1], opts) - }, - } - - flags := cmd.Flags() - flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory") - - return cmd -} - -func runRemove(dockerCli command.Cli, container string, checkpoint string, opts removeOptions) error { - client := dockerCli.Client() - - removeOpts := types.CheckpointDeleteOptions{ - CheckpointID: checkpoint, - CheckpointDir: opts.checkpointDir, - } - - return client.CheckpointDelete(context.Background(), container, removeOpts) -}
  15. Download patch cli/cli/command/container/prune.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/prune.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/prune.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -package container - -import ( - "context" - "fmt" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/opts" - units "github.com/docker/go-units" - "github.com/spf13/cobra" -) - -type pruneOptions struct { - force bool - filter opts.FilterOpt -} - -// NewPruneCommand returns a new cobra prune command for containers -func NewPruneCommand(dockerCli command.Cli) *cobra.Command { - options := pruneOptions{filter: opts.NewFilterOpt()} - - cmd := &cobra.Command{ - Use: "prune [OPTIONS]", - Short: "Remove all stopped containers", - Args: cli.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - spaceReclaimed, output, err := runPrune(dockerCli, options) - if err != nil { - return err - } - if output != "" { - fmt.Fprintln(dockerCli.Out(), output) - } - fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed))) - return nil - }, - Annotations: map[string]string{"version": "1.25"}, - } - - flags := cmd.Flags() - flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation") - flags.Var(&options.filter, "filter", "Provide filter values (e.g. 'until=<timestamp>')") - - return cmd -} - -const warning = `WARNING! This will remove all stopped containers. -Are you sure you want to continue?` - -func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) { - pruneFilters := command.PruneFilters(dockerCli, options.filter.Value()) - - if !options.force && !command.PromptForConfirmation(dockerCli.In(), dockerCli.Out(), warning) { - return 0, "", nil - } - - report, err := dockerCli.Client().ContainersPrune(context.Background(), pruneFilters) - if err != nil { - return 0, "", err - } - - if len(report.ContainersDeleted) > 0 { - output = "Deleted Containers:\n" - for _, id := range report.ContainersDeleted { - output += id + "\n" - } - spaceReclaimed = report.SpaceReclaimed - } - - return spaceReclaimed, output, nil -} - -// RunPrune calls the Container Prune API -// This returns the amount of space reclaimed and a detailed output string -func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { - return runPrune(dockerCli, pruneOptions{force: true, filter: filter}) -}
  16. Download patch cli/cli/command/config/testdata/config-inspect-pretty.simple.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-inspect-pretty.simple.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-inspect-pretty.simple.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -ID: configID -Name: configName -Labels: - - lbl1=value1 -Created at: 0001-01-01 00:00:00 +0000 utc -Updated at: 0001-01-01 00:00:00 +0000 utc -Data: -payload here
  17. Download patch cli/cli/command/container/client_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/client_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/client_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -package container - -import ( - "context" - "io" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/client" -) - -type fakeClient struct { - client.Client - inspectFunc func(string) (types.ContainerJSON, error) - execInspectFunc func(execID string) (types.ContainerExecInspect, error) - execCreateFunc func(container string, config types.ExecConfig) (types.IDResponse, error) - createContainerFunc func(config *container.Config, - hostConfig *container.HostConfig, - networkingConfig *network.NetworkingConfig, - containerName string) (container.ContainerCreateCreatedBody, error) - containerStartFunc func(container string, options types.ContainerStartOptions) error - imageCreateFunc func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) - infoFunc func() (types.Info, error) - containerStatPathFunc func(container, path string) (types.ContainerPathStat, error) - containerCopyFromFunc func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) - logFunc func(string, types.ContainerLogsOptions) (io.ReadCloser, error) - waitFunc func(string) (<-chan container.ContainerWaitOKBody, <-chan error) - containerListFunc func(types.ContainerListOptions) ([]types.Container, error) - containerExportFunc func(string) (io.ReadCloser, error) - containerExecResizeFunc func(id string, options types.ResizeOptions) error - Version string -} - -func (f *fakeClient) ContainerList(_ context.Context, options types.ContainerListOptions) ([]types.Container, error) { - if f.containerListFunc != nil { - return f.containerListFunc(options) - } - return []types.Container{}, nil -} - -func (f *fakeClient) ContainerInspect(_ context.Context, containerID string) (types.ContainerJSON, error) { - if f.inspectFunc != nil { - return f.inspectFunc(containerID) - } - return types.ContainerJSON{}, nil -} - -func (f *fakeClient) ContainerExecCreate(_ context.Context, container string, config types.ExecConfig) (types.IDResponse, error) { - if f.execCreateFunc != nil { - return f.execCreateFunc(container, config) - } - return types.IDResponse{}, nil -} - -func (f *fakeClient) ContainerExecInspect(_ context.Context, execID string) (types.ContainerExecInspect, error) { - if f.execInspectFunc != nil { - return f.execInspectFunc(execID) - } - return types.ContainerExecInspect{}, nil -} - -func (f *fakeClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error { - return nil -} - -func (f *fakeClient) ContainerCreate( - _ context.Context, - config *container.Config, - hostConfig *container.HostConfig, - networkingConfig *network.NetworkingConfig, - containerName string, -) (container.ContainerCreateCreatedBody, error) { - if f.createContainerFunc != nil { - return f.createContainerFunc(config, hostConfig, networkingConfig, containerName) - } - return container.ContainerCreateCreatedBody{}, nil -} - -func (f *fakeClient) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { - if f.imageCreateFunc != nil { - return f.imageCreateFunc(parentReference, options) - } - return nil, nil -} - -func (f *fakeClient) Info(_ context.Context) (types.Info, error) { - if f.infoFunc != nil { - return f.infoFunc() - } - return types.Info{}, nil -} - -func (f *fakeClient) ContainerStatPath(_ context.Context, container, path string) (types.ContainerPathStat, error) { - if f.containerStatPathFunc != nil { - return f.containerStatPathFunc(container, path) - } - return types.ContainerPathStat{}, nil -} - -func (f *fakeClient) CopyFromContainer(_ context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { - if f.containerCopyFromFunc != nil { - return f.containerCopyFromFunc(container, srcPath) - } - return nil, types.ContainerPathStat{}, nil -} - -func (f *fakeClient) ContainerLogs(_ context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) { - if f.logFunc != nil { - return f.logFunc(container, options) - } - return nil, nil -} - -func (f *fakeClient) ClientVersion() string { - return f.Version -} - -func (f *fakeClient) ContainerWait(_ context.Context, container string, _ container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) { - if f.waitFunc != nil { - return f.waitFunc(container) - } - return nil, nil -} - -func (f *fakeClient) ContainerStart(_ context.Context, container string, options types.ContainerStartOptions) error { - if f.containerStartFunc != nil { - return f.containerStartFunc(container, options) - } - return nil -} - -func (f *fakeClient) ContainerExport(_ context.Context, container string) (io.ReadCloser, error) { - if f.containerExportFunc != nil { - return f.containerExportFunc(container) - } - return nil, nil -} - -func (f *fakeClient) ContainerExecResize(_ context.Context, id string, options types.ResizeOptions) error { - if f.containerExecResizeFunc != nil { - return f.containerExecResizeFunc(id, options) - } - return nil -}
  18. Download patch cli/cli/command/container/unpause.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/unpause.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/unpause.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type unpauseOptions struct { - containers []string -} - -// NewUnpauseCommand creates a new cobra.Command for `docker unpause` -func NewUnpauseCommand(dockerCli command.Cli) *cobra.Command { - var opts unpauseOptions - - cmd := &cobra.Command{ - Use: "unpause CONTAINER [CONTAINER...]", - Short: "Unpause all processes within one or more containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - return runUnpause(dockerCli, &opts) - }, - } - return cmd -} - -func runUnpause(dockerCli command.Cli, opts *unpauseOptions) error { - ctx := context.Background() - - var errs []string - errChan := parallelOperation(ctx, opts.containers, dockerCli.Client().ContainerUnpause) - for _, container := range opts.containers { - if err := <-errChan; err != nil { - errs = append(errs, err.Error()) - continue - } - fmt.Fprintln(dockerCli.Out(), container) - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  19. Download patch cli/cli/command/container/inspect.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/inspect.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/inspect.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -package container - -import ( - "context" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/inspect" - "github.com/spf13/cobra" -) - -type inspectOptions struct { - format string - size bool - refs []string -} - -// newInspectCommand creates a new cobra.Command for `docker container inspect` -func newInspectCommand(dockerCli command.Cli) *cobra.Command { - var opts inspectOptions - - cmd := &cobra.Command{ - Use: "inspect [OPTIONS] CONTAINER [CONTAINER...]", - Short: "Display detailed information on one or more containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.refs = args - return runInspect(dockerCli, opts) - }, - } - - flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") - flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes") - - return cmd -} - -func runInspect(dockerCli command.Cli, opts inspectOptions) error { - client := dockerCli.Client() - ctx := context.Background() - - getRefFunc := func(ref string) (interface{}, []byte, error) { - return client.ContainerInspectWithRaw(ctx, ref, opts.size) - } - return inspect.Inspect(dockerCli.Out(), opts.refs, opts.format, getRefFunc) -}
  20. Download patch cli/cli/command/config/testdata/config-inspect-with-format.simple-template.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-inspect-with-format.simple-template.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-inspect-with-format.simple-template.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -foo
  21. Download patch cli/cli/command/cli_test.go
  22. Download patch cli/cli/command/checkpoint/create.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/create.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/create.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -package checkpoint - -import ( - "context" - "fmt" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/spf13/cobra" -) - -type createOptions struct { - container string - checkpoint string - checkpointDir string - leaveRunning bool -} - -func newCreateCommand(dockerCli command.Cli) *cobra.Command { - var opts createOptions - - cmd := &cobra.Command{ - Use: "create [OPTIONS] CONTAINER CHECKPOINT", - Short: "Create a checkpoint from a running container", - Args: cli.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - opts.checkpoint = args[1] - return runCreate(dockerCli, opts) - }, - } - - flags := cmd.Flags() - flags.BoolVar(&opts.leaveRunning, "leave-running", false, "Leave the container running after checkpoint") - flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory") - - return cmd -} - -func runCreate(dockerCli command.Cli, opts createOptions) error { - client := dockerCli.Client() - - checkpointOpts := types.CheckpointCreateOptions{ - CheckpointID: opts.checkpoint, - CheckpointDir: opts.checkpointDir, - Exit: !opts.leaveRunning, - } - - err := client.CheckpointCreate(context.Background(), opts.container, checkpointOpts) - if err != nil { - return err - } - - fmt.Fprintf(dockerCli.Out(), "%s\n", opts.checkpoint) - return nil -}
  23. Download patch cli/cli/command/container/testdata/container-list-without-format.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/container-list-without-format.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/container-list-without-format.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -container_id busybox:latest "top" Less than a second ago Up 1 second c1 -container_id busybox:latest "top" Less than a second ago Up 1 second c2 -container_id busybox:latest "top" Less than a second ago Up 1 second 80-82/tcp c3 -container_id busybox:latest "top" Less than a second ago Up 1 second 81/udp c4 -container_id busybox:latest "top" Less than a second ago Up 1 second 8.8.8.8:82->82/tcp c5
  24. Download patch cli/cli/command/checkpoint/cmd.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/cmd.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/cmd.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -package checkpoint - -import ( - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/spf13/cobra" -) - -// NewCheckpointCommand returns the `checkpoint` subcommand (only in experimental) -func NewCheckpointCommand(dockerCli command.Cli) *cobra.Command { - cmd := &cobra.Command{ - Use: "checkpoint", - Short: "Manage checkpoints", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Annotations: map[string]string{ - "experimental": "", - "ostype": "linux", - "version": "1.25", - }, - } - cmd.AddCommand( - newCreateCommand(dockerCli), - newListCommand(dockerCli), - newRemoveCommand(dockerCli), - ) - return cmd -}
  25. Download patch cli/cli/command/config/testdata/config-list-with-config-format.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-list-with-config-format.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-list-with-config-format.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -bar label=label-bar -foo
  26. Download patch cli/cli/command/config/ls.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/ls.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/ls.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -package config - -import ( - "context" - "sort" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/formatter" - "github.com/docker/cli/opts" - "github.com/docker/docker/api/types" - "github.com/spf13/cobra" - "vbom.ml/util/sortorder" -) - -type listOptions struct { - quiet bool - format string - filter opts.FilterOpt -} - -func newConfigListCommand(dockerCli command.Cli) *cobra.Command { - listOpts := listOptions{filter: opts.NewFilterOpt()} - - cmd := &cobra.Command{ - Use: "ls [OPTIONS]", - Aliases: []string{"list"}, - Short: "List configs", - Args: cli.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return runConfigList(dockerCli, listOpts) - }, - } - - flags := cmd.Flags() - flags.BoolVarP(&listOpts.quiet, "quiet", "q", false, "Only display IDs") - flags.StringVarP(&listOpts.format, "format", "", "", "Pretty-print configs using a Go template") - flags.VarP(&listOpts.filter, "filter", "f", "Filter output based on conditions provided") - - return cmd -} - -func runConfigList(dockerCli command.Cli, options listOptions) error { - client := dockerCli.Client() - ctx := context.Background() - - configs, err := client.ConfigList(ctx, types.ConfigListOptions{Filters: options.filter.Value()}) - if err != nil { - return err - } - - format := options.format - if len(format) == 0 { - if len(dockerCli.ConfigFile().ConfigFormat) > 0 && !options.quiet { - format = dockerCli.ConfigFile().ConfigFormat - } else { - format = formatter.TableFormatKey - } - } - - sort.Slice(configs, func(i, j int) bool { - return sortorder.NaturalLess(configs[i].Spec.Name, configs[j].Spec.Name) - }) - - configCtx := formatter.Context{ - Output: dockerCli.Out(), - Format: formatter.NewConfigFormat(format, options.quiet), - } - return formatter.ConfigWrite(configCtx, configs) -}
  27. Download patch cli/cli/command/checkpoint/testdata/checkpoint-list-with-options.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/testdata/checkpoint-list-with-options.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/testdata/checkpoint-list-with-options.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -CHECKPOINT NAME -checkpoint-foo
  28. Download patch cli/cli/command/container/pause.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/pause.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/pause.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type pauseOptions struct { - containers []string -} - -// NewPauseCommand creates a new cobra.Command for `docker pause` -func NewPauseCommand(dockerCli command.Cli) *cobra.Command { - var opts pauseOptions - - return &cobra.Command{ - Use: "pause CONTAINER [CONTAINER...]", - Short: "Pause all processes within one or more containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - return runPause(dockerCli, &opts) - }, - } -} - -func runPause(dockerCli command.Cli, opts *pauseOptions) error { - ctx := context.Background() - - var errs []string - errChan := parallelOperation(ctx, opts.containers, dockerCli.Client().ContainerPause) - for _, container := range opts.containers { - if err := <-errChan; err != nil { - errs = append(errs, err.Error()) - continue - } - fmt.Fprintln(dockerCli.Out(), container) - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  29. Download patch cli/cli/command/container/ps_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/ps_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/ps_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -package container - -import ( - "testing" - - "github.com/docker/cli/opts" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestBuildContainerListOptions(t *testing.T) { - filters := opts.NewFilterOpt() - assert.NilError(t, filters.Set("foo=bar")) - assert.NilError(t, filters.Set("baz=foo")) - - contexts := []struct { - psOpts *psOptions - expectedAll bool - expectedSize bool - expectedLimit int - expectedFilters map[string]string - }{ - { - psOpts: &psOptions{ - all: true, - size: true, - last: 5, - filter: filters, - }, - expectedAll: true, - expectedSize: true, - expectedLimit: 5, - expectedFilters: map[string]string{ - "foo": "bar", - "baz": "foo", - }, - }, - { - psOpts: &psOptions{ - all: true, - size: true, - last: -1, - nLatest: true, - }, - expectedAll: true, - expectedSize: true, - expectedLimit: 1, - expectedFilters: make(map[string]string), - }, - { - psOpts: &psOptions{ - all: true, - size: false, - last: 5, - filter: filters, - // With .Size, size should be true - format: "{{.Size}}", - }, - expectedAll: true, - expectedSize: true, - expectedLimit: 5, - expectedFilters: map[string]string{ - "foo": "bar", - "baz": "foo", - }, - }, - { - psOpts: &psOptions{ - all: true, - size: false, - last: 5, - filter: filters, - // With .Size, size should be true - format: "{{.Size}} {{.CreatedAt}} {{.Networks}}", - }, - expectedAll: true, - expectedSize: true, - expectedLimit: 5, - expectedFilters: map[string]string{ - "foo": "bar", - "baz": "foo", - }, - }, - { - psOpts: &psOptions{ - all: true, - size: false, - last: 5, - filter: filters, - // Without .Size, size should be false - format: "{{.CreatedAt}} {{.Networks}}", - }, - expectedAll: true, - expectedSize: false, - expectedLimit: 5, - expectedFilters: map[string]string{ - "foo": "bar", - "baz": "foo", - }, - }, - } - - for _, c := range contexts { - options, err := buildContainerListOptions(c.psOpts) - assert.NilError(t, err) - - assert.Check(t, is.Equal(c.expectedAll, options.All)) - assert.Check(t, is.Equal(c.expectedSize, options.Size)) - assert.Check(t, is.Equal(c.expectedLimit, options.Limit)) - assert.Check(t, is.Equal(len(c.expectedFilters), options.Filters.Len())) - - for k, v := range c.expectedFilters { - f := options.Filters - if !f.ExactMatch(k, v) { - t.Fatalf("Expected filter with key %s to be %s but got %s", k, v, f.Get(k)) - } - } - } -}
  30. Download patch cli/cli/command/container/list.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/list.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/list.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -package container - -import ( - "context" - "io/ioutil" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/formatter" - "github.com/docker/cli/opts" - "github.com/docker/cli/templates" - "github.com/docker/docker/api/types" - "github.com/spf13/cobra" -) - -type psOptions struct { - quiet bool - size bool - all bool - noTrunc bool - nLatest bool - last int - format string - filter opts.FilterOpt -} - -// NewPsCommand creates a new cobra.Command for `docker ps` -func NewPsCommand(dockerCli command.Cli) *cobra.Command { - options := psOptions{filter: opts.NewFilterOpt()} - - cmd := &cobra.Command{ - Use: "ps [OPTIONS]", - Short: "List containers", - Args: cli.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return runPs(dockerCli, &options) - }, - } - - flags := cmd.Flags() - - flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display numeric IDs") - flags.BoolVarP(&options.size, "size", "s", false, "Display total file sizes") - flags.BoolVarP(&options.all, "all", "a", false, "Show all containers (default shows just running)") - flags.BoolVar(&options.noTrunc, "no-trunc", false, "Don't truncate output") - flags.BoolVarP(&options.nLatest, "latest", "l", false, "Show the latest created container (includes all states)") - flags.IntVarP(&options.last, "last", "n", -1, "Show n last created containers (includes all states)") - flags.StringVarP(&options.format, "format", "", "", "Pretty-print containers using a Go template") - flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided") - - return cmd -} - -func newListCommand(dockerCli command.Cli) *cobra.Command { - cmd := *NewPsCommand(dockerCli) - cmd.Aliases = []string{"ps", "list"} - cmd.Use = "ls [OPTIONS]" - return &cmd -} - -// listOptionsProcessor is used to set any container list options which may only -// be embedded in the format template. -// This is passed directly into tmpl.Execute in order to allow the preprocessor -// to set any list options that were not provided by flags (e.g. `.Size`). -// It is using a `map[string]bool` so that unknown fields passed into the -// template format do not cause errors. These errors will get picked up when -// running through the actual template processor. -type listOptionsProcessor map[string]bool - -// Size sets the size of the map when called by a template execution. -func (o listOptionsProcessor) Size() bool { - o["size"] = true - return true -} - -// Label is needed here as it allows the correct pre-processing -// because Label() is a method with arguments -func (o listOptionsProcessor) Label(name string) string { - return "" -} - -func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, error) { - options := &types.ContainerListOptions{ - All: opts.all, - Limit: opts.last, - Size: opts.size, - Filters: opts.filter.Value(), - } - - if opts.nLatest && opts.last == -1 { - options.Limit = 1 - } - - tmpl, err := templates.Parse(opts.format) - - if err != nil { - return nil, err - } - - optionsProcessor := listOptionsProcessor{} - // This shouldn't error out but swallowing the error makes it harder - // to track down if preProcessor issues come up. Ref #24696 - if err := tmpl.Execute(ioutil.Discard, optionsProcessor); err != nil { - return nil, err - } - // At the moment all we need is to capture .Size for preprocessor - options.Size = opts.size || optionsProcessor["size"] - - return options, nil -} - -func runPs(dockerCli command.Cli, options *psOptions) error { - ctx := context.Background() - - listOptions, err := buildContainerListOptions(options) - if err != nil { - return err - } - - containers, err := dockerCli.Client().ContainerList(ctx, *listOptions) - if err != nil { - return err - } - - format := options.format - if len(format) == 0 { - if len(dockerCli.ConfigFile().PsFormat) > 0 && !options.quiet { - format = dockerCli.ConfigFile().PsFormat - } else { - format = formatter.TableFormatKey - } - } - - containerCtx := formatter.Context{ - Output: dockerCli.Out(), - Format: formatter.NewContainerFormat(format, options.quiet, listOptions.Size), - Trunc: !options.noTrunc, - } - return formatter.ContainerWrite(containerCtx, containers) -}
  31. Download patch cli/cli/command/container/hijack.go
  32. Download patch cli/cli/command/builder/prune.go

    --- 18.09.5+dfsg1-1/cli/cli/command/builder/prune.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/builder/prune.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -package builder - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/opts" - "github.com/docker/docker/api/types" - units "github.com/docker/go-units" - "github.com/spf13/cobra" -) - -type pruneOptions struct { - force bool - all bool - filter opts.FilterOpt - keepStorage opts.MemBytes -} - -// NewPruneCommand returns a new cobra prune command for images -func NewPruneCommand(dockerCli command.Cli) *cobra.Command { - options := pruneOptions{filter: opts.NewFilterOpt()} - - cmd := &cobra.Command{ - Use: "prune", - Short: "Remove build cache", - Args: cli.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - spaceReclaimed, output, err := runPrune(dockerCli, options) - if err != nil { - return err - } - if output != "" { - fmt.Fprintln(dockerCli.Out(), output) - } - fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed))) - return nil - }, - Annotations: map[string]string{"version": "1.39"}, - } - - flags := cmd.Flags() - flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation") - flags.BoolVarP(&options.all, "all", "a", false, "Remove all unused images, not just dangling ones") - flags.Var(&options.filter, "filter", "Provide filter values (e.g. 'unused-for=24h')") - flags.Var(&options.keepStorage, "keep-storage", "Amount of disk space to keep for cache") - - return cmd -} - -const ( - normalWarning = `WARNING! This will remove all dangling build cache. Are you sure you want to continue?` - allCacheWarning = `WARNING! This will remove all build cache. Are you sure you want to continue?` -) - -func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) { - pruneFilters := options.filter.Value() - pruneFilters = command.PruneFilters(dockerCli, pruneFilters) - - warning := normalWarning - if options.all { - warning = allCacheWarning - } - if !options.force && !command.PromptForConfirmation(dockerCli.In(), dockerCli.Out(), warning) { - return 0, "", nil - } - - report, err := dockerCli.Client().BuildCachePrune(context.Background(), types.BuildCachePruneOptions{ - All: options.all, - KeepStorage: options.keepStorage.Value(), - Filters: pruneFilters, - }) - if err != nil { - return 0, "", err - } - - if len(report.CachesDeleted) > 0 { - var sb strings.Builder - sb.WriteString("Deleted build cache objects:\n") - for _, id := range report.CachesDeleted { - sb.WriteString(id) - sb.WriteByte('\n') - } - output = sb.String() - } - - return report.SpaceReclaimed, output, nil -} - -// CachePrune executes a prune command for build cache -func CachePrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { - return runPrune(dockerCli, pruneOptions{force: true, all: all, filter: filter}) -}
  33. Download patch cli/cli/command/container/create.go
  34. Download patch cli/cli/command/checkpoint/create_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/create_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/create_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -package checkpoint - -import ( - "io/ioutil" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestCheckpointCreateErrors(t *testing.T) { - testCases := []struct { - args []string - checkpointCreateFunc func(container string, options types.CheckpointCreateOptions) error - expectedError string - }{ - { - args: []string{"too-few-arguments"}, - expectedError: "requires exactly 2 arguments", - }, - { - args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 2 arguments", - }, - { - args: []string{"foo", "bar"}, - checkpointCreateFunc: func(container string, options types.CheckpointCreateOptions) error { - return errors.Errorf("error creating checkpoint for container foo") - }, - expectedError: "error creating checkpoint for container foo", - }, - } - - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - checkpointCreateFunc: tc.checkpointCreateFunc, - }) - cmd := newCreateCommand(cli) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestCheckpointCreateWithOptions(t *testing.T) { - var containerID, checkpointID, checkpointDir string - var exit bool - cli := test.NewFakeCli(&fakeClient{ - checkpointCreateFunc: func(container string, options types.CheckpointCreateOptions) error { - containerID = container - checkpointID = options.CheckpointID - checkpointDir = options.CheckpointDir - exit = options.Exit - return nil - }, - }) - cmd := newCreateCommand(cli) - checkpoint := "checkpoint-bar" - cmd.SetArgs([]string{"container-foo", checkpoint}) - cmd.Flags().Set("leave-running", "true") - cmd.Flags().Set("checkpoint-dir", "/dir/foo") - assert.NilError(t, cmd.Execute()) - assert.Check(t, is.Equal("container-foo", containerID)) - assert.Check(t, is.Equal(checkpoint, checkpointID)) - assert.Check(t, is.Equal("/dir/foo", checkpointDir)) - assert.Check(t, is.Equal(false, exit)) - assert.Check(t, is.Equal(checkpoint, strings.TrimSpace(cli.OutBuffer().String()))) -}
  35. Download patch cli/cli/command/engine/activate_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/engine/activate_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/engine/activate_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -package engine - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/docker/cli/internal/licenseutils" - "github.com/docker/cli/internal/test" - clitypes "github.com/docker/cli/types" - "github.com/docker/docker/api/types" - "github.com/docker/docker/client" - "github.com/docker/licensing" - "github.com/docker/licensing/model" - "gotest.tools/assert" - "gotest.tools/fs" - "gotest.tools/golden" -) - -const ( - // nolint: lll - expiredLicense = `{"key_id":"irlYm3b9fdD8hMUXjazF39im7VQSSbAm9tfHK8cKUxJt","private_key":"aH5tTRDAVJpCRS2CRetTQVXIKgWUPfoCHODhDvNPvAbz","authorization":"ewogICAicGF5bG9hZCI6ICJleUpsZUhCcGNtRjBhVzl1SWpvaU1qQXhPQzB3TXkweE9GUXdOem93TURvd01Gb2lMQ0owYjJ0bGJpSTZJbkZtTVMxMlVtRmtialp5YjFaMldXdHJlVXN4VFdKMGNGUmpXR1ozVjA4MVRWZFFTM2cwUnpJd2NIYzlJaXdpYldGNFJXNW5hVzVsY3lJNk1Td2ljMk5oYm01cGJtZEZibUZpYkdWa0lqcDBjblZsTENKc2FXTmxibk5sVkhsd1pTSTZJazltWm14cGJtVWlMQ0owYVdWeUlqb2lVSEp2WkhWamRHbHZiaUo5IiwKICAgInNpZ25hdHVyZXMiOiBbCiAgICAgIHsKICAgICAgICAgImhlYWRlciI6IHsKICAgICAgICAgICAgImp3ayI6IHsKICAgICAgICAgICAgICAgImUiOiAiQVFBQiIsCiAgICAgICAgICAgICAgICJrZXlJRCI6ICJKN0xEOjY3VlI6TDVIWjpVN0JBOjJPNEc6NEFMMzpPRjJOOkpIR0I6RUZUSDo1Q1ZROk1GRU86QUVJVCIsCiAgICAgICAgICAgICAgICJraWQiOiAiSjdMRDo2N1ZSOkw1SFo6VTdCQToyTzRHOjRBTDM6T0YyTjpKSEdCOkVGVEg6NUNWUTpNRkVPOkFFSVQiLAogICAgICAgICAgICAgICAia3R5IjogIlJTQSIsCiAgICAgICAgICAgICAgICJuIjogInlkSXktbFU3bzdQY2VZLTQtcy1DUTVPRWdDeUY4Q3hJY1FJV3VLODRwSWlaY2lZNjczMHlDWW53TFNLVGx3LVU2VUNfUVJlV1Jpb01OTkU1RHM1VFlFWGJHRzZvbG0ycWRXYkJ3Y0NnLTJVVUhfT2NCOVd1UDZnUlBIcE1GTXN4RHpXd3ZheThKVXVIZ1lVTFVwbTFJdi1tcTdscDVuUV9SeHJUMEtaUkFRVFlMRU1FZkd3bTNoTU9fZ2VMUFMtaGdLUHRJSGxrZzZfV2NveFRHb0tQNzlkX3dhSFl4R05sN1doU25laUJTeGJwYlFBS2syMWxnNzk4WGI3dlp5RUFURE1yUlI5TWVFNkFkajVISnBZM0NveVJBUENtYUtHUkNLNHVvWlNvSXUwaEZWbEtVUHliYncwMDBHTy13YTJLTjhVd2dJSW0waTVJMXVXOUdrcTR6akJ5NXpoZ3F1VVhiRzliV1BBT1lycTVRYTgxRHhHY0JsSnlIWUFwLUREUEU5VEdnNHpZbVhqSm54WnFIRWR1R3FkZXZaOFhNSTB1a2ZrR0lJMTR3VU9pTUlJSXJYbEVjQmZfNDZJOGdRV0R6eHljWmVfSkdYLUxBdWF5WHJ5clVGZWhWTlVkWlVsOXdYTmFKQi1rYUNxejVRd2FSOTNzR3ctUVNmdEQwTnZMZTdDeU9ILUU2dmc2U3RfTmVUdmd2OFluaENpWElsWjhIT2ZJd05lN3RFRl9VY3o1T2JQeWttM3R5bHJOVWp0MFZ5QW10dGFjVkkyaUdpaGNVUHJtazRsVklaN1ZEX0xTVy1pN3lvU3VydHBzUFhjZTJwS0RJbzMwbEpHaE9fM0tVbWwyU1VaQ3F6SjF5RW1LcHlzSDVIRFc5Y3NJRkNBM2RlQWpmWlV2TjdVIgogICAgICAgICAgICB9LAogICAgICAgICAgICAiYWxnIjogIlJTMjU2IgogICAgICAgICB9LAogICAgICAgICAic2lnbmF0dXJlIjogIm5saTZIdzRrbW5KcTBSUmRXaGVfbkhZS2VJLVpKenM1U0d5SUpDakh1dWtnVzhBYklpVzFZYWJJR2NqWUt0QTY4dWN6T1hyUXZreGxWQXJLSlgzMDJzN0RpbzcxTlNPRzJVcnhsSjlibDFpd0F3a3ZyTEQ2T0p5MGxGLVg4WnRabXhPVmNQZmwzcmJwZFQ0dnlnWTdNcU1QRXdmb0IxTmlWZDYyZ1cxU2NSREZZcWw3R0FVaFVKNkp4QU15VzVaOXl5YVE0NV8wd0RMUk5mRjA5YWNXeVowTjRxVS1hZjhrUTZUUWZUX05ERzNCR3pRb2V3cHlEajRiMFBHb0diOFhLdDlwekpFdEdxM3lQM25VMFFBbk90a2gwTnZac1l1UFcyUnhDT3lRNEYzVlR3UkF2eF9HSTZrMVRpYmlKNnByUWluUy16Sjh6RE8zUjBuakE3OFBwNXcxcVpaUE9BdmtzZFNSYzJDcVMtcWhpTmF5YUhOVHpVNnpyOXlOZHR2S0o1QjNST0FmNUtjYXNiWURjTnVpeXBUNk90LUtqQ2I1dmYtWVpnc2FRNzJBdFBhSU4yeUpNREZHbmEwM0hpSjMxcTJRUlp5eTZrd3RYaGtwcDhTdEdIcHYxSWRaV09SVWttb0g5SFBzSGk4SExRLTZlM0tEY2x1RUQyMTNpZnljaVhtN0YzdHdaTTNHeDd1UXR1SldHaUlTZ2Z0QW9lVjZfUmI2VThkMmZxNzZuWHYxak5nckRRcE5waEZFd2tCdGRtZHZ2THByZVVYX3BWangza1AxN3pWbXFKNmNOOWkwWUc4WHg2VmRzcUxsRXUxQ2Rhd3Q0eko1M3VHMFlKTjRnUDZwc25yUS1uM0U1aFdlMDJ3d3dBZ3F3bGlPdmd4V1RTeXJyLXY2eDI0IiwKICAgICAgICAgInByb3RlY3RlZCI6ICJleUptYjNKdFlYUk1aVzVuZEdnaU9qRTNNeXdpWm05eWJXRjBWR0ZwYkNJNkltWlJJaXdpZEdsdFpTSTZJakl3TVRjdE1EVXRNRFZVTWpFNk5UYzZNek5hSW4wIgogICAgICB9CiAgIF0KfQ=="}` -) - -func TestActivateNoContainerd(t *testing.T) { - testCli.SetContainerizedEngineClient( - func(string) (clitypes.ContainerizedClient, error) { - return nil, fmt.Errorf("some error") - }, - ) - isRoot = func() bool { return true } - cmd := newActivateCommand(testCli) - cmd.Flags().Set("license", "invalidpath") - cmd.SilenceUsage = true - cmd.SilenceErrors = true - err := cmd.Execute() - assert.ErrorContains(t, err, "unable to access local containerd") -} - -func TestActivateBadLicense(t *testing.T) { - testCli.SetContainerizedEngineClient( - func(string) (clitypes.ContainerizedClient, error) { - return &fakeContainerizedEngineClient{}, nil - }, - ) - isRoot = func() bool { return true } - cmd := newActivateCommand(testCli) - cmd.SilenceUsage = true - cmd.SilenceErrors = true - cmd.Flags().Set("license", "invalidpath") - err := cmd.Execute() - assert.Error(t, err, "open invalidpath: no such file or directory") -} - -func TestActivateExpiredLicenseDryRun(t *testing.T) { - dir := fs.NewDir(t, "license", fs.WithFile("docker.lic", expiredLicense, fs.WithMode(0644))) - defer dir.Remove() - filename := dir.Join("docker.lic") - isRoot = func() bool { return true } - c := test.NewFakeCli(&verClient{client.Client{}, types.Version{}, nil, types.Info{}, nil}) - c.SetContainerizedEngineClient( - func(string) (clitypes.ContainerizedClient, error) { - return &fakeContainerizedEngineClient{}, nil - }, - ) - cmd := newActivateCommand(c) - cmd.SilenceUsage = true - cmd.SilenceErrors = true - cmd.Flags().Set("license", filename) - cmd.Flags().Set("display-only", "true") - c.OutBuffer().Reset() - err := cmd.Execute() - assert.NilError(t, err) - golden.Assert(t, c.OutBuffer().String(), "expired-license-display-only.golden") -} - -type mockLicenseClient struct{} - -func (c mockLicenseClient) LoginViaAuth(ctx context.Context, username, password string) (authToken string, err error) { - return "", fmt.Errorf("not implemented") -} - -func (c mockLicenseClient) GetHubUserOrgs(ctx context.Context, authToken string) (orgs []model.Org, err error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) GetHubUserByName(ctx context.Context, username string) (user *model.User, err error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) VerifyLicense(ctx context.Context, license model.IssuedLicense) (res *model.CheckResponse, err error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) GenerateNewTrialSubscription(ctx context.Context, authToken, dockerID string) (subscriptionID string, err error) { - return "", fmt.Errorf("not implemented") -} -func (c mockLicenseClient) ListSubscriptions(ctx context.Context, authToken, dockerID string) (response []*model.Subscription, err error) { - expires := time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC) - return []*model.Subscription{ - { - State: "active", - Expires: &expires, - }, - }, nil -} -func (c mockLicenseClient) ListSubscriptionsDetails(ctx context.Context, authToken, dockerID string) (response []*model.SubscriptionDetail, err error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) DownloadLicenseFromHub(ctx context.Context, authToken, subscriptionID string) (license *model.IssuedLicense, err error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) ParseLicense(license []byte) (parsedLicense *model.IssuedLicense, err error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) StoreLicense(ctx context.Context, dclnt licensing.WrappedDockerClient, licenses *model.IssuedLicense, localRootDir string) error { - return fmt.Errorf("not implemented") -} -func (c mockLicenseClient) LoadLocalLicense(ctx context.Context, dclnt licensing.WrappedDockerClient) (*model.Subscription, error) { - return nil, fmt.Errorf("not implemented") -} -func (c mockLicenseClient) SummarizeLicense(res *model.CheckResponse, keyID string) *model.Subscription { - return nil -} -func TestActivateDisplayOnlyHub(t *testing.T) { - isRoot = func() bool { return true } - c := test.NewFakeCli(&verClient{client.Client{}, types.Version{}, nil, types.Info{}, nil}) - c.SetContainerizedEngineClient( - func(string) (clitypes.ContainerizedClient, error) { - return &fakeContainerizedEngineClient{}, nil - }, - ) - - hubUser := licenseutils.HubUser{ - Client: mockLicenseClient{}, - } - options := activateOptions{ - licenseLoginFunc: func(ctx context.Context, authConfig *types.AuthConfig) (licenseutils.HubUser, error) { - return hubUser, nil - }, - displayOnly: true, - } - c.OutBuffer().Reset() - err := runActivate(c, options) - - assert.NilError(t, err) - golden.Assert(t, c.OutBuffer().String(), "expired-hub-license-display-only.golden") -}
  36. Download patch cli/cli/command/container/wait.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/wait.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/wait.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type waitOptions struct { - containers []string -} - -// NewWaitCommand creates a new cobra.Command for `docker wait` -func NewWaitCommand(dockerCli command.Cli) *cobra.Command { - var opts waitOptions - - cmd := &cobra.Command{ - Use: "wait CONTAINER [CONTAINER...]", - Short: "Block until one or more containers stop, then print their exit codes", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - return runWait(dockerCli, &opts) - }, - } - - return cmd -} - -func runWait(dockerCli command.Cli, opts *waitOptions) error { - ctx := context.Background() - - var errs []string - for _, container := range opts.containers { - resultC, errC := dockerCli.Client().ContainerWait(ctx, container, "") - - select { - case result := <-resultC: - fmt.Fprintf(dockerCli.Out(), "%d\n", result.StatusCode) - case err := <-errC: - errs = append(errs, err.Error()) - } - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  37. Download patch cli/cli/command/config/inspect.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/inspect.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/inspect.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -package config - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/formatter" - "github.com/spf13/cobra" -) - -type inspectOptions struct { - names []string - format string - pretty bool -} - -func newConfigInspectCommand(dockerCli command.Cli) *cobra.Command { - opts := inspectOptions{} - cmd := &cobra.Command{ - Use: "inspect [OPTIONS] CONFIG [CONFIG...]", - Short: "Display detailed information on one or more configs", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.names = args - return runConfigInspect(dockerCli, opts) - }, - } - - cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") - cmd.Flags().BoolVar(&opts.pretty, "pretty", false, "Print the information in a human friendly format") - return cmd -} - -func runConfigInspect(dockerCli command.Cli, opts inspectOptions) error { - client := dockerCli.Client() - ctx := context.Background() - - if opts.pretty { - opts.format = "pretty" - } - - getRef := func(id string) (interface{}, []byte, error) { - return client.ConfigInspectWithRaw(ctx, id) - } - f := opts.format - - // check if the user is trying to apply a template to the pretty format, which - // is not supported - if strings.HasPrefix(f, "pretty") && f != "pretty" { - return fmt.Errorf("Cannot supply extra formatting options to the pretty template") - } - - configCtx := formatter.Context{ - Output: dockerCli.Out(), - Format: formatter.NewConfigFormat(f, false), - } - - if err := formatter.ConfigInspectWrite(configCtx, opts.names, getRef); err != nil { - return cli.StatusError{StatusCode: 1, Status: err.Error()} - } - return nil - -}
  38. Download patch cli/cli/command/checkpoint/list.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/list.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/list.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -package checkpoint - -import ( - "context" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/formatter" - "github.com/docker/docker/api/types" - "github.com/spf13/cobra" -) - -type listOptions struct { - checkpointDir string -} - -func newListCommand(dockerCli command.Cli) *cobra.Command { - var opts listOptions - - cmd := &cobra.Command{ - Use: "ls [OPTIONS] CONTAINER", - Aliases: []string{"list"}, - Short: "List checkpoints for a container", - Args: cli.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return runList(dockerCli, args[0], opts) - }, - } - - flags := cmd.Flags() - flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory") - - return cmd - -} - -func runList(dockerCli command.Cli, container string, opts listOptions) error { - client := dockerCli.Client() - - listOpts := types.CheckpointListOptions{ - CheckpointDir: opts.checkpointDir, - } - - checkpoints, err := client.CheckpointList(context.Background(), container, listOpts) - if err != nil { - return err - } - - cpCtx := formatter.Context{ - Output: dockerCli.Out(), - Format: formatter.NewCheckpointFormat(formatter.TableFormatKey), - } - return formatter.CheckpointWrite(cpCtx, checkpoints) -}
  39. Download patch cli/cli/command/container/testdata/container-list-without-format-no-trunc.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/container-list-without-format-no-trunc.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/container-list-without-format-no-trunc.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -container_id busybox:latest "top" Less than a second ago Up 1 second c1 -container_id busybox:latest "top" Less than a second ago Up 1 second c2,foo/bar Binary files 18.09.5+dfsg1-1/cli/cli/command/container/testdata/utf16be.env and 18.09.8-0ubuntu3/cli/cli/command/container/testdata/utf16be.env differ Binary files 18.09.5+dfsg1-1/cli/cli/command/container/testdata/utf16.env and 18.09.8-0ubuntu3/cli/cli/command/container/testdata/utf16.env differ
  40. Download patch cli/cli/command/container/rm.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/rm.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/rm.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type rmOptions struct { - rmVolumes bool - rmLink bool - force bool - - containers []string -} - -// NewRmCommand creates a new cobra.Command for `docker rm` -func NewRmCommand(dockerCli command.Cli) *cobra.Command { - var opts rmOptions - - cmd := &cobra.Command{ - Use: "rm [OPTIONS] CONTAINER [CONTAINER...]", - Short: "Remove one or more containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - return runRm(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.BoolVarP(&opts.rmVolumes, "volumes", "v", false, "Remove the volumes associated with the container") - flags.BoolVarP(&opts.rmLink, "link", "l", false, "Remove the specified link") - flags.BoolVarP(&opts.force, "force", "f", false, "Force the removal of a running container (uses SIGKILL)") - return cmd -} - -func runRm(dockerCli command.Cli, opts *rmOptions) error { - ctx := context.Background() - - var errs []string - options := types.ContainerRemoveOptions{ - RemoveVolumes: opts.rmVolumes, - RemoveLinks: opts.rmLink, - Force: opts.force, - } - - errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error { - container = strings.Trim(container, "/") - if container == "" { - return errors.New("Container name cannot be empty") - } - return dockerCli.Client().ContainerRemove(ctx, container, options) - }) - - for _, name := range opts.containers { - if err := <-errChan; err != nil { - errs = append(errs, err.Error()) - continue - } - fmt.Fprintln(dockerCli.Out(), name) - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  41. Download patch cli/cli/command/container/logs.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/logs.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/logs.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -package container - -import ( - "context" - "io" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/docker/docker/pkg/stdcopy" - "github.com/spf13/cobra" -) - -type logsOptions struct { - follow bool - since string - until string - timestamps bool - details bool - tail string - - container string -} - -// NewLogsCommand creates a new cobra.Command for `docker logs` -func NewLogsCommand(dockerCli command.Cli) *cobra.Command { - var opts logsOptions - - cmd := &cobra.Command{ - Use: "logs [OPTIONS] CONTAINER", - Short: "Fetch the logs of a container", - Args: cli.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - return runLogs(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output") - flags.StringVar(&opts.since, "since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)") - flags.StringVar(&opts.until, "until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)") - flags.SetAnnotation("until", "version", []string{"1.35"}) - flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps") - flags.BoolVar(&opts.details, "details", false, "Show extra details provided to logs") - flags.StringVar(&opts.tail, "tail", "all", "Number of lines to show from the end of the logs") - return cmd -} - -func runLogs(dockerCli command.Cli, opts *logsOptions) error { - ctx := context.Background() - - options := types.ContainerLogsOptions{ - ShowStdout: true, - ShowStderr: true, - Since: opts.since, - Until: opts.until, - Timestamps: opts.timestamps, - Follow: opts.follow, - Tail: opts.tail, - Details: opts.details, - } - responseBody, err := dockerCli.Client().ContainerLogs(ctx, opts.container, options) - if err != nil { - return err - } - defer responseBody.Close() - - c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) - if err != nil { - return err - } - - if c.Config.Tty { - _, err = io.Copy(dockerCli.Out(), responseBody) - } else { - _, err = stdcopy.StdCopy(dockerCli.Out(), dockerCli.Err(), responseBody) - } - return err -}
  42. Download patch cli/cli/command/engine/activate_unix.go

    --- 18.09.5+dfsg1-1/cli/cli/command/engine/activate_unix.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/engine/activate_unix.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// +build !windows - -package engine - -import ( - "golang.org/x/sys/unix" -) - -var ( - isRoot = func() bool { - return unix.Geteuid() == 0 - } -)
  43. Download patch cli/cli/command/container/testdata/container-list-with-format.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/container-list-with-format.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/container-list-with-format.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -c1 busybox:latest some.label=value -c2 busybox:latest foo=bar
  44. Download patch cli/cli/command/container/port.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/port.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/port.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/go-connections/nat" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type portOptions struct { - container string - - port string -} - -// NewPortCommand creates a new cobra.Command for `docker port` -func NewPortCommand(dockerCli command.Cli) *cobra.Command { - var opts portOptions - - cmd := &cobra.Command{ - Use: "port CONTAINER [PRIVATE_PORT[/PROTO]]", - Short: "List port mappings or a specific mapping for the container", - Args: cli.RequiresRangeArgs(1, 2), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - if len(args) > 1 { - opts.port = args[1] - } - return runPort(dockerCli, &opts) - }, - } - return cmd -} - -func runPort(dockerCli command.Cli, opts *portOptions) error { - ctx := context.Background() - - c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) - if err != nil { - return err - } - - if opts.port != "" { - port := opts.port - proto := "tcp" - parts := strings.SplitN(port, "/", 2) - - if len(parts) == 2 && len(parts[1]) != 0 { - port = parts[0] - proto = parts[1] - } - natPort := port + "/" + proto - newP, err := nat.NewPort(proto, port) - if err != nil { - return err - } - if frontends, exists := c.NetworkSettings.Ports[newP]; exists && frontends != nil { - for _, frontend := range frontends { - fmt.Fprintf(dockerCli.Out(), "%s:%s\n", frontend.HostIP, frontend.HostPort) - } - return nil - } - return errors.Errorf("Error: No public port '%s' published for %s", natPort, opts.container) - } - - for from, frontends := range c.NetworkSettings.Ports { - for _, frontend := range frontends { - fmt.Fprintf(dockerCli.Out(), "%s -> %s:%s\n", from, frontend.HostIP, frontend.HostPort) - } - } - - return nil -}
  45. Download patch cli/cli/command/container/opts.go
  46. Download patch cli/cli/command/config/testdata/config-list-sort.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-list-sort.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-list-sort.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -ID NAME CREATED UPDATED -ID-1-foo 1-foo 2 hours ago About an hour ago -ID-2-foo 2-foo 2 hours ago About an hour ago -ID-10-foo 10-foo 2 hours ago About an hour ago
  47. Download patch cli/cli/command/container/update.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/update.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/update.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/opts" - containertypes "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type updateOptions struct { - blkioWeight uint16 - cpuPeriod int64 - cpuQuota int64 - cpuRealtimePeriod int64 - cpuRealtimeRuntime int64 - cpusetCpus string - cpusetMems string - cpuShares int64 - memory opts.MemBytes - memoryReservation opts.MemBytes - memorySwap opts.MemSwapBytes - kernelMemory opts.MemBytes - restartPolicy string - cpus opts.NanoCPUs - - nFlag int - - containers []string -} - -// NewUpdateCommand creates a new cobra.Command for `docker update` -func NewUpdateCommand(dockerCli command.Cli) *cobra.Command { - var options updateOptions - - cmd := &cobra.Command{ - Use: "update [OPTIONS] CONTAINER [CONTAINER...]", - Short: "Update configuration of one or more containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - options.containers = args - options.nFlag = cmd.Flags().NFlag() - return runUpdate(dockerCli, &options) - }, - } - - flags := cmd.Flags() - flags.Uint16Var(&options.blkioWeight, "blkio-weight", 0, "Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)") - flags.Int64Var(&options.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period") - flags.Int64Var(&options.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota") - flags.Int64Var(&options.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds") - flags.SetAnnotation("cpu-rt-period", "version", []string{"1.25"}) - flags.Int64Var(&options.cpuRealtimeRuntime, "cpu-rt-runtime", 0, "Limit the CPU real-time runtime in microseconds") - flags.SetAnnotation("cpu-rt-runtime", "version", []string{"1.25"}) - flags.StringVar(&options.cpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)") - flags.StringVar(&options.cpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)") - flags.Int64VarP(&options.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)") - flags.VarP(&options.memory, "memory", "m", "Memory limit") - flags.Var(&options.memoryReservation, "memory-reservation", "Memory soft limit") - flags.Var(&options.memorySwap, "memory-swap", "Swap limit equal to memory plus swap: '-1' to enable unlimited swap") - flags.Var(&options.kernelMemory, "kernel-memory", "Kernel memory limit") - flags.StringVar(&options.restartPolicy, "restart", "", "Restart policy to apply when a container exits") - - flags.Var(&options.cpus, "cpus", "Number of CPUs") - flags.SetAnnotation("cpus", "version", []string{"1.29"}) - - return cmd -} - -func runUpdate(dockerCli command.Cli, options *updateOptions) error { - var err error - - if options.nFlag == 0 { - return errors.New("you must provide one or more flags when using this command") - } - - var restartPolicy containertypes.RestartPolicy - if options.restartPolicy != "" { - restartPolicy, err = opts.ParseRestartPolicy(options.restartPolicy) - if err != nil { - return err - } - } - - resources := containertypes.Resources{ - BlkioWeight: options.blkioWeight, - CpusetCpus: options.cpusetCpus, - CpusetMems: options.cpusetMems, - CPUShares: options.cpuShares, - Memory: options.memory.Value(), - MemoryReservation: options.memoryReservation.Value(), - MemorySwap: options.memorySwap.Value(), - KernelMemory: options.kernelMemory.Value(), - CPUPeriod: options.cpuPeriod, - CPUQuota: options.cpuQuota, - CPURealtimePeriod: options.cpuRealtimePeriod, - CPURealtimeRuntime: options.cpuRealtimeRuntime, - NanoCPUs: options.cpus.Value(), - } - - updateConfig := containertypes.UpdateConfig{ - Resources: resources, - RestartPolicy: restartPolicy, - } - - ctx := context.Background() - - var ( - warns []string - errs []string - ) - for _, container := range options.containers { - r, err := dockerCli.Client().ContainerUpdate(ctx, container, updateConfig) - if err != nil { - errs = append(errs, err.Error()) - } else { - fmt.Fprintln(dockerCli.Out(), container) - } - warns = append(warns, r.Warnings...) - } - if len(warns) > 0 { - fmt.Fprintln(dockerCli.Out(), strings.Join(warns, "\n")) - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  48. Download patch cli/cli/command/cli.go
  49. Download patch cli/cli/command/container/testdata/valid.env

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/valid.env 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/valid.env 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -ENV1=value1
  50. Download patch cli/cli/command/container/start.go
  51. Download patch cli/cli/command/container/run.go
  52. Download patch cli/cli/command/config/create_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/create_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/create_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -package config - -import ( - "io/ioutil" - "path/filepath" - "reflect" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" - "gotest.tools/golden" -) - -const configDataFile = "config-create-with-name.golden" - -func TestConfigCreateErrors(t *testing.T) { - testCases := []struct { - args []string - configCreateFunc func(swarm.ConfigSpec) (types.ConfigCreateResponse, error) - expectedError string - }{ - { - args: []string{"too_few"}, - expectedError: "requires exactly 2 arguments", - }, - {args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 2 arguments", - }, - { - args: []string{"name", filepath.Join("testdata", configDataFile)}, - configCreateFunc: func(configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { - return types.ConfigCreateResponse{}, errors.Errorf("error creating config") - }, - expectedError: "error creating config", - }, - } - for _, tc := range testCases { - cmd := newConfigCreateCommand( - test.NewFakeCli(&fakeClient{ - configCreateFunc: tc.configCreateFunc, - }), - ) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestConfigCreateWithName(t *testing.T) { - name := "foo" - var actual []byte - cli := test.NewFakeCli(&fakeClient{ - configCreateFunc: func(spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { - if spec.Name != name { - return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) - } - - actual = spec.Data - - return types.ConfigCreateResponse{ - ID: "ID-" + spec.Name, - }, nil - }, - }) - - cmd := newConfigCreateCommand(cli) - cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)}) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, string(actual), configDataFile) - assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) -} - -func TestConfigCreateWithLabels(t *testing.T) { - expectedLabels := map[string]string{ - "lbl1": "Label-foo", - "lbl2": "Label-bar", - } - name := "foo" - - data, err := ioutil.ReadFile(filepath.Join("testdata", configDataFile)) - assert.NilError(t, err) - - expected := swarm.ConfigSpec{ - Annotations: swarm.Annotations{ - Name: name, - Labels: expectedLabels, - }, - Data: data, - } - - cli := test.NewFakeCli(&fakeClient{ - configCreateFunc: func(spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { - if !reflect.DeepEqual(spec, expected) { - return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec) - } - - return types.ConfigCreateResponse{ - ID: "ID-" + spec.Name, - }, nil - }, - }) - - cmd := newConfigCreateCommand(cli) - cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)}) - cmd.Flags().Set("label", "lbl1=Label-foo") - cmd.Flags().Set("label", "lbl2=Label-bar") - assert.NilError(t, cmd.Execute()) - assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) -} - -func TestConfigCreateWithTemplatingDriver(t *testing.T) { - expectedDriver := &swarm.Driver{ - Name: "template-driver", - } - name := "foo" - - cli := test.NewFakeCli(&fakeClient{ - configCreateFunc: func(spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { - if spec.Name != name { - return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) - } - - if spec.Templating.Name != expectedDriver.Name { - return types.ConfigCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) - } - - return types.ConfigCreateResponse{ - ID: "ID-" + spec.Name, - }, nil - }, - }) - - cmd := newConfigCreateCommand(cli) - cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)}) - cmd.Flags().Set("template-driver", expectedDriver.Name) - assert.NilError(t, cmd.Execute()) - assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) -}
  53. Download patch cli/cli/command/container/testdata/container-list-format-with-arg.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/container-list-format-with-arg.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/container-list-format-with-arg.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -c1 value -c2
  54. Download patch cli/cli/command/container/rename.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/rename.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/rename.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type renameOptions struct { - oldName string - newName string -} - -// NewRenameCommand creates a new cobra.Command for `docker rename` -func NewRenameCommand(dockerCli command.Cli) *cobra.Command { - var opts renameOptions - - cmd := &cobra.Command{ - Use: "rename CONTAINER NEW_NAME", - Short: "Rename a container", - Args: cli.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - opts.oldName = args[0] - opts.newName = args[1] - return runRename(dockerCli, &opts) - }, - } - return cmd -} - -func runRename(dockerCli command.Cli, opts *renameOptions) error { - ctx := context.Background() - - oldName := strings.TrimSpace(opts.oldName) - newName := strings.TrimSpace(opts.newName) - - if oldName == "" || newName == "" { - return errors.New("Error: Neither old nor new names may be empty") - } - - if err := dockerCli.Client().ContainerRename(ctx, oldName, newName); err != nil { - fmt.Fprintln(dockerCli.Err(), err) - return errors.Errorf("Error: failed to rename container named %s", oldName) - } - return nil -}
  55. Download patch cli/circle.yml

    --- 18.09.5+dfsg1-1/cli/circle.yml 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/circle.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -version: 2 - -jobs: - - lint: - working_directory: /work - docker: [{image: 'docker:18.03-git'}] - steps: - - checkout - - setup_remote_docker: - version: 18.03.1-ce - reusable: true - exclusive: false - - run: - command: docker version - - run: - name: "Lint" - command: | - docker build -f dockerfiles/Dockerfile.lint --tag cli-linter:$CIRCLE_BUILD_NUM . - docker run --rm cli-linter:$CIRCLE_BUILD_NUM - - cross: - working_directory: /work - docker: [{image: 'docker:18.03-git'}] - parallelism: 3 - steps: - - checkout - - setup_remote_docker: - version: 18.03.1-ce - reusable: true - exclusive: false - - run: - name: "Cross" - command: | - docker build -f dockerfiles/Dockerfile.cross --tag cli-builder:$CIRCLE_BUILD_NUM . - name=cross-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX - docker run \ - -e CROSS_GROUP=$CIRCLE_NODE_INDEX \ - --name $name cli-builder:$CIRCLE_BUILD_NUM \ - make cross - docker cp \ - $name:/go/src/github.com/docker/cli/build \ - /work/build - - store_artifacts: - path: /work/build - - test: - working_directory: /work - docker: [{image: 'docker:18.03-git'}] - steps: - - checkout - - setup_remote_docker: - version: 18.03.1-ce - reusable: true - exclusive: false - - run: - name: "Unit Test with Coverage" - command: | - docker build -f dockerfiles/Dockerfile.dev --tag cli-builder:$CIRCLE_BUILD_NUM . - docker run --name \ - test-$CIRCLE_BUILD_NUM cli-builder:$CIRCLE_BUILD_NUM \ - make test-coverage - - - run: - name: "Upload to Codecov" - command: | - docker cp \ - test-$CIRCLE_BUILD_NUM:/go/src/github.com/docker/cli/coverage.txt \ - coverage.txt - apk add -U bash curl - curl -s https://codecov.io/bash | bash || \ - echo 'Codecov failed to upload' - - validate: - working_directory: /work - docker: [{image: 'docker:18.03-git'}] - steps: - - checkout - - setup_remote_docker: - version: 18.03.1-ce - reusable: true - exclusive: false - - run: - name: "Validate Vendor, Docs, and Code Generation" - command: | - rm -f .dockerignore # include .git - docker build -f dockerfiles/Dockerfile.dev --tag cli-builder-with-git:$CIRCLE_BUILD_NUM . - docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \ - make ci-validate - shellcheck: - working_directory: /work - docker: [{image: 'docker:18.03-git'}] - steps: - - checkout - - setup_remote_docker: - version: 18.03.1-ce - reusable: true - exclusive: false - - run: - name: "Run shellcheck" - command: | - docker build -f dockerfiles/Dockerfile.shellcheck --tag cli-validator:$CIRCLE_BUILD_NUM . - docker run --rm cli-validator:$CIRCLE_BUILD_NUM \ - make shellcheck -workflows: - version: 2 - ci: - jobs: - - lint - - cross - - test - - validate - - shellcheck
  56. Download patch CHANGELOG.md

    --- 18.09.5+dfsg1-1/CHANGELOG.md 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/CHANGELOG.md 2019-07-17 17:03:56.000000000 +0000 @@ -3,6 +3,48 @@ For official release notes for Docker Engine CE and Docker Engine EE, visit the [release notes page](https://docs.docker.com/engine/release-notes/). +## 18.09.8 (2019-07-17) + +### Client + +- Fix Rollback config type interpolation. [docker/cli#1973](https://github.com/docker/cli/pull/1973) + +### Runtime + +- Fix [CVE-2019-13509](https://nvd.nist.gov/vuln/detail/CVE-2019-13509) in DebugRequestMiddleware: unconditionally scrub data field. + +## 18.09.7 (2019-06-27) + +### Builder + +- Fix panic when building dockerfiles containing only comments. [moby/moby#38487](https://github.com/moby/moby/pull/38487) +- builder: add workaround for gcr auth issue. [moby/moby#38246](https://github.com/moby/moby/pull/38246) +- builder-next: fix gcr workaround token cache. [moby/moby#39183](https://github.com/moby/moby/pull/39183) + +### Runtime + +* Performance optimizations in aufs and layer store for massively parallel container creation/removal. [moby/moby#39107](https://github.com/moby/moby/pull/39107) +* Update to containerd 1.2.6. [moby/moby#39016](https://github.com/moby/moby/pull/39016) +- Fix: [CVE-2018-15664](https://nvd.nist.gov/vuln/detail/CVE-2018-15664) symlink-exchange attack with directory traversal. [moby/moby#39357](https://github.com/moby/moby/pull/39357) +- Windows: fix support for `docker service create --limit-cpu`. [moby/moby#39190](https://github.com/moby/moby/pull/39190) +- daemon: fix mirrors validation. [moby/moby#38991](https://github.com/moby/moby/pull/38991) +- Stop sorting uid and gid ranges in id maps. [moby/moby#39288](https://github.com/moby/moby/pull/39288) + +### Logging + +- Fix to allow large log lines for logger plugins. [moby/moby#39038](https://github.com/moby/moby/pull/39038) + +## 18.09.6 (2019-05-02) + +### Builder + +- Fix `COPY` and `ADD` with multiple `<src>` do not invalidate cache if `DOCKER_BUILDKIT=1`. [moby/moby#38964](https://github.com/moby/moby/issues/38964) + +### Networking + +- Cleanup the cluster provider when the agent is closed. [docker/libnetwork#2354](https://github.com/docker/libnetwork/pull/2354) +- Windows: pick a random host port if the user does not specify a host port. [docker/libnetwork#2369](https://github.com/docker/libnetwork/pull/2369) + ## 18.09.5 (2019-04-11) ### Builder
  57. Download patch cli/cli/command/container/export.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/export.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/export.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -package container - -import ( - "context" - "io" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type exportOptions struct { - container string - output string -} - -// NewExportCommand creates a new `docker export` command -func NewExportCommand(dockerCli command.Cli) *cobra.Command { - var opts exportOptions - - cmd := &cobra.Command{ - Use: "export [OPTIONS] CONTAINER", - Short: "Export a container's filesystem as a tar archive", - Args: cli.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - return runExport(dockerCli, opts) - }, - } - - flags := cmd.Flags() - - flags.StringVarP(&opts.output, "output", "o", "", "Write to a file, instead of STDOUT") - - return cmd -} - -func runExport(dockerCli command.Cli, opts exportOptions) error { - if opts.output == "" && dockerCli.Out().IsTerminal() { - return errors.New("cowardly refusing to save to a terminal. Use the -o flag or redirect") - } - - clnt := dockerCli.Client() - - responseBody, err := clnt.ContainerExport(context.Background(), opts.container) - if err != nil { - return err - } - defer responseBody.Close() - - if opts.output == "" { - _, err := io.Copy(dockerCli.Out(), responseBody) - return err - } - - return command.CopyToFile(opts.output, responseBody) -}
  58. Download patch cli/cli/command/container/cp.go
  59. Download patch cli/cli/command/container/testdata/utf8.env

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/utf8.env 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/utf8.env 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -FOO=BAR -HELLO=您好 -BAR=FOO \ No newline at end of file
  60. Download patch cli/cli/command/config/testdata/config-list-with-filter.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-list-with-filter.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-list-with-filter.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -ID NAME CREATED UPDATED -ID-bar bar 2 hours ago About an hour ago -ID-foo foo 2 hours ago About an hour ago
  61. Download patch cli/cli/command/config/remove.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/remove.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/remove.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -package config - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type removeOptions struct { - names []string -} - -func newConfigRemoveCommand(dockerCli command.Cli) *cobra.Command { - return &cobra.Command{ - Use: "rm CONFIG [CONFIG...]", - Aliases: []string{"remove"}, - Short: "Remove one or more configs", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts := removeOptions{ - names: args, - } - return runConfigRemove(dockerCli, opts) - }, - } -} - -func runConfigRemove(dockerCli command.Cli, opts removeOptions) error { - client := dockerCli.Client() - ctx := context.Background() - - var errs []string - - for _, name := range opts.names { - if err := client.ConfigRemove(ctx, name); err != nil { - errs = append(errs, err.Error()) - continue - } - - fmt.Fprintln(dockerCli.Out(), name) - } - - if len(errs) > 0 { - return errors.Errorf("%s", strings.Join(errs, "\n")) - } - - return nil -}
  62. Download patch cli/cli/command/config/testdata/config-create-with-name.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-create-with-name.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-create-with-name.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -config_foo_bar
  63. Download patch cli/cli/command/container/cp_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/cp_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/cp_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ -package container - -import ( - "io" - "io/ioutil" - "os" - "runtime" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/docker/docker/pkg/archive" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" - "gotest.tools/fs" - "gotest.tools/skip" -) - -func TestRunCopyWithInvalidArguments(t *testing.T) { - var testcases = []struct { - doc string - options copyOptions - expectedErr string - }{ - { - doc: "copy between container", - options: copyOptions{ - source: "first:/path", - destination: "second:/path", - }, - expectedErr: "copying between containers is not supported", - }, - { - doc: "copy without a container", - options: copyOptions{ - source: "./source", - destination: "./dest", - }, - expectedErr: "must specify at least one container source", - }, - } - for _, testcase := range testcases { - t.Run(testcase.doc, func(t *testing.T) { - err := runCopy(test.NewFakeCli(nil), testcase.options) - assert.Error(t, err, testcase.expectedErr) - }) - } -} - -func TestRunCopyFromContainerToStdout(t *testing.T) { - tarContent := "the tar content" - - fakeClient := &fakeClient{ - containerCopyFromFunc: func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { - assert.Check(t, is.Equal("container", container)) - return ioutil.NopCloser(strings.NewReader(tarContent)), types.ContainerPathStat{}, nil - }, - } - options := copyOptions{source: "container:/path", destination: "-"} - cli := test.NewFakeCli(fakeClient) - err := runCopy(cli, options) - assert.NilError(t, err) - assert.Check(t, is.Equal(tarContent, cli.OutBuffer().String())) - assert.Check(t, is.Equal("", cli.ErrBuffer().String())) -} - -func TestRunCopyFromContainerToFilesystem(t *testing.T) { - destDir := fs.NewDir(t, "cp-test", - fs.WithFile("file1", "content\n")) - defer destDir.Remove() - - fakeClient := &fakeClient{ - containerCopyFromFunc: func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { - assert.Check(t, is.Equal("container", container)) - readCloser, err := archive.TarWithOptions(destDir.Path(), &archive.TarOptions{}) - return readCloser, types.ContainerPathStat{}, err - }, - } - options := copyOptions{source: "container:/path", destination: destDir.Path()} - cli := test.NewFakeCli(fakeClient) - err := runCopy(cli, options) - assert.NilError(t, err) - assert.Check(t, is.Equal("", cli.OutBuffer().String())) - assert.Check(t, is.Equal("", cli.ErrBuffer().String())) - - content, err := ioutil.ReadFile(destDir.Join("file1")) - assert.NilError(t, err) - assert.Check(t, is.Equal("content\n", string(content))) -} - -func TestRunCopyFromContainerToFilesystemMissingDestinationDirectory(t *testing.T) { - destDir := fs.NewDir(t, "cp-test", - fs.WithFile("file1", "content\n")) - defer destDir.Remove() - - fakeClient := &fakeClient{ - containerCopyFromFunc: func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { - assert.Check(t, is.Equal("container", container)) - readCloser, err := archive.TarWithOptions(destDir.Path(), &archive.TarOptions{}) - return readCloser, types.ContainerPathStat{}, err - }, - } - - options := copyOptions{ - source: "container:/path", - destination: destDir.Join("missing", "foo"), - } - cli := test.NewFakeCli(fakeClient) - err := runCopy(cli, options) - assert.ErrorContains(t, err, destDir.Join("missing")) -} - -func TestRunCopyToContainerFromFileWithTrailingSlash(t *testing.T) { - srcFile := fs.NewFile(t, t.Name()) - defer srcFile.Remove() - - options := copyOptions{ - source: srcFile.Path() + string(os.PathSeparator), - destination: "container:/path", - } - cli := test.NewFakeCli(&fakeClient{}) - err := runCopy(cli, options) - - expectedError := "not a directory" - if runtime.GOOS == "windows" { - expectedError = "The filename, directory name, or volume label syntax is incorrect" - } - assert.ErrorContains(t, err, expectedError) -} - -func TestRunCopyToContainerSourceDoesNotExist(t *testing.T) { - options := copyOptions{ - source: "/does/not/exist", - destination: "container:/path", - } - cli := test.NewFakeCli(&fakeClient{}) - err := runCopy(cli, options) - expected := "no such file or directory" - if runtime.GOOS == "windows" { - expected = "cannot find the file specified" - } - assert.ErrorContains(t, err, expected) -} - -func TestSplitCpArg(t *testing.T) { - var testcases = []struct { - doc string - path string - os string - expectedContainer string - expectedPath string - }{ - { - doc: "absolute path with colon", - os: "linux", - path: "/abs/path:withcolon", - expectedPath: "/abs/path:withcolon", - }, - { - doc: "relative path with colon", - path: "./relative:path", - expectedPath: "./relative:path", - }, - { - doc: "absolute path with drive", - os: "windows", - path: `d:\abs\path`, - expectedPath: `d:\abs\path`, - }, - { - doc: "no separator", - path: "relative/path", - expectedPath: "relative/path", - }, - { - doc: "with separator", - path: "container:/opt/foo", - expectedPath: "/opt/foo", - expectedContainer: "container", - }, - } - for _, testcase := range testcases { - t.Run(testcase.doc, func(t *testing.T) { - skip.If(t, testcase.os != "" && testcase.os != runtime.GOOS) - - container, path := splitCpArg(testcase.path) - assert.Check(t, is.Equal(testcase.expectedContainer, container)) - assert.Check(t, is.Equal(testcase.expectedPath, path)) - }) - } -}
  64. Download patch cli/cli/command/container/attach.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/attach.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/attach.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ -package container - -import ( - "context" - "fmt" - "io" - "net/http/httputil" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/signal" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" -) - -type attachOptions struct { - noStdin bool - proxy bool - detachKeys string - - container string -} - -func inspectContainerAndCheckState(ctx context.Context, cli client.APIClient, args string) (*types.ContainerJSON, error) { - c, err := cli.ContainerInspect(ctx, args) - if err != nil { - return nil, err - } - if !c.State.Running { - return nil, errors.New("You cannot attach to a stopped container, start it first") - } - if c.State.Paused { - return nil, errors.New("You cannot attach to a paused container, unpause it first") - } - if c.State.Restarting { - return nil, errors.New("You cannot attach to a restarting container, wait until it is running") - } - - return &c, nil -} - -// NewAttachCommand creates a new cobra.Command for `docker attach` -func NewAttachCommand(dockerCli command.Cli) *cobra.Command { - var opts attachOptions - - cmd := &cobra.Command{ - Use: "attach [OPTIONS] CONTAINER", - Short: "Attach local standard input, output, and error streams to a running container", - Args: cli.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - return runAttach(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.BoolVar(&opts.noStdin, "no-stdin", false, "Do not attach STDIN") - flags.BoolVar(&opts.proxy, "sig-proxy", true, "Proxy all received signals to the process") - flags.StringVar(&opts.detachKeys, "detach-keys", "", "Override the key sequence for detaching a container") - return cmd -} - -func runAttach(dockerCli command.Cli, opts *attachOptions) error { - ctx := context.Background() - client := dockerCli.Client() - - // request channel to wait for client - resultC, errC := client.ContainerWait(ctx, opts.container, "") - - c, err := inspectContainerAndCheckState(ctx, client, opts.container) - if err != nil { - return err - } - - if err := dockerCli.In().CheckTty(!opts.noStdin, c.Config.Tty); err != nil { - return err - } - - if opts.detachKeys != "" { - dockerCli.ConfigFile().DetachKeys = opts.detachKeys - } - - options := types.ContainerAttachOptions{ - Stream: true, - Stdin: !opts.noStdin && c.Config.OpenStdin, - Stdout: true, - Stderr: true, - DetachKeys: dockerCli.ConfigFile().DetachKeys, - } - - var in io.ReadCloser - if options.Stdin { - in = dockerCli.In() - } - - if opts.proxy && !c.Config.Tty { - sigc := ForwardAllSignals(ctx, dockerCli, opts.container) - defer signal.StopCatch(sigc) - } - - resp, errAttach := client.ContainerAttach(ctx, opts.container, options) - if errAttach != nil && errAttach != httputil.ErrPersistEOF { - // ContainerAttach returns an ErrPersistEOF (connection closed) - // means server met an error and put it in Hijacked connection - // keep the error and read detailed error message from hijacked connection later - return errAttach - } - defer resp.Close() - - // If use docker attach command to attach to a stop container, it will return - // "You cannot attach to a stopped container" error, it's ok, but when - // attach to a running container, it(docker attach) use inspect to check - // the container's state, if it pass the state check on the client side, - // and then the container is stopped, docker attach command still attach to - // the container and not exit. - // - // Recheck the container's state to avoid attach block. - _, err = inspectContainerAndCheckState(ctx, client, opts.container) - if err != nil { - return err - } - - if c.Config.Tty && dockerCli.Out().IsTerminal() { - resizeTTY(ctx, dockerCli, opts.container) - } - - streamer := hijackedIOStreamer{ - streams: dockerCli, - inputStream: in, - outputStream: dockerCli.Out(), - errorStream: dockerCli.Err(), - resp: resp, - tty: c.Config.Tty, - detachKeys: options.DetachKeys, - } - - if err := streamer.stream(ctx); err != nil { - return err - } - - if errAttach != nil { - return errAttach - } - - return getExitStatus(errC, resultC) -} - -func getExitStatus(errC <-chan error, resultC <-chan container.ContainerWaitOKBody) error { - select { - case result := <-resultC: - if result.Error != nil { - return fmt.Errorf(result.Error.Message) - } - if result.StatusCode != 0 { - return cli.StatusError{StatusCode: int(result.StatusCode)} - } - case err := <-errC: - return err - } - - return nil -} - -func resizeTTY(ctx context.Context, dockerCli command.Cli, containerID string) { - height, width := dockerCli.Out().GetTtySize() - // To handle the case where a user repeatedly attaches/detaches without resizing their - // terminal, the only way to get the shell prompt to display for attaches 2+ is to artificially - // resize it, then go back to normal. Without this, every attach after the first will - // require the user to manually resize or hit enter. - resizeTtyTo(ctx, dockerCli.Client(), containerID, height+1, width+1, false) - - // After the above resizing occurs, the call to MonitorTtySize below will handle resetting back - // to the actual size. - if err := MonitorTtySize(ctx, dockerCli, containerID, false); err != nil { - logrus.Debugf("Error monitoring TTY size: %s", err) - } -}
  65. Download patch cli/cli/command/config/testdata/config-inspect-without-format.multiple-configs-with-labels.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-inspect-without-format.multiple-configs-with-labels.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-inspect-without-format.multiple-configs-with-labels.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -[ - { - "ID": "ID-foo", - "Version": {}, - "CreatedAt": "0001-01-01T00:00:00Z", - "UpdatedAt": "0001-01-01T00:00:00Z", - "Spec": { - "Name": "foo", - "Labels": { - "label1": "label-foo" - } - } - }, - { - "ID": "ID-bar", - "Version": {}, - "CreatedAt": "0001-01-01T00:00:00Z", - "UpdatedAt": "0001-01-01T00:00:00Z", - "Spec": { - "Name": "bar", - "Labels": { - "label1": "label-foo" - } - } - } -]
  66. Download patch cli/cli/command/checkpoint/client_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/checkpoint/client_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/checkpoint/client_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -package checkpoint - -import ( - "context" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/client" -) - -type fakeClient struct { - client.Client - checkpointCreateFunc func(container string, options types.CheckpointCreateOptions) error - checkpointDeleteFunc func(container string, options types.CheckpointDeleteOptions) error - checkpointListFunc func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) -} - -func (cli *fakeClient) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error { - if cli.checkpointCreateFunc != nil { - return cli.checkpointCreateFunc(container, options) - } - return nil -} - -func (cli *fakeClient) CheckpointDelete(ctx context.Context, container string, options types.CheckpointDeleteOptions) error { - if cli.checkpointDeleteFunc != nil { - return cli.checkpointDeleteFunc(container, options) - } - return nil -} - -func (cli *fakeClient) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { - if cli.checkpointListFunc != nil { - return cli.checkpointListFunc(container, options) - } - return []types.Checkpoint{}, nil -}
  67. Download patch cli/cli/command/container/tty_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/tty_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/tty_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -package container - -import ( - "context" - "testing" - "time" - - "github.com/docker/cli/cli/command" - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestInitTtySizeErrors(t *testing.T) { - expectedError := "failed to resize tty, using default size\n" - fakeContainerExecResizeFunc := func(id string, options types.ResizeOptions) error { - return errors.Errorf("Error response from daemon: no such exec") - } - fakeResizeTtyFunc := func(ctx context.Context, cli command.Cli, id string, isExec bool) error { - height, width := uint(1024), uint(768) - return resizeTtyTo(ctx, cli.Client(), id, height, width, isExec) - } - ctx := context.Background() - cli := test.NewFakeCli(&fakeClient{containerExecResizeFunc: fakeContainerExecResizeFunc}) - initTtySize(ctx, cli, "8mm8nn8tt8bb", true, fakeResizeTtyFunc) - time.Sleep(100 * time.Millisecond) - assert.Check(t, is.Equal(expectedError, cli.ErrBuffer().String())) -}
  68. Download patch cli/cli/command/config/ls_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/ls_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/ls_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ -package config - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/docker/cli/cli/config/configfile" - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" - // Import builders to get the builder function as package function - . "github.com/docker/cli/internal/test/builders" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" - "gotest.tools/golden" -) - -func TestConfigListErrors(t *testing.T) { - testCases := []struct { - args []string - configListFunc func(types.ConfigListOptions) ([]swarm.Config, error) - expectedError string - }{ - { - args: []string{"foo"}, - expectedError: "accepts no argument", - }, - { - configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { - return []swarm.Config{}, errors.Errorf("error listing configs") - }, - expectedError: "error listing configs", - }, - } - for _, tc := range testCases { - cmd := newConfigListCommand( - test.NewFakeCli(&fakeClient{ - configListFunc: tc.configListFunc, - }), - ) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestConfigList(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { - return []swarm.Config{ - *Config(ConfigID("ID-1-foo"), - ConfigName("1-foo"), - ConfigVersion(swarm.Version{Index: 10}), - ConfigCreatedAt(time.Now().Add(-2*time.Hour)), - ConfigUpdatedAt(time.Now().Add(-1*time.Hour)), - ), - *Config(ConfigID("ID-10-foo"), - ConfigName("10-foo"), - ConfigVersion(swarm.Version{Index: 11}), - ConfigCreatedAt(time.Now().Add(-2*time.Hour)), - ConfigUpdatedAt(time.Now().Add(-1*time.Hour)), - ), - *Config(ConfigID("ID-2-foo"), - ConfigName("2-foo"), - ConfigVersion(swarm.Version{Index: 11}), - ConfigCreatedAt(time.Now().Add(-2*time.Hour)), - ConfigUpdatedAt(time.Now().Add(-1*time.Hour)), - ), - }, nil - }, - }) - cmd := newConfigListCommand(cli) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "config-list-sort.golden") -} - -func TestConfigListWithQuietOption(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { - return []swarm.Config{ - *Config(ConfigID("ID-foo"), ConfigName("foo")), - *Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{ - "label": "label-bar", - })), - }, nil - }, - }) - cmd := newConfigListCommand(cli) - cmd.Flags().Set("quiet", "true") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "config-list-with-quiet-option.golden") -} - -func TestConfigListWithConfigFormat(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { - return []swarm.Config{ - *Config(ConfigID("ID-foo"), ConfigName("foo")), - *Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{ - "label": "label-bar", - })), - }, nil - }, - }) - cli.SetConfigFile(&configfile.ConfigFile{ - ConfigFormat: "{{ .Name }} {{ .Labels }}", - }) - cmd := newConfigListCommand(cli) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "config-list-with-config-format.golden") -} - -func TestConfigListWithFormat(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { - return []swarm.Config{ - *Config(ConfigID("ID-foo"), ConfigName("foo")), - *Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{ - "label": "label-bar", - })), - }, nil - }, - }) - cmd := newConfigListCommand(cli) - cmd.Flags().Set("format", "{{ .Name }} {{ .Labels }}") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "config-list-with-format.golden") -} - -func TestConfigListWithFilter(t *testing.T) { - cli := test.NewFakeCli(&fakeClient{ - configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { - assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0])) - assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0])) - return []swarm.Config{ - *Config(ConfigID("ID-foo"), - ConfigName("foo"), - ConfigVersion(swarm.Version{Index: 10}), - ConfigCreatedAt(time.Now().Add(-2*time.Hour)), - ConfigUpdatedAt(time.Now().Add(-1*time.Hour)), - ), - *Config(ConfigID("ID-bar"), - ConfigName("bar"), - ConfigVersion(swarm.Version{Index: 11}), - ConfigCreatedAt(time.Now().Add(-2*time.Hour)), - ConfigUpdatedAt(time.Now().Add(-1*time.Hour)), - ), - }, nil - }, - }) - cmd := newConfigListCommand(cli) - cmd.Flags().Set("filter", "name=foo") - cmd.Flags().Set("filter", "label=lbl1=Label-bar") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), "config-list-with-filter.golden") -}
  69. Download patch cli/cli/command/bundlefile/bundlefile.go

    --- 18.09.5+dfsg1-1/cli/cli/command/bundlefile/bundlefile.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/bundlefile/bundlefile.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -package bundlefile - -import ( - "encoding/json" - "io" - - "github.com/pkg/errors" -) - -// Bundlefile stores the contents of a bundlefile -type Bundlefile struct { - Version string - Services map[string]Service -} - -// Service is a service from a bundlefile -type Service struct { - Image string - Command []string `json:",omitempty"` - Args []string `json:",omitempty"` - Env []string `json:",omitempty"` - Labels map[string]string `json:",omitempty"` - Ports []Port `json:",omitempty"` - WorkingDir *string `json:",omitempty"` - User *string `json:",omitempty"` - Networks []string `json:",omitempty"` -} - -// Port is a port as defined in a bundlefile -type Port struct { - Protocol string - Port uint32 -} - -// LoadFile loads a bundlefile from a path to the file -func LoadFile(reader io.Reader) (*Bundlefile, error) { - bundlefile := &Bundlefile{} - - decoder := json.NewDecoder(reader) - if err := decoder.Decode(bundlefile); err != nil { - switch jsonErr := err.(type) { - case *json.SyntaxError: - return nil, errors.Errorf( - "JSON syntax error at byte %v: %s", - jsonErr.Offset, - jsonErr.Error()) - case *json.UnmarshalTypeError: - return nil, errors.Errorf( - "Unexpected type at byte %v. Expected %s but received %s.", - jsonErr.Offset, - jsonErr.Type, - jsonErr.Value) - } - return nil, err - } - - return bundlefile, nil -} - -// Print writes the contents of the bundlefile to the output writer -// as human readable json -func Print(out io.Writer, bundle *Bundlefile) error { - bytes, err := json.MarshalIndent(*bundle, "", " ") - if err != nil { - return err - } - - _, err = out.Write(bytes) - return err -}
  70. Download patch cli/cli/command/container/testdata/valid.label

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/valid.label 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/valid.label 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -LABEL1=value1
  71. Download patch cli/cli/command/config/inspect_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/inspect_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/inspect_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -package config - -import ( - "fmt" - "io/ioutil" - "testing" - "time" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" - // Import builders to get the builder function as package function - . "github.com/docker/cli/internal/test/builders" - "gotest.tools/assert" - "gotest.tools/golden" -) - -func TestConfigInspectErrors(t *testing.T) { - testCases := []struct { - args []string - flags map[string]string - configInspectFunc func(configID string) (swarm.Config, []byte, error) - expectedError string - }{ - { - expectedError: "requires at least 1 argument", - }, - { - args: []string{"foo"}, - configInspectFunc: func(configID string) (swarm.Config, []byte, error) { - return swarm.Config{}, nil, errors.Errorf("error while inspecting the config") - }, - expectedError: "error while inspecting the config", - }, - { - args: []string{"foo"}, - flags: map[string]string{ - "format": "{{invalid format}}", - }, - expectedError: "Template parsing error", - }, - { - args: []string{"foo", "bar"}, - configInspectFunc: func(configID string) (swarm.Config, []byte, error) { - if configID == "foo" { - return *Config(ConfigName("foo")), nil, nil - } - return swarm.Config{}, nil, errors.Errorf("error while inspecting the config") - }, - expectedError: "error while inspecting the config", - }, - } - for _, tc := range testCases { - cmd := newConfigInspectCommand( - test.NewFakeCli(&fakeClient{ - configInspectFunc: tc.configInspectFunc, - }), - ) - cmd.SetArgs(tc.args) - for key, value := range tc.flags { - cmd.Flags().Set(key, value) - } - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestConfigInspectWithoutFormat(t *testing.T) { - testCases := []struct { - name string - args []string - configInspectFunc func(configID string) (swarm.Config, []byte, error) - }{ - { - name: "single-config", - args: []string{"foo"}, - configInspectFunc: func(name string) (swarm.Config, []byte, error) { - if name != "foo" { - return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name) - } - return *Config(ConfigID("ID-foo"), ConfigName("foo")), nil, nil - }, - }, - { - name: "multiple-configs-with-labels", - args: []string{"foo", "bar"}, - configInspectFunc: func(name string) (swarm.Config, []byte, error) { - return *Config(ConfigID("ID-"+name), ConfigName(name), ConfigLabels(map[string]string{ - "label1": "label-foo", - })), nil, nil - }, - }, - } - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{configInspectFunc: tc.configInspectFunc}) - cmd := newConfigInspectCommand(cli) - cmd.SetArgs(tc.args) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-without-format.%s.golden", tc.name)) - } -} - -func TestConfigInspectWithFormat(t *testing.T) { - configInspectFunc := func(name string) (swarm.Config, []byte, error) { - return *Config(ConfigName("foo"), ConfigLabels(map[string]string{ - "label1": "label-foo", - })), nil, nil - } - testCases := []struct { - name string - format string - args []string - configInspectFunc func(name string) (swarm.Config, []byte, error) - }{ - { - name: "simple-template", - format: "{{.Spec.Name}}", - args: []string{"foo"}, - configInspectFunc: configInspectFunc, - }, - { - name: "json-template", - format: "{{json .Spec.Labels}}", - args: []string{"foo"}, - configInspectFunc: configInspectFunc, - }, - } - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - configInspectFunc: tc.configInspectFunc, - }) - cmd := newConfigInspectCommand(cli) - cmd.SetArgs(tc.args) - cmd.Flags().Set("format", tc.format) - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-with-format.%s.golden", tc.name)) - } -} - -func TestConfigInspectPretty(t *testing.T) { - testCases := []struct { - name string - configInspectFunc func(string) (swarm.Config, []byte, error) - }{ - { - name: "simple", - configInspectFunc: func(id string) (swarm.Config, []byte, error) { - return *Config( - ConfigLabels(map[string]string{ - "lbl1": "value1", - }), - ConfigID("configID"), - ConfigName("configName"), - ConfigCreatedAt(time.Time{}), - ConfigUpdatedAt(time.Time{}), - ConfigData([]byte("payload here")), - ), []byte{}, nil - }, - }, - } - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - configInspectFunc: tc.configInspectFunc, - }) - cmd := newConfigInspectCommand(cli) - - cmd.SetArgs([]string{"configID"}) - cmd.Flags().Set("pretty", "true") - assert.NilError(t, cmd.Execute()) - golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-pretty.%s.golden", tc.name)) - } -}
  72. Download patch cli/cli/command/config/cmd.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/cmd.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/cmd.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -package config - -import ( - "github.com/spf13/cobra" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" -) - -// NewConfigCommand returns a cobra command for `config` subcommands -func NewConfigCommand(dockerCli command.Cli) *cobra.Command { - cmd := &cobra.Command{ - Use: "config", - Short: "Manage Docker configs", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Annotations: map[string]string{ - "version": "1.30", - "swarm": "", - }, - } - cmd.AddCommand( - newConfigListCommand(dockerCli), - newConfigCreateCommand(dockerCli), - newConfigInspectCommand(dockerCli), - newConfigRemoveCommand(dockerCli), - ) - return cmd -}
  73. Download patch cli/cli/command/container/testdata/container-list-with-config-format.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/container-list-with-config-format.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/container-list-with-config-format.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -c1 busybox:latest some.label=value -c2 busybox:latest foo=bar
  74. Download patch cli/cli/command/container/create_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/create_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/create_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -package container - -import ( - "context" - "fmt" - "io" - "io/ioutil" - "os" - "runtime" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/cli/internal/test/notary" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" - "github.com/google/go-cmp/cmp" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" - "gotest.tools/fs" -) - -func TestCIDFileNoOPWithNoFilename(t *testing.T) { - file, err := newCIDFile("") - assert.NilError(t, err) - assert.DeepEqual(t, &cidFile{}, file, cmp.AllowUnexported(cidFile{})) - - assert.NilError(t, file.Write("id")) - assert.NilError(t, file.Close()) -} - -func TestNewCIDFileWhenFileAlreadyExists(t *testing.T) { - tempfile := fs.NewFile(t, "test-cid-file") - defer tempfile.Remove() - - _, err := newCIDFile(tempfile.Path()) - assert.ErrorContains(t, err, "Container ID file found") -} - -func TestCIDFileCloseWithNoWrite(t *testing.T) { - tempdir := fs.NewDir(t, "test-cid-file") - defer tempdir.Remove() - - path := tempdir.Join("cidfile") - file, err := newCIDFile(path) - assert.NilError(t, err) - assert.Check(t, is.Equal(file.path, path)) - - assert.NilError(t, file.Close()) - _, err = os.Stat(path) - assert.Check(t, os.IsNotExist(err)) -} - -func TestCIDFileCloseWithWrite(t *testing.T) { - tempdir := fs.NewDir(t, "test-cid-file") - defer tempdir.Remove() - - path := tempdir.Join("cidfile") - file, err := newCIDFile(path) - assert.NilError(t, err) - - content := "id" - assert.NilError(t, file.Write(content)) - - actual, err := ioutil.ReadFile(path) - assert.NilError(t, err) - assert.Check(t, is.Equal(content, string(actual))) - - assert.NilError(t, file.Close()) - _, err = os.Stat(path) - assert.NilError(t, err) -} - -func TestCreateContainerPullsImageIfMissing(t *testing.T) { - imageName := "does-not-exist-locally" - responseCounter := 0 - containerID := "abcdef" - - client := &fakeClient{ - createContainerFunc: func( - config *container.Config, - hostConfig *container.HostConfig, - networkingConfig *network.NetworkingConfig, - containerName string, - ) (container.ContainerCreateCreatedBody, error) { - defer func() { responseCounter++ }() - switch responseCounter { - case 0: - return container.ContainerCreateCreatedBody{}, fakeNotFound{} - case 1: - return container.ContainerCreateCreatedBody{ID: containerID}, nil - default: - return container.ContainerCreateCreatedBody{}, errors.New("unexpected") - } - }, - imageCreateFunc: func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader("")), nil - }, - infoFunc: func() (types.Info, error) { - return types.Info{IndexServerAddress: "http://indexserver"}, nil - }, - } - cli := test.NewFakeCli(client) - config := &containerConfig{ - Config: &container.Config{ - Image: imageName, - }, - HostConfig: &container.HostConfig{}, - } - body, err := createContainer(context.Background(), cli, config, &createOptions{ - name: "name", - platform: runtime.GOOS, - untrusted: true, - }) - assert.NilError(t, err) - expected := container.ContainerCreateCreatedBody{ID: containerID} - assert.Check(t, is.DeepEqual(expected, *body)) - stderr := cli.ErrBuffer().String() - assert.Check(t, is.Contains(stderr, "Unable to find image 'does-not-exist-locally:latest' locally")) -} - -func TestNewCreateCommandWithContentTrustErrors(t *testing.T) { - testCases := []struct { - name string - args []string - expectedError string - notaryFunc test.NotaryClientFuncType - }{ - { - name: "offline-notary-server", - notaryFunc: notary.GetOfflineNotaryRepository, - expectedError: "client is offline", - args: []string{"image:tag"}, - }, - { - name: "uninitialized-notary-server", - notaryFunc: notary.GetUninitializedNotaryRepository, - expectedError: "remote trust data does not exist", - args: []string{"image:tag"}, - }, - { - name: "empty-notary-server", - notaryFunc: notary.GetEmptyTargetsNotaryRepository, - expectedError: "No valid trust data for tag", - args: []string{"image:tag"}, - }, - } - for _, tc := range testCases { - cli := test.NewFakeCli(&fakeClient{ - createContainerFunc: func(config *container.Config, - hostConfig *container.HostConfig, - networkingConfig *network.NetworkingConfig, - containerName string, - ) (container.ContainerCreateCreatedBody, error) { - return container.ContainerCreateCreatedBody{}, fmt.Errorf("shouldn't try to pull image") - }, - }, test.EnableContentTrust) - cli.SetNotaryClient(tc.notaryFunc) - cmd := NewCreateCommand(cli) - cmd.SetOutput(ioutil.Discard) - cmd.SetArgs(tc.args) - err := cmd.Execute() - assert.ErrorContains(t, err, tc.expectedError) - } -} - -type fakeNotFound struct{} - -func (f fakeNotFound) NotFound() bool { return true } -func (f fakeNotFound) Error() string { return "error fake not found" }
  75. Download patch cli/cli/cobra.go

    --- 18.09.5+dfsg1-1/cli/cli/cobra.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/cobra.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/docker/docker/pkg/term" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -// SetupRootCommand sets default usage, help, and error handling for the -// root command. -func SetupRootCommand(rootCmd *cobra.Command) { - cobra.AddTemplateFunc("hasSubCommands", hasSubCommands) - cobra.AddTemplateFunc("hasManagementSubCommands", hasManagementSubCommands) - cobra.AddTemplateFunc("operationSubCommands", operationSubCommands) - cobra.AddTemplateFunc("managementSubCommands", managementSubCommands) - cobra.AddTemplateFunc("wrappedFlagUsages", wrappedFlagUsages) - - rootCmd.SetUsageTemplate(usageTemplate) - rootCmd.SetHelpTemplate(helpTemplate) - rootCmd.SetFlagErrorFunc(FlagErrorFunc) - rootCmd.SetHelpCommand(helpCommand) - rootCmd.SetVersionTemplate("Docker version {{.Version}}\n") - - rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage") - rootCmd.PersistentFlags().MarkShorthandDeprecated("help", "please use --help") - rootCmd.PersistentFlags().Lookup("help").Hidden = true -} - -// FlagErrorFunc prints an error message which matches the format of the -// docker/cli/cli error messages -func FlagErrorFunc(cmd *cobra.Command, err error) error { - if err == nil { - return nil - } - - usage := "" - if cmd.HasSubCommands() { - usage = "\n\n" + cmd.UsageString() - } - return StatusError{ - Status: fmt.Sprintf("%s\nSee '%s --help'.%s", err, cmd.CommandPath(), usage), - StatusCode: 125, - } -} - -var helpCommand = &cobra.Command{ - Use: "help [command]", - Short: "Help about the command", - PersistentPreRun: func(cmd *cobra.Command, args []string) {}, - PersistentPostRun: func(cmd *cobra.Command, args []string) {}, - RunE: func(c *cobra.Command, args []string) error { - cmd, args, e := c.Root().Find(args) - if cmd == nil || e != nil || len(args) > 0 { - return errors.Errorf("unknown help topic: %v", strings.Join(args, " ")) - } - - helpFunc := cmd.HelpFunc() - helpFunc(cmd, args) - return nil - }, -} - -func hasSubCommands(cmd *cobra.Command) bool { - return len(operationSubCommands(cmd)) > 0 -} - -func hasManagementSubCommands(cmd *cobra.Command) bool { - return len(managementSubCommands(cmd)) > 0 -} - -func operationSubCommands(cmd *cobra.Command) []*cobra.Command { - cmds := []*cobra.Command{} - for _, sub := range cmd.Commands() { - if sub.IsAvailableCommand() && !sub.HasSubCommands() { - cmds = append(cmds, sub) - } - } - return cmds -} - -func wrappedFlagUsages(cmd *cobra.Command) string { - width := 80 - if ws, err := term.GetWinsize(0); err == nil { - width = int(ws.Width) - } - return cmd.Flags().FlagUsagesWrapped(width - 1) -} - -func managementSubCommands(cmd *cobra.Command) []*cobra.Command { - cmds := []*cobra.Command{} - for _, sub := range cmd.Commands() { - if sub.IsAvailableCommand() && sub.HasSubCommands() { - cmds = append(cmds, sub) - } - } - return cmds -} - -var usageTemplate = `Usage: - -{{- if not .HasSubCommands}} {{.UseLine}}{{end}} -{{- if .HasSubCommands}} {{ .CommandPath}}{{- if .HasAvailableFlags}} [OPTIONS]{{end}} COMMAND{{end}} - -{{ .Short | trim }} - -{{- if gt .Aliases 0}} - -Aliases: - {{.NameAndAliases}} - -{{- end}} -{{- if .HasExample}} - -Examples: -{{ .Example }} - -{{- end}} -{{- if .HasAvailableFlags}} - -Options: -{{ wrappedFlagUsages . | trimRightSpace}} - -{{- end}} -{{- if hasManagementSubCommands . }} - -Management Commands: - -{{- range managementSubCommands . }} - {{rpad .Name .NamePadding }} {{.Short}} -{{- end}} - -{{- end}} -{{- if hasSubCommands .}} - -Commands: - -{{- range operationSubCommands . }} - {{rpad .Name .NamePadding }} {{.Short}} -{{- end}} -{{- end}} - -{{- if .HasSubCommands }} - -Run '{{.CommandPath}} COMMAND --help' for more information on a command. -{{- end}} -` - -var helpTemplate = ` -{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
  76. Download patch cli/cli/command/container/testdata/container-list-format-name-name.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/container/testdata/container-list-format-name-name.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/testdata/container-list-format-name-name.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -c1 c1 -c2 c2
  77. Download patch cli/appveyor.yml

    --- 18.09.5+dfsg1-1/cli/appveyor.yml 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/appveyor.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -version: "{build}" - -clone_folder: c:\gopath\src\github.com\docker\cli - -environment: - GOPATH: c:\gopath - GOVERSION: 1.10.8 - DEPVERSION: v0.4.1 - -install: - - rmdir c:\go /s /q - - appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-amd64.msi - - msiexec /i go%GOVERSION%.windows-amd64.msi /q - - go version - - go env - -deploy: false - -build_script: - - ps: .\scripts\make.ps1 -Binary - -test_script: - - ps: .\scripts\make.ps1 -TestUnit \ No newline at end of file
  78. Download patch cli/cli/command/container/restart.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/restart.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/restart.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - "time" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type restartOptions struct { - nSeconds int - nSecondsChanged bool - - containers []string -} - -// NewRestartCommand creates a new cobra.Command for `docker restart` -func NewRestartCommand(dockerCli command.Cli) *cobra.Command { - var opts restartOptions - - cmd := &cobra.Command{ - Use: "restart [OPTIONS] CONTAINER [CONTAINER...]", - Short: "Restart one or more containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - opts.nSecondsChanged = cmd.Flags().Changed("time") - return runRestart(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.IntVarP(&opts.nSeconds, "time", "t", 10, "Seconds to wait for stop before killing the container") - return cmd -} - -func runRestart(dockerCli command.Cli, opts *restartOptions) error { - ctx := context.Background() - var errs []string - var timeout *time.Duration - if opts.nSecondsChanged { - timeoutValue := time.Duration(opts.nSeconds) * time.Second - timeout = &timeoutValue - } - - for _, name := range opts.containers { - if err := dockerCli.Client().ContainerRestart(ctx, name, timeout); err != nil { - errs = append(errs, err.Error()) - continue - } - fmt.Fprintln(dockerCli.Out(), name) - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  79. Download patch cli/cli/command/config/testdata/config-list-with-format.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-list-with-format.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-list-with-format.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -bar label=label-bar -foo
  80. Download patch cli/cli/command/commands/commands.go

    --- 18.09.5+dfsg1-1/cli/cli/command/commands/commands.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/commands/commands.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -package commands - -import ( - "os" - "runtime" - - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/builder" - "github.com/docker/cli/cli/command/checkpoint" - "github.com/docker/cli/cli/command/config" - "github.com/docker/cli/cli/command/container" - "github.com/docker/cli/cli/command/engine" - "github.com/docker/cli/cli/command/image" - "github.com/docker/cli/cli/command/manifest" - "github.com/docker/cli/cli/command/network" - "github.com/docker/cli/cli/command/node" - "github.com/docker/cli/cli/command/plugin" - "github.com/docker/cli/cli/command/registry" - "github.com/docker/cli/cli/command/secret" - "github.com/docker/cli/cli/command/service" - "github.com/docker/cli/cli/command/stack" - "github.com/docker/cli/cli/command/swarm" - "github.com/docker/cli/cli/command/system" - "github.com/docker/cli/cli/command/trust" - "github.com/docker/cli/cli/command/volume" - "github.com/spf13/cobra" -) - -// AddCommands adds all the commands from cli/command to the root command -func AddCommands(cmd *cobra.Command, dockerCli command.Cli) { - cmd.AddCommand( - // checkpoint - checkpoint.NewCheckpointCommand(dockerCli), - - // config - config.NewConfigCommand(dockerCli), - - // container - container.NewContainerCommand(dockerCli), - container.NewRunCommand(dockerCli), - - // image - image.NewImageCommand(dockerCli), - image.NewBuildCommand(dockerCli), - - // builder - builder.NewBuilderCommand(dockerCli), - - // manifest - manifest.NewManifestCommand(dockerCli), - - // network - network.NewNetworkCommand(dockerCli), - - // node - node.NewNodeCommand(dockerCli), - - // plugin - plugin.NewPluginCommand(dockerCli), - - // registry - registry.NewLoginCommand(dockerCli), - registry.NewLogoutCommand(dockerCli), - registry.NewSearchCommand(dockerCli), - - // secret - secret.NewSecretCommand(dockerCli), - - // service - service.NewServiceCommand(dockerCli), - - // system - system.NewSystemCommand(dockerCli), - system.NewVersionCommand(dockerCli), - - // stack - stack.NewStackCommand(dockerCli), - stack.NewTopLevelDeployCommand(dockerCli), - - // swarm - swarm.NewSwarmCommand(dockerCli), - - // trust - trust.NewTrustCommand(dockerCli), - - // volume - volume.NewVolumeCommand(dockerCli), - - // legacy commands may be hidden - hide(system.NewEventsCommand(dockerCli)), - hide(system.NewInfoCommand(dockerCli)), - hide(system.NewInspectCommand(dockerCli)), - hide(container.NewAttachCommand(dockerCli)), - hide(container.NewCommitCommand(dockerCli)), - hide(container.NewCopyCommand(dockerCli)), - hide(container.NewCreateCommand(dockerCli)), - hide(container.NewDiffCommand(dockerCli)), - hide(container.NewExecCommand(dockerCli)), - hide(container.NewExportCommand(dockerCli)), - hide(container.NewKillCommand(dockerCli)), - hide(container.NewLogsCommand(dockerCli)), - hide(container.NewPauseCommand(dockerCli)), - hide(container.NewPortCommand(dockerCli)), - hide(container.NewPsCommand(dockerCli)), - hide(container.NewRenameCommand(dockerCli)), - hide(container.NewRestartCommand(dockerCli)), - hide(container.NewRmCommand(dockerCli)), - hide(container.NewStartCommand(dockerCli)), - hide(container.NewStatsCommand(dockerCli)), - hide(container.NewStopCommand(dockerCli)), - hide(container.NewTopCommand(dockerCli)), - hide(container.NewUnpauseCommand(dockerCli)), - hide(container.NewUpdateCommand(dockerCli)), - hide(container.NewWaitCommand(dockerCli)), - hide(image.NewHistoryCommand(dockerCli)), - hide(image.NewImagesCommand(dockerCli)), - hide(image.NewImportCommand(dockerCli)), - hide(image.NewLoadCommand(dockerCli)), - hide(image.NewPullCommand(dockerCli)), - hide(image.NewPushCommand(dockerCli)), - hide(image.NewRemoveCommand(dockerCli)), - hide(image.NewSaveCommand(dockerCli)), - hide(image.NewTagCommand(dockerCli)), - ) - if runtime.GOOS == "linux" { - // engine - cmd.AddCommand(engine.NewEngineCommand(dockerCli)) - } -} - -func hide(cmd *cobra.Command) *cobra.Command { - // If the environment variable with name "DOCKER_HIDE_LEGACY_COMMANDS" is not empty, - // these legacy commands (such as `docker ps`, `docker exec`, etc) - // will not be shown in output console. - if os.Getenv("DOCKER_HIDE_LEGACY_COMMANDS") == "" { - return cmd - } - cmdCopy := *cmd - cmdCopy.Hidden = true - cmdCopy.Aliases = []string{} - return &cmdCopy -}
  81. Download patch cli/cli/command/container/stop.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/stop.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/stop.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - "time" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type stopOptions struct { - time int - timeChanged bool - - containers []string -} - -// NewStopCommand creates a new cobra.Command for `docker stop` -func NewStopCommand(dockerCli command.Cli) *cobra.Command { - var opts stopOptions - - cmd := &cobra.Command{ - Use: "stop [OPTIONS] CONTAINER [CONTAINER...]", - Short: "Stop one or more running containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - opts.timeChanged = cmd.Flags().Changed("time") - return runStop(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.IntVarP(&opts.time, "time", "t", 10, "Seconds to wait for stop before killing it") - return cmd -} - -func runStop(dockerCli command.Cli, opts *stopOptions) error { - ctx := context.Background() - - var timeout *time.Duration - if opts.timeChanged { - timeoutValue := time.Duration(opts.time) * time.Second - timeout = &timeoutValue - } - - var errs []string - - errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, id string) error { - return dockerCli.Client().ContainerStop(ctx, id, timeout) - }) - for _, container := range opts.containers { - if err := <-errChan; err != nil { - errs = append(errs, err.Error()) - continue - } - fmt.Fprintln(dockerCli.Out(), container) - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  82. Download patch cli/cli/command/container/attach_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/attach_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/attach_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -package container - -import ( - "fmt" - "io/ioutil" - "testing" - - "github.com/docker/cli/cli" - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" - "gotest.tools/assert" -) - -func TestNewAttachCommandErrors(t *testing.T) { - testCases := []struct { - name string - args []string - expectedError string - containerInspectFunc func(img string) (types.ContainerJSON, error) - }{ - { - name: "client-error", - args: []string{"5cb5bb5e4a3b"}, - expectedError: "something went wrong", - containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - return types.ContainerJSON{}, errors.Errorf("something went wrong") - }, - }, - { - name: "client-stopped", - args: []string{"5cb5bb5e4a3b"}, - expectedError: "You cannot attach to a stopped container", - containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - c := types.ContainerJSON{} - c.ContainerJSONBase = &types.ContainerJSONBase{} - c.ContainerJSONBase.State = &types.ContainerState{Running: false} - return c, nil - }, - }, - { - name: "client-paused", - args: []string{"5cb5bb5e4a3b"}, - expectedError: "You cannot attach to a paused container", - containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - c := types.ContainerJSON{} - c.ContainerJSONBase = &types.ContainerJSONBase{} - c.ContainerJSONBase.State = &types.ContainerState{ - Running: true, - Paused: true, - } - return c, nil - }, - }, - { - name: "client-restarting", - args: []string{"5cb5bb5e4a3b"}, - expectedError: "You cannot attach to a restarting container", - containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - c := types.ContainerJSON{} - c.ContainerJSONBase = &types.ContainerJSONBase{} - c.ContainerJSONBase.State = &types.ContainerState{ - Running: true, - Paused: false, - Restarting: true, - } - return c, nil - }, - }, - } - for _, tc := range testCases { - cmd := NewAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})) - cmd.SetOutput(ioutil.Discard) - cmd.SetArgs(tc.args) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestGetExitStatus(t *testing.T) { - var ( - expectedErr = fmt.Errorf("unexpected error") - errC = make(chan error, 1) - resultC = make(chan container.ContainerWaitOKBody, 1) - ) - - testcases := []struct { - result *container.ContainerWaitOKBody - err error - expectedError error - }{ - { - result: &container.ContainerWaitOKBody{ - StatusCode: 0, - }, - }, - { - err: expectedErr, - expectedError: expectedErr, - }, - { - result: &container.ContainerWaitOKBody{ - Error: &container.ContainerWaitOKBodyError{Message: expectedErr.Error()}, - }, - expectedError: expectedErr, - }, - { - result: &container.ContainerWaitOKBody{ - StatusCode: 15, - }, - expectedError: cli.StatusError{StatusCode: 15}, - }, - } - - for _, testcase := range testcases { - if testcase.err != nil { - errC <- testcase.err - } - if testcase.result != nil { - resultC <- *testcase.result - } - err := getExitStatus(errC, resultC) - if testcase.expectedError == nil { - assert.NilError(t, err) - } else { - assert.Error(t, err, testcase.expectedError.Error()) - } - } -}
  83. Download patch cli/cli/command/engine/activate.go
  84. Download patch cli/cli/command/container/utils_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/utils_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/utils_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -package container - -import ( - "context" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api" - "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func waitFn(cid string) (<-chan container.ContainerWaitOKBody, <-chan error) { - resC := make(chan container.ContainerWaitOKBody) - errC := make(chan error, 1) - var res container.ContainerWaitOKBody - - go func() { - switch { - case strings.Contains(cid, "exit-code-42"): - res.StatusCode = 42 - resC <- res - case strings.Contains(cid, "non-existent"): - err := errors.Errorf("No such container: %v", cid) - errC <- err - case strings.Contains(cid, "wait-error"): - res.Error = &container.ContainerWaitOKBodyError{Message: "removal failed"} - resC <- res - default: - // normal exit - resC <- res - } - }() - - return resC, errC -} - -func TestWaitExitOrRemoved(t *testing.T) { - testcases := []struct { - cid string - exitCode int - }{ - { - cid: "normal-container", - exitCode: 0, - }, - { - cid: "give-me-exit-code-42", - exitCode: 42, - }, - { - cid: "i-want-a-wait-error", - exitCode: 125, - }, - { - cid: "non-existent-container-id", - exitCode: 125, - }, - } - - client := test.NewFakeCli(&fakeClient{waitFunc: waitFn, Version: api.DefaultVersion}) - for _, testcase := range testcases { - statusC := waitExitOrRemoved(context.Background(), client, testcase.cid, true) - exitCode := <-statusC - assert.Check(t, is.Equal(testcase.exitCode, exitCode)) - } -}
  85. Download patch cli/cli/command/container/kill.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/kill.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/kill.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type killOptions struct { - signal string - - containers []string -} - -// NewKillCommand creates a new cobra.Command for `docker kill` -func NewKillCommand(dockerCli command.Cli) *cobra.Command { - var opts killOptions - - cmd := &cobra.Command{ - Use: "kill [OPTIONS] CONTAINER [CONTAINER...]", - Short: "Kill one or more running containers", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.containers = args - return runKill(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.StringVarP(&opts.signal, "signal", "s", "KILL", "Signal to send to the container") - return cmd -} - -func runKill(dockerCli command.Cli, opts *killOptions) error { - var errs []string - ctx := context.Background() - errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error { - return dockerCli.Client().ContainerKill(ctx, container, opts.signal) - }) - for _, name := range opts.containers { - if err := <-errChan; err != nil { - errs = append(errs, err.Error()) - } else { - fmt.Fprintln(dockerCli.Out(), name) - } - } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil -}
  86. Download patch cli/cli/command/container/stats_helpers.go
  87. Download patch cli/cli/command/container/diff.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/diff.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/diff.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -package container - -import ( - "context" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/formatter" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -type diffOptions struct { - container string -} - -// NewDiffCommand creates a new cobra.Command for `docker diff` -func NewDiffCommand(dockerCli command.Cli) *cobra.Command { - var opts diffOptions - - return &cobra.Command{ - Use: "diff CONTAINER", - Short: "Inspect changes to files or directories on a container's filesystem", - Args: cli.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - return runDiff(dockerCli, &opts) - }, - } -} - -func runDiff(dockerCli command.Cli, opts *diffOptions) error { - if opts.container == "" { - return errors.New("Container name cannot be empty") - } - ctx := context.Background() - - changes, err := dockerCli.Client().ContainerDiff(ctx, opts.container) - if err != nil { - return err - } - diffCtx := formatter.Context{ - Output: dockerCli.Out(), - Format: formatter.NewDiffFormat("{{.Type}} {{.Path}}"), - } - return formatter.DiffWrite(diffCtx, changes) -}
  88. Download patch cli/cli/command/config/testdata/config-list-with-quiet-option.golden

    --- 18.09.5+dfsg1-1/cli/cli/command/config/testdata/config-list-with-quiet-option.golden 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/testdata/config-list-with-quiet-option.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -ID-bar -ID-foo
  89. Download patch cli/cli/command/builder/cmd.go

    --- 18.09.5+dfsg1-1/cli/cli/command/builder/cmd.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/builder/cmd.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -package builder - -import ( - "github.com/spf13/cobra" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" -) - -// NewBuilderCommand returns a cobra command for `builder` subcommands -func NewBuilderCommand(dockerCli command.Cli) *cobra.Command { - cmd := &cobra.Command{ - Use: "builder", - Short: "Manage builds", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - } - cmd.AddCommand( - NewPruneCommand(dockerCli), - ) - return cmd -}
  90. Download patch cli/cli/command/container/cmd.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/cmd.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/cmd.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -package container - -import ( - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/spf13/cobra" -) - -// NewContainerCommand returns a cobra command for `container` subcommands -func NewContainerCommand(dockerCli command.Cli) *cobra.Command { - cmd := &cobra.Command{ - Use: "container", - Short: "Manage containers", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - } - cmd.AddCommand( - NewAttachCommand(dockerCli), - NewCommitCommand(dockerCli), - NewCopyCommand(dockerCli), - NewCreateCommand(dockerCli), - NewDiffCommand(dockerCli), - NewExecCommand(dockerCli), - NewExportCommand(dockerCli), - NewKillCommand(dockerCli), - NewLogsCommand(dockerCli), - NewPauseCommand(dockerCli), - NewPortCommand(dockerCli), - NewRenameCommand(dockerCli), - NewRestartCommand(dockerCli), - NewRmCommand(dockerCli), - NewRunCommand(dockerCli), - NewStartCommand(dockerCli), - NewStatsCommand(dockerCli), - NewStopCommand(dockerCli), - NewTopCommand(dockerCli), - NewUnpauseCommand(dockerCli), - NewUpdateCommand(dockerCli), - NewWaitCommand(dockerCli), - newListCommand(dockerCli), - newInspectCommand(dockerCli), - NewPruneCommand(dockerCli), - ) - return cmd -}
  91. Download patch cli/cli/command/bundlefile/bundlefile_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/bundlefile/bundlefile_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/bundlefile/bundlefile_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -package bundlefile - -import ( - "bytes" - "strings" - "testing" - - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestLoadFileV01Success(t *testing.T) { - reader := strings.NewReader(`{ - "Version": "0.1", - "Services": { - "redis": { - "Image": "redis@sha256:4b24131101fa0117bcaa18ac37055fffd9176aa1a240392bb8ea85e0be50f2ce", - "Networks": ["default"] - }, - "web": { - "Image": "dockercloud/hello-world@sha256:fe79a2cfbd17eefc344fb8419420808df95a1e22d93b7f621a7399fd1e9dca1d", - "Networks": ["default"], - "User": "web" - } - } - }`) - - bundle, err := LoadFile(reader) - assert.NilError(t, err) - assert.Check(t, is.Equal("0.1", bundle.Version)) - assert.Check(t, is.Len(bundle.Services, 2)) -} - -func TestLoadFileSyntaxError(t *testing.T) { - reader := strings.NewReader(`{ - "Version": "0.1", - "Services": unquoted string - }`) - - _, err := LoadFile(reader) - assert.Error(t, err, "JSON syntax error at byte 37: invalid character 'u' looking for beginning of value") -} - -func TestLoadFileTypeError(t *testing.T) { - reader := strings.NewReader(`{ - "Version": "0.1", - "Services": { - "web": { - "Image": "redis", - "Networks": "none" - } - } - }`) - - _, err := LoadFile(reader) - assert.Error(t, err, "Unexpected type at byte 94. Expected []string but received string.") -} - -func TestPrint(t *testing.T) { - var buffer bytes.Buffer - bundle := &Bundlefile{ - Version: "0.1", - Services: map[string]Service{ - "web": { - Image: "image", - Command: []string{"echo", "something"}, - }, - }, - } - assert.Check(t, Print(&buffer, bundle)) - output := buffer.String() - assert.Check(t, is.Contains(output, "\"Image\": \"image\"")) - assert.Check(t, is.Contains(output, - `"Command": [ - "echo", - "something" - ]`)) -}
  92. Download patch cli/AUTHORS
  93. Download patch cli/cli/command/container/commit.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/commit.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/commit.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -package container - -import ( - "context" - "fmt" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/opts" - "github.com/docker/docker/api/types" - "github.com/spf13/cobra" -) - -type commitOptions struct { - container string - reference string - - pause bool - comment string - author string - changes opts.ListOpts -} - -// NewCommitCommand creates a new cobra.Command for `docker commit` -func NewCommitCommand(dockerCli command.Cli) *cobra.Command { - var options commitOptions - - cmd := &cobra.Command{ - Use: "commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]", - Short: "Create a new image from a container's changes", - Args: cli.RequiresRangeArgs(1, 2), - RunE: func(cmd *cobra.Command, args []string) error { - options.container = args[0] - if len(args) > 1 { - options.reference = args[1] - } - return runCommit(dockerCli, &options) - }, - } - - flags := cmd.Flags() - flags.SetInterspersed(false) - - flags.BoolVarP(&options.pause, "pause", "p", true, "Pause container during commit") - flags.StringVarP(&options.comment, "message", "m", "", "Commit message") - flags.StringVarP(&options.author, "author", "a", "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")") - - options.changes = opts.NewListOpts(nil) - flags.VarP(&options.changes, "change", "c", "Apply Dockerfile instruction to the created image") - - return cmd -} - -func runCommit(dockerCli command.Cli, options *commitOptions) error { - ctx := context.Background() - - name := options.container - reference := options.reference - - commitOptions := types.ContainerCommitOptions{ - Reference: reference, - Comment: options.comment, - Author: options.author, - Changes: options.changes.GetAll(), - Pause: options.pause, - } - - response, err := dockerCli.Client().ContainerCommit(ctx, name, commitOptions) - if err != nil { - return err - } - - fmt.Fprintln(dockerCli.Out(), response.ID) - return nil -}
  94. Download patch cli/cli/command/container/stats.go
  95. Download patch cli/cli/command/container/logs_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/logs_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/logs_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -package container - -import ( - "io" - "io/ioutil" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -var logFn = func(expectedOut string) func(string, types.ContainerLogsOptions) (io.ReadCloser, error) { - return func(container string, opts types.ContainerLogsOptions) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader(expectedOut)), nil - } -} - -func TestRunLogs(t *testing.T) { - inspectFn := func(containerID string) (types.ContainerJSON, error) { - return types.ContainerJSON{ - Config: &container.Config{Tty: true}, - ContainerJSONBase: &types.ContainerJSONBase{State: &types.ContainerState{Running: false}}, - }, nil - } - - var testcases = []struct { - doc string - options *logsOptions - client fakeClient - expectedError string - expectedOut string - expectedErr string - }{ - { - doc: "successful logs", - expectedOut: "foo", - options: &logsOptions{}, - client: fakeClient{logFunc: logFn("foo"), inspectFunc: inspectFn}, - }, - } - - for _, testcase := range testcases { - t.Run(testcase.doc, func(t *testing.T) { - cli := test.NewFakeCli(&testcase.client) - - err := runLogs(cli, testcase.options) - if testcase.expectedError != "" { - assert.ErrorContains(t, err, testcase.expectedError) - } else { - if !assert.Check(t, err) { - return - } - } - assert.Check(t, is.Equal(testcase.expectedOut, cli.OutBuffer().String())) - assert.Check(t, is.Equal(testcase.expectedErr, cli.ErrBuffer().String())) - }) - } -}
  96. Download patch cli/cli/command/config/remove_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/remove_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/remove_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -package config - -import ( - "io/ioutil" - "strings" - "testing" - - "github.com/docker/cli/internal/test" - "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" -) - -func TestConfigRemoveErrors(t *testing.T) { - testCases := []struct { - args []string - configRemoveFunc func(string) error - expectedError string - }{ - { - args: []string{}, - expectedError: "requires at least 1 argument.", - }, - { - args: []string{"foo"}, - configRemoveFunc: func(name string) error { - return errors.Errorf("error removing config") - }, - expectedError: "error removing config", - }, - } - for _, tc := range testCases { - cmd := newConfigRemoveCommand( - test.NewFakeCli(&fakeClient{ - configRemoveFunc: tc.configRemoveFunc, - }), - ) - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - assert.ErrorContains(t, cmd.Execute(), tc.expectedError) - } -} - -func TestConfigRemoveWithName(t *testing.T) { - names := []string{"foo", "bar"} - var removedConfigs []string - cli := test.NewFakeCli(&fakeClient{ - configRemoveFunc: func(name string) error { - removedConfigs = append(removedConfigs, name) - return nil - }, - }) - cmd := newConfigRemoveCommand(cli) - cmd.SetArgs(names) - assert.NilError(t, cmd.Execute()) - assert.Check(t, is.DeepEqual(names, strings.Split(strings.TrimSpace(cli.OutBuffer().String()), "\n"))) - assert.Check(t, is.DeepEqual(names, removedConfigs)) -} - -func TestConfigRemoveContinueAfterError(t *testing.T) { - names := []string{"foo", "bar"} - var removedConfigs []string - - cli := test.NewFakeCli(&fakeClient{ - configRemoveFunc: func(name string) error { - removedConfigs = append(removedConfigs, name) - if name == "foo" { - return errors.Errorf("error removing config: %s", name) - } - return nil - }, - }) - - cmd := newConfigRemoveCommand(cli) - cmd.SetArgs(names) - cmd.SetOutput(ioutil.Discard) - assert.Error(t, cmd.Execute(), "error removing config: foo") - assert.Check(t, is.DeepEqual(names, removedConfigs)) -}
  97. Download patch cli/cli/command/config/client_test.go

    --- 18.09.5+dfsg1-1/cli/cli/command/config/client_test.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/config/client_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -package config - -import ( - "context" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/client" -) - -type fakeClient struct { - client.Client - configCreateFunc func(swarm.ConfigSpec) (types.ConfigCreateResponse, error) - configInspectFunc func(string) (swarm.Config, []byte, error) - configListFunc func(types.ConfigListOptions) ([]swarm.Config, error) - configRemoveFunc func(string) error -} - -func (c *fakeClient) ConfigCreate(ctx context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { - if c.configCreateFunc != nil { - return c.configCreateFunc(spec) - } - return types.ConfigCreateResponse{}, nil -} - -func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { - if c.configInspectFunc != nil { - return c.configInspectFunc(id) - } - return swarm.Config{}, nil, nil -} - -func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { - if c.configListFunc != nil { - return c.configListFunc(options) - } - return []swarm.Config{}, nil -} - -func (c *fakeClient) ConfigRemove(ctx context.Context, name string) error { - if c.configRemoveFunc != nil { - return c.configRemoveFunc(name) - } - return nil -}
  98. Download patch cli/cli/command/container/tty.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/tty.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/tty.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -package container - -import ( - "context" - "fmt" - "os" - gosignal "os/signal" - "runtime" - "time" - - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/signal" - "github.com/sirupsen/logrus" -) - -// resizeTtyTo resizes tty to specific height and width -func resizeTtyTo(ctx context.Context, client client.ContainerAPIClient, id string, height, width uint, isExec bool) error { - if height == 0 && width == 0 { - return nil - } - - options := types.ResizeOptions{ - Height: height, - Width: width, - } - - var err error - if isExec { - err = client.ContainerExecResize(ctx, id, options) - } else { - err = client.ContainerResize(ctx, id, options) - } - - if err != nil { - logrus.Debugf("Error resize: %s\r", err) - } - return err -} - -// resizeTty is to resize the tty with cli out's tty size -func resizeTty(ctx context.Context, cli command.Cli, id string, isExec bool) error { - height, width := cli.Out().GetTtySize() - return resizeTtyTo(ctx, cli.Client(), id, height, width, isExec) -} - -// initTtySize is to init the tty's size to the same as the window, if there is an error, it will retry 5 times. -func initTtySize(ctx context.Context, cli command.Cli, id string, isExec bool, resizeTtyFunc func(ctx context.Context, cli command.Cli, id string, isExec bool) error) { - rttyFunc := resizeTtyFunc - if rttyFunc == nil { - rttyFunc = resizeTty - } - if err := rttyFunc(ctx, cli, id, isExec); err != nil { - go func() { - var err error - for retry := 0; retry < 5; retry++ { - time.Sleep(10 * time.Millisecond) - if err = rttyFunc(ctx, cli, id, isExec); err == nil { - break - } - } - if err != nil { - fmt.Fprintln(cli.Err(), "failed to resize tty, using default size") - } - }() - } -} - -// MonitorTtySize updates the container tty size when the terminal tty changes size -func MonitorTtySize(ctx context.Context, cli command.Cli, id string, isExec bool) error { - initTtySize(ctx, cli, id, isExec, resizeTty) - if runtime.GOOS == "windows" { - go func() { - prevH, prevW := cli.Out().GetTtySize() - for { - time.Sleep(time.Millisecond * 250) - h, w := cli.Out().GetTtySize() - - if prevW != w || prevH != h { - resizeTty(ctx, cli, id, isExec) - } - prevH = h - prevW = w - } - }() - } else { - sigchan := make(chan os.Signal, 1) - gosignal.Notify(sigchan, signal.SIGWINCH) - go func() { - for range sigchan { - resizeTty(ctx, cli, id, isExec) - } - }() - } - return nil -} - -// ForwardAllSignals forwards signals to the container -func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string) chan os.Signal { - sigc := make(chan os.Signal, 128) - signal.CatchAll(sigc) - go func() { - for s := range sigc { - if s == signal.SIGCHLD || s == signal.SIGPIPE { - continue - } - var sig string - for sigStr, sigN := range signal.SignalMap { - if sigN == s { - sig = sigStr - break - } - } - if sig == "" { - fmt.Fprintf(cli.Err(), "Unsupported signal: %v. Discarding.\n", s) - continue - } - - if err := cli.Client().ContainerKill(ctx, cid, sig); err != nil { - logrus.Debugf("Error sending signal: %s", err) - } - } - }() - return sigc -}
  99. Download patch cli/cli/command/container/top.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/top.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/top.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -package container - -import ( - "context" - "fmt" - "strings" - "text/tabwriter" - - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/spf13/cobra" -) - -type topOptions struct { - container string - - args []string -} - -// NewTopCommand creates a new cobra.Command for `docker top` -func NewTopCommand(dockerCli command.Cli) *cobra.Command { - var opts topOptions - - cmd := &cobra.Command{ - Use: "top CONTAINER [ps OPTIONS]", - Short: "Display the running processes of a container", - Args: cli.RequiresMinArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - opts.container = args[0] - opts.args = args[1:] - return runTop(dockerCli, &opts) - }, - } - - flags := cmd.Flags() - flags.SetInterspersed(false) - - return cmd -} - -func runTop(dockerCli command.Cli, opts *topOptions) error { - ctx := context.Background() - - procList, err := dockerCli.Client().ContainerTop(ctx, opts.container, opts.args) - if err != nil { - return err - } - - w := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 3, ' ', 0) - fmt.Fprintln(w, strings.Join(procList.Titles, "\t")) - - for _, proc := range procList.Processes { - fmt.Fprintln(w, strings.Join(proc, "\t")) - } - w.Flush() - return nil -}
  100. Download patch cli/cli/command/container/utils.go

    --- 18.09.5+dfsg1-1/cli/cli/command/container/utils.go 2019-04-10 23:47:39.000000000 +0000 +++ 18.09.8-0ubuntu3/cli/cli/command/container/utils.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ -package container - -import ( - "context" - "strconv" - - "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/versions" - "github.com/sirupsen/logrus" -) - -func waitExitOrRemoved(ctx context.Context, dockerCli command.Cli, containerID string, waitRemove bool) <-chan int { - if len(containerID) == 0 { - // containerID can never be empty - panic("Internal Error: waitExitOrRemoved needs a containerID as parameter") - } - - // Older versions used the Events API, and even older versions did not - // support server-side removal. This legacyWaitExitOrRemoved method - // preserves that old behavior and any issues it may have. - if versions.LessThan(dockerCli.Client().ClientVersion(), "1.30") { - return legacyWaitExitOrRemoved(ctx, dockerCli, containerID, waitRemove) - } - - condition := container.WaitConditionNextExit - if waitRemove { - condition = container.WaitConditionRemoved - } - - resultC, errC := dockerCli.Client().ContainerWait(ctx, containerID, condition) - - statusC := make(chan int) - go func() { - select { - case result := <-resultC: - if result.Error != nil { - logrus.Errorf("Error waiting for container: %v", result.Error.Message) - statusC <- 125 - } else { - statusC <- int(result.StatusCode) - } - case err := <-errC: - logrus.Errorf("error waiting for container: %v", err) - statusC <- 125 - } - }() - - return statusC -} - -func legacyWaitExitOrRemoved(ctx context.Context, dockerCli command.Cli, containerID string, waitRemove bool) <-chan int { - var removeErr error - statusChan := make(chan int) - exitCode := 125 - - // Get events via Events API - f := filters.NewArgs() - f.Add("type", "container") - f.Add("container", containerID) - options := types.EventsOptions{ - Filters: f, - } - eventCtx, cancel := context.WithCancel(ctx) - eventq, errq := dockerCli.Client().Events(eventCtx, options) - - eventProcessor := func(e events.Message) bool { - stopProcessing := false - switch e.Status { - case "die": - if v, ok := e.Actor.Attributes["exitCode"]; ok { - code, cerr := strconv.Atoi(v) - if cerr != nil { - logrus.Errorf("failed to convert exitcode '%q' to int: %v", v, cerr) - } else { - exitCode = code - } - } - if !waitRemove { - stopProcessing = true - } else { - // If we are talking to an older daemon, `AutoRemove` is not supported. - // We need to fall back to the old behavior, which is client-side removal - if versions.LessThan(dockerCli.Client().ClientVersion(), "1.25") { - go func() { - removeErr = dockerCli.Client().ContainerRemove(ctx, containerID, types.ContainerRemoveOptions{RemoveVolumes: true}) - if removeErr != nil { - logrus.Errorf("error removing container: %v", removeErr) - cancel() // cancel the event Q - } - }() - } - } - case "detach": - exitCode = 0 - stopProcessing = true - case "destroy": - stopProcessing = true - } - return stopProcessing - } - - go func() { - defer func() { - statusChan <- exitCode // must always send an exit code or the caller will block - cancel() - }() - - for { - select { - case <-eventCtx.Done(): - if removeErr != nil { - return - } - case evt := <-eventq: - if eventProcessor(evt) { - return - } - case err := <-errq: - logrus.Errorf("error getting events from daemon: %v", err) - return - } - } - }() - - return statusChan -} - -func parallelOperation(ctx context.Context, containers []string, op func(ctx context.Context, container string) error) chan error { - if len(containers) == 0 { - return nil - } - const defaultParallel int = 50 - sem := make(chan struct{}, defaultParallel) - errChan := make(chan error) - - // make sure result is printed in correct order - output := map[string]chan error{} - for _, c := range containers { - output[c] = make(chan error, 1) - } - go func() { - for _, c := range containers { - err := <-output[c] - errChan <- err - } - }() - - go func() { - for _, c := range containers { - sem <- struct{}{} // Wait for active queue sem to drain. - go func(container string) { - output[container] <- op(ctx, container) - <-sem - }(c) - } - }() - return errChan -}
  101. ...

Debian ( Changelog | PTS | Bugs ) Ubuntu ( Changelog | txt | LP | Bugs ) | Diff from Ubuntu

Source: golang-1.11

golang-1.11 (1.11.13-1ubuntu1) eoan; urgency=low * Merge from Debian unstable. Remaining changes: - Do not distribute un-built from source race detector runtime files and recommend golang-race-detector-runtime instead (see Debian bug #807455). -- Gianfranco Costamagna <locutusofborg@debian.org> Fri, 16 Aug 2019 21:02:21 +0200

Modifications :
  1. Download patch debian/rules

    --- 1.11.13-1/debian/rules 2019-08-15 18:55:59.000000000 +0000 +++ 1.11.13-1ubuntu1/debian/rules 2019-08-16 01:13:59.000000000 +0000 @@ -85,6 +85,9 @@ override_dh_compress-indep: override_dh_install-arch: dh_install + # Remove .syso files of the race detector; they are binary files that + # are not built from source in the go source distribution. + find $(CURDIR)/debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src/runtime/race -type f -name '*.syso' -delete # Remove Plan9 rc(1) scripts find debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src -type f -name '*.rc' -delete # Remove empty /usr/share/go-$(GOVER)/src from golang-$(GOVER)-go, it is provided by golang-$(GOVER)-src
  2. Download patch debian/control

    --- 1.11.13-1/debian/control 2019-08-15 18:56:03.000000000 +0000 +++ 1.11.13-1ubuntu1/debian/control 2019-08-16 19:02:21.000000000 +0000 @@ -25,7 +25,11 @@ Depends: golang-1.11-src (>= ${source:Ve ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Recommends: g++, gcc, libc6-dev, pkg-config +Recommends: g++, + gcc, + golang-1.11-race-detector-runtime [amd64], + libc6-dev, + pkg-config Suggests: bzr | brz, ca-certificates, git, mercurial, subversion Description: Go programming language compiler, linker, compiled stdlib The Go programming language is an open source project to make programmers more
  3. Download patch debian/control.in

    --- 1.11.13-1/debian/control.in 2019-08-15 18:52:06.000000000 +0000 +++ 1.11.13-1ubuntu1/debian/control.in 2019-08-16 01:13:59.000000000 +0000 @@ -21,7 +21,11 @@ Depends: golang-X.Y-src (>= ${source:Ver ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Recommends: g++, gcc, libc6-dev, pkg-config +Recommends: g++, + gcc, + golang-X.Y-race-detector-runtime [amd64], + libc6-dev, + pkg-config Suggests: bzr | brz, ca-certificates, git, mercurial, subversion Description: Go programming language compiler, linker, compiled stdlib The Go programming language is an open source project to make programmers more
  4. Download patch debian/gbp.conf.in

    --- 1.11.13-1/debian/gbp.conf.in 2019-08-15 18:52:06.000000000 +0000 +++ 1.11.13-1ubuntu1/debian/gbp.conf.in 2019-08-16 01:13:59.000000000 +0000 @@ -1,5 +1,5 @@ [DEFAULT] -debian-branch = golang-X.Y +debian-branch = ubuntu-X.Y debian-tag = debian/%(version)s upstream-branch = upstream-X.Y upstream-tag = upstream/%(version)s
  5. Download patch debian/gbp.conf

    --- 1.11.13-1/debian/gbp.conf 2019-08-15 18:56:03.000000000 +0000 +++ 1.11.13-1ubuntu1/debian/gbp.conf 2019-08-16 19:02:21.000000000 +0000 @@ -3,7 +3,7 @@ # [DEFAULT] -debian-branch = golang-1.11 +debian-branch = ubuntu-1.11 debian-tag = debian/%(version)s upstream-branch = upstream-1.11 upstream-tag = upstream/%(version)s

Debian ( Changelog | PTS | Bugs ) Ubuntu ( Changelog | txt | LP | Bugs ) | Diff from Ubuntu

Source: golang-1.12

golang-1.12 (1.12.8-1ubuntu1) eoan; urgency=low * Merge from Debian unstable. Remaining changes: - Do not distribute un-built from source race detector runtime files and recommend golang-race-detector-runtime instead (see Debian bug #807455). -- Gianfranco Costamagna <locutusofborg@debian.org> Thu, 15 Aug 2019 23:16:12 +0200

Modifications :
  1. Download patch debian/rules

    --- 1.12.8-1/debian/rules 2019-08-14 19:25:24.000000000 +0000 +++ 1.12.8-1ubuntu1/debian/rules 2019-08-15 04:13:23.000000000 +0000 @@ -89,6 +89,9 @@ override_dh_compress-indep: override_dh_install-arch: dh_install + # Remove .syso files of the race detector; they are binary files that + # are not built from source in the go source distribution. + find $(CURDIR)/debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src/runtime/race -type f -name '*.syso' -delete # Remove Plan9 rc(1) scripts find debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src -type f -name '*.rc' -delete # Remove empty /usr/share/go-$(GOVER)/src from golang-$(GOVER)-go, it is provided by golang-$(GOVER)-src
  2. Download patch debian/control

    --- 1.12.8-1/debian/control 2019-08-14 19:59:24.000000000 +0000 +++ 1.12.8-1ubuntu1/debian/control 2019-08-15 21:16:12.000000000 +0000 @@ -25,7 +25,11 @@ Depends: golang-1.12-src (>= ${source:Ve ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Recommends: g++, gcc, libc6-dev, pkg-config +Recommends: g++, + gcc, + golang-1.12-race-detector-runtime [amd64], + libc6-dev, + pkg-config Suggests: bzr | brz, ca-certificates, git, mercurial, subversion Description: Go programming language compiler, linker, compiled stdlib The Go programming language is an open source project to make programmers more
  3. Download patch debian/control.in

    --- 1.12.8-1/debian/control.in 2019-08-14 19:25:24.000000000 +0000 +++ 1.12.8-1ubuntu1/debian/control.in 2019-08-15 04:13:23.000000000 +0000 @@ -21,7 +21,11 @@ Depends: golang-X.Y-src (>= ${source:Ver ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Recommends: g++, gcc, libc6-dev, pkg-config +Recommends: g++, + gcc, + golang-X.Y-race-detector-runtime [amd64], + libc6-dev, + pkg-config Suggests: bzr | brz, ca-certificates, git, mercurial, subversion Description: Go programming language compiler, linker, compiled stdlib The Go programming language is an open source project to make programmers more
  4. Download patch debian/gbp.conf.in

    --- 1.12.8-1/debian/gbp.conf.in 2019-07-09 18:26:43.000000000 +0000 +++ 1.12.8-1ubuntu1/debian/gbp.conf.in 2019-08-15 04:13:23.000000000 +0000 @@ -1,5 +1,5 @@ [DEFAULT] -debian-branch = golang-X.Y +debian-branch = ubuntu-X.Y debian-tag = debian/%(version)s upstream-branch = upstream-X.Y upstream-tag = upstream/%(version)s
  5. Download patch debian/gbp.conf

    --- 1.12.8-1/debian/gbp.conf 2019-08-14 19:59:24.000000000 +0000 +++ 1.12.8-1ubuntu1/debian/gbp.conf 2019-08-15 21:16:12.000000000 +0000 @@ -3,7 +3,7 @@ # [DEFAULT] -debian-branch = golang-1.12 +debian-branch = ubuntu-1.12 debian-tag = debian/%(version)s upstream-branch = upstream-1.12 upstream-tag = upstream/%(version)s

Debian ( Changelog | PTS | Bugs ) Ubuntu ( Changelog | txt | LP | Bugs ) | Diff from Ubuntu

Source: golang-defaults

golang-defaults (2:1.12~1ubuntu1) eoan; urgency=low * Merge from Debian unstable. Remaining changes: - Build and recommend golang-race-detector-runtime on amd64. -- Gianfranco Costamagna <locutusofborg@debian.org> Sun, 04 Aug 2019 22:46:14 +0200

Modifications :
  1. Download patch debian/control

    --- 2:1.12~1/debian/control 2019-08-03 10:22:56.000000000 +0000 +++ 2:1.12~1ubuntu1/debian/control 2019-08-03 15:44:09.000000000 +0000 @@ -55,6 +55,7 @@ Replaces: golang-doc (<< 2:1.6.1+1~), golang-go-windows-amd64, golang-go.tools (<< 1:0.0~git20151026.0.0f9d71c-1~), golang-golang-x-tools (<< 1:0.0~git20151026.0.0f9d71c-1~) +Recommends: golang-race-detector-runtime [amd64] Description: Go programming language compiler, linker, compiled stdlib The Go programming language is an open source project to make programmers more productive. Go is expressive, concise, clean, and efficient. Its concurrency @@ -168,3 +169,16 @@ Description: Go programming language com . This package is a metapackage that, when installed, guarantees that (most of) a full Go development environment is installed. + +Package: golang-race-detector-runtime +Architecture: amd64 +Depends: golang-${golang:GOVER}-race-detector-runtime, ${misc:Depends} +Description: Runtime support for Go's race detector + The runtime support for the race detector is included as a binary + file in the go source distribution so this package exists to build it + from source on trusted infrastructure. + . + Installing this package will make the -race flag to the go tool functional. + . + This is a dependency package that depends on the race detector runtime for the + default version of Go.
  1. docker.io
  2. golang-1.11
  3. golang-1.12
  4. golang-defaults