Commit Graph

6090 Commits

Author SHA1 Message Date
Ian Campbell 8f3798cf04 cli-plugins: Reinstate deprecated `-h` short form of `--help`.
In the initial implementation I thought it would be good to not pass on the
deprecation to plugins (since they are new). However it turns out this causes
`docker helloworld -h` to print a spurious "pflag: help requested" line:

    $ docker helloworld -h
    pflag: help requested
    See 'docker helloworld --help'.

    Usage:	docker helloworld [OPTIONS] COMMAND

    A basic Hello World plugin for tests
    ...

Compared with:

    $ docker ps -h
    Flag shorthand -h has been deprecated, please use --help

    Usage:	docker ps [OPTIONS]

This is in essence because having the flag undefined hits a different path
within cobra, causing `c.execute()` to return early due to getting an error
(`flag.ErrHelp`) from `c.ParseFlags`, which launders the error through our
`FlagErrorFunc` which wraps it in a `StatusError` which in turn defeats an `if
err == flag.ErrHelp` check further up the call chain. If the flag is defined we
instead hit a path which returns a bare `flag.ErrHelp` without wrapping it.

I considered updating our `FlagErrorFunc` to not wrap `flag.ErrHelp` (and then
following the chain to the next thing) however while doing that I realised that
the code for `-h` (and `--help`) is deeply embedded into cobra (and its flags
library) such that actually using `-h` as a plugin argument meaning something
other than `help` is basically impossible/impractical. Therefore we may as well
have plugins behave identically to the monolithic CLI and support (deprecated)
the `-h` argument.

With this changed the help related blocks of `SetupRootCommand` and
`SetupPluginRootCommand` are now identical, so consolidate into
`setupCommonRootCommand`.

Tests are updated to check `-h` in a variety of scenarios, including the happy
case here.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-03-28 17:18:20 +00:00
Ian Campbell 0b30592ee0 e2e/cli-plugins: improve checks for empty output by using `icmd.None`
In some cases this means switching to `icmd.Expected` rather than
`icmd.Success`, but this improves readability overall.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-03-28 14:30:51 +00:00
Tibor Vass f40f9c240a
Merge pull request #1770 from kolyshkin/fix-archive-detection
Fix archive detection
2019-03-21 16:48:15 -07:00
Tibor Vass 086df60bab
Merge pull request #1692 from thaJeztah/remove_bashisms
Remove some bashisms
2019-03-21 16:17:49 -07:00
Lifubang 06e250d37b add test case for DetectArchiveReader
Signed-off-by: Lifubang <lifubang@acmcoder.com>
2019-03-21 15:38:31 -07:00
Kir Kolyshkin 0c20554f69 image build: fix archive detection
As pointed out in #1459, docker cli fails to detect that the input is a tarball,
in case it is generated by `git archive --format=tgz`.

This happens because `git archive` adds some metadata to the initial tar header,
and so it is more than 1 block (of 512 bytes) long, while we only provide 1 block
to archive/tar.Next() and it fails.

To fix, give it 2 blocks :)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-03-21 15:38:07 -07:00
Tibor Vass 984ad2f075
Merge pull request #1626 from albers/completion-engine
Add bash completion for `docker engine` command family
2019-03-21 14:51:56 -07:00
leonGravel 95ce54a8de give `docker save` a gzip usage guide (#1678)
give `docker save` a gzip usage guide

Signed-off-by: Ao Li <la9249@163.com>
2019-03-21 14:49:21 -07:00
Tõnis Tiigi dca6d2afa1
Merge pull request #1765 from thaJeztah/carry_181_pids_limit
Add `--pids-limit` flag to `docker update`
2019-03-21 14:11:09 -07:00
Tõnis Tiigi cb6b33f038
Merge pull request #1768 from simonferquel/experimental-flag-message
Fix error message on experimental flags
2019-03-21 14:09:33 -07:00
Harald Albers e3544b2e99 Add bash completion for `docker engine` command family
Signed-off-by: Harald Albers <github@albersweb.de>
2019-03-21 22:02:48 +01:00
Sebastiaan van Stijn 059c085261
Merge pull request #1714 from tiborvass/nvidia-gpu
container: --gpus support
2019-03-21 21:26:16 +01:00
Tibor Vass 1ba368a5ac container: --gpus support
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-03-21 20:14:25 +00:00
Tibor Vass bc5ad41e87
Merge pull request #1766 from tonistiigi/outputs
build: allow setting buildkit outputs
2019-03-21 10:49:46 -07:00
Tonis Tiigi ca6eb5049b build: allow setting buildkit outputs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2019-03-21 10:27:59 -07:00
Sebastiaan van Stijn bc564080a9
Merge pull request #1769 from simonferquel/fix-config-create-annotation
Fix annnotation on docker config create --template-driver
2019-03-21 17:41:16 +01:00
Simon Ferquel 3beb60a96e Fix error message on experimental flags
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2019-03-21 16:21:03 +01:00
Simon Ferquel 470afe11ed Fix annnotation on docker config create --template-driver
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2019-03-21 16:19:06 +01:00
Sebastiaan van Stijn f1ca9f15d5
Merge pull request #1764 from StefanScherer/windows-platform-ldflags
Fix Windows LDFLAGS to use cli version package
2019-03-21 13:06:12 +01:00
Sebastiaan van Stijn 93f34dc097
Merge pull request #1727 from albers/completion-builder-prune
Add bash completion for `builder prune`
2019-03-21 12:08:07 +01:00
Sebastiaan van Stijn 62a9303232
Merge pull request #1726 from albers/completion-network-ls-filter-dangling
Add bash completion for `network ls --filter dangling`
2019-03-21 10:53:24 +01:00
Sunny de3a5f0fe5
Add `--pids-limit` flag to `docker update`
Signed-off-by: Sunny Gogoi <indiasuny000@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-21 01:20:32 +01:00
Stefan Scherer 69754ea952
Fix Windows LDFLAGS to use cli version package
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2019-03-20 15:33:17 -07:00
Tibor Vass 774d78fcb8
Merge pull request #1760 from StefanScherer/windows-programfiles-docker-cli-plugins
Search Windows CLI plugins also in ProgramFiles
2019-03-20 14:03:42 -07:00
Tibor Vass fd9d2e2b03
Merge pull request #1759 from thaJeztah/update_authors
Update authors
2019-03-20 14:02:30 -07:00
Tibor Vass 5b70f5a2da
Merge pull request #1763 from thaJeztah/bump_docker_licensing
bump docker/licensing to 9781369abdb5281cdc07a2a446c6df01347ec793
2019-03-20 13:57:08 -07:00
Silvin Lubecki 91339e1108
Merge pull request #1758 from thaJeztah/bump_some_deps
Update some dependencies
2019-03-20 21:26:33 +01:00
Stefan Scherer 4d3a76d71e
Search Windows CLI plugins also in ProgramFiles
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2019-03-20 11:45:03 -07:00
Sebastiaan van Stijn 5ac07c795f
bump docker/licensing to 9781369abdb5281cdc07a2a446c6df01347ec793
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-20 18:52:19 +01:00
Vincent Demeester f762697628
Merge pull request #1756 from thaJeztah/bump_engine_no_buildkit
Update docker/docker, containerd, runc, and some dependencies
2019-03-20 11:35:55 +01:00
Sebastiaan van Stijn 9a39a10e03
Merge pull request #1754 from thaJeztah/add_sysctls_for_services
Add systctl support for services
2019-03-20 00:17:33 +01:00
Sebastiaan van Stijn 9d802706a5
vendor github.com/Microsoft/go-winio v0.4.12
no local changes

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 22:22:11 +01:00
Sebastiaan van Stijn aaffb71746
vendor golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 22:22:03 +01:00
Sebastiaan van Stijn e06dedf365
bump containerd, runc and dependencies
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 22:22:00 +01:00
Sebastiaan van Stijn 208d69918d
vendor swarmkit 415dc72789e2b733ea884f09188c286ca187d8ec
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 22:21:57 +01:00
Sebastiaan van Stijn 5ccaaef8c1
vendor golang.org/x/sys d455e41777fca6e8a5a79e34a14b8368bc11d9ba
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 22:21:54 +01:00
Sebastiaan van Stijn fd769e1aff
Update docker/docker to 827cb09f87964ed38b46502f22a585f2ed4a78e1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 22:21:51 +01:00
Sebastiaan van Stijn 84d34d959a
bump imdario/mergo v0.3.7
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 17:13:08 +01:00
Sebastiaan van Stijn 5db2f9e301
bump json-iterator/go 1.1.6
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 17:13:03 +01:00
Sebastiaan van Stijn a29b0c945d
bump mattn/go-shellwords v1.0.5
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 17:13:00 +01:00
Sebastiaan van Stijn 0f0cedc5ac
bump github.com/pkg/errors v0.8.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 17:12:57 +01:00
Sebastiaan van Stijn b5993fa3b2
Update authors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 17:06:36 +01:00
Sebastiaan van Stijn 6d59892b66
Merge pull request #1704 from ijc/allow-passing-args-to-e2e-tests
Allow flags to be passed to e2e tests
2019-03-19 13:37:28 +01:00
Sebastiaan van Stijn f620349837
Add systctl support for services
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 13:33:32 +01:00
Vincent Demeester a4a50de4b8
Merge pull request #1671 from thaJeztah/fix_labels_expanding_env_vars
Fix labels copying value from environment variables
2019-03-19 12:18:55 +01:00
Vincent Demeester fc9ef7087e
Merge pull request #1732 from sjeandeaux/fix/issue-117
[pretty print] pretty print and healthcheck
2019-03-19 11:54:41 +01:00
Vincent Demeester 2871b723ad
Merge pull request #1746 from thaJeztah/carry_compose_template_driver
[carry] Add support for `template_driver` in composefiles
2019-03-19 08:09:27 +01:00
Sebastiaan van Stijn e5702e000c
Tweak validation messages
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 03:17:02 +01:00
Sebastiaan van Stijn b5d0d179e7
Add back validation for invalid label values on containers
This adds validation to `docker container run` / `docker container create`;

Validation of labels provided through flags was removed in 31dc5c0a9a,
after the validation was changed to fix labels without values, and to prevent
labels from being expanded with environment variables in 2b17f4c8a8

However, now empty label names from _files_ (`--label-file`) followed different
validation rules than labels passed through `--label`.

This patch adds back minimal validation for labels passed through the command-line

Before this patch:

```bash
docker container create \
  --name label \
  --label==with-leading-equal-sign \
  --label=without-value \
  --label=somelabel=somevalue \
  --label "  =  " \
  --label=with-quotes-in-value='{"foo"}' \
  --label='with"quotes"in-key=test' \
  busybox

docker container inspect --format '{{json .Config.Labels}}' label
```

```json
{
  "": "with-leading-equal-sign",
  "  ": "  ",
  "somelabel": "somevalue",
  "with\"quotes\"in-key": "test",
  "with-quotes-in-value": "{\"foo\"}",
  "without-value": ""
}
```

After this patch:

```bash
docker container create \
  --name label \
  --label==with-leading-equal-sign \
  --label=without-value \
  --label=somelabel=somevalue \
  --label "  =  " \
  --label=with-quotes-in-value='{"foo"}' \
  --label='with"quotes"in-key=test' \
  busybox

invalid argument "=with-leading-equal-sign" for "-l, --label" flag: invalid label format: "=with-leading-equal-sign"
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 03:02:06 +01:00
Sebastiaan van Stijn f2424bd375
Fix labels copying value from environment variables
This patch fixes a bug where labels use the same behavior as `--env`, resulting
in a value to be copied from environment variables with the same name as the
label if no value is set (i.e. a simple key, no `=` sign, no value).

An earlier pull request addressed similar cases for `docker run`;
2b17f4c8a8, but this did not address the
same situation for (e.g.) `docker service create`.

Digging in history for this bug, I found that use of the `ValidateEnv`
function for  labels was added in the original implementation of the labels feature in
abb5e9a077 (diff-ae476143d40e21ac0918630f7365ed3cR34)

However, the design never intended it to expand environment variables,
and use of this function was either due to either a "copy/paste" of the
equivalent `--env` flags, or a misunderstanding (the name `ValidateEnv` does
not communicate that it also expands environment variables), and the existing
`ValidateLabel` was designed for _engine_ labels (which required a value to
be set).

Following the initial implementation, other parts of the code followed
the same (incorrect) approach, therefore leading the bug to be introduced
in services as well.

This patch:

- updates the `ValidateLabel` to match the expected validation
  rules (this function is no longer used since 31dc5c0a9a),
  and the daemon has its own implementation)
- corrects various locations in the code where `ValidateEnv` was used instead of `ValidateLabel`.

Before this patch:

```bash
export SOME_ENV_VAR=I_AM_SOME_ENV_VAR
docker service create --label SOME_ENV_VAR --tty --name test busybox

docker service inspect --format '{{json .Spec.Labels}}' test
{"SOME_ENV_VAR":"I_AM_SOME_ENV_VAR"}
```

After this patch:

```bash
export SOME_ENV_VAR=I_AM_SOME_ENV_VAR
docker service create --label SOME_ENV_VAR --tty --name test busybox

docker container inspect --format '{{json .Config.Labels}}' test
{"SOME_ENV_VAR":""}
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 03:01:57 +01:00