Commit graph

540 commits

Author SHA1 Message Date
Sebastiaan van Stijn
5f0703c549
client: remove containerd "platform" dependency
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-07-29 23:32:46 +02:00
Sebastiaan van Stijn
b33f3c7802
client: remove unused Platform field from configWrapper
This field was added in 7a9cb29fb9,
but appears to be unused, so removing it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-07-29 23:28:12 +02:00
Roman Volosatovs
47ad2f3dd6
API,daemon: support type URL parameter to /system/df
Let clients choose object types to compute disk usage of.

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
2021-07-27 12:17:45 +02:00
Akihiro Suda
b9ad7b96bd
Merge pull request #41778 from kplachkov/feature/fix_err_canceled
Fix converting status code to error canceled
2021-06-17 17:26:14 +09:00
Sebastiaan van Stijn
b92be7e297
client: S1031: unnecessary nil check around range (gosimple)
client/request.go:245:2: S1031: unnecessary nil check around range (gosimple)
        if headers != nil {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-10 13:03:23 +02:00
Kostadin Plachkov
cd40eb89ae Fix client request error handling
Signed-off-by: Kostadin Plachkov <k.n.plachkov@gmail.com>
2021-05-29 01:06:58 +02:00
Sebastiaan van Stijn
328de0b8d9
Update documentation links
- Using "/go/" redirects for some topics, which allows us to
  redirect to new locations if topics are moved around in the
  documentation.
- Updated some old URLs to their new location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-25 12:11:50 +01:00
Levi Harrison
8128a9a478 Fix grammar in client function comments
Changes certain words and adds punctuation to the comments of functions in the client package, which end up in the GoDoc documentation. Areas where only periods were needed were ignored to prevent excessive code churn.

Signed-off-by: Levi Harrison <levisamuelharrison@gmail.com>
2021-02-16 10:07:44 -05:00
Tobias Pfandzelter
963e5afc04 Update documentation to reflect deprecation of "NewEnvClient"
As `NewEnvClient` is deprecated in favor of `NewClientWithOpts`, the main package documentation should reflect this. This is also the text that appears on godoc.org so it's quite important that it is correct (for newbies like me)

Signed-off-by: Tobias Pfandzelter <pfandzelter@campus.tu-berlin.de>
2020-10-03 15:12:30 +02:00
Evgeniy Makhrov
8ccb46a521 Check for context error that is wrapped in url.Error
Signed-off-by: Evgeniy Makhrov <e.makhrov@corp.badoo.com>
2020-08-03 15:59:22 +03:00
Tibor Vass
ca689bfd8d
Merge pull request #40826 from thaJeztah/cleanup_service
ServiceCreate/ServiceUpdate: refactor and fix potential NPE
2020-07-28 10:47:21 +02:00
Julien Pivotto
87a7fc1ced Enable client on netbsd and dragonfly
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-06-20 01:32:35 +02:00
Tibor Vass
5c10ea6ae8
Merge pull request #40725 from cpuguy83/check_img_platform
Accept platform spec on container create
2020-05-21 11:33:27 -07:00
Sebastiaan van Stijn
07d60bc257
Replace errors.Cause() with errors.Is() / errors.As()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-29 00:28:41 +02:00
Sebastiaan van Stijn
ed096538e8
extract logic for resolving image/plugin digest and platform
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-16 21:30:57 +02:00
Sebastiaan van Stijn
10c748cd39
imageWithDigestString: return image unmodified if there are no changes
Instead of returning an empty string, return the image unmodified

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-16 13:45:34 +02:00
Sebastiaan van Stijn
799bd475fb
ServiceCreate/ServiceUpdate: refactor and fix potential NPE
- `ContainerSpec` and `PluginSpec` are mutually exclusive, so instead of using
  two separate if-statements, combine them in a switch.
- Use local variables (at cost of some slight duplication)
- Fix a potential NPE if image-digest resolution failed for a `PluginSpec`.
  The code was always using `ContainerSpec.Image` to create a `digestWarning`,
  but in case we're resoling the digest for a `PluginSpec`, `ContainerSpec`
  will be `nil` (as they're mutually exclusive). This issue was introduced in
  72c3bcf2a5, where the new `PluginSpec` path
  was added.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-16 13:45:03 +02:00
Brian Goff
7a9cb29fb9 Accept platform spec on container create
This enables image lookup when creating a container to fail when the
reference exists but it is for the wrong platform. This prevents trying
to run an image for the wrong platform, as can be the case with, for
example binfmt_misc+qemu.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-03-20 16:10:36 -07:00
Brian Goff
ce1ceeb257 Add stats options to not prime the stats
Metrics collectors generally don't need the daemon to prime the stats
with something to compare since they already have something to compare
with.
Before this change, the API does 2 collection cycles (which takes
roughly 2s) in order to provide comparison for CPU usage over 1s. This
was primarily added so that `docker stats --no-stream` had something to
compare against.

Really the CLI should have just made a 2nd call and done the comparison
itself rather than forcing it on all API consumers.
That ship has long sailed, though.

With this change, clients can set an option to just pull a single stat,
which is *at least* a full second faster:

Old:
```
time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=false > /dev/null
2>&1

real0m1.864s
user0m0.005s
sys0m0.007s

time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=false > /dev/null
2>&1

real0m1.173s
user0m0.010s
sys0m0.006s
```

New:
```
time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=true > /dev/null
2>&1
real0m0.680s
user0m0.008s
sys0m0.004s

time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=true > /dev/null
2>&1

real0m0.156s
user0m0.007s
sys0m0.007s
```

This fixes issues with downstreams ability to use the stats API to
collect metrics.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-02-28 09:54:37 -08:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 00:06:42 +01:00
Sebastiaan van Stijn
ac058c1629
Merge pull request #40340 from thaJeztah/swagger_remove_classic_swarm_node
Swagger/API update "standalone" API fields
2020-01-23 20:45:46 +01:00
Daniel Helfand
4d249ae1f3 remove extra space in code comment in ping.go
Signed-off-by: Daniel Helfand <helfand.4@gmail.com>
2020-01-20 00:04:53 -05:00
Sebastiaan van Stijn
b5c22f4fcf
TestContainerInspectNode: document test as being for classic swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-06 12:25:00 +01:00
Sebastiaan van Stijn
5f9f41018e
Merge pull request #40238 from Toasterson/patch-1
Allow client consumers like traefik to compile on illumos
2019-12-12 21:11:29 +01:00
Brian Goff
b95fad8e51
Merge pull request #40263 from thaJeztah/normalize_comments
Normalize comment formatting
2019-12-12 12:06:22 -08:00
Sebastiaan van Stijn
d135dc242e
client.ImagePush(): default to ":latest" instead of "all tags"
The `docker push` command up until docker v0.9.1 always pushed all tags of a given
image, so `docker push foo/bar` would push (e.g.) all of  `foo/bar:latest`, `foo:/bar:v1`,
and `foo/bar:v1.0.0`.

Pushing all tags of an image was not desirable in many case, so docker v0.10.0
enhanced `docker push` to optionally specify a tag to push (`docker push foo/bar:v1`)
(see issue 3411 and PR 4948 (commit e648a186d6).

This behavior exists up until today, and is confusing, because unlike other commands,
`docker push` does not default to use the `:latest` tag when omitted, but instead
makes it push "all tags of the image".

`docker pull` had a similar behavior, but PR 7759 (9c08364a41)
changed the behavior to default to the `:latest` tag, and added a `--all-tags` flag
to the CLI to optionally pull all images.

This patch implements the API client changes to make `docker push` match the behavior
of `docker pull`, and default to pull a single image, unless the `all` option is passed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-12-10 12:24:14 +01:00
Sebastiaan van Stijn
a567ae3c31
client: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:44:49 +01:00
Till Wegmüller
bbf1edae4f Allow client consumers like traefik to compile on illumos
Signed-off-by: Till Wegmüller <toasterson@gmail.com>
2019-11-23 19:28:45 +01:00
Sebastiaan van Stijn
5f47cef514
fix nolint comments for SA1019: filters.ToParamWithVersion is deprecated
The old nolint comment didn't seem to work anymore;

```
client/container_list.go:39:22: SA1019: filters.ToParamWithVersion is deprecated: do not use in any new code; use ToJSON instead  (staticcheck)
client/events.go:94:22:         SA1019: filters.ToParamWithVersion is deprecated: do not use in any new code; use ToJSON instead  (staticcheck)
client/image_list.go:28:22:     SA1019: filters.ToParamWithVersion is deprecated: do not use in any new code; use ToJSON instead  (staticcheck)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:45:33 +02:00
Kirill Kolyshkin
0a96ee7ff8
Merge pull request #40080 from thaJeztah/client_string_matching
client: reduce string-matching in tests
2019-10-17 11:38:00 -07:00
Justin Cormack
f681590a25
Merge pull request #40081 from thaJeztah/http_constants
Use http constants for HTTP methods and status codes
2019-10-17 11:30:26 -07:00
Drew Erny
f36042d259 Add support for sending down service Running and Desired task counts
Adds a new ServiceStatus field to the Service object, which includes the
running and desired task counts. This new field is gated behind a
"status" query parameter.

Signed-off-by: Drew Erny <drew.erny@docker.com>
2019-10-14 10:43:00 -05:00
Sebastiaan van Stijn
d1817b6135
client: use constants for http status codes
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 17:30:23 +02:00
Sebastiaan van Stijn
dabc7cdb56
client: use constants for http methods
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 17:30:21 +02:00
Sebastiaan van Stijn
de10c7d013
client: reduce string-matching in tests
These checks were redundant, as we were not expecting
a specific string, just that a server-error or authentication
error was returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 17:00:40 +02:00
Sebastiaan van Stijn
fd65fed81b
client/hijack: suppress SA1019: httputil.ErrPersistEOF is deprecated (staticcheck)
Keeping this code for now to allow connecting to old daemons, but we might
want to remove this at some point

```
client/hijack.go:90:12: SA1019: httputil.ErrPersistEOF is deprecated: No longer used.  (staticcheck)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:54 +02:00
Kir Kolyshkin
6392e765ac
client: remove put()
Apparently it is not used anywhere

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:20 +02:00
Kir Kolyshkin
d584242236
client: suppress filters.ToParamWithVersion lint warning
Add annotations to suppress warnings like this one:

> client/container_list.go:38:22: SA1019: filters.ToParamWithVersion is deprecated: Use ToJSON  (staticcheck)
> 		filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
>		                   ^

Modify the deprecation notice to specify it is applicable to new code
only.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:19 +02:00
Sebastiaan van Stijn
07ff4f1de8
goimports: fix imports
Format the source according to latest goimports.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:56:54 +02:00
Sebastiaan van Stijn
02b4533a78
Merge pull request #39588 from zappy-shu/DESKTOP-1286-win-admin-error-readability
Improve readability of Windows connect error
2019-08-30 11:33:55 +02:00
Nick Adcock
1a5dafb31e Improve readability of Windows connect error
Improve the readability of the connection error displayed to the user on
Windows when running docker commands fails by checking if the client is
privileged. If so then display the actual error wrapped in a generic
error "This error may indicate that the docker daemon is not running."

If not that display the actual error wrapped in a more specific error:
"In the default daemon configuration on Windows, the docker client must
be run with elevated privileges to connect."

Signed-off-by: Nick Adcock <nick.adcock@docker.com>
2019-08-20 12:07:14 +01:00
Sebastiaan van Stijn
58b0585cd2
fix client.HTTPClient() not returning a copy
```
14:26:43 client/client.go:255:9: SA4001: &*x will be simplified to x. It will not copy x. (staticcheck)
14:26:43 	return &*cli.client
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-06 00:45:45 +02:00
Ian Campbell
8c8457b0f2 client: do not fallback to GET if HEAD on _ping fail to connect
When we see an `ECONNREFUSED` (or equivalent) from an attempted `HEAD` on the
`/_ping` endpoint there is no point in trying again with `GET` since the server
is not responding/available at all.

Once vendored into the cli this will partially mitigate https://github.com/docker/cli/issues/1739
("Docker commands take 1 minute to timeout if context endpoint is unreachable")
by cutting the effective timeout in half.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-05-13 13:48:17 +01:00
Sebastiaan van Stijn
28d7dba41d
Merge pull request #39032 from thaJeztah/improve_version_negotiation
Add client.WithAPIVersionNegotiation() option
2019-04-20 13:34:22 +02:00
Sebastiaan van Stijn
44982c775e
Add client.WithTimeout() option
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-11 13:35:48 +02:00
Sebastiaan van Stijn
b26aa97914
Add client.WithAPIVersionNegotiation() option
WithAPIVersionNegotiation enables automatic API version negotiation for the client.

With this option enabled, the client automatically negotiates the API version
to use when making requests. API version negotiation is performed on the first
request; subsequent requests will not re-negotiate.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-10 19:23:47 +02:00
Sebastiaan van Stijn
0041e2419a
Fix empty WithVersion blocking version negotiation
commit 3d72963ab8 fixed
situations where a version negotiation could override
the version, even though a client was initialized with a
fixed version.

In situations where the "fixed" version is empty, we
should ignore the option, and treat the client as
"not having a fixed version", so that API version
negotiation can still be performed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-10 11:14:37 +02:00
Sebastiaan van Stijn
e6c0d19c3a
client: define "Opt" type
Minor improvement, but makes defining a list of options
a bit cleaner, and more descriptive;

Before:

    opts := make([]func(*client.Client) error, 0)

After:

    opts := make([]client.Opt, 0)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-10 01:23:45 +02:00
Tibor Vass
e8382ece65 api: add undocumented /grpc endpoint to talk to GRPC services
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-04-02 19:57:59 +00:00
Tibor Vass
6cce52c245
Merge pull request #38909 from thaJeztah/fix_version_override
Fix client version not being pinned when set
2019-03-21 14:14:39 -07:00
Tõnis Tiigi
afa8f1b832
Merge pull request #38707 from thaJeztah/close_the_door_on_your_way_out
Client: always call ensureReaderClosed
2019-03-21 13:32:57 -07:00
Sebastiaan van Stijn
3d72963ab8
Fix client version not being pinned when set
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-20 10:46:36 +01:00
Tonis Tiigi
768c6d7b29 builder-next: allow outputs configuration
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2019-03-19 10:28:30 -07:00
Sebastiaan van Stijn
9c846b2fcc
Client: always call ensureReaderClosed
Unlike a plain `net/http/client.Do()`, requests made through client/request
use the `sendRequest` function, which parses the server response, and may
convert non-transport errors into errors (through `cli.checkResponseErr()`).

This means that we cannot assume that no reader was opened if an error is
returned.

This patch changes various locations where `ensureReaderClosed` was only
called in the non-error situation, and uses a `defer` to make sure it's
always called.

`ensureReaderClosed` itself already checks if the response's body was set,
so in situations where the error was due to a transport error, calling
`ensureReaderClosed` should be a no-op.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-18 15:26:21 +01:00
Sebastiaan van Stijn
0cafc84fb2
Use errdefs for handling errors in client
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:42:42 +01:00
Sebastiaan van Stijn
053c6f097a
Keep old "notfound" interface for backward compatibility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:42:36 +01:00
Sebastiaan van Stijn
2a9c987e5a
Move httputils error helpers to errdefs package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:42:23 +01:00
Sebastiaan van Stijn
161e0a90a6
Update tests to check returned errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:40:55 +01:00
Sebastiaan van Stijn
77c5668baf
client: remove special error handling for "no such image"
looks like we don't need this handling

Before this patch:

    Error: No such image: nosuchimage

After this patch:

    Error response from daemon: No such image: nosuchimage:latest
"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:40:47 +01:00
Sebastiaan van Stijn
38e6d474af
client: return rich / errdefs errors
this patch makes the client return errors matching
the errdefs interface.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:40:39 +01:00
Sebastiaan van Stijn
5d8ece522b
Make client.notfound error match errdefs.notfound
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:40:26 +01:00
Sebastiaan van Stijn
421b66a486
Make client/errors helpers work with errdefs errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-16 00:40:07 +01:00
xichengliudui
1d62807db3 Delete duplicate words
update pull request

Signed-off-by: “xichengliudui” <“liuduidui@beyondcent.com”>
2019-03-14 07:53:38 -04:00
Sebastiaan van Stijn
7e7e100be0
Add HEAD support for /_ping endpoint
Monitoring systems and load balancers are usually configured to use HEAD
requests for health monitoring. The /_ping endpoint currently does not
support this type of request, which means that those systems have fallback
to GET requests.

This patch adds support for HEAD requests on the /_ping endpoint.

Although optional, this patch also returns `Content-Type` and `Content-Length`
headers in case of a HEAD request; Refering to RFC 7231, section 4.3.2:

    The HEAD method is identical to GET except that the server MUST NOT
    send a message body in the response (i.e., the response terminates at
    the end of the header section).  The server SHOULD send the same
    header fields in response to a HEAD request as it would have sent if
    the request had been a GET, except that the payload header fields
    (Section 3.3) MAY be omitted.  This method can be used for obtaining
    metadata about the selected representation without transferring the
    representation data and is often used for testing hypertext links for
    validity, accessibility, and recent modification.

    A payload within a HEAD request message has no defined semantics;
    sending a payload body on a HEAD request might cause some existing
    implementations to reject the request.

    The response to a HEAD request is cacheable; a cache MAY use it to
    satisfy subsequent HEAD requests unless otherwise indicated by the
    Cache-Control header field (Section 5.2 of [RFC7234]).  A HEAD
    response might also have an effect on previously cached responses to
    GET; see Section 4.3.5 of [RFC7234].

With this patch applied, either `GET` or `HEAD` requests work; the only
difference is that the body is empty in case of a `HEAD` request;

    curl -i --unix-socket /var/run/docker.sock http://localhost/_ping
    HTTP/1.1 200 OK
    Api-Version: 1.40
    Cache-Control: no-cache, no-store, must-revalidate
    Docker-Experimental: false
    Ostype: linux
    Pragma: no-cache
    Server: Docker/dev (linux)
    Date: Mon, 14 Jan 2019 12:35:16 GMT
    Content-Length: 2
    Content-Type: text/plain; charset=utf-8

    OK

    curl --head -i --unix-socket /var/run/docker.sock http://localhost/_ping
    HTTP/1.1 200 OK
    Api-Version: 1.40
    Cache-Control: no-cache, no-store, must-revalidate
    Content-Length: 0
    Content-Type: text/plain; charset=utf-8
    Docker-Experimental: false
    Ostype: linux
    Pragma: no-cache
    Server: Docker/dev (linux)
    Date: Mon, 14 Jan 2019 12:34:15 GMT

The client is also updated to use `HEAD` by default, but fallback to `GET`
if the daemon does not support this method.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-31 18:18:24 +01:00
Sebastiaan van Stijn
3a4bb96ab7
Remove use of deprecated client.NewClient()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-28 17:08:54 +01:00
Yong Tang
6351619e2c
Merge pull request #38606 from thaJeztah/move_client_opts
Move client opts, and deprecated client constructors to separate files
2019-01-26 15:41:46 -08:00
Sebastiaan van Stijn
69d9ff3455
Move deprecated client constructors to a separate file
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-21 15:27:52 +01:00
Sebastiaan van Stijn
01eb35bfb3
Move client-opts to a separate file
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-21 14:52:46 +01:00
Sebastiaan van Stijn
3449b12cc7
Use assert.NilError() instead of assert.Assert()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-21 13:16:02 +01:00
Sebastiaan van Stijn
46b80550c1
Fix ping-tests using wrong status-code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-14 21:58:55 +01:00
Sebastiaan van Stijn
c8ff5ecc09
Remove use of deprecated client.NewEnvClient()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-03 22:49:00 +01:00
Sebastiaan van Stijn
744940056d
client/request: wrap some errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-12-31 15:33:40 +01:00
Hamish Hutchings
6a3d1e3e3e
Unify the defer syntax
A simple change to unify the http stream closing syntax.

Signed-off-by: Hamish Hutchings <hamish@aoeu.me>
2018-12-02 04:09:47 +01:00
Peter Kang
be2f7ce3ca Add an op func to override Client.scheme
Signed-off-by: Peter Kang <peter@spell.run>
2018-11-01 14:07:35 -04:00
Harrison Turton
77162b39da Update documentation for ServiceUpdate
Currently, the behaviour for the version field in ServiceUpdate()
is vague. Without an correct version number, users are unable to
successfully run ServiceUpdate(), which is a pretty critical method
for scaling services (for example). I've just added an extra sentence
explaining what the version number is for, and where to find it.

Signed-off-by: Harrison Turton <harrisonturton@gmail.com>
2018-10-23 13:16:51 +11:00
Brian Goff
3e5b9cb466 Use net/http instead of x/ctxhttp
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-10-16 09:44:53 -07:00
Akihiro Suda
1db4be0c32 client: use io.LimitedReader for reading HTTP error
client.checkResponseErr() was hanging and consuming infinite memory
when the serverResp.Body io.Reader returns infinite stream.

This commit prohibits reading more than 1MiB.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-10-11 01:37:39 +09:00
Tonis Tiigi
5974fc2540 client: dial tls on Dialer if tls config is set
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-04 17:43:33 -07:00
Tibor Vass
8ff7847d1c builder: add prune options to the API
Signed-off-by: Tibor Vass <tibor@docker.com>
2018-09-01 22:01:17 +00:00
Anda Xu
2be17666b4 add optional fields in daemon.json to enable buildkit
Signed-off-by: Anda Xu <anda.xu@docker.com>
2018-08-19 14:58:23 -07:00
Akihiro Suda
edac92409a client: add WithDialContext() and client.Dialer()
WithDialContext() allows specifying custom dialer for hijacking and supposed to
replace WithDialer().
WithDialer() is also updated to use WithDialContext().

client.Dialer() returns the dialer configured with WithDialContext().

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-07-28 23:35:47 +09:00
Sebastiaan van Stijn
4c0a050ee2
Remove stray uses of "golang.org/x/net/context"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-07-13 09:53:36 +02:00
Tibor Vass
facad55744 api: Change Platform field back to string (temporary workaround)
This partially reverts https://github.com/moby/moby/pull/37350

Although specs.Platform is desirable in the API, there is more work
to be done on helper functions, namely containerd's platforms.Parse
that assumes the default platform of the Go runtime.

That prevents a client to use the recommended Parse function to
retrieve a specs.Platform object.

With this change, no parsing is expected from the client.

Signed-off-by: Tibor Vass <tibor@docker.com>
2018-07-03 22:33:42 +00:00
Tonis Tiigi
81f862a1fe api: fix platform type
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-06-26 22:59:17 -07:00
Vincent Demeester
3845728524
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-13 09:04:30 +02:00
Tonis Tiigi
92395261b0 builder: add support for building from tarball
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-06-10 10:05:28 -07:00
Tonis Tiigi
0bddd4ccfe builder: add graceful cancellation endpoint
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-06-10 10:05:26 -07:00
Brian Goff
2ac277a56f
Use stdlib TLS dialer
Since go1.8, the stdlib TLS net.Conn implementation implements the
`CloseWrite()` interface.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-06-08 14:24:30 -07:00
John Stephens
b801361064
Clean up in TestNegotiateAPIVersionEmpty
Signed-off-by: John Stephens <johnstep@docker.com>
2018-06-07 20:05:29 -07:00
Brian Goff
b85799b63f
Merge pull request #36874 from kolyshkin/stop-timeout
daemon.ContainerStop(): fix for a negative timeout
2018-05-30 13:38:42 -04:00
Sebastiaan van Stijn
f23c00d870
Various code-cleanup
remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-23 17:50:54 +02:00
Vincent Demeester
da99009bbb
Merge pull request #35402 from thaJeztah/fix-GetTimestamp-parsing
Improve GetTimestamp parsing
2018-05-22 12:28:01 +02:00
Sebastiaan van Stijn
55bebbaecf
Replace deprecated testutil.ErrorContains()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-21 00:13:04 +02:00
Sebastiaan van Stijn
48cfe3f087
Improve GetTimestamp parsing
`GetTimestamp()` "assumed" values it could not parse
to be a valid unix timestamp, and would use invalid
values ("hello world") as-is (even testing that
it did so).

This patch validates unix timestamp to be a valid
numeric value, and makes other values invalid.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-20 13:07:17 +02:00
Sebastiaan van Stijn
4f8c870d62
Fix some linting issues
These showed locally when running `make validate`. CI doesn't seem to have the
same (possibly it's disabled in the configuration)

    builder/fscache/fscache.go:618::error: github.com/docker/docker/vendor/github.com/tonistiigi/fsutil.StatInfo composite literal uses unkeyed fields (vet)
    client/swarm_unlock_test.go:44::error: github.com/docker/docker/api/types/swarm.UnlockRequest composite literal uses unkeyed fields (vet)
    client/swarm_unlock_test.go:20::error: github.com/docker/docker/api/types/swarm.UnlockRequest composite literal uses unkeyed fields (vet)
    cmd/dockerd/daemon_unix.go:113::error: github.com/docker/docker/cmd/dockerd/hack.MalformedHostHeaderOverride composite literal uses unkeyed fields (vet)
    cmd/dockerd/daemon_unix.go:110::error: github.com/docker/docker/cmd/dockerd/hack.MalformedHostHeaderOverride composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay/overlay.go:171::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay/overlay.go:413::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay2/overlay.go:203::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay2/overlay.go:584::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/zfs/zfs.go:109::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/zfs/zfs.go:388::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/volumes_windows.go:27::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    integration/service/network_test.go:31::error: github.com/docker/docker/api/types/network.NetworkingConfig composite literal uses unkeyed fields (vet)
    api/server/server.go:129:10⚠️ should not use basic type string as key in context.WithValue (golint)
    integration/service/network_test.go:54::error: github.com/docker/docker/api/types/network.NetworkingConfig composite literal uses unkeyed fields (vet)
    libcontainerd/client_daemon_linux.go:61::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    libcontainerd/client_daemon_linux.go:74::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    pkg/archive/archive_windows.go:76::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    plugin/manager_linux.go:56::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-17 19:28:27 +02:00
Vincent Demeester
9aac187ce1
Merge pull request #37075 from tuscloud/fix-typos
Fix typos
2018-05-17 16:00:43 +02:00
Mathieu Champlon
5a84124739 Make client underlying HTTP client accessible
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
2018-05-16 05:24:11 +02:00
weipeng
f781ec45b5 Fix typos
Signed-off-by: weipeng <weipeng@tuscloud.io>
2018-05-16 09:15:43 +08:00
Brian Goff
b16b125bb4 Fix swagger volume type generation
This was broken by bf6a790f00

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-05-14 13:46:20 -04:00
Kir Kolyshkin
69b4fe4065 daemon.ContainerStop(): fix for a negative timeout
1. As daemon.ContainerStop() documentation says,

> If a negative number of seconds is given, ContainerStop
> will wait for a graceful termination.

but since commit cfdf84d5d0 (PR #32237) this is no longer the case.

This happens because `context.WithTimeout(ctx, timeout)` is implemented
as `WithDeadline(ctx, time.Now().Add(timeout))`, resulting in a deadline
which is in the past.

To fix, don't use WithDeadline() if the timeout is negative.

2. Add a test case to validate the correct behavior and
as a means to prevent a similar regression in the future.

3. Fix/improve daemon.ContainerStop() and client.ContainerStop()
description for clarity and completeness.

4. Fix/improve DefaultStopTimeout description.

Fixes: cfdf84d5d0 ("Update Container Wait")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-03 10:04:33 -07:00
Kir Kolyshkin
7d62e40f7e Switch from x/net/context -> context
Since Go 1.7, context is a standard package. Since Go 1.9, everything
that is provided by "x/net/context" is a couple of type aliases to
types in "context".

Many vendored packages still use x/net/context, so vendor entry remains
for now.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-04-23 13:52:44 -07:00
Tonis Tiigi
f094a05e26 client: fix hijackedconn reading from buffer
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-03-21 15:29:44 -07:00
Daniel Nephin
c9e52bd0da Post migration assertion fixes
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:46 -04:00
Daniel Nephin
6be0f70983 Automated migration using
gty-migrate-from-testify --ignore-build-tags

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:43 -04:00
Jim Minter
37983921c9 Ensure a hijacked connection implements CloseWrite whenever its underlying
connection does.  If this isn't done, then a container listening on stdin won't
receive an EOF when the client closes the stream at their end.

Signed-off-by: Jim Minter <jminter@redhat.com>
2018-03-14 09:07:55 -06:00
Vincent Demeester
5b124d7422
Merge pull request #36424 from liubin/fix-typo
Fix typos in builder and client
2018-02-27 10:24:20 +01:00
Daniel Nephin
0a91ba2d8c Remove duplicate calls for getting an APIClient
Remove request.SockRequest
Remove request.SockRequestHijack
Remove request.SockRequestRaw()
Remove deprecated ParseHost
Deprecate and unexport more helpers

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-20 17:27:24 -05:00
Daniel Nephin
a68ae4a2d9 Improve docstrings and small cleanup in client
Use client instead of helpers for TLS in integration test

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-20 15:15:02 -05:00
Daniel Nephin
2b445a53c1 Use gotestyourself env patching
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-20 15:15:02 -05:00
Tõnis Tiigi
db360995df
Merge pull request #36144 from emil2k/node-id-required
Produce errors when empty ids are passed into inspect calls.
2018-02-16 10:18:47 -08:00
Vincent Demeester
01bfb6d27c
Merge pull request #34900 from dnephin/send-codecov-report
Create and send codecov report
2018-02-16 11:36:51 +01:00
bin liu
ce09932704 Fix typos in builder and client
Signed-off-by: bin liu <liubin0329@gmail.com>
2018-02-10 19:39:26 +08:00
Drew Erny
80904e9571 Fix TLS from environment variables in client
A recent change accidently caused any TLS configuration in FromEnv to be
ignored. This change alters WithHost to create a new http client only if
one doesn't already exist, and otherwise applies the logic to the
transport on the existing client. This preserves the TLS configuration
that might already be on the client.

Signed-off-by: Drew Erny <drew.erny@docker.com>
2018-02-09 15:29:32 -08:00
Vincent Demeester
772edd020c Introduce NewClientWithOpts func to build custom client easily
This allows to create a client with default values and override those
using functors. As an example, `NewEnvClient()` becomes
`NewClientWithOpts(FromEnv)` ; and if you want a different api version
for this client : `NewClientWithOpts(FromEnv, WithVersion("1.35"))`

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-02-08 15:26:24 +01:00
Emil Davtyan
3e6bbefd26 Produce errors when empty ids are passed into inspect calls.
If a blank nodeID was previously passed in it resulted in a node list
request. The response would then fail to umarshal into a `Node`
type returning a JSON error.

This adds an extra validation to all inspect calls to check that the ID
that is required is provided and if not return an error.

Signed-off-by: Emil Davtyan <emil2k@gmail.com>
2018-02-07 14:05:14 +01:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Brian Goff
1d1845de54
Merge pull request #35979 from emil2k/fix-container-copy-err
Wrap response errors for container copy methods.
2018-01-25 13:48:49 -08:00
Adam Pointer
7732ca94fc Alias container and network packages to stop name clashes
Signed-off-by: Adam Pointer <adam.pointer@gmx.com>
2018-01-19 10:26:41 +00:00
Daniel Nephin
e5cce50c7e Add code coverage report and codecov config
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-01-16 16:50:56 -05:00
Emil Davtyan
2d6fb87ca4 Wrap response error for container logs method.
Signed-off-by: Emil Davtyan <emil2k@gmail.com>
2018-01-12 16:43:51 +01:00
Emil Davtyan
44369bdd65 Wrap response errors for container copy methods.
This allows IsErrNotFound and IsErrNotImplemented to work as intended.

Signed-off-by: Emil Davtyan <emil2k@gmail.com>
2018-01-11 13:40:49 +01:00
Yong Tang
e330e7a5ce Update doc for CopyFromContainer
This fix updates doc for CopyFromContainer to explicitly
mention that the content received from the reader is
a TAR archive.

This fix closes 35965.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-01-08 18:29:59 +00:00
Sebastiaan van Stijn
68a4552529
Merge pull request #32914 from jamiehannaford/until-logging
Add --until flag for docker logs; closes #32807
2017-11-03 16:08:30 +01:00
Yong Tang
4785f1a7ab Remove solaris build tag and `contrib/mkimage/solaris
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-11-02 00:01:46 +00:00
Jamie Hannaford
e8d9a61f4c Add --until flag for docker logs; closes #32807
Signed-off-by: Jamie Hannaford <jamie.hannaford@rackspace.com>
2017-11-01 10:08:49 +01:00
Yong Tang
8b24d2a960 Merge pull request #35128 from thaJeztah/fix-ContainerExecAttach-type
Use correct type for ContainerExecAttach
2017-10-10 10:59:16 -07:00
Sebastiaan van Stijn
5fee8bddfe
Use correct type for ContainerExecAttach
ContainerExecAttach used `types.ExecConfig` instead of `types.ExecStartCheck`,
which is the type that's expected by the `/exec/execid/start` API endpoint.

Investigating when this inconsistency was introduced, I found that the client has
sent the additional properties since its first imlpementation in
c786a8ee5e.

The `postContainerExecStart()` at that time used the "jobs" package, which
only took the information from the body that was needed (`Detach` and `Tty`).

Commit 24425021d2 refactored the Exec commands
to remove the "jobs", and introduced the `ExecStartCheck` type, but failed to
update the `cli.hijack()` call with the new type.

The change in this patch should not affect compatibility with older clients,
as the additional information from the `ExecConfig` type is not used (the
API server already decodes to the `ExecStartCheck` type).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-09 01:25:46 +02:00
John Howard
d98ecf2d6c LCOW: API change JSON header to string POST parameter
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-10-06 15:26:48 -07:00
John Howard
0380fbff37 LCOW: API: Add platform to /images/create and /build
Signed-off-by: John Howard <jhoward@microsoft.com>

This PR has the API changes described in https://github.com/moby/moby/issues/34617.
Specifically, it adds an HTTP header "X-Requested-Platform" which is a JSON-encoded
OCI Image-spec `Platform` structure.

In addition, it renames (almost all) uses of a string variable platform (and associated)
methods/functions to os. This makes it much clearer to disambiguate with the swarm
"platform" which is really os/arch. This is a stepping stone to getting the daemon towards
fully multi-platform/arch-aware, and makes it clear when "operating system" is being
referred to rather than "platform" which is misleadingly used - sometimes in the swarm
meaning, but more often as just the operating system.
2017-10-06 11:44:18 -07:00
Sebastiaan van Stijn
7553fc4bcd
Remove deprecated IsErr...NotFound() functions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-03 12:07:49 +02:00
Sebastiaan van Stijn
919726b5db
Replace uses of deprecated IsErr...Notfound()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-03 12:05:03 +02:00
Yu-Ju Hong
4b6ec10b07 Fix version comparison when negotiating the the API version
Signed-off-by: Yu-Ju Hong <yjhong@google.com>
2017-09-27 18:42:02 -07:00
Sebastiaan van Stijn
a4efe66cf2
Replace uses of filters.ToParam(), FromParam() with filters.ToJSON(), FromJSON()
`filters.ToParam()` and `filters.FromParam()` were deprecated in favor of
`filters.ToJSON()` and `filters.FromJSON()` in 065118390a,
but still used in various locations.

This patch replaces uses of `filters.ToParam()` and  `filters.FromParam()` with
`filters.ToJSON()` and `filters.FromJSON()`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-09-26 13:59:45 +02:00
Christopher Crone
7406088853 Match not implemented error check to others
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
2017-09-25 13:58:51 +02:00
Christopher Crone
e7e11bdd44 Handle plugin list not implemented
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
2017-09-20 19:48:33 +02:00
Vincent Demeester
bb0e8ee51c Merge pull request #34784 from dnephin/fix-client-not-found
Cleanup client not found errors
2017-09-14 12:04:56 +02:00
Daniel Nephin
f7f101d57e Add gosimple linter
Update gometalinter

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-12 12:09:59 -04:00
Daniel Nephin
81bb9978ab Cleanup client not found errors.
And fix remove calls to return a notFound error

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-11 19:53:18 -04:00
Yong Tang
63a9ea58eb Merge pull request #34770 from dnephin/fix-client-with-empty-id
Fix volume inspect with empty ID
2017-09-11 07:01:50 -07:00
Yong Tang
13fec06073 Merge pull request #34790 from dnephin/add-ineffassign-linter
Add ineffassign linter
2017-09-09 15:41:55 -07:00
Daniel Nephin
09652bf878 Add ineffassign linter
Also enable GC in linting to reduce memory usage.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-08 18:23:21 -04:00
Daniel Nephin
5ac298fd0e Fix volume inspect with empty ID
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-07 13:46:23 -04:00
Daniel Nephin
54242cd067 Cleanup client/ interface
- Remove ParseLogDetails, this is not part of the client. Moved to docker/cli
- Deprecate ParseHost and replace with ParseHostURL
- Deprecate redundant IsErr helpers

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-07 12:32:38 -04:00
Vincent Demeester
ea220e70a1 Merge pull request #34021 from nishanttotla/dont-set-architecture-constraint
Clear Architecture field in platform constraint for arm architectures
2017-09-07 11:18:12 +02:00
Daniel Nephin
6916c215b0 Move tlsconfig to client package.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-06 16:39:55 -04:00
Nishant Totla
772af6040e
Clear Architecture field in platform constraint for arm architectures
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-09-01 13:08:20 -07:00
Yong Tang
cb952bf006 Merge pull request #34625 from dnephin/more-linters
Add interfacer and unconvert linters
2017-09-01 08:46:08 -07:00
Daniel Nephin
e62b2d410c Move ErrorContains to an internal package.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-25 12:04:58 -04:00
Daniel Nephin
709bf8b7bc Add interfacer linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-24 15:08:26 -04:00
Daniel Nephin
62c1f0ef41 Add deadcode linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-21 18:18:50 -04:00
Daniel Nephin
372670b507 Add goimports to linters.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-21 18:15:08 -04:00
Arash Deshmeh
33d82b78d0 client should return imageNotFound error when API returns 404 status code
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
2017-08-15 17:16:02 -04:00
Tonis Tiigi
823e88d4c4 Fix requests for docker host ending with slash
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-08-11 10:47:02 -07:00
mrfly
e345cd12f9 fix client.Transport
`client.Transport` is `http.Client.Transport` just has `RoundTripper()`. Not `http.Transport`. So we cannot convert it here.

For a mock test, I can play with this https://play.golang.org/p/gs7_QrL9-Y

Signed-off-by: wrfly <mr.wrfly@gmail.com>
2017-08-03 17:14:26 +08:00
Tibor Vass
41445a4745 Remove client/session package, depend on buildkit's session package
gofmt -w -r '"github.com/docker/docker/client/session" -> "github.com/moby/buildkit/session"'
gofmt -w -r '"github.com/docker/docker/client/session/filesync" -> "github.com/moby/buildkit/session/filesync"'

Signed-off-by: Tibor Vass <tibor@docker.com>
2017-07-28 16:34:23 -07:00
Tibor Vass
7a53991bd6 Fix panic in hijack
Signed-off-by: Tibor Vass <tibor@docker.com>
2017-07-25 22:46:41 -07:00
Victor Vieux
45cad73ea8 Merge pull request #33887 from thaJeztah/update-version-error
Fix NewVersionError() for clients using default version
2017-07-12 15:24:00 +02:00
Brian Goff
72c3bcf2a5 Make plugin emit strongly typed, consumable events
Enables other subsystems to watch actions for a plugin(s).

This will be used specifically for implementing plugins on swarm where a
swarm controller needs to watch the state of a plugin.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-07-06 14:26:06 -04:00
Sebastiaan van Stijn
19ee873616 Merge pull request #33859 from tonistiigi/session-includepaths
Add path filtering to build session client
2017-07-05 18:21:48 -07:00
Vincent Demeester
ff4f700f74 Merge pull request #33322 from jsoref/spelling
Spelling
2017-07-04 15:46:34 +02:00
Sebastiaan van Stijn
a9358df62c Merge pull request #33494 from cpuguy83/document_stream_format_in_client_lib
Add stream format details for attach/logs endpoint
2017-07-03 22:02:24 -07:00
Josh Soref
39bcaee47b
Spelling fixes
* additional
* ambiguous
* anonymous
* anything
* application
* because
* before
* building
* capabilities
* circumstances
* commit
* committer
* compresses
* concatenated
* config
* container
* container's
* current
* definition
* delimiter
* disassociates
* discovery
* distributed
* doesnotexist
* downloads
* duplicates
* either
* enhancing
* enumerate
* escapable
* exactly
* expect
* expectations
* expected
* explicitly
* false
* filesystem
* following
* forbidden
* git with
* healthcheck
* ignore
* independent
* inheritance
* investigating
* irrelevant
* it
* logging
* looking
* membership
* mimic
* minimum
* modify
* mountpoint
* multiline
* notifier
* outputting
* outside
* overridden
* override
* parsable
* plugins
* precedence
* propagation
* provided
* provides
* registries
* repositories
* returning
* settings
* should
* signals
* someone
* something
* specifically
* successfully
* synchronize
* they've
* thinking
* uninitialized
* unintentionally
* unmarshaling
* unnamed
* unreferenced
* verify

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-07-03 13:13:09 -07:00
Sebastiaan van Stijn
5975dc4b4b
Always perform version-negotiation
If a client is initialized without a specific
version set, version negotiation would not be
functional.

This patch changes the behavior to always
perform version negotation (if called), in
which case the "current" (maximum supported
API version) is used as a default.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-06-29 22:24:49 -07:00
Sebastiaan van Stijn
ff2ed18530
Fix NewVersionError() for clients using default version
The NewVersionError checks if the client is using the API version
required for using a specific feature.

If the client is initialized without setting a specific version, an
error would be generated because it was not possible to compare
versions. However, a client without explicit version set is running
the latest supported version.

This patch changes the behavior to only generate an error if a version
was set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-06-29 22:22:32 -07:00
Sebastiaan van Stijn
654bb6368b Merge pull request #33827 from cpuguy83/return_ping_data_if_available
Set ping version even on error
2017-06-29 12:27:23 -07:00
Brian Goff
27ef09a46f Set ping version even on error
In some cases a server may return an error on the ping response but
still provide version details. The client should use these values when
available.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-06-29 12:42:14 -04:00
Nishant Totla
da85b62001
Do not add duplicate platform information to service spec
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-06-28 16:01:05 -07:00
Tonis Tiigi
4141d8fe5d add test for filesync path filtering and testutil helper
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-06-28 09:12:36 -07:00
Tonis Tiigi
ad46348d7c builder: enable path filtering for filesync session
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-06-28 09:12:30 -07:00
Sebastiaan van Stijn
5564fad406 Merge pull request #33467 from bschwind/copy-documentation
Add note to CopyToContainer documentation
2017-06-24 00:19:51 -07:00
Tonis Tiigi
5c3d2d552b Implement incremental file sync using client session
Also exposes shared cache and garbage collection/prune
for the source data.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-06-22 11:52:35 -07:00
Tonis Tiigi
ec7b6238c3 Add long-running client session endpoint
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-06-22 11:22:41 -07:00
Royce Remer
5f1d94e569 pull client API version negotiation out of the CLI and into the client
Signed-off-by: Royce Remer <royceremer@gmail.com>
2017-06-20 22:58:16 -07:00
Brian Schwind
1c3071e487 Add note to CopyToContainer documentation
Signed-off-by: Brian Schwind <brianmschwind@gmail.com>
2017-06-20 14:49:38 +09:00
Sebastiaan van Stijn
f3fce00ef3
Make TestServiceCreateCompatiblePlatforms use actual API response
The `TestServiceCreateCompatiblePlatforms()` test was confusing, because it
did not actually use the mocked API response, but used a local
`distributionInspectBody` variable to verify that the `/distribution/` endpoint
was called.

This flow was especially confusing, because a comment in the test describes;

    "check if the /distribution endpoint returned correct output"

If (for whatever reason), the endpoint was not called, the test would panic,
because the `distributionInspectBody` would not be set.

This patch rewrites the test to use the actual API response that is returned
by the mock, and verifies that the information returned by the `/distribution/`
endpoint is properly used in the service's definition.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-06-13 14:25:50 +02:00
Vincent Demeester
ae487e543c Merge pull request #33571 from thaJeztah/client-api-version-checks
Add API version checks to client
2017-06-13 10:50:05 +02:00
Yong Tang
158b2a1875 Add scope filter in /networks/<id>
This fix tries to add a `scope` in the query of `/networks/<id>`
(`NetworkInspect`) so that in case of duplicate network names,
it is possible to locate the network ID based on the network
scope (`local`, 'swarm', or `global`).

Multiple networks might exist in different scopes, which is a legitimate case.
For example, a network name `foo` might exists locally and in swarm network.

However, before this PR it was not possible to query a network name `foo`
in a specific scope like swarm.

This fix fixes the issue by allowing a `scope` query in `/networks/<id>`.

Additional test cases have been added to unit tests and integration tests.

This fix is related to docker/cli#167, moby/moby#30897, moby/moby#33561, moby/moby#30242

This fix fixes docker/cli#167

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-06-12 09:54:25 -07:00
Sebastiaan van Stijn
1401342f46 Add API version checks to client
The Docker CLI already performs version-checks when
running commands, but other clients consuming the API
client may not do so.

This patch adds a version check to various
client functions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-06-10 01:57:55 +02:00
Brian Goff
4721844811 Merge pull request #33424 from allencloud/add-swarm-unlock-test-in-client
add swarm unlock test in client
2017-06-09 08:39:23 -04:00
Lei Jitang
f35157433e Merge pull request #33262 from keloyang/exec-block
Add a error check in postHijacked to avoid docker exec command blocking.
2017-06-09 09:20:04 +08:00
yangshukui
26231b29e7 Add a error check in postHijacked to avoid docker exec command blocking.
When user execute docker exec command, docker daemon maybe have err return because
of ExecExists check, and then the hijack stream will not be close, it can lead to
docker exec command block.

Signed-off-by: yangshukui <yangshukui@huawei.com>
2017-06-08 15:46:50 +08:00
Brian Goff
48829ddf88 Add stream format details for attach/logs endpoint
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-06-02 12:32:25 -04:00
Aaron Lehmann
44c9ccc069 client: Use string concatenation instead of Sprintf
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-06-02 14:01:57 +02:00
Chen Min
2b62eb434b Fix Typos: continer,contianer -> container
Signed-off-by: Chen Min <chenmin46@huawei.com>
2017-06-01 19:21:01 +08:00
allencloud
8ff023fe5a add swarm unlock test in client
Signed-off-by: allencloud <allen.sun@daocloud.io>
2017-05-29 00:22:24 +08:00
Sebastiaan van Stijn
5648a1ada2 Merge pull request #33279 from nishanttotla/fix-service-image-issues
Ensure service images get default tag and print familiar strings
2017-05-22 21:45:11 +01:00
Sebastiaan van Stijn
ab2abb0d94 Merge pull request #33253 from dave-tucker/clientHost
client: Expose ClientHost to client users
2017-05-22 16:27:43 +01:00
Dave Tucker
6ce6ae1cd1 client: Expose DaemonHost to client users
This commit exposes `Client.host` as `Client.DaemonHost()`
This allows users of the client, a CLI for example, to query the Host
that the client is attempting to contact and vary their behaviour
accordingly. For example, to allow client-side configuration of
HTTP proxy settings for a number of different docker hosts.

Signed-off-by: Dave Tucker <dt@docker.com>
2017-05-22 13:25:11 +01:00
Nishant Totla
75c7536d2e
Adding unit tests for pin by digest (client)
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-05-19 10:48:12 -07:00
Nishant Totla
5efcec7717
Ensure service images get default tag and print familiar strings
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-05-19 10:35:34 -07:00
Simon Menke
4d2d2ea393 Remove deadlock in ContainerWait
when `cli.post(...)` fails `errC <- err` blocks because `errC` is unbufferd.

Signed-off-by: Simon Menke <simon.menke@gmail.com>
2017-05-19 09:23:52 +02:00
Sebastiaan van Stijn
b0dd3dfc11 Merge pull request #33267 from YuPengZTE/devImageWithDigestString
ineffectual assignment to isCanonical, delete it, and make the "if" sentence to fit the golang usage
2017-05-18 23:37:52 +02:00
yupengzte
b28c1eae01 ineffectual assignment to isCanonical, delete it
Signed-off-by: yupengzte <yu.peng36@zte.com.cn>
2017-05-18 17:16:19 +08:00
Nishant Totla
7d4b8fb3b5
Updating test for compatible platforms to test unmarshal body
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-05-17 17:12:22 -07:00
Nishant Totla
587d07cca8
Adding compatible platforms to service spec
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-05-17 16:20:42 -07:00
Sebastiaan van Stijn
c053a2069e Merge pull request #32237 from jlhawn/update_container_wait
Update Container Wait
2017-05-17 02:39:52 +02:00
Josh Hawn
4921171587 Update ContainerWait API
This patch adds the untilRemoved option to the ContainerWait API which
allows the client to wait until the container is not only exited but
also removed.

This patch also adds some more CLI integration tests for waiting for a
created container and waiting with the new --until-removed flag.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Handle detach sequence in CLI

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Update Container Wait Conditions

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Apply container wait changes to API 1.30

The set of changes to the containerWait API missed the cut for the
Docker 17.05 release (API version 1.29). This patch bumps the version
checks to use 1.30 instead.

This patch also makes a minor update to a testfile which was added to
the builder/dockerfile package.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Remove wait changes from CLI

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Address minor nits on wait changes

- Changed the name of the tty Proxy wrapper to `escapeProxy`
- Removed the unnecessary Error() method on container.State
- Fixes a typo in comment (repeated word)

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Use router.WithCancel in the containerWait handler

This handler previously added this functionality manually but now uses
the existing wrapper which does it for us.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Add WaitCondition constants to api/types/container

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Address more ContainerWait review comments

- Update ContainerWait backend interface to not return pointer values
  for container.StateStatus type.
- Updated container state's Wait() method comments to clarify that a
  context MUST be used for cancelling the request, setting timeouts,
  and to avoid goroutine leaks.
- Removed unnecessary buffering when making channels in the client's
  ContainerWait methods.
- Renamed result and error channels in client's ContainerWait methods
  to clarify that only a single result or error value would be sent
  on the channel.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Move container.WaitCondition type to separate file

... to avoid conflict with swagger-generated code for API response

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Address more ContainerWait review comments

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
2017-05-16 15:11:39 -07:00
Nishant Totla
c0afd9c873
Disabling digest pinning for API versions < 1.30
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-05-15 16:42:43 -07:00
Nishant Totla
c1635c1ae3
Moving docker service digest pinning to client side
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-05-15 16:42:43 -07:00
Brian Goff
3183031581 Merge pull request #32987 from allencloud/add-swarm-get-unlock-key-test-in-client
add swarm get unlock key test for client package
2017-05-15 09:56:43 -04:00