Commit Graph

5138 Commits

Author SHA1 Message Date
0e64c4ed59 Merge pull request #1105 from vdemeester/1044-compress-stream-friend
Fix panics when --compress and --stream are used together
Upstream-commit: d1cc8c731e
Component: cli
2018-06-01 23:00:01 +02:00
a87a3769f8 Fix panics when --compress and --stream are used together
Warns that `-compress` has no effect when used together with the
expremintal `--stream` flag.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 8b3dc39fce
Component: cli
2018-06-01 18:34:00 +02:00
d1ccf01fd1 Merge pull request #1101 from silvin-lubecki/filter-stack-service
Fix service filtering by name on Kubernetes
Upstream-commit: 7db15a4553
Component: cli
2018-06-01 15:50:34 +02:00
6f7cfb3c58 Merge pull request #1094 from thaJeztah/hide_checkpoint_on_windows
Hide experimental checkpoint features on Windows
Upstream-commit: 63ad0a0e88
Component: cli
2018-06-01 15:49:51 +02:00
2d6b52f5ec Merge pull request #1097 from vdemeester/x-objects
Allow `x-*` extension on 3rd level objects
Upstream-commit: eb54d3e5c0
Component: cli
2018-06-01 15:48:04 +02:00
14b4abdabd Fix service filtering by name on Kubernetes to mimic Swarm filtering
*  Kubernetes native filtering (server side) is an exact match, now filtering on name is made client-side to add prefix-matching

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: b1ff199167
Component: cli
2018-06-01 15:43:02 +02:00
a76ed6f917 YAML docs: add os_type property on flags and (sub)commands
This patch adds an `os_type` property in the generated YAML docs, both for
commands, and for flags;

Note that the ostype annotation on flags can have multiple values set,
however, multiple values are currently not used (and unlikely will).

To simplify usage of the os_type property in the YAML, and for consistency with
the same property for commands, we're only using the first ostype that's set.

```yaml
command: docker checkpoint create
short: Create a checkpoint from a running container
long: Create a checkpoint from a running container
usage: docker checkpoint create [OPTIONS] CONTAINER CHECKPOINT [flags]
pname: docker checkpoint
plink: docker_checkpoint.yaml
options:
- option: checkpoint-dir
  value_type: string
  description: Use a custom checkpoint storage directory
  deprecated: false
  experimental: false
  experimentalcli: false
  kubernetes: false
  swarm: false
- option: leave-running
  value_type: bool
  default_value: "false"
  description: Leave the container running after checkpoint
  deprecated: false
  experimental: false
  experimentalcli: false
  kubernetes: false
  swarm: false
deprecated: false
min_api_version: "1.25"
experimental: true
experimentalcli: false
kubernetes: false
swarm: false
os_type: windows
```

```yaml
command: docker container start
short: Start one or more stopped containers
long: Start one or more stopped containers
usage: docker container start [OPTIONS] CONTAINER [CONTAINER...] [flags]
pname: docker container
plink: docker_container.yaml
options:
- option: attach
  shorthand: a
  value_type: bool
  default_value: "false"
  description: Attach STDOUT/STDERR and forward signals
  deprecated: false
  experimental: false
  experimentalcli: false
  kubernetes: false
  swarm: false
- option: checkpoint
  value_type: string
  description: Restore from this checkpoint
  deprecated: false
  experimental: true
  experimentalcli: false
  kubernetes: false
  swarm: false
  os_type: linux
- option: checkpoint-dir
  value_type: string
  description: Use a custom checkpoint storage directory
  deprecated: false
  experimental: true
  experimentalcli: false
  kubernetes: false
  swarm: false
  os_type: linux
- option: detach-keys
  value_type: string
  description: Override the key sequence for detaching a container
  deprecated: false
  experimental: false
  experimentalcli: false
  kubernetes: false
  swarm: false
- option: interactive
  shorthand: i
  value_type: bool
  default_value: "false"
  description: Attach container's STDIN
  deprecated: false
  experimental: false
  experimentalcli: false
  kubernetes: false
  swarm: false
deprecated: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: be035a0272
Component: cli
2018-05-31 22:31:31 +02:00
ee64293c17 Mark checkpoint feature as Linux-only, and homogenize error messages
This patch adds annotations to mark the checkpoint commands as Linux only, which
hides them if the daemon is running a non-matching operating-system type;

Before:

    docker

    Usage:	docker COMMAND

    A self-sufficient runtime for containers

    ...

    Management Commands:
      config      Manage Docker configs
      container   Manage containers
      image       Manage images

After:

    docker

    Usage:	docker COMMAND

    A self-sufficient runtime for containers

    ...

    Management Commands:
      checkpoint  Manage checkpoints
      config      Manage Docker configs
      container   Manage containers
      image       Manage images

This change also prints errors when attempting to use checkpoint commands or
flags if the feature is not supported by the Daemon's operating system;

    $ docker checkpoint --help
    docker checkpoint is only supported on a Docker daemon running on linux, but the Docker daemon is running on windows

    $ docker checkpoint create --help
    docker checkpoint create is only supported on a Docker daemon running on linux, but the Docker daemon is running on windows

    $ docker checkpoint ls --help
    docker checkpoint ls is only supported on a Docker daemon running on linux, but the Docker daemon is running on windows

    $ docker checkpoint rm --help
    docker checkpoint rm is only supported on a Docker daemon running on linux, but the Docker daemon is running on windows

    $ docker container start --checkpoint=foo mycontainer
    "--checkpoint" requires the Docker daemon to run on linux, but the Docker daemon is running on windows

    $ docker container start --checkpoint-dir=/foo/bar mycontainer
    "--checkpoint-dir" requires the Docker daemon to run on linux, but the Docker daemon is running on windows

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 1df6b68111
Component: cli
2018-05-31 22:25:06 +02:00
0e3e1012ac Allow x-* extension on 3rd level objects
As for top-level key, any 3rd-level key which starts with `x-` will be
ignored by compose. This allows for users to:
* include additional metadata in their compose files
* create YAML anchor objects that can be re-used in other parts of the config

This matches a similar feature in the swagger spec definition:
https://swagger.io/specification/#specificationExtensions

This means a composefile like the following is valid

```
verison: "3.7"
services:
  foo:
    image: foo/bar
    x-foo: bar
network:
  bar:
    x-bar: baz
```

It concerns services, volumes, networks, configs and secrets.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 6bcfa8806c
Component: cli
2018-05-31 13:38:58 +02:00
2f36c5552c Add test for version output aligning
Includes some refactoring to allow testing the output
in isolation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: bb71808605
Component: cli
2018-05-31 10:15:15 +02:00
7dd704f7ab Merge pull request #1093 from silvin-lubecki/fix-listing-nodes
Fix always listing nodes in docker stack ps command
Upstream-commit: a8ee42ad53
Component: cli
2018-05-30 16:05:14 +02:00
5944032f12 Fix outputting twice the docker stack rm error message
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: a252cb1197
Component: cli
2018-05-30 15:56:41 +02:00
560846bf75 Fix always listing nodes during docker stack ps command on Kubernetes. A user without node listing rights could not use this command as it always fails.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 66059a925b
Component: cli
2018-05-30 15:28:35 +02:00
4fb60eb421 Add tests for Kubernetes
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
Upstream-commit: d420d67bcd
Component: cli
2018-05-29 15:26:07 +02:00
35713286b5 Make e2e test image
- Build image that contains everything needed to run e2e tests
- Add ability to run e2e tests against an endpoint

Signed-off-by: Christopher Crone <christopher.crone@docker.com>
Upstream-commit: 6b38918ce4
Component: cli
2018-05-29 13:39:31 +02:00
80262c1f77 Merge pull request #1090 from zkry/1089-quiet-stream-output-fix
Add String method so quieted output displays properly
Upstream-commit: daf021fe60
Component: cli
2018-05-29 12:43:26 +02:00
8393c32adf Support for rollback config in compose 3.7
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 4e6e5d583c
Component: cli
2018-05-29 11:37:51 +02:00
0a85ad23b1 Add composefile schema 3.7
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: df6e38b81a
Component: cli
2018-05-29 11:37:12 +02:00
40e9cf63c8 Add String method so quieted output displays properly
Fixes #1089

Signed-off-by: Zachary Romero <zacromero3@gmail.com>
Upstream-commit: b6cf6d87ae
Component: cli
2018-05-29 05:30:17 +03:00
776d9e8d2e Merge pull request #1068 from silvin-lubecki/remove-experimental-for-orchestrator
Remove Kubernetes commands from experimental
Upstream-commit: 824a0b4db9
Component: cli
2018-05-28 17:39:11 +02:00
2720165925 Validate stack-names for empty values
Add validation for stack names to prevent an empty name resulting in _all_
stacks to be returned after filtering, which can result in removal of services
for all stacks if `--prune`, or `docker stack rm` is used.

Before this change;

    docker stack deploy -c docker-compose.yml one
    docker stack deploy -c docker-compose.yml two
    docker stack deploy -c docker-compose.yml three

    docker stack deploy -c docker-compose.yml --prune ''
    Removing service one_web
    Removing service two_web
    Removing service three_web

After this change:

    docker stack deploy -c docker-compose.yml one
    docker stack deploy -c docker-compose.yml two
    docker stack deploy -c docker-compose.yml three

    docker stack deploy -c docker-compose.yml --prune ''
    invalid stack name: ""

Other stack commands were updated as well:

Before this change;

    docker stack deploy -c docker-compose.yml ''
    Creating network _default
    failed to create network _default: Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component

    docker stack ps ''
    nothing found in stack:

    docker stack rm ''
    Removing service one_web
    Removing service three_web
    Removing service two_web

After this change:

    docker stack deploy -c docker-compose.yml ''
    invalid stack name: ""

    docker stack ps ''
    invalid stack name: ""

    docker stack rm ''
    invalid stack name: ""

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: d38f397da1
Component: cli
2018-05-28 17:03:26 +02:00
be0c4cd5b8 Check allNamespace config value while loading configuration file
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: fb34ffc327
Component: cli
2018-05-28 15:15:25 +02:00
e1b9b6c0be Remove experimentalCli annotation from all kubernetes flags and commands
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: f2b75a879a
Component: cli
2018-05-28 15:06:31 +02:00
0fb2bafbb4 Merge pull request #1084 from thaJeztah/minor-code-refactor
Minor refactor in stack helper functions
Upstream-commit: 537e67d462
Component: cli
2018-05-28 12:39:15 +02:00
ec563a652e Minor refactor in stack helper functions
- Don't wrap the code to be slightly more readable
- Rename `getServiceFilter()` to `getStackServiceFilter()` to be
  consistent with other helper functions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 0c175fc21a
Component: cli
2018-05-28 12:26:14 +02:00
3b6fda6f6c Merge pull request #1059 from mat007/kubernetes-orchestrator-all-namespaces
Kubernetes orchestrator all namespaces
Upstream-commit: 82053236a3
Component: cli
2018-05-28 11:59:54 +02:00
108f480da7 --orchestrator flag is now a persistent flag
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 770daef564
Component: cli
2018-05-28 10:43:32 +02:00
4daf98b735 Imply all Kubernetes namespaces for docker stack list when orchestrator is all or Kubernetes
* Add "kubernetes" struct in config file with "allNamespaces" option, to opt-out this behavior when set as "disabled"

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 1c1300bef6
Component: cli
2018-05-28 10:43:32 +02:00
b47e46b815 Merge pull request #1023 from simonferquel/k8s-stack-services-filters
[Kubernetes] stack services filters
Upstream-commit: 0089f172b7
Component: cli
2018-05-24 19:56:33 +02:00
79dd15d857 Match Swarm in how to combine filters
`docker stack services --filter=label=foo=bar --filter=label=foo=baz my-stack` with Swarm gets handled as `filter on (a label named foo with value bar) AND (a label named foo with value baz).
This obviously yields an empty result set every time, but if and how this should be changed is out of scope here, so simply align Kubernetes with Swarm for now.

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 297866ebbe
Component: cli
2018-05-24 15:24:23 +02:00
11041e23de Merge pull request #1079 from thaJeztah/fix_update_memory_cpu_limit
Fix cpu/memory limits and reservations being reset on service update
Upstream-commit: 57ce5aa18d
Component: cli
2018-05-24 12:01:22 +02:00
2b328bedc5 Update vndr commit to latest
Some fixes and it also preserves directories with *.c files now.

See a6e196d8b4...1fc68ee0c8

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 08d6c18570
Component: cli
2018-05-24 09:39:22 +02:00
5fba89897b Minor refactor: use anyChanged() to detect changed flags
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: df9a0c7797
Component: cli
2018-05-24 01:30:09 +02:00
467129b37c Fix cpu/memory limits and reservations being reset on service update
Before this change:
----------------------------------------------------

Create a service with reservations and limits for memory and cpu:

    docker service create --name test \
      --limit-memory=100M --limit-cpu=1 \
      --reserve-memory=100M --reserve-cpu=1 \
      nginx:alpine

Verify the configuration

    docker service inspect --format '{{json .Spec.TaskTemplate.Resources}}' test
    {
      "Limits": {
        "NanoCPUs": 1000000000,
        "MemoryBytes": 104857600
      },
      "Reservations": {
        "NanoCPUs": 1000000000,
        "MemoryBytes": 104857600
      }
    }

Update just CPU limit and reservation:

    docker service update --limit-cpu=2 --reserve-cpu=2 test

Notice that the memory limit and reservation is not preserved:

    docker service inspect --format '{{json .Spec.TaskTemplate.Resources}}' test
    {
      "Limits": {
        "NanoCPUs": 2000000000
      },
      "Reservations": {
        "NanoCPUs": 2000000000
      }
    }

Update just Memory limit and reservation:

    docker service update --limit-memory=200M --reserve-memory=200M test

Notice that the CPU limit and reservation is not preserved:

    docker service inspect --format '{{json .Spec.TaskTemplate.Resources}}' test
    {
      "Limits": {
        "MemoryBytes": 209715200
      },
      "Reservations": {
        "MemoryBytes": 209715200
      }
    }

After this change:
----------------------------------------------------

Create a service with reservations and limits for memory and cpu:

    docker service create --name test \
      --limit-memory=100M --limit-cpu=1 \
      --reserve-memory=100M --reserve-cpu=1 \
      nginx:alpine

Verify the configuration

    docker service inspect --format '{{json .Spec.TaskTemplate.Resources}}' test
    {
      "Limits": {
        "NanoCPUs": 1000000000,
        "MemoryBytes": 104857600
      },
      "Reservations": {
        "NanoCPUs": 1000000000,
        "MemoryBytes": 104857600
      }
    }

Update just CPU limit and reservation:

    docker service update --limit-cpu=2 --reserve-cpu=2 test

Confirm that the CPU limits/reservations are updated, but memory limit and reservation are preserved:

    docker service inspect --format '{{json .Spec.TaskTemplate.Resources}}' test
    {
      "Limits": {
        "NanoCPUs": 2000000000,
        "MemoryBytes": 104857600
      },
      "Reservations": {
        "NanoCPUs": 2000000000,
        "MemoryBytes": 104857600
      }
    }

Update just Memory limit and reservation:

    docker service update --limit-memory=200M --reserve-memory=200M test

Confirm that the Mempry limits/reservations are updated, but CPU limit and reservation are preserved:

    docker service inspect --format '{{json .Spec.TaskTemplate.Resources}}' test
    {
      "Limits": {
        "NanoCPUs": 2000000000,
        "MemoryBytes": 209715200
      },
      "Reservations": {
        "NanoCPUs": 2000000000,
        "MemoryBytes": 209715200
      }
    }

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: df43eb931e
Component: cli
2018-05-24 01:30:00 +02:00
b8ca625f10 Add filter support for stack ps and services with Kubernetes
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 1f7aa1c036
Component: cli
2018-05-23 18:27:27 +02:00
274de24328 Merge pull request #1070 from taiji-tech/master
Update document links of help and comments to make it up-to-date
Upstream-commit: fd6165399d
Component: cli
2018-05-22 16:00:10 +02:00
98885f36d7 Update document links and title.
Signed-off-by: taiji-tech <csuhqg@foxmail.com>
Upstream-commit: 5119c4d8ef
Component: cli
2018-05-22 21:13:41 +08:00
d036351aa0 Merge pull request #1035 from mat007/kubernetes-check-hosts-match
For docker stack ls make an error if Swarm and Kubernetes hosts do not match
Upstream-commit: cc6ff56fd5
Component: cli
2018-05-22 14:50:09 +02:00
de98e98ecd For docker stack ls make an error if Swarm and Kubernetes hosts do no match
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: bfe9aed63a
Component: cli
2018-05-22 14:39:48 +02:00
e48b3121b7 Fix e2e/system tests
a setup step is required and the test fails.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 0016ff9c15
Component: cli
2018-05-22 14:36:41 +02:00
eba4c4ac67 Merge pull request #1072 from AntaresS/add-inspect-test
move inspect test from moby to cli
Upstream-commit: 0022bb83ea
Component: cli
2018-05-21 15:01:03 -10:00
c83bf05cc2 move inspect test from moby to cli
Signed-off-by: Anda Xu <anda.xu@docker.com>
Upstream-commit: 2d8d5fcd30
Component: cli
2018-05-21 15:57:39 -07:00
364c8ffbeb Merge pull request #1043 from justyntemme/patch-2
Fix issue #850, Warn user of filter when pruning
Upstream-commit: 680c5790d5
Component: cli
2018-05-22 00:26:26 +02:00
beaa0fd5b3 Merge pull request #1069 from thaJeztah/bump-cobra-pflags
Update Cobra and pflag, and use built-in --version feature
Upstream-commit: 09115e3750
Component: cli
2018-05-21 15:23:16 -07:00
1eb50df5ea Merge pull request #1054 from thaJeztah/fix-host-rm-being-too-greedy
Fix service update --host-rm not being granular enough
Upstream-commit: 7bdd820f28
Component: cli
2018-05-21 15:21:06 -07:00
c631ba5714 Merge pull request #1053 from justyntemme/patch-3
Change error message for unreadable files
Upstream-commit: 9a89c32e9a
Component: cli
2018-05-22 00:12:46 +02:00
c7c3e2db9d fix error message from docker inspect
Signed-off-by: Anda Xu <anda.xu@docker.com>
Upstream-commit: d2090430a6
Component: cli
2018-05-21 11:32:16 -07:00
31fc695941 Hide [flags] in usage output
This patch hides the [flags] in the usage output of commands, using the
new `.DisableFlagsInUseLine` option, instead of the temporary workaround
added in 8e600e10f7

Before this change:

    docker run
    "docker run" requires at least 1 argument.
    See 'docker run --help'.

    Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...] [flags]

    Run a command in a new container

After this change:

    docker run
    "docker run" requires at least 1 argument.
    See 'docker run --help'.

    Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

    Run a command in a new container

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 00d080269a
Component: cli
2018-05-19 02:51:55 +02:00
6e165aeab9 Use Cobra built-in --version feature
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a3fe7d62b8
Component: cli
2018-05-19 02:51:43 +02:00
efb6dd914b Bump spf13/cobra to v0.0.3, spf13/pflag to v1.0.1
Use a tagged release of Cobra

Relevant changes:

- spf13/cobra#567 Add `CalledAs` method to cobra.Command
- spf13/cobra#580 Update error message for missing required flags
- spf13/cobra#584 Add support for --version flag
- spf13/cobra#614 If user has a project in symlink, just use its destination folder and work there
- spf13/cobra#649 terminates the flags when -- is found in commandline
- spf13/cobra#662 Add support for ignoring parse errors
- spf13/cobra#686 doc: hide hidden parent flags

Also various improvements were added for generating Bash
completion scripts (currently not used by us)

Bump spf13/pflag to v1.0.1

Relevant changes:

- spf13/pflag#122 DurationSlice: implementation and tests
- spf13/pflag#115 Implement BytesHex type of argument
- spf13/pflag#150 Add uintSlice and boolSlice to name prettifier
- spf13/pflag#155 Add multiline wrapping support
- spf13/pflag#158 doc: clarify difference between string slice vs. array
- spf13/pflag#160 add ability to ignore unknown flags
- spf13/pflag#163 Allow Users To Show Deprecated Flags

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 0acb2522bd
Component: cli
2018-05-19 02:51:33 +02:00