DockerCLI/cli
Sebastiaan van Stijn cf663b526a
cli: perform feature detection lazily
- Perform feature detection when actually needed, instead of during
  initializing
- Version negotiation is performed either when making an API request,
  or when (e.g.) running `docker help` (to hide unsupported features)
- Use a 2 second timeout when 'pinging' the daemon; this should be
  sufficient for most cases, and when feature detection failed, the
  daemon will still perform validation (and produce an error if needed)
- context.WithTimeout doesn't currently work with ssh connections (connhelper),
  so we're only applying this timeout for tcp:// connections, otherwise
  keep the old behavior.

Before this change:

    time sh -c 'DOCKER_HOST=tcp://42.42.42.41:4242 docker help &> /dev/null'
    real   0m32.919s
    user   0m0.370s
    sys    0m0.227s

    time sh -c 'DOCKER_HOST=tcp://42.42.42.41:4242 docker context ls &> /dev/null'
    real   0m32.072s
    user   0m0.029s
    sys    0m0.023s

After this change:

    time sh -c 'DOCKER_HOST=tcp://42.42.42.41:4242 docker help &> /dev/null'
    real   0m 2.28s
    user   0m 0.03s
    sys    0m 0.03s

    time sh -c 'DOCKER_HOST=tcp://42.42.42.41:4242 docker context ls &> /dev/null'
    real   0m 0.13s
    user   0m 0.02s
    sys    0m 0.02s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit b39739123b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-29 17:12:23 +02:00
..
command cli: perform feature detection lazily 2020-04-29 17:12:23 +02:00
compose bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
config bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
connhelper bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
context bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
debug updated vendoring 2017-09-01 19:41:06 -04:00
flags bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
manifest bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
registry/client cli: remove unnecessary newlines (whitespace) 2020-01-06 13:16:57 +01:00
streams Extract streams helpers from command package to their own package to remove a cyclic dependency from command to internal/containerizedengine 2019-01-28 14:36:00 +01:00
trust bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
version Move versioning variables to a separate package. 2019-01-29 11:26:40 +00:00
winresources Add windows resources to binary. 2017-05-15 18:03:03 -04:00
cobra.go cli-plugins: Reinstate deprecated `-h` short form of `--help`. 2019-03-28 17:18:20 +00:00
cobra_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00
error.go Import docker/docker/cli 2017-04-17 17:40:59 -04:00
required.go Disable unparam linter: cli/required.go:102:16: `pluralize` - `word` always receives `"argument"` (unparam) 2020-01-06 13:16:40 +01:00
required_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-04-21 16:43:18 +02:00