From e49de6ef581076ad563886d471be43690b82f9a7 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 4 Jan 2016 18:54:13 -0500 Subject: [PATCH 1/3] Vendor engine-api project. Use latest tag for both, engine-api and go-connections. Signed-off-by: David Calavera Upstream-commit: 9927e712c0c5a04c2d802e160e27d3c16c650cf2 Component: engine --- components/engine/hack/vendor.sh | 3 +- .../src/github.com/docker/engine-api/LICENSE | 191 ++++++++ .../docker/engine-api/client/client.go | 142 ++++++ .../engine-api/client/container_attach.go | 33 ++ .../engine-api/client/container_commit.go | 37 ++ .../engine-api/client/container_create.go | 53 +++ .../engine-api/client/container_inspect.go | 64 +++ .../engine-api/client/container_list.go | 54 +++ .../engine-api/client/container_remove.go | 26 ++ .../engine-api/client/container_rename.go | 12 + .../engine-api/client/container_restart.go | 17 + .../engine-api/client/container_start.go | 8 + .../engine-api/client/container_stats.go | 22 + .../engine-api/client/container_stop.go | 16 + .../docker/engine-api/client/container_top.go | 27 ++ .../engine-api/client/container_unpause.go | 8 + .../engine-api/client/container_update.go | 12 + .../docker/engine-api/client/copy.go | 95 ++++ .../docker/engine-api/client/diff.go | 25 ++ .../docker/engine-api/client/errors.go | 94 ++++ .../docker/engine-api/client/events.go | 46 ++ .../docker/engine-api/client/exec.go | 48 ++ .../docker/engine-api/client/export.go | 18 + .../docker/engine-api/client/hijack.go | 164 +++++++ .../docker/engine-api/client/history.go | 23 + .../docker/engine-api/client/image_build.go | 127 ++++++ .../docker/engine-api/client/image_create.go | 26 ++ .../docker/engine-api/client/image_import.go | 27 ++ .../docker/engine-api/client/image_inspect.go | 37 ++ .../docker/engine-api/client/image_list.go | 39 ++ .../docker/engine-api/client/image_load.go | 22 + .../docker/engine-api/client/image_pull.go | 34 ++ .../docker/engine-api/client/image_push.go | 36 ++ .../docker/engine-api/client/image_remove.go | 30 ++ .../docker/engine-api/client/image_save.go | 20 + .../docker/engine-api/client/image_search.go | 39 ++ .../docker/engine-api/client/image_tag.go | 21 + .../docker/engine-api/client/info.go | 25 ++ .../docker/engine-api/client/kill.go | 13 + .../docker/engine-api/client/login.go | 27 ++ .../docker/engine-api/client/logs.go | 46 ++ .../docker/engine-api/client/network.go | 82 ++++ .../docker/engine-api/client/pause.go | 8 + .../docker/engine-api/client/privileged.go | 9 + .../docker/engine-api/client/request.go | 176 ++++++++ .../docker/engine-api/client/resize.go | 28 ++ .../docker/engine-api/client/version.go | 20 + .../docker/engine-api/client/volume.go | 66 +++ .../docker/engine-api/client/wait.go | 24 + .../docker/engine-api/types/auth.go | 11 + .../docker/engine-api/types/blkiodev/blkio.go | 23 + .../docker/engine-api/types/client.go | 245 ++++++++++ .../docker/engine-api/types/configs.go | 50 +++ .../engine-api/types/container/config.go | 38 ++ .../engine-api/types/container/host_config.go | 227 ++++++++++ .../types/container/hostconfig_unix.go | 87 ++++ .../types/container/hostconfig_windows.go | 75 ++++ .../docker/engine-api/types/events/events.go | 38 ++ .../docker/engine-api/types/filters/parse.go | 257 +++++++++++ .../engine-api/types/network/network.go | 33 ++ .../engine-api/types/registry/registry.go | 101 +++++ .../docker/engine-api/types/stats.go | 105 +++++ .../engine-api/types/strslice/strslice.go | 71 +++ .../docker/engine-api/types/time/timestamp.go | 124 +++++ .../docker/engine-api/types/types.go | 424 ++++++++++++++++++ .../engine-api/types/versions/v1p19/types.go | 35 ++ .../engine-api/types/versions/v1p20/types.go | 40 ++ 67 files changed, 4203 insertions(+), 1 deletion(-) create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/LICENSE create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/client.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_attach.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_commit.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_create.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_inspect.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_list.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_remove.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_rename.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_restart.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_start.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_stats.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_stop.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_top.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_unpause.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/container_update.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/copy.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/diff.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/errors.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/events.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/exec.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/export.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/hijack.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/history.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_build.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_create.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_import.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_inspect.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_list.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_load.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_pull.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_push.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_remove.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_save.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_search.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/image_tag.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/info.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/kill.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/login.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/logs.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/network.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/pause.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/privileged.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/request.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/resize.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/version.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/volume.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/client/wait.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/auth.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/blkiodev/blkio.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/client.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/configs.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/container/config.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/container/host_config.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_unix.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/events/events.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/filters/parse.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/network/network.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/registry/registry.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/stats.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/time/timestamp.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/types.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p19/types.go create mode 100644 components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p20/types.go diff --git a/components/engine/hack/vendor.sh b/components/engine/hack/vendor.sh index 9a4a612cdf..46045ef5a2 100755 --- a/components/engine/hack/vendor.sh +++ b/components/engine/hack/vendor.sh @@ -21,7 +21,8 @@ clone git github.com/tchap/go-patricia v2.1.0 clone git github.com/vdemeester/shakers 3c10293ce22b900c27acad7b28656196fcc2f73b clone git golang.org/x/net 47990a1ba55743e6ef1affd3a14e5bac8553615d https://github.com/golang/net.git clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 -clone git github.com/docker/go-connections 4e42727957c146776e5de9cec8c39e4059ed9f20 +clone git github.com/docker/go-connections v0.1.2 +clone git github.com/docker/engine-api v0.1.1 #get libnetwork packages clone git github.com/docker/libnetwork 9f0563ea8f430d8828553aac97161cbff4056436 diff --git a/components/engine/vendor/src/github.com/docker/engine-api/LICENSE b/components/engine/vendor/src/github.com/docker/engine-api/LICENSE new file mode 100644 index 0000000000..c157bff96a --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2015-2016 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/client.go b/components/engine/vendor/src/github.com/docker/engine-api/client/client.go new file mode 100644 index 0000000000..061fd55daf --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/client.go @@ -0,0 +1,142 @@ +package client + +import ( + "crypto/tls" + "fmt" + "net" + "net/http" + "net/url" + "os" + "path/filepath" + "strings" + "time" +) + +// Client is the API client that performs all operations +// against a docker server. +type Client struct { + // proto holds the client protocol i.e. unix. + proto string + // addr holds the client address. + addr string + // basePath holds the path to prepend to the requests + basePath string + // scheme holds the scheme of the client i.e. https. + scheme string + // tlsConfig holds the tls configuration to use in hijacked requests. + tlsConfig *tls.Config + // httpClient holds the client transport instance. Exported to keep the old code running. + httpClient *http.Client + // version of the server to talk to. + version string + // custom http headers configured by users + customHTTPHeaders map[string]string +} + +// NewEnvClient initializes a new API client based on environment variables. +// Use DOCKER_HOST to set the url to the docker server. +// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest. +// Use DOCKER_CERT_PATH to load the tls certificates from. +// Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default. +func NewEnvClient() (*Client, error) { + var transport *http.Transport + if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" { + tlsc := &tls.Config{} + + cert, err := tls.LoadX509KeyPair(filepath.Join(dockerCertPath, "cert.pem"), filepath.Join(dockerCertPath, "key.pem")) + if err != nil { + return nil, fmt.Errorf("Error loading x509 key pair: %s", err) + } + + tlsc.Certificates = append(tlsc.Certificates, cert) + tlsc.InsecureSkipVerify = os.Getenv("DOCKER_TLS_VERIFY") == "" + transport = &http.Transport{ + TLSClientConfig: tlsc, + } + } + + return NewClient(os.Getenv("DOCKER_HOST"), os.Getenv("DOCKER_API_VERSION"), transport, nil) +} + +// NewClient initializes a new API client for the given host and API version. +// It won't send any version information if the version number is empty. +// It uses the transport to create a new http client. +// It also initializes the custom http headers to add to each request. +func NewClient(host string, version string, transport *http.Transport, httpHeaders map[string]string) (*Client, error) { + var ( + basePath string + tlsConfig *tls.Config + scheme = "http" + protoAddrParts = strings.SplitN(host, "://", 2) + proto, addr = protoAddrParts[0], protoAddrParts[1] + ) + + if proto == "tcp" { + parsed, err := url.Parse("tcp://" + addr) + if err != nil { + return nil, err + } + addr = parsed.Host + basePath = parsed.Path + } + + transport = configureTransport(transport, proto, addr) + if transport.TLSClientConfig != nil { + scheme = "https" + } + + return &Client{ + proto: proto, + addr: addr, + basePath: basePath, + scheme: scheme, + tlsConfig: tlsConfig, + httpClient: &http.Client{Transport: transport}, + version: version, + customHTTPHeaders: httpHeaders, + }, nil +} + +// getAPIPath returns the versioned request path to call the api. +// It appends the query parameters to the path if they are not empty. +func (cli *Client) getAPIPath(p string, query url.Values) string { + var apiPath string + if cli.version != "" { + v := strings.TrimPrefix(cli.version, "v") + apiPath = fmt.Sprintf("%s/v%s%s", cli.basePath, v, p) + } else { + apiPath = fmt.Sprintf("%s%s", cli.basePath, p) + } + if len(query) > 0 { + apiPath += "?" + query.Encode() + } + return apiPath +} + +// ClientVersion returns the version string associated with this +// instance of the Client. Note that this value can be changed +// via the DOCKER_API_VERSION env var. +func (cli *Client) ClientVersion() string { + return cli.version +} + +func configureTransport(tr *http.Transport, proto, addr string) *http.Transport { + if tr == nil { + tr = &http.Transport{} + } + + // Why 32? See https://github.com/docker/docker/pull/8035. + timeout := 32 * time.Second + if proto == "unix" { + // No need for compression in local communications. + tr.DisableCompression = true + tr.Dial = func(_, _ string) (net.Conn, error) { + return net.DialTimeout(proto, addr, timeout) + } + } else { + tr.Proxy = http.ProxyFromEnvironment + tr.Dial = (&net.Dialer{Timeout: timeout}).Dial + } + + return tr +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_attach.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_attach.go new file mode 100644 index 0000000000..1a403c36e0 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_attach.go @@ -0,0 +1,33 @@ +package client + +import ( + "net/url" + + "github.com/docker/engine-api/types" +) + +// ContainerAttach attaches a connection to a container in the server. +// It returns a types.HijackedConnection with the hijacked connection +// and the a reader to get output. It's up to the called to close +// the hijacked connection by calling types.HijackedResponse.Close. +func (cli *Client) ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error) { + query := url.Values{} + if options.Stream { + query.Set("stream", "1") + } + if options.Stdin { + query.Set("stdin", "1") + } + if options.Stdout { + query.Set("stdout", "1") + } + if options.Stderr { + query.Set("stderr", "1") + } + if options.DetachKeys != "" { + query.Set("detachKeys", options.DetachKeys) + } + + headers := map[string][]string{"Content-Type": {"text/plain"}} + return cli.postHijacked("/containers/"+options.ContainerID+"/attach", query, nil, headers) +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_commit.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_commit.go new file mode 100644 index 0000000000..488d0876f7 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_commit.go @@ -0,0 +1,37 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ContainerCommit applies changes into a container and creates a new tagged image. +func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) { + query := url.Values{} + query.Set("container", options.ContainerID) + query.Set("repo", options.RepositoryName) + query.Set("tag", options.Tag) + query.Set("comment", options.Comment) + query.Set("author", options.Author) + for _, change := range options.Changes { + query.Add("changes", change) + } + if options.Pause != true { + query.Set("pause", "0") + } + + var response types.ContainerCommitResponse + resp, err := cli.post("/commit", query, options.Config, nil) + if err != nil { + return response, err + } + defer ensureReaderClosed(resp) + + if err := json.NewDecoder(resp.body).Decode(&response); err != nil { + return response, err + } + + return response, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_create.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_create.go new file mode 100644 index 0000000000..88a0520cea --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_create.go @@ -0,0 +1,53 @@ +package client + +import ( + "encoding/json" + "net/url" + "strings" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" +) + +type configWrapper struct { + *container.Config + HostConfig *container.HostConfig +} + +// ContainerCreate creates a new container based in the given configuration. +// It can be associated with a name, but it's not mandatory. +func (cli *Client) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, containerName string) (types.ContainerCreateResponse, error) { + var response types.ContainerCreateResponse + query := url.Values{} + if containerName != "" { + query.Set("name", containerName) + } + + body := configWrapper{ + Config: config, + HostConfig: hostConfig, + } + + serverResp, err := cli.post("/containers/create", query, body, nil) + if err != nil { + if serverResp != nil && serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) { + return response, imageNotFoundError{config.Image} + } + return response, err + } + + if serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) { + return response, imageNotFoundError{config.Image} + } + + if err != nil { + return response, err + } + defer ensureReaderClosed(serverResp) + + if err := json.NewDecoder(serverResp.body).Decode(&response); err != nil { + return response, err + } + + return response, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_inspect.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_inspect.go new file mode 100644 index 0000000000..c18a764ef8 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_inspect.go @@ -0,0 +1,64 @@ +package client + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ContainerInspect returns the container information. +func (cli *Client) ContainerInspect(containerID string) (types.ContainerJSON, error) { + serverResp, err := cli.get("/containers/"+containerID+"/json", nil, nil) + if err != nil { + if serverResp.statusCode == http.StatusNotFound { + return types.ContainerJSON{}, containerNotFoundError{containerID} + } + return types.ContainerJSON{}, err + } + defer ensureReaderClosed(serverResp) + + var response types.ContainerJSON + err = json.NewDecoder(serverResp.body).Decode(&response) + return response, err +} + +// ContainerInspectWithRaw returns the container information and it's raw representation. +func (cli *Client) ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error) { + query := url.Values{} + if getSize { + query.Set("size", "1") + } + serverResp, err := cli.get("/containers/"+containerID+"/json", query, nil) + if err != nil { + if serverResp.statusCode == http.StatusNotFound { + return types.ContainerJSON{}, nil, containerNotFoundError{containerID} + } + return types.ContainerJSON{}, nil, err + } + defer ensureReaderClosed(serverResp) + + body, err := ioutil.ReadAll(serverResp.body) + if err != nil { + return types.ContainerJSON{}, nil, err + } + + var response types.ContainerJSON + rdr := bytes.NewReader(body) + err = json.NewDecoder(rdr).Decode(&response) + return response, body, err +} + +func (cli *Client) containerInspectWithResponse(containerID string, query url.Values) (types.ContainerJSON, *serverResponse, error) { + serverResp, err := cli.get("/containers/"+containerID+"/json", nil, nil) + if err != nil { + return types.ContainerJSON{}, serverResp, err + } + + var response types.ContainerJSON + err = json.NewDecoder(serverResp.body).Decode(&response) + return response, serverResp, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_list.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_list.go new file mode 100644 index 0000000000..b55307c84e --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_list.go @@ -0,0 +1,54 @@ +package client + +import ( + "encoding/json" + "net/url" + "strconv" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" +) + +// ContainerList returns the list of containers in the docker host. +func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Container, error) { + query := url.Values{} + + if options.All { + query.Set("all", "1") + } + + if options.Limit != -1 { + query.Set("limit", strconv.Itoa(options.Limit)) + } + + if options.Since != "" { + query.Set("since", options.Since) + } + + if options.Before != "" { + query.Set("before", options.Before) + } + + if options.Size { + query.Set("size", "1") + } + + if options.Filter.Len() > 0 { + filterJSON, err := filters.ToParam(options.Filter) + if err != nil { + return nil, err + } + + query.Set("filters", filterJSON) + } + + resp, err := cli.get("/containers/json", query, nil) + if err != nil { + return nil, err + } + defer ensureReaderClosed(resp) + + var containers []types.Container + err = json.NewDecoder(resp.body).Decode(&containers) + return containers, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_remove.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_remove.go new file mode 100644 index 0000000000..b078d4880b --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_remove.go @@ -0,0 +1,26 @@ +package client + +import ( + "net/url" + + "github.com/docker/engine-api/types" +) + +// ContainerRemove kills and removes a container from the docker host. +func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error { + query := url.Values{} + if options.RemoveVolumes { + query.Set("v", "1") + } + if options.RemoveLinks { + query.Set("link", "1") + } + + if options.Force { + query.Set("force", "1") + } + + resp, err := cli.delete("/containers/"+options.ContainerID, query, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_rename.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_rename.go new file mode 100644 index 0000000000..9d8b08af0a --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_rename.go @@ -0,0 +1,12 @@ +package client + +import "net/url" + +// ContainerRename changes the name of a given container. +func (cli *Client) ContainerRename(containerID, newContainerName string) error { + query := url.Values{} + query.Set("name", newContainerName) + resp, err := cli.post("/containers/"+containerID+"/rename", query, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_restart.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_restart.go new file mode 100644 index 0000000000..73da43cb36 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_restart.go @@ -0,0 +1,17 @@ +package client + +import ( + "net/url" + "strconv" +) + +// ContainerRestart stops and starts a container again. +// It makes the daemon to wait for the container to be up again for +// a specific amount of time, given the timeout. +func (cli *Client) ContainerRestart(containerID string, timeout int) error { + query := url.Values{} + query.Set("t", strconv.Itoa(timeout)) + resp, err := cli.post("/containers/"+containerID+"/restart", query, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_start.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_start.go new file mode 100644 index 0000000000..3751ce7e3e --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_start.go @@ -0,0 +1,8 @@ +package client + +// ContainerStart sends a request to the docker daemon to start a container. +func (cli *Client) ContainerStart(containerID string) error { + resp, err := cli.post("/containers/"+containerID+"/start", nil, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_stats.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_stats.go new file mode 100644 index 0000000000..486b8b0e7e --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_stats.go @@ -0,0 +1,22 @@ +package client + +import ( + "io" + "net/url" +) + +// ContainerStats returns near realtime stats for a given container. +// It's up to the caller to close the io.ReadCloser returned. +func (cli *Client) ContainerStats(containerID string, stream bool) (io.ReadCloser, error) { + query := url.Values{} + query.Set("stream", "0") + if stream { + query.Set("stream", "1") + } + + resp, err := cli.get("/containers/"+containerID+"/stats", query, nil) + if err != nil { + return nil, err + } + return resp.body, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_stop.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_stop.go new file mode 100644 index 0000000000..7f850efe9a --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_stop.go @@ -0,0 +1,16 @@ +package client + +import ( + "net/url" + "strconv" +) + +// ContainerStop stops a container without terminating the process. +// The process is blocked until the container stops or the timeout expires. +func (cli *Client) ContainerStop(containerID string, timeout int) error { + query := url.Values{} + query.Set("t", strconv.Itoa(timeout)) + resp, err := cli.post("/containers/"+containerID+"/stop", query, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_top.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_top.go new file mode 100644 index 0000000000..04aecc278c --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_top.go @@ -0,0 +1,27 @@ +package client + +import ( + "encoding/json" + "net/url" + "strings" + + "github.com/docker/engine-api/types" +) + +// ContainerTop shows process information from within a container. +func (cli *Client) ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error) { + var response types.ContainerProcessList + query := url.Values{} + if len(arguments) > 0 { + query.Set("ps_args", strings.Join(arguments, " ")) + } + + resp, err := cli.get("/containers/"+containerID+"/top", query, nil) + if err != nil { + return response, err + } + defer ensureReaderClosed(resp) + + err = json.NewDecoder(resp.body).Decode(&response) + return response, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_unpause.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_unpause.go new file mode 100644 index 0000000000..cbaaed898a --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_unpause.go @@ -0,0 +1,8 @@ +package client + +// ContainerUnpause resumes the process execution within a container +func (cli *Client) ContainerUnpause(containerID string) error { + resp, err := cli.post("/containers/"+containerID+"/unpause", nil, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/container_update.go b/components/engine/vendor/src/github.com/docker/engine-api/client/container_update.go new file mode 100644 index 0000000000..f58b8c3293 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/container_update.go @@ -0,0 +1,12 @@ +package client + +import ( + "github.com/docker/engine-api/types/container" +) + +// ContainerUpdate updates resources of a container +func (cli *Client) ContainerUpdate(containerID string, hostConfig container.HostConfig) error { + resp, err := cli.post("/containers/"+containerID+"/update", nil, hostConfig, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/copy.go b/components/engine/vendor/src/github.com/docker/engine-api/client/copy.go new file mode 100644 index 0000000000..92cf384a07 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/copy.go @@ -0,0 +1,95 @@ +package client + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "path/filepath" + "strings" + + "github.com/docker/engine-api/types" +) + +// ContainerStatPath returns Stat information about a path inside the container filesystem. +func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) { + query := url.Values{} + query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API. + + urlStr := fmt.Sprintf("/containers/%s/archive", containerID) + response, err := cli.head(urlStr, query, nil) + if err != nil { + return types.ContainerPathStat{}, err + } + defer ensureReaderClosed(response) + return getContainerPathStatFromHeader(response.header) +} + +// CopyToContainer copies content into the container filesystem. +func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error { + query := url.Values{} + query.Set("path", filepath.ToSlash(options.Path)) // Normalize the paths used in the API. + // Do not allow for an existing directory to be overwritten by a non-directory and vice versa. + if !options.AllowOverwriteDirWithFile { + query.Set("noOverwriteDirNonDir", "true") + } + + path := fmt.Sprintf("/containers/%s/archive", options.ContainerID) + + response, err := cli.putRaw(path, query, options.Content, nil) + if err != nil { + return err + } + defer ensureReaderClosed(response) + + if response.statusCode != http.StatusOK { + return fmt.Errorf("unexpected status code from daemon: %d", response.statusCode) + } + + return nil +} + +// CopyFromContainer get the content from the container and return it as a Reader +// to manipulate it in the host. It's up to the caller to close the reader. +func (cli *Client) CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { + query := make(url.Values, 1) + query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API. + + apiPath := fmt.Sprintf("/containers/%s/archive", containerID) + response, err := cli.get(apiPath, query, nil) + if err != nil { + return nil, types.ContainerPathStat{}, err + } + + if response.statusCode != http.StatusOK { + return nil, types.ContainerPathStat{}, fmt.Errorf("unexpected status code from daemon: %d", response.statusCode) + } + + // In order to get the copy behavior right, we need to know information + // about both the source and the destination. The response headers include + // stat info about the source that we can use in deciding exactly how to + // copy it locally. Along with the stat info about the local destination, + // we have everything we need to handle the multiple possibilities there + // can be when copying a file/dir from one location to another file/dir. + stat, err := getContainerPathStatFromHeader(response.header) + if err != nil { + return nil, stat, fmt.Errorf("unable to get resource stat from response: %s", err) + } + return response.body, stat, err +} + +func getContainerPathStatFromHeader(header http.Header) (types.ContainerPathStat, error) { + var stat types.ContainerPathStat + + encodedStat := header.Get("X-Docker-Container-Path-Stat") + statDecoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(encodedStat)) + + err := json.NewDecoder(statDecoder).Decode(&stat) + if err != nil { + err = fmt.Errorf("unable to decode container path stat header: %s", err) + } + + return stat, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/diff.go b/components/engine/vendor/src/github.com/docker/engine-api/client/diff.go new file mode 100644 index 0000000000..6639d8bb25 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/diff.go @@ -0,0 +1,25 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ContainerDiff shows differences in a container filesystem since it was started. +func (cli *Client) ContainerDiff(containerID string) ([]types.ContainerChange, error) { + var changes []types.ContainerChange + + serverResp, err := cli.get("/containers/"+containerID+"/changes", url.Values{}, nil) + if err != nil { + return changes, err + } + defer ensureReaderClosed(serverResp) + + if err := json.NewDecoder(serverResp.body).Decode(&changes); err != nil { + return changes, err + } + + return changes, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/errors.go b/components/engine/vendor/src/github.com/docker/engine-api/client/errors.go new file mode 100644 index 0000000000..f1701f8e92 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/errors.go @@ -0,0 +1,94 @@ +package client + +import ( + "errors" + "fmt" +) + +// ErrConnectionFailed is a error raised when the connection between the client and the server failed. +var ErrConnectionFailed = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?") + +// imageNotFoundError implements an error returned when an image is not in the docker host. +type imageNotFoundError struct { + imageID string +} + +// Error returns a string representation of an imageNotFoundError +func (i imageNotFoundError) Error() string { + return fmt.Sprintf("Error: No such image: %s", i.imageID) +} + +// IsErrImageNotFound returns true if the error is caused +// when an image is not found in the docker host. +func IsErrImageNotFound(err error) bool { + _, ok := err.(imageNotFoundError) + return ok +} + +// containerNotFoundError implements an error returned when a container is not in the docker host. +type containerNotFoundError struct { + containerID string +} + +// Error returns a string representation of an containerNotFoundError +func (e containerNotFoundError) Error() string { + return fmt.Sprintf("Error: No such container: %s", e.containerID) +} + +// IsErrContainerNotFound returns true if the error is caused +// when a container is not found in the docker host. +func IsErrContainerNotFound(err error) bool { + _, ok := err.(containerNotFoundError) + return ok +} + +// networkNotFoundError implements an error returned when a network is not in the docker host. +type networkNotFoundError struct { + networkID string +} + +// Error returns a string representation of an networkNotFoundError +func (e networkNotFoundError) Error() string { + return fmt.Sprintf("Error: No such network: %s", e.networkID) +} + +// IsErrNetworkNotFound returns true if the error is caused +// when a network is not found in the docker host. +func IsErrNetworkNotFound(err error) bool { + _, ok := err.(networkNotFoundError) + return ok +} + +// volumeNotFoundError implements an error returned when a volume is not in the docker host. +type volumeNotFoundError struct { + volumeID string +} + +// Error returns a string representation of an networkNotFoundError +func (e volumeNotFoundError) Error() string { + return fmt.Sprintf("Error: No such volume: %s", e.volumeID) +} + +// IsErrVolumeNotFound returns true if the error is caused +// when a volume is not found in the docker host. +func IsErrVolumeNotFound(err error) bool { + _, ok := err.(networkNotFoundError) + return ok +} + +// unauthorizedError represents an authorization error in a remote registry. +type unauthorizedError struct { + cause error +} + +// Error returns a string representation of an unauthorizedError +func (u unauthorizedError) Error() string { + return u.cause.Error() +} + +// IsErrUnauthorized returns true if the error is caused +// when an the remote registry authentication fails +func IsErrUnauthorized(err error) bool { + _, ok := err.(unauthorizedError) + return ok +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/events.go b/components/engine/vendor/src/github.com/docker/engine-api/client/events.go new file mode 100644 index 0000000000..41f2f37334 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/events.go @@ -0,0 +1,46 @@ +package client + +import ( + "io" + "net/url" + "time" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" + timetypes "github.com/docker/engine-api/types/time" +) + +// Events returns a stream of events in the daemon in a ReadCloser. +// It's up to the caller to close the stream. +func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) { + query := url.Values{} + ref := time.Now() + + if options.Since != "" { + ts, err := timetypes.GetTimestamp(options.Since, ref) + if err != nil { + return nil, err + } + query.Set("since", ts) + } + if options.Until != "" { + ts, err := timetypes.GetTimestamp(options.Until, ref) + if err != nil { + return nil, err + } + query.Set("until", ts) + } + if options.Filters.Len() > 0 { + filterJSON, err := filters.ToParam(options.Filters) + if err != nil { + return nil, err + } + query.Set("filters", filterJSON) + } + + serverResponse, err := cli.get("/events", query, nil) + if err != nil { + return nil, err + } + return serverResponse.body, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/exec.go b/components/engine/vendor/src/github.com/docker/engine-api/client/exec.go new file mode 100644 index 0000000000..3a86b4043f --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/exec.go @@ -0,0 +1,48 @@ +package client + +import ( + "encoding/json" + + "github.com/docker/engine-api/types" +) + +// ContainerExecCreate creates a new exec configuration to run an exec process. +func (cli *Client) ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error) { + var response types.ContainerExecCreateResponse + resp, err := cli.post("/containers/"+config.Container+"/exec", nil, config, nil) + if err != nil { + return response, err + } + defer ensureReaderClosed(resp) + err = json.NewDecoder(resp.body).Decode(&response) + return response, err +} + +// ContainerExecStart starts an exec process already create in the docker host. +func (cli *Client) ContainerExecStart(execID string, config types.ExecStartCheck) error { + resp, err := cli.post("/exec/"+execID+"/start", nil, config, nil) + ensureReaderClosed(resp) + return err +} + +// ContainerExecAttach attaches a connection to an exec process in the server. +// It returns a types.HijackedConnection with the hijacked connection +// and the a reader to get output. It's up to the called to close +// the hijacked connection by calling types.HijackedResponse.Close. +func (cli *Client) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) { + headers := map[string][]string{"Content-Type": {"application/json"}} + return cli.postHijacked("/exec/"+execID+"/start", nil, config, headers) +} + +// ContainerExecInspect returns information about a specific exec process on the docker host. +func (cli *Client) ContainerExecInspect(execID string) (types.ContainerExecInspect, error) { + var response types.ContainerExecInspect + resp, err := cli.get("/exec/"+execID+"/json", nil, nil) + if err != nil { + return response, err + } + defer ensureReaderClosed(resp) + + err = json.NewDecoder(resp.body).Decode(&response) + return response, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/export.go b/components/engine/vendor/src/github.com/docker/engine-api/client/export.go new file mode 100644 index 0000000000..2b67c21df2 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/export.go @@ -0,0 +1,18 @@ +package client + +import ( + "io" + "net/url" +) + +// ContainerExport retrieves the raw contents of a container +// and returns them as a io.ReadCloser. It's up to the caller +// to close the stream. +func (cli *Client) ContainerExport(containerID string) (io.ReadCloser, error) { + serverResp, err := cli.get("/containers/"+containerID+"/export", url.Values{}, nil) + if err != nil { + return nil, err + } + + return serverResp.body, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/hijack.go b/components/engine/vendor/src/github.com/docker/engine-api/client/hijack.go new file mode 100644 index 0000000000..5835d8c603 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/hijack.go @@ -0,0 +1,164 @@ +package client + +import ( + "crypto/tls" + "errors" + "fmt" + "net" + "net/http/httputil" + "net/url" + "strings" + "time" + + "github.com/docker/engine-api/types" +) + +// tlsClientCon holds tls information and a dialed connection. +type tlsClientCon struct { + *tls.Conn + rawConn net.Conn +} + +func (c *tlsClientCon) CloseWrite() error { + // Go standard tls.Conn doesn't provide the CloseWrite() method so we do it + // on its underlying connection. + if conn, ok := c.rawConn.(types.CloseWriter); ok { + return conn.CloseWrite() + } + return nil +} + +// postHijacked sends a POST request and hijacks the connection. +func (cli *Client) postHijacked(path string, query url.Values, body interface{}, headers map[string][]string) (types.HijackedResponse, error) { + bodyEncoded, err := encodeData(body) + if err != nil { + return types.HijackedResponse{}, err + } + + req, err := cli.newRequest("POST", path, query, bodyEncoded, headers) + if err != nil { + return types.HijackedResponse{}, err + } + req.Host = cli.addr + + req.Header.Set("Connection", "Upgrade") + req.Header.Set("Upgrade", "tcp") + + conn, err := dial(cli.proto, cli.addr, cli.tlsConfig) + if err != nil { + if strings.Contains(err.Error(), "connection refused") { + return types.HijackedResponse{}, fmt.Errorf("Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?") + } + return types.HijackedResponse{}, err + } + + // When we set up a TCP connection for hijack, there could be long periods + // of inactivity (a long running command with no output) that in certain + // network setups may cause ECONNTIMEOUT, leaving the client in an unknown + // state. Setting TCP KeepAlive on the socket connection will prohibit + // ECONNTIMEOUT unless the socket connection truly is broken + if tcpConn, ok := conn.(*net.TCPConn); ok { + tcpConn.SetKeepAlive(true) + tcpConn.SetKeepAlivePeriod(30 * time.Second) + } + + clientconn := httputil.NewClientConn(conn, nil) + defer clientconn.Close() + + // Server hijacks the connection, error 'connection closed' expected + clientconn.Do(req) + + rwc, br := clientconn.Hijack() + + return types.HijackedResponse{Conn: rwc, Reader: br}, nil +} + +func tlsDial(network, addr string, config *tls.Config) (net.Conn, error) { + return tlsDialWithDialer(new(net.Dialer), network, addr, config) +} + +// We need to copy Go's implementation of tls.Dial (pkg/cryptor/tls/tls.go) in +// order to return our custom tlsClientCon struct which holds both the tls.Conn +// object _and_ its underlying raw connection. The rationale for this is that +// we need to be able to close the write end of the connection when attaching, +// which tls.Conn does not provide. +func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) { + // We want the Timeout and Deadline values from dialer to cover the + // whole process: TCP connection and TLS handshake. This means that we + // also need to start our own timers now. + timeout := dialer.Timeout + + if !dialer.Deadline.IsZero() { + deadlineTimeout := dialer.Deadline.Sub(time.Now()) + if timeout == 0 || deadlineTimeout < timeout { + timeout = deadlineTimeout + } + } + + var errChannel chan error + + if timeout != 0 { + errChannel = make(chan error, 2) + time.AfterFunc(timeout, func() { + errChannel <- errors.New("") + }) + } + + rawConn, err := dialer.Dial(network, addr) + if err != nil { + return nil, err + } + // When we set up a TCP connection for hijack, there could be long periods + // of inactivity (a long running command with no output) that in certain + // network setups may cause ECONNTIMEOUT, leaving the client in an unknown + // state. Setting TCP KeepAlive on the socket connection will prohibit + // ECONNTIMEOUT unless the socket connection truly is broken + if tcpConn, ok := rawConn.(*net.TCPConn); ok { + tcpConn.SetKeepAlive(true) + tcpConn.SetKeepAlivePeriod(30 * time.Second) + } + + colonPos := strings.LastIndex(addr, ":") + if colonPos == -1 { + colonPos = len(addr) + } + hostname := addr[:colonPos] + + // If no ServerName is set, infer the ServerName + // from the hostname we're connecting to. + if config.ServerName == "" { + // Make a copy to avoid polluting argument or default. + c := *config + c.ServerName = hostname + config = &c + } + + conn := tls.Client(rawConn, config) + + if timeout == 0 { + err = conn.Handshake() + } else { + go func() { + errChannel <- conn.Handshake() + }() + + err = <-errChannel + } + + if err != nil { + rawConn.Close() + return nil, err + } + + // This is Docker difference with standard's crypto/tls package: returned a + // wrapper which holds both the TLS and raw connections. + return &tlsClientCon{conn, rawConn}, nil +} + +func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { + if tlsConfig != nil && proto != "unix" { + // Notice this isn't Go standard's tls.Dial function + return tlsDial(proto, addr, tlsConfig) + } + return net.Dial(proto, addr) +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/history.go b/components/engine/vendor/src/github.com/docker/engine-api/client/history.go new file mode 100644 index 0000000000..77697274ae --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/history.go @@ -0,0 +1,23 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageHistory returns the changes in an image in history format. +func (cli *Client) ImageHistory(imageID string) ([]types.ImageHistory, error) { + var history []types.ImageHistory + serverResp, err := cli.get("/images/"+imageID+"/history", url.Values{}, nil) + if err != nil { + return history, err + } + defer ensureReaderClosed(serverResp) + + if err := json.NewDecoder(serverResp.body).Decode(&history); err != nil { + return history, err + } + return history, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_build.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_build.go new file mode 100644 index 0000000000..84e57fe68f --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_build.go @@ -0,0 +1,127 @@ +package client + +import ( + "encoding/base64" + "encoding/json" + "net/http" + "net/url" + "regexp" + "strconv" + "strings" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" +) + +var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`) + +// ImageBuild sends request to the daemon to build images. +// The Body in the response implement an io.ReadCloser and it's up to the caller to +// close it. +func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error) { + query, err := imageBuildOptionsToQuery(options) + if err != nil { + return types.ImageBuildResponse{}, err + } + + headers := http.Header(make(map[string][]string)) + buf, err := json.Marshal(options.AuthConfigs) + if err != nil { + return types.ImageBuildResponse{}, err + } + headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) + headers.Set("Content-Type", "application/tar") + + serverResp, err := cli.postRaw("/build", query, options.Context, headers) + if err != nil { + return types.ImageBuildResponse{}, err + } + + osType := getDockerOS(serverResp.header.Get("Server")) + + return types.ImageBuildResponse{ + Body: serverResp.body, + OSType: osType, + }, nil +} + +func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, error) { + query := url.Values{ + "t": options.Tags, + } + if options.SuppressOutput { + query.Set("q", "1") + } + if options.RemoteContext != "" { + query.Set("remote", options.RemoteContext) + } + if options.NoCache { + query.Set("nocache", "1") + } + if options.Remove { + query.Set("rm", "1") + } else { + query.Set("rm", "0") + } + + if options.ForceRemove { + query.Set("forcerm", "1") + } + + if options.PullParent { + query.Set("pull", "1") + } + + if !container.IsolationLevel.IsDefault(options.IsolationLevel) { + query.Set("isolation", string(options.IsolationLevel)) + } + + query.Set("cpusetcpus", options.CPUSetCPUs) + query.Set("cpusetmems", options.CPUSetMems) + query.Set("cpushares", strconv.FormatInt(options.CPUShares, 10)) + query.Set("cpuquota", strconv.FormatInt(options.CPUQuota, 10)) + query.Set("cpuperiod", strconv.FormatInt(options.CPUPeriod, 10)) + query.Set("memory", strconv.FormatInt(options.Memory, 10)) + query.Set("memswap", strconv.FormatInt(options.MemorySwap, 10)) + query.Set("cgroupparent", options.CgroupParent) + query.Set("shmsize", strconv.FormatInt(options.ShmSize, 10)) + query.Set("dockerfile", options.Dockerfile) + + ulimitsJSON, err := json.Marshal(options.Ulimits) + if err != nil { + return query, err + } + query.Set("ulimits", string(ulimitsJSON)) + + buildArgsJSON, err := json.Marshal(options.BuildArgs) + if err != nil { + return query, err + } + query.Set("buildargs", string(buildArgsJSON)) + + return query, nil +} + +func getDockerOS(serverHeader string) string { + var osType string + matches := headerRegexp.FindStringSubmatch(serverHeader) + if len(matches) > 0 { + osType = matches[1] + } + return osType +} + +// convertKVStringsToMap converts ["key=value"] to {"key":"value"} +func convertKVStringsToMap(values []string) map[string]string { + result := make(map[string]string, len(values)) + for _, value := range values { + kv := strings.SplitN(value, "=", 2) + if len(kv) == 1 { + result[kv[0]] = "" + } else { + result[kv[0]] = kv[1] + } + } + + return result +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_create.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_create.go new file mode 100644 index 0000000000..bd319228c5 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_create.go @@ -0,0 +1,26 @@ +package client + +import ( + "io" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageCreate creates a new image based in the parent options. +// It returns the JSON content in the response body. +func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) { + query := url.Values{} + query.Set("fromImage", options.Parent) + query.Set("tag", options.Tag) + resp, err := cli.tryImageCreate(query, options.RegistryAuth) + if err != nil { + return nil, err + } + return resp.body, nil +} + +func (cli *Client) tryImageCreate(query url.Values, registryAuth string) (*serverResponse, error) { + headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + return cli.post("/images/create", query, nil, headers) +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_import.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_import.go new file mode 100644 index 0000000000..212a942a5f --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_import.go @@ -0,0 +1,27 @@ +package client + +import ( + "io" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageImport creates a new image based in the source options. +// It returns the JSON content in the response body. +func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error) { + query := url.Values{} + query.Set("fromSrc", options.SourceName) + query.Set("repo", options.RepositoryName) + query.Set("tag", options.Tag) + query.Set("message", options.Message) + for _, change := range options.Changes { + query.Add("changes", change) + } + + resp, err := cli.postRaw("/images/create", query, options.Source, nil) + if err != nil { + return nil, err + } + return resp.body, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_inspect.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_inspect.go new file mode 100644 index 0000000000..9ef9fc36eb --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_inspect.go @@ -0,0 +1,37 @@ +package client + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageInspectWithRaw returns the image information and it's raw representation. +func (cli *Client) ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error) { + query := url.Values{} + if getSize { + query.Set("size", "1") + } + serverResp, err := cli.get("/images/"+imageID+"/json", query, nil) + if err != nil { + if serverResp.statusCode == http.StatusNotFound { + return types.ImageInspect{}, nil, imageNotFoundError{imageID} + } + return types.ImageInspect{}, nil, err + } + defer ensureReaderClosed(serverResp) + + body, err := ioutil.ReadAll(serverResp.body) + if err != nil { + return types.ImageInspect{}, nil, err + } + + var response types.ImageInspect + rdr := bytes.NewReader(body) + err = json.NewDecoder(rdr).Decode(&response) + return response, body, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_list.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_list.go new file mode 100644 index 0000000000..d961570c4a --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_list.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" +) + +// ImageList returns a list of images in the docker host. +func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error) { + var images []types.Image + query := url.Values{} + + if options.Filters.Len() > 0 { + filterJSON, err := filters.ToParam(options.Filters) + if err != nil { + return images, err + } + query.Set("filters", filterJSON) + } + if options.MatchName != "" { + // FIXME rename this parameter, to not be confused with the filters flag + query.Set("filter", options.MatchName) + } + if options.All { + query.Set("all", "1") + } + + serverResp, err := cli.get("/images/json", query, nil) + if err != nil { + return images, err + } + defer ensureReaderClosed(serverResp) + + err = json.NewDecoder(serverResp.body).Decode(&images) + return images, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_load.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_load.go new file mode 100644 index 0000000000..ea6924a57b --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_load.go @@ -0,0 +1,22 @@ +package client + +import ( + "io" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageLoad loads an image in the docker host from the client host. +// It's up to the caller to close the io.ReadCloser returned by +// this function. +func (cli *Client) ImageLoad(input io.Reader) (types.ImageLoadResponse, error) { + resp, err := cli.postRaw("/images/load", url.Values{}, input, nil) + if err != nil { + return types.ImageLoadResponse{}, err + } + return types.ImageLoadResponse{ + Body: resp.body, + JSON: resp.header.Get("Content-Type") == "application/json", + }, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_pull.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_pull.go new file mode 100644 index 0000000000..69636925cb --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_pull.go @@ -0,0 +1,34 @@ +package client + +import ( + "io" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImagePull request the docker host to pull an image from a remote registry. +// It executes the privileged function if the operation is unauthorized +// and it tries one more time. +// It's up to the caller to handle the io.ReadCloser and close it properly. +func (cli *Client) ImagePull(options types.ImagePullOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error) { + query := url.Values{} + query.Set("fromImage", options.ImageID) + if options.Tag != "" { + query.Set("tag", options.Tag) + } + + resp, err := cli.tryImageCreate(query, options.RegistryAuth) + if resp.statusCode == http.StatusUnauthorized { + newAuthHeader, privilegeErr := privilegeFunc() + if privilegeErr != nil { + return nil, privilegeErr + } + resp, err = cli.tryImageCreate(query, newAuthHeader) + } + if err != nil { + return nil, err + } + return resp.body, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_push.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_push.go new file mode 100644 index 0000000000..fe3877dd31 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_push.go @@ -0,0 +1,36 @@ +package client + +import ( + "io" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImagePush request the docker host to push an image to a remote registry. +// It executes the privileged function if the operation is unauthorized +// and it tries one more time. +// It's up to the caller to handle the io.ReadCloser and close it properly. +func (cli *Client) ImagePush(options types.ImagePushOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error) { + query := url.Values{} + query.Set("tag", options.Tag) + + resp, err := cli.tryImagePush(options.ImageID, query, options.RegistryAuth) + if resp.statusCode == http.StatusUnauthorized { + newAuthHeader, privilegeErr := privilegeFunc() + if privilegeErr != nil { + return nil, privilegeErr + } + resp, err = cli.tryImagePush(options.ImageID, query, newAuthHeader) + } + if err != nil { + return nil, err + } + return resp.body, nil +} + +func (cli *Client) tryImagePush(imageID string, query url.Values, registryAuth string) (*serverResponse, error) { + headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + return cli.post("/images/"+imageID+"/push", query, nil, headers) +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_remove.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_remove.go new file mode 100644 index 0000000000..c9c232cd1b --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_remove.go @@ -0,0 +1,30 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageRemove removes an image from the docker host. +func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) { + query := url.Values{} + + if options.Force { + query.Set("force", "1") + } + if !options.PruneChildren { + query.Set("noprune", "1") + } + + resp, err := cli.delete("/images/"+options.ImageID, query, nil) + if err != nil { + return nil, err + } + defer ensureReaderClosed(resp) + + var dels []types.ImageDelete + err = json.NewDecoder(resp.body).Decode(&dels) + return dels, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_save.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_save.go new file mode 100644 index 0000000000..755d05412d --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_save.go @@ -0,0 +1,20 @@ +package client + +import ( + "io" + "net/url" +) + +// ImageSave retrieves one or more images from the docker host as a io.ReadCloser. +// It's up to the caller to store the images and close the stream. +func (cli *Client) ImageSave(imageIDs []string) (io.ReadCloser, error) { + query := url.Values{ + "names": imageIDs, + } + + resp, err := cli.get("/images/get", query, nil) + if err != nil { + return nil, err + } + return resp.body, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_search.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_search.go new file mode 100644 index 0000000000..5d9413c701 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_search.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/registry" +) + +// ImageSearch makes the docker host to search by a term in a remote registry. +// The list of results is not sorted in any fashion. +func (cli *Client) ImageSearch(options types.ImageSearchOptions, privilegeFunc RequestPrivilegeFunc) ([]registry.SearchResult, error) { + var results []registry.SearchResult + query := url.Values{} + query.Set("term", options.Term) + + resp, err := cli.tryImageSearch(query, options.RegistryAuth) + if resp.statusCode == http.StatusUnauthorized { + newAuthHeader, privilegeErr := privilegeFunc() + if privilegeErr != nil { + return results, privilegeErr + } + resp, err = cli.tryImageSearch(query, newAuthHeader) + } + if err != nil { + return results, err + } + defer ensureReaderClosed(resp) + + err = json.NewDecoder(resp.body).Decode(&results) + return results, err +} + +func (cli *Client) tryImageSearch(query url.Values, registryAuth string) (*serverResponse, error) { + headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + return cli.get("/images/search", query, headers) +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/image_tag.go b/components/engine/vendor/src/github.com/docker/engine-api/client/image_tag.go new file mode 100644 index 0000000000..5ae35914fe --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/image_tag.go @@ -0,0 +1,21 @@ +package client + +import ( + "net/url" + + "github.com/docker/engine-api/types" +) + +// ImageTag tags an image in the docker host +func (cli *Client) ImageTag(options types.ImageTagOptions) error { + query := url.Values{} + query.Set("repo", options.RepositoryName) + query.Set("tag", options.Tag) + if options.Force { + query.Set("force", "1") + } + + resp, err := cli.post("/images/"+options.ImageID+"/tag", query, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/info.go b/components/engine/vendor/src/github.com/docker/engine-api/client/info.go new file mode 100644 index 0000000000..666d4aee73 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/info.go @@ -0,0 +1,25 @@ +package client + +import ( + "encoding/json" + "fmt" + "net/url" + + "github.com/docker/engine-api/types" +) + +// Info returns information about the docker server. +func (cli *Client) Info() (types.Info, error) { + var info types.Info + serverResp, err := cli.get("/info", url.Values{}, nil) + if err != nil { + return info, err + } + defer ensureReaderClosed(serverResp) + + if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil { + return info, fmt.Errorf("Error reading remote info: %v", err) + } + + return info, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/kill.go b/components/engine/vendor/src/github.com/docker/engine-api/client/kill.go new file mode 100644 index 0000000000..d1820cbf9e --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/kill.go @@ -0,0 +1,13 @@ +package client + +import "net/url" + +// ContainerKill terminates the container process but does not remove the container from the docker host. +func (cli *Client) ContainerKill(containerID, signal string) error { + query := url.Values{} + query.Set("signal", signal) + + resp, err := cli.post("/containers/"+containerID+"/kill", query, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/login.go b/components/engine/vendor/src/github.com/docker/engine-api/client/login.go new file mode 100644 index 0000000000..e9ba8421b0 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/login.go @@ -0,0 +1,27 @@ +package client + +import ( + "encoding/json" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" +) + +// RegistryLogin authenticates the docker server with a given docker registry. +// It returns UnauthorizerError when the authentication fails. +func (cli *Client) RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error) { + resp, err := cli.post("/auth", url.Values{}, auth, nil) + + if resp != nil && resp.statusCode == http.StatusUnauthorized { + return types.AuthResponse{}, unauthorizedError{err} + } + if err != nil { + return types.AuthResponse{}, err + } + defer ensureReaderClosed(resp) + + var response types.AuthResponse + err = json.NewDecoder(resp.body).Decode(&response) + return response, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/logs.go b/components/engine/vendor/src/github.com/docker/engine-api/client/logs.go new file mode 100644 index 0000000000..58f1d97bd4 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/logs.go @@ -0,0 +1,46 @@ +package client + +import ( + "io" + "net/url" + "time" + + "github.com/docker/engine-api/types" + timetypes "github.com/docker/engine-api/types/time" +) + +// ContainerLogs returns the logs generated by a container in an io.ReadCloser. +// It's up to the caller to close the stream. +func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error) { + query := url.Values{} + if options.ShowStdout { + query.Set("stdout", "1") + } + + if options.ShowStderr { + query.Set("stderr", "1") + } + + if options.Since != "" { + ts, err := timetypes.GetTimestamp(options.Since, time.Now()) + if err != nil { + return nil, err + } + query.Set("since", ts) + } + + if options.Timestamps { + query.Set("timestamps", "1") + } + + if options.Follow { + query.Set("follow", "1") + } + query.Set("tail", options.Tail) + + resp, err := cli.get("/containers/"+options.ContainerID+"/logs", query, nil) + if err != nil { + return nil, err + } + return resp.body, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/network.go b/components/engine/vendor/src/github.com/docker/engine-api/client/network.go new file mode 100644 index 0000000000..b35604e067 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/network.go @@ -0,0 +1,82 @@ +package client + +import ( + "encoding/json" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" +) + +// NetworkCreate creates a new network in the docker host. +func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) { + var response types.NetworkCreateResponse + serverResp, err := cli.post("/networks/create", nil, options, nil) + if err != nil { + return response, err + } + + json.NewDecoder(serverResp.body).Decode(&response) + ensureReaderClosed(serverResp) + return response, err +} + +// NetworkRemove removes an existent network from the docker host. +func (cli *Client) NetworkRemove(networkID string) error { + resp, err := cli.delete("/networks/"+networkID, nil, nil) + ensureReaderClosed(resp) + return err +} + +// NetworkConnect connects a container to an existent network in the docker host. +func (cli *Client) NetworkConnect(networkID, containerID string) error { + nc := types.NetworkConnect{Container: containerID} + resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil) + ensureReaderClosed(resp) + return err +} + +// NetworkDisconnect disconnects a container from an existent network in the docker host. +func (cli *Client) NetworkDisconnect(networkID, containerID string) error { + nc := types.NetworkConnect{Container: containerID} + resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nc, nil) + ensureReaderClosed(resp) + return err +} + +// NetworkList returns the list of networks configured in the docker host. +func (cli *Client) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) { + query := url.Values{} + if options.Filters.Len() > 0 { + filterJSON, err := filters.ToParam(options.Filters) + if err != nil { + return nil, err + } + + query.Set("filters", filterJSON) + } + var networkResources []types.NetworkResource + resp, err := cli.get("/networks", query, nil) + if err != nil { + return networkResources, err + } + defer ensureReaderClosed(resp) + err = json.NewDecoder(resp.body).Decode(&networkResources) + return networkResources, err +} + +// NetworkInspect returns the information for a specific network configured in the docker host. +func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error) { + var networkResource types.NetworkResource + resp, err := cli.get("/networks/"+networkID, nil, nil) + if err != nil { + if resp.statusCode == http.StatusNotFound { + return networkResource, networkNotFoundError{networkID} + } + return networkResource, err + } + defer ensureReaderClosed(resp) + err = json.NewDecoder(resp.body).Decode(&networkResource) + return networkResource, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/pause.go b/components/engine/vendor/src/github.com/docker/engine-api/client/pause.go new file mode 100644 index 0000000000..7671be9f95 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/pause.go @@ -0,0 +1,8 @@ +package client + +// ContainerPause pauses the main process of a given container without terminating it. +func (cli *Client) ContainerPause(containerID string) error { + resp, err := cli.post("/containers/"+containerID+"/pause", nil, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/privileged.go b/components/engine/vendor/src/github.com/docker/engine-api/client/privileged.go new file mode 100644 index 0000000000..945f18cef5 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/privileged.go @@ -0,0 +1,9 @@ +package client + +// RequestPrivilegeFunc is a function interface that +// clients can supply to retry operations after +// getting an authorization error. +// This function returns the registry authentication +// header value in base 64 format, or an error +// if the privilege request fails. +type RequestPrivilegeFunc func() (string, error) diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/request.go b/components/engine/vendor/src/github.com/docker/engine-api/client/request.go new file mode 100644 index 0000000000..cd8c3176d8 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/request.go @@ -0,0 +1,176 @@ +package client + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +// serverResponse is a wrapper for http API responses. +type serverResponse struct { + body io.ReadCloser + header http.Header + statusCode int +} + +// head sends an http request to the docker API using the method HEAD. +func (cli *Client) head(path string, query url.Values, headers map[string][]string) (*serverResponse, error) { + return cli.sendRequest("HEAD", path, query, nil, headers) +} + +// get sends an http request to the docker API using the method GET. +func (cli *Client) get(path string, query url.Values, headers map[string][]string) (*serverResponse, error) { + return cli.sendRequest("GET", path, query, nil, headers) +} + +// post sends an http request to the docker API using the method POST. +func (cli *Client) post(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) { + return cli.sendRequest("POST", path, query, body, headers) +} + +// postRaw sends the raw input to the docker API using the method POST. +func (cli *Client) postRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) { + return cli.sendClientRequest("POST", path, query, body, headers) +} + +// put sends an http request to the docker API using the method PUT. +func (cli *Client) put(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) { + return cli.sendRequest("PUT", path, query, body, headers) +} + +// putRaw sends the raw input to the docker API using the method PUT. +func (cli *Client) putRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) { + return cli.sendClientRequest("PUT", path, query, body, headers) +} + +// delete sends an http request to the docker API using the method DELETE. +func (cli *Client) delete(path string, query url.Values, headers map[string][]string) (*serverResponse, error) { + return cli.sendRequest("DELETE", path, query, nil, headers) +} + +func (cli *Client) sendRequest(method, path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) { + params, err := encodeData(body) + if err != nil { + return nil, err + } + + if body != nil { + if headers == nil { + headers = make(map[string][]string) + } + headers["Content-Type"] = []string{"application/json"} + } + + return cli.sendClientRequest(method, path, query, params, headers) +} + +func (cli *Client) sendClientRequest(method, path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) { + serverResp := &serverResponse{ + body: nil, + statusCode: -1, + } + + expectedPayload := (method == "POST" || method == "PUT") + if expectedPayload && body == nil { + body = bytes.NewReader([]byte{}) + } + + req, err := cli.newRequest(method, path, query, body, headers) + req.URL.Host = cli.addr + req.URL.Scheme = cli.scheme + + if expectedPayload && req.Header.Get("Content-Type") == "" { + req.Header.Set("Content-Type", "text/plain") + } + + resp, err := cli.httpClient.Do(req) + if resp != nil { + serverResp.statusCode = resp.StatusCode + } + + if err != nil { + if isTimeout(err) || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") { + return serverResp, ErrConnectionFailed + } + + if cli.scheme == "http" && strings.Contains(err.Error(), "malformed HTTP response") { + return serverResp, fmt.Errorf("%v.\n* Are you trying to connect to a TLS-enabled daemon without TLS?", err) + } + if cli.scheme == "https" && strings.Contains(err.Error(), "remote error: bad certificate") { + return serverResp, fmt.Errorf("The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: %v", err) + } + + return serverResp, fmt.Errorf("An error occurred trying to connect: %v", err) + } + + if serverResp.statusCode < 200 || serverResp.statusCode >= 400 { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return serverResp, err + } + if len(body) == 0 { + return serverResp, fmt.Errorf("Error: request returned %s for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), req.URL) + } + return serverResp, fmt.Errorf("Error response from daemon: %s", bytes.TrimSpace(body)) + } + + serverResp.body = resp.Body + serverResp.header = resp.Header + return serverResp, nil +} + +func (cli *Client) newRequest(method, path string, query url.Values, body io.Reader, headers map[string][]string) (*http.Request, error) { + apiPath := cli.getAPIPath(path, query) + req, err := http.NewRequest(method, apiPath, body) + if err != nil { + return nil, err + } + + // Add CLI Config's HTTP Headers BEFORE we set the Docker headers + // then the user can't change OUR headers + for k, v := range cli.customHTTPHeaders { + req.Header.Set(k, v) + } + + if headers != nil { + for k, v := range headers { + req.Header[k] = v + } + } + + return req, nil +} + +func encodeData(data interface{}) (*bytes.Buffer, error) { + params := bytes.NewBuffer(nil) + if data != nil { + if err := json.NewEncoder(params).Encode(data); err != nil { + return nil, err + } + } + return params, nil +} + +func ensureReaderClosed(response *serverResponse) { + if response != nil && response.body != nil { + response.body.Close() + } +} + +func isTimeout(err error) bool { + type timeout interface { + Timeout() bool + } + e := err + switch urlErr := err.(type) { + case *url.Error: + e = urlErr.Err + } + t, ok := e.(timeout) + return ok && t.Timeout() +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/resize.go b/components/engine/vendor/src/github.com/docker/engine-api/client/resize.go new file mode 100644 index 0000000000..6ccd92cd9b --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/resize.go @@ -0,0 +1,28 @@ +package client + +import ( + "net/url" + "strconv" + + "github.com/docker/engine-api/types" +) + +// ContainerResize changes the size of the tty for a container. +func (cli *Client) ContainerResize(options types.ResizeOptions) error { + return cli.resize("/containers/"+options.ID, options.Height, options.Width) +} + +// ContainerExecResize changes the size of the tty for an exec process running inside a container. +func (cli *Client) ContainerExecResize(options types.ResizeOptions) error { + return cli.resize("/exec/"+options.ID, options.Height, options.Width) +} + +func (cli *Client) resize(basePath string, height, width int) error { + query := url.Values{} + query.Set("h", strconv.Itoa(height)) + query.Set("w", strconv.Itoa(width)) + + resp, err := cli.post(basePath+"/resize", query, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/version.go b/components/engine/vendor/src/github.com/docker/engine-api/client/version.go new file mode 100644 index 0000000000..e97b79801d --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/version.go @@ -0,0 +1,20 @@ +package client + +import ( + "encoding/json" + + "github.com/docker/engine-api/types" +) + +// ServerVersion returns information of the docker client and server host. +func (cli *Client) ServerVersion() (types.Version, error) { + resp, err := cli.get("/version", nil, nil) + if err != nil { + return types.Version{}, err + } + defer ensureReaderClosed(resp) + + var server types.Version + err = json.NewDecoder(resp.body).Decode(&server) + return server, err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/volume.go b/components/engine/vendor/src/github.com/docker/engine-api/client/volume.go new file mode 100644 index 0000000000..3419def9bb --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/volume.go @@ -0,0 +1,66 @@ +package client + +import ( + "encoding/json" + "net/http" + "net/url" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" +) + +// VolumeList returns the volumes configured in the docker host. +func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, error) { + var volumes types.VolumesListResponse + query := url.Values{} + + if filter.Len() > 0 { + filterJSON, err := filters.ToParam(filter) + if err != nil { + return volumes, err + } + query.Set("filters", filterJSON) + } + resp, err := cli.get("/volumes", query, nil) + if err != nil { + return volumes, err + } + defer ensureReaderClosed(resp) + + err = json.NewDecoder(resp.body).Decode(&volumes) + return volumes, err +} + +// VolumeInspect returns the information about a specific volume in the docker host. +func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) { + var volume types.Volume + resp, err := cli.get("/volumes/"+volumeID, nil, nil) + if err != nil { + if resp.statusCode == http.StatusNotFound { + return volume, volumeNotFoundError{volumeID} + } + return volume, err + } + defer ensureReaderClosed(resp) + err = json.NewDecoder(resp.body).Decode(&volume) + return volume, err +} + +// VolumeCreate creates a volume in the docker host. +func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) { + var volume types.Volume + resp, err := cli.post("/volumes/create", nil, options, nil) + if err != nil { + return volume, err + } + defer ensureReaderClosed(resp) + err = json.NewDecoder(resp.body).Decode(&volume) + return volume, err +} + +// VolumeRemove removes a volume from the docker host. +func (cli *Client) VolumeRemove(volumeID string) error { + resp, err := cli.delete("/volumes/"+volumeID, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/client/wait.go b/components/engine/vendor/src/github.com/docker/engine-api/client/wait.go new file mode 100644 index 0000000000..17cb1d8ab5 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/client/wait.go @@ -0,0 +1,24 @@ +package client + +import ( + "encoding/json" + + "github.com/docker/engine-api/types" +) + +// ContainerWait pauses execution util a container is exits. +// It returns the API status code as response of its readiness. +func (cli *Client) ContainerWait(containerID string) (int, error) { + resp, err := cli.post("/containers/"+containerID+"/wait", nil, nil, nil) + if err != nil { + return -1, err + } + defer ensureReaderClosed(resp) + + var res types.ContainerWaitResponse + if err := json.NewDecoder(resp.body).Decode(&res); err != nil { + return -1, err + } + + return res.StatusCode, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/auth.go b/components/engine/vendor/src/github.com/docker/engine-api/types/auth.go new file mode 100644 index 0000000000..6cd4c36a83 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/auth.go @@ -0,0 +1,11 @@ +package types + +// AuthConfig contains authorization information for connecting to a Registry +type AuthConfig struct { + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth"` + Email string `json:"email"` + ServerAddress string `json:"serveraddress,omitempty"` + RegistryToken string `json:"registrytoken,omitempty"` +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/blkiodev/blkio.go b/components/engine/vendor/src/github.com/docker/engine-api/types/blkiodev/blkio.go new file mode 100644 index 0000000000..458a9c96bb --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/blkiodev/blkio.go @@ -0,0 +1,23 @@ +package blkiodev + +import "fmt" + +// WeightDevice is a structure that hold device:weight pair +type WeightDevice struct { + Path string + Weight uint16 +} + +func (w *WeightDevice) String() string { + return fmt.Sprintf("%s:%d", w.Path, w.Weight) +} + +// ThrottleDevice is a structure that hold device:rate_per_second pair +type ThrottleDevice struct { + Path string + Rate uint64 +} + +func (t *ThrottleDevice) String() string { + return fmt.Sprintf("%s:%d", t.Path, t.Rate) +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/client.go b/components/engine/vendor/src/github.com/docker/engine-api/types/client.go new file mode 100644 index 0000000000..77d94f33a1 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/client.go @@ -0,0 +1,245 @@ +package types + +import ( + "bufio" + "io" + "net" + + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/filters" + "github.com/docker/go-units" +) + +// ContainerAttachOptions holds parameters to attach to a container. +type ContainerAttachOptions struct { + ContainerID string + Stream bool + Stdin bool + Stdout bool + Stderr bool + DetachKeys string +} + +// ContainerCommitOptions holds parameters to commit changes into a container. +type ContainerCommitOptions struct { + ContainerID string + RepositoryName string + Tag string + Comment string + Author string + Changes []string + Pause bool + Config *container.Config +} + +// ContainerExecInspect holds information returned by exec inspect. +type ContainerExecInspect struct { + ExecID string + ContainerID string + Running bool + ExitCode int +} + +// ContainerListOptions holds parameters to list containers with. +type ContainerListOptions struct { + Quiet bool + Size bool + All bool + Latest bool + Since string + Before string + Limit int + Filter filters.Args +} + +// ContainerLogsOptions holds parameters to filter logs with. +type ContainerLogsOptions struct { + ContainerID string + ShowStdout bool + ShowStderr bool + Since string + Timestamps bool + Follow bool + Tail string +} + +// ContainerRemoveOptions holds parameters to remove containers. +type ContainerRemoveOptions struct { + ContainerID string + RemoveVolumes bool + RemoveLinks bool + Force bool +} + +// CopyToContainerOptions holds information +// about files to copy into a container +type CopyToContainerOptions struct { + ContainerID string + Path string + Content io.Reader + AllowOverwriteDirWithFile bool +} + +// EventsOptions hold parameters to filter events with. +type EventsOptions struct { + Since string + Until string + Filters filters.Args +} + +// NetworkListOptions holds parameters to filter the list of networks with. +type NetworkListOptions struct { + Filters filters.Args +} + +// HijackedResponse holds connection information for a hijacked request. +type HijackedResponse struct { + Conn net.Conn + Reader *bufio.Reader +} + +// Close closes the hijacked connection and reader. +func (h *HijackedResponse) Close() { + h.Conn.Close() +} + +// CloseWriter is an interface that implement structs +// that close input streams to prevent from writing. +type CloseWriter interface { + CloseWrite() error +} + +// CloseWrite closes a readWriter for writing. +func (h *HijackedResponse) CloseWrite() error { + if conn, ok := h.Conn.(CloseWriter); ok { + return conn.CloseWrite() + } + return nil +} + +// ImageBuildOptions holds the information +// necessary to build images. +type ImageBuildOptions struct { + Tags []string + SuppressOutput bool + RemoteContext string + NoCache bool + Remove bool + ForceRemove bool + PullParent bool + IsolationLevel container.IsolationLevel + CPUSetCPUs string + CPUSetMems string + CPUShares int64 + CPUQuota int64 + CPUPeriod int64 + Memory int64 + MemorySwap int64 + CgroupParent string + ShmSize int64 + Dockerfile string + Ulimits []*units.Ulimit + BuildArgs map[string]string + AuthConfigs map[string]AuthConfig + Context io.Reader +} + +// ImageBuildResponse holds information +// returned by a server after building +// an image. +type ImageBuildResponse struct { + Body io.ReadCloser + OSType string +} + +// ImageCreateOptions holds information to create images. +type ImageCreateOptions struct { + // Parent is the image to create this image from + Parent string + // Tag is the name to tag this image + Tag string + // RegistryAuth is the base64 encoded credentials for this server + RegistryAuth string +} + +// ImageImportOptions holds information to import images from the client host. +type ImageImportOptions struct { + // Source is the data to send to the server to create this image from + Source io.Reader + // Source is the name of the source to import this image from + SourceName string + // RepositoryName is the name of the repository to import this image + RepositoryName string + // Message is the message to tag the image with + Message string + // Tag is the name to tag this image + Tag string + // Changes are the raw changes to apply to the image + Changes []string +} + +// ImageListOptions holds parameters to filter the list of images with. +type ImageListOptions struct { + MatchName string + All bool + Filters filters.Args +} + +// ImageLoadResponse returns information to the client about a load process. +type ImageLoadResponse struct { + Body io.ReadCloser + JSON bool +} + +// ImagePullOptions holds information to pull images. +type ImagePullOptions struct { + ImageID string + Tag string + // RegistryAuth is the base64 encoded credentials for this server + RegistryAuth string +} + +//ImagePushOptions holds information to push images. +type ImagePushOptions ImagePullOptions + +// ImageRemoveOptions holds parameters to remove images. +type ImageRemoveOptions struct { + ImageID string + Force bool + PruneChildren bool +} + +// ImageSearchOptions holds parameters to search images with. +type ImageSearchOptions struct { + Term string + RegistryAuth string +} + +// ImageTagOptions holds parameters to tag an image +type ImageTagOptions struct { + ImageID string + RepositoryName string + Tag string + Force bool +} + +// ResizeOptions holds parameters to resize a tty. +// It can be used to resize container ttys and +// exec process ttys too. +type ResizeOptions struct { + ID string + Height int + Width int +} + +// VersionResponse holds version information for the client and the server +type VersionResponse struct { + Client *Version + Server *Version +} + +// ServerOK return true when the client could connect to the docker server +// and parse the information received. It returns false otherwise. +func (v VersionResponse) ServerOK() bool { + return v.Server != nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/configs.go b/components/engine/vendor/src/github.com/docker/engine-api/types/configs.go new file mode 100644 index 0000000000..fafbb5b53e --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/configs.go @@ -0,0 +1,50 @@ +package types + +import "github.com/docker/engine-api/types/container" + +// configs holds structs used for internal communication between the +// frontend (such as an http server) and the backend (such as the +// docker daemon). + +// ContainerCreateConfig is the parameter set to ContainerCreate() +type ContainerCreateConfig struct { + Name string + Config *container.Config + HostConfig *container.HostConfig + AdjustCPUShares bool +} + +// ContainerRmConfig holds arguments for the container remove +// operation. This struct is used to tell the backend what operations +// to perform. +type ContainerRmConfig struct { + ForceRemove, RemoveVolume, RemoveLink bool +} + +// ContainerCommitConfig contains build configs for commit operation, +// and is used when making a commit with the current state of the container. +type ContainerCommitConfig struct { + Pause bool + Repo string + Tag string + Author string + Comment string + // merge container config into commit config before commit + MergeConfigs bool + Config *container.Config +} + +// ExecConfig is a small subset of the Config struct that hold the configuration +// for the exec feature of docker. +type ExecConfig struct { + User string // User that will run the command + Privileged bool // Is the container in privileged mode + Tty bool // Attach standard streams to a tty. + Container string // Name of the container (to execute in) + AttachStdin bool // Attach the standard input, makes possible user interaction + AttachStderr bool // Attach the standard output + AttachStdout bool // Attach the standard error + Detach bool // Execute in detach mode + DetachKeys string // Escape keys for detach + Cmd []string // Execution commands and args +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/container/config.go b/components/engine/vendor/src/github.com/docker/engine-api/types/container/config.go new file mode 100644 index 0000000000..b4e6205d21 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/container/config.go @@ -0,0 +1,38 @@ +package container + +import ( + "github.com/docker/engine-api/types/strslice" + "github.com/docker/go-connections/nat" +) + +// Config contains the configuration data about a container. +// It should hold only portable information about the container. +// Here, "portable" means "independent from the host we are running on". +// Non-portable information *should* appear in HostConfig. +// All fields added to this struct must be marked `omitempty` to keep getting +// predictable hashes from the old `v1Compatibility` configuration. +type Config struct { + Hostname string // Hostname + Domainname string // Domainname + User string // User that will run the command(s) inside the container + AttachStdin bool // Attach the standard input, makes possible user interaction + AttachStdout bool // Attach the standard output + AttachStderr bool // Attach the standard error + ExposedPorts map[nat.Port]struct{} `json:",omitempty"` // List of exposed ports + PublishService string `json:",omitempty"` // Name of the network service exposed by the container + Tty bool // Attach standard streams to a tty, including stdin if it is not closed. + OpenStdin bool // Open stdin + StdinOnce bool // If true, close stdin after the 1 attached client disconnects. + Env []string // List of environment variable to set in the container + Cmd *strslice.StrSlice // Command to run when starting the container + ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) + Image string // Name of the image as it was passed by the operator (eg. could be symbolic) + Volumes map[string]struct{} // List of volumes (mounts) used for the container + WorkingDir string // Current directory (PWD) in the command will be launched + Entrypoint *strslice.StrSlice // Entrypoint to run when starting the container + NetworkDisabled bool `json:",omitempty"` // Is network disabled + MacAddress string `json:",omitempty"` // Mac Address of the container + OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile + Labels map[string]string // List of labels set to this container + StopSignal string `json:",omitempty"` // Signal to stop a container +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/container/host_config.go b/components/engine/vendor/src/github.com/docker/engine-api/types/container/host_config.go new file mode 100644 index 0000000000..ac425921b8 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/container/host_config.go @@ -0,0 +1,227 @@ +package container + +import ( + "strings" + + "github.com/docker/engine-api/types/blkiodev" + "github.com/docker/engine-api/types/strslice" + "github.com/docker/go-connections/nat" + "github.com/docker/go-units" +) + +// NetworkMode represents the container network stack. +type NetworkMode string + +// IsolationLevel represents the isolation level of a container. The supported +// values are platform specific +type IsolationLevel string + +// IsDefault indicates the default isolation level of a container. On Linux this +// is the native driver. On Windows, this is a Windows Server Container. +func (i IsolationLevel) IsDefault() bool { + return strings.ToLower(string(i)) == "default" || string(i) == "" +} + +// IpcMode represents the container ipc stack. +type IpcMode string + +// IsPrivate indicates whether the container uses it's private ipc stack. +func (n IpcMode) IsPrivate() bool { + return !(n.IsHost() || n.IsContainer()) +} + +// IsHost indicates whether the container uses the host's ipc stack. +func (n IpcMode) IsHost() bool { + return n == "host" +} + +// IsContainer indicates whether the container uses a container's ipc stack. +func (n IpcMode) IsContainer() bool { + parts := strings.SplitN(string(n), ":", 2) + return len(parts) > 1 && parts[0] == "container" +} + +// Valid indicates whether the ipc stack is valid. +func (n IpcMode) Valid() bool { + parts := strings.Split(string(n), ":") + switch mode := parts[0]; mode { + case "", "host": + case "container": + if len(parts) != 2 || parts[1] == "" { + return false + } + default: + return false + } + return true +} + +// Container returns the name of the container ipc stack is going to be used. +func (n IpcMode) Container() string { + parts := strings.SplitN(string(n), ":", 2) + if len(parts) > 1 { + return parts[1] + } + return "" +} + +// UTSMode represents the UTS namespace of the container. +type UTSMode string + +// IsPrivate indicates whether the container uses it's private UTS namespace. +func (n UTSMode) IsPrivate() bool { + return !(n.IsHost()) +} + +// IsHost indicates whether the container uses the host's UTS namespace. +func (n UTSMode) IsHost() bool { + return n == "host" +} + +// Valid indicates whether the UTS namespace is valid. +func (n UTSMode) Valid() bool { + parts := strings.Split(string(n), ":") + switch mode := parts[0]; mode { + case "", "host": + default: + return false + } + return true +} + +// PidMode represents the pid stack of the container. +type PidMode string + +// IsPrivate indicates whether the container uses it's private pid stack. +func (n PidMode) IsPrivate() bool { + return !(n.IsHost()) +} + +// IsHost indicates whether the container uses the host's pid stack. +func (n PidMode) IsHost() bool { + return n == "host" +} + +// Valid indicates whether the pid stack is valid. +func (n PidMode) Valid() bool { + parts := strings.Split(string(n), ":") + switch mode := parts[0]; mode { + case "", "host": + default: + return false + } + return true +} + +// DeviceMapping represents the device mapping between the host and the container. +type DeviceMapping struct { + PathOnHost string + PathInContainer string + CgroupPermissions string +} + +// RestartPolicy represents the restart policies of the container. +type RestartPolicy struct { + Name string + MaximumRetryCount int +} + +// IsNone indicates whether the container has the "no" restart policy. +// This means the container will not automatically restart when exiting. +func (rp *RestartPolicy) IsNone() bool { + return rp.Name == "no" +} + +// IsAlways indicates whether the container has the "always" restart policy. +// This means the container will automatically restart regardless of the exit status. +func (rp *RestartPolicy) IsAlways() bool { + return rp.Name == "always" +} + +// IsOnFailure indicates whether the container has the "on-failure" restart policy. +// This means the contain will automatically restart of exiting with a non-zero exit status. +func (rp *RestartPolicy) IsOnFailure() bool { + return rp.Name == "on-failure" +} + +// IsUnlessStopped indicates whether the container has the +// "unless-stopped" restart policy. This means the container will +// automatically restart unless user has put it to stopped state. +func (rp *RestartPolicy) IsUnlessStopped() bool { + return rp.Name == "unless-stopped" +} + +// LogConfig represents the logging configuration of the container. +type LogConfig struct { + Type string + Config map[string]string +} + +// Resources contains container's resources (cgroups config, ulimits...) +type Resources struct { + // Applicable to all platforms + CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) + + // Applicable to UNIX platforms + CgroupParent string // Parent cgroup. + BlkioWeight uint16 // Block IO weight (relative weight vs. other containers) + BlkioWeightDevice []*blkiodev.WeightDevice + BlkioDeviceReadBps []*blkiodev.ThrottleDevice + BlkioDeviceWriteBps []*blkiodev.ThrottleDevice + BlkioDeviceReadIOps []*blkiodev.ThrottleDevice + BlkioDeviceWriteIOps []*blkiodev.ThrottleDevice + CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period + CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota + CpusetCpus string // CpusetCpus 0-2, 0,1 + CpusetMems string // CpusetMems 0-2, 0,1 + Devices []DeviceMapping // List of devices to map inside the container + KernelMemory int64 // Kernel memory limit (in bytes) + Memory int64 // Memory limit (in bytes) + MemoryReservation int64 // Memory soft limit (in bytes) + MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap + MemorySwappiness *int64 // Tuning container memory swappiness behaviour + OomKillDisable bool // Whether to disable OOM Killer or not + Ulimits []*units.Ulimit // List of ulimits to be set in the container +} + +// HostConfig the non-portable Config structure of a container. +// Here, "non-portable" means "dependent of the host we are running on". +// Portable information *should* appear in Config. +type HostConfig struct { + // Applicable to all platforms + Binds []string // List of volume bindings for this container + ContainerIDFile string // File (path) where the containerId is written + LogConfig LogConfig // Configuration of the logs for this container + NetworkMode NetworkMode // Network mode to use for the container + PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host + RestartPolicy RestartPolicy // Restart policy to be used for the container + VolumeDriver string // Name of the volume driver used to mount volumes + VolumesFrom []string // List of volumes to take from other container + + // Applicable to UNIX platforms + CapAdd *strslice.StrSlice // List of kernel capabilities to add to the container + CapDrop *strslice.StrSlice // List of kernel capabilities to remove from the container + DNS []string `json:"Dns"` // List of DNS server to lookup + DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for + DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for + ExtraHosts []string // List of extra hosts + GroupAdd []string // List of additional groups that the container process will run as + IpcMode IpcMode // IPC namespace to use for the container + Links []string // List of links (in the name:alias form) + OomScoreAdj int // Container preference for OOM-killing + PidMode PidMode // PID namespace to use for the container + Privileged bool // Is the container in privileged mode + PublishAllPorts bool // Should docker publish all exposed port for the container + ReadonlyRootfs bool // Is the container root filesystem in read-only + SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. + Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container + UTSMode UTSMode // UTS namespace to use for the container + ShmSize int64 // Total shm memory usage + + // Applicable to Windows + ConsoleSize [2]int // Initial console size + Isolation IsolationLevel // Isolation level of the container (eg default, hyperv) + + // Contains container's resources (cgroups, ulimits) + Resources +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_unix.go b/components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_unix.go new file mode 100644 index 0000000000..775e903f1c --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_unix.go @@ -0,0 +1,87 @@ +// +build !windows + +package container + +import "strings" + +// IsValid indicates is an isolation level is valid +func (i IsolationLevel) IsValid() bool { + return i.IsDefault() +} + +// IsPrivate indicates whether container uses it's private network stack. +func (n NetworkMode) IsPrivate() bool { + return !(n.IsHost() || n.IsContainer()) +} + +// IsDefault indicates whether container uses the default network stack. +func (n NetworkMode) IsDefault() bool { + return n == "default" +} + +// NetworkName returns the name of the network stack. +func (n NetworkMode) NetworkName() string { + if n.IsBridge() { + return "bridge" + } else if n.IsHost() { + return "host" + } else if n.IsContainer() { + return "container" + } else if n.IsNone() { + return "none" + } else if n.IsDefault() { + return "default" + } else if n.IsUserDefined() { + return n.UserDefined() + } + return "" +} + +// IsBridge indicates whether container uses the bridge network stack +func (n NetworkMode) IsBridge() bool { + return n == "bridge" +} + +// IsHost indicates whether container uses the host network stack. +func (n NetworkMode) IsHost() bool { + return n == "host" +} + +// IsContainer indicates whether container uses a container network stack. +func (n NetworkMode) IsContainer() bool { + parts := strings.SplitN(string(n), ":", 2) + return len(parts) > 1 && parts[0] == "container" +} + +// IsNone indicates whether container isn't using a network stack. +func (n NetworkMode) IsNone() bool { + return n == "none" +} + +// ConnectedContainer is the id of the container which network this container is connected to. +func (n NetworkMode) ConnectedContainer() string { + parts := strings.SplitN(string(n), ":", 2) + if len(parts) > 1 { + return parts[1] + } + return "" +} + +// IsUserDefined indicates user-created network +func (n NetworkMode) IsUserDefined() bool { + return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() +} + +// IsPreDefinedNetwork indicates if a network is predefined by the daemon +func IsPreDefinedNetwork(network string) bool { + n := NetworkMode(network) + return n.IsBridge() || n.IsHost() || n.IsNone() +} + +//UserDefined indicates user-created network +func (n NetworkMode) UserDefined() string { + if n.IsUserDefined() { + return string(n) + } + return "" +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go b/components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go new file mode 100644 index 0000000000..16267ff416 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go @@ -0,0 +1,75 @@ +package container + +import ( + "fmt" + "strings" +) + +// IsDefault indicates whether container uses the default network stack. +func (n NetworkMode) IsDefault() bool { + return n == "default" +} + +// IsHyperV indicates the use of a Hyper-V partition for isolation +func (i IsolationLevel) IsHyperV() bool { + return strings.ToLower(string(i)) == "hyperv" +} + +// IsProcess indicates the use of process isolation +func (i IsolationLevel) IsProcess() bool { + return strings.ToLower(string(i)) == "process" +} + +// IsValid indicates is an isolation level is valid +func (i IsolationLevel) IsValid() bool { + return i.IsDefault() || i.IsHyperV() || i.IsProcess() +} + +// DefaultDaemonNetworkMode returns the default network stack the daemon should +// use. +func DefaultDaemonNetworkMode() NetworkMode { + return NetworkMode("default") +} + +// NetworkName returns the name of the network stack. +func (n NetworkMode) NetworkName() string { + if n.IsDefault() { + return "default" + } + return "" +} + +// IsPreDefinedNetwork indicates if a network is predefined by the daemon +func IsPreDefinedNetwork(network string) bool { + return false +} + +// ValidateNetMode ensures that the various combinations of requested +// network settings are valid. +func ValidateNetMode(c *Config, hc *HostConfig) error { + // We may not be passed a host config, such as in the case of docker commit + if hc == nil { + return nil + } + parts := strings.Split(string(hc.NetworkMode), ":") + switch mode := parts[0]; mode { + case "default", "none": + default: + return fmt.Errorf("invalid --net: %s", hc.NetworkMode) + } + return nil +} + +// ValidateIsolationLevel performs platform specific validation of the +// isolation level in the hostconfig structure. Windows supports 'default' (or +// blank), 'process', or 'hyperv'. +func ValidateIsolationLevel(hc *HostConfig) error { + // We may not be passed a host config, such as in the case of docker commit + if hc == nil { + return nil + } + if !hc.Isolation.IsValid() { + return fmt.Errorf("invalid --isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation) + } + return nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/events/events.go b/components/engine/vendor/src/github.com/docker/engine-api/types/events/events.go new file mode 100644 index 0000000000..c5987aaf14 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/events/events.go @@ -0,0 +1,38 @@ +package events + +const ( + // ContainerEventType is the event type that containers generate + ContainerEventType = "container" + // ImageEventType is the event type that images generate + ImageEventType = "image" + // VolumeEventType is the event type that volumes generate + VolumeEventType = "volume" + // NetworkEventType is the event type that networks generate + NetworkEventType = "network" +) + +// Actor describes something that generates events, +// like a container, or a network, or a volume. +// It has a defined name and a set or attributes. +// The container attributes are its labels, other actors +// can generate these attributes from other properties. +type Actor struct { + ID string + Attributes map[string]string +} + +// Message represents the information an event contains +type Message struct { + // Deprecated information from JSONMessage. + // With data only in container events. + Status string `json:"status,omitempty"` + ID string `json:"id,omitempty"` + From string `json:"from,omitempty"` + + Type string + Action string + Actor Actor + + Time int64 `json:"time,omitempty"` + TimeNano int64 `json:"timeNano,omitempty"` +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/filters/parse.go b/components/engine/vendor/src/github.com/docker/engine-api/types/filters/parse.go new file mode 100644 index 0000000000..e99462c0a8 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/filters/parse.go @@ -0,0 +1,257 @@ +// Package filters provides helper function to parse and handle command line +// filter, used for example in docker ps or docker images commands. +package filters + +import ( + "encoding/json" + "errors" + "fmt" + "regexp" + "strings" +) + +// Args stores filter arguments as map key:{array of values}. +// It contains a aggregation of the list of arguments (which are in the form +// of -f 'key=value') based on the key, and store values for the same key +// in an slice. +// e.g given -f 'label=label1=1' -f 'label=label2=2' -f 'image.name=ubuntu' +// the args will be {'label': {'label1=1','label2=2'}, 'image.name', {'ubuntu'}} +type Args struct { + fields map[string]map[string]bool +} + +// NewArgs initializes a new Args struct. +func NewArgs() Args { + return Args{fields: map[string]map[string]bool{}} +} + +// ParseFlag parses the argument to the filter flag. Like +// +// `docker ps -f 'created=today' -f 'image.name=ubuntu*'` +// +// If prev map is provided, then it is appended to, and returned. By default a new +// map is created. +func ParseFlag(arg string, prev Args) (Args, error) { + filters := prev + if len(arg) == 0 { + return filters, nil + } + + if !strings.Contains(arg, "=") { + return filters, ErrBadFormat + } + + f := strings.SplitN(arg, "=", 2) + + name := strings.ToLower(strings.TrimSpace(f[0])) + value := strings.TrimSpace(f[1]) + + filters.Add(name, value) + + return filters, nil +} + +// ErrBadFormat is an error returned in case of bad format for a filter. +var ErrBadFormat = errors.New("bad format of filter (expected name=value)") + +// ToParam packs the Args into an string for easy transport from client to server. +func ToParam(a Args) (string, error) { + // this way we don't URL encode {}, just empty space + if a.Len() == 0 { + return "", nil + } + + buf, err := json.Marshal(a.fields) + if err != nil { + return "", err + } + return string(buf), nil +} + +// FromParam unpacks the filter Args. +func FromParam(p string) (Args, error) { + if len(p) == 0 { + return NewArgs(), nil + } + + r := strings.NewReader(p) + d := json.NewDecoder(r) + + m := map[string]map[string]bool{} + if err := d.Decode(&m); err != nil { + r.Seek(0, 0) + + // Allow parsing old arguments in slice format. + // Because other libraries might be sending them in this format. + deprecated := map[string][]string{} + if deprecatedErr := d.Decode(&deprecated); deprecatedErr == nil { + m = deprecatedArgs(deprecated) + } else { + return NewArgs(), err + } + } + return Args{m}, nil +} + +// Get returns the list of values associates with a field. +// It returns a slice of strings to keep backwards compatibility with old code. +func (filters Args) Get(field string) []string { + values := filters.fields[field] + if values == nil { + return make([]string, 0) + } + slice := make([]string, 0, len(values)) + for key := range values { + slice = append(slice, key) + } + return slice +} + +// Add adds a new value to a filter field. +func (filters Args) Add(name, value string) { + if _, ok := filters.fields[name]; ok { + filters.fields[name][value] = true + } else { + filters.fields[name] = map[string]bool{value: true} + } +} + +// Del removes a value from a filter field. +func (filters Args) Del(name, value string) { + if _, ok := filters.fields[name]; ok { + delete(filters.fields[name], value) + } +} + +// Len returns the number of fields in the arguments. +func (filters Args) Len() int { + return len(filters.fields) +} + +// MatchKVList returns true if the values for the specified field matches the ones +// from the sources. +// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, +// field is 'label' and sources are {'label1': '1', 'label2': '2'} +// it returns true. +func (filters Args) MatchKVList(field string, sources map[string]string) bool { + fieldValues := filters.fields[field] + + //do not filter if there is no filter set or cannot determine filter + if len(fieldValues) == 0 { + return true + } + + if sources == nil || len(sources) == 0 { + return false + } + + for name2match := range fieldValues { + testKV := strings.SplitN(name2match, "=", 2) + + v, ok := sources[testKV[0]] + if !ok { + return false + } + if len(testKV) == 2 && testKV[1] != v { + return false + } + } + + return true +} + +// Match returns true if the values for the specified field matches the source string +// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, +// field is 'image.name' and source is 'ubuntu' +// it returns true. +func (filters Args) Match(field, source string) bool { + if filters.ExactMatch(field, source) { + return true + } + + fieldValues := filters.fields[field] + for name2match := range fieldValues { + match, err := regexp.MatchString(name2match, source) + if err != nil { + continue + } + if match { + return true + } + } + return false +} + +// ExactMatch returns true if the source matches exactly one of the filters. +func (filters Args) ExactMatch(field, source string) bool { + fieldValues, ok := filters.fields[field] + //do not filter if there is no filter set or cannot determine filter + if !ok || len(fieldValues) == 0 { + return true + } + + // try to march full name value to avoid O(N) regular expression matching + if fieldValues[source] { + return true + } + return false +} + +// FuzzyMatch returns true if the source matches exactly one of the filters, +// or the source has one of the filters as a prefix. +func (filters Args) FuzzyMatch(field, source string) bool { + if filters.ExactMatch(field, source) { + return true + } + + fieldValues := filters.fields[field] + for prefix := range fieldValues { + if strings.HasPrefix(source, prefix) { + return true + } + } + return false +} + +// Include returns true if the name of the field to filter is in the filters. +func (filters Args) Include(field string) bool { + _, ok := filters.fields[field] + return ok +} + +// Validate ensures that all the fields in the filter are valid. +// It returns an error as soon as it finds an invalid field. +func (filters Args) Validate(accepted map[string]bool) error { + for name := range filters.fields { + if !accepted[name] { + return fmt.Errorf("Invalid filter '%s'", name) + } + } + return nil +} + +// WalkValues iterates over the list of filtered values for a field. +// It stops the iteration if it finds an error and it returns that error. +func (filters Args) WalkValues(field string, op func(value string) error) error { + if _, ok := filters.fields[field]; !ok { + return nil + } + for v := range filters.fields[field] { + if err := op(v); err != nil { + return err + } + } + return nil +} + +func deprecatedArgs(d map[string][]string) map[string]map[string]bool { + m := map[string]map[string]bool{} + for k, v := range d { + values := map[string]bool{} + for _, vv := range v { + values[vv] = true + } + m[k] = values + } + return m +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/network/network.go b/components/engine/vendor/src/github.com/docker/engine-api/types/network/network.go new file mode 100644 index 0000000000..c81c621178 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/network/network.go @@ -0,0 +1,33 @@ +package network + +// Address represents an IP address +type Address struct { + Addr string + PrefixLen int +} + +// IPAM represents IP Address Management +type IPAM struct { + Driver string + Config []IPAMConfig +} + +// IPAMConfig represents IPAM configurations +type IPAMConfig struct { + Subnet string `json:",omitempty"` + IPRange string `json:",omitempty"` + Gateway string `json:",omitempty"` + AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` +} + +// EndpointSettings stores the network endpoint details +type EndpointSettings struct { + EndpointID string + Gateway string + IPAddress string + IPPrefixLen int + IPv6Gateway string + GlobalIPv6Address string + GlobalIPv6PrefixLen int + MacAddress string +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/registry/registry.go b/components/engine/vendor/src/github.com/docker/engine-api/types/registry/registry.go new file mode 100644 index 0000000000..4fcf986e7b --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/registry/registry.go @@ -0,0 +1,101 @@ +package registry + +import ( + "encoding/json" + "net" +) + +// ServiceConfig stores daemon registry services configuration. +type ServiceConfig struct { + InsecureRegistryCIDRs []*NetIPNet `json:"InsecureRegistryCIDRs"` + IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"` + Mirrors []string +} + +// NetIPNet is the net.IPNet type, which can be marshalled and +// unmarshalled to JSON +type NetIPNet net.IPNet + +// MarshalJSON returns the JSON representation of the IPNet +func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) { + return json.Marshal((*net.IPNet)(ipnet).String()) +} + +// UnmarshalJSON sets the IPNet from a byte array of JSON +func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) { + var ipnetStr string + if err = json.Unmarshal(b, &ipnetStr); err == nil { + var cidr *net.IPNet + if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil { + *ipnet = NetIPNet(*cidr) + } + } + return +} + +// IndexInfo contains information about a registry +// +// RepositoryInfo Examples: +// { +// "Index" : { +// "Name" : "docker.io", +// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"], +// "Secure" : true, +// "Official" : true, +// }, +// "RemoteName" : "library/debian", +// "LocalName" : "debian", +// "CanonicalName" : "docker.io/debian" +// "Official" : true, +// } +// +// { +// "Index" : { +// "Name" : "127.0.0.1:5000", +// "Mirrors" : [], +// "Secure" : false, +// "Official" : false, +// }, +// "RemoteName" : "user/repo", +// "LocalName" : "127.0.0.1:5000/user/repo", +// "CanonicalName" : "127.0.0.1:5000/user/repo", +// "Official" : false, +// } +type IndexInfo struct { + // Name is the name of the registry, such as "docker.io" + Name string + // Mirrors is a list of mirrors, expressed as URIs + Mirrors []string + // Secure is set to false if the registry is part of the list of + // insecure registries. Insecure registries accept HTTP and/or accept + // HTTPS with certificates from unknown CAs. + Secure bool + // Official indicates whether this is an official registry + Official bool +} + +// SearchResult describes a search result returned from a registry +type SearchResult struct { + // StarCount indicates the number of stars this repository has + StarCount int `json:"star_count"` + // IsOfficial indicates whether the result is an official repository or not + IsOfficial bool `json:"is_official"` + // Name is the name of the repository + Name string `json:"name"` + // IsOfficial indicates whether the result is trusted + IsTrusted bool `json:"is_trusted"` + // IsAutomated indicates whether the result is automated + IsAutomated bool `json:"is_automated"` + // Description is a textual description of the repository + Description string `json:"description"` +} + +// SearchResults lists a collection search results returned from a registry +type SearchResults struct { + // Query contains the query string that generated the search results + Query string `json:"query"` + // NumResults indicates the number of results the query returned + NumResults int `json:"num_results"` + // Results is a slice containing the actual results for the search + Results []SearchResult `json:"results"` +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/stats.go b/components/engine/vendor/src/github.com/docker/engine-api/types/stats.go new file mode 100644 index 0000000000..e21fe39c9d --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/stats.go @@ -0,0 +1,105 @@ +// Package types is used for API stability in the types and response to the +// consumers of the API stats endpoint. +package types + +import "time" + +// ThrottlingData stores CPU throttling stats of one running container +type ThrottlingData struct { + // Number of periods with throttling active + Periods uint64 `json:"periods"` + // Number of periods when the container hit its throttling limit. + ThrottledPeriods uint64 `json:"throttled_periods"` + // Aggregate time the container was throttled for in nanoseconds. + ThrottledTime uint64 `json:"throttled_time"` +} + +// CPUUsage stores All CPU stats aggregated since container inception. +type CPUUsage struct { + // Total CPU time consumed. + // Units: nanoseconds. + TotalUsage uint64 `json:"total_usage"` + // Total CPU time consumed per core. + // Units: nanoseconds. + PercpuUsage []uint64 `json:"percpu_usage"` + // Time spent by tasks of the cgroup in kernel mode. + // Units: nanoseconds. + UsageInKernelmode uint64 `json:"usage_in_kernelmode"` + // Time spent by tasks of the cgroup in user mode. + // Units: nanoseconds. + UsageInUsermode uint64 `json:"usage_in_usermode"` +} + +// CPUStats aggregates and wraps all CPU related info of container +type CPUStats struct { + CPUUsage CPUUsage `json:"cpu_usage"` + SystemUsage uint64 `json:"system_cpu_usage"` + ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` +} + +// MemoryStats aggregates All memory stats since container inception +type MemoryStats struct { + // current res_counter usage for memory + Usage uint64 `json:"usage"` + // maximum usage ever recorded. + MaxUsage uint64 `json:"max_usage"` + // TODO(vishh): Export these as stronger types. + // all the stats exported via memory.stat. + Stats map[string]uint64 `json:"stats"` + // number of times memory usage hits limits. + Failcnt uint64 `json:"failcnt"` + Limit uint64 `json:"limit"` +} + +// BlkioStatEntry is one small entity to store a piece of Blkio stats +// TODO Windows: This can be factored out +type BlkioStatEntry struct { + Major uint64 `json:"major"` + Minor uint64 `json:"minor"` + Op string `json:"op"` + Value uint64 `json:"value"` +} + +// BlkioStats stores All IO service stats for data read and write +// TODO Windows: This can be factored out +type BlkioStats struct { + // number of bytes transferred to and from the block device + IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"` + IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"` + IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"` + IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"` + IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"` + IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"` + IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"` + SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"` +} + +// NetworkStats aggregates All network stats of one container +// TODO Windows: This will require refactoring +type NetworkStats struct { + RxBytes uint64 `json:"rx_bytes"` + RxPackets uint64 `json:"rx_packets"` + RxErrors uint64 `json:"rx_errors"` + RxDropped uint64 `json:"rx_dropped"` + TxBytes uint64 `json:"tx_bytes"` + TxPackets uint64 `json:"tx_packets"` + TxErrors uint64 `json:"tx_errors"` + TxDropped uint64 `json:"tx_dropped"` +} + +// Stats is Ultimate struct aggregating all types of stats of one container +type Stats struct { + Read time.Time `json:"read"` + PreCPUStats CPUStats `json:"precpu_stats,omitempty"` + CPUStats CPUStats `json:"cpu_stats,omitempty"` + MemoryStats MemoryStats `json:"memory_stats,omitempty"` + BlkioStats BlkioStats `json:"blkio_stats,omitempty"` +} + +// StatsJSON is newly used Networks +type StatsJSON struct { + Stats + + // Networks request version >=1.21 + Networks map[string]NetworkStats `json:"networks,omitempty"` +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go b/components/engine/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go new file mode 100644 index 0000000000..9f3ee620a3 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go @@ -0,0 +1,71 @@ +package strslice + +import ( + "encoding/json" + "strings" +) + +// StrSlice represents a string or an array of strings. +// We need to override the json decoder to accept both options. +type StrSlice struct { + parts []string +} + +// MarshalJSON Marshals (or serializes) the StrSlice into the json format. +// This method is needed to implement json.Marshaller. +func (e *StrSlice) MarshalJSON() ([]byte, error) { + if e == nil { + return []byte{}, nil + } + return json.Marshal(e.Slice()) +} + +// UnmarshalJSON decodes the byte slice whether it's a string or an array of strings. +// This method is needed to implement json.Unmarshaler. +func (e *StrSlice) UnmarshalJSON(b []byte) error { + if len(b) == 0 { + return nil + } + + p := make([]string, 0, 1) + if err := json.Unmarshal(b, &p); err != nil { + var s string + if err := json.Unmarshal(b, &s); err != nil { + return err + } + p = append(p, s) + } + + e.parts = p + return nil +} + +// Len returns the number of parts of the StrSlice. +func (e *StrSlice) Len() int { + if e == nil { + return 0 + } + return len(e.parts) +} + +// Slice gets the parts of the StrSlice as a Slice of string. +func (e *StrSlice) Slice() []string { + if e == nil { + return nil + } + return e.parts +} + +// ToString gets space separated string of all the parts. +func (e *StrSlice) ToString() string { + s := e.Slice() + if s == nil { + return "" + } + return strings.Join(s, " ") +} + +// New creates an StrSlice based on the specified parts (as strings). +func New(parts ...string) *StrSlice { + return &StrSlice{parts} +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/time/timestamp.go b/components/engine/vendor/src/github.com/docker/engine-api/types/time/timestamp.go new file mode 100644 index 0000000000..d3695ba723 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/time/timestamp.go @@ -0,0 +1,124 @@ +package time + +import ( + "fmt" + "math" + "strconv" + "strings" + "time" +) + +// These are additional predefined layouts for use in Time.Format and Time.Parse +// with --since and --until parameters for `docker logs` and `docker events` +const ( + rFC3339Local = "2006-01-02T15:04:05" // RFC3339 with local timezone + rFC3339NanoLocal = "2006-01-02T15:04:05.999999999" // RFC3339Nano with local timezone + dateWithZone = "2006-01-02Z07:00" // RFC3339 with time at 00:00:00 + dateLocal = "2006-01-02" // RFC3339 with local timezone and time at 00:00:00 +) + +// GetTimestamp tries to parse given string as golang duration, +// then RFC3339 time and finally as a Unix timestamp. If +// any of these were successful, it returns a Unix timestamp +// as string otherwise returns the given value back. +// In case of duration input, the returned timestamp is computed +// as the given reference time minus the amount of the duration. +func GetTimestamp(value string, reference time.Time) (string, error) { + if d, err := time.ParseDuration(value); value != "0" && err == nil { + return strconv.FormatInt(reference.Add(-d).Unix(), 10), nil + } + + var format string + var parseInLocation bool + + // if the string has a Z or a + or three dashes use parse otherwise use parseinlocation + parseInLocation = !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3) + + if strings.Contains(value, ".") { + if parseInLocation { + format = rFC3339NanoLocal + } else { + format = time.RFC3339Nano + } + } else if strings.Contains(value, "T") { + // we want the number of colons in the T portion of the timestamp + tcolons := strings.Count(value, ":") + // if parseInLocation is off and we have a +/- zone offset (not Z) then + // there will be an extra colon in the input for the tz offset subtract that + // colon from the tcolons count + if !parseInLocation && !strings.ContainsAny(value, "zZ") && tcolons > 0 { + tcolons-- + } + if parseInLocation { + switch tcolons { + case 0: + format = "2006-01-02T15" + case 1: + format = "2006-01-02T15:04" + default: + format = rFC3339Local + } + } else { + switch tcolons { + case 0: + format = "2006-01-02T15Z07:00" + case 1: + format = "2006-01-02T15:04Z07:00" + default: + format = time.RFC3339 + } + } + } else if parseInLocation { + format = dateLocal + } else { + format = dateWithZone + } + + var t time.Time + var err error + + if parseInLocation { + t, err = time.ParseInLocation(format, value, time.FixedZone(reference.Zone())) + } else { + t, err = time.Parse(format, value) + } + + if err != nil { + // if there is a `-` then its an RFC3339 like timestamp otherwise assume unixtimestamp + if strings.Contains(value, "-") { + return "", err // was probably an RFC3339 like timestamp but the parser failed with an error + } + return value, nil // unixtimestamp in and out case (meaning: the value passed at the command line is already in the right format for passing to the server) + } + + return fmt.Sprintf("%d.%09d", t.Unix(), int64(t.Nanosecond())), nil +} + +// ParseTimestamps returns seconds and nanoseconds from a timestamp that has the +// format "%d.%09d", time.Unix(), int64(time.Nanosecond())) +// if the incoming nanosecond portion is longer or shorter than 9 digits it is +// converted to nanoseconds. The expectation is that the seconds and +// seconds will be used to create a time variable. For example: +// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0) +// if err == nil since := time.Unix(seconds, nanoseconds) +// returns seconds as def(aultSeconds) if value == "" +func ParseTimestamps(value string, def int64) (int64, int64, error) { + if value == "" { + return def, 0, nil + } + sa := strings.SplitN(value, ".", 2) + s, err := strconv.ParseInt(sa[0], 10, 64) + if err != nil { + return s, 0, err + } + if len(sa) != 2 { + return s, 0, nil + } + n, err := strconv.ParseInt(sa[1], 10, 64) + if err != nil { + return s, n, err + } + // should already be in nanoseconds but just in case convert n to nanoseonds + n = int64(float64(n) * math.Pow(float64(10), float64(9-len(sa[1])))) + return s, n, nil +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/types.go b/components/engine/vendor/src/github.com/docker/engine-api/types/types.go new file mode 100644 index 0000000000..5f9e018998 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/types.go @@ -0,0 +1,424 @@ +package types + +import ( + "os" + "time" + + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/network" + "github.com/docker/engine-api/types/registry" + "github.com/docker/go-connections/nat" +) + +// ContainerCreateResponse contains the information returned to a client on the +// creation of a new container. +type ContainerCreateResponse struct { + // ID is the ID of the created container. + ID string `json:"Id"` + + // Warnings are any warnings encountered during the creation of the container. + Warnings []string `json:"Warnings"` +} + +// ContainerExecCreateResponse contains response of Remote API: +// POST "/containers/{name:.*}/exec" +type ContainerExecCreateResponse struct { + // ID is the exec ID. + ID string `json:"Id"` +} + +// ContainerUpdateResponse contains response of Remote API: +// POST /containers/{name:.*}/update +type ContainerUpdateResponse struct { + // Warnings are any warnings encountered during the updating of the container. + Warnings []string `json:"Warnings"` +} + +// AuthResponse contains response of Remote API: +// POST "/auth" +type AuthResponse struct { + // Status is the authentication status + Status string `json:"Status"` +} + +// ContainerWaitResponse contains response of Remote API: +// POST "/containers/"+containerID+"/wait" +type ContainerWaitResponse struct { + // StatusCode is the status code of the wait job + StatusCode int `json:"StatusCode"` +} + +// ContainerCommitResponse contains response of Remote API: +// POST "/commit?container="+containerID +type ContainerCommitResponse struct { + ID string `json:"Id"` +} + +// ContainerChange contains response of Remote API: +// GET "/containers/{name:.*}/changes" +type ContainerChange struct { + Kind int + Path string +} + +// ImageHistory contains response of Remote API: +// GET "/images/{name:.*}/history" +type ImageHistory struct { + ID string `json:"Id"` + Created int64 + CreatedBy string + Tags []string + Size int64 + Comment string +} + +// ImageDelete contains response of Remote API: +// DELETE "/images/{name:.*}" +type ImageDelete struct { + Untagged string `json:",omitempty"` + Deleted string `json:",omitempty"` +} + +// Image contains response of Remote API: +// GET "/images/json" +type Image struct { + ID string `json:"Id"` + ParentID string `json:"ParentId"` + RepoTags []string + RepoDigests []string + Created int64 + Size int64 + VirtualSize int64 + Labels map[string]string +} + +// GraphDriverData returns Image's graph driver config info +// when calling inspect command +type GraphDriverData struct { + Name string + Data map[string]string +} + +// ImageInspect contains response of Remote API: +// GET "/images/{name:.*}/json" +type ImageInspect struct { + ID string `json:"Id"` + RepoTags []string + RepoDigests []string + Parent string + Comment string + Created string + Container string + ContainerConfig *container.Config + DockerVersion string + Author string + Config *container.Config + Architecture string + Os string + Size int64 + VirtualSize int64 + GraphDriver GraphDriverData +} + +// Port stores open ports info of container +// e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"} +type Port struct { + IP string `json:",omitempty"` + PrivatePort int + PublicPort int `json:",omitempty"` + Type string +} + +// Container contains response of Remote API: +// GET "/containers/json" +type Container struct { + ID string `json:"Id"` + Names []string + Image string + ImageID string + Command string + Created int64 + Ports []Port + SizeRw int64 `json:",omitempty"` + SizeRootFs int64 `json:",omitempty"` + Labels map[string]string + Status string + HostConfig struct { + NetworkMode string `json:",omitempty"` + } + NetworkSettings *SummaryNetworkSettings +} + +// CopyConfig contains request body of Remote API: +// POST "/containers/"+containerID+"/copy" +type CopyConfig struct { + Resource string +} + +// ContainerPathStat is used to encode the header from +// GET "/containers/{name:.*}/archive" +// "Name" is the file or directory name. +type ContainerPathStat struct { + Name string `json:"name"` + Size int64 `json:"size"` + Mode os.FileMode `json:"mode"` + Mtime time.Time `json:"mtime"` + LinkTarget string `json:"linkTarget"` +} + +// ContainerProcessList contains response of Remote API: +// GET "/containers/{name:.*}/top" +type ContainerProcessList struct { + Processes [][]string + Titles []string +} + +// Version contains response of Remote API: +// GET "/version" +type Version struct { + Version string + APIVersion string `json:"ApiVersion"` + GitCommit string + GoVersion string + Os string + Arch string + KernelVersion string `json:",omitempty"` + Experimental bool `json:",omitempty"` + BuildTime string `json:",omitempty"` +} + +// Info contains response of Remote API: +// GET "/info" +type Info struct { + ID string + Containers int + Images int + Driver string + DriverStatus [][2]string + Plugins PluginsInfo + MemoryLimit bool + SwapLimit bool + CPUCfsPeriod bool `json:"CpuCfsPeriod"` + CPUCfsQuota bool `json:"CpuCfsQuota"` + CPUShares bool + CPUSet bool + IPv4Forwarding bool + BridgeNfIptables bool + BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` + Debug bool + NFd int + OomKillDisable bool + NGoroutines int + SystemTime string + ExecutionDriver string + LoggingDriver string + NEventsListener int + KernelVersion string + OperatingSystem string + OSType string + Architecture string + IndexServerAddress string + RegistryConfig *registry.ServiceConfig + InitSha1 string + InitPath string + NCPU int + MemTotal int64 + DockerRootDir string + HTTPProxy string `json:"HttpProxy"` + HTTPSProxy string `json:"HttpsProxy"` + NoProxy string + Name string + Labels []string + ExperimentalBuild bool + ServerVersion string + ClusterStore string + ClusterAdvertise string +} + +// PluginsInfo is temp struct holds Plugins name +// registered with docker daemon. It used by Info struct +type PluginsInfo struct { + // List of Volume plugins registered + Volume []string + // List of Network plugins registered + Network []string + // List of Authorization plugins registered + Authorization []string +} + +// ExecStartCheck is a temp struct used by execStart +// Config fields is part of ExecConfig in runconfig package +type ExecStartCheck struct { + // ExecStart will first check if it's detached + Detach bool + // Check if there's a tty + Tty bool +} + +// ContainerState stores container's running state +// it's part of ContainerJSONBase and will return by "inspect" command +type ContainerState struct { + Status string + Running bool + Paused bool + Restarting bool + OOMKilled bool + Dead bool + Pid int + ExitCode int + Error string + StartedAt string + FinishedAt string +} + +// ContainerJSONBase contains response of Remote API: +// GET "/containers/{name:.*}/json" +type ContainerJSONBase struct { + ID string `json:"Id"` + Created string + Path string + Args []string + State *ContainerState + Image string + ResolvConfPath string + HostnamePath string + HostsPath string + LogPath string + Name string + RestartCount int + Driver string + MountLabel string + ProcessLabel string + AppArmorProfile string + ExecIDs []string + HostConfig *container.HostConfig + GraphDriver GraphDriverData + SizeRw *int64 `json:",omitempty"` + SizeRootFs *int64 `json:",omitempty"` +} + +// ContainerJSON is newly used struct along with MountPoint +type ContainerJSON struct { + *ContainerJSONBase + Mounts []MountPoint + Config *container.Config + NetworkSettings *NetworkSettings +} + +// NetworkSettings exposes the network settings in the api +type NetworkSettings struct { + NetworkSettingsBase + DefaultNetworkSettings + Networks map[string]*network.EndpointSettings +} + +// SummaryNetworkSettings provides a summary of container's networks +// in /containers/json +type SummaryNetworkSettings struct { + Networks map[string]*network.EndpointSettings +} + +// NetworkSettingsBase holds basic information about networks +type NetworkSettingsBase struct { + Bridge string + SandboxID string + HairpinMode bool + LinkLocalIPv6Address string + LinkLocalIPv6PrefixLen int + Ports nat.PortMap + SandboxKey string + SecondaryIPAddresses []network.Address + SecondaryIPv6Addresses []network.Address +} + +// DefaultNetworkSettings holds network information +// during the 2 release deprecation period. +// It will be removed in Docker 1.11. +type DefaultNetworkSettings struct { + EndpointID string + Gateway string + GlobalIPv6Address string + GlobalIPv6PrefixLen int + IPAddress string + IPPrefixLen int + IPv6Gateway string + MacAddress string +} + +// MountPoint represents a mount point configuration inside the container. +type MountPoint struct { + Name string `json:",omitempty"` + Source string + Destination string + Driver string `json:",omitempty"` + Mode string + RW bool + Propagation string +} + +// Volume represents the configuration of a volume for the remote API +type Volume struct { + Name string // Name is the name of the volume + Driver string // Driver is the Driver name used to create the volume + Mountpoint string // Mountpoint is the location on disk of the volume +} + +// VolumesListResponse contains the response for the remote API: +// GET "/volumes" +type VolumesListResponse struct { + Volumes []*Volume // Volumes is the list of volumes being returned + Warnings []string // Warnings is a list of warnings that occurred when getting the list from the volume drivers +} + +// VolumeCreateRequest contains the response for the remote API: +// POST "/volumes/create" +type VolumeCreateRequest struct { + Name string // Name is the requested name of the volume + Driver string // Driver is the name of the driver that should be used to create the volume + DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume. +} + +// NetworkResource is the body of the "get network" http response message +type NetworkResource struct { + Name string + ID string `json:"Id"` + Scope string + Driver string + IPAM network.IPAM + Containers map[string]EndpointResource + Options map[string]string +} + +// EndpointResource contains network resources allocated and used for a container in a network +type EndpointResource struct { + Name string + EndpointID string + MacAddress string + IPv4Address string + IPv6Address string +} + +// NetworkCreate is the expected body of the "create network" http request message +type NetworkCreate struct { + Name string + CheckDuplicate bool + Driver string + IPAM network.IPAM + Options map[string]string +} + +// NetworkCreateResponse is the response message sent by the server for network create call +type NetworkCreateResponse struct { + ID string `json:"Id"` + Warning string +} + +// NetworkConnect represents the data to be used to connect a container to the network +type NetworkConnect struct { + Container string +} + +// NetworkDisconnect represents the data to be used to disconnect a container from the network +type NetworkDisconnect struct { + Container string +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p19/types.go b/components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p19/types.go new file mode 100644 index 0000000000..4ed4335881 --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p19/types.go @@ -0,0 +1,35 @@ +// Package v1p19 provides specific API types for the API version 1, patch 19. +package v1p19 + +import ( + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/versions/v1p20" + "github.com/docker/go-connections/nat" +) + +// ContainerJSON is a backcompatibility struct for APIs prior to 1.20. +// Note this is not used by the Windows daemon. +type ContainerJSON struct { + *types.ContainerJSONBase + Volumes map[string]string + VolumesRW map[string]bool + Config *ContainerConfig + NetworkSettings *v1p20.NetworkSettings +} + +// ContainerConfig is a backcompatibility struct for APIs prior to 1.20. +type ContainerConfig struct { + *container.Config + + MacAddress string + NetworkDisabled bool + ExposedPorts map[nat.Port]struct{} + + // backward compatibility, they now live in HostConfig + VolumeDriver string + Memory int64 + MemorySwap int64 + CPUShares int64 `json:"CpuShares"` + CPUSet string `json:"Cpuset"` +} diff --git a/components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p20/types.go b/components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p20/types.go new file mode 100644 index 0000000000..ed800061fa --- /dev/null +++ b/components/engine/vendor/src/github.com/docker/engine-api/types/versions/v1p20/types.go @@ -0,0 +1,40 @@ +// Package v1p20 provides specific API types for the API version 1, patch 20. +package v1p20 + +import ( + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" + "github.com/docker/go-connections/nat" +) + +// ContainerJSON is a backcompatibility struct for the API 1.20 +type ContainerJSON struct { + *types.ContainerJSONBase + Mounts []types.MountPoint + Config *ContainerConfig + NetworkSettings *NetworkSettings +} + +// ContainerConfig is a backcompatibility struct used in ContainerJSON for the API 1.20 +type ContainerConfig struct { + *container.Config + + MacAddress string + NetworkDisabled bool + ExposedPorts map[nat.Port]struct{} + + // backward compatibility, they now live in HostConfig + VolumeDriver string +} + +// StatsJSON is a backcompatibility struct used in Stats for API prior to 1.21 +type StatsJSON struct { + types.Stats + Network types.NetworkStats `json:"network,omitempty"` +} + +// NetworkSettings is a backward compatible struct for APIs prior to 1.21 +type NetworkSettings struct { + types.NetworkSettingsBase + types.DefaultNetworkSettings +} From 4ec2693c9e20600f4af28cafa8b42daf1c7a6418 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 4 Jan 2016 19:05:26 -0500 Subject: [PATCH 2/3] Modify import paths to point to the new engine-api package. Signed-off-by: David Calavera Upstream-commit: 907407d0b2e5863f0e1b40b93a356bbf03c7b9fb Component: engine --- components/engine/api/client/attach.go | 2 +- components/engine/api/client/build.go | 4 ++-- components/engine/api/client/cli.go | 4 ++-- components/engine/api/client/client.go | 16 ++++++++-------- components/engine/api/client/commit.go | 4 ++-- components/engine/api/client/cp.go | 2 +- components/engine/api/client/create.go | 8 ++++---- components/engine/api/client/events.go | 6 +++--- components/engine/api/client/exec.go | 2 +- components/engine/api/client/exec_test.go | 2 +- components/engine/api/client/formatter/custom.go | 2 +- .../engine/api/client/formatter/custom_test.go | 2 +- .../engine/api/client/formatter/formatter.go | 2 +- .../api/client/formatter/formatter_test.go | 2 +- components/engine/api/client/hijack.go | 2 +- components/engine/api/client/images.go | 4 ++-- components/engine/api/client/import.go | 2 +- components/engine/api/client/inspect.go | 6 +++--- .../engine/api/client/lib/container_attach.go | 2 +- .../engine/api/client/lib/container_commit.go | 2 +- .../engine/api/client/lib/container_create.go | 4 ++-- .../engine/api/client/lib/container_inspect.go | 2 +- .../engine/api/client/lib/container_list.go | 4 ++-- .../engine/api/client/lib/container_remove.go | 2 +- .../engine/api/client/lib/container_top.go | 2 +- .../engine/api/client/lib/container_update.go | 2 +- components/engine/api/client/lib/copy.go | 2 +- components/engine/api/client/lib/diff.go | 2 +- components/engine/api/client/lib/events.go | 6 +++--- components/engine/api/client/lib/exec.go | 2 +- components/engine/api/client/lib/hijack.go | 2 +- components/engine/api/client/lib/history.go | 2 +- components/engine/api/client/lib/image_build.go | 4 ++-- components/engine/api/client/lib/image_create.go | 2 +- components/engine/api/client/lib/image_import.go | 2 +- .../engine/api/client/lib/image_inspect.go | 2 +- components/engine/api/client/lib/image_list.go | 4 ++-- components/engine/api/client/lib/image_load.go | 2 +- components/engine/api/client/lib/image_pull.go | 2 +- components/engine/api/client/lib/image_push.go | 2 +- components/engine/api/client/lib/image_remove.go | 2 +- components/engine/api/client/lib/image_search.go | 4 ++-- components/engine/api/client/lib/image_tag.go | 2 +- components/engine/api/client/lib/info.go | 2 +- components/engine/api/client/lib/login.go | 2 +- components/engine/api/client/lib/logs.go | 4 ++-- components/engine/api/client/lib/network.go | 4 ++-- components/engine/api/client/lib/resize.go | 2 +- components/engine/api/client/lib/version.go | 2 +- components/engine/api/client/lib/volume.go | 4 ++-- components/engine/api/client/lib/wait.go | 2 +- components/engine/api/client/login.go | 6 +++--- components/engine/api/client/logs.go | 2 +- components/engine/api/client/network.go | 6 +++--- components/engine/api/client/ps.go | 4 ++-- components/engine/api/client/pull.go | 6 +++--- components/engine/api/client/push.go | 6 +++--- components/engine/api/client/rm.go | 2 +- components/engine/api/client/rmi.go | 2 +- components/engine/api/client/run.go | 2 +- components/engine/api/client/search.go | 4 ++-- components/engine/api/client/start.go | 2 +- components/engine/api/client/stats.go | 6 +++--- components/engine/api/client/stats_unit_test.go | 2 +- components/engine/api/client/tag.go | 2 +- components/engine/api/client/trust.go | 10 +++++----- components/engine/api/client/trust_test.go | 2 +- components/engine/api/client/update.go | 2 +- components/engine/api/client/utils.go | 12 ++++++------ components/engine/api/client/version.go | 2 +- components/engine/api/client/volume.go | 4 ++-- components/engine/api/common.go | 2 +- components/engine/api/common_test.go | 2 +- .../api/server/router/build/build_routes.go | 4 ++-- .../api/server/router/container/backend.go | 4 ++-- .../server/router/container/container_routes.go | 6 +++--- .../engine/api/server/router/container/copy.go | 2 +- .../engine/api/server/router/container/exec.go | 2 +- .../engine/api/server/router/local/image.go | 4 ++-- .../engine/api/server/router/network/backend.go | 2 +- .../engine/api/server/router/network/filter.go | 2 +- .../api/server/router/network/network_routes.go | 6 +++--- .../engine/api/server/router/system/backend.go | 6 +++--- .../api/server/router/system/system_routes.go | 8 ++++---- .../engine/api/server/router/volume/backend.go | 2 +- .../api/server/router/volume/volume_routes.go | 2 +- components/engine/api/types/client.go | 4 ++-- components/engine/api/types/configs.go | 2 +- components/engine/api/types/container/config.go | 2 +- .../engine/api/types/container/host_config.go | 4 ++-- components/engine/api/types/types.go | 6 +++--- .../engine/api/types/versions/v1p19/types.go | 6 +++--- .../engine/api/types/versions/v1p20/types.go | 4 ++-- components/engine/builder/builder.go | 4 ++-- components/engine/builder/dockerfile/builder.go | 4 ++-- .../engine/builder/dockerfile/dispatchers.go | 4 ++-- .../engine/builder/dockerfile/internals.go | 6 +++--- components/engine/builder/image.go | 2 +- components/engine/cliconfig/config.go | 2 +- components/engine/cliconfig/config_test.go | 2 +- components/engine/container/archive.go | 2 +- components/engine/container/container.go | 2 +- .../engine/container/container_unit_test.go | 2 +- components/engine/container/container_unix.go | 4 ++-- components/engine/container/container_windows.go | 2 +- components/engine/container/monitor.go | 2 +- components/engine/daemon/archive.go | 2 +- components/engine/daemon/commit.go | 4 ++-- components/engine/daemon/config.go | 2 +- .../engine/daemon/container_operations_unix.go | 4 ++-- components/engine/daemon/create.go | 4 ++-- components/engine/daemon/create_unix.go | 2 +- components/engine/daemon/create_windows.go | 2 +- components/engine/daemon/daemon.go | 12 ++++++------ components/engine/daemon/daemon_experimental.go | 2 +- components/engine/daemon/daemon_stub.go | 2 +- components/engine/daemon/daemon_test.go | 2 +- components/engine/daemon/daemon_unix.go | 4 ++-- components/engine/daemon/daemon_unix_test.go | 2 +- components/engine/daemon/daemon_windows.go | 2 +- .../engine/daemon/daemonbuilder/builder.go | 4 ++-- components/engine/daemon/daemonbuilder/image.go | 2 +- components/engine/daemon/delete.go | 2 +- components/engine/daemon/delete_test.go | 4 ++-- components/engine/daemon/events.go | 2 +- components/engine/daemon/events/events.go | 2 +- components/engine/daemon/events/events_test.go | 2 +- components/engine/daemon/events/filter.go | 4 ++-- components/engine/daemon/events_test.go | 2 +- components/engine/daemon/exec.go | 4 ++-- components/engine/daemon/exec_unix.go | 2 +- components/engine/daemon/exec_windows.go | 2 +- .../engine/daemon/execdriver/windows/info.go | 2 +- .../engine/daemon/execdriver/windows/windows.go | 2 +- components/engine/daemon/image_delete.go | 2 +- components/engine/daemon/images.go | 4 ++-- components/engine/daemon/import.go | 2 +- components/engine/daemon/info.go | 2 +- components/engine/daemon/inspect.go | 6 +++--- components/engine/daemon/inspect_unix.go | 4 ++-- components/engine/daemon/inspect_windows.go | 2 +- components/engine/daemon/list.go | 4 ++-- components/engine/daemon/network.go | 2 +- components/engine/daemon/network/settings.go | 2 +- components/engine/daemon/start.go | 2 +- components/engine/daemon/stats.go | 4 ++-- components/engine/daemon/stats_freebsd.go | 2 +- components/engine/daemon/stats_linux.go | 2 +- components/engine/daemon/stats_windows.go | 2 +- components/engine/daemon/top_unix.go | 2 +- components/engine/daemon/top_windows.go | 2 +- components/engine/daemon/update.go | 2 +- components/engine/daemon/volumes.go | 4 ++-- components/engine/distribution/pull.go | 2 +- components/engine/distribution/push.go | 2 +- components/engine/distribution/registry.go | 2 +- .../engine/distribution/registry_unit_test.go | 4 ++-- components/engine/image/image.go | 2 +- .../docker_api_containers_test.go | 4 ++-- .../integration-cli/docker_api_images_test.go | 2 +- .../integration-cli/docker_api_inspect_test.go | 4 ++-- .../integration-cli/docker_api_network_test.go | 6 +++--- .../integration-cli/docker_api_stats_test.go | 2 +- .../integration-cli/docker_api_version_test.go | 2 +- .../integration-cli/docker_api_volumes_test.go | 2 +- .../integration-cli/docker_cli_by_digest_test.go | 2 +- .../docker_cli_inspect_experimental_test.go | 2 +- .../integration-cli/docker_cli_inspect_test.go | 4 ++-- .../docker_cli_network_unix_test.go | 4 ++-- .../docker_cli_update_unix_test.go | 2 +- .../engine/integration-cli/docker_utils.go | 2 +- components/engine/registry/auth.go | 4 ++-- components/engine/registry/auth_test.go | 4 ++-- components/engine/registry/config.go | 2 +- components/engine/registry/endpoint.go | 2 +- components/engine/registry/registry_mock_test.go | 2 +- components/engine/registry/registry_test.go | 4 ++-- components/engine/registry/service.go | 4 ++-- components/engine/registry/session.go | 4 ++-- components/engine/registry/types.go | 2 +- components/engine/runconfig/compare.go | 2 +- components/engine/runconfig/compare_test.go | 4 ++-- components/engine/runconfig/config.go | 2 +- components/engine/runconfig/config_test.go | 4 ++-- components/engine/runconfig/config_unix.go | 2 +- components/engine/runconfig/config_windows.go | 2 +- components/engine/runconfig/hostconfig.go | 2 +- components/engine/runconfig/hostconfig_test.go | 2 +- components/engine/runconfig/hostconfig_unix.go | 2 +- .../engine/runconfig/hostconfig_windows.go | 2 +- components/engine/runconfig/opts/parse.go | 4 ++-- components/engine/runconfig/opts/parse_test.go | 2 +- .../engine/runconfig/opts/throttledevice.go | 2 +- components/engine/runconfig/opts/weightdevice.go | 2 +- 194 files changed, 304 insertions(+), 304 deletions(-) diff --git a/components/engine/api/client/attach.go b/components/engine/api/client/attach.go index 1cb097dfb5..6bfe1be187 100644 --- a/components/engine/api/client/attach.go +++ b/components/engine/api/client/attach.go @@ -5,10 +5,10 @@ import ( "io" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/signal" + "github.com/docker/engine-api/types" ) // CmdAttach attaches to a running container. diff --git a/components/engine/api/client/build.go b/components/engine/api/client/build.go index 0706b2f0c6..ee470bcd05 100644 --- a/components/engine/api/client/build.go +++ b/components/engine/api/client/build.go @@ -15,8 +15,6 @@ import ( "strings" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder/dockerignore" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" @@ -31,6 +29,8 @@ import ( "github.com/docker/docker/pkg/urlutil" "github.com/docker/docker/reference" runconfigopts "github.com/docker/docker/runconfig/opts" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" "github.com/docker/go-units" ) diff --git a/components/engine/api/client/cli.go b/components/engine/api/client/cli.go index 4f4362d90b..5d54ccfaf9 100644 --- a/components/engine/api/client/cli.go +++ b/components/engine/api/client/cli.go @@ -9,12 +9,12 @@ import ( "runtime" "github.com/docker/docker/api" - "github.com/docker/docker/api/client/lib" "github.com/docker/docker/cli" "github.com/docker/docker/cliconfig" "github.com/docker/docker/dockerversion" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/term" + "github.com/docker/engine-api/client" "github.com/docker/go-connections/tlsconfig" ) @@ -120,7 +120,7 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, clientFlags *cli.ClientF return err } - client, err := lib.NewClient(host, verStr, clientTransport, customHeaders) + client, err := client.NewClient(host, verStr, clientTransport, customHeaders) if err != nil { return err } diff --git a/components/engine/api/client/client.go b/components/engine/api/client/client.go index d820dad12e..4bea72c6c7 100644 --- a/components/engine/api/client/client.go +++ b/components/engine/api/client/client.go @@ -7,11 +7,11 @@ package client import ( "io" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/registry" + "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/filters" + "github.com/docker/engine-api/types/registry" ) // apiClient is an interface that clients that talk with a docker server must implement. @@ -55,10 +55,10 @@ type apiClient interface { ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error) ImageList(options types.ImageListOptions) ([]types.Image, error) ImageLoad(input io.Reader) (types.ImageLoadResponse, error) - ImagePull(options types.ImagePullOptions, privilegeFunc lib.RequestPrivilegeFunc) (io.ReadCloser, error) - ImagePush(options types.ImagePushOptions, privilegeFunc lib.RequestPrivilegeFunc) (io.ReadCloser, error) + ImagePull(options types.ImagePullOptions, privilegeFunc client.RequestPrivilegeFunc) (io.ReadCloser, error) + ImagePush(options types.ImagePushOptions, privilegeFunc client.RequestPrivilegeFunc) (io.ReadCloser, error) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) - ImageSearch(options types.ImageSearchOptions, privilegeFunc lib.RequestPrivilegeFunc) ([]registry.SearchResult, error) + ImageSearch(options types.ImageSearchOptions, privilegeFunc client.RequestPrivilegeFunc) ([]registry.SearchResult, error) ImageSave(imageIDs []string) (io.ReadCloser, error) ImageTag(options types.ImageTagOptions) error Info() (types.Info, error) diff --git a/components/engine/api/client/commit.go b/components/engine/api/client/commit.go index 48678d4d8f..4c0d5c28d8 100644 --- a/components/engine/api/client/commit.go +++ b/components/engine/api/client/commit.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) // CmdCommit creates a new image from a container's changes. diff --git a/components/engine/api/client/cp.go b/components/engine/api/client/cp.go index 0c3f19ffc6..43573d906b 100644 --- a/components/engine/api/client/cp.go +++ b/components/engine/api/client/cp.go @@ -7,11 +7,11 @@ import ( "path/filepath" "strings" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" "github.com/docker/docker/pkg/archive" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/system" + "github.com/docker/engine-api/types" ) type copyDirection int diff --git a/components/engine/api/client/create.go b/components/engine/api/client/create.go index 2569ae755a..fce4062f81 100644 --- a/components/engine/api/client/create.go +++ b/components/engine/api/client/create.go @@ -5,14 +5,14 @@ import ( "io" "os" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" Cli "github.com/docker/docker/cli" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/reference" "github.com/docker/docker/registry" runconfigopts "github.com/docker/docker/runconfig/opts" + "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) func (cli *DockerCli) pullImage(image string) error { @@ -110,7 +110,7 @@ func (cli *DockerCli) createContainer(config *container.Config, hostConfig *cont response, err := cli.client.ContainerCreate(config, hostConfig, name) //if image not found try to pull it if err != nil { - if lib.IsErrImageNotFound(err) { + if client.IsErrImageNotFound(err) { fmt.Fprintf(cli.err, "Unable to find image '%s' locally\n", ref.String()) // we don't want to write to stdout anything apart from container.ID diff --git a/components/engine/api/client/events.go b/components/engine/api/client/events.go index 4ceaf43f84..c2a6ab3bb1 100644 --- a/components/engine/api/client/events.go +++ b/components/engine/api/client/events.go @@ -7,13 +7,13 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" - eventtypes "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/jsonlog" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" + eventtypes "github.com/docker/engine-api/types/events" + "github.com/docker/engine-api/types/filters" ) // CmdEvents prints a live stream of real time events from the server. diff --git a/components/engine/api/client/exec.go b/components/engine/api/client/exec.go index ac2e65868d..0ce9e81fe3 100644 --- a/components/engine/api/client/exec.go +++ b/components/engine/api/client/exec.go @@ -5,10 +5,10 @@ import ( "io" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/promise" + "github.com/docker/engine-api/types" ) // CmdExec runs a command in a running container. diff --git a/components/engine/api/client/exec_test.go b/components/engine/api/client/exec_test.go index 7fd4f7aded..1680fa6e79 100644 --- a/components/engine/api/client/exec_test.go +++ b/components/engine/api/client/exec_test.go @@ -5,8 +5,8 @@ import ( "io/ioutil" "testing" - "github.com/docker/docker/api/types" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" ) type arguments struct { diff --git a/components/engine/api/client/formatter/custom.go b/components/engine/api/client/formatter/custom.go index 97cdbc1896..8a680705ca 100644 --- a/components/engine/api/client/formatter/custom.go +++ b/components/engine/api/client/formatter/custom.go @@ -7,9 +7,9 @@ import ( "time" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringutils" + "github.com/docker/engine-api/types" "github.com/docker/go-units" ) diff --git a/components/engine/api/client/formatter/custom_test.go b/components/engine/api/client/formatter/custom_test.go index fee3ba889f..608622564a 100644 --- a/components/engine/api/client/formatter/custom_test.go +++ b/components/engine/api/client/formatter/custom_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/stringid" + "github.com/docker/engine-api/types" ) func TestContainerPsContext(t *testing.T) { diff --git a/components/engine/api/client/formatter/formatter.go b/components/engine/api/client/formatter/formatter.go index 2e19e9396a..749148ac82 100644 --- a/components/engine/api/client/formatter/formatter.go +++ b/components/engine/api/client/formatter/formatter.go @@ -8,8 +8,8 @@ import ( "text/tabwriter" "text/template" - "github.com/docker/docker/api/types" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" ) const ( diff --git a/components/engine/api/client/formatter/formatter_test.go b/components/engine/api/client/formatter/formatter_test.go index 6d7185311c..223cab970a 100644 --- a/components/engine/api/client/formatter/formatter_test.go +++ b/components/engine/api/client/formatter/formatter_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) func TestContainerContextWrite(t *testing.T) { diff --git a/components/engine/api/client/hijack.go b/components/engine/api/client/hijack.go index 72f5ed43de..ea4b5e3875 100644 --- a/components/engine/api/client/hijack.go +++ b/components/engine/api/client/hijack.go @@ -5,9 +5,9 @@ import ( "os" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/term" + "github.com/docker/engine-api/types" ) func (cli *DockerCli) holdHijackedConnection(setRawTerminal bool, inputStream io.ReadCloser, outputStream, errorStream io.Writer, resp types.HijackedResponse) error { diff --git a/components/engine/api/client/images.go b/components/engine/api/client/images.go index ef19bd32f3..2b0b4045d2 100644 --- a/components/engine/api/client/images.go +++ b/components/engine/api/client/images.go @@ -2,11 +2,11 @@ package client import ( "github.com/docker/docker/api/client/formatter" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // CmdImages lists the images in a specified repository, or all top-level images if no repository is specified. diff --git a/components/engine/api/client/import.go b/components/engine/api/client/import.go index 692566d72b..ece821aef6 100644 --- a/components/engine/api/client/import.go +++ b/components/engine/api/client/import.go @@ -5,13 +5,13 @@ import ( "io" "os" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/jsonmessage" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/urlutil" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" ) // CmdImport creates an empty filesystem image, imports the contents of the tarball into the image, and optionally tags the image. diff --git a/components/engine/api/client/inspect.go b/components/engine/api/client/inspect.go index 375129bdaa..5401d3bc3d 100644 --- a/components/engine/api/client/inspect.go +++ b/components/engine/api/client/inspect.go @@ -6,9 +6,9 @@ import ( "text/template" "github.com/docker/docker/api/client/inspect" - "github.com/docker/docker/api/client/lib" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/client" ) var funcMap = template.FuncMap{ @@ -64,10 +64,10 @@ func (cli *DockerCli) inspectAll(getSize bool) inspectSearcher { c, rawContainer, err := cli.client.ContainerInspectWithRaw(ref, getSize) if err != nil { // Search for image with that id if a container doesn't exist. - if lib.IsErrContainerNotFound(err) { + if client.IsErrContainerNotFound(err) { i, rawImage, err := cli.client.ImageInspectWithRaw(ref, getSize) if err != nil { - if lib.IsErrImageNotFound(err) { + if client.IsErrImageNotFound(err) { return nil, nil, fmt.Errorf("Error: No such image or container: %s", ref) } return nil, nil, err diff --git a/components/engine/api/client/lib/container_attach.go b/components/engine/api/client/lib/container_attach.go index aac4d65304..4074bc99a8 100644 --- a/components/engine/api/client/lib/container_attach.go +++ b/components/engine/api/client/lib/container_attach.go @@ -3,7 +3,7 @@ package lib import ( "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerAttach attaches a connection to a container in the server. diff --git a/components/engine/api/client/lib/container_commit.go b/components/engine/api/client/lib/container_commit.go index 45cf166250..9908a19273 100644 --- a/components/engine/api/client/lib/container_commit.go +++ b/components/engine/api/client/lib/container_commit.go @@ -4,7 +4,7 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerCommit applies changes into a container and creates a new tagged image. diff --git a/components/engine/api/client/lib/container_create.go b/components/engine/api/client/lib/container_create.go index e563d7b5a2..50fa927dc7 100644 --- a/components/engine/api/client/lib/container_create.go +++ b/components/engine/api/client/lib/container_create.go @@ -5,8 +5,8 @@ import ( "net/url" "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) type configWrapper struct { diff --git a/components/engine/api/client/lib/container_inspect.go b/components/engine/api/client/lib/container_inspect.go index 41e413132e..49b8893982 100644 --- a/components/engine/api/client/lib/container_inspect.go +++ b/components/engine/api/client/lib/container_inspect.go @@ -7,7 +7,7 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerInspect returns the container information. diff --git a/components/engine/api/client/lib/container_list.go b/components/engine/api/client/lib/container_list.go index 6ffe415856..c05b1d5d66 100644 --- a/components/engine/api/client/lib/container_list.go +++ b/components/engine/api/client/lib/container_list.go @@ -5,8 +5,8 @@ import ( "net/url" "strconv" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // ContainerList returns the list of containers in the docker host. diff --git a/components/engine/api/client/lib/container_remove.go b/components/engine/api/client/lib/container_remove.go index aff5012b36..76fe9bd40d 100644 --- a/components/engine/api/client/lib/container_remove.go +++ b/components/engine/api/client/lib/container_remove.go @@ -3,7 +3,7 @@ package lib import ( "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerRemove kills and removes a container from the docker host. diff --git a/components/engine/api/client/lib/container_top.go b/components/engine/api/client/lib/container_top.go index abee1ed417..98860c8aa7 100644 --- a/components/engine/api/client/lib/container_top.go +++ b/components/engine/api/client/lib/container_top.go @@ -5,7 +5,7 @@ import ( "net/url" "strings" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerTop shows process information from within a container. diff --git a/components/engine/api/client/lib/container_update.go b/components/engine/api/client/lib/container_update.go index 387a6c475d..6976e3d9f1 100644 --- a/components/engine/api/client/lib/container_update.go +++ b/components/engine/api/client/lib/container_update.go @@ -1,7 +1,7 @@ package lib import ( - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // ContainerUpdate updates resources of a container diff --git a/components/engine/api/client/lib/copy.go b/components/engine/api/client/lib/copy.go index e26a7f79b0..b18c89334e 100644 --- a/components/engine/api/client/lib/copy.go +++ b/components/engine/api/client/lib/copy.go @@ -10,7 +10,7 @@ import ( "path/filepath" "strings" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerStatPath returns Stat information about a path inside the container filesystem. diff --git a/components/engine/api/client/lib/diff.go b/components/engine/api/client/lib/diff.go index 15954c5ed7..eaa7db112d 100644 --- a/components/engine/api/client/lib/diff.go +++ b/components/engine/api/client/lib/diff.go @@ -4,7 +4,7 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerDiff shows differences in a container filesystem since it was started. diff --git a/components/engine/api/client/lib/events.go b/components/engine/api/client/lib/events.go index 502e765208..9d4606829b 100644 --- a/components/engine/api/client/lib/events.go +++ b/components/engine/api/client/lib/events.go @@ -5,9 +5,9 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" - timetypes "github.com/docker/docker/api/types/time" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" + timetypes "github.com/docker/engine-api/types/time" ) // Events returns a stream of events in the daemon in a ReadCloser. diff --git a/components/engine/api/client/lib/exec.go b/components/engine/api/client/lib/exec.go index 8bcabb1657..229db2711b 100644 --- a/components/engine/api/client/lib/exec.go +++ b/components/engine/api/client/lib/exec.go @@ -3,7 +3,7 @@ package lib import ( "encoding/json" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerExecCreate creates a new exec configuration to run an exec process. diff --git a/components/engine/api/client/lib/hijack.go b/components/engine/api/client/lib/hijack.go index 6c76f0a88e..6ee8d160e4 100644 --- a/components/engine/api/client/lib/hijack.go +++ b/components/engine/api/client/lib/hijack.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // tlsClientCon holds tls information and a dialed connection. diff --git a/components/engine/api/client/lib/history.go b/components/engine/api/client/lib/history.go index e729f70eff..4fb4e5d8df 100644 --- a/components/engine/api/client/lib/history.go +++ b/components/engine/api/client/lib/history.go @@ -4,7 +4,7 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageHistory returns the changes in an image in history format. diff --git a/components/engine/api/client/lib/image_build.go b/components/engine/api/client/lib/image_build.go index da4d6efc68..c6d8740477 100644 --- a/components/engine/api/client/lib/image_build.go +++ b/components/engine/api/client/lib/image_build.go @@ -9,8 +9,8 @@ import ( "strconv" "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`) diff --git a/components/engine/api/client/lib/image_create.go b/components/engine/api/client/lib/image_create.go index 75d4b75e4a..f4070d62c0 100644 --- a/components/engine/api/client/lib/image_create.go +++ b/components/engine/api/client/lib/image_create.go @@ -4,7 +4,7 @@ import ( "io" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageCreate creates a new image based in the parent options. diff --git a/components/engine/api/client/lib/image_import.go b/components/engine/api/client/lib/image_import.go index 873010f3e5..fbd487bf9a 100644 --- a/components/engine/api/client/lib/image_import.go +++ b/components/engine/api/client/lib/image_import.go @@ -4,7 +4,7 @@ import ( "io" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageImport creates a new image based in the source options. diff --git a/components/engine/api/client/lib/image_inspect.go b/components/engine/api/client/lib/image_inspect.go index f4089cba0b..59f991f689 100644 --- a/components/engine/api/client/lib/image_inspect.go +++ b/components/engine/api/client/lib/image_inspect.go @@ -7,7 +7,7 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageInspectWithRaw returns the image information and it's raw representation. diff --git a/components/engine/api/client/lib/image_list.go b/components/engine/api/client/lib/image_list.go index d0b18ea911..61c62bfe57 100644 --- a/components/engine/api/client/lib/image_list.go +++ b/components/engine/api/client/lib/image_list.go @@ -4,8 +4,8 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // ImageList returns a list of images in the docker host. diff --git a/components/engine/api/client/lib/image_load.go b/components/engine/api/client/lib/image_load.go index c713262c79..1fcb904523 100644 --- a/components/engine/api/client/lib/image_load.go +++ b/components/engine/api/client/lib/image_load.go @@ -4,7 +4,7 @@ import ( "io" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageLoad loads an image in the docker host from the client host. diff --git a/components/engine/api/client/lib/image_pull.go b/components/engine/api/client/lib/image_pull.go index ef5f1ce6e6..98fd6e86f2 100644 --- a/components/engine/api/client/lib/image_pull.go +++ b/components/engine/api/client/lib/image_pull.go @@ -5,7 +5,7 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImagePull request the docker host to pull an image from a remote registry. diff --git a/components/engine/api/client/lib/image_push.go b/components/engine/api/client/lib/image_push.go index 14c369afac..620ea7d510 100644 --- a/components/engine/api/client/lib/image_push.go +++ b/components/engine/api/client/lib/image_push.go @@ -5,7 +5,7 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImagePush request the docker host to push an image to a remote registry. diff --git a/components/engine/api/client/lib/image_remove.go b/components/engine/api/client/lib/image_remove.go index fb221da6bd..d0ec6040dc 100644 --- a/components/engine/api/client/lib/image_remove.go +++ b/components/engine/api/client/lib/image_remove.go @@ -4,7 +4,7 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageRemove removes an image from the docker host. diff --git a/components/engine/api/client/lib/image_search.go b/components/engine/api/client/lib/image_search.go index 4e6bc7da13..3f9f24e1e7 100644 --- a/components/engine/api/client/lib/image_search.go +++ b/components/engine/api/client/lib/image_search.go @@ -5,8 +5,8 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/registry" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/registry" ) // ImageSearch makes the docker host to search by a term in a remote registry. diff --git a/components/engine/api/client/lib/image_tag.go b/components/engine/api/client/lib/image_tag.go index d83e33fe23..a0a2230fb2 100644 --- a/components/engine/api/client/lib/image_tag.go +++ b/components/engine/api/client/lib/image_tag.go @@ -3,7 +3,7 @@ package lib import ( "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ImageTag tags an image in the docker host diff --git a/components/engine/api/client/lib/info.go b/components/engine/api/client/lib/info.go index 04d854a290..e1fa4229ea 100644 --- a/components/engine/api/client/lib/info.go +++ b/components/engine/api/client/lib/info.go @@ -5,7 +5,7 @@ import ( "fmt" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // Info returns information about the docker server. diff --git a/components/engine/api/client/lib/login.go b/components/engine/api/client/lib/login.go index c896d67ef2..426533f0ef 100644 --- a/components/engine/api/client/lib/login.go +++ b/components/engine/api/client/lib/login.go @@ -5,7 +5,7 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // RegistryLogin authenticates the docker server with a given docker registry. diff --git a/components/engine/api/client/lib/logs.go b/components/engine/api/client/lib/logs.go index 119f41306d..f3fe1770ef 100644 --- a/components/engine/api/client/lib/logs.go +++ b/components/engine/api/client/lib/logs.go @@ -5,8 +5,8 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types" - timetypes "github.com/docker/docker/api/types/time" + "github.com/docker/engine-api/types" + timetypes "github.com/docker/engine-api/types/time" ) // ContainerLogs returns the logs generated by a container in an io.ReadCloser. diff --git a/components/engine/api/client/lib/network.go b/components/engine/api/client/lib/network.go index e38d9e8c8b..ba80ca39c4 100644 --- a/components/engine/api/client/lib/network.go +++ b/components/engine/api/client/lib/network.go @@ -5,8 +5,8 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // NetworkCreate creates a new network in the docker host. diff --git a/components/engine/api/client/lib/resize.go b/components/engine/api/client/lib/resize.go index dffd81d544..4040368fbc 100644 --- a/components/engine/api/client/lib/resize.go +++ b/components/engine/api/client/lib/resize.go @@ -4,7 +4,7 @@ import ( "net/url" "strconv" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerResize changes the size of the tty for a container. diff --git a/components/engine/api/client/lib/version.go b/components/engine/api/client/lib/version.go index 4101bfee0b..2b03ac4ea7 100644 --- a/components/engine/api/client/lib/version.go +++ b/components/engine/api/client/lib/version.go @@ -3,7 +3,7 @@ package lib import ( "encoding/json" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ServerVersion returns information of the docker client and server host. diff --git a/components/engine/api/client/lib/volume.go b/components/engine/api/client/lib/volume.go index fdcd1cf529..f41f75bf09 100644 --- a/components/engine/api/client/lib/volume.go +++ b/components/engine/api/client/lib/volume.go @@ -5,8 +5,8 @@ import ( "net/http" "net/url" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // VolumeList returns the volumes configured in the docker host. diff --git a/components/engine/api/client/lib/wait.go b/components/engine/api/client/lib/wait.go index 70993d84aa..e490e09965 100644 --- a/components/engine/api/client/lib/wait.go +++ b/components/engine/api/client/lib/wait.go @@ -3,7 +3,7 @@ package lib import ( "encoding/json" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // ContainerWait pauses execution util a container is exits. diff --git a/components/engine/api/client/login.go b/components/engine/api/client/login.go index 3b7a547175..a396450de1 100644 --- a/components/engine/api/client/login.go +++ b/components/engine/api/client/login.go @@ -8,12 +8,12 @@ import ( "runtime" "strings" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/term" "github.com/docker/docker/registry" + "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" ) // CmdLogin logs in or registers a user to a Docker registry service. @@ -122,7 +122,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error { auth := cli.configFile.AuthConfigs[serverAddress] response, err := cli.client.RegistryLogin(auth) if err != nil { - if lib.IsErrUnauthorized(err) { + if client.IsErrUnauthorized(err) { delete(cli.configFile.AuthConfigs, serverAddress) if err2 := cli.configFile.Save(); err2 != nil { fmt.Fprintf(cli.out, "WARNING: could not save config file: %v\n", err2) diff --git a/components/engine/api/client/logs.go b/components/engine/api/client/logs.go index 77c754f4da..92b75e0505 100644 --- a/components/engine/api/client/logs.go +++ b/components/engine/api/client/logs.go @@ -4,10 +4,10 @@ import ( "fmt" "io" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/stdcopy" + "github.com/docker/engine-api/types" ) var validDrivers = map[string]bool{ diff --git a/components/engine/api/client/network.go b/components/engine/api/client/network.go index 8c769d56db..31cd4dbfd3 100644 --- a/components/engine/api/client/network.go +++ b/components/engine/api/client/network.go @@ -6,13 +6,13 @@ import ( "strings" "text/tabwriter" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/stringid" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" + "github.com/docker/engine-api/types/network" ) // CmdNetwork is the parent subcommand for all network commands diff --git a/components/engine/api/client/ps.go b/components/engine/api/client/ps.go index 3f02fa1d60..c0589738d6 100644 --- a/components/engine/api/client/ps.go +++ b/components/engine/api/client/ps.go @@ -2,11 +2,11 @@ package client import ( "github.com/docker/docker/api/client/formatter" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // CmdPs outputs a list of Docker containers. diff --git a/components/engine/api/client/pull.go b/components/engine/api/client/pull.go index 361c341d06..5566d7976f 100644 --- a/components/engine/api/client/pull.go +++ b/components/engine/api/client/pull.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" "github.com/docker/docker/pkg/jsonmessage" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" ) // CmdPull pulls an image or a repository from the registry. @@ -65,7 +65,7 @@ func (cli *DockerCli) CmdPull(args ...string) error { return cli.imagePullPrivileged(authConfig, distributionRef.String(), "", requestPrivilege) } -func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, imageID, tag string, requestPrivilege lib.RequestPrivilegeFunc) error { +func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, imageID, tag string, requestPrivilege client.RequestPrivilegeFunc) error { encodedAuth, err := encodeAuthToBase64(authConfig) if err != nil { diff --git a/components/engine/api/client/push.go b/components/engine/api/client/push.go index cc78c3c5b3..bbfbaf5fea 100644 --- a/components/engine/api/client/push.go +++ b/components/engine/api/client/push.go @@ -4,13 +4,13 @@ import ( "errors" "io" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" "github.com/docker/docker/pkg/jsonmessage" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" ) // CmdPush pushes an image or repository to the registry. @@ -52,7 +52,7 @@ func (cli *DockerCli) CmdPush(args ...string) error { return cli.imagePushPrivileged(authConfig, ref.Name(), tag, cli.out, requestPrivilege) } -func (cli *DockerCli) imagePushPrivileged(authConfig types.AuthConfig, imageID, tag string, outputStream io.Writer, requestPrivilege lib.RequestPrivilegeFunc) error { +func (cli *DockerCli) imagePushPrivileged(authConfig types.AuthConfig, imageID, tag string, outputStream io.Writer, requestPrivilege client.RequestPrivilegeFunc) error { encodedAuth, err := encodeAuthToBase64(authConfig) if err != nil { return err diff --git a/components/engine/api/client/rm.go b/components/engine/api/client/rm.go index b26cb53d02..39d22f669c 100644 --- a/components/engine/api/client/rm.go +++ b/components/engine/api/client/rm.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" ) // CmdRm removes one or more containers. diff --git a/components/engine/api/client/rmi.go b/components/engine/api/client/rmi.go index 9569370ea2..c5593d6d04 100644 --- a/components/engine/api/client/rmi.go +++ b/components/engine/api/client/rmi.go @@ -4,9 +4,9 @@ import ( "fmt" "net/url" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" ) // CmdRmi removes all images with the specified name(s). diff --git a/components/engine/api/client/run.go b/components/engine/api/client/run.go index 0a7f5265ca..3eea9dc667 100644 --- a/components/engine/api/client/run.go +++ b/components/engine/api/client/run.go @@ -8,13 +8,13 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" derr "github.com/docker/docker/errors" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" runconfigopts "github.com/docker/docker/runconfig/opts" + "github.com/docker/engine-api/types" "github.com/docker/libnetwork/resolvconf/dns" ) diff --git a/components/engine/api/client/search.go b/components/engine/api/client/search.go index d627ef653d..64bbb67ea7 100644 --- a/components/engine/api/client/search.go +++ b/components/engine/api/client/search.go @@ -7,12 +7,12 @@ import ( "strings" "text/tabwriter" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/stringutils" "github.com/docker/docker/registry" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) // CmdSearch searches the Docker Hub for images. diff --git a/components/engine/api/client/start.go b/components/engine/api/client/start.go index fcfa3f366d..3a2bc12636 100644 --- a/components/engine/api/client/start.go +++ b/components/engine/api/client/start.go @@ -7,11 +7,11 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" + "github.com/docker/engine-api/types" ) func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal { diff --git a/components/engine/api/client/stats.go b/components/engine/api/client/stats.go index 968d17eab4..46f4c04b9f 100644 --- a/components/engine/api/client/stats.go +++ b/components/engine/api/client/stats.go @@ -10,10 +10,10 @@ import ( "text/tabwriter" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" Cli "github.com/docker/docker/cli" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/events" + "github.com/docker/engine-api/types/filters" "github.com/docker/go-units" ) diff --git a/components/engine/api/client/stats_unit_test.go b/components/engine/api/client/stats_unit_test.go index 301e0a6782..ce1c3a1741 100644 --- a/components/engine/api/client/stats_unit_test.go +++ b/components/engine/api/client/stats_unit_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) func TestDisplay(t *testing.T) { diff --git a/components/engine/api/client/tag.go b/components/engine/api/client/tag.go index a1492666d0..5a824714bd 100644 --- a/components/engine/api/client/tag.go +++ b/components/engine/api/client/tag.go @@ -3,10 +3,10 @@ package client import ( "errors" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" ) // CmdTag tags an image into a repository. diff --git a/components/engine/api/client/trust.go b/components/engine/api/client/trust.go index cc93ebae00..31f47e468c 100644 --- a/components/engine/api/client/trust.go +++ b/components/engine/api/client/trust.go @@ -21,15 +21,15 @@ import ( "github.com/docker/distribution/digest" "github.com/docker/distribution/registry/client/auth" "github.com/docker/distribution/registry/client/transport" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/cliconfig" "github.com/docker/docker/pkg/ansiescape" "github.com/docker/docker/pkg/ioutils" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + apiclient "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" "github.com/docker/go-connections/tlsconfig" "github.com/docker/notary/client" "github.com/docker/notary/passphrase" @@ -280,7 +280,7 @@ func notaryError(err error) error { return err } -func (cli *DockerCli) trustedPull(repoInfo *registry.RepositoryInfo, ref registry.Reference, authConfig types.AuthConfig, requestPrivilege lib.RequestPrivilegeFunc) error { +func (cli *DockerCli) trustedPull(repoInfo *registry.RepositoryInfo, ref registry.Reference, authConfig types.AuthConfig, requestPrivilege apiclient.RequestPrivilegeFunc) error { var refs []target notaryRepo, err := cli.getNotaryRepository(repoInfo, authConfig) @@ -383,7 +383,7 @@ func targetStream(in io.Writer) (io.WriteCloser, <-chan []target) { return ioutils.NewWriteCloserWrapper(out, w.Close), targetChan } -func (cli *DockerCli) trustedPush(repoInfo *registry.RepositoryInfo, tag string, authConfig types.AuthConfig, requestPrivilege lib.RequestPrivilegeFunc) error { +func (cli *DockerCli) trustedPush(repoInfo *registry.RepositoryInfo, tag string, authConfig types.AuthConfig, requestPrivilege apiclient.RequestPrivilegeFunc) error { streamOut, targetChan := targetStream(cli.out) reqError := cli.imagePushPrivileged(authConfig, repoInfo.Name(), tag, streamOut, requestPrivilege) diff --git a/components/engine/api/client/trust_test.go b/components/engine/api/client/trust_test.go index 86f9e61e4d..ec95bd9d35 100644 --- a/components/engine/api/client/trust_test.go +++ b/components/engine/api/client/trust_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/registry" + registrytypes "github.com/docker/engine-api/types/registry" ) func unsetENV() { diff --git a/components/engine/api/client/update.go b/components/engine/api/client/update.go index 3f71171264..d1e1fd3254 100644 --- a/components/engine/api/client/update.go +++ b/components/engine/api/client/update.go @@ -3,9 +3,9 @@ package client import ( "fmt" - "github.com/docker/docker/api/types/container" Cli "github.com/docker/docker/cli" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types/container" "github.com/docker/go-units" ) diff --git a/components/engine/api/client/utils.go b/components/engine/api/client/utils.go index af58728866..687add5bc2 100644 --- a/components/engine/api/client/utils.go +++ b/components/engine/api/client/utils.go @@ -10,12 +10,12 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client/lib" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/term" "github.com/docker/docker/registry" + "github.com/docker/engine-api/client" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) // encodeAuthToBase64 serializes the auth configuration as JSON base64 payload @@ -32,7 +32,7 @@ func (cli *DockerCli) encodeRegistryAuth(index *registrytypes.IndexInfo) (string return encodeAuthToBase64(authConfig) } -func (cli *DockerCli) registryAuthenticationPrivilegedFunc(index *registrytypes.IndexInfo, cmdName string) lib.RequestPrivilegeFunc { +func (cli *DockerCli) registryAuthenticationPrivilegedFunc(index *registrytypes.IndexInfo, cmdName string) client.RequestPrivilegeFunc { return func() (string, error) { fmt.Fprintf(cli.out, "\nPlease login prior to %s:\n", cmdName) if err := cli.CmdLogin(registry.GetAuthConfigKey(index)); err != nil { @@ -72,7 +72,7 @@ func getExitCode(cli *DockerCli, containerID string) (bool, int, error) { c, err := cli.client.ContainerInspect(containerID) if err != nil { // If we can't connect, then the daemon probably died. - if err != lib.ErrConnectionFailed { + if err != client.ErrConnectionFailed { return false, -1, err } return false, -1, nil @@ -87,7 +87,7 @@ func getExecExitCode(cli *DockerCli, execID string) (bool, int, error) { resp, err := cli.client.ContainerExecInspect(execID) if err != nil { // If we can't connect, then the daemon probably died. - if err != lib.ErrConnectionFailed { + if err != client.ErrConnectionFailed { return false, -1, err } return false, -1, nil diff --git a/components/engine/api/client/version.go b/components/engine/api/client/version.go index 83ba89660b..a64deef69a 100644 --- a/components/engine/api/client/version.go +++ b/components/engine/api/client/version.go @@ -5,11 +5,11 @@ import ( "text/template" "time" - "github.com/docker/docker/api/types" Cli "github.com/docker/docker/cli" "github.com/docker/docker/dockerversion" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/utils" + "github.com/docker/engine-api/types" ) var versionTemplate = `Client: diff --git a/components/engine/api/client/volume.go b/components/engine/api/client/volume.go index 53ad3da780..284e30c3cb 100644 --- a/components/engine/api/client/volume.go +++ b/components/engine/api/client/volume.go @@ -4,11 +4,11 @@ import ( "fmt" "text/tabwriter" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" Cli "github.com/docker/docker/cli" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) // CmdVolume is the parent subcommand for all volume commands diff --git a/components/engine/api/common.go b/components/engine/api/common.go index ca7f0dc869..96064a83a1 100644 --- a/components/engine/api/common.go +++ b/components/engine/api/common.go @@ -9,9 +9,9 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/version" + "github.com/docker/engine-api/types" "github.com/docker/libtrust" ) diff --git a/components/engine/api/common_test.go b/components/engine/api/common_test.go index a513c75212..4f36b45471 100644 --- a/components/engine/api/common_test.go +++ b/components/engine/api/common_test.go @@ -7,7 +7,7 @@ import ( "os" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) type ports struct { diff --git a/components/engine/api/server/router/build/build_routes.go b/components/engine/api/server/router/build/build_routes.go index 0fec49586b..2962d87f35 100644 --- a/components/engine/api/server/router/build/build_routes.go +++ b/components/engine/api/server/router/build/build_routes.go @@ -13,8 +13,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder" "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/daemon/daemonbuilder" @@ -25,6 +23,8 @@ import ( "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/reference" "github.com/docker/docker/utils" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" "github.com/docker/go-units" "golang.org/x/net/context" ) diff --git a/components/engine/api/server/router/container/backend.go b/components/engine/api/server/router/container/backend.go index cdb50bca81..80bed6442e 100644 --- a/components/engine/api/server/router/container/backend.go +++ b/components/engine/api/server/router/container/backend.go @@ -4,12 +4,12 @@ import ( "io" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/version" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) // execBackend includes functions to implement to provide exec functionality. diff --git a/components/engine/api/server/router/container/container_routes.go b/components/engine/api/server/router/container/container_routes.go index 5fde786697..8a7de24fe1 100644 --- a/components/engine/api/server/router/container/container_routes.go +++ b/components/engine/api/server/router/container/container_routes.go @@ -12,9 +12,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/distribution/registry/api/errcode" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - timetypes "github.com/docker/docker/api/types/time" "github.com/docker/docker/daemon" derr "github.com/docker/docker/errors" "github.com/docker/docker/pkg/ioutils" @@ -22,6 +19,9 @@ import ( "github.com/docker/docker/pkg/term" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" + timetypes "github.com/docker/engine-api/types/time" "golang.org/x/net/context" "golang.org/x/net/websocket" ) diff --git a/components/engine/api/server/router/container/copy.go b/components/engine/api/server/router/container/copy.go index 4f04f94a3c..69584b31f5 100644 --- a/components/engine/api/server/router/container/copy.go +++ b/components/engine/api/server/router/container/copy.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" "golang.org/x/net/context" ) diff --git a/components/engine/api/server/router/container/exec.go b/components/engine/api/server/router/container/exec.go index b2735638c8..caa5da061d 100644 --- a/components/engine/api/server/router/container/exec.go +++ b/components/engine/api/server/router/container/exec.go @@ -9,9 +9,9 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/utils" + "github.com/docker/engine-api/types" "golang.org/x/net/context" ) diff --git a/components/engine/api/server/router/local/image.go b/components/engine/api/server/router/local/image.go index 450c6dd65e..b43c8ddc2f 100644 --- a/components/engine/api/server/router/local/image.go +++ b/components/engine/api/server/router/local/image.go @@ -11,14 +11,14 @@ import ( "github.com/docker/distribution/digest" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder/dockerfile" derr "github.com/docker/docker/errors" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/reference" "github.com/docker/docker/runconfig" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" "golang.org/x/net/context" ) diff --git a/components/engine/api/server/router/network/backend.go b/components/engine/api/server/router/network/backend.go index c3d6101db6..9b62e0c33f 100644 --- a/components/engine/api/server/router/network/backend.go +++ b/components/engine/api/server/router/network/backend.go @@ -1,7 +1,7 @@ package network import ( - "github.com/docker/docker/api/types/network" + "github.com/docker/engine-api/types/network" "github.com/docker/libnetwork" ) diff --git a/components/engine/api/server/router/network/filter.go b/components/engine/api/server/router/network/filter.go index 58bdb10449..31d8d0c521 100644 --- a/components/engine/api/server/router/network/filter.go +++ b/components/engine/api/server/router/network/filter.go @@ -5,8 +5,8 @@ import ( "regexp" "strings" - "github.com/docker/docker/api/types/filters" "github.com/docker/docker/runconfig" + "github.com/docker/engine-api/types/filters" "github.com/docker/libnetwork" ) diff --git a/components/engine/api/server/router/network/network_routes.go b/components/engine/api/server/router/network/network_routes.go index 86ef6854c1..7ba59bd474 100644 --- a/components/engine/api/server/router/network/network_routes.go +++ b/components/engine/api/server/router/network/network_routes.go @@ -8,11 +8,11 @@ import ( "golang.org/x/net/context" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" "github.com/docker/docker/daemon" "github.com/docker/docker/runconfig" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" + "github.com/docker/engine-api/types/network" "github.com/docker/libnetwork" ) diff --git a/components/engine/api/server/router/system/backend.go b/components/engine/api/server/router/system/backend.go index bc218087d9..8a270027ff 100644 --- a/components/engine/api/server/router/system/backend.go +++ b/components/engine/api/server/router/system/backend.go @@ -1,9 +1,9 @@ package system import ( - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/events" + "github.com/docker/engine-api/types/filters" ) // Backend is the methods that need to be implemented to provide diff --git a/components/engine/api/server/router/system/system_routes.go b/components/engine/api/server/router/system/system_routes.go index afd60a0042..40ec748a88 100644 --- a/components/engine/api/server/router/system/system_routes.go +++ b/components/engine/api/server/router/system/system_routes.go @@ -8,11 +8,11 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" - timetypes "github.com/docker/docker/api/types/time" "github.com/docker/docker/pkg/ioutils" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/events" + "github.com/docker/engine-api/types/filters" + timetypes "github.com/docker/engine-api/types/time" "golang.org/x/net/context" ) diff --git a/components/engine/api/server/router/volume/backend.go b/components/engine/api/server/router/volume/backend.go index 0c09b073e2..ede5dc4d91 100644 --- a/components/engine/api/server/router/volume/backend.go +++ b/components/engine/api/server/router/volume/backend.go @@ -2,7 +2,7 @@ package volume import ( // TODO return types need to be refactored into pkg - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" ) // Backend is the methods that need to be implemented to provide diff --git a/components/engine/api/server/router/volume/volume_routes.go b/components/engine/api/server/router/volume/volume_routes.go index 882de3a60b..feef77cb57 100644 --- a/components/engine/api/server/router/volume/volume_routes.go +++ b/components/engine/api/server/router/volume/volume_routes.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/docker/docker/api/server/httputils" - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" "golang.org/x/net/context" ) diff --git a/components/engine/api/types/client.go b/components/engine/api/types/client.go index c936235173..77d94f33a1 100644 --- a/components/engine/api/types/client.go +++ b/components/engine/api/types/client.go @@ -5,8 +5,8 @@ import ( "io" "net" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/filters" "github.com/docker/go-units" ) diff --git a/components/engine/api/types/configs.go b/components/engine/api/types/configs.go index 43ea4c10a5..fafbb5b53e 100644 --- a/components/engine/api/types/configs.go +++ b/components/engine/api/types/configs.go @@ -1,6 +1,6 @@ package types -import "github.com/docker/docker/api/types/container" +import "github.com/docker/engine-api/types/container" // configs holds structs used for internal communication between the // frontend (such as an http server) and the backend (such as the diff --git a/components/engine/api/types/container/config.go b/components/engine/api/types/container/config.go index 5459b5dbaf..b4e6205d21 100644 --- a/components/engine/api/types/container/config.go +++ b/components/engine/api/types/container/config.go @@ -1,7 +1,7 @@ package container import ( - "github.com/docker/docker/api/types/strslice" + "github.com/docker/engine-api/types/strslice" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/api/types/container/host_config.go b/components/engine/api/types/container/host_config.go index 623e5d108f..ac425921b8 100644 --- a/components/engine/api/types/container/host_config.go +++ b/components/engine/api/types/container/host_config.go @@ -3,8 +3,8 @@ package container import ( "strings" - "github.com/docker/docker/api/types/blkiodev" - "github.com/docker/docker/api/types/strslice" + "github.com/docker/engine-api/types/blkiodev" + "github.com/docker/engine-api/types/strslice" "github.com/docker/go-connections/nat" "github.com/docker/go-units" ) diff --git a/components/engine/api/types/types.go b/components/engine/api/types/types.go index 80780ca9b0..5f9e018998 100644 --- a/components/engine/api/types/types.go +++ b/components/engine/api/types/types.go @@ -4,9 +4,9 @@ import ( "os" "time" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/registry" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/network" + "github.com/docker/engine-api/types/registry" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/api/types/versions/v1p19/types.go b/components/engine/api/types/versions/v1p19/types.go index dc13150545..4ed4335881 100644 --- a/components/engine/api/types/versions/v1p19/types.go +++ b/components/engine/api/types/versions/v1p19/types.go @@ -2,9 +2,9 @@ package v1p19 import ( - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/versions/v1p20" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/versions/v1p20" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/api/types/versions/v1p20/types.go b/components/engine/api/types/versions/v1p20/types.go index fa395ac1f6..ed800061fa 100644 --- a/components/engine/api/types/versions/v1p20/types.go +++ b/components/engine/api/types/versions/v1p20/types.go @@ -2,8 +2,8 @@ package v1p20 import ( - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/builder/builder.go b/components/engine/builder/builder.go index 90ab204f8e..0defa613dc 100644 --- a/components/engine/builder/builder.go +++ b/components/engine/builder/builder.go @@ -9,8 +9,8 @@ import ( "os" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) // Context represents a file system tree. diff --git a/components/engine/builder/dockerfile/builder.go b/components/engine/builder/dockerfile/builder.go index 8951793bff..70d3db01df 100644 --- a/components/engine/builder/dockerfile/builder.go +++ b/components/engine/builder/dockerfile/builder.go @@ -10,11 +10,11 @@ import ( "sync" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/pkg/stringid" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) var validCommitCommands = map[string]bool{ diff --git a/components/engine/builder/dockerfile/dispatchers.go b/components/engine/builder/dockerfile/dispatchers.go index 53e6322bfb..ea674edc5c 100644 --- a/components/engine/builder/dockerfile/dispatchers.go +++ b/components/engine/builder/dockerfile/dispatchers.go @@ -18,13 +18,13 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/builder" derr "github.com/docker/docker/errors" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/system" runconfigopts "github.com/docker/docker/runconfig/opts" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/strslice" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/builder/dockerfile/internals.go b/components/engine/builder/dockerfile/internals.go index 24c9087eae..bf5880f093 100644 --- a/components/engine/builder/dockerfile/internals.go +++ b/components/engine/builder/dockerfile/internals.go @@ -20,9 +20,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/builder" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/pkg/archive" @@ -36,6 +33,9 @@ import ( "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/pkg/urlutil" "github.com/docker/docker/runconfig/opts" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/strslice" ) func (b *Builder) commit(id string, autoCmd *strslice.StrSlice, comment string) error { diff --git a/components/engine/builder/image.go b/components/engine/builder/image.go index 4de620fae6..2e545cfa9d 100644 --- a/components/engine/builder/image.go +++ b/components/engine/builder/image.go @@ -1,6 +1,6 @@ package builder -import "github.com/docker/docker/api/types/container" +import "github.com/docker/engine-api/types/container" // Image represents a Docker image used by the builder. type Image interface { diff --git a/components/engine/cliconfig/config.go b/components/engine/cliconfig/config.go index 7e657ecbd2..f5b2be8a40 100644 --- a/components/engine/cliconfig/config.go +++ b/components/engine/cliconfig/config.go @@ -10,8 +10,8 @@ import ( "path/filepath" "strings" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/homedir" + "github.com/docker/engine-api/types" ) const ( diff --git a/components/engine/cliconfig/config_test.go b/components/engine/cliconfig/config_test.go index 147f5adbd6..17f9fd673b 100644 --- a/components/engine/cliconfig/config_test.go +++ b/components/engine/cliconfig/config_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/homedir" + "github.com/docker/engine-api/types" ) func TestEmptyConfigDir(t *testing.T) { diff --git a/components/engine/container/archive.go b/components/engine/container/archive.go index a7dd87fb84..95b6828575 100644 --- a/components/engine/container/archive.go +++ b/components/engine/container/archive.go @@ -4,8 +4,8 @@ import ( "os" "path/filepath" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/archive" + "github.com/docker/engine-api/types" ) // ResolvePath resolves the given path in the container to a resource on the diff --git a/components/engine/container/container.go b/components/engine/container/container.go index a4ae82cf20..9974a70725 100644 --- a/components/engine/container/container.go +++ b/components/engine/container/container.go @@ -11,7 +11,6 @@ import ( "time" "github.com/Sirupsen/logrus" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/logger" @@ -25,6 +24,7 @@ import ( "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/runconfig" "github.com/docker/docker/volume" + containertypes "github.com/docker/engine-api/types/container" "github.com/docker/go-connections/nat" "github.com/opencontainers/runc/libcontainer/label" ) diff --git a/components/engine/container/container_unit_test.go b/components/engine/container/container_unit_test.go index f14dc12e97..67b829f9f9 100644 --- a/components/engine/container/container_unit_test.go +++ b/components/engine/container/container_unit_test.go @@ -3,8 +3,8 @@ package container import ( "testing" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/signal" + "github.com/docker/engine-api/types/container" ) func TestContainerStopSignal(t *testing.T) { diff --git a/components/engine/container/container_unix.go b/components/engine/container/container_unix.go index c9afcaa0c0..361c77c15b 100644 --- a/components/engine/container/container_unix.go +++ b/components/engine/container/container_unix.go @@ -13,8 +13,6 @@ import ( "syscall" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" "github.com/docker/docker/daemon/execdriver" derr "github.com/docker/docker/errors" "github.com/docker/docker/pkg/chrootarchive" @@ -22,6 +20,8 @@ import ( "github.com/docker/docker/pkg/system" "github.com/docker/docker/utils" "github.com/docker/docker/volume" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/network" "github.com/docker/go-connections/nat" "github.com/docker/libnetwork" "github.com/docker/libnetwork/netlabel" diff --git a/components/engine/container/container_windows.go b/components/engine/container/container_windows.go index cd8134472f..af68086f8d 100644 --- a/components/engine/container/container_windows.go +++ b/components/engine/container/container_windows.go @@ -3,9 +3,9 @@ package container import ( - "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/volume" + "github.com/docker/engine-api/types/container" ) // Container holds fields specific to the Windows implementation. See diff --git a/components/engine/container/monitor.go b/components/engine/container/monitor.go index 8098f23bae..c866542118 100644 --- a/components/engine/container/monitor.go +++ b/components/engine/container/monitor.go @@ -9,12 +9,12 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon/execdriver" derr "github.com/docker/docker/errors" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/utils" + "github.com/docker/engine-api/types/container" ) const ( diff --git a/components/engine/daemon/archive.go b/components/engine/daemon/archive.go index 1c3cec0e9d..4ac667d261 100644 --- a/components/engine/daemon/archive.go +++ b/components/engine/daemon/archive.go @@ -7,11 +7,11 @@ import ( "path/filepath" "strings" - "github.com/docker/docker/api/types" "github.com/docker/docker/container" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/ioutils" + "github.com/docker/engine-api/types" ) // ErrExtractPointNotDirectory is used to convey that the operation to extract diff --git a/components/engine/daemon/commit.go b/components/engine/daemon/commit.go index d8495ac65e..d0c4924e8e 100644 --- a/components/engine/daemon/commit.go +++ b/components/engine/daemon/commit.go @@ -7,8 +7,6 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/dockerversion" "github.com/docker/docker/image" @@ -16,6 +14,8 @@ import ( "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" + containertypes "github.com/docker/engine-api/types/container" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/daemon/config.go b/components/engine/daemon/config.go index b6477a6f33..8e46713bc9 100644 --- a/components/engine/daemon/config.go +++ b/components/engine/daemon/config.go @@ -1,9 +1,9 @@ package daemon import ( - "github.com/docker/docker/api/types/container" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" + "github.com/docker/engine-api/types/container" ) const ( diff --git a/components/engine/daemon/container_operations_unix.go b/components/engine/daemon/container_operations_unix.go index fceb2da42c..6820d4b155 100644 --- a/components/engine/daemon/container_operations_unix.go +++ b/components/engine/daemon/container_operations_unix.go @@ -13,8 +13,6 @@ import ( "time" "github.com/Sirupsen/logrus" - containertypes "github.com/docker/docker/api/types/container" - networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/container" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/links" @@ -25,6 +23,8 @@ import ( "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/runconfig" + containertypes "github.com/docker/engine-api/types/container" + networktypes "github.com/docker/engine-api/types/network" "github.com/docker/go-units" "github.com/docker/libnetwork" "github.com/docker/libnetwork/netlabel" diff --git a/components/engine/daemon/create.go b/components/engine/daemon/create.go index 7456a99797..12e9449320 100644 --- a/components/engine/daemon/create.go +++ b/components/engine/daemon/create.go @@ -2,8 +2,6 @@ package daemon import ( "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" derr "github.com/docker/docker/errors" "github.com/docker/docker/image" @@ -11,6 +9,8 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/stringid" volumestore "github.com/docker/docker/volume/store" + "github.com/docker/engine-api/types" + containertypes "github.com/docker/engine-api/types/container" "github.com/opencontainers/runc/libcontainer/label" ) diff --git a/components/engine/daemon/create_unix.go b/components/engine/daemon/create_unix.go index 865400cacc..0f2f4d0270 100644 --- a/components/engine/daemon/create_unix.go +++ b/components/engine/daemon/create_unix.go @@ -6,12 +6,12 @@ import ( "os" "path/filepath" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" derr "github.com/docker/docker/errors" "github.com/docker/docker/image" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/volume" + containertypes "github.com/docker/engine-api/types/container" "github.com/opencontainers/runc/libcontainer/label" ) diff --git a/components/engine/daemon/create_windows.go b/components/engine/daemon/create_windows.go index 6e6ec9c12e..54b0ab6ab7 100644 --- a/components/engine/daemon/create_windows.go +++ b/components/engine/daemon/create_windows.go @@ -3,11 +3,11 @@ package daemon import ( "fmt" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/image" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/volume" + containertypes "github.com/docker/engine-api/types/container" ) // createContainerPlatformSpecificSettings performs platform specific container create functionality diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go index 849a97b9df..b23543a52a 100644 --- a/components/engine/daemon/daemon.go +++ b/components/engine/daemon/daemon.go @@ -22,17 +22,17 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" - eventtypes "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" - registrytypes "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/container" "github.com/docker/docker/daemon/events" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/execdriver/execdrivers" + "github.com/docker/engine-api/types" + containertypes "github.com/docker/engine-api/types/container" + eventtypes "github.com/docker/engine-api/types/events" + "github.com/docker/engine-api/types/filters" + registrytypes "github.com/docker/engine-api/types/registry" + "github.com/docker/engine-api/types/strslice" // register graph drivers _ "github.com/docker/docker/daemon/graphdriver/register" "github.com/docker/docker/daemon/logger" diff --git a/components/engine/daemon/daemon_experimental.go b/components/engine/daemon/daemon_experimental.go index 9ff05271a1..cc3852c853 100644 --- a/components/engine/daemon/daemon_experimental.go +++ b/components/engine/daemon/daemon_experimental.go @@ -9,8 +9,8 @@ import ( "runtime" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/idtools" + "github.com/docker/engine-api/types/container" ) func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error) { diff --git a/components/engine/daemon/daemon_stub.go b/components/engine/daemon/daemon_stub.go index 20b2263071..d60f063847 100644 --- a/components/engine/daemon/daemon_stub.go +++ b/components/engine/daemon/daemon_stub.go @@ -5,9 +5,9 @@ package daemon import ( "os" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/system" + "github.com/docker/engine-api/types/container" ) func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error) { diff --git a/components/engine/daemon/daemon_test.go b/components/engine/daemon/daemon_test.go index a46712b47a..0d927f76ae 100644 --- a/components/engine/daemon/daemon_test.go +++ b/components/engine/daemon/daemon_test.go @@ -7,7 +7,6 @@ import ( "path/filepath" "testing" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/pkg/graphdb" "github.com/docker/docker/pkg/truncindex" @@ -15,6 +14,7 @@ import ( volumedrivers "github.com/docker/docker/volume/drivers" "github.com/docker/docker/volume/local" "github.com/docker/docker/volume/store" + containertypes "github.com/docker/engine-api/types/container" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/daemon/daemon_unix.go b/components/engine/daemon/daemon_unix.go index 5186b29107..78ca7595ac 100644 --- a/components/engine/daemon/daemon_unix.go +++ b/components/engine/daemon/daemon_unix.go @@ -12,8 +12,6 @@ import ( "syscall" "github.com/Sirupsen/logrus" - pblkiodev "github.com/docker/docker/api/types/blkiodev" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" derr "github.com/docker/docker/errors" "github.com/docker/docker/image" @@ -24,6 +22,8 @@ import ( "github.com/docker/docker/reference" "github.com/docker/docker/runconfig" runconfigopts "github.com/docker/docker/runconfig/opts" + pblkiodev "github.com/docker/engine-api/types/blkiodev" + containertypes "github.com/docker/engine-api/types/container" "github.com/docker/libnetwork" nwconfig "github.com/docker/libnetwork/config" "github.com/docker/libnetwork/drivers/bridge" diff --git a/components/engine/daemon/daemon_unix_test.go b/components/engine/daemon/daemon_unix_test.go index 083b2bd45b..8a99b4b884 100644 --- a/components/engine/daemon/daemon_unix_test.go +++ b/components/engine/daemon/daemon_unix_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) func TestAdjustCPUShares(t *testing.T) { diff --git a/components/engine/daemon/daemon_windows.go b/components/engine/daemon/daemon_windows.go index a85f14c7e4..1e36892e01 100644 --- a/components/engine/daemon/daemon_windows.go +++ b/components/engine/daemon/daemon_windows.go @@ -9,13 +9,13 @@ import ( "strings" "github.com/Sirupsen/logrus" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/dockerversion" "github.com/docker/docker/image" "github.com/docker/docker/layer" "github.com/docker/docker/reference" + containertypes "github.com/docker/engine-api/types/container" // register the windows graph driver "github.com/docker/docker/daemon/graphdriver/windows" "github.com/docker/docker/pkg/system" diff --git a/components/engine/daemon/daemonbuilder/builder.go b/components/engine/daemon/daemonbuilder/builder.go index e286508604..fba6039091 100644 --- a/components/engine/daemon/daemonbuilder/builder.go +++ b/components/engine/daemon/daemonbuilder/builder.go @@ -10,8 +10,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder" "github.com/docker/docker/daemon" "github.com/docker/docker/image" @@ -22,6 +20,8 @@ import ( "github.com/docker/docker/pkg/urlutil" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" ) // Docker implements builder.Backend for the docker Daemon object. diff --git a/components/engine/daemon/daemonbuilder/image.go b/components/engine/daemon/daemonbuilder/image.go index 34dbe3007c..0683a08275 100644 --- a/components/engine/daemon/daemonbuilder/image.go +++ b/components/engine/daemon/daemonbuilder/image.go @@ -1,8 +1,8 @@ package daemonbuilder import ( - "github.com/docker/docker/api/types/container" "github.com/docker/docker/image" + "github.com/docker/engine-api/types/container" ) type imgWrap struct { diff --git a/components/engine/daemon/delete.go b/components/engine/daemon/delete.go index c513cd8ddd..af9903f508 100644 --- a/components/engine/daemon/delete.go +++ b/components/engine/daemon/delete.go @@ -5,11 +5,11 @@ import ( "path" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" "github.com/docker/docker/container" derr "github.com/docker/docker/errors" "github.com/docker/docker/layer" volumestore "github.com/docker/docker/volume/store" + "github.com/docker/engine-api/types" ) // ContainerRm removes the container id from the filesystem. An error diff --git a/components/engine/daemon/delete_test.go b/components/engine/daemon/delete_test.go index 487bb5d4e3..e0e6466a9c 100644 --- a/components/engine/daemon/delete_test.go +++ b/components/engine/daemon/delete_test.go @@ -5,9 +5,9 @@ import ( "os" "testing" - "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" + "github.com/docker/engine-api/types" + containertypes "github.com/docker/engine-api/types/container" ) func TestContainerDoubleDelete(t *testing.T) { diff --git a/components/engine/daemon/events.go b/components/engine/daemon/events.go index 3211679c10..825ce8a0d1 100644 --- a/components/engine/daemon/events.go +++ b/components/engine/daemon/events.go @@ -3,8 +3,8 @@ package daemon import ( "strings" - "github.com/docker/docker/api/types/events" "github.com/docker/docker/container" + "github.com/docker/engine-api/types/events" "github.com/docker/libnetwork" ) diff --git a/components/engine/daemon/events/events.go b/components/engine/daemon/events/events.go index 6f44e7c500..a8cd66fd99 100644 --- a/components/engine/daemon/events/events.go +++ b/components/engine/daemon/events/events.go @@ -4,8 +4,8 @@ import ( "sync" "time" - eventtypes "github.com/docker/docker/api/types/events" "github.com/docker/docker/pkg/pubsub" + eventtypes "github.com/docker/engine-api/types/events" ) const ( diff --git a/components/engine/daemon/events/events_test.go b/components/engine/daemon/events/events_test.go index a782636370..fc3b84bb85 100644 --- a/components/engine/daemon/events/events_test.go +++ b/components/engine/daemon/events/events_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types/events" + "github.com/docker/engine-api/types/events" ) func TestEventsLog(t *testing.T) { diff --git a/components/engine/daemon/events/filter.go b/components/engine/daemon/events/filter.go index fc4fa7aae1..8936e371d2 100644 --- a/components/engine/daemon/events/filter.go +++ b/components/engine/daemon/events/filter.go @@ -1,9 +1,9 @@ package events import ( - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types/events" + "github.com/docker/engine-api/types/filters" ) // Filter can filter out docker events from a stream diff --git a/components/engine/daemon/events_test.go b/components/engine/daemon/events_test.go index 7035ebd06b..acc285ed60 100644 --- a/components/engine/daemon/events_test.go +++ b/components/engine/daemon/events_test.go @@ -3,9 +3,9 @@ package daemon import ( "testing" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/events" + containertypes "github.com/docker/engine-api/types/container" ) func TestLogContainerCopyLabels(t *testing.T) { diff --git a/components/engine/daemon/exec.go b/components/engine/daemon/exec.go index fb40941821..464dd5db66 100644 --- a/components/engine/daemon/exec.go +++ b/components/engine/daemon/exec.go @@ -6,8 +6,6 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/container" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/execdriver" @@ -15,6 +13,8 @@ import ( "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/term" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/strslice" ) func (d *Daemon) registerExecCommand(container *container.Container, config *exec.Config) { diff --git a/components/engine/daemon/exec_unix.go b/components/engine/daemon/exec_unix.go index 40bd2c8ab8..754f73138a 100644 --- a/components/engine/daemon/exec_unix.go +++ b/components/engine/daemon/exec_unix.go @@ -3,9 +3,9 @@ package daemon import ( - "github.com/docker/docker/api/types" "github.com/docker/docker/container" "github.com/docker/docker/daemon/execdriver" + "github.com/docker/engine-api/types" ) // setPlatformSpecificExecProcessConfig sets platform-specific fields in the diff --git a/components/engine/daemon/exec_windows.go b/components/engine/daemon/exec_windows.go index f1b93bf02a..09efa82a2e 100644 --- a/components/engine/daemon/exec_windows.go +++ b/components/engine/daemon/exec_windows.go @@ -1,9 +1,9 @@ package daemon import ( - "github.com/docker/docker/api/types" "github.com/docker/docker/container" "github.com/docker/docker/daemon/execdriver" + "github.com/docker/engine-api/types" ) // setPlatformSpecificExecProcessConfig sets platform-specific fields in the diff --git a/components/engine/daemon/execdriver/windows/info.go b/components/engine/daemon/execdriver/windows/info.go index 5a92f5d6dc..5e26e879c4 100644 --- a/components/engine/daemon/execdriver/windows/info.go +++ b/components/engine/daemon/execdriver/windows/info.go @@ -3,8 +3,8 @@ package windows import ( - "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon/execdriver" + "github.com/docker/engine-api/types/container" ) type info struct { diff --git a/components/engine/daemon/execdriver/windows/windows.go b/components/engine/daemon/execdriver/windows/windows.go index 810f452ed5..03949ad5a6 100644 --- a/components/engine/daemon/execdriver/windows/windows.go +++ b/components/engine/daemon/execdriver/windows/windows.go @@ -8,10 +8,10 @@ import ( "sync" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/parsers" + "github.com/docker/engine-api/types/container" ) // This is a daemon development variable only and should not be diff --git a/components/engine/daemon/image_delete.go b/components/engine/daemon/image_delete.go index b2aacfb606..5de9f55859 100644 --- a/components/engine/daemon/image_delete.go +++ b/components/engine/daemon/image_delete.go @@ -4,12 +4,12 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/types" "github.com/docker/docker/container" derr "github.com/docker/docker/errors" "github.com/docker/docker/image" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" ) // ImageDelete deletes the image referenced by the given imageRef from this diff --git a/components/engine/daemon/images.go b/components/engine/daemon/images.go index a5ed6b18f3..2b2a994b1e 100644 --- a/components/engine/daemon/images.go +++ b/components/engine/daemon/images.go @@ -5,11 +5,11 @@ import ( "path" "sort" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" "github.com/docker/docker/image" "github.com/docker/docker/layer" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" ) var acceptedImageFilterTags = map[string]bool{ diff --git a/components/engine/daemon/import.go b/components/engine/daemon/import.go index 80d2146c23..c04e8a38f2 100644 --- a/components/engine/daemon/import.go +++ b/components/engine/daemon/import.go @@ -8,7 +8,6 @@ import ( "runtime" "time" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/dockerversion" "github.com/docker/docker/image" "github.com/docker/docker/layer" @@ -16,6 +15,7 @@ import ( "github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types/container" ) // ImportImage imports an image, getting the archived layer data either from diff --git a/components/engine/daemon/info.go b/components/engine/daemon/info.go index 83fe68fcb9..d060a14fdf 100644 --- a/components/engine/daemon/info.go +++ b/components/engine/daemon/info.go @@ -7,7 +7,6 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/parsers/kernel" @@ -18,6 +17,7 @@ import ( "github.com/docker/docker/registry" "github.com/docker/docker/utils" "github.com/docker/docker/volume/drivers" + "github.com/docker/engine-api/types" ) // SystemInfo returns information about the host server the daemon is running on. diff --git a/components/engine/daemon/inspect.go b/components/engine/daemon/inspect.go index b1e4eb43a7..098d43df5d 100644 --- a/components/engine/daemon/inspect.go +++ b/components/engine/daemon/inspect.go @@ -4,13 +4,13 @@ import ( "fmt" "time" - "github.com/docker/docker/api/types" - networktypes "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/container" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/network" "github.com/docker/docker/pkg/version" + "github.com/docker/engine-api/types" + networktypes "github.com/docker/engine-api/types/network" + "github.com/docker/engine-api/types/versions/v1p20" ) // ContainerInspect returns low-level information about a diff --git a/components/engine/daemon/inspect_unix.go b/components/engine/daemon/inspect_unix.go index 27aad9057c..b9321f34c3 100644 --- a/components/engine/daemon/inspect_unix.go +++ b/components/engine/daemon/inspect_unix.go @@ -3,9 +3,9 @@ package daemon import ( - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions/v1p19" "github.com/docker/docker/container" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/versions/v1p19" ) // This sets platform-specific fields diff --git a/components/engine/daemon/inspect_windows.go b/components/engine/daemon/inspect_windows.go index 330bc901dc..e42a61dadc 100644 --- a/components/engine/daemon/inspect_windows.go +++ b/components/engine/daemon/inspect_windows.go @@ -1,8 +1,8 @@ package daemon import ( - "github.com/docker/docker/api/types" "github.com/docker/docker/container" + "github.com/docker/engine-api/types" ) // This sets platform-specific fields diff --git a/components/engine/daemon/list.go b/components/engine/daemon/list.go index 2e9ff83310..c5765e387a 100644 --- a/components/engine/daemon/list.go +++ b/components/engine/daemon/list.go @@ -7,11 +7,11 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" "github.com/docker/docker/container" "github.com/docker/docker/image" "github.com/docker/docker/pkg/graphdb" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/daemon/network.go b/components/engine/daemon/network.go index a3282517de..4dba9a80e1 100644 --- a/components/engine/daemon/network.go +++ b/components/engine/daemon/network.go @@ -6,9 +6,9 @@ import ( "net" "strings" - "github.com/docker/docker/api/types/network" derr "github.com/docker/docker/errors" "github.com/docker/docker/runconfig" + "github.com/docker/engine-api/types/network" "github.com/docker/libnetwork" ) diff --git a/components/engine/daemon/network/settings.go b/components/engine/daemon/network/settings.go index 1bf4b5a672..823bec2696 100644 --- a/components/engine/daemon/network/settings.go +++ b/components/engine/daemon/network/settings.go @@ -1,7 +1,7 @@ package network import ( - networktypes "github.com/docker/docker/api/types/network" + networktypes "github.com/docker/engine-api/types/network" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/daemon/start.go b/components/engine/daemon/start.go index 54cb94884f..43734fc317 100644 --- a/components/engine/daemon/start.go +++ b/components/engine/daemon/start.go @@ -4,10 +4,10 @@ import ( "runtime" "github.com/Sirupsen/logrus" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" derr "github.com/docker/docker/errors" "github.com/docker/docker/runconfig" + containertypes "github.com/docker/engine-api/types/container" ) // ContainerStart starts a container. diff --git a/components/engine/daemon/stats.go b/components/engine/daemon/stats.go index e2b2420ca4..9812dce575 100644 --- a/components/engine/daemon/stats.go +++ b/components/engine/daemon/stats.go @@ -4,10 +4,10 @@ import ( "encoding/json" "io" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/pkg/version" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/versions/v1p20" ) // ContainerStatsConfig holds information for configuring the runtime diff --git a/components/engine/daemon/stats_freebsd.go b/components/engine/daemon/stats_freebsd.go index 1898ca9d40..44c330aab6 100644 --- a/components/engine/daemon/stats_freebsd.go +++ b/components/engine/daemon/stats_freebsd.go @@ -1,7 +1,7 @@ package daemon import ( - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" "github.com/opencontainers/runc/libcontainer" ) diff --git a/components/engine/daemon/stats_linux.go b/components/engine/daemon/stats_linux.go index 466f2df5e7..201552a4e1 100644 --- a/components/engine/daemon/stats_linux.go +++ b/components/engine/daemon/stats_linux.go @@ -1,7 +1,7 @@ package daemon import ( - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/cgroups" ) diff --git a/components/engine/daemon/stats_windows.go b/components/engine/daemon/stats_windows.go index fc8991ba2a..0f47cf09e0 100644 --- a/components/engine/daemon/stats_windows.go +++ b/components/engine/daemon/stats_windows.go @@ -1,7 +1,7 @@ package daemon import ( - "github.com/docker/docker/api/types" + "github.com/docker/engine-api/types" "github.com/opencontainers/runc/libcontainer" ) diff --git a/components/engine/daemon/top_unix.go b/components/engine/daemon/top_unix.go index 7bee57af2e..22dac6f218 100644 --- a/components/engine/daemon/top_unix.go +++ b/components/engine/daemon/top_unix.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/docker/docker/api/types" derr "github.com/docker/docker/errors" + "github.com/docker/engine-api/types" ) // ContainerTop lists the processes running inside of the given diff --git a/components/engine/daemon/top_windows.go b/components/engine/daemon/top_windows.go index f224b2e2d2..dc4cace65d 100644 --- a/components/engine/daemon/top_windows.go +++ b/components/engine/daemon/top_windows.go @@ -1,8 +1,8 @@ package daemon import ( - "github.com/docker/docker/api/types" derr "github.com/docker/docker/errors" + "github.com/docker/engine-api/types" ) // ContainerTop is not supported on Windows and returns an error. diff --git a/components/engine/daemon/update.go b/components/engine/daemon/update.go index 5699901e75..6f07e92584 100644 --- a/components/engine/daemon/update.go +++ b/components/engine/daemon/update.go @@ -3,7 +3,7 @@ package daemon import ( "fmt" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // ContainerUpdate updates resources of the container diff --git a/components/engine/daemon/volumes.go b/components/engine/daemon/volumes.go index df95af79aa..a7b648a56f 100644 --- a/components/engine/daemon/volumes.go +++ b/components/engine/daemon/volumes.go @@ -6,12 +6,12 @@ import ( "path/filepath" "strings" - "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/execdriver" derr "github.com/docker/docker/errors" "github.com/docker/docker/volume" + "github.com/docker/engine-api/types" + containertypes "github.com/docker/engine-api/types/container" "github.com/opencontainers/runc/libcontainer/label" ) diff --git a/components/engine/distribution/pull.go b/components/engine/distribution/pull.go index cddc40e24e..db6e29d681 100644 --- a/components/engine/distribution/pull.go +++ b/components/engine/distribution/pull.go @@ -7,13 +7,13 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" "github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/xfer" "github.com/docker/docker/image" "github.com/docker/docker/pkg/progress" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + "github.com/docker/engine-api/types" "golang.org/x/net/context" ) diff --git a/components/engine/distribution/push.go b/components/engine/distribution/push.go index 9c49d40857..b4dec42952 100644 --- a/components/engine/distribution/push.go +++ b/components/engine/distribution/push.go @@ -8,7 +8,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" - "github.com/docker/docker/api/types" "github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/xfer" "github.com/docker/docker/image" @@ -16,6 +15,7 @@ import ( "github.com/docker/docker/pkg/progress" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + "github.com/docker/engine-api/types" "github.com/docker/libtrust" "golang.org/x/net/context" ) diff --git a/components/engine/distribution/registry.go b/components/engine/distribution/registry.go index 49346f0746..d39a44411f 100644 --- a/components/engine/distribution/registry.go +++ b/components/engine/distribution/registry.go @@ -16,10 +16,10 @@ import ( "github.com/docker/distribution/registry/client" "github.com/docker/distribution/registry/client/auth" "github.com/docker/distribution/registry/client/transport" - "github.com/docker/docker/api/types" "github.com/docker/docker/distribution/xfer" "github.com/docker/docker/reference" "github.com/docker/docker/registry" + "github.com/docker/engine-api/types" "golang.org/x/net/context" ) diff --git a/components/engine/distribution/registry_unit_test.go b/components/engine/distribution/registry_unit_test.go index 53bf6324a6..ac1019b3c9 100644 --- a/components/engine/distribution/registry_unit_test.go +++ b/components/engine/distribution/registry_unit_test.go @@ -8,11 +8,11 @@ import ( "testing" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/reference" "github.com/docker/docker/registry" "github.com/docker/docker/utils" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" "golang.org/x/net/context" ) diff --git a/components/engine/image/image.go b/components/engine/image/image.go index c0508c1b98..b33b0b8402 100644 --- a/components/engine/image/image.go +++ b/components/engine/image/image.go @@ -7,7 +7,7 @@ import ( "time" "github.com/docker/distribution/digest" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // ID is the content-addressable ID of an image. diff --git a/components/engine/integration-cli/docker_api_containers_test.go b/components/engine/integration-cli/docker_api_containers_test.go index 6e1d288e61..568beca238 100644 --- a/components/engine/integration-cli/docker_api_containers_test.go +++ b/components/engine/integration-cli/docker_api_containers_test.go @@ -15,11 +15,11 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/integration" "github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/pkg/stringid" + "github.com/docker/engine-api/types" + containertypes "github.com/docker/engine-api/types/container" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_api_images_test.go b/components/engine/integration-cli/docker_api_images_test.go index 18625c5fb3..61298d3c68 100644 --- a/components/engine/integration-cli/docker_api_images_test.go +++ b/components/engine/integration-cli/docker_api_images_test.go @@ -6,8 +6,8 @@ import ( "net/url" "strings" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_api_inspect_test.go b/components/engine/integration-cli/docker_api_inspect_test.go index 37172b039f..0e00638a21 100644 --- a/components/engine/integration-cli/docker_api_inspect_test.go +++ b/components/engine/integration-cli/docker_api_inspect_test.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/pkg/stringutils" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/versions/v1p20" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_api_network_test.go b/components/engine/integration-cli/docker_api_network_test.go index 5e4f2eb094..0552978387 100644 --- a/components/engine/integration-cli/docker_api_network_test.go +++ b/components/engine/integration-cli/docker_api_network_test.go @@ -8,10 +8,10 @@ import ( "net/url" "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" + "github.com/docker/engine-api/types/network" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_api_stats_test.go b/components/engine/integration-cli/docker_api_stats_test.go index 715012f785..5041efbe21 100644 --- a/components/engine/integration-cli/docker_api_stats_test.go +++ b/components/engine/integration-cli/docker_api_stats_test.go @@ -10,9 +10,9 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/pkg/version" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_api_version_test.go b/components/engine/integration-cli/docker_api_version_test.go index eb2de5904a..ccb1484190 100644 --- a/components/engine/integration-cli/docker_api_version_test.go +++ b/components/engine/integration-cli/docker_api_version_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "net/http" - "github.com/docker/docker/api/types" "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_api_volumes_test.go b/components/engine/integration-cli/docker_api_volumes_test.go index 68b3c2a2cb..eab19091ce 100644 --- a/components/engine/integration-cli/docker_api_volumes_test.go +++ b/components/engine/integration-cli/docker_api_volumes_test.go @@ -5,8 +5,8 @@ import ( "net/http" "path/filepath" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_cli_by_digest_test.go b/components/engine/integration-cli/docker_cli_by_digest_test.go index 75c8b4fd6f..446a28eadf 100644 --- a/components/engine/integration-cli/docker_cli_by_digest_test.go +++ b/components/engine/integration-cli/docker_cli_by_digest_test.go @@ -10,9 +10,9 @@ import ( "github.com/docker/distribution/digest" "github.com/docker/distribution/manifest/schema1" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/pkg/stringutils" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_cli_inspect_experimental_test.go b/components/engine/integration-cli/docker_cli_inspect_experimental_test.go index c6e9c5c89f..9ba3df0eff 100644 --- a/components/engine/integration-cli/docker_cli_inspect_experimental_test.go +++ b/components/engine/integration-cli/docker_cli_inspect_experimental_test.go @@ -3,8 +3,8 @@ package main import ( - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_cli_inspect_test.go b/components/engine/integration-cli/docker_cli_inspect_test.go index 52c6ad3a73..986ed29821 100644 --- a/components/engine/integration-cli/docker_cli_inspect_test.go +++ b/components/engine/integration-cli/docker_cli_inspect_test.go @@ -8,9 +8,9 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/container" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_cli_network_unix_test.go b/components/engine/integration-cli/docker_cli_network_unix_test.go index 7a4a497cdf..9615642214 100644 --- a/components/engine/integration-cli/docker_cli_network_unix_test.go +++ b/components/engine/integration-cli/docker_cli_network_unix_test.go @@ -13,10 +13,10 @@ import ( "sort" "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/runconfig" + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/versions/v1p20" "github.com/docker/libnetwork/driverapi" remoteapi "github.com/docker/libnetwork/drivers/remote/api" "github.com/docker/libnetwork/ipamapi" diff --git a/components/engine/integration-cli/docker_cli_update_unix_test.go b/components/engine/integration-cli/docker_cli_update_unix_test.go index cb1cfee892..612efbe58b 100644 --- a/components/engine/integration-cli/docker_cli_update_unix_test.go +++ b/components/engine/integration-cli/docker_cli_update_unix_test.go @@ -7,8 +7,8 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/engine-api/types" "github.com/go-check/check" ) diff --git a/components/engine/integration-cli/docker_utils.go b/components/engine/integration-cli/docker_utils.go index 17611581e1..55bd1295c7 100644 --- a/components/engine/integration-cli/docker_utils.go +++ b/components/engine/integration-cli/docker_utils.go @@ -22,12 +22,12 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/integration" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringutils" + "github.com/docker/engine-api/types" "github.com/docker/go-connections/sockets" "github.com/docker/go-connections/tlsconfig" "github.com/go-check/check" diff --git a/components/engine/registry/auth.go b/components/engine/registry/auth.go index 34d5d6702b..7175598c71 100644 --- a/components/engine/registry/auth.go +++ b/components/engine/registry/auth.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) // Login tries to register/login to the registry server. diff --git a/components/engine/registry/auth_test.go b/components/engine/registry/auth_test.go index ff1bd54715..caff8667d1 100644 --- a/components/engine/registry/auth_test.go +++ b/components/engine/registry/auth_test.go @@ -3,8 +3,8 @@ package registry import ( "testing" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) func buildAuthConfigs() map[string]types.AuthConfig { diff --git a/components/engine/registry/config.go b/components/engine/registry/config.go index 9708d03634..ec8ec271c9 100644 --- a/components/engine/registry/config.go +++ b/components/engine/registry/config.go @@ -7,10 +7,10 @@ import ( "net/url" "strings" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/reference" + registrytypes "github.com/docker/engine-api/types/registry" ) // Options holds command line options. diff --git a/components/engine/registry/endpoint.go b/components/engine/registry/endpoint.go index 43ac9053fb..258a9c2854 100644 --- a/components/engine/registry/endpoint.go +++ b/components/engine/registry/endpoint.go @@ -13,7 +13,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/distribution/registry/api/v2" "github.com/docker/distribution/registry/client/transport" - registrytypes "github.com/docker/docker/api/types/registry" + registrytypes "github.com/docker/engine-api/types/registry" ) // for mocking in unit tests diff --git a/components/engine/registry/registry_mock_test.go b/components/engine/registry/registry_mock_test.go index be04e34689..057afac10d 100644 --- a/components/engine/registry/registry_mock_test.go +++ b/components/engine/registry/registry_mock_test.go @@ -15,9 +15,9 @@ import ( "testing" "time" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/opts" "github.com/docker/docker/reference" + registrytypes "github.com/docker/engine-api/types/registry" "github.com/gorilla/mux" "github.com/Sirupsen/logrus" diff --git a/components/engine/registry/registry_test.go b/components/engine/registry/registry_test.go index 46d2818fb7..7630d9a523 100644 --- a/components/engine/registry/registry_test.go +++ b/components/engine/registry/registry_test.go @@ -9,9 +9,9 @@ import ( "testing" "github.com/docker/distribution/registry/client/transport" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) var ( diff --git a/components/engine/registry/service.go b/components/engine/registry/service.go index 7223cbd8f3..dbdf173113 100644 --- a/components/engine/registry/service.go +++ b/components/engine/registry/service.go @@ -6,9 +6,9 @@ import ( "net/url" "strings" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) // Service is a registry service. It tracks configuration data such as a list diff --git a/components/engine/registry/session.go b/components/engine/registry/session.go index 494b84bf5a..57acbc0cf6 100644 --- a/components/engine/registry/session.go +++ b/components/engine/registry/session.go @@ -19,13 +19,13 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/types" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/reference" + "github.com/docker/engine-api/types" + registrytypes "github.com/docker/engine-api/types/registry" ) var ( diff --git a/components/engine/registry/types.go b/components/engine/registry/types.go index da3eaacb3f..ee88276e4e 100644 --- a/components/engine/registry/types.go +++ b/components/engine/registry/types.go @@ -1,8 +1,8 @@ package registry import ( - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/reference" + registrytypes "github.com/docker/engine-api/types/registry" ) // RepositoryData tracks the image list, list of endpoints, and list of tokens diff --git a/components/engine/runconfig/compare.go b/components/engine/runconfig/compare.go index 81f16b0a35..e774ba2294 100644 --- a/components/engine/runconfig/compare.go +++ b/components/engine/runconfig/compare.go @@ -1,6 +1,6 @@ package runconfig -import "github.com/docker/docker/api/types/container" +import "github.com/docker/engine-api/types/container" // Compare two Config struct. Do not compare the "Image" nor "Hostname" fields // If OpenStdin is set, then it differs diff --git a/components/engine/runconfig/compare_test.go b/components/engine/runconfig/compare_test.go index ed7528d67b..e67f659ef9 100644 --- a/components/engine/runconfig/compare_test.go +++ b/components/engine/runconfig/compare_test.go @@ -3,8 +3,8 @@ package runconfig import ( "testing" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/strslice" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/runconfig/config.go b/components/engine/runconfig/config.go index d12457393c..f40da2275a 100644 --- a/components/engine/runconfig/config.go +++ b/components/engine/runconfig/config.go @@ -5,8 +5,8 @@ import ( "fmt" "io" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/volume" + "github.com/docker/engine-api/types/container" ) // DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper diff --git a/components/engine/runconfig/config_test.go b/components/engine/runconfig/config_test.go index 7a1c785c2f..8c8cb15b00 100644 --- a/components/engine/runconfig/config_test.go +++ b/components/engine/runconfig/config_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/strslice" ) type f struct { diff --git a/components/engine/runconfig/config_unix.go b/components/engine/runconfig/config_unix.go index 05af155f5d..7bff0a2783 100644 --- a/components/engine/runconfig/config_unix.go +++ b/components/engine/runconfig/config_unix.go @@ -2,7 +2,7 @@ package runconfig -import "github.com/docker/docker/api/types/container" +import "github.com/docker/engine-api/types/container" // ContainerConfigWrapper is a Config wrapper that hold the container Config (portable) // and the corresponding HostConfig (non-portable). diff --git a/components/engine/runconfig/config_windows.go b/components/engine/runconfig/config_windows.go index 6ff7afcdaf..c8d387becd 100644 --- a/components/engine/runconfig/config_windows.go +++ b/components/engine/runconfig/config_windows.go @@ -1,6 +1,6 @@ package runconfig -import "github.com/docker/docker/api/types/container" +import "github.com/docker/engine-api/types/container" // ContainerConfigWrapper is a Config wrapper that hold the container Config (portable) // and the corresponding HostConfig (non-portable). diff --git a/components/engine/runconfig/hostconfig.go b/components/engine/runconfig/hostconfig.go index 2b81d02c20..769cc9f5da 100644 --- a/components/engine/runconfig/hostconfig.go +++ b/components/engine/runconfig/hostconfig.go @@ -4,7 +4,7 @@ import ( "encoding/json" "io" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // DecodeHostConfig creates a HostConfig based on the specified Reader. diff --git a/components/engine/runconfig/hostconfig_test.go b/components/engine/runconfig/hostconfig_test.go index 941c16d6e8..ef82a7143f 100644 --- a/components/engine/runconfig/hostconfig_test.go +++ b/components/engine/runconfig/hostconfig_test.go @@ -8,7 +8,7 @@ import ( "io/ioutil" "testing" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // TODO Windows: This will need addressing for a Windows daemon. diff --git a/components/engine/runconfig/hostconfig_unix.go b/components/engine/runconfig/hostconfig_unix.go index 4c28799395..7875d82e25 100644 --- a/components/engine/runconfig/hostconfig_unix.go +++ b/components/engine/runconfig/hostconfig_unix.go @@ -7,7 +7,7 @@ import ( "runtime" "strings" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // DefaultDaemonNetworkMode returns the default network stack the daemon should diff --git a/components/engine/runconfig/hostconfig_windows.go b/components/engine/runconfig/hostconfig_windows.go index 3cade744ad..56aa171819 100644 --- a/components/engine/runconfig/hostconfig_windows.go +++ b/components/engine/runconfig/hostconfig_windows.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/types/container" + "github.com/docker/engine-api/types/container" ) // DefaultDaemonNetworkMode returns the default network stack the daemon should diff --git a/components/engine/runconfig/opts/parse.go b/components/engine/runconfig/opts/parse.go index ad3c0eeaab..6f7c7cde7e 100644 --- a/components/engine/runconfig/opts/parse.go +++ b/components/engine/runconfig/opts/parse.go @@ -6,12 +6,12 @@ import ( "strconv" "strings" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/signal" + "github.com/docker/engine-api/types/container" + "github.com/docker/engine-api/types/strslice" "github.com/docker/go-connections/nat" "github.com/docker/go-units" ) diff --git a/components/engine/runconfig/opts/parse_test.go b/components/engine/runconfig/opts/parse_test.go index 2c7e100ef9..58a853ac82 100644 --- a/components/engine/runconfig/opts/parse_test.go +++ b/components/engine/runconfig/opts/parse_test.go @@ -10,9 +10,9 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types/container" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/runconfig" + "github.com/docker/engine-api/types/container" "github.com/docker/go-connections/nat" ) diff --git a/components/engine/runconfig/opts/throttledevice.go b/components/engine/runconfig/opts/throttledevice.go index 1f206b48f0..acb00ed5f7 100644 --- a/components/engine/runconfig/opts/throttledevice.go +++ b/components/engine/runconfig/opts/throttledevice.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/docker/docker/api/types/blkiodev" + "github.com/docker/engine-api/types/blkiodev" "github.com/docker/go-units" ) diff --git a/components/engine/runconfig/opts/weightdevice.go b/components/engine/runconfig/opts/weightdevice.go index 4d9aa93235..bd3c0b178a 100644 --- a/components/engine/runconfig/opts/weightdevice.go +++ b/components/engine/runconfig/opts/weightdevice.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/docker/docker/api/types/blkiodev" + "github.com/docker/engine-api/types/blkiodev" ) // ValidatorWeightFctType defines a validator function that returns a validated struct and/or an error. From 6ca136001815b398c4730a93fbfe2a2ca8c757c7 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 4 Jan 2016 19:06:11 -0500 Subject: [PATCH 3/3] Remove types and lib packages from the engine. They live in github.com/docker/engine-api now. Signed-off-by: David Calavera Upstream-commit: c7d811c8161b1acc677b15f56b02c773824dfb87 Component: engine --- components/engine/api/client/lib/client.go | 142 ------ .../engine/api/client/lib/client_test.go | 36 -- .../engine/api/client/lib/container_attach.go | 33 -- .../engine/api/client/lib/container_commit.go | 37 -- .../engine/api/client/lib/container_create.go | 53 --- .../api/client/lib/container_inspect.go | 64 --- .../engine/api/client/lib/container_list.go | 54 --- .../engine/api/client/lib/container_remove.go | 26 -- .../engine/api/client/lib/container_rename.go | 12 - .../api/client/lib/container_restart.go | 17 - .../engine/api/client/lib/container_start.go | 8 - .../engine/api/client/lib/container_stats.go | 22 - .../engine/api/client/lib/container_stop.go | 16 - .../engine/api/client/lib/container_top.go | 27 -- .../api/client/lib/container_unpause.go | 8 - .../engine/api/client/lib/container_update.go | 12 - components/engine/api/client/lib/copy.go | 95 ---- components/engine/api/client/lib/diff.go | 25 -- components/engine/api/client/lib/errors.go | 94 ---- components/engine/api/client/lib/events.go | 46 -- components/engine/api/client/lib/exec.go | 48 -- components/engine/api/client/lib/export.go | 18 - components/engine/api/client/lib/hijack.go | 164 ------- components/engine/api/client/lib/history.go | 23 - .../engine/api/client/lib/image_build.go | 127 ------ .../engine/api/client/lib/image_build_test.go | 17 - .../engine/api/client/lib/image_create.go | 26 -- .../engine/api/client/lib/image_import.go | 27 -- .../engine/api/client/lib/image_inspect.go | 37 -- .../engine/api/client/lib/image_list.go | 39 -- .../engine/api/client/lib/image_load.go | 22 - .../engine/api/client/lib/image_pull.go | 34 -- .../engine/api/client/lib/image_push.go | 36 -- .../engine/api/client/lib/image_remove.go | 30 -- .../engine/api/client/lib/image_save.go | 20 - .../engine/api/client/lib/image_search.go | 39 -- components/engine/api/client/lib/image_tag.go | 21 - components/engine/api/client/lib/info.go | 25 -- components/engine/api/client/lib/kill.go | 13 - components/engine/api/client/lib/login.go | 27 -- components/engine/api/client/lib/logs.go | 46 -- components/engine/api/client/lib/network.go | 82 ---- components/engine/api/client/lib/pause.go | 8 - .../engine/api/client/lib/privileged.go | 9 - components/engine/api/client/lib/request.go | 176 -------- components/engine/api/client/lib/resize.go | 28 -- components/engine/api/client/lib/version.go | 20 - components/engine/api/client/lib/volume.go | 66 --- components/engine/api/client/lib/wait.go | 24 - components/engine/api/types/auth.go | 11 - components/engine/api/types/blkiodev/blkio.go | 23 - components/engine/api/types/client.go | 245 ---------- components/engine/api/types/configs.go | 50 --- .../engine/api/types/container/config.go | 38 -- .../engine/api/types/container/host_config.go | 227 ---------- .../api/types/container/hostconfig_unix.go | 87 ---- .../api/types/container/hostconfig_windows.go | 75 ---- components/engine/api/types/events/events.go | 38 -- components/engine/api/types/filters/parse.go | 257 ----------- .../engine/api/types/filters/parse_test.go | 369 --------------- .../engine/api/types/network/network.go | 33 -- .../engine/api/types/registry/registry.go | 101 ----- components/engine/api/types/stats.go | 105 ----- .../engine/api/types/strslice/strslice.go | 71 --- .../api/types/strslice/strslice_test.go | 135 ------ components/engine/api/types/time/timestamp.go | 124 ----- .../engine/api/types/time/timestamp_test.go | 93 ---- components/engine/api/types/types.go | 424 ------------------ .../engine/api/types/versions/README.md | 14 - .../engine/api/types/versions/v1p19/types.go | 35 -- .../engine/api/types/versions/v1p20/types.go | 40 -- 71 files changed, 4674 deletions(-) delete mode 100644 components/engine/api/client/lib/client.go delete mode 100644 components/engine/api/client/lib/client_test.go delete mode 100644 components/engine/api/client/lib/container_attach.go delete mode 100644 components/engine/api/client/lib/container_commit.go delete mode 100644 components/engine/api/client/lib/container_create.go delete mode 100644 components/engine/api/client/lib/container_inspect.go delete mode 100644 components/engine/api/client/lib/container_list.go delete mode 100644 components/engine/api/client/lib/container_remove.go delete mode 100644 components/engine/api/client/lib/container_rename.go delete mode 100644 components/engine/api/client/lib/container_restart.go delete mode 100644 components/engine/api/client/lib/container_start.go delete mode 100644 components/engine/api/client/lib/container_stats.go delete mode 100644 components/engine/api/client/lib/container_stop.go delete mode 100644 components/engine/api/client/lib/container_top.go delete mode 100644 components/engine/api/client/lib/container_unpause.go delete mode 100644 components/engine/api/client/lib/container_update.go delete mode 100644 components/engine/api/client/lib/copy.go delete mode 100644 components/engine/api/client/lib/diff.go delete mode 100644 components/engine/api/client/lib/errors.go delete mode 100644 components/engine/api/client/lib/events.go delete mode 100644 components/engine/api/client/lib/exec.go delete mode 100644 components/engine/api/client/lib/export.go delete mode 100644 components/engine/api/client/lib/hijack.go delete mode 100644 components/engine/api/client/lib/history.go delete mode 100644 components/engine/api/client/lib/image_build.go delete mode 100644 components/engine/api/client/lib/image_build_test.go delete mode 100644 components/engine/api/client/lib/image_create.go delete mode 100644 components/engine/api/client/lib/image_import.go delete mode 100644 components/engine/api/client/lib/image_inspect.go delete mode 100644 components/engine/api/client/lib/image_list.go delete mode 100644 components/engine/api/client/lib/image_load.go delete mode 100644 components/engine/api/client/lib/image_pull.go delete mode 100644 components/engine/api/client/lib/image_push.go delete mode 100644 components/engine/api/client/lib/image_remove.go delete mode 100644 components/engine/api/client/lib/image_save.go delete mode 100644 components/engine/api/client/lib/image_search.go delete mode 100644 components/engine/api/client/lib/image_tag.go delete mode 100644 components/engine/api/client/lib/info.go delete mode 100644 components/engine/api/client/lib/kill.go delete mode 100644 components/engine/api/client/lib/login.go delete mode 100644 components/engine/api/client/lib/logs.go delete mode 100644 components/engine/api/client/lib/network.go delete mode 100644 components/engine/api/client/lib/pause.go delete mode 100644 components/engine/api/client/lib/privileged.go delete mode 100644 components/engine/api/client/lib/request.go delete mode 100644 components/engine/api/client/lib/resize.go delete mode 100644 components/engine/api/client/lib/version.go delete mode 100644 components/engine/api/client/lib/volume.go delete mode 100644 components/engine/api/client/lib/wait.go delete mode 100644 components/engine/api/types/auth.go delete mode 100644 components/engine/api/types/blkiodev/blkio.go delete mode 100644 components/engine/api/types/client.go delete mode 100644 components/engine/api/types/configs.go delete mode 100644 components/engine/api/types/container/config.go delete mode 100644 components/engine/api/types/container/host_config.go delete mode 100644 components/engine/api/types/container/hostconfig_unix.go delete mode 100644 components/engine/api/types/container/hostconfig_windows.go delete mode 100644 components/engine/api/types/events/events.go delete mode 100644 components/engine/api/types/filters/parse.go delete mode 100644 components/engine/api/types/filters/parse_test.go delete mode 100644 components/engine/api/types/network/network.go delete mode 100644 components/engine/api/types/registry/registry.go delete mode 100644 components/engine/api/types/stats.go delete mode 100644 components/engine/api/types/strslice/strslice.go delete mode 100644 components/engine/api/types/strslice/strslice_test.go delete mode 100644 components/engine/api/types/time/timestamp.go delete mode 100644 components/engine/api/types/time/timestamp_test.go delete mode 100644 components/engine/api/types/types.go delete mode 100644 components/engine/api/types/versions/README.md delete mode 100644 components/engine/api/types/versions/v1p19/types.go delete mode 100644 components/engine/api/types/versions/v1p20/types.go diff --git a/components/engine/api/client/lib/client.go b/components/engine/api/client/lib/client.go deleted file mode 100644 index d85a55e70f..0000000000 --- a/components/engine/api/client/lib/client.go +++ /dev/null @@ -1,142 +0,0 @@ -package lib - -import ( - "crypto/tls" - "fmt" - "net" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - "time" -) - -// Client is the API client that performs all operations -// against a docker server. -type Client struct { - // proto holds the client protocol i.e. unix. - proto string - // addr holds the client address. - addr string - // basePath holds the path to prepend to the requests - basePath string - // scheme holds the scheme of the client i.e. https. - scheme string - // tlsConfig holds the tls configuration to use in hijacked requests. - tlsConfig *tls.Config - // httpClient holds the client transport instance. Exported to keep the old code running. - httpClient *http.Client - // version of the server to talk to. - version string - // custom http headers configured by users - customHTTPHeaders map[string]string -} - -// NewEnvClient initializes a new API client based on environment variables. -// Use DOCKER_HOST to set the url to the docker server. -// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest. -// Use DOCKER_CERT_PATH to load the tls certificates from. -// Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default. -func NewEnvClient() (*Client, error) { - var transport *http.Transport - if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" { - tlsc := &tls.Config{} - - cert, err := tls.LoadX509KeyPair(filepath.Join(dockerCertPath, "cert.pem"), filepath.Join(dockerCertPath, "key.pem")) - if err != nil { - return nil, fmt.Errorf("Error loading x509 key pair: %s", err) - } - - tlsc.Certificates = append(tlsc.Certificates, cert) - tlsc.InsecureSkipVerify = os.Getenv("DOCKER_TLS_VERIFY") == "" - transport = &http.Transport{ - TLSClientConfig: tlsc, - } - } - - return NewClient(os.Getenv("DOCKER_HOST"), os.Getenv("DOCKER_API_VERSION"), transport, nil) -} - -// NewClient initializes a new API client for the given host and API version. -// It won't send any version information if the version number is empty. -// It uses the transport to create a new http client. -// It also initializes the custom http headers to add to each request. -func NewClient(host string, version string, transport *http.Transport, httpHeaders map[string]string) (*Client, error) { - var ( - basePath string - tlsConfig *tls.Config - scheme = "http" - protoAddrParts = strings.SplitN(host, "://", 2) - proto, addr = protoAddrParts[0], protoAddrParts[1] - ) - - if proto == "tcp" { - parsed, err := url.Parse("tcp://" + addr) - if err != nil { - return nil, err - } - addr = parsed.Host - basePath = parsed.Path - } - - transport = configureTransport(transport, proto, addr) - if transport.TLSClientConfig != nil { - scheme = "https" - } - - return &Client{ - proto: proto, - addr: addr, - basePath: basePath, - scheme: scheme, - tlsConfig: tlsConfig, - httpClient: &http.Client{Transport: transport}, - version: version, - customHTTPHeaders: httpHeaders, - }, nil -} - -// getAPIPath returns the versioned request path to call the api. -// It appends the query parameters to the path if they are not empty. -func (cli *Client) getAPIPath(p string, query url.Values) string { - var apiPath string - if cli.version != "" { - v := strings.TrimPrefix(cli.version, "v") - apiPath = fmt.Sprintf("%s/v%s%s", cli.basePath, v, p) - } else { - apiPath = fmt.Sprintf("%s%s", cli.basePath, p) - } - if len(query) > 0 { - apiPath += "?" + query.Encode() - } - return apiPath -} - -// ClientVersion returns the version string associated with this -// instance of the Client. Note that this value can be changed -// via the DOCKER_API_VERSION env var. -func (cli *Client) ClientVersion() string { - return cli.version -} - -func configureTransport(tr *http.Transport, proto, addr string) *http.Transport { - if tr == nil { - tr = &http.Transport{} - } - - // Why 32? See https://github.com/docker/docker/pull/8035. - timeout := 32 * time.Second - if proto == "unix" { - // No need for compression in local communications. - tr.DisableCompression = true - tr.Dial = func(_, _ string) (net.Conn, error) { - return net.DialTimeout(proto, addr, timeout) - } - } else { - tr.Proxy = http.ProxyFromEnvironment - tr.Dial = (&net.Dialer{Timeout: timeout}).Dial - } - - return tr -} diff --git a/components/engine/api/client/lib/client_test.go b/components/engine/api/client/lib/client_test.go deleted file mode 100644 index 97634beb85..0000000000 --- a/components/engine/api/client/lib/client_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package lib - -import ( - "net/url" - "testing" -) - -func TestGetAPIPath(t *testing.T) { - cases := []struct { - v string - p string - q url.Values - e string - }{ - {"", "/containers/json", nil, "/containers/json"}, - {"", "/containers/json", url.Values{}, "/containers/json"}, - {"", "/containers/json", url.Values{"s": []string{"c"}}, "/containers/json?s=c"}, - {"1.22", "/containers/json", nil, "/v1.22/containers/json"}, - {"1.22", "/containers/json", url.Values{}, "/v1.22/containers/json"}, - {"1.22", "/containers/json", url.Values{"s": []string{"c"}}, "/v1.22/containers/json?s=c"}, - {"v1.22", "/containers/json", nil, "/v1.22/containers/json"}, - {"v1.22", "/containers/json", url.Values{}, "/v1.22/containers/json"}, - {"v1.22", "/containers/json", url.Values{"s": []string{"c"}}, "/v1.22/containers/json?s=c"}, - } - - for _, cs := range cases { - c, err := NewClient("unix:///var/run/docker.sock", cs.v, nil, nil) - if err != nil { - t.Fatal(err) - } - g := c.getAPIPath(cs.p, cs.q) - if g != cs.e { - t.Fatalf("Expected %s, got %s", cs.e, g) - } - } -} diff --git a/components/engine/api/client/lib/container_attach.go b/components/engine/api/client/lib/container_attach.go deleted file mode 100644 index 4074bc99a8..0000000000 --- a/components/engine/api/client/lib/container_attach.go +++ /dev/null @@ -1,33 +0,0 @@ -package lib - -import ( - "net/url" - - "github.com/docker/engine-api/types" -) - -// ContainerAttach attaches a connection to a container in the server. -// It returns a types.HijackedConnection with the hijacked connection -// and the a reader to get output. It's up to the called to close -// the hijacked connection by calling types.HijackedResponse.Close. -func (cli *Client) ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error) { - query := url.Values{} - if options.Stream { - query.Set("stream", "1") - } - if options.Stdin { - query.Set("stdin", "1") - } - if options.Stdout { - query.Set("stdout", "1") - } - if options.Stderr { - query.Set("stderr", "1") - } - if options.DetachKeys != "" { - query.Set("detachKeys", options.DetachKeys) - } - - headers := map[string][]string{"Content-Type": {"text/plain"}} - return cli.postHijacked("/containers/"+options.ContainerID+"/attach", query, nil, headers) -} diff --git a/components/engine/api/client/lib/container_commit.go b/components/engine/api/client/lib/container_commit.go deleted file mode 100644 index 9908a19273..0000000000 --- a/components/engine/api/client/lib/container_commit.go +++ /dev/null @@ -1,37 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ContainerCommit applies changes into a container and creates a new tagged image. -func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) { - query := url.Values{} - query.Set("container", options.ContainerID) - query.Set("repo", options.RepositoryName) - query.Set("tag", options.Tag) - query.Set("comment", options.Comment) - query.Set("author", options.Author) - for _, change := range options.Changes { - query.Add("changes", change) - } - if options.Pause != true { - query.Set("pause", "0") - } - - var response types.ContainerCommitResponse - resp, err := cli.post("/commit", query, options.Config, nil) - if err != nil { - return response, err - } - defer ensureReaderClosed(resp) - - if err := json.NewDecoder(resp.body).Decode(&response); err != nil { - return response, err - } - - return response, nil -} diff --git a/components/engine/api/client/lib/container_create.go b/components/engine/api/client/lib/container_create.go deleted file mode 100644 index 50fa927dc7..0000000000 --- a/components/engine/api/client/lib/container_create.go +++ /dev/null @@ -1,53 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - "strings" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" -) - -type configWrapper struct { - *container.Config - HostConfig *container.HostConfig -} - -// ContainerCreate creates a new container based in the given configuration. -// It can be associated with a name, but it's not mandatory. -func (cli *Client) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, containerName string) (types.ContainerCreateResponse, error) { - var response types.ContainerCreateResponse - query := url.Values{} - if containerName != "" { - query.Set("name", containerName) - } - - body := configWrapper{ - Config: config, - HostConfig: hostConfig, - } - - serverResp, err := cli.post("/containers/create", query, body, nil) - if err != nil { - if serverResp != nil && serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) { - return response, imageNotFoundError{config.Image} - } - return response, err - } - - if serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) { - return response, imageNotFoundError{config.Image} - } - - if err != nil { - return response, err - } - defer ensureReaderClosed(serverResp) - - if err := json.NewDecoder(serverResp.body).Decode(&response); err != nil { - return response, err - } - - return response, nil -} diff --git a/components/engine/api/client/lib/container_inspect.go b/components/engine/api/client/lib/container_inspect.go deleted file mode 100644 index 49b8893982..0000000000 --- a/components/engine/api/client/lib/container_inspect.go +++ /dev/null @@ -1,64 +0,0 @@ -package lib - -import ( - "bytes" - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ContainerInspect returns the container information. -func (cli *Client) ContainerInspect(containerID string) (types.ContainerJSON, error) { - serverResp, err := cli.get("/containers/"+containerID+"/json", nil, nil) - if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return types.ContainerJSON{}, containerNotFoundError{containerID} - } - return types.ContainerJSON{}, err - } - defer ensureReaderClosed(serverResp) - - var response types.ContainerJSON - err = json.NewDecoder(serverResp.body).Decode(&response) - return response, err -} - -// ContainerInspectWithRaw returns the container information and it's raw representation. -func (cli *Client) ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error) { - query := url.Values{} - if getSize { - query.Set("size", "1") - } - serverResp, err := cli.get("/containers/"+containerID+"/json", query, nil) - if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return types.ContainerJSON{}, nil, containerNotFoundError{containerID} - } - return types.ContainerJSON{}, nil, err - } - defer ensureReaderClosed(serverResp) - - body, err := ioutil.ReadAll(serverResp.body) - if err != nil { - return types.ContainerJSON{}, nil, err - } - - var response types.ContainerJSON - rdr := bytes.NewReader(body) - err = json.NewDecoder(rdr).Decode(&response) - return response, body, err -} - -func (cli *Client) containerInspectWithResponse(containerID string, query url.Values) (types.ContainerJSON, *serverResponse, error) { - serverResp, err := cli.get("/containers/"+containerID+"/json", nil, nil) - if err != nil { - return types.ContainerJSON{}, serverResp, err - } - - var response types.ContainerJSON - err = json.NewDecoder(serverResp.body).Decode(&response) - return response, serverResp, err -} diff --git a/components/engine/api/client/lib/container_list.go b/components/engine/api/client/lib/container_list.go deleted file mode 100644 index c05b1d5d66..0000000000 --- a/components/engine/api/client/lib/container_list.go +++ /dev/null @@ -1,54 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - "strconv" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" -) - -// ContainerList returns the list of containers in the docker host. -func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Container, error) { - query := url.Values{} - - if options.All { - query.Set("all", "1") - } - - if options.Limit != -1 { - query.Set("limit", strconv.Itoa(options.Limit)) - } - - if options.Since != "" { - query.Set("since", options.Since) - } - - if options.Before != "" { - query.Set("before", options.Before) - } - - if options.Size { - query.Set("size", "1") - } - - if options.Filter.Len() > 0 { - filterJSON, err := filters.ToParam(options.Filter) - if err != nil { - return nil, err - } - - query.Set("filters", filterJSON) - } - - resp, err := cli.get("/containers/json", query, nil) - if err != nil { - return nil, err - } - defer ensureReaderClosed(resp) - - var containers []types.Container - err = json.NewDecoder(resp.body).Decode(&containers) - return containers, err -} diff --git a/components/engine/api/client/lib/container_remove.go b/components/engine/api/client/lib/container_remove.go deleted file mode 100644 index 76fe9bd40d..0000000000 --- a/components/engine/api/client/lib/container_remove.go +++ /dev/null @@ -1,26 +0,0 @@ -package lib - -import ( - "net/url" - - "github.com/docker/engine-api/types" -) - -// ContainerRemove kills and removes a container from the docker host. -func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error { - query := url.Values{} - if options.RemoveVolumes { - query.Set("v", "1") - } - if options.RemoveLinks { - query.Set("link", "1") - } - - if options.Force { - query.Set("force", "1") - } - - resp, err := cli.delete("/containers/"+options.ContainerID, query, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/container_rename.go b/components/engine/api/client/lib/container_rename.go deleted file mode 100644 index 1aed00ada1..0000000000 --- a/components/engine/api/client/lib/container_rename.go +++ /dev/null @@ -1,12 +0,0 @@ -package lib - -import "net/url" - -// ContainerRename changes the name of a given container. -func (cli *Client) ContainerRename(containerID, newContainerName string) error { - query := url.Values{} - query.Set("name", newContainerName) - resp, err := cli.post("/containers/"+containerID+"/rename", query, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/container_restart.go b/components/engine/api/client/lib/container_restart.go deleted file mode 100644 index 74b5022b90..0000000000 --- a/components/engine/api/client/lib/container_restart.go +++ /dev/null @@ -1,17 +0,0 @@ -package lib - -import ( - "net/url" - "strconv" -) - -// ContainerRestart stops and starts a container again. -// It makes the daemon to wait for the container to be up again for -// a specific amount of time, given the timeout. -func (cli *Client) ContainerRestart(containerID string, timeout int) error { - query := url.Values{} - query.Set("t", strconv.Itoa(timeout)) - resp, err := cli.post("/containers/"+containerID+"/restart", query, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/container_start.go b/components/engine/api/client/lib/container_start.go deleted file mode 100644 index 2c65b5df30..0000000000 --- a/components/engine/api/client/lib/container_start.go +++ /dev/null @@ -1,8 +0,0 @@ -package lib - -// ContainerStart sends a request to the docker daemon to start a container. -func (cli *Client) ContainerStart(containerID string) error { - resp, err := cli.post("/containers/"+containerID+"/start", nil, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/container_stats.go b/components/engine/api/client/lib/container_stats.go deleted file mode 100644 index a18fae7a0b..0000000000 --- a/components/engine/api/client/lib/container_stats.go +++ /dev/null @@ -1,22 +0,0 @@ -package lib - -import ( - "io" - "net/url" -) - -// ContainerStats returns near realtime stats for a given container. -// It's up to the caller to close the io.ReadCloser returned. -func (cli *Client) ContainerStats(containerID string, stream bool) (io.ReadCloser, error) { - query := url.Values{} - query.Set("stream", "0") - if stream { - query.Set("stream", "1") - } - - resp, err := cli.get("/containers/"+containerID+"/stats", query, nil) - if err != nil { - return nil, err - } - return resp.body, err -} diff --git a/components/engine/api/client/lib/container_stop.go b/components/engine/api/client/lib/container_stop.go deleted file mode 100644 index 3bb73ea75e..0000000000 --- a/components/engine/api/client/lib/container_stop.go +++ /dev/null @@ -1,16 +0,0 @@ -package lib - -import ( - "net/url" - "strconv" -) - -// ContainerStop stops a container without terminating the process. -// The process is blocked until the container stops or the timeout expires. -func (cli *Client) ContainerStop(containerID string, timeout int) error { - query := url.Values{} - query.Set("t", strconv.Itoa(timeout)) - resp, err := cli.post("/containers/"+containerID+"/stop", query, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/container_top.go b/components/engine/api/client/lib/container_top.go deleted file mode 100644 index 98860c8aa7..0000000000 --- a/components/engine/api/client/lib/container_top.go +++ /dev/null @@ -1,27 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - "strings" - - "github.com/docker/engine-api/types" -) - -// ContainerTop shows process information from within a container. -func (cli *Client) ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error) { - var response types.ContainerProcessList - query := url.Values{} - if len(arguments) > 0 { - query.Set("ps_args", strings.Join(arguments, " ")) - } - - resp, err := cli.get("/containers/"+containerID+"/top", query, nil) - if err != nil { - return response, err - } - defer ensureReaderClosed(resp) - - err = json.NewDecoder(resp.body).Decode(&response) - return response, err -} diff --git a/components/engine/api/client/lib/container_unpause.go b/components/engine/api/client/lib/container_unpause.go deleted file mode 100644 index 146cbd8fc4..0000000000 --- a/components/engine/api/client/lib/container_unpause.go +++ /dev/null @@ -1,8 +0,0 @@ -package lib - -// ContainerUnpause resumes the process execution within a container -func (cli *Client) ContainerUnpause(containerID string) error { - resp, err := cli.post("/containers/"+containerID+"/unpause", nil, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/container_update.go b/components/engine/api/client/lib/container_update.go deleted file mode 100644 index 6976e3d9f1..0000000000 --- a/components/engine/api/client/lib/container_update.go +++ /dev/null @@ -1,12 +0,0 @@ -package lib - -import ( - "github.com/docker/engine-api/types/container" -) - -// ContainerUpdate updates resources of a container -func (cli *Client) ContainerUpdate(containerID string, hostConfig container.HostConfig) error { - resp, err := cli.post("/containers/"+containerID+"/update", nil, hostConfig, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/copy.go b/components/engine/api/client/lib/copy.go deleted file mode 100644 index b18c89334e..0000000000 --- a/components/engine/api/client/lib/copy.go +++ /dev/null @@ -1,95 +0,0 @@ -package lib - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "path/filepath" - "strings" - - "github.com/docker/engine-api/types" -) - -// ContainerStatPath returns Stat information about a path inside the container filesystem. -func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) { - query := url.Values{} - query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API. - - urlStr := fmt.Sprintf("/containers/%s/archive", containerID) - response, err := cli.head(urlStr, query, nil) - if err != nil { - return types.ContainerPathStat{}, err - } - defer ensureReaderClosed(response) - return getContainerPathStatFromHeader(response.header) -} - -// CopyToContainer copies content into the container filesystem. -func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error { - query := url.Values{} - query.Set("path", filepath.ToSlash(options.Path)) // Normalize the paths used in the API. - // Do not allow for an existing directory to be overwritten by a non-directory and vice versa. - if !options.AllowOverwriteDirWithFile { - query.Set("noOverwriteDirNonDir", "true") - } - - path := fmt.Sprintf("/containers/%s/archive", options.ContainerID) - - response, err := cli.putRaw(path, query, options.Content, nil) - if err != nil { - return err - } - defer ensureReaderClosed(response) - - if response.statusCode != http.StatusOK { - return fmt.Errorf("unexpected status code from daemon: %d", response.statusCode) - } - - return nil -} - -// CopyFromContainer get the content from the container and return it as a Reader -// to manipulate it in the host. It's up to the caller to close the reader. -func (cli *Client) CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { - query := make(url.Values, 1) - query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API. - - apiPath := fmt.Sprintf("/containers/%s/archive", containerID) - response, err := cli.get(apiPath, query, nil) - if err != nil { - return nil, types.ContainerPathStat{}, err - } - - if response.statusCode != http.StatusOK { - return nil, types.ContainerPathStat{}, fmt.Errorf("unexpected status code from daemon: %d", response.statusCode) - } - - // In order to get the copy behavior right, we need to know information - // about both the source and the destination. The response headers include - // stat info about the source that we can use in deciding exactly how to - // copy it locally. Along with the stat info about the local destination, - // we have everything we need to handle the multiple possibilities there - // can be when copying a file/dir from one location to another file/dir. - stat, err := getContainerPathStatFromHeader(response.header) - if err != nil { - return nil, stat, fmt.Errorf("unable to get resource stat from response: %s", err) - } - return response.body, stat, err -} - -func getContainerPathStatFromHeader(header http.Header) (types.ContainerPathStat, error) { - var stat types.ContainerPathStat - - encodedStat := header.Get("X-Docker-Container-Path-Stat") - statDecoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(encodedStat)) - - err := json.NewDecoder(statDecoder).Decode(&stat) - if err != nil { - err = fmt.Errorf("unable to decode container path stat header: %s", err) - } - - return stat, err -} diff --git a/components/engine/api/client/lib/diff.go b/components/engine/api/client/lib/diff.go deleted file mode 100644 index eaa7db112d..0000000000 --- a/components/engine/api/client/lib/diff.go +++ /dev/null @@ -1,25 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ContainerDiff shows differences in a container filesystem since it was started. -func (cli *Client) ContainerDiff(containerID string) ([]types.ContainerChange, error) { - var changes []types.ContainerChange - - serverResp, err := cli.get("/containers/"+containerID+"/changes", url.Values{}, nil) - if err != nil { - return changes, err - } - defer ensureReaderClosed(serverResp) - - if err := json.NewDecoder(serverResp.body).Decode(&changes); err != nil { - return changes, err - } - - return changes, nil -} diff --git a/components/engine/api/client/lib/errors.go b/components/engine/api/client/lib/errors.go deleted file mode 100644 index 95b88075da..0000000000 --- a/components/engine/api/client/lib/errors.go +++ /dev/null @@ -1,94 +0,0 @@ -package lib - -import ( - "errors" - "fmt" -) - -// ErrConnectionFailed is a error raised when the connection between the client and the server failed. -var ErrConnectionFailed = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?") - -// imageNotFoundError implements an error returned when an image is not in the docker host. -type imageNotFoundError struct { - imageID string -} - -// Error returns a string representation of an imageNotFoundError -func (i imageNotFoundError) Error() string { - return fmt.Sprintf("Error: No such image: %s", i.imageID) -} - -// IsErrImageNotFound returns true if the error is caused -// when an image is not found in the docker host. -func IsErrImageNotFound(err error) bool { - _, ok := err.(imageNotFoundError) - return ok -} - -// containerNotFoundError implements an error returned when a container is not in the docker host. -type containerNotFoundError struct { - containerID string -} - -// Error returns a string representation of an containerNotFoundError -func (e containerNotFoundError) Error() string { - return fmt.Sprintf("Error: No such container: %s", e.containerID) -} - -// IsErrContainerNotFound returns true if the error is caused -// when a container is not found in the docker host. -func IsErrContainerNotFound(err error) bool { - _, ok := err.(containerNotFoundError) - return ok -} - -// networkNotFoundError implements an error returned when a network is not in the docker host. -type networkNotFoundError struct { - networkID string -} - -// Error returns a string representation of an networkNotFoundError -func (e networkNotFoundError) Error() string { - return fmt.Sprintf("Error: No such network: %s", e.networkID) -} - -// IsErrNetworkNotFound returns true if the error is caused -// when a network is not found in the docker host. -func IsErrNetworkNotFound(err error) bool { - _, ok := err.(networkNotFoundError) - return ok -} - -// volumeNotFoundError implements an error returned when a volume is not in the docker host. -type volumeNotFoundError struct { - volumeID string -} - -// Error returns a string representation of an networkNotFoundError -func (e volumeNotFoundError) Error() string { - return fmt.Sprintf("Error: No such volume: %s", e.volumeID) -} - -// IsErrVolumeNotFound returns true if the error is caused -// when a volume is not found in the docker host. -func IsErrVolumeNotFound(err error) bool { - _, ok := err.(networkNotFoundError) - return ok -} - -// unauthorizedError represents an authorization error in a remote registry. -type unauthorizedError struct { - cause error -} - -// Error returns a string representation of an unauthorizedError -func (u unauthorizedError) Error() string { - return u.cause.Error() -} - -// IsErrUnauthorized returns true if the error is caused -// when an the remote registry authentication fails -func IsErrUnauthorized(err error) bool { - _, ok := err.(unauthorizedError) - return ok -} diff --git a/components/engine/api/client/lib/events.go b/components/engine/api/client/lib/events.go deleted file mode 100644 index 9d4606829b..0000000000 --- a/components/engine/api/client/lib/events.go +++ /dev/null @@ -1,46 +0,0 @@ -package lib - -import ( - "io" - "net/url" - "time" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" - timetypes "github.com/docker/engine-api/types/time" -) - -// Events returns a stream of events in the daemon in a ReadCloser. -// It's up to the caller to close the stream. -func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) { - query := url.Values{} - ref := time.Now() - - if options.Since != "" { - ts, err := timetypes.GetTimestamp(options.Since, ref) - if err != nil { - return nil, err - } - query.Set("since", ts) - } - if options.Until != "" { - ts, err := timetypes.GetTimestamp(options.Until, ref) - if err != nil { - return nil, err - } - query.Set("until", ts) - } - if options.Filters.Len() > 0 { - filterJSON, err := filters.ToParam(options.Filters) - if err != nil { - return nil, err - } - query.Set("filters", filterJSON) - } - - serverResponse, err := cli.get("/events", query, nil) - if err != nil { - return nil, err - } - return serverResponse.body, nil -} diff --git a/components/engine/api/client/lib/exec.go b/components/engine/api/client/lib/exec.go deleted file mode 100644 index 229db2711b..0000000000 --- a/components/engine/api/client/lib/exec.go +++ /dev/null @@ -1,48 +0,0 @@ -package lib - -import ( - "encoding/json" - - "github.com/docker/engine-api/types" -) - -// ContainerExecCreate creates a new exec configuration to run an exec process. -func (cli *Client) ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error) { - var response types.ContainerExecCreateResponse - resp, err := cli.post("/containers/"+config.Container+"/exec", nil, config, nil) - if err != nil { - return response, err - } - defer ensureReaderClosed(resp) - err = json.NewDecoder(resp.body).Decode(&response) - return response, err -} - -// ContainerExecStart starts an exec process already create in the docker host. -func (cli *Client) ContainerExecStart(execID string, config types.ExecStartCheck) error { - resp, err := cli.post("/exec/"+execID+"/start", nil, config, nil) - ensureReaderClosed(resp) - return err -} - -// ContainerExecAttach attaches a connection to an exec process in the server. -// It returns a types.HijackedConnection with the hijacked connection -// and the a reader to get output. It's up to the called to close -// the hijacked connection by calling types.HijackedResponse.Close. -func (cli *Client) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) { - headers := map[string][]string{"Content-Type": {"application/json"}} - return cli.postHijacked("/exec/"+execID+"/start", nil, config, headers) -} - -// ContainerExecInspect returns information about a specific exec process on the docker host. -func (cli *Client) ContainerExecInspect(execID string) (types.ContainerExecInspect, error) { - var response types.ContainerExecInspect - resp, err := cli.get("/exec/"+execID+"/json", nil, nil) - if err != nil { - return response, err - } - defer ensureReaderClosed(resp) - - err = json.NewDecoder(resp.body).Decode(&response) - return response, err -} diff --git a/components/engine/api/client/lib/export.go b/components/engine/api/client/lib/export.go deleted file mode 100644 index 07893c5b83..0000000000 --- a/components/engine/api/client/lib/export.go +++ /dev/null @@ -1,18 +0,0 @@ -package lib - -import ( - "io" - "net/url" -) - -// ContainerExport retrieves the raw contents of a container -// and returns them as a io.ReadCloser. It's up to the caller -// to close the stream. -func (cli *Client) ContainerExport(containerID string) (io.ReadCloser, error) { - serverResp, err := cli.get("/containers/"+containerID+"/export", url.Values{}, nil) - if err != nil { - return nil, err - } - - return serverResp.body, nil -} diff --git a/components/engine/api/client/lib/hijack.go b/components/engine/api/client/lib/hijack.go deleted file mode 100644 index 6ee8d160e4..0000000000 --- a/components/engine/api/client/lib/hijack.go +++ /dev/null @@ -1,164 +0,0 @@ -package lib - -import ( - "crypto/tls" - "errors" - "fmt" - "net" - "net/http/httputil" - "net/url" - "strings" - "time" - - "github.com/docker/engine-api/types" -) - -// tlsClientCon holds tls information and a dialed connection. -type tlsClientCon struct { - *tls.Conn - rawConn net.Conn -} - -func (c *tlsClientCon) CloseWrite() error { - // Go standard tls.Conn doesn't provide the CloseWrite() method so we do it - // on its underlying connection. - if conn, ok := c.rawConn.(types.CloseWriter); ok { - return conn.CloseWrite() - } - return nil -} - -// postHijacked sends a POST request and hijacks the connection. -func (cli *Client) postHijacked(path string, query url.Values, body interface{}, headers map[string][]string) (types.HijackedResponse, error) { - bodyEncoded, err := encodeData(body) - if err != nil { - return types.HijackedResponse{}, err - } - - req, err := cli.newRequest("POST", path, query, bodyEncoded, headers) - if err != nil { - return types.HijackedResponse{}, err - } - req.Host = cli.addr - - req.Header.Set("Connection", "Upgrade") - req.Header.Set("Upgrade", "tcp") - - conn, err := dial(cli.proto, cli.addr, cli.tlsConfig) - if err != nil { - if strings.Contains(err.Error(), "connection refused") { - return types.HijackedResponse{}, fmt.Errorf("Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?") - } - return types.HijackedResponse{}, err - } - - // When we set up a TCP connection for hijack, there could be long periods - // of inactivity (a long running command with no output) that in certain - // network setups may cause ECONNTIMEOUT, leaving the client in an unknown - // state. Setting TCP KeepAlive on the socket connection will prohibit - // ECONNTIMEOUT unless the socket connection truly is broken - if tcpConn, ok := conn.(*net.TCPConn); ok { - tcpConn.SetKeepAlive(true) - tcpConn.SetKeepAlivePeriod(30 * time.Second) - } - - clientconn := httputil.NewClientConn(conn, nil) - defer clientconn.Close() - - // Server hijacks the connection, error 'connection closed' expected - clientconn.Do(req) - - rwc, br := clientconn.Hijack() - - return types.HijackedResponse{Conn: rwc, Reader: br}, nil -} - -func tlsDial(network, addr string, config *tls.Config) (net.Conn, error) { - return tlsDialWithDialer(new(net.Dialer), network, addr, config) -} - -// We need to copy Go's implementation of tls.Dial (pkg/cryptor/tls/tls.go) in -// order to return our custom tlsClientCon struct which holds both the tls.Conn -// object _and_ its underlying raw connection. The rationale for this is that -// we need to be able to close the write end of the connection when attaching, -// which tls.Conn does not provide. -func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) { - // We want the Timeout and Deadline values from dialer to cover the - // whole process: TCP connection and TLS handshake. This means that we - // also need to start our own timers now. - timeout := dialer.Timeout - - if !dialer.Deadline.IsZero() { - deadlineTimeout := dialer.Deadline.Sub(time.Now()) - if timeout == 0 || deadlineTimeout < timeout { - timeout = deadlineTimeout - } - } - - var errChannel chan error - - if timeout != 0 { - errChannel = make(chan error, 2) - time.AfterFunc(timeout, func() { - errChannel <- errors.New("") - }) - } - - rawConn, err := dialer.Dial(network, addr) - if err != nil { - return nil, err - } - // When we set up a TCP connection for hijack, there could be long periods - // of inactivity (a long running command with no output) that in certain - // network setups may cause ECONNTIMEOUT, leaving the client in an unknown - // state. Setting TCP KeepAlive on the socket connection will prohibit - // ECONNTIMEOUT unless the socket connection truly is broken - if tcpConn, ok := rawConn.(*net.TCPConn); ok { - tcpConn.SetKeepAlive(true) - tcpConn.SetKeepAlivePeriod(30 * time.Second) - } - - colonPos := strings.LastIndex(addr, ":") - if colonPos == -1 { - colonPos = len(addr) - } - hostname := addr[:colonPos] - - // If no ServerName is set, infer the ServerName - // from the hostname we're connecting to. - if config.ServerName == "" { - // Make a copy to avoid polluting argument or default. - c := *config - c.ServerName = hostname - config = &c - } - - conn := tls.Client(rawConn, config) - - if timeout == 0 { - err = conn.Handshake() - } else { - go func() { - errChannel <- conn.Handshake() - }() - - err = <-errChannel - } - - if err != nil { - rawConn.Close() - return nil, err - } - - // This is Docker difference with standard's crypto/tls package: returned a - // wrapper which holds both the TLS and raw connections. - return &tlsClientCon{conn, rawConn}, nil -} - -func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { - if tlsConfig != nil && proto != "unix" { - // Notice this isn't Go standard's tls.Dial function - return tlsDial(proto, addr, tlsConfig) - } - return net.Dial(proto, addr) -} diff --git a/components/engine/api/client/lib/history.go b/components/engine/api/client/lib/history.go deleted file mode 100644 index 4fb4e5d8df..0000000000 --- a/components/engine/api/client/lib/history.go +++ /dev/null @@ -1,23 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageHistory returns the changes in an image in history format. -func (cli *Client) ImageHistory(imageID string) ([]types.ImageHistory, error) { - var history []types.ImageHistory - serverResp, err := cli.get("/images/"+imageID+"/history", url.Values{}, nil) - if err != nil { - return history, err - } - defer ensureReaderClosed(serverResp) - - if err := json.NewDecoder(serverResp.body).Decode(&history); err != nil { - return history, err - } - return history, nil -} diff --git a/components/engine/api/client/lib/image_build.go b/components/engine/api/client/lib/image_build.go deleted file mode 100644 index c6d8740477..0000000000 --- a/components/engine/api/client/lib/image_build.go +++ /dev/null @@ -1,127 +0,0 @@ -package lib - -import ( - "encoding/base64" - "encoding/json" - "net/http" - "net/url" - "regexp" - "strconv" - "strings" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" -) - -var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`) - -// ImageBuild sends request to the daemon to build images. -// The Body in the response implement an io.ReadCloser and it's up to the caller to -// close it. -func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error) { - query, err := imageBuildOptionsToQuery(options) - if err != nil { - return types.ImageBuildResponse{}, err - } - - headers := http.Header(make(map[string][]string)) - buf, err := json.Marshal(options.AuthConfigs) - if err != nil { - return types.ImageBuildResponse{}, err - } - headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) - headers.Set("Content-Type", "application/tar") - - serverResp, err := cli.postRaw("/build", query, options.Context, headers) - if err != nil { - return types.ImageBuildResponse{}, err - } - - osType := getDockerOS(serverResp.header.Get("Server")) - - return types.ImageBuildResponse{ - Body: serverResp.body, - OSType: osType, - }, nil -} - -func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, error) { - query := url.Values{ - "t": options.Tags, - } - if options.SuppressOutput { - query.Set("q", "1") - } - if options.RemoteContext != "" { - query.Set("remote", options.RemoteContext) - } - if options.NoCache { - query.Set("nocache", "1") - } - if options.Remove { - query.Set("rm", "1") - } else { - query.Set("rm", "0") - } - - if options.ForceRemove { - query.Set("forcerm", "1") - } - - if options.PullParent { - query.Set("pull", "1") - } - - if !container.IsolationLevel.IsDefault(options.IsolationLevel) { - query.Set("isolation", string(options.IsolationLevel)) - } - - query.Set("cpusetcpus", options.CPUSetCPUs) - query.Set("cpusetmems", options.CPUSetMems) - query.Set("cpushares", strconv.FormatInt(options.CPUShares, 10)) - query.Set("cpuquota", strconv.FormatInt(options.CPUQuota, 10)) - query.Set("cpuperiod", strconv.FormatInt(options.CPUPeriod, 10)) - query.Set("memory", strconv.FormatInt(options.Memory, 10)) - query.Set("memswap", strconv.FormatInt(options.MemorySwap, 10)) - query.Set("cgroupparent", options.CgroupParent) - query.Set("shmsize", strconv.FormatInt(options.ShmSize, 10)) - query.Set("dockerfile", options.Dockerfile) - - ulimitsJSON, err := json.Marshal(options.Ulimits) - if err != nil { - return query, err - } - query.Set("ulimits", string(ulimitsJSON)) - - buildArgsJSON, err := json.Marshal(options.BuildArgs) - if err != nil { - return query, err - } - query.Set("buildargs", string(buildArgsJSON)) - - return query, nil -} - -func getDockerOS(serverHeader string) string { - var osType string - matches := headerRegexp.FindStringSubmatch(serverHeader) - if len(matches) > 0 { - osType = matches[1] - } - return osType -} - -// convertKVStringsToMap converts ["key=value"] to {"key":"value"} -func convertKVStringsToMap(values []string) map[string]string { - result := make(map[string]string, len(values)) - for _, value := range values { - kv := strings.SplitN(value, "=", 2) - if len(kv) == 1 { - result[kv[0]] = "" - } else { - result[kv[0]] = kv[1] - } - } - - return result -} diff --git a/components/engine/api/client/lib/image_build_test.go b/components/engine/api/client/lib/image_build_test.go deleted file mode 100644 index a1737f14c9..0000000000 --- a/components/engine/api/client/lib/image_build_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package lib - -import "testing" - -func TestGetDockerOS(t *testing.T) { - cases := map[string]string{ - "Docker/v1.22 (linux)": "linux", - "Docker/v1.22 (windows)": "windows", - "Foo/v1.22 (bar)": "", - } - for header, os := range cases { - g := getDockerOS(header) - if g != os { - t.Fatalf("Expected %s, got %s", os, g) - } - } -} diff --git a/components/engine/api/client/lib/image_create.go b/components/engine/api/client/lib/image_create.go deleted file mode 100644 index f4070d62c0..0000000000 --- a/components/engine/api/client/lib/image_create.go +++ /dev/null @@ -1,26 +0,0 @@ -package lib - -import ( - "io" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageCreate creates a new image based in the parent options. -// It returns the JSON content in the response body. -func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) { - query := url.Values{} - query.Set("fromImage", options.Parent) - query.Set("tag", options.Tag) - resp, err := cli.tryImageCreate(query, options.RegistryAuth) - if err != nil { - return nil, err - } - return resp.body, nil -} - -func (cli *Client) tryImageCreate(query url.Values, registryAuth string) (*serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} - return cli.post("/images/create", query, nil, headers) -} diff --git a/components/engine/api/client/lib/image_import.go b/components/engine/api/client/lib/image_import.go deleted file mode 100644 index fbd487bf9a..0000000000 --- a/components/engine/api/client/lib/image_import.go +++ /dev/null @@ -1,27 +0,0 @@ -package lib - -import ( - "io" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageImport creates a new image based in the source options. -// It returns the JSON content in the response body. -func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error) { - query := url.Values{} - query.Set("fromSrc", options.SourceName) - query.Set("repo", options.RepositoryName) - query.Set("tag", options.Tag) - query.Set("message", options.Message) - for _, change := range options.Changes { - query.Add("changes", change) - } - - resp, err := cli.postRaw("/images/create", query, options.Source, nil) - if err != nil { - return nil, err - } - return resp.body, nil -} diff --git a/components/engine/api/client/lib/image_inspect.go b/components/engine/api/client/lib/image_inspect.go deleted file mode 100644 index 59f991f689..0000000000 --- a/components/engine/api/client/lib/image_inspect.go +++ /dev/null @@ -1,37 +0,0 @@ -package lib - -import ( - "bytes" - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageInspectWithRaw returns the image information and it's raw representation. -func (cli *Client) ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error) { - query := url.Values{} - if getSize { - query.Set("size", "1") - } - serverResp, err := cli.get("/images/"+imageID+"/json", query, nil) - if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return types.ImageInspect{}, nil, imageNotFoundError{imageID} - } - return types.ImageInspect{}, nil, err - } - defer ensureReaderClosed(serverResp) - - body, err := ioutil.ReadAll(serverResp.body) - if err != nil { - return types.ImageInspect{}, nil, err - } - - var response types.ImageInspect - rdr := bytes.NewReader(body) - err = json.NewDecoder(rdr).Decode(&response) - return response, body, err -} diff --git a/components/engine/api/client/lib/image_list.go b/components/engine/api/client/lib/image_list.go deleted file mode 100644 index 61c62bfe57..0000000000 --- a/components/engine/api/client/lib/image_list.go +++ /dev/null @@ -1,39 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" -) - -// ImageList returns a list of images in the docker host. -func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error) { - var images []types.Image - query := url.Values{} - - if options.Filters.Len() > 0 { - filterJSON, err := filters.ToParam(options.Filters) - if err != nil { - return images, err - } - query.Set("filters", filterJSON) - } - if options.MatchName != "" { - // FIXME rename this parameter, to not be confused with the filters flag - query.Set("filter", options.MatchName) - } - if options.All { - query.Set("all", "1") - } - - serverResp, err := cli.get("/images/json", query, nil) - if err != nil { - return images, err - } - defer ensureReaderClosed(serverResp) - - err = json.NewDecoder(serverResp.body).Decode(&images) - return images, err -} diff --git a/components/engine/api/client/lib/image_load.go b/components/engine/api/client/lib/image_load.go deleted file mode 100644 index 1fcb904523..0000000000 --- a/components/engine/api/client/lib/image_load.go +++ /dev/null @@ -1,22 +0,0 @@ -package lib - -import ( - "io" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageLoad loads an image in the docker host from the client host. -// It's up to the caller to close the io.ReadCloser returned by -// this function. -func (cli *Client) ImageLoad(input io.Reader) (types.ImageLoadResponse, error) { - resp, err := cli.postRaw("/images/load", url.Values{}, input, nil) - if err != nil { - return types.ImageLoadResponse{}, err - } - return types.ImageLoadResponse{ - Body: resp.body, - JSON: resp.header.Get("Content-Type") == "application/json", - }, nil -} diff --git a/components/engine/api/client/lib/image_pull.go b/components/engine/api/client/lib/image_pull.go deleted file mode 100644 index 98fd6e86f2..0000000000 --- a/components/engine/api/client/lib/image_pull.go +++ /dev/null @@ -1,34 +0,0 @@ -package lib - -import ( - "io" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImagePull request the docker host to pull an image from a remote registry. -// It executes the privileged function if the operation is unauthorized -// and it tries one more time. -// It's up to the caller to handle the io.ReadCloser and close it properly. -func (cli *Client) ImagePull(options types.ImagePullOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error) { - query := url.Values{} - query.Set("fromImage", options.ImageID) - if options.Tag != "" { - query.Set("tag", options.Tag) - } - - resp, err := cli.tryImageCreate(query, options.RegistryAuth) - if resp.statusCode == http.StatusUnauthorized { - newAuthHeader, privilegeErr := privilegeFunc() - if privilegeErr != nil { - return nil, privilegeErr - } - resp, err = cli.tryImageCreate(query, newAuthHeader) - } - if err != nil { - return nil, err - } - return resp.body, nil -} diff --git a/components/engine/api/client/lib/image_push.go b/components/engine/api/client/lib/image_push.go deleted file mode 100644 index 620ea7d510..0000000000 --- a/components/engine/api/client/lib/image_push.go +++ /dev/null @@ -1,36 +0,0 @@ -package lib - -import ( - "io" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImagePush request the docker host to push an image to a remote registry. -// It executes the privileged function if the operation is unauthorized -// and it tries one more time. -// It's up to the caller to handle the io.ReadCloser and close it properly. -func (cli *Client) ImagePush(options types.ImagePushOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error) { - query := url.Values{} - query.Set("tag", options.Tag) - - resp, err := cli.tryImagePush(options.ImageID, query, options.RegistryAuth) - if resp.statusCode == http.StatusUnauthorized { - newAuthHeader, privilegeErr := privilegeFunc() - if privilegeErr != nil { - return nil, privilegeErr - } - resp, err = cli.tryImagePush(options.ImageID, query, newAuthHeader) - } - if err != nil { - return nil, err - } - return resp.body, nil -} - -func (cli *Client) tryImagePush(imageID string, query url.Values, registryAuth string) (*serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} - return cli.post("/images/"+imageID+"/push", query, nil, headers) -} diff --git a/components/engine/api/client/lib/image_remove.go b/components/engine/api/client/lib/image_remove.go deleted file mode 100644 index d0ec6040dc..0000000000 --- a/components/engine/api/client/lib/image_remove.go +++ /dev/null @@ -1,30 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageRemove removes an image from the docker host. -func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) { - query := url.Values{} - - if options.Force { - query.Set("force", "1") - } - if !options.PruneChildren { - query.Set("noprune", "1") - } - - resp, err := cli.delete("/images/"+options.ImageID, query, nil) - if err != nil { - return nil, err - } - defer ensureReaderClosed(resp) - - var dels []types.ImageDelete - err = json.NewDecoder(resp.body).Decode(&dels) - return dels, err -} diff --git a/components/engine/api/client/lib/image_save.go b/components/engine/api/client/lib/image_save.go deleted file mode 100644 index 10fb6130e8..0000000000 --- a/components/engine/api/client/lib/image_save.go +++ /dev/null @@ -1,20 +0,0 @@ -package lib - -import ( - "io" - "net/url" -) - -// ImageSave retrieves one or more images from the docker host as a io.ReadCloser. -// It's up to the caller to store the images and close the stream. -func (cli *Client) ImageSave(imageIDs []string) (io.ReadCloser, error) { - query := url.Values{ - "names": imageIDs, - } - - resp, err := cli.get("/images/get", query, nil) - if err != nil { - return nil, err - } - return resp.body, nil -} diff --git a/components/engine/api/client/lib/image_search.go b/components/engine/api/client/lib/image_search.go deleted file mode 100644 index 3f9f24e1e7..0000000000 --- a/components/engine/api/client/lib/image_search.go +++ /dev/null @@ -1,39 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/registry" -) - -// ImageSearch makes the docker host to search by a term in a remote registry. -// The list of results is not sorted in any fashion. -func (cli *Client) ImageSearch(options types.ImageSearchOptions, privilegeFunc RequestPrivilegeFunc) ([]registry.SearchResult, error) { - var results []registry.SearchResult - query := url.Values{} - query.Set("term", options.Term) - - resp, err := cli.tryImageSearch(query, options.RegistryAuth) - if resp.statusCode == http.StatusUnauthorized { - newAuthHeader, privilegeErr := privilegeFunc() - if privilegeErr != nil { - return results, privilegeErr - } - resp, err = cli.tryImageSearch(query, newAuthHeader) - } - if err != nil { - return results, err - } - defer ensureReaderClosed(resp) - - err = json.NewDecoder(resp.body).Decode(&results) - return results, err -} - -func (cli *Client) tryImageSearch(query url.Values, registryAuth string) (*serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} - return cli.get("/images/search", query, headers) -} diff --git a/components/engine/api/client/lib/image_tag.go b/components/engine/api/client/lib/image_tag.go deleted file mode 100644 index a0a2230fb2..0000000000 --- a/components/engine/api/client/lib/image_tag.go +++ /dev/null @@ -1,21 +0,0 @@ -package lib - -import ( - "net/url" - - "github.com/docker/engine-api/types" -) - -// ImageTag tags an image in the docker host -func (cli *Client) ImageTag(options types.ImageTagOptions) error { - query := url.Values{} - query.Set("repo", options.RepositoryName) - query.Set("tag", options.Tag) - if options.Force { - query.Set("force", "1") - } - - resp, err := cli.post("/images/"+options.ImageID+"/tag", query, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/info.go b/components/engine/api/client/lib/info.go deleted file mode 100644 index e1fa4229ea..0000000000 --- a/components/engine/api/client/lib/info.go +++ /dev/null @@ -1,25 +0,0 @@ -package lib - -import ( - "encoding/json" - "fmt" - "net/url" - - "github.com/docker/engine-api/types" -) - -// Info returns information about the docker server. -func (cli *Client) Info() (types.Info, error) { - var info types.Info - serverResp, err := cli.get("/info", url.Values{}, nil) - if err != nil { - return info, err - } - defer ensureReaderClosed(serverResp) - - if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil { - return info, fmt.Errorf("Error reading remote info: %v", err) - } - - return info, nil -} diff --git a/components/engine/api/client/lib/kill.go b/components/engine/api/client/lib/kill.go deleted file mode 100644 index 4da1a94008..0000000000 --- a/components/engine/api/client/lib/kill.go +++ /dev/null @@ -1,13 +0,0 @@ -package lib - -import "net/url" - -// ContainerKill terminates the container process but does not remove the container from the docker host. -func (cli *Client) ContainerKill(containerID, signal string) error { - query := url.Values{} - query.Set("signal", signal) - - resp, err := cli.post("/containers/"+containerID+"/kill", query, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/login.go b/components/engine/api/client/lib/login.go deleted file mode 100644 index 426533f0ef..0000000000 --- a/components/engine/api/client/lib/login.go +++ /dev/null @@ -1,27 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" -) - -// RegistryLogin authenticates the docker server with a given docker registry. -// It returns UnauthorizerError when the authentication fails. -func (cli *Client) RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error) { - resp, err := cli.post("/auth", url.Values{}, auth, nil) - - if resp != nil && resp.statusCode == http.StatusUnauthorized { - return types.AuthResponse{}, unauthorizedError{err} - } - if err != nil { - return types.AuthResponse{}, err - } - defer ensureReaderClosed(resp) - - var response types.AuthResponse - err = json.NewDecoder(resp.body).Decode(&response) - return response, err -} diff --git a/components/engine/api/client/lib/logs.go b/components/engine/api/client/lib/logs.go deleted file mode 100644 index f3fe1770ef..0000000000 --- a/components/engine/api/client/lib/logs.go +++ /dev/null @@ -1,46 +0,0 @@ -package lib - -import ( - "io" - "net/url" - "time" - - "github.com/docker/engine-api/types" - timetypes "github.com/docker/engine-api/types/time" -) - -// ContainerLogs returns the logs generated by a container in an io.ReadCloser. -// It's up to the caller to close the stream. -func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error) { - query := url.Values{} - if options.ShowStdout { - query.Set("stdout", "1") - } - - if options.ShowStderr { - query.Set("stderr", "1") - } - - if options.Since != "" { - ts, err := timetypes.GetTimestamp(options.Since, time.Now()) - if err != nil { - return nil, err - } - query.Set("since", ts) - } - - if options.Timestamps { - query.Set("timestamps", "1") - } - - if options.Follow { - query.Set("follow", "1") - } - query.Set("tail", options.Tail) - - resp, err := cli.get("/containers/"+options.ContainerID+"/logs", query, nil) - if err != nil { - return nil, err - } - return resp.body, nil -} diff --git a/components/engine/api/client/lib/network.go b/components/engine/api/client/lib/network.go deleted file mode 100644 index ba80ca39c4..0000000000 --- a/components/engine/api/client/lib/network.go +++ /dev/null @@ -1,82 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" -) - -// NetworkCreate creates a new network in the docker host. -func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) { - var response types.NetworkCreateResponse - serverResp, err := cli.post("/networks/create", nil, options, nil) - if err != nil { - return response, err - } - - json.NewDecoder(serverResp.body).Decode(&response) - ensureReaderClosed(serverResp) - return response, err -} - -// NetworkRemove removes an existent network from the docker host. -func (cli *Client) NetworkRemove(networkID string) error { - resp, err := cli.delete("/networks/"+networkID, nil, nil) - ensureReaderClosed(resp) - return err -} - -// NetworkConnect connects a container to an existent network in the docker host. -func (cli *Client) NetworkConnect(networkID, containerID string) error { - nc := types.NetworkConnect{Container: containerID} - resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil) - ensureReaderClosed(resp) - return err -} - -// NetworkDisconnect disconnects a container from an existent network in the docker host. -func (cli *Client) NetworkDisconnect(networkID, containerID string) error { - nc := types.NetworkConnect{Container: containerID} - resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nc, nil) - ensureReaderClosed(resp) - return err -} - -// NetworkList returns the list of networks configured in the docker host. -func (cli *Client) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) { - query := url.Values{} - if options.Filters.Len() > 0 { - filterJSON, err := filters.ToParam(options.Filters) - if err != nil { - return nil, err - } - - query.Set("filters", filterJSON) - } - var networkResources []types.NetworkResource - resp, err := cli.get("/networks", query, nil) - if err != nil { - return networkResources, err - } - defer ensureReaderClosed(resp) - err = json.NewDecoder(resp.body).Decode(&networkResources) - return networkResources, err -} - -// NetworkInspect returns the information for a specific network configured in the docker host. -func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error) { - var networkResource types.NetworkResource - resp, err := cli.get("/networks/"+networkID, nil, nil) - if err != nil { - if resp.statusCode == http.StatusNotFound { - return networkResource, networkNotFoundError{networkID} - } - return networkResource, err - } - defer ensureReaderClosed(resp) - err = json.NewDecoder(resp.body).Decode(&networkResource) - return networkResource, err -} diff --git a/components/engine/api/client/lib/pause.go b/components/engine/api/client/lib/pause.go deleted file mode 100644 index 3247ec3a57..0000000000 --- a/components/engine/api/client/lib/pause.go +++ /dev/null @@ -1,8 +0,0 @@ -package lib - -// ContainerPause pauses the main process of a given container without terminating it. -func (cli *Client) ContainerPause(containerID string) error { - resp, err := cli.post("/containers/"+containerID+"/pause", nil, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/privileged.go b/components/engine/api/client/lib/privileged.go deleted file mode 100644 index cb3da51ea8..0000000000 --- a/components/engine/api/client/lib/privileged.go +++ /dev/null @@ -1,9 +0,0 @@ -package lib - -// RequestPrivilegeFunc is a function interface that -// clients can supply to retry operations after -// getting an authorization error. -// This function returns the registry authentication -// header value in base 64 format, or an error -// if the privilege request fails. -type RequestPrivilegeFunc func() (string, error) diff --git a/components/engine/api/client/lib/request.go b/components/engine/api/client/lib/request.go deleted file mode 100644 index 67984d116b..0000000000 --- a/components/engine/api/client/lib/request.go +++ /dev/null @@ -1,176 +0,0 @@ -package lib - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// serverResponse is a wrapper for http API responses. -type serverResponse struct { - body io.ReadCloser - header http.Header - statusCode int -} - -// head sends an http request to the docker API using the method HEAD. -func (cli *Client) head(path string, query url.Values, headers map[string][]string) (*serverResponse, error) { - return cli.sendRequest("HEAD", path, query, nil, headers) -} - -// get sends an http request to the docker API using the method GET. -func (cli *Client) get(path string, query url.Values, headers map[string][]string) (*serverResponse, error) { - return cli.sendRequest("GET", path, query, nil, headers) -} - -// post sends an http request to the docker API using the method POST. -func (cli *Client) post(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) { - return cli.sendRequest("POST", path, query, body, headers) -} - -// postRaw sends the raw input to the docker API using the method POST. -func (cli *Client) postRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) { - return cli.sendClientRequest("POST", path, query, body, headers) -} - -// put sends an http request to the docker API using the method PUT. -func (cli *Client) put(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) { - return cli.sendRequest("PUT", path, query, body, headers) -} - -// putRaw sends the raw input to the docker API using the method PUT. -func (cli *Client) putRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) { - return cli.sendClientRequest("PUT", path, query, body, headers) -} - -// delete sends an http request to the docker API using the method DELETE. -func (cli *Client) delete(path string, query url.Values, headers map[string][]string) (*serverResponse, error) { - return cli.sendRequest("DELETE", path, query, nil, headers) -} - -func (cli *Client) sendRequest(method, path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) { - params, err := encodeData(body) - if err != nil { - return nil, err - } - - if body != nil { - if headers == nil { - headers = make(map[string][]string) - } - headers["Content-Type"] = []string{"application/json"} - } - - return cli.sendClientRequest(method, path, query, params, headers) -} - -func (cli *Client) sendClientRequest(method, path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) { - serverResp := &serverResponse{ - body: nil, - statusCode: -1, - } - - expectedPayload := (method == "POST" || method == "PUT") - if expectedPayload && body == nil { - body = bytes.NewReader([]byte{}) - } - - req, err := cli.newRequest(method, path, query, body, headers) - req.URL.Host = cli.addr - req.URL.Scheme = cli.scheme - - if expectedPayload && req.Header.Get("Content-Type") == "" { - req.Header.Set("Content-Type", "text/plain") - } - - resp, err := cli.httpClient.Do(req) - if resp != nil { - serverResp.statusCode = resp.StatusCode - } - - if err != nil { - if isTimeout(err) || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") { - return serverResp, ErrConnectionFailed - } - - if cli.scheme == "http" && strings.Contains(err.Error(), "malformed HTTP response") { - return serverResp, fmt.Errorf("%v.\n* Are you trying to connect to a TLS-enabled daemon without TLS?", err) - } - if cli.scheme == "https" && strings.Contains(err.Error(), "remote error: bad certificate") { - return serverResp, fmt.Errorf("The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: %v", err) - } - - return serverResp, fmt.Errorf("An error occurred trying to connect: %v", err) - } - - if serverResp.statusCode < 200 || serverResp.statusCode >= 400 { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return serverResp, err - } - if len(body) == 0 { - return serverResp, fmt.Errorf("Error: request returned %s for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), req.URL) - } - return serverResp, fmt.Errorf("Error response from daemon: %s", bytes.TrimSpace(body)) - } - - serverResp.body = resp.Body - serverResp.header = resp.Header - return serverResp, nil -} - -func (cli *Client) newRequest(method, path string, query url.Values, body io.Reader, headers map[string][]string) (*http.Request, error) { - apiPath := cli.getAPIPath(path, query) - req, err := http.NewRequest(method, apiPath, body) - if err != nil { - return nil, err - } - - // Add CLI Config's HTTP Headers BEFORE we set the Docker headers - // then the user can't change OUR headers - for k, v := range cli.customHTTPHeaders { - req.Header.Set(k, v) - } - - if headers != nil { - for k, v := range headers { - req.Header[k] = v - } - } - - return req, nil -} - -func encodeData(data interface{}) (*bytes.Buffer, error) { - params := bytes.NewBuffer(nil) - if data != nil { - if err := json.NewEncoder(params).Encode(data); err != nil { - return nil, err - } - } - return params, nil -} - -func ensureReaderClosed(response *serverResponse) { - if response != nil && response.body != nil { - response.body.Close() - } -} - -func isTimeout(err error) bool { - type timeout interface { - Timeout() bool - } - e := err - switch urlErr := err.(type) { - case *url.Error: - e = urlErr.Err - } - t, ok := e.(timeout) - return ok && t.Timeout() -} diff --git a/components/engine/api/client/lib/resize.go b/components/engine/api/client/lib/resize.go deleted file mode 100644 index 4040368fbc..0000000000 --- a/components/engine/api/client/lib/resize.go +++ /dev/null @@ -1,28 +0,0 @@ -package lib - -import ( - "net/url" - "strconv" - - "github.com/docker/engine-api/types" -) - -// ContainerResize changes the size of the tty for a container. -func (cli *Client) ContainerResize(options types.ResizeOptions) error { - return cli.resize("/containers/"+options.ID, options.Height, options.Width) -} - -// ContainerExecResize changes the size of the tty for an exec process running inside a container. -func (cli *Client) ContainerExecResize(options types.ResizeOptions) error { - return cli.resize("/exec/"+options.ID, options.Height, options.Width) -} - -func (cli *Client) resize(basePath string, height, width int) error { - query := url.Values{} - query.Set("h", strconv.Itoa(height)) - query.Set("w", strconv.Itoa(width)) - - resp, err := cli.post(basePath+"/resize", query, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/version.go b/components/engine/api/client/lib/version.go deleted file mode 100644 index 2b03ac4ea7..0000000000 --- a/components/engine/api/client/lib/version.go +++ /dev/null @@ -1,20 +0,0 @@ -package lib - -import ( - "encoding/json" - - "github.com/docker/engine-api/types" -) - -// ServerVersion returns information of the docker client and server host. -func (cli *Client) ServerVersion() (types.Version, error) { - resp, err := cli.get("/version", nil, nil) - if err != nil { - return types.Version{}, err - } - defer ensureReaderClosed(resp) - - var server types.Version - err = json.NewDecoder(resp.body).Decode(&server) - return server, err -} diff --git a/components/engine/api/client/lib/volume.go b/components/engine/api/client/lib/volume.go deleted file mode 100644 index f41f75bf09..0000000000 --- a/components/engine/api/client/lib/volume.go +++ /dev/null @@ -1,66 +0,0 @@ -package lib - -import ( - "encoding/json" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" -) - -// VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, error) { - var volumes types.VolumesListResponse - query := url.Values{} - - if filter.Len() > 0 { - filterJSON, err := filters.ToParam(filter) - if err != nil { - return volumes, err - } - query.Set("filters", filterJSON) - } - resp, err := cli.get("/volumes", query, nil) - if err != nil { - return volumes, err - } - defer ensureReaderClosed(resp) - - err = json.NewDecoder(resp.body).Decode(&volumes) - return volumes, err -} - -// VolumeInspect returns the information about a specific volume in the docker host. -func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) { - var volume types.Volume - resp, err := cli.get("/volumes/"+volumeID, nil, nil) - if err != nil { - if resp.statusCode == http.StatusNotFound { - return volume, volumeNotFoundError{volumeID} - } - return volume, err - } - defer ensureReaderClosed(resp) - err = json.NewDecoder(resp.body).Decode(&volume) - return volume, err -} - -// VolumeCreate creates a volume in the docker host. -func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) { - var volume types.Volume - resp, err := cli.post("/volumes/create", nil, options, nil) - if err != nil { - return volume, err - } - defer ensureReaderClosed(resp) - err = json.NewDecoder(resp.body).Decode(&volume) - return volume, err -} - -// VolumeRemove removes a volume from the docker host. -func (cli *Client) VolumeRemove(volumeID string) error { - resp, err := cli.delete("/volumes/"+volumeID, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/components/engine/api/client/lib/wait.go b/components/engine/api/client/lib/wait.go deleted file mode 100644 index e490e09965..0000000000 --- a/components/engine/api/client/lib/wait.go +++ /dev/null @@ -1,24 +0,0 @@ -package lib - -import ( - "encoding/json" - - "github.com/docker/engine-api/types" -) - -// ContainerWait pauses execution util a container is exits. -// It returns the API status code as response of its readiness. -func (cli *Client) ContainerWait(containerID string) (int, error) { - resp, err := cli.post("/containers/"+containerID+"/wait", nil, nil, nil) - if err != nil { - return -1, err - } - defer ensureReaderClosed(resp) - - var res types.ContainerWaitResponse - if err := json.NewDecoder(resp.body).Decode(&res); err != nil { - return -1, err - } - - return res.StatusCode, nil -} diff --git a/components/engine/api/types/auth.go b/components/engine/api/types/auth.go deleted file mode 100644 index 6cd4c36a83..0000000000 --- a/components/engine/api/types/auth.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -// AuthConfig contains authorization information for connecting to a Registry -type AuthConfig struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Auth string `json:"auth"` - Email string `json:"email"` - ServerAddress string `json:"serveraddress,omitempty"` - RegistryToken string `json:"registrytoken,omitempty"` -} diff --git a/components/engine/api/types/blkiodev/blkio.go b/components/engine/api/types/blkiodev/blkio.go deleted file mode 100644 index 458a9c96bb..0000000000 --- a/components/engine/api/types/blkiodev/blkio.go +++ /dev/null @@ -1,23 +0,0 @@ -package blkiodev - -import "fmt" - -// WeightDevice is a structure that hold device:weight pair -type WeightDevice struct { - Path string - Weight uint16 -} - -func (w *WeightDevice) String() string { - return fmt.Sprintf("%s:%d", w.Path, w.Weight) -} - -// ThrottleDevice is a structure that hold device:rate_per_second pair -type ThrottleDevice struct { - Path string - Rate uint64 -} - -func (t *ThrottleDevice) String() string { - return fmt.Sprintf("%s:%d", t.Path, t.Rate) -} diff --git a/components/engine/api/types/client.go b/components/engine/api/types/client.go deleted file mode 100644 index 77d94f33a1..0000000000 --- a/components/engine/api/types/client.go +++ /dev/null @@ -1,245 +0,0 @@ -package types - -import ( - "bufio" - "io" - "net" - - "github.com/docker/engine-api/types/container" - "github.com/docker/engine-api/types/filters" - "github.com/docker/go-units" -) - -// ContainerAttachOptions holds parameters to attach to a container. -type ContainerAttachOptions struct { - ContainerID string - Stream bool - Stdin bool - Stdout bool - Stderr bool - DetachKeys string -} - -// ContainerCommitOptions holds parameters to commit changes into a container. -type ContainerCommitOptions struct { - ContainerID string - RepositoryName string - Tag string - Comment string - Author string - Changes []string - Pause bool - Config *container.Config -} - -// ContainerExecInspect holds information returned by exec inspect. -type ContainerExecInspect struct { - ExecID string - ContainerID string - Running bool - ExitCode int -} - -// ContainerListOptions holds parameters to list containers with. -type ContainerListOptions struct { - Quiet bool - Size bool - All bool - Latest bool - Since string - Before string - Limit int - Filter filters.Args -} - -// ContainerLogsOptions holds parameters to filter logs with. -type ContainerLogsOptions struct { - ContainerID string - ShowStdout bool - ShowStderr bool - Since string - Timestamps bool - Follow bool - Tail string -} - -// ContainerRemoveOptions holds parameters to remove containers. -type ContainerRemoveOptions struct { - ContainerID string - RemoveVolumes bool - RemoveLinks bool - Force bool -} - -// CopyToContainerOptions holds information -// about files to copy into a container -type CopyToContainerOptions struct { - ContainerID string - Path string - Content io.Reader - AllowOverwriteDirWithFile bool -} - -// EventsOptions hold parameters to filter events with. -type EventsOptions struct { - Since string - Until string - Filters filters.Args -} - -// NetworkListOptions holds parameters to filter the list of networks with. -type NetworkListOptions struct { - Filters filters.Args -} - -// HijackedResponse holds connection information for a hijacked request. -type HijackedResponse struct { - Conn net.Conn - Reader *bufio.Reader -} - -// Close closes the hijacked connection and reader. -func (h *HijackedResponse) Close() { - h.Conn.Close() -} - -// CloseWriter is an interface that implement structs -// that close input streams to prevent from writing. -type CloseWriter interface { - CloseWrite() error -} - -// CloseWrite closes a readWriter for writing. -func (h *HijackedResponse) CloseWrite() error { - if conn, ok := h.Conn.(CloseWriter); ok { - return conn.CloseWrite() - } - return nil -} - -// ImageBuildOptions holds the information -// necessary to build images. -type ImageBuildOptions struct { - Tags []string - SuppressOutput bool - RemoteContext string - NoCache bool - Remove bool - ForceRemove bool - PullParent bool - IsolationLevel container.IsolationLevel - CPUSetCPUs string - CPUSetMems string - CPUShares int64 - CPUQuota int64 - CPUPeriod int64 - Memory int64 - MemorySwap int64 - CgroupParent string - ShmSize int64 - Dockerfile string - Ulimits []*units.Ulimit - BuildArgs map[string]string - AuthConfigs map[string]AuthConfig - Context io.Reader -} - -// ImageBuildResponse holds information -// returned by a server after building -// an image. -type ImageBuildResponse struct { - Body io.ReadCloser - OSType string -} - -// ImageCreateOptions holds information to create images. -type ImageCreateOptions struct { - // Parent is the image to create this image from - Parent string - // Tag is the name to tag this image - Tag string - // RegistryAuth is the base64 encoded credentials for this server - RegistryAuth string -} - -// ImageImportOptions holds information to import images from the client host. -type ImageImportOptions struct { - // Source is the data to send to the server to create this image from - Source io.Reader - // Source is the name of the source to import this image from - SourceName string - // RepositoryName is the name of the repository to import this image - RepositoryName string - // Message is the message to tag the image with - Message string - // Tag is the name to tag this image - Tag string - // Changes are the raw changes to apply to the image - Changes []string -} - -// ImageListOptions holds parameters to filter the list of images with. -type ImageListOptions struct { - MatchName string - All bool - Filters filters.Args -} - -// ImageLoadResponse returns information to the client about a load process. -type ImageLoadResponse struct { - Body io.ReadCloser - JSON bool -} - -// ImagePullOptions holds information to pull images. -type ImagePullOptions struct { - ImageID string - Tag string - // RegistryAuth is the base64 encoded credentials for this server - RegistryAuth string -} - -//ImagePushOptions holds information to push images. -type ImagePushOptions ImagePullOptions - -// ImageRemoveOptions holds parameters to remove images. -type ImageRemoveOptions struct { - ImageID string - Force bool - PruneChildren bool -} - -// ImageSearchOptions holds parameters to search images with. -type ImageSearchOptions struct { - Term string - RegistryAuth string -} - -// ImageTagOptions holds parameters to tag an image -type ImageTagOptions struct { - ImageID string - RepositoryName string - Tag string - Force bool -} - -// ResizeOptions holds parameters to resize a tty. -// It can be used to resize container ttys and -// exec process ttys too. -type ResizeOptions struct { - ID string - Height int - Width int -} - -// VersionResponse holds version information for the client and the server -type VersionResponse struct { - Client *Version - Server *Version -} - -// ServerOK return true when the client could connect to the docker server -// and parse the information received. It returns false otherwise. -func (v VersionResponse) ServerOK() bool { - return v.Server != nil -} diff --git a/components/engine/api/types/configs.go b/components/engine/api/types/configs.go deleted file mode 100644 index fafbb5b53e..0000000000 --- a/components/engine/api/types/configs.go +++ /dev/null @@ -1,50 +0,0 @@ -package types - -import "github.com/docker/engine-api/types/container" - -// configs holds structs used for internal communication between the -// frontend (such as an http server) and the backend (such as the -// docker daemon). - -// ContainerCreateConfig is the parameter set to ContainerCreate() -type ContainerCreateConfig struct { - Name string - Config *container.Config - HostConfig *container.HostConfig - AdjustCPUShares bool -} - -// ContainerRmConfig holds arguments for the container remove -// operation. This struct is used to tell the backend what operations -// to perform. -type ContainerRmConfig struct { - ForceRemove, RemoveVolume, RemoveLink bool -} - -// ContainerCommitConfig contains build configs for commit operation, -// and is used when making a commit with the current state of the container. -type ContainerCommitConfig struct { - Pause bool - Repo string - Tag string - Author string - Comment string - // merge container config into commit config before commit - MergeConfigs bool - Config *container.Config -} - -// ExecConfig is a small subset of the Config struct that hold the configuration -// for the exec feature of docker. -type ExecConfig struct { - User string // User that will run the command - Privileged bool // Is the container in privileged mode - Tty bool // Attach standard streams to a tty. - Container string // Name of the container (to execute in) - AttachStdin bool // Attach the standard input, makes possible user interaction - AttachStderr bool // Attach the standard output - AttachStdout bool // Attach the standard error - Detach bool // Execute in detach mode - DetachKeys string // Escape keys for detach - Cmd []string // Execution commands and args -} diff --git a/components/engine/api/types/container/config.go b/components/engine/api/types/container/config.go deleted file mode 100644 index b4e6205d21..0000000000 --- a/components/engine/api/types/container/config.go +++ /dev/null @@ -1,38 +0,0 @@ -package container - -import ( - "github.com/docker/engine-api/types/strslice" - "github.com/docker/go-connections/nat" -) - -// Config contains the configuration data about a container. -// It should hold only portable information about the container. -// Here, "portable" means "independent from the host we are running on". -// Non-portable information *should* appear in HostConfig. -// All fields added to this struct must be marked `omitempty` to keep getting -// predictable hashes from the old `v1Compatibility` configuration. -type Config struct { - Hostname string // Hostname - Domainname string // Domainname - User string // User that will run the command(s) inside the container - AttachStdin bool // Attach the standard input, makes possible user interaction - AttachStdout bool // Attach the standard output - AttachStderr bool // Attach the standard error - ExposedPorts map[nat.Port]struct{} `json:",omitempty"` // List of exposed ports - PublishService string `json:",omitempty"` // Name of the network service exposed by the container - Tty bool // Attach standard streams to a tty, including stdin if it is not closed. - OpenStdin bool // Open stdin - StdinOnce bool // If true, close stdin after the 1 attached client disconnects. - Env []string // List of environment variable to set in the container - Cmd *strslice.StrSlice // Command to run when starting the container - ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) - Image string // Name of the image as it was passed by the operator (eg. could be symbolic) - Volumes map[string]struct{} // List of volumes (mounts) used for the container - WorkingDir string // Current directory (PWD) in the command will be launched - Entrypoint *strslice.StrSlice // Entrypoint to run when starting the container - NetworkDisabled bool `json:",omitempty"` // Is network disabled - MacAddress string `json:",omitempty"` // Mac Address of the container - OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile - Labels map[string]string // List of labels set to this container - StopSignal string `json:",omitempty"` // Signal to stop a container -} diff --git a/components/engine/api/types/container/host_config.go b/components/engine/api/types/container/host_config.go deleted file mode 100644 index ac425921b8..0000000000 --- a/components/engine/api/types/container/host_config.go +++ /dev/null @@ -1,227 +0,0 @@ -package container - -import ( - "strings" - - "github.com/docker/engine-api/types/blkiodev" - "github.com/docker/engine-api/types/strslice" - "github.com/docker/go-connections/nat" - "github.com/docker/go-units" -) - -// NetworkMode represents the container network stack. -type NetworkMode string - -// IsolationLevel represents the isolation level of a container. The supported -// values are platform specific -type IsolationLevel string - -// IsDefault indicates the default isolation level of a container. On Linux this -// is the native driver. On Windows, this is a Windows Server Container. -func (i IsolationLevel) IsDefault() bool { - return strings.ToLower(string(i)) == "default" || string(i) == "" -} - -// IpcMode represents the container ipc stack. -type IpcMode string - -// IsPrivate indicates whether the container uses it's private ipc stack. -func (n IpcMode) IsPrivate() bool { - return !(n.IsHost() || n.IsContainer()) -} - -// IsHost indicates whether the container uses the host's ipc stack. -func (n IpcMode) IsHost() bool { - return n == "host" -} - -// IsContainer indicates whether the container uses a container's ipc stack. -func (n IpcMode) IsContainer() bool { - parts := strings.SplitN(string(n), ":", 2) - return len(parts) > 1 && parts[0] == "container" -} - -// Valid indicates whether the ipc stack is valid. -func (n IpcMode) Valid() bool { - parts := strings.Split(string(n), ":") - switch mode := parts[0]; mode { - case "", "host": - case "container": - if len(parts) != 2 || parts[1] == "" { - return false - } - default: - return false - } - return true -} - -// Container returns the name of the container ipc stack is going to be used. -func (n IpcMode) Container() string { - parts := strings.SplitN(string(n), ":", 2) - if len(parts) > 1 { - return parts[1] - } - return "" -} - -// UTSMode represents the UTS namespace of the container. -type UTSMode string - -// IsPrivate indicates whether the container uses it's private UTS namespace. -func (n UTSMode) IsPrivate() bool { - return !(n.IsHost()) -} - -// IsHost indicates whether the container uses the host's UTS namespace. -func (n UTSMode) IsHost() bool { - return n == "host" -} - -// Valid indicates whether the UTS namespace is valid. -func (n UTSMode) Valid() bool { - parts := strings.Split(string(n), ":") - switch mode := parts[0]; mode { - case "", "host": - default: - return false - } - return true -} - -// PidMode represents the pid stack of the container. -type PidMode string - -// IsPrivate indicates whether the container uses it's private pid stack. -func (n PidMode) IsPrivate() bool { - return !(n.IsHost()) -} - -// IsHost indicates whether the container uses the host's pid stack. -func (n PidMode) IsHost() bool { - return n == "host" -} - -// Valid indicates whether the pid stack is valid. -func (n PidMode) Valid() bool { - parts := strings.Split(string(n), ":") - switch mode := parts[0]; mode { - case "", "host": - default: - return false - } - return true -} - -// DeviceMapping represents the device mapping between the host and the container. -type DeviceMapping struct { - PathOnHost string - PathInContainer string - CgroupPermissions string -} - -// RestartPolicy represents the restart policies of the container. -type RestartPolicy struct { - Name string - MaximumRetryCount int -} - -// IsNone indicates whether the container has the "no" restart policy. -// This means the container will not automatically restart when exiting. -func (rp *RestartPolicy) IsNone() bool { - return rp.Name == "no" -} - -// IsAlways indicates whether the container has the "always" restart policy. -// This means the container will automatically restart regardless of the exit status. -func (rp *RestartPolicy) IsAlways() bool { - return rp.Name == "always" -} - -// IsOnFailure indicates whether the container has the "on-failure" restart policy. -// This means the contain will automatically restart of exiting with a non-zero exit status. -func (rp *RestartPolicy) IsOnFailure() bool { - return rp.Name == "on-failure" -} - -// IsUnlessStopped indicates whether the container has the -// "unless-stopped" restart policy. This means the container will -// automatically restart unless user has put it to stopped state. -func (rp *RestartPolicy) IsUnlessStopped() bool { - return rp.Name == "unless-stopped" -} - -// LogConfig represents the logging configuration of the container. -type LogConfig struct { - Type string - Config map[string]string -} - -// Resources contains container's resources (cgroups config, ulimits...) -type Resources struct { - // Applicable to all platforms - CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) - - // Applicable to UNIX platforms - CgroupParent string // Parent cgroup. - BlkioWeight uint16 // Block IO weight (relative weight vs. other containers) - BlkioWeightDevice []*blkiodev.WeightDevice - BlkioDeviceReadBps []*blkiodev.ThrottleDevice - BlkioDeviceWriteBps []*blkiodev.ThrottleDevice - BlkioDeviceReadIOps []*blkiodev.ThrottleDevice - BlkioDeviceWriteIOps []*blkiodev.ThrottleDevice - CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period - CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota - CpusetCpus string // CpusetCpus 0-2, 0,1 - CpusetMems string // CpusetMems 0-2, 0,1 - Devices []DeviceMapping // List of devices to map inside the container - KernelMemory int64 // Kernel memory limit (in bytes) - Memory int64 // Memory limit (in bytes) - MemoryReservation int64 // Memory soft limit (in bytes) - MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap - MemorySwappiness *int64 // Tuning container memory swappiness behaviour - OomKillDisable bool // Whether to disable OOM Killer or not - Ulimits []*units.Ulimit // List of ulimits to be set in the container -} - -// HostConfig the non-portable Config structure of a container. -// Here, "non-portable" means "dependent of the host we are running on". -// Portable information *should* appear in Config. -type HostConfig struct { - // Applicable to all platforms - Binds []string // List of volume bindings for this container - ContainerIDFile string // File (path) where the containerId is written - LogConfig LogConfig // Configuration of the logs for this container - NetworkMode NetworkMode // Network mode to use for the container - PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host - RestartPolicy RestartPolicy // Restart policy to be used for the container - VolumeDriver string // Name of the volume driver used to mount volumes - VolumesFrom []string // List of volumes to take from other container - - // Applicable to UNIX platforms - CapAdd *strslice.StrSlice // List of kernel capabilities to add to the container - CapDrop *strslice.StrSlice // List of kernel capabilities to remove from the container - DNS []string `json:"Dns"` // List of DNS server to lookup - DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for - DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for - ExtraHosts []string // List of extra hosts - GroupAdd []string // List of additional groups that the container process will run as - IpcMode IpcMode // IPC namespace to use for the container - Links []string // List of links (in the name:alias form) - OomScoreAdj int // Container preference for OOM-killing - PidMode PidMode // PID namespace to use for the container - Privileged bool // Is the container in privileged mode - PublishAllPorts bool // Should docker publish all exposed port for the container - ReadonlyRootfs bool // Is the container root filesystem in read-only - SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. - Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container - UTSMode UTSMode // UTS namespace to use for the container - ShmSize int64 // Total shm memory usage - - // Applicable to Windows - ConsoleSize [2]int // Initial console size - Isolation IsolationLevel // Isolation level of the container (eg default, hyperv) - - // Contains container's resources (cgroups, ulimits) - Resources -} diff --git a/components/engine/api/types/container/hostconfig_unix.go b/components/engine/api/types/container/hostconfig_unix.go deleted file mode 100644 index 775e903f1c..0000000000 --- a/components/engine/api/types/container/hostconfig_unix.go +++ /dev/null @@ -1,87 +0,0 @@ -// +build !windows - -package container - -import "strings" - -// IsValid indicates is an isolation level is valid -func (i IsolationLevel) IsValid() bool { - return i.IsDefault() -} - -// IsPrivate indicates whether container uses it's private network stack. -func (n NetworkMode) IsPrivate() bool { - return !(n.IsHost() || n.IsContainer()) -} - -// IsDefault indicates whether container uses the default network stack. -func (n NetworkMode) IsDefault() bool { - return n == "default" -} - -// NetworkName returns the name of the network stack. -func (n NetworkMode) NetworkName() string { - if n.IsBridge() { - return "bridge" - } else if n.IsHost() { - return "host" - } else if n.IsContainer() { - return "container" - } else if n.IsNone() { - return "none" - } else if n.IsDefault() { - return "default" - } else if n.IsUserDefined() { - return n.UserDefined() - } - return "" -} - -// IsBridge indicates whether container uses the bridge network stack -func (n NetworkMode) IsBridge() bool { - return n == "bridge" -} - -// IsHost indicates whether container uses the host network stack. -func (n NetworkMode) IsHost() bool { - return n == "host" -} - -// IsContainer indicates whether container uses a container network stack. -func (n NetworkMode) IsContainer() bool { - parts := strings.SplitN(string(n), ":", 2) - return len(parts) > 1 && parts[0] == "container" -} - -// IsNone indicates whether container isn't using a network stack. -func (n NetworkMode) IsNone() bool { - return n == "none" -} - -// ConnectedContainer is the id of the container which network this container is connected to. -func (n NetworkMode) ConnectedContainer() string { - parts := strings.SplitN(string(n), ":", 2) - if len(parts) > 1 { - return parts[1] - } - return "" -} - -// IsUserDefined indicates user-created network -func (n NetworkMode) IsUserDefined() bool { - return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() -} - -// IsPreDefinedNetwork indicates if a network is predefined by the daemon -func IsPreDefinedNetwork(network string) bool { - n := NetworkMode(network) - return n.IsBridge() || n.IsHost() || n.IsNone() -} - -//UserDefined indicates user-created network -func (n NetworkMode) UserDefined() string { - if n.IsUserDefined() { - return string(n) - } - return "" -} diff --git a/components/engine/api/types/container/hostconfig_windows.go b/components/engine/api/types/container/hostconfig_windows.go deleted file mode 100644 index 16267ff416..0000000000 --- a/components/engine/api/types/container/hostconfig_windows.go +++ /dev/null @@ -1,75 +0,0 @@ -package container - -import ( - "fmt" - "strings" -) - -// IsDefault indicates whether container uses the default network stack. -func (n NetworkMode) IsDefault() bool { - return n == "default" -} - -// IsHyperV indicates the use of a Hyper-V partition for isolation -func (i IsolationLevel) IsHyperV() bool { - return strings.ToLower(string(i)) == "hyperv" -} - -// IsProcess indicates the use of process isolation -func (i IsolationLevel) IsProcess() bool { - return strings.ToLower(string(i)) == "process" -} - -// IsValid indicates is an isolation level is valid -func (i IsolationLevel) IsValid() bool { - return i.IsDefault() || i.IsHyperV() || i.IsProcess() -} - -// DefaultDaemonNetworkMode returns the default network stack the daemon should -// use. -func DefaultDaemonNetworkMode() NetworkMode { - return NetworkMode("default") -} - -// NetworkName returns the name of the network stack. -func (n NetworkMode) NetworkName() string { - if n.IsDefault() { - return "default" - } - return "" -} - -// IsPreDefinedNetwork indicates if a network is predefined by the daemon -func IsPreDefinedNetwork(network string) bool { - return false -} - -// ValidateNetMode ensures that the various combinations of requested -// network settings are valid. -func ValidateNetMode(c *Config, hc *HostConfig) error { - // We may not be passed a host config, such as in the case of docker commit - if hc == nil { - return nil - } - parts := strings.Split(string(hc.NetworkMode), ":") - switch mode := parts[0]; mode { - case "default", "none": - default: - return fmt.Errorf("invalid --net: %s", hc.NetworkMode) - } - return nil -} - -// ValidateIsolationLevel performs platform specific validation of the -// isolation level in the hostconfig structure. Windows supports 'default' (or -// blank), 'process', or 'hyperv'. -func ValidateIsolationLevel(hc *HostConfig) error { - // We may not be passed a host config, such as in the case of docker commit - if hc == nil { - return nil - } - if !hc.Isolation.IsValid() { - return fmt.Errorf("invalid --isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation) - } - return nil -} diff --git a/components/engine/api/types/events/events.go b/components/engine/api/types/events/events.go deleted file mode 100644 index c5987aaf14..0000000000 --- a/components/engine/api/types/events/events.go +++ /dev/null @@ -1,38 +0,0 @@ -package events - -const ( - // ContainerEventType is the event type that containers generate - ContainerEventType = "container" - // ImageEventType is the event type that images generate - ImageEventType = "image" - // VolumeEventType is the event type that volumes generate - VolumeEventType = "volume" - // NetworkEventType is the event type that networks generate - NetworkEventType = "network" -) - -// Actor describes something that generates events, -// like a container, or a network, or a volume. -// It has a defined name and a set or attributes. -// The container attributes are its labels, other actors -// can generate these attributes from other properties. -type Actor struct { - ID string - Attributes map[string]string -} - -// Message represents the information an event contains -type Message struct { - // Deprecated information from JSONMessage. - // With data only in container events. - Status string `json:"status,omitempty"` - ID string `json:"id,omitempty"` - From string `json:"from,omitempty"` - - Type string - Action string - Actor Actor - - Time int64 `json:"time,omitempty"` - TimeNano int64 `json:"timeNano,omitempty"` -} diff --git a/components/engine/api/types/filters/parse.go b/components/engine/api/types/filters/parse.go deleted file mode 100644 index e99462c0a8..0000000000 --- a/components/engine/api/types/filters/parse.go +++ /dev/null @@ -1,257 +0,0 @@ -// Package filters provides helper function to parse and handle command line -// filter, used for example in docker ps or docker images commands. -package filters - -import ( - "encoding/json" - "errors" - "fmt" - "regexp" - "strings" -) - -// Args stores filter arguments as map key:{array of values}. -// It contains a aggregation of the list of arguments (which are in the form -// of -f 'key=value') based on the key, and store values for the same key -// in an slice. -// e.g given -f 'label=label1=1' -f 'label=label2=2' -f 'image.name=ubuntu' -// the args will be {'label': {'label1=1','label2=2'}, 'image.name', {'ubuntu'}} -type Args struct { - fields map[string]map[string]bool -} - -// NewArgs initializes a new Args struct. -func NewArgs() Args { - return Args{fields: map[string]map[string]bool{}} -} - -// ParseFlag parses the argument to the filter flag. Like -// -// `docker ps -f 'created=today' -f 'image.name=ubuntu*'` -// -// If prev map is provided, then it is appended to, and returned. By default a new -// map is created. -func ParseFlag(arg string, prev Args) (Args, error) { - filters := prev - if len(arg) == 0 { - return filters, nil - } - - if !strings.Contains(arg, "=") { - return filters, ErrBadFormat - } - - f := strings.SplitN(arg, "=", 2) - - name := strings.ToLower(strings.TrimSpace(f[0])) - value := strings.TrimSpace(f[1]) - - filters.Add(name, value) - - return filters, nil -} - -// ErrBadFormat is an error returned in case of bad format for a filter. -var ErrBadFormat = errors.New("bad format of filter (expected name=value)") - -// ToParam packs the Args into an string for easy transport from client to server. -func ToParam(a Args) (string, error) { - // this way we don't URL encode {}, just empty space - if a.Len() == 0 { - return "", nil - } - - buf, err := json.Marshal(a.fields) - if err != nil { - return "", err - } - return string(buf), nil -} - -// FromParam unpacks the filter Args. -func FromParam(p string) (Args, error) { - if len(p) == 0 { - return NewArgs(), nil - } - - r := strings.NewReader(p) - d := json.NewDecoder(r) - - m := map[string]map[string]bool{} - if err := d.Decode(&m); err != nil { - r.Seek(0, 0) - - // Allow parsing old arguments in slice format. - // Because other libraries might be sending them in this format. - deprecated := map[string][]string{} - if deprecatedErr := d.Decode(&deprecated); deprecatedErr == nil { - m = deprecatedArgs(deprecated) - } else { - return NewArgs(), err - } - } - return Args{m}, nil -} - -// Get returns the list of values associates with a field. -// It returns a slice of strings to keep backwards compatibility with old code. -func (filters Args) Get(field string) []string { - values := filters.fields[field] - if values == nil { - return make([]string, 0) - } - slice := make([]string, 0, len(values)) - for key := range values { - slice = append(slice, key) - } - return slice -} - -// Add adds a new value to a filter field. -func (filters Args) Add(name, value string) { - if _, ok := filters.fields[name]; ok { - filters.fields[name][value] = true - } else { - filters.fields[name] = map[string]bool{value: true} - } -} - -// Del removes a value from a filter field. -func (filters Args) Del(name, value string) { - if _, ok := filters.fields[name]; ok { - delete(filters.fields[name], value) - } -} - -// Len returns the number of fields in the arguments. -func (filters Args) Len() int { - return len(filters.fields) -} - -// MatchKVList returns true if the values for the specified field matches the ones -// from the sources. -// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, -// field is 'label' and sources are {'label1': '1', 'label2': '2'} -// it returns true. -func (filters Args) MatchKVList(field string, sources map[string]string) bool { - fieldValues := filters.fields[field] - - //do not filter if there is no filter set or cannot determine filter - if len(fieldValues) == 0 { - return true - } - - if sources == nil || len(sources) == 0 { - return false - } - - for name2match := range fieldValues { - testKV := strings.SplitN(name2match, "=", 2) - - v, ok := sources[testKV[0]] - if !ok { - return false - } - if len(testKV) == 2 && testKV[1] != v { - return false - } - } - - return true -} - -// Match returns true if the values for the specified field matches the source string -// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, -// field is 'image.name' and source is 'ubuntu' -// it returns true. -func (filters Args) Match(field, source string) bool { - if filters.ExactMatch(field, source) { - return true - } - - fieldValues := filters.fields[field] - for name2match := range fieldValues { - match, err := regexp.MatchString(name2match, source) - if err != nil { - continue - } - if match { - return true - } - } - return false -} - -// ExactMatch returns true if the source matches exactly one of the filters. -func (filters Args) ExactMatch(field, source string) bool { - fieldValues, ok := filters.fields[field] - //do not filter if there is no filter set or cannot determine filter - if !ok || len(fieldValues) == 0 { - return true - } - - // try to march full name value to avoid O(N) regular expression matching - if fieldValues[source] { - return true - } - return false -} - -// FuzzyMatch returns true if the source matches exactly one of the filters, -// or the source has one of the filters as a prefix. -func (filters Args) FuzzyMatch(field, source string) bool { - if filters.ExactMatch(field, source) { - return true - } - - fieldValues := filters.fields[field] - for prefix := range fieldValues { - if strings.HasPrefix(source, prefix) { - return true - } - } - return false -} - -// Include returns true if the name of the field to filter is in the filters. -func (filters Args) Include(field string) bool { - _, ok := filters.fields[field] - return ok -} - -// Validate ensures that all the fields in the filter are valid. -// It returns an error as soon as it finds an invalid field. -func (filters Args) Validate(accepted map[string]bool) error { - for name := range filters.fields { - if !accepted[name] { - return fmt.Errorf("Invalid filter '%s'", name) - } - } - return nil -} - -// WalkValues iterates over the list of filtered values for a field. -// It stops the iteration if it finds an error and it returns that error. -func (filters Args) WalkValues(field string, op func(value string) error) error { - if _, ok := filters.fields[field]; !ok { - return nil - } - for v := range filters.fields[field] { - if err := op(v); err != nil { - return err - } - } - return nil -} - -func deprecatedArgs(d map[string][]string) map[string]map[string]bool { - m := map[string]map[string]bool{} - for k, v := range d { - values := map[string]bool{} - for _, vv := range v { - values[vv] = true - } - m[k] = values - } - return m -} diff --git a/components/engine/api/types/filters/parse_test.go b/components/engine/api/types/filters/parse_test.go deleted file mode 100644 index 4d5c814551..0000000000 --- a/components/engine/api/types/filters/parse_test.go +++ /dev/null @@ -1,369 +0,0 @@ -package filters - -import ( - "fmt" - "testing" -) - -func TestParseArgs(t *testing.T) { - // equivalent of `docker ps -f 'created=today' -f 'image.name=ubuntu*' -f 'image.name=*untu'` - flagArgs := []string{ - "created=today", - "image.name=ubuntu*", - "image.name=*untu", - } - var ( - args = NewArgs() - err error - ) - for i := range flagArgs { - args, err = ParseFlag(flagArgs[i], args) - if err != nil { - t.Errorf("failed to parse %s: %s", flagArgs[i], err) - } - } - if len(args.Get("created")) != 1 { - t.Errorf("failed to set this arg") - } - if len(args.Get("image.name")) != 2 { - t.Errorf("the args should have collapsed") - } -} - -func TestParseArgsEdgeCase(t *testing.T) { - var filters Args - args, err := ParseFlag("", filters) - if err != nil { - t.Fatal(err) - } - if args.Len() != 0 { - t.Fatalf("Expected an empty Args (map), got %v", args) - } - if args, err = ParseFlag("anything", args); err == nil || err != ErrBadFormat { - t.Fatalf("Expected ErrBadFormat, got %v", err) - } -} - -func TestToParam(t *testing.T) { - fields := map[string]map[string]bool{ - "created": {"today": true}, - "image.name": {"ubuntu*": true, "*untu": true}, - } - a := Args{fields: fields} - - _, err := ToParam(a) - if err != nil { - t.Errorf("failed to marshal the filters: %s", err) - } -} - -func TestFromParam(t *testing.T) { - invalids := []string{ - "anything", - "['a','list']", - "{'key': 'value'}", - `{"key": "value"}`, - } - valid := map[*Args][]string{ - &Args{fields: map[string]map[string]bool{"key": {"value": true}}}: { - `{"key": ["value"]}`, - `{"key": {"value": true}}`, - }, - &Args{fields: map[string]map[string]bool{"key": {"value1": true, "value2": true}}}: { - `{"key": ["value1", "value2"]}`, - `{"key": {"value1": true, "value2": true}}`, - }, - &Args{fields: map[string]map[string]bool{"key1": {"value1": true}, "key2": {"value2": true}}}: { - `{"key1": ["value1"], "key2": ["value2"]}`, - `{"key1": {"value1": true}, "key2": {"value2": true}}`, - }, - } - - for _, invalid := range invalids { - if _, err := FromParam(invalid); err == nil { - t.Fatalf("Expected an error with %v, got nothing", invalid) - } - } - - for expectedArgs, matchers := range valid { - for _, json := range matchers { - args, err := FromParam(json) - if err != nil { - t.Fatal(err) - } - if args.Len() != expectedArgs.Len() { - t.Fatalf("Expected %v, go %v", expectedArgs, args) - } - for key, expectedValues := range expectedArgs.fields { - values := args.Get(key) - - if len(values) != len(expectedValues) { - t.Fatalf("Expected %v, go %v", expectedArgs, args) - } - - for _, v := range values { - if !expectedValues[v] { - t.Fatalf("Expected %v, go %v", expectedArgs, args) - } - } - } - } - } -} - -func TestEmpty(t *testing.T) { - a := Args{} - v, err := ToParam(a) - if err != nil { - t.Errorf("failed to marshal the filters: %s", err) - } - v1, err := FromParam(v) - if err != nil { - t.Errorf("%s", err) - } - if a.Len() != v1.Len() { - t.Errorf("these should both be empty sets") - } -} - -func TestArgsMatchKVListEmptySources(t *testing.T) { - args := NewArgs() - if !args.MatchKVList("created", map[string]string{}) { - t.Fatalf("Expected true for (%v,created), got true", args) - } - - args = Args{map[string]map[string]bool{"created": {"today": true}}} - if args.MatchKVList("created", map[string]string{}) { - t.Fatalf("Expected false for (%v,created), got true", args) - } -} - -func TestArgsMatchKVList(t *testing.T) { - // Not empty sources - sources := map[string]string{ - "key1": "value1", - "key2": "value2", - "key3": "value3", - } - - matches := map[*Args]string{ - &Args{}: "field", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today": true}, - "labels": map[string]bool{"key1": true}}, - }: "labels", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today": true}, - "labels": map[string]bool{"key1=value1": true}}, - }: "labels", - } - - for args, field := range matches { - if args.MatchKVList(field, sources) != true { - t.Fatalf("Expected true for %v on %v, got false", sources, args) - } - } - - differs := map[*Args]string{ - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today": true}, - "labels": map[string]bool{"key4": true}}, - }: "labels", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today": true}, - "labels": map[string]bool{"key1=value3": true}}, - }: "labels", - } - - for args, field := range differs { - if args.MatchKVList(field, sources) != false { - t.Fatalf("Expected false for %v on %v, got true", sources, args) - } - } -} - -func TestArgsMatch(t *testing.T) { - source := "today" - - matches := map[*Args]string{ - &Args{}: "field", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today": true}}, - }: "today", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"to*": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"to(.*)": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"tod": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"anyting": true, "to*": true}}, - }: "created", - } - - for args, field := range matches { - if args.Match(field, source) != true { - t.Fatalf("Expected true for %v on %v, got false", source, args) - } - } - - differs := map[*Args]string{ - &Args{map[string]map[string]bool{ - "created": map[string]bool{"tomorrow": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"to(day": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"tom(.*)": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"tom": true}}, - }: "created", - &Args{map[string]map[string]bool{ - "created": map[string]bool{"today1": true}, - "labels": map[string]bool{"today": true}}, - }: "created", - } - - for args, field := range differs { - if args.Match(field, source) != false { - t.Fatalf("Expected false for %v on %v, got true", source, args) - } - } -} - -func TestAdd(t *testing.T) { - f := NewArgs() - f.Add("status", "running") - v := f.fields["status"] - if len(v) != 1 || !v["running"] { - t.Fatalf("Expected to include a running status, got %v", v) - } - - f.Add("status", "paused") - if len(v) != 2 || !v["paused"] { - t.Fatalf("Expected to include a paused status, got %v", v) - } -} - -func TestDel(t *testing.T) { - f := NewArgs() - f.Add("status", "running") - f.Del("status", "running") - v := f.fields["status"] - if v["running"] { - t.Fatalf("Expected to not include a running status filter, got true") - } -} - -func TestLen(t *testing.T) { - f := NewArgs() - if f.Len() != 0 { - t.Fatalf("Expected to not include any field") - } - f.Add("status", "running") - if f.Len() != 1 { - t.Fatalf("Expected to include one field") - } -} - -func TestExactMatch(t *testing.T) { - f := NewArgs() - - if !f.ExactMatch("status", "running") { - t.Fatalf("Expected to match `running` when there are no filters, got false") - } - - f.Add("status", "running") - f.Add("status", "pause*") - - if !f.ExactMatch("status", "running") { - t.Fatalf("Expected to match `running` with one of the filters, got false") - } - - if f.ExactMatch("status", "paused") { - t.Fatalf("Expected to not match `paused` with one of the filters, got true") - } -} - -func TestInclude(t *testing.T) { - f := NewArgs() - if f.Include("status") { - t.Fatalf("Expected to not include a status key, got true") - } - f.Add("status", "running") - if !f.Include("status") { - t.Fatalf("Expected to include a status key, got false") - } -} - -func TestValidate(t *testing.T) { - f := NewArgs() - f.Add("status", "running") - - valid := map[string]bool{ - "status": true, - "dangling": true, - } - - if err := f.Validate(valid); err != nil { - t.Fatal(err) - } - - f.Add("bogus", "running") - if err := f.Validate(valid); err == nil { - t.Fatalf("Expected to return an error, got nil") - } -} - -func TestWalkValues(t *testing.T) { - f := NewArgs() - f.Add("status", "running") - f.Add("status", "paused") - - f.WalkValues("status", func(value string) error { - if value != "running" && value != "paused" { - t.Fatalf("Unexpected value %s", value) - } - return nil - }) - - err := f.WalkValues("status", func(value string) error { - return fmt.Errorf("return") - }) - if err == nil { - t.Fatalf("Expected to get an error, got nil") - } - - err = f.WalkValues("foo", func(value string) error { - return fmt.Errorf("return") - }) - if err != nil { - t.Fatalf("Expected to not iterate when the field doesn't exist, got %v", err) - } -} - -func TestFuzzyMatch(t *testing.T) { - f := NewArgs() - f.Add("container", "foo") - - cases := map[string]bool{ - "foo": true, - "foobar": true, - "barfoo": false, - "bar": false, - } - for source, match := range cases { - got := f.FuzzyMatch("container", source) - if got != match { - t.Fatalf("Expected %v, got %v: %s", match, got, source) - } - } -} diff --git a/components/engine/api/types/network/network.go b/components/engine/api/types/network/network.go deleted file mode 100644 index c81c621178..0000000000 --- a/components/engine/api/types/network/network.go +++ /dev/null @@ -1,33 +0,0 @@ -package network - -// Address represents an IP address -type Address struct { - Addr string - PrefixLen int -} - -// IPAM represents IP Address Management -type IPAM struct { - Driver string - Config []IPAMConfig -} - -// IPAMConfig represents IPAM configurations -type IPAMConfig struct { - Subnet string `json:",omitempty"` - IPRange string `json:",omitempty"` - Gateway string `json:",omitempty"` - AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` -} - -// EndpointSettings stores the network endpoint details -type EndpointSettings struct { - EndpointID string - Gateway string - IPAddress string - IPPrefixLen int - IPv6Gateway string - GlobalIPv6Address string - GlobalIPv6PrefixLen int - MacAddress string -} diff --git a/components/engine/api/types/registry/registry.go b/components/engine/api/types/registry/registry.go deleted file mode 100644 index 4fcf986e7b..0000000000 --- a/components/engine/api/types/registry/registry.go +++ /dev/null @@ -1,101 +0,0 @@ -package registry - -import ( - "encoding/json" - "net" -) - -// ServiceConfig stores daemon registry services configuration. -type ServiceConfig struct { - InsecureRegistryCIDRs []*NetIPNet `json:"InsecureRegistryCIDRs"` - IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"` - Mirrors []string -} - -// NetIPNet is the net.IPNet type, which can be marshalled and -// unmarshalled to JSON -type NetIPNet net.IPNet - -// MarshalJSON returns the JSON representation of the IPNet -func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) { - return json.Marshal((*net.IPNet)(ipnet).String()) -} - -// UnmarshalJSON sets the IPNet from a byte array of JSON -func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) { - var ipnetStr string - if err = json.Unmarshal(b, &ipnetStr); err == nil { - var cidr *net.IPNet - if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil { - *ipnet = NetIPNet(*cidr) - } - } - return -} - -// IndexInfo contains information about a registry -// -// RepositoryInfo Examples: -// { -// "Index" : { -// "Name" : "docker.io", -// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"], -// "Secure" : true, -// "Official" : true, -// }, -// "RemoteName" : "library/debian", -// "LocalName" : "debian", -// "CanonicalName" : "docker.io/debian" -// "Official" : true, -// } -// -// { -// "Index" : { -// "Name" : "127.0.0.1:5000", -// "Mirrors" : [], -// "Secure" : false, -// "Official" : false, -// }, -// "RemoteName" : "user/repo", -// "LocalName" : "127.0.0.1:5000/user/repo", -// "CanonicalName" : "127.0.0.1:5000/user/repo", -// "Official" : false, -// } -type IndexInfo struct { - // Name is the name of the registry, such as "docker.io" - Name string - // Mirrors is a list of mirrors, expressed as URIs - Mirrors []string - // Secure is set to false if the registry is part of the list of - // insecure registries. Insecure registries accept HTTP and/or accept - // HTTPS with certificates from unknown CAs. - Secure bool - // Official indicates whether this is an official registry - Official bool -} - -// SearchResult describes a search result returned from a registry -type SearchResult struct { - // StarCount indicates the number of stars this repository has - StarCount int `json:"star_count"` - // IsOfficial indicates whether the result is an official repository or not - IsOfficial bool `json:"is_official"` - // Name is the name of the repository - Name string `json:"name"` - // IsOfficial indicates whether the result is trusted - IsTrusted bool `json:"is_trusted"` - // IsAutomated indicates whether the result is automated - IsAutomated bool `json:"is_automated"` - // Description is a textual description of the repository - Description string `json:"description"` -} - -// SearchResults lists a collection search results returned from a registry -type SearchResults struct { - // Query contains the query string that generated the search results - Query string `json:"query"` - // NumResults indicates the number of results the query returned - NumResults int `json:"num_results"` - // Results is a slice containing the actual results for the search - Results []SearchResult `json:"results"` -} diff --git a/components/engine/api/types/stats.go b/components/engine/api/types/stats.go deleted file mode 100644 index e21fe39c9d..0000000000 --- a/components/engine/api/types/stats.go +++ /dev/null @@ -1,105 +0,0 @@ -// Package types is used for API stability in the types and response to the -// consumers of the API stats endpoint. -package types - -import "time" - -// ThrottlingData stores CPU throttling stats of one running container -type ThrottlingData struct { - // Number of periods with throttling active - Periods uint64 `json:"periods"` - // Number of periods when the container hit its throttling limit. - ThrottledPeriods uint64 `json:"throttled_periods"` - // Aggregate time the container was throttled for in nanoseconds. - ThrottledTime uint64 `json:"throttled_time"` -} - -// CPUUsage stores All CPU stats aggregated since container inception. -type CPUUsage struct { - // Total CPU time consumed. - // Units: nanoseconds. - TotalUsage uint64 `json:"total_usage"` - // Total CPU time consumed per core. - // Units: nanoseconds. - PercpuUsage []uint64 `json:"percpu_usage"` - // Time spent by tasks of the cgroup in kernel mode. - // Units: nanoseconds. - UsageInKernelmode uint64 `json:"usage_in_kernelmode"` - // Time spent by tasks of the cgroup in user mode. - // Units: nanoseconds. - UsageInUsermode uint64 `json:"usage_in_usermode"` -} - -// CPUStats aggregates and wraps all CPU related info of container -type CPUStats struct { - CPUUsage CPUUsage `json:"cpu_usage"` - SystemUsage uint64 `json:"system_cpu_usage"` - ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` -} - -// MemoryStats aggregates All memory stats since container inception -type MemoryStats struct { - // current res_counter usage for memory - Usage uint64 `json:"usage"` - // maximum usage ever recorded. - MaxUsage uint64 `json:"max_usage"` - // TODO(vishh): Export these as stronger types. - // all the stats exported via memory.stat. - Stats map[string]uint64 `json:"stats"` - // number of times memory usage hits limits. - Failcnt uint64 `json:"failcnt"` - Limit uint64 `json:"limit"` -} - -// BlkioStatEntry is one small entity to store a piece of Blkio stats -// TODO Windows: This can be factored out -type BlkioStatEntry struct { - Major uint64 `json:"major"` - Minor uint64 `json:"minor"` - Op string `json:"op"` - Value uint64 `json:"value"` -} - -// BlkioStats stores All IO service stats for data read and write -// TODO Windows: This can be factored out -type BlkioStats struct { - // number of bytes transferred to and from the block device - IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"` - IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"` - IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"` - IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"` - IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"` - IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"` - IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"` - SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"` -} - -// NetworkStats aggregates All network stats of one container -// TODO Windows: This will require refactoring -type NetworkStats struct { - RxBytes uint64 `json:"rx_bytes"` - RxPackets uint64 `json:"rx_packets"` - RxErrors uint64 `json:"rx_errors"` - RxDropped uint64 `json:"rx_dropped"` - TxBytes uint64 `json:"tx_bytes"` - TxPackets uint64 `json:"tx_packets"` - TxErrors uint64 `json:"tx_errors"` - TxDropped uint64 `json:"tx_dropped"` -} - -// Stats is Ultimate struct aggregating all types of stats of one container -type Stats struct { - Read time.Time `json:"read"` - PreCPUStats CPUStats `json:"precpu_stats,omitempty"` - CPUStats CPUStats `json:"cpu_stats,omitempty"` - MemoryStats MemoryStats `json:"memory_stats,omitempty"` - BlkioStats BlkioStats `json:"blkio_stats,omitempty"` -} - -// StatsJSON is newly used Networks -type StatsJSON struct { - Stats - - // Networks request version >=1.21 - Networks map[string]NetworkStats `json:"networks,omitempty"` -} diff --git a/components/engine/api/types/strslice/strslice.go b/components/engine/api/types/strslice/strslice.go deleted file mode 100644 index 9f3ee620a3..0000000000 --- a/components/engine/api/types/strslice/strslice.go +++ /dev/null @@ -1,71 +0,0 @@ -package strslice - -import ( - "encoding/json" - "strings" -) - -// StrSlice represents a string or an array of strings. -// We need to override the json decoder to accept both options. -type StrSlice struct { - parts []string -} - -// MarshalJSON Marshals (or serializes) the StrSlice into the json format. -// This method is needed to implement json.Marshaller. -func (e *StrSlice) MarshalJSON() ([]byte, error) { - if e == nil { - return []byte{}, nil - } - return json.Marshal(e.Slice()) -} - -// UnmarshalJSON decodes the byte slice whether it's a string or an array of strings. -// This method is needed to implement json.Unmarshaler. -func (e *StrSlice) UnmarshalJSON(b []byte) error { - if len(b) == 0 { - return nil - } - - p := make([]string, 0, 1) - if err := json.Unmarshal(b, &p); err != nil { - var s string - if err := json.Unmarshal(b, &s); err != nil { - return err - } - p = append(p, s) - } - - e.parts = p - return nil -} - -// Len returns the number of parts of the StrSlice. -func (e *StrSlice) Len() int { - if e == nil { - return 0 - } - return len(e.parts) -} - -// Slice gets the parts of the StrSlice as a Slice of string. -func (e *StrSlice) Slice() []string { - if e == nil { - return nil - } - return e.parts -} - -// ToString gets space separated string of all the parts. -func (e *StrSlice) ToString() string { - s := e.Slice() - if s == nil { - return "" - } - return strings.Join(s, " ") -} - -// New creates an StrSlice based on the specified parts (as strings). -func New(parts ...string) *StrSlice { - return &StrSlice{parts} -} diff --git a/components/engine/api/types/strslice/strslice_test.go b/components/engine/api/types/strslice/strslice_test.go deleted file mode 100644 index 50955c1be2..0000000000 --- a/components/engine/api/types/strslice/strslice_test.go +++ /dev/null @@ -1,135 +0,0 @@ -package strslice - -import ( - "encoding/json" - "reflect" - "testing" -) - -func TestStrSliceMarshalJSON(t *testing.T) { - strss := map[*StrSlice]string{ - nil: "", - &StrSlice{}: "null", - &StrSlice{[]string{"/bin/sh", "-c", "echo"}}: `["/bin/sh","-c","echo"]`, - } - - for strs, expected := range strss { - data, err := strs.MarshalJSON() - if err != nil { - t.Fatal(err) - } - if string(data) != expected { - t.Fatalf("Expected %v, got %v", expected, string(data)) - } - } -} - -func TestStrSliceUnmarshalJSON(t *testing.T) { - parts := map[string][]string{ - "": {"default", "values"}, - "[]": {}, - `["/bin/sh","-c","echo"]`: {"/bin/sh", "-c", "echo"}, - } - for json, expectedParts := range parts { - strs := &StrSlice{ - []string{"default", "values"}, - } - if err := strs.UnmarshalJSON([]byte(json)); err != nil { - t.Fatal(err) - } - - actualParts := strs.Slice() - if len(actualParts) != len(expectedParts) { - t.Fatalf("Expected %v parts, got %v (%v)", len(expectedParts), len(actualParts), expectedParts) - } - for index, part := range actualParts { - if part != expectedParts[index] { - t.Fatalf("Expected %v, got %v", expectedParts, actualParts) - break - } - } - } -} - -func TestStrSliceUnmarshalString(t *testing.T) { - var e *StrSlice - echo, err := json.Marshal("echo") - if err != nil { - t.Fatal(err) - } - if err := json.Unmarshal(echo, &e); err != nil { - t.Fatal(err) - } - - slice := e.Slice() - if len(slice) != 1 { - t.Fatalf("expected 1 element after unmarshal: %q", slice) - } - - if slice[0] != "echo" { - t.Fatalf("expected `echo`, got: %q", slice[0]) - } -} - -func TestStrSliceUnmarshalSlice(t *testing.T) { - var e *StrSlice - echo, err := json.Marshal([]string{"echo"}) - if err != nil { - t.Fatal(err) - } - if err := json.Unmarshal(echo, &e); err != nil { - t.Fatal(err) - } - - slice := e.Slice() - if len(slice) != 1 { - t.Fatalf("expected 1 element after unmarshal: %q", slice) - } - - if slice[0] != "echo" { - t.Fatalf("expected `echo`, got: %q", slice[0]) - } -} - -func TestStrSliceToString(t *testing.T) { - slices := map[*StrSlice]string{ - New(""): "", - New("one"): "one", - New("one", "two"): "one two", - } - for s, expected := range slices { - toString := s.ToString() - if toString != expected { - t.Fatalf("Expected %v, got %v", expected, toString) - } - } -} - -func TestStrSliceLen(t *testing.T) { - var emptyStrSlice *StrSlice - slices := map[*StrSlice]int{ - New(""): 1, - New("one"): 1, - New("one", "two"): 2, - emptyStrSlice: 0, - } - for s, expected := range slices { - if s.Len() != expected { - t.Fatalf("Expected %d, got %d", s.Len(), expected) - } - } -} - -func TestStrSliceSlice(t *testing.T) { - var emptyStrSlice *StrSlice - slices := map[*StrSlice][]string{ - New("one"): {"one"}, - New("one", "two"): {"one", "two"}, - emptyStrSlice: nil, - } - for s, expected := range slices { - if !reflect.DeepEqual(s.Slice(), expected) { - t.Fatalf("Expected %v, got %v", s.Slice(), expected) - } - } -} diff --git a/components/engine/api/types/time/timestamp.go b/components/engine/api/types/time/timestamp.go deleted file mode 100644 index 68895ec727..0000000000 --- a/components/engine/api/types/time/timestamp.go +++ /dev/null @@ -1,124 +0,0 @@ -package time - -import ( - "fmt" - "math" - "strconv" - "strings" - "time" -) - -// These are additional predefined layouts for use in Time.Format and Time.Parse -// with --since and --until parameters for `docker logs` and `docker events` -const ( - rFC3339Local = "2006-01-02T15:04:05" // RFC3339 with local timezone - rFC3339NanoLocal = "2006-01-02T15:04:05.999999999" // RFC3339Nano with local timezone - dateWithZone = "2006-01-02Z07:00" // RFC3339 with time at 00:00:00 - dateLocal = "2006-01-02" // RFC3339 with local timezone and time at 00:00:00 -) - -// GetTimestamp tries to parse given string as golang duration, -// then RFC3339 time and finally as a Unix timestamp. If -// any of these were successful, it returns a Unix timestamp -// as string otherwise returns the given value back. -// In case of duration input, the returned timestamp is computed -// as the given reference time minus the amount of the duration. -func GetTimestamp(value string, reference time.Time) (string, error) { - if d, err := time.ParseDuration(value); value != "0" && err == nil { - return strconv.FormatInt(reference.Add(-d).Unix(), 10), nil - } - - var format string - var parseInLocation bool - - // if the string has a Z or a + or three dashes use parse otherwise use parseinlocation - parseInLocation = !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3) - - if strings.Contains(value, ".") { - if parseInLocation { - format = rFC3339NanoLocal - } else { - format = time.RFC3339Nano - } - } else if strings.Contains(value, "T") { - // we want the number of colons in the T portion of the timestamp - tcolons := strings.Count(value, ":") - // if parseInLocation is off and we have a +/- zone offset (not Z) then - // there will be an extra colon in the input for the tz offset subtract that - // colon from the tcolons count - if !parseInLocation && !strings.ContainsAny(value, "zZ") && tcolons > 0 { - tcolons-- - } - if parseInLocation { - switch tcolons { - case 0: - format = "2006-01-02T15" - case 1: - format = "2006-01-02T15:04" - default: - format = rFC3339Local - } - } else { - switch tcolons { - case 0: - format = "2006-01-02T15Z07:00" - case 1: - format = "2006-01-02T15:04Z07:00" - default: - format = time.RFC3339 - } - } - } else if parseInLocation { - format = dateLocal - } else { - format = dateWithZone - } - - var t time.Time - var err error - - if parseInLocation { - t, err = time.ParseInLocation(format, value, time.FixedZone(time.Now().Zone())) - } else { - t, err = time.Parse(format, value) - } - - if err != nil { - // if there is a `-` then its an RFC3339 like timestamp otherwise assume unixtimestamp - if strings.Contains(value, "-") { - return "", err // was probably an RFC3339 like timestamp but the parser failed with an error - } - return value, nil // unixtimestamp in and out case (meaning: the value passed at the command line is already in the right format for passing to the server) - } - - return fmt.Sprintf("%d.%09d", t.Unix(), int64(t.Nanosecond())), nil -} - -// ParseTimestamps returns seconds and nanoseconds from a timestamp that has the -// format "%d.%09d", time.Unix(), int64(time.Nanosecond())) -// if the incoming nanosecond portion is longer or shorter than 9 digits it is -// converted to nanoseconds. The expectation is that the seconds and -// seconds will be used to create a time variable. For example: -// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0) -// if err == nil since := time.Unix(seconds, nanoseconds) -// returns seconds as def(aultSeconds) if value == "" -func ParseTimestamps(value string, def int64) (int64, int64, error) { - if value == "" { - return def, 0, nil - } - sa := strings.SplitN(value, ".", 2) - s, err := strconv.ParseInt(sa[0], 10, 64) - if err != nil { - return s, 0, err - } - if len(sa) != 2 { - return s, 0, nil - } - n, err := strconv.ParseInt(sa[1], 10, 64) - if err != nil { - return s, n, err - } - // should already be in nanoseconds but just in case convert n to nanoseonds - n = int64(float64(n) * math.Pow(float64(10), float64(9-len(sa[1])))) - return s, n, nil -} diff --git a/components/engine/api/types/time/timestamp_test.go b/components/engine/api/types/time/timestamp_test.go deleted file mode 100644 index 19854d0ea3..0000000000 --- a/components/engine/api/types/time/timestamp_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package time - -import ( - "fmt" - "testing" - "time" -) - -func TestGetTimestamp(t *testing.T) { - now := time.Now() - cases := []struct { - in, expected string - expectedErr bool - }{ - // Partial RFC3339 strings get parsed with second precision - {"2006-01-02T15:04:05.999999999+07:00", "1136189045.999999999", false}, - {"2006-01-02T15:04:05.999999999Z", "1136214245.999999999", false}, - {"2006-01-02T15:04:05.999999999", "1136214245.999999999", false}, - {"2006-01-02T15:04:05Z", "1136214245.000000000", false}, - {"2006-01-02T15:04:05", "1136214245.000000000", false}, - {"2006-01-02T15:04:0Z", "", true}, - {"2006-01-02T15:04:0", "", true}, - {"2006-01-02T15:04Z", "1136214240.000000000", false}, - {"2006-01-02T15:04+00:00", "1136214240.000000000", false}, - {"2006-01-02T15:04-00:00", "1136214240.000000000", false}, - {"2006-01-02T15:04", "1136214240.000000000", false}, - {"2006-01-02T15:0Z", "", true}, - {"2006-01-02T15:0", "", true}, - {"2006-01-02T15Z", "1136214000.000000000", false}, - {"2006-01-02T15+00:00", "1136214000.000000000", false}, - {"2006-01-02T15-00:00", "1136214000.000000000", false}, - {"2006-01-02T15", "1136214000.000000000", false}, - {"2006-01-02T1Z", "1136163600.000000000", false}, - {"2006-01-02T1", "1136163600.000000000", false}, - {"2006-01-02TZ", "", true}, - {"2006-01-02T", "", true}, - {"2006-01-02+00:00", "1136160000.000000000", false}, - {"2006-01-02-00:00", "1136160000.000000000", false}, - {"2006-01-02-00:01", "1136160060.000000000", false}, - {"2006-01-02Z", "1136160000.000000000", false}, - {"2006-01-02", "1136160000.000000000", false}, - {"2015-05-13T20:39:09Z", "1431549549.000000000", false}, - - // unix timestamps returned as is - {"1136073600", "1136073600", false}, - {"1136073600.000000001", "1136073600.000000001", false}, - // Durations - {"1m", fmt.Sprintf("%d", now.Add(-1*time.Minute).Unix()), false}, - {"1.5h", fmt.Sprintf("%d", now.Add(-90*time.Minute).Unix()), false}, - {"1h30m", fmt.Sprintf("%d", now.Add(-90*time.Minute).Unix()), false}, - - // String fallback - {"invalid", "invalid", false}, - } - - for _, c := range cases { - o, err := GetTimestamp(c.in, now) - if o != c.expected || - (err == nil && c.expectedErr) || - (err != nil && !c.expectedErr) { - t.Errorf("wrong value for '%s'. expected:'%s' got:'%s' with error: `%s`", c.in, c.expected, o, err) - t.Fail() - } - } -} - -func TestParseTimestamps(t *testing.T) { - cases := []struct { - in string - def, expectedS, expectedN int64 - expectedErr bool - }{ - // unix timestamps - {"1136073600", 0, 1136073600, 0, false}, - {"1136073600.000000001", 0, 1136073600, 1, false}, - {"1136073600.0000000010", 0, 1136073600, 1, false}, - {"1136073600.00000001", 0, 1136073600, 10, false}, - {"foo.bar", 0, 0, 0, true}, - {"1136073600.bar", 0, 1136073600, 0, true}, - {"", -1, -1, 0, false}, - } - - for _, c := range cases { - s, n, err := ParseTimestamps(c.in, c.def) - if s != c.expectedS || - n != c.expectedN || - (err == nil && c.expectedErr) || - (err != nil && !c.expectedErr) { - t.Errorf("wrong values for input `%s` with default `%d` expected:'%d'seconds and `%d`nanosecond got:'%d'seconds and `%d`nanoseconds with error: `%s`", c.in, c.def, c.expectedS, c.expectedN, s, n, err) - t.Fail() - } - } -} diff --git a/components/engine/api/types/types.go b/components/engine/api/types/types.go deleted file mode 100644 index 5f9e018998..0000000000 --- a/components/engine/api/types/types.go +++ /dev/null @@ -1,424 +0,0 @@ -package types - -import ( - "os" - "time" - - "github.com/docker/engine-api/types/container" - "github.com/docker/engine-api/types/network" - "github.com/docker/engine-api/types/registry" - "github.com/docker/go-connections/nat" -) - -// ContainerCreateResponse contains the information returned to a client on the -// creation of a new container. -type ContainerCreateResponse struct { - // ID is the ID of the created container. - ID string `json:"Id"` - - // Warnings are any warnings encountered during the creation of the container. - Warnings []string `json:"Warnings"` -} - -// ContainerExecCreateResponse contains response of Remote API: -// POST "/containers/{name:.*}/exec" -type ContainerExecCreateResponse struct { - // ID is the exec ID. - ID string `json:"Id"` -} - -// ContainerUpdateResponse contains response of Remote API: -// POST /containers/{name:.*}/update -type ContainerUpdateResponse struct { - // Warnings are any warnings encountered during the updating of the container. - Warnings []string `json:"Warnings"` -} - -// AuthResponse contains response of Remote API: -// POST "/auth" -type AuthResponse struct { - // Status is the authentication status - Status string `json:"Status"` -} - -// ContainerWaitResponse contains response of Remote API: -// POST "/containers/"+containerID+"/wait" -type ContainerWaitResponse struct { - // StatusCode is the status code of the wait job - StatusCode int `json:"StatusCode"` -} - -// ContainerCommitResponse contains response of Remote API: -// POST "/commit?container="+containerID -type ContainerCommitResponse struct { - ID string `json:"Id"` -} - -// ContainerChange contains response of Remote API: -// GET "/containers/{name:.*}/changes" -type ContainerChange struct { - Kind int - Path string -} - -// ImageHistory contains response of Remote API: -// GET "/images/{name:.*}/history" -type ImageHistory struct { - ID string `json:"Id"` - Created int64 - CreatedBy string - Tags []string - Size int64 - Comment string -} - -// ImageDelete contains response of Remote API: -// DELETE "/images/{name:.*}" -type ImageDelete struct { - Untagged string `json:",omitempty"` - Deleted string `json:",omitempty"` -} - -// Image contains response of Remote API: -// GET "/images/json" -type Image struct { - ID string `json:"Id"` - ParentID string `json:"ParentId"` - RepoTags []string - RepoDigests []string - Created int64 - Size int64 - VirtualSize int64 - Labels map[string]string -} - -// GraphDriverData returns Image's graph driver config info -// when calling inspect command -type GraphDriverData struct { - Name string - Data map[string]string -} - -// ImageInspect contains response of Remote API: -// GET "/images/{name:.*}/json" -type ImageInspect struct { - ID string `json:"Id"` - RepoTags []string - RepoDigests []string - Parent string - Comment string - Created string - Container string - ContainerConfig *container.Config - DockerVersion string - Author string - Config *container.Config - Architecture string - Os string - Size int64 - VirtualSize int64 - GraphDriver GraphDriverData -} - -// Port stores open ports info of container -// e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"} -type Port struct { - IP string `json:",omitempty"` - PrivatePort int - PublicPort int `json:",omitempty"` - Type string -} - -// Container contains response of Remote API: -// GET "/containers/json" -type Container struct { - ID string `json:"Id"` - Names []string - Image string - ImageID string - Command string - Created int64 - Ports []Port - SizeRw int64 `json:",omitempty"` - SizeRootFs int64 `json:",omitempty"` - Labels map[string]string - Status string - HostConfig struct { - NetworkMode string `json:",omitempty"` - } - NetworkSettings *SummaryNetworkSettings -} - -// CopyConfig contains request body of Remote API: -// POST "/containers/"+containerID+"/copy" -type CopyConfig struct { - Resource string -} - -// ContainerPathStat is used to encode the header from -// GET "/containers/{name:.*}/archive" -// "Name" is the file or directory name. -type ContainerPathStat struct { - Name string `json:"name"` - Size int64 `json:"size"` - Mode os.FileMode `json:"mode"` - Mtime time.Time `json:"mtime"` - LinkTarget string `json:"linkTarget"` -} - -// ContainerProcessList contains response of Remote API: -// GET "/containers/{name:.*}/top" -type ContainerProcessList struct { - Processes [][]string - Titles []string -} - -// Version contains response of Remote API: -// GET "/version" -type Version struct { - Version string - APIVersion string `json:"ApiVersion"` - GitCommit string - GoVersion string - Os string - Arch string - KernelVersion string `json:",omitempty"` - Experimental bool `json:",omitempty"` - BuildTime string `json:",omitempty"` -} - -// Info contains response of Remote API: -// GET "/info" -type Info struct { - ID string - Containers int - Images int - Driver string - DriverStatus [][2]string - Plugins PluginsInfo - MemoryLimit bool - SwapLimit bool - CPUCfsPeriod bool `json:"CpuCfsPeriod"` - CPUCfsQuota bool `json:"CpuCfsQuota"` - CPUShares bool - CPUSet bool - IPv4Forwarding bool - BridgeNfIptables bool - BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` - Debug bool - NFd int - OomKillDisable bool - NGoroutines int - SystemTime string - ExecutionDriver string - LoggingDriver string - NEventsListener int - KernelVersion string - OperatingSystem string - OSType string - Architecture string - IndexServerAddress string - RegistryConfig *registry.ServiceConfig - InitSha1 string - InitPath string - NCPU int - MemTotal int64 - DockerRootDir string - HTTPProxy string `json:"HttpProxy"` - HTTPSProxy string `json:"HttpsProxy"` - NoProxy string - Name string - Labels []string - ExperimentalBuild bool - ServerVersion string - ClusterStore string - ClusterAdvertise string -} - -// PluginsInfo is temp struct holds Plugins name -// registered with docker daemon. It used by Info struct -type PluginsInfo struct { - // List of Volume plugins registered - Volume []string - // List of Network plugins registered - Network []string - // List of Authorization plugins registered - Authorization []string -} - -// ExecStartCheck is a temp struct used by execStart -// Config fields is part of ExecConfig in runconfig package -type ExecStartCheck struct { - // ExecStart will first check if it's detached - Detach bool - // Check if there's a tty - Tty bool -} - -// ContainerState stores container's running state -// it's part of ContainerJSONBase and will return by "inspect" command -type ContainerState struct { - Status string - Running bool - Paused bool - Restarting bool - OOMKilled bool - Dead bool - Pid int - ExitCode int - Error string - StartedAt string - FinishedAt string -} - -// ContainerJSONBase contains response of Remote API: -// GET "/containers/{name:.*}/json" -type ContainerJSONBase struct { - ID string `json:"Id"` - Created string - Path string - Args []string - State *ContainerState - Image string - ResolvConfPath string - HostnamePath string - HostsPath string - LogPath string - Name string - RestartCount int - Driver string - MountLabel string - ProcessLabel string - AppArmorProfile string - ExecIDs []string - HostConfig *container.HostConfig - GraphDriver GraphDriverData - SizeRw *int64 `json:",omitempty"` - SizeRootFs *int64 `json:",omitempty"` -} - -// ContainerJSON is newly used struct along with MountPoint -type ContainerJSON struct { - *ContainerJSONBase - Mounts []MountPoint - Config *container.Config - NetworkSettings *NetworkSettings -} - -// NetworkSettings exposes the network settings in the api -type NetworkSettings struct { - NetworkSettingsBase - DefaultNetworkSettings - Networks map[string]*network.EndpointSettings -} - -// SummaryNetworkSettings provides a summary of container's networks -// in /containers/json -type SummaryNetworkSettings struct { - Networks map[string]*network.EndpointSettings -} - -// NetworkSettingsBase holds basic information about networks -type NetworkSettingsBase struct { - Bridge string - SandboxID string - HairpinMode bool - LinkLocalIPv6Address string - LinkLocalIPv6PrefixLen int - Ports nat.PortMap - SandboxKey string - SecondaryIPAddresses []network.Address - SecondaryIPv6Addresses []network.Address -} - -// DefaultNetworkSettings holds network information -// during the 2 release deprecation period. -// It will be removed in Docker 1.11. -type DefaultNetworkSettings struct { - EndpointID string - Gateway string - GlobalIPv6Address string - GlobalIPv6PrefixLen int - IPAddress string - IPPrefixLen int - IPv6Gateway string - MacAddress string -} - -// MountPoint represents a mount point configuration inside the container. -type MountPoint struct { - Name string `json:",omitempty"` - Source string - Destination string - Driver string `json:",omitempty"` - Mode string - RW bool - Propagation string -} - -// Volume represents the configuration of a volume for the remote API -type Volume struct { - Name string // Name is the name of the volume - Driver string // Driver is the Driver name used to create the volume - Mountpoint string // Mountpoint is the location on disk of the volume -} - -// VolumesListResponse contains the response for the remote API: -// GET "/volumes" -type VolumesListResponse struct { - Volumes []*Volume // Volumes is the list of volumes being returned - Warnings []string // Warnings is a list of warnings that occurred when getting the list from the volume drivers -} - -// VolumeCreateRequest contains the response for the remote API: -// POST "/volumes/create" -type VolumeCreateRequest struct { - Name string // Name is the requested name of the volume - Driver string // Driver is the name of the driver that should be used to create the volume - DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume. -} - -// NetworkResource is the body of the "get network" http response message -type NetworkResource struct { - Name string - ID string `json:"Id"` - Scope string - Driver string - IPAM network.IPAM - Containers map[string]EndpointResource - Options map[string]string -} - -// EndpointResource contains network resources allocated and used for a container in a network -type EndpointResource struct { - Name string - EndpointID string - MacAddress string - IPv4Address string - IPv6Address string -} - -// NetworkCreate is the expected body of the "create network" http request message -type NetworkCreate struct { - Name string - CheckDuplicate bool - Driver string - IPAM network.IPAM - Options map[string]string -} - -// NetworkCreateResponse is the response message sent by the server for network create call -type NetworkCreateResponse struct { - ID string `json:"Id"` - Warning string -} - -// NetworkConnect represents the data to be used to connect a container to the network -type NetworkConnect struct { - Container string -} - -// NetworkDisconnect represents the data to be used to disconnect a container from the network -type NetworkDisconnect struct { - Container string -} diff --git a/components/engine/api/types/versions/README.md b/components/engine/api/types/versions/README.md deleted file mode 100644 index 76c516e6a3..0000000000 --- a/components/engine/api/types/versions/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## Legacy API type versions - -This package includes types for legacy API versions. The stable version of the API types live in `api/types/*.go`. - -Consider moving a type here when you need to keep backwards compatibility in the API. This legacy types are organized by the latest API version they appear in. For instance, types in the `v1p19` package are valid for API versions below or equal `1.19`. Types in the `v1p20` package are valid for the API version `1.20`, since the versions below that will use the legacy types in `v1p19`. - -### Package name conventions - -The package name convention is to use `v` as a prefix for the version number and `p`(patch) as a separator. We use this nomenclature due to a few restrictions in the Go package name convention: - -1. We cannot use `.` because it's interpreted by the language, think of `v1.20.CallFunction`. -2. We cannot use `_` because golint complains abount it. The code is actually valid, but it looks probably more weird: `v1_20.CallFunction`. - -For instance, if you want to modify a type that was available in the version `1.21` of the API but it will have different fields in the version `1.22`, you want to create a new package under `api/types/versions/v1p21`. diff --git a/components/engine/api/types/versions/v1p19/types.go b/components/engine/api/types/versions/v1p19/types.go deleted file mode 100644 index 4ed4335881..0000000000 --- a/components/engine/api/types/versions/v1p19/types.go +++ /dev/null @@ -1,35 +0,0 @@ -// Package v1p19 provides specific API types for the API version 1, patch 19. -package v1p19 - -import ( - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" - "github.com/docker/engine-api/types/versions/v1p20" - "github.com/docker/go-connections/nat" -) - -// ContainerJSON is a backcompatibility struct for APIs prior to 1.20. -// Note this is not used by the Windows daemon. -type ContainerJSON struct { - *types.ContainerJSONBase - Volumes map[string]string - VolumesRW map[string]bool - Config *ContainerConfig - NetworkSettings *v1p20.NetworkSettings -} - -// ContainerConfig is a backcompatibility struct for APIs prior to 1.20. -type ContainerConfig struct { - *container.Config - - MacAddress string - NetworkDisabled bool - ExposedPorts map[nat.Port]struct{} - - // backward compatibility, they now live in HostConfig - VolumeDriver string - Memory int64 - MemorySwap int64 - CPUShares int64 `json:"CpuShares"` - CPUSet string `json:"Cpuset"` -} diff --git a/components/engine/api/types/versions/v1p20/types.go b/components/engine/api/types/versions/v1p20/types.go deleted file mode 100644 index ed800061fa..0000000000 --- a/components/engine/api/types/versions/v1p20/types.go +++ /dev/null @@ -1,40 +0,0 @@ -// Package v1p20 provides specific API types for the API version 1, patch 20. -package v1p20 - -import ( - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" - "github.com/docker/go-connections/nat" -) - -// ContainerJSON is a backcompatibility struct for the API 1.20 -type ContainerJSON struct { - *types.ContainerJSONBase - Mounts []types.MountPoint - Config *ContainerConfig - NetworkSettings *NetworkSettings -} - -// ContainerConfig is a backcompatibility struct used in ContainerJSON for the API 1.20 -type ContainerConfig struct { - *container.Config - - MacAddress string - NetworkDisabled bool - ExposedPorts map[nat.Port]struct{} - - // backward compatibility, they now live in HostConfig - VolumeDriver string -} - -// StatsJSON is a backcompatibility struct used in Stats for API prior to 1.21 -type StatsJSON struct { - types.Stats - Network types.NetworkStats `json:"network,omitempty"` -} - -// NetworkSettings is a backward compatible struct for APIs prior to 1.21 -type NetworkSettings struct { - types.NetworkSettingsBase - types.DefaultNetworkSettings -}